#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*/ fetchInput(double *, double *, int *);
int pow(int, int);
int /*<<< orphan*/ printf(char *, double, double, int);
double computePayment() {
  double principal = 0;
  double rate = 0;
  int periods = 0;
  fetchInput(&principal, &rate, &periods);
  printf("%.2f, %.2f, %d\n", principal, rate, periods);
  rate = (rate / 100) / 12;
  return principal * (rate * pow((1 + rate), periods)) /
         ((pow((1 + rate), periods)) - 1);
}


x86 assembly (clang, -O0):
<computePayment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <fetchInput@plt>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x14(%rbp),%esi
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xe8a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe76(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe49(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
mov    -0x14(%rbp),%esi
call   1050 <pow@plt>
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe15(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
mov    -0x14(%rbp),%esi
call   1050 <pow@plt>
movsd  -0x20(%rbp),%xmm0
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<computePayment>:
sub    $0x28,%rsp
movq   $0x0,0x18(%rsp)
movq   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x18(%rsp),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1040 <fetchInput@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    0x4(%rsp),%esi
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm1
divsd  0xe74(%rip),%xmm1
divsd  0xe74(%rip),%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movapd %xmm1,%xmm0
addsd  0xe58(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    0x4(%rsp),%esi
call   1050 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x20(%rsp),%xmm0
movsd  0xe36(%rip),%xmm1
addsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
cvttsd2si %xmm1,%edi
mov    0x4(%rsp),%esi
call   1050 <pow@plt>
add    $0xffffffff,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%.2f, %.2f, %d\0A\00"
define double @computePayment() {
%1 = alloca double
%2 = alloca double
%3 = alloca i32
store double 0.000000e+00, double* %1
store double 0.000000e+00, double* %2
store i32 0, i32* %3
%4 = call i32 @fetchInput(double* %1, double* %2, i32* %3)
%5 = load double, double* %1
%6 = load double, double* %2
%7 = load i32, i32* %3
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %5, double %6, i32 %7)
%9 = load double, double* %2
%10 = fdiv double %9, 1.000000e+02
%11 = fdiv double %10, 1.200000e+01
store double %11, double* %2
%12 = load double, double* %1
%13 = load double, double* %2
%14 = load double, double* %2
%15 = fadd double 1.000000e+00, %14
%16 = fptosi double %15 to i32
%17 = load i32, i32* %3
%18 = call i32 @pow(i32 %16, i32 %17)
%19 = sitofp i32 %18 to double
%20 = fmul double %13, %19
%21 = fmul double %12, %20
%22 = load double, double* %2
%23 = fadd double 1.000000e+00, %22
%24 = fptosi double %23 to i32
%25 = load i32, i32* %3
%26 = call i32 @pow(i32 %24, i32 %25)
%27 = sub nsw i32 %26, 1
%28 = sitofp i32 %27 to double
%29 = fdiv double %21, %28
ret double %29
}

LLVM IR (-O2):
@.str = [16 x i8] c"%.2f, %.2f, %d\0A\00"
define double @computePayment() {
%1 = alloca double
%2 = alloca double
%3 = alloca i32
%4 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%5 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = call i32 @fetchInput(double* %1, double* %2, i32* %3)
%8 = load double, double* %1
%9 = load double, double* %2
%10 = load i32, i32* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), double %8, double %9, i32 %10)
%12 = load double, double* %2
%13 = fdiv double %12, 1.000000e+02
%14 = fdiv double %13, 1.200000e+01
store double %14, double* %2
%15 = load double, double* %1
%16 = fadd double %14, 1.000000e+00
%17 = fptosi double %16 to i32
%18 = load i32, i32* %3
%19 = call i32 @pow(i32 %17, i32 %18)
%20 = sitofp i32 %19 to double
%21 = fmul double %14, %20
%22 = fmul double %15, %21
%23 = load double, double* %2
%24 = fadd double %23, 1.000000e+00
%25 = fptosi double %24 to i32
%26 = load i32, i32* %3
%27 = call i32 @pow(i32 %25, i32 %26)
%28 = add nsw i32 %27, -1
%29 = sitofp i32 %28 to double
%30 = fdiv double %22, %29
ret double %30
}