#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 amount, bill20, bill10, bill5, bill1;
  printf("Enter a dollar amount: ");
  scanf("%d", &amount);
  bill20 = amount / 20;
  bill10 = (amount - 20 * bill20) / 10;
  bill5 = (amount - 20 * bill20 - 10 * bill10) / 5;
  bill1 = (amount - 20 * bill20 - 10 * bill10 - 5 * bill5);
  printf("$20 bills: %d\n", bill20);
  printf("$10 bills: %d\n", bill10);
  printf("$5 bills: %d\n", bill5);
  printf("$1 bills: %d\n", bill1);
  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
sub    %ecx,%eax
imul   $0xa,-0x10(%rbp),%ecx
sub    %ecx,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
imul   $0x14,-0xc(%rbp),%ecx
sub    %ecx,%eax
imul   $0xa,-0x10(%rbp),%ecx
sub    %ecx,%eax
imul   $0x5,-0x14(%rbp),%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    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe69(%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
sub    %ecx,%eax
cltq
imul   $0x66666667,%rax,%r15
mov    %r15,%rcx
shr    $0x3f,%rcx
sar    $0x22,%r15
add    %ecx,%r15d
lea    (%r15,%r15,1),%ecx
lea    (%rcx,%rcx,4),%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    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe69(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe67(%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
%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 = sub nsw i32 %16, %18
%20 = load i32, i32* %4
%21 = mul nsw i32 10, %20
%22 = sub nsw i32 %19, %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 = sub nsw i32 %24, %26
%28 = load i32, i32* %4
%29 = mul nsw i32 10, %28
%30 = sub nsw i32 %27, %29
%31 = load i32, i32* %5
%32 = mul nsw i32 5, %31
%33 = sub nsw i32 %30, %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*
%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 = add i32 %7, %5
%9 = sdiv i32 %8, 10
%10 = mul nsw i32 %9, -10
%11 = add i32 %10, %8
%12 = sdiv i32 %11, 5
%13 = mul nsw i32 %12, -5
%14 = add i32 %13, %11
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %14)
ret i32 0
}