#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main(void) {
  float p_start, p_final, mix_start, mix_final, p_remove, p_test;
  printf("Enter the current tank pressure(in bar)\n");
  scanf("%f", &p_start);
  printf("Enter the current mix -> e.g for EAN36 enter 36\n");
  scanf("%f", &mix_start);
  mix_start /= 100;
  printf("Target final pressure(in bar)\n");
  scanf("%f", &p_final);
  printf("Target final percent of O2 -> for EAN32 enter 32\n");
  scanf("%f", &mix_final);
  mix_final /= 100;
  p_test = ((p_final * (mix_final - 0.209)) - (p_start * (mix_start - 0.209))) /
           0.791;
  if (p_test < 0) {
    p_remove = (p_final * (mix_final - 0.209)) / (mix_start - 0.209);
    printf("You should bleed the tank to %.2f bar then top up to your required "
           "pressure with air.",
           p_remove);
  } else {
    printf("Amount of O2: %.2f bar\n", p_test);
    printf("Amount of air: %.2f bar\n", (p_final - p_start - p_test));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x10(%rbp),%xmm0
movss  0xe98(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x14(%rbp),%xmm0
movss  0xe46(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe1b(%rip),%xmm1
subsd  %xmm1,%xmm2
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x10(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
movsd  0xdfd(%rip),%xmm4
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdc6(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    12b4 <main+0x194>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xd9a(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xd81(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe1a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12ec <main+0x1cc>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe54(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xf66(%rip),%rdi
call   1030 <puts@plt>
lea    0xed0(%rip),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf6e(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
divss  0xe84(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xf71(%rip),%rdi
call   1030 <puts@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf76(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0x10(%rsp),%xmm2
divss  0xe3e(%rip),%xmm2
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
movsd  0xe2d(%rip),%xmm3
addsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm0
movss  0x18(%rsp),%xmm1
cvtss2sd %xmm1,%xmm4
movss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm3,%xmm1
mulsd  %xmm1,%xmm4
movapd %xmm0,%xmm3
subsd  %xmm4,%xmm3
divsd  0xe01(%rip),%xmm3
cvtsd2ss %xmm3,%xmm3
movss  %xmm2,0x10(%rsp)
xorps  %xmm2,%xmm2
ucomiss %xmm3,%xmm2
jbe    1232 <main+0x102>
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
lea    0xdeb(%rip),%rdi
jmp    1266 <main+0x136>
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
lea    0xe31(%rip),%rdi
mov    $0x1,%al
movss  %xmm3,0x1c(%rsp)
call   1040 <printf@plt>
movss  0x14(%rsp),%xmm0
subss  0x18(%rsp),%xmm0
subss  0x1c(%rsp),%xmm0
lea    0xe23(%rip),%rdi
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Enter the current tank pressure(in bar)\0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [49 x i8] c"Enter the current mix -> e.g for EAN36 enter 36\0A\00"
@.str.3 = [31 x i8] c"Target final pressure(in bar)\0A\00"
@.str.4 = [50 x i8] c"Target final percent of O2 -> for EAN32 enter 32\0A\00"
@.str.5 = [86 x i8] c"You should bleed the tank to %.2f bar then top up to your required pressure with air.\00"
@.str.6 = [24 x i8] c"Amount of O2: %.2f bar\0A\00"
@.str.7 = [25 x i8] c"Amount of air: %.2f bar\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%12 = load float, float* %4
%13 = fdiv float %12, 1.000000e+02
store float %13, float* %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%18 = load float, float* %5
%19 = fdiv float %18, 1.000000e+02
store float %19, float* %5
%20 = load float, float* %3
%21 = fpext float %20 to double
%22 = load float, float* %5
%23 = fpext float %22 to double
%24 = fsub double %23, 2.090000e-01
%25 = load float, float* %2
%26 = fpext float %25 to double
%27 = load float, float* %4
%28 = fpext float %27 to double
%29 = fsub double %28, 2.090000e-01
%30 = fmul double %26, %29
%31 = fneg double %30
%32 = call double @llvm.fmuladd.f64(double %21, double %24, double %31)
%33 = fdiv double %32, 7.910000e-01
%34 = fptrunc double %33 to float
store float %34, float* %7
%35 = load float, float* %7
%36 = fcmp olt float %35, 0.000000e+00
br i1 %36, label %37, label %52
37: ; preds = %0
%38 = load float, float* %3
%39 = fpext float %38 to double
%40 = load float, float* %5
%41 = fpext float %40 to double
%42 = fsub double %41, 2.090000e-01
%43 = fmul double %39, %42
%44 = load float, float* %4
%45 = fpext float %44 to double
%46 = fsub double %45, 2.090000e-01
%47 = fdiv double %43, %46
%48 = fptrunc double %47 to float
store float %48, float* %6
%49 = load float, float* %6
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.5, i64 0, i64 0), double %50)
br label %63
52: ; preds = %0
%53 = load float, float* %7
%54 = fpext float %53 to double
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %54)
%56 = load float, float* %3
%57 = load float, float* %2
%58 = fsub float %56, %57
%59 = load float, float* %7
%60 = fsub float %58, %59
%61 = fpext float %60 to double
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), double %61)
br label %63
63: ; preds = %52, %37
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%f\00"
@.str.5 = [86 x i8] c"You should bleed the tank to %.2f bar then top up to your required pressure with air.\00"
@.str.6 = [24 x i8] c"Amount of O2: %.2f bar\0A\00"
@.str.7 = [25 x i8] c"Amount of air: %.2f bar\0A\00"
@str = [40 x i8] c"Enter the current tank pressure(in bar)\00"
@str.8 = [48 x i8] c"Enter the current mix -> e.g for EAN36 enter 36\00"
@str.9 = [30 x i8] c"Target final pressure(in bar)\00"
@str.10 = [49 x i8] c"Target final percent of O2 -> for EAN32 enter 32\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = bitcast float* %1 to i8*
%6 = bitcast float* %2 to i8*
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.8, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%13 = load float, float* %3
%14 = fdiv float %13, 1.000000e+02
store float %14, float* %3
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.9, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.10, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%19 = load float, float* %4
%20 = fdiv float %19, 1.000000e+02
store float %20, float* %4
%21 = load float, float* %2
%22 = fpext float %21 to double
%23 = fpext float %20 to double
%24 = fadd double %23, -2.090000e-01
%25 = load float, float* %1
%26 = fpext float %25 to double
%27 = load float, float* %3
%28 = fpext float %27 to double
%29 = fadd double %28, -2.090000e-01
%30 = fneg double %29
%31 = fmul double %26, %30
%32 = call double @llvm.fmuladd.f64(double %22, double %24, double %31)
%33 = fdiv double %32, 7.910000e-01
%34 = fptrunc double %33 to float
%35 = fcmp olt float %34, 0.000000e+00
br i1 %35, label %36, label %40
36: ; preds = %0
%37 = fmul double %24, %22
%38 = fdiv double %37, %29
%39 = fptrunc double %38 to float
br label %47
40: ; preds = %0
%41 = fpext float %34 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), double %41)
%43 = load float, float* %2
%44 = load float, float* %1
%45 = fsub float %43, %44
%46 = fsub float %45, %34
br label %47
47: ; preds = %40, %36
%48 = phi float [ %46, %40 ], [ %39, %36 ]
%49 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), %40 ], [ getelementptr inbounds ([86 x i8], [86 x i8]* @.str.5, i64 0, i64 0), %36 ]
%50 = fpext float %48 to double
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %49, double %50)
ret i32 0
}