#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 /*<<< orphan*/ decrypt();
int /*<<< orphan*/ dumpConnections();
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ parsePcapFile(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ readSessionkeyFile(char *);
int /*<<< orphan*/ removeInvalidConnections();
int strlen(char *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    printf("Usage: %s $dumpfile.cap $keyfile.txt\n", argv[0]);
    return 1;
  }
  char *pcapFile = argv[1];
  char *keyFile = argv[2];
  char *magicKeyfileEnd = "txt";
  if (strlen(keyFile) >= 3 &&
      memcmp(keyFile + strlen(keyFile) - 3, magicKeyfileEnd, 3)) {
    pcapFile = argv[2];
    keyFile = argv[1];
  }
  readSessionkeyFile(keyFile);
  parsePcapFile(pcapFile);
  removeInvalidConnections();
  dumpConnections();
  decrypt();
  return 0;
}


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)
cmpl   $0x3,-0x8(%rbp)
je     11bf <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe52(%rip),%rdi
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1270 <main+0xf0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xe48(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x3,%eax
jl     1242 <main+0xc2>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x30(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
mov    -0x28(%rbp),%rsi
mov    $0x3,%edx
call   1080 <memcmp@plt>
cmp    $0x0,%rax
je     1242 <main+0xc2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   10a0 <readSessionkeyFile@plt>
mov    -0x18(%rbp),%rdi
call   1090 <parsePcapFile@plt>
mov    $0x0,%al
call   1050 <removeInvalidConnections@plt>
mov    $0x0,%al
call   1040 <dumpConnections@plt>
mov    $0x0,%al
call   1030 <decrypt@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11fb <main+0x7b>
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
cmp    $0x3,%eax
jl     11d2 <main+0x52>
mov    %r15,%rdi
call   1060 <strlen@plt>
cltq
lea    (%r15,%rax,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe6b(%rip),%rsi
mov    $0x3,%edx
call   1080 <memcmp@plt>
test   %rax,%rax
je     11d2 <main+0x52>
mov    0x8(%rbx),%r15
mov    0x10(%rbx),%r14
mov    %r15,%rdi
call   10a0 <readSessionkeyFile@plt>
mov    %r14,%rdi
call   1090 <parsePcapFile@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <removeInvalidConnections@plt>
xor    %eax,%eax
call   1040 <dumpConnections@plt>
xor    %eax,%eax
call   1030 <decrypt@plt>
jmp    120f <main+0x8f>
mov    (%rbx),%rsi
lea    0xdfb(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Usage: %s $dumpfile.cap $keyfile.txt\0A\00"
@.str.1 = [4 x i8] c"txt\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %51
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
store i8* %22, i8** %7
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %8
%23 = load i8*, i8** %7
%24 = call i32 @strlen(i8* %23)
%25 = icmp sge i32 %24, 3
br i1 %25, label %26, label %43
26: ; preds = %16
%27 = load i8*, i8** %7
%28 = load i8*, i8** %7
%29 = call i32 @strlen(i8* %28)
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
%32 = getelementptr inbounds i8, i8* %31, i64 -3
%33 = load i8*, i8** %8
%34 = call i64 @memcmp(i8* %32, i8* %33, i32 3)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %26
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
store i8* %39, i8** %6
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
store i8* %42, i8** %7
br label %43
43: ; preds = %36, %26, %16
%44 = load i8*, i8** %7
%45 = call i32 @readSessionkeyFile(i8* %44)
%46 = load i8*, i8** %6
%47 = call i32 @parsePcapFile(i8* %46)
%48 = call i32 (...) @removeInvalidConnections()
%49 = call i32 (...) @dumpConnections()
%50 = call i32 (...) @decrypt()
store i32 0, i32* %3
br label %51
51: ; preds = %43, %11
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [38 x i8] c"Usage: %s $dumpfile.cap $keyfile.txt\0A\00"
@.str.1 = [4 x i8] c"txt\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %32
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @strlen(i8* %11)
%13 = icmp sgt i32 %12, 2
br i1 %13, label %14, label %24
14: ; preds = %7
%15 = tail call i32 @strlen(i8* %11)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %11, i64 %16
%18 = getelementptr inbounds i8, i8* %17, i64 -3
%19 = tail call i64 @memcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %14
%22 = load i8*, i8** %10
%23 = load i8*, i8** %8
br label %24
24: ; preds = %21, %14, %7
%25 = phi i8* [ %22, %21 ], [ %9, %14 ], [ %9, %7 ]
%26 = phi i8* [ %23, %21 ], [ %11, %14 ], [ %11, %7 ]
%27 = tail call i32 @readSessionkeyFile(i8* %26)
%28 = tail call i32 @parsePcapFile(i8* %25)
%29 = tail call i32 (...) @removeInvalidConnections()
%30 = tail call i32 (...) @dumpConnections()
%31 = tail call i32 (...) @decrypt()
br label %32
32: ; preds = %24, %4
%33 = phi i32 [ 1, %4 ], [ 0, %24 ]
ret i32 %33
}