#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *, int, char *, int, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, ...);
int strlen(char *);
int toupper(char);
char *moral_regla6(char *result, char *palabras[], const int verbose) {
  memset(result, 0, 4);
  if (strlen(palabras[1]) > 1) {
    if (verbose)
      printf("Aplicando regla 6:\n\t%-20s %c\n\t%-20s %c%c\n", palabras[0],
             toupper(*palabras[0]), palabras[1], toupper(*palabras[1]),
             toupper(*(palabras[1] + 1)));
    snprintf(result, 4, "%c%c%c", toupper(*palabras[0]), toupper(*palabras[1]),
             toupper(*(palabras[1] + 1)));
  } else {
    if (verbose)
      printf("Aplicando regla 6, y regla 8 (agregando una X al final para "
             "completar la clave):\n\t%-20s %c\n\t%-20s %c\n",
             palabras[0], toupper(*palabras[0]), palabras[1],
             toupper(*palabras[1]));
    snprintf(result, 4, "%c%cX", toupper(*palabras[0]), toupper(*palabras[1]));
  }
  return result;
}


x86 assembly (clang, -O0):
<moral_regla6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1070 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jle    1264 <moral_regla6+0x114>
cmpl   $0x0,-0x14(%rbp)
je     1200 <moral_regla6+0xb0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%edi
call   1030 <toupper@plt>
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8d
mov    %eax,%r9d
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%edi
call   1030 <toupper@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    %eax,%r9d
mov    $0x4,%esi
lea    0xdd2(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    130a <moral_regla6+0x1ba>
cmpl   $0x0,-0x14(%rbp)
je     12c3 <moral_regla6+0x173>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    -0x58(%rbp),%rsi
mov    -0x4c(%rbp),%edx
mov    -0x48(%rbp),%rcx
mov    %eax,%r8d
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    -0x68(%rbp),%rdi
mov    -0x5c(%rbp),%ecx
mov    %eax,%r8d
mov    $0x4,%esi
lea    0xd94(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<moral_regla6>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %esi,%esi
mov    $0x4,%edx
call   1070 <memset@plt>
mov    0x8(%rbx),%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1219 <moral_regla6+0xc9>
test   %ebp,%ebp
je     11cf <moral_regla6+0x7f>
mov    (%rbx),%r12
movsbl (%r12),%edi
call   1030 <toupper@plt>
mov    %eax,%r15d
mov    0x8(%rbx),%rbp
movsbl 0x0(%rbp),%edi
call   1030 <toupper@plt>
mov    %eax,%r13d
mov    0x8(%rbx),%rax
movsbl 0x1(%rax),%edi
call   1030 <toupper@plt>
lea    0xe47(%rip),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %rbp,%rcx
mov    %r13d,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%r15d
mov    0x8(%rbx),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rax
movsbl 0x1(%rax),%edi
call   1030 <toupper@plt>
lea    0xe2b(%rip),%rdx
mov    %r14,%rdi
mov    $0x4,%esi
mov    %r15d,%ecx
mov    %ebp,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1060 <snprintf@plt>
jmp    1288 <moral_regla6+0x138>
test   %ebp,%ebp
je     1254 <moral_regla6+0x104>
mov    (%rbx),%r12
movsbl (%r12),%edi
call   1030 <toupper@plt>
mov    %eax,%r15d
mov    0x8(%rbx),%rbp
movsbl 0x0(%rbp),%edi
call   1030 <toupper@plt>
lea    0xdf0(%rip),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %rbp,%rcx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
lea    0xe23(%rip),%rdx
mov    %r14,%rdi
mov    $0x4,%esi
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <snprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Aplicando regla 6:\0A\09%-20s %c\0A\09%-20s %c%c\0A\00"
@.str.1 = [7 x i8] c"%c%c%c\00"
@.str.2 = [102 x i8] c"Aplicando regla 6, y regla 8 (agregando una X al final para completar la clave):\0A\09%-20s %c\0A\09%-20s %c\0A\00"
@.str.3 = [6 x i8] c"%c%cX\00"
define i8* @moral_regla6(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = call i32 @memset(i8* %7, i32 0, i32 4)
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strlen(i8* %11)
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %60
14: ; preds = %3
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %41
17: ; preds = %14
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = load i8, i8* %23
%25 = call i32 @toupper(i8 signext %24)
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = load i8, i8* %31
%33 = call i32 @toupper(i8 signext %32)
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8, i8* %37
%39 = call i32 @toupper(i8 signext %38)
%40 = call i32 (i8*, i8*, i32, i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %20, i32 %25, i8* %28, i32 %33, i32 %39)
br label %41
41: ; preds = %17, %14
%42 = load i8*, i8** %4
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 0
%45 = load i8*, i8** %44
%46 = load i8, i8* %45
%47 = call i32 @toupper(i8 signext %46)
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = load i8, i8* %50
%52 = call i32 @toupper(i8 signext %51)
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = getelementptr inbounds i8, i8* %55, i64 1
%57 = load i8, i8* %56
%58 = call i32 @toupper(i8 signext %57)
%59 = call i32 (i8*, i32, i8*, i32, i32, ...) @snprintf(i8* %42, i32 4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %47, i32 %52, i32 %58)
br label %94
60: ; preds = %3
%61 = load i32, i32* %6
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %81
63: ; preds = %60
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 0
%66 = load i8*, i8** %65
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 0
%69 = load i8*, i8** %68
%70 = load i8, i8* %69
%71 = call i32 @toupper(i8 signext %70)
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 1
%74 = load i8*, i8** %73
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 1
%77 = load i8*, i8** %76
%78 = load i8, i8* %77
%79 = call i32 @toupper(i8 signext %78)
%80 = call i32 (i8*, i8*, i32, i8*, i32, ...) @printf(i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.2, i64 0, i64 0), i8* %66, i32 %71, i8* %74, i32 %79)
br label %81
81: ; preds = %63, %60
%82 = load i8*, i8** %4
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 0
%85 = load i8*, i8** %84
%86 = load i8, i8* %85
%87 = call i32 @toupper(i8 signext %86)
%88 = load i8**, i8*** %5
%89 = getelementptr inbounds i8*, i8** %88, i64 1
%90 = load i8*, i8** %89
%91 = load i8, i8* %90
%92 = call i32 @toupper(i8 signext %91)
%93 = call i32 (i8*, i32, i8*, i32, i32, ...) @snprintf(i8* %82, i32 4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %87, i32 %92)
br label %94
94: ; preds = %81, %41
%95 = load i8*, i8** %4
ret i8* %95
}

LLVM IR (-O2):
@.str = [42 x i8] c"Aplicando regla 6:\0A\09%-20s %c\0A\09%-20s %c%c\0A\00"
@.str.1 = [7 x i8] c"%c%c%c\00"
@.str.2 = [102 x i8] c"Aplicando regla 6, y regla 8 (agregando una X al final para completar la clave):\0A\09%-20s %c\0A\09%-20s %c\0A\00"
@.str.3 = [6 x i8] c"%c%cX\00"
define i8* @moral_regla6(i8* returned %0, i8** nocapture %1, i32 %2) {
%4 = tail call i32 @memset(i8* %0, i32 0, i32 4)
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strlen(i8* %6)
%8 = icmp sgt i32 %7, 1
%9 = icmp eq i32 %2, 0
br i1 %8, label %10, label %35
10: ; preds = %3
br i1 %9, label %23, label %11
11: ; preds = %10
%12 = load i8*, i8** %1
%13 = load i8, i8* %12
%14 = tail call i32 @toupper(i8 signext %13)
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = tail call i32 @toupper(i8 signext %16)
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = tail call i32 @toupper(i8 signext %20)
%22 = tail call i32 (i8*, i8*, i32, i8*, i32, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %14, i8* %15, i32 %17, i32 %21)
br label %23
23: ; preds = %11, %10
%24 = load i8*, i8** %1
%25 = load i8, i8* %24
%26 = tail call i32 @toupper(i8 signext %25)
%27 = load i8*, i8** %5
%28 = load i8, i8* %27
%29 = tail call i32 @toupper(i8 signext %28)
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = tail call i32 @toupper(i8 signext %32)
%34 = tail call i32 (i8*, i32, i8*, i32, i32, ...) @snprintf(i8* %0, i32 4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %29, i32 %33)
br label %52
35: ; preds = %3
br i1 %9, label %44, label %36
36: ; preds = %35
%37 = load i8*, i8** %1
%38 = load i8, i8* %37
%39 = tail call i32 @toupper(i8 signext %38)
%40 = load i8*, i8** %5
%41 = load i8, i8* %40
%42 = tail call i32 @toupper(i8 signext %41)
%43 = tail call i32 (i8*, i8*, i32, i8*, i32, ...) @printf(i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.2, i64 0, i64 0), i8* %37, i32 %39, i8* %40, i32 %42)
br label %44
44: ; preds = %36, %35
%45 = load i8*, i8** %1
%46 = load i8, i8* %45
%47 = tail call i32 @toupper(i8 signext %46)
%48 = load i8*, i8** %5
%49 = load i8, i8* %48
%50 = tail call i32 @toupper(i8 signext %49)
%51 = tail call i32 (i8*, i32, i8*, i32, i32, ...) @snprintf(i8* %0, i32 4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %47, i32 %50)
br label %52
52: ; preds = %44, %23
ret i8* %0
}