// language: metal1.0
#include <metal_stdlib>
#include <simd/simd.h>

using metal::uint;


void switch_default_break(
    int i
) {
    switch(i) {
        default: {
            break;
        }
    }
}

void switch_case_break(
) {
    switch(0) {
        case 0: {
            break;
        }
        default: {
            break;
        }
    }
    return;
}

void loop_switch_continue(
    int x
) {
    while(true) {
        switch(x) {
            case 1: {
                continue;
            }
            default: {
                break;
            }
        }
#define LOOP_IS_BOUNDED { volatile bool unpredictable_break_from_loop = false; if (unpredictable_break_from_loop) break; }
        LOOP_IS_BOUNDED
    }
    return;
}

void loop_switch_continue_nesting(
    int x_1,
    int y,
    int z
) {
    while(true) {
        switch(x_1) {
            case 1: {
                continue;
            }
            case 2: {
                switch(y) {
                    case 1: {
                        continue;
                    }
                    default: {
                        while(true) {
                            switch(z) {
                                case 1: {
                                    continue;
                                }
                                default: {
                                    break;
                                }
                            }
                            LOOP_IS_BOUNDED
                        }
                        break;
                    }
                }
                break;
            }
            default: {
                break;
            }
        }
        switch(y) {
            default: {
                continue;
            }
        }
        LOOP_IS_BOUNDED
    }
    while(true) {
        switch(y) {
            case 1:
            default: {
                switch(z) {
                    default: {
                        continue;
                    }
                }
                break;
            }
        }
        LOOP_IS_BOUNDED
    }
    return;
}

void loop_switch_omit_continue_variable_checks(
    int x_2,
    int y_1,
    int z_1,
    int w
) {
    int pos_1 = 0;
    while(true) {
        switch(x_2) {
            case 1: {
                pos_1 = 1;
                break;
            }
            default: {
                break;
            }
        }
        LOOP_IS_BOUNDED
    }
    while(true) {
        switch(x_2) {
            case 1: {
                break;
            }
            case 2: {
                switch(y_1) {
                    case 1: {
                        continue;
                    }
                    default: {
                        switch(z_1) {
                            case 1: {
                                pos_1 = 2;
                                break;
                            }
                            default: {
                                break;
                            }
                        }
                        break;
                    }
                }
                break;
            }
            default: {
                break;
            }
        }
        LOOP_IS_BOUNDED
    }
    return;
}

struct main_Input {
};
kernel void main_(
  metal::uint3 global_id [[thread_position_in_grid]]
) {
    int pos = {};
    metal::threadgroup_barrier(metal::mem_flags::mem_device);
    metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup);
    switch(1) {
        default: {
            pos = 1;
            break;
        }
    }
    int _e4 = pos;
    switch(_e4) {
        case 1: {
            pos = 0;
            break;
        }
        case 2: {
            pos = 1;
            break;
        }
        case 3:
        case 4: {
            pos = 2;
            break;
        }
        case 5: {
            pos = 3;
            break;
        }
        default:
        case 6: {
            pos = 4;
            break;
        }
    }
    switch(0u) {
        case 0u: {
            break;
        }
        default: {
            break;
        }
    }
    int _e11 = pos;
    switch(_e11) {
        case 1: {
            pos = 0;
            break;
        }
        case 2: {
            pos = 1;
            return;
        }
        case 3: {
            pos = 2;
            return;
        }
        case 4: {
            return;
        }
        default: {
            pos = 3;
            return;
        }
    }
}
