#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, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int valor;
  int notas[] = {100, 50, 20, 10, 5, 2, 1, 0};
  int notaIndex = 0;
  int quantidadeNotas;
  scanf("%d", &valor);
  printf("%d\n", valor);
  while (notas[notaIndex] != 0) {
    quantidadeNotas = valor / notas[notaIndex];
    printf("%d nota(s) de R$ %d,00\n", quantidadeNotas, notas[notaIndex]);
    valor = valor % notas[notaIndex];
    notaIndex++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x34(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
je     11d7 <main+0xb7>
mov    -0x8(%rbp),%eax
movslq -0x34(%rbp),%rcx
cltd
idivl  -0x30(%rbp,%rcx,4)
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%esi
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
movslq -0x34(%rbp),%rcx
cltd
idivl  -0x30(%rbp,%rcx,4)
mov    %edx,-0x8(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1183 <main+0x63>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x51eb851f,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x25,%rsi
add    %eax,%esi
lea    0xe9f(%rip),%rbx
mov    %rbx,%rdi
mov    $0x64,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
movsbl %al,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,8),%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
shr    $0xb,%ecx
add    %al,%cl
movsbl %cl,%esi
mov    %rbx,%rdi
mov    $0x32,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
movsbl %al,%eax
imul   $0x67,%eax,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
shr    $0xb,%ecx
add    %al,%cl
movsbl %cl,%esi
mov    %rbx,%rdi
mov    $0x14,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
movsbl %al,%eax
imul   $0x67,%eax,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
shr    $0xa,%ecx
add    %al,%cl
movsbl %cl,%esi
mov    %rbx,%rdi
mov    $0xa,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
movsbl %al,%eax
imul   $0x67,%eax,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
shr    $0x9,%ecx
add    %al,%cl
movsbl %cl,%esi
mov    %rbx,%rdi
mov    $0x5,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
mov    %eax,%ecx
shr    $0x7,%cl
add    %al,%cl
sar    %cl
movsbl %cl,%esi
mov    %rbx,%rdi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    %esi,%eax
shr    $0x1f,%eax
add    %esi,%eax
and    $0xfffffffe,%eax
sub    %eax,%esi
mov    %esi,0xc(%rsp)
mov    %rbx,%rdi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.notas = [8 x i32] [i32 100, i32 50, i32 20, i32 10, i32 5, i32 2, i32 1, i32 0]
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [24 x i8] c"%d nota(s) de R$ %d,00\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [8 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [8 x i32]* %3 to i8*
store i32 0, i32* %4
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %16, %0
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %37
16: ; preds = %10
%17 = load i32, i32* %2
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = sdiv i32 %17, %21
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %27)
%29 = load i32, i32* %2
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = srem i32 %29, %33
store i32 %34, i32* %2
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %10
37: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [24 x i8] c"%d nota(s) de R$ %d,00\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = load i32, i32* %1
%7 = sdiv i32 %6, 100
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 100)
%9 = load i32, i32* %1
%10 = srem i32 %9, 100
store i32 %10, i32* %1
%11 = trunc i32 %10 to i8
%12 = sdiv i8 %11, 50
%13 = sext i8 %12 to i32
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 50)
%15 = load i32, i32* %1
%16 = srem i32 %15, 50
store i32 %16, i32* %1
%17 = trunc i32 %16 to i8
%18 = sdiv i8 %17, 20
%19 = sext i8 %18 to i32
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 20)
%21 = load i32, i32* %1
%22 = srem i32 %21, 20
store i32 %22, i32* %1
%23 = trunc i32 %22 to i8
%24 = sdiv i8 %23, 10
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 10)
%27 = load i32, i32* %1
%28 = srem i32 %27, 10
store i32 %28, i32* %1
%29 = trunc i32 %28 to i8
%30 = sdiv i8 %29, 5
%31 = sext i8 %30 to i32
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 5)
%33 = load i32, i32* %1
%34 = srem i32 %33, 5
store i32 %34, i32* %1
%35 = trunc i32 %34 to i8
%36 = sdiv i8 %35, 2
%37 = sext i8 %36 to i32
%38 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %37, i32 2)
%39 = load i32, i32* %1
%40 = srem i32 %39, 2
store i32 %40, i32* %1
%41 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 1)
ret i32 0
}