#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 main() {
  int mass = 0;
  int vel_i = 0;
  int coeff = 0;
  double f_grav = 1.0;
  double f_resist = 1.0;
  double f_total = 0.0;
  int ch = 0;
  int ch2 = 0;
  printf("\nPlease input the mass in kilograms: ");
  scanf("%d", &mass);
  printf("Please input the launch speed (m/s): ");
  scanf("%d", &vel_i);
  printf("Please input the coefficient of resistance (kg/s): ");
  scanf("%d", &coeff);
  printf("\nChoices for calculation:");
  printf("\n1. Force due to gravity only");
  printf("\n2. Net force");
  printf("\n3. Force due to resistance only");
  printf("\nPlease enter your choice: ");
  scanf("%d", &ch);
  f_grav = mass * 9.81;
  f_resist = (-coeff) * vel_i;
  ch2 = ch;
  ch = (ch2 / 2) + (ch2 / 3) - (4 % ch2);
  f_total = f_resist * ch;
  ch = 1 - (ch2 / 3);
  f_total += f_grav * ch;
  printf("\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
  printf("Desired force:%10.3f N\n", f_total);
  printf("Experienced g:%10.3f times\n", f_total / (mass * 9.81));
  printf("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeaf(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe71(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1b(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xdcf(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
xor    %eax,%eax
sub    -0x10(%rbp),%eax
imul   -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    $0x4,%eax
cltd
idivl  -0x30(%rbp)
mov    -0x34(%rbp),%eax
sub    %edx,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xe52(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xd01(%rip),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
lea    0xe42(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec4(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xed7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf06(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
cvtsi2sdl 0xc(%rsp),%xmm0
mov    0x10(%rsp),%eax
imul   0x14(%rsp),%eax
neg    %eax
cvtsi2sd %eax,%xmm1
mulsd  0xde3(%rip),%xmm0
movslq 0x8(%rsp),%rcx
mov    %ecx,%esi
shr    $0x1f,%esi
add    %ecx,%esi
sar    %esi
imul   $0x55555556,%rcx,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
shr    $0x20,%rdi
add    %eax,%edi
add    %edi,%esi
mov    $0x4,%eax
xor    %edx,%edx
idiv   %ecx
sub    %edx,%esi
cvtsi2sd %esi,%xmm2
mulsd  %xmm1,%xmm2
mov    $0x1,%eax
sub    %edi,%eax
mov    %eax,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x18(%rsp)
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe87(%rip),%rdi
movsd  0x18(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
mulsd  0xd5b(%rip),%xmm1
movsd  0x18(%rsp),%xmm0
divsd  %xmm1,%xmm0
lea    0xe70(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"\0APlease input the mass in kilograms: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"Please input the launch speed (m/s): \00"
@.str.3 = [52 x i8] c"Please input the coefficient of resistance (kg/s): \00"
@.str.4 = [26 x i8] c"\0AChoices for calculation:\00"
@.str.5 = [30 x i8] c"\0A1. Force due to gravity only\00"
@.str.6 = [14 x i8] c"\0A2. Net force\00"
@.str.7 = [33 x i8] c"\0A3. Force due to resistance only\00"
@.str.8 = [28 x i8] c"\0APlease enter your choice: \00"
@.str.9 = [34 x i8] c"\0A-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\0A\00"
@.str.10 = [24 x i8] c"Desired force:%10.3f N\0A\00"
@.str.11 = [28 x i8] c"Experienced g:%10.3f times\0A\00"
@.str.12 = [34 x i8] c"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store double 1.000000e+00, double* %5
store double 1.000000e+00, double* %6
store double 0.000000e+00, double* %7
store i32 0, i32* %8
store i32 0, i32* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 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), i32* %4)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%22 = load i32, i32* %2
%23 = sitofp i32 %22 to double
%24 = fmul double %23, 9.810000e+00
store double %24, double* %5
%25 = load i32, i32* %4
%26 = sub nsw i32 0, %25
%27 = load i32, i32* %3
%28 = mul nsw i32 %26, %27
%29 = sitofp i32 %28 to double
store double %29, double* %6
%30 = load i32, i32* %8
store i32 %30, i32* %9
%31 = load i32, i32* %9
%32 = sdiv i32 %31, 2
%33 = load i32, i32* %9
%34 = sdiv i32 %33, 3
%35 = add nsw i32 %32, %34
%36 = load i32, i32* %9
%37 = srem i32 4, %36
%38 = sub nsw i32 %35, %37
store i32 %38, i32* %8
%39 = load double, double* %6
%40 = load i32, i32* %8
%41 = sitofp i32 %40 to double
%42 = fmul double %39, %41
store double %42, double* %7
%43 = load i32, i32* %9
%44 = sdiv i32 %43, 3
%45 = sub nsw i32 1, %44
store i32 %45, i32* %8
%46 = load double, double* %5
%47 = load i32, i32* %8
%48 = sitofp i32 %47 to double
%49 = load double, double* %7
%50 = call double @llvm.fmuladd.f64(double %46, double %48, double %49)
store double %50, double* %7
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
%52 = load double, double* %7
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), double %52)
%54 = load double, double* %7
%55 = load i32, i32* %2
%56 = sitofp i32 %55 to double
%57 = fmul double %56, 9.810000e+00
%58 = fdiv double %54, %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), double %58)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.12, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"\0APlease input the mass in kilograms: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"Please input the launch speed (m/s): \00"
@.str.3 = [52 x i8] c"Please input the coefficient of resistance (kg/s): \00"
@.str.4 = [26 x i8] c"\0AChoices for calculation:\00"
@.str.5 = [30 x i8] c"\0A1. Force due to gravity only\00"
@.str.6 = [14 x i8] c"\0A2. Net force\00"
@.str.7 = [33 x i8] c"\0A3. Force due to resistance only\00"
@.str.8 = [28 x i8] c"\0APlease enter your choice: \00"
@.str.10 = [24 x i8] c"Desired force:%10.3f N\0A\00"
@.str.11 = [28 x i8] c"Experienced g:%10.3f times\0A\00"
@str = [33 x i8] c"\0A-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\00"
@str.13 = [33 x i8] c"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 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), i32* %1)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%21 = load i32, i32* %1
%22 = sitofp i32 %21 to double
%23 = fmul double %22, 9.810000e+00
%24 = load i32, i32* %3
%25 = load i32, i32* %2
%26 = mul i32 %24, %25
%27 = sub i32 0, %26
%28 = sitofp i32 %27 to double
%29 = load i32, i32* %4
%30 = sdiv i32 %29, 2
%31 = sdiv i32 %29, 3
%32 = add nsw i32 %30, %31
%33 = srem i32 4, %29
%34 = sub nsw i32 %32, %33
%35 = sitofp i32 %34 to double
%36 = fmul double %28, %35
%37 = sub nsw i32 1, %31
store i32 %37, i32* %4
%38 = sitofp i32 %37 to double
%39 = call double @llvm.fmuladd.f64(double %23, double %38, double %36)
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), double %39)
%42 = load i32, i32* %1
%43 = sitofp i32 %42 to double
%44 = fmul double %43, 9.810000e+00
%45 = fdiv double %39, %44
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), double %45)
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.13, i64 0, i64 0))
ret i32 0
}