#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 int /*<<< orphan*/ buf;

/* Variables and functions */
unsigned long get_kernel_sym(char *);
scalar_t__ kmem_read(unsigned long, unsigned char *, int);
scalar_t__ kmem_read_str(unsigned long, unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int ac, char **av) {
  int rc = -1;
  int row, i, j;
  unsigned char buf[256];
  unsigned long addr;
  int num_syms, num_crcs;
  unsigned long addr_syms, addr_syms_stop;
  unsigned long addr_crcs, addr_crcs_stop;
  char *sym_tables_info[] = {"__start___ksymtab",
                             "__stop___ksymtab",
                             "__start___kcrctab",
                             "__stop___kcrctab",
                             "__start___ksymtab_gpl",
                             "__stop___ksymtab_gpl",
                             "__start___kcrctab_gpl",
                             "__stop___kcrctab_gpl",
                             "__start___ksymtab_gpl_future",
                             "__stop___ksymtab_gpl_future",
                             "__start___kcrctab_gpl_future",
                             "__stop___kcrctab_gpl_future",
                             "__start___ksymtab_unused",
                             "__stop___ksymtab_unused",
                             "__start___kcrctab_unused",
                             "__stop___kcrctab_unused",
                             "__start___ksymtab_unused_gpl",
                             "__stop___ksymtab_unused_gpl",
                             "__start___kcrctab_unused_gpl",
                             "__stop___kcrctab_unused_gpl"};
  for (row = 0; row < 5; ++row) {
    addr_syms = get_kernel_sym(sym_tables_info[row * 4 + 0]);
    addr_syms_stop = get_kernel_sym(sym_tables_info[row * 4 + 1]);
    addr_crcs = get_kernel_sym(sym_tables_info[row * 4 + 2]);
    addr_crcs_stop = get_kernel_sym(sym_tables_info[row * 4 + 3]);
    if (!addr_syms || !addr_syms_stop || !addr_crcs || !addr_crcs_stop) {
      printf("ERROR: resolving symbols %s or %s or %s or %s\n",
             sym_tables_info[row * 4 + 0], sym_tables_info[row * 4 + 1],
             sym_tables_info[row * 4 + 2], sym_tables_info[row * 4 + 3]);
      goto cleanup;
    }
    num_crcs = (addr_crcs_stop - addr_crcs) / 4;
    num_syms = (addr_syms_stop - addr_syms) / 8;
    if (num_crcs != num_syms) {
      printf("something's fucked up, %d symbols but %d crc's\n", num_crcs,
             num_syms);
      goto cleanup;
    }
    for (i = 0; i < num_syms; ++i) {
      unsigned long addr_sym_name, addr_sym, crc;
      if (kmem_read(addr_syms + 8 * i, buf, 8)) {
        printf("ERROR: kmem_read() from address 0x%X\n", addr_syms + 8 * i);
        goto cleanup;
      }
      addr_sym = *(unsigned long *)buf;
      addr_sym_name = *(unsigned long *)(buf + 4);
      if (kmem_read(addr_crcs + 4 * i, buf, 4)) {
        printf("ERROR: kmem_read() from address 0x%X\n", addr_crcs + 4 * i);
        goto cleanup;
      }
      crc = *(unsigned long *)buf;
      if (kmem_read_str(addr_sym_name, buf, sizeof(buf))) {
        printf("ERROR: kmem_read() from address 0x%X\n", addr_sym_name);
        goto cleanup;
      }
      printf("0x%x\t%s\tdummy/path\n", crc, buf);
    }
  }
  rc = 0;
cleanup:
  return rc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
lea    -0x1f0(%rbp),%rdi
lea    0x2c02(%rip),%rsi
mov    $0xa0,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x5,-0x18(%rbp)
jge    146a <main+0x31a>
mov    -0x18(%rbp),%eax
shl    $0x2,%eax
add    $0x0,%eax
cltq
mov    -0x1f0(%rbp,%rax,8),%rdi
ff
call   1060 <get_kernel_sym@plt>
mov    %rax,-0x138(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x2,%eax
add    $0x1,%eax
cltq
mov    -0x1f0(%rbp,%rax,8),%rdi
ff
call   1060 <get_kernel_sym@plt>
mov    %rax,-0x140(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x2,%eax
add    $0x2,%eax
cltq
mov    -0x1f0(%rbp,%rax,8),%rdi
ff
call   1060 <get_kernel_sym@plt>
mov    %rax,-0x148(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x2,%eax
add    $0x3,%eax
cltq
mov    -0x1f0(%rbp,%rax,8),%rdi
ff
call   1060 <get_kernel_sym@plt>
mov    %rax,-0x150(%rbp)
cmpq   $0x0,-0x138(%rbp)
je     124d <main+0xfd>
cmpq   $0x0,-0x140(%rbp)
je     124d <main+0xfd>
cmpq   $0x0,-0x148(%rbp)
je     124d <main+0xfd>
cmpq   $0x0,-0x150(%rbp)
jne    12ac <main+0x15c>
mov    -0x18(%rbp),%eax
shl    $0x2,%eax
add    $0x0,%eax
cltq
mov    -0x1f0(%rbp,%rax,8),%rsi
ff
mov    -0x18(%rbp),%eax
shl    $0x2,%eax
add    $0x1,%eax
cltq
mov    -0x1f0(%rbp,%rax,8),%rdx
ff
mov    -0x18(%rbp),%eax
shl    $0x2,%eax
add    $0x2,%eax
cltq
mov    -0x1f0(%rbp,%rax,8),%rcx
ff
mov    -0x18(%rbp),%eax
shl    $0x2,%eax
add    $0x3,%eax
cltq
mov    -0x1f0(%rbp,%rax,8),%r8
ff
lea    0xf42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1471 <main+0x321>
mov    -0x150(%rbp),%rax
sub    -0x148(%rbp),%rax
shr    $0x2,%rax
mov    %eax,-0x130(%rbp)
mov    -0x140(%rbp),%rax
sub    -0x138(%rbp),%rax
shr    $0x3,%rax
mov    %eax,-0x12c(%rbp)
mov    -0x130(%rbp),%eax
cmp    -0x12c(%rbp),%eax
je     130d <main+0x1bd>
mov    -0x130(%rbp),%esi
mov    -0x12c(%rbp),%edx
lea    0xf10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1471 <main+0x321>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x12c(%rbp),%eax
jge    1457 <main+0x307>
mov    -0x138(%rbp),%rdi
mov    -0x1c(%rbp),%eax
shl    $0x3,%eax
cltq
add    %rax,%rdi
lea    -0x120(%rbp),%rsi
mov    $0x8,%edx
call   1070 <kmem_read@plt>
cmp    $0x0,%rax
je     1375 <main+0x225>
mov    -0x138(%rbp),%rsi
mov    -0x1c(%rbp),%eax
shl    $0x3,%eax
cltq
add    %rax,%rsi
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1471 <main+0x321>
mov    -0x120(%rbp),%rax
mov    %rax,-0x200(%rbp)
mov    -0x11c(%rbp),%rax
mov    %rax,-0x1f8(%rbp)
mov    -0x148(%rbp),%rdi
mov    -0x1c(%rbp),%eax
shl    $0x2,%eax
cltq
add    %rax,%rdi
lea    -0x120(%rbp),%rsi
mov    $0x4,%edx
call   1070 <kmem_read@plt>
cmp    $0x0,%rax
je     13e3 <main+0x293>
mov    -0x148(%rbp),%rsi
mov    -0x1c(%rbp),%eax
shl    $0x2,%eax
cltq
add    %rax,%rsi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1471 <main+0x321>
mov    -0x120(%rbp),%rax
mov    %rax,-0x208(%rbp)
mov    -0x1f8(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1050 <kmem_read_str@plt>
cmp    $0x0,%rax
je     142d <main+0x2dd>
mov    -0x1f8(%rbp),%rsi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1471 <main+0x321>
mov    -0x208(%rbp),%rsi
lea    -0x120(%rbp),%rdx
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1314 <main+0x1c4>
jmp    145c <main+0x30c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118f <main+0x3f>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
lea    0x2c28(%rip),%rbx
xor    %ebp,%ebp
mov    %rbp,0x18(%rsp)
shl    $0x5,%rbp
mov    0x0(%rbp,%rbx,1),%rdi
mov    0x8(%rbp,%rbx,1),%r14
mov    %rdi,(%rsp)
call   1050 <get_kernel_sym@plt>
mov    %rax,%r15
mov    %r14,0x10(%rsp)
mov    %r14,%rdi
call   1050 <get_kernel_sym@plt>
mov    %rax,%r13
mov    0x10(%rbp,%rbx,1),%rdi
mov    %rdi,0x8(%rsp)
call   1050 <get_kernel_sym@plt>
mov    %rax,%r12
mov    0x18(%rbp,%rbx,1),%r14
mov    %r14,%rdi
call   1050 <get_kernel_sym@plt>
test   %r15,%r15
je     12d1 <main+0x191>
test   %r13,%r13
je     12d1 <main+0x191>
test   %r12,%r12
je     12d1 <main+0x191>
test   %rax,%rax
je     12d1 <main+0x191>
sub    %r12,%rax
shr    $0x2,%rax
sub    %r15,%r13
shr    $0x3,%r13
cmp    %r13d,%eax
jne    12f2 <main+0x1b2>
test   %eax,%eax
lea    0x20(%rsp),%r14
jle    1273 <main+0x133>
mov    %eax,%eax
shl    $0x2,%rax
mov    %rax,(%rsp)
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
call   1060 <kmem_read@plt>
test   %rax,%rax
jne    1291 <main+0x151>
mov    0x24(%rsp),%r13
mov    %ebp,%ebx
and    $0xfffffffc,%ebx
add    %r12,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1060 <kmem_read@plt>
test   %rax,%rax
jne    129d <main+0x15d>
mov    0x20(%rsp),%rbx
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x100,%edx
call   1040 <kmem_read_str@plt>
test   %rax,%rax
jne    12a9 <main+0x169>
lea    0x100f(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x4,%rbp
add    $0x8,%r15
cmp    %rbp,(%rsp)
jne    1200 <main+0xc0>
mov    0x18(%rsp),%rbp
add    $0x1,%rbp
cmp    $0x5,%rbp
lea    0x2af9(%rip),%rbx
jne    115a <main+0x1a>
xor    %eax,%eax
jmp    12bf <main+0x17f>
lea    0xfa9(%rip),%rdi
mov    %r15,%rsi
jmp    12b3 <main+0x173>
lea    0xf9d(%rip),%rdi
mov    %rbx,%rsi
jmp    12b3 <main+0x173>
lea    0xf91(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xf0a(%rip),%rdi
mov    (%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    0x8(%rsp),%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1030 <printf@plt>
jmp    12ba <main+0x17a>
lea    0xf18(%rip),%rdi
mov    %eax,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    12ba <main+0x17a>

LLVM IR (-O0):
@.str = [18 x i8] c"__start___ksymtab\00"
@.str.1 = [17 x i8] c"__stop___ksymtab\00"
@.str.2 = [18 x i8] c"__start___kcrctab\00"
@.str.3 = [17 x i8] c"__stop___kcrctab\00"
@.str.4 = [22 x i8] c"__start___ksymtab_gpl\00"
@.str.5 = [21 x i8] c"__stop___ksymtab_gpl\00"
@.str.6 = [22 x i8] c"__start___kcrctab_gpl\00"
@.str.7 = [21 x i8] c"__stop___kcrctab_gpl\00"
@.str.8 = [29 x i8] c"__start___ksymtab_gpl_future\00"
@.str.9 = [28 x i8] c"__stop___ksymtab_gpl_future\00"
@.str.10 = [29 x i8] c"__start___kcrctab_gpl_future\00"
@.str.11 = [28 x i8] c"__stop___kcrctab_gpl_future\00"
@.str.12 = [25 x i8] c"__start___ksymtab_unused\00"
@.str.13 = [24 x i8] c"__stop___ksymtab_unused\00"
@.str.14 = [25 x i8] c"__start___kcrctab_unused\00"
@.str.15 = [24 x i8] c"__stop___kcrctab_unused\00"
@.str.16 = [29 x i8] c"__start___ksymtab_unused_gpl\00"
@.str.17 = [28 x i8] c"__stop___ksymtab_unused_gpl\00"
@.str.18 = [29 x i8] c"__start___kcrctab_unused_gpl\00"
@.str.19 = [28 x i8] c"__stop___kcrctab_unused_gpl\00"
@__const.main.sym_tables_info = [20 x i8*] [i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.19, i32 0, i32 0)]
@.str.20 = [47 x i8] c"ERROR: resolving symbols %s or %s or %s or %s\0A\00"
@.str.21 = [48 x i8] c"something's fucked up, %d symbols but %d crc's\0A\00"
@.str.22 = [38 x i8] c"ERROR: kmem_read() from address 0x%X\0A\00"
@.str.23 = [20 x i8] c"0x%x\09%s\09dummy/path\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [256 x i8]
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca [20 x i8*]
%19 = alloca i64
%20 = alloca i64
%21 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
%22 = bitcast [20 x i8*]* %18 to i8*
store i32 0, i32* %7
br label %23
23: ; preds = %173, %2
%24 = load i32, i32* %7
%25 = icmp slt i32 %24, 5
br i1 %25, label %26, label %176
26: ; preds = %23
%27 = load i32, i32* %7
%28 = mul nsw i32 %27, 4
%29 = add nsw i32 %28, 0
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [20 x i8*], [20 x i8*]* %18, i64 0, i64 %30
%32 = load i8*, i8** %31
%33 = call i64 @get_kernel_sym(i8* %32)
store i64 %33, i64* %14
%34 = load i32, i32* %7
%35 = mul nsw i32 %34, 4
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [20 x i8*], [20 x i8*]* %18, i64 0, i64 %37
%39 = load i8*, i8** %38
%40 = call i64 @get_kernel_sym(i8* %39)
store i64 %40, i64* %15
%41 = load i32, i32* %7
%42 = mul nsw i32 %41, 4
%43 = add nsw i32 %42, 2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [20 x i8*], [20 x i8*]* %18, i64 0, i64 %44
%46 = load i8*, i8** %45
%47 = call i64 @get_kernel_sym(i8* %46)
store i64 %47, i64* %16
%48 = load i32, i32* %7
%49 = mul nsw i32 %48, 4
%50 = add nsw i32 %49, 3
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [20 x i8*], [20 x i8*]* %18, i64 0, i64 %51
%53 = load i8*, i8** %52
%54 = call i64 @get_kernel_sym(i8* %53)
store i64 %54, i64* %17
%55 = load i64, i64* %14
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %66
57: ; preds = %26
%58 = load i64, i64* %15
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %66
60: ; preds = %57
%61 = load i64, i64* %16
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = load i64, i64* %17
%65 = icmp ne i64 %64, 0
br i1 %65, label %92, label %66
66: ; preds = %63, %60, %57, %26
%67 = load i32, i32* %7
%68 = mul nsw i32 %67, 4
%69 = add nsw i32 %68, 0
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [20 x i8*], [20 x i8*]* %18, i64 0, i64 %70
%72 = load i8*, i8** %71
%73 = load i32, i32* %7
%74 = mul nsw i32 %73, 4
%75 = add nsw i32 %74, 1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [20 x i8*], [20 x i8*]* %18, i64 0, i64 %76
%78 = load i8*, i8** %77
%79 = load i32, i32* %7
%80 = mul nsw i32 %79, 4
%81 = add nsw i32 %80, 2
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [20 x i8*], [20 x i8*]* %18, i64 0, i64 %82
%84 = load i8*, i8** %83
%85 = load i32, i32* %7
%86 = mul nsw i32 %85, 4
%87 = add nsw i32 %86, 3
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [20 x i8*], [20 x i8*]* %18, i64 0, i64 %88
%90 = load i8*, i8** %89
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.20, i64 0, i64 0), i8* %72, i8* %78, i8* %84, i8* %90)
br label %177
92: ; preds = %63
%93 = load i64, i64* %17
%94 = load i64, i64* %16
%95 = sub i64 %93, %94
%96 = udiv i64 %95, 4
%97 = trunc i64 %96 to i32
store i32 %97, i32* %13
%98 = load i64, i64* %15
%99 = load i64, i64* %14
%100 = sub i64 %98, %99
%101 = udiv i64 %100, 8
%102 = trunc i64 %101 to i32
store i32 %102, i32* %12
%103 = load i32, i32* %13
%104 = load i32, i32* %12
%105 = icmp ne i32 %103, %104
br i1 %105, label %106, label %110
106: ; preds = %92
%107 = load i32, i32* %13
%108 = load i32, i32* %12
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.21, i64 0, i64 0), i32 %107, i32 %108)
br label %177
110: ; preds = %92
store i32 0, i32* %8
br label %111
111: ; preds = %169, %110
%112 = load i32, i32* %8
%113 = load i32, i32* %12
%114 = icmp slt i32 %112, %113
br i1 %114, label %115, label %172
115: ; preds = %111
%116 = load i64, i64* %14
%117 = load i32, i32* %8
%118 = mul nsw i32 8, %117
%119 = sext i32 %118 to i64
%120 = add i64 %116, %119
%121 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%122 = call i64 @kmem_read(i64 %120, i8* %121, i32 8)
%123 = icmp ne i64 %122, 0
br i1 %123, label %124, label %131
124: ; preds = %115
%125 = load i64, i64* %14
%126 = load i32, i32* %8
%127 = mul nsw i32 8, %126
%128 = sext i32 %127 to i64
%129 = add i64 %125, %128
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.22, i64 0, i64 0), i64 %129)
br label %177
131: ; preds = %115
%132 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%133 = bitcast i8* %132 to i64*
%134 = load i64, i64* %133
store i64 %134, i64* %20
%135 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%136 = getelementptr inbounds i8, i8* %135, i64 4
%137 = bitcast i8* %136 to i64*
%138 = load i64, i64* %137
store i64 %138, i64* %19
%139 = load i64, i64* %16
%140 = load i32, i32* %8
%141 = mul nsw i32 4, %140
%142 = sext i32 %141 to i64
%143 = add i64 %139, %142
%144 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%145 = call i64 @kmem_read(i64 %143, i8* %144, i32 4)
%146 = icmp ne i64 %145, 0
br i1 %146, label %147, label %154
147: ; preds = %131
%148 = load i64, i64* %16
%149 = load i32, i32* %8
%150 = mul nsw i32 4, %149
%151 = sext i32 %150 to i64
%152 = add i64 %148, %151
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.22, i64 0, i64 0), i64 %152)
br label %177
154: ; preds = %131
%155 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%156 = bitcast i8* %155 to i64*
%157 = load i64, i64* %156
store i64 %157, i64* %21
%158 = load i64, i64* %19
%159 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%160 = call i64 @kmem_read_str(i64 %158, i8* %159, i32 256)
%161 = icmp ne i64 %160, 0
br i1 %161, label %162, label %165
162: ; preds = %154
%163 = load i64, i64* %19
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.22, i64 0, i64 0), i64 %163)
br label %177
165: ; preds = %154
%166 = load i64, i64* %21
%167 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.23, i64 0, i64 0), i64 %166, i8* %167)
br label %169
169: ; preds = %165
%170 = load i32, i32* %8
%171 = add nsw i32 %170, 1
store i32 %171, i32* %8
br label %111
172: ; preds = %111
br label %173
173: ; preds = %172
%174 = load i32, i32* %7
%175 = add nsw i32 %174, 1
store i32 %175, i32* %7
br label %23
176: ; preds = %23
store i32 0, i32* %6
br label %177
177: ; preds = %176, %162, %147, %124, %106, %66
%178 = load i32, i32* %6
ret i32 %178
}

LLVM IR (-O2):
@.str = [18 x i8] c"__start___ksymtab\00"
@.str.1 = [17 x i8] c"__stop___ksymtab\00"
@.str.2 = [18 x i8] c"__start___kcrctab\00"
@.str.3 = [17 x i8] c"__stop___kcrctab\00"
@.str.4 = [22 x i8] c"__start___ksymtab_gpl\00"
@.str.5 = [21 x i8] c"__stop___ksymtab_gpl\00"
@.str.6 = [22 x i8] c"__start___kcrctab_gpl\00"
@.str.7 = [21 x i8] c"__stop___kcrctab_gpl\00"
@.str.8 = [29 x i8] c"__start___ksymtab_gpl_future\00"
@.str.9 = [28 x i8] c"__stop___ksymtab_gpl_future\00"
@.str.10 = [29 x i8] c"__start___kcrctab_gpl_future\00"
@.str.11 = [28 x i8] c"__stop___kcrctab_gpl_future\00"
@.str.12 = [25 x i8] c"__start___ksymtab_unused\00"
@.str.13 = [24 x i8] c"__stop___ksymtab_unused\00"
@.str.14 = [25 x i8] c"__start___kcrctab_unused\00"
@.str.15 = [24 x i8] c"__stop___kcrctab_unused\00"
@.str.16 = [29 x i8] c"__start___ksymtab_unused_gpl\00"
@.str.17 = [28 x i8] c"__stop___ksymtab_unused_gpl\00"
@.str.18 = [29 x i8] c"__start___kcrctab_unused_gpl\00"
@.str.19 = [28 x i8] c"__stop___kcrctab_unused_gpl\00"
@__const.main.sym_tables_info = [20 x i8*] [i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.19, i32 0, i32 0)]
@.str.20 = [47 x i8] c"ERROR: resolving symbols %s or %s or %s or %s\0A\00"
@.str.21 = [48 x i8] c"something's fucked up, %d symbols but %d crc's\0A\00"
@.str.22 = [38 x i8] c"ERROR: kmem_read() from address 0x%X\0A\00"
@.str.23 = [20 x i8] c"0x%x\09%s\09dummy/path\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 4
%6 = bitcast i8* %5 to i64*
%7 = bitcast [256 x i8]* %3 to i64*
br label %8
8: ; preds = %2, %78
%9 = phi i64 [ 0, %2 ], [ %79, %78 ]
%10 = shl nuw nsw i64 %9, 2
%11 = getelementptr inbounds [20 x i8*], [20 x i8*]* @__const.main.sym_tables_info, i64 0, i64 %10
%12 = load i8*, i8** %11
%13 = call i64 @get_kernel_sym(i8* %12)
%14 = or i64 %10, 1
%15 = getelementptr inbounds [20 x i8*], [20 x i8*]* @__const.main.sym_tables_info, i64 0, i64 %14
%16 = load i8*, i8** %15
%17 = call i64 @get_kernel_sym(i8* %16)
%18 = or i64 %10, 2
%19 = getelementptr inbounds [20 x i8*], [20 x i8*]* @__const.main.sym_tables_info, i64 0, i64 %18
%20 = load i8*, i8** %19
%21 = call i64 @get_kernel_sym(i8* %20)
%22 = or i64 %10, 3
%23 = getelementptr inbounds [20 x i8*], [20 x i8*]* @__const.main.sym_tables_info, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = call i64 @get_kernel_sym(i8* %24)
%26 = icmp ne i64 %13, 0
%27 = icmp ne i64 %17, 0
%28 = select i1 %26, i1 %27, i1 false
%29 = icmp ne i64 %21, 0
%30 = select i1 %28, i1 %29, i1 false
%31 = icmp ne i64 %25, 0
%32 = select i1 %30, i1 %31, i1 false
br i1 %32, label %35, label %33
33: ; preds = %8
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.20, i64 0, i64 0), i8* %12, i8* %16, i8* %20, i8* %24)
br label %81
35: ; preds = %8
%36 = sub i64 %25, %21
%37 = lshr i64 %36, 2
%38 = trunc i64 %37 to i32
%39 = sub i64 %17, %13
%40 = lshr i64 %39, 3
%41 = trunc i64 %40 to i32
%42 = icmp eq i32 %38, %41
br i1 %42, label %43, label %47
43: ; preds = %35
%44 = icmp sgt i32 %38, 0
br i1 %44, label %45, label %78
45: ; preds = %43
%46 = and i64 %37, 4294967295
br label %51
47: ; preds = %35
%48 = trunc i64 %37 to i32
%49 = trunc i64 %40 to i32
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.21, i64 0, i64 0), i32 %48, i32 %49)
br label %81
51: ; preds = %45, %74
%52 = phi i64 [ 0, %45 ], [ %76, %74 ]
%53 = shl nsw i64 %52, 3
%54 = add i64 %13, %53
%55 = call i64 @kmem_read(i64 %54, i8* %4, i32 8)
%56 = icmp eq i64 %55, 0
br i1 %56, label %59, label %57
57: ; preds = %51
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.22, i64 0, i64 0), i64 %54)
br label %81
59: ; preds = %51
%60 = load i64, i64* %6
%61 = shl i64 %52, 2
%62 = and i64 %61, 4294967292
%63 = add i64 %21, %62
%64 = call i64 @kmem_read(i64 %63, i8* %4, i32 4)
%65 = icmp eq i64 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %59
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.22, i64 0, i64 0), i64 %63)
br label %81
68: ; preds = %59
%69 = load i64, i64* %7
%70 = call i64 @kmem_read_str(i64 %60, i8* %4, i32 256)
%71 = icmp eq i64 %70, 0
br i1 %71, label %74, label %72
72: ; preds = %68
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.22, i64 0, i64 0), i64 %60)
br label %81
74: ; preds = %68
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.23, i64 0, i64 0), i64 %69, i8* %4)
%76 = add nuw nsw i64 %52, 1
%77 = icmp eq i64 %76, %46
br i1 %77, label %78, label %51
78: ; preds = %74, %43
%79 = add nuw nsw i64 %9, 1
%80 = icmp eq i64 %79, 5
br i1 %80, label %81, label %8
81: ; preds = %78, %72, %66, %57, %33, %47
%82 = phi i32 [ -1, %47 ], [ -1, %33 ], [ -1, %57 ], [ -1, %66 ], [ -1, %72 ], [ 0, %78 ]
ret i32 %82
}