#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*/ cyclicCipher(char, int);
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int k;
  char c;
  printf("This program encodes a message using a yclic cipher.\n");
  printf("Ener the numeric key: ");
  scanf("%d%*c", &k);
  printf("Enter a message: ");
  while ((c = getchar()) != '\n') {
    static int flag = 1;
    if (flag) {
      printf("Encoded message: ");
      flag = 0;
    }
    putchar(cyclicCipher(c, k));
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
call   1040 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xebe(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11ed <main+0x9d>
cmpl   $0x0,0x2e91(%rip)
je     11d3 <main+0x83>
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,0x2e75(%rip)
mov    -0x15(%rbp),%al
mov    -0x14(%rbp),%esi
movsbl %al,%edi
call   1070 <cyclicCipher@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    119a <main+0x4a>
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed6(%rip),%rdi
call   1040 <puts@plt>
lea    0xe89(%rip),%rdi
call   1050 <printf@plt>
lea    0xe94(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
lea    0xe89(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
jne    11b8 <main+0x58>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %eax,%ebx
lea    0xe6e(%rip),%r14
jmp    11f0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x4(%rsp),%esi
movsbl %bl,%edi
call   1080 <cyclicCipher@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebx
cmp    $0xa,%al
je     11a4 <main+0x44>
cmpb   $0x0,0x2e5d(%rip)
jne    11d0 <main+0x70>
mov    %r14,%rdi
call   1050 <printf@plt>
movb   $0x1,0x2e4c(%rip)
jmp    11d0 <main+0x70>

LLVM IR (-O0):
@.str = [54 x i8] c"This program encodes a message using a yclic cipher.\0A\00"
@.str.1 = [23 x i8] c"Ener the numeric key: \00"
@.str.2 = [6 x i8] c"%d%*c\00"
@.str.3 = [18 x i8] c"Enter a message: \00"
@main.flag = internal global i32 1
@.str.4 = [18 x i8] c"Encoded message: \00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%11 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %21, %2
%13 = call signext i8 (...) @getchar()
store i8 %13, i8* %7
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 10
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i32, i32* @main.flag
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* @main.flag
br label %21
21: ; preds = %19, %16
%22 = load i8, i8* %7
%23 = load i32, i32* %6
%24 = call i32 @cyclicCipher(i8 signext %22, i32 %23)
%25 = call i32 @putchar(i32 %24)
br label %12
26: ; preds = %12
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c"Ener the numeric key: \00"
@.str.2 = [6 x i8] c"%d%*c\00"
@.str.3 = [18 x i8] c"Enter a message: \00"
@main.flag = internal unnamed_addr global i1 false
@.str.4 = [18 x i8] c"Encoded message: \00"
@str = [53 x i8] c"This program encodes a message using a yclic cipher.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%9 = call signext i8 (...) @getchar()
%10 = icmp eq i8 %9, 10
br i1 %10, label %22, label %11
11: ; preds = %2, %16
%12 = phi i8 [ %20, %16 ], [ %9, %2 ]
%13 = load i1, i1* @main.flag
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
store i1 true, i1* @main.flag
br label %16
16: ; preds = %14, %11
%17 = load i32, i32* %3
%18 = call i32 @cyclicCipher(i8 signext %12, i32 %17)
%19 = call i32 @putchar(i32 %18)
%20 = call signext i8 (...) @getchar()
%21 = icmp eq i8 %20, 10
br i1 %21, label %22, label %11
22: ; preds = %16, %2
%23 = call i32 @putchar(i32 10)
ret i32 0
}