#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 irq_routing_table {
  int dummy;
};
typedef int /*<<< orphan*/ off_t;

/* Variables and functions */
char *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ code_gen(char *, struct irq_routing_table *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(void *);
scalar_t__ getuid();
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
void *malloc(int);
char *mmap(int /*<<< orphan*/, int, int /*<<< orphan*/, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int /*<<< orphan*/ munmap(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
struct irq_routing_table *probe_table(char *);
int /*<<< orphan*/ read(int, void *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char *ptr;
  int fd_mem = -1;
  struct irq_routing_table *rt = NULL;
  void *bios_image = NULL;
  if (argc > 1) {
    printf("Opening memory image file '%s'\n", argv[1]);
    fd_mem = open(argv[1], O_RDONLY);
    if (fd_mem > 0) {
      int file_size = lseek(fd_mem, 0, SEEK_END);
      printf("Memory image '%i'\n", file_size);
      bios_image = malloc(file_size);
      if (bios_image) {
        lseek(fd_mem, 0, SEEK_SET);
        read(fd_mem, bios_image, file_size);
        ptr = (char *)bios_image;
      } else {
        perror("Failed to open imagefile\n");
        return (-3);
      }
    } else {
      perror("Failed to open imagefile");
      return (-2);
    }
  } else {
    printf("Accessing memory\n");
    if (getuid()) {
      fprintf(stderr, "Run me as root, I need access to "
                      "/dev/mem"
                      ".\n");
    }
    fd_mem = open("/dev/mem", O_RDONLY);
    if (fd_mem < 0) {
      perror("Could not open "
             "/dev/mem"
             ":");
      exit(1);
    }
    printf("Probing PIRQ table in memory.\n");
    ptr = mmap(0, 0x10000, PROT_READ, MAP_SHARED, fd_mem, (off_t)0xf0000);
    if (ptr == MAP_FAILED) {
      perror("Mapping system memory failed: ");
      close(fd_mem);
      return (1);
    }
  }
  if (ptr) {
    rt = probe_table(ptr);
    if (rt != NULL && bios_image == NULL) {
      printf("Creating irq_tables.c ...\n");
      code_gen("irq_tables.c", rt);
      printf("Done, you can move the file to the coreboot tree now.\n");
    }
  } else {
    printf("invalid memory pointer\n");
  }
  if (bios_image) {
    free(bios_image);
  } else {
    munmap(ptr, 0x10000);
  }
  close(fd_mem);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1307 <main+0x117>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d84(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    12ea <main+0xfa>
mov    -0x1c(%rbp),%edi
mov    0x2d6e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <lseek@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x34(%rbp),%edi
call   10b0 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12cd <main+0xdd>
mov    -0x1c(%rbp),%edi
mov    0x2d10(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <lseek@plt>
mov    -0x1c(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1090 <read@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    12e5 <main+0xf5>
lea    0xd5f(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1489 <main+0x299>
jmp    1302 <main+0x112>
lea    0xd5c(%rip),%rdi
call   10f0 <perror@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1489 <main+0x299>
jmp    13e6 <main+0x1f6>
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <getuid@plt>
cmp    $0x0,%rax
je     133b <main+0x14b>
mov    0x2c93(%rip),%rax
mov    (%rax),%edi
lea    0xd42(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x2c8e(%rip),%rax
mov    (%rax),%esi
lea    0xd59(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1373 <main+0x183>
lea    0xd49(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2c70(%rip),%rax
mov    (%rax),%edx
mov    0x2c57(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
xor    %edi,%edi
mov    $0x10000,%esi
mov    $0xf0000,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2bf8(%rip),%rcx
cmp    (%rcx),%rax
jne    13e1 <main+0x1f1>
lea    0xd1d(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1489 <main+0x299>
jmp    13e6 <main+0x1f6>
cmpq   $0x0,-0x18(%rbp)
je     1445 <main+0x255>
mov    -0x18(%rbp),%rdi
call   10d0 <probe_table@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1440 <main+0x250>
cmpq   $0x0,-0x30(%rbp)
jne    1440 <main+0x250>
lea    0xce9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xcf2(%rip),%rdi
call   1110 <code_gen@plt>
lea    0xcf3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1453 <main+0x263>
lea    0xd17(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpq   $0x0,-0x30(%rbp)
je     146c <main+0x27c>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    147a <main+0x28a>
mov    -0x18(%rbp),%rdi
mov    $0x10000,%esi
call   10c0 <munmap@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     12a2 <main+0xa2>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0xde2(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%rdi
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
call   10f0 <open@plt>
test   %eax,%eax
jle    13b5 <main+0x1b5>
mov    %eax,%r14d
mov    0x2d8f(%rip),%rax
mov    (%rax),%edx
mov    %r14d,%edi
xor    %esi,%esi
call   1080 <lseek@plt>
mov    %eax,%ebp
lea    0xdc2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     13e3 <main+0x1e3>
mov    %rax,%rbx
mov    0x2d37(%rip),%rax
mov    (%rax),%edx
mov    %r14d,%edi
xor    %esi,%esi
call   1080 <lseek@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   10a0 <read@plt>
mov    %rbx,%r15
jmp    133f <main+0x13f>
lea    0xe37(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <getuid@plt>
test   %rax,%rax
je     12cf <main+0xcf>
mov    0x2cff(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2cfa(%rip),%rax
mov    (%rax),%esi
lea    0xdb3(%rip),%rdi
call   10f0 <open@plt>
test   %eax,%eax
js     13f6 <main+0x1f6>
mov    %eax,%r14d
lea    0xdfb(%rip),%rdi
call   1040 <puts@plt>
mov    0x2cf6(%rip),%rax
mov    (%rax),%edx
mov    0x2cdd(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    $0x10000,%esi
mov    %r14d,%r8d
mov    $0xf0000,%r9d
call   1060 <mmap@plt>
mov    0x2c87(%rip),%rcx
cmp    (%rcx),%rax
je     13c8 <main+0x1c8>
xor    %r15d,%r15d
test   %rax,%rax
je     1387 <main+0x187>
xor    %ebx,%ebx
mov    %rax,%r15
mov    %r15,%rdi
call   10e0 <probe_table@plt>
test   %rbx,%rbx
jne    1378 <main+0x178>
mov    %rax,%rbp
test   %rax,%rax
je     1378 <main+0x178>
lea    0xdcb(%rip),%rdi
call   1040 <puts@plt>
lea    0xd6c(%rip),%rdi
mov    %rbp,%rsi
call   1120 <code_gen@plt>
lea    0xdca(%rip),%rdi
jmp    138e <main+0x18e>
test   %rbx,%rbx
je     1393 <main+0x193>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    13a0 <main+0x1a0>
lea    0xd81(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    $0x10000,%esi
call   10d0 <munmap@plt>
mov    %r14d,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc91(%rip),%rdi
call   1100 <perror@plt>
mov    $0xfffffffe,%eax
jmp    13aa <main+0x1aa>
lea    0xce5(%rip),%rdi
call   1100 <perror@plt>
mov    %r14d,%edi
call   1090 <close@plt>
mov    $0x1,%eax
jmp    13aa <main+0x1aa>
lea    0xc49(%rip),%rdi
call   1100 <perror@plt>
mov    $0xfffffffd,%eax
jmp    13aa <main+0x1aa>
lea    0xc9e(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.irq_routing_table = type { i32 }
@.str = [32 x i8] c"Opening memory image file '%s'\0A\00"
@O_RDONLY = global i32 0
@SEEK_END = global i32 0
@.str.1 = [19 x i8] c"Memory image '%i'\0A\00"
@SEEK_SET = global i32 0
@.str.2 = [26 x i8] c"Failed to open imagefile\0A\00"
@.str.3 = [25 x i8] c"Failed to open imagefile\00"
@.str.4 = [18 x i8] c"Accessing memory\0A\00"
@stderr = global i32 0
@.str.5 = [44 x i8] c"Run me as root, I need access to /dev/mem.\0A\00"
@.str.6 = [9 x i8] c"/dev/mem\00"
@.str.7 = [25 x i8] c"Could not open /dev/mem:\00"
@.str.8 = [31 x i8] c"Probing PIRQ table in memory.\0A\00"
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.9 = [31 x i8] c"Mapping system memory failed: \00"
@.str.10 = [27 x i8] c"Creating irq_tables.c ...\0A\00"
@.str.11 = [13 x i8] c"irq_tables.c\00"
@.str.12 = [55 x i8] c"Done, you can move the file to the coreboot tree now.\0A\00"
@.str.13 = [24 x i8] c"invalid memory pointer\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca %struct.irq_routing_table*
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %7
store %struct.irq_routing_table* null, %struct.irq_routing_table** %8
store i8* null, i8** %9
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %50
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load i32, i32* @O_RDONLY
%22 = call i32 @open(i8* %20, i32 %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %47
25: ; preds = %13
%26 = load i32, i32* %7
%27 = load i32, i32* @SEEK_END
%28 = call i32 @lseek(i32 %26, i32 0, i32 %27)
store i32 %28, i32* %10
%29 = load i32, i32* %10
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %10
%32 = call i8* @malloc(i32 %31)
store i8* %32, i8** %9
%33 = load i8*, i8** %9
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %44
35: ; preds = %25
%36 = load i32, i32* %7
%37 = load i32, i32* @SEEK_SET
%38 = call i32 @lseek(i32 %36, i32 0, i32 %37)
%39 = load i32, i32* %7
%40 = load i8*, i8** %9
%41 = load i32, i32* %10
%42 = call i32 @read(i32 %39, i8* %40, i32 %41)
%43 = load i8*, i8** %9
store i8* %43, i8** %6
br label %46
44: ; preds = %25
%45 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 -3, i32* %3
br label %110
46: ; preds = %35
br label %49
47: ; preds = %13
%48 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
store i32 -2, i32* %3
br label %110
49: ; preds = %46
br label %79
50: ; preds = %2
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%52 = call i64 (...) @getuid()
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
br label %57
57: ; preds = %54, %50
%58 = load i32, i32* @O_RDONLY
%59 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %58)
store i32 %59, i32* %7
%60 = load i32, i32* %7
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %57
%63 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %57
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
%67 = load i32, i32* @PROT_READ
%68 = load i32, i32* @MAP_SHARED
%69 = load i32, i32* %7
%70 = call i8* @mmap(i32 0, i32 65536, i32 %67, i32 %68, i32 %69, i32 983040)
store i8* %70, i8** %6
%71 = load i8*, i8** %6
%72 = load i8*, i8** @MAP_FAILED
%73 = icmp eq i8* %71, %72
br i1 %73, label %74, label %78
74: ; preds = %65
%75 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%76 = load i32, i32* %7
%77 = call i32 @close(i32 %76)
store i32 1, i32* %3
br label %110
78: ; preds = %65
br label %79
79: ; preds = %78, %49
%80 = load i8*, i8** %6
%81 = icmp ne i8* %80, null
br i1 %81, label %82, label %96
82: ; preds = %79
%83 = load i8*, i8** %6
%84 = call %struct.irq_routing_table* @probe_table(i8* %83)
store %struct.irq_routing_table* %84, %struct.irq_routing_table** %8
%85 = load %struct.irq_routing_table*, %struct.irq_routing_table** %8
%86 = icmp ne %struct.irq_routing_table* %85, null
br i1 %86, label %87, label %95
87: ; preds = %82
%88 = load i8*, i8** %9
%89 = icmp eq i8* %88, null
br i1 %89, label %90, label %95
90: ; preds = %87
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%92 = load %struct.irq_routing_table*, %struct.irq_routing_table** %8
%93 = call i32 @code_gen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), %struct.irq_routing_table* %92)
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.12, i64 0, i64 0))
br label %95
95: ; preds = %90, %87, %82
br label %98
96: ; preds = %79
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0))
br label %98
98: ; preds = %96, %95
%99 = load i8*, i8** %9
%100 = icmp ne i8* %99, null
br i1 %100, label %101, label %104
101: ; preds = %98
%102 = load i8*, i8** %9
%103 = call i32 @free(i8* %102)
br label %107
104: ; preds = %98
%105 = load i8*, i8** %6
%106 = call i32 @munmap(i8* %105, i32 65536)
br label %107
107: ; preds = %104, %101
%108 = load i32, i32* %7
%109 = call i32 @close(i32 %108)
store i32 0, i32* %3
br label %110
110: ; preds = %107, %74, %47, %44
%111 = load i32, i32* %3
ret i32 %111
}

LLVM IR (-O2):
%struct.irq_routing_table = type { i32 }
@.str = [32 x i8] c"Opening memory image file '%s'\0A\00"
@O_RDONLY = global i32 0
@SEEK_END = global i32 0
@.str.1 = [19 x i8] c"Memory image '%i'\0A\00"
@SEEK_SET = global i32 0
@.str.2 = [26 x i8] c"Failed to open imagefile\0A\00"
@.str.3 = [25 x i8] c"Failed to open imagefile\00"
@stderr = global i32 0
@.str.5 = [44 x i8] c"Run me as root, I need access to /dev/mem.\0A\00"
@.str.6 = [9 x i8] c"/dev/mem\00"
@.str.7 = [25 x i8] c"Could not open /dev/mem:\00"
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.9 = [31 x i8] c"Mapping system memory failed: \00"
@.str.11 = [13 x i8] c"irq_tables.c\00"
@str = [17 x i8] c"Accessing memory\00"
@str.14 = [30 x i8] c"Probing PIRQ table in memory.\00"
@str.15 = [23 x i8] c"invalid memory pointer\00"
@str.16 = [26 x i8] c"Creating irq_tables.c ...\00"
@str.17 = [54 x i8] c"Done, you can move the file to the coreboot tree now.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %26
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %5
%9 = load i32, i32* @O_RDONLY
%10 = tail call i32 @open(i8* %8, i32 %9)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %4
%13 = load i32, i32* @SEEK_END
%14 = tail call i32 @lseek(i32 %10, i32 0, i32 %13)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = tail call i8* @malloc(i32 %14)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %78
20: ; preds = %12
%21 = load i32, i32* @SEEK_SET
%22 = tail call i32 @lseek(i32 %10, i32 0, i32 %21)
%23 = tail call i32 @read(i32 %10, i8* %16, i32 %14)
br label %52
24: ; preds = %4
%25 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %78
26: ; preds = %2
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%28 = tail call i64 (...) @getuid()
%29 = icmp eq i64 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = tail call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
br label %33
33: ; preds = %30, %26
%34 = load i32, i32* @O_RDONLY
%35 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %34)
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%39 = tail call i32 @exit(i32 1)
unreachable
40: ; preds = %33
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.14, i64 0, i64 0))
%42 = load i32, i32* @PROT_READ
%43 = load i32, i32* @MAP_SHARED
%44 = tail call i8* @mmap(i32 0, i32 65536, i32 %42, i32 %43, i32 %35, i32 983040)
%45 = load i8*, i8** @MAP_FAILED
%46 = icmp eq i8* %44, %45
br i1 %46, label %47, label %50
47: ; preds = %40
%48 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%49 = tail call i32 @close(i32 %35)
br label %78
50: ; preds = %40
%51 = icmp eq i8* %44, null
br i1 %51, label %66, label %52
52: ; preds = %20, %50
%53 = phi i8* [ %16, %20 ], [ null, %50 ]
%54 = phi i32 [ %10, %20 ], [ %35, %50 ]
%55 = phi i8* [ %16, %20 ], [ %44, %50 ]
%56 = tail call %struct.irq_routing_table* @probe_table(i8* %55)
%57 = icmp ne %struct.irq_routing_table* %56, null
%58 = icmp eq i8* %53, null
%59 = and i1 %58, %57
br i1 %59, label %60, label %63
60: ; preds = %52
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.16, i64 0, i64 0))
%62 = tail call i32 @code_gen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), %struct.irq_routing_table* %56)
br label %66
63: ; preds = %52
br i1 %58, label %71, label %64
64: ; preds = %63
%65 = tail call i32 @free(i8* %53)
br label %75
66: ; preds = %50, %60
%67 = phi i8* [ getelementptr inbounds ([54 x i8], [54 x i8]* @str.17, i64 0, i64 0), %60 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.15, i64 0, i64 0), %50 ]
%68 = phi i8* [ %55, %60 ], [ null, %50 ]
%69 = phi i32 [ %54, %60 ], [ %35, %50 ]
%70 = tail call i32 @puts(i8* dereferenceable(1) %67)
br label %71
71: ; preds = %66, %63
%72 = phi i8* [ %55, %63 ], [ %68, %66 ]
%73 = phi i32 [ %54, %63 ], [ %69, %66 ]
%74 = tail call i32 @munmap(i8* %72, i32 65536)
br label %75
75: ; preds = %71, %64
%76 = phi i32 [ %73, %71 ], [ %54, %64 ]
%77 = tail call i32 @close(i32 %76)
br label %78
78: ; preds = %18, %75, %47, %24
%79 = phi i32 [ 0, %75 ], [ -2, %24 ], [ 1, %47 ], [ -3, %18 ]
ret i32 %79
}