#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 atoi(char *);
scalar_t__ calloc(size_t, int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
char *numeral_alloc(char *, int const);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, int);
int strlen(char const *);
char *strncpy(char *, char const *, int);
scalar_t__ strstr(char const *, char *);
char *strtok(char *, char *);
char *cantidadcl_alloc(const char *numero, const int debug) {
  char *cents = 0;
  char *integral = 0;
  char *buffer = NULL;
  size_t buffer_len = 0;
  int cents_len = 0;
  int must_freed = 0;
  char *nombre = NULL;
  cents = (char *)strstr(numero, ".");
  if (cents != NULL)
    cents_len = strlen(cents);
  integral = (char *)malloc(strlen(numero) - cents_len + 1);
  memset(integral, 0, strlen(numero) - cents_len + 1);
  integral = strncpy(integral, numero, strlen(numero) - cents_len);
  if (cents_len <= 1) {
    cents = NULL;
    cents = (char *)malloc(3);
    memset(cents, 0, 3);
    cents = strncpy(cents, "00", 2);
    must_freed = 1;
  } else {
    cents = strtok(cents, ".");
    if (strlen(cents) == 1) {
      *(cents + 1) = '0';
      *(cents + 2) = 0;
    } else if (strlen(cents) > 2) {
      if (debug)
        printf("Cantidad de centavos mayor a 100. Eliminando cantidades "
               "menores que centesimos...");
      *(cents + 2) = 0;
      if (debug)
        printf("eliminados.\n");
    }
  }
  buffer = numeral_alloc(integral, debug);
  free(integral);
  *buffer -= 32;
  buffer_len = strlen(buffer);
  nombre = (char *)calloc(buffer_len + 19, sizeof(char));
  snprintf(nombre, strlen(buffer) + 19, "%s pesos %02d/100 M.N.", buffer,
           atoi(cents));
  if (must_freed)
    free(cents);
  free(buffer);
  return nombre;
}


x86 assembly (clang, -O0):
<cantidadcl_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1230 <cantidadcl_alloc+0x70>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
sub    -0x34(%rbp),%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%edx
sub    -0x34(%rbp),%edx
add    $0x1,%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
sub    -0x34(%rbp),%edx
call   1040 <strncpy@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x34(%rbp)
jg     12f2 <cantidadcl_alloc+0x132>
movq   $0x0,-0x18(%rbp)
mov    $0x3,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1080 <memset@plt>
mov    -0x18(%rbp),%rdi
lea    0xd28(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncpy@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    1382 <cantidadcl_alloc+0x1c2>
mov    -0x18(%rbp),%rdi
lea    0xd56(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x1,%eax
jne    132d <cantidadcl_alloc+0x16d>
mov    -0x18(%rbp),%rax
movb   $0x30,0x1(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x2(%rax)
jmp    137d <cantidadcl_alloc+0x1bd>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jle    1378 <cantidadcl_alloc+0x1b8>
cmpl   $0x0,-0xc(%rbp)
je     1355 <cantidadcl_alloc+0x195>
lea    0xcb3(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,0x2(%rax)
cmpl   $0x0,-0xc(%rbp)
je     1373 <cantidadcl_alloc+0x1b3>
lea    0xce7(%rip),%rdi
call   1060 <printf@plt>
jmp    1378 <cantidadcl_alloc+0x1b8>
jmp    137d <cantidadcl_alloc+0x1bd>
jmp    1382 <cantidadcl_alloc+0x1c2>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   10b0 <numeral_alloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
sub    $0x20,%ecx
mov    %cl,(%rax)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
add    $0x13,%rdi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x13,%eax
mov    %eax,-0x64(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rdi
call   10d0 <atoi@plt>
mov    -0x70(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    -0x60(%rbp),%rcx
mov    %eax,%r8d
lea    0xc59(%rip),%rdx
call   1070 <snprintf@plt>
cmpl   $0x0,-0x38(%rbp)
je     1421 <cantidadcl_alloc+0x261>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cantidadcl_alloc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xe6b(%rip),%rsi
call   10f0 <strstr@plt>
mov    %rax,%r12
test   %rax,%rax
je     1202 <cantidadcl_alloc+0x32>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %eax,%r13d
jmp    1205 <cantidadcl_alloc+0x35>
xor    %r13d,%r13d
mov    %rbp,%rdi
call   1060 <strlen@plt>
lea    -0x1(%r13),%ebx
sub    %ebx,%eax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,%r15
mov    %rbp,%rdi
call   1060 <strlen@plt>
sub    %ebx,%eax
mov    %r15,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1090 <memset@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
sub    %r13d,%eax
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    %rax,%r15
dec    %r13d
jg     128b <cantidadcl_alloc+0xbb>
mov    $0x3,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
xor    %r13d,%r13d
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1090 <memset@plt>
lea    0xd87(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1040 <strncpy@plt>
mov    %rax,%r12
jmp    12f2 <cantidadcl_alloc+0x122>
lea    0xdc1(%rip),%rsi
mov    %r12,%rdi
call   10d0 <strtok@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1060 <strlen@plt>
cmp    $0x1,%eax
jne    12b7 <cantidadcl_alloc+0xe7>
movw   $0x30,0x1(%r12)
mov    $0x1,%r13b
jmp    12f2 <cantidadcl_alloc+0x122>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    $0x1,%r13b
cmp    $0x3,%eax
jl     12f2 <cantidadcl_alloc+0x122>
test   %r14d,%r14d
je     12ec <cantidadcl_alloc+0x11c>
lea    0xd30(%rip),%rdi
call   1070 <printf@plt>
movb   $0x0,0x2(%r12)
lea    0xd87(%rip),%rdi
call   1050 <puts@plt>
jmp    12f2 <cantidadcl_alloc+0x122>
movb   $0x0,0x2(%r12)
mov    %r15,%rdi
mov    %r14d,%esi
call   10c0 <numeral_alloc@plt>
mov    %rax,%rbp
mov    %r15,%rdi
call   1030 <free@plt>
addb   $0xe0,0x0(%rbp)
mov    %rbp,%rdi
call   1060 <strlen@plt>
movslq %eax,%rdi
add    $0x13,%rdi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,%r14
mov    %rbp,%rdi
call   1060 <strlen@plt>
lea    0x13(%rax),%ebx
mov    %r12,%rdi
call   10e0 <atoi@plt>
lea    0xd13(%rip),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rbp,%rcx
mov    %eax,%r8d
call   1080 <snprintf@plt>
test   %r13b,%r13b
jne    135f <cantidadcl_alloc+0x18f>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"00\00"
@.str.2 = [82 x i8] c"Cantidad de centavos mayor a 100. Eliminando cantidades menores que centesimos...\00"
@.str.3 = [13 x i8] c"eliminados.\0A\00"
@.str.4 = [23 x i8] c"%s pesos %02d/100 M.N.\00"
define i8* @cantidadcl_alloc(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
store i8* null, i8** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i64 0, i64* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i8* null, i8** %11
%12 = load i8*, i8** %3
%13 = call i64 @strstr(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %9
br label %20
20: ; preds = %17, %2
%21 = load i8*, i8** %3
%22 = call i32 @strlen(i8* %21)
%23 = load i32, i32* %9
%24 = sub nsw i32 %22, %23
%25 = add nsw i32 %24, 1
%26 = call i64 @malloc(i32 %25)
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %6
%28 = load i8*, i8** %6
%29 = load i8*, i8** %3
%30 = call i32 @strlen(i8* %29)
%31 = load i32, i32* %9
%32 = sub nsw i32 %30, %31
%33 = add nsw i32 %32, 1
%34 = call i32 @memset(i8* %28, i32 0, i32 %33)
%35 = load i8*, i8** %6
%36 = load i8*, i8** %3
%37 = load i8*, i8** %3
%38 = call i32 @strlen(i8* %37)
%39 = load i32, i32* %9
%40 = sub nsw i32 %38, %39
%41 = call i8* @strncpy(i8* %35, i8* %36, i32 %40)
store i8* %41, i8** %6
%42 = load i32, i32* %9
%43 = icmp sle i32 %42, 1
br i1 %43, label %44, label %51
44: ; preds = %20
store i8* null, i8** %5
%45 = call i64 @malloc(i32 3)
%46 = inttoptr i64 %45 to i8*
store i8* %46, i8** %5
%47 = load i8*, i8** %5
%48 = call i32 @memset(i8* %47, i32 0, i32 3)
%49 = load i8*, i8** %5
%50 = call i8* @strncpy(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
store i8* %50, i8** %5
store i32 1, i32* %10
br label %81
51: ; preds = %20
%52 = load i8*, i8** %5
%53 = call i8* @strtok(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %53, i8** %5
%54 = load i8*, i8** %5
%55 = call i32 @strlen(i8* %54)
%56 = icmp eq i32 %55, 1
br i1 %56, label %57, label %62
57: ; preds = %51
%58 = load i8*, i8** %5
%59 = getelementptr inbounds i8, i8* %58, i64 1
store i8 48, i8* %59
%60 = load i8*, i8** %5
%61 = getelementptr inbounds i8, i8* %60, i64 2
store i8 0, i8* %61
br label %80
62: ; preds = %51
%63 = load i8*, i8** %5
%64 = call i32 @strlen(i8* %63)
%65 = icmp sgt i32 %64, 2
br i1 %65, label %66, label %79
66: ; preds = %62
%67 = load i32, i32* %4
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %66
%70 = call i32 @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0))
br label %71
71: ; preds = %69, %66
%72 = load i8*, i8** %5
%73 = getelementptr inbounds i8, i8* %72, i64 2
store i8 0, i8* %73
%74 = load i32, i32* %4
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %78
78: ; preds = %76, %71
br label %79
79: ; preds = %78, %62
br label %80
80: ; preds = %79, %57
br label %81
81: ; preds = %80, %44
%82 = load i8*, i8** %6
%83 = load i32, i32* %4
%84 = call i8* @numeral_alloc(i8* %82, i32 %83)
store i8* %84, i8** %7
%85 = load i8*, i8** %6
%86 = call i32 @free(i8* %85)
%87 = load i8*, i8** %7
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = sub nsw i32 %89, 32
%91 = trunc i32 %90 to i8
store i8 %91, i8* %87
%92 = load i8*, i8** %7
%93 = call i32 @strlen(i8* %92)
%94 = sext i32 %93 to i64
store i64 %94, i64* %8
%95 = load i64, i64* %8
%96 = add i64 %95, 19
%97 = call i64 @calloc(i64 %96, i32 1)
%98 = inttoptr i64 %97 to i8*
store i8* %98, i8** %11
%99 = load i8*, i8** %11
%100 = load i8*, i8** %7
%101 = call i32 @strlen(i8* %100)
%102 = add nsw i32 %101, 19
%103 = load i8*, i8** %7
%104 = load i8*, i8** %5
%105 = call i32 @atoi(i8* %104)
%106 = call i32 @snprintf(i8* %99, i32 %102, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %103, i32 %105)
%107 = load i32, i32* %10
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %112
109: ; preds = %81
%110 = load i8*, i8** %5
%111 = call i32 @free(i8* %110)
br label %112
112: ; preds = %109, %81
%113 = load i8*, i8** %7
%114 = call i32 @free(i8* %113)
%115 = load i8*, i8** %11
ret i8* %115
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"00\00"
@.str.2 = [82 x i8] c"Cantidad de centavos mayor a 100. Eliminando cantidades menores que centesimos...\00"
@.str.4 = [23 x i8] c"%s pesos %02d/100 M.N.\00"
@str = [12 x i8] c"eliminados.\00"
define i8* @cantidadcl_alloc(i8* %0, i32 %1) {
%3 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i64 %3, 0
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %4)
br label %8
8: ; preds = %6, %2
%9 = phi i32 [ %7, %6 ], [ 0, %2 ]
%10 = tail call i32 @strlen(i8* %0)
%11 = sub i32 1, %9
%12 = add i32 %11, %10
%13 = tail call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
%15 = tail call i32 @strlen(i8* %0)
%16 = add i32 %11, %15
%17 = tail call i32 @memset(i8* %14, i32 0, i32 %16)
%18 = tail call i32 @strlen(i8* %0)
%19 = sub nsw i32 %18, %9
%20 = tail call i8* @strncpy(i8* %14, i8* %0, i32 %19)
%21 = icmp slt i32 %9, 2
br i1 %21, label %22, label %27
22: ; preds = %8
%23 = tail call i64 @malloc(i32 3)
%24 = inttoptr i64 %23 to i8*
%25 = tail call i32 @memset(i8* %24, i32 0, i32 3)
%26 = tail call i8* @strncpy(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %45
27: ; preds = %8
%28 = tail call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%29 = tail call i32 @strlen(i8* %28)
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = getelementptr inbounds i8, i8* %28, i64 1
store i8 48, i8* %32
%33 = getelementptr inbounds i8, i8* %28, i64 2
store i8 0, i8* %33
br label %45
34: ; preds = %27
%35 = tail call i32 @strlen(i8* %28)
%36 = icmp sgt i32 %35, 2
br i1 %36, label %37, label %45
37: ; preds = %34
%38 = icmp eq i32 %1, 0
br i1 %38, label %43, label %39
39: ; preds = %37
%40 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0))
%41 = getelementptr inbounds i8, i8* %28, i64 2
store i8 0, i8* %41
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %45
43: ; preds = %37
%44 = getelementptr inbounds i8, i8* %28, i64 2
store i8 0, i8* %44
br label %45
45: ; preds = %43, %31, %39, %34, %22
%46 = phi i8* [ %26, %22 ], [ %28, %31 ], [ %28, %39 ], [ %28, %34 ], [ %28, %43 ]
%47 = phi i1 [ false, %22 ], [ true, %31 ], [ true, %39 ], [ true, %34 ], [ true, %43 ]
%48 = tail call i8* @numeral_alloc(i8* %20, i32 %1)
%49 = tail call i32 @free(i8* %20)
%50 = load i8, i8* %48
%51 = add i8 %50, -32
store i8 %51, i8* %48
%52 = tail call i32 @strlen(i8* %48)
%53 = sext i32 %52 to i64
%54 = add nsw i64 %53, 19
%55 = tail call i64 @calloc(i64 %54, i32 1)
%56 = inttoptr i64 %55 to i8*
%57 = tail call i32 @strlen(i8* %48)
%58 = add nsw i32 %57, 19
%59 = tail call i32 @atoi(i8* %46)
%60 = tail call i32 @snprintf(i8* %56, i32 %58, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %48, i32 %59)
br i1 %47, label %63, label %61
61: ; preds = %45
%62 = tail call i32 @free(i8* %46)
br label %63
63: ; preds = %61, %45
%64 = tail call i32 @free(i8* %48)
ret i8* %56
}