#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*/ cesar_cifrado(char *, int);
int /*<<< orphan*/ cesar_descifrado(char *, int);
int /*<<< orphan*/ exit(int);
size_t getline(char **, size_t *, int /*<<< orphan*/);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char *buffer;
  size_t bufsize = 256;
  size_t n;
  buffer = (char *)malloc(bufsize * sizeof(char));
  if (buffer == NULL) {
    perror("ERROR: no se puede asignar memoria");
    exit(1);
  }
  char cipher[50];
  int shift;
  printf("Texto a cifrar (solo mayusculas): ");
  n = getline(&buffer, &bufsize, stdin);
  buffer[n - 1] = '\0';
  printf("Usted digito: %s\nEn total %d caracteres \n", buffer, n);
  strcpy(cipher, buffer);
  printf("Ingresar el corrimiento: ");
  scanf("%d", &shift);
  cesar_cifrado(cipher, shift);
  cesar_descifrado(cipher, shift);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x100,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
shl    $0x0,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d9 <main+0x49>
lea    0xe36(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <getline@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe41(%rip),%rdi
lea    -0x64(%rbp),%rsi
call   1070 <scanf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   10b0 <cesar_cifrado@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
call   1040 <cesar_descifrado@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
movq   $0x100,0x18(%rsp)
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     124d <main+0xbd>
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1090 <getline@plt>
mov    0x10(%rsp),%rcx
movb   $0x0,-0x1(%rax,%rcx,1)
mov    0x10(%rsp),%rsi
lea    0xe54(%rip),%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe67(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   10b0 <cesar_cifrado@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1040 <cesar_descifrado@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret
lea    0xdac(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"ERROR: no se puede asignar memoria\00"
@.str.1 = [35 x i8] c"Texto a cifrar (solo mayusculas): \00"
@stdin = global i32 0
@.str.2 = [42 x i8] c"Usted digito: %s\0AEn total %d caracteres \0A\00"
@.str.3 = [26 x i8] c"Ingresar el corrimiento: \00"
@.str.4 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca [50 x i8]
%6 = alloca i32
store i32 0, i32* %1
store i64 256, i64* %3
%7 = load i64, i64* %3
%8 = mul i64 %7, 1
%9 = call i64 @malloc(i64 %8)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %2
%11 = load i8*, i8** %2
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @stdin
%19 = call i64 @getline(i8** %2, i64* %3, i32 %18)
store i64 %19, i64* %4
%20 = load i8*, i8** %2
%21 = load i64, i64* %4
%22 = sub i64 %21, 1
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 0, i8* %23
%24 = load i8*, i8** %2
%25 = load i64, i64* %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %24, i64 %25)
%27 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%28 = load i8*, i8** %2
%29 = call i32 @strcpy(i8* %27, i8* %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%33 = load i32, i32* %6
%34 = call i32 @cesar_cifrado(i8* %32, i32 %33)
%35 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%36 = load i32, i32* %6
%37 = call i32 @cesar_descifrado(i8* %35, i32 %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"ERROR: no se puede asignar memoria\00"
@.str.1 = [35 x i8] c"Texto a cifrar (solo mayusculas): \00"
@stdin = global i32 0
@.str.2 = [42 x i8] c"Usted digito: %s\0AEn total %d caracteres \0A\00"
@.str.3 = [26 x i8] c"Ingresar el corrimiento: \00"
@.str.4 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca [50 x i8]
%4 = alloca i32
%5 = bitcast i8** %1 to i8*
%6 = bitcast i64* %2 to i8*
store i64 256, i64* %2
%7 = tail call i64 @malloc(i64 256)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %1
%9 = icmp eq i64 %7, 0
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = tail call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %0
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%15 = bitcast i32* %4 to i8*
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @stdin
%18 = call i64 @getline(i8** %1, i64* %2, i32 %17)
%19 = load i8*, i8** %1
%20 = add i64 %18, -1
%21 = getelementptr inbounds i8, i8* %19, i64 %20
store i8 0, i8* %21
%22 = load i8*, i8** %1
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %22, i64 %18)
%24 = load i8*, i8** %1
%25 = call i32 @strcpy(i8* %14, i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%28 = load i32, i32* %4
%29 = call i32 @cesar_cifrado(i8* %14, i32 %28)
%30 = load i32, i32* %4
%31 = call i32 @cesar_descifrado(i8* %14, i32 %30)
ret i32 0
}