#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ number_of_bills(int, int *, int *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *);
int /*<<< orphan*/ stderr;
int main(void) {
  int dollars = 0, scanf_res = 0;
  int ten_bills = 0, twenty_bills = 0, fifty_bills = 0, hundred_bills = 0;
  printf("Enter a dollar amount to be delivered:\n");
  scanf_res = scanf(" %d", &dollars);
  if (scanf_res != 1 || dollars < 0) {
    fprintf(stderr, "Error reading number.\n");
    fprintf(stderr, "Check that you have entered an integer greater than 0.\n");
    return 1;
  }
  if (dollars % 10 != 0) {
    fprintf(stderr, "Error reading number.\n");
    fprintf(stderr, "Check you have entered the amount divisible with 10.\n");
    return 1;
  }
  number_of_bills(dollars, &ten_bills, &twenty_bills, &fifty_bills,
                  &hundred_bills);
  printf("To be delivered:\n");
  printf("%d ten-dollar bill%c\n", ten_bills, ten_bills != 1 ? 's' : ' ');
  printf("%d twenty-dollar bill%c\n", twenty_bills,
         twenty_bills != 1 ? 's' : ' ');
  printf("%d fifty-dollar bill%c\n", fifty_bills, fifty_bills != 1 ? 's' : ' ');
  printf("%d hundred-dollar bill%c\n", hundred_bills,
         hundred_bills != 1 ? 's' : ' ');
  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)
movl   $0x0,-0x1c(%rbp)
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    11ae <main+0x6e>
cmpl   $0x0,-0x8(%rbp)
jge    11e4 <main+0xa4>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12eb <main+0x1ab>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     122e <main+0xee>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12eb <main+0x1ab>
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
call   1060 <number_of_bills@plt>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%ecx
mov    $0x20,%edx
mov    $0x73,%eax
cmp    $0x1,%ecx
cmovne %eax,%edx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%ecx
mov    $0x20,%edx
mov    $0x73,%eax
cmp    $0x1,%ecx
cmovne %eax,%edx
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
mov    -0x18(%rbp),%ecx
mov    $0x20,%edx
mov    $0x73,%eax
cmp    $0x1,%ecx
cmovne %eax,%edx
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%ecx
mov    $0x20,%edx
mov    $0x73,%eax
cmp    $0x1,%ecx
cmovne %eax,%edx
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movl   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xf63(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6d(%rip),%rdi
lea    0x1c(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11d9 <main+0x89>
mov    0x1c(%rsp),%edi
test   %edi,%edi
js     11d9 <main+0x89>
imul   $0xcccccccd,%edi,%eax
ror    %eax
cmp    $0x1999999a,%eax
jb     120c <main+0xbc>
mov    0x2e20(%rip),%rbx
mov    (%rbx),%edi
lea    0xe3b(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe7c(%rip),%rsi
jmp    11f7 <main+0xa7>
mov    0x2e00(%rip),%rbx
mov    (%rbx),%edi
lea    0xe1b(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe24(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0x18(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1070 <number_of_bills@plt>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
mov    0x18(%rsp),%esi
cmp    $0x1,%esi
mov    $0x20,%r14d
mov    $0x73,%ebp
mov    $0x73,%edx
cmove  %r14d,%edx
lea    0xe36(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
cmp    $0x1,%esi
mov    $0x73,%edx
cmove  %r14d,%edx
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
cmp    $0x1,%esi
mov    $0x73,%edx
cmove  %r14d,%edx
lea    0xe27(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
cmp    $0x1,%esi
cmove  %r14d,%ebp
lea    0xe26(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1201 <main+0xb1>

LLVM IR (-O0):
@.str = [40 x i8] c"Enter a dollar amount to be delivered:\0A\00"
@.str.1 = [4 x i8] c" %d\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"Error reading number.\0A\00"
@.str.3 = [56 x i8] c"Check that you have entered an integer greater than 0.\0A\00"
@.str.4 = [54 x i8] c"Check you have entered the amount divisible with 10.\0A\00"
@.str.5 = [18 x i8] c"To be delivered:\0A\00"
@.str.6 = [22 x i8] c"%d ten-dollar bill%c\0A\00"
@.str.7 = [25 x i8] c"%d twenty-dollar bill%c\0A\00"
@.str.8 = [24 x i8] c"%d fifty-dollar bill%c\0A\00"
@.str.9 = [26 x i8] c"%d hundred-dollar bill%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = 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
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 1
br i1 %11, label %15, label %12
12: ; preds = %0
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %12, %0
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %57
20: ; preds = %12
%21 = load i32, i32* %2
%22 = srem i32 %21, 10
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %1
br label %57
29: ; preds = %20
%30 = load i32, i32* %2
%31 = call i32 @number_of_bills(i32 %30, i32* %4, i32* %5, i32* %6, i32* %7)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%33 = load i32, i32* %4
%34 = load i32, i32* %4
%35 = icmp ne i32 %34, 1
%36 = zext i1 %35 to i64
%37 = select i1 %35, i32 115, i32 32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %33, i32 %37)
%39 = load i32, i32* %5
%40 = load i32, i32* %5
%41 = icmp ne i32 %40, 1
%42 = zext i1 %41 to i64
%43 = select i1 %41, i32 115, i32 32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %39, i32 %43)
%45 = load i32, i32* %6
%46 = load i32, i32* %6
%47 = icmp ne i32 %46, 1
%48 = zext i1 %47 to i64
%49 = select i1 %47, i32 115, i32 32
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i32 %45, i32 %49)
%51 = load i32, i32* %7
%52 = load i32, i32* %7
%53 = icmp ne i32 %52, 1
%54 = zext i1 %53 to i64
%55 = select i1 %53, i32 115, i32 32
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i32 %51, i32 %55)
store i32 0, i32* %1
br label %57
57: ; preds = %29, %24, %15
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c" %d\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"Error reading number.\0A\00"
@.str.3 = [56 x i8] c"Check that you have entered an integer greater than 0.\0A\00"
@.str.4 = [54 x i8] c"Check you have entered the amount divisible with 10.\0A\00"
@.str.6 = [22 x i8] c"%d ten-dollar bill%c\0A\00"
@.str.7 = [25 x i8] c"%d twenty-dollar bill%c\0A\00"
@.str.8 = [24 x i8] c"%d fifty-dollar bill%c\0A\00"
@.str.9 = [26 x i8] c"%d hundred-dollar bill%c\0A\00"
@str = [39 x i8] c"Enter a dollar amount to be delivered:\00"
@str.10 = [17 x i8] c"To be delivered:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%7 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%10 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = icmp ne i32 %12, 1
%14 = load i32, i32* %1
%15 = icmp slt i32 %14, 0
%16 = select i1 %13, i1 true, i1 %15
br i1 %16, label %17, label %22
17: ; preds = %0
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
br label %49
22: ; preds = %0
%23 = urem i32 %14, 10
%24 = icmp eq i32 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
br label %49
30: ; preds = %22
%31 = call i32 @number_of_bills(i32 %14, i32* %2, i32* %3, i32* %4, i32* %5)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.10, i64 0, i64 0))
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, 1
%35 = select i1 %34, i32 32, i32 115
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %33, i32 %35)
%37 = load i32, i32* %3
%38 = icmp eq i32 %37, 1
%39 = select i1 %38, i32 32, i32 115
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %37, i32 %39)
%41 = load i32, i32* %4
%42 = icmp eq i32 %41, 1
%43 = select i1 %42, i32 32, i32 115
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i32 %41, i32 %43)
%45 = load i32, i32* %5
%46 = icmp eq i32 %45, 1
%47 = select i1 %46, i32 32, i32 115
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i32 %45, i32 %47)
br label %49
49: ; preds = %30, %25, %17
%50 = phi i32 [ 1, %17 ], [ 1, %25 ], [ 0, %30 ]
ret i32 %50
}