#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*/ cleanMap(int **, int);
int makeChange(int, int const, int const *, int /*<<< orphan*/, int **);
int **makeMap(int, int const);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int amount = 0;
  const int denomsCount = 4;
  const int denoms[] = {25, 10, 5, 1};
  while (true) {
    printf("Please enter the amount or -9999 for exit: ");
    scanf("%i", &amount);
    if (amount == -9999)
      break;
    int **map = makeMap(amount + 1, denomsCount);
    printf("%i\n", makeChange(amount, denomsCount, denoms, 0, map));
    cleanMap(map, amount + 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x4,-0xc(%rbp)
mov    0xe8c(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe89(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0xffffd8f1,-0x8(%rbp)
jne    11b3 <main+0x63>
jmp    1202 <main+0xb2>
mov    -0x8(%rbp),%edi
add    $0x1,%edi
mov    $0x4,%esi
call   1070 <makeMap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%r8
mov    $0x4,%esi
xor    %ecx,%ecx
call   1050 <makeChange@plt>
mov    %eax,%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
add    $0x1,%esi
call   1040 <cleanMap@plt>
jmp    1183 <main+0x33>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x0,0xc(%rsp)
movaps 0xe93(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
cmp    $0xffffd8f1,%edi
je     1222 <main+0xd2>
lea    0x10(%rsp),%r14
lea    0xe92(%rip),%r15
lea    0xe5c(%rip),%r12
lea    0xe81(%rip),%r13
lea    0xc(%rsp),%rbx
add    $0x1,%edi
mov    $0x4,%esi
call   1070 <makeMap@plt>
mov    %rax,%rbp
mov    0xc(%rsp),%edi
mov    $0x4,%esi
mov    %r14,%rdx
xor    %ecx,%ecx
mov    %rax,%r8
call   1050 <makeChange@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
add    $0x1,%esi
mov    %rbp,%rdi
call   1040 <cleanMap@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
cmp    $0xffffd8f1,%edi
jne    11c0 <main+0x70>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.denoms = [4 x i32] [i32 25, i32 10, i32 5, i32 1]
@.str = [44 x i8] c"Please enter the amount or -9999 for exit: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i32]
%5 = alloca i32**
store i32 0, i32* %1
store i32 0, i32* %2
store i32 4, i32* %3
%6 = bitcast [4 x i32]* %4 to i8*
br label %7
7: ; preds = %0, %13
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, -9999
br i1 %11, label %12, label %13
12: ; preds = %7
br label %26
13: ; preds = %7
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
%16 = call i32** @makeMap(i32 %15, i32 4)
store i32** %16, i32*** %5
%17 = load i32, i32* %2
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%19 = load i32**, i32*** %5
%20 = call i32 @makeChange(i32 %17, i32 4, i32* %18, i32 0, i32** %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = load i32**, i32*** %5
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
%25 = call i32 @cleanMap(i32** %22, i32 %24)
br label %7
26: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@__const.main.denoms = [4 x i32] [i32 25, i32 10, i32 5, i32 1]
@.str = [44 x i8] c"Please enter the amount or -9999 for exit: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast [4 x i32]* %2 to i8*
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, -9999
br i1 %8, label %25, label %9
9: ; preds = %0
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
br label %11
11: ; preds = %9, %11
%12 = phi i32 [ %7, %9 ], [ %23, %11 ]
%13 = add nsw i32 %12, 1
%14 = call i32** @makeMap(i32 %13, i32 4)
%15 = load i32, i32* %1
%16 = call i32 @makeChange(i32 %15, i32 4, i32* %10, i32 0, i32** %14)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %1
%19 = add nsw i32 %18, 1
%20 = call i32 @cleanMap(i32** %14, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%23 = load i32, i32* %1
%24 = icmp eq i32 %23, -9999
br i1 %24, label %25, label %11
25: ; preds = %11, %0
ret i32 0
}