#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 *, ...);
void greedyCoinReturn(double change) {
  double coins[8] = {0.01, 0.05, 0.1, 0.2, 0.5, 1, 2};
  int i;
  printf("The change of £%.2lf will be paid as follows:\n", change);
  for (i = 6; i >= 0; i--) {
    int remainderCoins = change / coins[i] + 1e-9;
    if (remainderCoins > 0) {
      printf("%d coins of £%.2lf\n", remainderCoins, coins[i]);
      change -= remainderCoins * coins[i];
    }
  }
  printf("\n");
  return;
}


x86 assembly (clang, -O0):
<greedyCoinReturn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xed8(%rip),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
movsd  -0x8(%rbp),%xmm0
lea    0xf02(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x6,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jl     11f8 <greedyCoinReturn+0xd8>
movsd  -0x8(%rbp),%xmm0
movslq -0x54(%rbp),%rax
divsd  -0x50(%rbp,%rax,8),%xmm0
movsd  0xe83(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jle    11e5 <greedyCoinReturn+0xc5>
mov    -0x58(%rbp),%esi
movslq -0x54(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm0
lea    0xeda(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvtsi2sdl -0x58(%rbp),%xmm0
movslq -0x54(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm2
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ea <greedyCoinReturn+0xca>
mov    -0x54(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x54(%rbp)
jmp    115c <greedyCoinReturn+0x3c>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<greedyCoinReturn>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
lea    0xf0e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
movsd  0xeb9(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xeb5(%rip),%xmm0
cvttsd2si %xmm0,%ebx
test   %ebx,%ebx
jle    1188 <greedyCoinReturn+0x68>
lea    0xf0e(%rip),%rdi
movsd  0xea6(%rip),%xmm0
mov    %ebx,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
addsd  %xmm0,%xmm0
subsd  %xmm0,%xmm1
movsd  0xe78(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ebx
test   %ebx,%ebx
jle    11cb <greedyCoinReturn+0xab>
lea    0xecd(%rip),%rdi
movsd  0xe6d(%rip),%xmm0
mov    %ebx,%esi
mov    $0x1,%al
movsd  %xmm1,0x8(%rsp)
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  0xe2d(%rip),%xmm0
cvttsd2si %xmm0,%ebx
test   %ebx,%ebx
jle    121a <greedyCoinReturn+0xfa>
lea    0xe86(%rip),%rdi
movsd  0xe0e(%rip),%xmm0
mov    %ebx,%esi
mov    $0x1,%al
movsd  %xmm1,0x8(%rsp)
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xdea(%rip),%xmm0
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
divsd  0xdfa(%rip),%xmm0
addsd  0xdda(%rip),%xmm0
cvttsd2si %xmm0,%ebx
test   %ebx,%ebx
jle    126d <greedyCoinReturn+0x14d>
lea    0xe33(%rip),%rdi
movsd  0xddb(%rip),%xmm0
mov    %ebx,%esi
mov    $0x1,%al
movsd  %xmm1,0x8(%rsp)
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xdb7(%rip),%xmm0
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
divsd  0xdaf(%rip),%xmm0
addsd  0xd87(%rip),%xmm0
cvttsd2si %xmm0,%ebx
test   %ebx,%ebx
jle    12c0 <greedyCoinReturn+0x1a0>
lea    0xde0(%rip),%rdi
movsd  0xd90(%rip),%xmm0
mov    %ebx,%esi
mov    $0x1,%al
movsd  %xmm1,0x8(%rsp)
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xd6c(%rip),%xmm0
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
divsd  0xd64(%rip),%xmm0
addsd  0xd34(%rip),%xmm0
cvttsd2si %xmm0,%ebx
test   %ebx,%ebx
jle    1313 <greedyCoinReturn+0x1f3>
lea    0xd8d(%rip),%rdi
movsd  0xd45(%rip),%xmm0
mov    %ebx,%esi
mov    $0x1,%al
movsd  %xmm1,0x8(%rsp)
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xd21(%rip),%xmm0
subsd  %xmm0,%xmm1
divsd  0xd1d(%rip),%xmm1
addsd  0xce5(%rip),%xmm1
cvttsd2si %xmm1,%esi
test   %esi,%esi
jle    1341 <greedyCoinReturn+0x221>
lea    0xd3e(%rip),%rdi
movsd  0xcfe(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@__const.greedyCoinReturn.coins = [8 x double] [double 1.000000e-02, double 5.000000e-02, double 1.000000e-01, double 2.000000e-01, double 5.000000e-01, double 1.000000e+00, double 2.000000e+00, double 0.000000e+00]
@.str = [48 x i8] c"The change of \C2\A3%.2lf will be paid as follows:\0A\00"
@.str.1 = [21 x i8] c"%d coins of \C2\A3%.2lf\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @greedyCoinReturn(double %0) {
%2 = alloca double
%3 = alloca [8 x double]
%4 = alloca i32
%5 = alloca i32
store double %0, double* %2
%6 = bitcast [8 x double]* %3 to i8*
%7 = load double, double* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), double %7)
store i32 6, i32* %4
br label %9
9: ; preds = %40, %1
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %43
12: ; preds = %9
%13 = load double, double* %2
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 %15
%17 = load double, double* %16
%18 = fdiv double %13, %17
%19 = fadd double %18, 1.000000e-09
%20 = fptosi double %19 to i32
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %39
23: ; preds = %12
%24 = load i32, i32* %5
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 %26
%28 = load double, double* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %24, double %28)
%30 = load i32, i32* %5
%31 = sitofp i32 %30 to double
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [8 x double], [8 x double]* %3, i64 0, i64 %33
%35 = load double, double* %34
%36 = load double, double* %2
%37 = fneg double %31
%38 = call double @llvm.fmuladd.f64(double %37, double %35, double %36)
store double %38, double* %2
br label %39
39: ; preds = %23, %12
br label %40
40: ; preds = %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, -1
store i32 %42, i32* %4
br label %9
43: ; preds = %9
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [48 x i8] c"The change of \C2\A3%.2lf will be paid as follows:\0A\00"
@.str.1 = [21 x i8] c"%d coins of \C2\A3%.2lf\0A\00"
define void @greedyCoinReturn(double %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), double %0)
%3 = fmul double %0, 5.000000e-01
%4 = fadd double %3, 1.000000e-09
%5 = fptosi double %4 to i32
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %5, double 2.000000e+00)
%9 = sitofp i32 %5 to double
%10 = fneg double %9
%11 = tail call double @llvm.fmuladd.f64(double %10, double 2.000000e+00, double %0)
br label %12
12: ; preds = %7, %1
%13 = phi double [ %11, %7 ], [ %0, %1 ]
%14 = fadd double %13, 1.000000e-09
%15 = fptosi double %14 to i32
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %15, double 1.000000e+00)
%19 = sitofp i32 %15 to double
%20 = fsub double %13, %19
br label %21
21: ; preds = %17, %12
%22 = phi double [ %20, %17 ], [ %13, %12 ]
%23 = fmul double %22, 2.000000e+00
%24 = fadd double %23, 1.000000e-09
%25 = fptosi double %24 to i32
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %21
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %25, double 5.000000e-01)
%29 = sitofp i32 %25 to double
%30 = fneg double %29
%31 = tail call double @llvm.fmuladd.f64(double %30, double 5.000000e-01, double %22)
br label %32
32: ; preds = %27, %21
%33 = phi double [ %31, %27 ], [ %22, %21 ]
%34 = fdiv double %33, 2.000000e-01
%35 = fadd double %34, 1.000000e-09
%36 = fptosi double %35 to i32
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %32
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %36, double 2.000000e-01)
%40 = sitofp i32 %36 to double
%41 = fneg double %40
%42 = tail call double @llvm.fmuladd.f64(double %41, double 2.000000e-01, double %33)
br label %43
43: ; preds = %38, %32
%44 = phi double [ %42, %38 ], [ %33, %32 ]
%45 = fdiv double %44, 1.000000e-01
%46 = fadd double %45, 1.000000e-09
%47 = fptosi double %46 to i32
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %43
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %47, double 1.000000e-01)
%51 = sitofp i32 %47 to double
%52 = fneg double %51
%53 = tail call double @llvm.fmuladd.f64(double %52, double 1.000000e-01, double %44)
br label %54
54: ; preds = %49, %43
%55 = phi double [ %53, %49 ], [ %44, %43 ]
%56 = fdiv double %55, 5.000000e-02
%57 = fadd double %56, 1.000000e-09
%58 = fptosi double %57 to i32
%59 = icmp sgt i32 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %54
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %58, double 5.000000e-02)
%62 = sitofp i32 %58 to double
%63 = fneg double %62
%64 = tail call double @llvm.fmuladd.f64(double %63, double 5.000000e-02, double %55)
br label %65
65: ; preds = %60, %54
%66 = phi double [ %64, %60 ], [ %55, %54 ]
%67 = fdiv double %66, 1.000000e-02
%68 = fadd double %67, 1.000000e-09
%69 = fptosi double %68 to i32
%70 = icmp sgt i32 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %65
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %69, double 1.000000e-02)
br label %73
73: ; preds = %71, %65
%74 = tail call i32 @putchar(i32 10)
ret void
}