#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 u_int32_t;
struct stat {
  int st_rdev;
  int /*<<< orphan*/ st_mode;
};
struct fb_con2fbmap {
  int console;
  int framebuffer;
};

/* Variables and functions */
int /*<<< orphan*/ FBIOPUT_CON2FBMAP;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ S_ISCHR(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct fb_con2fbmap *);
int open(char *, int /*<<< orphan*/);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strrchr(char *, char);
int strtoul(char *, char **, int);
int main(int argc, char *argv[]) {
  struct fb_con2fbmap c2m;
  char *fbPath;
  u_int32_t con, fb;
  char *e;
  char *progname = strrchr(argv[0], '/');
  int f;
  if (progname)
    progname++;
  else
    progname = argv[0];
  if (argc < 3) {
    fprintf(stderr, "usage: %s fbdev console\n", progname);
    return 1;
  }
  fb = strtoul(argv[1], &e, 10);
  if (*e) {
    struct stat sbf;
    if (stat(argv[1], &sbf)) {
      fprintf(stderr,
              "%s: are you sure that %s can be used to describe fbdev?\n",
              progname, argv[1]);
      return 1;
    }
    if (!S_ISCHR(sbf.st_mode)) {
      fprintf(stderr, "%s: %s must be character device\n", progname, argv[1]);
      return 1;
    }
    fb = sbf.st_rdev & 0xFF;
    if (fb >= 32)
      fb >>= 5;
    fbPath = argv[1];
  } else
    fbPath = "/dev/fb0";
  con = strtoul(argv[2], &e, 10);
  if (*e) {
    struct stat sbf;
    if (stat(argv[2], &sbf)) {
      fprintf(stderr, "%s: are you sure that %s can be used to describe vt?\n",
              progname, argv[2]);
      return 1;
    }
    if (!S_ISCHR(sbf.st_mode)) {
      fprintf(stderr, "%s: %s must be character device\n", progname, argv[2]);
      return 1;
    }
    con = sbf.st_rdev & 0xFF;
  }
  c2m.console = con;
  c2m.framebuffer = fb;
  f = open(fbPath, O_RDWR);
  if (f < 0) {
    fprintf(stderr, "%s: Cannot open %s\n", progname, fbPath);
    return 1;
  }
  if (ioctl(f, FBIOPUT_CON2FBMAP, &c2m)) {
    fprintf(stderr, "%s: Cannot set console mapping\n", progname);
    close(f);
    return 1;
  }
  close(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11c7 <main+0x47>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11d2 <main+0x52>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1203 <main+0x83>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    145b <main+0x2db>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   10a0 <strtoul@plt>
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     12e2 <main+0x162>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x48(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
je     1273 <main+0xf3>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    145b <main+0x2db>
mov    -0x44(%rbp),%edi
call   1080 <S_ISCHR@plt>
cmp    $0x0,%eax
jne    12b3 <main+0x133>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xdb2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    145b <main+0x2db>
mov    -0x48(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x20,-0x28(%rbp)
jl     12d1 <main+0x151>
mov    -0x28(%rbp),%eax
sar    $0x5,%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    12ed <main+0x16d>
lea    0xd8a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   10a0 <strtoul@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     13a8 <main+0x228>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x50(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
je     135d <main+0x1dd>
mov    0x2c9b(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xd32(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    145b <main+0x2db>
mov    -0x4c(%rbp),%edi
call   1080 <S_ISCHR@plt>
cmp    $0x0,%eax
jne    139d <main+0x21d>
mov    0x2c5b(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xcc8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    145b <main+0x2db>
mov    -0x50(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2c29(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    13fe <main+0x27e>
mov    0x2bf6(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xcc7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    145b <main+0x2db>
mov    -0x3c(%rbp),%edi
mov    0x2bd8(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1040 <ioctl@plt>
cmp    $0x0,%rax
je     144c <main+0x2cc>
mov    0x2bac(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xc95(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x3c(%rbp),%edi
call   1050 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    145b <main+0x2db>
mov    -0x3c(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r12
mov    %edi,%ebp
mov    (%rsi),%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
lea    0x1(%rax),%r14
test   %rax,%rax
cmove  %rbx,%r14
cmp    $0x2,%ebp
jg     11d0 <main+0x50>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1296 <main+0x116>
mov    0x8(%r12),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   10a0 <strtoul@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     1219 <main+0x99>
mov    0x8(%r12),%rdi
mov    %rsp,%rsi
call   1070 <stat@plt>
test   %rax,%rax
je     1222 <main+0xa2>
lea    0xe10(%rip),%rsi
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r12),%rcx
jmp    128c <main+0x10c>
lea    0xe53(%rip),%r15
jmp    1247 <main+0xc7>
mov    0x4(%rsp),%edi
call   1080 <S_ISCHR@plt>
test   %eax,%eax
je     1331 <main+0x1b1>
movzbl (%rsp),%eax
mov    %eax,%ebp
shr    $0x5,%ebp
cmp    $0x20,%eax
cmovb  %eax,%ebp
mov    0x8(%r12),%r15
mov    0x10(%r12),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   10a0 <strtoul@plt>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
je     12bd <main+0x13d>
mov    0x10(%r12),%rdi
mov    %rsp,%rsi
call   1070 <stat@plt>
test   %rax,%rax
je     12a8 <main+0x128>
lea    0xdfe(%rip),%rsi
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
mov    0x10(%r12),%rcx
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x4(%rsp),%edi
call   1080 <S_ISCHR@plt>
test   %eax,%eax
je     134b <main+0x1cb>
movzbl (%rsp),%eax
mov    %eax,(%rsp)
mov    %ebp,0x4(%rsp)
mov    0x2d1d(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1090 <open@plt>
test   %eax,%eax
js     1316 <main+0x196>
mov    %eax,%ebx
mov    0x2cfe(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %ebx,%edi
call   1040 <ioctl@plt>
test   %rax,%rax
je     133d <main+0x1bd>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
lea    0xdc3(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %ebx,%edi
call   1050 <close@plt>
jmp    1296 <main+0x116>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edi
lea    0xd8c(%rip),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
jmp    128f <main+0x10f>
lea    0xd1a(%rip),%rsi
jmp    1209 <main+0x89>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
jmp    129b <main+0x11b>
lea    0xd00(%rip),%rsi
jmp    127e <main+0xfe>

LLVM IR (-O0):
%struct.fb_con2fbmap = type { i32, i32 }
%struct.stat = type { i32, i32 }
@stderr = global i32 0
@.str = [25 x i8] c"usage: %s fbdev console\0A\00"
@.str.1 = [57 x i8] c"%s: are you sure that %s can be used to describe fbdev?\0A\00"
@.str.2 = [33 x i8] c"%s: %s must be character device\0A\00"
@.str.3 = [9 x i8] c"/dev/fb0\00"
@.str.4 = [54 x i8] c"%s: are you sure that %s can be used to describe vt?\0A\00"
@O_RDWR = global i32 0
@.str.5 = [20 x i8] c"%s: Cannot open %s\0A\00"
@FBIOPUT_CON2FBMAP = global i32 0
@.str.6 = [32 x i8] c"%s: Cannot set console mapping\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.fb_con2fbmap
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca %struct.stat
%14 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i8* @strrchr(i8* %17, i8 signext 47)
store i8* %18, i8** %11
%19 = load i8*, i8** %11
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = load i8*, i8** %11
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %11
br label %28
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
store i8* %27, i8** %11
br label %28
28: ; preds = %24, %21
%29 = load i32, i32* %4
%30 = icmp slt i32 %29, 3
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %11
%34 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %33)
store i32 1, i32* %3
br label %148
35: ; preds = %28
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @strtoul(i8* %38, i8** %10, i32 10)
store i32 %39, i32* %9
%40 = load i8*, i8** %10
%41 = load i8, i8* %40
%42 = icmp ne i8 %41, 0
br i1 %42, label %43, label %81
43: ; preds = %35
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i64 @stat(i8* %46, %struct.stat* %13)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %43
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %11
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i8* %51, i8* %54)
store i32 1, i32* %3
br label %148
56: ; preds = %43
%57 = getelementptr inbounds %struct.stat, %struct.stat* %13, i32 0, i32 1
%58 = load i32, i32* %57
%59 = call i32 @S_ISCHR(i32 %58)
%60 = icmp ne i32 %59, 0
br i1 %60, label %68, label %61
61: ; preds = %56
%62 = load i32, i32* @stderr
%63 = load i8*, i8** %11
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 1
%66 = load i8*, i8** %65
%67 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %63, i8* %66)
store i32 1, i32* %3
br label %148
68: ; preds = %56
%69 = getelementptr inbounds %struct.stat, %struct.stat* %13, i32 0, i32 0
%70 = load i32, i32* %69
%71 = and i32 %70, 255
store i32 %71, i32* %9
%72 = load i32, i32* %9
%73 = icmp sge i32 %72, 32
br i1 %73, label %74, label %77
74: ; preds = %68
%75 = load i32, i32* %9
%76 = ashr i32 %75, 5
store i32 %76, i32* %9
br label %77
77: ; preds = %74, %68
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 1
%80 = load i8*, i8** %79
store i8* %80, i8** %7
br label %82
81: ; preds = %35
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %7
br label %82
82: ; preds = %81, %77
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 2
%85 = load i8*, i8** %84
%86 = call i32 @strtoul(i8* %85, i8** %10, i32 10)
store i32 %86, i32* %8
%87 = load i8*, i8** %10
%88 = load i8, i8* %87
%89 = icmp ne i8 %88, 0
br i1 %89, label %90, label %119
90: ; preds = %82
%91 = load i8**, i8*** %5
%92 = getelementptr inbounds i8*, i8** %91, i64 2
%93 = load i8*, i8** %92
%94 = call i64 @stat(i8* %93, %struct.stat* %14)
%95 = icmp ne i64 %94, 0
br i1 %95, label %96, label %103
96: ; preds = %90
%97 = load i32, i32* @stderr
%98 = load i8*, i8** %11
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 2
%101 = load i8*, i8** %100
%102 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i8* %98, i8* %101)
store i32 1, i32* %3
br label %148
103: ; preds = %90
%104 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 1
%105 = load i32, i32* %104
%106 = call i32 @S_ISCHR(i32 %105)
%107 = icmp ne i32 %106, 0
br i1 %107, label %115, label %108
108: ; preds = %103
%109 = load i32, i32* @stderr
%110 = load i8*, i8** %11
%111 = load i8**, i8*** %5
%112 = getelementptr inbounds i8*, i8** %111, i64 2
%113 = load i8*, i8** %112
%114 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %110, i8* %113)
store i32 1, i32* %3
br label %148
115: ; preds = %103
%116 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%117 = load i32, i32* %116
%118 = and i32 %117, 255
store i32 %118, i32* %8
br label %119
119: ; preds = %115, %82
%120 = load i32, i32* %8
%121 = getelementptr inbounds %struct.fb_con2fbmap, %struct.fb_con2fbmap* %6, i32 0, i32 0
store i32 %120, i32* %121
%122 = load i32, i32* %9
%123 = getelementptr inbounds %struct.fb_con2fbmap, %struct.fb_con2fbmap* %6, i32 0, i32 1
store i32 %122, i32* %123
%124 = load i8*, i8** %7
%125 = load i32, i32* @O_RDWR
%126 = call i32 @open(i8* %124, i32 %125)
store i32 %126, i32* %12
%127 = load i32, i32* %12
%128 = icmp slt i32 %127, 0
br i1 %128, label %129, label %134
129: ; preds = %119
%130 = load i32, i32* @stderr
%131 = load i8*, i8** %11
%132 = load i8*, i8** %7
%133 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %130, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %131, i8* %132)
store i32 1, i32* %3
br label %148
134: ; preds = %119
%135 = load i32, i32* %12
%136 = load i32, i32* @FBIOPUT_CON2FBMAP
%137 = call i64 @ioctl(i32 %135, i32 %136, %struct.fb_con2fbmap* %6)
%138 = icmp ne i64 %137, 0
br i1 %138, label %139, label %145
139: ; preds = %134
%140 = load i32, i32* @stderr
%141 = load i8*, i8** %11
%142 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %141)
%143 = load i32, i32* %12
%144 = call i32 @close(i32 %143)
store i32 1, i32* %3
br label %148
145: ; preds = %134
%146 = load i32, i32* %12
%147 = call i32 @close(i32 %146)
store i32 0, i32* %3
br label %148
148: ; preds = %145, %139, %129, %108, %96, %61, %49, %31
%149 = load i32, i32* %3
ret i32 %149
}

LLVM IR (-O2):
%struct.fb_con2fbmap = type { i32, i32 }
%struct.stat = type { i32, i32 }
@stderr = global i32 0
@.str = [25 x i8] c"usage: %s fbdev console\0A\00"
@.str.1 = [57 x i8] c"%s: are you sure that %s can be used to describe fbdev?\0A\00"
@.str.2 = [33 x i8] c"%s: %s must be character device\0A\00"
@.str.3 = [9 x i8] c"/dev/fb0\00"
@.str.4 = [54 x i8] c"%s: are you sure that %s can be used to describe vt?\0A\00"
@O_RDWR = global i32 0
@.str.5 = [20 x i8] c"%s: Cannot open %s\0A\00"
@FBIOPUT_CON2FBMAP = global i32 0
@.str.6 = [32 x i8] c"%s: Cannot set console mapping\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.fb_con2fbmap
%4 = alloca i8*
%5 = alloca %struct.stat
%6 = alloca %struct.stat
%7 = bitcast %struct.fb_con2fbmap* %3 to i8*
%8 = bitcast i8** %4 to i8*
%9 = load i8*, i8** %1
%10 = tail call i8* @strrchr(i8* dereferenceable(1) %9, i8 signext 47)
%11 = icmp eq i8* %10, null
%12 = getelementptr inbounds i8, i8* %10, i64 1
%13 = select i1 %11, i8* %9, i8* %12
%14 = icmp slt i32 %0, 3
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %96
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strtoul(i8* %20, i8** %4, i32 10)
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %48, label %25
25: ; preds = %18
%26 = bitcast %struct.stat* %5 to i8*
%27 = load i8*, i8** %19
%28 = call i64 @stat(i8* %27, %struct.stat* %5)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 1
%32 = load i32, i32* %31
%33 = call i32 @S_ISCHR(i32 %32)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %30, %25
%36 = phi i8* [ getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), %25 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), %30 ]
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %19
%39 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %37, i8* %36, i8* %13, i8* %38)
br label %96
40: ; preds = %30
%41 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%42 = load i32, i32* %41
%43 = and i32 %42, 255
%44 = icmp ugt i32 %43, 31
%45 = lshr i32 %43, 5
%46 = select i1 %44, i32 %45, i32 %43
%47 = load i8*, i8** %19
br label %48
48: ; preds = %40, %18
%49 = phi i8* [ %47, %40 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), %18 ]
%50 = phi i32 [ %46, %40 ], [ %21, %18 ]
%51 = getelementptr inbounds i8*, i8** %1, i64 2
%52 = load i8*, i8** %51
%53 = call i32 @strtoul(i8* %52, i8** %4, i32 10)
%54 = load i8*, i8** %4
%55 = load i8, i8* %54
%56 = icmp eq i8 %55, 0
br i1 %56, label %76, label %57
57: ; preds = %48
%58 = bitcast %struct.stat* %6 to i8*
%59 = load i8*, i8** %51
%60 = call i64 @stat(i8* %59, %struct.stat* %6)
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %67
62: ; preds = %57
%63 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 1
%64 = load i32, i32* %63
%65 = call i32 @S_ISCHR(i32 %64)
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %72
67: ; preds = %62, %57
%68 = phi i8* [ getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), %57 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), %62 ]
%69 = load i32, i32* @stderr
%70 = load i8*, i8** %51
%71 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %69, i8* %68, i8* %13, i8* %70)
br label %96
72: ; preds = %62
%73 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
%74 = load i32, i32* %73
%75 = and i32 %74, 255
br label %76
76: ; preds = %72, %48
%77 = phi i32 [ %75, %72 ], [ %53, %48 ]
%78 = getelementptr inbounds %struct.fb_con2fbmap, %struct.fb_con2fbmap* %3, i64 0, i32 0
store i32 %77, i32* %78
%79 = getelementptr inbounds %struct.fb_con2fbmap, %struct.fb_con2fbmap* %3, i64 0, i32 1
store i32 %50, i32* %79
%80 = load i32, i32* @O_RDWR
%81 = call i32 @open(i8* %49, i32 %80)
%82 = icmp slt i32 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %76
%84 = load i32, i32* @stderr
%85 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %13, i8* %49)
br label %96
86: ; preds = %76
%87 = load i32, i32* @FBIOPUT_CON2FBMAP
%88 = call i64 @ioctl(i32 %81, i32 %87, %struct.fb_con2fbmap* %3)
%89 = icmp eq i64 %88, 0
br i1 %89, label %94, label %90
90: ; preds = %86
%91 = load i32, i32* @stderr
%92 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %13)
%93 = call i32 @close(i32 %81)
br label %96
94: ; preds = %86
%95 = call i32 @close(i32 %81)
br label %96
96: ; preds = %67, %35, %94, %90, %83, %15
%97 = phi i32 [ 1, %15 ], [ 1, %83 ], [ 1, %90 ], [ 0, %94 ], [ 1, %35 ], [ 1, %67 ]
ret i32 %97
}