#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_error(int devid, int wr, uint32_t high, uint32_t low,
                 unsigned char err) {
  printf("ata%d %s %serror ", devid, wr ? "write" : "read",
         err & (1 << 6) ? "uncorrectable " : "");
  printf("at sector %x%x: ", high, low);
  if (err & (1 << 2))
    printf("abort ");
  if (err & (1 << 4))
    printf("invalid address ");
  if (err & (1 << 1))
    printf("no media ");
  printf("(%x)\n", (unsigned int)err);
}


x86 assembly (clang, -O0):
<print_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8b,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%ecx
lea    0xee1(%rip),%rdx
lea    0xed4(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
movzbl -0x11(%rbp),%edi
and    $0x40,%edi
lea    0xf11(%rip),%rcx
lea    0xec3(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%rcx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0x11(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11a1 <print_error+0x91>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0x11(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11bf <print_error+0xaf>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0x11(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11dd <print_error+0xcd>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0x11(%rbp),%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_error>:
push   %rbp
push   %r14
push   %rbx
mov    %r8d,%ebx
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %edi,%eax
test   %esi,%esi
lea    0xef1(%rip),%rcx
lea    0xee4(%rip),%rdx
cmove  %rcx,%rdx
test   $0x40,%bl
lea    0xf28(%rip),%rsi
lea    0xeda(%rip),%rcx
cmove  %rsi,%rcx
lea    0xeb2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
test   $0x4,%bl
jne    119b <print_error+0x8b>
test   $0x10,%bl
jne    11ae <print_error+0x9e>
test   $0x2,%bl
je     1187 <print_error+0x77>
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   $0x10,%bl
je     1174 <print_error+0x64>
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   $0x2,%bl
jne    1179 <print_error+0x69>
jmp    1187 <print_error+0x77>

LLVM IR (-O0):
@.str = [18 x i8] c"ata%d %s %serror \00"
@.str.1 = [6 x i8] c"write\00"
@.str.2 = [5 x i8] c"read\00"
@.str.3 = [15 x i8] c"uncorrectable \00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [17 x i8] c"at sector %x%x: \00"
@.str.6 = [7 x i8] c"abort \00"
@.str.7 = [17 x i8] c"invalid address \00"
@.str.8 = [10 x i8] c"no media \00"
@.str.9 = [6 x i8] c"(%x)\0A\00"
define void @print_error(i32 %0, i32 %1, i32 %2, i32 %3, i8 zeroext %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8 %4, i8* %10
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%16 = load i8, i8* %10
%17 = zext i8 %16 to i32
%18 = and i32 %17, 64
%19 = icmp ne i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %15, i8* %21)
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %23, i32 %24)
%26 = load i8, i8* %10
%27 = zext i8 %26 to i32
%28 = and i32 %27, 4
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %32
32: ; preds = %30, %5
%33 = load i8, i8* %10
%34 = zext i8 %33 to i32
%35 = and i32 %34, 16
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %39
39: ; preds = %37, %32
%40 = load i8, i8* %10
%41 = zext i8 %40 to i32
%42 = and i32 %41, 2
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %46
46: ; preds = %44, %39
%47 = load i8, i8* %10
%48 = zext i8 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %48)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"ata%d %s %serror \00"
@.str.1 = [6 x i8] c"write\00"
@.str.2 = [5 x i8] c"read\00"
@.str.3 = [15 x i8] c"uncorrectable \00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [17 x i8] c"at sector %x%x: \00"
@.str.6 = [7 x i8] c"abort \00"
@.str.7 = [17 x i8] c"invalid address \00"
@.str.8 = [10 x i8] c"no media \00"
@.str.9 = [6 x i8] c"(%x)\0A\00"
define void @print_error(i32 %0, i32 %1, i32 %2, i32 %3, i8 zeroext %4) {
%6 = icmp eq i32 %1, 0
%7 = select i1 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0)
%8 = zext i8 %4 to i32
%9 = and i32 %8, 64
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %7, i8* %11)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %2, i32 %3)
%14 = and i32 %8, 4
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %5
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %18
18: ; preds = %16, %5
%19 = and i32 %8, 16
%20 = icmp eq i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %23
23: ; preds = %21, %18
%24 = and i32 %8, 2
%25 = icmp eq i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %8)
ret void
}