#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 *, ...);
int round(float);
int /*<<< orphan*/ scanf(char *, float *);
void greedy(void) {
  int i;
  int coins[4] = {0, 0, 0, 0};
  int coinValues[4] = {25, 10, 5, 1};
  int balance;
  float change;
  do {
    printf("Enter amount of change:");
    scanf("%f.2", &change);
  } while (change < 0 || change);
  change *= 100;
  balance = round(change);
  for (i = 0; i < 5; i++) {
    while (balance >= coinValues[i]) {
      coins[i]++;
      balance -= coinValues[i];
    }
  }
  printf("%d quarters, %d dimes, %d nickel, and %d pennies", coins[0], coins[1],
         coins[2], coins[3]);
}


x86 assembly (clang, -O0):
<greedy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    0xeb1(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x1,%al
xorps  %xmm0,%xmm0
ucomiss -0x38(%rbp),%xmm0
mov    %al,-0x39(%rbp)
ja     11b4 <greedy+0x74>
movss  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
setne  %al
setp   %cl
or     %cl,%al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    116e <greedy+0x2e>
movss  0xe39(%rip),%xmm0
mulss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
call   1060 <round@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x5,-0x4(%rbp)
jge    123c <greedy+0xfc>
jmp    11f4 <greedy+0xb4>
mov    -0x34(%rbp),%eax
movslq -0x4(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jl     1229 <greedy+0xe9>
movslq -0x4(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp,%rax,4)
movslq -0x4(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
mov    -0x34(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
jmp    11f4 <greedy+0xb4>
jmp    122e <greedy+0xee>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11e5 <greedy+0xa5>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<greedy>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec8(%rip),%r14
lea    0xed9(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm0
ucomiss 0xe92(%rip),%xmm0
jne    1150 <greedy+0x20>
jp     1150 <greedy+0x20>
mulss  0xe82(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
call   1050 <round@plt>
xor    %edx,%edx
mov    $0x0,%esi
cmp    $0x19,%eax
jl     11ae <greedy+0x7e>
lea    -0x19(%rax),%ecx
imul   $0x51eb851f,%rcx,%rsi
shr    $0x23,%rsi
imul   $0xffffffe7,%esi,%ecx
add    $0x1,%esi
add    %ecx,%eax
add    $0xffffffe7,%eax
cmp    $0xa,%eax
jl     11ce <greedy+0x9e>
add    $0xfffffff6,%eax
mov    $0xcccccccd,%edx
imul   %rax,%rdx
shr    $0x23,%rdx
lea    (%rdx,%rdx,1),%ecx
lea    (%rcx,%rcx,4),%ecx
add    $0x1,%edx
sub    %ecx,%eax
xor    %edi,%edi
cmp    $0x5,%eax
jge    11d9 <greedy+0xa9>
xor    %ecx,%ecx
jmp    11f1 <greedy+0xc1>
add    $0xfffffffb,%eax
mov    $0xcccccccd,%ecx
imul   %rax,%rcx
shr    $0x22,%rcx
lea    (%rcx,%rcx,4),%ebx
add    $0x1,%ecx
sub    %ebx,%eax
test   %eax,%eax
cmovs  %edi,%eax
lea    0xe28(%rip),%rdi
mov    %eax,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.greedy.coinValues = [4 x i32] [i32 25, i32 10, i32 5, i32 1]
@.str = [24 x i8] c"Enter amount of change:\00"
@.str.1 = [5 x i8] c"%f.2\00"
@.str.2 = [49 x i8] c"%d quarters, %d dimes, %d nickel, and %d pennies\00"
define void @greedy() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca [4 x i32]
%4 = alloca i32
%5 = alloca float
%6 = bitcast [4 x i32]* %2 to i8*
%7 = bitcast [4 x i32]* %3 to i8*
br label %8
8: ; preds = %17, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float* %5)
br label %11
11: ; preds = %8
%12 = load float, float* %5
%13 = fcmp olt float %12, 0.000000e+00
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load float, float* %5
%16 = fcmp une float %15, 0.000000e+00
br label %17
17: ; preds = %14, %11
%18 = phi i1 [ true, %11 ], [ %16, %14 ]
br i1 %18, label %8, label %19
19: ; preds = %17
%20 = load float, float* %5
%21 = fmul float %20, 1.000000e+02
store float %21, float* %5
%22 = load float, float* %5
%23 = call i32 @round(float %22)
store i32 %23, i32* %4
store i32 0, i32* %1
br label %24
24: ; preds = %48, %19
%25 = load i32, i32* %1
%26 = icmp slt i32 %25, 5
br i1 %26, label %27, label %51
27: ; preds = %24
br label %28
28: ; preds = %35, %27
%29 = load i32, i32* %4
%30 = load i32, i32* %1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = icmp sge i32 %29, %33
br i1 %34, label %35, label %47
35: ; preds = %28
%36 = load i32, i32* %1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1
store i32 %40, i32* %38
%41 = load i32, i32* %1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = load i32, i32* %4
%46 = sub nsw i32 %45, %44
store i32 %46, i32* %4
br label %28
47: ; preds = %28
br label %48
48: ; preds = %47
%49 = load i32, i32* %1
%50 = add nsw i32 %49, 1
store i32 %50, i32* %1
br label %24
51: ; preds = %24
%52 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%53 = load i32, i32* %52
%54 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%55 = load i32, i32* %54
%56 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%57 = load i32, i32* %56
%58 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %53, i32 %55, i32 %57, i32 %59)
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Enter amount of change:\00"
@.str.1 = [5 x i8] c"%f.2\00"
@.str.2 = [49 x i8] c"%d quarters, %d dimes, %d nickel, and %d pennies\00"
define void @greedy() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float* %1)
%6 = load float, float* %1
%7 = fcmp une float %6, 0.000000e+00
br i1 %7, label %3, label %8
8: ; preds = %3
%9 = fmul float %6, 1.000000e+02
store float %9, float* %1
%10 = call i32 @round(float %9)
%11 = icmp slt i32 %10, 25
br i1 %11, label %18, label %12
12: ; preds = %8
%13 = add nsw i32 %10, -25
%14 = udiv i32 %13, 25
%15 = mul nsw i32 %14, -25
%16 = add nuw nsw i32 %14, 1
%17 = add nsw i32 %15, %13
br label %18
18: ; preds = %12, %8
%19 = phi i32 [ 0, %8 ], [ %16, %12 ]
%20 = phi i32 [ %10, %8 ], [ %17, %12 ]
%21 = icmp slt i32 %20, 10
br i1 %21, label %28, label %22
22: ; preds = %18
%23 = add nsw i32 %20, -10
%24 = udiv i32 %23, 10
%25 = mul nsw i32 %24, -10
%26 = add nuw nsw i32 %24, 1
%27 = add nsw i32 %25, %23
br label %28
28: ; preds = %22, %18
%29 = phi i32 [ 0, %18 ], [ %26, %22 ]
%30 = phi i32 [ %20, %18 ], [ %27, %22 ]
%31 = icmp slt i32 %30, 5
br i1 %31, label %38, label %32
32: ; preds = %28
%33 = add nsw i32 %30, -5
%34 = udiv i32 %33, 5
%35 = mul nsw i32 %34, -5
%36 = add nuw nsw i32 %34, 1
%37 = add nsw i32 %35, %33
br label %38
38: ; preds = %32, %28
%39 = phi i32 [ 0, %28 ], [ %36, %32 ]
%40 = phi i32 [ %30, %28 ], [ %37, %32 ]
%41 = icmp sgt i32 %40, 0
%42 = select i1 %41, i32 %40, i32 0
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %29, i32 %39, i32 %42)
ret void
}