#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 */
unsigned short get_boot_drive();
int /*<<< orphan*/ puthex(unsigned short);
int /*<<< orphan*/ puts0(char *);
void print_boot(void) {
  unsigned short i;
  i = get_boot_drive();
  puts0("boot drive ");
  puthex(i);
  puts0(" ");
  if ((i) == 0xDDDD)
    puts0("Booted from HDD");
  else if ((i) == 0xAAAA)
    puts0("Booted from diskette");
  else {
    puts0("Booted from unknown device ");
    puthex(i);
  }
  puts0("\r\n");
}


x86 assembly (clang, -O0):
<print_boot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <get_boot_drive@plt>
mov    %ax,-0x2(%rbp)
lea    0xeb6(%rip),%rdi
call   1050 <puts0@plt>
movzwl -0x2(%rbp),%edi
call   1030 <puthex@plt>
lea    0xeec(%rip),%rdi
call   1050 <puts0@plt>
movzwl -0x2(%rbp),%eax
cmp    $0xdddd,%eax
jne    1184 <print_boot+0x54>
lea    0xe92(%rip),%rdi
call   1050 <puts0@plt>
jmp    11be <print_boot+0x8e>
movzwl -0x2(%rbp),%eax
cmp    $0xaaaa,%eax
jne    11a4 <print_boot+0x74>
lea    0xe82(%rip),%rdi
call   1050 <puts0@plt>
jmp    11b9 <print_boot+0x89>
lea    0xe86(%rip),%rdi
call   1050 <puts0@plt>
movzwl -0x2(%rbp),%edi
call   1030 <puthex@plt>
jmp    11be <print_boot+0x8e>
lea    0xe88(%rip),%rdi
call   1050 <puts0@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_boot>:
push   %rbx
xor    %eax,%eax
call   1040 <get_boot_drive@plt>
mov    %eax,%ebx
lea    0xebf(%rip),%rdi
call   1050 <puts0@plt>
movzwl %bx,%ebx
mov    %ebx,%edi
call   1030 <puthex@plt>
lea    0xef4(%rip),%rdi
call   1050 <puts0@plt>
cmp    $0xaaaa,%ebx
je     117a <print_boot+0x4a>
cmp    $0xdddd,%ebx
jne    1188 <print_boot+0x58>
lea    0xe99(%rip),%rdi
call   1050 <puts0@plt>
jmp    119b <print_boot+0x6b>
lea    0xe9b(%rip),%rdi
call   1050 <puts0@plt>
jmp    119b <print_boot+0x6b>
lea    0xea2(%rip),%rdi
call   1050 <puts0@plt>
mov    %ebx,%edi
call   1030 <puthex@plt>
lea    0xeab(%rip),%rdi
pop    %rbx
jmp    1050 <puts0@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"boot drive \00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [16 x i8] c"Booted from HDD\00"
@.str.3 = [21 x i8] c"Booted from diskette\00"
@.str.4 = [28 x i8] c"Booted from unknown device \00"
@.str.5 = [3 x i8] c"\0D\0A\00"
define void @print_boot() {
%1 = alloca i16
%2 = call zeroext i16 (...) @get_boot_drive()
store i16 %2, i16* %1
%3 = call i32 @puts0(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = load i16, i16* %1
%5 = call i32 @puthex(i16 zeroext %4)
%6 = call i32 @puts0(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = load i16, i16* %1
%8 = zext i16 %7 to i32
%9 = icmp eq i32 %8, 56797
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @puts0(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %23
12: ; preds = %0
%13 = load i16, i16* %1
%14 = zext i16 %13 to i32
%15 = icmp eq i32 %14, 43690
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @puts0(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %22
18: ; preds = %12
%19 = call i32 @puts0(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%20 = load i16, i16* %1
%21 = call i32 @puthex(i16 zeroext %20)
br label %22
22: ; preds = %18, %16
br label %23
23: ; preds = %22, %10
%24 = call i32 @puts0(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"boot drive \00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [16 x i8] c"Booted from HDD\00"
@.str.3 = [21 x i8] c"Booted from diskette\00"
@.str.4 = [28 x i8] c"Booted from unknown device \00"
@.str.5 = [3 x i8] c"\0D\0A\00"
define void @print_boot() {
%1 = tail call zeroext i16 (...) @get_boot_drive()
%2 = tail call i32 @puts0(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @puthex(i16 zeroext %1)
%4 = tail call i32 @puts0(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
switch i16 %1, label %9 [
i16 -8739, label %5
i16 -21846, label %7
]
5: ; preds = %0
%6 = tail call i32 @puts0(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %12
7: ; preds = %0
%8 = tail call i32 @puts0(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %12
9: ; preds = %0
%10 = tail call i32 @puts0(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%11 = tail call i32 @puthex(i16 zeroext %1)
br label %12
12: ; preds = %7, %9, %5
%13 = tail call i32 @puts0(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
ret void
}