#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_close(int);
int I2C_open(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
float getRH(int);
float getTemp(int);
int /*<<< orphan*/ printf(char *, float);
int main() {
  int i2c_fd;
  float temp, rh;
  i2c_fd = I2C_open(1);
  if (i2c_fd < 0) {
    printf("*Could not open I2C bus %d\n", 1);
    exit(0);
  }
  temp = getTemp(i2c_fd);
  rh = getRH(i2c_fd);
  printf("Temp : %5.2fC\n", temp);
  printf("RH   : %5.2f%%\n", rh);
  I2C_close(i2c_fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
call   1070 <I2C_open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11a1 <main+0x41>
lea    0xe77(%rip),%rdi
movss  0xe6b(%rip),%xmm0
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%edi
call   1030 <getTemp@plt>
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <getRH@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
movss  -0x10(%rbp),%xmm0
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1060 <I2C_close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%edi
call   1070 <I2C_open@plt>
test   %eax,%eax
js     11c2 <main+0x62>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <getTemp@plt>
movss  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1050 <getRH@plt>
movss  %xmm0,0xc(%rsp)
lea    0xe8a(%rip),%rdi
movss  0x8(%rsp),%xmm0
call   1040 <printf@plt>
lea    0xe87(%rip),%rdi
movss  0xc(%rsp),%xmm0
call   1040 <printf@plt>
mov    %ebx,%edi
call   1060 <I2C_close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe3b(%rip),%rdi
movss  0xe2f(%rip),%xmm0
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"*Could not open I2C bus %d\0A\00"
@.str.1 = [15 x i8] c"Temp : %5.2fC\0A\00"
@.str.2 = [16 x i8] c"RH : %5.2f%%\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
%5 = call i32 @I2C_open(i32 1)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), float 1.000000e+00)
%10 = call i32 @exit(i32 0)
unreachable
11: ; preds = %0
%12 = load i32, i32* %2
%13 = call float @getTemp(i32 %12)
store float %13, float* %3
%14 = load i32, i32* %2
%15 = call float @getRH(i32 %14)
store float %15, float* %4
%16 = load float, float* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), float %16)
%18 = load float, float* %4
%19 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), float %18)
%20 = load i32, i32* %2
%21 = call i32 @I2C_close(i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"*Could not open I2C bus %d\0A\00"
@.str.1 = [15 x i8] c"Temp : %5.2fC\0A\00"
@.str.2 = [16 x i8] c"RH : %5.2f%%\0A\00"
define i32 @main() {
%1 = tail call i32 @I2C_open(i32 1)
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), float 1.000000e+00)
%5 = tail call i32 @exit(i32 0)
unreachable
6: ; preds = %0
%7 = tail call float @getTemp(i32 %1)
%8 = tail call float @getRH(i32 %1)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), float %7)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), float %8)
%11 = tail call i32 @I2C_close(i32 %1)
ret i32 0
}