#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;
  while (amount <= 0) {
    printf("Amount (R$): ");
    scanf("%d", &amount);
  }
  int n100, n50, n10, n5, n1;
  n100 = amount / 100;
  n50 = amount % 100 / 50;
  n10 = amount % 50 / 10;
  n5 = amount % 10 / 5;
  n1 = amount % 5;
  printf("R$ 100: %d\n R$ 50: %d\n R$ 10: %d\n  R$ 5: %d\n  R$ 1: %d\n", n100,
         n50, n10, n5, n1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     1163 <main+0x43>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1136 <main+0x16>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x32,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x32,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe32(%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),%r14
lea    0xecf(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%r9d
test   %r9d,%r9d
jle    1150 <main+0x30>
mov    %r9d,%eax
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rsi
shr    $0x25,%rsi
imul   $0x64,%esi,%edx
mov    %r9d,%edi
sub    %edx,%edi
lea    (%rdi,%rdi,4),%edx
lea    (%rdi,%rdx,8),%edx
movzwl %dx,%edx
shr    $0xb,%edx
shr    $0x24,%rcx
imul   $0x32,%ecx,%ecx
mov    %r9d,%edi
sub    %ecx,%edi
imul   $0xcd,%edi,%ecx
movzwl %cx,%ecx
shr    $0xb,%ecx
mov    $0xcccccccd,%edi
imul   %rax,%rdi
mov    %rdi,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %r9d,%ebx
sub    %eax,%ebx
imul   $0xcd,%ebx,%eax
movzwl %ax,%r8d
shr    $0xa,%r8d
shr    $0x22,%rdi
lea    (%rdi,%rdi,4),%eax
sub    %eax,%r9d
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Amount (R$): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [56 x i8] c"R$ 100: %d\0A R$ 50: %d\0A R$ 10: %d\0A R$ 5: %d\0A R$ 1: %d\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
br label %8
8: ; preds = %11, %0
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
14: ; preds = %8
%15 = load i32, i32* %2
%16 = sdiv i32 %15, 100
store i32 %16, i32* %3
%17 = load i32, i32* %2
%18 = srem i32 %17, 100
%19 = sdiv i32 %18, 50
store i32 %19, i32* %4
%20 = load i32, i32* %2
%21 = srem i32 %20, 50
%22 = sdiv i32 %21, 10
store i32 %22, i32* %5
%23 = load i32, i32* %2
%24 = srem i32 %23, 10
%25 = sdiv i32 %24, 5
store i32 %25, i32* %6
%26 = load i32, i32* %2
%27 = srem i32 %26, 5
store i32 %27, i32* %7
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i32 %28, i32 %29, i32 %30, i32 %31, i32 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Amount (R$): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [56 x i8] c"R$ 100: %d\0A R$ 50: %d\0A R$ 10: %d\0A R$ 5: %d\0A R$ 1: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %0, %3
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %3, label %8
8: ; preds = %3
%9 = udiv i32 %6, 100
%10 = urem i32 %6, 100
%11 = trunc i32 %10 to i8
%12 = udiv i8 %11, 50
%13 = zext i8 %12 to i32
%14 = urem i32 %6, 50
%15 = trunc i32 %14 to i8
%16 = udiv i8 %15, 10
%17 = zext i8 %16 to i32
%18 = urem i32 %6, 10
%19 = trunc i32 %18 to i8
%20 = udiv i8 %19, 5
%21 = zext i8 %20 to i32
%22 = urem i32 %6, 5
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %13, i32 %17, i32 %21, i32 %22)
ret i32 0
}