#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 uint16_t;
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(unsigned char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
int getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
unsigned char *malloc(int);
scalar_t__ meet_vesa_table(unsigned char *);
#define no_argument 128
int optind;
int optopt;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ show_usage(char *);
int main(int argc, char **argv) {
  static struct option longopts[] = {{"help", no_argument, 0, 'h'},
                                     {"verbose", no_argument, 0, 'v'}};
  char *name = argv[0];
  bool verbose = false;
  char *filename = NULL;
  int opt;
  while ((opt = getopt_long(argc, argv, "vh", longopts, NULL)) != -1) {
    switch (opt) {
    case 'v':
      verbose = true;
      break;
    case 'h':
      show_usage(name);
      exit(0);
    case '?':
      printf("%s: invalid option -- %c\n", name, optopt);
      printf("See %s -h for usage.\n", name);
      break;
    }
  }
  if (optind < argc) {
    filename = argv[optind];
  } else {
    show_usage(name);
    exit(1);
  }
  puts(
      "Warning: This is free software; see the source for copying conditions.");
  puts("There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A "
       "PARTICULAR PURPOSE.\n");
  printf("Opening VBIOS: %s\n", filename);
  FILE *vbios_fp = fopen(filename, "rb");
  if (!vbios_fp) {
    printf("%s: can't open %s\n", name, filename);
    return 1;
  }
  fseek(vbios_fp, 0, SEEK_END);
  size_t length = ftell(vbios_fp);
  fseek(vbios_fp, 0, SEEK_SET);
  printf("Length: %ld\n", length);
  unsigned char *vbios = malloc(sizeof(unsigned char) * length);
  if (!vbios) {
    printf("%s: out of memory!\n", name);
    return 1;
  }
  size_t size = fread(vbios, sizeof(unsigned char), length, vbios_fp);
  fclose(vbios_fp);
  if (size != length) {
    printf("%s: incomplete read occurred during fread()\n", name);
    return 1;
  }
  int vesa_tables = 0;
  for (size_t i = 0; i < length - 30; i++) {
    if (meet_vesa_table(&vbios[i])) {
      vesa_tables++;
      printf("\n#%d possible VESA modes table @ 0x%08lx\n", vesa_tables, i);
      for (size_t j = i; j < i + 512; j += 32) {
        if (vbios[j] == 0x00 && vbios[j + 1] == 0x00) {
          printf("--- an empty modeline @ 0x%08lx\n", j);
        } else {
          printf("--- ");
          printf("%dx%d ", *(uint16_t *)&vbios[j], *(uint16_t *)&vbios[j + 14]);
          if (verbose) {
            for (size_t z = j; z < j + 32; z++) {
              printf("%02x ", vbios[z]);
            }
          }
          printf("@ 0x%08lx\n", j);
        }
      }
    }
  }
  free(vbios);
  putchar('\n');
  if (vesa_tables == 1) {
    puts("[+] We found 1 VESA table, which is the correct number.");
    puts("[+] VBIOS Resolution modding should be working. Happy Hacking!");
  } else {
    printf("[!] Unexpected, we found %d VESA tables. What's wrong?\n",
           vesa_tables);
    puts("[!] VBIOS Resolution modding may not working.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdec(%rip),%rdx
lea    0x2e78(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1080 <getopt_long@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     12c2 <main+0xe2>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x74(%rbp)
sub    $0x3f,%eax
je     1290 <main+0xb0>
jmp    1252 <main+0x72>
mov    -0x74(%rbp),%eax
sub    $0x68,%eax
je     1280 <main+0xa0>
jmp    1263 <main+0x83>
mov    -0x74(%rbp),%eax
sub    $0x76,%eax
jne    12bd <main+0xdd>
jmp    1274 <main+0x94>
movl   $0x1,-0x1c(%rbp)
jmp    12bd <main+0xdd>
mov    -0x18(%rbp),%rdi
call   10e0 <show_usage@plt>
xor    %edi,%edi
call   1100 <exit@plt>
mov    -0x18(%rbp),%rsi
mov    0x2d45(%rip),%rax
mov    (%rax),%edx
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    1213 <main+0x33>
mov    0x2d0f(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    12ef <main+0x10f>
mov    -0x10(%rbp),%rax
mov    0x2cf9(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
jmp    1302 <main+0x122>
mov    -0x18(%rbp),%rdi
call   10e0 <show_usage@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xd37(%rip),%rdi
call   1050 <puts@plt>
lea    0xd72(%rip),%rdi
call   1050 <puts@plt>
mov    -0x28(%rbp),%rsi
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    0xdbc(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    136d <main+0x18d>
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <main+0x445>
mov    -0x38(%rbp),%rdi
mov    0x2c70(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    -0x38(%rbp),%rdi
call   10b0 <ftell@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    0x2c2f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    -0x40(%rbp),%rsi
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x40(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    13f0 <main+0x210>
mov    -0x18(%rbp),%rsi
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <main+0x445>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1060 <fread@plt>
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x50(%rbp),%rax
cmp    -0x40(%rbp),%rax
je     143f <main+0x25f>
mov    -0x18(%rbp),%rsi
lea    0xcfe(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1625 <main+0x445>
movl   $0x0,-0x54(%rbp)
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    -0x40(%rbp),%rcx
sub    $0x1e,%rcx
cmp    %rcx,%rax
jae    15c7 <main+0x3e7>
mov    -0x48(%rbp),%rdi
add    -0x60(%rbp),%rdi
call   10a0 <meet_vesa_table@plt>
cmp    $0x0,%rax
je     15b1 <main+0x3d1>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%esi
mov    -0x60(%rbp),%rdx
lea    0xcc6(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    -0x60(%rbp),%rcx
add    $0x200,%rcx
cmp    %rcx,%rax
jae    15ac <main+0x3cc>
mov    -0x48(%rbp),%rax
mov    -0x68(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    14fa <main+0x31a>
mov    -0x48(%rbp),%rax
mov    -0x68(%rbp),%rcx
movzbl 0x1(%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    14fa <main+0x31a>
mov    -0x68(%rbp),%rsi
lea    0xc93(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    1596 <main+0x3b6>
lea    0xca1(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x48(%rbp),%rax
mov    -0x68(%rbp),%rcx
mov    (%rax,%rcx,1),%esi
mov    -0x48(%rbp),%rax
mov    -0x68(%rbp),%rcx
mov    0xe(%rax,%rcx,1),%edx
lea    0xc81(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1584 <main+0x3a4>
mov    -0x68(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    -0x68(%rbp),%rcx
add    $0x20,%rcx
cmp    %rcx,%rax
jae    157f <main+0x39f>
mov    -0x48(%rbp),%rax
mov    -0x70(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xc47(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
jmp    153f <main+0x35f>
jmp    1584 <main+0x3a4>
mov    -0x68(%rbp),%rsi
lea    0xbe7(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    159b <main+0x3bb>
mov    -0x68(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x68(%rbp)
jmp    14a0 <main+0x2c0>
jmp    15b1 <main+0x3d1>
jmp    15b6 <main+0x3d6>
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    144e <main+0x26e>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
cmpl   $0x1,-0x54(%rbp)
jne    1601 <main+0x421>
lea    0xbc9(%rip),%rdi
call   1050 <puts@plt>
lea    0xbf5(%rip),%rdi
call   1050 <puts@plt>
jmp    161e <main+0x43e>
mov    -0x54(%rbp),%esi
lea    0xc20(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    0xc4a(%rip),%rdi
call   1050 <puts@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%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    %edi,%ebp
mov    (%rsi),%r15
mov    $0x1,%al
mov    %eax,(%rsp)
lea    0xe0b(%rip),%r14
lea    0x2e97(%rip),%r12
lea    0xe1a(%rip),%r13
jmp    1247 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2db9(%rip),%rax
mov    (%rax),%edx
lea    0xde0(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
xor    %r8d,%r8d
call   1080 <getopt_long@plt>
cmp    $0x67,%eax
jg     1270 <main+0x90>
cmp    $0x3f,%eax
je     1220 <main+0x40>
cmp    $0xffffffff,%eax
jne    1247 <main+0x67>
jmp    1288 <main+0xa8>
nopl   0x0(%rax,%rax,1)
cmp    $0x76,%eax
je     127f <main+0x9f>
cmp    $0x68,%eax
jne    1247 <main+0x67>
jmp    155f <main+0x37f>
movl   $0x0,(%rsp)
jmp    1247 <main+0x67>
mov    0x2d49(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
jge    156e <main+0x38e>
mov    (%rbx,%rax,8),%rbx
lea    0xd9b(%rip),%rdi
call   1050 <puts@plt>
lea    0xdd6(%rip),%rdi
call   1050 <puts@plt>
lea    0xe23(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xe25(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     14aa <main+0x2ca>
mov    %rax,%rbp
mov    0x2cff(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    %rbp,%rdi
call   10b0 <ftell@plt>
mov    %rax,%r13
mov    0x2cc1(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
lea    0xdef(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r13d,%edi
call   10c0 <malloc@plt>
test   %rax,%rax
je     14c9 <main+0x2e9>
mov    %rax,%rbx
mov    $0x1,%r14d
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1060 <fread@plt>
mov    %rax,%r12
mov    %rbp,%rdi
call   1070 <fclose@plt>
cmp    %r13,%r12
jne    14e2 <main+0x302>
mov    %r13,%r12
add    $0xffffffffffffffe2,%r12
je     14f5 <main+0x315>
lea    0xe35(%rip),%r15
xor    %ebp,%ebp
xor    %r13d,%r13d
mov    (%rsp),%r14d
mov    %r12,0x8(%rsp)
jmp    13ac <main+0x1cc>
nopl   0x0(%rax)
mov    0x8(%rsp),%r12
mov    0x4(%rsp),%r13d
mov    0x10(%rsp),%rbp
add    $0x1,%rbp
cmp    %r12,%rbp
je     14f8 <main+0x318>
lea    (%rbx,%rbp,1),%rdi
call   10a0 <meet_vesa_table@plt>
test   %rax,%rax
je     139f <main+0x1bf>
add    $0x1,%r13d
lea    0xd92(%rip),%rdi
mov    %r13d,%esi
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbp,%r12
sub    $0xfffffffffffffe00,%r12
jae    14a0 <main+0x2c0>
mov    %r13d,0x4(%rsp)
mov    %rbp,0x10(%rsp)
lea    0xdaf(%rip),%r13
jmp    1417 <main+0x237>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
add    $0x20,%rbp
cmp    %r12,%rbp
jae    1390 <main+0x1b0>
cmpb   $0x0,(%rbx,%rbp,1)
jne    142b <main+0x24b>
cmpb   $0x0,0x1(%rbp,%rbx,1)
lea    0xd58(%rip),%rdi
je     1400 <main+0x220>
mov    %r13,%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    (%rbx,%rbp,1),%esi
mov    0xe(%rbx,%rbp,1),%edx
lea    0xd64(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd25(%rip),%rdi
test   $0x1,%r14b
jne    1400 <main+0x220>
lea    0xd18(%rip),%rdi
cmp    $0xffffffffffffffdf,%rbp
ja     1400 <main+0x220>
lea    0x20(%rbp),%r13
mov    %rbp,%r14
nopl   0x0(%rax,%rax,1)
movzbl (%rbx,%r14,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1090 <printf@plt>
add    $0x1,%r14
cmp    %r13,%r14
jb     1470 <main+0x290>
lea    0xce7(%rip),%rdi
mov    (%rsp),%r14d
lea    0xd08(%rip),%r13
jmp    1400 <main+0x220>
nop
mov    0x8(%rsp),%r12
jmp    139f <main+0x1bf>
lea    0xc45(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%r14d
jmp    154d <main+0x36d>
lea    0xc46(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%r14d
jmp    154d <main+0x36d>
lea    0xc41(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    154d <main+0x36d>
xor    %r13d,%r13d
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
cmp    $0x1,%r13d
jne    152d <main+0x34d>
lea    0xc9d(%rip),%rdi
call   1050 <puts@plt>
lea    0xcc9(%rip),%rdi
call   1050 <puts@plt>
xor    %r14d,%r14d
jmp    154d <main+0x36d>
lea    0xcf7(%rip),%rdi
xor    %r14d,%r14d
mov    %r13d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd1b(%rip),%rdi
call   1050 <puts@plt>
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
call   10e0 <show_usage@plt>
xor    %edi,%edi
call   1100 <exit@plt>
mov    %r15,%rdi
call   10e0 <show_usage@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@main.longopts = internal global [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 118 }]
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"verbose\00"
@.str.2 = [3 x i8] c"vh\00"
@.str.3 = [26 x i8] c"%s: invalid option -- %c\0A\00"
@optopt = global i32 0
@.str.4 = [22 x i8] c"See %s -h for usage.\0A\00"
@optind = global i32 0
@.str.5 = [71 x i8] c"Warning: This is free software; see the source for copying conditions.\00"
@.str.6 = [89 x i8] c"There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\0A\00"
@.str.7 = [19 x i8] c"Opening VBIOS: %s\0A\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [19 x i8] c"%s: can't open %s\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.10 = [13 x i8] c"Length: %ld\0A\00"
@.str.11 = [20 x i8] c"%s: out of memory!\0A\00"
@.str.12 = [45 x i8] c"%s: incomplete read occurred during fread()\0A\00"
@.str.13 = [42 x i8] c"\0A#%d possible VESA modes table @ 0x%08lx\0A\00"
@.str.14 = [33 x i8] c"--- an empty modeline @ 0x%08lx\0A\00"
@.str.15 = [5 x i8] c"--- \00"
@.str.16 = [7 x i8] c"%dx%d \00"
@.str.17 = [6 x i8] c"%02x \00"
@.str.18 = [11 x i8] c"@ 0x%08lx\0A\00"
@.str.19 = [56 x i8] c"[+] We found 1 VESA table, which is the correct number.\00"
@.str.20 = [63 x i8] c"[+] VBIOS Resolution modding should be working. Happy Hacking!\00"
@.str.21 = [56 x i8] c"[!] Unexpected, we found %d VESA tables. What's wrong?\0A\00"
@.str.22 = [46 x i8] c"[!] VBIOS Resolution modding may not working.\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 i8*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
store i8* %20, i8** %6
store i32 0, i32* %7
store i8* null, i8** %8
br label %21
21: ; preds = %39, %2
%22 = load i32, i32* %4
%23 = load i8**, i8*** %5
%24 = call i32 @getopt_long(i32 %22, i8** %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.longopts, i64 0, i64 0), i32* null)
store i32 %24, i32* %9
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %40
26: ; preds = %21
%27 = load i32, i32* %9
switch i32 %27, label %39 [
i32 118, label %28
i32 104, label %29
i32 63, label %33
]
28: ; preds = %26
store i32 1, i32* %7
br label %39
29: ; preds = %26
%30 = load i8*, i8** %6
%31 = call i32 @show_usage(i8* %30)
%32 = call i32 @exit(i32 0)
unreachable
33: ; preds = %26
%34 = load i8*, i8** %6
%35 = load i32, i32* @optopt
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %34, i32 %35)
%37 = load i8*, i8** %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %26, %33, %28
br label %21
40: ; preds = %21
%41 = load i32, i32* @optind
%42 = load i32, i32* %4
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = load i8**, i8*** %5
%46 = load i32, i32* @optind
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
store i8* %49, i8** %8
br label %54
50: ; preds = %40
%51 = load i8*, i8** %6
%52 = call i32 @show_usage(i8* %51)
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %44
%55 = call i32 @puts(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0))
%56 = call i32 @puts(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.6, i64 0, i64 0))
%57 = load i8*, i8** %8
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %57)
%59 = load i8*, i8** %8
%60 = call i32* @fopen(i8* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %60, i32** %10
%61 = load i32*, i32** %10
%62 = icmp ne i32* %61, null
br i1 %62, label %67, label %63
63: ; preds = %54
%64 = load i8*, i8** %6
%65 = load i8*, i8** %8
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %64, i8* %65)
store i32 1, i32* %3
br label %202
67: ; preds = %54
%68 = load i32*, i32** %10
%69 = load i32, i32* @SEEK_END
%70 = call i32 @fseek(i32* %68, i32 0, i32 %69)
%71 = load i32*, i32** %10
%72 = call i64 @ftell(i32* %71)
store i64 %72, i64* %11
%73 = load i32*, i32** %10
%74 = load i32, i32* @SEEK_SET
%75 = call i32 @fseek(i32* %73, i32 0, i32 %74)
%76 = load i64, i64* %11
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i64 %76)
%78 = load i64, i64* %11
%79 = mul i64 1, %78
%80 = trunc i64 %79 to i32
%81 = call i8* @malloc(i32 %80)
store i8* %81, i8** %12
%82 = load i8*, i8** %12
%83 = icmp ne i8* %82, null
br i1 %83, label %87, label %84
84: ; preds = %67
%85 = load i8*, i8** %6
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %85)
store i32 1, i32* %3
br label %202
87: ; preds = %67
%88 = load i8*, i8** %12
%89 = load i64, i64* %11
%90 = load i32*, i32** %10
%91 = call i64 @fread(i8* %88, i32 1, i64 %89, i32* %90)
store i64 %91, i64* %13
%92 = load i32*, i32** %10
%93 = call i32 @fclose(i32* %92)
%94 = load i64, i64* %13
%95 = load i64, i64* %11
%96 = icmp ne i64 %94, %95
br i1 %96, label %97, label %100
97: ; preds = %87
%98 = load i8*, i8** %6
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0), i8* %98)
store i32 1, i32* %3
br label %202
100: ; preds = %87
store i32 0, i32* %14
store i64 0, i64* %15
br label %101
101: ; preds = %185, %100
%102 = load i64, i64* %15
%103 = load i64, i64* %11
%104 = sub i64 %103, 30
%105 = icmp ult i64 %102, %104
br i1 %105, label %106, label %188
106: ; preds = %101
%107 = load i8*, i8** %12
%108 = load i64, i64* %15
%109 = getelementptr inbounds i8, i8* %107, i64 %108
%110 = call i64 @meet_vesa_table(i8* %109)
%111 = icmp ne i64 %110, 0
br i1 %111, label %112, label %184
112: ; preds = %106
%113 = load i32, i32* %14
%114 = add nsw i32 %113, 1
store i32 %114, i32* %14
%115 = load i32, i32* %14
%116 = load i64, i64* %15
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.13, i64 0, i64 0), i32 %115, i64 %116)
%118 = load i64, i64* %15
store i64 %118, i64* %16
br label %119
119: ; preds = %180, %112
%120 = load i64, i64* %16
%121 = load i64, i64* %15
%122 = add i64 %121, 512
%123 = icmp ult i64 %120, %122
br i1 %123, label %124, label %183
124: ; preds = %119
%125 = load i8*, i8** %12
%126 = load i64, i64* %16
%127 = getelementptr inbounds i8, i8* %125, i64 %126
%128 = load i8, i8* %127
%129 = zext i8 %128 to i32
%130 = icmp eq i32 %129, 0
br i1 %130, label %131, label %142
131: ; preds = %124
%132 = load i8*, i8** %12
%133 = load i64, i64* %16
%134 = add i64 %133, 1
%135 = getelementptr inbounds i8, i8* %132, i64 %134
%136 = load i8, i8* %135
%137 = zext i8 %136 to i32
%138 = icmp eq i32 %137, 0
br i1 %138, label %139, label %142
139: ; preds = %131
%140 = load i64, i64* %16
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0), i64 %140)
br label %179
142: ; preds = %131, %124
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
%144 = load i8*, i8** %12
%145 = load i64, i64* %16
%146 = getelementptr inbounds i8, i8* %144, i64 %145
%147 = bitcast i8* %146 to i32*
%148 = load i32, i32* %147
%149 = load i8*, i8** %12
%150 = load i64, i64* %16
%151 = add i64 %150, 14
%152 = getelementptr inbounds i8, i8* %149, i64 %151
%153 = bitcast i8* %152 to i32*
%154 = load i32, i32* %153
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0), i32 %148, i32 %154)
%156 = load i32, i32* %7
%157 = icmp ne i32 %156, 0
br i1 %157, label %158, label %176
158: ; preds = %142
%159 = load i64, i64* %16
store i64 %159, i64* %17
br label %160
160: ; preds = %172, %158
%161 = load i64, i64* %17
%162 = load i64, i64* %16
%163 = add i64 %162, 32
%164 = icmp ult i64 %161, %163
br i1 %164, label %165, label %175
165: ; preds = %160
%166 = load i8*, i8** %12
%167 = load i64, i64* %17
%168 = getelementptr inbounds i8, i8* %166, i64 %167
%169 = load i8, i8* %168
%170 = zext i8 %169 to i32
%171 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i32 %170)
br label %172
172: ; preds = %165
%173 = load i64, i64* %17
%174 = add i64 %173, 1
store i64 %174, i64* %17
br label %160
175: ; preds = %160
br label %176
176: ; preds = %175, %142
%177 = load i64, i64* %16
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0), i64 %177)
br label %179
179: ; preds = %176, %139
br label %180
180: ; preds = %179
%181 = load i64, i64* %16
%182 = add i64 %181, 32
store i64 %182, i64* %16
br label %119
183: ; preds = %119
br label %184
184: ; preds = %183, %106
br label %185
185: ; preds = %184
%186 = load i64, i64* %15
%187 = add i64 %186, 1
store i64 %187, i64* %15
br label %101
188: ; preds = %101
%189 = load i8*, i8** %12
%190 = call i32 @free(i8* %189)
%191 = call i32 @putchar(i8 signext 10)
%192 = load i32, i32* %14
%193 = icmp eq i32 %192, 1
br i1 %193, label %194, label %197
194: ; preds = %188
%195 = call i32 @puts(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.19, i64 0, i64 0))
%196 = call i32 @puts(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.20, i64 0, i64 0))
br label %201
197: ; preds = %188
%198 = load i32, i32* %14
%199 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.21, i64 0, i64 0), i32 %198)
%200 = call i32 @puts(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.22, i64 0, i64 0))
br label %201
201: ; preds = %197, %194
store i32 0, i32* %3
br label %202
202: ; preds = %201, %97, %84, %63
%203 = load i32, i32* %3
ret i32 %203
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@main.longopts = internal global [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 118 }]
@.str = [5 x i8] c"help\00"
@.str.1 = [8 x i8] c"verbose\00"
@.str.2 = [3 x i8] c"vh\00"
@.str.3 = [26 x i8] c"%s: invalid option -- %c\0A\00"
@optopt = global i32 0
@.str.4 = [22 x i8] c"See %s -h for usage.\0A\00"
@optind = global i32 0
@.str.5 = [71 x i8] c"Warning: This is free software; see the source for copying conditions.\00"
@.str.6 = [89 x i8] c"There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\0A\00"
@.str.7 = [19 x i8] c"Opening VBIOS: %s\0A\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [19 x i8] c"%s: can't open %s\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.10 = [13 x i8] c"Length: %ld\0A\00"
@.str.11 = [20 x i8] c"%s: out of memory!\0A\00"
@.str.12 = [45 x i8] c"%s: incomplete read occurred during fread()\0A\00"
@.str.13 = [42 x i8] c"\0A#%d possible VESA modes table @ 0x%08lx\0A\00"
@.str.14 = [33 x i8] c"--- an empty modeline @ 0x%08lx\0A\00"
@.str.15 = [5 x i8] c"--- \00"
@.str.16 = [7 x i8] c"%dx%d \00"
@.str.17 = [6 x i8] c"%02x \00"
@.str.18 = [11 x i8] c"@ 0x%08lx\0A\00"
@.str.19 = [56 x i8] c"[+] We found 1 VESA table, which is the correct number.\00"
@.str.20 = [63 x i8] c"[+] VBIOS Resolution modding should be working. Happy Hacking!\00"
@.str.21 = [56 x i8] c"[!] Unexpected, we found %d VESA tables. What's wrong?\0A\00"
@.str.22 = [46 x i8] c"[!] VBIOS Resolution modding may not working.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
br label %4
4: ; preds = %6, %2
%5 = phi i1 [ true, %2 ], [ false, %6 ]
br label %6
6: ; preds = %8, %4
%7 = tail call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.longopts, i64 0, i64 0), i32* null)
switch i32 %7, label %8 [
i32 -1, label %16
i32 118, label %4
i32 104, label %9
i32 63, label %12
]
8: ; preds = %6, %12
br label %6
9: ; preds = %6
%10 = tail call i32 @show_usage(i8* %3)
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %6
%13 = load i32, i32* @optopt
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %3, i32 %13)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %3)
br label %8
16: ; preds = %6
%17 = load i32, i32* @optind
%18 = icmp slt i32 %17, %0
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = sext i32 %17 to i64
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([89 x i8], [89 x i8]* @.str.6, i64 0, i64 0))
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %22)
%26 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %31, label %33
28: ; preds = %16
%29 = tail call i32 @show_usage(i8* %3)
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %19
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %3, i8* %22)
br label %115
33: ; preds = %19
%34 = load i32, i32* @SEEK_END
%35 = tail call i32 @fseek(i32* %26, i32 0, i32 %34)
%36 = tail call i64 @ftell(i32* %26)
%37 = load i32, i32* @SEEK_SET
%38 = tail call i32 @fseek(i32* %26, i32 0, i32 %37)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i64 %36)
%40 = trunc i64 %36 to i32
%41 = tail call i8* @malloc(i32 %40)
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %45
43: ; preds = %33
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %3)
br label %115
45: ; preds = %33
%46 = tail call i64 @fread(i8* %41, i32 1, i64 %36, i32* %26)
%47 = tail call i32 @fclose(i32* %26)
%48 = icmp eq i64 %46, %36
br i1 %48, label %49, label %52
49: ; preds = %45
%50 = add i64 %36, -30
%51 = icmp eq i64 %50, 0
br i1 %51, label %54, label %59
52: ; preds = %45
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0), i8* %3)
br label %115
54: ; preds = %105, %49
%55 = phi i32 [ 0, %49 ], [ %106, %105 ]
%56 = tail call i32 @free(i8* %41)
%57 = tail call i32 @putchar(i8 signext 10)
%58 = icmp eq i32 %55, 1
br i1 %58, label %109, label %112
59: ; preds = %49, %105
%60 = phi i64 [ %107, %105 ], [ 0, %49 ]
%61 = phi i32 [ %106, %105 ], [ 0, %49 ]
%62 = getelementptr inbounds i8, i8* %41, i64 %60
%63 = tail call i64 @meet_vesa_table(i8* %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %105, label %65
65: ; preds = %59
%66 = add nsw i32 %61, 1
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.13, i64 0, i64 0), i32 %66, i64 %60)
%68 = add i64 %60, 512
%69 = icmp ult i64 %60, -512
br i1 %69, label %70, label %105
70: ; preds = %65, %100
%71 = phi i64 [ %103, %100 ], [ %60, %65 ]
%72 = getelementptr inbounds i8, i8* %41, i64 %71
%73 = load i8, i8* %72
%74 = icmp eq i8 %73, 0
br i1 %74, label %75, label %80
75: ; preds = %70
%76 = add nuw i64 %71, 1
%77 = getelementptr inbounds i8, i8* %41, i64 %76
%78 = load i8, i8* %77
%79 = icmp eq i8 %78, 0
br i1 %79, label %100, label %80
80: ; preds = %75, %70
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
%82 = bitcast i8* %72 to i32*
%83 = load i32, i32* %82
%84 = add i64 %71, 14
%85 = getelementptr inbounds i8, i8* %41, i64 %84
%86 = bitcast i8* %85 to i32*
%87 = load i32, i32* %86
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0), i32 %83, i32 %87)
br i1 %5, label %100, label %89
89: ; preds = %80
%90 = add i64 %71, 32
%91 = icmp ult i64 %71, -32
br i1 %91, label %92, label %100
92: ; preds = %89, %92
%93 = phi i64 [ %98, %92 ], [ %71, %89 ]
%94 = getelementptr inbounds i8, i8* %41, i64 %93
%95 = load i8, i8* %94
%96 = zext i8 %95 to i32
%97 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i32 %96)
%98 = add nuw i64 %93, 1
%99 = icmp ult i64 %98, %90
br i1 %99, label %92, label %100
100: ; preds = %92, %80, %89, %75
%101 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0), %75 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0), %89 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0), %80 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0), %92 ]
%102 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %101, i64 %71)
%103 = add i64 %71, 32
%104 = icmp ult i64 %103, %68
br i1 %104, label %70, label %105
105: ; preds = %100, %65, %59
%106 = phi i32 [ %61, %59 ], [ %66, %65 ], [ %66, %100 ]
%107 = add nuw i64 %60, 1
%108 = icmp eq i64 %107, %50
br i1 %108, label %54, label %59
109: ; preds = %54
%110 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.19, i64 0, i64 0))
%111 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.20, i64 0, i64 0))
br label %115
112: ; preds = %54
%113 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.21, i64 0, i64 0), i32 %55)
%114 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.22, i64 0, i64 0))
br label %115
115: ; preds = %43, %109, %112, %52, %31
%116 = phi i32 [ 1, %31 ], [ 1, %43 ], [ 1, %52 ], [ 0, %112 ], [ 0, %109 ]
ret i32 %116
}