#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 */
double atof(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main(int argc, char *argv[]) {
  double abv1, abv2, target_abv, target_vol, vol1, vol2;
  if (argc - 1 == 0) {
    printf("%%ABV of first ingredient: ");
    (void)scanf("%lf", &abv1);
  } else
    abv1 = atof(argv[1]);
  if (argc - 1 <= 1) {
    printf("%%ABV of second ingredient: ");
    (void)scanf("%lf", &abv2);
  } else
    abv2 = atof(argv[2]);
  if (argc - 1 <= 2) {
    printf("%%Target ABV: ");
    (void)scanf("%lf", &target_abv);
  } else
    target_abv = atof(argv[3]);
  if (argc - 1 <= 3) {
    printf("Target volume (fl. oz.): ");
    (void)scanf("%lf", &target_vol);
  } else
    target_vol = atof(argv[4]);
  vol1 = target_vol * (target_abv - abv2) / (abv1 - abv2);
  vol2 = target_vol - vol1;
  printf(
      "\nYou will need %.1f fl. oz. of the first ingredient (%.1lf%% ABV), and",
      vol1, abv1);
  printf("\n              %.1f fl. oz. of the second ingredient (%.1lf%% "
         "ABV).\n\n",
         vol2, abv2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cmp    $0x0,%eax
jne    1178 <main+0x48>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
jmp    118a <main+0x5a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cmp    $0x1,%eax
jg     11bc <main+0x8c>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6e(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
jmp    11ce <main+0x9e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cmp    $0x2,%eax
jg     1200 <main+0xd0>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2a(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <scanf@plt>
jmp    1212 <main+0xe2>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cmp    $0x3,%eax
jg     1244 <main+0x114>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde6(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <scanf@plt>
jmp    1256 <main+0x126>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xdca(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xdf9(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
cmp    $0x1,%edi
jne    115c <main+0x2c>
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1050 <scanf@plt>
jmp    1179 <main+0x49>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x20(%rsp)
cmp    $0x2,%ebp
jg     1243 <main+0x113>
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6f(%rip),%rdi
lea    0x18(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe50(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
movsd  0x20(%rsp),%xmm1
subsd  %xmm2,%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm0,%xmm4
movapd %xmm1,%xmm0
subsd  %xmm2,%xmm0
divsd  %xmm0,%xmm3
subsd  %xmm3,%xmm4
movsd  %xmm4,(%rsp)
lea    0xe50(%rip),%rdi
movapd %xmm3,%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
lea    0xe7f(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret
movsd  %xmm0,(%rsp)
mov    0x10(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
cmp    $0x3,%ebp
je     1198 <main+0x68>
movsd  %xmm0,0x30(%rsp)
mov    0x18(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x18(%rsp)
cmp    $0x4,%ebp
jbe    11b7 <main+0x87>
mov    0x20(%rbx),%rdi
movsd  %xmm0,0x28(%rsp)
call   1030 <atof@plt>
movsd  0x28(%rsp),%xmm3
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
jmp    11ee <main+0xbe>

LLVM IR (-O0):
@.str = [28 x i8] c"%%ABV of first ingredient: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [29 x i8] c"%%ABV of second ingredient: \00"
@.str.3 = [15 x i8] c"%%Target ABV: \00"
@.str.4 = [26 x i8] c"Target volume (fl. oz.): \00"
@.str.5 = [71 x i8] c"\0AYou will need %.1f fl. oz. of the first ingredient (%.1lf%% ABV), and\00"
@.str.6 = [70 x i8] c"\0A %.1f fl. oz. of the second ingredient (%.1lf%% ABV).\0A\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 double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = sub nsw i32 %12, 1
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %6)
br label %23
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call double @atof(i8* %21)
store double %22, double* %6
br label %23
23: ; preds = %18, %15
%24 = load i32, i32* %4
%25 = sub nsw i32 %24, 1
%26 = icmp sle i32 %25, 1
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %7)
br label %35
30: ; preds = %23
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call double @atof(i8* %33)
store double %34, double* %7
br label %35
35: ; preds = %30, %27
%36 = load i32, i32* %4
%37 = sub nsw i32 %36, 1
%38 = icmp sle i32 %37, 2
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%41 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %8)
br label %47
42: ; preds = %35
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 3
%45 = load i8*, i8** %44
%46 = call double @atof(i8* %45)
store double %46, double* %8
br label %47
47: ; preds = %42, %39
%48 = load i32, i32* %4
%49 = sub nsw i32 %48, 1
%50 = icmp sle i32 %49, 3
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%53 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %9)
br label %59
54: ; preds = %47
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 4
%57 = load i8*, i8** %56
%58 = call double @atof(i8* %57)
store double %58, double* %9
br label %59
59: ; preds = %54, %51
%60 = load double, double* %9
%61 = load double, double* %8
%62 = load double, double* %7
%63 = fsub double %61, %62
%64 = fmul double %60, %63
%65 = load double, double* %6
%66 = load double, double* %7
%67 = fsub double %65, %66
%68 = fdiv double %64, %67
store double %68, double* %10
%69 = load double, double* %9
%70 = load double, double* %10
%71 = fsub double %69, %70
store double %71, double* %11
%72 = load double, double* %10
%73 = load double, double* %6
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0), double %72, double %73)
%75 = load double, double* %11
%76 = load double, double* %7
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.6, i64 0, i64 0), double %75, double %76)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"%%ABV of first ingredient: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [29 x i8] c"%%ABV of second ingredient: \00"
@.str.3 = [15 x i8] c"%%Target ABV: \00"
@.str.4 = [26 x i8] c"Target volume (fl. oz.): \00"
@.str.5 = [71 x i8] c"\0AYou will need %.1f fl. oz. of the first ingredient (%.1lf%% ABV), and\00"
@.str.6 = [70 x i8] c"\0A %.1f fl. oz. of the second ingredient (%.1lf%% ABV).\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
%9 = bitcast double* %5 to i8*
%10 = bitcast double* %6 to i8*
%11 = icmp eq i32 %0, 1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
br label %20
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call double @atof(i8* %17)
store double %18, double* %3
%19 = icmp slt i32 %0, 3
br i1 %19, label %20, label %23
20: ; preds = %15, %12
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
br label %28
23: ; preds = %15
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call double @atof(i8* %25)
store double %26, double* %4
%27 = icmp eq i32 %0, 3
br i1 %27, label %28, label %31
28: ; preds = %23, %20
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
br label %36
31: ; preds = %23
%32 = getelementptr inbounds i8*, i8** %1, i64 3
%33 = load i8*, i8** %32
%34 = tail call double @atof(i8* %33)
store double %34, double* %5
%35 = icmp ult i32 %0, 5
br i1 %35, label %36, label %43
36: ; preds = %28, %31
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%38 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %6)
%39 = load double, double* %6
%40 = load double, double* %5
%41 = load double, double* %4
%42 = load double, double* %3
br label %47
43: ; preds = %31
%44 = getelementptr inbounds i8*, i8** %1, i64 4
%45 = load i8*, i8** %44
%46 = tail call double @atof(i8* %45)
store double %46, double* %6
br label %47
47: ; preds = %43, %36
%48 = phi double [ %18, %43 ], [ %42, %36 ]
%49 = phi double [ %26, %43 ], [ %41, %36 ]
%50 = phi double [ %34, %43 ], [ %40, %36 ]
%51 = phi double [ %46, %43 ], [ %39, %36 ]
%52 = fsub double %50, %49
%53 = fmul double %51, %52
%54 = fsub double %48, %49
%55 = fdiv double %53, %54
%56 = fsub double %51, %55
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0), double %55, double %48)
%58 = load double, double* %4
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.6, i64 0, i64 0), double %56, double %58)
ret i32 0
}