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

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ EXIT_FAILURE;
int atoi(char *);
int /*<<< orphan*/ check_pharse(int, char **);
int /*<<< orphan*/ decrypt(char *, char *, int, int);
int /*<<< orphan*/ encrypt(char *, char *, int, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  check_pharse(argc, argv);
  int key, count;
  FILE *file;
  char *path;
  char raw[BUFSIZ];
  char result[sizeof(raw)];
  if (argv[2][1] == 'o') {
    path = argv[3];
  } else {
    printf("input the output file name.\n");
    return 0;
  }
  key = atoi(argv[5]);
  if (key < 1 || 25 < key) {
    printf("1 <= k <= 25, integer");
    return 0;
  }
  file = fopen(path, "w");
  if (file == NULL) {
    fprintf(stderr, "%s LINE %d: %s\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/time-river/a-collection-of-junior/refs/"
            "heads/master/homework/cryptology/caesar.c",
            40, strerror(errno));
    exit(EXIT_FAILURE);
  }
  while ((count = fread(raw, sizeof(char), sizeof(raw), stdin)) != 0) {
    switch (argv[1][1]) {
    case 'e':
      encrypt(result, raw, count, key);
      break;
    case 'd':
      decrypt(result, raw, count, key);
      break;
    }
    fwrite(result, sizeof(char), count, file);
  }
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10b0 <check_pharse@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x60(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6f,%eax
jne    1249 <main+0x89>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1268 <main+0xa8>
lea    0xdb0(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    13cc <main+0x20c>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     1290 <main+0xd0>
mov    $0x19,%eax
cmp    -0x14(%rbp),%eax
jge    12af <main+0xef>
lea    0xd86(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    13cc <main+0x20c>
mov    -0x28(%rbp),%rdi
lea    0xd79(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1314 <main+0x154>
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x64(%rbp),%edi
mov    %rax,%r8
lea    0xd40(%rip),%rsi
lea    0xd49(%rip),%rdx
mov    $0x28,%ecx
call   1080 <fprintf@plt>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    1319 <main+0x159>
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rax
mov    %eax,%edx
mov    0x2cbe(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
je     13b5 <main+0x1f5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x68(%rbp)
sub    $0x64,%eax
je     1388 <main+0x1c8>
jmp    135f <main+0x19f>
mov    -0x68(%rbp),%eax
sub    $0x65,%eax
jne    139b <main+0x1db>
jmp    1370 <main+0x1b0>
mov    -0x58(%rbp),%rsi
mov    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1070 <encrypt@plt>
jmp    139b <main+0x1db>
mov    -0x58(%rbp),%rsi
mov    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <decrypt@plt>
mov    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   10d0 <fwrite@plt>
jmp    1319 <main+0x159>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
call   10c0 <check_pharse@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r12
mov    %rax,-0x38(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x10(%r15),%rax
cmpb   $0x6f,0x1(%rax)
jne    1240 <main+0x70>
mov    0x28(%r15),%rdi
call   10b0 <atoi@plt>
mov    %rax,-0x30(%rbp)
add    $0xffffffe6,%eax
cmp    $0xffffffe7,%eax
jae    1251 <main+0x81>
lea    0xdca(%rip),%rdi
call   1070 <printf@plt>
jmp    1304 <main+0x134>
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
jmp    1304 <main+0x134>
mov    0x18(%r15),%rdi
lea    0xdba(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1315 <main+0x145>
mov    %rax,%r13
mov    0x2d74(%rip),%rax
mov    (%rax),%ecx
mov    %r12,%rdi
mov    $0x1,%esi
mov    -0x38(%rbp),%rdx
call   1050 <fread@plt>
test   %eax,%eax
je     12fc <main+0x12c>
mov    %eax,%r14d
jmp    12d6 <main+0x106>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
mov    -0x30(%rbp),%rcx
call   1030 <decrypt@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %r13,%rcx
call   10e0 <fwrite@plt>
mov    0x2d2c(%rip),%rax
mov    (%rax),%ecx
mov    %r12,%rdi
mov    $0x1,%esi
mov    -0x38(%rbp),%rdx
call   1050 <fread@plt>
mov    %eax,%r14d
test   %eax,%eax
je     12fc <main+0x12c>
mov    0x8(%r15),%rax
movsbl 0x1(%rax),%eax
cmp    $0x64,%eax
je     1290 <main+0xc0>
cmp    $0x65,%eax
jne    12a2 <main+0xd2>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
mov    -0x30(%rbp),%rcx
call   1080 <encrypt@plt>
jmp    12a2 <main+0xd2>
mov    %r13,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cbc(%rip),%rax
mov    (%rax),%ebx
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xce5(%rip),%rsi
lea    0xcee(%rip),%rdx
mov    %ebx,%edi
mov    $0x28,%ecx
mov    %rax,%r8
call   1090 <fprintf@plt>
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [29 x i8] c"input the output file name.\0A\00"
@.str.1 = [22 x i8] c"1 <= k <= 25, integer\00"
@.str.2 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.3 = [16 x i8] c"%s LINE %d: %s\0A\00"
@.str.4 = [171 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/time-river/a-collection-of-junior/refs/heads/master/homework/cryptology/caesar.c\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @check_pharse(i32 %14, i8** %15)
%17 = load i32, i32* @BUFSIZ
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %10
%20 = alloca i8, i64 %18
store i64 %18, i64* %11
%21 = alloca i8, i64 %18
store i64 %18, i64* %12
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 111
br i1 %28, label %29, label %33
29: ; preds = %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
store i8* %32, i8** %9
br label %35
33: ; preds = %2
%34 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
store i32 1, i32* %13
br label %87
35: ; preds = %29
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 5
%38 = load i8*, i8** %37
%39 = call i32 @atoi(i8* %38)
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = icmp slt i32 %40, 1
br i1 %41, label %45, label %42
42: ; preds = %35
%43 = load i32, i32* %6
%44 = icmp slt i32 25, %43
br i1 %44, label %45, label %47
45: ; preds = %42, %35
%46 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
store i32 1, i32* %13
br label %87
47: ; preds = %42
%48 = load i8*, i8** %9
%49 = call i32* @fopen(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %49, i32** %8
%50 = load i32*, i32** %8
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %59
52: ; preds = %47
%53 = load i32, i32* @stderr
%54 = load i32, i32* @errno
%55 = call i8* @strerror(i32 %54)
%56 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.4, i64 0, i64 0), i32 40, i8* %55)
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %47
br label %60
60: ; preds = %80, %59
%61 = trunc i64 %18 to i32
%62 = load i32, i32* @stdin
%63 = call i32 @fread(i8* %20, i32 1, i32 %61, i32 %62)
store i32 %63, i32* %7
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %84
65: ; preds = %60
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 1
%68 = load i8*, i8** %67
%69 = getelementptr inbounds i8, i8* %68, i64 1
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
switch i32 %71, label %80 [
i32 101, label %72
i32 100, label %76
]
72: ; preds = %65
%73 = load i32, i32* %7
%74 = load i32, i32* %6
%75 = call i32 @encrypt(i8* %21, i8* %20, i32 %73, i32 %74)
br label %80
76: ; preds = %65
%77 = load i32, i32* %7
%78 = load i32, i32* %6
%79 = call i32 @decrypt(i8* %21, i8* %20, i32 %77, i32 %78)
br label %80
80: ; preds = %65, %76, %72
%81 = load i32, i32* %7
%82 = load i32*, i32** %8
%83 = call i32 @fwrite(i8* %21, i32 1, i32 %81, i32* %82)
br label %60
84: ; preds = %60
%85 = load i32*, i32** %8
%86 = call i32 @fclose(i32* %85)
store i32 0, i32* %3
store i32 1, i32* %13
br label %87
87: ; preds = %84, %45, %33
%88 = load i8*, i8** %10
%89 = load i32, i32* %3
ret i32 %89
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str.1 = [22 x i8] c"1 <= k <= 25, integer\00"
@.str.2 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.3 = [16 x i8] c"%s LINE %d: %s\0A\00"
@.str.4 = [171 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/time-river/a-collection-of-junior/refs/heads/master/homework/cryptology/caesar.c\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@stdin = global i32 0
@str = [28 x i8] c"input the output file name.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @check_pharse(i32 %0, i8** %1)
%4 = load i32, i32* @BUFSIZ
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = alloca i8, i64 %5
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 111
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 5
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = add i32 %16, -26
%18 = icmp ult i32 %17, -25
br i1 %18, label %21, label %23
19: ; preds = %2
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %58
21: ; preds = %13
%22 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %58
23: ; preds = %13
%24 = getelementptr inbounds i8*, i8** %1, i64 3
%25 = load i8*, i8** %24
%26 = tail call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %34, label %28
28: ; preds = %23
%29 = load i32, i32* @stdin
%30 = call i32 @fread(i8* %6, i32 1, i32 %4, i32 %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %56, label %32
32: ; preds = %28
%33 = getelementptr inbounds i8*, i8** %1, i64 1
br label %41
34: ; preds = %23
%35 = load i32, i32* @stderr
%36 = load i32, i32* @errno
%37 = tail call i8* @strerror(i32 %36)
%38 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.4, i64 0, i64 0), i32 40, i8* %37)
%39 = load i32, i32* @EXIT_FAILURE
%40 = tail call i32 @exit(i32 %39)
unreachable
41: ; preds = %32, %51
%42 = phi i32 [ %30, %32 ], [ %54, %51 ]
%43 = load i8*, i8** %33
%44 = getelementptr inbounds i8, i8* %43, i64 1
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
switch i32 %46, label %51 [
i32 101, label %47
i32 100, label %49
]
47: ; preds = %41
%48 = call i32 @encrypt(i8* %7, i8* %6, i32 %42, i32 %16)
br label %51
49: ; preds = %41
%50 = call i32 @decrypt(i8* %7, i8* %6, i32 %42, i32 %16)
br label %51
51: ; preds = %41, %49, %47
%52 = call i32 @fwrite(i8* %7, i32 1, i32 %42, i32* %26)
%53 = load i32, i32* @stdin
%54 = call i32 @fread(i8* %6, i32 1, i32 %4, i32 %53)
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %41
56: ; preds = %51, %28
%57 = call i32 @fclose(i32* %26)
br label %58
58: ; preds = %56, %21, %19
ret i32 0
}