#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 main() {
  float n, b, times, i;
  float total, a;
  int d, c;
  printf("What is the principle amount");
  scanf("%f", &a);
  printf("Type the interest rate and on how many months\nInterest Rate:");
  scanf("%f", &b);
  printf("\nNo. of Months:");
  scanf("%d", &c);
  printf("After how many months do you want to calculate the total amount");
  scanf("%d", &d);
  times = d / c;
  printf("What do you want to calculate?\n 1.Simple Interest\n 2.Compound "
         "Interest");
  scanf("%f", &n);
  if (n == 1) {
    total = a + (b / 100) * a * times;
  } else if (n == 2) {
    total = a;
    for (i = 1; i <= times; i++) {
      total = total + (total * (b / 100));
    }
  } else {
    printf("Invalid Entry");
  }
  printf("The amount you have to pay after %d months is %f", d, total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xff8(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfd8(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x20(%rbp),%eax
cltd
idivl  -0x24(%rbp)
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf68(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
movss  0xe14(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    122d <main+0x10d>
jp     122d <main+0x10d>
movss  -0x1c(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
movss  0xdfb(%rip),%xmm2
divss  %xmm2,%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    12ca <main+0x1aa>
movss  -0x8(%rbp),%xmm0
movss  0xdca(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    12b7 <main+0x197>
jp     12b7 <main+0x197>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xda5(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     12b2 <main+0x192>
movss  -0x18(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  0xd7e(%rip),%xmm3
divss  %xmm3,%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xd5d(%rip),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1260 <main+0x140>
jmp    12c5 <main+0x1a5>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ca <main+0x1aa>
mov    -0x20(%rbp),%esi
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe31(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xedf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x1001(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xef8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefa(%rip),%rbp
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xee7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cltd
idivl  0x10(%rsp)
mov    %eax,%ebp
cvtsi2ss %eax,%xmm0
movss  %xmm0,(%rsp)
lea    0xef6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0x14(%rsp),%xmm0
ucomiss 0xe1a(%rip),%xmm0
jne    122a <main+0x10a>
jp     122a <main+0x10a>
movss  0xc(%rsp),%xmm0
divss  0xe10(%rip),%xmm0
movss  0x8(%rsp),%xmm1
mulss  %xmm1,%xmm0
mulss  (%rsp),%xmm0
addss  %xmm1,%xmm0
mov    0x4(%rsp),%esi
cvtss2sd %xmm0,%xmm0
lea    0xef4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
movss  (%rsp),%xmm5
ucomiss 0xdce(%rip),%xmm0
jne    1276 <main+0x156>
jp     1276 <main+0x156>
movss  0x8(%rsp),%xmm0
test   %ebp,%ebp
jle    120b <main+0xeb>
movss  0xc(%rsp),%xmm1
divss  0xdb6(%rip),%xmm1
movss  0xda6(%rip),%xmm2
movaps %xmm2,%xmm3
nopl   (%rax)
movaps %xmm0,%xmm4
mulss  %xmm1,%xmm4
addss  %xmm4,%xmm0
addss  %xmm2,%xmm3
ucomiss %xmm3,%xmm5
jae    1260 <main+0x140>
jmp    120b <main+0xeb>
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    120b <main+0xeb>

LLVM IR (-O0):
@.str = [29 x i8] c"What is the principle amount\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [61 x i8] c"Type the interest rate and on how many months\0AInterest Rate:\00"
@.str.3 = [16 x i8] c"\0ANo. of Months:\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [64 x i8] c"After how many months do you want to calculate the total amount\00"
@.str.6 = [71 x i8] c"What do you want to calculate?\0A 1.Simple Interest\0A 2.Compound Interest\00"
@.str.7 = [14 x i8] c"Invalid Entry\00"
@.str.8 = [49 x i8] c"The amount you have to pay after %d months is %f\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 i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %7)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %9)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = sdiv i32 %18, %19
%21 = sitofp i32 %20 to float
store float %21, float* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%24 = load float, float* %2
%25 = fcmp oeq float %24, 1.000000e+00
br i1 %25, label %26, label %34
26: ; preds = %0
%27 = load float, float* %7
%28 = load float, float* %3
%29 = fdiv float %28, 1.000000e+02
%30 = load float, float* %7
%31 = fmul float %29, %30
%32 = load float, float* %4
%33 = call float @llvm.fmuladd.f32(float %31, float %32, float %27)
store float %33, float* %6
br label %56
34: ; preds = %0
%35 = load float, float* %2
%36 = fcmp oeq float %35, 2.000000e+00
br i1 %36, label %37, label %53
37: ; preds = %34
%38 = load float, float* %7
store float %38, float* %6
store float 1.000000e+00, float* %5
br label %39
39: ; preds = %49, %37
%40 = load float, float* %5
%41 = load float, float* %4
%42 = fcmp ole float %40, %41
br i1 %42, label %43, label %52
43: ; preds = %39
%44 = load float, float* %6
%45 = load float, float* %6
%46 = load float, float* %3
%47 = fdiv float %46, 1.000000e+02
%48 = call float @llvm.fmuladd.f32(float %45, float %47, float %44)
store float %48, float* %6
br label %49
49: ; preds = %43
%50 = load float, float* %5
%51 = fadd float %50, 1.000000e+00
store float %51, float* %5
br label %39
52: ; preds = %39
br label %55
53: ; preds = %34
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %55
55: ; preds = %53, %52
br label %56
56: ; preds = %55, %26
%57 = load i32, i32* %8
%58 = load float, float* %6
%59 = fpext float %58 to double
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i32 %57, double %59)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"What is the principle amount\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [61 x i8] c"Type the interest rate and on how many months\0AInterest Rate:\00"
@.str.3 = [16 x i8] c"\0ANo. of Months:\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [64 x i8] c"After how many months do you want to calculate the total amount\00"
@.str.6 = [71 x i8] c"What do you want to calculate?\0A 1.Simple Interest\0A 2.Compound Interest\00"
@.str.7 = [14 x i8] c"Invalid Entry\00"
@.str.8 = [49 x i8] c"The amount you have to pay after %d months is %f\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = bitcast float* %1 to i8*
%7 = bitcast float* %2 to i8*
%8 = bitcast float* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = sdiv i32 %19, %20
%22 = sitofp i32 %21 to float
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.6, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%25 = load float, float* %1
%26 = fcmp oeq float %25, 1.000000e+00
br i1 %26, label %27, label %33
27: ; preds = %0
%28 = load float, float* %3
%29 = load float, float* %2
%30 = fdiv float %29, 1.000000e+02
%31 = fmul float %28, %30
%32 = call float @llvm.fmuladd.f32(float %31, float %22, float %28)
br label %49
33: ; preds = %0
%34 = fcmp oeq float %25, 2.000000e+00
br i1 %34, label %35, label %47
35: ; preds = %33
%36 = load float, float* %3
%37 = icmp slt i32 %21, 1
br i1 %37, label %49, label %38
38: ; preds = %35
%39 = load float, float* %2
%40 = fdiv float %39, 1.000000e+02
br label %41
41: ; preds = %38, %41
%42 = phi float [ %36, %38 ], [ %44, %41 ]
%43 = phi float [ 1.000000e+00, %38 ], [ %45, %41 ]
%44 = call float @llvm.fmuladd.f32(float %42, float %40, float %42)
%45 = fadd float %43, 1.000000e+00
%46 = fcmp ugt float %45, %22
br i1 %46, label %49, label %41
47: ; preds = %33
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %49
49: ; preds = %41, %35, %47, %27
%50 = phi float [ %32, %27 ], [ undef, %47 ], [ %36, %35 ], [ %44, %41 ]
%51 = load i32, i32* %4
%52 = fpext float %50 to double
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i32 %51, double %52)
ret i32 0
}