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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int sscanf(char *, char *, int *, char *);
int /*<<< orphan*/ stderr;
char *strdup(char *);
void rtnl_tab_initialize(char *file, char **tab, int size) {
  static char buf[512];
  FILE *fp;
  fp = fopen(file, "r");
  if (!fp)
    return;
  while (fgets(buf, sizeof(buf), fp)) {
    char *p = buf;
    int id;
    static char namebuf[512];
    while (*p == ' ' || *p == '\t')
      p++;
    if (*p == '#' || *p == '\n' || *p == 0)
      continue;
    if (sscanf(p, "0x%x %s\n", &id, namebuf) != 2 &&
        sscanf(p, "0x%x %s #", &id, namebuf) != 2 &&
        sscanf(p, "%d %s\n", &id, namebuf) != 2 &&
        sscanf(p, "%d %s #", &id, namebuf) != 2) {
      fprintf(stderr, "Database %s is corrupted at %s\n", file, p);
      return;
    }
    if (id < 0 || id > size)
      continue;
    tab[id] = strdup(namebuf);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<rtnl_tab_initialize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1197 <rtnl_tab_initialize+0x37>
jmp    1337 <rtnl_tab_initialize+0x1d7>
jmp    119c <rtnl_tab_initialize+0x3c>
mov    -0x20(%rbp),%rdx
lea    0x2eb9(%rip),%rdi
mov    $0x200,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     132e <rtnl_tab_initialize+0x1ce>
lea    0x2e9e(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x2d(%rbp)
je     11eb <rtnl_tab_initialize+0x8b>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    11fb <rtnl_tab_initialize+0x9b>
jmp    120c <rtnl_tab_initialize+0xac>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11c6 <rtnl_tab_initialize+0x66>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     123c <rtnl_tab_initialize+0xdc>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     123c <rtnl_tab_initialize+0xdc>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1241 <rtnl_tab_initialize+0xe1>
jmp    119c <rtnl_tab_initialize+0x3c>
mov    -0x28(%rbp),%rdi
lea    0xdb6(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    0x3009(%rip),%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
je     12f3 <rtnl_tab_initialize+0x193>
mov    -0x28(%rbp),%rdi
lea    0xd9b(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    0x2fe5(%rip),%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
je     12f3 <rtnl_tab_initialize+0x193>
mov    -0x28(%rbp),%rdi
lea    0xd81(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    0x2fc1(%rip),%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
je     12f3 <rtnl_tab_initialize+0x193>
mov    -0x28(%rbp),%rdi
lea    0xd64(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    0x2f9d(%rip),%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
je     12f3 <rtnl_tab_initialize+0x193>
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xd3b(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1337 <rtnl_tab_initialize+0x1d7>
cmpl   $0x0,-0x2c(%rbp)
jl     1309 <rtnl_tab_initialize+0x1a9>
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    130e <rtnl_tab_initialize+0x1ae>
jmp    119c <rtnl_tab_initialize+0x3c>
lea    0x2f4b(%rip),%rdi
call   1080 <strdup@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    119c <rtnl_tab_initialize+0x3c>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtnl_tab_initialize>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0x4(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,%rbp
lea    0xe7f(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12d3 <rtnl_tab_initialize+0x173>
mov    %rax,%rbx
mov    %rbp,0x8(%rsp)
lea    0x2ec2(%rip),%r15
mov    %r15,%rdi
mov    $0x200,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     12cb <rtnl_tab_initialize+0x16b>
lea    0x30a2(%rip),%r13
mov    %rsp,%r14
movabs $0x100000200,%r12
jmp    1203 <rtnl_tab_initialize+0xa3>
nopl   (%rax)
movabs $0x800000401,%rcx
bt     %rax,%rcx
jae    1230 <rtnl_tab_initialize+0xd0>
mov    %r15,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
lea    0x3069(%rip),%r13
mov    %rsp,%r14
test   %rax,%rax
je     12cb <rtnl_tab_initialize+0x16b>
mov    %r15,%rbp
cs nopw 0x0(%rax,%rax,1)
movzbl 0x0(%rbp),%eax
cmp    $0x23,%rax
ja     1230 <rtnl_tab_initialize+0xd0>
bt     %rax,%r12
jae    11d0 <rtnl_tab_initialize+0x70>
add    $0x1,%rbp
jmp    1210 <rtnl_tab_initialize+0xb0>
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
lea    0xdc8(%rip),%rsi
mov    %r14,%rdx
mov    %r13,%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
je     12a0 <rtnl_tab_initialize+0x140>
mov    %rbp,%rdi
lea    0xdb7(%rip),%rsi
mov    %r14,%rdx
mov    %r13,%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
je     12a0 <rtnl_tab_initialize+0x140>
mov    %rbp,%rdi
lea    0xda7(%rip),%rsi
mov    %r14,%rdx
mov    %r13,%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
je     12a0 <rtnl_tab_initialize+0x140>
mov    %rbp,%rdi
lea    0xd94(%rip),%rsi
mov    %r14,%rdx
mov    %r13,%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
jne    12e2 <rtnl_tab_initialize+0x182>
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%ebp
test   %ebp,%ebp
js     11e0 <rtnl_tab_initialize+0x80>
cmp    0x4(%rsp),%ebp
jg     11e0 <rtnl_tab_initialize+0x80>
mov    %r13,%rdi
call   1080 <strdup@plt>
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx,%rbp,8)
jmp    11e0 <rtnl_tab_initialize+0x80>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cf7(%rip),%rax
mov    (%rax),%edi
lea    0xd32(%rip),%rsi
mov    0x8(%rsp),%rdx
mov    %rbp,%rcx
call   1050 <fprintf@plt>
jmp    12d3 <rtnl_tab_initialize+0x173>

LLVM IR (-O0):
@rtnl_tab_initialize.buf = internal global [512 x i8] zeroinitializer
@.str = [2 x i8] c"r\00"
@rtnl_tab_initialize.namebuf = internal global [512 x i8] zeroinitializer
@.str.1 = [9 x i8] c"0x%x %s\0A\00"
@.str.2 = [10 x i8] c"0x%x %s #\00"
@.str.3 = [7 x i8] c"%d %s\0A\00"
@.str.4 = [8 x i8] c"%d %s #\00"
@stderr = global i32 0
@.str.5 = [32 x i8] c"Database %s is corrupted at %s\0A\00"
define void @rtnl_tab_initialize(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = icmp ne i32* %12, null
br i1 %13, label %15, label %14
14: ; preds = %3
br label %90
15: ; preds = %3
br label %16
16: ; preds = %81, %80, %51, %15
%17 = load i32*, i32** %7
%18 = call i64 @fgets(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.buf, i64 0, i64 0), i32 512, i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %87
20: ; preds = %16
store i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.buf, i64 0, i64 0), i8** %8
br label %21
21: ; preds = %33, %20
%22 = load i8*, i8** %8
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 32
br i1 %25, label %31, label %26
26: ; preds = %21
%27 = load i8*, i8** %8
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 9
br label %31
31: ; preds = %26, %21
%32 = phi i1 [ true, %21 ], [ %30, %26 ]
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = load i8*, i8** %8
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %8
br label %21
36: ; preds = %31
%37 = load i8*, i8** %8
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 35
br i1 %40, label %51, label %41
41: ; preds = %36
%42 = load i8*, i8** %8
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 10
br i1 %45, label %51, label %46
46: ; preds = %41
%47 = load i8*, i8** %8
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %46, %41, %36
br label %16
52: ; preds = %46
%53 = load i8*, i8** %8
%54 = call i32 @sscanf(i8* %53, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %9, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.namebuf, i64 0, i64 0))
%55 = icmp ne i32 %54, 2
br i1 %55, label %56, label %73
56: ; preds = %52
%57 = load i8*, i8** %8
%58 = call i32 @sscanf(i8* %57, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32* %9, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.namebuf, i64 0, i64 0))
%59 = icmp ne i32 %58, 2
br i1 %59, label %60, label %73
60: ; preds = %56
%61 = load i8*, i8** %8
%62 = call i32 @sscanf(i8* %61, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32* %9, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.namebuf, i64 0, i64 0))
%63 = icmp ne i32 %62, 2
br i1 %63, label %64, label %73
64: ; preds = %60
%65 = load i8*, i8** %8
%66 = call i32 @sscanf(i8* %65, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32* %9, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.namebuf, i64 0, i64 0))
%67 = icmp ne i32 %66, 2
br i1 %67, label %68, label %73
68: ; preds = %64
%69 = load i32, i32* @stderr
%70 = load i8*, i8** %4
%71 = load i8*, i8** %8
%72 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %70, i8* %71)
br label %90
73: ; preds = %64, %60, %56, %52
%74 = load i32, i32* %9
%75 = icmp slt i32 %74, 0
br i1 %75, label %80, label %76
76: ; preds = %73
%77 = load i32, i32* %9
%78 = load i32, i32* %6
%79 = icmp sgt i32 %77, %78
br i1 %79, label %80, label %81
80: ; preds = %76, %73
br label %16
81: ; preds = %76
%82 = call i8* @strdup(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.namebuf, i64 0, i64 0))
%83 = load i8**, i8*** %5
%84 = load i32, i32* %9
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8*, i8** %83, i64 %85
store i8* %82, i8** %86
br label %16
87: ; preds = %16
%88 = load i32*, i32** %7
%89 = call i32 @fclose(i32* %88)
br label %90
90: ; preds = %87, %68, %14
ret void
}

LLVM IR (-O2):
@rtnl_tab_initialize.buf = internal global [512 x i8] zeroinitializer
@.str = [2 x i8] c"r\00"
@rtnl_tab_initialize.namebuf = internal global [512 x i8] zeroinitializer
@.str.1 = [9 x i8] c"0x%x %s\0A\00"
@.str.2 = [10 x i8] c"0x%x %s #\00"
@.str.3 = [7 x i8] c"%d %s\0A\00"
@.str.4 = [8 x i8] c"%d %s #\00"
@stderr = global i32 0
@.str.5 = [32 x i8] c"Database %s is corrupted at %s\0A\00"
define void @rtnl_tab_initialize(i8* %0, i8** nocapture writeonly %1, i32 %2) {
%4 = alloca i32
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %47, label %7
7: ; preds = %3
%8 = call i64 @fgets(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.buf, i64 0, i64 0), i32 512, i32* %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %45, label %10
10: ; preds = %7
%11 = bitcast i32* %4 to i8*
br label %12
12: ; preds = %10, %42
br label %13
13: ; preds = %16, %12
%14 = phi i8* [ getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.buf, i64 0, i64 0), %12 ], [ %17, %16 ]
%15 = load i8, i8* %14
switch i8 %15, label %18 [
i8 32, label %16
i8 9, label %16
i8 35, label %42
i8 10, label %42
i8 0, label %42
]
16: ; preds = %13, %13
%17 = getelementptr inbounds i8, i8* %14, i64 1
br label %13
18: ; preds = %13
%19 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %4, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.namebuf, i64 0, i64 0))
%20 = icmp eq i32 %19, 2
br i1 %20, label %33, label %21
21: ; preds = %18
%22 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32* %4, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.namebuf, i64 0, i64 0))
%23 = icmp eq i32 %22, 2
br i1 %23, label %33, label %24
24: ; preds = %21
%25 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32* %4, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.namebuf, i64 0, i64 0))
%26 = icmp eq i32 %25, 2
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32* %4, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.namebuf, i64 0, i64 0))
%29 = icmp eq i32 %28, 2
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %0, i8* %14)
br label %47
33: ; preds = %27, %24, %21, %18
%34 = load i32, i32* %4
%35 = icmp slt i32 %34, 0
%36 = icmp sgt i32 %34, %2
%37 = or i1 %35, %36
br i1 %37, label %42, label %38
38: ; preds = %33
%39 = call i8* @strdup(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.namebuf, i64 0, i64 0))
%40 = zext i32 %34 to i64
%41 = getelementptr inbounds i8*, i8** %1, i64 %40
store i8* %39, i8** %41
br label %42
42: ; preds = %13, %13, %13, %33, %38
%43 = call i64 @fgets(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @rtnl_tab_initialize.buf, i64 0, i64 0), i32 512, i32* %5)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %12
45: ; preds = %42, %7
%46 = call i32 @fclose(i32* %5)
br label %47
47: ; preds = %30, %3, %45
ret void
}