#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*/ destroy_rnnctx();
int getopt(int, char **, char *);
int /*<<< orphan*/ init_rnnctx(char *, int);
scalar_t__ lookup_trace(char *, char *);
int /*<<< orphan*/ optarg;
char *strdup(int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  char *event = NULL, *chipset = NULL;
  int use_colors = 1;
  int c;
  if (argc < 4) {
    usage();
    return 1;
  }
  while ((c = getopt(argc, argv, "a:c:e:")) != -1) {
    switch (c) {
    case 'a':
      chipset = strdup(optarg);
      break;
    case 'c':
      use_colors = 0;
      break;
    case 'e':
      event = strdup(optarg);
      break;
    default:
      usage();
    }
  }
  if (!chipset || !event)
    usage();
  init_rnnctx(chipset, use_colors);
  if (lookup_trace(chipset, event))
    return 1;
  destroy_rnnctx();
  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)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11aa <main+0x4a>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a4 <main+0x144>
jmp    11af <main+0x4f>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe43(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
je     124a <main+0xea>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x61,%eax
je     1204 <main+0xa4>
jmp    11e2 <main+0x82>
mov    -0x2c(%rbp),%eax
sub    $0x63,%eax
je     121b <main+0xbb>
jmp    11f3 <main+0x93>
mov    -0x2c(%rbp),%eax
sub    $0x65,%eax
je     1227 <main+0xc7>
jmp    123e <main+0xde>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
call   1070 <strdup@plt>
mov    %rax,-0x20(%rbp)
jmp    1245 <main+0xe5>
movl   $0x0,-0x24(%rbp)
jmp    1245 <main+0xe5>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1070 <strdup@plt>
mov    %rax,-0x18(%rbp)
jmp    1245 <main+0xe5>
mov    $0x0,%al
call   1050 <usage@plt>
jmp    11af <main+0x4f>
cmpq   $0x0,-0x20(%rbp)
je     1260 <main+0x100>
cmpq   $0x0,-0x18(%rbp)
jne    1267 <main+0x107>
mov    $0x0,%al
call   1050 <usage@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1080 <init_rnnctx@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <lookup_trace@plt>
cmp    $0x0,%rax
je     1296 <main+0x136>
movl   $0x1,-0x4(%rbp)
jmp    12a4 <main+0x144>
mov    $0x0,%al
call   1030 <destroy_rnnctx@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x4,%edi
jge    1181 <main+0x21>
xor    %eax,%eax
call   1050 <usage@plt>
mov    $0x1,%ebx
jmp    123c <main+0xdc>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r14d
lea    0xe6d(%rip),%r13
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    11a7 <main+0x47>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1060 <getopt@plt>
cmp    $0x62,%eax
jg     11e0 <main+0x80>
cmp    $0xffffffff,%eax
je     1202 <main+0xa2>
cmp    $0x61,%eax
jne    11a0 <main+0x40>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1070 <strdup@plt>
mov    %rax,%r12
jmp    11a7 <main+0x47>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x63,%eax
je     11fd <main+0x9d>
cmp    $0x65,%eax
jne    11a0 <main+0x40>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1070 <strdup@plt>
mov    %rax,%r15
jmp    11a7 <main+0x47>
xor    %r14d,%r14d
jmp    11a7 <main+0x47>
test   %r12,%r12
je     120c <main+0xac>
test   %r15,%r15
jne    1213 <main+0xb3>
xor    %eax,%eax
call   1050 <usage@plt>
mov    %r12,%rdi
mov    %r14d,%esi
call   1080 <init_rnnctx@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <lookup_trace@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    123c <main+0xdc>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <destroy_rnnctx@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"a:c:e:\00"
@optarg = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i32 1, i32* %8
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (...) @usage()
store i32 1, i32* %3
br label %51
14: ; preds = %2
br label %15
15: ; preds = %31, %14
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %18, i32* %9
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %32
20: ; preds = %15
%21 = load i32, i32* %9
switch i32 %21, label %29 [
i32 97, label %22
i32 99, label %25
i32 101, label %26
]
22: ; preds = %20
%23 = load i32, i32* @optarg
%24 = call i8* @strdup(i32 %23)
store i8* %24, i8** %7
br label %31
25: ; preds = %20
store i32 0, i32* %8
br label %31
26: ; preds = %20
%27 = load i32, i32* @optarg
%28 = call i8* @strdup(i32 %27)
store i8* %28, i8** %6
br label %31
29: ; preds = %20
%30 = call i32 (...) @usage()
br label %31
31: ; preds = %29, %26, %25, %22
br label %15
32: ; preds = %15
%33 = load i8*, i8** %7
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i8*, i8** %6
%37 = icmp ne i8* %36, null
br i1 %37, label %40, label %38
38: ; preds = %35, %32
%39 = call i32 (...) @usage()
br label %40
40: ; preds = %38, %35
%41 = load i8*, i8** %7
%42 = load i32, i32* %8
%43 = call i32 @init_rnnctx(i8* %41, i32 %42)
%44 = load i8*, i8** %7
%45 = load i8*, i8** %6
%46 = call i64 @lookup_trace(i8* %44, i8* %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %40
store i32 1, i32* %3
br label %51
49: ; preds = %40
%50 = call i32 (...) @destroy_rnnctx()
store i32 0, i32* %3
br label %51
51: ; preds = %49, %48, %12
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [7 x i8] c"a:c:e:\00"
@optarg = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %37
6: ; preds = %21, %23
%7 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %7, label %23 [
i32 -1, label %25
i32 97, label %8
i32 99, label %21
i32 101, label %11
]
8: ; preds = %6
%9 = load i32, i32* @optarg
%10 = tail call i8* @strdup(i32 %9)
br label %18
11: ; preds = %6
%12 = load i32, i32* @optarg
%13 = tail call i8* @strdup(i32 %12)
br label %14
14: ; preds = %2, %11
%15 = phi i8* [ %13, %11 ], [ null, %2 ]
%16 = phi i8* [ %19, %11 ], [ null, %2 ]
%17 = phi i32 [ %22, %11 ], [ 1, %2 ]
br label %18
18: ; preds = %14, %8
%19 = phi i8* [ %16, %14 ], [ %10, %8 ]
%20 = phi i32 [ %17, %14 ], [ %22, %8 ]
br label %21
21: ; preds = %6, %18
%22 = phi i32 [ %20, %18 ], [ 0, %6 ]
br label %6
23: ; preds = %6
%24 = tail call i32 (...) @usage()
br label %6
25: ; preds = %6
%26 = icmp ne i8* %19, null
%27 = icmp ne i8* %15, null
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = tail call i32 (...) @usage()
br label %31
31: ; preds = %25, %29
%32 = tail call i32 @init_rnnctx(i8* %19, i32 %22)
%33 = tail call i64 @lookup_trace(i8* %19, i8* %15)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = tail call i32 (...) @destroy_rnnctx()
br label %37
37: ; preds = %31, %35, %4
%38 = phi i32 [ 1, %4 ], [ 0, %35 ], [ 1, %31 ]
ret i32 %38
}