#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*/ FILE;

/* Variables and functions */
scalar_t__ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ cryptstream(int /*<<< orphan*/ *, short, int *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ parseoptions(int, char **, char **, short *, int *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printusage(char *);
int main(int argc, char *argv[]) {
  short rotornumbers = 0123;
  int rpositions[3] = {0};
  char *input_filename;
  FILE *fd;
  if (parseoptions(argc, argv, &input_filename, &rotornumbers, rpositions) ==
      EXIT_FAILURE) {
    printusage(argv[0]);
    return EXIT_FAILURE;
  }
  if ((fd = fopen(input_filename, "r")) == NULL) {
    perror("fopen:");
    return EXIT_FAILURE;
  }
  cryptstream(fd, rotornumbers, rpositions);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movw   $0x53,-0x12(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%r8
lea    -0x28(%rbp),%rdx
lea    -0x12(%rbp),%rcx
call   1070 <parseoptions@plt>
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%rax
jne    11d2 <main+0x72>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <printusage@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    122e <main+0xce>
mov    -0x28(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    120e <main+0xae>
lea    0xe0b(%rip),%rdi
call   1060 <perror@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    122e <main+0xce>
mov    -0x30(%rbp),%rdi
mov    -0x12(%rbp),%ax
lea    -0x20(%rbp),%rdx
movswl %ax,%esi
call   1080 <cryptstream@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
movw   $0x53,0xe(%rsp)
movl   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x20(%rsp),%rdx
lea    0xe(%rsp),%rcx
lea    0x10(%rsp),%r8
call   1060 <parseoptions@plt>
mov    0x2e53(%rip),%r14
cmp    (%r14),%rax
jne    119f <main+0x4f>
mov    (%rbx),%rdi
call   1030 <printusage@plt>
mov    (%r14),%eax
jmp    11d0 <main+0x80>
mov    0x20(%rsp),%rdi
lea    0xe55(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     11d8 <main+0x88>
movswl 0xe(%rsp),%esi
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
call   1070 <cryptstream@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe23(%rip),%rdi
call   1050 <perror@plt>
mov    (%r14),%eax
jmp    11d0 <main+0x80>

LLVM IR (-O0):
@EXIT_FAILURE = global i64 0
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"fopen:\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i16
%7 = alloca [3 x i32]
%8 = alloca i8*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i16 83, i16* %6
%10 = bitcast [3 x i32]* %7 to i8*
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%14 = call i64 @parseoptions(i32 %11, i8** %12, i8** %8, i16* %6, i32* %13)
%15 = load i64, i64* @EXIT_FAILURE
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %24
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @printusage(i8* %20)
%22 = load i64, i64* @EXIT_FAILURE
%23 = trunc i64 %22 to i32
store i32 %23, i32* %3
br label %38
24: ; preds = %2
%25 = load i8*, i8** %8
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %26, i32** %9
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%30 = load i64, i64* @EXIT_FAILURE
%31 = trunc i64 %30 to i32
store i32 %31, i32* %3
br label %38
32: ; preds = %24
%33 = load i32*, i32** %9
%34 = load i16, i16* %6
%35 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%36 = call i32 @cryptstream(i32* %33, i16 signext %34, i32* %35)
%37 = load i32, i32* @EXIT_SUCCESS
store i32 %37, i32* %3
br label %38
38: ; preds = %32, %28, %17
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@EXIT_FAILURE = global i64 0
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"fopen:\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i16
%4 = alloca [3 x i32]
%5 = alloca i8*
%6 = bitcast i16* %3 to i8*
store i16 83, i16* %3
%7 = bitcast [3 x i32]* %4 to i8*
%8 = bitcast i8** %5 to i8*
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%10 = call i64 @parseoptions(i32 %0, i8** %1, i8** %5, i16* %3, i32* %9)
%11 = load i64, i64* @EXIT_FAILURE
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8*, i8** %1
%15 = call i32 @printusage(i8* %14)
%16 = load i64, i64* @EXIT_FAILURE
%17 = trunc i64 %16 to i32
br label %30
18: ; preds = %2
%19 = load i8*, i8** %5
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%24 = load i64, i64* @EXIT_FAILURE
%25 = trunc i64 %24 to i32
br label %30
26: ; preds = %18
%27 = load i16, i16* %3
%28 = call i32 @cryptstream(i32* %20, i16 signext %27, i32* %9)
%29 = load i32, i32* @EXIT_SUCCESS
br label %30
30: ; preds = %26, %22, %13
%31 = phi i32 [ %17, %13 ], [ %25, %22 ], [ %29, %26 ]
ret i32 %31
}