#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*/ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int /*<<< orphan*/ wep_keygen128(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ wep_keygen40(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ wep_keyprint128(int /*<<< orphan*/ *);
int /*<<< orphan*/ wep_keyprint40(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  u_char keys[(5 * 4)];
  u_char strongkeys[(13 * 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:
      usage(prog);
    }
  }
  argc -= optind;
  argv += optind;
  if (argc == 2)
    if (!strcmp(argv[1], "13")) {
      strong++;
      argc--;
    } else
      argc--;
  if (argc != 1)
    usage(prog);
  genstr = argv[0];
  if (strong) {
    wep_keygen128(genstr, strongkeys);
    wep_keyprint128(strongkeys);
  } else {
    wep_keygen40(genstr, keys);
    wep_keyprint40(keys);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x138(%rbp)
movl   $0x0,-0x144(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe51(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x148(%rbp)
mov    0x2e27(%rip),%rcx
cmp    (%rcx),%eax
je     1202 <main+0x92>
mov    -0x148(%rbp),%eax
sub    $0x73,%eax
jne    11f1 <main+0x81>
jmp    11dd <main+0x6d>
mov    -0x144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x144(%rbp)
jmp    11fd <main+0x8d>
mov    -0x138(%rbp),%rdi
call   1060 <usage@plt>
jmp    11a1 <main+0x31>
mov    0x2dd7(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2dc3(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    127e <main+0x10e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdbd(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1270 <main+0x100>
mov    -0x144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x144(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1279 <main+0x109>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    127e <main+0x10e>
cmpl   $0x1,-0x8(%rbp)
je     1294 <main+0x124>
mov    -0x138(%rbp),%rdi
call   1060 <usage@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x140(%rbp)
cmpl   $0x0,-0x144(%rbp)
je     12d3 <main+0x163>
mov    -0x140(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1080 <wep_keygen128@plt>
lea    -0x130(%rbp),%rdi
call   1030 <wep_keyprint128@plt>
jmp    12ec <main+0x17c>
mov    -0x140(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1050 <wep_keygen40@plt>
lea    -0x60(%rbp),%rdi
call   1070 <wep_keyprint40@plt>
xor    %eax,%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rsi,%r12
mov    %edi,%ebp
mov    (%rsi),%r14
lea    0xe70(%rip),%rdx
call   1090 <getopt@plt>
mov    0x2e4c(%rip),%r13
xor    %ebx,%ebx
cmp    0x0(%r13),%eax
jne    11d4 <main+0x64>
mov    0x2e35(%rip),%rax
mov    (%rax),%r15
sub    %r15d,%ebp
cmp    $0x1,%ebp
je     120d <main+0x9d>
cmp    $0x2,%ebp
jne    1205 <main+0x95>
mov    0x8(%r12,%r15,8),%rdi
lea    0xe3b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x1,%eax
adc    $0x0,%ebx
jmp    120d <main+0x9d>
xor    %ebx,%ebx
lea    0xe23(%rip),%r15
jmp    11fb <main+0x8b>
nop
mov    %r14,%rdi
call   1060 <usage@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   1090 <getopt@plt>
cmp    0x0(%r13),%eax
je     11a4 <main+0x34>
cmp    $0x73,%eax
jne    11e0 <main+0x70>
add    $0x1,%ebx
jmp    11e8 <main+0x78>
mov    %r14,%rdi
call   1060 <usage@plt>
mov    (%r12,%r15,8),%rdi
test   %ebx,%ebx
je     122a <main+0xba>
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1080 <wep_keygen128@plt>
mov    %rbx,%rdi
call   1030 <wep_keyprint128@plt>
jmp    123d <main+0xcd>
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <wep_keygen40@plt>
mov    %rbx,%rdi
call   1070 <wep_keyprint40@plt>
xor    %eax,%eax
add    $0xd8,%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
@.str.1 = [3 x i8] c"13\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x i32]
%7 = alloca [52 x i32]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
store i8* %14, i8** %8
store i32 0, i32* %10
br label %15
15: ; preds = %29, %2
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %18, i32* %11
%19 = load i32, i32* @EOF
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %15
%22 = load i32, i32* %11
switch i32 %22, label %26 [
i32 115, label %23
]
23: ; preds = %21
%24 = load i32, i32* %10
%25 = add nsw i32 %24, 1
store i32 %25, i32* %10
br label %29
26: ; preds = %21
%27 = load i8*, i8** %8
%28 = call i32 @usage(i8* %27)
br label %29
29: ; preds = %26, %23
br label %15
30: ; preds = %15
%31 = load i64, i64* @optind
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = sub nsw i64 %33, %31
%35 = trunc i64 %34 to i32
store i32 %35, i32* %4
%36 = load i64, i64* @optind
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 %36
store i8** %38, i8*** %5
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 2
br i1 %40, label %41, label %56
41: ; preds = %30
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i32 @strcmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp ne i32 %45, 0
br i1 %46, label %52, label %47
47: ; preds = %41
%48 = load i32, i32* %10
%49 = add nsw i32 %48, 1
store i32 %49, i32* %10
%50 = load i32, i32* %4
%51 = add nsw i32 %50, -1
store i32 %51, i32* %4
br label %55
52: ; preds = %41
%53 = load i32, i32* %4
%54 = add nsw i32 %53, -1
store i32 %54, i32* %4
br label %55
55: ; preds = %52, %47
br label %56
56: ; preds = %55, %30
%57 = load i32, i32* %4
%58 = icmp ne i32 %57, 1
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i8*, i8** %8
%61 = call i32 @usage(i8* %60)
br label %62
62: ; preds = %59, %56
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 0
%65 = load i8*, i8** %64
store i8* %65, i8** %9
%66 = load i32, i32* %10
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %74
68: ; preds = %62
%69 = load i8*, i8** %9
%70 = getelementptr inbounds [52 x i32], [52 x i32]* %7, i64 0, i64 0
%71 = call i32 @wep_keygen128(i8* %69, i32* %70)
%72 = getelementptr inbounds [52 x i32], [52 x i32]* %7, i64 0, i64 0
%73 = call i32 @wep_keyprint128(i32* %72)
br label %80
74: ; preds = %62
%75 = load i8*, i8** %9
%76 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%77 = call i32 @wep_keygen40(i8* %75, i32* %76)
%78 = getelementptr inbounds [20 x i32], [20 x i32]* %6, i64 0, i64 0
%79 = call i32 @wep_keyprint40(i32* %78)
br label %80
80: ; preds = %74, %68
ret i32 0
}

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