#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*/ callback();
int /*<<< orphan*/ rx(char);
int /*<<< orphan*/ serial_init();
int /*<<< orphan*/ serial_poll();
int /*<<< orphan*/ txn(int);
int /*<<< orphan*/ usb_arrive(char *);
int main(void) {
  serial_init();
  serial_poll();
  usb_arrive("TEST");
  usb_arrive("MORE");
  txn(4);
  txn(5);
  usb_arrive("XXXX");
  usb_arrive("YYYY");
  txn(10);
  rx('A');
  serial_poll();
  rx('B');
  rx('C');
  rx('D');
  rx('E');
  rx('F');
  rx('G');
  serial_poll();
  serial_poll();
  callback();
  serial_poll();
  serial_poll();
  callback();
  rx('H');
  serial_poll();
  serial_poll();
  callback();
  serial_poll();
  serial_poll();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <serial_init@plt>
mov    $0x0,%al
call   1080 <serial_poll@plt>
lea    0xe7c(%rip),%rdi
call   1050 <usb_arrive@plt>
lea    0xe75(%rip),%rdi
call   1050 <usb_arrive@plt>
mov    $0x4,%edi
call   1030 <txn@plt>
mov    $0x5,%edi
call   1030 <txn@plt>
lea    0xe5a(%rip),%rdi
call   1050 <usb_arrive@plt>
lea    0xe53(%rip),%rdi
call   1050 <usb_arrive@plt>
mov    $0xa,%edi
call   1030 <txn@plt>
mov    $0x41,%edi
call   1040 <rx@plt>
mov    $0x0,%al
call   1080 <serial_poll@plt>
mov    $0x42,%edi
call   1040 <rx@plt>
mov    $0x43,%edi
call   1040 <rx@plt>
mov    $0x44,%edi
call   1040 <rx@plt>
mov    $0x45,%edi
call   1040 <rx@plt>
mov    $0x46,%edi
call   1040 <rx@plt>
mov    $0x47,%edi
call   1040 <rx@plt>
mov    $0x0,%al
call   1080 <serial_poll@plt>
mov    $0x0,%al
call   1080 <serial_poll@plt>
mov    $0x0,%al
call   1060 <callback@plt>
mov    $0x0,%al
call   1080 <serial_poll@plt>
mov    $0x0,%al
call   1080 <serial_poll@plt>
mov    $0x0,%al
call   1060 <callback@plt>
mov    $0x48,%edi
call   1040 <rx@plt>
mov    $0x0,%al
call   1080 <serial_poll@plt>
mov    $0x0,%al
call   1080 <serial_poll@plt>
mov    $0x0,%al
call   1060 <callback@plt>
mov    $0x0,%al
call   1080 <serial_poll@plt>
mov    $0x0,%al
call   1080 <serial_poll@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1070 <serial_init@plt>
xor    %eax,%eax
call   1080 <serial_poll@plt>
lea    0xe8a(%rip),%rdi
call   1050 <usb_arrive@plt>
lea    0xe83(%rip),%rdi
call   1050 <usb_arrive@plt>
mov    $0x4,%edi
call   1030 <txn@plt>
mov    $0x5,%edi
call   1030 <txn@plt>
lea    0xe68(%rip),%rdi
call   1050 <usb_arrive@plt>
lea    0xe61(%rip),%rdi
call   1050 <usb_arrive@plt>
mov    $0xa,%edi
call   1030 <txn@plt>
mov    $0x41,%edi
call   1040 <rx@plt>
xor    %eax,%eax
call   1080 <serial_poll@plt>
mov    $0x42,%edi
call   1040 <rx@plt>
mov    $0x43,%edi
call   1040 <rx@plt>
mov    $0x44,%edi
call   1040 <rx@plt>
mov    $0x45,%edi
call   1040 <rx@plt>
mov    $0x46,%edi
call   1040 <rx@plt>
mov    $0x47,%edi
call   1040 <rx@plt>
xor    %eax,%eax
call   1080 <serial_poll@plt>
xor    %eax,%eax
call   1080 <serial_poll@plt>
xor    %eax,%eax
call   1060 <callback@plt>
xor    %eax,%eax
call   1080 <serial_poll@plt>
xor    %eax,%eax
call   1080 <serial_poll@plt>
xor    %eax,%eax
call   1060 <callback@plt>
mov    $0x48,%edi
call   1040 <rx@plt>
xor    %eax,%eax
call   1080 <serial_poll@plt>
xor    %eax,%eax
call   1080 <serial_poll@plt>
xor    %eax,%eax
call   1060 <callback@plt>
xor    %eax,%eax
call   1080 <serial_poll@plt>
xor    %eax,%eax
call   1080 <serial_poll@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"TEST\00"
@.str.1 = [5 x i8] c"MORE\00"
@.str.2 = [5 x i8] c"XXXX\00"
@.str.3 = [5 x i8] c"YYYY\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @serial_init()
%3 = call i32 (...) @serial_poll()
%4 = call i32 @usb_arrive(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @usb_arrive(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @txn(i32 4)
%7 = call i32 @txn(i32 5)
%8 = call i32 @usb_arrive(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @usb_arrive(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @txn(i32 10)
%11 = call i32 @rx(i8 signext 65)
%12 = call i32 (...) @serial_poll()
%13 = call i32 @rx(i8 signext 66)
%14 = call i32 @rx(i8 signext 67)
%15 = call i32 @rx(i8 signext 68)
%16 = call i32 @rx(i8 signext 69)
%17 = call i32 @rx(i8 signext 70)
%18 = call i32 @rx(i8 signext 71)
%19 = call i32 (...) @serial_poll()
%20 = call i32 (...) @serial_poll()
%21 = call i32 (...) @callback()
%22 = call i32 (...) @serial_poll()
%23 = call i32 (...) @serial_poll()
%24 = call i32 (...) @callback()
%25 = call i32 @rx(i8 signext 72)
%26 = call i32 (...) @serial_poll()
%27 = call i32 (...) @serial_poll()
%28 = call i32 (...) @callback()
%29 = call i32 (...) @serial_poll()
%30 = call i32 (...) @serial_poll()
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"TEST\00"
@.str.1 = [5 x i8] c"MORE\00"
@.str.2 = [5 x i8] c"XXXX\00"
@.str.3 = [5 x i8] c"YYYY\00"
define i32 @main() {
%1 = tail call i32 (...) @serial_init()
%2 = tail call i32 (...) @serial_poll()
%3 = tail call i32 @usb_arrive(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @usb_arrive(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @txn(i32 4)
%6 = tail call i32 @txn(i32 5)
%7 = tail call i32 @usb_arrive(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @usb_arrive(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @txn(i32 10)
%10 = tail call i32 @rx(i8 signext 65)
%11 = tail call i32 (...) @serial_poll()
%12 = tail call i32 @rx(i8 signext 66)
%13 = tail call i32 @rx(i8 signext 67)
%14 = tail call i32 @rx(i8 signext 68)
%15 = tail call i32 @rx(i8 signext 69)
%16 = tail call i32 @rx(i8 signext 70)
%17 = tail call i32 @rx(i8 signext 71)
%18 = tail call i32 (...) @serial_poll()
%19 = tail call i32 (...) @serial_poll()
%20 = tail call i32 (...) @callback()
%21 = tail call i32 (...) @serial_poll()
%22 = tail call i32 (...) @serial_poll()
%23 = tail call i32 (...) @callback()
%24 = tail call i32 @rx(i8 signext 72)
%25 = tail call i32 (...) @serial_poll()
%26 = tail call i32 (...) @serial_poll()
%27 = tail call i32 (...) @callback()
%28 = tail call i32 (...) @serial_poll()
%29 = tail call i32 (...) @serial_poll()
ret i32 0
}