#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() {
  int amount = 0, twenty = 0, ten = 0, five = 0, one = 0;
  printf("Enter a dollar amount: ");
  scanf("%d", &amount);
  twenty = amount / 20;
  ten = (amount - 20 * twenty) / 10;
  five = (amount - (20 * twenty + 10 * ten)) / 5;
  one = amount - (20 * twenty + 10 * ten + 5 * five);
  printf("$20 bills: %d\n", twenty);
  printf("$10 bills: %d\n", ten);
  printf("$5 bills: %d\n", five);
  printf("$1 bills: %d\n", one);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%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    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe46(%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
movl   $0x0,0xc(%rsp)
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed2(%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    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe60(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5e(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5c(%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 = [15 x i8] c"$20 bills: %d\0A\00"
@.str.3 = [15 x i8] c"$10 bills: %d\0A\00"
@.str.4 = [14 x i8] c"$5 bills: %d\0A\00"
@.str.5 = [14 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
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%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 20, %12
%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 20, %17
%19 = load i32, i32* %4
%20 = mul nsw i32 10, %19
%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 20, %25
%27 = load i32, i32* %4
%28 = mul nsw i32 10, %27
%29 = add nsw i32 %26, %28
%30 = load i32, i32* %5
%31 = mul nsw i32 5, %30
%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 ([15 x i8], [15 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 ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %6
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 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 = [15 x i8] c"$20 bills: %d\0A\00"
@.str.3 = [15 x i8] c"$10 bills: %d\0A\00"
@.str.4 = [14 x i8] c"$5 bills: %d\0A\00"
@.str.5 = [14 x i8] c"$1 bills: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%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 ([15 x i8], [15 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 ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %13)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %15)
ret i32 0
}