#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*/ die(char *, int);
char *name(int stage) {
  switch (stage) {
  case 1:
    return "First boot sector";
  case 2:
    return "Second boot sector";
  case 0x10:
    return "Chain loader";
  default:
    die("Internal error: Unknown stage code %d", stage);
  }
  return NULL;
}


x86 assembly (clang, -O0):
<name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     1151 <name+0x41>
jmp    112f <name+0x1f>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     1161 <name+0x51>
jmp    1140 <name+0x30>
mov    -0x10(%rbp),%eax
sub    $0x10,%eax
je     1171 <name+0x61>
jmp    1181 <name+0x71>
lea    0xea8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1198 <name+0x88>
lea    0xeaa(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1198 <name+0x88>
lea    0xead(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1198 <name+0x88>
mov    -0xc(%rbp),%esi
lea    0xea7(%rip),%rdi
call   1030 <die@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<name>:
cmp    $0x1,%edi
je     1129 <name+0x19>
mov    %edi,%esi
cmp    $0x10,%edi
je     1131 <name+0x21>
cmp    $0x2,%esi
jne    1139 <name+0x29>
lea    0xeea(%rip),%rax
ret
lea    0xed0(%rip),%rax
ret
lea    0xeed(%rip),%rax
ret
push   %rax
lea    0xef1(%rip),%rdi
call   1030 <die@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"First boot sector\00"
@.str.1 = [19 x i8] c"Second boot sector\00"
@.str.2 = [13 x i8] c"Chain loader\00"
@.str.3 = [38 x i8] c"Internal error: Unknown stage code %d\00"
define i8* @name(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %8 [
i32 1, label %5
i32 2, label %6
i32 16, label %7
]
5: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8** %2
br label %12
6: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %12
7: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %12
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i32 @die(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %8
store i8* null, i8** %2
br label %12
12: ; preds = %11, %7, %6, %5
%13 = load i8*, i8** %2
ret i8* %13
}

LLVM IR (-O2):
@.str = [18 x i8] c"First boot sector\00"
@.str.1 = [19 x i8] c"Second boot sector\00"
@.str.2 = [13 x i8] c"Chain loader\00"
@.str.3 = [38 x i8] c"Internal error: Unknown stage code %d\00"
define i8* @name(i32 %0) {
switch i32 %0, label %4 [
i32 1, label %6
i32 2, label %2
i32 16, label %3
]
2: ; preds = %1
br label %6
3: ; preds = %1
br label %6
4: ; preds = %1
%5 = tail call i32 @die(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %0)
br label %6
6: ; preds = %1, %4, %3, %2
%7 = phi i8* [ null, %4 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %7
}