#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 */
float pow(int, int);
int /*<<< orphan*/ printf(char *, float, float);
float getDiscount(int years, float annual_rate) {
  float dis, rate;
  int num_of_pay;
  num_of_pay = (int)(12 * years);
  rate = (annual_rate / 100.0) / 12;
  dis =
      ((pow((1 + rate), num_of_pay) - 1) / (rate * pow(1 + rate, num_of_pay)));
  if (0)
    printf("monthly rate is :%f\n, discount is: %f\n", rate, dis);
  return dis;
}


x86 assembly (clang, -O0):
<getDiscount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
imul   $0xc,-0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xed8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xec4(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xea7(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
cvttss2si %xmm0,%edi
mov    -0x14(%rbp),%esi
call   1030 <pow@plt>
movss  0xe8e(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe73(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
cvttss2si %xmm0,%edi
mov    -0x14(%rbp),%esi
call   1030 <pow@plt>
movss  -0x1c(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x18(%rbp),%xmm0
mulss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getDiscount>:
push   %rbp
push   %rbx
push   %rax
shl    $0x2,%edi
lea    (%rdi,%rdi,2),%ebx
cvtss2sd %xmm0,%xmm0
divsd  0xedb(%rip),%xmm0
divsd  0xedb(%rip),%xmm0
cvtsd2ss %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0xed1(%rip),%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%ebp
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <pow@plt>
addss  0xebc(%rip),%xmm0
movss  %xmm0,(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <pow@plt>
mulss  0x4(%rsp),%xmm0
movss  (%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define float @getDiscount(i32 %0, float %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
store i32 %0, i32* %3
store float %1, float* %4
%8 = load i32, i32* %3
%9 = mul nsw i32 12, %8
store i32 %9, i32* %7
%10 = load float, float* %4
%11 = fpext float %10 to double
%12 = fdiv double %11, 1.000000e+02
%13 = fdiv double %12, 1.200000e+01
%14 = fptrunc double %13 to float
store float %14, float* %6
%15 = load float, float* %6
%16 = fadd float 1.000000e+00, %15
%17 = fptosi float %16 to i32
%18 = load i32, i32* %7
%19 = call float @pow(i32 %17, i32 %18)
%20 = fsub float %19, 1.000000e+00
%21 = load float, float* %6
%22 = load float, float* %6
%23 = fadd float 1.000000e+00, %22
%24 = fptosi float %23 to i32
%25 = load i32, i32* %7
%26 = call float @pow(i32 %24, i32 %25)
%27 = fmul float %21, %26
%28 = fdiv float %20, %27
store float %28, float* %5
%29 = load float, float* %5
ret float %29
}

LLVM IR (-O2):
define float @getDiscount(i32 %0, float %1) {
%3 = mul nsw i32 %0, 12
%4 = fpext float %1 to double
%5 = fdiv double %4, 1.000000e+02
%6 = fdiv double %5, 1.200000e+01
%7 = fptrunc double %6 to float
%8 = fadd float %7, 1.000000e+00
%9 = fptosi float %8 to i32
%10 = tail call float @pow(i32 %9, i32 %3)
%11 = fadd float %10, -1.000000e+00
%12 = tail call float @pow(i32 %9, i32 %3)
%13 = fmul float %12, %7
%14 = fdiv float %11, %13
ret float %14
}