#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 i2c_read_status();
int /*<<< orphan*/ i2c_write_command(int);
int /*<<< orphan*/ i2c_write_tx_data(int);
int i2c_write_data_command(int data, int command) {
  int t, sr;
  i2c_write_tx_data(data);
  i2c_write_command(command);
  sr = i2c_read_status();
  if ((sr & 0x02) == 0) {
  }
  for (t = 100 * 1250; (t > 0) && ((sr & 0x02) != 0); t--)
    sr = i2c_read_status();
  return sr;
}


x86 assembly (clang, -O0):
<i2c_write_data_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <i2c_write_tx_data@plt>
mov    -0x8(%rbp),%edi
call   1030 <i2c_write_command@plt>
mov    $0x0,%al
call   1050 <i2c_read_status@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
jne    116c <i2c_write_data_command+0x3c>
jmp    116c <i2c_write_data_command+0x3c>
movl   $0x1e848,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x11(%rbp)
jle    1191 <i2c_write_data_command+0x61>
mov    -0x10(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11a1 <i2c_write_data_command+0x71>
jmp    11b9 <i2c_write_data_command+0x89>
mov    $0x0,%al
call   1050 <i2c_read_status@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1173 <i2c_write_data_command+0x43>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i2c_write_data_command>:
push   %rbx
mov    %esi,%ebx
call   1040 <i2c_write_tx_data@plt>
mov    %ebx,%edi
call   1030 <i2c_write_command@plt>
xor    %eax,%eax
call   1050 <i2c_read_status@plt>
test   $0x2,%al
je     1166 <i2c_write_data_command+0x36>
mov    $0x1e848,%ebx
nop
xor    %eax,%eax
call   1050 <i2c_read_status@plt>
cmp    $0x2,%ebx
jb     1166 <i2c_write_data_command+0x36>
add    $0xffffffff,%ebx
mov    %eax,%ecx
and    $0x2,%ecx
jne    1150 <i2c_write_data_command+0x20>
pop    %rbx
ret

LLVM IR (-O0):
define i32 @i2c_write_data_command(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = call i32 @i2c_write_tx_data(i32 %7)
%9 = load i32, i32* %4
%10 = call i32 @i2c_write_command(i32 %9)
%11 = call i32 (...) @i2c_read_status()
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = and i32 %12, 2
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %2
br label %16
16: ; preds = %15, %2
store i32 125000, i32* %5
br label %17
17: ; preds = %28, %16
%18 = load i32, i32* %5
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %6
%22 = and i32 %21, 2
%23 = icmp ne i32 %22, 0
br label %24
24: ; preds = %20, %17
%25 = phi i1 [ false, %17 ], [ %23, %20 ]
br i1 %25, label %26, label %31
26: ; preds = %24
%27 = call i32 (...) @i2c_read_status()
store i32 %27, i32* %6
br label %28
28: ; preds = %26
%29 = load i32, i32* %5
%30 = add nsw i32 %29, -1
store i32 %30, i32* %5
br label %17
31: ; preds = %24
%32 = load i32, i32* %6
ret i32 %32
}

LLVM IR (-O2):
define i32 @i2c_write_data_command(i32 %0, i32 %1) {
%3 = tail call i32 @i2c_write_tx_data(i32 %0)
%4 = tail call i32 @i2c_write_command(i32 %1)
%5 = tail call i32 (...) @i2c_read_status()
%6 = and i32 %5, 2
%7 = icmp eq i32 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %2, %8
%9 = phi i32 [ %11, %8 ], [ 125000, %2 ]
%10 = tail call i32 (...) @i2c_read_status()
%11 = add nsw i32 %9, -1
%12 = icmp ugt i32 %9, 1
%13 = and i32 %10, 2
%14 = icmp ne i32 %13, 0
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %8, label %16
16: ; preds = %8, %2
%17 = phi i32 [ %5, %2 ], [ %10, %8 ]
ret i32 %17
}