#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 /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int dollar_amount, twenties, tens, fives, ones;
  printf("Enter a dollar amount: ");
  scanf("%d", &dollar_amount);
  twenties = dollar_amount / 20;
  tens = (dollar_amount - (twenties * 20)) / 10;
  fives = (dollar_amount - (twenties * 20 + tens * 10)) / 5;
  ones = (dollar_amount - (twenties * 20 + tens * 10 + fives * 5));
  printf("\n$20 bills: %d\n", twenties);
  printf("$10 bills: %d\n", tens);
  printf(" $5 bills: %d\n", fives);
  printf(" $1 bills: %d\n", ones);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
imul   $0x14,-0xc(%rbp),%ecx
sub    %ecx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
imul   $0x14,-0xc(%rbp),%ecx
imul   $0xa,-0x10(%rbp),%edx
add    %edx,%ecx
sub    %ecx,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
imul   $0x14,-0xc(%rbp),%ecx
imul   $0xa,-0x10(%rbp),%edx
add    %edx,%ecx
imul   $0x5,-0x14(%rbp),%edx
add    %edx,%ecx
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rsi
add    %ecx,%esi
lea    0x0(,%rsi,4),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%edx
sub    %ecx,%edx
movslq %edx,%rdx
imul   $0x66666667,%rdx,%r15
mov    %r15,%rdx
shr    $0x3f,%rdx
sar    $0x22,%r15
add    %edx,%r15d
lea    (%r15,%r15,4),%edx
lea    (%rcx,%rdx,2),%ecx
sub    %ecx,%eax
movslq %eax,%r14
imul   $0x66666667,%r14,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x21,%rbx
add    %eax,%ebx
lea    (%rbx,%rbx,4),%eax
sub    %eax,%r14d
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe69(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe67(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe66(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Enter a dollar amount: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"\0A$20 bills: %d\0A\00"
@.str.3 = [15 x i8] c"$10 bills: %d\0A\00"
@.str.4 = [15 x i8] c" $5 bills: %d\0A\00"
@.str.5 = [15 x i8] c" $1 bills: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = sdiv i32 %9, 20
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = mul nsw i32 %12, 20
%14 = sub nsw i32 %11, %13
%15 = sdiv i32 %14, 10
store i32 %15, i32* %4
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = mul nsw i32 %17, 20
%19 = load i32, i32* %4
%20 = mul nsw i32 %19, 10
%21 = add nsw i32 %18, %20
%22 = sub nsw i32 %16, %21
%23 = sdiv i32 %22, 5
store i32 %23, i32* %5
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = mul nsw i32 %25, 20
%27 = load i32, i32* %4
%28 = mul nsw i32 %27, 10
%29 = add nsw i32 %26, %28
%30 = load i32, i32* %5
%31 = mul nsw i32 %30, 5
%32 = add nsw i32 %29, %31
%33 = sub nsw i32 %24, %32
store i32 %33, i32* %6
%34 = load i32, i32* %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %4
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %5
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %6
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Enter a dollar amount: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"\0A$20 bills: %d\0A\00"
@.str.3 = [15 x i8] c"$10 bills: %d\0A\00"
@.str.4 = [15 x i8] c" $5 bills: %d\0A\00"
@.str.5 = [15 x i8] c" $1 bills: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = sdiv i32 %5, 20
%7 = mul nsw i32 %6, 20
%8 = srem i32 %5, 20
%9 = sdiv i32 %8, 10
%10 = mul nsw i32 %9, 10
%11 = add nsw i32 %10, %7
%12 = sub i32 %5, %11
%13 = sdiv i32 %12, 5
%14 = mul nsw i32 %13, -5
%15 = add i32 %12, %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %13)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %15)
ret i32 0
}