#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 unsigned long long uint64_t;
typedef unsigned long long uint32_t;
typedef unsigned long long uint16_t;
struct fb_var_screeninfo {
  unsigned int line_length;
  unsigned int yres_virtual;
};
struct fb_fix_screeninfo {
  unsigned int line_length;
  unsigned int yres_virtual;
};

/* 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(unsigned int);
int errno;
scalar_t__ ioctl(unsigned int, int /*<<< orphan*/, struct fb_var_screeninfo *);
int /*<<< orphan*/ memset(void *, unsigned long long, unsigned int);
void *mmap(int /*<<< orphan*/, unsigned int, int, int /*<<< orphan*/,
           unsigned int, int /*<<< orphan*/);
int /*<<< orphan*/ munmap(void *, unsigned int);
unsigned int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
unsigned int strtol(char *, int /*<<< orphan*/, int /*<<< orphan*/);
unsigned long long strtoull(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct fb_fix_screeninfo finfo;
  struct fb_var_screeninfo vinfo;
  void *fbp, *p, *fbp_end;
  unsigned int fbfd, width, fb_size;
  unsigned long long int value;
  char fb_dev[10];
  if (argc != 4) {
    puts("Usage: fbfill /dev/fb*  bits-per-pixel  value");
    return -1;
  }
  if (strlen(argv[1]) >= 10) {
    printf("string %s to long\n", argv[1]);
    return -1;
  } else
    strcpy(fb_dev, argv[1]);
  width = strtol(argv[2], 0, 0);
  if (width != 8 && width != 16 && width != 32 && width != 64) {
    puts("Supported bits-per-pixel: 8, 16, 32, 64");
    return -1;
  }
  value = strtoull(argv[3], 0, 0);
  printf("0x%llX\n", value);
  fbfd = open(fb_dev, O_RDWR);
  if (fbfd < 0) {
    printf("Error opening framebuffer device %s\n", fb_dev);
    perror(NULL);
    return -errno;
  }
  if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
    perror("Error reading fixed information");
    return -errno;
  }
  if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
    perror("Error reading variable information");
    return -errno;
  }
  fb_size = finfo.line_length * vinfo.yres_virtual;
  fbp = mmap(0, fb_size, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
  if ((int)fbp == -1) {
    perror("Error mapping framebuffer device");
    close(fbfd);
    return -errno;
  }
  p = fbp;
  fbp_end = fbp + fb_size;
  switch (width) {
  case 8:
    memset(p, value, fb_size);
    break;
  case 16:
    for (; p < fbp_end; p += 2)
      *(uint16_t *)p = value;
    break;
  case 32:
    for (; p < fbp_end; p += 4)
      *(uint32_t *)p = value;
    break;
  case 64:
    for (; p < fbp_end; p += 8)
      *(uint64_t *)p = value;
    break;
  }
  munmap(fbp, fb_size);
  close(fbfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1208 <main+0x38>
lea    0xe09(%rip),%rdi
call   1040 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    152d <main+0x35d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlen@plt>
cmp    $0xa,%eax
jl     1240 <main+0x70>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    152d <main+0x35d>
lea    -0x5a(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10c0 <strtol@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x8,-0x40(%rbp)
je     12a5 <main+0xd5>
cmpl   $0x10,-0x40(%rbp)
je     12a5 <main+0xd5>
cmpl   $0x20,-0x40(%rbp)
je     12a5 <main+0xd5>
cmpl   $0x40,-0x40(%rbp)
je     12a5 <main+0xd5>
lea    0xdad(%rip),%rdi
call   1040 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    152d <main+0x35d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   10b0 <strtoull@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rsi
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x5a(%rbp),%rdi
mov    0x2d01(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jae    1319 <main+0x149>
lea    -0x5a(%rbp),%rsi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <perror@plt>
xor    %eax,%eax
mov    0x2cb1(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    152d <main+0x35d>
mov    -0x3c(%rbp),%edi
mov    0x2ca5(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1090 <ioctl@plt>
cmp    $0x0,%rax
je     1357 <main+0x187>
lea    0xd57(%rip),%rdi
call   10f0 <perror@plt>
xor    %eax,%eax
mov    0x2c73(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    152d <main+0x35d>
mov    -0x3c(%rbp),%edi
mov    0x2c4f(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1090 <ioctl@plt>
cmp    $0x0,%rax
je     1395 <main+0x1c5>
lea    0xd39(%rip),%rdi
call   10f0 <perror@plt>
xor    %eax,%eax
mov    0x2c35(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    152d <main+0x35d>
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%esi
mov    0x2c4f(%rip),%rax
mov    (%rax),%edx
mov    0x2c06(%rip),%rax
or     (%rax),%edx
mov    0x2c2d(%rip),%rax
mov    (%rax),%ecx
mov    -0x3c(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1060 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    $0xffffffff,%eax
jne    1404 <main+0x234>
lea    0xcf5(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x3c(%rbp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
mov    0x2bc6(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    152d <main+0x35d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x44(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x60(%rbp)
sub    $0x8,%eax
je     1461 <main+0x291>
jmp    142e <main+0x25e>
mov    -0x60(%rbp),%eax
sub    $0x10,%eax
je     1476 <main+0x2a6>
jmp    143f <main+0x26f>
mov    -0x60(%rbp),%eax
sub    $0x20,%eax
je     14aa <main+0x2da>
jmp    1450 <main+0x280>
mov    -0x60(%rbp),%eax
sub    $0x40,%eax
je     14de <main+0x30e>
jmp    1512 <main+0x342>
mov    -0x30(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1080 <memset@plt>
jmp    1512 <main+0x342>
jmp    147b <main+0x2ab>
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    14a5 <main+0x2d5>
mov    -0x50(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x30(%rbp)
jmp    147b <main+0x2ab>
jmp    1512 <main+0x342>
jmp    14af <main+0x2df>
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    14d9 <main+0x309>
mov    -0x50(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
jmp    14af <main+0x2df>
jmp    1512 <main+0x342>
jmp    14e3 <main+0x313>
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    150d <main+0x33d>
mov    -0x50(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
jmp    14e3 <main+0x313>
jmp    1512 <main+0x342>
mov    -0x28(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   10d0 <munmap@plt>
mov    -0x3c(%rbp),%edi
call   10a0 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x4,%edi
jne    1210 <main+0x40>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
call   1050 <strlen@plt>
mov    0x8(%rbp),%rsi
cmp    $0xa,%eax
jl     1226 <main+0x56>
lea    0xe4f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%ebp
jmp    1501 <main+0x331>
lea    0xe09(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebp
jmp    1501 <main+0x331>
lea    0x1e(%rsp),%rdi
call   1030 <strcpy@plt>
mov    0x10(%rbp),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <strtol@plt>
mov    %eax,%ebx
add    $0xfffffff8,%ebx
rol    $0x1d,%ebx
cmp    $0x7,%ebx
ja     134c <main+0x17c>
mov    $0x8b,%eax
bt     %ebx,%eax
jae    134c <main+0x17c>
mov    0x18(%rbp),%rdi
xor    %ebp,%ebp
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <strtoull@plt>
mov    %rax,%r12
lea    0xe14(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%esi
lea    0x1e(%rsp),%rdi
call   10e0 <open@plt>
mov    %eax,%r14d
mov    0x2d2c(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %r14d,%edi
call   1090 <ioctl@plt>
test   %rax,%rax
jne    1405 <main+0x235>
mov    0x2cf5(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %r14d,%edi
call   1090 <ioctl@plt>
test   %rax,%rax
jne    1413 <main+0x243>
mov    0xc(%rsp),%r15d
imul   0x10(%rsp),%r15d
mov    0x2d13(%rip),%rax
mov    0x2ccc(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2cf1(%rip),%rax
mov    (%rax),%ecx
xor    %ebp,%ebp
xor    %edi,%edi
mov    %r15d,%esi
mov    %r14d,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,%r13
cmp    $0xffffffff,%r13d
je     142f <main+0x25f>
cmp    $0x7,%ebx
ja     14ec <main+0x31c>
mov    %r15d,%eax
add    %r13,%rax
mov    %ebx,%ecx
lea    0xcd0(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1080 <memset@plt>
jmp    14ec <main+0x31c>
lea    0xd0e(%rip),%rdi
jmp    1217 <main+0x47>
cmp    %rax,%r13
jae    14ec <main+0x31c>
mov    %r13,%rcx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,(%rcx)
add    $0x2,%rcx
cmp    %rax,%rcx
jb     1370 <main+0x1a0>
jmp    14ec <main+0x31c>
cmp    %rax,%r13
jae    14ec <main+0x31c>
mov    %r13,%rcx
nopl   (%rax)
mov    %r12,(%rcx)
add    $0x4,%rcx
cmp    %rax,%rcx
jb     1390 <main+0x1c0>
jmp    14ec <main+0x31c>
cmp    %rax,%r13
jae    14ec <main+0x31c>
lea    0x8(%r13),%rdx
cmp    %rdx,%rax
cmova  %rax,%rdx
mov    %r13,%rcx
not    %rcx
add    %rdx,%rcx
mov    %r13,%rdx
cmp    $0x18,%rcx
jb     14e0 <main+0x310>
shr    $0x3,%rcx
add    $0x1,%rcx
mov    %rcx,%rdx
and    $0xfffffffffffffffc,%rdx
movq   %r12,%xmm0
pshufd $0x44,%xmm0,%xmm0
lea    -0x4(%rdx),%rbp
mov    %rbp,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
mov    %edi,%esi
and    $0x3,%esi
cmp    $0xc,%rbp
jae    1451 <main+0x281>
xor    %ebp,%ebp
jmp    1499 <main+0x2c9>
lea    0xc85(%rip),%rdi
call   10f0 <perror@plt>
jmp    1443 <main+0x273>
lea    0xc97(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b9a(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
jmp    1501 <main+0x331>
lea    0xc9e(%rip),%rdi
call   10f0 <perror@plt>
mov    %r14d,%edi
call   10a0 <close@plt>
mov    0x2b76(%rip),%rax
sub    (%rax),%ebp
jmp    1501 <main+0x331>
and    $0xfffffffffffffffc,%rdi
xor    %ebp,%ebp
movdqu %xmm0,0x0(%r13,%rbp,8)
movdqu %xmm0,0x10(%r13,%rbp,8)
movdqu %xmm0,0x20(%r13,%rbp,8)
movdqu %xmm0,0x30(%r13,%rbp,8)
movdqu %xmm0,0x40(%r13,%rbp,8)
movdqu %xmm0,0x50(%r13,%rbp,8)
movdqu %xmm0,0x60(%r13,%rbp,8)
movdqu %xmm0,0x70(%r13,%rbp,8)
add    $0x10,%rbp
add    $0xfffffffffffffffc,%rdi
jne    1457 <main+0x287>
test   %rsi,%rsi
je     14c3 <main+0x2f3>
lea    0x10(,%rbp,8),%rdi
add    %r13,%rdi
shl    $0x5,%rsi
xor    %ebp,%ebp
movdqu %xmm0,-0x10(%rdi,%rbp,1)
movdqu %xmm0,(%rdi,%rbp,1)
add    $0x20,%rbp
cmp    %rbp,%rsi
jne    14af <main+0x2df>
cmp    %rdx,%rcx
je     14ec <main+0x31c>
lea    0x0(,%rdx,8),%rdx
add    %r13,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,(%rdx)
add    $0x8,%rdx
cmp    %rax,%rdx
jb     14e0 <main+0x310>
mov    %r13,%rdi
mov    %r15d,%esi
call   10d0 <munmap@plt>
mov    %r14d,%edi
call   10a0 <close@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.fb_fix_screeninfo = type { i32, i32 }
%struct.fb_var_screeninfo = type { i32, i32 }
@.str = [46 x i8] c"Usage: fbfill /dev/fb* bits-per-pixel value\00"
@.str.1 = [19 x i8] c"string %s to long\0A\00"
@.str.2 = [40 x i8] c"Supported bits-per-pixel: 8, 16, 32, 64\00"
@.str.3 = [8 x i8] c"0x%llX\0A\00"
@O_RDWR = global i32 0
@.str.4 = [37 x i8] c"Error opening framebuffer device %s\0A\00"
@errno = global i32 0
@FBIOGET_FSCREENINFO = global i32 0
@.str.5 = [32 x i8] c"Error reading fixed information\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.6 = [35 x i8] c"Error reading variable information\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.7 = [33 x i8] c"Error mapping framebuffer device\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.fb_fix_screeninfo
%7 = alloca %struct.fb_var_screeninfo
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca [10 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 4
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @puts(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %171
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @strlen(i8* %23)
%25 = icmp sge i32 %24, 10
br i1 %25, label %26, label %31
26: ; preds = %20
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %29)
store i32 -1, i32* %3
br label %171
31: ; preds = %20
%32 = getelementptr inbounds [10 x i8], [10 x i8]* %15, i64 0, i64 0
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strcpy(i8* %32, i8* %35)
br label %37
37: ; preds = %31
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @strtol(i8* %40, i32 0, i32 0)
store i32 %41, i32* %12
%42 = load i32, i32* %12
%43 = icmp ne i32 %42, 8
br i1 %43, label %44, label %55
44: ; preds = %37
%45 = load i32, i32* %12
%46 = icmp ne i32 %45, 16
br i1 %46, label %47, label %55
47: ; preds = %44
%48 = load i32, i32* %12
%49 = icmp ne i32 %48, 32
br i1 %49, label %50, label %55
50: ; preds = %47
%51 = load i32, i32* %12
%52 = icmp ne i32 %51, 64
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 @puts(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %171
55: ; preds = %50, %47, %44, %37
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 3
%58 = load i8*, i8** %57
%59 = call i64 @strtoull(i8* %58, i32 0, i32 0)
store i64 %59, i64* %14
%60 = load i64, i64* %14
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %60)
%62 = getelementptr inbounds [10 x i8], [10 x i8]* %15, i64 0, i64 0
%63 = load i32, i32* @O_RDWR
%64 = call i32 @open(i8* %62, i32 %63)
store i32 %64, i32* %11
%65 = load i32, i32* %11
%66 = icmp ult i32 %65, 0
br i1 %66, label %67, label %73
67: ; preds = %55
%68 = getelementptr inbounds [10 x i8], [10 x i8]* %15, i64 0, i64 0
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %68)
%70 = call i32 @perror(i8* null)
%71 = load i32, i32* @errno
%72 = sub nsw i32 0, %71
store i32 %72, i32* %3
br label %171
73: ; preds = %55
%74 = load i32, i32* %11
%75 = load i32, i32* @FBIOGET_FSCREENINFO
%76 = bitcast %struct.fb_fix_screeninfo* %6 to %struct.fb_var_screeninfo*
%77 = call i64 @ioctl(i32 %74, i32 %75, %struct.fb_var_screeninfo* %76)
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %83
79: ; preds = %73
%80 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%81 = load i32, i32* @errno
%82 = sub nsw i32 0, %81
store i32 %82, i32* %3
br label %171
83: ; preds = %73
%84 = load i32, i32* %11
%85 = load i32, i32* @FBIOGET_VSCREENINFO
%86 = call i64 @ioctl(i32 %84, i32 %85, %struct.fb_var_screeninfo* %7)
%87 = icmp ne i64 %86, 0
br i1 %87, label %88, label %92
88: ; preds = %83
%89 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%90 = load i32, i32* @errno
%91 = sub nsw i32 0, %90
store i32 %91, i32* %3
br label %171
92: ; preds = %83
%93 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %6, i32 0, i32 0
%94 = load i32, i32* %93
%95 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i32 0, i32 1
%96 = load i32, i32* %95
%97 = mul i32 %94, %96
store i32 %97, i32* %13
%98 = load i32, i32* %13
%99 = load i32, i32* @PROT_READ
%100 = load i32, i32* @PROT_WRITE
%101 = or i32 %99, %100
%102 = load i32, i32* @MAP_SHARED
%103 = load i32, i32* %11
%104 = call i8* @mmap(i32 0, i32 %98, i32 %101, i32 %102, i32 %103, i32 0)
store i8* %104, i8** %8
%105 = load i8*, i8** %8
%106 = ptrtoint i8* %105 to i32
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %114
108: ; preds = %92
%109 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%110 = load i32, i32* %11
%111 = call i32 @close(i32 %110)
%112 = load i32, i32* @errno
%113 = sub nsw i32 0, %112
store i32 %113, i32* %3
br label %171
114: ; preds = %92
%115 = load i8*, i8** %8
store i8* %115, i8** %9
%116 = load i8*, i8** %8
%117 = load i32, i32* %13
%118 = zext i32 %117 to i64
%119 = getelementptr i8, i8* %116, i64 %118
store i8* %119, i8** %10
%120 = load i32, i32* %12
switch i32 %120, label %165 [
i32 8, label %121
i32 16, label %126
i32 32, label %139
i32 64, label %152
]
121: ; preds = %114
%122 = load i8*, i8** %9
%123 = load i64, i64* %14
%124 = load i32, i32* %13
%125 = call i32 @memset(i8* %122, i64 %123, i32 %124)
br label %165
126: ; preds = %114
br label %127
127: ; preds = %135, %126
%128 = load i8*, i8** %9
%129 = load i8*, i8** %10
%130 = icmp ult i8* %128, %129
br i1 %130, label %131, label %138
131: ; preds = %127
%132 = load i64, i64* %14
%133 = load i8*, i8** %9
%134 = bitcast i8* %133 to i64*
store i64 %132, i64* %134
br label %135
135: ; preds = %131
%136 = load i8*, i8** %9
%137 = getelementptr i8, i8* %136, i64 2
store i8* %137, i8** %9
br label %127
138: ; preds = %127
br label %165
139: ; preds = %114
br label %140
140: ; preds = %148, %139
%141 = load i8*, i8** %9
%142 = load i8*, i8** %10
%143 = icmp ult i8* %141, %142
br i1 %143, label %144, label %151
144: ; preds = %140
%145 = load i64, i64* %14
%146 = load i8*, i8** %9
%147 = bitcast i8* %146 to i64*
store i64 %145, i64* %147
br label %148
148: ; preds = %144
%149 = load i8*, i8** %9
%150 = getelementptr i8, i8* %149, i64 4
store i8* %150, i8** %9
br label %140
151: ; preds = %140
br label %165
152: ; preds = %114
br label %153
153: ; preds = %161, %152
%154 = load i8*, i8** %9
%155 = load i8*, i8** %10
%156 = icmp ult i8* %154, %155
br i1 %156, label %157, label %164
157: ; preds = %153
%158 = load i64, i64* %14
%159 = load i8*, i8** %9
%160 = bitcast i8* %159 to i64*
store i64 %158, i64* %160
br label %161
161: ; preds = %157
%162 = load i8*, i8** %9
%163 = getelementptr i8, i8* %162, i64 8
store i8* %163, i8** %9
br label %153
164: ; preds = %153
br label %165
165: ; preds = %114, %164, %151, %138, %121
%166 = load i8*, i8** %8
%167 = load i32, i32* %13
%168 = call i32 @munmap(i8* %166, i32 %167)
%169 = load i32, i32* %11
%170 = call i32 @close(i32 %169)
store i32 0, i32* %3
br label %171
171: ; preds = %165, %108, %88, %79, %67, %53, %26, %18
%172 = load i32, i32* %3
ret i32 %172
}

LLVM IR (-O2):
%struct.fb_fix_screeninfo = type { i32, i32 }
%struct.fb_var_screeninfo = type { i32, i32 }
@.str = [46 x i8] c"Usage: fbfill /dev/fb* bits-per-pixel value\00"
@.str.1 = [19 x i8] c"string %s to long\0A\00"
@.str.2 = [40 x i8] c"Supported bits-per-pixel: 8, 16, 32, 64\00"
@.str.3 = [8 x i8] c"0x%llX\0A\00"
@O_RDWR = global i32 0
@errno = global i32 0
@FBIOGET_FSCREENINFO = global i32 0
@.str.5 = [32 x i8] c"Error reading fixed information\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.6 = [35 x i8] c"Error reading variable information\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.7 = [33 x i8] c"Error mapping framebuffer device\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.fb_fix_screeninfo
%4 = alloca %struct.fb_var_screeninfo
%5 = alloca [10 x i8]
%6 = bitcast %struct.fb_fix_screeninfo* %3 to i8*
%7 = bitcast %struct.fb_var_screeninfo* %4 to i8*
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 4
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %171
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @strlen(i8* %14)
%16 = icmp sgt i32 %15, 9
%17 = load i8*, i8** %13
br i1 %16, label %18, label %20
18: ; preds = %12
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %171
20: ; preds = %12
%21 = call i32 @strcpy(i8* %8, i8* %17)
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @strtol(i8* %23, i32 0, i32 0)
%25 = add i32 %24, -8
%26 = call i32 @llvm.fshl.i32(i32 %25, i32 %25, i32 29)
switch i32 %26, label %27 [
i32 7, label %29
i32 3, label %29
i32 1, label %29
i32 0, label %29
]
27: ; preds = %20
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
br label %171
29: ; preds = %20, %20, %20, %20
%30 = getelementptr inbounds i8*, i8** %1, i64 3
%31 = load i8*, i8** %30
%32 = call i64 @strtoull(i8* %31, i32 0, i32 0)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %32)
%34 = load i32, i32* @O_RDWR
%35 = call i32 @open(i8* %8, i32 %34)
%36 = load i32, i32* @FBIOGET_FSCREENINFO
%37 = bitcast %struct.fb_fix_screeninfo* %3 to %struct.fb_var_screeninfo*
%38 = call i64 @ioctl(i32 %35, i32 %36, %struct.fb_var_screeninfo* %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %29
%41 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%42 = load i32, i32* @errno
%43 = sub nsw i32 0, %42
br label %171
44: ; preds = %29
%45 = load i32, i32* @FBIOGET_VSCREENINFO
%46 = call i64 @ioctl(i32 %35, i32 %45, %struct.fb_var_screeninfo* %4)
%47 = icmp eq i64 %46, 0
br i1 %47, label %52, label %48
48: ; preds = %44
%49 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%50 = load i32, i32* @errno
%51 = sub nsw i32 0, %50
br label %171
52: ; preds = %44
%53 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %3, i64 0, i32 0
%54 = load i32, i32* %53
%55 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %4, i64 0, i32 1
%56 = load i32, i32* %55
%57 = mul i32 %56, %54
%58 = load i32, i32* @PROT_READ
%59 = load i32, i32* @PROT_WRITE
%60 = or i32 %59, %58
%61 = load i32, i32* @MAP_SHARED
%62 = call i8* @mmap(i32 0, i32 %57, i32 %60, i32 %61, i32 %35, i32 0)
%63 = ptrtoint i8* %62 to i64
%64 = trunc i64 %63 to i32
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %71
66: ; preds = %52
%67 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%68 = call i32 @close(i32 %35)
%69 = load i32, i32* @errno
%70 = sub nsw i32 0, %69
br label %171
71: ; preds = %52
%72 = zext i32 %57 to i64
%73 = getelementptr i8, i8* %62, i64 %72
switch i32 %26, label %168 [
i32 0, label %151
i32 1, label %149
i32 3, label %147
i32 7, label %74
]
74: ; preds = %71
%75 = icmp ult i8* %62, %73
br i1 %75, label %76, label %168
76: ; preds = %74
%77 = add i64 %63, %72
%78 = add i64 %63, 8
%79 = call i64 @llvm.umax.i64(i64 %77, i64 %78)
%80 = xor i64 %63, -1
%81 = add i64 %79, %80
%82 = lshr i64 %81, 3
%83 = add nuw nsw i64 %82, 1
%84 = icmp ult i64 %81, 24
br i1 %84, label %145, label %85
85: ; preds = %76
%86 = and i64 %83, 4611686018427387900
%87 = shl i64 %86, 3
%88 = getelementptr i8, i8* %62, i64 %87
%89 = insertelement <2 x i64> poison, i64 %32, i64 0
%90 = shufflevector <2 x i64> %89, <2 x i64> poison, <2 x i32> zeroinitializer
%91 = insertelement <2 x i64> poison, i64 %32, i64 0
%92 = shufflevector <2 x i64> %91, <2 x i64> poison, <2 x i32> zeroinitializer
%93 = add nsw i64 %86, -4
%94 = lshr exact i64 %93, 2
%95 = add nuw nsw i64 %94, 1
%96 = and i64 %95, 3
%97 = icmp ult i64 %93, 12
br i1 %97, label %129, label %98
98: ; preds = %85
%99 = and i64 %95, 9223372036854775804
br label %100
100: ; preds = %100, %98
%101 = phi i64 [ 0, %98 ], [ %126, %100 ]
%102 = phi i64 [ 0, %98 ], [ %127, %100 ]
%103 = shl i64 %101, 3
%104 = getelementptr i8, i8* %62, i64 %103
%105 = bitcast i8* %104 to <2 x i64>*
store <2 x i64> %90, <2 x i64>* %105
%106 = getelementptr i8, i8* %104, i64 16
%107 = bitcast i8* %106 to <2 x i64>*
store <2 x i64> %92, <2 x i64>* %107
%108 = shl i64 %101, 3
%109 = or i64 %108, 32
%110 = getelementptr i8, i8* %62, i64 %109
%111 = bitcast i8* %110 to <2 x i64>*
store <2 x i64> %90, <2 x i64>* %111
%112 = getelementptr i8, i8* %110, i64 16
%113 = bitcast i8* %112 to <2 x i64>*
store <2 x i64> %92, <2 x i64>* %113
%114 = shl i64 %101, 3
%115 = or i64 %114, 64
%116 = getelementptr i8, i8* %62, i64 %115
%117 = bitcast i8* %116 to <2 x i64>*
store <2 x i64> %90, <2 x i64>* %117
%118 = getelementptr i8, i8* %116, i64 16
%119 = bitcast i8* %118 to <2 x i64>*
store <2 x i64> %92, <2 x i64>* %119
%120 = shl i64 %101, 3
%121 = or i64 %120, 96
%122 = getelementptr i8, i8* %62, i64 %121
%123 = bitcast i8* %122 to <2 x i64>*
store <2 x i64> %90, <2 x i64>* %123
%124 = getelementptr i8, i8* %122, i64 16
%125 = bitcast i8* %124 to <2 x i64>*
store <2 x i64> %92, <2 x i64>* %125
%126 = add nuw i64 %101, 16
%127 = add nuw i64 %102, 4
%128 = icmp eq i64 %127, %99
br i1 %128, label %129, label %100
129: ; preds = %100, %85
%130 = phi i64 [ 0, %85 ], [ %126, %100 ]
%131 = icmp eq i64 %96, 0
br i1 %131, label %143, label %132
132: ; preds = %129, %132
%133 = phi i64 [ %140, %132 ], [ %130, %129 ]
%134 = phi i64 [ %141, %132 ], [ 0, %129 ]
%135 = shl i64 %133, 3
%136 = getelementptr i8, i8* %62, i64 %135
%137 = bitcast i8* %136 to <2 x i64>*
store <2 x i64> %90, <2 x i64>* %137
%138 = getelementptr i8, i8* %136, i64 16
%139 = bitcast i8* %138 to <2 x i64>*
store <2 x i64> %92, <2 x i64>* %139
%140 = add nuw i64 %133, 4
%141 = add i64 %134, 1
%142 = icmp eq i64 %141, %96
br i1 %142, label %143, label %132
143: ; preds = %132, %129
%144 = icmp eq i64 %83, %86
br i1 %144, label %168, label %145
145: ; preds = %76, %143
%146 = phi i8* [ %62, %76 ], [ %88, %143 ]
br label %163
147: ; preds = %71
%148 = icmp ult i8* %62, %73
br i1 %148, label %158, label %168
149: ; preds = %71
%150 = icmp ult i8* %62, %73
br i1 %150, label %153, label %168
151: ; preds = %71
%152 = call i32 @memset(i8* %62, i64 %32, i32 %57)
br label %168
153: ; preds = %149, %153
%154 = phi i8* [ %156, %153 ], [ %62, %149 ]
%155 = bitcast i8* %154 to i64*
store i64 %32, i64* %155
%156 = getelementptr i8, i8* %154, i64 2
%157 = icmp ult i8* %156, %73
br i1 %157, label %153, label %168
158: ; preds = %147, %158
%159 = phi i8* [ %161, %158 ], [ %62, %147 ]
%160 = bitcast i8* %159 to i64*
store i64 %32, i64* %160
%161 = getelementptr i8, i8* %159, i64 4
%162 = icmp ult i8* %161, %73
br i1 %162, label %158, label %168
163: ; preds = %145, %163
%164 = phi i8* [ %166, %163 ], [ %146, %145 ]
%165 = bitcast i8* %164 to i64*
store i64 %32, i64* %165
%166 = getelementptr i8, i8* %164, i64 8
%167 = icmp ult i8* %166, %73
br i1 %167, label %163, label %168
168: ; preds = %163, %158, %153, %143, %74, %147, %149, %71, %151
%169 = call i32 @munmap(i8* %62, i32 %57)
%170 = call i32 @close(i32 %35)
br label %171
171: ; preds = %168, %66, %48, %40, %27, %18, %10
%172 = phi i32 [ -1, %10 ], [ -1, %18 ], [ -1, %27 ], [ %43, %40 ], [ %51, %48 ], [ %70, %66 ], [ 0, %168 ]
ret i32 %172
}