#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 currentGrade = 0;
  double currentGradeWeight = 0.0;
  int finalWorth = 0;
  double finalScoreWeight = 0.0;
  int finalScore = 0;
  int finalGrade = 0;
  double pointsOutOf = 100.0;
  printf("What is your current grade? ");
  scanf("%d", &currentGrade);
  printf("How much is the final worth? ");
  scanf("%d", &finalWorth);
  printf("What is your final exam score? ");
  scanf("%d", &finalScore);
  currentGradeWeight =
      (currentGrade / pointsOutOf) * (pointsOutOf - finalWorth);
  finalScoreWeight = (finalScore / pointsOutOf) * (finalWorth);
  finalGrade = (currentGradeWeight + finalScoreWeight) + 0.99;
  printf("Your final grade is %d", finalGrade);
  printf("%%");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movsd  0xea5(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <scanf@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
cvtsi2sdl -0x14(%rbp),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xdf3(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf2d(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xec7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
cvtsi2sdl 0x8(%rsp),%xmm0
movsd  0xe4d(%rip),%xmm1
subsd  %xmm0,%xmm1
movss  0x4(%rsp),%xmm2
movss  0xc(%rsp),%xmm3
unpcklps %xmm2,%xmm3
cvtdq2pd %xmm3,%xmm2
divpd  0xe3e(%rip),%xmm2
unpcklpd %xmm0,%xmm1
mulpd  %xmm2,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  0xe1a(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x25,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"What is your current grade? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"How much is the final worth? \00"
@.str.3 = [32 x i8] c"What is your final exam score? \00"
@.str.4 = [23 x i8] c"Your final grade is %d\00"
@.str.5 = [3 x i8] c"%%\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
store double 0.000000e+00, double* %3
store i32 0, i32* %4
store double 0.000000e+00, double* %5
store i32 0, i32* %6
store i32 0, i32* %7
store double 1.000000e+02, double* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 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* %2)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 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* %4)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 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* %6)
%15 = load i32, i32* %2
%16 = sitofp i32 %15 to double
%17 = load double, double* %8
%18 = fdiv double %16, %17
%19 = load double, double* %8
%20 = load i32, i32* %4
%21 = sitofp i32 %20 to double
%22 = fsub double %19, %21
%23 = fmul double %18, %22
store double %23, double* %3
%24 = load i32, i32* %6
%25 = sitofp i32 %24 to double
%26 = load double, double* %8
%27 = fdiv double %25, %26
%28 = load i32, i32* %4
%29 = sitofp i32 %28 to double
%30 = fmul double %27, %29
store double %30, double* %5
%31 = load double, double* %3
%32 = load double, double* %5
%33 = fadd double %31, %32
%34 = fadd double %33, 0x3FEFAE147AE147AE
%35 = fptosi double %34 to i32
store i32 %35, i32* %7
%36 = load i32, i32* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"What is your current grade? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [30 x i8] c"How much is the final worth? \00"
@.str.3 = [32 x i8] c"What is your final exam score? \00"
@.str.4 = [23 x i8] c"Your final grade is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = sitofp i32 %14 to double
%16 = fsub double 1.000000e+02, %15
%17 = load i32, i32* %3
%18 = insertelement <2 x i32> poison, i32 %13, i64 0
%19 = insertelement <2 x i32> %18, i32 %17, i64 1
%20 = sitofp <2 x i32> %19 to <2 x double>
%21 = fdiv <2 x double> %20, <double 1.000000e+02, double 1.000000e+02>
%22 = insertelement <2 x double> poison, double %16, i64 0
%23 = insertelement <2 x double> %22, double %15, i64 1
%24 = fmul <2 x double> %21, %23
%25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%26 = fadd <2 x double> %24, %25
%27 = extractelement <2 x double> %26, i64 0
%28 = fadd double %27, 0x3FEFAE147AE147AE
%29 = fptosi double %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %29)
%31 = call i32 @putchar(i32 37)
ret i32 0
}