void number_of_bills(int dollars, int *ten_bills, int *twenty_bills,
                     int *fifty_bills, int *hundred_bills) {
  if (dollars == 0) {
    return;
  } else if (dollars >= 100) {
    *hundred_bills += 1;
    number_of_bills(dollars - 100, ten_bills, twenty_bills, fifty_bills,
                    hundred_bills);
  } else if (dollars >= 50) {
    *fifty_bills += 1;
    number_of_bills(dollars - 50, ten_bills, twenty_bills, fifty_bills,
                    hundred_bills);
  } else if (dollars >= 20) {
    *twenty_bills += 1;
    number_of_bills(dollars - 20, ten_bills, twenty_bills, fifty_bills,
                    hundred_bills);
  } else {
    *ten_bills += 1;
    number_of_bills(dollars - 10, ten_bills, twenty_bills, fifty_bills,
                    hundred_bills);
  }
}


x86 assembly (clang, -O0):
<number_of_bills>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    113a <number_of_bills+0x2a>
jmp    120e <number_of_bills+0xfe>
cmpl   $0x64,-0x4(%rbp)
jl     116f <number_of_bills+0x5f>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x4(%rbp),%edi
sub    $0x64,%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <number_of_bills@plt>
jmp    1209 <number_of_bills+0xf9>
cmpl   $0x32,-0x4(%rbp)
jl     11a4 <number_of_bills+0x94>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x4(%rbp),%edi
sub    $0x32,%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <number_of_bills@plt>
jmp    1204 <number_of_bills+0xf4>
cmpl   $0x14,-0x4(%rbp)
jl     11d9 <number_of_bills+0xc9>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x4(%rbp),%edi
sub    $0x14,%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <number_of_bills@plt>
jmp    11ff <number_of_bills+0xef>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x4(%rbp),%edi
sub    $0xa,%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <number_of_bills@plt>
jmp    1204 <number_of_bills+0xf4>
jmp    1209 <number_of_bills+0xf9>
jmp    120e <number_of_bills+0xfe>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number_of_bills>:
test   %edi,%edi
je     114a <number_of_bills+0x4a>
mov    $0xffffffec,%r9d
jmp    1118 <number_of_bills+0x18>
nopl   0x0(%rax)
addl   $0x1,(%rax)
add    %r10d,%edi
je     114a <number_of_bills+0x4a>
mov    $0xffffff9c,%r10d
mov    %r8,%rax
cmp    $0x64,%edi
jge    1110 <number_of_bills+0x10>
mov    $0xffffffce,%r10d
mov    %rcx,%rax
cmp    $0x31,%edi
jg     1110 <number_of_bills+0x10>
cmp    $0x14,%edi
mov    %rsi,%rax
cmovge %rdx,%rax
mov    $0xfffffff6,%r10d
cmovge %r9d,%r10d
jmp    1110 <number_of_bills+0x10>
ret

LLVM IR (-O0):
define void @number_of_bills(i32 %0, i32* %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
store i32 %0, i32* %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %5
br label %66
14: ; preds = %5
%15 = load i32, i32* %6
%16 = icmp sge i32 %15, 100
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = load i32*, i32** %10
%19 = load i32, i32* %18
%20 = add nsw i32 %19, 1
store i32 %20, i32* %18
%21 = load i32, i32* %6
%22 = sub nsw i32 %21, 100
%23 = load i32*, i32** %7
%24 = load i32*, i32** %8
%25 = load i32*, i32** %9
%26 = load i32*, i32** %10
br label %65
27: ; preds = %14
%28 = load i32, i32* %6
%29 = icmp sge i32 %28, 50
br i1 %29, label %30, label %40
30: ; preds = %27
%31 = load i32*, i32** %9
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
store i32 %33, i32* %31
%34 = load i32, i32* %6
%35 = sub nsw i32 %34, 50
%36 = load i32*, i32** %7
%37 = load i32*, i32** %8
%38 = load i32*, i32** %9
%39 = load i32*, i32** %10
br label %64
40: ; preds = %27
%41 = load i32, i32* %6
%42 = icmp sge i32 %41, 20
br i1 %42, label %43, label %53
43: ; preds = %40
%44 = load i32*, i32** %8
%45 = load i32, i32* %44
%46 = add nsw i32 %45, 1
store i32 %46, i32* %44
%47 = load i32, i32* %6
%48 = sub nsw i32 %47, 20
%49 = load i32*, i32** %7
%50 = load i32*, i32** %8
%51 = load i32*, i32** %9
%52 = load i32*, i32** %10
br label %63
53: ; preds = %40
%54 = load i32*, i32** %7
%55 = load i32, i32* %54
%56 = add nsw i32 %55, 1
store i32 %56, i32* %54
%57 = load i32, i32* %6
%58 = sub nsw i32 %57, 10
%59 = load i32*, i32** %7
%60 = load i32*, i32** %8
%61 = load i32*, i32** %9
%62 = load i32*, i32** %10
br label %63
63: ; preds = %53, %43
br label %64
64: ; preds = %63, %30
br label %65
65: ; preds = %64, %17
br label %66
66: ; preds = %13, %65
ret void
}

LLVM IR (-O2):
define void @number_of_bills(i32 %0, i32* %1, i32* %2, i32* %3, i32* %4) {
%6 = icmp eq i32 %0, 0
br i1 %6, label %23, label %7
7: ; preds = %5, %10
%8 = phi i32 [ %15, %10 ], [ %0, %5 ]
%9 = icmp sgt i32 %8, 99
br i1 %9, label %10, label %17
10: ; preds = %7, %19, %17
%11 = phi i32* [ %3, %17 ], [ %21, %19 ], [ %4, %7 ]
%12 = phi i32 [ -50, %17 ], [ %22, %19 ], [ -100, %7 ]
%13 = load i32, i32* %11
%14 = add nsw i32 %13, 1
store i32 %14, i32* %11
%15 = add nsw i32 %8, %12
%16 = icmp eq i32 %15, 0
br i1 %16, label %23, label %7
17: ; preds = %7
%18 = icmp sgt i32 %8, 49
br i1 %18, label %10, label %19
19: ; preds = %17
%20 = icmp sgt i32 %8, 19
%21 = select i1 %20, i32* %2, i32* %1
%22 = select i1 %20, i32 -20, i32 -10
br label %10
23: ; preds = %10, %5
ret void
}