#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 status_check(int operation, unsigned char error_reg,
                 unsigned char status_reg) {
  int rtvl = 0;
  if ((status_reg & 0x1) && !(status_reg & 0x80)) {
    if (operation == 0) {
      printf("error reading drive\n");
    } else if (operation == 1) {
      printf("error writing drive\n");
    }
    rtvl = 1;
    if (error_reg & 128) {
      printf("BBK(bit 7) sector marked as bad by host\n");
    }
    if (error_reg & 64) {
      printf("UNC(bit 6) uncorrectable data error\n");
    }
    if (error_reg & 16) {
      printf("NID(bit 4) ID mark not found\n");
    }
    if (error_reg & 4) {
      printf("ABT(bit 2) command abort\n");
    }
    if (error_reg & 2) {
      printf("NTO(bit 1) track 0 not found\n");
    }
    if (error_reg & 1) {
      printf("NDM(bit 0) data address mark not found\n");
    }
  }
  return rtvl;
}


x86 assembly (clang, -O0):
<status_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %edi,-0x4(%rbp)
mov    %cl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
movl   $0x0,-0xc(%rbp)
movzbl -0x6(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     123b <status_check+0x12b>
movzbl -0x6(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    123b <status_check+0x12b>
cmpl   $0x0,-0x4(%rbp)
jne    116a <status_check+0x5a>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
jmp    1185 <status_check+0x75>
cmpl   $0x1,-0x4(%rbp)
jne    1180 <status_check+0x70>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
jmp    1185 <status_check+0x75>
movl   $0x1,-0xc(%rbp)
movzbl -0x5(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     11aa <status_check+0x9a>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
movzbl -0x5(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     11c6 <status_check+0xb6>
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
movzbl -0x5(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11e2 <status_check+0xd2>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
movzbl -0x5(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11fe <status_check+0xee>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
movzbl -0x5(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     121a <status_check+0x10a>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
movzbl -0x5(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1236 <status_check+0x126>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
jmp    123b <status_check+0x12b>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<status_check>:
push   %rbp
push   %rbx
push   %rax
and    $0x81,%dl
xor    %ebp,%ebp
cmp    $0x1,%dl
jne    1178 <status_check+0x68>
mov    %esi,%ebx
test   %edi,%edi
je     1131 <status_check+0x21>
cmp    $0x1,%edi
jne    113d <status_check+0x2d>
lea    0xf97(%rip),%rdi
jmp    1138 <status_check+0x28>
lea    0xfa2(%rip),%rdi
call   1030 <puts@plt>
test   $0x80,%bl
jne    1181 <status_check+0x71>
test   $0x40,%bl
jne    1192 <status_check+0x82>
test   $0x10,%bl
jne    11a3 <status_check+0x93>
test   $0x4,%bl
jne    11b4 <status_check+0xa4>
test   $0x2,%bl
je     1162 <status_check+0x52>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
test   $0x1,%bl
je     1178 <status_check+0x68>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xf16(%rip),%rdi
call   1030 <puts@plt>
test   $0x40,%bl
je     1147 <status_check+0x37>
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
test   $0x10,%bl
je     114c <status_check+0x3c>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
test   $0x4,%bl
je     1151 <status_check+0x41>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
test   $0x2,%bl
jne    1156 <status_check+0x46>
jmp    1162 <status_check+0x52>

LLVM IR (-O0):
@.str = [21 x i8] c"error reading drive\0A\00"
@.str.1 = [21 x i8] c"error writing drive\0A\00"
@.str.2 = [41 x i8] c"BBK(bit 7) sector marked as bad by host\0A\00"
@.str.3 = [37 x i8] c"UNC(bit 6) uncorrectable data error\0A\00"
@.str.4 = [30 x i8] c"NID(bit 4) ID mark not found\0A\00"
@.str.5 = [26 x i8] c"ABT(bit 2) command abort\0A\00"
@.str.6 = [30 x i8] c"NTO(bit 1) track 0 not found\0A\00"
@.str.7 = [40 x i8] c"NDM(bit 0) data address mark not found\0A\00"
define i32 @status_check(i32 %0, i8 zeroext %1, i8 zeroext %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = alloca i32
store i32 %0, i32* %4
store i8 %1, i8* %5
store i8 %2, i8* %6
store i32 0, i32* %7
%8 = load i8, i8* %6
%9 = zext i8 %8 to i32
%10 = and i32 %9, 1
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %71
12: ; preds = %3
%13 = load i8, i8* %6
%14 = zext i8 %13 to i32
%15 = and i32 %14, 128
%16 = icmp ne i32 %15, 0
br i1 %16, label %71, label %17
17: ; preds = %12
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %28
22: ; preds = %17
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
br label %28
28: ; preds = %27, %20
store i32 1, i32* %7
%29 = load i8, i8* %5
%30 = zext i8 %29 to i32
%31 = and i32 %30, 128
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33, %28
%36 = load i8, i8* %5
%37 = zext i8 %36 to i32
%38 = and i32 %37, 64
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %35
%43 = load i8, i8* %5
%44 = zext i8 %43 to i32
%45 = and i32 %44, 16
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %42
%48 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %47, %42
%50 = load i8, i8* %5
%51 = zext i8 %50 to i32
%52 = and i32 %51, 4
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %49
%55 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %56
56: ; preds = %54, %49
%57 = load i8, i8* %5
%58 = zext i8 %57 to i32
%59 = and i32 %58, 2
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %56
%62 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
br label %63
63: ; preds = %61, %56
%64 = load i8, i8* %5
%65 = zext i8 %64 to i32
%66 = and i32 %65, 1
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %63
%69 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
br label %70
70: ; preds = %68, %63
br label %71
71: ; preds = %70, %12, %3
%72 = load i32, i32* %7
ret i32 %72
}

LLVM IR (-O2):
@str = [39 x i8] c"NDM(bit 0) data address mark not found\00"
@str.8 = [29 x i8] c"NTO(bit 1) track 0 not found\00"
@str.9 = [25 x i8] c"ABT(bit 2) command abort\00"
@str.10 = [29 x i8] c"NID(bit 4) ID mark not found\00"
@str.11 = [36 x i8] c"UNC(bit 6) uncorrectable data error\00"
@str.12 = [40 x i8] c"BBK(bit 7) sector marked as bad by host\00"
@str.13 = [20 x i8] c"error writing drive\00"
@str.14 = [20 x i8] c"error reading drive\00"
define i32 @status_check(i32 %0, i8 zeroext %1, i8 zeroext %2) {
%4 = and i8 %2, -127
%5 = icmp eq i8 %4, 1
br i1 %5, label %6, label %42
6: ; preds = %3
switch i32 %0, label %11 [
i32 0, label %8
i32 1, label %7
]
7: ; preds = %6
br label %8
8: ; preds = %6, %7
%9 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.13, i64 0, i64 0), %7 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.14, i64 0, i64 0), %6 ]
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
br label %11
11: ; preds = %8, %6
%12 = zext i8 %1 to i32
%13 = and i32 %12, 128
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.12, i64 0, i64 0))
br label %17
17: ; preds = %15, %11
%18 = and i32 %12, 64
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.11, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = and i32 %12, 16
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.10, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = and i32 %12, 4
%29 = icmp eq i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = and i32 %12, 2
%34 = icmp eq i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.8, i64 0, i64 0))
br label %37
37: ; preds = %35, %32
%38 = and i32 %12, 1
%39 = icmp eq i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
br label %42
42: ; preds = %37, %40, %3
%43 = phi i32 [ 1, %40 ], [ 1, %37 ], [ 0, %3 ]
ret i32 %43
}