#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 /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int /*<<< orphan*/ wep_40keyprint(int /*<<< orphan*/ *);
int /*<<< orphan*/ wep_keygen104(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ wep_keygen40(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ wep_nkeyprint(int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  u_char key104[13];
  u_char key40[(5 * 4)];
  if (argc != 2) {
    printf("usage: %s <passphrase>\n", argv[0]);
    return 1;
  }
  wep_keygen40(argv[1], key40);
  wep_keygen104(argv[1], key104);
  printf("\n40-bit keys:\n");
  wep_40keyprint(key40);
  printf("\n104-bit key:\n");
  wep_nkeyprint(key104, 13);
  printf("\n");
  if (strlen(argv[1]) == 5) {
    printf("40-bit ASCII key:\n");
    wep_nkeyprint((u_char *)argv[1], 5);
    printf("\n");
  } else if (strlen(argv[1]) == 13) {
    printf("104-bit ASCII key:\n");
    wep_nkeyprint((u_char *)argv[1], 13);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11a4 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a6 <main+0x146>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0xa0(%rbp),%rsi
call   1080 <wep_keygen40@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <wep_keygen104@plt>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   1060 <wep_40keyprint@plt>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    $0xd,%esi
call   1070 <wep_nkeyprint@plt>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
cmp    $0x5,%eax
jne    1256 <main+0xf6>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x5,%esi
call   1070 <wep_nkeyprint@plt>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    129f <main+0x13f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
cmp    $0xd,%eax
jne    129a <main+0x13a>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0xd,%esi
call   1070 <wep_nkeyprint@plt>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    129f <main+0x13f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1224 <main+0xa4>
mov    0x8(%rbx),%rdi
lea    0x40(%rsp),%rbp
mov    %rbp,%rsi
call   10a0 <wep_keygen40@plt>
mov    0x8(%rbx),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1070 <wep_keygen104@plt>
lea    0xe5a(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1080 <wep_40keyprint@plt>
lea    0xe54(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    $0xd,%esi
call   1090 <wep_nkeyprint@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rbx),%rdi
call   1050 <strlen@plt>
cmp    $0x5,%eax
jne    123c <main+0xbc>
lea    0xe44(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rbx),%rdi
mov    $0x5,%esi
call   1090 <wep_nkeyprint@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    1270 <main+0xf0>
mov    (%rbx),%rsi
lea    0xdd2(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%ebp
jmp    1270 <main+0xf0>
mov    0x8(%rbx),%rdi
call   1050 <strlen@plt>
xor    %ebp,%ebp
cmp    $0xd,%eax
jne    1270 <main+0xf0>
lea    0xde1(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rbx),%rdi
mov    $0xd,%esi
call   1090 <wep_nkeyprint@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"usage: %s <passphrase>\0A\00"
@.str.1 = [15 x i8] c"\0A40-bit keys:\0A\00"
@.str.2 = [15 x i8] c"\0A104-bit key:\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [19 x i8] c"40-bit ASCII key:\0A\00"
@.str.5 = [20 x i8] c"104-bit ASCII key:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [13 x i32]
%7 = alloca [20 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 1, i32* %3
br label %62
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = getelementptr inbounds [20 x i32], [20 x i32]* %7, i64 0, i64 0
%20 = call i32 @wep_keygen40(i8* %18, i32* %19)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 0
%25 = call i32 @wep_keygen104(i8* %23, i32* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%27 = getelementptr inbounds [20 x i32], [20 x i32]* %7, i64 0, i64 0
%28 = call i32 @wep_40keyprint(i32* %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%30 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 0
%31 = call i32 @wep_nkeyprint(i32* %30, i32 13)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strlen(i8* %35)
%37 = icmp eq i32 %36, 5
br i1 %37, label %38, label %46
38: ; preds = %15
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = bitcast i8* %42 to i32*
%44 = call i32 @wep_nkeyprint(i32* %43, i32 5)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %61
46: ; preds = %15
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @strlen(i8* %49)
%51 = icmp eq i32 %50, 13
br i1 %51, label %52, label %60
52: ; preds = %46
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = bitcast i8* %56 to i32*
%58 = call i32 @wep_nkeyprint(i32* %57, i32 13)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %60
60: ; preds = %52, %46
br label %61
61: ; preds = %60, %38
store i32 0, i32* %3
br label %62
62: ; preds = %61, %10
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
@.str = [24 x i8] c"usage: %s <passphrase>\0A\00"
@str = [14 x i8] c"\0A40-bit keys:\00"
@str.6 = [14 x i8] c"\0A104-bit key:\00"
@str.7 = [19 x i8] c"104-bit ASCII key:\00"
@str.8 = [18 x i8] c"40-bit ASCII key:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [13 x i32]
%4 = alloca [20 x i32]
%5 = bitcast [13 x i32]* %3 to i8*
%6 = bitcast [20 x i32]* %4 to i8*
%7 = icmp eq i32 %0, 2
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %43
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 0
%15 = call i32 @wep_keygen40(i8* %13, i32* %14)
%16 = load i8*, i8** %12
%17 = getelementptr inbounds [13 x i32], [13 x i32]* %3, i64 0, i64 0
%18 = call i32 @wep_keygen104(i8* %16, i32* %17)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%20 = call i32 @wep_40keyprint(i32* %14)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0))
%22 = call i32 @wep_nkeyprint(i32* %17, i32 13)
%23 = call i32 @putchar(i32 10)
%24 = load i8*, i8** %12
%25 = call i32 @strlen(i8* %24)
%26 = icmp eq i32 %25, 5
br i1 %26, label %27, label %33
27: ; preds = %11
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
%29 = bitcast i8** %12 to i32**
%30 = load i32*, i32** %29
%31 = call i32 @wep_nkeyprint(i32* %30, i32 5)
%32 = call i32 @putchar(i32 10)
br label %43
33: ; preds = %11
%34 = load i8*, i8** %12
%35 = call i32 @strlen(i8* %34)
%36 = icmp eq i32 %35, 13
br i1 %36, label %37, label %43
37: ; preds = %33
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
%39 = bitcast i8** %12 to i32**
%40 = load i32*, i32** %39
%41 = call i32 @wep_nkeyprint(i32* %40, i32 13)
%42 = call i32 @putchar(i32 10)
br label %43
43: ; preds = %27, %37, %33, %8
%44 = phi i32 [ 1, %8 ], [ 0, %33 ], [ 0, %37 ], [ 0, %27 ]
ret i32 %44
}