void dispense_cash(int desiredAmount, int *notes100, int *notes50, int *notes20,
                   int *notes10) {
  int reminder;
  *notes100 = desiredAmount / 100;
  reminder = desiredAmount % 100;
  *notes50 = reminder / 50;
  reminder %= 50;
  *notes20 = reminder / 20;
  reminder %= 20;
  *notes10 = reminder / 10;
}


x86 assembly (clang, -O0):
<dispense_cash>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x32,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
mov    $0x32,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<dispense_cash>:
movslq %edi,%r9
imul   $0x51eb851f,%r9,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x25,%rdi
add    %eax,%edi
mov    %edi,(%rsi)
imul   $0x64,%edi,%eax
sub    %eax,%r9d
movsbl %r9b,%eax
lea    (%rax,%rax,4),%esi
lea    (%rax,%rsi,8),%eax
movzwl %ax,%eax
movswl %ax,%esi
shr    $0xf,%eax
shr    $0xb,%esi
add    %al,%sil
movsbl %sil,%eax
mov    %eax,(%rdx)
movzbl %al,%eax
imul   $0x32,%eax,%eax
sub    %al,%r9b
movsbl %r9b,%eax
imul   $0x67,%eax,%edx
movzwl %dx,%esi
shr    $0xb,%edx
shr    $0xf,%esi
add    %dl,%sil
movsbl %sil,%edx
mov    %edx,(%rcx)
movzbl %dl,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
movsbl %al,%eax
imul   $0x67,%eax,%eax
movzwl %ax,%ecx
shr    $0xa,%eax
shr    $0xf,%ecx
add    %al,%cl
movsbl %cl,%eax
mov    %eax,(%r8)
ret

LLVM IR (-O0):
define void @dispense_cash(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*
%11 = 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
%12 = load i32, i32* %6
%13 = sdiv i32 %12, 100
%14 = load i32*, i32** %7
store i32 %13, i32* %14
%15 = load i32, i32* %6
%16 = srem i32 %15, 100
store i32 %16, i32* %11
%17 = load i32, i32* %11
%18 = sdiv i32 %17, 50
%19 = load i32*, i32** %8
store i32 %18, i32* %19
%20 = load i32, i32* %11
%21 = srem i32 %20, 50
store i32 %21, i32* %11
%22 = load i32, i32* %11
%23 = sdiv i32 %22, 20
%24 = load i32*, i32** %9
store i32 %23, i32* %24
%25 = load i32, i32* %11
%26 = srem i32 %25, 20
store i32 %26, i32* %11
%27 = load i32, i32* %11
%28 = sdiv i32 %27, 10
%29 = load i32*, i32** %10
store i32 %28, i32* %29
ret void
}

LLVM IR (-O2):
define void @dispense_cash(i32 %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = sdiv i32 %0, 100
store i32 %6, i32* %1
%7 = srem i32 %0, 100
%8 = trunc i32 %7 to i8
%9 = sdiv i8 %8, 50
%10 = sext i8 %9 to i32
store i32 %10, i32* %2
%11 = srem i8 %8, 50
%12 = sdiv i8 %11, 20
%13 = sext i8 %12 to i32
store i32 %13, i32* %3
%14 = srem i8 %11, 20
%15 = sdiv i8 %14, 10
%16 = sext i8 %15 to i32
store i32 %16, i32* %4
ret void
}