#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 f(int input) {
  int x = 0;
  while (x < 100) {
    switch (x) {
    case 0:
      x += input;
      break;
    case 1:
      x += 1;
      break;
    case 2:
      x += 6;
      break;
    case 3:
      x += 5;
      break;
    case 4:
      x += 4;
      break;
    case 5:
      x += 3;
      break;
    case 6:
      x += 2;
      break;
    }
  }
  printf("woo\n");
  return x;
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    11b3 <f+0xa3>
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x6,%rax
ja     11ae <f+0x9e>
mov    -0x10(%rbp),%rax
lea    0xeb8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11ae <f+0x9e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ae <f+0x9e>
mov    -0x8(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x8(%rbp)
jmp    11ae <f+0x9e>
mov    -0x8(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x8(%rbp)
jmp    11ae <f+0x9e>
mov    -0x8(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x8(%rbp)
jmp    11ae <f+0x9e>
mov    -0x8(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x8(%rbp)
jmp    11ae <f+0x9e>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <f+0x12>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rbx
xor    %ebx,%ebx
lea    0xee6(%rip),%rax
jmp    1135 <f+0x25>
mov    $0x2,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x64,%ebx
jge    1150 <f+0x40>
cmp    $0x6,%ebx
ja     1130 <f+0x20>
mov    %ebx,%ecx
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    $0x8,%ebx
jmp    1130 <f+0x20>
mov    %edi,%ebx
jmp    1130 <f+0x20>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"woo\0A\00"
define i32 @f(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %31, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 100
br i1 %6, label %7, label %32
7: ; preds = %4
%8 = load i32, i32* %3
switch i32 %8, label %31 [
i32 0, label %9
i32 1, label %13
i32 2, label %16
i32 3, label %19
i32 4, label %22
i32 5, label %25
i32 6, label %28
]
9: ; preds = %7
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = add nsw i32 %11, %10
store i32 %12, i32* %3
br label %31
13: ; preds = %7
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %31
16: ; preds = %7
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 6
store i32 %18, i32* %3
br label %31
19: ; preds = %7
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 5
store i32 %21, i32* %3
br label %31
22: ; preds = %7
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 4
store i32 %24, i32* %3
br label %31
25: ; preds = %7
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 3
store i32 %27, i32* %3
br label %31
28: ; preds = %7
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 2
store i32 %30, i32* %3
br label %31
31: ; preds = %7, %28, %25, %22, %19, %16, %13, %9
br label %4
32: ; preds = %4
%33 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@str = [4 x i8] c"woo\00"
define i32 @f(i32 %0) {
br label %2
2: ; preds = %1, %11
%3 = phi i32 [ 0, %1 ], [ %12, %11 ]
switch i32 %3, label %11 [
i32 0, label %4
i32 1, label %5
i32 2, label %6
i32 3, label %7
i32 4, label %8
i32 5, label %9
i32 6, label %10
]
4: ; preds = %2
br label %11
5: ; preds = %2
br label %11
6: ; preds = %2
br label %11
7: ; preds = %2
br label %11
8: ; preds = %2
br label %11
9: ; preds = %2
br label %11
10: ; preds = %2
br label %11
11: ; preds = %2, %10, %9, %8, %7, %6, %5, %4
%12 = phi i32 [ %3, %2 ], [ 8, %10 ], [ 8, %9 ], [ 8, %8 ], [ 8, %7 ], [ 8, %6 ], [ 2, %5 ], [ %0, %4 ]
%13 = icmp slt i32 %12, 100
br i1 %13, label %2, label %14
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
ret i32 %12
}