#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 */
unsigned int I2CReadReg16(int, unsigned char, int);
int /*<<< orphan*/ I2CWriteReg8(int, unsigned char, int, unsigned char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
unsigned int ad7410Init(int fd, unsigned char i2cAddress) {
  unsigned int readData = 0;
  unsigned char writeData;
  unsigned int testFail = 0;
  printf("Configuring ADT7410\n");
  writeData = 0x00;
  I2CWriteReg8(fd, i2cAddress, 0x2f, writeData);
  sleep(1);
  writeData = 0x80;
  I2CWriteReg8(fd, i2cAddress, 0x03, writeData);
  readData = I2CReadReg16(fd, i2cAddress, 0x00);
  printf("ADT7410_TEMP = 0x%0x\n", readData);
  printf("Temp = %.2f C\n", readData * 0.0078f);
  if (testFail == 0)
    printf("--- ADT7410 Init Test passed\n");
  else
    printf("--- ADT7410 Init Test failed\n");
  printf("\n");
  return testFail;
}


x86 assembly (clang, -O0):
<ad7410Init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
mov    %al,-0x15(%rbp)
call   1030 <printf@plt>
movb   $0x0,-0xd(%rbp)
mov    -0x4(%rbp),%edi
movzbl -0x5(%rbp),%esi
movzbl -0xd(%rbp),%ecx
mov    $0x2f,%edx
call   1040 <I2CWriteReg8@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
movb   $0x80,-0xd(%rbp)
mov    -0x4(%rbp),%edi
movzbl -0x5(%rbp),%esi
movzbl -0xd(%rbp),%ecx
mov    $0x3,%edx
call   1040 <I2CWriteReg8@plt>
mov    -0x1c(%rbp),%edx
mov    -0x4(%rbp),%edi
movzbl -0x5(%rbp),%esi
call   1050 <I2CReadReg16@plt>
mov    %eax,%ecx
mov    -0x15(%rbp),%al
mov    %ecx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cvtsi2ss %rax,%xmm0
movss  0xe1b(%rip),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe3b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1218 <ad7410Init+0xd8>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1226 <ad7410Init+0xe6>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ad7410Init>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xebb(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x2f,%edx
xor    %ecx,%ecx
call   1060 <I2CWriteReg8@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x3,%edx
mov    $0x80,%ecx
call   1060 <I2CWriteReg8@plt>
mov    %ebp,%edi
mov    %ebx,%esi
xor    %edx,%edx
call   1070 <I2CReadReg16@plt>
mov    %eax,%ebx
lea    0xe50(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
cvtsi2ss %rax,%xmm0
mulss  0xe34(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe43(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe58(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Configuring ADT7410\0A\00"
@.str.1 = [22 x i8] c"ADT7410_TEMP = 0x%0x\0A\00"
@.str.2 = [15 x i8] c"Temp = %.2f C\0A\00"
@.str.3 = [30 x i8] c"--- ADT7410 Init Test passed\0A\00"
@.str.4 = [30 x i8] c"--- ADT7410 Init Test failed\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @ad7410Init(i32 %0, i8 zeroext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
store i32 %0, i32* %3
store i8 %1, i8* %4
store i32 0, i32* %5
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i8 0, i8* %6
%9 = load i32, i32* %3
%10 = load i8, i8* %4
%11 = load i8, i8* %6
%12 = call i32 @I2CWriteReg8(i32 %9, i8 zeroext %10, i32 47, i8 zeroext %11)
%13 = call i32 @sleep(i32 1)
store i8 -128, i8* %6
%14 = load i32, i32* %3
%15 = load i8, i8* %4
%16 = load i8, i8* %6
%17 = call i32 @I2CWriteReg8(i32 %14, i8 zeroext %15, i32 3, i8 zeroext %16)
%18 = load i32, i32* %3
%19 = load i8, i8* %4
%20 = call i32 @I2CReadReg16(i32 %18, i8 zeroext %19, i32 0)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %5
%24 = uitofp i32 %23 to float
%25 = fmul float %24, 0x3F7FF2E480000000
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %26)
%28 = load i32, i32* %7
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %34
32: ; preds = %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%36 = load i32, i32* %7
ret i32 %36
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"ADT7410_TEMP = 0x%0x\0A\00"
@.str.2 = [15 x i8] c"Temp = %.2f C\0A\00"
@str = [20 x i8] c"Configuring ADT7410\00"
@str.6 = [29 x i8] c"--- ADT7410 Init Test passed\00"
define i32 @ad7410Init(i32 %0, i8 zeroext %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @I2CWriteReg8(i32 %0, i8 zeroext %1, i32 47, i8 zeroext 0)
%5 = tail call i32 @sleep(i32 1)
%6 = tail call i32 @I2CWriteReg8(i32 %0, i8 zeroext %1, i32 3, i8 zeroext -128)
%7 = tail call i32 @I2CReadReg16(i32 %0, i8 zeroext %1, i32 0)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = uitofp i32 %7 to float
%10 = fmul float %9, 0x3F7FF2E480000000
%11 = fpext float %10 to double
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %11)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.6, i64 0, i64 0))
%14 = tail call i32 @putchar(i32 10)
ret i32 0
}