#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 EXIT_FAILURE;
int EXIT_SUCCESS;
char getopt(int, char **, char *);
char *optarg;
int optind;
int /*<<< orphan*/ printf(char *);
void *strtol(char *, char **, int);
int parseoptions(int argc, char **argv, char **input_filename,
                 short *rotornumbers, int rpositions[]) {
  char option;
  char *c;
  int i;
  while ((option = getopt(argc, argv, "r:p:")) != -1) {
    switch (option) {
    case 'r':
      *rotornumbers = strtol(optarg, NULL, 8);
      if (*rotornumbers < 0123 || *rotornumbers > 0543) {
        printf("You must specify 3 different rotors between 1"
               "and 5.\n");
        return EXIT_FAILURE;
      }
      break;
    case 'p':
      c = optarg;
      for (i = 0; i < 3; ++i) {
        while (*c != ',' && *c != '\0')
          ++c;
        --c;
        rpositions[i] = strtol(optarg, &c, 10);
        optarg = c + 1;
      }
      break;
    default:
      return EXIT_FAILURE;
      break;
    }
  }
  if (optind >= argc) {
    printf("Expected filename\n");
    return EXIT_FAILURE;
  }
  *input_filename = argv[optind];
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<parseoptions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea7(%rip),%rdx
call   1050 <getopt@plt>
mov    %al,-0x29(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     12cf <parseoptions+0x19f>
movsbl -0x29(%rbp),%eax
mov    %eax,-0x40(%rbp)
sub    $0x70,%eax
je     11f9 <parseoptions+0xc9>
jmp    1182 <parseoptions+0x52>
mov    -0x40(%rbp),%eax
sub    $0x72,%eax
jne    12b9 <parseoptions+0x189>
jmp    1193 <parseoptions+0x63>
mov    0x2e5e(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x8,%edx
call   1040 <strtol@plt>
mov    %ax,%cx
mov    -0x20(%rbp),%rax
mov    %cx,(%rax)
mov    -0x20(%rbp),%rax
movswl (%rax),%eax
cmp    $0x53,%eax
jl     11d7 <parseoptions+0xa7>
mov    -0x20(%rbp),%rax
movswl (%rax),%eax
cmp    $0x163,%eax
jle    11f4 <parseoptions+0xc4>
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1323 <parseoptions+0x1f3>
jmp    12ca <parseoptions+0x19a>
mov    0x2df8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x3c(%rbp)
jge    12b4 <parseoptions+0x184>
jmp    121d <parseoptions+0xed>
mov    -0x38(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2c,%ecx
mov    %al,-0x41(%rbp)
je     1242 <parseoptions+0x112>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1252 <parseoptions+0x122>
jmp    1263 <parseoptions+0x133>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    121d <parseoptions+0xed>
mov    -0x38(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
mov    0x2d82(%rip),%rax
mov    (%rax),%rdi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%edx
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%rcx
add    $0x1,%rcx
mov    0x2d55(%rip),%rax
mov    %rcx,(%rax)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    120e <parseoptions+0xde>
jmp    12ca <parseoptions+0x19a>
mov    0x2d10(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1323 <parseoptions+0x1f3>
jmp    114b <parseoptions+0x1b>
mov    0x2d0a(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     12fe <parseoptions+0x1ce>
lea    0xd52(%rip),%rdi
call   1030 <printf@plt>
mov    0x2cdc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1323 <parseoptions+0x1f3>
mov    -0x10(%rbp),%rax
mov    0x2cd7(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2caa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseoptions>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
mov    %rcx,%r12
mov    %rdx,0x10(%rsp)
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xeab(%rip),%rdx
call   1050 <getopt@plt>
cmp    $0xff,%al
je     12bb <parseoptions+0x18b>
mov    0x2e8f(%rip),%r14
lea    0x8(%rsp),%r13
jmp    11aa <parseoptions+0x7a>
mov    %rax,0x8(%rsp)
mov    %r13,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,0x8(%rbx)
mov    0x8(%rsp),%rax
add    $0x1,%rax
mov    %rax,(%r14)
mov    %ebp,%edi
mov    %r15,%rsi
lea    0xe63(%rip),%rdx
call   1050 <getopt@plt>
cmp    $0xff,%al
je     12bb <parseoptions+0x18b>
movsbl %al,%eax
cmp    $0x70,%eax
je     11f0 <parseoptions+0xc0>
cmp    $0x72,%eax
jne    12f3 <parseoptions+0x1c3>
mov    (%r14),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <strtol@plt>
mov    %ax,(%r12)
add    $0xfffffe9c,%eax
movzwl %ax,%eax
cmp    $0xfeee,%eax
ja     1191 <parseoptions+0x61>
jmp    12e7 <parseoptions+0x1b7>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14),%rdi
lea    -0x1(%rdi),%rax
nopw   0x0(%rax,%rax,1)
movzbl 0x1(%rax),%ecx
test   %cl,%cl
je     1220 <parseoptions+0xf0>
cmp    $0x2c,%cl
je     1220 <parseoptions+0xf0>
add    $0x1,%rax
jmp    1200 <parseoptions+0xd0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,0x8(%rsp)
mov    %r13,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,(%rbx)
mov    0x8(%rsp),%rax
lea    0x1(%rax),%rdi
mov    %rdi,(%r14)
add    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x1(%rax),%ecx
cmp    $0x2c,%cl
je     1270 <parseoptions+0x140>
test   %cl,%cl
je     1270 <parseoptions+0x140>
add    $0x1,%rax
jmp    1250 <parseoptions+0x120>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,0x8(%rsp)
mov    %r13,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,0x4(%rbx)
mov    0x8(%rsp),%rax
lea    0x1(%rax),%rdi
mov    %rdi,(%r14)
add    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x1(%rax),%ecx
cmp    $0x2c,%cl
je     1170 <parseoptions+0x40>
test   %cl,%cl
je     1170 <parseoptions+0x40>
add    $0x1,%rax
jmp    12a0 <parseoptions+0x170>
mov    0x2d1e(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
jge    12de <parseoptions+0x1ae>
mov    (%r15,%rax,8),%rax
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
mov    0x2cec(%rip),%rax
jmp    12fa <parseoptions+0x1ca>
lea    0xd20(%rip),%rdi
jmp    12ee <parseoptions+0x1be>
lea    0xd29(%rip),%rdi
call   1030 <puts@plt>
mov    0x2cd6(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"r:p:\00"
@optarg = global i8* null
@.str.1 = [53 x i8] c"You must specify 3 different rotors between 1and 5.\0A\00"
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@.str.2 = [19 x i8] c"Expected filename\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @parseoptions(i32 %0, i8** %1, i8** %2, i16* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i16*
%11 = alloca i32*
%12 = alloca i8
%13 = alloca i8*
%14 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store i8** %2, i8*** %9
store i16* %3, i16** %10
store i32* %4, i32** %11
br label %15
15: ; preds = %81, %5
%16 = load i32, i32* %7
%17 = load i8**, i8*** %8
%18 = call signext i8 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8 %18, i8* %12
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %82
21: ; preds = %15
%22 = load i8, i8* %12
%23 = sext i8 %22 to i32
switch i32 %23, label %79 [
i32 114, label %24
i32 112, label %42
]
24: ; preds = %21
%25 = load i8*, i8** @optarg
%26 = call i8* @strtol(i8* %25, i8** null, i32 8)
%27 = ptrtoint i8* %26 to i16
%28 = load i16*, i16** %10
store i16 %27, i16* %28
%29 = load i16*, i16** %10
%30 = load i16, i16* %29
%31 = sext i16 %30 to i32
%32 = icmp slt i32 %31, 83
br i1 %32, label %38, label %33
33: ; preds = %24
%34 = load i16*, i16** %10
%35 = load i16, i16* %34
%36 = sext i16 %35 to i32
%37 = icmp sgt i32 %36, 355
br i1 %37, label %38, label %41
38: ; preds = %33, %24
%39 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
store i32 %40, i32* %6
br label %97
41: ; preds = %33
br label %81
42: ; preds = %21
%43 = load i8*, i8** @optarg
store i8* %43, i8** %13
store i32 0, i32* %14
br label %44
44: ; preds = %75, %42
%45 = load i32, i32* %14
%46 = icmp slt i32 %45, 3
br i1 %46, label %47, label %78
47: ; preds = %44
br label %48
48: ; preds = %60, %47
%49 = load i8*, i8** %13
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 44
br i1 %52, label %53, label %58
53: ; preds = %48
%54 = load i8*, i8** %13
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp ne i32 %56, 0
br label %58
58: ; preds = %53, %48
%59 = phi i1 [ false, %48 ], [ %57, %53 ]
br i1 %59, label %60, label %63
60: ; preds = %58
%61 = load i8*, i8** %13
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %13
br label %48
63: ; preds = %58
%64 = load i8*, i8** %13
%65 = getelementptr inbounds i8, i8* %64, i32 -1
store i8* %65, i8** %13
%66 = load i8*, i8** @optarg
%67 = call i8* @strtol(i8* %66, i8** %13, i32 10)
%68 = ptrtoint i8* %67 to i32
%69 = load i32*, i32** %11
%70 = load i32, i32* %14
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i32, i32* %69, i64 %71
store i32 %68, i32* %72
%73 = load i8*, i8** %13
%74 = getelementptr inbounds i8, i8* %73, i64 1
store i8* %74, i8** @optarg
br label %75
75: ; preds = %63
%76 = load i32, i32* %14
%77 = add nsw i32 %76, 1
store i32 %77, i32* %14
br label %44
78: ; preds = %44
br label %81
79: ; preds = %21
%80 = load i32, i32* @EXIT_FAILURE
store i32 %80, i32* %6
br label %97
81: ; preds = %78, %41
br label %15
82: ; preds = %15
%83 = load i32, i32* @optind
%84 = load i32, i32* %7
%85 = icmp sge i32 %83, %84
br i1 %85, label %86, label %89
86: ; preds = %82
%87 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%88 = load i32, i32* @EXIT_FAILURE
store i32 %88, i32* %6
br label %97
89: ; preds = %82
%90 = load i8**, i8*** %8
%91 = load i32, i32* @optind
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8*, i8** %90, i64 %92
%94 = load i8*, i8** %93
%95 = load i8**, i8*** %9
store i8* %94, i8** %95
%96 = load i32, i32* @EXIT_SUCCESS
store i32 %96, i32* %6
br label %97
97: ; preds = %89, %86, %79, %38
%98 = load i32, i32* %6
ret i32 %98
}

LLVM IR (-O2):
@.str = [5 x i8] c"r:p:\00"
@optarg = global i8* null
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [18 x i8] c"Expected filename\00"
@str.3 = [52 x i8] c"You must specify 3 different rotors between 1and 5.\00"
define i32 @parseoptions(i32 %0, i8** %1, i8** nocapture writeonly %2, i16* nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = alloca i8*
%7 = bitcast i8** %6 to i8*
%8 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i8 %8, -1
br i1 %9, label %66, label %10
10: ; preds = %5
%11 = getelementptr inbounds i32, i32* %4, i64 1
%12 = getelementptr inbounds i32, i32* %4, i64 2
br label %13
13: ; preds = %10, %63
%14 = phi i8 [ %64, %63 ], [ %8, %10 ]
%15 = sext i8 %14 to i32
switch i32 %15, label %75 [
i32 114, label %16
i32 112, label %25
]
16: ; preds = %13
%17 = load i8*, i8** @optarg
%18 = tail call i8* @strtol(i8* nocapture %17, i8** null, i32 8)
%19 = ptrtoint i8* %18 to i64
%20 = trunc i64 %19 to i16
store i16 %20, i16* %3
%21 = add i16 %20, -356
%22 = icmp ult i16 %21, -273
br i1 %22, label %23, label %63
23: ; preds = %16
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.3, i64 0, i64 0))
br label %75
25: ; preds = %13
%26 = load i8*, i8** @optarg
br label %27
27: ; preds = %25, %30
%28 = phi i8* [ %26, %25 ], [ %31, %30 ]
%29 = load i8, i8* %28
switch i8 %29, label %30 [
i8 44, label %32
i8 0, label %32
]
30: ; preds = %27
%31 = getelementptr inbounds i8, i8* %28, i64 1
br label %27
32: ; preds = %27, %27
%33 = getelementptr inbounds i8, i8* %28, i64 -1
store i8* %33, i8** %6
%34 = call i8* @strtol(i8* %26, i8** %6, i32 10)
%35 = ptrtoint i8* %34 to i64
%36 = trunc i64 %35 to i32
store i32 %36, i32* %4
%37 = load i8*, i8** %6
%38 = getelementptr inbounds i8, i8* %37, i64 1
store i8* %38, i8** @optarg
br label %39
39: ; preds = %49, %32
%40 = phi i8* [ %37, %32 ], [ %50, %49 ]
%41 = load i8, i8* %40
switch i8 %41, label %49 [
i8 44, label %42
i8 0, label %42
]
42: ; preds = %39, %39
%43 = getelementptr inbounds i8, i8* %40, i64 -1
store i8* %43, i8** %6
%44 = call i8* @strtol(i8* %38, i8** %6, i32 10)
%45 = ptrtoint i8* %44 to i64
%46 = trunc i64 %45 to i32
store i32 %46, i32* %11
%47 = load i8*, i8** %6
%48 = getelementptr inbounds i8, i8* %47, i64 1
store i8* %48, i8** @optarg
br label %51
49: ; preds = %39
%50 = getelementptr inbounds i8, i8* %40, i64 1
br label %39
51: ; preds = %61, %42
%52 = phi i8* [ %47, %42 ], [ %62, %61 ]
%53 = load i8, i8* %52
switch i8 %53, label %61 [
i8 44, label %54
i8 0, label %54
]
54: ; preds = %51, %51
%55 = getelementptr inbounds i8, i8* %52, i64 -1
store i8* %55, i8** %6
%56 = call i8* @strtol(i8* %48, i8** %6, i32 10)
%57 = ptrtoint i8* %56 to i64
%58 = trunc i64 %57 to i32
store i32 %58, i32* %12
%59 = load i8*, i8** %6
%60 = getelementptr inbounds i8, i8* %59, i64 1
store i8* %60, i8** @optarg
br label %63
61: ; preds = %51
%62 = getelementptr inbounds i8, i8* %52, i64 1
br label %51
63: ; preds = %54, %16
%64 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%65 = icmp eq i8 %64, -1
br i1 %65, label %66, label %13
66: ; preds = %63, %5
%67 = load i32, i32* @optind
%68 = icmp slt i32 %67, %0
br i1 %68, label %71, label %69
69: ; preds = %66
%70 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %75
71: ; preds = %66
%72 = sext i32 %67 to i64
%73 = getelementptr inbounds i8*, i8** %1, i64 %72
%74 = load i8*, i8** %73
store i8* %74, i8** %2
br label %75
75: ; preds = %13, %71, %69, %23
%76 = phi i32* [ @EXIT_FAILURE, %23 ], [ @EXIT_FAILURE, %69 ], [ @EXIT_SUCCESS, %71 ], [ @EXIT_FAILURE, %13 ]
%77 = load i32, i32* %76
ret i32 %77
}