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

/* Variables and functions */
int EOF;
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ wep_keygen128(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ wep_keygen40(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ wep_keyprint(int /*<<< orphan*/ *);
int /*<<< orphan*/ wepkeygen_usage(char *);
int main(int argc, char **argv) {
  u_char keys[(5 * 4)];
  char *prog, *genstr;
  int strong, ch;
  prog = argv[0];
  strong = 0;
  while ((ch = getopt(argc, argv, "s")) != EOF) {
    switch (ch) {
    case 's':
      strong++;
      break;
    default:
      wepkeygen_usage(prog);
    }
  }
  argc -= optind;
  argv += optind;
  if (argc != 1)
    wepkeygen_usage(prog);
  genstr = argv[0];
  if (strong)
    wep_keygen128(genstr, keys);
  else
    wep_keygen40(genstr, keys);
  wep_keyprint(keys);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe77(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x78(%rbp)
mov    0x2e50(%rip),%rcx
cmp    (%rcx),%eax
je     11cd <main+0x7d>
mov    -0x78(%rbp),%eax
sub    $0x73,%eax
jne    11bf <main+0x6f>
jmp    11b1 <main+0x61>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11c8 <main+0x78>
mov    -0x68(%rbp),%rdi
call   1030 <wepkeygen_usage@plt>
jmp    117b <main+0x2b>
mov    0x2e0c(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2df8(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     120a <main+0xba>
mov    -0x68(%rbp),%rdi
call   1030 <wepkeygen_usage@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
cmpl   $0x0,-0x74(%rbp)
je     1231 <main+0xe1>
mov    -0x70(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1050 <wep_keygen128@plt>
jmp    123e <main+0xee>
mov    -0x70(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1040 <wep_keygen40@plt>
lea    -0x60(%rbp),%rdi
call   1070 <wep_keyprint@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%r12
mov    %edi,%ebp
mov    (%rsi),%r14
lea    0xe93(%rip),%rdx
call   1060 <getopt@plt>
mov    0x2e6f(%rip),%r13
xor    %ebx,%ebx
cmp    0x0(%r13),%eax
jne    11ad <main+0x5d>
mov    0x2e58(%rip),%rax
mov    (%rax),%r15
sub    %r15d,%ebp
cmp    $0x1,%ebp
je     119b <main+0x4b>
mov    %r14,%rdi
call   1030 <wepkeygen_usage@plt>
mov    (%r12,%r15,8),%rdi
mov    %rsp,%rsi
test   %ebx,%ebx
je     11e5 <main+0x95>
call   1050 <wep_keygen128@plt>
jmp    11ea <main+0x9a>
xor    %ebx,%ebx
lea    0xe4a(%rip),%r15
jmp    11db <main+0x8b>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <wepkeygen_usage@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   1060 <getopt@plt>
cmp    0x0(%r13),%eax
je     1181 <main+0x31>
cmp    $0x73,%eax
jne    11c0 <main+0x70>
add    $0x1,%ebx
jmp    11c8 <main+0x78>
call   1040 <wep_keygen40@plt>
mov    %rsp,%rdi
call   1070 <wep_keyprint@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"s\00"
@EOF = global i32 0
@optind = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x i32]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
store i8* %13, i8** %7
store i32 0, i32* %9
br label %14
14: ; preds = %28, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %10
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %29
20: ; preds = %14
%21 = load i32, i32* %10
switch i32 %21, label %25 [
i32 115, label %22
]
22: ; preds = %20
%23 = load i32, i32* %9
%24 = add nsw i32 %23, 1
store i32 %24, i32* %9
br label %28
25: ; preds = %20
%26 = load i8*, i8** %7
%27 = call i32 @wepkeygen_usage(i8* %26)
br label %28
28: ; preds = %25, %22
br label %14
29: ; preds = %14
%30 = load i64, i64* @optind
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = sub nsw i64 %32, %30
%34 = trunc i64 %33 to i32
store i32 %34, i32* %4
%35 = load i64, i64* @optind
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 %35
store i8** %37, i8*** %5
%38 = load i32, i32* %4
%39 = icmp ne i32 %38, 1
br i1 %39, label %40, label %43
40: ; preds = %29
%41 = load i8*, i8** %7
%42 = call i32 @wepkeygen_usage(i8* %41)
br label %43
43: ; preds = %40, %29
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
store i8* %46, i8** %8
%47 = load i32, i32* %9
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %43
%50 = load i8*, i8** %8
%51 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%52 = call i32 @wep_keygen128(i8* %50, i32* %51)
br label %57
53: ; preds = %43
%54 = load i8*, i8** %8
%55 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%56 = call i32 @wep_keygen40(i8* %54, i32* %55)
br label %57
57: ; preds = %53, %49
%58 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%59 = call i32 @wep_keyprint(i32* %58)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"s\00"
@EOF = global i32 0
@optind = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [20 x i32]
%4 = bitcast [20 x i32]* %3 to i8*
%5 = load i8*, i8** %1
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %22, label %9
9: ; preds = %2, %17
%10 = phi i32 [ %19, %17 ], [ %6, %2 ]
%11 = phi i32 [ %18, %17 ], [ 0, %2 ]
%12 = icmp eq i32 %10, 115
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = add nsw i32 %11, 1
br label %17
15: ; preds = %9
%16 = tail call i32 @wepkeygen_usage(i8* %5)
br label %17
17: ; preds = %15, %13
%18 = phi i32 [ %14, %13 ], [ %11, %15 ]
%19 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %9
22: ; preds = %17, %2
%23 = phi i32 [ 0, %2 ], [ %18, %17 ]
%24 = load i64, i64* @optind
%25 = trunc i64 %24 to i32
%26 = sub i32 %0, %25
%27 = getelementptr inbounds i8*, i8** %1, i64 %24
%28 = icmp eq i32 %26, 1
br i1 %28, label %31, label %29
29: ; preds = %22
%30 = tail call i32 @wepkeygen_usage(i8* %5)
br label %31
31: ; preds = %29, %22
%32 = load i8*, i8** %27
%33 = icmp eq i32 %23, 0
%34 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
br i1 %33, label %37, label %35
35: ; preds = %31
%36 = call i32 @wep_keygen128(i8* %32, i32* %34)
br label %39
37: ; preds = %31
%38 = call i32 @wep_keygen40(i8* %32, i32* %34)
br label %39
39: ; preds = %37, %35
%40 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%41 = call i32 @wep_keyprint(i32* %40)
ret i32 0
}