#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 */
struct utsname {
  char *release;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, void *, char *);
int fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, int);
char *strrchr(char *, char);
scalar_t__ strstr(char *, char *);
int /*<<< orphan*/ uname(struct utsname *);
unsigned long get_kernel_sym(char *name) {
  FILE *f;
  unsigned long addr;
  char dummy;
  char sname[512];
  struct utsname ver;
  int ret;
  int rep = 0;
  int oldstyle = 0;
  f = fopen("/proc/kallsyms", "r");
  if (f == NULL) {
    f = fopen("/proc/ksyms", "r");
    if (f == NULL)
      goto fallback;
    oldstyle = 1;
  }
repeat:
  ret = 0;
  while (ret != EOF) {
    if (!oldstyle)
      ret = fscanf(f, "%p %c %s\n", (void **)&addr, &dummy, sname);
    else {
      ret = fscanf(f, "%p %s\n", (void **)&addr, sname);
      if (ret == 2) {
        char *p;
        if (strstr(sname, "_O/") || strstr(sname, "_S."))
          continue;
        p = strrchr(sname, '_');
        if (p > ((char *)sname + 5) && !strncmp(p - 3, "smp", 3)) {
          p = p - 4;
          while (p > (char *)sname && *(p - 1) == '_')
            p--;
          *p = '\0';
        }
      }
    }
    if (ret == 0) {
      fscanf(f, "%s\n", sname);
      continue;
    }
    if (!strcmp(name, sname)) {
      fprintf(stdout, "[+] Resolved %s to %p%s\n", name, (void *)addr,
              rep ? " (via System.map)" : "");
      fclose(f);
      return addr;
    }
  }
  fclose(f);
  if (rep)
    return 0;
fallback:
  uname(&ver);
  if (strncmp(ver.release, "2.6", 3))
    oldstyle = 1;
  sprintf(sname, "/boot/System.map-%s", ver.release);
  f = fopen(sname, "r");
  if (f == NULL)
    return 0;
  rep = 1;
  goto repeat;
}


x86 assembly (clang, -O0):
<get_kernel_sym>:
push   %rbp
mov    %rsp,%rbp
sub    $0x260,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x240(%rbp)
movl   $0x0,-0x244(%rbp)
lea    0xe36(%rip),%rdi
lea    0xe3e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1216 <get_kernel_sym+0x76>
lea    0xe25(%rip),%rdi
lea    0xe1c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    120c <get_kernel_sym+0x6c>
jmp    1480 <get_kernel_sym+0x2e0>
movl   $0x1,-0x244(%rbp)
jmp    121b <get_kernel_sym+0x7b>
movl   $0x0,-0x23c(%rbp)
mov    -0x23c(%rbp),%eax
mov    0x2db6(%rip),%rcx
cmp    (%rcx),%eax
je     1458 <get_kernel_sym+0x2b8>
cmpl   $0x0,-0x244(%rbp)
jne    1273 <get_kernel_sym+0xd3>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    -0x230(%rbp),%r8
lea    0xdc0(%rip),%rsi
lea    -0x21(%rbp),%rcx
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    %eax,-0x23c(%rbp)
jmp    13c1 <get_kernel_sym+0x221>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    -0x230(%rbp),%rcx
lea    0xd9e(%rip),%rsi
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    %eax,-0x23c(%rbp)
cmpl   $0x2,-0x23c(%rbp)
jne    13bc <get_kernel_sym+0x21c>
lea    -0x230(%rbp),%rdi
lea    0xd7d(%rip),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
jne    12dd <get_kernel_sym+0x13d>
lea    -0x230(%rbp),%rdi
lea    0xd64(%rip),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
je     12e2 <get_kernel_sym+0x142>
jmp    1225 <get_kernel_sym+0x85>
lea    -0x230(%rbp),%rdi
mov    $0x5f,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x250(%rbp)
mov    -0x250(%rbp),%rax
lea    -0x230(%rbp),%rcx
add    $0x5,%rcx
cmp    %rcx,%rax
jbe    13b7 <get_kernel_sym+0x217>
mov    -0x250(%rbp),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xd0f(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    13b7 <get_kernel_sym+0x217>
mov    -0x250(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x250(%rbp)
mov    -0x250(%rbp),%rcx
lea    -0x230(%rbp),%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x251(%rbp)
jbe    1383 <get_kernel_sym+0x1e3>
mov    -0x250(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0x251(%rbp)
mov    -0x251(%rbp),%al
test   $0x1,%al
jne    1396 <get_kernel_sym+0x1f6>
jmp    13ad <get_kernel_sym+0x20d>
mov    -0x250(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x250(%rbp)
jmp    134d <get_kernel_sym+0x1ad>
mov    -0x250(%rbp),%rax
movb   $0x0,(%rax)
jmp    13bc <get_kernel_sym+0x21c>
jmp    13c1 <get_kernel_sym+0x221>
cmpl   $0x0,-0x23c(%rbp)
jne    13ec <get_kernel_sym+0x24c>
mov    -0x18(%rbp),%rdi
lea    -0x230(%rbp),%rdx
lea    0xc43(%rip),%rsi
mov    $0x0,%al
call   1070 <fscanf@plt>
jmp    1225 <get_kernel_sym+0x85>
mov    -0x10(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1453 <get_kernel_sym+0x2b3>
mov    0x2bcc(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x240(%rbp),%esi
lea    0xc03(%rip),%r8
lea    0xc29(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%r8
lea    0xc02(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1510 <get_kernel_sym+0x370>
jmp    1225 <get_kernel_sym+0x85>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x0,-0x240(%rbp)
je     147b <get_kernel_sym+0x2db>
movq   $0x0,-0x8(%rbp)
jmp    1510 <get_kernel_sym+0x370>
jmp    1480 <get_kernel_sym+0x2e0>
lea    -0x238(%rbp),%rdi
call   1060 <uname@plt>
mov    -0x238(%rbp),%rdi
lea    0xbcb(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     14b8 <get_kernel_sym+0x318>
movl   $0x1,-0x244(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x238(%rbp),%rdx
lea    0xb9c(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x230(%rbp),%rdi
lea    0xb2f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1501 <get_kernel_sym+0x361>
movq   $0x0,-0x8(%rbp)
jmp    1510 <get_kernel_sym+0x370>
movl   $0x1,-0x240(%rbp)
jmp    121b <get_kernel_sym+0x7b>
mov    -0x8(%rbp),%rax
add    $0x260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_kernel_sym>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    %rdi,%r14
lea    0xe45(%rip),%rdi
lea    0xe4d(%rip),%rsi
call   10a0 <fopen@plt>
xor    %r15d,%r15d
mov    $0x1,%bpl
test   %rax,%rax
mov    %r14,0x10(%rsp)
je     11dc <get_kernel_sym+0x3c>
mov    %rax,%rbx
jmp    1204 <get_kernel_sym+0x64>
lea    0xe2e(%rip),%rdi
lea    0xe25(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
mov    $0x1,%r15d
xor    %r12d,%r12d
test   %rax,%rax
je     136b <get_kernel_sym+0x1cb>
mov    %rbp,0x20(%rsp)
mov    0x2dd8(%rip),%r12
cmpl   $0x0,(%r12)
je     1353 <get_kernel_sym+0x1b3>
lea    0x30(%rsp),%rbp
jmp    124d <get_kernel_sym+0xad>
movb   $0x0,(%rax)
mov    0x10(%rsp),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
je     13d6 <get_kernel_sym+0x236>
cmp    (%r12),%r13d
je     1353 <get_kernel_sym+0x1b3>
mov    %rbx,%rdi
test   %r15d,%r15d
je     1310 <get_kernel_sym+0x170>
lea    0xdc7(%rip),%rsi
lea    0x18(%rsp),%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    %eax,%r13d
cmp    $0x2,%eax
jne    132e <get_kernel_sym+0x18e>
mov    %rbp,%rdi
lea    0xda9(%rip),%rsi
call   10c0 <strstr@plt>
mov    $0x2,%r13d
test   %rax,%rax
jne    1243 <get_kernel_sym+0xa3>
mov    %rbp,%rdi
lea    0xd93(%rip),%rsi
call   10c0 <strstr@plt>
test   %rax,%rax
jne    1243 <get_kernel_sym+0xa3>
mov    %rbp,%rdi
mov    $0x5f,%esi
call   1050 <strrchr@plt>
mov    %rax,%r14
mov    $0x2,%r13d
lea    0x35(%rsp),%rax
cmp    %rax,%r14
jbe    1225 <get_kernel_sym+0x85>
lea    -0x3(%r14),%rdi
lea    0xd5e(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1225 <get_kernel_sym+0x85>
add    $0xfffffffffffffffc,%r14
nop
mov    %r14,%rax
cmp    %rbp,%r14
jbe    1222 <get_kernel_sym+0x82>
lea    -0x1(%rax),%r14
cmpb   $0x5f,-0x1(%rax)
je     12f0 <get_kernel_sym+0x150>
jmp    1222 <get_kernel_sym+0x82>
nopl   0x0(%rax,%rax,1)
lea    0xd06(%rip),%rsi
lea    0x18(%rsp),%rdx
lea    0xf(%rsp),%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    %eax,%r13d
test   %r13d,%r13d
jne    1230 <get_kernel_sym+0x90>
xor    %r13d,%r13d
mov    %rbx,%rdi
lea    0xcdf(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1070 <fscanf@plt>
jmp    1243 <get_kernel_sym+0xa3>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
mov    %r15d,%r12d
cmpb   $0x0,0x20(%rsp)
je     1417 <get_kernel_sym+0x277>
lea    0x28(%rsp),%rdi
call   1060 <uname@plt>
mov    0x28(%rsp),%rbx
lea    0xce4(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    $0x1,%r15d
cmove  %r12d,%r15d
lea    0xcc7(%rip),%rsi
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
call   10b0 <sprintf@plt>
lea    0xc56(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <fopen@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
mov    $0x0,%eax
test   %rbx,%rbx
jne    1204 <get_kernel_sym+0x64>
jmp    1417 <get_kernel_sym+0x277>
mov    0x2bfb(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rsp),%rcx
lea    0xc3b(%rip),%rax
lea    0xc61(%rip),%r8
cmpb   $0x0,0x20(%rsp)
cmovne %rax,%r8
lea    0xc38(%rip),%rsi
mov    %r14,%rdx
call   1090 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x18(%rsp),%rax
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.utsname = type { i8* }
@.str = [15 x i8] c"/proc/kallsyms\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"/proc/ksyms\00"
@EOF = global i32 0
@.str.3 = [10 x i8] c"%p %c %s\0A\00"
@.str.4 = [7 x i8] c"%p %s\0A\00"
@.str.5 = [4 x i8] c"_O/\00"
@.str.6 = [4 x i8] c"_S.\00"
@.str.7 = [4 x i8] c"smp\00"
@.str.8 = [4 x i8] c"%s\0A\00"
@stdout = global i32 0
@.str.9 = [25 x i8] c"[+] Resolved %s to %p%s\0A\00"
@.str.10 = [18 x i8] c" (via System.map)\00"
@.str.11 = [1 x i8] zeroinitializer
@.str.12 = [4 x i8] c"2.6\00"
@.str.13 = [20 x i8] c"/boot/System.map-%s\00"
define i64 @get_kernel_sym(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i8
%7 = alloca [512 x i8]
%8 = alloca %struct.utsname
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %10
store i32 0, i32* %11
%13 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %4
%14 = load i32*, i32** %4
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %22
16: ; preds = %1
%17 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %4
%18 = load i32*, i32** %4
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %21
20: ; preds = %16
br label %119
21: ; preds = %16
store i32 1, i32* %11
br label %22
22: ; preds = %21, %1
br label %23
23: ; preds = %136, %22
store i32 0, i32* %9
br label %24
24: ; preds = %111, %89, %51, %23
%25 = load i32, i32* %9
%26 = load i32, i32* @EOF
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %112
28: ; preds = %24
%29 = load i32, i32* %11
%30 = icmp ne i32 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %28
%32 = load i32*, i32** %4
%33 = bitcast i64* %5 to i8**
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%35 = call i32 (i32*, i8*, ...) @fscanf(i32* %32, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %33, i8* %6, i8* %34)
store i32 %35, i32* %9
br label %86
36: ; preds = %28
%37 = load i32*, i32** %4
%38 = bitcast i64* %5 to i8**
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%40 = call i32 (i32*, i8*, ...) @fscanf(i32* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %38, i8* %39)
store i32 %40, i32* %9
%41 = load i32, i32* %9
%42 = icmp eq i32 %41, 2
br i1 %42, label %43, label %85
43: ; preds = %36
%44 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%45 = call i64 @strstr(i8* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%46 = icmp ne i64 %45, 0
br i1 %46, label %51, label %47
47: ; preds = %43
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%49 = call i64 @strstr(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %47, %43
br label %24
52: ; preds = %47
%53 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%54 = call i8* @strrchr(i8* %53, i8 signext 95)
store i8* %54, i8** %12
%55 = load i8*, i8** %12
%56 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%57 = getelementptr inbounds i8, i8* %56, i64 5
%58 = icmp ugt i8* %55, %57
br i1 %58, label %59, label %84
59: ; preds = %52
%60 = load i8*, i8** %12
%61 = getelementptr inbounds i8, i8* %60, i64 -3
%62 = call i64 @strncmp(i8* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
%63 = icmp ne i64 %62, 0
br i1 %63, label %84, label %64
64: ; preds = %59
%65 = load i8*, i8** %12
%66 = getelementptr inbounds i8, i8* %65, i64 -4
store i8* %66, i8** %12
br label %67
67: ; preds = %79, %64
%68 = load i8*, i8** %12
%69 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%70 = icmp ugt i8* %68, %69
br i1 %70, label %71, label %77
71: ; preds = %67
%72 = load i8*, i8** %12
%73 = getelementptr inbounds i8, i8* %72, i64 -1
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 95
br label %77
77: ; preds = %71, %67
%78 = phi i1 [ false, %67 ], [ %76, %71 ]
br i1 %78, label %79, label %82
79: ; preds = %77
%80 = load i8*, i8** %12
%81 = getelementptr inbounds i8, i8* %80, i32 -1
store i8* %81, i8** %12
br label %67
82: ; preds = %77
%83 = load i8*, i8** %12
store i8 0, i8* %83
br label %84
84: ; preds = %82, %59, %52
br label %85
85: ; preds = %84, %36
br label %86
86: ; preds = %85, %31
%87 = load i32, i32* %9
%88 = icmp eq i32 %87, 0
br i1 %88, label %89, label %93
89: ; preds = %86
%90 = load i32*, i32** %4
%91 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%92 = call i32 (i32*, i8*, ...) @fscanf(i32* %90, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %91)
br label %24
93: ; preds = %86
%94 = load i8*, i8** %3
%95 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%96 = call i32 @strcmp(i8* %94, i8* %95)
%97 = icmp ne i32 %96, 0
br i1 %97, label %111, label %98
98: ; preds = %93
%99 = load i32, i32* @stdout
%100 = load i8*, i8** %3
%101 = load i64, i64* %5
%102 = inttoptr i64 %101 to i8*
%103 = load i32, i32* %10
%104 = icmp ne i32 %103, 0
%105 = zext i1 %104 to i64
%106 = select i1 %104, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.11, i64 0, i64 0)
%107 = call i32 @fprintf(i32 %99, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8* %100, i8* %102, i8* %106)
%108 = load i32*, i32** %4
%109 = call i32 @fclose(i32* %108)
%110 = load i64, i64* %5
store i64 %110, i64* %2
br label %137
111: ; preds = %93
br label %24
112: ; preds = %24
%113 = load i32*, i32** %4
%114 = call i32 @fclose(i32* %113)
%115 = load i32, i32* %10
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %118
117: ; preds = %112
store i64 0, i64* %2
br label %137
118: ; preds = %112
br label %119
119: ; preds = %118, %20
%120 = call i32 @uname(%struct.utsname* %8)
%121 = getelementptr inbounds %struct.utsname, %struct.utsname* %8, i32 0, i32 0
%122 = load i8*, i8** %121
%123 = call i64 @strncmp(i8* %122, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i32 3)
%124 = icmp ne i64 %123, 0
br i1 %124, label %125, label %126
125: ; preds = %119
store i32 1, i32* %11
br label %126
126: ; preds = %125, %119
%127 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%128 = getelementptr inbounds %struct.utsname, %struct.utsname* %8, i32 0, i32 0
%129 = load i8*, i8** %128
%130 = call i32 @sprintf(i8* %127, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* %129)
%131 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%132 = call i32* @fopen(i8* %131, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %132, i32** %4
%133 = load i32*, i32** %4
%134 = icmp eq i32* %133, null
br i1 %134, label %135, label %136
135: ; preds = %126
store i64 0, i64* %2
br label %137
136: ; preds = %126
store i32 1, i32* %10
br label %23
137: ; preds = %135, %117, %98
%138 = load i64, i64* %2
ret i64 %138
}

LLVM IR (-O2):
%struct.utsname = type { i8* }
@.str = [15 x i8] c"/proc/kallsyms\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"/proc/ksyms\00"
@EOF = global i32 0
@.str.3 = [10 x i8] c"%p %c %s\0A\00"
@.str.4 = [7 x i8] c"%p %s\0A\00"
@.str.5 = [4 x i8] c"_O/\00"
@.str.6 = [4 x i8] c"_S.\00"
@.str.7 = [4 x i8] c"smp\00"
@.str.8 = [4 x i8] c"%s\0A\00"
@stdout = global i32 0
@.str.9 = [25 x i8] c"[+] Resolved %s to %p%s\0A\00"
@.str.10 = [18 x i8] c" (via System.map)\00"
@.str.11 = [1 x i8] zeroinitializer
@.str.12 = [4 x i8] c"2.6\00"
@.str.13 = [20 x i8] c"/boot/System.map-%s\00"
define i64 @get_kernel_sym(i8* %0) {
%2 = alloca i64
%3 = alloca i8
%4 = alloca [512 x i8]
%5 = alloca %struct.utsname
%6 = bitcast i64* %2 to i8*
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = bitcast %struct.utsname* %5 to i8*
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %75, label %14
14: ; preds = %75, %11, %1
%15 = phi i32* [ %9, %1 ], [ %12, %11 ], [ %84, %75 ]
%16 = phi i1 [ true, %1 ], [ true, %11 ], [ false, %75 ]
%17 = phi i32 [ 0, %1 ], [ 1, %11 ], [ %82, %75 ]
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %18, 0
br i1 %19, label %73, label %20
20: ; preds = %14
%21 = icmp eq i32 %17, 0
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 5
br label %23
23: ; preds = %20, %57
br i1 %21, label %24, label %26
24: ; preds = %23
%25 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64* %2, i8* %3, i8* %7)
br label %52
26: ; preds = %23
%27 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64* %2, i8* %7)
%28 = icmp eq i32 %27, 2
br i1 %28, label %29, label %52
29: ; preds = %26
%30 = call i64 @strstr(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %57
32: ; preds = %29
%33 = call i64 @strstr(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %57
35: ; preds = %32
%36 = call i8* @strrchr(i8* %7, i8 signext 95)
%37 = icmp ugt i8* %36, %22
br i1 %37, label %38, label %61
38: ; preds = %35
%39 = getelementptr inbounds i8, i8* %36, i64 -3
%40 = call i64 @strncmp(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %61
42: ; preds = %38
%43 = getelementptr inbounds i8, i8* %36, i64 -4
br label %44
44: ; preds = %47, %42
%45 = phi i8* [ %43, %42 ], [ %48, %47 ]
%46 = icmp ugt i8* %45, %7
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = getelementptr inbounds i8, i8* %45, i64 -1
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 95
br i1 %50, label %44, label %51
51: ; preds = %44, %47
store i8 0, i8* %45
br label %61
52: ; preds = %26, %24
%53 = phi i32 [ %27, %26 ], [ %25, %24 ]
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %61
55: ; preds = %52
%56 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %7)
br label %57
57: ; preds = %32, %29, %55, %61
%58 = phi i32 [ 0, %55 ], [ %62, %61 ], [ 2, %29 ], [ 2, %32 ]
%59 = load i32, i32* @EOF
%60 = icmp eq i32 %58, %59
br i1 %60, label %73, label %23
61: ; preds = %51, %38, %35, %52
%62 = phi i32 [ %53, %52 ], [ 2, %35 ], [ 2, %38 ], [ 2, %51 ]
%63 = call i32 @strcmp(i8* dereferenceable(1) %0, i8* %7)
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %57
65: ; preds = %61
%66 = load i32, i32* @stdout
%67 = load i64, i64* %2
%68 = inttoptr i64 %67 to i8*
%69 = select i1 %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0)
%70 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8* %0, i8* %68, i8* %69)
%71 = call i32 @fclose(i32* %15)
%72 = load i64, i64* %2
br label %86
73: ; preds = %57, %14
%74 = call i32 @fclose(i32* %15)
br i1 %16, label %75, label %86
75: ; preds = %73, %11
%76 = phi i32 [ 0, %11 ], [ %17, %73 ]
%77 = call i32 @uname(%struct.utsname* %5)
%78 = getelementptr inbounds %struct.utsname, %struct.utsname* %5, i64 0, i32 0
%79 = load i8*, i8** %78
%80 = call i64 @strncmp(i8* %79, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i32 3)
%81 = icmp eq i64 %80, 0
%82 = select i1 %81, i32 %76, i32 1
%83 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* %79)
%84 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%85 = icmp eq i32* %84, null
br i1 %85, label %86, label %14
86: ; preds = %75, %73, %65
%87 = phi i64 [ %72, %65 ], [ 0, %73 ], [ 0, %75 ]
ret i64 %87
}