#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 */
scalar_t__ exp_close();
int exp_open();
scalar_t__ printf(char *, double);
int read_board_temp();
int read_board_version();
int read_humidity();
double read_pressure();
double read_sensor_temp(int);
int print_summary() {
  int r = exp_open();
  r += printf("Board Version:\t\t%d\n", read_board_version());
  r += printf("Board Pressure:\t\t%.1f kPa\n", read_pressure());
  r += printf("Board Humidity:\t\t%d %%\n", read_humidity());
  r += printf("Board Temperature:\t%d C\n", read_board_temp());
  r += printf("Room Temperature:\t%.1f C\n", read_sensor_temp(1));
  r += printf("Outdoor Temperature:\t%.1f C\n", read_sensor_temp(2));
  r += exp_close();
  return r;
}


x86 assembly (clang, -O0):
<print_summary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <exp_open@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1060 <read_board_version@plt>
cvtsi2sd %eax,%xmm0
lea    0xe5c(%rip),%rdi
call   1070 <printf@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1080 <read_pressure@plt>
lea    0xe50(%rip),%rdi
call   1070 <printf@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1090 <read_humidity@plt>
cvtsi2sd %eax,%xmm0
lea    0xe47(%rip),%rdi
call   1070 <printf@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   10a0 <read_board_temp@plt>
cvtsi2sd %eax,%xmm0
lea    0xe3b(%rip),%rdi
call   1070 <printf@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    $0x1,%edi
call   1040 <read_sensor_temp@plt>
lea    0xe31(%rip),%rdi
call   1070 <printf@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    $0x2,%edi
call   1040 <read_sensor_temp@plt>
lea    0xe28(%rip),%rdi
call   1070 <printf@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1050 <exp_close@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_summary>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <exp_open@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <read_board_version@plt>
cvtsi2sd %eax,%xmm0
lea    0xe62(%rip),%rdi
call   1070 <printf@plt>
mov    %rax,%rbx
add    %ebp,%ebx
xor    %eax,%eax
call   1080 <read_pressure@plt>
lea    0xe5e(%rip),%rdi
call   1070 <printf@plt>
mov    %rax,%rbp
add    %ebx,%ebp
xor    %eax,%eax
call   1090 <read_humidity@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xe5a(%rip),%rdi
call   1070 <printf@plt>
mov    %rax,%rbx
add    %ebp,%ebx
xor    %eax,%eax
call   10a0 <read_board_temp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xe53(%rip),%rdi
call   1070 <printf@plt>
mov    %rax,%rbp
add    %ebx,%ebp
mov    $0x1,%edi
call   1040 <read_sensor_temp@plt>
lea    0xe51(%rip),%rdi
call   1070 <printf@plt>
mov    %rax,%rbx
add    %ebp,%ebx
mov    $0x2,%edi
call   1040 <read_sensor_temp@plt>
lea    0xe50(%rip),%rdi
call   1070 <printf@plt>
mov    %rax,%rbp
add    %ebx,%ebp
xor    %eax,%eax
call   1050 <exp_close@plt>
add    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Board Version:\09\09%d\0A\00"
@.str.1 = [27 x i8] c"Board Pressure:\09\09%.1f kPa\0A\00"
@.str.2 = [24 x i8] c"Board Humidity:\09\09%d %%\0A\00"
@.str.3 = [25 x i8] c"Board Temperature:\09%d C\0A\00"
@.str.4 = [26 x i8] c"Room Temperature:\09%.1f C\0A\00"
@.str.5 = [29 x i8] c"Outdoor Temperature:\09%.1f C\0A\00"
define i32 @print_summary() {
%1 = alloca i32
%2 = call i32 (...) @exp_open()
store i32 %2, i32* %1
%3 = call i32 (...) @read_board_version()
%4 = sitofp i32 %3 to double
%5 = call i64 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %4)
%6 = load i32, i32* %1
%7 = sext i32 %6 to i64
%8 = add nsw i64 %7, %5
%9 = trunc i64 %8 to i32
store i32 %9, i32* %1
%10 = call double (...) @read_pressure()
%11 = call i64 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), double %10)
%12 = load i32, i32* %1
%13 = sext i32 %12 to i64
%14 = add nsw i64 %13, %11
%15 = trunc i64 %14 to i32
store i32 %15, i32* %1
%16 = call i32 (...) @read_humidity()
%17 = sitofp i32 %16 to double
%18 = call i64 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), double %17)
%19 = load i32, i32* %1
%20 = sext i32 %19 to i64
%21 = add nsw i64 %20, %18
%22 = trunc i64 %21 to i32
store i32 %22, i32* %1
%23 = call i32 (...) @read_board_temp()
%24 = sitofp i32 %23 to double
%25 = call i64 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %24)
%26 = load i32, i32* %1
%27 = sext i32 %26 to i64
%28 = add nsw i64 %27, %25
%29 = trunc i64 %28 to i32
store i32 %29, i32* %1
%30 = call double @read_sensor_temp(i32 1)
%31 = call i64 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), double %30)
%32 = load i32, i32* %1
%33 = sext i32 %32 to i64
%34 = add nsw i64 %33, %31
%35 = trunc i64 %34 to i32
store i32 %35, i32* %1
%36 = call double @read_sensor_temp(i32 2)
%37 = call i64 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), double %36)
%38 = load i32, i32* %1
%39 = sext i32 %38 to i64
%40 = add nsw i64 %39, %37
%41 = trunc i64 %40 to i32
store i32 %41, i32* %1
%42 = call i64 (...) @exp_close()
%43 = load i32, i32* %1
%44 = sext i32 %43 to i64
%45 = add nsw i64 %44, %42
%46 = trunc i64 %45 to i32
store i32 %46, i32* %1
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str = [20 x i8] c"Board Version:\09\09%d\0A\00"
@.str.1 = [27 x i8] c"Board Pressure:\09\09%.1f kPa\0A\00"
@.str.2 = [24 x i8] c"Board Humidity:\09\09%d %%\0A\00"
@.str.3 = [25 x i8] c"Board Temperature:\09%d C\0A\00"
@.str.4 = [26 x i8] c"Room Temperature:\09%.1f C\0A\00"
@.str.5 = [29 x i8] c"Outdoor Temperature:\09%.1f C\0A\00"
define i32 @print_summary() {
%1 = tail call i32 (...) @exp_open()
%2 = tail call i32 (...) @read_board_version()
%3 = sitofp i32 %2 to double
%4 = tail call i64 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %3)
%5 = trunc i64 %4 to i32
%6 = add i32 %1, %5
%7 = tail call double (...) @read_pressure()
%8 = tail call i64 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), double %7)
%9 = trunc i64 %8 to i32
%10 = add i32 %6, %9
%11 = tail call i32 (...) @read_humidity()
%12 = sitofp i32 %11 to double
%13 = tail call i64 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), double %12)
%14 = trunc i64 %13 to i32
%15 = add i32 %10, %14
%16 = tail call i32 (...) @read_board_temp()
%17 = sitofp i32 %16 to double
%18 = tail call i64 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %17)
%19 = trunc i64 %18 to i32
%20 = add i32 %15, %19
%21 = tail call double @read_sensor_temp(i32 1)
%22 = tail call i64 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), double %21)
%23 = trunc i64 %22 to i32
%24 = add i32 %20, %23
%25 = tail call double @read_sensor_temp(i32 2)
%26 = tail call i64 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), double %25)
%27 = trunc i64 %26 to i32
%28 = add i32 %24, %27
%29 = tail call i64 (...) @exp_close()
%30 = trunc i64 %29 to i32
%31 = add i32 %28, %30
ret i32 %31
}