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

/* 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);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct fb_var_screeninfo *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
scalar_t__ mmap(int /*<<< orphan*/, int, int, int /*<<< orphan*/, int,
                int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ output_bmp(unsigned char *, int, int, int, char *);
int /*<<< orphan*/ printf(char *, ...);
int screenshot(char *filename) {
  struct fb_var_screeninfo vinfo;
  struct fb_fix_screeninfo fix;
  unsigned char *buf;
  int i;
  int screen_size;
  int fb_fd;
  unsigned char *fb_area;
  fb_fd = open("/dev/fb0", O_RDWR);
  if (!fb_fd) {
    printf("Could not open framebuffer.\n");
    return -1;
  }
  if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &vinfo)) {
    printf("Could not read variable screen info.\n");
    return -3;
  }
  printf("Screen Info\n");
  printf("vinfo.bits_per_pixel %d\n", vinfo.bits_per_pixel);
  printf("vinfo.xres %d\n", vinfo.xres);
  printf("vinfo.yres %d\n", vinfo.yres);
  screen_size = vinfo.xres * vinfo.yres * (vinfo.bits_per_pixel / 8);
  printf("screen_size %d\n", screen_size);
  if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &fix)) {
    printf("Could get fix screen info.\n");
    close(fb_fd);
    return -3;
  }
  printf("Line Length %d\n", fix.line_length);
  printf("Physical Address %x\n", fix.smem_start);
  printf("Buffer Length %d\n", fix.smem_len);
  fb_area = (unsigned char *)mmap(0, screen_size, PROT_READ | PROT_WRITE,
                                  MAP_SHARED, fb_fd, 0);
  if (fb_area < 0) {
    printf("Memory Map for the LCD failed\n");
    close(fb_fd);
    return -1;
  }
  buf = (unsigned char *)malloc(screen_size);
  memcpy(buf, fb_area, screen_size);
  output_bmp(buf, vinfo.xres, vinfo.yres, vinfo.bits_per_pixel, filename);
  close(fb_fd);
  return 0;
}


x86 assembly (clang, -O0):
<screenshot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
lea    0xe64(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jne    11c8 <screenshot+0x48>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1386 <screenshot+0x206>
mov    -0x54(%rbp),%edi
mov    0x2de6(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
je     1201 <screenshot+0x81>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1386 <screenshot+0x206>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x54(%rbp),%edi
mov    0x2d4b(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
je     12b4 <screenshot+0x134>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x54(%rbp),%edi
call   1070 <close@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1386 <screenshot+0x206>
mov    -0x34(%rbp),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x50(%rbp),%esi
mov    0x2d07(%rip),%rax
mov    (%rax),%edx
mov    0x2cc6(%rip),%rax
or     (%rax),%edx
mov    0x2ce5(%rip),%rax
mov    (%rax),%ecx
mov    -0x54(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jae    1345 <screenshot+0x1c5>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x54(%rbp),%edi
call   1070 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1386 <screenshot+0x206>
mov    -0x50(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x50(%rbp),%edx
call   1080 <memcpy@plt>
mov    -0x48(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x10(%rbp),%r8
call   1050 <output_bmp@plt>
mov    -0x54(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<screenshot>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
lea    0xe4f(%rip),%rdi
call   10b0 <open@plt>
test   %eax,%eax
je     11ed <screenshot+0x5d>
mov    %eax,%ebx
mov    0x2df5(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1070 <ioctl@plt>
test   %rax,%rax
je     1204 <screenshot+0x74>
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
mov    $0xfffffffd,%r15d
jmp    1344 <screenshot+0x1b4>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r15d
jmp    1344 <screenshot+0x1b4>
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%esi
lea    0xdee(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xdf2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xdef(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%eax
mov    0x10(%rsp),%ecx
imul   0xc(%rsp),%ecx
lea    0x7(%rax),%ebp
test   %eax,%eax
cmovns %eax,%ebp
sar    $0x3,%ebp
imul   %ecx,%ebp
lea    0xdd5(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rdx
mov    %ebx,%edi
call   1070 <ioctl@plt>
test   %rax,%rax
je     12ac <screenshot+0x11c>
lea    0xe1a(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1080 <close@plt>
mov    $0xfffffffd,%r15d
jmp    1344 <screenshot+0x1b4>
mov    0x2c(%rsp),%esi
lea    0xd99(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x30(%rsp),%esi
lea    0xd97(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x34(%rsp),%esi
lea    0xd9a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d0f(%rip),%rax
mov    0x2cd0(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2ced(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %ebp,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%r12
mov    %ebp,%edi
call   10a0 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1090 <memcpy@plt>
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    %r13,%rdi
mov    %r14,%r8
call   1060 <output_bmp@plt>
mov    %ebx,%edi
call   1080 <close@plt>
mov    %r15d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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 = [29 x i8] c"Could not open framebuffer.\0A\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.2 = [38 x i8] c"Could not read variable screen info.\0A\00"
@.str.3 = [13 x i8] c"Screen Info\0A\00"
@.str.4 = [25 x i8] c"vinfo.bits_per_pixel %d\0A\00"
@.str.5 = [15 x i8] c"vinfo.xres %d\0A\00"
@.str.6 = [15 x i8] c"vinfo.yres %d\0A\00"
@.str.7 = [16 x i8] c"screen_size %d\0A\00"
@FBIOGET_FSCREENINFO = global i32 0
@.str.8 = [28 x i8] c"Could get fix screen info.\0A\00"
@.str.9 = [16 x i8] c"Line Length %d\0A\00"
@.str.10 = [21 x i8] c"Physical Address %x\0A\00"
@.str.11 = [18 x i8] c"Buffer Length %d\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.12 = [31 x i8] c"Memory Map for the LCD failed\0A\00"
define i32 @screenshot(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.fb_var_screeninfo
%5 = alloca %struct.fb_fix_screeninfo
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %3
%11 = load i32, i32* @O_RDWR
%12 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %98
17: ; preds = %1
%18 = load i32, i32* %9
%19 = load i32, i32* @FBIOGET_VSCREENINFO
%20 = call i64 @ioctl(i32 %18, i32 %19, %struct.fb_var_screeninfo* %4)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
store i32 -3, i32* %2
br label %98
24: ; preds = %17
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%26 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i32 0, i32 0
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i32 0, i32 1
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i32 0, i32 2
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i32 0, i32 1
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i32 0, i32 2
%38 = load i32, i32* %37
%39 = mul nsw i32 %36, %38
%40 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i32 0, i32 0
%41 = load i32, i32* %40
%42 = sdiv i32 %41, 8
%43 = mul nsw i32 %39, %42
store i32 %43, i32* %8
%44 = load i32, i32* %8
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %9
%47 = load i32, i32* @FBIOGET_FSCREENINFO
%48 = bitcast %struct.fb_fix_screeninfo* %5 to %struct.fb_var_screeninfo*
%49 = call i64 @ioctl(i32 %46, i32 %47, %struct.fb_var_screeninfo* %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %24
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%53 = load i32, i32* %9
%54 = call i32 @close(i32 %53)
store i32 -3, i32* %2
br label %98
55: ; preds = %24
%56 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %5, i32 0, i32 3
%57 = load i32, i32* %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %57)
%59 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %5, i32 0, i32 4
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i32 %60)
%62 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %5, i32 0, i32 5
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i32 %63)
%65 = load i32, i32* %8
%66 = load i32, i32* @PROT_READ
%67 = load i32, i32* @PROT_WRITE
%68 = or i32 %66, %67
%69 = load i32, i32* @MAP_SHARED
%70 = load i32, i32* %9
%71 = call i64 @mmap(i32 0, i32 %65, i32 %68, i32 %69, i32 %70, i32 0)
%72 = inttoptr i64 %71 to i8*
store i8* %72, i8** %10
%73 = load i8*, i8** %10
%74 = icmp ult i8* %73, null
br i1 %74, label %75, label %79
75: ; preds = %55
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0))
%77 = load i32, i32* %9
%78 = call i32 @close(i32 %77)
store i32 -1, i32* %2
br label %98
79: ; preds = %55
%80 = load i32, i32* %8
%81 = call i64 @malloc(i32 %80)
%82 = inttoptr i64 %81 to i8*
store i8* %82, i8** %6
%83 = load i8*, i8** %6
%84 = load i8*, i8** %10
%85 = load i32, i32* %8
%86 = call i32 @memcpy(i8* %83, i8* %84, i32 %85)
%87 = load i8*, i8** %6
%88 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i32 0, i32 1
%89 = load i32, i32* %88
%90 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i32 0, i32 2
%91 = load i32, i32* %90
%92 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i32 0, i32 0
%93 = load i32, i32* %92
%94 = load i8*, i8** %3
%95 = call i32 @output_bmp(i8* %87, i32 %89, i32 %91, i32 %93, i8* %94)
%96 = load i32, i32* %9
%97 = call i32 @close(i32 %96)
store i32 0, i32* %2
br label %98
98: ; preds = %79, %75, %51, %22, %15
%99 = load i32, i32* %2
ret i32 %99
}

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
@FBIOGET_VSCREENINFO = global i32 0
@.str.4 = [25 x i8] c"vinfo.bits_per_pixel %d\0A\00"
@.str.5 = [15 x i8] c"vinfo.xres %d\0A\00"
@.str.6 = [15 x i8] c"vinfo.yres %d\0A\00"
@.str.7 = [16 x i8] c"screen_size %d\0A\00"
@FBIOGET_FSCREENINFO = global i32 0
@.str.9 = [16 x i8] c"Line Length %d\0A\00"
@.str.10 = [21 x i8] c"Physical Address %x\0A\00"
@.str.11 = [18 x i8] c"Buffer Length %d\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@str = [28 x i8] c"Could not open framebuffer.\00"
@str.13 = [12 x i8] c"Screen Info\00"
@str.14 = [27 x i8] c"Could get fix screen info.\00"
@str.15 = [37 x i8] c"Could not read variable screen info.\00"
define i32 @screenshot(i8* %0) {
%2 = alloca %struct.fb_var_screeninfo
%3 = alloca %struct.fb_fix_screeninfo
%4 = bitcast %struct.fb_var_screeninfo* %2 to i8*
%5 = bitcast %struct.fb_fix_screeninfo* %3 to i8*
%6 = load i32, i32* @O_RDWR
%7 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %66
11: ; preds = %1
%12 = load i32, i32* @FBIOGET_VSCREENINFO
%13 = call i64 @ioctl(i32 %7, i32 %12, %struct.fb_var_screeninfo* %2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.15, i64 0, i64 0))
br label %66
17: ; preds = %11
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.13, i64 0, i64 0))
%19 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %2, i64 0, i32 0
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %2, i64 0, i32 1
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %2, i64 0, i32 2
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %22
%29 = load i32, i32* %25
%30 = mul nsw i32 %29, %28
%31 = load i32, i32* %19
%32 = sdiv i32 %31, 8
%33 = mul nsw i32 %30, %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %33)
%35 = load i32, i32* @FBIOGET_FSCREENINFO
%36 = bitcast %struct.fb_fix_screeninfo* %3 to %struct.fb_var_screeninfo*
%37 = call i64 @ioctl(i32 %7, i32 %35, %struct.fb_var_screeninfo* %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %17
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.14, i64 0, i64 0))
%41 = call i32 @close(i32 %7)
br label %66
42: ; preds = %17
%43 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %3, i64 0, i32 3
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %3, i64 0, i32 4
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %3, i64 0, i32 5
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i32 %50)
%52 = load i32, i32* @PROT_READ
%53 = load i32, i32* @PROT_WRITE
%54 = or i32 %53, %52
%55 = load i32, i32* @MAP_SHARED
%56 = call i64 @mmap(i32 0, i32 %33, i32 %54, i32 %55, i32 %7, i32 0)
%57 = inttoptr i64 %56 to i8*
%58 = call i64 @malloc(i32 %33)
%59 = inttoptr i64 %58 to i8*
%60 = call i32 @memcpy(i8* %59, i8* %57, i32 %33)
%61 = load i32, i32* %22
%62 = load i32, i32* %25
%63 = load i32, i32* %19
%64 = call i32 @output_bmp(i8* %59, i32 %61, i32 %62, i32 %63, i8* %0)
%65 = call i32 @close(i32 %7)
br label %66
66: ; preds = %42, %39, %15, %9
%67 = phi i32 [ -3, %15 ], [ -3, %39 ], [ 0, %42 ], [ -1, %9 ]
ret i32 %67
}