#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 */
typedef scalar_t__ uint8_t;
typedef scalar_t__ uint32_t;
typedef double int64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int64_t deposit = 0;
  float rate = 0.0;
  uint32_t years = 0;
  double result = 0.0;
  printf("Welcome to interest calculator!\n");
  printf("Please, enter deposit amount: ");
  scanf("%ld", &deposit);
  printf("Please, enter interest rate(%%): ");
  scanf("%f", &rate);
  rate /= 100;
  printf("Please, enter duration ");
  scanf("%u", &years);
  result = deposit;
  for (uint8_t i = 0; i < years; ++i) {
    result += result * rate;
  }
  printf("Resulting sum: %f, interst: %f\n", result, result - deposit);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x14(%rbp),%xmm0
movss  0xe56(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    1224 <main+0x104>
movsd  -0x28(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11e5 <main+0xc5>
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
lea    0xe4e(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
movl   $0x0,0x4(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xf32(%rip),%rdi
call   1030 <puts@plt>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm0
divss  0xe56(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm2
mov    0x8(%rsp),%rcx
movapd %xmm2,%xmm0
test   %rcx,%rcx
jle    1292 <main+0x162>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm1
lea    -0x1(%rcx),%rdx
mov    %ecx,%eax
and    $0x7,%eax
movapd %xmm2,%xmm0
cmp    $0x7,%rdx
jb     1276 <main+0x146>
and    $0xfffffffffffffff8,%rcx
movapd %xmm2,%xmm0
xchg   %ax,%ax
movapd %xmm0,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
movapd %xmm0,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
movapd %xmm0,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
movapd %xmm0,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
add    $0xfffffffffffffff8,%rcx
jne    1210 <main+0xe0>
test   %rax,%rax
je     1292 <main+0x162>
nopl   0x0(%rax,%rax,1)
movapd %xmm0,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm3,%xmm0
add    $0xffffffffffffffff,%rax
jne    1280 <main+0x150>
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
lea    0xdc6(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Welcome to interest calculator!\0A\00"
@.str.1 = [31 x i8] c"Please, enter deposit amount: \00"
@.str.2 = [4 x i8] c"%ld\00"
@.str.3 = [34 x i8] c"Please, enter interest rate(%%): \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [24 x i8] c"Please, enter duration \00"
@.str.6 = [3 x i8] c"%u\00"
@.str.7 = [32 x i8] c"Resulting sum: %f, interst: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca float
%4 = alloca i64
%5 = alloca double
%6 = alloca i64
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store float 0.000000e+00, float* %3
store i64 0, i64* %4
store double 0.000000e+00, double* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %3)
%12 = load float, float* %3
%13 = fdiv float %12, 1.000000e+02
store float %13, float* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i64* %4)
%16 = load double, double* %2
store double %16, double* %5
store i64 0, i64* %6
br label %17
17: ; preds = %27, %0
%18 = load i64, i64* %6
%19 = load i64, i64* %4
%20 = icmp slt i64 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load double, double* %5
%23 = load float, float* %3
%24 = fpext float %23 to double
%25 = load double, double* %5
%26 = call double @llvm.fmuladd.f64(double %22, double %24, double %25)
store double %26, double* %5
br label %27
27: ; preds = %21
%28 = load i64, i64* %6
%29 = add nsw i64 %28, 1
store i64 %29, i64* %6
br label %17
30: ; preds = %17
%31 = load double, double* %5
%32 = load double, double* %5
%33 = load double, double* %2
%34 = fsub double %32, %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), double %31, double %34)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"Please, enter deposit amount: \00"
@.str.2 = [4 x i8] c"%ld\00"
@.str.3 = [34 x i8] c"Please, enter interest rate(%%): \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [24 x i8] c"Please, enter duration \00"
@.str.6 = [3 x i8] c"%u\00"
@.str.7 = [32 x i8] c"Resulting sum: %f, interst: %f\0A\00"
@str = [32 x i8] c"Welcome to interest calculator!\00"
define i32 @main() {
%1 = alloca double
%2 = alloca float
%3 = alloca i64
%4 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%5 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %2)
%12 = load float, float* %2
%13 = fdiv float %12, 1.000000e+02
store float %13, float* %2
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i64* %3)
%16 = load double, double* %1
%17 = load i64, i64* %3
%18 = icmp sgt i64 %17, 0
br i1 %18, label %19, label %37
19: ; preds = %0
%20 = load float, float* %2
%21 = fpext float %20 to double
%22 = add i64 %17, -1
%23 = and i64 %17, 7
%24 = icmp ult i64 %22, 7
br i1 %24, label %27, label %25
25: ; preds = %19
%26 = and i64 %17, -8
br label %41
27: ; preds = %41, %19
%28 = phi double [ undef, %19 ], [ %51, %41 ]
%29 = phi double [ %16, %19 ], [ %51, %41 ]
%30 = icmp eq i64 %23, 0
br i1 %30, label %37, label %31
31: ; preds = %27, %31
%32 = phi double [ %34, %31 ], [ %29, %27 ]
%33 = phi i64 [ %35, %31 ], [ 0, %27 ]
%34 = call double @llvm.fmuladd.f64(double %32, double %21, double %32)
%35 = add i64 %33, 1
%36 = icmp eq i64 %35, %23
br i1 %36, label %37, label %31
37: ; preds = %27, %31, %0
%38 = phi double [ %16, %0 ], [ %28, %27 ], [ %34, %31 ]
%39 = fsub double %38, %16
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), double %38, double %39)
ret i32 0
41: ; preds = %41, %25
%42 = phi double [ %16, %25 ], [ %51, %41 ]
%43 = phi i64 [ 0, %25 ], [ %52, %41 ]
%44 = call double @llvm.fmuladd.f64(double %42, double %21, double %42)
%45 = call double @llvm.fmuladd.f64(double %44, double %21, double %44)
%46 = call double @llvm.fmuladd.f64(double %45, double %21, double %45)
%47 = call double @llvm.fmuladd.f64(double %46, double %21, double %46)
%48 = call double @llvm.fmuladd.f64(double %47, double %21, double %47)
%49 = call double @llvm.fmuladd.f64(double %48, double %21, double %48)
%50 = call double @llvm.fmuladd.f64(double %49, double %21, double %49)
%51 = call double @llvm.fmuladd.f64(double %50, double %21, double %50)
%52 = add i64 %43, 8
%53 = icmp eq i64 %52, %26
br i1 %53, label %27, label %41
}