#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*/ barrier();
void putc(int c) {
  unsigned long serial_port;
  do {
    serial_port = 0x206000;
    if ((*(volatile unsigned long *)(serial_port + (0x80))) & 1)
      break;
    serial_port = 0x207000;
    if ((*(volatile unsigned long *)(serial_port + (0x80))) & 1)
      break;
    return;
  } while (0);
  while (!((*(volatile unsigned long *)(serial_port + (0x98))) & (1 << 14)))
    barrier();
  (*(volatile unsigned long *)(serial_port + (0x40))) = c;
}


x86 assembly (clang, -O0):
<putc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x206000,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x80(%rax),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1141 <putc+0x31>
jmp    116c <putc+0x5c>
movq   $0x207000,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x80(%rax),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1167 <putc+0x57>
jmp    116c <putc+0x5c>
jmp    11b0 <putc+0xa0>
jmp    1171 <putc+0x61>
mov    -0x10(%rbp),%rax
mov    0x98(%rax),%rax
and    $0x4000,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1198 <putc+0x88>
jmp    11a4 <putc+0x94>
mov    $0x0,%al
call   1030 <barrier@plt>
jmp    1171 <putc+0x61>
movslq -0x4(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x40(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putc>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    0x206080,%rax
mov    $0x206000,%ebp
test   $0x1,%al
jne    113b <putc+0x2b>
mov    $0x207000,%ebp
testq  $0x1,0x207080
je     116b <putc+0x5b>
mov    %rbp,%rbx
or     $0x98,%rbx
testq  $0x4000,(%rbx)
jne    1160 <putc+0x50>
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <barrier@plt>
testq  $0x4000,(%rbx)
je     1150 <putc+0x40>
movslq %r14d,%rax
or     $0x40,%rbp
mov    %rax,0x0(%rbp)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @putc(i32 %0) {
%2 = alloca i32
%3 = alloca i64
store i32 %0, i32* %2
br label %4
4: ; preds = %1
store i64 2121728, i64* %3
%5 = load i64, i64* %3
%6 = add i64 %5, 128
%7 = inttoptr i64 %6 to i64*
%8 = load volatile i64, i64* %7
%9 = and i64 %8, 1
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %4
br label %21
12: ; preds = %4
store i64 2125824, i64* %3
%13 = load i64, i64* %3
%14 = add i64 %13, 128
%15 = inttoptr i64 %14 to i64*
%16 = load volatile i64, i64* %15
%17 = and i64 %16, 1
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %12
br label %21
20: ; preds = %12
br label %38
21: ; preds = %19, %11
br label %22
22: ; preds = %30, %21
%23 = load i64, i64* %3
%24 = add i64 %23, 152
%25 = inttoptr i64 %24 to i64*
%26 = load volatile i64, i64* %25
%27 = and i64 %26, 16384
%28 = icmp ne i64 %27, 0
%29 = xor i1 %28, true
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = call i32 (...) @barrier()
br label %22
32: ; preds = %22
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = load i64, i64* %3
%36 = add i64 %35, 64
%37 = inttoptr i64 %36 to i64*
store volatile i64 %34, i64* %37
br label %38
38: ; preds = %32, %20
ret void
}

LLVM IR (-O2):
define void @putc(i32 %0) {
%2 = load volatile i64, i64* inttoptr (i64 2121856 to i64*)
%3 = and i64 %2, 1
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = load volatile i64, i64* inttoptr (i64 2125952 to i64*)
%7 = and i64 %6, 1
%8 = icmp eq i64 %7, 0
br i1 %8, label %25, label %9
9: ; preds = %5, %1
%10 = phi i64 [ 2121728, %1 ], [ 2125824, %5 ]
%11 = or i64 %10, 152
%12 = inttoptr i64 %11 to i64*
%13 = load volatile i64, i64* %12
%14 = and i64 %13, 16384
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %9, %16
%17 = tail call i32 (...) @barrier()
%18 = load volatile i64, i64* %12
%19 = and i64 %18, 16384
%20 = icmp eq i64 %19, 0
br i1 %20, label %16, label %21
21: ; preds = %16, %9
%22 = sext i32 %0 to i64
%23 = or i64 %10, 64
%24 = inttoptr i64 %23 to i64*
store volatile i64 %22, i64* %24
br label %25
25: ; preds = %5, %21
ret void
}