#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 fail(char *, int);
int getreg(int);
int /*<<< orphan*/ printf(char *, unsigned int, int);
int /*<<< orphan*/ report(int);
int /*<<< orphan*/ setreg(scalar_t__, int);
void send_char(int ch) {
  report(ch);
  while (!(getreg(((0x9c000000) + 5)) & (0x20)))
    ;
  {
    unsigned x = getreg(((0x9c000000) + 5));
    if ((x & ((0x10) | (0x08) | (0x04) | (0x02))) && !(x & (0x80)))
      printf("LSR7 (0x%02x) ERR @ %i\n", x, 144);
    ((!(x & (0x80)) && ((x & 0x60) != 0x40)) ? 1 : fail("?", 144));
  };
  setreg(((0x9c000000) + 0), ch);
  {
    unsigned x = getreg(((0x9c000000) + 5));
    if ((x & ((0x10) | (0x08) | (0x04) | (0x02))) && !(x & (0x80)))
      printf("LSR7 (0x%02x) ERR @ %i\n", x, 146);
    ((!(x & (0x80)) && ((x & 0x60) != 0x40)) ? 1 : fail("?", 146));
  };
}


x86 assembly (clang, -O0):
<send_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <report@plt>
mov    $0x9c000005,%edi
call   1060 <getreg@plt>
and    $0x20,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1185 <send_char+0x35>
jmp    118a <send_char+0x3a>
jmp    1163 <send_char+0x13>
mov    $0x9c000005,%edi
call   1060 <getreg@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1e,%eax
cmp    $0x0,%eax
je     11cb <send_char+0x7b>
mov    -0x8(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    11cb <send_char+0x7b>
mov    -0x8(%rbp),%esi
lea    0xe3f(%rip),%rdi
mov    $0x90,%edx
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    11f0 <send_char+0xa0>
mov    -0x8(%rbp),%eax
and    $0x60,%eax
cmp    $0x40,%eax
je     11f0 <send_char+0xa0>
jmp    1201 <send_char+0xb1>
lea    0xe21(%rip),%rdi
mov    $0x90,%esi
call   1030 <fail@plt>
mov    -0x4(%rbp),%esi
mov    $0x9c000000,%edi
call   1040 <setreg@plt>
mov    $0x9c000005,%edi
call   1060 <getreg@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1e,%eax
cmp    $0x0,%eax
je     124f <send_char+0xff>
mov    -0xc(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    124f <send_char+0xff>
mov    -0xc(%rbp),%esi
lea    0xdbb(%rip),%rdi
mov    $0x92,%edx
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    1274 <send_char+0x124>
mov    -0xc(%rbp),%eax
and    $0x60,%eax
cmp    $0x40,%eax
je     1274 <send_char+0x124>
jmp    1285 <send_char+0x135>
lea    0xd9d(%rip),%rdi
mov    $0x92,%esi
call   1030 <fail@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_char>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
call   1070 <report@plt>
nopw   0x0(%rax,%rax,1)
mov    $0x9c000005,%edi
call   1060 <getreg@plt>
test   $0x20,%al
je     1160 <send_char+0x10>
mov    $0x9c000005,%edi
call   1060 <getreg@plt>
mov    %eax,%ebp
test   $0x1e,%bpl
je     119c <send_char+0x4c>
mov    %ebp,%eax
and    $0x80,%eax
jne    119c <send_char+0x4c>
lea    0xe70(%rip),%rdi
mov    %ebp,%esi
mov    $0x90,%edx
call   1050 <printf@plt>
test   $0x80,%bpl
jne    11aa <send_char+0x5a>
and    $0x60,%ebp
cmp    $0x40,%ebp
jne    11bb <send_char+0x6b>
lea    0xe67(%rip),%rdi
mov    $0x90,%esi
call   1030 <fail@plt>
mov    $0x9c000000,%edi
mov    %ebx,%esi
call   1040 <setreg@plt>
mov    $0x9c000005,%edi
call   1060 <getreg@plt>
mov    %eax,%ebx
test   $0x1e,%bl
je     11f4 <send_char+0xa4>
mov    %ebx,%eax
and    $0x80,%eax
jne    11f4 <send_char+0xa4>
lea    0xe18(%rip),%rdi
mov    %ebx,%esi
mov    $0x92,%edx
call   1050 <printf@plt>
test   $0x80,%bl
jne    1208 <send_char+0xb8>
and    $0x60,%ebx
cmp    $0x40,%ebx
je     1208 <send_char+0xb8>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe09(%rip),%rdi
mov    $0x92,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fail@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"LSR7 (0x%02x) ERR @ %i\0A\00"
@.str.1 = [2 x i8] c"?\00"
define void @send_char(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @report(i32 %5)
br label %7
7: ; preds = %12, %1
%8 = call i32 @getreg(i32 -1677721595)
%9 = and i32 %8, 32
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
br i1 %11, label %12, label %13
12: ; preds = %7
br label %7
13: ; preds = %7
%14 = call i32 @getreg(i32 -1677721595)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = and i32 %15, 30
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %13
%19 = load i32, i32* %3
%20 = and i32 %19, 128
%21 = icmp ne i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = load i32, i32* %3
%24 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %23, i32 144)
br label %25
25: ; preds = %22, %18, %13
%26 = load i32, i32* %3
%27 = and i32 %26, 128
%28 = icmp ne i32 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %25
%30 = load i32, i32* %3
%31 = and i32 %30, 96
%32 = icmp ne i32 %31, 64
br i1 %32, label %33, label %34
33: ; preds = %29
br label %36
34: ; preds = %29, %25
%35 = call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 144)
br label %36
36: ; preds = %34, %33
%37 = phi i32 [ 1, %33 ], [ %35, %34 ]
%38 = load i32, i32* %2
%39 = call i32 @setreg(i64 2617245696, i32 %38)
%40 = call i32 @getreg(i32 -1677721595)
store i32 %40, i32* %4
%41 = load i32, i32* %4
%42 = and i32 %41, 30
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %51
44: ; preds = %36
%45 = load i32, i32* %4
%46 = and i32 %45, 128
%47 = icmp ne i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %44
%49 = load i32, i32* %4
%50 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %49, i32 146)
br label %51
51: ; preds = %48, %44, %36
%52 = load i32, i32* %4
%53 = and i32 %52, 128
%54 = icmp ne i32 %53, 0
br i1 %54, label %60, label %55
55: ; preds = %51
%56 = load i32, i32* %4
%57 = and i32 %56, 96
%58 = icmp ne i32 %57, 64
br i1 %58, label %59, label %60
59: ; preds = %55
br label %62
60: ; preds = %55, %51
%61 = call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 146)
br label %62
62: ; preds = %60, %59
%63 = phi i32 [ 1, %59 ], [ %61, %60 ]
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"LSR7 (0x%02x) ERR @ %i\0A\00"
@.str.1 = [2 x i8] c"?\00"
define void @send_char(i32 %0) {
%2 = tail call i32 @report(i32 %0)
br label %3
3: ; preds = %3, %1
%4 = tail call i32 @getreg(i32 -1677721595)
%5 = and i32 %4, 32
%6 = icmp eq i32 %5, 0
br i1 %6, label %3, label %7
7: ; preds = %3
%8 = tail call i32 @getreg(i32 -1677721595)
%9 = and i32 %8, 30
%10 = icmp ne i32 %9, 0
%11 = and i32 %8, 128
%12 = icmp eq i32 %11, 0
%13 = and i1 %10, %12
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %8, i32 144)
br label %16
16: ; preds = %14, %7
%17 = icmp ne i32 %11, 0
%18 = and i32 %8, 96
%19 = icmp eq i32 %18, 64
%20 = or i1 %17, %19
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = tail call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 144)
br label %23
23: ; preds = %16, %21
%24 = tail call i32 @setreg(i64 2617245696, i32 %0)
%25 = tail call i32 @getreg(i32 -1677721595)
%26 = and i32 %25, 30
%27 = icmp ne i32 %26, 0
%28 = and i32 %25, 128
%29 = icmp eq i32 %28, 0
%30 = and i1 %27, %29
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %25, i32 146)
br label %33
33: ; preds = %31, %23
%34 = icmp ne i32 %28, 0
%35 = and i32 %25, 96
%36 = icmp eq i32 %35, 64
%37 = or i1 %34, %36
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = tail call i32 @fail(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 146)
br label %40
40: ; preds = %33, %38
ret void
}