#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*/ EXIT_SUCCESS;
int abs(int /*<<< orphan*/);
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ input(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char frase[50], keyword[5], ch;
  int key, c = 0;
  printf("Digite a frase: ");
  input(frase);
  printf("Digite a chave numerica: ");
  input(keyword);
  key = abs(atoi(keyword));
  while (key > 25)
    key -= 26;
  do {
    ch = frase[c];
    if ((ch > 64 && ch < 91) || (ch > 96 && ch < 123)) {
      ch += key;
      if ((ch > 90 && ch < 97) || ch > 122)
        ch -= 26;
      frase[c] = ch;
    }
    c++;
  } while (ch != 0);
  printf(">>> %s\n", frase);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x50(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1030 <input@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x45(%rbp),%rdi
call   1030 <input@plt>
lea    -0x45(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1040 <abs@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x19,-0x4c(%rbp)
jle    11bf <main+0x6f>
mov    -0x4c(%rbp),%eax
sub    $0x1a,%eax
mov    %eax,-0x4c(%rbp)
jmp    11a7 <main+0x57>
jmp    11c4 <main+0x74>
movslq -0x50(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%al
mov    %al,-0x46(%rbp)
movsbl -0x46(%rbp),%eax
cmp    $0x40,%eax
jle    11e9 <main+0x99>
movsbl -0x46(%rbp),%eax
cmp    $0x5b,%eax
jl     1203 <main+0xb3>
movsbl -0x46(%rbp),%eax
cmp    $0x60,%eax
jle    124b <main+0xfb>
movsbl -0x46(%rbp),%eax
cmp    $0x7b,%eax
jge    124b <main+0xfb>
mov    -0x4c(%rbp),%ecx
movsbl -0x46(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x46(%rbp)
movsbl -0x46(%rbp),%eax
cmp    $0x5a,%eax
jle    1229 <main+0xd9>
movsbl -0x46(%rbp),%eax
cmp    $0x61,%eax
jl     1236 <main+0xe6>
movsbl -0x46(%rbp),%eax
cmp    $0x7a,%eax
jle    1240 <main+0xf0>
movsbl -0x46(%rbp),%eax
sub    $0x1a,%eax
mov    %al,-0x46(%rbp)
mov    -0x46(%rbp),%cl
movslq -0x50(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
movsbl -0x46(%rbp),%eax
cmp    $0x0,%eax
jne    11c4 <main+0x74>
lea    -0x40(%rbp),%rsi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
lea    0xeb1(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <input@plt>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xb(%rsp),%r14
mov    %r14,%rdi
call   1030 <input@plt>
mov    %r14,%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
mov    %ecx,%edx
sub    $0x19,%edx
cmovb  %ebp,%edx
add    $0x19,%edx
imul   $0x4ec4ec4f,%rdx,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%esi
lea    (%rsi,%rsi,4),%esi
add    %eax,%esi
mov    %edx,%eax
sub    %esi,%eax
sub    %edx,%eax
add    %ecx,%eax
movabs $0x1f0000003f,%rdi
jmp    11da <main+0x9a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %dl,(%rbx)
add    $0x1,%rbx
test   %dl,%dl
je     1204 <main+0xc4>
movzbl (%rbx),%edx
mov    %edx,%ecx
and    $0xdf,%cl
add    $0xbf,%cl
cmp    $0x19,%cl
ja     11d2 <main+0x92>
add    %al,%dl
lea    -0x5b(%rdx),%esi
cmp    $0x24,%sil
ja     11d0 <main+0x90>
movzbl %sil,%ecx
bt     %rcx,%rdi
jae    11d0 <main+0x90>
add    $0xe6,%dl
jmp    11d0 <main+0x90>
lea    0xe20(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"Digite a frase: \00"
@.str.1 = [26 x i8] c"Digite a chave numerica: \00"
@.str.2 = [8 x i8] c">>> %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [5 x i8]
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%9 = call i32 @input(i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%12 = call i32 @input(i8* %11)
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%14 = call i32 @atoi(i8* %13)
%15 = call i32 @abs(i32 %14)
store i32 %15, i32* %5
br label %16
16: ; preds = %19, %0
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 25
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %5
%21 = sub nsw i32 %20, 26
store i32 %21, i32* %5
br label %16
22: ; preds = %16
br label %23
23: ; preds = %73, %22
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
store i8 %27, i8* %4
%28 = load i8, i8* %4
%29 = sext i8 %28 to i32
%30 = icmp sgt i32 %29, 64
br i1 %30, label %31, label %35
31: ; preds = %23
%32 = load i8, i8* %4
%33 = sext i8 %32 to i32
%34 = icmp slt i32 %33, 91
br i1 %34, label %43, label %35
35: ; preds = %31, %23
%36 = load i8, i8* %4
%37 = sext i8 %36 to i32
%38 = icmp sgt i32 %37, 96
br i1 %38, label %39, label %70
39: ; preds = %35
%40 = load i8, i8* %4
%41 = sext i8 %40 to i32
%42 = icmp slt i32 %41, 123
br i1 %42, label %43, label %70
43: ; preds = %39, %31
%44 = load i32, i32* %5
%45 = load i8, i8* %4
%46 = sext i8 %45 to i32
%47 = add nsw i32 %46, %44
%48 = trunc i32 %47 to i8
store i8 %48, i8* %4
%49 = load i8, i8* %4
%50 = sext i8 %49 to i32
%51 = icmp sgt i32 %50, 90
br i1 %51, label %52, label %56
52: ; preds = %43
%53 = load i8, i8* %4
%54 = sext i8 %53 to i32
%55 = icmp slt i32 %54, 97
br i1 %55, label %60, label %56
56: ; preds = %52, %43
%57 = load i8, i8* %4
%58 = sext i8 %57 to i32
%59 = icmp sgt i32 %58, 122
br i1 %59, label %60, label %65
60: ; preds = %56, %52
%61 = load i8, i8* %4
%62 = sext i8 %61 to i32
%63 = sub nsw i32 %62, 26
%64 = trunc i32 %63 to i8
store i8 %64, i8* %4
br label %65
65: ; preds = %60, %56
%66 = load i8, i8* %4
%67 = load i32, i32* %6
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %68
store i8 %66, i8* %69
br label %70
70: ; preds = %65, %39, %35
%71 = load i32, i32* %6
%72 = add nsw i32 %71, 1
store i32 %72, i32* %6
br label %73
73: ; preds = %70
%74 = load i8, i8* %4
%75 = sext i8 %74 to i32
%76 = icmp ne i32 %75, 0
br i1 %76, label %23, label %77
77: ; preds = %73
%78 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %78)
%80 = load i32, i32* @EXIT_SUCCESS
%81 = call i32 @exit(i32 %80)
unreachable
}

LLVM IR (-O2):
@.str = [17 x i8] c"Digite a frase: \00"
@.str.1 = [26 x i8] c"Digite a chave numerica: \00"
@.str.2 = [8 x i8] c">>> %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @input(i8* %3)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @input(i8* %4)
%9 = call i32 @atoi(i8* %4)
%10 = call i32 @llvm.abs.i32(i32 %9, i1 true)
%11 = add nuw i32 %10, 25
%12 = call i32 @llvm.umin.i32(i32 %10, i32 25)
%13 = sub nuw i32 %11, %12
%14 = urem i32 %13, 26
%15 = sub i32 %14, %13
%16 = add i32 %15, %10
%17 = trunc i32 %16 to i8
br label %18
18: ; preds = %0, %31
%19 = phi i64 [ 0, %0 ], [ %33, %31 ]
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = and i8 %21, -33
%23 = add i8 %22, -65
%24 = icmp ult i8 %23, 26
br i1 %24, label %25, label %31
25: ; preds = %18
%26 = add i8 %21, %17
switch i8 %26, label %29 [
i8 127, label %27
i8 126, label %27
i8 125, label %27
i8 124, label %27
i8 123, label %27
i8 96, label %27
i8 95, label %27
i8 94, label %27
i8 93, label %27
i8 92, label %27
i8 91, label %27
]
27: ; preds = %25, %25, %25, %25, %25, %25, %25, %25, %25, %25, %25
%28 = add nsw i8 %26, -26
br label %29
29: ; preds = %25, %27
%30 = phi i8 [ %28, %27 ], [ %26, %25 ]
store i8 %30, i8* %20
br label %31
31: ; preds = %18, %29
%32 = phi i8 [ %30, %29 ], [ %21, %18 ]
%33 = add nuw i64 %19, 1
%34 = icmp eq i8 %32, 0
br i1 %34, label %35, label %18
35: ; preds = %31
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%37 = load i32, i32* @EXIT_SUCCESS
%38 = call i32 @exit(i32 %37)
unreachable
}