#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 */
typedef int uint32_t;

/* Variables and functions */
int panos_now();
int /*<<< orphan*/ panos_pin_clear(int);
int /*<<< orphan*/ panos_pin_set(int);
int /*<<< orphan*/ panos_wait_till(int);
void panos_uart_char(char c) {
  panos_pin_clear(14);
  uint32_t timestamp = panos_now();
  timestamp += (1000 * 1000 / 9600);
  panos_wait_till(timestamp);
  for (int i = 0; i < 8; ++i) {
    if (c & 0x01) {
      panos_pin_set(14);
    } else {
      panos_pin_clear(14);
    }
    c >>= 1;
    timestamp += (1000 * 1000 / 9600);
    panos_wait_till(timestamp);
  }
  panos_pin_set(14);
  timestamp += 2 * (1000 * 1000 / 9600);
  panos_wait_till(timestamp);
}


x86 assembly (clang, -O0):
<panos_uart_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0xe,%edi
call   1050 <panos_pin_clear@plt>
mov    $0x0,%al
call   1030 <panos_now@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x68,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <panos_wait_till@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    11d6 <panos_uart_char+0x96>
movsbl -0x1(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a3 <panos_uart_char+0x63>
mov    $0xe,%edi
call   1060 <panos_pin_set@plt>
jmp    11ad <panos_uart_char+0x6d>
mov    $0xe,%edi
call   1050 <panos_pin_clear@plt>
movsbl -0x1(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x1(%rbp)
mov    -0x8(%rbp),%eax
add    $0x68,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <panos_wait_till@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117a <panos_uart_char+0x3a>
mov    $0xe,%edi
call   1060 <panos_pin_set@plt>
mov    -0x8(%rbp),%eax
add    $0xd0,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <panos_wait_till@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<panos_uart_char>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0xe,%edi
call   1050 <panos_pin_clear@plt>
xor    %eax,%eax
call   1030 <panos_now@plt>
mov    %eax,%ebx
lea    0x68(%rbx),%edi
call   1040 <panos_wait_till@plt>
mov    $0xe,%edi
test   $0x1,%bpl
jne    1172 <panos_uart_char+0x32>
call   1050 <panos_pin_clear@plt>
jmp    1177 <panos_uart_char+0x37>
call   1060 <panos_pin_set@plt>
lea    0xd0(%rbx),%edi
call   1040 <panos_wait_till@plt>
mov    $0xe,%edi
test   $0x2,%bpl
jne    1194 <panos_uart_char+0x54>
call   1050 <panos_pin_clear@plt>
jmp    1199 <panos_uart_char+0x59>
call   1060 <panos_pin_set@plt>
lea    0x138(%rbx),%edi
call   1040 <panos_wait_till@plt>
mov    $0xe,%edi
test   $0x4,%bpl
jne    11b6 <panos_uart_char+0x76>
call   1050 <panos_pin_clear@plt>
jmp    11bb <panos_uart_char+0x7b>
call   1060 <panos_pin_set@plt>
lea    0x1a0(%rbx),%edi
call   1040 <panos_wait_till@plt>
mov    $0xe,%edi
test   $0x8,%bpl
jne    11d8 <panos_uart_char+0x98>
call   1050 <panos_pin_clear@plt>
jmp    11dd <panos_uart_char+0x9d>
call   1060 <panos_pin_set@plt>
lea    0x208(%rbx),%edi
call   1040 <panos_wait_till@plt>
mov    $0xe,%edi
test   $0x10,%bpl
jne    11fa <panos_uart_char+0xba>
call   1050 <panos_pin_clear@plt>
jmp    11ff <panos_uart_char+0xbf>
call   1060 <panos_pin_set@plt>
lea    0x270(%rbx),%edi
call   1040 <panos_wait_till@plt>
mov    $0xe,%edi
test   $0x20,%bpl
jne    121c <panos_uart_char+0xdc>
call   1050 <panos_pin_clear@plt>
jmp    1221 <panos_uart_char+0xe1>
call   1060 <panos_pin_set@plt>
lea    0x2d8(%rbx),%edi
call   1040 <panos_wait_till@plt>
mov    $0xe,%edi
test   $0x40,%bpl
jne    123e <panos_uart_char+0xfe>
call   1050 <panos_pin_clear@plt>
jmp    1243 <panos_uart_char+0x103>
call   1060 <panos_pin_set@plt>
lea    0x340(%rbx),%edi
call   1040 <panos_wait_till@plt>
mov    $0xe,%edi
test   %bpl,%bpl
js     125f <panos_uart_char+0x11f>
call   1050 <panos_pin_clear@plt>
jmp    1264 <panos_uart_char+0x124>
call   1060 <panos_pin_set@plt>
lea    0x3a8(%rbx),%edi
call   1040 <panos_wait_till@plt>
mov    $0xe,%edi
call   1060 <panos_pin_set@plt>
add    $0x478,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <panos_wait_till@plt>

LLVM IR (-O0):
define void @panos_uart_char(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i8 %0, i8* %2
%5 = call i32 @panos_pin_clear(i32 14)
%6 = call i32 (...) @panos_now()
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = add nsw i32 %7, 104
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = call i32 @panos_wait_till(i32 %9)
store i32 0, i32* %4
br label %11
11: ; preds = %32, %1
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 8
br i1 %13, label %14, label %35
14: ; preds = %11
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = and i32 %16, 1
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = call i32 @panos_pin_set(i32 14)
br label %23
21: ; preds = %14
%22 = call i32 @panos_pin_clear(i32 14)
br label %23
23: ; preds = %21, %19
%24 = load i8, i8* %2
%25 = sext i8 %24 to i32
%26 = ashr i32 %25, 1
%27 = trunc i32 %26 to i8
store i8 %27, i8* %2
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 104
store i32 %29, i32* %3
%30 = load i32, i32* %3
%31 = call i32 @panos_wait_till(i32 %30)
br label %32
32: ; preds = %23
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %11
35: ; preds = %11
%36 = call i32 @panos_pin_set(i32 14)
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 208
store i32 %38, i32* %3
%39 = load i32, i32* %3
%40 = call i32 @panos_wait_till(i32 %39)
ret void
}

LLVM IR (-O2):
define void @panos_uart_char(i8 signext %0) {
%2 = tail call i32 @panos_pin_clear(i32 14)
%3 = tail call i32 (...) @panos_now()
%4 = add nsw i32 %3, 104
%5 = tail call i32 @panos_wait_till(i32 %4)
%6 = and i8 %0, 1
%7 = icmp eq i8 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = tail call i32 @panos_pin_set(i32 14)
br label %12
10: ; preds = %1
%11 = tail call i32 @panos_pin_clear(i32 14)
br label %12
12: ; preds = %10, %8
%13 = add nsw i32 %3, 208
%14 = tail call i32 @panos_wait_till(i32 %13)
%15 = and i8 %0, 2
%16 = icmp eq i8 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = tail call i32 @panos_pin_set(i32 14)
br label %21
19: ; preds = %12
%20 = tail call i32 @panos_pin_clear(i32 14)
br label %21
21: ; preds = %19, %17
%22 = add nsw i32 %3, 312
%23 = tail call i32 @panos_wait_till(i32 %22)
%24 = and i8 %0, 4
%25 = icmp eq i8 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %21
%27 = tail call i32 @panos_pin_set(i32 14)
br label %30
28: ; preds = %21
%29 = tail call i32 @panos_pin_clear(i32 14)
br label %30
30: ; preds = %28, %26
%31 = add nsw i32 %3, 416
%32 = tail call i32 @panos_wait_till(i32 %31)
%33 = and i8 %0, 8
%34 = icmp eq i8 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %30
%36 = tail call i32 @panos_pin_set(i32 14)
br label %39
37: ; preds = %30
%38 = tail call i32 @panos_pin_clear(i32 14)
br label %39
39: ; preds = %37, %35
%40 = add nsw i32 %3, 520
%41 = tail call i32 @panos_wait_till(i32 %40)
%42 = and i8 %0, 16
%43 = icmp eq i8 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %39
%45 = tail call i32 @panos_pin_set(i32 14)
br label %48
46: ; preds = %39
%47 = tail call i32 @panos_pin_clear(i32 14)
br label %48
48: ; preds = %46, %44
%49 = add nsw i32 %3, 624
%50 = tail call i32 @panos_wait_till(i32 %49)
%51 = and i8 %0, 32
%52 = icmp eq i8 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %48
%54 = tail call i32 @panos_pin_set(i32 14)
br label %57
55: ; preds = %48
%56 = tail call i32 @panos_pin_clear(i32 14)
br label %57
57: ; preds = %55, %53
%58 = add nsw i32 %3, 728
%59 = tail call i32 @panos_wait_till(i32 %58)
%60 = and i8 %0, 64
%61 = icmp eq i8 %60, 0
br i1 %61, label %64, label %62
62: ; preds = %57
%63 = tail call i32 @panos_pin_set(i32 14)
br label %66
64: ; preds = %57
%65 = tail call i32 @panos_pin_clear(i32 14)
br label %66
66: ; preds = %64, %62
%67 = add nsw i32 %3, 832
%68 = tail call i32 @panos_wait_till(i32 %67)
%69 = icmp sgt i8 %0, -1
br i1 %69, label %72, label %70
70: ; preds = %66
%71 = tail call i32 @panos_pin_set(i32 14)
br label %74
72: ; preds = %66
%73 = tail call i32 @panos_pin_clear(i32 14)
br label %74
74: ; preds = %72, %70
%75 = add nsw i32 %3, 936
%76 = tail call i32 @panos_wait_till(i32 %75)
%77 = tail call i32 @panos_pin_set(i32 14)
%78 = add nsw i32 %3, 1144
%79 = tail call i32 @panos_wait_till(i32 %78)
ret void
}