#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 uint32_t;
struct stat {
  int st_size;
};

/* Variables and functions */
int const *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ fstat(int, struct stat *);
int *mmap(int /*<<< orphan*/ *, int, int /*<<< orphan*/, int /*<<< orphan*/,
          int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, void *, char *, ...);
int /*<<< orphan*/ strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  const uint32_t *rodata;
  int fd;
  struct stat sb;
  uint32_t base = (uint32_t)strtol(argv[2], NULL, 0);
  uint32_t class_type_info = (uint32_t)strtol(argv[3], NULL, 0);
  uint32_t si_class_type_info = (uint32_t)strtol(argv[4], NULL, 0);
  fd = open(argv[1], O_RDONLY);
  fstat(fd, &sb);
  rodata = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
  if (rodata == MAP_FAILED) {
    perror("mmap");
  }
  uint32_t i;
  for (i = 0; i < sb.st_size / 4; i += 1) {
    if (rodata[i] == class_type_info) {
      printf("%p\t%s\n", (void *)(base + 4 * i),
             ((char *)rodata) + rodata[i + 1] - base);
    } else if (rodata[i] == si_class_type_info) {
      printf("%p\t%s\t%p\n", (void *)(base + 4 * i),
             ((char *)rodata) + rodata[i + 1] - base, (void *)rodata[i + 2]);
    }
  }
  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)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e11(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1080 <fstat@plt>
mov    -0x20(%rbp),%esi
mov    0x2e11(%rip),%rax
mov    (%rax),%edx
mov    0x2df8(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2db7(%rip),%rcx
cmp    (%rcx),%rax
jne    1226 <main+0xc6>
lea    0xddf(%rip),%rdi
call   1070 <perror@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    1321 <main+0x1c1>
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x28(%rbp),%eax
jne    12a4 <main+0x144>
mov    -0x24(%rbp),%eax
mov    -0x30(%rbp),%ecx
shl    $0x2,%ecx
add    %ecx,%eax
movslq %eax,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movslq (%rax,%rcx,4),%rax
add    %rax,%rdx
movslq -0x24(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rdx
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    130e <main+0x1ae>
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x2c(%rbp),%eax
jne    1309 <main+0x1a9>
mov    -0x24(%rbp),%eax
mov    -0x30(%rbp),%ecx
shl    $0x2,%ecx
add    %ecx,%eax
movslq %eax,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movslq (%rax,%rcx,4),%rax
add    %rax,%rdx
movslq -0x24(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movslq (%rax,%rcx,4),%rcx
lea    0xd0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    130e <main+0x1ae>
jmp    1313 <main+0x1b3>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    122d <main+0xcd>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,%r12d
mov    0x18(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,%ebp
mov    0x20(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,%r15d
mov    0x8(%rbx),%rdi
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
call   1080 <fstat@plt>
mov    (%rsp),%r13d
mov    0x2e2f(%rip),%rax
mov    (%rax),%edx
mov    0x2e16(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r13d,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
mov    0x2dda(%rip),%rax
cmp    (%rax),%rbx
je     1296 <main+0x136>
cmp    $0x4,%r13d
jl     12ac <main+0x14c>
shr    $0x2,%r13
movslq %r12d,%r12
mov    %rbx,%rax
sub    %r12,%rax
mov    %rax,0x8(%rsp)
xor    %r14d,%r14d
mov    %r13,0x10(%rsp)
jmp    1245 <main+0xe5>
nopl   (%rax)
lea    (%r12,%r14,4),%rsi
movslq 0x4(%rbx,%r14,4),%rdx
add    $0x1,%r14
add    0x8(%rsp),%rdx
lea    0xdcc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r13,%r14
je     12ac <main+0x14c>
mov    (%rbx,%r14,4),%eax
cmp    %ebp,%eax
je     1220 <main+0xc0>
cmp    %r15d,%eax
jne    1290 <main+0x130>
lea    (%r12,%r14,4),%rsi
mov    %r12,%r13
mov    %r15d,%r12d
lea    0x1(%r14),%r15
movslq 0x4(%rbx,%r14,4),%rdx
add    0x8(%rsp),%rdx
movslq 0x8(%rbx,%r14,4),%rcx
lea    0xd96(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%r14
mov    %r12d,%r15d
mov    %r13,%r12
mov    0x10(%rsp),%r13
jmp    1240 <main+0xe0>
nopl   (%rax)
add    $0x1,%r14
jmp    1240 <main+0xe0>
lea    0xd63(%rip),%rdi
call   1070 <perror@plt>
cmp    $0x4,%r13d
jge    1201 <main+0xa1>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@O_RDONLY = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i32* null
@.str = [5 x i8] c"mmap\00"
@.str.1 = [7 x i8] c"%p\09%s\0A\00"
@.str.2 = [10 x i8] c"%p\09%s\09%p\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 %struct.stat
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call i32 @strtol(i8* %15, i32* null, i32 0)
store i32 %16, i32* %9
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 3
%19 = load i8*, i8** %18
%20 = call i32 @strtol(i8* %19, i32* null, i32 0)
store i32 %20, i32* %10
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 4
%23 = load i8*, i8** %22
%24 = call i32 @strtol(i8* %23, i32* null, i32 0)
store i32 %24, i32* %11
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = load i32, i32* @O_RDONLY
%29 = call i32 @open(i8* %27, i32 %28)
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = call i32 @fstat(i32 %30, %struct.stat* %8)
%32 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%33 = load i32, i32* %32
%34 = load i32, i32* @PROT_READ
%35 = load i32, i32* @MAP_SHARED
%36 = load i32, i32* %7
%37 = call i32* @mmap(i32* null, i32 %33, i32 %34, i32 %35, i32 %36, i32 0)
store i32* %37, i32** %6
%38 = load i32*, i32** %6
%39 = load i32*, i32** @MAP_FAILED
%40 = icmp eq i32* %38, %39
br i1 %40, label %41, label %43
41: ; preds = %2
%42 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %41, %2
store i32 0, i32* %12
br label %44
44: ; preds = %120, %43
%45 = load i32, i32* %12
%46 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%47 = load i32, i32* %46
%48 = sdiv i32 %47, 4
%49 = icmp slt i32 %45, %48
br i1 %49, label %50, label %123
50: ; preds = %44
%51 = load i32*, i32** %6
%52 = load i32, i32* %12
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
%55 = load i32, i32* %54
%56 = load i32, i32* %10
%57 = icmp eq i32 %55, %56
br i1 %57, label %58, label %80
58: ; preds = %50
%59 = load i32, i32* %9
%60 = load i32, i32* %12
%61 = mul nsw i32 4, %60
%62 = add nsw i32 %59, %61
%63 = sext i32 %62 to i64
%64 = inttoptr i64 %63 to i8*
%65 = load i32*, i32** %6
%66 = bitcast i32* %65 to i8*
%67 = load i32*, i32** %6
%68 = load i32, i32* %12
%69 = add nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %67, i64 %70
%72 = load i32, i32* %71
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %66, i64 %73
%75 = load i32, i32* %9
%76 = sext i32 %75 to i64
%77 = sub i64 0, %76
%78 = getelementptr inbounds i8, i8* %74, i64 %77
%79 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %64, i8* %78)
br label %119
80: ; preds = %50
%81 = load i32*, i32** %6
%82 = load i32, i32* %12
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %81, i64 %83
%85 = load i32, i32* %84
%86 = load i32, i32* %11
%87 = icmp eq i32 %85, %86
br i1 %87, label %88, label %118
88: ; preds = %80
%89 = load i32, i32* %9
%90 = load i32, i32* %12
%91 = mul nsw i32 4, %90
%92 = add nsw i32 %89, %91
%93 = sext i32 %92 to i64
%94 = inttoptr i64 %93 to i8*
%95 = load i32*, i32** %6
%96 = bitcast i32* %95 to i8*
%97 = load i32*, i32** %6
%98 = load i32, i32* %12
%99 = add nsw i32 %98, 1
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i32, i32* %97, i64 %100
%102 = load i32, i32* %101
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i8, i8* %96, i64 %103
%105 = load i32, i32* %9
%106 = sext i32 %105 to i64
%107 = sub i64 0, %106
%108 = getelementptr inbounds i8, i8* %104, i64 %107
%109 = load i32*, i32** %6
%110 = load i32, i32* %12
%111 = add nsw i32 %110, 2
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds i32, i32* %109, i64 %112
%114 = load i32, i32* %113
%115 = sext i32 %114 to i64
%116 = inttoptr i64 %115 to i8*
%117 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %94, i8* %108, i8* %116)
br label %118
118: ; preds = %88, %80
br label %119
119: ; preds = %118, %58
br label %120
120: ; preds = %119
%121 = load i32, i32* %12
%122 = add nsw i32 %121, 1
store i32 %122, i32* %12
br label %44
123: ; preds = %44
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@O_RDONLY = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i32* null
@.str = [5 x i8] c"mmap\00"
@.str.1 = [7 x i8] c"%p\09%s\0A\00"
@.str.2 = [10 x i8] c"%p\09%s\09%p\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32 @strtol(i8* nocapture %6, i32* null, i32 0)
%8 = getelementptr inbounds i8*, i8** %1, i64 3
%9 = load i8*, i8** %8
%10 = tail call i32 @strtol(i8* nocapture %9, i32* null, i32 0)
%11 = getelementptr inbounds i8*, i8** %1, i64 4
%12 = load i8*, i8** %11
%13 = tail call i32 @strtol(i8* nocapture %12, i32* null, i32 0)
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_RDONLY
%17 = tail call i32 @open(i8* %15, i32 %16)
%18 = call i32 @fstat(i32 %17, %struct.stat* %3)
%19 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%20 = load i32, i32* %19
%21 = load i32, i32* @PROT_READ
%22 = load i32, i32* @MAP_SHARED
%23 = tail call i32* @mmap(i32* null, i32 %20, i32 %21, i32 %22, i32 %17, i32 0)
%24 = load i32*, i32** @MAP_FAILED
%25 = icmp eq i32* %23, %24
br i1 %25, label %26, label %28
26: ; preds = %2
%27 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %2
%29 = icmp sgt i32 %20, 3
br i1 %29, label %30, label %75
30: ; preds = %28
%31 = lshr i32 %20, 2
%32 = bitcast i32* %23 to i8*
%33 = sext i32 %7 to i64
%34 = sub nsw i64 0, %33
%35 = zext i32 %31 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %34
%37 = getelementptr inbounds i8, i8* %32, i64 %34
br label %38
38: ; preds = %30, %72
%39 = phi i64 [ 0, %30 ], [ %73, %72 ]
%40 = getelementptr inbounds i32, i32* %23, i64 %39
%41 = load i32, i32* %40
%42 = icmp eq i32 %41, %10
br i1 %42, label %43, label %53
43: ; preds = %38
%44 = shl nsw i64 %39, 2
%45 = add nsw i64 %44, %33
%46 = inttoptr i64 %45 to i8*
%47 = add nuw nsw i64 %39, 1
%48 = getelementptr inbounds i32, i32* %23, i64 %47
%49 = load i32, i32* %48
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %37, i64 %50
%52 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %46, i8* %51)
br label %72
53: ; preds = %38
%54 = icmp eq i32 %41, %13
br i1 %54, label %57, label %55
55: ; preds = %53
%56 = add nuw nsw i64 %39, 1
br label %72
57: ; preds = %53
%58 = shl nsw i64 %39, 2
%59 = add nsw i64 %58, %33
%60 = inttoptr i64 %59 to i8*
%61 = add nuw nsw i64 %39, 1
%62 = getelementptr inbounds i32, i32* %23, i64 %61
%63 = load i32, i32* %62
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %36, i64 %64
%66 = add nuw nsw i64 %39, 2
%67 = getelementptr inbounds i32, i32* %23, i64 %66
%68 = load i32, i32* %67
%69 = sext i32 %68 to i64
%70 = inttoptr i64 %69 to i8*
%71 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %60, i8* %65, i8* %70)
br label %72
72: ; preds = %55, %43, %57
%73 = phi i64 [ %56, %55 ], [ %47, %43 ], [ %61, %57 ]
%74 = icmp eq i64 %73, %35
br i1 %74, label %75, label %38
75: ; preds = %72, %28
ret i32 0
}