#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*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *status2txt(unsigned char status, char *buf) {
  strcpy(buf, "[ ");
  if (status & 0x80)
    strcat(buf, "B_BUSY ");
  if (status & 0x40)
    strcat(buf, "H_BUSY ");
  if (status & 0x20)
    strcat(buf, "OEM0 ");
  if (status & 0x10)
    strcat(buf, "SMS ");
  if (status & 0x08)
    strcat(buf, "B2H ");
  if (status & 0x04)
    strcat(buf, "H2B ");
  strcat(buf, "]");
  return buf;
}


x86 assembly (clang, -O0):
<status2txt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec3(%rip),%rsi
call   1030 <strcpy@plt>
movzbl -0x1(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1164 <status2txt+0x44>
mov    -0x10(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1040 <strcat@plt>
movzbl -0x1(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     1184 <status2txt+0x64>
mov    -0x10(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1040 <strcat@plt>
movzbl -0x1(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     11a4 <status2txt+0x84>
mov    -0x10(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1040 <strcat@plt>
movzbl -0x1(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11c4 <status2txt+0xa4>
mov    -0x10(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1040 <strcat@plt>
movzbl -0x1(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11e4 <status2txt+0xc4>
mov    -0x10(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1040 <strcat@plt>
movzbl -0x1(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1204 <status2txt+0xe4>
mov    -0x10(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<status2txt>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xed1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
test   $0x80,%bpl
jne    1187 <status2txt+0x67>
test   $0x40,%bpl
jne    119c <status2txt+0x7c>
test   $0x20,%bpl
jne    11b1 <status2txt+0x91>
test   $0x10,%bpl
jne    11c6 <status2txt+0xa6>
test   $0x8,%bpl
jne    11df <status2txt+0xbf>
test   $0x4,%bpl
je     116e <status2txt+0x4e>
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
lea    0xeb3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe75(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
test   $0x40,%bpl
je     1143 <status2txt+0x23>
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
test   $0x20,%bpl
je     1149 <status2txt+0x29>
lea    0xe5b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
test   $0x10,%bpl
je     114f <status2txt+0x2f>
lea    0xe4c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
test   $0x8,%bpl
je     1159 <status2txt+0x39>
lea    0xe38(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
test   $0x4,%bpl
jne    115f <status2txt+0x3f>
jmp    116e <status2txt+0x4e>

LLVM IR (-O0):
@.str = [3 x i8] c"[ \00"
@.str.1 = [8 x i8] c"B_BUSY \00"
@.str.2 = [8 x i8] c"H_BUSY \00"
@.str.3 = [6 x i8] c"OEM0 \00"
@.str.4 = [5 x i8] c"SMS \00"
@.str.5 = [5 x i8] c"B2H \00"
@.str.6 = [5 x i8] c"H2B \00"
@.str.7 = [2 x i8] c"]\00"
define i8* @status2txt(i8 zeroext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
store i8 %0, i8* %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = load i8, i8* %3
%8 = zext i8 %7 to i32
%9 = and i32 %8, 128
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %11, %2
%15 = load i8, i8* %3
%16 = zext i8 %15 to i32
%17 = and i32 %16, 64
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %19, %14
%23 = load i8, i8* %3
%24 = zext i8 %23 to i32
%25 = and i32 %24, 32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i8*, i8** %4
%29 = call i32 @strcat(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %27, %22
%31 = load i8, i8* %3
%32 = zext i8 %31 to i32
%33 = and i32 %32, 16
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %38
38: ; preds = %35, %30
%39 = load i8, i8* %3
%40 = zext i8 %39 to i32
%41 = and i32 %40, 8
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %38
%44 = load i8*, i8** %4
%45 = call i32 @strcat(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %43, %38
%47 = load i8, i8* %3
%48 = zext i8 %47 to i32
%49 = and i32 %48, 4
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = load i8*, i8** %4
%53 = call i32 @strcat(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %54
54: ; preds = %51, %46
%55 = load i8*, i8** %4
%56 = call i32 @strcat(i8* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%57 = load i8*, i8** %4
ret i8* %57
}

LLVM IR (-O2):
@.str = [3 x i8] c"[ \00"
@.str.1 = [8 x i8] c"B_BUSY \00"
@.str.2 = [8 x i8] c"H_BUSY \00"
@.str.3 = [6 x i8] c"OEM0 \00"
@.str.4 = [5 x i8] c"SMS \00"
@.str.5 = [5 x i8] c"B2H \00"
@.str.6 = [5 x i8] c"H2B \00"
@.str.7 = [2 x i8] c"]\00"
define i8* @status2txt(i8 zeroext %0, i8* returned %1) {
%3 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = zext i8 %0 to i32
%5 = and i32 %4, 128
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %2
%10 = and i32 %4, 64
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = and i32 %4, 32
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
%20 = and i32 %4, 16
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
%25 = and i32 %4, 8
%26 = icmp eq i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
%30 = and i32 %4, 4
%31 = icmp eq i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
%35 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
ret i8* %1
}