#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 offset;
  int length;
};
struct TYPE_7__ {
  int offset;
  int length;
};
struct TYPE_6__ {
  int offset;
  int length;
};
struct TYPE_5__ {
  int offset;
  int length;
};
struct fb_var_screeninfo {
  int bits_per_pixel;
  int /*<<< orphan*/ grayscale;
  TYPE_4__ blue;
  TYPE_3__ green;
  TYPE_2__ red;
  TYPE_1__ transp;
};
struct fb_fix_screeninfo {
  int visual;
};
struct fb_cmap {
  int len;
  int *transp;
  int *red;
  int *green;
  int *blue;
};

/* Variables and functions */
int FB_VISUAL_PSEUDOCOLOR;
int FB_VISUAL_TRUECOLOR;
int /*<<< orphan*/ V4L2_PIX_FMT_VYUY;
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ rgb_to_yuv(unsigned int, unsigned int, unsigned int *, int,
                              int);
int /*<<< orphan*/ v4l2_fourcc(char, char, unsigned char, char);
int set_pixel_color_format(struct fb_fix_screeninfo *finfo,
                           struct fb_var_screeninfo *vinfo,
                           struct fb_cmap *cmap, void *pixel,
                           unsigned int color) {
  int i, bpp;
  int A_off, R_off, G_off, B_off;
  int A_len, R_len, G_len, B_len;
  unsigned int tmp;
  unsigned int *pix32;
  unsigned short *pix16;
  unsigned char *pix8;
  bpp = vinfo->bits_per_pixel;
  A_off = vinfo->transp.offset;
  A_len = vinfo->transp.length;
  R_off = vinfo->red.offset;
  R_len = vinfo->red.length;
  G_off = vinfo->green.offset;
  G_len = vinfo->green.length;
  B_off = vinfo->blue.offset;
  B_len = vinfo->blue.length;
  switch (bpp) {
  case 8:
    if ((finfo->visual == FB_VISUAL_PSEUDOCOLOR) || (finfo->visual == 6)) {
      for (i = 0; i < cmap->len; i++) {
        tmp = ((cmap->transp[i] & 0xFF) << 24);
        tmp |= ((cmap->red[i] & 0xFF) << 16);
        tmp |= ((cmap->green[i] & 0xFF) << 8);
        tmp |= (cmap->blue[i] & 0xFF);
        if (tmp == color)
          break;
        if ((tmp << 8) == (color << 8))
          break;
      }
      *(unsigned char *)pixel = i;
    } else if (finfo->visual == FB_VISUAL_TRUECOLOR) {
      pix8 = (unsigned char *)pixel;
      *pix8 = 0;
      if (A_len) {
        tmp = color >> 24;
        tmp >>= (8 - A_len);
        tmp <<= A_off;
        *pix8 |= tmp;
      }
      tmp = (color >> 16) & 0xFF;
      tmp >>= (8 - R_len);
      tmp <<= R_off;
      *pix8 |= tmp;
      tmp = (color >> 8) & 0xFF;
      tmp >>= (8 - G_len);
      tmp <<= G_off;
      *pix8 |= tmp;
      tmp = color & 0xFF;
      tmp >>= (8 - B_len);
      tmp <<= B_off;
      *pix8 |= tmp;
    } else {
      puts("8bpp format not supported!");
      goto spcf_fb_not_supported;
    }
    break;
  case 16:
    if (finfo->visual == FB_VISUAL_TRUECOLOR) {
      pix16 = (unsigned short *)pixel;
      *pix16 = 0;
      if (A_len) {
        tmp = color >> 24;
        tmp >>= (8 - A_len);
        tmp <<= A_off;
        *pix16 |= tmp;
      }
      tmp = (color >> 16) & 0xFF;
      tmp >>= (8 - R_len);
      tmp <<= R_off;
      *pix16 |= tmp;
      tmp = (color >> 8) & 0xFF;
      tmp >>= (8 - G_len);
      tmp <<= G_off;
      *pix16 |= tmp;
      tmp = color & 0xFF;
      tmp >>= (8 - B_len);
      tmp <<= B_off;
      *pix16 |= tmp;
    } else if (finfo->visual == 6) {
      rgb_to_yuv(color, color, (unsigned int *)pixel, bpp,
                 vinfo->grayscale == V4L2_PIX_FMT_VYUY ? 0 : 1);
    } else {
      puts("16bpp format not supported!");
      goto spcf_fb_not_supported;
    }
    break;
  case 32:
    if (finfo->visual == FB_VISUAL_TRUECOLOR) {
      pix32 = (unsigned int *)pixel;
      *pix32 = 0;
      if (R_len == 8) {
        *pix32 = color;
      } else {
        if (A_len) {
          tmp = color >> 24;
          tmp >>= (8 - A_len);
          tmp <<= A_off;
          *pix32 |= tmp;
        }
        tmp = (color >> 16) & 0xFF;
        tmp >>= (8 - R_len);
        tmp <<= R_off;
        *pix32 |= tmp;
        tmp = (color >> 8) & 0xFF;
        tmp >>= (8 - G_len);
        tmp <<= G_off;
        *pix32 |= tmp;
        tmp = color & 0xFF;
        tmp >>= (8 - B_len);
        tmp <<= B_off;
        *pix32 |= tmp;
      }
    } else if (finfo->visual == 6) {
      rgb_to_yuv(color, 0, (unsigned int *)pixel, bpp,
                 vinfo->grayscale == v4l2_fourcc('A', 'Y', 'U', 'V') ? 0 : 1);
    } else {
      puts("32bpp format not supported!");
      goto spcf_fb_not_supported;
    }
    break;
  }
  return 0;
spcf_fb_not_supported:
  return -1;
}


x86 assembly (clang, -O0):
<set_pixel_color_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    0x24(%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x1c(%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x74(%rbp)
sub    $0x8,%eax
je     11de <set_pixel_color_format+0xae>
jmp    11bc <set_pixel_color_format+0x8c>
mov    -0x74(%rbp),%eax
sub    $0x10,%eax
je     13f3 <set_pixel_color_format+0x2c3>
jmp    11cd <set_pixel_color_format+0x9d>
mov    -0x74(%rbp),%eax
sub    $0x20,%eax
je     1560 <set_pixel_color_format+0x430>
jmp    170c <set_pixel_color_format+0x5dc>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2ddd(%rip),%rcx
cmp    (%rcx),%eax
je     1200 <set_pixel_color_format+0xd0>
mov    -0x10(%rbp),%rax
cmpl   $0x6,(%rax)
jne    12d1 <set_pixel_color_format+0x1a1>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    12c1 <set_pixel_color_format+0x191>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xff,%eax
shl    $0x18,%eax
mov    %eax,-0x58(%rbp)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xff,%eax
shl    $0x10,%eax
or     -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xff,%eax
shl    $0x8,%eax
or     -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x20(%rbp),%rax
mov    0x20(%rax),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xff,%eax
or     -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    1295 <set_pixel_color_format+0x165>
jmp    12c1 <set_pixel_color_format+0x191>
mov    -0x58(%rbp),%eax
shl    $0x8,%eax
mov    -0x2c(%rbp),%ecx
shl    $0x8,%ecx
cmp    %ecx,%eax
jne    12ae <set_pixel_color_format+0x17e>
jmp    12c1 <set_pixel_color_format+0x191>
jmp    12b3 <set_pixel_color_format+0x183>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1207 <set_pixel_color_format+0xd7>
mov    -0x30(%rbp),%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
jmp    13ee <set_pixel_color_format+0x2be>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2d0a(%rip),%rcx
cmp    (%rcx),%eax
jne    13d8 <set_pixel_color_format+0x2a8>
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
movb   $0x0,(%rax)
cmpl   $0x0,-0x48(%rbp)
je     1331 <set_pixel_color_format+0x201>
mov    -0x2c(%rbp),%eax
shr    $0x18,%eax
mov    %eax,-0x58(%rbp)
mov    $0x8,%ecx
sub    -0x48(%rbp),%ecx
mov    -0x58(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x38(%rbp),%ecx
mov    -0x58(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%edx
mov    -0x70(%rbp),%rax
movzbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
mov    -0x2c(%rbp),%eax
shr    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x58(%rbp)
mov    $0x8,%ecx
sub    -0x4c(%rbp),%ecx
mov    -0x58(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x3c(%rbp),%ecx
mov    -0x58(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%edx
mov    -0x70(%rbp),%rax
movzbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
mov    -0x2c(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x58(%rbp)
mov    $0x8,%ecx
sub    -0x50(%rbp),%ecx
mov    -0x58(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x40(%rbp),%ecx
mov    -0x58(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%edx
mov    -0x70(%rbp),%rax
movzbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
mov    -0x2c(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x58(%rbp)
mov    $0x8,%ecx
sub    -0x54(%rbp),%ecx
mov    -0x58(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x44(%rbp),%ecx
mov    -0x58(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%edx
mov    -0x70(%rbp),%rax
movzbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
jmp    13e9 <set_pixel_color_format+0x2b9>
lea    0xc21(%rip),%rdi
call   1040 <puts@plt>
jmp    1718 <set_pixel_color_format+0x5e8>
jmp    13ee <set_pixel_color_format+0x2be>
jmp    170c <set_pixel_color_format+0x5dc>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2be8(%rip),%rcx
cmp    (%rcx),%eax
jne    1500 <set_pixel_color_format+0x3d0>
mov    -0x28(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movw   $0x0,(%rax)
cmpl   $0x0,-0x48(%rbp)
je     1456 <set_pixel_color_format+0x326>
mov    -0x2c(%rbp),%eax
shr    $0x18,%eax
mov    %eax,-0x58(%rbp)
mov    $0x8,%ecx
sub    -0x48(%rbp),%ecx
mov    -0x58(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x38(%rbp),%ecx
mov    -0x58(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%edx
mov    -0x68(%rbp),%rax
movzwl (%rax),%ecx
or     %edx,%ecx
mov    %cx,(%rax)
mov    -0x2c(%rbp),%eax
shr    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x58(%rbp)
mov    $0x8,%ecx
sub    -0x4c(%rbp),%ecx
mov    -0x58(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x3c(%rbp),%ecx
mov    -0x58(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%edx
mov    -0x68(%rbp),%rax
movzwl (%rax),%ecx
or     %edx,%ecx
mov    %cx,(%rax)
mov    -0x2c(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x58(%rbp)
mov    $0x8,%ecx
sub    -0x50(%rbp),%ecx
mov    -0x58(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x40(%rbp),%ecx
mov    -0x58(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%edx
mov    -0x68(%rbp),%rax
movzwl (%rax),%ecx
or     %edx,%ecx
mov    %cx,(%rax)
mov    -0x2c(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x58(%rbp)
mov    $0x8,%ecx
sub    -0x54(%rbp),%ecx
mov    -0x58(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x44(%rbp),%ecx
mov    -0x58(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%edx
mov    -0x68(%rbp),%rax
movzwl (%rax),%ecx
or     %edx,%ecx
mov    %cx,(%rax)
jmp    155b <set_pixel_color_format+0x42b>
mov    -0x10(%rbp),%rax
cmpl   $0x6,(%rax)
jne    1545 <set_pixel_color_format+0x415>
mov    -0x2c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%r9d
mov    0x2ab7(%rip),%rax
mov    (%rax),%r10d
mov    $0x1,%r8d
xor    %eax,%eax
cmp    %r10d,%r9d
cmove  %eax,%r8d
call   1050 <rgb_to_yuv@plt>
jmp    1556 <set_pixel_color_format+0x426>
lea    0xacf(%rip),%rdi
call   1040 <puts@plt>
jmp    1718 <set_pixel_color_format+0x5e8>
jmp    155b <set_pixel_color_format+0x42b>
jmp    170c <set_pixel_color_format+0x5dc>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2a7b(%rip),%rcx
cmp    (%rcx),%eax
jne    1676 <set_pixel_color_format+0x546>
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movl   $0x0,(%rax)
cmpl   $0x8,-0x4c(%rbp)
jne    159f <set_pixel_color_format+0x46f>
mov    -0x2c(%rbp),%ecx
mov    -0x60(%rbp),%rax
mov    %ecx,(%rax)
jmp    1671 <set_pixel_color_format+0x541>
cmpl   $0x0,-0x48(%rbp)
je     15d8 <set_pixel_color_format+0x4a8>
mov    -0x2c(%rbp),%eax
shr    $0x18,%eax
mov    %eax,-0x58(%rbp)
mov    $0x8,%ecx
sub    -0x48(%rbp),%ecx
mov    -0x58(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x38(%rbp),%ecx
mov    -0x58(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x60(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
shr    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x58(%rbp)
mov    $0x8,%ecx
sub    -0x4c(%rbp),%ecx
mov    -0x58(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x3c(%rbp),%ecx
mov    -0x58(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x60(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x58(%rbp)
mov    $0x8,%ecx
sub    -0x50(%rbp),%ecx
mov    -0x58(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x40(%rbp),%ecx
mov    -0x58(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x60(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x58(%rbp)
mov    $0x8,%ecx
sub    -0x54(%rbp),%ecx
mov    -0x58(%rbp),%eax
shr    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x44(%rbp),%ecx
mov    -0x58(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%ecx
mov    -0x60(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
jmp    1707 <set_pixel_color_format+0x5d7>
mov    -0x10(%rbp),%rax
cmpl   $0x6,(%rax)
jne    16f1 <set_pixel_color_format+0x5c1>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x88(%rbp)
mov    $0x41,%edi
mov    $0x59,%esi
mov    $0x55,%edx
mov    $0x56,%ecx
call   1030 <v4l2_fourcc@plt>
mov    -0x88(%rbp),%esi
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rdx
mov    -0x78(%rbp),%ecx
mov    %eax,%r9d
mov    $0x1,%r8d
xor    %eax,%eax
cmp    %r9d,%esi
cmove  %eax,%r8d
xor    %esi,%esi
call   1050 <rgb_to_yuv@plt>
jmp    1702 <set_pixel_color_format+0x5d2>
lea    0x93f(%rip),%rdi
call   1040 <puts@plt>
jmp    1718 <set_pixel_color_format+0x5e8>
jmp    1707 <set_pixel_color_format+0x5d7>
jmp    170c <set_pixel_color_format+0x5dc>
movl   $0x0,-0x4(%rbp)
jmp    171f <set_pixel_color_format+0x5ef>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_pixel_color_format>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    0x20(%rsi),%ebp
mov    0x24(%rsi),%eax
mov    0x18(%rsi),%r12d
mov    0x1c(%rsi),%r13d
mov    0x10(%rsi),%r9d
mov    0x14(%rsi),%r11d
mov    (%rsi),%ebx
mov    0x8(%rsi),%r8d
mov    0xc(%rsi),%r10d
xor    %r15d,%r15d
cmp    $0x20,%ebx
je     1208 <set_pixel_color_format+0xd8>
cmp    $0x10,%ebx
je     122b <set_pixel_color_format+0xfb>
cmp    $0x8,%ebx
jne    141f <set_pixel_color_format+0x2ef>
mov    (%rdi),%edi
cmp    $0x6,%edi
je     129f <set_pixel_color_format+0x16f>
mov    0x2e3a(%rip),%rsi
cmp    (%rsi),%edi
je     129f <set_pixel_color_format+0x16f>
mov    0x2e4b(%rip),%rdx
cmp    (%rdx),%edi
jne    139c <set_pixel_color_format+0x26c>
mov    %rcx,(%rsp)
mov    %r14d,%ebx
mov    %r14d,%edx
shr    $0x18,%edx
mov    $0x8,%cl
sub    %al,%cl
shr    %cl,%edx
mov    %ebp,%ecx
shl    %cl,%edx
test   %eax,%eax
cmove  %eax,%edx
mov    %r14d,%eax
shr    $0x10,%eax
movzbl %al,%esi
mov    $0x8,%cl
sub    %r13b,%cl
shr    %cl,%esi
mov    %r12d,%ecx
shl    %cl,%esi
mov    $0x8,%al
movzbl %bh,%edi
mov    $0x8,%cl
sub    %r11b,%cl
shr    %cl,%edi
mov    %r9d,%ecx
shl    %cl,%edi
movzbl %bl,%ebp
sub    %r10b,%al
mov    %eax,%ecx
shr    %cl,%ebp
mov    %r8d,%ecx
shl    %cl,%ebp
or     %esi,%edi
or     %edi,%ebp
or     %edx,%ebp
mov    (%rsp),%rax
mov    %bpl,(%rax)
jmp    141f <set_pixel_color_format+0x2ef>
mov    (%rdi),%edi
mov    0x2dd7(%rip),%rdx
cmp    (%rdx),%edi
jne    131d <set_pixel_color_format+0x1ed>
cmp    $0x8,%r13d
jne    13a5 <set_pixel_color_format+0x275>
mov    %r14d,(%rcx)
jmp    141f <set_pixel_color_format+0x2ef>
mov    (%rdi),%edi
mov    0x2db4(%rip),%rdx
cmp    (%rdx),%edi
jne    1368 <set_pixel_color_format+0x238>
mov    %rcx,(%rsp)
mov    %r14d,%ebx
mov    %r14d,%edx
shr    $0x18,%edx
mov    $0x8,%cl
sub    %al,%cl
shr    %cl,%edx
mov    %ebp,%ecx
shl    %cl,%edx
test   %eax,%eax
cmove  %eax,%edx
mov    %r14d,%eax
shr    $0x10,%eax
movzbl %al,%esi
mov    $0x8,%cl
sub    %r13b,%cl
shr    %cl,%esi
mov    %r12d,%ecx
shl    %cl,%esi
mov    $0x8,%al
movzbl %bh,%edi
mov    $0x8,%cl
sub    %r11b,%cl
shr    %cl,%edi
mov    %r9d,%ecx
shl    %cl,%edi
movzbl %bl,%ebp
sub    %r10b,%al
mov    %eax,%ecx
shr    %cl,%ebp
mov    %r8d,%ecx
shl    %cl,%ebp
or     %esi,%edi
or     %edi,%ebp
or     %edx,%ebp
mov    (%rsp),%rax
mov    %bp,(%rax)
jmp    141f <set_pixel_color_format+0x2ef>
mov    (%rdx),%r9d
xor    %r15d,%r15d
mov    $0x0,%edi
test   %r9d,%r9d
jle    1315 <set_pixel_color_format+0x1e5>
mov    0x8(%rdx),%r8
mov    0x10(%rdx),%r10
mov    0x18(%rdx),%rbp
mov    0x20(%rdx),%rdx
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r8,%rdi,4),%ebx
shl    $0x18,%ebx
mov    (%r10,%rdi,4),%esi
movzbl %sil,%esi
shl    $0x10,%esi
or     %ebx,%esi
mov    0x0(%rbp,%rdi,4),%ebx
shl    $0x8,%ebx
movzwl %bx,%eax
or     %esi,%eax
movzbl (%rdx,%rdi,4),%ebx
or     %eax,%ebx
cmp    %r14d,%ebx
je     1315 <set_pixel_color_format+0x1e5>
mov    %r14d,%eax
xor    %r14d,%ebx
test   $0xffffff,%ebx
je     1315 <set_pixel_color_format+0x1e5>
add    $0x1,%rdi
cmp    %rdi,%r9
jne    12d0 <set_pixel_color_format+0x1a0>
mov    %r9d,%edi
mov    %dil,(%rcx)
jmp    141f <set_pixel_color_format+0x2ef>
cmp    $0x6,%edi
jne    1404 <set_pixel_color_format+0x2d4>
mov    %rcx,%rbp
mov    0x4(%rsi),%ebx
mov    $0x41,%edi
mov    $0x59,%esi
mov    $0x55,%edx
mov    $0x56,%ecx
call   1030 <v4l2_fourcc@plt>
xor    %r8d,%r8d
cmp    %eax,%ebx
setne  %r8b
xor    %r15d,%r15d
mov    %r14d,%edi
xor    %esi,%esi
mov    %rbp,%rdx
mov    $0x20,%ecx
call   1050 <rgb_to_yuv@plt>
jmp    141f <set_pixel_color_format+0x2ef>
cmp    $0x6,%edi
jne    140d <set_pixel_color_format+0x2dd>
mov    0x4(%rsi),%eax
mov    0x2c65(%rip),%rdx
xor    %r8d,%r8d
cmp    (%rdx),%eax
setne  %r8b
mov    %r14d,%edi
mov    %r14d,%esi
mov    %rcx,%rdx
mov    $0x10,%ecx
call   1050 <rgb_to_yuv@plt>
jmp    141f <set_pixel_color_format+0x2ef>
lea    0xc5d(%rip),%rdi
jmp    1414 <set_pixel_color_format+0x2e4>
mov    %rcx,(%rsp)
mov    %r14d,%ebx
mov    %r14d,%edx
shr    $0x18,%edx
mov    $0x8,%cl
sub    %al,%cl
shr    %cl,%edx
mov    %ebp,%ecx
shl    %cl,%edx
test   %eax,%eax
cmove  %eax,%edx
mov    %r14d,%eax
shr    $0x10,%eax
movzbl %al,%esi
mov    $0x8,%cl
sub    %r13b,%cl
shr    %cl,%esi
mov    %r12d,%ecx
shl    %cl,%esi
mov    $0x8,%al
movzbl %bh,%edi
mov    $0x8,%cl
sub    %r11b,%cl
shr    %cl,%edi
mov    %r9d,%ecx
shl    %cl,%edi
movzbl %bl,%ebp
sub    %r10b,%al
mov    %eax,%ecx
shr    %cl,%ebp
mov    %r8d,%ecx
shl    %cl,%ebp
or     %esi,%edi
or     %edi,%ebp
or     %edx,%ebp
mov    (%rsp),%rax
mov    %ebp,(%rax)
jmp    141f <set_pixel_color_format+0x2ef>
lea    0xc2c(%rip),%rdi
jmp    1414 <set_pixel_color_format+0x2e4>
lea    0xc07(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.fb_fix_screeninfo = type { i32 }
%struct.fb_var_screeninfo = type { i32, i32, %struct.TYPE_8__, %struct.TYPE_7__, %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_8__ = type { i32, i32 }
%struct.TYPE_7__ = type { i32, i32 }
%struct.TYPE_6__ = type { i32, i32 }
%struct.TYPE_5__ = type { i32, i32 }
%struct.fb_cmap = type { i32, i32*, i32*, i32*, i32* }
@FB_VISUAL_PSEUDOCOLOR = global i32 0
@FB_VISUAL_TRUECOLOR = global i32 0
@.str = [27 x i8] c"8bpp format not supported!\00"
@V4L2_PIX_FMT_VYUY = global i32 0
@.str.1 = [28 x i8] c"16bpp format not supported!\00"
@.str.2 = [28 x i8] c"32bpp format not supported!\00"
define i32 @set_pixel_color_format(%struct.fb_fix_screeninfo* %0, %struct.fb_var_screeninfo* %1, %struct.fb_cmap* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca %struct.fb_fix_screeninfo*
%8 = alloca %struct.fb_var_screeninfo*
%9 = alloca %struct.fb_cmap*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32*
%24 = alloca i16*
%25 = 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 %struct.fb_cmap* %2, %struct.fb_cmap** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%26 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%27 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %26, i32 0, i32 0
%28 = load i32, i32* %27
store i32 %28, i32* %13
%29 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%30 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %29, i32 0, i32 5
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %30, i32 0, i32 0
%32 = load i32, i32* %31
store i32 %32, i32* %14
%33 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%34 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %33, i32 0, i32 5
%35 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %34, i32 0, i32 1
%36 = load i32, i32* %35
store i32 %36, i32* %18
%37 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%38 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %37, i32 0, i32 4
%39 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %38, i32 0, i32 0
%40 = load i32, i32* %39
store i32 %40, i32* %15
%41 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%42 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %41, i32 0, i32 4
%43 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %42, i32 0, i32 1
%44 = load i32, i32* %43
store i32 %44, i32* %19
%45 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%46 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %45, i32 0, i32 3
%47 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %46, i32 0, i32 0
%48 = load i32, i32* %47
store i32 %48, i32* %16
%49 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%50 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %49, i32 0, i32 3
%51 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %50, i32 0, i32 1
%52 = load i32, i32* %51
store i32 %52, i32* %20
%53 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%54 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %53, i32 0, i32 2
%55 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %54, i32 0, i32 0
%56 = load i32, i32* %55
store i32 %56, i32* %17
%57 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%58 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %57, i32 0, i32 2
%59 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %58, i32 0, i32 1
%60 = load i32, i32* %59
store i32 %60, i32* %21
%61 = load i32, i32* %13
switch i32 %61, label %416 [
i32 8, label %62
i32 16, label %220
i32 32, label %319
]
62: ; preds = %5
%63 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%64 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %63, i32 0, i32 0
%65 = load i32, i32* %64
%66 = load i32, i32* @FB_VISUAL_PSEUDOCOLOR
%67 = icmp eq i32 %65, %66
br i1 %67, label %73, label %68
68: ; preds = %62
%69 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%70 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %69, i32 0, i32 0
%71 = load i32, i32* %70
%72 = icmp eq i32 %71, 6
br i1 %72, label %73, label %141
73: ; preds = %68, %62
store i32 0, i32* %12
br label %74
74: ; preds = %134, %73
%75 = load i32, i32* %12
%76 = load %struct.fb_cmap*, %struct.fb_cmap** %9
%77 = getelementptr inbounds %struct.fb_cmap, %struct.fb_cmap* %76, i32 0, i32 0
%78 = load i32, i32* %77
%79 = icmp slt i32 %75, %78
br i1 %79, label %80, label %137
80: ; preds = %74
%81 = load %struct.fb_cmap*, %struct.fb_cmap** %9
%82 = getelementptr inbounds %struct.fb_cmap, %struct.fb_cmap* %81, i32 0, i32 1
%83 = load i32*, i32** %82
%84 = load i32, i32* %12
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i32, i32* %83, i64 %85
%87 = load i32, i32* %86
%88 = and i32 %87, 255
%89 = shl i32 %88, 24
store i32 %89, i32* %22
%90 = load %struct.fb_cmap*, %struct.fb_cmap** %9
%91 = getelementptr inbounds %struct.fb_cmap, %struct.fb_cmap* %90, i32 0, i32 2
%92 = load i32*, i32** %91
%93 = load i32, i32* %12
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i32, i32* %92, i64 %94
%96 = load i32, i32* %95
%97 = and i32 %96, 255
%98 = shl i32 %97, 16
%99 = load i32, i32* %22
%100 = or i32 %99, %98
store i32 %100, i32* %22
%101 = load %struct.fb_cmap*, %struct.fb_cmap** %9
%102 = getelementptr inbounds %struct.fb_cmap, %struct.fb_cmap* %101, i32 0, i32 3
%103 = load i32*, i32** %102
%104 = load i32, i32* %12
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i32, i32* %103, i64 %105
%107 = load i32, i32* %106
%108 = and i32 %107, 255
%109 = shl i32 %108, 8
%110 = load i32, i32* %22
%111 = or i32 %110, %109
store i32 %111, i32* %22
%112 = load %struct.fb_cmap*, %struct.fb_cmap** %9
%113 = getelementptr inbounds %struct.fb_cmap, %struct.fb_cmap* %112, i32 0, i32 4
%114 = load i32*, i32** %113
%115 = load i32, i32* %12
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i32, i32* %114, i64 %116
%118 = load i32, i32* %117
%119 = and i32 %118, 255
%120 = load i32, i32* %22
%121 = or i32 %120, %119
store i32 %121, i32* %22
%122 = load i32, i32* %22
%123 = load i32, i32* %11
%124 = icmp eq i32 %122, %123
br i1 %124, label %125, label %126
125: ; preds = %80
br label %137
126: ; preds = %80
%127 = load i32, i32* %22
%128 = shl i32 %127, 8
%129 = load i32, i32* %11
%130 = shl i32 %129, 8
%131 = icmp eq i32 %128, %130
br i1 %131, label %132, label %133
132: ; preds = %126
br label %137
133: ; preds = %126
br label %134
134: ; preds = %133
%135 = load i32, i32* %12
%136 = add nsw i32 %135, 1
store i32 %136, i32* %12
br label %74
137: ; preds = %132, %125, %74
%138 = load i32, i32* %12
%139 = trunc i32 %138 to i8
%140 = load i8*, i8** %10
store i8 %139, i8* %140
br label %219
141: ; preds = %68
%142 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%143 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %142, i32 0, i32 0
%144 = load i32, i32* %143
%145 = load i32, i32* @FB_VISUAL_TRUECOLOR
%146 = icmp eq i32 %144, %145
br i1 %146, label %147, label %216
147: ; preds = %141
%148 = load i8*, i8** %10
store i8* %148, i8** %25
%149 = load i8*, i8** %25
store i8 0, i8* %149
%150 = load i32, i32* %18
%151 = icmp ne i32 %150, 0
br i1 %151, label %152, label %168
152: ; preds = %147
%153 = load i32, i32* %11
%154 = lshr i32 %153, 24
store i32 %154, i32* %22
%155 = load i32, i32* %18
%156 = sub nsw i32 8, %155
%157 = load i32, i32* %22
%158 = lshr i32 %157, %156
store i32 %158, i32* %22
%159 = load i32, i32* %14
%160 = load i32, i32* %22
%161 = shl i32 %160, %159
store i32 %161, i32* %22
%162 = load i32, i32* %22
%163 = load i8*, i8** %25
%164 = load i8, i8* %163
%165 = zext i8 %164 to i32
%166 = or i32 %165, %162
%167 = trunc i32 %166 to i8
store i8 %167, i8* %163
br label %168
168: ; preds = %152, %147
%169 = load i32, i32* %11
%170 = lshr i32 %169, 16
%171 = and i32 %170, 255
store i32 %171, i32* %22
%172 = load i32, i32* %19
%173 = sub nsw i32 8, %172
%174 = load i32, i32* %22
%175 = lshr i32 %174, %173
store i32 %175, i32* %22
%176 = load i32, i32* %15
%177 = load i32, i32* %22
%178 = shl i32 %177, %176
store i32 %178, i32* %22
%179 = load i32, i32* %22
%180 = load i8*, i8** %25
%181 = load i8, i8* %180
%182 = zext i8 %181 to i32
%183 = or i32 %182, %179
%184 = trunc i32 %183 to i8
store i8 %184, i8* %180
%185 = load i32, i32* %11
%186 = lshr i32 %185, 8
%187 = and i32 %186, 255
store i32 %187, i32* %22
%188 = load i32, i32* %20
%189 = sub nsw i32 8, %188
%190 = load i32, i32* %22
%191 = lshr i32 %190, %189
store i32 %191, i32* %22
%192 = load i32, i32* %16
%193 = load i32, i32* %22
%194 = shl i32 %193, %192
store i32 %194, i32* %22
%195 = load i32, i32* %22
%196 = load i8*, i8** %25
%197 = load i8, i8* %196
%198 = zext i8 %197 to i32
%199 = or i32 %198, %195
%200 = trunc i32 %199 to i8
store i8 %200, i8* %196
%201 = load i32, i32* %11
%202 = and i32 %201, 255
store i32 %202, i32* %22
%203 = load i32, i32* %21
%204 = sub nsw i32 8, %203
%205 = load i32, i32* %22
%206 = lshr i32 %205, %204
store i32 %206, i32* %22
%207 = load i32, i32* %17
%208 = load i32, i32* %22
%209 = shl i32 %208, %207
store i32 %209, i32* %22
%210 = load i32, i32* %22
%211 = load i8*, i8** %25
%212 = load i8, i8* %211
%213 = zext i8 %212 to i32
%214 = or i32 %213, %210
%215 = trunc i32 %214 to i8
store i8 %215, i8* %211
br label %218
216: ; preds = %141
%217 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %417
218: ; preds = %168
br label %219
219: ; preds = %218, %137
br label %416
220: ; preds = %5
%221 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%222 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %221, i32 0, i32 0
%223 = load i32, i32* %222
%224 = load i32, i32* @FB_VISUAL_TRUECOLOR
%225 = icmp eq i32 %223, %224
br i1 %225, label %226, label %296
226: ; preds = %220
%227 = load i8*, i8** %10
%228 = bitcast i8* %227 to i16*
store i16* %228, i16** %24
%229 = load i16*, i16** %24
store i16 0, i16* %229
%230 = load i32, i32* %18
%231 = icmp ne i32 %230, 0
br i1 %231, label %232, label %248
232: ; preds = %226
%233 = load i32, i32* %11
%234 = lshr i32 %233, 24
store i32 %234, i32* %22
%235 = load i32, i32* %18
%236 = sub nsw i32 8, %235
%237 = load i32, i32* %22
%238 = lshr i32 %237, %236
store i32 %238, i32* %22
%239 = load i32, i32* %14
%240 = load i32, i32* %22
%241 = shl i32 %240, %239
store i32 %241, i32* %22
%242 = load i32, i32* %22
%243 = load i16*, i16** %24
%244 = load i16, i16* %243
%245 = zext i16 %244 to i32
%246 = or i32 %245, %242
%247 = trunc i32 %246 to i16
store i16 %247, i16* %243
br label %248
248: ; preds = %232, %226
%249 = load i32, i32* %11
%250 = lshr i32 %249, 16
%251 = and i32 %250, 255
store i32 %251, i32* %22
%252 = load i32, i32* %19
%253 = sub nsw i32 8, %252
%254 = load i32, i32* %22
%255 = lshr i32 %254, %253
store i32 %255, i32* %22
%256 = load i32, i32* %15
%257 = load i32, i32* %22
%258 = shl i32 %257, %256
store i32 %258, i32* %22
%259 = load i32, i32* %22
%260 = load i16*, i16** %24
%261 = load i16, i16* %260
%262 = zext i16 %261 to i32
%263 = or i32 %262, %259
%264 = trunc i32 %263 to i16
store i16 %264, i16* %260
%265 = load i32, i32* %11
%266 = lshr i32 %265, 8
%267 = and i32 %266, 255
store i32 %267, i32* %22
%268 = load i32, i32* %20
%269 = sub nsw i32 8, %268
%270 = load i32, i32* %22
%271 = lshr i32 %270, %269
store i32 %271, i32* %22
%272 = load i32, i32* %16
%273 = load i32, i32* %22
%274 = shl i32 %273, %272
store i32 %274, i32* %22
%275 = load i32, i32* %22
%276 = load i16*, i16** %24
%277 = load i16, i16* %276
%278 = zext i16 %277 to i32
%279 = or i32 %278, %275
%280 = trunc i32 %279 to i16
store i16 %280, i16* %276
%281 = load i32, i32* %11
%282 = and i32 %281, 255
store i32 %282, i32* %22
%283 = load i32, i32* %21
%284 = sub nsw i32 8, %283
%285 = load i32, i32* %22
%286 = lshr i32 %285, %284
store i32 %286, i32* %22
%287 = load i32, i32* %17
%288 = load i32, i32* %22
%289 = shl i32 %288, %287
store i32 %289, i32* %22
%290 = load i32, i32* %22
%291 = load i16*, i16** %24
%292 = load i16, i16* %291
%293 = zext i16 %292 to i32
%294 = or i32 %293, %290
%295 = trunc i32 %294 to i16
store i16 %295, i16* %291
br label %318
296: ; preds = %220
%297 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%298 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %297, i32 0, i32 0
%299 = load i32, i32* %298
%300 = icmp eq i32 %299, 6
br i1 %300, label %301, label %315
301: ; preds = %296
%302 = load i32, i32* %11
%303 = load i32, i32* %11
%304 = load i8*, i8** %10
%305 = bitcast i8* %304 to i32*
%306 = load i32, i32* %13
%307 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%308 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %307, i32 0, i32 1
%309 = load i32, i32* %308
%310 = load i32, i32* @V4L2_PIX_FMT_VYUY
%311 = icmp eq i32 %309, %310
%312 = zext i1 %311 to i64
%313 = select i1 %311, i32 0, i32 1
%314 = call i32 @rgb_to_yuv(i32 %302, i32 %303, i32* %305, i32 %306, i32 %313)
br label %317
315: ; preds = %296
%316 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %417
317: ; preds = %301
br label %318
318: ; preds = %317, %248
br label %416
319: ; preds = %5
%320 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%321 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %320, i32 0, i32 0
%322 = load i32, i32* %321
%323 = load i32, i32* @FB_VISUAL_TRUECOLOR
%324 = icmp eq i32 %322, %323
br i1 %324, label %325, label %394
325: ; preds = %319
%326 = load i8*, i8** %10
%327 = bitcast i8* %326 to i32*
store i32* %327, i32** %23
%328 = load i32*, i32** %23
store i32 0, i32* %328
%329 = load i32, i32* %19
%330 = icmp eq i32 %329, 8
br i1 %330, label %331, label %334
331: ; preds = %325
%332 = load i32, i32* %11
%333 = load i32*, i32** %23
store i32 %332, i32* %333
br label %393
334: ; preds = %325
%335 = load i32, i32* %18
%336 = icmp ne i32 %335, 0
br i1 %336, label %337, label %351
337: ; preds = %334
%338 = load i32, i32* %11
%339 = lshr i32 %338, 24
store i32 %339, i32* %22
%340 = load i32, i32* %18
%341 = sub nsw i32 8, %340
%342 = load i32, i32* %22
%343 = lshr i32 %342, %341
store i32 %343, i32* %22
%344 = load i32, i32* %14
%345 = load i32, i32* %22
%346 = shl i32 %345, %344
store i32 %346, i32* %22
%347 = load i32, i32* %22
%348 = load i32*, i32** %23
%349 = load i32, i32* %348
%350 = or i32 %349, %347
store i32 %350, i32* %348
br label %351
351: ; preds = %337, %334
%352 = load i32, i32* %11
%353 = lshr i32 %352, 16
%354 = and i32 %353, 255
store i32 %354, i32* %22
%355 = load i32, i32* %19
%356 = sub nsw i32 8, %355
%357 = load i32, i32* %22
%358 = lshr i32 %357, %356
store i32 %358, i32* %22
%359 = load i32, i32* %15
%360 = load i32, i32* %22
%361 = shl i32 %360, %359
store i32 %361, i32* %22
%362 = load i32, i32* %22
%363 = load i32*, i32** %23
%364 = load i32, i32* %363
%365 = or i32 %364, %362
store i32 %365, i32* %363
%366 = load i32, i32* %11
%367 = lshr i32 %366, 8
%368 = and i32 %367, 255
store i32 %368, i32* %22
%369 = load i32, i32* %20
%370 = sub nsw i32 8, %369
%371 = load i32, i32* %22
%372 = lshr i32 %371, %370
store i32 %372, i32* %22
%373 = load i32, i32* %16
%374 = load i32, i32* %22
%375 = shl i32 %374, %373
store i32 %375, i32* %22
%376 = load i32, i32* %22
%377 = load i32*, i32** %23
%378 = load i32, i32* %377
%379 = or i32 %378, %376
store i32 %379, i32* %377
%380 = load i32, i32* %11
%381 = and i32 %380, 255
store i32 %381, i32* %22
%382 = load i32, i32* %21
%383 = sub nsw i32 8, %382
%384 = load i32, i32* %22
%385 = lshr i32 %384, %383
store i32 %385, i32* %22
%386 = load i32, i32* %17
%387 = load i32, i32* %22
%388 = shl i32 %387, %386
store i32 %388, i32* %22
%389 = load i32, i32* %22
%390 = load i32*, i32** %23
%391 = load i32, i32* %390
%392 = or i32 %391, %389
store i32 %392, i32* %390
br label %393
393: ; preds = %351, %331
br label %415
394: ; preds = %319
%395 = load %struct.fb_fix_screeninfo*, %struct.fb_fix_screeninfo** %7
%396 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %395, i32 0, i32 0
%397 = load i32, i32* %396
%398 = icmp eq i32 %397, 6
br i1 %398, label %399, label %412
399: ; preds = %394
%400 = load i32, i32* %11
%401 = load i8*, i8** %10
%402 = bitcast i8* %401 to i32*
%403 = load i32, i32* %13
%404 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %8
%405 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %404, i32 0, i32 1
%406 = load i32, i32* %405
%407 = call i32 @v4l2_fourcc(i8 signext 65, i8 signext 89, i8 zeroext 85, i8 signext 86)
%408 = icmp eq i32 %406, %407
%409 = zext i1 %408 to i64
%410 = select i1 %408, i32 0, i32 1
%411 = call i32 @rgb_to_yuv(i32 %400, i32 0, i32* %402, i32 %403, i32 %410)
br label %414
412: ; preds = %394
%413 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %417
414: ; preds = %399
br label %415
415: ; preds = %414, %393
br label %416
416: ; preds = %5, %415, %318, %219
store i32 0, i32* %6
br label %418
417: ; preds = %412, %315, %216
store i32 -1, i32* %6
br label %418
418: ; preds = %417, %416
%419 = load i32, i32* %6
ret i32 %419
}

LLVM IR (-O2):
%struct.fb_fix_screeninfo = type { i32 }
%struct.fb_var_screeninfo = type { i32, i32, %struct.TYPE_8__, %struct.TYPE_7__, %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_8__ = type { i32, i32 }
%struct.TYPE_7__ = type { i32, i32 }
%struct.TYPE_6__ = type { i32, i32 }
%struct.TYPE_5__ = type { i32, i32 }
%struct.fb_cmap = type { i32, i32*, i32*, i32*, i32* }
@FB_VISUAL_PSEUDOCOLOR = global i32 0
@FB_VISUAL_TRUECOLOR = global i32 0
@.str = [27 x i8] c"8bpp format not supported!\00"
@V4L2_PIX_FMT_VYUY = global i32 0
@.str.1 = [28 x i8] c"16bpp format not supported!\00"
@.str.2 = [28 x i8] c"32bpp format not supported!\00"
define i32 @set_pixel_color_format(%struct.fb_fix_screeninfo* nocapture %0, %struct.fb_var_screeninfo* nocapture %1, %struct.fb_cmap* nocapture %2, i8* %3, i32 %4) {
%6 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 5, i32 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 5, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 4, i32 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 4, i32 1
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 3, i32 0
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 3, i32 1
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 2, i32 0
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 2, i32 1
%23 = load i32, i32* %22
switch i32 %7, label %203 [
i32 8, label %24
i32 16, label %112
i32 32, label %158
]
24: ; preds = %5
%25 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %0, i64 0, i32 0
%26 = load i32, i32* %25
%27 = load i32, i32* @FB_VISUAL_PSEUDOCOLOR
%28 = icmp eq i32 %26, %27
%29 = icmp eq i32 %26, 6
%30 = or i1 %29, %28
br i1 %30, label %31, label %79
31: ; preds = %24
%32 = getelementptr inbounds %struct.fb_cmap, %struct.fb_cmap* %2, i64 0, i32 0
%33 = load i32, i32* %32
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %76
35: ; preds = %31
%36 = getelementptr inbounds %struct.fb_cmap, %struct.fb_cmap* %2, i64 0, i32 1
%37 = load i32*, i32** %36
%38 = getelementptr inbounds %struct.fb_cmap, %struct.fb_cmap* %2, i64 0, i32 2
%39 = load i32*, i32** %38
%40 = getelementptr inbounds %struct.fb_cmap, %struct.fb_cmap* %2, i64 0, i32 3
%41 = load i32*, i32** %40
%42 = getelementptr inbounds %struct.fb_cmap, %struct.fb_cmap* %2, i64 0, i32 4
%43 = load i32*, i32** %42
%44 = zext i32 %33 to i64
br label %45
45: ; preds = %35, %69
%46 = phi i64 [ 0, %35 ], [ %70, %69 ]
%47 = getelementptr inbounds i32, i32* %37, i64 %46
%48 = load i32, i32* %47
%49 = shl i32 %48, 24
%50 = getelementptr inbounds i32, i32* %39, i64 %46
%51 = load i32, i32* %50
%52 = shl i32 %51, 16
%53 = and i32 %52, 16711680
%54 = or i32 %53, %49
%55 = getelementptr inbounds i32, i32* %41, i64 %46
%56 = load i32, i32* %55
%57 = shl i32 %56, 8
%58 = and i32 %57, 65280
%59 = or i32 %58, %54
%60 = getelementptr inbounds i32, i32* %43, i64 %46
%61 = load i32, i32* %60
%62 = and i32 %61, 255
%63 = or i32 %59, %62
%64 = icmp eq i32 %63, %4
br i1 %64, label %74, label %65
65: ; preds = %45
%66 = xor i32 %63, %4
%67 = and i32 %66, 16777215
%68 = icmp eq i32 %67, 0
br i1 %68, label %72, label %69
69: ; preds = %65
%70 = add nuw nsw i64 %46, 1
%71 = icmp eq i64 %70, %44
br i1 %71, label %76, label %45
72: ; preds = %65
%73 = trunc i64 %46 to i32
br label %76
74: ; preds = %45
%75 = trunc i64 %46 to i32
br label %76
76: ; preds = %69, %72, %74, %31
%77 = phi i32 [ 0, %31 ], [ %73, %72 ], [ %75, %74 ], [ %33, %69 ]
%78 = trunc i32 %77 to i8
store i8 %78, i8* %3
br label %203
79: ; preds = %24
%80 = load i32, i32* @FB_VISUAL_TRUECOLOR
%81 = icmp eq i32 %26, %80
br i1 %81, label %82, label %110
82: ; preds = %79
%83 = icmp eq i32 %11, 0
%84 = lshr i32 %4, 24
%85 = sub nsw i32 8, %11
%86 = lshr i32 %84, %85
%87 = shl i32 %86, %9
%88 = trunc i32 %87 to i8
%89 = select i1 %83, i8 0, i8 %88
%90 = lshr i32 %4, 16
%91 = and i32 %90, 255
%92 = sub nsw i32 8, %15
%93 = lshr i32 %91, %92
%94 = shl i32 %93, %13
%95 = trunc i32 %94 to i8
%96 = or i8 %89, %95
%97 = lshr i32 %4, 8
%98 = and i32 %97, 255
%99 = sub nsw i32 8, %19
%100 = lshr i32 %98, %99
%101 = shl i32 %100, %17
%102 = trunc i32 %101 to i8
%103 = or i8 %96, %102
%104 = and i32 %4, 255
%105 = sub nsw i32 8, %23
%106 = lshr i32 %104, %105
%107 = shl i32 %106, %21
%108 = trunc i32 %107 to i8
%109 = or i8 %103, %108
store i8 %109, i8* %3
br label %203
110: ; preds = %79
%111 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %203
112: ; preds = %5
%113 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %0, i64 0, i32 0
%114 = load i32, i32* %113
%115 = load i32, i32* @FB_VISUAL_TRUECOLOR
%116 = icmp eq i32 %114, %115
br i1 %116, label %117, label %146
117: ; preds = %112
%118 = bitcast i8* %3 to i16*
%119 = icmp eq i32 %11, 0
%120 = lshr i32 %4, 24
%121 = sub nsw i32 8, %11
%122 = lshr i32 %120, %121
%123 = shl i32 %122, %9
%124 = trunc i32 %123 to i16
%125 = select i1 %119, i16 0, i16 %124
%126 = lshr i32 %4, 16
%127 = and i32 %126, 255
%128 = sub nsw i32 8, %15
%129 = lshr i32 %127, %128
%130 = shl i32 %129, %13
%131 = trunc i32 %130 to i16
%132 = or i16 %125, %131
%133 = lshr i32 %4, 8
%134 = and i32 %133, 255
%135 = sub nsw i32 8, %19
%136 = lshr i32 %134, %135
%137 = shl i32 %136, %17
%138 = trunc i32 %137 to i16
%139 = or i16 %132, %138
%140 = and i32 %4, 255
%141 = sub nsw i32 8, %23
%142 = lshr i32 %140, %141
%143 = shl i32 %142, %21
%144 = trunc i32 %143 to i16
%145 = or i16 %139, %144
store i16 %145, i16* %118
br label %203
146: ; preds = %112
%147 = icmp eq i32 %114, 6
br i1 %147, label %148, label %156
148: ; preds = %146
%149 = bitcast i8* %3 to i32*
%150 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 1
%151 = load i32, i32* %150
%152 = load i32, i32* @V4L2_PIX_FMT_VYUY
%153 = icmp ne i32 %151, %152
%154 = zext i1 %153 to i32
%155 = tail call i32 @rgb_to_yuv(i32 %4, i32 %4, i32* %149, i32 16, i32 %154)
br label %203
156: ; preds = %146
%157 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %203
158: ; preds = %5
%159 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %0, i64 0, i32 0
%160 = load i32, i32* %159
%161 = load i32, i32* @FB_VISUAL_TRUECOLOR
%162 = icmp eq i32 %160, %161
br i1 %162, label %163, label %191
163: ; preds = %158
%164 = bitcast i8* %3 to i32*
%165 = icmp eq i32 %15, 8
br i1 %165, label %166, label %167
166: ; preds = %163
store i32 %4, i32* %164
br label %203
167: ; preds = %163
%168 = icmp eq i32 %11, 0
%169 = lshr i32 %4, 24
%170 = sub nsw i32 8, %11
%171 = lshr i32 %169, %170
%172 = shl i32 %171, %9
%173 = select i1 %168, i32 0, i32 %172
%174 = lshr i32 %4, 16
%175 = and i32 %174, 255
%176 = sub nsw i32 8, %15
%177 = lshr i32 %175, %176
%178 = shl i32 %177, %13
%179 = lshr i32 %4, 8
%180 = and i32 %179, 255
%181 = sub nsw i32 8, %19
%182 = lshr i32 %180, %181
%183 = shl i32 %182, %17
%184 = and i32 %4, 255
%185 = sub nsw i32 8, %23
%186 = lshr i32 %184, %185
%187 = shl i32 %186, %21
%188 = or i32 %183, %178
%189 = or i32 %188, %187
%190 = or i32 %189, %173
store i32 %190, i32* %164
br label %203
191: ; preds = %158
%192 = icmp eq i32 %160, 6
br i1 %192, label %193, label %201
193: ; preds = %191
%194 = bitcast i8* %3 to i32*
%195 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 1
%196 = load i32, i32* %195
%197 = tail call i32 @v4l2_fourcc(i8 signext 65, i8 signext 89, i8 zeroext 85, i8 signext 86)
%198 = icmp ne i32 %196, %197
%199 = zext i1 %198 to i32
%200 = tail call i32 @rgb_to_yuv(i32 %4, i32 0, i32* %194, i32 32, i32 %199)
br label %203
201: ; preds = %191
%202 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %203
203: ; preds = %110, %156, %201, %5, %82, %76, %148, %117, %166, %167, %193
%204 = phi i32 [ 0, %193 ], [ 0, %167 ], [ 0, %166 ], [ 0, %117 ], [ 0, %148 ], [ 0, %76 ], [ 0, %82 ], [ 0, %5 ], [ -1, %201 ], [ -1, %156 ], [ -1, %110 ]
ret i32 %204
}