#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 xres;
  int yres;
  int bits_per_pixel;
  int xoffset;
  int yoffset;
  int line_length;
};
struct fb_fix_screeninfo {
  int xres;
  int yres;
  int bits_per_pixel;
  int xoffset;
  int yoffset;
  int line_length;
};

/* Variables and functions */
int /*<<< orphan*/ FBIOGET_FSCREENINFO;
int /*<<< orphan*/ FBIOGET_VSCREENINFO;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int ioctl(int, int /*<<< orphan*/, struct fb_var_screeninfo *);
scalar_t__ mmap(int /*<<< orphan*/, long, int, int /*<<< orphan*/, int,
                int /*<<< orphan*/);
int /*<<< orphan*/ munmap(char *, long);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int fbfd = 0;
  struct fb_var_screeninfo vinfo;
  struct fb_fix_screeninfo finfo;
  long int screensize = 0;
  char *fbp = 0;
  int x = 0, y = 0;
  long int location = 0;
  fbfd = open("/dev/fb0", O_RDWR);
  if (fbfd == -1) {
    perror("Error: cannot open framebuffer device");
    exit(1);
  }
  printf("The framebuffer device was opened successfully.\n");
  if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1) {
    perror("Error reading fixed information");
    exit(2);
  }
  if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo) == -1) {
    perror("Error reading variable information");
    exit(3);
  }
  printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);
  screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
  fbp =
      (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
  if ((int)fbp == -1) {
    perror("Error: failed to map framebuffer device to memory");
    exit(4);
  }
  printf("The framebuffer device was mapped to memory successfully.\n");
  x = 100;
  y = 100;
  for (y = 100; y < 300; y++)
    for (x = 100; x < 300; x++) {
      location = (x + vinfo.xoffset) * (vinfo.bits_per_pixel / 8) +
                 (y + vinfo.yoffset) * finfo.line_length;
      if (vinfo.bits_per_pixel == 32) {
        *(fbp + location) = 100;
        *(fbp + location + 1) = 15 + (x - 100) / 2;
        *(fbp + location + 2) = 200 - (y - 100) / 5;
        *(fbp + location + 3) = 0;
      } else {
        int b = 10;
        int g = (x - 100) / 6;
        int r = 31 - (y - 100) / 16;
        unsigned short int t = r << 11 | g << 5 | b;
        *((unsigned short int *)(fbp + location)) = t;
      }
    }
  munmap(fbp, screensize);
  close(fbfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    0x2e15(%rip),%rax
mov    (%rax),%esi
lea    0xe34(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11f4 <main+0x74>
lea    0xe24(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
mov    0x2dbc(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1236 <main+0xb6>
lea    0xe39(%rip),%rdi
call   1090 <perror@plt>
mov    $0x2,%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    0x2d78(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    126a <main+0xea>
lea    0xe25(%rip),%rdi
call   1090 <perror@plt>
mov    $0x3,%edi
call   10a0 <exit@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
imul   -0x1c(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
mov    0x2d53(%rip),%rax
mov    (%rax),%edx
mov    0x2d12(%rip),%rax
or     (%rax),%edx
mov    0x2d31(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    $0xffffffff,%eax
jne    12ef <main+0x16f>
lea    0xdd1(%rip),%rdi
call   1090 <perror@plt>
mov    $0x4,%edi
call   10a0 <exit@plt>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x64,-0x4c(%rbp)
movl   $0x64,-0x50(%rbp)
movl   $0x64,-0x50(%rbp)
cmpl   $0x12c,-0x50(%rbp)
jge    144a <main+0x2ca>
movl   $0x64,-0x4c(%rbp)
cmpl   $0x12c,-0x4c(%rbp)
jge    1437 <main+0x2b7>
mov    -0x4c(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
imul   %ecx,%eax
mov    -0x50(%rbp),%ecx
add    -0x10(%rbp),%ecx
imul   -0x24(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x58(%rbp)
cmpl   $0x20,-0x18(%rbp)
jne    13cd <main+0x24d>
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
movb   $0x64,(%rax,%rcx,1)
mov    -0x4c(%rbp),%eax
sub    $0x64,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0xf,%eax
mov    %al,%dl
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    %dl,0x1(%rax,%rcx,1)
mov    -0x50(%rbp),%eax
sub    $0x64,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0xc8,%eax
sub    %ecx,%eax
mov    %al,%dl
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    %dl,0x2(%rax,%rcx,1)
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
movb   $0x0,0x3(%rax,%rcx,1)
jmp    1424 <main+0x2a4>
movl   $0xa,-0x5c(%rbp)
mov    -0x4c(%rbp),%eax
sub    $0x64,%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %eax,-0x60(%rbp)
mov    -0x50(%rbp),%eax
sub    $0x64,%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x1f,%eax
sub    %ecx,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
shl    $0xb,%eax
mov    -0x60(%rbp),%ecx
shl    $0x5,%ecx
or     %ecx,%eax
or     -0x5c(%rbp),%eax
mov    %ax,-0x66(%rbp)
mov    -0x66(%rbp),%dx
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    %dx,(%rax,%rcx,1)
jmp    1429 <main+0x2a9>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1326 <main+0x1a6>
jmp    143c <main+0x2bc>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1312 <main+0x192>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <munmap@plt>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
lea    0xe56(%rip),%rdi
call   1090 <open@plt>
cmp    $0xffffffff,%eax
je     137c <main+0x1ec>
mov    %eax,%r15d
lea    0xef0(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rdx
mov    %r15d,%edi
call   1060 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1392 <main+0x202>
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %r15d,%edi
call   1060 <ioctl@plt>
cmp    $0xffffffff,%eax
je     13a8 <main+0x218>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%ecx
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%eax
imul   0x8(%rsp),%eax
imul   0x10(%rsp),%eax
lea    0x7(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x3,%ecx
movslq %ecx,%r14
mov    0x2db6(%rip),%rax
mov    0x2d77(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d94(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r14,%rsi
mov    %r15d,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%rbx
cmp    $0xffffffff,%ebx
je     13be <main+0x22e>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
mov    $0x64,%eax
jmp    129e <main+0x10e>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%eax
cmp    $0x12c,%eax
je     135c <main+0x1cc>
lea    -0x64(%rax),%edx
lea    -0x55(%rax),%esi
test   %edx,%edx
cmovns %edx,%esi
and    $0xfffffff0,%esi
shl    $0x7,%esi
mov    $0xf800,%r8d
sub    %esi,%r8d
movslq %edx,%rdx
imul   $0xffffffff99999999,%rdx,%r9
mov    %r9,%rsi
shr    $0x3f,%rsi
shr    $0x21,%r9
add    %esi,%r9d
add    $0xc8,%r9b
xor    %esi,%esi
jmp    130b <main+0x17b>
nopl   0x0(%rax,%rax,1)
movswl %si,%ecx
imul   $0x2aab,%ecx,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
shr    $0x10,%ecx
add    %edx,%ecx
shl    $0x5,%ecx
or     %r8d,%ecx
or     $0xa,%ecx
mov    %cx,(%rbx,%rdi,1)
add    $0x1,%esi
cmp    $0xc8,%esi
je     1290 <main+0x100>
mov    0x10(%rsp),%ebp
mov    0x14(%rsp),%edi
add    %esi,%edi
add    $0x64,%edi
lea    0x7(%rbp),%ecx
test   %ebp,%ebp
cmovns %ebp,%ecx
sar    $0x3,%ecx
mov    0x18(%rsp),%edx
add    %eax,%edx
imul   0x34(%rsp),%edx
imul   %edi,%ecx
add    %ecx,%edx
movslq %edx,%rdi
cmp    $0x20,%ebp
jne    12e0 <main+0x150>
movb   $0x64,(%rbx,%rdi,1)
movzwl %si,%ecx
shr    $0xf,%ecx
add    %esi,%ecx
shr    %ecx
add    $0xf,%cl
mov    %cl,0x1(%rbx,%rdi,1)
mov    %r9b,0x2(%rbx,%rdi,1)
movb   $0x0,0x3(%rbx,%rdi,1)
jmp    1300 <main+0x170>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <munmap@plt>
mov    %r15d,%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc86(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xc96(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
lea    0xca0(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x3,%edi
call   10b0 <exit@plt>
lea    0xcbb(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x4,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.fb_var_screeninfo = type { i32, i32, i32, i32, i32, i32 }
%struct.fb_fix_screeninfo = type { i32, i32, i32, i32, i32, i32 }
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@.str.1 = [38 x i8] c"Error: cannot open framebuffer device\00"
@.str.2 = [49 x i8] c"The framebuffer device was opened successfully.\0A\00"
@FBIOGET_FSCREENINFO = global i32 0
@.str.3 = [32 x i8] c"Error reading fixed information\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.4 = [35 x i8] c"Error reading variable information\00"
@.str.5 = [14 x i8] c"%dx%d, %dbpp\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.6 = [50 x i8] c"Error: failed to map framebuffer device to memory\00"
@.str.7 = [59 x i8] c"The framebuffer device was mapped to memory successfully.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.fb_var_screeninfo
%4 = alloca %struct.fb_fix_screeninfo
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i16
store i32 0, i32* %1
store i32 0, i32* %2
store i64 0, i64* %5
store i8* null, i8** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i64 0, i64* %9
%14 = load i32, i32* @O_RDWR
%15 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %14)
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %0
%19 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* %2
%24 = load i32, i32* @FBIOGET_FSCREENINFO
%25 = bitcast %struct.fb_fix_screeninfo* %4 to %struct.fb_var_screeninfo*
%26 = call i32 @ioctl(i32 %23, i32 %24, %struct.fb_var_screeninfo* %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %21
%29 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @exit(i32 2)
unreachable
31: ; preds = %21
%32 = load i32, i32* %2
%33 = load i32, i32* @FBIOGET_VSCREENINFO
%34 = call i32 @ioctl(i32 %32, i32 %33, %struct.fb_var_screeninfo* %3)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%38 = call i32 @exit(i32 3)
unreachable
39: ; preds = %31
%40 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i32 0, i32 0
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i32 0, i32 1
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i32 0, i32 2
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %41, i32 %43, i32 %45)
%47 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i32 0, i32 0
%48 = load i32, i32* %47
%49 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i32 0, i32 1
%50 = load i32, i32* %49
%51 = mul nsw i32 %48, %50
%52 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i32 0, i32 2
%53 = load i32, i32* %52
%54 = mul nsw i32 %51, %53
%55 = sdiv i32 %54, 8
%56 = sext i32 %55 to i64
store i64 %56, i64* %5
%57 = load i64, i64* %5
%58 = load i32, i32* @PROT_READ
%59 = load i32, i32* @PROT_WRITE
%60 = or i32 %58, %59
%61 = load i32, i32* @MAP_SHARED
%62 = load i32, i32* %2
%63 = call i64 @mmap(i32 0, i64 %57, i32 %60, i32 %61, i32 %62, i32 0)
%64 = inttoptr i64 %63 to i8*
store i8* %64, i8** %6
%65 = load i8*, i8** %6
%66 = ptrtoint i8* %65 to i32
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %71
68: ; preds = %39
%69 = call i32 @perror(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0))
%70 = call i32 @exit(i32 4)
unreachable
71: ; preds = %39
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.7, i64 0, i64 0))
store i32 100, i32* %7
store i32 100, i32* %8
store i32 100, i32* %8
br label %73
73: ; preds = %153, %71
%74 = load i32, i32* %8
%75 = icmp slt i32 %74, 300
br i1 %75, label %76, label %156
76: ; preds = %73
store i32 100, i32* %7
br label %77
77: ; preds = %149, %76
%78 = load i32, i32* %7
%79 = icmp slt i32 %78, 300
br i1 %79, label %80, label %152
80: ; preds = %77
%81 = load i32, i32* %7
%82 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i32 0, i32 3
%83 = load i32, i32* %82
%84 = add nsw i32 %81, %83
%85 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i32 0, i32 2
%86 = load i32, i32* %85
%87 = sdiv i32 %86, 8
%88 = mul nsw i32 %84, %87
%89 = load i32, i32* %8
%90 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i32 0, i32 4
%91 = load i32, i32* %90
%92 = add nsw i32 %89, %91
%93 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %4, i32 0, i32 5
%94 = load i32, i32* %93
%95 = mul nsw i32 %92, %94
%96 = add nsw i32 %88, %95
%97 = sext i32 %96 to i64
store i64 %97, i64* %9
%98 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %3, i32 0, i32 2
%99 = load i32, i32* %98
%100 = icmp eq i32 %99, 32
br i1 %100, label %101, label %127
101: ; preds = %80
%102 = load i8*, i8** %6
%103 = load i64, i64* %9
%104 = getelementptr inbounds i8, i8* %102, i64 %103
store i8 100, i8* %104
%105 = load i32, i32* %7
%106 = sub nsw i32 %105, 100
%107 = sdiv i32 %106, 2
%108 = add nsw i32 15, %107
%109 = trunc i32 %108 to i8
%110 = load i8*, i8** %6
%111 = load i64, i64* %9
%112 = getelementptr inbounds i8, i8* %110, i64 %111
%113 = getelementptr inbounds i8, i8* %112, i64 1
store i8 %109, i8* %113
%114 = load i32, i32* %8
%115 = sub nsw i32 %114, 100
%116 = sdiv i32 %115, 5
%117 = sub nsw i32 200, %116
%118 = trunc i32 %117 to i8
%119 = load i8*, i8** %6
%120 = load i64, i64* %9
%121 = getelementptr inbounds i8, i8* %119, i64 %120
%122 = getelementptr inbounds i8, i8* %121, i64 2
store i8 %118, i8* %122
%123 = load i8*, i8** %6
%124 = load i64, i64* %9
%125 = getelementptr inbounds i8, i8* %123, i64 %124
%126 = getelementptr inbounds i8, i8* %125, i64 3
store i8 0, i8* %126
br label %148
127: ; preds = %80
store i32 10, i32* %10
%128 = load i32, i32* %7
%129 = sub nsw i32 %128, 100
%130 = sdiv i32 %129, 6
store i32 %130, i32* %11
%131 = load i32, i32* %8
%132 = sub nsw i32 %131, 100
%133 = sdiv i32 %132, 16
%134 = sub nsw i32 31, %133
store i32 %134, i32* %12
%135 = load i32, i32* %12
%136 = shl i32 %135, 11
%137 = load i32, i32* %11
%138 = shl i32 %137, 5
%139 = or i32 %136, %138
%140 = load i32, i32* %10
%141 = or i32 %139, %140
%142 = trunc i32 %141 to i16
store i16 %142, i16* %13
%143 = load i16, i16* %13
%144 = load i8*, i8** %6
%145 = load i64, i64* %9
%146 = getelementptr inbounds i8, i8* %144, i64 %145
%147 = bitcast i8* %146 to i16*
store i16 %143, i16* %147
br label %148
148: ; preds = %127, %101
br label %149
149: ; preds = %148
%150 = load i32, i32* %7
%151 = add nsw i32 %150, 1
store i32 %151, i32* %7
br label %77
152: ; preds = %77
br label %153
153: ; preds = %152
%154 = load i32, i32* %8
%155 = add nsw i32 %154, 1
store i32 %155, i32* %8
br label %73
156: ; preds = %73
%157 = load i8*, i8** %6
%158 = load i64, i64* %5
%159 = call i32 @munmap(i8* %157, i64 %158)
%160 = load i32, i32* %2
%161 = call i32 @close(i32 %160)
ret i32 0
}

LLVM IR (-O2):
%struct.fb_var_screeninfo = type { i32, i32, i32, i32, i32, i32 }
%struct.fb_fix_screeninfo = type { i32, i32, i32, i32, i32, i32 }
@.str = [9 x i8] c"/dev/fb0\00"
@O_RDWR = global i32 0
@.str.1 = [38 x i8] c"Error: cannot open framebuffer device\00"
@FBIOGET_FSCREENINFO = global i32 0
@.str.3 = [32 x i8] c"Error reading fixed information\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.4 = [35 x i8] c"Error reading variable information\00"
@.str.5 = [14 x i8] c"%dx%d, %dbpp\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.6 = [50 x i8] c"Error: failed to map framebuffer device to memory\00"
@str = [48 x i8] c"The framebuffer device was opened successfully.\00"
@str.8 = [58 x i8] c"The framebuffer device was mapped to memory successfully.\00"
define i32 @main() {
%1 = alloca %struct.fb_var_screeninfo
%2 = alloca %struct.fb_fix_screeninfo
%3 = bitcast %struct.fb_var_screeninfo* %1 to i8*
%4 = bitcast %struct.fb_fix_screeninfo* %2 to i8*
%5 = load i32, i32* @O_RDWR
%6 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = tail call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* @FBIOGET_FSCREENINFO
%14 = bitcast %struct.fb_fix_screeninfo* %2 to %struct.fb_var_screeninfo*
%15 = call i32 @ioctl(i32 %6, i32 %13, %struct.fb_var_screeninfo* %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @exit(i32 2)
unreachable
20: ; preds = %11
%21 = load i32, i32* @FBIOGET_VSCREENINFO
%22 = call i32 @ioctl(i32 %6, i32 %21, %struct.fb_var_screeninfo* %1)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 @exit(i32 3)
unreachable
27: ; preds = %20
%28 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 0
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 1
%31 = load i32, i32* %30
%32 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 2
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %29, i32 %31, i32 %33)
%35 = load i32, i32* %28
%36 = load i32, i32* %30
%37 = mul nsw i32 %36, %35
%38 = load i32, i32* %32
%39 = mul nsw i32 %37, %38
%40 = sdiv i32 %39, 8
%41 = sext i32 %40 to i64
%42 = load i32, i32* @PROT_READ
%43 = load i32, i32* @PROT_WRITE
%44 = or i32 %43, %42
%45 = load i32, i32* @MAP_SHARED
%46 = call i64 @mmap(i32 0, i64 %41, i32 %44, i32 %45, i32 %6, i32 0)
%47 = inttoptr i64 %46 to i8*
%48 = trunc i64 %46 to i32
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %53
50: ; preds = %27
%51 = call i32 @perror(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0))
%52 = call i32 @exit(i32 4)
unreachable
53: ; preds = %27
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.8, i64 0, i64 0))
%55 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 3
%56 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 4
%57 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %2, i64 0, i32 5
br label %58
58: ; preds = %53, %105
%59 = phi i32 [ 100, %53 ], [ %106, %105 ]
%60 = add nsw i32 %59, -100
%61 = sdiv i32 %60, -16
%62 = shl i32 %61, 11
%63 = add i32 %62, 63488
%64 = sdiv i32 %60, -5
%65 = trunc i32 %64 to i8
%66 = add i8 %65, -56
br label %67
67: ; preds = %58, %102
%68 = phi i32 [ 100, %58 ], [ %103, %102 ]
%69 = load i32, i32* %55
%70 = add nsw i32 %69, %68
%71 = load i32, i32* %32
%72 = sdiv i32 %71, 8
%73 = mul nsw i32 %72, %70
%74 = load i32, i32* %56
%75 = add nsw i32 %74, %59
%76 = load i32, i32* %57
%77 = mul nsw i32 %75, %76
%78 = add nsw i32 %77, %73
%79 = sext i32 %78 to i64
%80 = icmp eq i32 %71, 32
br i1 %80, label %81, label %91
81: ; preds = %67
%82 = getelementptr inbounds i8, i8* %47, i64 %79
store i8 100, i8* %82
%83 = trunc i32 %68 to i16
%84 = add i16 %83, -100
%85 = sdiv i16 %84, 2
%86 = trunc i16 %85 to i8
%87 = add nsw i8 %86, 15
%88 = getelementptr inbounds i8, i8* %82, i64 1
store i8 %87, i8* %88
%89 = getelementptr inbounds i8, i8* %82, i64 2
store i8 %66, i8* %89
%90 = getelementptr inbounds i8, i8* %82, i64 3
store i8 0, i8* %90
br label %102
91: ; preds = %67
%92 = trunc i32 %68 to i16
%93 = add i16 %92, -100
%94 = sdiv i16 %93, 6
%95 = sext i16 %94 to i32
%96 = shl nsw i32 %95, 5
%97 = or i32 %96, %63
%98 = trunc i32 %97 to i16
%99 = or i16 %98, 10
%100 = getelementptr inbounds i8, i8* %47, i64 %79
%101 = bitcast i8* %100 to i16*
store i16 %99, i16* %101
br label %102
102: ; preds = %81, %91
%103 = add nuw nsw i32 %68, 1
%104 = icmp eq i32 %103, 300
br i1 %104, label %105, label %67
105: ; preds = %102
%106 = add nuw nsw i32 %59, 1
%107 = icmp eq i32 %106, 300
br i1 %107, label %108, label %58
108: ; preds = %105
%109 = call i32 @munmap(i8* %47, i64 %41)
%110 = call i32 @close(i32 %6)
ret i32 0
}