#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;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ sleep(double);
int /*<<< orphan*/ write(int, char *, int);
void main() {
  int file;
  char *bus = "/dev/i2c-1";
  float humidity;
  if ((file = open(bus, O_RDWR)) < 0) {
    printf("Failed to open the bus. \n");
    exit(1);
  }
  ioctl(file, I2C_SLAVE, 0x40);
  char config[1] = {0xF5};
  write(file, config, 1);
  sleep(0.3);
  char data[2] = {0};
  if (read(file, data, 2) != 2) {
    printf("Error : Input/output Error \n");
    exit(1);
  } else {
    humidity = (((data[0] * 256 + data[1]) * 125.0) / 65536.0) - 6;
  }
  config[0] = 0xF3;
  write(file, config, 1);
  sleep(0.3);
  if (read(file, data, 2) != 2) {
    printf("Error : Input/output Error \n");
    exit(1);
  } else {
    float cTemp = (((data[0] * 256 + data[1]) * 175.72) / 65536.0) - 46.85;
    float fTemp = cTemp * 1.8 + 32;
    printf("%.2f %.2f", cTemp, humidity);
    exit(0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jge    11c9 <main+0x49>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x4(%rbp),%edi
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
mov    $0x40,%edx
call   1060 <ioctl@plt>
mov    0xea7(%rip),%al
mov    %al,-0x15(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x15(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
movsd  0xdff(%rip),%xmm0
call   10a0 <sleep@plt>
lea    -0x17(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x17(%rbp),%rsi
mov    $0x2,%edx
call   1070 <read@plt>
cmp    $0x2,%eax
je     1248 <main+0xc8>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
movsbl -0x17(%rbp),%eax
shl    $0x8,%eax
movsbl -0x16(%rbp),%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xdb7(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xda3(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd8f(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movb   $0xf3,-0x15(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x15(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
movsd  0xd5d(%rip),%xmm0
call   10a0 <sleep@plt>
mov    -0x4(%rbp),%edi
lea    -0x17(%rbp),%rsi
mov    $0x2,%edx
call   1070 <read@plt>
cmp    $0x2,%eax
je     12da <main+0x15a>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
movsbl -0x17(%rbp),%eax
shl    $0x8,%eax
movsbl -0x16(%rbp),%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd45(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd11(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd25(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcf7(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xcf3(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd27(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
lea    0xe98(%rip),%rdi
call   1080 <open@plt>
test   %eax,%eax
jns    11ad <main+0x2d>
lea    0xeb9(%rip),%rdi
jmp    12ce <main+0x14e>
mov    %eax,%ebx
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    $0x40,%edx
call   1060 <ioctl@plt>
movb   $0xf5,0xd(%rsp)
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1040 <write@plt>
movsd  0xe1e(%rip),%xmm0
call   10a0 <sleep@plt>
movw   $0x0,0xe(%rsp)
lea    0xe(%rsp),%rsi
mov    %ebx,%edi
mov    $0x2,%edx
call   1070 <read@plt>
cmp    $0x2,%eax
jne    12c7 <main+0x147>
movsbl 0xe(%rsp),%ebp
movsbl 0xf(%rsp),%r14d
movb   $0xf3,0xd(%rsp)
lea    0xd(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1040 <write@plt>
movsd  0xdcf(%rip),%xmm0
call   10a0 <sleep@plt>
lea    0xe(%rsp),%rsi
mov    %ebx,%edi
mov    $0x2,%edx
call   1070 <read@plt>
cmp    $0x2,%eax
jne    12c7 <main+0x147>
shl    $0x8,%ebp
add    %r14d,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xda7(%rip),%xmm0
movsd  0xda7(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  0xda3(%rip),%xmm0
cvtsd2ss %xmm0,%xmm2
movsbl 0xe(%rsp),%eax
shl    $0x8,%eax
movsbl 0xf(%rsp),%ecx
add    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  0xd89(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xd85(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
lea    0xd82(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xd77(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"/dev/i2c-1\00"
@O_RDWR = global i32 0
@.str.1 = [26 x i8] c"Failed to open the bus. \0A\00"
@I2C_SLAVE = global i32 0
@__const.main.config = [1 x i8] c"\F5"
@.str.2 = [29 x i8] c"Error : Input/output Error \0A\00"
@.str.3 = [10 x i8] c"%.2f %.2f\00"
define void @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca float
%4 = alloca [1 x i8]
%5 = alloca [2 x i8]
%6 = alloca float
%7 = alloca float
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
%8 = load i8*, i8** %2
%9 = load i32, i32* @O_RDWR
%10 = call i32 @open(i8* %8, i32 %9)
store i32 %10, i32* %1
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
%16 = load i32, i32* %1
%17 = load i32, i32* @I2C_SLAVE
%18 = call i32 @ioctl(i32 %16, i32 %17, i32 64)
%19 = bitcast [1 x i8]* %4 to i8*
%20 = load i32, i32* %1
%21 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%22 = call i32 @write(i32 %20, i8* %21, i32 1)
%23 = call i32 @sleep(double 3.000000e-01)
%24 = bitcast [2 x i8]* %5 to i8*
%25 = load i32, i32* %1
%26 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%27 = call i32 @read(i32 %25, i8* %26, i32 2)
%28 = icmp ne i32 %27, 2
br i1 %28, label %29, label %32
29: ; preds = %15
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %15
%33 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = mul nsw i32 %35, 256
%37 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = add nsw i32 %36, %39
%41 = sitofp i32 %40 to double
%42 = fmul double %41, 1.250000e+02
%43 = fdiv double %42, 6.553600e+04
%44 = fsub double %43, 6.000000e+00
%45 = fptrunc double %44 to float
store float %45, float* %3
br label %46
46: ; preds = %32
%47 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
store i8 -13, i8* %47
%48 = load i32, i32* %1
%49 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%50 = call i32 @write(i32 %48, i8* %49, i32 1)
%51 = call i32 @sleep(double 3.000000e-01)
%52 = load i32, i32* %1
%53 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%54 = call i32 @read(i32 %52, i8* %53, i32 2)
%55 = icmp ne i32 %54, 2
br i1 %55, label %56, label %59
56: ; preds = %46
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %46
%60 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = mul nsw i32 %62, 256
%64 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = add nsw i32 %63, %66
%68 = sitofp i32 %67 to double
%69 = fmul double %68, 1.757200e+02
%70 = fdiv double %69, 6.553600e+04
%71 = fsub double %70, 4.685000e+01
%72 = fptrunc double %71 to float
store float %72, float* %6
%73 = load float, float* %6
%74 = fpext float %73 to double
%75 = call double @llvm.fmuladd.f64(double %74, double 1.800000e+00, double 3.200000e+01)
%76 = fptrunc double %75 to float
store float %76, float* %7
%77 = load float, float* %6
%78 = fpext float %77 to double
%79 = load float, float* %3
%80 = fpext float %79 to double
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), double %78, double %80)
%82 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-1\00"
@O_RDWR = global i32 0
@I2C_SLAVE = global i32 0
@.str.3 = [10 x i8] c"%.2f %.2f\00"
@str.4 = [28 x i8] c"Error : Input/output Error \00"
@str.5 = [25 x i8] c"Failed to open the bus. \00"
define void @main() {
%1 = alloca [1 x i8]
%2 = alloca i16
%3 = bitcast i16* %2 to [2 x i8]*
%4 = load i32, i32* @O_RDWR
%5 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = load i32, i32* @I2C_SLAVE
%12 = tail call i32 @ioctl(i32 %5, i32 %11, i32 64)
%13 = getelementptr inbounds [1 x i8], [1 x i8]* %1, i64 0, i64 0
store i8 -11, i8* %13
%14 = call i32 @write(i32 %5, i8* %13, i32 1)
%15 = tail call i32 @sleep(double 3.000000e-01)
%16 = bitcast i16* %2 to i8*
store i16 0, i16* %2
%17 = call i32 @read(i32 %5, i8* %16, i32 2)
%18 = icmp eq i32 %17, 2
br i1 %18, label %22, label %19
19: ; preds = %10
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %10
%23 = load i8, i8* %16
%24 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
%25 = load i8, i8* %24
store i8 -13, i8* %13
%26 = call i32 @write(i32 %5, i8* %13, i32 1)
%27 = tail call i32 @sleep(double 3.000000e-01)
%28 = call i32 @read(i32 %5, i8* %16, i32 2)
%29 = icmp eq i32 %28, 2
br i1 %29, label %33, label %30
30: ; preds = %22
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0))
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %22
%34 = sext i8 %23 to i32
%35 = shl nsw i32 %34, 8
%36 = sext i8 %25 to i32
%37 = add nsw i32 %35, %36
%38 = sitofp i32 %37 to double
%39 = fmul double %38, 1.250000e+02
%40 = fmul double %39, 0x3EF0000000000000
%41 = fadd double %40, -6.000000e+00
%42 = fptrunc double %41 to float
%43 = load i8, i8* %16
%44 = sext i8 %43 to i32
%45 = shl nsw i32 %44, 8
%46 = load i8, i8* %24
%47 = sext i8 %46 to i32
%48 = add nsw i32 %45, %47
%49 = sitofp i32 %48 to double
%50 = fmul double %49, 1.757200e+02
%51 = fmul double %50, 0x3EF0000000000000
%52 = fadd double %51, -4.685000e+01
%53 = fptrunc double %52 to float
%54 = fpext float %53 to double
%55 = fpext float %42 to double
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), double %54, double %55)
%57 = tail call i32 @exit(i32 0)
unreachable
}