int main() {
  int graduation_threshold = 70;
  float your_grade = 69.9999;
  float your_grade_rounded = round(your_grade);
  printf("Your rounded grade as a double: %.2f\n", your_grade_rounded);
  int your_grade_as_int = your_grade;
  int your_grade_as_int_rounded = round(your_grade_as_int);
  if (your_grade_as_int_rounded >= graduation_threshold) {
    printf("You graduated. Congrats!\n");
  } else {
    printf("You failed! Oh no!\n");
  }
  printf("Your final grade: %d\n", your_grade_as_int_rounded);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x46,-0x8(%rbp)
movss  0xec2(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <round@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvttss2si -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
call   1040 <round@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     11a9 <main+0x89>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b7 <main+0x97>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee0(%rip),%rdi
movsd  0xed0(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
lea    0xee4(%rip),%rdi
mov    $0x45,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Your rounded grade as a double: %.2f\0A\00"
@.str.1 = [26 x i8] c"You graduated. Congrats!\0A\00"
@.str.2 = [20 x i8] c"You failed! Oh no!\0A\00"
@.str.3 = [22 x i8] c"Your final grade: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 70, i32* %2
store float 0x40517FFE60000000, float* %3
%7 = load float, float* %3
%8 = fpext float %7 to double
%9 = call double @llvm.round.f64(double %8)
%10 = fptrunc double %9 to float
store float %10, float* %4
%11 = load float, float* %4
%12 = fpext float %11 to double
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), double %12)
%14 = load float, float* %3
%15 = fptosi float %14 to i32
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = sitofp i32 %16 to double
%18 = call double @llvm.round.f64(double %17)
%19 = fptosi double %18 to i32
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = load i32, i32* %2
%22 = icmp sge i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %27
25: ; preds = %0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
%28 = load i32, i32* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"Your rounded grade as a double: %.2f\0A\00"
@.str.3 = [22 x i8] c"Your final grade: %d\0A\00"
@str = [19 x i8] c"You failed! Oh no!\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), double 7.000000e+01)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 69)
ret i32 0
}