#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_SLAVE;
scalar_t__ i2c_smbus_write_byte(int const, int);
scalar_t__ i2c_smbus_write_byte_data(int const, int, int);
scalar_t__ ioctl(int const, int /*<<< orphan*/, int const);
int /*<<< orphan*/ usleep(int);
int init_adt74x0(const int file, const int addr) {
  if (ioctl(file, I2C_SLAVE, addr) < 0)
    return -1;
  if (i2c_smbus_write_byte(file, 0x2f) < 0)
    return -2;
  usleep(250);
  if (i2c_smbus_write_byte_data(file, 0x03, 0x80) < 0)
    return -5;
  return 0;
}


x86 assembly (clang, -O0):
<init_adt74x0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
mov    -0xc(%rbp),%edx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    1178 <init_adt74x0+0x38>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d4 <init_adt74x0+0x94>
mov    -0x8(%rbp),%edi
mov    $0x2f,%esi
call   1040 <i2c_smbus_write_byte@plt>
cmp    $0x0,%rax
jge    119b <init_adt74x0+0x5b>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11d4 <init_adt74x0+0x94>
mov    $0xfa,%edi
call   1060 <usleep@plt>
mov    -0x8(%rbp),%edi
mov    $0x3,%esi
mov    $0x80,%edx
call   1050 <i2c_smbus_write_byte_data@plt>
cmp    $0x0,%rax
jge    11cd <init_adt74x0+0x8d>
movl   $0xfffffffb,-0x4(%rbp)
jmp    11d4 <init_adt74x0+0x94>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_adt74x0>:
push   %rbx
mov    %esi,%edx
mov    %edi,%ebx
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
call   1030 <ioctl@plt>
test   %rax,%rax
js     118d <init_adt74x0+0x4d>
mov    %ebx,%edi
mov    $0x2f,%esi
call   1040 <i2c_smbus_write_byte@plt>
test   %rax,%rax
js     1194 <init_adt74x0+0x54>
mov    $0xfa,%edi
call   1060 <usleep@plt>
mov    %ebx,%edi
mov    $0x3,%esi
mov    $0x80,%edx
call   1050 <i2c_smbus_write_byte_data@plt>
sar    $0x3f,%rax
and    $0xfffffffb,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret
mov    $0xfffffffe,%eax
pop    %rbx
ret

LLVM IR (-O0):
@I2C_SLAVE = global i32 0
define i32 @init_adt74x0(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = load i32, i32* @I2C_SLAVE
%8 = load i32, i32* %5
%9 = call i64 @ioctl(i32 %6, i32 %7, i32 %8)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %24
12: ; preds = %2
%13 = load i32, i32* %4
%14 = call i64 @i2c_smbus_write_byte(i32 %13, i32 47)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 -2, i32* %3
br label %24
17: ; preds = %12
%18 = call i32 @usleep(i32 250)
%19 = load i32, i32* %4
%20 = call i64 @i2c_smbus_write_byte_data(i32 %19, i32 3, i32 128)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 -5, i32* %3
br label %24
23: ; preds = %17
store i32 0, i32* %3
br label %24
24: ; preds = %23, %22, %16, %11
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@I2C_SLAVE = global i32 0
define i32 @init_adt74x0(i32 %0, i32 %1) {
%3 = load i32, i32* @I2C_SLAVE
%4 = tail call i64 @ioctl(i32 %0, i32 %3, i32 %1)
%5 = icmp slt i64 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = tail call i64 @i2c_smbus_write_byte(i32 %0, i32 47)
%8 = icmp slt i64 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = tail call i32 @usleep(i32 250)
%11 = tail call i64 @i2c_smbus_write_byte_data(i32 %0, i32 3, i32 128)
%12 = icmp slt i64 %11, 0
%13 = select i1 %12, i32 -5, i32 0
br label %14
14: ; preds = %9, %6, %2
%15 = phi i32 [ -1, %2 ], [ -2, %6 ], [ %13, %9 ]
ret i32 %15
}