#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 caesardec(char *, char *, char);
int caesarenc(char *, char *, char);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdin;
int main() {
  char *CC;
  char *VV;
  char Zero[256];
  char key;
  int i, j;
  printf("Masukkan string yang akan di enkripsi : ");
  fgets(Zero, 256, stdin);
  printf("Masukkan char key pergeseran : ");
  scanf("%c", &key);
  i = 0;
  while (Zero[i] != '\0' && Zero[i] != '\n') {
    i++;
  }
  CC = malloc(sizeof(char) * i);
  VV = malloc(sizeof(char) * i);
  printf("String hasil enkripsi : ");
  j = caesarenc(Zero, CC, key);
  i = 0;
  while (CC[i] != '\0' && Zero[i] != '\n') {
    printf("%c", CC[i]);
    i++;
  }
  printf("\n");
  printf("String hasil dekripsi dari enkripsi diatas : ");
  j = caesardec(CC, VV, key);
  i = 0;
  while (VV[i] != '\0') {
    printf("%c", VV[i]);
    i++;
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    0x2e5a(%rip),%rax
mov    (%rax),%edx
mov    $0x100,%esi
call   1060 <fgets@plt>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x121(%rbp),%rsi
call   1080 <scanf@plt>
movl   $0x0,-0x128(%rbp)
movslq -0x128(%rbp),%rax
movsbl -0x120(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x12d(%rbp)
je     1200 <main+0xa0>
movslq -0x128(%rbp),%rax
movsbl -0x120(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
setne  %al
mov    %al,-0x12d(%rbp)
mov    -0x12d(%rbp),%al
test   $0x1,%al
jne    1213 <main+0xb3>
jmp    1227 <main+0xc7>
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    11c5 <main+0x65>
movslq -0x128(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
movslq -0x128(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsbl -0x121(%rbp),%edx
call   1050 <caesarenc@plt>
mov    %eax,-0x12c(%rbp)
movl   $0x0,-0x128(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x128(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x12e(%rbp)
je     12c3 <main+0x163>
movslq -0x128(%rbp),%rax
movsbl -0x120(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
setne  %al
mov    %al,-0x12e(%rbp)
mov    -0x12e(%rbp),%al
test   $0x1,%al
jne    12d6 <main+0x176>
jmp    1307 <main+0x1a7>
mov    -0x10(%rbp),%rax
movslq -0x128(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    1288 <main+0x128>
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsbl -0x121(%rbp),%edx
call   1030 <caesardec@plt>
mov    %eax,-0x12c(%rbp)
movl   $0x0,-0x128(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x128(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1390 <main+0x230>
mov    -0x18(%rbp),%rax
movslq -0x128(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xcd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    1347 <main+0x1e7>
lea    0xcce(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
lea    0xe7d(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
mov    $0x100,%esi
call   1070 <fgets@plt>
lea    0xe7e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe90(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1090 <scanf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x10(%rsp,%rbx,1),%eax
test   %al,%al
je     11e3 <main+0x73>
cmp    $0xa,%al
je     11e3 <main+0x73>
add    $0x1,%rbx
jmp    11d0 <main+0x60>
mov    %ebx,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0xf(%rsp),%edx
lea    0x10(%rsp),%rdi
mov    %r14,%rsi
call   1060 <caesarenc@plt>
mov    (%r14),%al
test   %al,%al
je     123d <main+0xcd>
xor    %ebx,%ebx
cmpb   $0xa,0x10(%rsp,%rbx,1)
je     123d <main+0xcd>
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x1(%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1220 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe17(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0xf(%rsp),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <caesardec@plt>
mov    (%r15),%al
test   %al,%al
je     1284 <main+0x114>
add    $0x1,%r15
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%r15),%eax
add    $0x1,%r15
test   %al,%al
jne    1270 <main+0x100>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Masukkan string yang akan di enkripsi : \00"
@stdin = global i32 0
@.str.1 = [32 x i8] c"Masukkan char key pergeseran : \00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [25 x i8] c"String hasil enkripsi : \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [46 x i8] c"String hasil dekripsi dari enkripsi diatas : \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [256 x i8]
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 256, i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
store i32 0, i32* %6
br label %14
14: ; preds = %30, %0
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %14
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 10
br label %28
28: ; preds = %21, %14
%29 = phi i1 [ false, %14 ], [ %27, %21 ]
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %14
33: ; preds = %28
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = mul i64 1, %35
%37 = trunc i64 %36 to i32
%38 = call i8* @malloc(i32 %37)
store i8* %38, i8** %2
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = mul i64 1, %40
%42 = trunc i64 %41 to i32
%43 = call i8* @malloc(i32 %42)
store i8* %43, i8** %3
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%46 = load i8*, i8** %2
%47 = load i8, i8* %5
%48 = call i32 @caesarenc(i8* %45, i8* %46, i8 signext %47)
store i32 %48, i32* %7
store i32 0, i32* %6
br label %49
49: ; preds = %66, %33
%50 = load i8*, i8** %2
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %64
57: ; preds = %49
%58 = load i32, i32* %6
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp ne i32 %62, 10
br label %64
64: ; preds = %57, %49
%65 = phi i1 [ false, %49 ], [ %63, %57 ]
br i1 %65, label %66, label %76
66: ; preds = %64
%67 = load i8*, i8** %2
%68 = load i32, i32* %6
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %72)
%74 = load i32, i32* %6
%75 = add nsw i32 %74, 1
store i32 %75, i32* %6
br label %49
76: ; preds = %64
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0))
%79 = load i8*, i8** %2
%80 = load i8*, i8** %3
%81 = load i8, i8* %5
%82 = call i32 @caesardec(i8* %79, i8* %80, i8 signext %81)
store i32 %82, i32* %7
store i32 0, i32* %6
br label %83
83: ; preds = %91, %76
%84 = load i8*, i8** %3
%85 = load i32, i32* %6
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %84, i64 %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %101
91: ; preds = %83
%92 = load i8*, i8** %3
%93 = load i32, i32* %6
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8, i8* %92, i64 %94
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %97)
%99 = load i32, i32* %6
%100 = add nsw i32 %99, 1
store i32 %100, i32* %6
br label %83
101: ; preds = %83
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"Masukkan string yang akan di enkripsi : \00"
@stdin = global i32 0
@.str.1 = [32 x i8] c"Masukkan char key pergeseran : \00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [25 x i8] c"String hasil enkripsi : \00"
@.str.5 = [46 x i8] c"String hasil dekripsi dari enkripsi diatas : \00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca i8
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %3, i32 256, i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %9
9: ; preds = %13, %0
%10 = phi i64 [ %14, %13 ], [ 0, %0 ]
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %13 [
i8 0, label %15
i8 10, label %15
]
13: ; preds = %9
%14 = add nuw i64 %10, 1
br label %9
15: ; preds = %9, %9
%16 = trunc i64 %10 to i32
%17 = call i8* @malloc(i32 %16)
%18 = call i8* @malloc(i32 %16)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%20 = load i8, i8* %2
%21 = call i32 @caesarenc(i8* %3, i8* %17, i8 signext %20)
%22 = load i8, i8* %17
%23 = icmp eq i8 %22, 0
br i1 %23, label %37, label %24
24: ; preds = %15, %30
%25 = phi i64 [ %33, %30 ], [ 0, %15 ]
%26 = phi i8 [ %35, %30 ], [ %22, %15 ]
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %25
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 10
br i1 %29, label %37, label %30
30: ; preds = %24
%31 = sext i8 %26 to i32
%32 = call i32 @putchar(i32 %31)
%33 = add nuw i64 %25, 1
%34 = getelementptr inbounds i8, i8* %17, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %37, label %24
37: ; preds = %24, %30, %15
%38 = call i32 @putchar(i32 10)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0))
%40 = load i8, i8* %2
%41 = call i32 @caesardec(i8* %17, i8* %18, i8 signext %40)
%42 = load i8, i8* %18
%43 = icmp eq i8 %42, 0
br i1 %43, label %53, label %44
44: ; preds = %37, %44
%45 = phi i64 [ %49, %44 ], [ 0, %37 ]
%46 = phi i8 [ %51, %44 ], [ %42, %37 ]
%47 = sext i8 %46 to i32
%48 = call i32 @putchar(i32 %47)
%49 = add nuw i64 %45, 1
%50 = getelementptr inbounds i8, i8* %18, i64 %49
%51 = load i8, i8* %50
%52 = icmp eq i8 %51, 0
br i1 %52, label %53, label %44
53: ; preds = %44, %37
%54 = call i32 @putchar(i32 10)
ret i32 0
}