#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 bmp_Calibration(int);
int bmp_GetPressure(int, double *);
int bmp_GetTemperature(int, double *);
double bmp_altitude(double);
double bmp_qnh(double, int);
int /*<<< orphan*/ close(int);
int i2c_Open(char *);
double ppl_DensityAlt(double, double);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int fd;
  double temperature, pressure;
  double PAlt;
  fd = i2c_Open("/dev/i2c-1");
  printf("\nCalibration:%i (0= worked)\n", bmp_Calibration(fd));
  printf("Return:%i\tTemperature\t:%.1f C\n",
         bmp_GetTemperature(fd, &temperature), temperature);
  printf(
      "Return:%i\tPressure\t:%.2f hPa/mB\tThis is known as station pressure\n",
      bmp_GetPressure(fd, &pressure), pressure);
  PAlt = bmp_altitude(pressure);
  printf("\t\tP.Altitude\t:%.0f ft\tThis is known as a Pressure Altitude\n",
         PAlt);
  printf("\t\tQNH\t\t:%.2f hPa/mB\tSetting required on an Aircraft\n",
         bmp_qnh(pressure, 5085));
  printf(
      "\t\t\t\t\t\taltimeter for it to read Elevation while on the ground\n");
  printf("\t\t\t\t\t\tand Altitude while in the air\n");
  printf("\t\t\t\t\t\tSensor Elevation MUST BE KNOWN ACCURATELY\n");
  printf("\t\tD.Altitude\t:%.0f ft\tThis is known as a density Altitude\n\n",
         ppl_DensityAlt(PAlt, temperature));
  close(fd);
  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)
lea    0xe53(%rip),%rdi
call   1080 <i2c_Open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <bmp_Calibration@plt>
mov    %eax,%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   10b0 <bmp_GetTemperature@plt>
mov    %eax,%esi
movsd  -0x20(%rbp),%xmm0
lea    0xe41(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   1050 <bmp_GetPressure@plt>
mov    %eax,%esi
movsd  -0x28(%rbp),%xmm0
lea    0xe3f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x28(%rbp),%xmm0
call   10a0 <bmp_altitude@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xe60(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x28(%rbp),%xmm0
mov    $0x13dd,%edi
call   1030 <bmp_qnh@plt>
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1090 <ppl_DensityAlt@plt>
lea    0xf01(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xe54(%rip),%rdi
call   1090 <i2c_Open@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1070 <bmp_Calibration@plt>
lea    0xe4a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
call   10c0 <bmp_GetTemperature@plt>
movsd  0x10(%rsp),%xmm0
lea    0xe45(%rip),%rdi
mov    %eax,%esi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
call   1060 <bmp_GetPressure@plt>
movsd  0x8(%rsp),%xmm0
lea    0xe42(%rip),%rdi
mov    %eax,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
call   10b0 <bmp_altitude@plt>
movsd  %xmm0,0x18(%rsp)
lea    0xe64(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
mov    $0x13dd,%edi
call   1040 <bmp_qnh@plt>
lea    0xe82(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
lea    0xf16(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2e(%rip),%rdi
call   1030 <puts@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
call   10a0 <ppl_DensityAlt@plt>
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %ebx,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"/dev/i2c-1\00"
@.str.1 = [29 x i8] c"\0ACalibration:%i (0= worked)\0A\00"
@.str.2 = [31 x i8] c"Return:%i\09Temperature\09:%.1f C\0A\00"
@.str.3 = [67 x i8] c"Return:%i\09Pressure\09:%.2f hPa/mB\09This is known as station pressure\0A\00"
@.str.4 = [60 x i8] c"\09\09P.Altitude\09:%.0f ft\09This is known as a Pressure Altitude\0A\00"
@.str.5 = [53 x i8] c"\09\09QNH\09\09:%.2f hPa/mB\09Setting required on an Aircraft\0A\00"
@.str.6 = [62 x i8] c"\09\09\09\09\09\09altimeter for it to read Elevation while on the ground\0A\00"
@.str.7 = [37 x i8] c"\09\09\09\09\09\09and Altitude while in the air\0A\00"
@.str.8 = [49 x i8] c"\09\09\09\09\09\09Sensor Elevation MUST BE KNOWN ACCURATELY\0A\00"
@.str.9 = [60 x i8] c"\09\09D.Altitude\09:%.0f ft\09This is known as a density Altitude\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @i2c_Open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = call i32 @bmp_Calibration(i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %6
%15 = call i32 @bmp_GetTemperature(i32 %14, double* %7)
%16 = load double, double* %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %15, double %16)
%18 = load i32, i32* %6
%19 = call i32 @bmp_GetPressure(i32 %18, double* %8)
%20 = load double, double* %8
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0), i32 %19, double %20)
%22 = load double, double* %8
%23 = call double @bmp_altitude(double %22)
store double %23, double* %9
%24 = load double, double* %9
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), double %24)
%26 = load double, double* %8
%27 = call double @bmp_qnh(double %26, i32 5085)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), double %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.6, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0))
%32 = load double, double* %9
%33 = load double, double* %7
%34 = call double @ppl_DensityAlt(double %32, double %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), double %34)
%36 = load i32, i32* %6
%37 = call i32 @close(i32 %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-1\00"
@.str.1 = [29 x i8] c"\0ACalibration:%i (0= worked)\0A\00"
@.str.2 = [31 x i8] c"Return:%i\09Temperature\09:%.1f C\0A\00"
@.str.3 = [67 x i8] c"Return:%i\09Pressure\09:%.2f hPa/mB\09This is known as station pressure\0A\00"
@.str.4 = [60 x i8] c"\09\09P.Altitude\09:%.0f ft\09This is known as a Pressure Altitude\0A\00"
@.str.5 = [53 x i8] c"\09\09QNH\09\09:%.2f hPa/mB\09Setting required on an Aircraft\0A\00"
@.str.9 = [60 x i8] c"\09\09D.Altitude\09:%.0f ft\09This is known as a density Altitude\0A\0A\00"
@str = [61 x i8] c"\09\09\09\09\09\09altimeter for it to read Elevation while on the ground\00"
@str.10 = [36 x i8] c"\09\09\09\09\09\09and Altitude while in the air\00"
@str.11 = [48 x i8] c"\09\09\09\09\09\09Sensor Elevation MUST BE KNOWN ACCURATELY\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 @i2c_Open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @bmp_Calibration(i32 %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = call i32 @bmp_GetTemperature(i32 %7, double* %3)
%11 = load double, double* %3
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %10, double %11)
%13 = call i32 @bmp_GetPressure(i32 %7, double* %4)
%14 = load double, double* %4
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0), i32 %13, double %14)
%16 = load double, double* %4
%17 = call double @bmp_altitude(double %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), double %17)
%19 = load double, double* %4
%20 = call double @bmp_qnh(double %19, i32 5085)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), double %20)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.10, i64 0, i64 0))
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.11, i64 0, i64 0))
%25 = load double, double* %3
%26 = call double @ppl_DensityAlt(double %17, double %25)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), double %26)
%28 = call i32 @close(i32 %7)
ret i32 0
}