#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() {
  float r_length, r_width, r_height, num_win, num_door, num_sky;
  printf("CSCE 1030 - Program One - Ahmad Rashed - arashed31@gmail.com - CSP03 "
         "\n\n");
  printf("Enter room length: ");
  scanf("%f", &r_length);
  printf("Enter room width: ");
  scanf("%f", &r_width);
  printf("Enter room height: ");
  scanf("%f", &r_height);
  printf("Enter number of windows: ");
  scanf("%f", &num_win);
  printf("Enter number of doors: ");
  scanf("%f", &num_door);
  printf("Enter number of slylights: ");
  scanf("%f", &num_sky);
  double room_s_area = (r_length * r_height * 2) + (r_width * r_height * 2) +
                       (r_length * r_width);
  double other_area = (num_win * 12) + (num_door * 20) + (num_sky * 24);
  double gallons = (room_s_area - other_area) / 220;
  if (gallons > 0)
    printf("\nThe number of gallons needed would be %d. \n",
           (int)(gallons + 0.99999));
  else
    printf("\nYou have no walls to paint. \n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf2a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xf1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xf12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xf08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xf04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xefe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm1
mulss  -0x10(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  0xe0f(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm1
addss  %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x14(%rbp),%xmm1
movss  0xdd7(%rip),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  0xdc6(%rip),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
movss  0xdad(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xd7a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12c5 <main+0x1a5>
movsd  0xd5f(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d3 <main+0x1b3>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xfbd(%rip),%rdi
call   1030 <puts@plt>
lea    0xef8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xefe(%rip),%rbx
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeed(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xee5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xede(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xedd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeda(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0x1c(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
movaps %xmm0,%xmm2
mulss  %xmm1,%xmm2
movss  0x18(%rsp),%xmm3
mulss  %xmm3,%xmm1
movss  0xc(%rsp),%xmm4
unpcklps %xmm4,%xmm1
mulps  0xde9(%rip),%xmm1
movss  0x10(%rsp),%xmm4
unpcklps %xmm4,%xmm2
mulps  0xde9(%rip),%xmm2
addps  %xmm1,%xmm2
movss  0x8(%rsp),%xmm1
unpcklps %xmm1,%xmm0
movaps 0xde6(%rip),%xmm1
movss  %xmm3,%xmm1
mulps  %xmm0,%xmm1
addps  %xmm2,%xmm1
cvtps2pd %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
divsd  0xdd5(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1281 <main+0x151>
addsd  0xdcb(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe54(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    128d <main+0x15d>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [72 x i8] c"CSCE 1030 - Program One - Ahmad Rashed - arashed31@gmail.com - CSP03 \0A\0A\00"
@.str.1 = [20 x i8] c"Enter room length: \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [19 x i8] c"Enter room width: \00"
@.str.4 = [20 x i8] c"Enter room height: \00"
@.str.5 = [26 x i8] c"Enter number of windows: \00"
@.str.6 = [24 x i8] c"Enter number of doors: \00"
@.str.7 = [28 x i8] c"Enter number of slylights: \00"
@.str.8 = [45 x i8] c"\0AThe number of gallons needed would be %d. \0A\00"
@.str.9 = [31 x i8] c"\0AYou have no walls to paint. \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
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i32 0, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %4)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %5)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %6)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %7)
%24 = load float, float* %2
%25 = load float, float* %4
%26 = fmul float %24, %25
%27 = load float, float* %3
%28 = load float, float* %4
%29 = fmul float %27, %28
%30 = fmul float %29, 2.000000e+00
%31 = call float @llvm.fmuladd.f32(float %26, float 2.000000e+00, float %30)
%32 = load float, float* %2
%33 = load float, float* %3
%34 = call float @llvm.fmuladd.f32(float %32, float %33, float %31)
%35 = fpext float %34 to double
store double %35, double* %8
%36 = load float, float* %5
%37 = load float, float* %6
%38 = fmul float %37, 2.000000e+01
%39 = call float @llvm.fmuladd.f32(float %36, float 1.200000e+01, float %38)
%40 = load float, float* %7
%41 = call float @llvm.fmuladd.f32(float %40, float 2.400000e+01, float %39)
%42 = fpext float %41 to double
store double %42, double* %9
%43 = load double, double* %8
%44 = load double, double* %9
%45 = fsub double %43, %44
%46 = fdiv double %45, 2.200000e+02
store double %46, double* %10
%47 = load double, double* %10
%48 = fcmp ogt double %47, 0.000000e+00
br i1 %48, label %49, label %54
49: ; preds = %0
%50 = load double, double* %10
%51 = fadd double %50, 9.999900e-01
%52 = fptosi double %51 to i32
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0), i32 %52)
br label %56
54: ; preds = %0
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
br label %56
56: ; preds = %54, %49
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"Enter room length: \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [19 x i8] c"Enter room width: \00"
@.str.4 = [20 x i8] c"Enter room height: \00"
@.str.5 = [26 x i8] c"Enter number of windows: \00"
@.str.6 = [24 x i8] c"Enter number of doors: \00"
@.str.7 = [28 x i8] c"Enter number of slylights: \00"
@.str.8 = [45 x i8] c"\0AThe number of gallons needed would be %d. \0A\00"
@str = [71 x i8] c"CSCE 1030 - Program One - Ahmad Rashed - arashed31@gmail.com - CSP03 \0A\00"
@str.10 = [30 x i8] c"\0AYou have no walls to paint. \00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = bitcast float* %1 to i8*
%8 = bitcast float* %2 to i8*
%9 = bitcast float* %3 to i8*
%10 = bitcast float* %4 to i8*
%11 = bitcast float* %5 to i8*
%12 = bitcast float* %6 to i8*
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %4)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %5)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %6)
%26 = load float, float* %1
%27 = load float, float* %3
%28 = fmul float %26, %27
%29 = load float, float* %2
%30 = fmul float %27, %29
%31 = load float, float* %4
%32 = load float, float* %5
%33 = insertelement <2 x float> poison, float %30, i64 0
%34 = insertelement <2 x float> %33, float %32, i64 1
%35 = fmul <2 x float> %34, <float 2.000000e+00, float 2.000000e+01>
%36 = insertelement <2 x float> poison, float %28, i64 0
%37 = insertelement <2 x float> %36, float %31, i64 1
%38 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %37, <2 x float> <float 2.000000e+00, float 1.200000e+01>, <2 x float> %35)
%39 = load float, float* %6
%40 = insertelement <2 x float> poison, float %26, i64 0
%41 = insertelement <2 x float> %40, float %39, i64 1
%42 = insertelement <2 x float> <float poison, float 2.400000e+01>, float %29, i64 0
%43 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %41, <2 x float> %42, <2 x float> %38)
%44 = fpext <2 x float> %43 to <2 x double>
%45 = shufflevector <2 x double> %44, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%46 = fsub <2 x double> %44, %45
%47 = extractelement <2 x double> %46, i64 0
%48 = fdiv double %47, 2.200000e+02
%49 = fcmp ogt double %48, 0.000000e+00
br i1 %49, label %50, label %54
50: ; preds = %0
%51 = fadd double %48, 9.999900e-01
%52 = fptosi double %51 to i32
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0), i32 %52)
br label %56
54: ; preds = %0
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.10, i64 0, i64 0))
br label %56
56: ; preds = %54, %50
ret i32 0
}