#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*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
void *grab_file(char *, unsigned long *);
long init_module(void *, unsigned long, char *);
int /*<<< orphan*/ moderror(int /*<<< orphan*/);
int /*<<< orphan*/ print_usage(char *);
int /*<<< orphan*/ puts(char *);
char *realloc(char *, scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strchr(char *, char);
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
char *strerror(int /*<<< orphan*/);
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  int i;
  long int ret;
  unsigned long len;
  void *file;
  char *filename, *options = strdup("");
  char *progname = argv[0];
  if (argv[1] && ((strcmp((argv[1]), ("--version")) == 0) ||
                  (strcmp((argv[1]), ("-V")) == 0))) {
    puts("klibc insmod");
    exit(0);
  }
  while (argv[1] && ((strcmp((argv[1]), ("-p")) == 0) ||
                     (strcmp((argv[1]), ("-s")) == 0) ||
                     (strcmp((argv[1]), ("-f")) == 0))) {
    argv++;
    argc--;
  }
  filename = argv[1];
  if (!filename)
    print_usage(progname);
  for (i = 2; i < argc; i++) {
    options = realloc(options, strlen(options) + 2 + strlen(argv[i]) + 2);
    if (strchr(argv[i], ' '))
      strcat(options, "\"");
    strcat(options, argv[i]);
    if (strchr(argv[i], ' '))
      strcat(options, "\"");
    strcat(options, " ");
  }
  file = grab_file(filename, &len);
  if (!file) {
    fprintf(stderr, "insmod: can't read '%s': %s\n", filename, strerror(errno));
    exit(1);
  }
  ret = init_module(file, len, options);
  if (ret != 0) {
    fprintf(stderr, "insmod: error inserting '%s': %li %s\n", filename, ret,
            moderror(errno));
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe43(%rip),%rdi
call   10f0 <strdup@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1272 <main+0x92>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdce(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     125f <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdba(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1272 <main+0x92>
lea    0xda7(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
jmp    1277 <main+0x97>
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,0x8(%rcx)
mov    %al,-0x49(%rbp)
je     12fb <main+0x11b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd80(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x4a(%rbp)
je     12f5 <main+0x115>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd5d(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x4a(%rbp)
je     12f5 <main+0x115>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd3a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x4a(%rbp)
mov    -0x4a(%rbp),%al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    130b <main+0x12b>
jmp    1325 <main+0x145>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1277 <main+0x97>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1345 <main+0x165>
mov    -0x48(%rbp),%rdi
call   10e0 <print_usage@plt>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    142d <main+0x24d>
mov    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x2,%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    -0x60(%rbp),%rsi
mov    -0x58(%rbp),%rdi
add    %rax,%rsi
add    $0x2,%rsi
call   10b0 <realloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     13ca <main+0x1ea>
mov    -0x40(%rbp),%rdi
lea    0xc5e(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   10c0 <strcat@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     140f <main+0x22f>
mov    -0x40(%rbp),%rdi
lea    0xc19(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x40(%rbp),%rdi
lea    0xc0b(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    134c <main+0x16c>
mov    -0x38(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <grab_file@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    148d <main+0x2ad>
mov    0x2b90(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    0x2b74(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rdx
mov    %rax,%rcx
lea    0xbab(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   10a0 <init_module@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1503 <main+0x323>
mov    0x2b2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    0x2b05(%rip),%rax
mov    (%rax),%edi
call   1090 <moderror@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rdx
mov    -0x78(%rbp),%rcx
mov    %eax,%r8d
lea    0xb52(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xe49(%rip),%rdi
call   10f0 <strdup@plt>
mov    %rax,%rbx
mov    (%r14),%r15
mov    0x8(%r14),%rdi
test   %rdi,%rdi
jne    132a <main+0x14a>
mov    %r15,0x8(%rsp)
mov    0x8(%rsp),%rdi
call   10e0 <print_usage@plt>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
cmp    $0x3,%ebp
jl     12dc <main+0xfc>
mov    %ebp,%r15d
mov    $0x2,%r12d
lea    0xde2(%rip),%r13
jmp    1268 <main+0x88>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
lea    0xdcb(%rip),%rsi
call   10c0 <strcat@plt>
add    $0x1,%r12
cmp    %r12,%r15
je     12dc <main+0xfc>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
mov    (%r14,%r12,8),%rdi
call   1050 <strlen@plt>
lea    (%rax,%rbp,1),%rsi
add    $0x4,%rsi
mov    %rbx,%rdi
call   10b0 <realloc@plt>
mov    %rax,%rbx
mov    (%r14,%r12,8),%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     12ad <main+0xcd>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10c0 <strcat@plt>
mov    (%r14,%r12,8),%rsi
mov    %rbx,%rdi
call   10c0 <strcat@plt>
mov    (%r14,%r12,8),%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     1250 <main+0x70>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10c0 <strcat@plt>
jmp    1250 <main+0x70>
lea    0x10(%rsp),%rsi
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <grab_file@plt>
test   %rax,%rax
jne    1363 <main+0x183>
mov    0x2ce6(%rip),%rax
mov    (%rax),%ebx
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xd16(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xccf(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1350 <main+0x170>
mov    0x8(%r14),%rdi
lea    0xcc4(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    13be <main+0x1de>
lea    0xcb6(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    0x10(%rsp),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   10a0 <init_module@plt>
test   %rax,%rax
jne    137f <main+0x19f>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    %rax,%rbx
mov    0x2c57(%rip),%rax
mov    (%rax),%r14d
mov    0x2c45(%rip),%rax
mov    (%rax),%edi
call   1090 <moderror@plt>
lea    0xca3(%rip),%rsi
mov    %r14d,%edi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    %eax,%r8d
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    %r15,0x8(%rsp)
mov    0x8(%r14),%rdi
test   %rdi,%rdi
je     1217 <main+0x37>
lea    0xc43(%rip),%r15
lea    0xc3f(%rip),%r13
lea    0xc3b(%rip),%r12
jmp    1404 <main+0x224>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
mov    0x10(%r14),%rdi
add    $0x8,%r14
test   %rdi,%rdi
je     1217 <main+0x37>
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     13f0 <main+0x210>
mov    0x8(%r14),%rdi
mov    %r13,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     13f0 <main+0x210>
mov    0x8(%r14),%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     13f0 <main+0x210>
mov    0x8(%r14),%rax
test   %rax,%rax
je     1217 <main+0x37>
jmp    1223 <main+0x43>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [10 x i8] c"--version\00"
@.str.2 = [3 x i8] c"-V\00"
@.str.3 = [13 x i8] c"klibc insmod\00"
@.str.4 = [3 x i8] c"-p\00"
@.str.5 = [3 x i8] c"-s\00"
@.str.6 = [3 x i8] c"-f\00"
@.str.7 = [2 x i8] c"\22\00"
@.str.8 = [2 x i8] c" \00"
@stderr = global i32 0
@.str.9 = [29 x i8] c"insmod: can't read '%s': %s\0A\00"
@errno = global i32 0
@.str.10 = [38 x i8] c"insmod: error inserting '%s': %li %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %11
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
store i8* %16, i8** %12
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %36
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %33, label %27
27: ; preds = %21
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %27, %21
%34 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 @exit(i32 0)
unreachable
36: ; preds = %27, %2
br label %37
37: ; preds = %64, %36
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %62
42: ; preds = %37
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %60, label %48
48: ; preds = %42
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %60, label %54
54: ; preds = %48
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br label %60
60: ; preds = %54, %48, %42
%61 = phi i1 [ true, %48 ], [ true, %42 ], [ %59, %54 ]
br label %62
62: ; preds = %60, %37
%63 = phi i1 [ false, %37 ], [ %61, %60 ]
br i1 %63, label %64, label %69
64: ; preds = %62
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i32 1
store i8** %66, i8*** %5
%67 = load i32, i32* %4
%68 = add nsw i32 %67, -1
store i32 %68, i32* %4
br label %37
69: ; preds = %62
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 1
%72 = load i8*, i8** %71
store i8* %72, i8** %10
%73 = load i8*, i8** %10
%74 = icmp ne i8* %73, null
br i1 %74, label %78, label %75
75: ; preds = %69
%76 = load i8*, i8** %12
%77 = call i32 @print_usage(i8* %76)
br label %78
78: ; preds = %75, %69
store i32 2, i32* %6
br label %79
79: ; preds = %128, %78
%80 = load i32, i32* %6
%81 = load i32, i32* %4
%82 = icmp slt i32 %80, %81
br i1 %82, label %83, label %131
83: ; preds = %79
%84 = load i8*, i8** %11
%85 = load i8*, i8** %11
%86 = call i64 @strlen(i8* %85)
%87 = add nsw i64 %86, 2
%88 = load i8**, i8*** %5
%89 = load i32, i32* %6
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8*, i8** %88, i64 %90
%92 = load i8*, i8** %91
%93 = call i64 @strlen(i8* %92)
%94 = add nsw i64 %87, %93
%95 = add nsw i64 %94, 2
%96 = call i8* @realloc(i8* %84, i64 %95)
store i8* %96, i8** %11
%97 = load i8**, i8*** %5
%98 = load i32, i32* %6
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8*, i8** %97, i64 %99
%101 = load i8*, i8** %100
%102 = call i64 @strchr(i8* %101, i8 signext 32)
%103 = icmp ne i64 %102, 0
br i1 %103, label %104, label %107
104: ; preds = %83
%105 = load i8*, i8** %11
%106 = call i32 @strcat(i8* %105, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %107
107: ; preds = %104, %83
%108 = load i8*, i8** %11
%109 = load i8**, i8*** %5
%110 = load i32, i32* %6
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8*, i8** %109, i64 %111
%113 = load i8*, i8** %112
%114 = call i32 @strcat(i8* %108, i8* %113)
%115 = load i8**, i8*** %5
%116 = load i32, i32* %6
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8*, i8** %115, i64 %117
%119 = load i8*, i8** %118
%120 = call i64 @strchr(i8* %119, i8 signext 32)
%121 = icmp ne i64 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %107
%123 = load i8*, i8** %11
%124 = call i32 @strcat(i8* %123, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %125
125: ; preds = %122, %107
%126 = load i8*, i8** %11
%127 = call i32 @strcat(i8* %126, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %128
128: ; preds = %125
%129 = load i32, i32* %6
%130 = add nsw i32 %129, 1
store i32 %130, i32* %6
br label %79
131: ; preds = %79
%132 = load i8*, i8** %10
%133 = call i8* @grab_file(i8* %132, i64* %8)
store i8* %133, i8** %9
%134 = load i8*, i8** %9
%135 = icmp ne i8* %134, null
br i1 %135, label %143, label %136
136: ; preds = %131
%137 = load i32, i32* @stderr
%138 = load i8*, i8** %10
%139 = load i32, i32* @errno
%140 = call i8* @strerror(i32 %139)
%141 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i8* %138, i8* %140)
%142 = call i32 @exit(i32 1)
unreachable
143: ; preds = %131
%144 = load i8*, i8** %9
%145 = load i64, i64* %8
%146 = load i8*, i8** %11
%147 = call i64 @init_module(i8* %144, i64 %145, i8* %146)
store i64 %147, i64* %7
%148 = load i64, i64* %7
%149 = icmp ne i64 %148, 0
br i1 %149, label %150, label %158
150: ; preds = %143
%151 = load i32, i32* @stderr
%152 = load i8*, i8** %10
%153 = load i64, i64* %7
%154 = load i32, i32* @errno
%155 = call i32 @moderror(i32 %154)
%156 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), i8* %152, i64 %153, i32 %155)
%157 = call i32 @exit(i32 1)
unreachable
158: ; preds = %143
%159 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [10 x i8] c"--version\00"
@.str.2 = [3 x i8] c"-V\00"
@.str.3 = [13 x i8] c"klibc insmod\00"
@.str.4 = [3 x i8] c"-p\00"
@.str.5 = [3 x i8] c"-s\00"
@.str.6 = [3 x i8] c"-f\00"
@.str.7 = [2 x i8] c"\22\00"
@.str.8 = [2 x i8] c" \00"
@stderr = global i32 0
@.str.9 = [29 x i8] c"insmod: can't read '%s': %s\0A\00"
@errno = global i32 0
@.str.10 = [38 x i8] c"insmod: error inserting '%s': %li %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %1
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %46, label %10
10: ; preds = %2
%11 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = load i8*, i8** %7
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13, %10
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%19 = tail call i32 @exit(i32 0)
unreachable
20: ; preds = %13
%21 = load i8*, i8** %7
%22 = icmp eq i8* %21, null
br i1 %22, label %46, label %23
23: ; preds = %20, %38
%24 = phi i8* [ %41, %38 ], [ %21, %20 ]
%25 = phi i8** [ %40, %38 ], [ %7, %20 ]
%26 = phi i32 [ %39, %38 ], [ %0, %20 ]
%27 = phi i8** [ %25, %38 ], [ %1, %20 ]
%28 = tail call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %38, label %30
30: ; preds = %23
%31 = load i8*, i8** %25
%32 = tail call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i8*, i8** %25
%36 = tail call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %23, %30, %34
%39 = add nsw i32 %26, -1
%40 = getelementptr inbounds i8*, i8** %25, i64 1
%41 = load i8*, i8** %40
%42 = icmp eq i8* %41, null
br i1 %42, label %46, label %23
43: ; preds = %34
%44 = load i8*, i8** %25
%45 = icmp eq i8* %44, null
br i1 %45, label %46, label %50
46: ; preds = %38, %2, %20, %43
%47 = phi i8** [ %27, %43 ], [ %1, %20 ], [ %1, %2 ], [ %25, %38 ]
%48 = phi i32 [ %26, %43 ], [ %0, %20 ], [ %0, %2 ], [ %39, %38 ]
%49 = tail call i32 @print_usage(i8* %6)
br label %50
50: ; preds = %46, %43
%51 = phi i8** [ %47, %46 ], [ %27, %43 ]
%52 = phi i32 [ %48, %46 ], [ %26, %43 ]
%53 = phi i8* [ null, %46 ], [ %44, %43 ]
%54 = icmp sgt i32 %52, 2
br i1 %54, label %55, label %84
55: ; preds = %50
%56 = zext i32 %52 to i64
br label %57
57: ; preds = %55, %80
%58 = phi i64 [ 2, %55 ], [ %82, %80 ]
%59 = phi i8* [ %5, %55 ], [ %66, %80 ]
%60 = tail call i64 @strlen(i8* dereferenceable(1) %59)
%61 = getelementptr inbounds i8*, i8** %51, i64 %58
%62 = load i8*, i8** %61
%63 = tail call i64 @strlen(i8* dereferenceable(1) %62)
%64 = add i64 %60, 4
%65 = add i64 %64, %63
%66 = tail call i8* @realloc(i8* %59, i64 %65)
%67 = load i8*, i8** %61
%68 = tail call i64 @strchr(i8* %67, i8 signext 32)
%69 = icmp eq i64 %68, 0
br i1 %69, label %72, label %70
70: ; preds = %57
%71 = tail call i32 @strcat(i8* %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %72
72: ; preds = %70, %57
%73 = load i8*, i8** %61
%74 = tail call i32 @strcat(i8* %66, i8* %73)
%75 = load i8*, i8** %61
%76 = tail call i64 @strchr(i8* %75, i8 signext 32)
%77 = icmp eq i64 %76, 0
br i1 %77, label %80, label %78
78: ; preds = %72
%79 = tail call i32 @strcat(i8* %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %80
80: ; preds = %78, %72
%81 = tail call i32 @strcat(i8* %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%82 = add nuw nsw i64 %58, 1
%83 = icmp eq i64 %82, %56
br i1 %83, label %84, label %57
84: ; preds = %80, %50
%85 = phi i8* [ %5, %50 ], [ %66, %80 ]
%86 = call i8* @grab_file(i8* %53, i64* %3)
%87 = icmp eq i8* %86, null
br i1 %87, label %88, label %94
88: ; preds = %84
%89 = load i32, i32* @stderr
%90 = load i32, i32* @errno
%91 = call i8* @strerror(i32 %90)
%92 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i8* %53, i8* %91)
%93 = call i32 @exit(i32 1)
unreachable
94: ; preds = %84
%95 = load i64, i64* %3
%96 = call i64 @init_module(i8* %86, i64 %95, i8* %85)
%97 = icmp eq i64 %96, 0
br i1 %97, label %104, label %98
98: ; preds = %94
%99 = load i32, i32* @stderr
%100 = load i32, i32* @errno
%101 = call i32 @moderror(i32 %100)
%102 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), i8* %53, i64 %96, i32 %101)
%103 = call i32 @exit(i32 1)
unreachable
104: ; preds = %94
%105 = call i32 @exit(i32 0)
unreachable
}