#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*/ free(char *);
scalar_t__ isalpha(char);
scalar_t__ isdigit(char);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *, int, ...);
int sscanf(char *, char *, char *, char *, char *, char *);
size_t strlen(char *);
char *to_upper_case_and_convert(unsigned char *);
int extrae_fecha(const char *semiclave, char *day, char *month, char *year,
                 int verbose) {
  int res = 0;
  char siglas[5];
  int letras = 0;
  int digitos = 0;
  int i = 0;
  char *clave = NULL;
  size_t len = 0;
  clave = to_upper_case_and_convert((unsigned char *)semiclave);
  len = strlen(clave);
  if (len > 13 || len < 9) {
    if (verbose)
      printf("%s:%d : Error -1. Longitud de la clave no suficiente para "
             "realizar la extracción (longitud = %d.)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/egamez/inere/refs/heads/master/lib/"
             "extrae_fecha.c",
             91, len);
    free(clave);
    return -1;
  }
  while (*clave) {
    if (isalpha(*clave))
      letras++;
    else if (*clave == '^')
      letras++;
    else if (*clave == '&')
      letras++;
    else if (isdigit(*clave))
      digitos++;
    if (letras > 4) {
      if (verbose)
        printf("%s:%d : Se ha completado la cantidad maxima de carácteres para "
               "este test.\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/egamez/inere/refs/heads/"
               "master/lib/extrae_fecha.c",
               105);
      break;
    }
    if (digitos == 6) {
      if (verbose)
        printf("%s:%d : Se ha completado la cantidad máxima para los digitos "
               "que representan la fecha en la clave.\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/egamez/inere/refs/heads/"
               "master/lib/extrae_fecha.c",
               111);
      break;
    }
    clave++;
    i++;
  }
  clave -= i;
  if (digitos != 6) {
    if (verbose)
      printf("%s:%d : Error 2. No es suficiente la cantidad de digitos para la "
             "fecha (digitos = %d.)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/egamez/inere/refs/heads/master/lib/"
             "extrae_fecha.c",
             125, digitos);
    free(clave);
    return -2;
  } else if (letras > 4 || letras < 3) {
    if (verbose)
      printf("%s:%d : Error 4. Cantidad de letras mayor a la esperada (letras "
             "= %d.)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/egamez/inere/refs/heads/master/lib/"
             "extrae_fecha.c",
             131, letras);
    free(clave);
    return -3;
  }
  memset(day, 0, 3);
  memset(month, 0, 3);
  memset(year, 0, 3);
  memset(siglas, 0, 5);
  if (letras == 4) {
    if (verbose)
      printf("%s:%d : Aplicando sscanf con el siguiente formato "
             "\"%%4s%%2s%%2s%%2s\" para la clave de una persona fisica.\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/egamez/inere/refs/heads/master/lib/"
             "extrae_fecha.c",
             145);
    res = sscanf(clave, "%4s%2s%2s%2s", siglas, year, month, day);
  } else if (letras == 3) {
    if (verbose)
      printf("%s:%d : Aplicando sscanf con el siguiente formato "
             "\"%%3s%%2s%%2s%%2s\" para la clave de una persona moral.\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/egamez/inere/refs/heads/master/lib/"
             "extrae_fecha.c",
             150);
    res = sscanf(clave, "%3s%2s%2s%2s", siglas, year, month, day);
  } else {
    if (verbose)
      printf(
          "%s:%d : Error 4. Error inesperador (letras = %d, digitos = %d.)\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/egamez/inere/refs/heads/master/lib/"
          "extrae_fecha.c",
          155, letras, digitos);
    free(clave);
    return -4;
  }
  if (res != 4) {
    if (verbose)
      printf("%s:%d : Error 5. Cantidad de sustituciones mayor a la esperada "
             "(sustituciones = %d.)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/egamez/inere/refs/heads/master/lib/"
             "extrae_fecha.c",
             162, res);
    free(clave);
    return -5;
  }
  if (verbose)
    printf("%s:%d : Input [%s], letras de la clave [%s], año [%s], mes [%s], "
           "día [%s]\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/egamez/inere/refs/heads/master/lib/"
           "extrae_fecha.c",
           168, semiclave, siglas, year, month, day);
  free(clave);
  return 0;
}


x86 assembly (clang, -O0):
<extrae_fecha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   10a0 <to_upper_case_and_convert@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0xd,-0x58(%rbp)
ja     11f8 <extrae_fecha+0x78>
cmpq   $0x9,-0x58(%rbp)
jae    1235 <extrae_fecha+0xb5>
cmpl   $0x0,-0x2c(%rbp)
je     1220 <extrae_fecha+0xa0>
mov    -0x58(%rbp),%rcx
lea    0xdf3(%rip),%rdi
lea    0xe50(%rip),%rsi
mov    $0x5b,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15ce <extrae_fecha+0x44e>
jmp    123a <extrae_fecha+0xba>
mov    -0x50(%rbp),%rax
cmpb   $0x0,(%rax)
je     1355 <extrae_fecha+0x1d5>
mov    -0x50(%rbp),%rax
movsbl (%rax),%edi
call   1090 <isalpha@plt>
cmp    $0x0,%rax
je     126b <extrae_fecha+0xeb>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12d5 <extrae_fecha+0x155>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5e,%eax
jne    1289 <extrae_fecha+0x109>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12d0 <extrae_fecha+0x150>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x26,%eax
jne    12a7 <extrae_fecha+0x127>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12cb <extrae_fecha+0x14b>
mov    -0x50(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     12c6 <extrae_fecha+0x146>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    12cb <extrae_fecha+0x14b>
jmp    12d0 <extrae_fecha+0x150>
jmp    12d5 <extrae_fecha+0x155>
cmpl   $0x4,-0x3c(%rbp)
jle    1308 <extrae_fecha+0x188>
cmpl   $0x0,-0x2c(%rbp)
je     1303 <extrae_fecha+0x183>
lea    0xe00(%rip),%rdi
lea    0xd6d(%rip),%rsi
mov    $0x69,%edx
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1355 <extrae_fecha+0x1d5>
cmpl   $0x6,-0x40(%rbp)
jne    133b <extrae_fecha+0x1bb>
cmpl   $0x0,-0x2c(%rbp)
je     1336 <extrae_fecha+0x1b6>
lea    0xe19(%rip),%rdi
lea    0xd3a(%rip),%rsi
mov    $0x6f,%edx
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1355 <extrae_fecha+0x1d5>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    123a <extrae_fecha+0xba>
mov    -0x44(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
cmpl   $0x6,-0x40(%rbp)
je     13b1 <extrae_fecha+0x231>
cmpl   $0x0,-0x2c(%rbp)
je     139c <extrae_fecha+0x21c>
mov    -0x40(%rbp),%ecx
lea    0xe18(%rip),%rdi
lea    0xcd4(%rip),%rsi
mov    $0x7d,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    15ce <extrae_fecha+0x44e>
cmpl   $0x4,-0x3c(%rbp)
jg     13c5 <extrae_fecha+0x245>
cmpl   $0x3,-0x3c(%rbp)
jge    1401 <extrae_fecha+0x281>
cmpl   $0x0,-0x2c(%rbp)
je     13ec <extrae_fecha+0x26c>
mov    -0x3c(%rbp),%ecx
lea    0xe20(%rip),%rdi
lea    0xc84(%rip),%rsi
mov    $0x83,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    15ce <extrae_fecha+0x44e>
jmp    1406 <extrae_fecha+0x286>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1070 <memset@plt>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1070 <memset@plt>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1070 <memset@plt>
lea    -0x35(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1070 <memset@plt>
cmpl   $0x4,-0x3c(%rbp)
jne    149c <extrae_fecha+0x31c>
cmpl   $0x0,-0x2c(%rbp)
je     1474 <extrae_fecha+0x2f4>
lea    0xde0(%rip),%rdi
lea    0xbfc(%rip),%rsi
mov    $0x91,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
lea    -0x35(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0xe1d(%rip),%rsi
call   1080 <sscanf@plt>
mov    %eax,-0x30(%rbp)
jmp    1537 <extrae_fecha+0x3b7>
cmpl   $0x3,-0x3c(%rbp)
jne    14f2 <extrae_fecha+0x372>
cmpl   $0x0,-0x2c(%rbp)
je     14ca <extrae_fecha+0x34a>
lea    0xe02(%rip),%rdi
lea    0xba6(%rip),%rsi
mov    $0x96,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
lea    -0x35(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0xe3e(%rip),%rsi
call   1080 <sscanf@plt>
mov    %eax,-0x30(%rbp)
jmp    1532 <extrae_fecha+0x3b2>
cmpl   $0x0,-0x2c(%rbp)
je     151d <extrae_fecha+0x39d>
mov    -0x3c(%rbp),%ecx
mov    -0x40(%rbp),%r8d
lea    0xe26(%rip),%rdi
lea    0xb53(%rip),%rsi
mov    $0x9b,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    15ce <extrae_fecha+0x44e>
jmp    1537 <extrae_fecha+0x3b7>
cmpl   $0x4,-0x30(%rbp)
je     157d <extrae_fecha+0x3fd>
cmpl   $0x0,-0x2c(%rbp)
je     1568 <extrae_fecha+0x3e8>
mov    -0x30(%rbp),%ecx
lea    0xe1c(%rip),%rdi
lea    0xb08(%rip),%rsi
mov    $0xa2,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffffb,-0x4(%rbp)
jmp    15ce <extrae_fecha+0x44e>
cmpl   $0x0,-0x2c(%rbp)
je     15be <extrae_fecha+0x43e>
mov    -0x10(%rbp),%rcx
lea    -0x35(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    -0x20(%rbp),%r10
mov    -0x18(%rbp),%rax
lea    0xe25(%rip),%rdi
lea    0xabb(%rip),%rsi
mov    $0xa8,%edx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extrae_fecha>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%ebp
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
call   10a0 <to_upper_case_and_convert@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
lea    -0xe(%rax),%rcx
cmp    $0xfffffffffffffffb,%rcx
jae    11ea <extrae_fecha+0x6a>
test   %ebp,%ebp
je     11d8 <extrae_fecha+0x58>
lea    0xe3e(%rip),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x5b,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0xffffffff,%eax
jmp    131c <extrae_fecha+0x19c>
mov    (%rbx),%al
test   %al,%al
je     12ba <extrae_fecha+0x13a>
mov    %r12,0x10(%rsp)
mov    %r15,0x18(%rsp)
mov    %r14,0x20(%rsp)
xor    %r12d,%r12d
xor    %r15d,%r15d
xor    %r14d,%r14d
nopl   0x0(%rax)
movsbl %al,%edi
call   1090 <isalpha@plt>
test   %rax,%rax
je     1240 <extrae_fecha+0xc0>
cmp    $0x4,%r14d
jge    12ce <extrae_fecha+0x14e>
add    $0x1,%r14d
movzbl 0x1(%rbx,%r12,1),%eax
add    $0x1,%r12
test   %al,%al
jne    1210 <extrae_fecha+0x90>
jmp    12c2 <extrae_fecha+0x142>
xchg   %ax,%ax
movzbl (%rbx,%r12,1),%eax
cmp    $0x5e,%al
je     121d <extrae_fecha+0x9d>
cmp    $0x26,%al
je     121d <extrae_fecha+0x9d>
movsbl %al,%edi
call   1040 <isdigit@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%r15d
cmp    $0x6,%r15d
jne    122b <extrae_fecha+0xab>
add    %r12,%rbx
test   %ebp,%ebp
je     1330 <extrae_fecha+0x1b0>
lea    0xec7(%rip),%rdi
lea    0xde8(%rip),%rsi
mov    $0x6f,%edx
xor    %eax,%eax
call   1060 <printf@plt>
sub    %r12,%rbx
lea    -0x5(%r14),%eax
cmp    $0xfffffffe,%eax
jae    134b <extrae_fecha+0x1cb>
lea    0xf5a(%rip),%rdi
lea    0xdbe(%rip),%rsi
mov    $0x83,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    133c <extrae_fecha+0x1bc>
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    12c5 <extrae_fecha+0x145>
add    %r12,%rbx
sub    %r12,%rbx
test   %ebp,%ebp
jne    12f2 <extrae_fecha+0x172>
jmp    130f <extrae_fecha+0x18f>
add    %r12,%rbx
test   %ebp,%ebp
je     132b <extrae_fecha+0x1ab>
lea    0xe14(%rip),%rdi
lea    0xd81(%rip),%rsi
mov    $0x69,%edx
xor    %eax,%eax
call   1060 <printf@plt>
sub    %r12,%rbx
lea    0xea8(%rip),%rdi
lea    0xd64(%rip),%rsi
mov    $0x7d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0xfffffffe,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
sub    %r12,%rbx
jmp    130f <extrae_fecha+0x18f>
sub    %r12,%rbx
lea    -0x5(%r14),%eax
cmp    $0xfffffffe,%eax
jae    134b <extrae_fecha+0x1cb>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0xfffffffd,%eax
jmp    131c <extrae_fecha+0x19c>
mov    0x18(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1070 <memset@plt>
mov    0x20(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1070 <memset@plt>
mov    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1070 <memset@plt>
lea    0xb(%rsp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1070 <memset@plt>
cmp    $0x4,%r14d
jne    13bb <extrae_fecha+0x23b>
lea    0xf0a(%rip),%r14
test   %ebp,%ebp
je     13e0 <extrae_fecha+0x260>
lea    0xe94(%rip),%rdi
lea    0xcb0(%rip),%rsi
mov    $0x91,%edx
jmp    13d9 <extrae_fecha+0x259>
lea    0xf61(%rip),%r14
test   %ebp,%ebp
je     13e0 <extrae_fecha+0x260>
lea    0xeec(%rip),%rdi
lea    0xc90(%rip),%rsi
mov    $0x96,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xb(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    0x10(%rsp),%rcx
mov    %r15,%r8
mov    %r12,%r9
call   1080 <sscanf@plt>
cmp    $0x4,%eax
jne    1442 <extrae_fecha+0x2c2>
test   %ebp,%ebp
je     1433 <extrae_fecha+0x2b3>
lea    0xf7b(%rip),%rdi
lea    0xc52(%rip),%rsi
lea    0xb(%rsp),%r8
mov    $0xa8,%edx
mov    %r13,%rcx
mov    0x10(%rsp),%r9
xor    %eax,%eax
push   %r12
push   %r15
call   1060 <printf@plt>
add    $0x10,%rsp
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    131c <extrae_fecha+0x19c>
test   %ebp,%ebp
je     1462 <extrae_fecha+0x2e2>
lea    0xee3(%rip),%rdi
lea    0xc10(%rip),%rsi
mov    $0xa2,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0xfffffffb,%eax
jmp    131c <extrae_fecha+0x19c>

LLVM IR (-O0):
@.str = [100 x i8] c"%s:%d : Error -1. Longitud de la clave no suficiente para realizar la extracci\C3\B3n (longitud = %d.)\0A\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/egamez/inere/refs/heads/master/lib/extrae_fecha.c\00"
@.str.2 = [76 x i8] c"%s:%d : Se ha completado la cantidad maxima de car\C3\A1cteres para este test.\0A\00"
@.str.3 = [101 x i8] c"%s:%d : Se ha completado la cantidad m\C3\A1xima para los digitos que representan la fecha en la clave.\0A\00"
@.str.4 = [88 x i8] c"%s:%d : Error 2. No es suficiente la cantidad de digitos para la fecha (digitos = %d.)\0A\00"
@.str.5 = [72 x i8] c"%s:%d : Error 4. Cantidad de letras mayor a la esperada (letras = %d.)\0A\00"
@.str.6 = [107 x i8] c"%s:%d : Aplicando sscanf con el siguiente formato \22%%4s%%2s%%2s%%2s\22 para la clave de una persona fisica.\0A\00"
@.str.7 = [13 x i8] c"%4s%2s%2s%2s\00"
@.str.8 = [106 x i8] c"%s:%d : Aplicando sscanf con el siguiente formato \22%%3s%%2s%%2s%%2s\22 para la clave de una persona moral.\0A\00"
@.str.9 = [13 x i8] c"%3s%2s%2s%2s\00"
@.str.10 = [65 x i8] c"%s:%d : Error 4. Error inesperador (letras = %d, digitos = %d.)\0A\00"
@.str.11 = [86 x i8] c"%s:%d : Error 5. Cantidad de sustituciones mayor a la esperada (sustituciones = %d.)\0A\00"
@.str.12 = [77 x i8] c"%s:%d : Input [%s], letras de la clave [%s], a\C3\B1o [%s], mes [%s], d\C3\ADa [%s]\0A\00"
define i32 @extrae_fecha(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca [5 x i8]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i64
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i32 0, i32* %12
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i8* null, i8** %17
store i64 0, i64* %18
%19 = load i8*, i8** %7
%20 = call i8* @to_upper_case_and_convert(i8* %19)
store i8* %20, i8** %17
%21 = load i8*, i8** %17
%22 = call i64 @strlen(i8* %21)
store i64 %22, i64* %18
%23 = load i64, i64* %18
%24 = icmp ugt i64 %23, 13
br i1 %24, label %28, label %25
25: ; preds = %5
%26 = load i64, i64* %18
%27 = icmp ult i64 %26, 9
br i1 %27, label %28, label %37
28: ; preds = %25, %5
%29 = load i32, i32* %11
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i64, i64* %18
%33 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 91, i64 %32)
br label %34
34: ; preds = %31, %28
%35 = load i8*, i8** %17
%36 = call i32 @free(i8* %35)
store i32 -1, i32* %6
br label %207
37: ; preds = %25
br label %38
38: ; preds = %95, %37
%39 = load i8*, i8** %17
%40 = load i8, i8* %39
%41 = icmp ne i8 %40, 0
br i1 %41, label %42, label %100
42: ; preds = %38
%43 = load i8*, i8** %17
%44 = load i8, i8* %43
%45 = call i64 @isalpha(i8 signext %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %42
%48 = load i32, i32* %14
%49 = add nsw i32 %48, 1
store i32 %49, i32* %14
br label %77
50: ; preds = %42
%51 = load i8*, i8** %17
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 94
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = load i32, i32* %14
%57 = add nsw i32 %56, 1
store i32 %57, i32* %14
br label %76
58: ; preds = %50
%59 = load i8*, i8** %17
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 38
br i1 %62, label %63, label %66
63: ; preds = %58
%64 = load i32, i32* %14
%65 = add nsw i32 %64, 1
store i32 %65, i32* %14
br label %75
66: ; preds = %58
%67 = load i8*, i8** %17
%68 = load i8, i8* %67
%69 = call i64 @isdigit(i8 signext %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %66
%72 = load i32, i32* %15
%73 = add nsw i32 %72, 1
store i32 %73, i32* %15
br label %74
74: ; preds = %71, %66
br label %75
75: ; preds = %74, %63
br label %76
76: ; preds = %75, %55
br label %77
77: ; preds = %76, %47
%78 = load i32, i32* %14
%79 = icmp sgt i32 %78, 4
br i1 %79, label %80, label %86
80: ; preds = %77
%81 = load i32, i32* %11
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %80
%84 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 105)
br label %85
85: ; preds = %83, %80
br label %100
86: ; preds = %77
%87 = load i32, i32* %15
%88 = icmp eq i32 %87, 6
br i1 %88, label %89, label %95
89: ; preds = %86
%90 = load i32, i32* %11
%91 = icmp ne i32 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %89
%93 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 111)
br label %94
94: ; preds = %92, %89
br label %100
95: ; preds = %86
%96 = load i8*, i8** %17
%97 = getelementptr inbounds i8, i8* %96, i32 1
store i8* %97, i8** %17
%98 = load i32, i32* %16
%99 = add nsw i32 %98, 1
store i32 %99, i32* %16
br label %38
100: ; preds = %94, %85, %38
%101 = load i32, i32* %16
%102 = load i8*, i8** %17
%103 = sext i32 %101 to i64
%104 = sub i64 0, %103
%105 = getelementptr inbounds i8, i8* %102, i64 %104
store i8* %105, i8** %17
%106 = load i32, i32* %15
%107 = icmp ne i32 %106, 6
br i1 %107, label %108, label %117
108: ; preds = %100
%109 = load i32, i32* %11
%110 = icmp ne i32 %109, 0
br i1 %110, label %111, label %114
111: ; preds = %108
%112 = load i32, i32* %15
%113 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 125, i32 %112)
br label %114
114: ; preds = %111, %108
%115 = load i8*, i8** %17
%116 = call i32 @free(i8* %115)
store i32 -2, i32* %6
br label %207
117: ; preds = %100
%118 = load i32, i32* %14
%119 = icmp sgt i32 %118, 4
br i1 %119, label %123, label %120
120: ; preds = %117
%121 = load i32, i32* %14
%122 = icmp slt i32 %121, 3
br i1 %122, label %123, label %132
123: ; preds = %120, %117
%124 = load i32, i32* %11
%125 = icmp ne i32 %124, 0
br i1 %125, label %126, label %129
126: ; preds = %123
%127 = load i32, i32* %14
%128 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 131, i32 %127)
br label %129
129: ; preds = %126, %123
%130 = load i8*, i8** %17
%131 = call i32 @free(i8* %130)
store i32 -3, i32* %6
br label %207
132: ; preds = %120
br label %133
133: ; preds = %132
%134 = load i8*, i8** %8
%135 = call i32 @memset(i8* %134, i32 0, i32 3)
%136 = load i8*, i8** %9
%137 = call i32 @memset(i8* %136, i32 0, i32 3)
%138 = load i8*, i8** %10
%139 = call i32 @memset(i8* %138, i32 0, i32 3)
%140 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 0
%141 = call i32 @memset(i8* %140, i32 0, i32 5)
%142 = load i32, i32* %14
%143 = icmp eq i32 %142, 4
br i1 %143, label %144, label %156
144: ; preds = %133
%145 = load i32, i32* %11
%146 = icmp ne i32 %145, 0
br i1 %146, label %147, label %149
147: ; preds = %144
%148 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 145)
br label %149
149: ; preds = %147, %144
%150 = load i8*, i8** %17
%151 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 0
%152 = load i8*, i8** %10
%153 = load i8*, i8** %9
%154 = load i8*, i8** %8
%155 = call i32 @sscanf(i8* %150, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %151, i8* %152, i8* %153, i8* %154)
store i32 %155, i32* %12
br label %182
156: ; preds = %133
%157 = load i32, i32* %14
%158 = icmp eq i32 %157, 3
br i1 %158, label %159, label %171
159: ; preds = %156
%160 = load i32, i32* %11
%161 = icmp ne i32 %160, 0
br i1 %161, label %162, label %164
162: ; preds = %159
%163 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 150)
br label %164
164: ; preds = %162, %159
%165 = load i8*, i8** %17
%166 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 0
%167 = load i8*, i8** %10
%168 = load i8*, i8** %9
%169 = load i8*, i8** %8
%170 = call i32 @sscanf(i8* %165, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i8* %166, i8* %167, i8* %168, i8* %169)
store i32 %170, i32* %12
br label %181
171: ; preds = %156
%172 = load i32, i32* %11
%173 = icmp ne i32 %172, 0
br i1 %173, label %174, label %178
174: ; preds = %171
%175 = load i32, i32* %14
%176 = load i32, i32* %15
%177 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 155, i32 %175, i32 %176)
br label %178
178: ; preds = %174, %171
%179 = load i8*, i8** %17
%180 = call i32 @free(i8* %179)
store i32 -4, i32* %6
br label %207
181: ; preds = %164
br label %182
182: ; preds = %181, %149
%183 = load i32, i32* %12
%184 = icmp ne i32 %183, 4
br i1 %184, label %185, label %194
185: ; preds = %182
%186 = load i32, i32* %11
%187 = icmp ne i32 %186, 0
br i1 %187, label %188, label %191
188: ; preds = %185
%189 = load i32, i32* %12
%190 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 162, i32 %189)
br label %191
191: ; preds = %188, %185
%192 = load i8*, i8** %17
%193 = call i32 @free(i8* %192)
store i32 -5, i32* %6
br label %207
194: ; preds = %182
%195 = load i32, i32* %11
%196 = icmp ne i32 %195, 0
br i1 %196, label %197, label %204
197: ; preds = %194
%198 = load i8*, i8** %7
%199 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 0
%200 = load i8*, i8** %10
%201 = load i8*, i8** %9
%202 = load i8*, i8** %8
%203 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 168, i8* %198, i8* %199, i8* %200, i8* %201, i8* %202)
br label %204
204: ; preds = %197, %194
%205 = load i8*, i8** %17
%206 = call i32 @free(i8* %205)
store i32 0, i32* %6
br label %207
207: ; preds = %204, %191, %178, %129, %114, %34
%208 = load i32, i32* %6
ret i32 %208
}

LLVM IR (-O2):
@.str = [100 x i8] c"%s:%d : Error -1. Longitud de la clave no suficiente para realizar la extracci\C3\B3n (longitud = %d.)\0A\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/egamez/inere/refs/heads/master/lib/extrae_fecha.c\00"
@.str.2 = [76 x i8] c"%s:%d : Se ha completado la cantidad maxima de car\C3\A1cteres para este test.\0A\00"
@.str.3 = [101 x i8] c"%s:%d : Se ha completado la cantidad m\C3\A1xima para los digitos que representan la fecha en la clave.\0A\00"
@.str.4 = [88 x i8] c"%s:%d : Error 2. No es suficiente la cantidad de digitos para la fecha (digitos = %d.)\0A\00"
@.str.5 = [72 x i8] c"%s:%d : Error 4. Cantidad de letras mayor a la esperada (letras = %d.)\0A\00"
@.str.6 = [107 x i8] c"%s:%d : Aplicando sscanf con el siguiente formato \22%%4s%%2s%%2s%%2s\22 para la clave de una persona fisica.\0A\00"
@.str.7 = [13 x i8] c"%4s%2s%2s%2s\00"
@.str.8 = [106 x i8] c"%s:%d : Aplicando sscanf con el siguiente formato \22%%3s%%2s%%2s%%2s\22 para la clave de una persona moral.\0A\00"
@.str.9 = [13 x i8] c"%3s%2s%2s%2s\00"
@.str.11 = [86 x i8] c"%s:%d : Error 5. Cantidad de sustituciones mayor a la esperada (sustituciones = %d.)\0A\00"
@.str.12 = [77 x i8] c"%s:%d : Input [%s], letras de la clave [%s], a\C3\B1o [%s], mes [%s], d\C3\ADa [%s]\0A\00"
define i32 @extrae_fecha(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca [5 x i8]
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%8 = tail call i8* @to_upper_case_and_convert(i8* %0)
%9 = tail call i64 @strlen(i8* dereferenceable(1) %8)
%10 = add i64 %9, -14
%11 = icmp ult i64 %10, -5
br i1 %11, label %15, label %12
12: ; preds = %5
%13 = load i8, i8* %8
%14 = icmp eq i8 %13, 0
br i1 %14, label %62, label %21
15: ; preds = %5
%16 = icmp eq i32 %4, 0
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 91, i64 %9)
br label %19
19: ; preds = %17, %15
%20 = tail call i32 @free(i8* %8)
br label %121
21: ; preds = %12, %53
%22 = phi i8 [ %58, %53 ], [ %13, %12 ]
%23 = phi i8* [ %56, %53 ], [ %8, %12 ]
%24 = phi i32 [ %57, %53 ], [ 0, %12 ]
%25 = phi i32 [ %55, %53 ], [ 0, %12 ]
%26 = phi i32 [ %54, %53 ], [ 0, %12 ]
%27 = tail call i64 @isalpha(i8 signext %22)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = load i8, i8* %23
switch i8 %30, label %45 [
i8 94, label %31
i8 38, label %31
]
31: ; preds = %29, %29, %21
%32 = add nsw i32 %26, 1
%33 = icmp sgt i32 %26, 3
br i1 %33, label %34, label %53
34: ; preds = %31
%35 = icmp eq i32 %4, 0
br i1 %35, label %36, label %40
36: ; preds = %34
%37 = zext i32 %24 to i64
%38 = sub nsw i64 0, %37
%39 = getelementptr inbounds i8, i8* %23, i64 %38
br label %73
40: ; preds = %34
%41 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 105)
%42 = zext i32 %24 to i64
%43 = sub nsw i64 0, %42
%44 = getelementptr inbounds i8, i8* %23, i64 %43
br label %69
45: ; preds = %29
%46 = tail call i64 @isdigit(i8 signext %30)
%47 = icmp ne i64 %46, 0
%48 = zext i1 %47 to i32
%49 = add nsw i32 %25, %48
%50 = icmp eq i32 %49, 6
br i1 %50, label %51, label %53
51: ; preds = %45
%52 = icmp eq i32 %4, 0
br i1 %52, label %83, label %76
53: ; preds = %31, %45
%54 = phi i32 [ %26, %45 ], [ %32, %31 ]
%55 = phi i32 [ %49, %45 ], [ %25, %31 ]
%56 = getelementptr inbounds i8, i8* %23, i64 1
%57 = add nuw nsw i32 %24, 1
%58 = load i8, i8* %56
%59 = icmp eq i8 %58, 0
br i1 %59, label %60, label %21
60: ; preds = %53
%61 = zext i32 %57 to i64
br label %62
62: ; preds = %60, %12
%63 = phi i32 [ 0, %12 ], [ %55, %60 ]
%64 = phi i64 [ 0, %12 ], [ %61, %60 ]
%65 = phi i8* [ %8, %12 ], [ %56, %60 ]
%66 = sub nsw i64 0, %64
%67 = getelementptr inbounds i8, i8* %65, i64 %66
%68 = icmp eq i32 %4, 0
br i1 %68, label %73, label %69
69: ; preds = %40, %62
%70 = phi i32 [ %25, %40 ], [ %63, %62 ]
%71 = phi i8* [ %44, %40 ], [ %67, %62 ]
%72 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 125, i32 %70)
br label %73
73: ; preds = %36, %69, %62
%74 = phi i8* [ %39, %36 ], [ %71, %69 ], [ %67, %62 ]
%75 = tail call i32 @free(i8* %74)
br label %121
76: ; preds = %51
%77 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 111)
%78 = zext i32 %24 to i64
%79 = sub nsw i64 0, %78
%80 = getelementptr inbounds i8, i8* %23, i64 %79
%81 = add i32 %26, -5
%82 = icmp ult i32 %81, -2
br i1 %82, label %89, label %94
83: ; preds = %51
%84 = zext i32 %24 to i64
%85 = sub nsw i64 0, %84
%86 = getelementptr inbounds i8, i8* %23, i64 %85
%87 = add i32 %26, -5
%88 = icmp ult i32 %87, -2
br i1 %88, label %91, label %94
89: ; preds = %76
%90 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 131, i32 %26)
br label %91
91: ; preds = %83, %89
%92 = phi i8* [ %80, %89 ], [ %86, %83 ]
%93 = tail call i32 @free(i8* %92)
br label %121
94: ; preds = %83, %76
%95 = phi i8* [ %86, %83 ], [ %80, %76 ]
%96 = tail call i32 @memset(i8* %1, i32 0, i32 3)
%97 = tail call i32 @memset(i8* %2, i32 0, i32 3)
%98 = tail call i32 @memset(i8* %3, i32 0, i32 3)
%99 = call i32 @memset(i8* %7, i32 0, i32 5)
%100 = icmp eq i32 %26, 4
br i1 %100, label %101, label %104
101: ; preds = %94
br i1 %52, label %107, label %102
102: ; preds = %101
%103 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 145)
br label %107
104: ; preds = %94
br i1 %52, label %107, label %105
105: ; preds = %104
%106 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 150)
br label %107
107: ; preds = %104, %105, %101, %102
%108 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), %102 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), %101 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), %105 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), %104 ]
%109 = call i32 @sscanf(i8* %95, i8* %108, i8* %7, i8* %3, i8* %2, i8* %1)
%110 = icmp eq i32 %109, 4
br i1 %110, label %116, label %111
111: ; preds = %107
br i1 %52, label %114, label %112
112: ; preds = %111
%113 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 162, i32 %109)
br label %114
114: ; preds = %112, %111
%115 = call i32 @free(i8* %95)
br label %121
116: ; preds = %107
br i1 %52, label %119, label %117
117: ; preds = %116
%118 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 168, i8* %0, i8* %7, i8* %3, i8* %2, i8* %1)
br label %119
119: ; preds = %117, %116
%120 = call i32 @free(i8* %95)
br label %121
121: ; preds = %119, %114, %91, %73, %19
%122 = phi i32 [ -1, %19 ], [ -2, %73 ], [ -3, %91 ], [ -5, %114 ], [ 0, %119 ]
ret i32 %122
}