#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*/ check_serial_input();
int /*<<< orphan*/ set_leds(unsigned int);
void serial_out(unsigned ch) {
  check_serial_input();
  if (ch == '\n')
    serial_out('\r');
  check_serial_input();
  while ((*(volatile unsigned *)0xFF000000 != 0))
    check_serial_input();
  (*(volatile unsigned *)0xFF000000 = (ch));
  set_leds(ch);
}


x86 assembly (clang, -O0):
<serial_out>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1050 <check_serial_input@plt>
cmpl   $0xa,-0x4(%rbp)
jne    1156 <serial_out+0x26>
mov    $0xd,%edi
call   1030 <serial_out@plt>
mov    $0x0,%al
call   1050 <check_serial_input@plt>
mov    $0xff000000,%eax
mov    (%rax),%eax
cmp    $0x0,%eax
je     1179 <serial_out+0x49>
mov    $0x0,%al
call   1050 <check_serial_input@plt>
jmp    115d <serial_out+0x2d>
mov    -0x4(%rbp),%ecx
mov    $0xff000000,%eax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%edi
call   1040 <set_leds@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serial_out>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0xff000000,%ebx
xor    %eax,%eax
call   1040 <check_serial_input@plt>
cmp    $0xa,%ebp
jne    1160 <serial_out+0x40>
xor    %eax,%eax
call   1040 <check_serial_input@plt>
nopl   (%rax)
xor    %eax,%eax
call   1040 <check_serial_input@plt>
cmpl   $0x0,(%rbx)
jne    1140 <serial_out+0x20>
movl   $0xd,(%rbx)
mov    $0xd,%edi
call   1030 <set_leds@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <check_serial_input@plt>
cmpl   $0x0,(%rbx)
jne    1160 <serial_out+0x40>
mov    %ebp,(%rbx)
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <set_leds@plt>

LLVM IR (-O0):
define void @serial_out(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (...) @check_serial_input()
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 10
br i1 %5, label %6, label %7
6: ; preds = %1
br label %7
7: ; preds = %6, %1
%8 = call i32 (...) @check_serial_input()
br label %9
9: ; preds = %12, %7
%10 = load volatile i32, i32* inttoptr (i64 4278190080 to i32*)
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 (...) @check_serial_input()
br label %9
14: ; preds = %9
%15 = load i32, i32* %2
store volatile i32 %15, i32* inttoptr (i64 4278190080 to i32*)
%16 = load i32, i32* %2
%17 = call i32 @set_leds(i32 %16)
ret void
}

LLVM IR (-O2):
define void @serial_out(i32 %0) {
%2 = tail call i32 (...) @check_serial_input()
%3 = icmp eq i32 %0, 10
br i1 %3, label %4, label %15
4: ; preds = %1
%5 = tail call i32 (...) @check_serial_input()
%6 = tail call i32 (...) @check_serial_input()
%7 = load volatile i32, i32* inttoptr (i64 4278190080 to i32*)
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %4, %9
%10 = tail call i32 (...) @check_serial_input()
%11 = load volatile i32, i32* inttoptr (i64 4278190080 to i32*)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %9
13: ; preds = %9, %4
store volatile i32 13, i32* inttoptr (i64 4278190080 to i32*)
%14 = tail call i32 @set_leds(i32 13)
br label %15
15: ; preds = %13, %1
%16 = tail call i32 (...) @check_serial_input()
%17 = load volatile i32, i32* inttoptr (i64 4278190080 to i32*)
%18 = icmp eq i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %15, %19
%20 = tail call i32 (...) @check_serial_input()
%21 = load volatile i32, i32* inttoptr (i64 4278190080 to i32*)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %19
23: ; preds = %19, %15
store volatile i32 %0, i32* inttoptr (i64 4278190080 to i32*)
%24 = tail call i32 @set_leds(i32 %0)
ret void
}