#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 uint8_t;
typedef double uint16_t;
typedef double int16_t;

/* Variables and functions */
scalar_t__ SHT21_Cleanup();
int /*<<< orphan*/ SHT21_Init(int, int);
int SHT21_Read(double *, double *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int16_t temperature;
  uint16_t humidity;
  uint8_t err;
  SHT21_Init(24, 25);
  err = SHT21_Read(&temperature, &humidity);
  if (SHT21_Cleanup() != 0) {
    printf("ERROR during SHT cleanup\n");
    return -1;
  }
  if (err == 0) {
    printf("T=%.1fC\tH=%.1f%%\n", temperature / 10.0, humidity / 10.0);
  } else {
    printf("ERROR 0x%X reading sensor\n", err);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x18,%edi
mov    $0x19,%esi
call   1040 <SHT21_Init@plt>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <SHT21_Read@plt>
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1060 <SHT21_Cleanup@plt>
cmp    $0x0,%rax
je     11a0 <main+0x60>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f7 <main+0xb7>
cmpl   $0x0,-0x24(%rbp)
jne    11df <main+0x9f>
movsd  -0x18(%rbp),%xmm0
movsd  0xe49(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe38(%rip),%xmm2
divsd  %xmm2,%xmm1
lea    0xe4f(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    11f0 <main+0xb0>
mov    -0x24(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    $0x18,%edi
mov    $0x19,%esi
call   1050 <SHT21_Init@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1060 <SHT21_Read@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <SHT21_Cleanup@plt>
test   %rax,%rax
je     1195 <main+0x45>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebp
jmp    11d9 <main+0x89>
test   %ebx,%ebx
je     11ad <main+0x5d>
lea    0xe7a(%rip),%rdi
xor    %ebp,%ebp
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d9 <main+0x89>
movsd  0x10(%rsp),%xmm0
movsd  0xe45(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm2,%xmm1
lea    0xe38(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"ERROR during SHT cleanup\0A\00"
@.str.1 = [18 x i8] c"T=%.1fC\09H=%.1f%%\0A\00"
@.str.2 = [27 x i8] c"ERROR 0x%X reading sensor\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @SHT21_Init(i32 24, i32 25)
%10 = call i32 @SHT21_Read(double* %6, double* %7)
store i32 %10, i32* %8
%11 = call i64 (...) @SHT21_Cleanup()
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %28
15: ; preds = %2
%16 = load i32, i32* %8
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load double, double* %6
%20 = fdiv double %19, 1.000000e+01
%21 = load double, double* %7
%22 = fdiv double %21, 1.000000e+01
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), double %20, double %22)
br label %27
24: ; preds = %15
%25 = load i32, i32* %8
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %18
store i32 0, i32* %3
br label %28
28: ; preds = %27, %13
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"T=%.1fC\09H=%.1f%%\0A\00"
@.str.2 = [27 x i8] c"ERROR 0x%X reading sensor\0A\00"
@str = [25 x i8] c"ERROR during SHT cleanup\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = tail call i32 @SHT21_Init(i32 24, i32 25)
%8 = call i32 @SHT21_Read(double* %3, double* %4)
%9 = call i64 (...) @SHT21_Cleanup()
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %23
13: ; preds = %2
%14 = icmp eq i32 %8, 0
br i1 %14, label %15, label %21
15: ; preds = %13
%16 = load double, double* %3
%17 = fdiv double %16, 1.000000e+01
%18 = load double, double* %4
%19 = fdiv double %18, 1.000000e+01
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), double %17, double %19)
br label %23
21: ; preds = %13
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %8)
br label %23
23: ; preds = %15, %21, %11
%24 = phi i32 [ -1, %11 ], [ 0, %21 ], [ 0, %15 ]
ret i32 %24
}