#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ dekrypt(char *, int);
int /*<<< orphan*/ getInput(char *, int);
int /*<<< orphan*/ krypt(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sscanf(char *, char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int main(int argc, const char *argv[]) {
  int move;
  char str[4096];
  char buf[4096];
  printf(
      "please use the following commands: \ninput [string]\ncode [number]\n");
  do {
    printf("$ ");
    getInput(buf, sizeof(buf));
    if (!strncmp("input ", buf, 6)) {
      sscanf(buf + 6, "%s", str);
    } else if (!strncmp("code ", buf, 5)) {
      sscanf(buf + 5, "%d", &move);
      if (move > 0) {
        krypt(str, move);
      } else {
        dekrypt(str, -move);
      }
      puts(str);
    }
  } while (strcmp(buf, "quit\n"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
lea    0xe96(%rip),%rdi
call   1050 <printf@plt>
lea    -0x2020(%rbp),%rdi
mov    $0x1000,%esi
call   1060 <getInput@plt>
lea    -0x2020(%rbp),%rsi
lea    0xe75(%rip),%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1208 <main+0x88>
lea    -0x2020(%rbp),%rdi
add    $0x6,%rdi
lea    -0x1020(%rbp),%rdx
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1090 <sscanf@plt>
jmp    1286 <main+0x106>
lea    -0x2020(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1281 <main+0x101>
lea    -0x2020(%rbp),%rdi
add    $0x5,%rdi
lea    0xe1a(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1090 <sscanf@plt>
cmpl   $0x0,-0x14(%rbp)
jle    1264 <main+0xe4>
lea    -0x1020(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <krypt@plt>
jmp    1275 <main+0xf5>
lea    -0x1020(%rbp),%rdi
xor    %esi,%esi
sub    -0x14(%rbp),%esi
call   1080 <dekrypt@plt>
lea    -0x1020(%rbp),%rdi
call   1040 <puts@plt>
jmp    1286 <main+0x106>
jmp    128b <main+0x10b>
lea    -0x2020(%rbp),%rdi
lea    0xdbf(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11a5 <main+0x25>
xor    %eax,%eax
add    $0x2020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2018,%rsp
lea    0xe84(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5c(%rip),%r12
lea    0x10(%rsp),%rbx
lea    0xe53(%rip),%r13
lea    0x1010(%rsp),%r14
lea    0xe57(%rip),%r15
lea    0xe47(%rip),%rbp
jmp    11f6 <main+0x76>
nopl   0x0(%rax,%rax,1)
lea    0x16(%rsp),%rdi
lea    0xe2e(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1274 <main+0xf4>
mov    %r12,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1060 <getInput@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11d0 <main+0x50>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    11e6 <main+0x66>
lea    0x15(%rsp),%rdi
lea    0xdd4(%rip),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    125d <main+0xdd>
mov    %r14,%rdi
call   10a0 <krypt@plt>
jmp    1267 <main+0xe7>
neg    %esi
mov    %r14,%rdi
call   1080 <dekrypt@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
jmp    11e6 <main+0x66>
xor    %eax,%eax
add    $0x2018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [66 x i8] c"please use the following commands: \0Ainput [string]\0Acode [number]\0A\00"
@.str.1 = [3 x i8] c"$ \00"
@.str.2 = [7 x i8] c"input \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [6 x i8] c"code \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [6 x i8] c"quit\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [4096 x i8]
%8 = alloca [4096 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %46, %2
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%13 = call i32 @getInput(i8* %12, i32 4096)
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%15 = call i32 @strncmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32 6)
%16 = icmp ne i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %10
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%19 = getelementptr inbounds i8, i8* %18, i64 6
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%21 = call i32 (i8*, i8*, ...) @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %20)
br label %45
22: ; preds = %10
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%24 = call i32 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %23, i32 5)
%25 = icmp ne i32 %24, 0
br i1 %25, label %44, label %26
26: ; preds = %22
%27 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%28 = getelementptr inbounds i8, i8* %27, i64 5
%29 = call i32 (i8*, i8*, ...) @sscanf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %6)
%30 = load i32, i32* %6
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%34 = load i32, i32* %6
%35 = call i32 @krypt(i8* %33, i32 %34)
br label %41
36: ; preds = %26
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%38 = load i32, i32* %6
%39 = sub nsw i32 0, %38
%40 = call i32 @dekrypt(i8* %37, i32 %39)
br label %41
41: ; preds = %36, %32
%42 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%43 = call i32 @puts(i8* %42)
br label %44
44: ; preds = %41, %22
br label %45
45: ; preds = %44, %17
br label %46
46: ; preds = %45
%47 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%49 = icmp ne i64 %48, 0
br i1 %49, label %10, label %50
50: ; preds = %46
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"$ \00"
@.str.2 = [7 x i8] c"input \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [6 x i8] c"code \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [6 x i8] c"quit\0A\00"
@str = [65 x i8] c"please use the following commands: \0Ainput [string]\0Acode [number]\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [4096 x i8]
%5 = alloca [4096 x i8]
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 5
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 6
br label %12
12: ; preds = %33, %2
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @getInput(i8* %8, i32 4096)
%15 = call i32 @strncmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %8, i32 6)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 (i8*, i8*, ...) @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %7)
br label %33
19: ; preds = %12
%20 = call i32 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %8, i32 5)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %33
22: ; preds = %19
%23 = call i32 (i8*, i8*, ...) @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%24 = load i32, i32* %3
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @krypt(i8* %7, i32 %24)
br label %31
28: ; preds = %22
%29 = sub nsw i32 0, %24
%30 = call i32 @dekrypt(i8* %7, i32 %29)
br label %31
31: ; preds = %28, %26
%32 = call i32 @puts(i8* %7)
br label %33
33: ; preds = %17, %31, %19
%34 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %12
36: ; preds = %33
ret i32 0
}