#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 fb_var_screeninfo {
  int rotate;
  unsigned int yres;
  unsigned int xres;
  unsigned int xres_virtual;
  int yres_virtual;
  unsigned int yoffset;
};

/* Variables and functions */
int EOF;
int /*<<< orphan*/ FBIOGET_VSCREENINFO;
int /*<<< orphan*/ FBIOPUT_VSCREENINFO;
int /*<<< orphan*/ O_RDWR;
int atoi(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int getopt(int, char **, char *);
int ioctl(int, int /*<<< orphan*/, struct fb_var_screeninfo *);
int open(char *, int /*<<< orphan*/);
char *optarg;
int optind;
int optopt;
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int rotatefb_main(int argc, char *argv[]) {
  int c;
  char *fbdev = "/dev/graphics/fb0";
  int rotation = 0;
  int fd;
  int res;
  struct fb_var_screeninfo fbinfo;
  do {
    c = getopt(argc, argv, "d:");
    if (c == EOF)
      break;
    switch (c) {
    case 'd':
      fbdev = optarg;
      break;
    case '?':
      fprintf(stderr, "%s: invalid option -%c\n", argv[0], optopt);
      exit(1);
    }
  } while (1);
  if (optind + 1 != argc) {
    fprintf(stderr, "%s: specify rotation\n", argv[0]);
    exit(1);
  }
  rotation = atoi(argv[optind]);
  fd = open(fbdev, O_RDWR);
  if (fd < 0) {
    fprintf(stderr, "cannot open %s\n", fbdev);
    return 1;
  }
  res = ioctl(fd, FBIOGET_VSCREENINFO, &fbinfo);
  if (res < 0) {
    fprintf(stderr, "failed to get fbinfo: %s\n", strerror(errno));
    return 1;
  }
  if ((fbinfo.rotate ^ rotation) & 1) {
    unsigned int xres = fbinfo.yres;
    fbinfo.yres = fbinfo.xres;
    fbinfo.xres = xres;
    fbinfo.xres_virtual = fbinfo.xres;
    fbinfo.yres_virtual = fbinfo.yres * 2;
    if (fbinfo.yoffset == xres)
      fbinfo.yoffset = fbinfo.yres;
  }
  fbinfo.rotate = rotation;
  res = ioctl(fd, FBIOPUT_VSCREENINFO, &fbinfo);
  if (res < 0) {
    fprintf(stderr, "failed to set fbinfo: %s\n", strerror(errno));
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<rotatefb_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe7a(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe73(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e17(%rip),%rcx
cmp    (%rcx),%eax
jne    11be <rotatefb_main+0x4e>
jmp    123b <rotatefb_main+0xcb>
mov    -0x14(%rbp),%eax
mov    %eax,-0x50(%rbp)
sub    $0x3f,%eax
je     11f6 <rotatefb_main+0x86>
jmp    11d2 <rotatefb_main+0x62>
mov    -0x50(%rbp),%eax
sub    $0x64,%eax
jne    1227 <rotatefb_main+0xb7>
jmp    11e3 <rotatefb_main+0x73>
mov    0x2e0e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1227 <rotatefb_main+0xb7>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    0x2dc3(%rip),%rax
mov    (%rax),%ecx
lea    0xdff(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    122c <rotatefb_main+0xbc>
mov    $0x1,%al
test   $0x1,%al
jne    1191 <rotatefb_main+0x21>
jmp    123b <rotatefb_main+0xcb>
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
je     1278 <rotatefb_main+0x108>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x2d3d(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2d43(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    12d8 <rotatefb_main+0x168>
mov    0x2cf8(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd7e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e7 <rotatefb_main+0x277>
mov    -0x28(%rbp),%edi
mov    0x2cbe(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdx
call   1030 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1334 <rotatefb_main+0x1c4>
mov    0x2caf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    0x2c9b(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x54(%rbp),%edi
mov    %rax,%rdx
lea    0xd32(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e7 <rotatefb_main+0x277>
mov    -0x48(%rbp),%eax
xor    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     137e <rotatefb_main+0x20e>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x44(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jne    1379 <rotatefb_main+0x209>
mov    -0x44(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    137e <rotatefb_main+0x20e>
mov    -0x24(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x28(%rbp),%edi
mov    0x2c4a(%rip),%rax
mov    (%rax),%esi
lea    -0x48(%rbp),%rdx
call   1030 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    13e0 <rotatefb_main+0x270>
mov    0x2c03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    0x2bef(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x58(%rbp),%edi
mov    %rax,%rdx
lea    0xca0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e7 <rotatefb_main+0x277>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotatefb_main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe88(%rip),%rdx
call   1060 <getopt@plt>
mov    0x2e32(%rip),%r12
cmp    (%r12),%eax
jne    1270 <rotatefb_main+0x100>
lea    0xe59(%rip),%r14
mov    0x2e12(%rip),%rax
movslq (%rax),%rax
lea    0x1(%rax),%ecx
cmp    %ebp,%ecx
jne    1335 <rotatefb_main+0x1c5>
mov    (%rbx,%rax,8),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    0x2e12(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1050 <open@plt>
test   %eax,%eax
js     12e2 <rotatefb_main+0x172>
mov    %eax,%ebp
mov    0x2db7(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %ebp,%edi
call   1030 <ioctl@plt>
test   %eax,%eax
js     12f7 <rotatefb_main+0x187>
mov    (%rsp),%eax
xor    %ebx,%eax
test   $0x1,%al
je     122b <rotatefb_main+0xbb>
mov    0x4(%rsp),%ecx
mov    0x8(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    %ecx,0x8(%rsp)
mov    %ecx,0xc(%rsp)
lea    (%rax,%rax,1),%edx
mov    %edx,0x10(%rsp)
cmp    %ecx,0x14(%rsp)
jne    122b <rotatefb_main+0xbb>
mov    %eax,0x14(%rsp)
mov    %ebx,(%rsp)
mov    0x2da3(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %ebp,%edi
call   1030 <ioctl@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jns    1326 <rotatefb_main+0x1b6>
mov    0x2d5c(%rip),%rax
mov    (%rax),%ebx
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe02(%rip),%rsi
jmp    1315 <rotatefb_main+0x1a5>
lea    0xd89(%rip),%r14
mov    0x2d7a(%rip),%r13
lea    0xd8d(%rip),%r15
jmp    12ab <rotatefb_main+0x13b>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%r14
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1060 <getopt@plt>
cmp    (%r12),%eax
je     11a7 <rotatefb_main+0x37>
cmp    $0x64,%eax
je     1290 <rotatefb_main+0x120>
cmp    $0x3f,%eax
jne    1294 <rotatefb_main+0x124>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
mov    0x2d08(%rip),%rax
mov    (%rax),%ecx
lea    0xd44(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
lea    0xd51(%rip),%rsi
mov    %r14,%rdx
jmp    131a <rotatefb_main+0x1aa>
mov    0x2cb2(%rip),%rax
mov    (%rax),%ebx
mov    0x2ca1(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xd3e(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xce5(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.fb_var_screeninfo = type { i32, i32, i32, i32, i32, i32 }
@.str = [18 x i8] c"/dev/graphics/fb0\00"
@.str.1 = [3 x i8] c"d:\00"
@EOF = global i32 0
@optarg = global i8* null
@stderr = global i32 0
@.str.2 = [24 x i8] c"%s: invalid option -%c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.3 = [22 x i8] c"%s: specify rotation\0A\00"
@O_RDWR = global i32 0
@.str.4 = [16 x i8] c"cannot open %s\0A\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.5 = [26 x i8] c"failed to get fbinfo: %s\0A\00"
@errno = global i32 0
@FBIOPUT_VSCREENINFO = global i32 0
@.str.6 = [26 x i8] c"failed to set fbinfo: %s\0A\00"
define i32 @rotatefb_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.fb_var_screeninfo
%12 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8** %7
store i32 0, i32* %8
br label %13
13: ; preds = %34, %2
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %13
br label %35
21: ; preds = %13
%22 = load i32, i32* %6
switch i32 %22, label %33 [
i32 100, label %23
i32 63, label %25
]
23: ; preds = %21
%24 = load i8*, i8** @optarg
store i8* %24, i8** %7
br label %33
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = load i32, i32* @optopt
%31 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %29, i32 %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %21, %23
br label %34
34: ; preds = %33
br i1 true, label %13, label %35
35: ; preds = %34, %20
%36 = load i32, i32* @optind
%37 = add nsw i32 %36, 1
%38 = load i32, i32* %4
%39 = icmp ne i32 %37, %38
br i1 %39, label %40, label %47
40: ; preds = %35
%41 = load i32, i32* @stderr
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 0
%44 = load i8*, i8** %43
%45 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %35
%48 = load i8**, i8*** %5
%49 = load i32, i32* @optind
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 @atoi(i8* %52)
store i32 %53, i32* %8
%54 = load i8*, i8** %7
%55 = load i32, i32* @O_RDWR
%56 = call i32 @open(i8* %54, i32 %55)
store i32 %56, i32* %9
%57 = load i32, i32* %9
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %47
%60 = load i32, i32* @stderr
%61 = load i8*, i8** %7
%62 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %61)
store i32 1, i32* %3
br label %119
63: ; preds = %47
%64 = load i32, i32* %9
%65 = load i32, i32* @FBIOGET_VSCREENINFO
%66 = call i32 @ioctl(i32 %64, i32 %65, %struct.fb_var_screeninfo* %11)
store i32 %66, i32* %10
%67 = load i32, i32* %10
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %74
69: ; preds = %63
%70 = load i32, i32* @stderr
%71 = load i32, i32* @errno
%72 = call i8* @strerror(i32 %71)
%73 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %72)
store i32 1, i32* %3
br label %119
74: ; preds = %63
%75 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 0
%76 = load i32, i32* %75
%77 = load i32, i32* %8
%78 = xor i32 %76, %77
%79 = and i32 %78, 1
%80 = icmp ne i32 %79, 0
br i1 %80, label %81, label %105
81: ; preds = %74
%82 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 1
%83 = load i32, i32* %82
store i32 %83, i32* %12
%84 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
%85 = load i32, i32* %84
%86 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 1
store i32 %85, i32* %86
%87 = load i32, i32* %12
%88 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
store i32 %87, i32* %88
%89 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 2
%90 = load i32, i32* %89
%91 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 3
store i32 %90, i32* %91
%92 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 1
%93 = load i32, i32* %92
%94 = mul i32 %93, 2
%95 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 4
store i32 %94, i32* %95
%96 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 5
%97 = load i32, i32* %96
%98 = load i32, i32* %12
%99 = icmp eq i32 %97, %98
br i1 %99, label %100, label %104
100: ; preds = %81
%101 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 1
%102 = load i32, i32* %101
%103 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 5
store i32 %102, i32* %103
br label %104
104: ; preds = %100, %81
br label %105
105: ; preds = %104, %74
%106 = load i32, i32* %8
%107 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %11, i32 0, i32 0
store i32 %106, i32* %107
%108 = load i32, i32* %9
%109 = load i32, i32* @FBIOPUT_VSCREENINFO
%110 = call i32 @ioctl(i32 %108, i32 %109, %struct.fb_var_screeninfo* %11)
store i32 %110, i32* %10
%111 = load i32, i32* %10
%112 = icmp slt i32 %111, 0
br i1 %112, label %113, label %118
113: ; preds = %105
%114 = load i32, i32* @stderr
%115 = load i32, i32* @errno
%116 = call i8* @strerror(i32 %115)
%117 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %116)
store i32 1, i32* %3
br label %119
118: ; preds = %105
store i32 0, i32* %3
br label %119
119: ; preds = %118, %113, %69, %59
%120 = load i32, i32* %3
ret i32 %120
}

LLVM IR (-O2):
%struct.fb_var_screeninfo = type { i32, i32, i32, i32, i32, i32 }
@.str = [18 x i8] c"/dev/graphics/fb0\00"
@.str.1 = [3 x i8] c"d:\00"
@EOF = global i32 0
@optarg = global i8* null
@stderr = global i32 0
@.str.2 = [24 x i8] c"%s: invalid option -%c\0A\00"
@optopt = global i32 0
@optind = global i32 0
@.str.3 = [22 x i8] c"%s: specify rotation\0A\00"
@O_RDWR = global i32 0
@.str.4 = [16 x i8] c"cannot open %s\0A\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.5 = [26 x i8] c"failed to get fbinfo: %s\0A\00"
@errno = global i32 0
@FBIOPUT_VSCREENINFO = global i32 0
@.str.6 = [26 x i8] c"failed to set fbinfo: %s\0A\00"
define i32 @rotatefb_main(i32 %0, i8** %1) {
%3 = alloca %struct.fb_var_screeninfo
%4 = bitcast %struct.fb_var_screeninfo* %3 to i8*
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %24, label %8
8: ; preds = %2, %19
%9 = phi i32 [ %21, %19 ], [ %5, %2 ]
%10 = phi i8* [ %20, %19 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %2 ]
switch i32 %9, label %19 [
i32 100, label %11
i32 63, label %13
]
11: ; preds = %8
%12 = load i8*, i8** @optarg
br label %19
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %1
%16 = load i32, i32* @optopt
%17 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %15, i32 %16)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %11, %8
%20 = phi i8* [ %10, %8 ], [ %12, %11 ]
%21 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %8
24: ; preds = %19, %2
%25 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %2 ], [ %20, %19 ]
%26 = load i32, i32* @optind
%27 = add nsw i32 %26, 1
%28 = icmp eq i32 %27, %0
br i1 %28, label %34, label %29
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %1
%32 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %24
%35 = sext i32 %26 to i64
%36 = getelementptr inbounds i8*, i8** %1, i64 %35
%37 = load i8*, i8** %36
%38 = tail call i32 @atoi(i8* %37)
%39 = load i32, i32* @O_RDWR
%40 = tail call i32 @open(i8* %25, i32 %39)
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %34
%43 = load i32, i32* @stderr
%44 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %25)
br label %81
45: ; preds = %34
%46 = load i32, i32* @FBIOGET_VSCREENINFO
%47 = call i32 @ioctl(i32 %40, i32 %46, %struct.fb_var_screeninfo* %3)
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %45
%50 = load i32, i32* @stderr
%51 = load i32, i32* @errno
%52 = call i8* @strerror(i32 %51)
%53 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %52)
br label %81
54: ; preds = %45
%55 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 0
%56 = load i32, i32* %55
%57 = xor i32 %56, %38
%58 = and i32 %57, 1
%59 = icmp eq i32 %58, 0
br i1 %59, label %72, label %60
60: ; preds = %54
%61 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 1
%62 = load i32, i32* %61
%63 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 2
%64 = load i32, i32* %63
store i32 %64, i32* %61
store i32 %62, i32* %63
%65 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 3
store i32 %62, i32* %65
%66 = shl i32 %64, 1
%67 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 4
store i32 %66, i32* %67
%68 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i64 0, i32 5
%69 = load i32, i32* %68
%70 = icmp eq i32 %69, %62
br i1 %70, label %71, label %72
71: ; preds = %60
store i32 %64, i32* %68
br label %72
72: ; preds = %60, %71, %54
store i32 %38, i32* %55
%73 = load i32, i32* @FBIOPUT_VSCREENINFO
%74 = call i32 @ioctl(i32 %40, i32 %73, %struct.fb_var_screeninfo* %3)
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %81
76: ; preds = %72
%77 = load i32, i32* @stderr
%78 = load i32, i32* @errno
%79 = call i8* @strerror(i32 %78)
%80 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %79)
br label %81
81: ; preds = %72, %76, %49, %42
%82 = phi i32 [ 1, %42 ], [ 1, %49 ], [ 1, %76 ], [ 0, %72 ]
ret i32 %82
}