#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 */
char *get_option(char *, int /*<<< orphan*/ *);
int pcap2pigsty(char *, char *, char *, int /*<<< orphan*/);
int pcap_import_help();
int /*<<< orphan*/ printf(char *);
int pcap_import(void) {
  char *pcap = NULL;
  char *pigsty = NULL;
  char *incl_ethframe = NULL;
  char *signature_fmt = NULL;
  if (get_option("help", NULL) != NULL) {
    return pcap_import_help();
  }
  pcap = get_option("pcap", NULL);
  pigsty = get_option("pigsty", NULL);
  incl_ethframe = get_option("include-ethernet-frames", NULL);
  signature_fmt = get_option("signature-fmt", NULL);
  if (pcap == NULL) {
    printf("pig ERROR: --pcap option is missing.\n");
    return 1;
  }
  if (pigsty == NULL) {
    printf("pig ERROR: --pigsty option is missing.\n");
    return 1;
  }
  return pcap2pigsty(pigsty, pcap, signature_fmt, incl_ethframe != NULL);
}


x86 assembly (clang, -O0):
<pcap_import>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe91(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <get_option@plt>
cmp    $0x0,%rax
je     1191 <pcap_import+0x51>
mov    $0x0,%al
call   1050 <pcap_import_help@plt>
mov    %eax,-0x4(%rbp)
jmp    1248 <pcap_import+0x108>
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <get_option@plt>
mov    %rax,-0x10(%rbp)
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <get_option@plt>
mov    %rax,-0x18(%rbp)
lea    0xe51(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <get_option@plt>
mov    %rax,-0x20(%rbp)
lea    0xe55(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <get_option@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1204 <pcap_import+0xc4>
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1248 <pcap_import+0x108>
cmpq   $0x0,-0x18(%rbp)
jne    1227 <pcap_import+0xe7>
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1248 <pcap_import+0x108>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%ecx
call   1030 <pcap2pigsty@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pcap_import>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rdi
xor    %esi,%esi
call   1060 <get_option@plt>
test   %rax,%rax
je     1164 <pcap_import+0x24>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <pcap_import_help@plt>
lea    0xe9a(%rip),%rdi
xor    %esi,%esi
call   1060 <get_option@plt>
mov    %rax,%rbx
lea    0xe8e(%rip),%rdi
xor    %esi,%esi
call   1060 <get_option@plt>
mov    %rax,%r14
lea    0xe84(%rip),%rdi
xor    %esi,%esi
call   1060 <get_option@plt>
mov    %rax,%r15
lea    0xe8b(%rip),%rdi
xor    %esi,%esi
call   1060 <get_option@plt>
test   %rbx,%rbx
je     11ca <pcap_import+0x8a>
test   %r14,%r14
je     11d3 <pcap_import+0x93>
xor    %ecx,%ecx
test   %r15,%r15
setne  %cl
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <pcap2pigsty@plt>
lea    0xe8d(%rip),%rdi
jmp    11da <pcap_import+0x9a>
lea    0xe5d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"help\00"
@.str.1 = [5 x i8] c"pcap\00"
@.str.2 = [7 x i8] c"pigsty\00"
@.str.3 = [24 x i8] c"include-ethernet-frames\00"
@.str.4 = [14 x i8] c"signature-fmt\00"
@.str.5 = [38 x i8] c"pig ERROR: --pcap option is missing.\0A\00"
@.str.6 = [40 x i8] c"pig ERROR: --pigsty option is missing.\0A\00"
define i32 @pcap_import() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* null, i8** %2
store i8* null, i8** %3
store i8* null, i8** %4
store i8* null, i8** %5
%6 = call i8* @get_option(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* null)
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (...) @pcap_import_help()
store i32 %9, i32* %1
br label %32
10: ; preds = %0
%11 = call i8* @get_option(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* null)
store i8* %11, i8** %2
%12 = call i8* @get_option(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32* null)
store i8* %12, i8** %3
%13 = call i8* @get_option(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32* null)
store i8* %13, i8** %4
%14 = call i8* @get_option(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32* null)
store i8* %14, i8** %5
%15 = load i8*, i8** %2
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %1
br label %32
19: ; preds = %10
%20 = load i8*, i8** %3
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %1
br label %32
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = load i8*, i8** %2
%27 = load i8*, i8** %5
%28 = load i8*, i8** %4
%29 = icmp ne i8* %28, null
%30 = zext i1 %29 to i32
%31 = call i32 @pcap2pigsty(i8* %25, i8* %26, i8* %27, i32 %30)
store i32 %31, i32* %1
br label %32
32: ; preds = %24, %22, %17, %8
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [5 x i8] c"help\00"
@.str.1 = [5 x i8] c"pcap\00"
@.str.2 = [7 x i8] c"pigsty\00"
@.str.3 = [24 x i8] c"include-ethernet-frames\00"
@.str.4 = [14 x i8] c"signature-fmt\00"
@str = [39 x i8] c"pig ERROR: --pigsty option is missing.\00"
@str.7 = [37 x i8] c"pig ERROR: --pcap option is missing.\00"
define i32 @pcap_import() {
%1 = tail call i8* @get_option(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* null)
%2 = icmp eq i8* %1, null
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 (...) @pcap_import_help()
br label %21
5: ; preds = %0
%6 = tail call i8* @get_option(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* null)
%7 = tail call i8* @get_option(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32* null)
%8 = tail call i8* @get_option(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32* null)
%9 = tail call i8* @get_option(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32* null)
%10 = icmp eq i8* %6, null
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %21
13: ; preds = %5
%14 = icmp eq i8* %7, null
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
br label %21
17: ; preds = %13
%18 = icmp ne i8* %8, null
%19 = zext i1 %18 to i32
%20 = tail call i32 @pcap2pigsty(i8* %7, i8* %6, i8* %9, i32 %19)
br label %21
21: ; preds = %17, %15, %11, %3
%22 = phi i32 [ %4, %3 ], [ 1, %11 ], [ 1, %15 ], [ %20, %17 ]
ret i32 %22
}