#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
void main() {
  char palavra[10];
  int k;
  printf("Informe a palavra: ");
  scanf("%[A-Za-z ]s", palavra);
  printf("Informe a constante K: ");
  scanf("%d", &k);
  for (int i = 0; palavra[i] != '\0'; i++) {
    if (palavra[i] > 65 && palavra[i] < 90) {
      palavra[i] += 32;
    }
    if (palavra[i] == ' ') {
      printf(" ");
    } else if (palavra[i] + k > 122) {
      printf("%c", 96 + (palavra[i] + k - 122));
    } else {
      printf("%c", palavra[i] + k);
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xa(%rbp),%rsi
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
movsbl -0xa(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1246 <main+0x126>
movslq -0x14(%rbp),%rax
movsbl -0xa(%rbp,%rax,1),%eax
cmp    $0x41,%eax
jle    11b5 <main+0x95>
movslq -0x14(%rbp),%rax
movsbl -0xa(%rbp,%rax,1),%eax
cmp    $0x5a,%eax
jge    11b5 <main+0x95>
movslq -0x14(%rbp),%rax
movsbl -0xa(%rbp,%rax,1),%ecx
add    $0x20,%ecx
mov    %cl,-0xa(%rbp,%rax,1)
movslq -0x14(%rbp),%rax
movsbl -0xa(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jne    11da <main+0xba>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x113>
movslq -0x14(%rbp),%rax
movsbl -0xa(%rbp,%rax,1),%eax
add    -0x10(%rbp),%eax
cmp    $0x7a,%eax
jle    1214 <main+0xf4>
movslq -0x14(%rbp),%rax
movsbl -0xa(%rbp,%rax,1),%esi
add    -0x10(%rbp),%esi
sub    $0x7a,%esi
add    $0x60,%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122e <main+0x10e>
movslq -0x14(%rbp),%rax
movsbl -0xa(%rbp,%rax,1),%esi
add    -0x10(%rbp),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x113>
jmp    1238 <main+0x118>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116f <main+0x4f>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
lea    0x6(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x6(%rsp),%al
test   %al,%al
je     11cb <main+0x9b>
lea    0x7(%rsp),%rbx
jmp    11b8 <main+0x88>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x20,%al
mov    %al,-0x1(%rbx)
movsbl %al,%eax
mov    (%rsp),%ecx
lea    (%rcx,%rax,1),%edx
cmp    $0x7b,%edx
lea    -0x1a(%rcx,%rax,1),%edi
cmovl  %edx,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11cb <main+0x9b>
lea    -0x42(%rax),%ecx
cmp    $0x17,%cl
jbe    1190 <main+0x60>
mov    $0x20,%edi
cmp    $0x20,%al
jne    1195 <main+0x65>
jmp    11a8 <main+0x78>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [20 x i8] c"Informe a palavra: \00"
@.str.1 = [12 x i8] c"%[A-Za-z ]s\00"
@.str.2 = [24 x i8] c"Informe a constante K: \00"
@.str.3 = [3 x i8] c"%d\00"
define void @main() {
%1 = alloca [10 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%9 = load i8, i8* %3
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %31, %0
%12 = call i32 @putchar(i32 10)
ret void
13: ; preds = %0, %31
%14 = phi i64 [ %34, %31 ], [ 0, %0 ]
%15 = phi i8 [ %36, %31 ], [ %9, %0 ]
%16 = phi i8* [ %35, %31 ], [ %3, %0 ]
%17 = add i8 %15, -66
%18 = icmp ult i8 %17, 24
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = add nuw nsw i8 %15, 32
store i8 %20, i8* %16
br label %23
21: ; preds = %13
%22 = icmp eq i8 %15, 32
br i1 %22, label %31, label %23
23: ; preds = %19, %21
%24 = phi i8 [ %20, %19 ], [ %15, %21 ]
%25 = sext i8 %24 to i32
%26 = load i32, i32* %2
%27 = add nsw i32 %26, %25
%28 = icmp sgt i32 %27, 122
%29 = add nsw i32 %27, -26
%30 = select i1 %28, i32 %29, i32 %27
br label %31
31: ; preds = %23, %21
%32 = phi i32 [ 32, %21 ], [ %30, %23 ]
%33 = call i32 @putchar(i32 %32)
%34 = add nuw i64 %14, 1
%35 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 0
br i1 %37, label %11, label %13
}