#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 minCoins(int, int *, int);
int /*<<< orphan*/ printf(char *, int, int);
void testMinCoins() {
  int sum = 100;
  int numCoins = 3;
  int coins[] = {1, 3, 5};
  for (int i = 0; i <= sum; i++) {
    int coinsRequired = minCoins(i, coins, numCoins);
    printf("Minimum number of coins to reach %d = %d\n", i, coinsRequired);
  }
}


x86 assembly (clang, -O0):
<testMinCoins>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x64,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x14(%rbp)
mov    0xec1(%rip),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     118f <testMinCoins+0x6f>
mov    -0x18(%rbp),%edi
lea    -0x14(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1030 <minCoins@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1151 <testMinCoins+0x31>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testMinCoins>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0xed9(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xec6(%rip),%rax
mov    %rax,(%rsp)
xor    %ebx,%ebx
mov    %rsp,%r14
lea    0xec2(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x3,%edx
call   1030 <minCoins@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    $0x65,%ebx
jne    1150 <testMinCoins+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.testMinCoins.coins = [3 x i32] [i32 1, i32 3, i32 5]
@.str = [42 x i8] c"Minimum number of coins to reach %d = %d\0A\00"
define void @testMinCoins() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [3 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 100, i32* %1
store i32 3, i32* %2
%6 = bitcast [3 x i32]* %3 to i8*
store i32 0, i32* %4
br label %7
7: ; preds = %19, %0
%8 = load i32, i32* %4
%9 = load i32, i32* %1
%10 = icmp sle i32 %8, %9
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = load i32, i32* %4
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%14 = load i32, i32* %2
%15 = call i32 @minCoins(i32 %12, i32* %13, i32 %14)
store i32 %15, i32* %5
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17)
br label %19
19: ; preds = %11
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %7
22: ; preds = %7
ret void
}

LLVM IR (-O2):
@__const.testMinCoins.coins = [3 x i32] [i32 1, i32 3, i32 5]
@.str = [42 x i8] c"Minimum number of coins to reach %d = %d\0A\00"
define void @testMinCoins() {
%1 = alloca [3 x i32]
%2 = bitcast [3 x i32]* %1 to i8*
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
br label %5
4: ; preds = %5
ret void
5: ; preds = %0, %5
%6 = phi i32 [ 0, %0 ], [ %9, %5 ]
%7 = call i32 @minCoins(i32 %6, i32* %3, i32 3)
%8 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = add nuw nsw i32 %6, 1
%10 = icmp eq i32 %9, 101
br i1 %10, label %4, label %5
}