#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 n1, n5, n10, n20, n50, n100, dinheiro;
  printf("Caixa eletronico inteligente. Procura troco? Voce esta no lugar "
         "certo\n");
  printf("Digite quantos reais voce possui (nao trabalho com centavos) para eu "
         "te dar ele trocado\n");
  scanf("%d", &dinheiro);
  n100 = dinheiro / 100;
  dinheiro = dinheiro - n100 * 100;
  n50 = dinheiro / 50;
  dinheiro = dinheiro - n50 * 50;
  n20 = dinheiro / 20;
  dinheiro = dinheiro - n20 * 20;
  n10 = dinheiro / 10;
  dinheiro = dinheiro - n10 * 10;
  n5 = dinheiro / 5;
  dinheiro = dinheiro - n5 * 5;
  n1 = dinheiro;
  printf(
      "Com o que voce me deu, eu consigo te dar:\n %d notas de 100, %d notas "
      "de 50, %d notas de 20\n %d notas de 10, %d notas de 5 e %d notas de 1",
      n100, n50, n20, n10, n5, n1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4e(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x20(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
imul   $0x64,-0x1c(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x32,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
imul   $0x32,-0x18(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%eax
imul   $0x14,-0x14(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x20(%rbp),%eax
imul   $0xa,-0x10(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%eax
imul   $0x5,-0xc(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0xc(%rbp),%r9d
mov    -0x8(%rbp),%eax
lea    0xea5(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf52(%rip),%rdi
call   1030 <puts@plt>
lea    0xf8c(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1050 <scanf@plt>
movslq 0x14(%rsp),%rax
imul   $0x51eb851f,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rsi
add    %ecx,%esi
imul   $0xffffff9c,%esi,%ecx
add    %eax,%ecx
movslq %ecx,%rax
imul   $0x51eb851f,%rax,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x24,%rdx
add    %ecx,%edx
imul   $0xffffffce,%edx,%ecx
add    %ecx,%eax
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdi
shr    $0x3f,%rdi
sar    $0x23,%rcx
add    %edi,%ecx
lea    0x0(,%rcx,4),%edi
lea    (%rdi,%rdi,4),%edi
sub    %edi,%eax
cltq
imul   $0x66666667,%rax,%r8
mov    %r8,%rdi
shr    $0x3f,%rdi
sar    $0x22,%r8
add    %edi,%r8d
lea    (%r8,%r8,1),%edi
lea    (%rdi,%rdi,4),%edi
sub    %edi,%eax
cltq
imul   $0x66666667,%rax,%r9
mov    %r9,%rdi
shr    $0x3f,%rdi
sar    $0x21,%r9
add    %edi,%r9d
lea    (%r9,%r9,4),%edi
sub    %edi,%eax
mov    %eax,0x14(%rsp)
mov    %eax,(%rsp)
lea    0xdff(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [71 x i8] c"Caixa eletronico inteligente. Procura troco? Voce esta no lugar certo\0A\00"
@.str.1 = [89 x i8] c"Digite quantos reais voce possui (nao trabalho com centavos) para eu te dar ele trocado\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [138 x i8] c"Com o que voce me deu, eu consigo te dar:\0A %d notas de 100, %d notas de 50, %d notas de 20\0A %d notas de 10, %d notas de 5 e %d notas de 1\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
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%12 = load i32, i32* %8
%13 = sdiv i32 %12, 100
store i32 %13, i32* %7
%14 = load i32, i32* %8
%15 = load i32, i32* %7
%16 = mul nsw i32 %15, 100
%17 = sub nsw i32 %14, %16
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = sdiv i32 %18, 50
store i32 %19, i32* %6
%20 = load i32, i32* %8
%21 = load i32, i32* %6
%22 = mul nsw i32 %21, 50
%23 = sub nsw i32 %20, %22
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = sdiv i32 %24, 20
store i32 %25, i32* %5
%26 = load i32, i32* %8
%27 = load i32, i32* %5
%28 = mul nsw i32 %27, 20
%29 = sub nsw i32 %26, %28
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = sdiv i32 %30, 10
store i32 %31, i32* %4
%32 = load i32, i32* %8
%33 = load i32, i32* %4
%34 = mul nsw i32 %33, 10
%35 = sub nsw i32 %32, %34
store i32 %35, i32* %8
%36 = load i32, i32* %8
%37 = sdiv i32 %36, 5
store i32 %37, i32* %3
%38 = load i32, i32* %8
%39 = load i32, i32* %3
%40 = mul nsw i32 %39, 5
%41 = sub nsw i32 %38, %40
store i32 %41, i32* %8
%42 = load i32, i32* %8
store i32 %42, i32* %2
%43 = load i32, i32* %7
%44 = load i32, i32* %6
%45 = load i32, i32* %5
%46 = load i32, i32* %4
%47 = load i32, i32* %3
%48 = load i32, i32* %2
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.3, i64 0, i64 0), i32 %43, i32 %44, i32 %45, i32 %46, i32 %47, i32 %48)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [138 x i8] c"Com o que voce me deu, eu consigo te dar:\0A %d notas de 100, %d notas de 50, %d notas de 20\0A %d notas de 10, %d notas de 5 e %d notas de 1\00"
@str = [70 x i8] c"Caixa eletronico inteligente. Procura troco? Voce esta no lugar certo\00"
@str.4 = [88 x i8] c"Digite quantos reais voce possui (nao trabalho com centavos) para eu te dar ele trocado\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([88 x i8], [88 x i8]* @str.4, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = sdiv i32 %6, 100
%8 = mul nsw i32 %7, -100
%9 = add i32 %8, %6
%10 = sdiv i32 %9, 50
%11 = mul nsw i32 %10, -50
%12 = add i32 %11, %9
%13 = sdiv i32 %12, 20
%14 = mul nsw i32 %13, -20
%15 = add i32 %14, %12
%16 = sdiv i32 %15, 10
%17 = mul nsw i32 %16, -10
%18 = add i32 %17, %15
%19 = sdiv i32 %18, 5
%20 = mul nsw i32 %19, -5
%21 = add i32 %20, %18
store i32 %21, i32* %1
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([138 x i8], [138 x i8]* @.str.3, i64 0, i64 0), i32 %7, i32 %10, i32 %13, i32 %16, i32 %19, i32 %21)
ret i32 0
}