#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 uint8_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ clockDown();
int /*<<< orphan*/ clockUp();
int /*<<< orphan*/ resetLoadPin();
int /*<<< orphan*/ setDataPin(int);
int /*<<< orphan*/ setLoadPin();
int /*<<< orphan*/ waitEnough();
int sendByte(uint8_t data, uint8_t address) {
  uint16_t serial_packet = 0;
  uint8_t i = 0;
  serial_packet |= (address << 8);
  serial_packet |= data;
  setLoadPin();
  for (i = 0; i < 16; i++) {
    waitEnough();
    setDataPin((serial_packet >> (15 - i) & 0x01));
    clockUp();
    waitEnough();
    clockDown();
  }
  resetLoadPin();
  waitEnough();
}


x86 assembly (clang, -O0):
<sendByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1070 <setLoadPin@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    11e8 <sendByte+0x88>
mov    $0x0,%al
call   1060 <waitEnough@plt>
mov    -0x10(%rbp),%edi
mov    $0xf,%ecx
sub    -0x14(%rbp),%ecx
sar    %cl,%edi
and    $0x1,%edi
call   1030 <setDataPin@plt>
mov    $0x0,%al
call   1050 <clockUp@plt>
mov    $0x0,%al
call   1060 <waitEnough@plt>
mov    $0x0,%al
call   1080 <clockDown@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119f <sendByte+0x3f>
mov    $0x0,%al
call   1040 <resetLoadPin@plt>
mov    $0x0,%al
call   1060 <waitEnough@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendByte>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
shl    $0x8,%ebx
or     %edi,%ebx
xor    %eax,%eax
call   1070 <setLoadPin@plt>
mov    $0xf,%ebp
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <waitEnough@plt>
mov    %ebx,%edi
mov    %ebp,%ecx
shr    %cl,%edi
and    $0x1,%edi
call   1030 <setDataPin@plt>
xor    %eax,%eax
call   1050 <clockUp@plt>
xor    %eax,%eax
call   1060 <waitEnough@plt>
xor    %eax,%eax
call   1080 <clockDown@plt>
add    $0xffffffff,%ebp
jb     1180 <sendByte+0x20>
xor    %eax,%eax
call   1040 <resetLoadPin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <waitEnough@plt>

LLVM IR (-O0):
define i32 @sendByte(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load i32, i32* %5
%9 = shl i32 %8, 8
%10 = load i32, i32* %6
%11 = or i32 %10, %9
store i32 %11, i32* %6
%12 = load i32, i32* %4
%13 = load i32, i32* %6
%14 = or i32 %13, %12
store i32 %14, i32* %6
%15 = call i32 (...) @setLoadPin()
store i32 0, i32* %7
br label %16
16: ; preds = %30, %2
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 16
br i1 %18, label %19, label %33
19: ; preds = %16
%20 = call i32 (...) @waitEnough()
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = sub nsw i32 15, %22
%24 = ashr i32 %21, %23
%25 = and i32 %24, 1
%26 = call i32 @setDataPin(i32 %25)
%27 = call i32 (...) @clockUp()
%28 = call i32 (...) @waitEnough()
%29 = call i32 (...) @clockDown()
br label %30
30: ; preds = %19
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %16
33: ; preds = %16
%34 = call i32 (...) @resetLoadPin()
%35 = call i32 (...) @waitEnough()
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
define i32 @sendByte(i32 %0, i32 %1) {
%3 = shl i32 %1, 8
%4 = or i32 %3, %0
%5 = tail call i32 (...) @setLoadPin()
br label %6
6: ; preds = %2, %6
%7 = phi i32 [ 0, %2 ], [ %16, %6 ]
%8 = tail call i32 (...) @waitEnough()
%9 = sub nuw nsw i32 15, %7
%10 = lshr i32 %4, %9
%11 = and i32 %10, 1
%12 = tail call i32 @setDataPin(i32 %11)
%13 = tail call i32 (...) @clockUp()
%14 = tail call i32 (...) @waitEnough()
%15 = tail call i32 (...) @clockDown()
%16 = add nuw nsw i32 %7, 1
%17 = icmp eq i32 %16, 16
br i1 %17, label %18, label %6
18: ; preds = %6
%19 = tail call i32 (...) @resetLoadPin()
%20 = tail call i32 (...) @waitEnough()
ret i32 undef
}