#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 *, int *, int *, float *, float *);
int main(void) {
  printf("[n00862133@osprey COP2220]$ ./project2\n\nCOP2220 Project 2 - Gary "
         "Frazier\n\n");
  int number1;
  int number2;
  float number3;
  float number4;
  printf("Enter four numbers in the format nnn nnn nnn.nn nnn.nn<enter>:\n");
  scanf("%d %d %f %f", &number1, &number2, &number3, &number4);
  float result = ((number1 - number4) / number3) * number2;
  float sum = number1 + number2 + number3 + number4;
  float avg = sum / 4;
  printf(
      "\nThe result of the calculation ((%d - %.2f) / %.2f) * %d is %.2f\n\n",
      number1, number4, number3, number2, result);
  printf("The sum of the input numbers is:     %.2f\n", sum);
  printf("The average of the input numbers is: %.2f\n\n", avg);
  printf("Have a nice day!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf44(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
lea    -0x10(%rbp),%r8
call   1040 <scanf@plt>
cvtsi2ssl -0x4(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm0
addss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  0xe5d(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x4(%rbp),%esi
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mov    -0x8(%rbp),%edx
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xec7(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xef3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xf07(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xf25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf6f(%rip),%rdi
call   1030 <puts@plt>
lea    0xfad(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1050 <scanf@plt>
mov    0x14(%rsp),%esi
cvtsi2ss %esi,%xmm0
movss  0x8(%rsp),%xmm1
subss  %xmm1,%xmm0
movss  0xc(%rsp),%xmm2
divss  %xmm2,%xmm0
mov    0x10(%rsp),%edx
cvtsi2ss %edx,%xmm3
lea    (%rdx,%rsi,1),%eax
cvtsi2ss %eax,%xmm4
mulss  %xmm0,%xmm3
addss  %xmm2,%xmm4
addss  %xmm1,%xmm4
movss  %xmm4,(%rsp)
movss  0xe50(%rip),%xmm0
mulss  %xmm4,%xmm0
movss  %xmm0,0x4(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm3,%xmm2
lea    0xe3a(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe66(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe79(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xf20(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [75 x i8] c"[n00862133@osprey COP2220]$ ./project2\0A\0ACOP2220 Project 2 - Gary Frazier\0A\0A\00"
@.str.1 = [64 x i8] c"Enter four numbers in the format nnn nnn nnn.nn nnn.nn<enter>:\0A\00"
@.str.2 = [12 x i8] c"%d %d %f %f\00"
@.str.3 = [67 x i8] c"\0AThe result of the calculation ((%d - %.2f) / %.2f) * %d is %.2f\0A\0A\00"
@.str.4 = [43 x i8] c"The sum of the input numbers is: %.2f\0A\00"
@.str.5 = [44 x i8] c"The average of the input numbers is: %.2f\0A\0A\00"
@.str.6 = [18 x i8] c"Have a nice day!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, float* %3, float* %4)
%11 = load i32, i32* %1
%12 = sitofp i32 %11 to float
%13 = load float, float* %4
%14 = fsub float %12, %13
%15 = load float, float* %3
%16 = fdiv float %14, %15
%17 = load i32, i32* %2
%18 = sitofp i32 %17 to float
%19 = fmul float %16, %18
store float %19, float* %5
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = add nsw i32 %20, %21
%23 = sitofp i32 %22 to float
%24 = load float, float* %3
%25 = fadd float %23, %24
%26 = load float, float* %4
%27 = fadd float %25, %26
store float %27, float* %6
%28 = load float, float* %6
%29 = fdiv float %28, 4.000000e+00
store float %29, float* %7
%30 = load i32, i32* %1
%31 = load float, float* %4
%32 = fpext float %31 to double
%33 = load float, float* %3
%34 = fpext float %33 to double
%35 = load i32, i32* %2
%36 = load float, float* %5
%37 = fpext float %36 to double
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0), i32 %30, double %32, double %34, i32 %35, double %37)
%39 = load float, float* %6
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), double %40)
%42 = load float, float* %7
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), double %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [12 x i8] c"%d %d %f %f\00"
@.str.3 = [67 x i8] c"\0AThe result of the calculation ((%d - %.2f) / %.2f) * %d is %.2f\0A\0A\00"
@.str.4 = [43 x i8] c"The sum of the input numbers is: %.2f\0A\00"
@.str.5 = [44 x i8] c"The average of the input numbers is: %.2f\0A\0A\00"
@str = [74 x i8] c"[n00862133@osprey COP2220]$ ./project2\0A\0ACOP2220 Project 2 - Gary Frazier\0A\00"
@str.7 = [63 x i8] c"Enter four numbers in the format nnn nnn nnn.nn nnn.nn<enter>:\00"
@str.8 = [17 x i8] c"Have a nice day!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str, i64 0, i64 0))
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast float* %3 to i8*
%9 = bitcast float* %4 to i8*
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.7, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, float* %3, float* %4)
%12 = load i32, i32* %1
%13 = sitofp i32 %12 to float
%14 = load float, float* %4
%15 = fsub float %13, %14
%16 = load float, float* %3
%17 = fdiv float %15, %16
%18 = load i32, i32* %2
%19 = sitofp i32 %18 to float
%20 = fmul float %17, %19
%21 = add nsw i32 %18, %12
%22 = sitofp i32 %21 to float
%23 = fadd float %16, %22
%24 = fadd float %14, %23
%25 = fmul float %24, 2.500000e-01
%26 = fpext float %14 to double
%27 = fpext float %16 to double
%28 = fpext float %20 to double
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0), i32 %12, double %26, double %27, i32 %18, double %28)
%30 = fpext float %24 to double
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), double %30)
%32 = fpext float %25 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), double %32)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.8, i64 0, i64 0))
ret i32 0
}