#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*/ i2c_delay();
int /*<<< orphan*/ scl_high();
int /*<<< orphan*/ scl_low();
int /*<<< orphan*/ sda_high();
int /*<<< orphan*/ sda_input();
int /*<<< orphan*/ sda_low();
int /*<<< orphan*/ sda_output();
unsigned int sda_read();
unsigned int i2c_write_byte(unsigned int b) {
  unsigned int ra;
  for (ra = 0x80; ra; ra >>= 1) {
    i2c_delay();
    if (ra & b)
      sda_high();
    else
      sda_low();
    i2c_delay();
    scl_high();
    i2c_delay();
    scl_low();
    i2c_delay();
    sda_low();
    i2c_delay();
  }
  i2c_delay();
  sda_input();
  i2c_delay();
  scl_high();
  i2c_delay();
  ra = sda_read();
  i2c_delay();
  scl_low();
  i2c_delay();
  sda_output();
  i2c_delay();
  return (ra);
}


x86 assembly (clang, -O0):
<i2c_write_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x80,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1204 <i2c_write_byte+0x84>
mov    $0x0,%al
call   1050 <i2c_delay@plt>
mov    -0x8(%rbp),%eax
and    -0x4(%rbp),%eax
cmp    $0x0,%eax
je     11be <i2c_write_byte+0x3e>
mov    $0x0,%al
call   1060 <sda_high@plt>
jmp    11c5 <i2c_write_byte+0x45>
mov    $0x0,%al
call   1080 <sda_low@plt>
mov    $0x0,%al
call   1050 <i2c_delay@plt>
mov    $0x0,%al
call   1030 <scl_high@plt>
mov    $0x0,%al
call   1050 <i2c_delay@plt>
mov    $0x0,%al
call   1090 <scl_low@plt>
mov    $0x0,%al
call   1050 <i2c_delay@plt>
mov    $0x0,%al
call   1080 <sda_low@plt>
mov    $0x0,%al
call   1050 <i2c_delay@plt>
mov    -0x8(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1192 <i2c_write_byte+0x12>
mov    $0x0,%al
call   1050 <i2c_delay@plt>
mov    $0x0,%al
call   10a0 <sda_input@plt>
mov    $0x0,%al
call   1050 <i2c_delay@plt>
mov    $0x0,%al
call   1030 <scl_high@plt>
mov    $0x0,%al
call   1050 <i2c_delay@plt>
mov    $0x0,%al
call   1040 <sda_read@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <i2c_delay@plt>
mov    $0x0,%al
call   1090 <scl_low@plt>
mov    $0x0,%al
call   1050 <i2c_delay@plt>
mov    $0x0,%al
call   1070 <sda_output@plt>
mov    $0x0,%al
call   1050 <i2c_delay@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i2c_write_byte>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
test   $0x80,%bl
jne    1198 <i2c_write_byte+0x18>
call   1080 <sda_low@plt>
jmp    119d <i2c_write_byte+0x1d>
call   1060 <sda_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1030 <scl_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1090 <scl_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1080 <sda_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
test   $0x40,%bl
jne    11e3 <i2c_write_byte+0x63>
call   1080 <sda_low@plt>
jmp    11e8 <i2c_write_byte+0x68>
call   1060 <sda_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1030 <scl_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1090 <scl_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1080 <sda_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
test   $0x20,%bl
jne    122e <i2c_write_byte+0xae>
call   1080 <sda_low@plt>
jmp    1233 <i2c_write_byte+0xb3>
call   1060 <sda_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1030 <scl_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1090 <scl_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1080 <sda_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
test   $0x10,%bl
jne    1279 <i2c_write_byte+0xf9>
call   1080 <sda_low@plt>
jmp    127e <i2c_write_byte+0xfe>
call   1060 <sda_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1030 <scl_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1090 <scl_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1080 <sda_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
test   $0x8,%bl
jne    12c4 <i2c_write_byte+0x144>
call   1080 <sda_low@plt>
jmp    12c9 <i2c_write_byte+0x149>
call   1060 <sda_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1030 <scl_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1090 <scl_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1080 <sda_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
test   $0x4,%bl
jne    130f <i2c_write_byte+0x18f>
call   1080 <sda_low@plt>
jmp    1314 <i2c_write_byte+0x194>
call   1060 <sda_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1030 <scl_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1090 <scl_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1080 <sda_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
test   $0x2,%bl
jne    135a <i2c_write_byte+0x1da>
call   1080 <sda_low@plt>
jmp    135f <i2c_write_byte+0x1df>
call   1060 <sda_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1030 <scl_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1090 <scl_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1080 <sda_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
test   $0x1,%bl
jne    13a5 <i2c_write_byte+0x225>
call   1080 <sda_low@plt>
jmp    13aa <i2c_write_byte+0x22a>
call   1060 <sda_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1030 <scl_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1090 <scl_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1080 <sda_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   10a0 <sda_input@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1030 <scl_high@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1040 <sda_read@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1090 <scl_low@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
xor    %eax,%eax
call   1070 <sda_output@plt>
xor    %eax,%eax
call   1050 <i2c_delay@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @i2c_write_byte(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 128, i32* %3
br label %4
4: ; preds = %25, %1
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %28
7: ; preds = %4
%8 = call i32 (...) @i2c_delay()
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = and i32 %9, %10
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = call i32 (...) @sda_high()
br label %17
15: ; preds = %7
%16 = call i32 (...) @sda_low()
br label %17
17: ; preds = %15, %13
%18 = call i32 (...) @i2c_delay()
%19 = call i32 (...) @scl_high()
%20 = call i32 (...) @i2c_delay()
%21 = call i32 (...) @scl_low()
%22 = call i32 (...) @i2c_delay()
%23 = call i32 (...) @sda_low()
%24 = call i32 (...) @i2c_delay()
br label %25
25: ; preds = %17
%26 = load i32, i32* %3
%27 = lshr i32 %26, 1
store i32 %27, i32* %3
br label %4
28: ; preds = %4
%29 = call i32 (...) @i2c_delay()
%30 = call i32 (...) @sda_input()
%31 = call i32 (...) @i2c_delay()
%32 = call i32 (...) @scl_high()
%33 = call i32 (...) @i2c_delay()
%34 = call i32 (...) @sda_read()
store i32 %34, i32* %3
%35 = call i32 (...) @i2c_delay()
%36 = call i32 (...) @scl_low()
%37 = call i32 (...) @i2c_delay()
%38 = call i32 (...) @sda_output()
%39 = call i32 (...) @i2c_delay()
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
define i32 @i2c_write_byte(i32 %0) {
%2 = tail call i32 (...) @i2c_delay()
%3 = and i32 %0, 128
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 (...) @sda_high()
br label %9
7: ; preds = %1
%8 = tail call i32 (...) @sda_low()
br label %9
9: ; preds = %7, %5
%10 = tail call i32 (...) @i2c_delay()
%11 = tail call i32 (...) @scl_high()
%12 = tail call i32 (...) @i2c_delay()
%13 = tail call i32 (...) @scl_low()
%14 = tail call i32 (...) @i2c_delay()
%15 = tail call i32 (...) @sda_low()
%16 = tail call i32 (...) @i2c_delay()
%17 = tail call i32 (...) @i2c_delay()
%18 = and i32 %0, 64
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %9
%21 = tail call i32 (...) @sda_high()
br label %24
22: ; preds = %9
%23 = tail call i32 (...) @sda_low()
br label %24
24: ; preds = %22, %20
%25 = tail call i32 (...) @i2c_delay()
%26 = tail call i32 (...) @scl_high()
%27 = tail call i32 (...) @i2c_delay()
%28 = tail call i32 (...) @scl_low()
%29 = tail call i32 (...) @i2c_delay()
%30 = tail call i32 (...) @sda_low()
%31 = tail call i32 (...) @i2c_delay()
%32 = tail call i32 (...) @i2c_delay()
%33 = and i32 %0, 32
%34 = icmp eq i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %24
%36 = tail call i32 (...) @sda_high()
br label %39
37: ; preds = %24
%38 = tail call i32 (...) @sda_low()
br label %39
39: ; preds = %37, %35
%40 = tail call i32 (...) @i2c_delay()
%41 = tail call i32 (...) @scl_high()
%42 = tail call i32 (...) @i2c_delay()
%43 = tail call i32 (...) @scl_low()
%44 = tail call i32 (...) @i2c_delay()
%45 = tail call i32 (...) @sda_low()
%46 = tail call i32 (...) @i2c_delay()
%47 = tail call i32 (...) @i2c_delay()
%48 = and i32 %0, 16
%49 = icmp eq i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %39
%51 = tail call i32 (...) @sda_high()
br label %54
52: ; preds = %39
%53 = tail call i32 (...) @sda_low()
br label %54
54: ; preds = %52, %50
%55 = tail call i32 (...) @i2c_delay()
%56 = tail call i32 (...) @scl_high()
%57 = tail call i32 (...) @i2c_delay()
%58 = tail call i32 (...) @scl_low()
%59 = tail call i32 (...) @i2c_delay()
%60 = tail call i32 (...) @sda_low()
%61 = tail call i32 (...) @i2c_delay()
%62 = tail call i32 (...) @i2c_delay()
%63 = and i32 %0, 8
%64 = icmp eq i32 %63, 0
br i1 %64, label %67, label %65
65: ; preds = %54
%66 = tail call i32 (...) @sda_high()
br label %69
67: ; preds = %54
%68 = tail call i32 (...) @sda_low()
br label %69
69: ; preds = %67, %65
%70 = tail call i32 (...) @i2c_delay()
%71 = tail call i32 (...) @scl_high()
%72 = tail call i32 (...) @i2c_delay()
%73 = tail call i32 (...) @scl_low()
%74 = tail call i32 (...) @i2c_delay()
%75 = tail call i32 (...) @sda_low()
%76 = tail call i32 (...) @i2c_delay()
%77 = tail call i32 (...) @i2c_delay()
%78 = and i32 %0, 4
%79 = icmp eq i32 %78, 0
br i1 %79, label %82, label %80
80: ; preds = %69
%81 = tail call i32 (...) @sda_high()
br label %84
82: ; preds = %69
%83 = tail call i32 (...) @sda_low()
br label %84
84: ; preds = %82, %80
%85 = tail call i32 (...) @i2c_delay()
%86 = tail call i32 (...) @scl_high()
%87 = tail call i32 (...) @i2c_delay()
%88 = tail call i32 (...) @scl_low()
%89 = tail call i32 (...) @i2c_delay()
%90 = tail call i32 (...) @sda_low()
%91 = tail call i32 (...) @i2c_delay()
%92 = tail call i32 (...) @i2c_delay()
%93 = and i32 %0, 2
%94 = icmp eq i32 %93, 0
br i1 %94, label %97, label %95
95: ; preds = %84
%96 = tail call i32 (...) @sda_high()
br label %99
97: ; preds = %84
%98 = tail call i32 (...) @sda_low()
br label %99
99: ; preds = %97, %95
%100 = tail call i32 (...) @i2c_delay()
%101 = tail call i32 (...) @scl_high()
%102 = tail call i32 (...) @i2c_delay()
%103 = tail call i32 (...) @scl_low()
%104 = tail call i32 (...) @i2c_delay()
%105 = tail call i32 (...) @sda_low()
%106 = tail call i32 (...) @i2c_delay()
%107 = tail call i32 (...) @i2c_delay()
%108 = and i32 %0, 1
%109 = icmp eq i32 %108, 0
br i1 %109, label %112, label %110
110: ; preds = %99
%111 = tail call i32 (...) @sda_high()
br label %114
112: ; preds = %99
%113 = tail call i32 (...) @sda_low()
br label %114
114: ; preds = %112, %110
%115 = tail call i32 (...) @i2c_delay()
%116 = tail call i32 (...) @scl_high()
%117 = tail call i32 (...) @i2c_delay()
%118 = tail call i32 (...) @scl_low()
%119 = tail call i32 (...) @i2c_delay()
%120 = tail call i32 (...) @sda_low()
%121 = tail call i32 (...) @i2c_delay()
%122 = tail call i32 (...) @i2c_delay()
%123 = tail call i32 (...) @sda_input()
%124 = tail call i32 (...) @i2c_delay()
%125 = tail call i32 (...) @scl_high()
%126 = tail call i32 (...) @i2c_delay()
%127 = tail call i32 (...) @sda_read()
%128 = tail call i32 (...) @i2c_delay()
%129 = tail call i32 (...) @scl_low()
%130 = tail call i32 (...) @i2c_delay()
%131 = tail call i32 (...) @sda_output()
%132 = tail call i32 (...) @i2c_delay()
ret i32 %127
}