#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 *, double);
void showprice(double rate, int nights) {
  int n;
  double total = 0.0;
  double factor = 1.0;
  for (n = 1; n <= nights; n++, factor *= 0.95) {
    total += rate * factor;
  }
  printf("The total cost will be $%0.2f.\n", total);
}


x86 assembly (clang, -O0):
<showprice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1184 <showprice+0x74>
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movsd  0xe93(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    113c <showprice+0x2c>
movsd  -0x18(%rbp),%xmm0
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showprice>:
test   %edi,%edi
jle    112f <showprice+0x1f>
lea    -0x1(%rdi),%ecx
mov    %edi,%eax
and    $0x3,%eax
cmp    $0x3,%ecx
jae    1138 <showprice+0x28>
xorpd  %xmm1,%xmm1
movsd  0xed3(%rip),%xmm2
jmp    1195 <showprice+0x85>
xorpd  %xmm1,%xmm1
jmp    11c5 <showprice+0xb5>
and    $0xfffffffc,%edi
xorpd  %xmm1,%xmm1
movsd  0xeb9(%rip),%xmm2
movsd  0xeb9(%rip),%xmm3
nop
movapd %xmm0,%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm1,%xmm4
mulsd  %xmm3,%xmm2
movapd %xmm0,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm4,%xmm1
mulsd  %xmm3,%xmm2
movapd %xmm0,%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm1,%xmm4
mulsd  %xmm3,%xmm2
movapd %xmm0,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm4,%xmm1
mulsd  %xmm3,%xmm2
add    $0xfffffffc,%edi
jne    1150 <showprice+0x40>
test   %eax,%eax
je     11c5 <showprice+0xb5>
movsd  0xe67(%rip),%xmm3
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movapd %xmm0,%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm4,%xmm1
mulsd  %xmm3,%xmm2
add    $0xffffffff,%eax
jne    11b0 <showprice+0xa0>
lea    0xe44(%rip),%rdi
movapd %xmm1,%xmm0
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"The total cost will be $%0.2f.\0A\00"
define void @showprice(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %6
store double 1.000000e+00, double* %7
store i32 1, i32* %5
br label %8
8: ; preds = %17, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = load double, double* %3
%14 = load double, double* %7
%15 = load double, double* %6
%16 = call double @llvm.fmuladd.f64(double %13, double %14, double %15)
store double %16, double* %6
br label %17
17: ; preds = %12
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
%20 = load double, double* %7
%21 = fmul double %20, 0x3FEE666666666666
store double %21, double* %7
br label %8
22: ; preds = %8
%23 = load double, double* %6
%24 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %23)
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"The total cost will be $%0.2f.\0A\00"
define void @showprice(double %0, i32 %1) {
%3 = icmp slt i32 %1, 1
br i1 %3, label %37, label %4
4: ; preds = %2
%5 = add i32 %1, -1
%6 = and i32 %1, 3
%7 = icmp ult i32 %5, 3
br i1 %7, label %24, label %8
8: ; preds = %4
%9 = and i32 %1, -4
br label %10
10: ; preds = %10, %8
%11 = phi double [ 1.000000e+00, %8 ], [ %21, %10 ]
%12 = phi double [ 0.000000e+00, %8 ], [ %20, %10 ]
%13 = phi i32 [ 0, %8 ], [ %22, %10 ]
%14 = tail call double @llvm.fmuladd.f64(double %0, double %11, double %12)
%15 = fmul double %11, 0x3FEE666666666666
%16 = tail call double @llvm.fmuladd.f64(double %0, double %15, double %14)
%17 = fmul double %15, 0x3FEE666666666666
%18 = tail call double @llvm.fmuladd.f64(double %0, double %17, double %16)
%19 = fmul double %17, 0x3FEE666666666666
%20 = tail call double @llvm.fmuladd.f64(double %0, double %19, double %18)
%21 = fmul double %19, 0x3FEE666666666666
%22 = add i32 %13, 4
%23 = icmp eq i32 %22, %9
br i1 %23, label %24, label %10
24: ; preds = %10, %4
%25 = phi double [ undef, %4 ], [ %20, %10 ]
%26 = phi double [ 1.000000e+00, %4 ], [ %21, %10 ]
%27 = phi double [ 0.000000e+00, %4 ], [ %20, %10 ]
%28 = icmp eq i32 %6, 0
br i1 %28, label %37, label %29
29: ; preds = %24, %29
%30 = phi double [ %34, %29 ], [ %26, %24 ]
%31 = phi double [ %33, %29 ], [ %27, %24 ]
%32 = phi i32 [ %35, %29 ], [ 0, %24 ]
%33 = tail call double @llvm.fmuladd.f64(double %0, double %30, double %31)
%34 = fmul double %30, 0x3FEE666666666666
%35 = add i32 %32, 1
%36 = icmp eq i32 %35, %6
br i1 %36, label %37, label %29
37: ; preds = %24, %29, %2
%38 = phi double [ 0.000000e+00, %2 ], [ %25, %24 ], [ %33, %29 ]
%39 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %38)
ret void
}