#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 */
typedef struct TYPE_8__ TYPE_4__;
typedef struct TYPE_7__ TYPE_3__;
typedef struct TYPE_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_8__ {
  int offset;
  scalar_t__ length;
};
struct TYPE_7__ {
  int length;
  scalar_t__ offset;
};
struct TYPE_6__ {
  int offset;
  int length;
};
struct TYPE_5__ {
  int offset;
  int length;
};
struct fb_var_screeninfo {
  int bits_per_pixel;
  int xres_virtual;
  int yres_virtual;
  scalar_t__ yoffset;
  scalar_t__ xoffset;
  TYPE_4__ transp;
  TYPE_3__ blue;
  TYPE_2__ green;
  TYPE_1__ red;
};

/* Variables and functions */
int /*<<< orphan*/ FBIOGET_VSCREENINFO;
int /*<<< orphan*/ FBIOPUT_VSCREENINFO;
int /*<<< orphan*/ KDGETMODE;
int /*<<< orphan*/ KDSETMODE;
int KD_TEXT;
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ PROT_WRITE;
int /*<<< orphan*/ VT_UNLOCKSWITCH;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ ioctl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, size_t);
void *mmap(int /*<<< orphan*/ *, size_t, int /*<<< orphan*/, int /*<<< orphan*/,
           int, int /*<<< orphan*/);
int /*<<< orphan*/ munmap(void *, size_t);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int i;
  int fd;
  char tty[10];
  struct fb_var_screeninfo vinfo;
  void *fb;
  size_t len;
  fd = open("/dev/fb0", O_RDWR);
  if (fd < 0) {
    fprintf(stderr, "Unable to open framebuffer\n");
    return 1;
  }
  if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0) {
    fprintf(stderr, "Could not get framebuffer info\n");
    close(fd);
    return 1;
  }
  vinfo.bits_per_pixel = 32;
  vinfo.blue.offset = 0;
  vinfo.green.offset = 8;
  vinfo.red.offset = 16;
  vinfo.transp.offset = 24;
  vinfo.red.length = vinfo.green.length = vinfo.blue.length = 8;
  vinfo.transp.length = 0;
  vinfo.xoffset = vinfo.yoffset = 0;
  len = vinfo.xres_virtual * vinfo.yres_virtual * 4;
  fb = mmap(NULL, len, PROT_WRITE, MAP_SHARED, fd, 0);
  if (fb == MAP_FAILED) {
    fprintf(stderr, "Could not map framebuffer\n");
    close(fd);
    return 1;
  }
  memset(fb, 0, len);
  munmap(fb, len);
  ioctl(fd, FBIOPUT_VSCREENINFO, &vinfo);
  close(fd);
  for (i = 0; i < 10; i++) {
    int mode;
    sprintf(tty, "/dev/tty%i", i);
    fd = open(tty, O_RDWR);
    if (fd < 0)
      continue;
    if (ioctl(fd, KDGETMODE, &mode) < 0) {
      fprintf(stderr, "Unable to get mode for tty %i.\n", i);
      close(fd);
      return 1;
    }
    if (mode != KD_TEXT)
      break;
    close(fd);
  }
  if (i == 10) {
    printf("No graphic tty found.\n");
    return 1;
  }
  printf("Graphic tty found on %s.\n", tty);
  if (ioctl(fd, KDSETMODE, KD_TEXT) < 0)
    fprintf(stderr, "Unable to set keyboard mode.\n");
  if (ioctl(fd, VT_UNLOCKSWITCH, 1) < 0)
    fprintf(stderr, "Unable to unlock terminal.\n");
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
lea    0xe47(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11ee <main+0x5e>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d0 <main+0x340>
mov    -0x18(%rbp),%edi
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
lea    -0x78(%rbp),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    123a <main+0xaa>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d0 <main+0x340>
movl   $0x20,-0x78(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x8,-0x38(%rbp)
movl   $0x10,-0x30(%rbp)
movl   $0x18,-0x58(%rbp)
movl   $0x8,-0x48(%rbp)
movl   $0x8,-0x34(%rbp)
movl   $0x8,-0x2c(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x68(%rbp)
movq   $0x0,-0x60(%rbp)
mov    -0x74(%rbp),%eax
imul   -0x70(%rbp),%eax
shl    $0x2,%eax
cltq
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rsi
mov    0x2cf4(%rip),%rax
mov    (%rax),%edx
mov    0x2d2b(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
mov    0x2cba(%rip),%rcx
cmp    (%rcx),%rax
jne    130a <main+0x17a>
mov    0x2cc2(%rip),%rax
mov    (%rax),%edi
lea    0xd56(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d0 <main+0x340>
mov    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rdx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rsi
call   1090 <munmap@plt>
mov    -0x18(%rbp),%edi
mov    0x2c8a(%rip),%rax
mov    (%rax),%esi
lea    -0x78(%rbp),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1415 <main+0x285>
lea    -0x22(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xcf6(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x22(%rbp),%rdi
mov    0x2c56(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1393 <main+0x203>
jmp    1407 <main+0x277>
mov    -0x18(%rbp),%edi
mov    0x2c4b(%rip),%rax
mov    (%rax),%esi
lea    -0x8c(%rbp),%rdx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    13e5 <main+0x255>
mov    0x2bea(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xca1(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d0 <main+0x340>
mov    -0x8c(%rbp),%eax
mov    0x2bfe(%rip),%rcx
cmp    (%rcx),%eax
je     13ff <main+0x26f>
jmp    1415 <main+0x285>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1352 <main+0x1c2>
cmpl   $0xa,-0x14(%rbp)
jne    1439 <main+0x2a9>
lea    0xc65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d0 <main+0x340>
lea    -0x22(%rbp),%rsi
lea    0xc5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
mov    0x2b63(%rip),%rax
mov    (%rax),%esi
mov    0x2b92(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1488 <main+0x2f8>
mov    0x2b30(%rip),%rax
mov    (%rax),%edi
lea    0xc3b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%edi
mov    0x2b36(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edx
mov    $0x0,%al
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    14c1 <main+0x331>
mov    0x2af7(%rip),%rax
mov    (%rax),%edi
lea    0xc20(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    0x2e1b(%rip),%r13
mov    0x0(%r13),%esi
lea    0xe50(%rip),%rdi
call   10b0 <open@plt>
test   %eax,%eax
js     13a7 <main+0x207>
mov    %eax,%ebx
mov    0x2dc2(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
js     13c0 <main+0x220>
movl   $0x20,0x18(%rsp)
movq   $0x0,0x50(%rsp)
movl   $0x18,0x38(%rsp)
movl   $0x8,0x48(%rsp)
movaps 0xde9(%rip),%xmm0
movups %xmm0,0x58(%rsp)
movq   $0x0,0x40(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x28(%rsp)
mov    0x1c(%rsp),%eax
imul   0x20(%rsp),%eax
shl    $0x2,%eax
movslq %eax,%r14
mov    0x2d5d(%rip),%rax
mov    (%rax),%edx
mov    0x2d94(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r14,%rsi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%rbp
mov    0x2d28(%rip),%rax
cmp    (%rax),%rbp
je     13d2 <main+0x232>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1060 <memset@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   10a0 <munmap@plt>
mov    0x2d30(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rdx
mov    %ebx,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
mov    %ebx,%edi
call   1080 <close@plt>
lea    0xdc2(%rip),%r14
lea    0xe(%rsp),%r15
lea    0x8(%rsp),%r12
xor    %ebp,%ebp
jmp    12d3 <main+0x133>
nopl   0x0(%rax)
mov    %ebx,%edi
call   1080 <close@plt>
add    $0x1,%ebp
cmp    $0xa,%ebp
je     1406 <main+0x266>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   10c0 <sprintf@plt>
mov    0x0(%r13),%esi
mov    %r15,%rdi
call   10b0 <open@plt>
test   %eax,%eax
js     12c7 <main+0x127>
mov    %eax,%ebx
mov    0x2cef(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r12,%rdx
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
js     1414 <main+0x274>
mov    0x8(%rsp),%eax
mov    0x2cd5(%rip),%rcx
cmp    (%rcx),%eax
je     12c0 <main+0x120>
lea    0xd75(%rip),%rdi
lea    0xe(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c7f(%rip),%rax
mov    (%rax),%esi
mov    0x2cae(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
jns    1369 <main+0x1c9>
mov    0x2c4f(%rip),%rax
mov    (%rax),%edi
lea    0xd53(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2c58(%rip),%rax
mov    (%rax),%esi
xor    %ebp,%ebp
mov    %ebx,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   1070 <ioctl@plt>
test   %rax,%rax
jns    139e <main+0x1fe>
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
lea    0xd3c(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %ebx,%edi
call   1080 <close@plt>
jmp    13f5 <main+0x255>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
lea    0xc62(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    13f0 <main+0x250>
mov    0x2be1(%rip),%rax
mov    (%rax),%edi
lea    0xc65(%rip),%rsi
jmp    13e2 <main+0x242>
mov    0x2bcf(%rip),%rax
mov    (%rax),%edi
lea    0xc73(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %ebx,%edi
call   1080 <close@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xce2(%rip),%rdi
call   1030 <puts@plt>
jmp    13f0 <main+0x250>
mov    0x2b8d(%rip),%rax
mov    (%rax),%edi
lea    0xc57(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    13e9 <main+0x249>

LLVM IR (-O0):
%struct.fb_var_screeninfo = type { i32, i32, i32, i64, i64, %struct.TYPE_8__, %struct.TYPE_7__, %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_8__ = type { i32, i64 }
%struct.TYPE_7__ = type { i32, i64 }
%struct.TYPE_6__ = type { i32, i32 }
%struct.TYPE_5__ = type { i32, i32 }
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@stderr = global i32 0
@.str.1 = [28 x i8] c"Unable to open framebuffer\0A\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.2 = [32 x i8] c"Could not get framebuffer info\0A\00"
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.3 = [27 x i8] c"Could not map framebuffer\0A\00"
@FBIOPUT_VSCREENINFO = global i32 0
@.str.4 = [11 x i8] c"/dev/tty%i\00"
@KDGETMODE = global i32 0
@.str.5 = [32 x i8] c"Unable to get mode for tty %i.\0A\00"
@KD_TEXT = global i32 0
@.str.6 = [23 x i8] c"No graphic tty found.\0A\00"
@.str.7 = [26 x i8] c"Graphic tty found on %s.\0A\00"
@KDSETMODE = global i32 0
@.str.8 = [30 x i8] c"Unable to set keyboard mode.\0A\00"
@VT_UNLOCKSWITCH = global i32 0
@.str.9 = [28 x i8] c"Unable to unlock terminal.\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 [10 x i8]
%9 = alloca %struct.fb_var_screeninfo
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* @O_RDWR
%14 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %144
20: ; preds = %2
%21 = load i32, i32* %7
%22 = load i32, i32* @FBIOGET_VSCREENINFO
%23 = call i64 (i32, i32, ...) @ioctl(i32 %21, i32 %22, %struct.fb_var_screeninfo* %9)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32, i32* %7
%29 = call i32 @close(i32 %28)
store i32 1, i32* %3
br label %144
30: ; preds = %20
%31 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 0
store i32 32, i32* %31
%32 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 6
%33 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %32, i32 0, i32 1
store i64 0, i64* %33
%34 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 7
%35 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %34, i32 0, i32 0
store i32 8, i32* %35
%36 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 8
%37 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i32 0, i32 0
store i32 16, i32* %37
%38 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 5
%39 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %38, i32 0, i32 0
store i32 24, i32* %39
%40 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 6
%41 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %40, i32 0, i32 0
store i32 8, i32* %41
%42 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 7
%43 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %42, i32 0, i32 1
store i32 8, i32* %43
%44 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 8
%45 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %44, i32 0, i32 1
store i32 8, i32* %45
%46 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 5
%47 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %46, i32 0, i32 1
store i64 0, i64* %47
%48 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 3
store i64 0, i64* %48
%49 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 4
store i64 0, i64* %49
%50 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 1
%51 = load i32, i32* %50
%52 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %9, i32 0, i32 2
%53 = load i32, i32* %52
%54 = mul nsw i32 %51, %53
%55 = mul nsw i32 %54, 4
%56 = sext i32 %55 to i64
store i64 %56, i64* %11
%57 = load i64, i64* %11
%58 = load i32, i32* @PROT_WRITE
%59 = load i32, i32* @MAP_SHARED
%60 = load i32, i32* %7
%61 = call i8* @mmap(i32* null, i64 %57, i32 %58, i32 %59, i32 %60, i32 0)
store i8* %61, i8** %10
%62 = load i8*, i8** %10
%63 = load i8*, i8** @MAP_FAILED
%64 = icmp eq i8* %62, %63
br i1 %64, label %65, label %70
65: ; preds = %30
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%68 = load i32, i32* %7
%69 = call i32 @close(i32 %68)
store i32 1, i32* %3
br label %144
70: ; preds = %30
%71 = load i8*, i8** %10
%72 = load i64, i64* %11
%73 = call i32 @memset(i8* %71, i32 0, i64 %72)
%74 = load i8*, i8** %10
%75 = load i64, i64* %11
%76 = call i32 @munmap(i8* %74, i64 %75)
%77 = load i32, i32* %7
%78 = load i32, i32* @FBIOPUT_VSCREENINFO
%79 = call i64 (i32, i32, ...) @ioctl(i32 %77, i32 %78, %struct.fb_var_screeninfo* %9)
%80 = load i32, i32* %7
%81 = call i32 @close(i32 %80)
store i32 0, i32* %6
br label %82
82: ; preds = %114, %70
%83 = load i32, i32* %6
%84 = icmp slt i32 %83, 10
br i1 %84, label %85, label %117
85: ; preds = %82
%86 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%87 = load i32, i32* %6
%88 = call i32 @sprintf(i8* %86, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %87)
%89 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%90 = load i32, i32* @O_RDWR
%91 = call i32 @open(i8* %89, i32 %90)
store i32 %91, i32* %7
%92 = load i32, i32* %7
%93 = icmp slt i32 %92, 0
br i1 %93, label %94, label %95
94: ; preds = %85
br label %114
95: ; preds = %85
%96 = load i32, i32* %7
%97 = load i32, i32* @KDGETMODE
%98 = call i64 (i32, i32, ...) @ioctl(i32 %96, i32 %97, i32* %12)
%99 = icmp slt i64 %98, 0
br i1 %99, label %100, label %106
100: ; preds = %95
%101 = load i32, i32* @stderr
%102 = load i32, i32* %6
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %102)
%104 = load i32, i32* %7
%105 = call i32 @close(i32 %104)
store i32 1, i32* %3
br label %144
106: ; preds = %95
%107 = load i32, i32* %12
%108 = load i32, i32* @KD_TEXT
%109 = icmp ne i32 %107, %108
br i1 %109, label %110, label %111
110: ; preds = %106
br label %117
111: ; preds = %106
%112 = load i32, i32* %7
%113 = call i32 @close(i32 %112)
br label %114
114: ; preds = %111, %94
%115 = load i32, i32* %6
%116 = add nsw i32 %115, 1
store i32 %116, i32* %6
br label %82
117: ; preds = %110, %82
%118 = load i32, i32* %6
%119 = icmp eq i32 %118, 10
br i1 %119, label %120, label %122
120: ; preds = %117
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %144
122: ; preds = %117
%123 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* %123)
%125 = load i32, i32* %7
%126 = load i32, i32* @KDSETMODE
%127 = load i32, i32* @KD_TEXT
%128 = call i64 (i32, i32, ...) @ioctl(i32 %125, i32 %126, i32 %127)
%129 = icmp slt i64 %128, 0
br i1 %129, label %130, label %133
130: ; preds = %122
%131 = load i32, i32* @stderr
%132 = call i32 (i32, i8*, ...) @fprintf(i32 %131, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
br label %133
133: ; preds = %130, %122
%134 = load i32, i32* %7
%135 = load i32, i32* @VT_UNLOCKSWITCH
%136 = call i64 (i32, i32, ...) @ioctl(i32 %134, i32 %135, i32 1)
%137 = icmp slt i64 %136, 0
br i1 %137, label %138, label %141
138: ; preds = %133
%139 = load i32, i32* @stderr
%140 = call i32 (i32, i8*, ...) @fprintf(i32 %139, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
br label %141
141: ; preds = %138, %133
%142 = load i32, i32* %7
%143 = call i32 @close(i32 %142)
store i32 0, i32* %3
br label %144
144: ; preds = %141, %120, %100, %65, %25, %17
%145 = load i32, i32* %3
ret i32 %145
}

LLVM IR (-O2):
%struct.fb_var_screeninfo = type { i32, i32, i32, i64, i64, %struct.TYPE_8__, %struct.TYPE_7__, %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_8__ = type { i32, i64 }
%struct.TYPE_7__ = type { i32, i64 }
%struct.TYPE_6__ = type { i32, i32 }
%struct.TYPE_5__ = type { i32, i32 }
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@stderr = global i32 0
@.str.1 = [28 x i8] c"Unable to open framebuffer\0A\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.2 = [32 x i8] c"Could not get framebuffer info\0A\00"
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.3 = [27 x i8] c"Could not map framebuffer\0A\00"
@FBIOPUT_VSCREENINFO = global i32 0
@.str.4 = [11 x i8] c"/dev/tty%i\00"
@KDGETMODE = global i32 0
@.str.5 = [32 x i8] c"Unable to get mode for tty %i.\0A\00"
@KD_TEXT = global i32 0
@.str.7 = [26 x i8] c"Graphic tty found on %s.\0A\00"
@KDSETMODE = global i32 0
@.str.8 = [30 x i8] c"Unable to set keyboard mode.\0A\00"
@VT_UNLOCKSWITCH = global i32 0
@.str.9 = [28 x i8] c"Unable to unlock terminal.\0A\00"
@str = [22 x i8] c"No graphic tty found.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i8]
%4 = alloca %struct.fb_var_screeninfo
%5 = alloca i32
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = bitcast %struct.fb_var_screeninfo* %4 to i8*
%8 = load i32, i32* @O_RDWR
%9 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %98
14: ; preds = %2
%15 = load i32, i32* @FBIOGET_VSCREENINFO
%16 = call i64 (i32, i32, ...) @ioctl(i32 %9, i32 %15, %struct.fb_var_screeninfo* %4)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @close(i32 %9)
br label %98
22: ; preds = %14
%23 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i64 0, i32 0
store i32 32, i32* %23
%24 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i64 0, i32 6, i32 1
store i64 0, i64* %24
%25 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i64 0, i32 7, i32 0
%26 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i64 0, i32 5, i32 0
store i32 24, i32* %26
%27 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i64 0, i32 6, i32 0
store i32 8, i32* %27
%28 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> <i32 8, i32 8, i32 16, i32 8>, <4 x i32>* %28
%29 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i64 0, i32 5, i32 1
store i64 0, i64* %29
%30 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i64 0, i32 3
%31 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i64 0, i32 1
%32 = bitcast i64* %30 to i8*
%33 = load i32, i32* %31
%34 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i64 0, i32 2
%35 = load i32, i32* %34
%36 = shl i32 %33, 2
%37 = mul i32 %36, %35
%38 = sext i32 %37 to i64
%39 = load i32, i32* @PROT_WRITE
%40 = load i32, i32* @MAP_SHARED
%41 = call i8* @mmap(i32* null, i64 %38, i32 %39, i32 %40, i32 %9, i32 0)
%42 = load i8*, i8** @MAP_FAILED
%43 = icmp eq i8* %41, %42
br i1 %43, label %44, label %48
44: ; preds = %22
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%47 = call i32 @close(i32 %9)
br label %98
48: ; preds = %22
%49 = call i32 @memset(i8* %41, i32 0, i64 %38)
%50 = call i32 @munmap(i8* %41, i64 %38)
%51 = load i32, i32* @FBIOPUT_VSCREENINFO
%52 = call i64 (i32, i32, ...) @ioctl(i32 %9, i32 %51, %struct.fb_var_screeninfo* %4)
%53 = call i32 @close(i32 %9)
%54 = bitcast i32* %5 to i8*
br label %55
55: ; preds = %48, %75
%56 = phi i32 [ 0, %48 ], [ %76, %75 ]
%57 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %56)
%58 = load i32, i32* @O_RDWR
%59 = call i32 @open(i8* %6, i32 %58)
%60 = icmp slt i32 %59, 0
br i1 %60, label %75, label %61
61: ; preds = %55
%62 = load i32, i32* @KDGETMODE
%63 = call i64 (i32, i32, ...) @ioctl(i32 %59, i32 %62, i32* %5)
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %61
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %56)
%68 = call i32 @close(i32 %59)
br label %98
69: ; preds = %61
%70 = load i32, i32* %5
%71 = load i32, i32* @KD_TEXT
%72 = icmp eq i32 %70, %71
br i1 %72, label %73, label %80
73: ; preds = %69
%74 = call i32 @close(i32 %59)
br label %75
75: ; preds = %73, %55
%76 = add nuw nsw i32 %56, 1
%77 = icmp eq i32 %76, 10
br i1 %77, label %78, label %55
78: ; preds = %75
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %98
80: ; preds = %69
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%82 = load i32, i32* @KDSETMODE
%83 = load i32, i32* @KD_TEXT
%84 = call i64 (i32, i32, ...) @ioctl(i32 %59, i32 %82, i32 %83)
%85 = icmp slt i64 %84, 0
br i1 %85, label %86, label %89
86: ; preds = %80
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
br label %89
89: ; preds = %86, %80
%90 = load i32, i32* @VT_UNLOCKSWITCH
%91 = call i64 (i32, i32, ...) @ioctl(i32 %59, i32 %90, i32 1)
%92 = icmp slt i64 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %89
%94 = load i32, i32* @stderr
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
br label %96
96: ; preds = %93, %89
%97 = call i32 @close(i32 %59)
br label %98
98: ; preds = %65, %96, %78, %44, %18, %11
%99 = phi i32 [ 1, %11 ], [ 1, %18 ], [ 1, %44 ], [ 1, %78 ], [ 0, %96 ], [ 1, %65 ]
ret i32 %99
}