#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__ EOF;
int /*<<< orphan*/ printf(char *, double);
scalar_t__ scanf(char *, ...);
int main(void) {
  int G, A, H, W;
  scanf("%*d");
  while (scanf("%d %d %d %d", &G, &A, &H, &W) != EOF) {
    printf("%.2f\n", (G ? (13.7 * W + 5.0 * H - 6.8 * A + 66)
                        : (9.6 * W + 1.8 * H - 4.7 * A + 655)));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf0a(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf00(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
mov    $0x0,%al
call   1040 <scanf@plt>
mov    0x2e86(%rip),%rcx
cmp    (%rcx),%rax
je     1228 <main+0x108>
cmpl   $0x0,-0x8(%rbp)
je     11c6 <main+0xa6>
cvtsi2sdl -0x14(%rbp),%xmm1
cvtsi2sdl -0x10(%rbp),%xmm2
movsd  0xeb1(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  0xe9d(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe80(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe68(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1212 <main+0xf2>
cvtsi2sdl -0x14(%rbp),%xmm1
cvtsi2sdl -0x10(%rbp),%xmm2
movsd  0xe40(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  0xe2c(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe0f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdf7(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf0b(%rip),%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xf01(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x2e83(%rip),%rcx
cmp    (%rcx),%rax
jne    117b <main+0x5b>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xece(%rip),%r14
lea    0xebb(%rip),%r15
lea    0x14(%rsp),%r12
lea    0x8(%rsp),%r13
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%rbp
jmp    11ff <main+0xdf>
nop
mulsd  0xe78(%rip),%xmm2
mulsd  0xe78(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdl 0x8(%rsp),%xmm0
addsd  %xmm2,%xmm1
mulsd  0xe6b(%rip),%xmm0
addsd  %xmm1,%xmm0
addsd  0xe67(%rip),%xmm0
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x2df2(%rip),%rcx
cmp    (%rcx),%rax
je     116a <main+0x4a>
cmpl   $0x0,0x14(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
xorps  %xmm2,%xmm2
cvtsi2sdl 0x10(%rsp),%xmm2
je     11a0 <main+0x80>
mulsd  0xde0(%rip),%xmm2
mulsd  0xde0(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdl 0x8(%rsp),%xmm0
addsd  %xmm2,%xmm1
mulsd  0xdd3(%rip),%xmm0
addsd  %xmm1,%xmm0
addsd  0xdcf(%rip),%xmm0
jmp    11d1 <main+0xb1>

LLVM IR (-O0):
@.str = [4 x i8] c"%*d\00"
@.str.1 = [12 x i8] c"%d %d %d %d\00"
@EOF = global i64 0
@.str.2 = [6 x i8] c"%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %36, %0
%8 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5)
%9 = load i64, i64* @EOF
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %39
11: ; preds = %7
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %11
%15 = load i32, i32* %5
%16 = sitofp i32 %15 to double
%17 = load i32, i32* %4
%18 = sitofp i32 %17 to double
%19 = fmul double 5.000000e+00, %18
%20 = call double @llvm.fmuladd.f64(double 1.370000e+01, double %16, double %19)
%21 = load i32, i32* %3
%22 = sitofp i32 %21 to double
%23 = call double @llvm.fmuladd.f64(double -6.800000e+00, double %22, double %20)
%24 = fadd double %23, 6.600000e+01
br label %36
25: ; preds = %11
%26 = load i32, i32* %5
%27 = sitofp i32 %26 to double
%28 = load i32, i32* %4
%29 = sitofp i32 %28 to double
%30 = fmul double 1.800000e+00, %29
%31 = call double @llvm.fmuladd.f64(double 0x4023333333333333, double %27, double %30)
%32 = load i32, i32* %3
%33 = sitofp i32 %32 to double
%34 = call double @llvm.fmuladd.f64(double -4.700000e+00, double %33, double %31)
%35 = fadd double %34, 6.550000e+02
br label %36
36: ; preds = %25, %14
%37 = phi double [ %24, %14 ], [ %35, %25 ]
%38 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %37)
br label %7
39: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%*d\00"
@.str.1 = [12 x i8] c"%d %d %d %d\00"
@EOF = global i64 0
@.str.2 = [6 x i8] c"%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = tail call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
br i1 %12, label %40, label %13
13: ; preds = %0, %34
%14 = load i32, i32* %1
%15 = icmp eq i32 %14, 0
%16 = load i32, i32* %4
%17 = sitofp i32 %16 to double
%18 = load i32, i32* %3
%19 = sitofp i32 %18 to double
br i1 %15, label %27, label %20
20: ; preds = %13
%21 = fmul double %19, 5.000000e+00
%22 = call double @llvm.fmuladd.f64(double %17, double 1.370000e+01, double %21)
%23 = load i32, i32* %2
%24 = sitofp i32 %23 to double
%25 = call double @llvm.fmuladd.f64(double %24, double -6.800000e+00, double %22)
%26 = fadd double %25, 6.600000e+01
br label %34
27: ; preds = %13
%28 = fmul double %19, 1.800000e+00
%29 = call double @llvm.fmuladd.f64(double %17, double 0x4023333333333333, double %28)
%30 = load i32, i32* %2
%31 = sitofp i32 %30 to double
%32 = call double @llvm.fmuladd.f64(double %31, double -4.700000e+00, double %29)
%33 = fadd double %32, 6.550000e+02
br label %34
34: ; preds = %27, %20
%35 = phi double [ %26, %20 ], [ %33, %27 ]
%36 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %35)
%37 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%38 = load i64, i64* @EOF
%39 = icmp eq i64 %37, %38
br i1 %39, label %40, label %13
40: ; preds = %34, %0
ret i32 0
}