#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 */
typedef int time_t;

/* Variables and functions */
int hdc1000_init(char *, int);
int hdc1000_read(float *, float *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, float, float, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ time(int *);
int main() {
  float humidity, temp;
  time_t t;
  int r;
  r = hdc1000_init("/dev/i2c-1", 0x43);
  if (r != 0) {
    perror("cannot initialize i2c device: ");
    return -1;
  }
  while (1) {
    time(&t);
    r = hdc1000_read(&humidity, &temp);
    printf("%d: %.4f%% %.4fC (err=%d)\n", t, humidity, temp, r);
    sleep(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x43,%esi
call   1080 <hdc1000_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11a4 <main+0x44>
lea    0xe77(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbp
ret
jmp    11a9 <main+0x49>
lea    -0x10(%rbp),%rdi
call   1040 <time@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <hdc1000_read@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%esi
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
mov    -0x14(%rbp),%edx
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
jmp    11a9 <main+0x49>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8e(%rip),%rdi
mov    $0x43,%esi
call   1080 <hdc1000_init@plt>
test   %eax,%eax
jne    11d9 <main+0x79>
lea    0xc(%rsp),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe94(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <time@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <hdc1000_read@plt>
mov    0xc(%rsp),%esi
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
jmp    11a0 <main+0x40>
lea    0xe2b(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"/dev/i2c-1\00"
@.str.1 = [31 x i8] c"cannot initialize i2c device: \00"
@.str.2 = [27 x i8] c"%d: %.4f%% %.4fC (err=%d)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @hdc1000_init(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 67)
store i32 %6, i32* %5
%7 = load i32, i32* %5
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
ret i32 -1
11: ; preds = %0
br label %12
12: ; preds = %11, %12
%13 = call i32 @time(i32* %4)
%14 = call i32 @hdc1000_read(float* %2, float* %3)
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = load float, float* %2
%17 = load float, float* %3
%18 = load i32, i32* %5
%19 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %15, float %16, float %17, i32 %18)
%20 = call i32 @sleep(i32 1)
br label %12
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-1\00"
@.str.1 = [31 x i8] c"cannot initialize i2c device: \00"
@.str.2 = [27 x i8] c"%d: %.4f%% %.4fC (err=%d)\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca i32
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @hdc1000_init(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 67)
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
ret i32 -1
11: ; preds = %0, %11
%12 = call i32 @time(i32* %3)
%13 = call i32 @hdc1000_read(float* %1, float* %2)
%14 = load i32, i32* %3
%15 = load float, float* %1
%16 = load float, float* %2
%17 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %14, float %15, float %16, i32 %13)
%18 = call i32 @sleep(i32 1)
br label %11
}