#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 omapfb_plane_info {
  scalar_t__ yoffset;
  scalar_t__ size;
  scalar_t__ enabled;
};
struct omapfb_mem_info {
  scalar_t__ yoffset;
  scalar_t__ size;
  scalar_t__ enabled;
};
struct fb_var_screeninfo {
  scalar_t__ yoffset;
  scalar_t__ size;
  scalar_t__ enabled;
};

/* Variables and functions */
int /*<<< orphan*/ FBIOGET_VSCREENINFO;
int /*<<< orphan*/ FBIOPAN_DISPLAY;
int /*<<< orphan*/ KDSETMODE;
struct omapfb_plane_info *KD_TEXT;
int /*<<< orphan*/ OMAPFB_QUERY_MEM;
int /*<<< orphan*/ OMAPFB_QUERY_PLANE;
int /*<<< orphan*/ OMAPFB_SETUP_MEM;
int /*<<< orphan*/ OMAPFB_SETUP_PLANE;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
int ioctl(int, int /*<<< orphan*/, struct omapfb_plane_info *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int main() {
  struct fb_var_screeninfo fbvar;
  struct omapfb_plane_info pi;
  struct omapfb_mem_info mi;
  int ret, fbdev, kbdfd;
  fbdev = open("/dev/fb0", O_RDWR);
  if (fbdev == -1) {
    perror("open fb0");
    goto end_fb0;
  }
  ret = ioctl(fbdev, FBIOGET_VSCREENINFO, &fbvar);
  if (ret == -1) {
    perror("FBIOGET_VSCREENINFO ioctl");
    goto end_fb0;
  }
  if (fbvar.yoffset != 0) {
    printf("fixing yoffset.. ");
    fbvar.yoffset = 0;
    ret = ioctl(fbdev, FBIOPAN_DISPLAY, &fbvar);
    if (ret < 0)
      perror("ioctl FBIOPAN_DISPLAY");
    else
      printf("ok\n");
  }
end_fb0:
  if (fbdev >= 0)
    close(fbdev);
  fbdev = open("/dev/fb1", O_RDWR);
  if (fbdev == -1) {
    perror("open fb1");
    goto end_fb1;
  }
  ret = ioctl(fbdev, OMAPFB_QUERY_PLANE, &pi);
  ret |= ioctl(fbdev, OMAPFB_QUERY_MEM, &mi);
  if (ret != 0)
    perror("QUERY_*");
  pi.enabled = 0;
  ret = ioctl(fbdev, OMAPFB_SETUP_PLANE, &pi);
  if (ret != 0)
    perror("SETUP_PLANE");
  mi.size = 0;
  ret = ioctl(fbdev, OMAPFB_SETUP_MEM, &mi);
  if (ret != 0)
    perror("SETUP_MEM");
end_fb1:
  if (fbdev >= 0)
    close(fbdev);
  kbdfd = open("/dev/tty", O_RDWR);
  if (kbdfd == -1) {
    perror("open /dev/tty");
    return 1;
  }
  if (ioctl(kbdfd, KDSETMODE, KD_TEXT) == -1)
    perror("KDSETMODE KD_TEXT");
  close(kbdfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
lea    0xe91(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0xffffffff,-0x58(%rbp)
jne    1192 <main+0x42>
lea    0xe81(%rip),%rdi
call   1070 <perror@plt>
jmp    122d <main+0xdd>
mov    -0x58(%rbp),%edi
mov    0x2e14(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0xffffffff,-0x54(%rbp)
jne    11c5 <main+0x75>
lea    0xe57(%rip),%rdi
call   1070 <perror@plt>
jmp    122d <main+0xdd>
cmpq   $0x0,-0x20(%rbp)
je     1228 <main+0xd8>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x58(%rbp),%edi
mov    0x2dd2(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    1217 <main+0xc7>
lea    0xe31(%rip),%rdi
call   1070 <perror@plt>
jmp    1223 <main+0xd3>
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
jmp    1228 <main+0xd8>
jmp    122d <main+0xdd>
cmpl   $0x0,-0x58(%rbp)
jl     123f <main+0xef>
mov    -0x58(%rbp),%edi
call   1050 <close@plt>
mov    0x2d92(%rip),%rax
mov    (%rax),%esi
lea    0xe09(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0xffffffff,-0x58(%rbp)
jne    1272 <main+0x122>
lea    0xdf9(%rip),%rdi
call   1070 <perror@plt>
jmp    132c <main+0x1dc>
mov    -0x58(%rbp),%edi
mov    0x2d24(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x54(%rbp)
mov    -0x58(%rbp),%edi
mov    0x2d5c(%rip),%rax
mov    (%rax),%esi
lea    -0x50(%rbp),%rdx
call   1040 <ioctl@plt>
or     -0x54(%rbp),%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     12bb <main+0x16b>
lea    0xdb4(%rip),%rdi
call   1070 <perror@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x58(%rbp),%edi
mov    0x2ceb(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     12f1 <main+0x1a1>
lea    0xd86(%rip),%rdi
call   1070 <perror@plt>
movq   $0x0,-0x48(%rbp)
mov    -0x58(%rbp),%edi
mov    0x2ca5(%rip),%rax
mov    (%rax),%esi
lea    -0x50(%rbp),%rdx
call   1040 <ioctl@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
je     1327 <main+0x1d7>
lea    0xd5c(%rip),%rdi
call   1070 <perror@plt>
jmp    132c <main+0x1dc>
cmpl   $0x0,-0x58(%rbp)
jl     133e <main+0x1ee>
mov    -0x58(%rbp),%edi
call   1050 <close@plt>
mov    0x2c93(%rip),%rax
mov    (%rax),%esi
lea    0xd3f(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0xffffffff,-0x5c(%rbp)
jne    1378 <main+0x228>
lea    0xd21(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b7 <main+0x267>
mov    -0x5c(%rbp),%edi
mov    0x2c4e(%rip),%rax
mov    (%rax),%esi
mov    0x2c5d(%rip),%rax
mov    (%rax),%rdx
call   1040 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    13a8 <main+0x258>
lea    0xcf3(%rip),%rdi
call   1070 <perror@plt>
mov    -0x5c(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    0x2e69(%rip),%r14
mov    (%r14),%esi
lea    0xe87(%rip),%rdi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     12e8 <main+0x188>
mov    %eax,%ebx
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     131a <main+0x1ba>
cmpq   $0x0,0x8(%rsp)
je     11ed <main+0x8d>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,0x8(%rsp)
mov    0x2df5(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
test   %eax,%eax
js     1377 <main+0x217>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
js     11f8 <main+0x98>
mov    %ebx,%edi
call   1060 <close@plt>
mov    (%r14),%esi
lea    0xe52(%rip),%rdi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     12f9 <main+0x199>
mov    %eax,%ebx
mov    0x2d87(%rip),%rax
mov    (%rax),%esi
lea    0x38(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
mov    %eax,%ebp
mov    0x2dc0(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
or     %ebp,%eax
jne    132b <main+0x1cb>
movq   $0x0,0x48(%rsp)
mov    0x2d62(%rip),%rax
mov    (%rax),%esi
lea    0x38(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
test   %eax,%eax
jne    133c <main+0x1dc>
movq   $0x0,0x28(%rsp)
mov    0x2d2c(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
test   %eax,%eax
jne    134d <main+0x1ed>
test   %ebx,%ebx
js     129d <main+0x13d>
mov    %ebx,%edi
call   1060 <close@plt>
mov    (%r14),%esi
lea    0xde2(%rip),%rdi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     1307 <main+0x1a7>
mov    %eax,%ebx
mov    0x2d16(%rip),%rax
mov    (%rax),%esi
mov    0x2d25(%rip),%rax
mov    (%rax),%rdx
mov    %ebx,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1366 <main+0x206>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xd1a(%rip),%rdi
call   1080 <perror@plt>
jmp    11f8 <main+0x98>
lea    0xd5d(%rip),%rdi
call   1080 <perror@plt>
jmp    129d <main+0x13d>
lea    0xd76(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%eax
jmp    12df <main+0x17f>
lea    0xcf1(%rip),%rdi
call   1080 <perror@plt>
jmp    11ed <main+0x8d>
lea    0xd34(%rip),%rdi
call   1080 <perror@plt>
jmp    1246 <main+0xe6>
lea    0xd2b(%rip),%rdi
call   1080 <perror@plt>
jmp    126c <main+0x10c>
lea    0xd26(%rip),%rdi
call   1080 <perror@plt>
test   %ebx,%ebx
jns    1296 <main+0x136>
jmp    129d <main+0x13d>
lea    0xd25(%rip),%rdi
call   1080 <perror@plt>
jmp    12d6 <main+0x176>
lea    0xcc0(%rip),%rdi
call   1080 <perror@plt>
jmp    11ed <main+0x8d>

LLVM IR (-O0):
%struct.omapfb_plane_info = type { i64, i64, i64 }
%struct.fb_var_screeninfo = type { i64, i64, i64 }
%struct.omapfb_mem_info = type { i64, i64, i64 }
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@.str.1 = [9 x i8] c"open fb0\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.2 = [26 x i8] c"FBIOGET_VSCREENINFO ioctl\00"
@.str.3 = [18 x i8] c"fixing yoffset.. \00"
@FBIOPAN_DISPLAY = global i32 0
@.str.4 = [22 x i8] c"ioctl FBIOPAN_DISPLAY\00"
@.str.5 = [4 x i8] c"ok\0A\00"
@.str.6 = [9 x i8] c"/dev/fb1\00"
@.str.7 = [9 x i8] c"open fb1\00"
@OMAPFB_QUERY_PLANE = global i32 0
@OMAPFB_QUERY_MEM = global i32 0
@.str.8 = [8 x i8] c"QUERY_*\00"
@OMAPFB_SETUP_PLANE = global i32 0
@.str.9 = [12 x i8] c"SETUP_PLANE\00"
@OMAPFB_SETUP_MEM = global i32 0
@.str.10 = [10 x i8] c"SETUP_MEM\00"
@.str.11 = [9 x i8] c"/dev/tty\00"
@.str.12 = [14 x i8] c"open /dev/tty\00"
@KDSETMODE = global i32 0
@KD_TEXT = global %struct.omapfb_plane_info* null
@.str.13 = [18 x i8] c"KDSETMODE KD_TEXT\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.fb_var_screeninfo
%3 = alloca %struct.omapfb_plane_info
%4 = alloca %struct.omapfb_mem_info
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = load i32, i32* @O_RDWR
%9 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %42
14: ; preds = %0
%15 = load i32, i32* %6
%16 = load i32, i32* @FBIOGET_VSCREENINFO
%17 = bitcast %struct.fb_var_screeninfo* %2 to %struct.omapfb_plane_info*
%18 = call i32 @ioctl(i32 %15, i32 %16, %struct.omapfb_plane_info* %17)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %42
23: ; preds = %14
%24 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %2, i32 0, i32 0
%25 = load i64, i64* %24
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %41
27: ; preds = %23
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%29 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %2, i32 0, i32 0
store i64 0, i64* %29
%30 = load i32, i32* %6
%31 = load i32, i32* @FBIOPAN_DISPLAY
%32 = bitcast %struct.fb_var_screeninfo* %2 to %struct.omapfb_plane_info*
%33 = call i32 @ioctl(i32 %30, i32 %31, %struct.omapfb_plane_info* %32)
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %27
%37 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %40
38: ; preds = %27
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
br label %41
41: ; preds = %40, %23
br label %42
42: ; preds = %41, %21, %12
%43 = load i32, i32* %6
%44 = icmp sge i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %6
%47 = call i32 @close(i32 %46)
br label %48
48: ; preds = %45, %42
%49 = load i32, i32* @O_RDWR
%50 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %49)
store i32 %50, i32* %6
%51 = load i32, i32* %6
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %55
53: ; preds = %48
%54 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %89
55: ; preds = %48
%56 = load i32, i32* %6
%57 = load i32, i32* @OMAPFB_QUERY_PLANE
%58 = call i32 @ioctl(i32 %56, i32 %57, %struct.omapfb_plane_info* %3)
store i32 %58, i32* %5
%59 = load i32, i32* %6
%60 = load i32, i32* @OMAPFB_QUERY_MEM
%61 = bitcast %struct.omapfb_mem_info* %4 to %struct.omapfb_plane_info*
%62 = call i32 @ioctl(i32 %59, i32 %60, %struct.omapfb_plane_info* %61)
%63 = load i32, i32* %5
%64 = or i32 %63, %62
store i32 %64, i32* %5
%65 = load i32, i32* %5
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %55
%68 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %69
69: ; preds = %67, %55
%70 = getelementptr inbounds %struct.omapfb_plane_info, %struct.omapfb_plane_info* %3, i32 0, i32 2
store i64 0, i64* %70
%71 = load i32, i32* %6
%72 = load i32, i32* @OMAPFB_SETUP_PLANE
%73 = call i32 @ioctl(i32 %71, i32 %72, %struct.omapfb_plane_info* %3)
store i32 %73, i32* %5
%74 = load i32, i32* %5
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %69
%77 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
br label %78
78: ; preds = %76, %69
%79 = getelementptr inbounds %struct.omapfb_mem_info, %struct.omapfb_mem_info* %4, i32 0, i32 1
store i64 0, i64* %79
%80 = load i32, i32* %6
%81 = load i32, i32* @OMAPFB_SETUP_MEM
%82 = bitcast %struct.omapfb_mem_info* %4 to %struct.omapfb_plane_info*
%83 = call i32 @ioctl(i32 %80, i32 %81, %struct.omapfb_plane_info* %82)
store i32 %83, i32* %5
%84 = load i32, i32* %5
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %88
86: ; preds = %78
%87 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
br label %88
88: ; preds = %86, %78
br label %89
89: ; preds = %88, %53
%90 = load i32, i32* %6
%91 = icmp sge i32 %90, 0
br i1 %91, label %92, label %95
92: ; preds = %89
%93 = load i32, i32* %6
%94 = call i32 @close(i32 %93)
br label %95
95: ; preds = %92, %89
%96 = load i32, i32* @O_RDWR
%97 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i32 %96)
store i32 %97, i32* %7
%98 = load i32, i32* %7
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %102
100: ; preds = %95
%101 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %1
br label %113
102: ; preds = %95
%103 = load i32, i32* %7
%104 = load i32, i32* @KDSETMODE
%105 = load %struct.omapfb_plane_info*, %struct.omapfb_plane_info** @KD_TEXT
%106 = call i32 @ioctl(i32 %103, i32 %104, %struct.omapfb_plane_info* %105)
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %110
108: ; preds = %102
%109 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0))
br label %110
110: ; preds = %108, %102
%111 = load i32, i32* %7
%112 = call i32 @close(i32 %111)
store i32 0, i32* %1
br label %113
113: ; preds = %110, %100
%114 = load i32, i32* %1
ret i32 %114
}

LLVM IR (-O2):
%struct.omapfb_plane_info = type { i64, i64, i64 }
%struct.fb_var_screeninfo = type { i64, i64, i64 }
%struct.omapfb_mem_info = type { i64, i64, i64 }
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@.str.1 = [9 x i8] c"open fb0\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.2 = [26 x i8] c"FBIOGET_VSCREENINFO ioctl\00"
@.str.3 = [18 x i8] c"fixing yoffset.. \00"
@FBIOPAN_DISPLAY = global i32 0
@.str.4 = [22 x i8] c"ioctl FBIOPAN_DISPLAY\00"
@.str.6 = [9 x i8] c"/dev/fb1\00"
@.str.7 = [9 x i8] c"open fb1\00"
@OMAPFB_QUERY_PLANE = global i32 0
@OMAPFB_QUERY_MEM = global i32 0
@.str.8 = [8 x i8] c"QUERY_*\00"
@OMAPFB_SETUP_PLANE = global i32 0
@.str.9 = [12 x i8] c"SETUP_PLANE\00"
@OMAPFB_SETUP_MEM = global i32 0
@.str.10 = [10 x i8] c"SETUP_MEM\00"
@.str.11 = [9 x i8] c"/dev/tty\00"
@.str.12 = [14 x i8] c"open /dev/tty\00"
@KDSETMODE = global i32 0
@KD_TEXT = global %struct.omapfb_plane_info* null
@.str.13 = [18 x i8] c"KDSETMODE KD_TEXT\00"
@str = [3 x i8] c"ok\00"
define i32 @main() {
%1 = alloca %struct.fb_var_screeninfo
%2 = alloca %struct.omapfb_plane_info
%3 = alloca %struct.omapfb_mem_info
%4 = bitcast %struct.fb_var_screeninfo* %1 to i8*
%5 = bitcast %struct.omapfb_plane_info* %2 to i8*
%6 = bitcast %struct.omapfb_mem_info* %3 to i8*
%7 = load i32, i32* @O_RDWR
%8 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %36
12: ; preds = %0
%13 = load i32, i32* @FBIOGET_VSCREENINFO
%14 = bitcast %struct.fb_var_screeninfo* %1 to %struct.omapfb_plane_info*
%15 = call i32 @ioctl(i32 %8, i32 %13, %struct.omapfb_plane_info* %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %32
19: ; preds = %12
%20 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 0
%21 = load i64, i64* %20
%22 = icmp eq i64 %21, 0
br i1 %22, label %32, label %23
23: ; preds = %19
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i64 0, i64* %20
%25 = load i32, i32* @FBIOPAN_DISPLAY
%26 = call i32 @ioctl(i32 %8, i32 %25, %struct.omapfb_plane_info* %14)
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %32
30: ; preds = %23
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %19, %30, %28, %17
%33 = icmp sgt i32 %8, -1
br i1 %33, label %34, label %36
34: ; preds = %32
%35 = call i32 @close(i32 %8)
br label %36
36: ; preds = %10, %34, %32
%37 = load i32, i32* @O_RDWR
%38 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %37)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %70
42: ; preds = %36
%43 = load i32, i32* @OMAPFB_QUERY_PLANE
%44 = call i32 @ioctl(i32 %38, i32 %43, %struct.omapfb_plane_info* %2)
%45 = load i32, i32* @OMAPFB_QUERY_MEM
%46 = bitcast %struct.omapfb_mem_info* %3 to %struct.omapfb_plane_info*
%47 = call i32 @ioctl(i32 %38, i32 %45, %struct.omapfb_plane_info* %46)
%48 = or i32 %47, %44
%49 = icmp eq i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %42
%51 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %52
52: ; preds = %50, %42
%53 = getelementptr inbounds %struct.omapfb_plane_info, %struct.omapfb_plane_info* %2, i64 0, i32 2
store i64 0, i64* %53
%54 = load i32, i32* @OMAPFB_SETUP_PLANE
%55 = call i32 @ioctl(i32 %38, i32 %54, %struct.omapfb_plane_info* %2)
%56 = icmp eq i32 %55, 0
br i1 %56, label %59, label %57
57: ; preds = %52
%58 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
br label %59
59: ; preds = %57, %52
%60 = getelementptr inbounds %struct.omapfb_mem_info, %struct.omapfb_mem_info* %3, i64 0, i32 1
store i64 0, i64* %60
%61 = load i32, i32* @OMAPFB_SETUP_MEM
%62 = call i32 @ioctl(i32 %38, i32 %61, %struct.omapfb_plane_info* %46)
%63 = icmp eq i32 %62, 0
br i1 %63, label %66, label %64
64: ; preds = %59
%65 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
br label %66
66: ; preds = %59, %64
%67 = icmp sgt i32 %38, -1
br i1 %67, label %68, label %70
68: ; preds = %66
%69 = call i32 @close(i32 %38)
br label %70
70: ; preds = %40, %68, %66
%71 = load i32, i32* @O_RDWR
%72 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i32 %71)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %76
74: ; preds = %70
%75 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
br label %85
76: ; preds = %70
%77 = load i32, i32* @KDSETMODE
%78 = load %struct.omapfb_plane_info*, %struct.omapfb_plane_info** @KD_TEXT
%79 = call i32 @ioctl(i32 %72, i32 %77, %struct.omapfb_plane_info* %78)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %83
81: ; preds = %76
%82 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0))
br label %83
83: ; preds = %81, %76
%84 = call i32 @close(i32 %72)
br label %85
85: ; preds = %83, %74
%86 = phi i32 [ 1, %74 ], [ 0, %83 ]
ret i32 %86
}