#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() {
  int i, times;
  float rate, loan, remainder;
  printf("Enter amount of loan:");
  scanf("%f", &loan);
  printf("Enter interest rate:");
  scanf("%f", &rate);
  printf("Enter payment times:");
  scanf("%d", &times);
  rate /= (float)times * 100;
  for (i = 0; i < times; i++) {
    remainder = (loan * (((float)times - i - 1) / (float)times)) * (1.0 + rate);
    printf("loan remain:%.2f\n", remainder);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cvtsi2ssl -0xc(%rbp),%xmm1
movss  0xe64(%rip),%xmm0
mulss  %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1238 <main+0x118>
movss  -0x14(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
cvtsi2ssl -0x8(%rbp),%xmm2
subss  %xmm2,%xmm1
movss  0xe28(%rip),%xmm2
subss  %xmm2,%xmm1
cvtsi2ssl -0xc(%rbp),%xmm2
divss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe06(%rip),%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe33(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b5 <main+0x95>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xee2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeea(%rip),%rbx
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xed7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
cvtsi2ss %eax,%xmm1
mulss  0xe67(%rip),%xmm1
movss  0xc(%rsp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
test   %eax,%eax
jle    1226 <main+0x106>
mov    $0x1,%ebx
lea    0xe9d(%rip),%r14
nopl   0x0(%rax)
lea    -0x1(%rbx),%ecx
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
xorps  %xmm2,%xmm2
cvtsi2ss %ecx,%xmm2
movaps %xmm1,%xmm3
subss  %xmm2,%xmm3
addss  0xe24(%rip),%xmm3
divss  %xmm1,%xmm3
mulss  0x14(%rsp),%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
cvtss2sd %xmm0,%xmm0
addsd  0xe0b(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x10(%rsp),%eax
cmp    %eax,%ebx
jge    1226 <main+0x106>
movss  0xc(%rsp),%xmm0
add    $0x1,%ebx
jmp    11c0 <main+0xa0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter amount of loan:\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [21 x i8] c"Enter interest rate:\00"
@.str.3 = [21 x i8] c"Enter payment times:\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [18 x i8] c"loan remain:%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = sitofp i32 %13 to float
%15 = fmul float %14, 1.000000e+02
%16 = load float, float* %4
%17 = fdiv float %16, %15
store float %17, float* %4
store i32 0, i32* %2
br label %18
18: ; preds = %43, %0
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %46
22: ; preds = %18
%23 = load float, float* %5
%24 = load i32, i32* %3
%25 = sitofp i32 %24 to float
%26 = load i32, i32* %2
%27 = sitofp i32 %26 to float
%28 = fsub float %25, %27
%29 = fsub float %28, 1.000000e+00
%30 = load i32, i32* %3
%31 = sitofp i32 %30 to float
%32 = fdiv float %29, %31
%33 = fmul float %23, %32
%34 = fpext float %33 to double
%35 = load float, float* %4
%36 = fpext float %35 to double
%37 = fadd double 1.000000e+00, %36
%38 = fmul double %34, %37
%39 = fptrunc double %38 to float
store float %39, float* %6
%40 = load float, float* %6
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), double %41)
br label %43
43: ; preds = %22
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %18
46: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Enter amount of loan:\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [21 x i8] c"Enter interest rate:\00"
@.str.3 = [21 x i8] c"Enter payment times:\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [18 x i8] c"loan remain:%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = bitcast i32* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = sitofp i32 %13 to float
%15 = fmul float %14, 1.000000e+02
%16 = load float, float* %2
%17 = fdiv float %16, %15
store float %17, float* %2
%18 = icmp sgt i32 %13, 0
br i1 %18, label %19, label %42
19: ; preds = %0, %40
%20 = phi float [ %41, %40 ], [ %17, %0 ]
%21 = phi i32 [ %38, %40 ], [ %13, %0 ]
%22 = phi i32 [ %37, %40 ], [ 0, %0 ]
%23 = load float, float* %3
%24 = sitofp i32 %21 to float
%25 = sitofp i32 %22 to float
%26 = fsub float %24, %25
%27 = fadd float %26, -1.000000e+00
%28 = fdiv float %27, %24
%29 = fmul float %28, %23
%30 = fpext float %29 to double
%31 = fpext float %20 to double
%32 = fadd double %31, 1.000000e+00
%33 = fmul double %32, %30
%34 = fptrunc double %33 to float
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), double %35)
%37 = add nuw nsw i32 %22, 1
%38 = load i32, i32* %1
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %19
%41 = load float, float* %2
br label %19
42: ; preds = %19, %0
ret i32 0
}