#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  while (1) {
    printf("Type an integer: ");
    int selected;
    scanf("%d", &selected);
    switch (selected) {
    case 0: {
      printf("selected 0\n");
      break;
    }
    case 1: {
      printf("selected 1\n");
    }
    case 2: {
      printf("selected 2\n");
      continue;
    }
    case 3: {
      printf("selected 3\n");
      continue;
    }
    default: {
      printf("selected %d\n", selected);
    }
    }
    printf("Breaking out of loop!\n");
    break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x3,%rax
ja     11b9 <main+0x99>
mov    -0x10(%rbp),%rax
lea    0xe97(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ca <main+0xaa>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
mov    -0x8(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%r14
lea    0xed9(%rip),%r15
lea    0x4(%rsp),%r13
lea    0xee8(%rip),%rbx
lea    0xea4(%rip),%rbp
lea    0xecf(%rip),%r12
jmp    1184 <main+0x54>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0x3,%rsi
ja     11ba <main+0x8a>
movslq 0x0(%rbp,%rsi,4),%rax
add    %rbp,%rax
mov    %rbx,%rdi
jmp    *%rax
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    1184 <main+0x54>
lea    0xe64(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d6 <main+0xa6>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Type an integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"selected 0\0A\00"
@.str.3 = [12 x i8] c"selected 1\0A\00"
@.str.4 = [12 x i8] c"selected 2\0A\00"
@.str.5 = [12 x i8] c"selected 3\0A\00"
@.str.6 = [13 x i8] c"selected %d\0A\00"
@.str.7 = [23 x i8] c"Breaking out of loop!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %0, %11, %13
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
switch i32 %6, label %15 [
i32 0, label %7
i32 1, label %9
i32 2, label %11
i32 3, label %13
]
7: ; preds = %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %18
9: ; preds = %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %11
11: ; preds = %3, %9
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %3
13: ; preds = %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %3
15: ; preds = %3
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %15, %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %20
20: ; preds = %18
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [18 x i8] c"Type an integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.6 = [13 x i8] c"selected %d\0A\00"
@str = [11 x i8] c"selected 3\00"
@str.8 = [11 x i8] c"selected 2\00"
@str.9 = [11 x i8] c"selected 1\00"
@str.10 = [11 x i8] c"selected 0\00"
@str.11 = [22 x i8] c"Breaking out of loop!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %14, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
switch i32 %6, label %12 [
i32 0, label %7
i32 1, label %9
i32 2, label %14
i32 3, label %11
]
7: ; preds = %3
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.10, i64 0, i64 0))
br label %17
9: ; preds = %3
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0))
br label %14
11: ; preds = %3
br label %14
12: ; preds = %3
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %6)
br label %17
14: ; preds = %9, %3, %11
%15 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0), %11 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0), %3 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0), %9 ]
%16 = call i32 @puts(i8* dereferenceable(1) %15)
br label %3
17: ; preds = %7, %12
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.11, i64 0, i64 0))
ret i32 0
}