#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, ...);
void main() {
  char name[20];
  int x = 0, feria[10] = {1, 2, 5, 10, 20, 50, 100, 200, 500, 1000},
      total[10] = {0}, n = 0, i = 0;
  puts("este programa determina el minimo conjunto de billetes necesarios para "
       "lograr la cifra monetaria deseada en pesos mexicanos");
  printf("Usuario, para empezar favor de introducir su nombre:\n>>");
  scanf("%s", name);
  printf("Muy bien %s, Ahora introdusca la cantidad entera a denominar en "
         "MXN\n>>$",
         name);
  scanf("%d", &n);
  for (x = 9; x >= 0; x--) {
    while (n > 0 && n / feria[x] >= 1) {
      total[i]++;
      n -= feria[x];
    }
    i++;
  }
  puts("se requieren billetes en las siguientes cantidades y "
       "denominaciones:\n\t[cant] ---- [Denom]\n\n");
  for (x = 0; x < i; x++) {
    printf("\n\t%dx -------- $%d\n", total[x], feria[9 - x]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x24(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xf1c(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    -0x20(%rbp),%rsi
lea    0xf0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf47(%rip),%rdi
lea    -0x84(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movl   $0x9,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     1291 <main+0x141>
jmp    1204 <main+0xb4>
xor    %eax,%eax
cmpl   $0x0,-0x84(%rbp)
mov    %al,-0x89(%rbp)
jle    1234 <main+0xe4>
mov    -0x84(%rbp),%eax
movslq -0x24(%rbp),%rcx
cltd
idivl  -0x50(%rbp,%rcx,4)
cmp    $0x1,%eax
setge  %al
mov    %al,-0x89(%rbp)
mov    -0x89(%rbp),%al
test   $0x1,%al
jne    1247 <main+0xf7>
jmp    1274 <main+0x124>
movslq -0x88(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x80(%rbp,%rax,4)
movslq -0x24(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%ecx
mov    -0x84(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x84(%rbp)
jmp    1204 <main+0xb4>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    11f5 <main+0xa5>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x88(%rbp),%eax
jge    12e5 <main+0x195>
movslq -0x24(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%esi
mov    $0x9,%eax
sub    -0x24(%rbp),%eax
cltq
mov    -0x50(%rbp,%rax,4),%edx
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12a4 <main+0x154>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
lea    0xf3c(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf64(%rip),%rdi
lea    0x40(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf51(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf88(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    $0x9,%r9d
mov    0xc(%rsp),%ecx
lea    0xe44(%rip),%r8
jmp    11ce <main+0x9e>
xchg   %ax,%ax
add    $0x1,%rbx
add    $0xffffffffffffffff,%r9
cmp    $0xa,%rbx
je     11fd <main+0xcd>
test   %ecx,%ecx
jle    11c0 <main+0x90>
mov    (%r8,%r9,4),%edi
mov    %edi,%esi
neg    %esi
nopw   0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %edi
test   %eax,%eax
jle    11c0 <main+0x90>
addl   $0x1,0x10(%rsp,%rbx,4)
lea    (%rsi,%rcx,1),%eax
sub    %edi,%ecx
mov    %eax,0xc(%rsp)
test   %ecx,%ecx
jg     11e0 <main+0xb0>
jmp    11c0 <main+0x90>
lea    0xf26(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%esi
lea    0xf72(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
mov    $0x1f4,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
mov    $0xc8,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
mov    $0x64,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
mov    $0x32,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
mov    $0x14,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
mov    $0xa,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
mov    $0x5,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x34(%rsp),%esi
mov    %rbx,%rdi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.feria = [10 x i32] [i32 1, i32 2, i32 5, i32 10, i32 20, i32 50, i32 100, i32 200, i32 500, i32 1000]
@.str = [124 x i8] c"este programa determina el minimo conjunto de billetes necesarios para lograr la cifra monetaria deseada en pesos mexicanos\00"
@.str.1 = [56 x i8] c"Usuario, para empezar favor de introducir su nombre:\0A>>\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [72 x i8] c"Muy bien %s, Ahora introdusca la cantidad entera a denominar en MXN\0A>>$\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [92 x i8] c"se requieren billetes en las siguientes cantidades y denominaciones:\0A\09[cant] ---- [Denom]\0A\0A\00"
@.str.6 = [20 x i8] c"\0A\09%dx -------- $%d\0A\00"
define void @main() {
%1 = alloca [20 x i8]
%2 = alloca i32
%3 = alloca [10 x i32]
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %2
%7 = bitcast [10 x i32]* %3 to i8*
%8 = bitcast [10 x i32]* %4 to i8*
store i32 0, i32* %5
store i32 0, i32* %6
%9 = call i32 @puts(i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
store i32 9, i32* %2
br label %16
16: ; preds = %48, %0
%17 = load i32, i32* %2
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %51
19: ; preds = %16
br label %20
20: ; preds = %33, %19
%21 = load i32, i32* %5
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = load i32, i32* %5
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = sdiv i32 %24, %28
%30 = icmp sge i32 %29, 1
br label %31
31: ; preds = %23, %20
%32 = phi i1 [ false, %20 ], [ %30, %23 ]
br i1 %32, label %33, label %45
33: ; preds = %31
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = add nsw i32 %37, 1
store i32 %38, i32* %36
%39 = load i32, i32* %2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = load i32, i32* %5
%44 = sub nsw i32 %43, %42
store i32 %44, i32* %5
br label %20
45: ; preds = %31
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
br label %48
48: ; preds = %45
%49 = load i32, i32* %2
%50 = add nsw i32 %49, -1
store i32 %50, i32* %2
br label %16
51: ; preds = %16
%52 = call i32 @puts(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
br label %53
53: ; preds = %68, %51
%54 = load i32, i32* %2
%55 = load i32, i32* %6
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %71
57: ; preds = %53
%58 = load i32, i32* %2
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = load i32, i32* %2
%63 = sub nsw i32 9, %62
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %61, i32 %66)
br label %68
68: ; preds = %57
%69 = load i32, i32* %2
%70 = add nsw i32 %69, 1
store i32 %70, i32* %2
br label %53
71: ; preds = %53
ret void
}

LLVM IR (-O2):
@__const.main.feria = [10 x i32] [i32 1, i32 2, i32 5, i32 10, i32 20, i32 50, i32 100, i32 200, i32 500, i32 1000]
@.str = [124 x i8] c"este programa determina el minimo conjunto de billetes necesarios para lograr la cifra monetaria deseada en pesos mexicanos\00"
@.str.1 = [56 x i8] c"Usuario, para empezar favor de introducir su nombre:\0A>>\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [72 x i8] c"Muy bien %s, Ahora introdusca la cantidad entera a denominar en MXN\0A>>$\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [92 x i8] c"se requieren billetes en las siguientes cantidades y denominaciones:\0A\09[cant] ---- [Denom]\0A\0A\00"
@.str.6 = [20 x i8] c"\0A\09%dx -------- $%d\0A\00"
define void @main() {
%1 = alloca [20 x i8]
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = bitcast [10 x i32]* %2 to i8*
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([124 x i8], [124 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %3
br label %13
13: ; preds = %0, %31
%14 = phi i64 [ 9, %0 ], [ %34, %31 ]
%15 = phi i64 [ 0, %0 ], [ %33, %31 ]
%16 = phi i32 [ %12, %0 ], [ %32, %31 ]
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %31
18: ; preds = %13
%19 = getelementptr inbounds [10 x i32], [10 x i32]* @__const.main.feria, i64 0, i64 %14
%20 = load i32, i32* %19
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %15
br label %22
22: ; preds = %18, %26
%23 = phi i32 [ %16, %18 ], [ %29, %26 ]
%24 = sdiv i32 %23, %20
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i32, i32* %21
%28 = add nsw i32 %27, 1
store i32 %28, i32* %21
%29 = sub nsw i32 %23, %20
store i32 %29, i32* %3
%30 = icmp sgt i32 %29, 0
br i1 %30, label %22, label %31
31: ; preds = %22, %26, %13
%32 = phi i32 [ %16, %13 ], [ %29, %26 ], [ %23, %22 ]
%33 = add nuw nsw i64 %15, 1
%34 = add nsw i64 %14, -1
%35 = icmp eq i64 %33, 10
br i1 %35, label %36, label %13
36: ; preds = %31
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([92 x i8], [92 x i8]* @.str.5, i64 0, i64 0))
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %39, i32 1000)
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 1
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %42, i32 500)
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 2
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %45, i32 200)
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 3
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %48, i32 100)
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 4
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %51, i32 50)
%53 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 5
%54 = load i32, i32* %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %54, i32 20)
%56 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 6
%57 = load i32, i32* %56
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %57, i32 10)
%59 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 7
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %60, i32 5)
%62 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 8
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %63, i32 2)
%65 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 9
%66 = load i32, i32* %65
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %66, i32 1)
ret void
}