#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 EXIT_FAILURE;
int atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("switch 0|1|2|3|4\n");
    return EXIT_FAILURE;
  }
  int num = atoi(argv[1]);
  switch (num) {
  case 0:
  case 4:
  case 1:
    printf("Argument is zero, one or four\n");
    break;
  case 2:
    printf("Argument is 2\n");
  case 3:
    printf("Implicit fallthrough is fun!\n");
    break;
  default:
    printf("Argument is unknown: %d\n", num);
    break;
  };
  printf("To the end\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    115f <main+0x3f>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11e7 <main+0xc7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x4,%rax
ja     11c8 <main+0xa8>
mov    -0x20(%rbp),%rax
lea    0xe75(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <main+0xb9>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <main+0xb9>
mov    -0x14(%rbp),%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x1,%edi
jg     114d <main+0x1d>
lea    0xf44(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e97(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
cmp    $0x4,%eax
ja     1176 <main+0x46>
mov    %eax,%eax
lea    0xe9c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeef(%rip),%rdi
jmp    119b <main+0x6b>
lea    0xe97(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a0 <main+0x70>
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"switch 0|1|2|3|4\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [31 x i8] c"Argument is zero, one or four\0A\00"
@.str.2 = [15 x i8] c"Argument is 2\0A\00"
@.str.3 = [30 x i8] c"Implicit fallthrough is fun!\0A\00"
@.str.4 = [25 x i8] c"Argument is unknown: %d\0A\00"
@.str.5 = [12 x i8] c"To the end\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
store i32 %11, i32* %3
br label %29
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
switch i32 %17, label %24 [
i32 0, label %18
i32 4, label %18
i32 1, label %18
i32 2, label %20
i32 3, label %22
]
18: ; preds = %12, %12, %12
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %27
20: ; preds = %12
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %12, %20
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %27
24: ; preds = %12
%25 = load i32, i32* %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %22, %18
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %29
29: ; preds = %27, %9
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.4 = [25 x i8] c"Argument is unknown: %d\0A\00"
@str = [29 x i8] c"Implicit fallthrough is fun!\00"
@str.6 = [11 x i8] c"To the end\00"
@str.7 = [14 x i8] c"Argument is 2\00"
@str.8 = [30 x i8] c"Argument is zero, one or four\00"
@str.9 = [17 x i8] c"switch 0|1|2|3|4\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
br label %21
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
switch i32 %10, label %17 [
i32 0, label %11
i32 4, label %11
i32 1, label %11
i32 2, label %13
i32 3, label %15
]
11: ; preds = %7, %7, %7
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0))
br label %19
13: ; preds = %7
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
br label %15
15: ; preds = %7, %13
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %19
17: ; preds = %7
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %10)
br label %19
19: ; preds = %17, %15, %11
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0))
br label %21
21: ; preds = %19, %4
%22 = phi i32 [ %6, %4 ], [ 0, %19 ]
ret i32 %22
}