#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_smbus_write_byte_data(int, int, unsigned char);
int /*<<< orphan*/ usleep(int);
int lps331_write_reg(int fd, int addr, unsigned char byte) {
  int i, res;
  for (i = 0; i < 10; i++) {
    res = i2c_smbus_write_byte_data(fd, addr, byte);
    if (res >= 0 || i == 10 - 1)
      break;
    usleep(10 * 1000);
  }
  return res;
}


x86 assembly (clang, -O0):
<lps331_write_reg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    1187 <lps331_write_reg+0x67>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
movzbl -0x9(%rbp),%edx
call   1030 <i2c_smbus_write_byte_data@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    116a <lps331_write_reg+0x4a>
cmpl   $0x9,-0x10(%rbp)
jne    116f <lps331_write_reg+0x4f>
jmp    1187 <lps331_write_reg+0x67>
mov    $0x2710,%edi
call   1040 <usleep@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113a <lps331_write_reg+0x1a>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lps331_write_reg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%r15d
call   1030 <i2c_smbus_write_byte_data@plt>
test   %eax,%eax
jns    1165 <lps331_write_reg+0x45>
mov    $0x8,%ebp
movzbl %bl,%ebx
mov    $0x2710,%edi
call   1040 <usleep@plt>
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1030 <i2c_smbus_write_byte_data@plt>
sub    $0x1,%ebp
setb   %cl
test   %eax,%eax
jns    1165 <lps331_write_reg+0x45>
test   %cl,%cl
je     1140 <lps331_write_reg+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @lps331_write_reg(i32 %0, i32 %1, i8 zeroext %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8 %2, i8* %6
store i32 0, i32* %7
br label %9
9: ; preds = %25, %3
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = load i8, i8* %6
%16 = call i32 @i2c_smbus_write_byte_data(i32 %13, i32 %14, i8 zeroext %15)
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = icmp sge i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %12
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 9
br i1 %21, label %22, label %23
22: ; preds = %19, %12
br label %28
23: ; preds = %19
%24 = call i32 @usleep(i32 10000)
br label %25
25: ; preds = %23
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %9
28: ; preds = %22, %9
%29 = load i32, i32* %8
ret i32 %29
}

LLVM IR (-O2):
define i32 @lps331_write_reg(i32 %0, i32 %1, i8 zeroext %2) {
%4 = tail call i32 @i2c_smbus_write_byte_data(i32 %0, i32 %1, i8 zeroext %2)
%5 = icmp sgt i32 %4, -1
br i1 %5, label %14, label %6
6: ; preds = %3, %6
%7 = phi i32 [ %9, %6 ], [ 0, %3 ]
%8 = tail call i32 @usleep(i32 10000)
%9 = add nuw nsw i32 %7, 1
%10 = tail call i32 @i2c_smbus_write_byte_data(i32 %0, i32 %1, i8 zeroext %2)
%11 = icmp sgt i32 %10, -1
%12 = icmp eq i32 %9, 9
%13 = select i1 %11, i1 true, i1 %12
br i1 %13, label %14, label %6
14: ; preds = %6, %3
%15 = phi i32 [ %4, %3 ], [ %10, %6 ]
ret i32 %15
}