#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*/ BRANCHTO(int);
unsigned int GET32(int);
int /*<<< orphan*/ PUT32(int, int);
int /*<<< orphan*/ hexstring(unsigned int);
int /*<<< orphan*/ timer_init();
unsigned int timer_tick();
scalar_t__ uart_check();
unsigned int uart_getc();
int /*<<< orphan*/ uart_init();
int /*<<< orphan*/ uart_putc(int);
int /*<<< orphan*/ uart_writeline(char *);
void bootloader() {
  unsigned int pin16_funcbits = GET32(((0x20000000 + 0x200000) + 4));
  pin16_funcbits &= ~(7 << 18);
  pin16_funcbits |= 1 << 18;
  PUT32(((0x20000000 + 0x200000) + 4), pin16_funcbits);
  PUT32(((0x20000000 + 0x200000) + 0x28), 1 << 16);
  uart_init();
  timer_init();
  uart_writeline("Trollboot - Ready for your program!");
  while (1) {
    unsigned int start = timer_tick();
    unsigned int state = 192;
    unsigned int checksum = 0;
    unsigned int block = 1;
    unsigned int bytesRecieved = 0;
    unsigned char *xstring = (unsigned char *)0x8000;
    uart_putc(0x15);
    while (1) {
      unsigned int current = timer_tick();
      if ((current - start) >= 4000000) {
        uart_putc(0x15);
        start = current;
      }
      if (uart_check()) {
        break;
      }
    }
    while (state != 255) {
      unsigned int data = uart_getc();
      switch (state) {
      case 192: {
        switch (data) {
        case 0x01: {
          checksum = data;
          state++;
          break;
        }
        case 0x04: {
          uart_putc(0x06);
          start = timer_tick();
          while (1) {
            unsigned int current = timer_tick();
            if ((current - start) >= 2000000) {
              break;
            }
          }
          uart_writeline("Bytes recieved:");
          hexstring(bytesRecieved);
          uart_writeline("xstring:");
          hexstring((unsigned int)xstring);
          uart_writeline("Ready to run. Press g/G to run.\0");
          while (1) {
            data = uart_getc();
            if ((data == 'g') || (data == 'G')) {
              uart_writeline("Branching to program. Good bye!\0");
              BRANCHTO(0x8000);
            }
          }
          break;
        }
        default: {
          state = 255;
          break;
        }
        }
        break;
      }
      case 193: {
        if (data == block) {
          checksum += data;
          state++;
        } else {
          state = 255;
        }
        break;
      }
      case 194: {
        if (data == (0xFF - block)) {
          checksum += data;
          state = 0;
        } else {
          state = 255;
        }
        break;
      }
      case 128: {
        checksum &= 0xFF;
        if (data == checksum) {
          uart_putc(0x06);
          block = (block + 1) & 0xFF;
          xstring += 128;
          state = 192;
        } else {
          state = 255;
        }
        break;
      }
      default: {
        checksum += data;
        xstring[state] = data & 0xFF;
        state++;
        bytesRecieved++;
        break;
      }
      }
    }
  }
}


x86 assembly (clang, -O0):
<bootloader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x20200004,%edi
call   10d0 <GET32@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffe3ffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
or     $0x40000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x20200004,%edi
call   1070 <PUT32@plt>
mov    $0x20200028,%edi
mov    $0x10000,%esi
call   1070 <PUT32@plt>
mov    $0x0,%al
call   1040 <uart_init@plt>
mov    $0x0,%al
call   1080 <timer_init@plt>
lea    0xdf4(%rip),%rdi
call   1090 <uart_writeline@plt>
mov    $0x0,%al
call   10c0 <timer_tick@plt>
mov    %eax,-0x8(%rbp)
movl   $0xc0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x8000,%eax
mov    %rax,-0x20(%rbp)
mov    $0x15,%edi
call   1030 <uart_putc@plt>
mov    $0x0,%al
call   10c0 <timer_tick@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
sub    -0x8(%rbp),%eax
cmp    $0x3d0900,%eax
jb     1275 <bootloader+0xc5>
mov    $0x15,%edi
call   1030 <uart_putc@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <uart_check@plt>
cmp    $0x0,%rax
je     128b <bootloader+0xdb>
jmp    1290 <bootloader+0xe0>
jmp    124a <bootloader+0x9a>
jmp    1295 <bootloader+0xe5>
cmpl   $0xff,-0xc(%rbp)
je     14d5 <bootloader+0x325>
xor    %eax,%eax
call   10b0 <uart_getc@plt>
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x80,%eax
je     144c <bootloader+0x29c>
jmp    12c2 <bootloader+0x112>
mov    -0x30(%rbp),%eax
sub    $0xc0,%eax
je     12fb <bootloader+0x14b>
jmp    12d5 <bootloader+0x125>
mov    -0x30(%rbp),%eax
sub    $0xc1,%eax
je     13e9 <bootloader+0x239>
jmp    12e8 <bootloader+0x138>
mov    -0x30(%rbp),%eax
sub    $0xc2,%eax
je     1418 <bootloader+0x268>
jmp    14a1 <bootloader+0x2f1>
mov    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x1,%eax
je     1320 <bootloader+0x170>
jmp    130f <bootloader+0x15f>
mov    -0x34(%rbp),%eax
sub    $0x4,%eax
je     1334 <bootloader+0x184>
jmp    13dd <bootloader+0x22d>
mov    -0x28(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    13e4 <bootloader+0x234>
mov    $0x6,%edi
call   1030 <uart_putc@plt>
mov    $0x0,%al
call   10c0 <timer_tick@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   10c0 <timer_tick@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
sub    -0x8(%rbp),%eax
cmp    $0x1e8480,%eax
jb     1368 <bootloader+0x1b8>
jmp    136d <bootloader+0x1bd>
jmp    1348 <bootloader+0x198>
lea    0xcb0(%rip),%rdi
call   1090 <uart_writeline@plt>
mov    -0x18(%rbp),%edi
call   1060 <hexstring@plt>
lea    0xcac(%rip),%rdi
call   1090 <uart_writeline@plt>
mov    -0x20(%rbp),%rax
mov    %eax,%edi
call   1060 <hexstring@plt>
lea    0xc9e(%rip),%rdi
call   1090 <uart_writeline@plt>
mov    $0x0,%al
call   10b0 <uart_getc@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x67,-0x28(%rbp)
je     13c2 <bootloader+0x212>
cmpl   $0x47,-0x28(%rbp)
jne    13d8 <bootloader+0x228>
lea    0xc95(%rip),%rdi
call   1090 <uart_writeline@plt>
mov    $0x8000,%edi
call   10a0 <BRANCHTO@plt>
jmp    13a4 <bootloader+0x1f4>
movl   $0xff,-0xc(%rbp)
jmp    14d0 <bootloader+0x320>
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    140c <bootloader+0x25c>
mov    -0x28(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1413 <bootloader+0x263>
movl   $0xff,-0xc(%rbp)
jmp    14d0 <bootloader+0x320>
mov    -0x28(%rbp),%eax
mov    $0xff,%ecx
sub    -0x14(%rbp),%ecx
cmp    %ecx,%eax
jne    1440 <bootloader+0x290>
mov    -0x28(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    1447 <bootloader+0x297>
movl   $0xff,-0xc(%rbp)
jmp    14d0 <bootloader+0x320>
mov    -0x10(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1495 <bootloader+0x2e5>
mov    $0x6,%edi
call   1030 <uart_putc@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
and    $0xff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
add    $0x80,%rax
mov    %rax,-0x20(%rbp)
movl   $0xc0,-0xc(%rbp)
jmp    149c <bootloader+0x2ec>
movl   $0xff,-0xc(%rbp)
jmp    14d0 <bootloader+0x320>
mov    -0x28(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x28(%rbp),%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1295 <bootloader+0xe5>
jmp    1211 <bootloader+0x61>

x86 assembly (clang, -O2):
<bootloader>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x20200004,%edi
call   10d0 <GET32@plt>
and    $0xffe3ffff,%eax
lea    0x40000(%rax),%esi
mov    $0x20200004,%edi
call   1070 <PUT32@plt>
mov    $0x20200028,%edi
mov    $0x10000,%esi
call   1070 <PUT32@plt>
xor    %eax,%eax
call   1040 <uart_init@plt>
xor    %eax,%eax
call   1080 <timer_init@plt>
lea    0xe02(%rip),%rdi
call   1090 <uart_writeline@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   10c0 <timer_tick@plt>
mov    %eax,%ebx
mov    $0x15,%edi
call   1030 <uart_putc@plt>
jmp    123c <bootloader+0x8c>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1050 <uart_check@plt>
test   %rax,%rax
jne    1260 <bootloader+0xb0>
xor    %eax,%eax
call   10c0 <timer_tick@plt>
mov    %eax,%ebp
sub    %ebx,%eax
cmp    $0x3d0900,%eax
jb     1230 <bootloader+0x80>
mov    $0x15,%edi
call   1030 <uart_putc@plt>
mov    %ebp,%ebx
jmp    1230 <bootloader+0x80>
nopl   0x0(%rax)
mov    $0x1,%r12d
xor    %r14d,%r14d
mov    $0x8000,%r15d
mov    $0xc0,%ebx
xor    %ebp,%ebp
jmp    129f <bootloader+0xef>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
mov    %r13b,(%r15,%rax,1)
add    %ebp,%r13d
add    $0x1,%ebx
add    $0x1,%r14d
mov    %r13d,%ebp
cmp    $0xff,%ebx
je     1210 <bootloader+0x60>
xor    %eax,%eax
call   10b0 <uart_getc@plt>
mov    %eax,%r13d
cmp    $0xc0,%ebx
jg     12e0 <bootloader+0x130>
cmp    $0x80,%ebx
je     1320 <bootloader+0x170>
cmp    $0xc0,%ebx
jne    1280 <bootloader+0xd0>
mov    $0xc1,%ebx
cmp    $0x1,%r13d
je     1290 <bootloader+0xe0>
jmp    1374 <bootloader+0x1c4>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0xc1,%ebx
je     1350 <bootloader+0x1a0>
cmp    $0xc2,%ebx
jne    1280 <bootloader+0xd0>
mov    $0xff,%eax
sub    %r12d,%eax
xor    %ebx,%ebx
cmp    %eax,%r13d
mov    $0x0,%ecx
cmove  %r13d,%ecx
add    %ebp,%ecx
cmp    %eax,%r13d
mov    %ecx,%r13d
je     1290 <bootloader+0xe0>
jmp    1210 <bootloader+0x60>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl %bpl,%eax
cmp    %eax,%r13d
jne    1210 <bootloader+0x60>
mov    $0x6,%edi
call   1030 <uart_putc@plt>
add    $0x1,%r12d
movzbl %r12b,%r12d
sub    $0xffffffffffffff80,%r15
mov    $0xc0,%ebx
jmp    1290 <bootloader+0xe0>
nopl   (%rax)
cmp    %r12d,%r13d
mov    $0x0,%eax
cmove  %r13d,%eax
add    %eax,%ebp
mov    $0xc2,%ebx
cmp    %r12d,%r13d
mov    %ebp,%r13d
je     1290 <bootloader+0xe0>
jmp    1210 <bootloader+0x60>
cmp    $0x4,%r13d
jne    1210 <bootloader+0x60>
mov    $0x6,%edi
call   1030 <uart_putc@plt>
xor    %eax,%eax
call   10c0 <timer_tick@plt>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10c0 <timer_tick@plt>
sub    %ebp,%eax
cmp    $0x1e8480,%eax
jb     13a0 <bootloader+0x1f0>
lea    0xc6d(%rip),%rdi
call   1090 <uart_writeline@plt>
mov    %r14d,%edi
call   1060 <hexstring@plt>
lea    0xc69(%rip),%rdi
call   1090 <uart_writeline@plt>
mov    %r15d,%edi
call   1060 <hexstring@plt>
lea    0xc5e(%rip),%rdi
call   1090 <uart_writeline@plt>
lea    0xc73(%rip),%rbx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10b0 <uart_getc@plt>
and    $0xffffffdf,%eax
cmp    $0x47,%eax
jne    13f0 <bootloader+0x240>
mov    %rbx,%rdi
call   1090 <uart_writeline@plt>
mov    $0x8000,%edi
call   10a0 <BRANCHTO@plt>
jmp    13f0 <bootloader+0x240>

LLVM IR (-O0):
@.str = [36 x i8] c"Trollboot - Ready for your program!\00"
@.str.1 = [16 x i8] c"Bytes recieved:\00"
@.str.2 = [9 x i8] c"xstring:\00"
@.str.3 = [33 x i8] c"Ready to run. Press g/G to run.\00\00"
@.str.4 = [33 x i8] c"Branching to program. Good bye!\00\00"
define void @bootloader() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = call i32 @GET32(i32 538968068)
store i32 %11, i32* %1
%12 = load i32, i32* %1
%13 = and i32 %12, -1835009
store i32 %13, i32* %1
%14 = load i32, i32* %1
%15 = or i32 %14, 262144
store i32 %15, i32* %1
%16 = load i32, i32* %1
%17 = call i32 @PUT32(i32 538968068, i32 %16)
%18 = call i32 @PUT32(i32 538968104, i32 65536)
%19 = call i32 (...) @uart_init()
%20 = call i32 (...) @timer_init()
%21 = call i32 @uart_writeline(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %0, %139
%23 = call i32 (...) @timer_tick()
store i32 %23, i32* %2
store i32 192, i32* %3
store i32 0, i32* %4
store i32 1, i32* %5
store i32 0, i32* %6
store i8* inttoptr (i64 32768 to i8*), i8** %7
%24 = call i32 @uart_putc(i32 21)
br label %25
25: ; preds = %22, %38
%26 = call i32 (...) @timer_tick()
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = load i32, i32* %2
%29 = sub i32 %27, %28
%30 = icmp uge i32 %29, 4000000
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = call i32 @uart_putc(i32 21)
%33 = load i32, i32* %8
store i32 %33, i32* %2
br label %34
34: ; preds = %31, %25
%35 = call i64 (...) @uart_check()
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %34
br label %39
38: ; preds = %34
br label %25
39: ; preds = %37
br label %40
40: ; preds = %138, %39
%41 = load i32, i32* %3
%42 = icmp ne i32 %41, 255
br i1 %42, label %43, label %139
43: ; preds = %40
%44 = call i32 (...) @uart_getc()
store i32 %44, i32* %9
%45 = load i32, i32* %3
switch i32 %45, label %123 [
i32 192, label %46
i32 193, label %85
i32 194, label %97
i32 128, label %108
]
46: ; preds = %43
%47 = load i32, i32* %9
switch i32 %47, label %83 [
i32 1, label %48
i32 4, label %52
]
48: ; preds = %46
%49 = load i32, i32* %9
store i32 %49, i32* %4
%50 = load i32, i32* %3
%51 = add i32 %50, 1
store i32 %51, i32* %3
br label %84
52: ; preds = %46
%53 = call i32 @uart_putc(i32 6)
%54 = call i32 (...) @timer_tick()
store i32 %54, i32* %2
br label %55
55: ; preds = %52, %62
%56 = call i32 (...) @timer_tick()
store i32 %56, i32* %10
%57 = load i32, i32* %10
%58 = load i32, i32* %2
%59 = sub i32 %57, %58
%60 = icmp uge i32 %59, 2000000
br i1 %60, label %61, label %62
61: ; preds = %55
br label %63
62: ; preds = %55
br label %55
63: ; preds = %61
%64 = call i32 @uart_writeline(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%65 = load i32, i32* %6
%66 = call i32 @hexstring(i32 %65)
%67 = call i32 @uart_writeline(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%68 = load i8*, i8** %7
%69 = ptrtoint i8* %68 to i32
%70 = call i32 @hexstring(i32 %69)
%71 = call i32 @uart_writeline(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %72
72: ; preds = %63, %82
%73 = call i32 (...) @uart_getc()
store i32 %73, i32* %9
%74 = load i32, i32* %9
%75 = icmp eq i32 %74, 103
br i1 %75, label %79, label %76
76: ; preds = %72
%77 = load i32, i32* %9
%78 = icmp eq i32 %77, 71
br i1 %78, label %79, label %82
79: ; preds = %76, %72
%80 = call i32 @uart_writeline(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%81 = call i32 @BRANCHTO(i32 32768)
br label %82
82: ; preds = %79, %76
br label %72
83: ; preds = %46
store i32 255, i32* %3
br label %84
84: ; preds = %83, %48
br label %138
85: ; preds = %43
%86 = load i32, i32* %9
%87 = load i32, i32* %5
%88 = icmp eq i32 %86, %87
br i1 %88, label %89, label %95
89: ; preds = %85
%90 = load i32, i32* %9
%91 = load i32, i32* %4
%92 = add i32 %91, %90
store i32 %92, i32* %4
%93 = load i32, i32* %3
%94 = add i32 %93, 1
store i32 %94, i32* %3
br label %96
95: ; preds = %85
store i32 255, i32* %3
br label %96
96: ; preds = %95, %89
br label %138
97: ; preds = %43
%98 = load i32, i32* %9
%99 = load i32, i32* %5
%100 = sub i32 255, %99
%101 = icmp eq i32 %98, %100
br i1 %101, label %102, label %106
102: ; preds = %97
%103 = load i32, i32* %9
%104 = load i32, i32* %4
%105 = add i32 %104, %103
store i32 %105, i32* %4
store i32 0, i32* %3
br label %107
106: ; preds = %97
store i32 255, i32* %3
br label %107
107: ; preds = %106, %102
br label %138
108: ; preds = %43
%109 = load i32, i32* %4
%110 = and i32 %109, 255
store i32 %110, i32* %4
%111 = load i32, i32* %9
%112 = load i32, i32* %4
%113 = icmp eq i32 %111, %112
br i1 %113, label %114, label %121
114: ; preds = %108
%115 = call i32 @uart_putc(i32 6)
%116 = load i32, i32* %5
%117 = add i32 %116, 1
%118 = and i32 %117, 255
store i32 %118, i32* %5
%119 = load i8*, i8** %7
%120 = getelementptr inbounds i8, i8* %119, i64 128
store i8* %120, i8** %7
store i32 192, i32* %3
br label %122
121: ; preds = %108
store i32 255, i32* %3
br label %122
122: ; preds = %121, %114
br label %138
123: ; preds = %43
%124 = load i32, i32* %9
%125 = load i32, i32* %4
%126 = add i32 %125, %124
store i32 %126, i32* %4
%127 = load i32, i32* %9
%128 = and i32 %127, 255
%129 = trunc i32 %128 to i8
%130 = load i8*, i8** %7
%131 = load i32, i32* %3
%132 = zext i32 %131 to i64
%133 = getelementptr inbounds i8, i8* %130, i64 %132
store i8 %129, i8* %133
%134 = load i32, i32* %3
%135 = add i32 %134, 1
store i32 %135, i32* %3
%136 = load i32, i32* %6
%137 = add i32 %136, 1
store i32 %137, i32* %6
br label %138
138: ; preds = %123, %122, %107, %96, %84
br label %40
139: ; preds = %40
br label %22
}

LLVM IR (-O2):
@.str = [36 x i8] c"Trollboot - Ready for your program!\00"
@.str.1 = [16 x i8] c"Bytes recieved:\00"
@.str.2 = [9 x i8] c"xstring:\00"
@.str.3 = [33 x i8] c"Ready to run. Press g/G to run.\00\00"
@.str.4 = [33 x i8] c"Branching to program. Good bye!\00\00"
define void @bootloader() {
%1 = tail call i32 @GET32(i32 538968068)
%2 = and i32 %1, -1835009
%3 = or i32 %2, 262144
%4 = tail call i32 @PUT32(i32 538968068, i32 %3)
%5 = tail call i32 @PUT32(i32 538968104, i32 65536)
%6 = tail call i32 (...) @uart_init()
%7 = tail call i32 (...) @timer_init()
%8 = tail call i32 @uart_writeline(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %10
9: ; preds = %55, %59, %64, %31, %79
br label %10
10: ; preds = %9, %0
%11 = tail call i32 (...) @timer_tick()
%12 = tail call i32 @uart_putc(i32 21)
br label %13
13: ; preds = %20, %10
%14 = phi i32 [ %11, %10 ], [ %21, %20 ]
%15 = tail call i32 (...) @timer_tick()
%16 = sub i32 %15, %14
%17 = icmp ugt i32 %16, 3999999
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 @uart_putc(i32 21)
br label %20
20: ; preds = %18, %13
%21 = phi i32 [ %15, %18 ], [ %14, %13 ]
%22 = tail call i64 (...) @uart_check()
%23 = icmp eq i64 %22, 0
br i1 %23, label %13, label %24
24: ; preds = %20, %79
%25 = phi i32 [ %84, %79 ], [ 192, %20 ]
%26 = phi i8* [ %83, %79 ], [ inttoptr (i64 32768 to i8*), %20 ]
%27 = phi i32 [ %82, %79 ], [ 0, %20 ]
%28 = phi i32 [ %81, %79 ], [ 1, %20 ]
%29 = phi i32 [ %80, %79 ], [ 0, %20 ]
%30 = tail call i32 (...) @uart_getc()
switch i32 %25, label %72 [
i32 192, label %31
i32 193, label %55
i32 194, label %59
i32 128, label %64
]
31: ; preds = %24
switch i32 %30, label %9 [
i32 1, label %79
i32 4, label %32
]
32: ; preds = %31
%33 = tail call i32 @uart_putc(i32 6)
%34 = tail call i32 (...) @timer_tick()
br label %35
35: ; preds = %35, %32
%36 = tail call i32 (...) @timer_tick()
%37 = sub i32 %36, %34
%38 = icmp ugt i32 %37, 1999999
br i1 %38, label %39, label %35
39: ; preds = %35
%40 = tail call i32 @uart_writeline(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%41 = tail call i32 @hexstring(i32 %27)
%42 = tail call i32 @uart_writeline(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%43 = ptrtoint i8* %26 to i64
%44 = trunc i64 %43 to i32
%45 = tail call i32 @hexstring(i32 %44)
%46 = tail call i32 @uart_writeline(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %51, %39
%48 = tail call i32 (...) @uart_getc()
%49 = and i32 %48, -33
%50 = icmp eq i32 %49, 71
br i1 %50, label %52, label %51
51: ; preds = %47, %52
br label %47
52: ; preds = %47
%53 = tail call i32 @uart_writeline(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%54 = tail call i32 @BRANCHTO(i32 32768)
br label %51
55: ; preds = %24
%56 = icmp eq i32 %30, %28
%57 = select i1 %56, i32 %30, i32 0
%58 = add i32 %29, %57
br i1 %56, label %79, label %9
59: ; preds = %24
%60 = sub i32 255, %28
%61 = icmp eq i32 %30, %60
%62 = select i1 %61, i32 %30, i32 0
%63 = add i32 %62, %29
br i1 %61, label %79, label %9
64: ; preds = %24
%65 = and i32 %29, 255
%66 = icmp eq i32 %30, %65
br i1 %66, label %67, label %9
67: ; preds = %64
%68 = tail call i32 @uart_putc(i32 6)
%69 = add i32 %28, 1
%70 = and i32 %69, 255
%71 = getelementptr inbounds i8, i8* %26, i64 128
br label %79
72: ; preds = %24
%73 = add i32 %30, %29
%74 = trunc i32 %30 to i8
%75 = zext i32 %25 to i64
%76 = getelementptr inbounds i8, i8* %26, i64 %75
store i8 %74, i8* %76
%77 = add i32 %25, 1
%78 = add i32 %27, 1
br label %79
79: ; preds = %55, %59, %31, %67, %72
%80 = phi i32 [ %73, %72 ], [ %30, %67 ], [ %30, %31 ], [ %63, %59 ], [ %58, %55 ]
%81 = phi i32 [ %28, %72 ], [ %70, %67 ], [ %28, %31 ], [ %28, %59 ], [ %28, %55 ]
%82 = phi i32 [ %78, %72 ], [ %27, %67 ], [ %27, %31 ], [ %27, %59 ], [ %27, %55 ]
%83 = phi i8* [ %26, %72 ], [ %71, %67 ], [ %26, %31 ], [ %26, %59 ], [ %26, %55 ]
%84 = phi i32 [ %77, %72 ], [ 192, %67 ], [ 193, %31 ], [ 0, %59 ], [ 194, %55 ]
%85 = icmp eq i32 %84, 255
br i1 %85, label %9, label %24
}