#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 */
typedef struct TYPE_8__ TYPE_4__;
typedef struct TYPE_7__ TYPE_3__;
typedef struct TYPE_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_8__ {
  int length;
};
struct TYPE_7__ {
  int length;
};
struct TYPE_6__ {
  int /*<<< orphan*/ length;
};
struct TYPE_5__ {
  int /*<<< orphan*/ length;
};
struct fb_var_screeninfo {
  char *id;
  int visual;
  unsigned int grayscale;
  int bits_per_pixel;
  TYPE_4__ transp;
  TYPE_3__ red;
  TYPE_2__ blue;
  TYPE_1__ green;
};
struct fb_fix_screeninfo {
  char *id;
  int visual;
  unsigned int grayscale;
  int bits_per_pixel;
  TYPE_4__ transp;
  TYPE_3__ red;
  TYPE_2__ blue;
  TYPE_1__ green;
};

/* Variables and functions */
int EPERM;
int /*<<< orphan*/ FBIOGET_FSCREENINFO;
int /*<<< orphan*/ FBIOGET_VSCREENINFO;
#define FB_VISUAL_DIRECTCOLOR 133
#define FB_VISUAL_MONO01 132
#define FB_VISUAL_MONO10 131
#define FB_VISUAL_PSEUDOCOLOR 130
#define FB_VISUAL_STATIC_PSEUDOCOLOR 129
#define FB_VISUAL_TRUECOLOR 128
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
int errno;
scalar_t__ ioctl(int, int /*<<< orphan*/, struct fb_var_screeninfo *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sprintf(char *, char *, char);
int /*<<< orphan*/ strncmp(char *, char *, int);
int find_fb_device(struct fb_fix_screeninfo *finfo,
                   struct fb_var_screeninfo *vinfo, int bpp, int expanded,
                   unsigned char *fbid) {
  unsigned int color_type;
  int fbfd;
  char fb_dev[10], fb_id;
  printf("Searching for Xylon FB device (%d bpp) ...\n", bpp);
  fb_id = 0;
  color_type = 0;
  while (1) {
    sprintf(fb_dev, "/dev/fb%d", fb_id);
    printf("Opening device %s\n", fb_dev);
    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");
      continue;
    }
    if (ioctl(fbfd, FBIOGET_VSCREENINFO, vinfo)) {
      perror("Error reading variable information");
      continue;
    }
    printf("FB driver name: %s\n", finfo->id);
    printf("FB driver color type: ");
    switch (finfo->visual) {
    case FB_VISUAL_MONO01:
      puts("Monochrome Black(0)/White(1)");
      goto ffd_fb_not_supported;
    case FB_VISUAL_MONO10:
      puts("Monochrome Black(1)/White(0)");
      goto ffd_fb_not_supported;
    case FB_VISUAL_TRUECOLOR:
      puts("True color");
      break;
    case FB_VISUAL_PSEUDOCOLOR:
      puts("Pseudo color (ATARI)");
      break;
    case FB_VISUAL_DIRECTCOLOR:
      puts("Direct color");
      goto ffd_fb_not_supported;
    case FB_VISUAL_STATIC_PSEUDOCOLOR:
      puts("Pseudo color (readonly)");
      goto ffd_fb_not_supported;
    case 6:
      puts("Four CC color");
      color_type = vinfo->grayscale;
      break;
    default:
      goto ffd_fb_not_supported;
    }
    printf("FB driver color format:");
    if (color_type == 0)
      printf(" ARGB : ");
    else if (color_type > 0)
      printf(" %c%c%c%c : ", (color_type & 0x000000FF),
             ((color_type & 0x0000FF00) >> 8),
             ((color_type & 0x00FF0000) >> 16),
             ((color_type & 0xFF000000) >> 24));
    printf("%d%d%d%d\n", vinfo->transp.length, vinfo->red.length,
           vinfo->green.length, vinfo->blue.length);
    if (!strncmp("Xylon FB", finfo->id, 8)) {
      if (vinfo->bits_per_pixel == bpp) {
        if (expanded && (finfo->visual == FB_VISUAL_TRUECOLOR ||
                         vinfo->transp.length != 0)) {
          printf("Xylon FB device with expanded %d bpp"
                 "found: %s\n",
                 bpp, fb_dev);
          break;
        } else if (!expanded && (finfo->visual == FB_VISUAL_PSEUDOCOLOR ||
                                 vinfo->transp.length == 0)) {
          printf("Xylon FB device with %d bpp found: %s\n", bpp, fb_dev);
          break;
        }
      }
    }
    close(fbfd);
    fb_id++;
  }
  return fbfd;
ffd_fb_not_supported:
  puts("NOT SUPPORTED!");
  errno = EPERM;
  return -errno;
}


x86 assembly (clang, -O0):
<find_fb_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movb   $0x0,-0x3b(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    -0x3a(%rbp),%rdi
lea    0xe6b(%rip),%rsi
movsbl -0x3b(%rbp),%edx
call   10a0 <sprintf@plt>
lea    -0x3a(%rbp),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x3a(%rbp),%rdi
mov    0x2e01(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jge    1229 <find_fb_device+0xa9>
lea    -0x3a(%rbp),%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <perror@plt>
xor    %eax,%eax
mov    0x2db1(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1575 <find_fb_device+0x3f5>
mov    -0x30(%rbp),%edi
mov    0x2da5(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
je     1259 <find_fb_device+0xd9>
lea    0xe1f(%rip),%rdi
call   1090 <perror@plt>
jmp    11b6 <find_fb_device+0x36>
mov    -0x30(%rbp),%edi
mov    0x2d65(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
je     1289 <find_fb_device+0x109>
lea    0xe0f(%rip),%rdi
call   1090 <perror@plt>
jmp    11b6 <find_fb_device+0x36>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe1a(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x41(%rbp)
call   1050 <printf@plt>
mov    -0x41(%rbp),%al
lea    0xe1a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x40(%rbp)
sub    $0x6,%eax
je     13a0 <find_fb_device+0x220>
jmp    12c8 <find_fb_device+0x148>
mov    -0x40(%rbp),%eax
sub    $0x80,%eax
je     135c <find_fb_device+0x1dc>
jmp    12db <find_fb_device+0x15b>
mov    -0x40(%rbp),%eax
sub    $0x81,%eax
je     138f <find_fb_device+0x20f>
jmp    12ee <find_fb_device+0x16e>
mov    -0x40(%rbp),%eax
sub    $0x82,%eax
je     136d <find_fb_device+0x1ed>
jmp    1301 <find_fb_device+0x181>
mov    -0x40(%rbp),%eax
sub    $0x83,%eax
je     134b <find_fb_device+0x1cb>
jmp    1314 <find_fb_device+0x194>
mov    -0x40(%rbp),%eax
sub    $0x84,%eax
je     133a <find_fb_device+0x1ba>
jmp    1327 <find_fb_device+0x1a7>
mov    -0x40(%rbp),%eax
sub    $0x85,%eax
je     137e <find_fb_device+0x1fe>
jmp    13bb <find_fb_device+0x23b>
lea    0xd9b(%rip),%rdi
call   1040 <puts@plt>
jmp    1549 <find_fb_device+0x3c9>
lea    0xda7(%rip),%rdi
call   1040 <puts@plt>
jmp    1549 <find_fb_device+0x3c9>
lea    0xdb3(%rip),%rdi
call   1040 <puts@plt>
jmp    13c0 <find_fb_device+0x240>
lea    0xdad(%rip),%rdi
call   1040 <puts@plt>
jmp    13c0 <find_fb_device+0x240>
lea    0xdb1(%rip),%rdi
call   1040 <puts@plt>
jmp    1549 <find_fb_device+0x3c9>
lea    0xdad(%rip),%rdi
call   1040 <puts@plt>
jmp    1549 <find_fb_device+0x3c9>
lea    0xdb4(%rip),%rdi
call   1040 <puts@plt>
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    13c0 <find_fb_device+0x240>
jmp    1549 <find_fb_device+0x3c9>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    13eb <find_fb_device+0x26b>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1438 <find_fb_device+0x2b8>
cmpl   $0x0,-0x2c(%rbp)
jbe    1433 <find_fb_device+0x2b3>
mov    -0x2c(%rbp),%esi
and    $0xff,%esi
mov    -0x2c(%rbp),%edx
and    $0xff00,%edx
shr    $0x8,%edx
mov    -0x2c(%rbp),%ecx
and    $0xff0000,%ecx
shr    $0x10,%ecx
mov    -0x2c(%rbp),%r8d
and    $0xff000000,%r8d
shr    $0x18,%r8d
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1438 <find_fb_device+0x2b8>
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%edx
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x1c(%rax),%r8d
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd30(%rip),%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1529 <find_fb_device+0x3a9>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%eax
cmp    -0x1c(%rbp),%eax
jne    1524 <find_fb_device+0x3a4>
cmpl   $0x0,-0x20(%rbp)
je     14d7 <find_fb_device+0x357>
mov    -0x10(%rbp),%rax
cmpl   $0x80,0x8(%rax)
je     14bd <find_fb_device+0x33d>
mov    -0x18(%rbp),%rax
cmpl   $0x0,0x14(%rax)
je     14d7 <find_fb_device+0x357>
mov    -0x1c(%rbp),%esi
lea    -0x3a(%rbp),%rdx
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    153e <find_fb_device+0x3be>
cmpl   $0x0,-0x20(%rbp)
jne    151a <find_fb_device+0x39a>
mov    -0x10(%rbp),%rax
cmpl   $0x82,0x8(%rax)
je     1500 <find_fb_device+0x380>
mov    -0x18(%rbp),%rax
cmpl   $0x0,0x14(%rax)
jne    151a <find_fb_device+0x39a>
mov    -0x1c(%rbp),%esi
lea    -0x3a(%rbp),%rdx
lea    0xccb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    153e <find_fb_device+0x3be>
jmp    151f <find_fb_device+0x39f>
jmp    1524 <find_fb_device+0x3a4>
jmp    1529 <find_fb_device+0x3a9>
mov    -0x30(%rbp),%edi
call   1070 <close@plt>
mov    -0x3b(%rbp),%al
add    $0x1,%al
mov    %al,-0x3b(%rbp)
jmp    11b6 <find_fb_device+0x36>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1575 <find_fb_device+0x3f5>
lea    0xcb0(%rip),%rdi
call   1040 <puts@plt>
mov    0x2a5c(%rip),%rax
mov    (%rax),%ecx
mov    0x2a6b(%rip),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
mov    0x2a60(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_fb_device>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,0x8(%rsp)
mov    %rsi,%rbp
mov    %rdi,%r12
lea    0xe79(%rip),%rdi
mov    %edx,0x4(%rsp)
mov    %edx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe91(%rip),%rsi
lea    0xe(%rsp),%rbx
mov    %rbx,%rdi
xor    %edx,%edx
call   10a0 <sprintf@plt>
lea    0xe85(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <open@plt>
test   %eax,%eax
js     13d0 <find_fb_device+0x250>
mov    %eax,%ebx
lea    0xe(%rsp),%r13
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    1244 <find_fb_device+0xc4>
nopl   0x0(%rax,%rax,1)
call   1090 <perror@plt>
movsbl %r15b,%edx
mov    %r13,%rdi
lea    0xe31(%rip),%rsi
call   10a0 <sprintf@plt>
lea    0xe2f(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
call   1080 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     13d0 <find_fb_device+0x250>
mov    0x2d8d(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r12,%rdx
call   1060 <ioctl@plt>
lea    0xe28(%rip),%rdi
test   %rax,%rax
jne    1200 <find_fb_device+0x80>
mov    0x2d5e(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %rbp,%rdx
call   1060 <ioctl@plt>
lea    0xe29(%rip),%rdi
test   %rax,%rax
jne    1200 <find_fb_device+0x80>
mov    (%r12),%rsi
lea    0xe38(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%r12),%eax
lea    -0x80(%rax),%ecx
cmp    $0x5,%ecx
ja     12cc <find_fb_device+0x14c>
lea    0xd46(%rip),%rdx
movslq (%rdx,%rcx,4),%rax
add    %rdx,%rax
jmp    *%rax
lea    0xe64(%rip),%rdi
jmp    12ee <find_fb_device+0x16e>
cmp    $0x6,%eax
jne    141e <find_fb_device+0x29e>
lea    0xe97(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rbp),%r14d
jmp    12f3 <find_fb_device+0x173>
lea    0xe4b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r14d,%r14d
mov    %r14d,%eax
je     1332 <find_fb_device+0x1b2>
movzbl %al,%esi
movzbl %ah,%edx
mov    %eax,%edi
shr    $0x10,%eax
movzbl %al,%ecx
mov    %edi,%r14d
mov    %edi,%eax
shr    $0x18,%eax
lea    0xe7c(%rip),%rdi
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1343 <find_fb_device+0x1c3>
mov    %eax,%r14d
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rbp),%esi
mov    0x18(%rbp),%edx
mov    0x20(%rbp),%ecx
mov    0x1c(%rbp),%r8d
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r12),%rsi
lea    0xe50(%rip),%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    13c0 <find_fb_device+0x240>
mov    0x4(%rsp),%eax
cmp    %eax,0x10(%rbp)
jne    13c0 <find_fb_device+0x240>
mov    0x8(%r12),%eax
cmpl   $0x0,0x8(%rsp)
je     13a2 <find_fb_device+0x222>
cmp    $0x80,%eax
je     144f <find_fb_device+0x2cf>
cmpl   $0x0,0x14(%rbp)
je     13c0 <find_fb_device+0x240>
jmp    144f <find_fb_device+0x2cf>
cmp    $0x82,%eax
je     1458 <find_fb_device+0x2d8>
cmpl   $0x0,0x14(%rbp)
je     1458 <find_fb_device+0x2d8>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1070 <close@plt>
add    $0x1,%r15b
jmp    1205 <find_fb_device+0x85>
lea    0xc8a(%rip),%rdi
xor    %ebx,%ebx
lea    0xe(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <perror@plt>
mov    0x2bdd(%rip),%rax
sub    (%rax),%ebx
jmp    143e <find_fb_device+0x2be>
lea    0xd5d(%rip),%rdi
jmp    1419 <find_fb_device+0x299>
lea    0xd0a(%rip),%rdi
jmp    1419 <find_fb_device+0x299>
lea    0xce4(%rip),%rdi
jmp    1419 <find_fb_device+0x299>
lea    0xd35(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf3(%rip),%rdi
call   1040 <puts@plt>
mov    0x2b87(%rip),%rax
mov    (%rax),%ebx
mov    0x2b96(%rip),%rax
mov    %ebx,(%rax)
neg    %ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd6c(%rip),%rdi
jmp    145f <find_fb_device+0x2df>
lea    0xd92(%rip),%rdi
lea    0xe(%rsp),%rdx
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    143e <find_fb_device+0x2be>

LLVM IR (-O0):
%struct.fb_fix_screeninfo = type { i8*, i32, i32, i32, %struct.TYPE_8__, %struct.TYPE_7__, %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32 }
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_5__ = type { i32 }
%struct.fb_var_screeninfo = type { i8*, i32, i32, i32, %struct.TYPE_8__, %struct.TYPE_7__, %struct.TYPE_6__, %struct.TYPE_5__ }
@.str = [44 x i8] c"Searching for Xylon FB device (%d bpp) ...\0A\00"
@.str.1 = [10 x i8] c"/dev/fb%d\00"
@.str.2 = [19 x i8] c"Opening device %s\0A\00"
@O_RDWR = global i32 0
@.str.3 = [37 x i8] c"Error opening framebuffer device %s\0A\00"
@errno = global i32 0
@FBIOGET_FSCREENINFO = global i32 0
@.str.4 = [32 x i8] c"Error reading fixed information\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.5 = [35 x i8] c"Error reading variable information\00"
@.str.6 = [20 x i8] c"FB driver name: %s\0A\00"
@.str.7 = [23 x i8] c"FB driver color type: \00"
@.str.8 = [29 x i8] c"Monochrome Black(0)/White(1)\00"
@.str.9 = [29 x i8] c"Monochrome Black(1)/White(0)\00"
@.str.10 = [11 x i8] c"True color\00"
@.str.11 = [21 x i8] c"Pseudo color (ATARI)\00"
@.str.12 = [13 x i8] c"Direct color\00"
@.str.13 = [24 x i8] c"Pseudo color (readonly)\00"
@.str.14 = [14 x i8] c"Four CC color\00"
@.str.15 = [24 x i8] c"FB driver color format:\00"
@.str.16 = [9 x i8] c" ARGB : \00"
@.str.17 = [13 x i8] c" %c%c%c%c : \00"
@.str.18 = [10 x i8] c"%d%d%d%d\0A\00"
@.str.19 = [9 x i8] c"Xylon FB\00"
@.str.20 = [47 x i8] c"Xylon FB device with expanded %d bppfound: %s\0A\00"
@.str.21 = [39 x i8] c"Xylon FB device with %d bpp found: %s\0A\00"
@.str.22 = [15 x i8] c"NOT SUPPORTED!\00"
@EPERM = global i32 0
define i32 @find_fb_device(%struct.fb_fix_screeninfo* %0, %struct.fb_var_screeninfo* %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca %struct.fb_fix_screeninfo*
%8 = alloca %struct.fb_var_screeninfo*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca [10 x i8]
%15 = alloca i8
store %struct.fb_fix_screeninfo* %0, %struct.fb_fix_screeninfo** %7
store %struct.fb_var_screeninfo* %1, %struct.fb_var_screeninfo** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8* %4, i8** %11
%16 = load i32, i32* %9
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %16)
store i8 0, i8* %15
store i32 0, i32* %12
br label %18
18: ; preds = %5, %42, %50, %170
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %14, i64 0, i64 0
%20 = load i8, i8* %15
%21 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext %20)
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %14, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %14, i64 0, i64 0
%25 = load i32, i32* @O_RDWR
%26 = call i32 @open(i8* %24, i32 %25)
store i32 %26, i32* %13
%27 = load i32, i32* %13
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %18
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %14, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %30)
%32 = call i32 @perror(i8* null)
%33 = load i32, i32* @errno
%34 = sub nsw i32 0, %33
store i32 %34, i32* %6
br label %182
35: ; preds = %18
%36 = load i32, i32* %13
%37 = load i32, i32* @FBIOGET_FSCREENINFO
%38 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%39 = bitcast %struct.fb_fix_screeninfo* %38 to %struct.fb_var_screeninfo*
%40 = call i64 @ioctl(i32 %36, i32 %37, %struct.fb_var_screeninfo* %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %35
%43 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
br label %18
44: ; preds = %35
%45 = load i32, i32* %13
%46 = load i32, i32* @FBIOGET_VSCREENINFO
%47 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%48 = call i64 @ioctl(i32 %45, i32 %46, %struct.fb_var_screeninfo* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %44
%51 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %18
52: ; preds = %44
%53 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%54 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %53, i32 0, i32 0
%55 = load i8*, i8** %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%58 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%59 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %58, i32 0, i32 1
%60 = load i32, i32* %59
switch i32 %60, label %78 [
i32 132, label %61
i32 131, label %63
i32 128, label %65
i32 130, label %67
i32 133, label %69
i32 129, label %71
i32 6, label %73
]
61: ; preds = %52
%62 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
br label %177
63: ; preds = %52
%64 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
br label %177
65: ; preds = %52
%66 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
br label %79
67: ; preds = %52
%68 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
br label %79
69: ; preds = %52
%70 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
br label %177
71: ; preds = %52
%72 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0))
br label %177
73: ; preds = %52
%74 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0))
%75 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%76 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %75, i32 0, i32 2
%77 = load i32, i32* %76
store i32 %77, i32* %12
br label %79
78: ; preds = %52
br label %177
79: ; preds = %73, %67, %65
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0))
%81 = load i32, i32* %12
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %79
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i64 0, i64 0))
br label %102
85: ; preds = %79
%86 = load i32, i32* %12
%87 = icmp ugt i32 %86, 0
br i1 %87, label %88, label %101
88: ; preds = %85
%89 = load i32, i32* %12
%90 = and i32 %89, 255
%91 = load i32, i32* %12
%92 = and i32 %91, 65280
%93 = lshr i32 %92, 8
%94 = load i32, i32* %12
%95 = and i32 %94, 16711680
%96 = lshr i32 %95, 16
%97 = load i32, i32* %12
%98 = and i32 %97, -16777216
%99 = lshr i32 %98, 24
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i32 %90, i32 %93, i32 %96, i32 %99)
br label %101
101: ; preds = %88, %85
br label %102
102: ; preds = %101, %83
%103 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%104 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %103, i32 0, i32 4
%105 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %104, i32 0, i32 0
%106 = load i32, i32* %105
%107 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%108 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %107, i32 0, i32 5
%109 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %108, i32 0, i32 0
%110 = load i32, i32* %109
%111 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%112 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %111, i32 0, i32 7
%113 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %112, i32 0, i32 0
%114 = load i32, i32* %113
%115 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%116 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %115, i32 0, i32 6
%117 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %116, i32 0, i32 0
%118 = load i32, i32* %117
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), i32 %106, i32 %110, i32 %114, i32 %118)
%120 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%121 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %120, i32 0, i32 0
%122 = load i8*, i8** %121
%123 = call i32 @strncmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0), i8* %122, i32 8)
%124 = icmp ne i32 %123, 0
br i1 %124, label %170, label %125
125: ; preds = %102
%126 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%127 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %126, i32 0, i32 3
%128 = load i32, i32* %127
%129 = load i32, i32* %9
%130 = icmp eq i32 %128, %129
br i1 %130, label %131, label %169
131: ; preds = %125
%132 = load i32, i32* %10
%133 = icmp ne i32 %132, 0
br i1 %133, label %134, label %149
134: ; preds = %131
%135 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%136 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %135, i32 0, i32 1
%137 = load i32, i32* %136
%138 = icmp eq i32 %137, 128
br i1 %138, label %145, label %139
139: ; preds = %134
%140 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%141 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %140, i32 0, i32 4
%142 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %141, i32 0, i32 0
%143 = load i32, i32* %142
%144 = icmp ne i32 %143, 0
br i1 %144, label %145, label %149
145: ; preds = %139, %134
%146 = load i32, i32* %9
%147 = getelementptr inbounds [10 x i8], [10 x i8]* %14, i64 0, i64 0
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.20, i64 0, i64 0), i32 %146, i8* %147)
br label %175
149: ; preds = %139, %131
%150 = load i32, i32* %10
%151 = icmp ne i32 %150, 0
br i1 %151, label %167, label %152
152: ; preds = %149
%153 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%154 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %153, i32 0, i32 1
%155 = load i32, i32* %154
%156 = icmp eq i32 %155, 130
br i1 %156, label %163, label %157
157: ; preds = %152
%158 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%159 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %158, i32 0, i32 4
%160 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %159, i32 0, i32 0
%161 = load i32, i32* %160
%162 = icmp eq i32 %161, 0
br i1 %162, label %163, label %167
163: ; preds = %157, %152
%164 = load i32, i32* %9
%165 = getelementptr inbounds [10 x i8], [10 x i8]* %14, i64 0, i64 0
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.21, i64 0, i64 0), i32 %164, i8* %165)
br label %175
167: ; preds = %157, %149
br label %168
168: ; preds = %167
br label %169
169: ; preds = %168, %125
br label %170
170: ; preds = %169, %102
%171 = load i32, i32* %13
%172 = call i32 @close(i32 %171)
%173 = load i8, i8* %15
%174 = add i8 %173, 1
store i8 %174, i8* %15
br label %18
175: ; preds = %163, %145
%176 = load i32, i32* %13
store i32 %176, i32* %6
br label %182
177: ; preds = %78, %71, %69, %63, %61
%178 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.22, i64 0, i64 0))
%179 = load i32, i32* @EPERM
store i32 %179, i32* @errno
%180 = load i32, i32* @errno
%181 = sub nsw i32 0, %180
store i32 %181, i32* %6
br label %182
182: ; preds = %177, %175, %29
%183 = load i32, i32* %6
ret i32 %183
}

LLVM IR (-O2):
%struct.fb_fix_screeninfo = type { i8*, i32, i32, i32, %struct.TYPE_8__, %struct.TYPE_7__, %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32 }
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_5__ = type { i32 }
%struct.fb_var_screeninfo = type { i8*, i32, i32, i32, %struct.TYPE_8__, %struct.TYPE_7__, %struct.TYPE_6__, %struct.TYPE_5__ }
@.str = [44 x i8] c"Searching for Xylon FB device (%d bpp) ...\0A\00"
@.str.1 = [10 x i8] c"/dev/fb%d\00"
@.str.2 = [19 x i8] c"Opening device %s\0A\00"
@O_RDWR = global i32 0
@.str.3 = [37 x i8] c"Error opening framebuffer device %s\0A\00"
@errno = global i32 0
@FBIOGET_FSCREENINFO = global i32 0
@.str.4 = [32 x i8] c"Error reading fixed information\00"
@FBIOGET_VSCREENINFO = global i32 0
@.str.5 = [35 x i8] c"Error reading variable information\00"
@.str.6 = [20 x i8] c"FB driver name: %s\0A\00"
@.str.7 = [23 x i8] c"FB driver color type: \00"
@.str.8 = [29 x i8] c"Monochrome Black(0)/White(1)\00"
@.str.9 = [29 x i8] c"Monochrome Black(1)/White(0)\00"
@.str.10 = [11 x i8] c"True color\00"
@.str.11 = [21 x i8] c"Pseudo color (ATARI)\00"
@.str.12 = [13 x i8] c"Direct color\00"
@.str.13 = [24 x i8] c"Pseudo color (readonly)\00"
@.str.14 = [14 x i8] c"Four CC color\00"
@.str.15 = [24 x i8] c"FB driver color format:\00"
@.str.16 = [9 x i8] c" ARGB : \00"
@.str.17 = [13 x i8] c" %c%c%c%c : \00"
@.str.18 = [10 x i8] c"%d%d%d%d\0A\00"
@.str.19 = [9 x i8] c"Xylon FB\00"
@.str.20 = [47 x i8] c"Xylon FB device with expanded %d bppfound: %s\0A\00"
@.str.21 = [39 x i8] c"Xylon FB device with %d bpp found: %s\0A\00"
@.str.22 = [15 x i8] c"NOT SUPPORTED!\00"
@EPERM = global i32 0
define i32 @find_fb_device(%struct.fb_fix_screeninfo* %0, %struct.fb_var_screeninfo* %1, i32 %2, i32 %3, i8* nocapture readnone %4) {
%6 = alloca [10 x i8]
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %2)
%9 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 0)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%11 = load i32, i32* @O_RDWR
%12 = call i32 @open(i8* %7, i32 %11)
%13 = icmp slt i32 %12, 0
br i1 %13, label %29, label %14
14: ; preds = %5
%15 = bitcast %struct.fb_fix_screeninfo* %0 to %struct.fb_var_screeninfo*
%16 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %0, i64 0, i32 0
%17 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %0, i64 0, i32 1
%18 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 2
%19 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 4, i32 0
%20 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 5, i32 0
%21 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 7, i32 0
%22 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 6, i32 0
%23 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 3
%24 = icmp eq i32 %3, 0
br label %25
25: ; preds = %14, %106
%26 = phi i32 [ %12, %14 ], [ %112, %106 ]
%27 = phi i8 [ 0, %14 ], [ %108, %106 ]
%28 = phi i32 [ 0, %14 ], [ %65, %106 ]
br label %34
29: ; preds = %106, %39, %5
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%31 = call i32 @perror(i8* null)
%32 = load i32, i32* @errno
%33 = sub nsw i32 0, %32
br label %123
34: ; preds = %25, %39
%35 = phi i32 [ %26, %25 ], [ %45, %39 ]
%36 = load i32, i32* @FBIOGET_FSCREENINFO
%37 = call i64 @ioctl(i32 %35, i32 %36, %struct.fb_var_screeninfo* %15)
%38 = icmp eq i64 %37, 0
br i1 %38, label %47, label %39
39: ; preds = %34, %47
%40 = phi i8* [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), %47 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), %34 ]
%41 = call i32 @perror(i8* %40)
%42 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext %27)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%44 = load i32, i32* @O_RDWR
%45 = call i32 @open(i8* %7, i32 %44)
%46 = icmp slt i32 %45, 0
br i1 %46, label %29, label %34
47: ; preds = %34
%48 = load i32, i32* @FBIOGET_VSCREENINFO
%49 = call i64 @ioctl(i32 %35, i32 %48, %struct.fb_var_screeninfo* %1)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %39
51: ; preds = %47
%52 = load i8*, i8** %16
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %52)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%55 = load i32, i32* %17
switch i32 %55, label %119 [
i32 132, label %114
i32 131, label %115
i32 128, label %56
i32 130, label %58
i32 133, label %116
i32 129, label %60
i32 6, label %61
]
56: ; preds = %51
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
br label %64
58: ; preds = %51
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
br label %64
60: ; preds = %51
br label %116
61: ; preds = %51
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0))
%63 = load i32, i32* %18
br label %64
64: ; preds = %61, %58, %56
%65 = phi i32 [ %63, %61 ], [ %28, %58 ], [ %28, %56 ]
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0))
%67 = icmp eq i32 %65, 0
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i64 0, i64 0))
br label %78
70: ; preds = %64
%71 = and i32 %65, 255
%72 = lshr i32 %65, 8
%73 = and i32 %72, 255
%74 = lshr i32 %65, 16
%75 = and i32 %74, 255
%76 = lshr i32 %65, 24
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i32 %71, i32 %73, i32 %75, i32 %76)
br label %78
78: ; preds = %70, %68
%79 = load i32, i32* %19
%80 = load i32, i32* %20
%81 = load i32, i32* %21
%82 = load i32, i32* %22
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), i32 %79, i32 %80, i32 %81, i32 %82)
%84 = load i8*, i8** %16
%85 = call i32 @strncmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0), i8* %84, i32 8)
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %106
87: ; preds = %78
%88 = load i32, i32* %23
%89 = icmp eq i32 %88, %2
br i1 %89, label %90, label %106
90: ; preds = %87
%91 = load i32, i32* %17
br i1 %24, label %99, label %92
92: ; preds = %90
%93 = icmp eq i32 %91, 128
br i1 %93, label %97, label %94
94: ; preds = %92
%95 = load i32, i32* %19
%96 = icmp eq i32 %95, 0
br i1 %96, label %106, label %97
97: ; preds = %94, %92
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.20, i64 0, i64 0), i32 %2, i8* %7)
br label %123
99: ; preds = %90
%100 = icmp eq i32 %91, 130
br i1 %100, label %104, label %101
101: ; preds = %99
%102 = load i32, i32* %19
%103 = icmp eq i32 %102, 0
br i1 %103, label %104, label %106
104: ; preds = %101, %99
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.21, i64 0, i64 0), i32 %2, i8* %7)
br label %123
106: ; preds = %94, %87, %101, %78
%107 = call i32 @close(i32 %35)
%108 = add i8 %27, 1
%109 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext %108)
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%111 = load i32, i32* @O_RDWR
%112 = call i32 @open(i8* %7, i32 %111)
%113 = icmp slt i32 %112, 0
br i1 %113, label %29, label %25
114: ; preds = %51
br label %116
115: ; preds = %51
br label %116
116: ; preds = %51, %115, %114, %60
%117 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), %60 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), %114 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), %115 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), %51 ]
%118 = call i32 @puts(i8* dereferenceable(1) %117)
br label %119
119: ; preds = %51, %116
%120 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.22, i64 0, i64 0))
%121 = load i32, i32* @EPERM
store i32 %121, i32* @errno
%122 = sub nsw i32 0, %121
br label %123
123: ; preds = %97, %104, %119, %29
%124 = phi i32 [ %33, %29 ], [ %122, %119 ], [ %35, %104 ], [ %35, %97 ]
ret i32 %124
}