#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 scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ check_crc();
scalar_t__ load_file(char const *, unsigned char *);
int /*<<< orphan*/ pcap_list_insert_at_cursor(unsigned char *, scalar_t__,
                                              int /*<<< orphan*/ *,
                                              int /*<<< orphan*/);
int /*<<< orphan*/ warn_text_ui(char *);
bool cmd_insert(const char *arg) {
  ssize_t n;
  unsigned char frame[128];
  if (!arg) {
    warn_text_ui("Expected a filename for the insert command");
    goto EXIT;
  }
  n = load_file(arg, frame);
  if (n < 0)
    goto EXIT;
  pcap_list_insert_at_cursor(frame, n, NULL, check_crc());
EXIT:
  return true;
}


x86 assembly (clang, -O0):
<cmd_insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    116b <cmd_insert+0x2b>
lea    0xe9f(%rip),%rdi
call   1030 <warn_text_ui@plt>
jmp    11c8 <cmd_insert+0x88>
mov    -0x8(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1050 <load_file@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    118f <cmd_insert+0x4f>
jmp    11c8 <cmd_insert+0x88>
lea    -0x90(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    $0x0,%al
call   1040 <check_crc@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    %eax,%ecx
xor    %eax,%eax
mov    %eax,%edx
call   1060 <pcap_list_insert_at_cursor@plt>
mov    $0x1,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_insert>:
push   %rbx
sub    $0x80,%rsp
test   %rdi,%rdi
je     1175 <cmd_insert+0x35>
mov    %rsp,%rsi
call   1050 <load_file@plt>
test   %rax,%rax
js     1181 <cmd_insert+0x41>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <check_crc@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    %eax,%ecx
call   1060 <pcap_list_insert_at_cursor@plt>
jmp    1181 <cmd_insert+0x41>
lea    0xe84(%rip),%rdi
call   1030 <warn_text_ui@plt>
mov    $0x1,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Expected a filename for the insert command\00"
define i32 @cmd_insert(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca [128 x i8]
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @warn_text_ui(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %21
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%12 = call i64 @load_file(i8* %10, i8* %11)
store i64 %12, i64* %3
%13 = load i64, i64* %3
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %9
br label %21
16: ; preds = %9
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%18 = load i64, i64* %3
%19 = call i32 (...) @check_crc()
%20 = call i32 @pcap_list_insert_at_cursor(i8* %17, i64 %18, i32* null, i32 %19)
br label %21
21: ; preds = %16, %15, %7
ret i32 1
}

LLVM IR (-O2):
@.str = [43 x i8] c"Expected a filename for the insert command\00"
define i32 @cmd_insert(i8* %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @warn_text_ui(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %13
7: ; preds = %1
%8 = call i64 @load_file(i8* %0, i8* %3)
%9 = icmp slt i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = call i32 (...) @check_crc()
%12 = call i32 @pcap_list_insert_at_cursor(i8* %3, i64 %8, i32* null, i32 %11)
br label %13
13: ; preds = %7, %10, %5
ret i32 1
}