#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 *, char *);
char toupper(char);
int main(void) {
  int counter = 0, i;
  char ch, letter[300];
  printf("Enter the message to be encrypted: ");
  for (i = 0; counter < 300; i++) {
    scanf("%c", &letter[i]);
    if (letter[i] == '\n') {
      break;
    }
    counter++;
    if (letter[i] == ' ') {
      continue;
    }
    letter[i] = toupper(letter[i]);
    if (letter[i] >= 65 && letter[i] <= 91) {
      letter[i] = ((((letter[i] - 65) * 3) + 7) % 26) + 65;
    }
  }
  printf("\nThe encrypted message is: ");
  for (i = 0; i < counter; i++) {
    printf("%c", letter[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x12c,-0x8(%rbp)
jge    124a <main+0x11a>
movslq -0xc(%rbp),%rax
lea    -0x140(%rbp),%rsi
add    %rax,%rsi
lea    0xea4(%rip),%rdi
call   1050 <scanf@plt>
movslq -0xc(%rbp),%rax
movsbl -0x140(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    119f <main+0x6f>
jmp    124a <main+0x11a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movslq -0xc(%rbp),%rax
movsbl -0x140(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    11c2 <main+0x92>
jmp    123c <main+0x10c>
movslq -0xc(%rbp),%rax
movsbl -0x140(%rbp,%rax,1),%edi
ff
call   1030 <toupper@plt>
mov    %al,%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x140(%rbp,%rax,1)
movslq -0xc(%rbp),%rax
movsbl -0x140(%rbp,%rax,1),%eax
ff
cmp    $0x41,%eax
jl     1237 <main+0x107>
movslq -0xc(%rbp),%rax
movsbl -0x140(%rbp,%rax,1),%eax
cmp    $0x5b,%eax
jg     1237 <main+0x107>
movslq -0xc(%rbp),%rax
movsbl -0x140(%rbp,%rax,1),%eax
ff
sub    $0x41,%eax
imul   $0x3,%eax,%eax
add    $0x7,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    %dl,%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x140(%rbp,%rax,1)
jmp    123c <main+0x10c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115e <main+0x2e>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1293 <main+0x163>
movslq -0xc(%rbp),%rax
movsbl -0x140(%rbp,%rax,1),%esi
ff
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    125f <main+0x12f>
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x130,%rsp
lea    0xead(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec0(%rip),%r14
jmp    1179 <main+0x39>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x12c,%r15
je     11cc <main+0x8c>
lea    (%rsp,%r15,1),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movzbl (%rsp,%r15,1),%eax
cmp    $0xa,%al
je     11e2 <main+0xa2>
add    $0x1,%r15
cmp    $0x20,%al
je     1170 <main+0x30>
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %al,(%rbx)
lea    -0x41(%rax),%ecx
cmp    $0x1a,%cl
ja     1170 <main+0x30>
movzbl %al,%eax
lea    (%rax,%rax,2),%eax
add    $0x44,%al
movzbl %al,%eax
imul   $0x4f,%eax,%ecx
shr    $0xb,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %dl,%al
add    $0x41,%al
mov    %al,(%rbx)
jmp    1170 <main+0x30>
lea    0xe54(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x12c,%r15d
jmp    11f5 <main+0xb5>
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15d,%r15d
je     1212 <main+0xd2>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1200 <main+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Enter the message to be encrypted: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [28 x i8] c"\0AThe encrypted message is: \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca [300 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %7
7: ; preds = %70, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 300
br i1 %9, label %10, label %73
10: ; preds = %7
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %12
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %22
21: ; preds = %10
br label %73
22: ; preds = %10
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 32
br i1 %30, label %31, label %32
31: ; preds = %22
br label %70
32: ; preds = %22
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = call signext i8 @toupper(i8 signext %36)
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %39
store i8 %37, i8* %40
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp sge i32 %45, 65
br i1 %46, label %47, label %69
47: ; preds = %32
%48 = load i32, i32* %3
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp sle i32 %52, 91
br i1 %53, label %54, label %69
54: ; preds = %47
%55 = load i32, i32* %3
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = sub nsw i32 %59, 65
%61 = mul nsw i32 %60, 3
%62 = add nsw i32 %61, 7
%63 = srem i32 %62, 26
%64 = add nsw i32 %63, 65
%65 = trunc i32 %64 to i8
%66 = load i32, i32* %3
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %67
store i8 %65, i8* %68
br label %69
69: ; preds = %54, %47, %32
br label %70
70: ; preds = %69, %31
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 1
store i32 %72, i32* %3
br label %7
73: ; preds = %21, %7
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %75
75: ; preds = %86, %73
%76 = load i32, i32* %3
%77 = load i32, i32* %2
%78 = icmp slt i32 %76, %77
br i1 %78, label %79, label %89
79: ; preds = %75
%80 = load i32, i32* %3
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %81
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %84)
br label %86
86: ; preds = %79
%87 = load i32, i32* %3
%88 = add nsw i32 %87, 1
store i32 %88, i32* %3
br label %75
89: ; preds = %75
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"Enter the message to be encrypted: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [28 x i8] c"\0AThe encrypted message is: \00"
define i32 @main() {
%1 = alloca [300 x i8]
%2 = getelementptr inbounds [300 x i8], [300 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %0, %22
%5 = phi i64 [ 0, %0 ], [ %11, %22 ]
%6 = getelementptr inbounds [300 x i8], [300 x i8]* %1, i64 0, i64 %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = load i8, i8* %6
%9 = icmp eq i8 %8, 10
br i1 %9, label %26, label %10
10: ; preds = %4
%11 = add nuw nsw i64 %5, 1
%12 = icmp eq i8 %8, 32
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = call signext i8 @toupper(i8 signext %8)
store i8 %14, i8* %6
%15 = add i8 %14, -65
%16 = icmp ult i8 %15, 27
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = mul i8 %14, 3
%19 = add i8 %18, 68
%20 = urem i8 %19, 26
%21 = add nuw nsw i8 %20, 65
store i8 %21, i8* %6
br label %22
22: ; preds = %13, %17, %10
%23 = icmp eq i64 %11, 300
br i1 %23, label %24, label %4
24: ; preds = %22
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %30
26: ; preds = %4
%27 = trunc i64 %5 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i32 %27, 0
br i1 %29, label %41, label %30
30: ; preds = %24, %26
%31 = phi i64 [ 300, %24 ], [ %5, %26 ]
%32 = and i64 %31, 4294967295
br label %33
33: ; preds = %30, %33
%34 = phi i64 [ 0, %30 ], [ %39, %33 ]
%35 = getelementptr inbounds [300 x i8], [300 x i8]* %1, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = call i32 @putchar(i32 %37)
%39 = add nuw nsw i64 %34, 1
%40 = icmp eq i64 %39, %32
br i1 %40, label %41, label %33
41: ; preds = %33, %26
%42 = call i32 @putchar(i32 10)
ret i32 0
}