#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 EOF;
int getopt(int, char **, char *);
size_t optind;
int /*<<< orphan*/ setup_dev(char *, char *, int);
int /*<<< orphan*/ setup_dev_chardev(char *, char *, int);
int /*<<< orphan*/ show_mappings();
scalar_t__ strchr(char *, char);
int usage();
int main(int argc, char **argv) {
  int rem = 0, c;
  char *pkt_device;
  char *device;
  if (argc == 1)
    return usage();
  while ((c = getopt(argc, argv, "ds?")) != EOF) {
    switch (c) {
    case 'd':
      rem = 1;
      break;
    case 's':
      show_mappings();
      return 0;
    default:
      return usage();
    }
  }
  pkt_device = argv[optind];
  device = argv[optind + 1];
  if (strchr(pkt_device, '/'))
    setup_dev(pkt_device, device, rem);
  else
    setup_dev_chardev(pkt_device, device, rem);
  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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1196 <main+0x36>
mov    $0x0,%al
call   1070 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1289 <main+0x129>
jmp    119b <main+0x3b>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe57(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e30(%rip),%rcx
cmp    (%rcx),%eax
je     1218 <main+0xb8>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x64,%eax
je     11e5 <main+0x85>
jmp    11d4 <main+0x74>
mov    -0x2c(%rbp),%eax
sub    $0x73,%eax
je     11f1 <main+0x91>
jmp    1204 <main+0xa4>
movl   $0x1,-0x14(%rbp)
jmp    1213 <main+0xb3>
mov    $0x0,%al
call   1060 <show_mappings@plt>
movl   $0x0,-0x4(%rbp)
jmp    1289 <main+0x129>
mov    $0x0,%al
call   1070 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1289 <main+0x129>
jmp    119b <main+0x3b>
mov    -0x10(%rbp),%rax
mov    0x2dbd(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2da7(%rip),%rcx
mov    (%rcx),%rcx
mov    0x8(%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     1272 <main+0x112>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <setup_dev@plt>
jmp    1282 <main+0x122>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <setup_dev_chardev@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   %rbx
push   %rax
cmp    $0x1,%edi
jne    117d <main+0x1d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <usage@plt>
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe77(%rip),%rdx
call   1080 <getopt@plt>
mov    0x2e53(%rip),%r15
xor    %r14d,%r14d
cmp    (%r15),%eax
je     11cd <main+0x6d>
lea    0xe5c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x64,%eax
jne    1202 <main+0xa2>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <getopt@plt>
cmp    (%r15),%eax
jne    11b0 <main+0x50>
mov    $0x1,%r14d
mov    0x2e0c(%rip),%rax
mov    (%rax),%rax
mov    (%rbx,%rax,8),%rbp
mov    0x8(%rbx,%rax,8),%rbx
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
test   %rax,%rax
je     1214 <main+0xb4>
call   1030 <setup_dev@plt>
jmp    1219 <main+0xb9>
cmp    $0x73,%eax
jne    116c <main+0xc>
xor    %eax,%eax
call   1060 <show_mappings@plt>
jmp    1219 <main+0xb9>
call   1050 <setup_dev_chardev@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"ds?\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 i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (...) @usage()
store i32 %13, i32* %3
br label %53
14: ; preds = %2
br label %15
15: ; preds = %28, %14
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %18, i32* %7
%19 = load i32, i32* @EOF
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %29
21: ; preds = %15
%22 = load i32, i32* %7
switch i32 %22, label %26 [
i32 100, label %23
i32 115, label %24
]
23: ; preds = %21
store i32 1, i32* %6
br label %28
24: ; preds = %21
%25 = call i32 (...) @show_mappings()
store i32 0, i32* %3
br label %53
26: ; preds = %21
%27 = call i32 (...) @usage()
store i32 %27, i32* %3
br label %53
28: ; preds = %23
br label %15
29: ; preds = %15
%30 = load i8**, i8*** %5
%31 = load i64, i64* @optind
%32 = getelementptr inbounds i8*, i8** %30, i64 %31
%33 = load i8*, i8** %32
store i8* %33, i8** %8
%34 = load i8**, i8*** %5
%35 = load i64, i64* @optind
%36 = add i64 %35, 1
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
store i8* %38, i8** %9
%39 = load i8*, i8** %8
%40 = call i64 @strchr(i8* %39, i8 signext 47)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %29
%43 = load i8*, i8** %8
%44 = load i8*, i8** %9
%45 = load i32, i32* %6
%46 = call i32 @setup_dev(i8* %43, i8* %44, i32 %45)
br label %52
47: ; preds = %29
%48 = load i8*, i8** %8
%49 = load i8*, i8** %9
%50 = load i32, i32* %6
%51 = call i32 @setup_dev_chardev(i8* %48, i8* %49, i32 %50)
br label %52
52: ; preds = %47, %42
store i32 0, i32* %3
br label %53
53: ; preds = %52, %26, %24, %12
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@.str = [4 x i8] c"ds?\00"
@EOF = global i32 0
@optind = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %20, label %14
8: ; preds = %2
%9 = tail call i32 (...) @usage()
br label %34
10: ; preds = %14
%11 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %11, %12
br i1 %13, label %20, label %14
14: ; preds = %4, %10
%15 = phi i32 [ %11, %10 ], [ %5, %4 ]
switch i32 %15, label %18 [
i32 100, label %10
i32 115, label %16
]
16: ; preds = %14
%17 = tail call i32 (...) @show_mappings()
br label %34
18: ; preds = %14
%19 = tail call i32 (...) @usage()
br label %34
20: ; preds = %10, %4
%21 = phi i32 [ 0, %4 ], [ 1, %10 ]
%22 = load i64, i64* @optind
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = add i64 %22, 1
%26 = getelementptr inbounds i8*, i8** %1, i64 %25
%27 = load i8*, i8** %26
%28 = tail call i64 @strchr(i8* %24, i8 signext 47)
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %20
%31 = tail call i32 @setup_dev(i8* %24, i8* %27, i32 %21)
br label %34
32: ; preds = %20
%33 = tail call i32 @setup_dev_chardev(i8* %24, i8* %27, i32 %21)
br label %34
34: ; preds = %30, %32, %18, %16, %8
%35 = phi i32 [ %9, %8 ], [ %19, %18 ], [ 0, %16 ], [ 0, %32 ], [ 0, %30 ]
ret i32 %35
}