#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_6__ TYPE_3__;
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
typedef unsigned int uint8_t;
typedef unsigned int uint32_t;
struct TYPE_6__ {
  unsigned int length;
  unsigned int offset;
};
struct TYPE_5__ {
  unsigned int length;
  unsigned int offset;
};
struct TYPE_4__ {
  unsigned int length;
  unsigned int offset;
};
struct fb_var_screeninfo {
  TYPE_3__ blue;
  TYPE_2__ green;
  TYPE_1__ red;
};

/* Variables and functions */
void *setPixelRGBRaw(void *, struct fb_var_screeninfo const *, unsigned int);
void *setPixelRGBCol(void *buf_v, struct fb_var_screeninfo const *info,
                     uint8_t r, uint8_t g, uint8_t b) {
  uint32_t val =
      ((r) == 0
           ? 0
           : (((r) >= (1u << info->red.length) ? ((1u << info->red.length) - 1u)
                                               : (r))
              << (info->red.offset))) |
      ((g) == 0 ? 0
                : (((g) >= (1u << info->green.length)
                        ? ((1u << info->green.length) - 1u)
                        : (g))
                   << (info->green.offset))) |
      ((b) == 0 ? 0
                : (((b) >= (1u << info->blue.length)
                        ? ((1u << info->blue.length) - 1u)
                        : (b))
                   << (info->blue.offset)));
  return setPixelRGBRaw(buf_v, info, val);
}


x86 assembly (clang, -O0):
<setPixelRGBCol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    113e <setPixelRGBCol+0x2e>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    1187 <setPixelRGBCol+0x77>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    0x10(%rcx),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cmp    %ecx,%eax
jb     1172 <setPixelRGBCol+0x62>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1178 <setPixelRGBCol+0x68>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    0x14(%rcx),%ecx
shl    %cl,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11a1 <setPixelRGBCol+0x91>
xor    %eax,%eax
mov    %eax,-0x30(%rbp)
jmp    11ea <setPixelRGBCol+0xda>
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cmp    %ecx,%eax
jb     11d5 <setPixelRGBCol+0xc5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11db <setPixelRGBCol+0xcb>
mov    -0x18(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    0xc(%rcx),%ecx
shl    %cl,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x30(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1209 <setPixelRGBCol+0xf9>
xor    %eax,%eax
mov    %eax,-0x3c(%rbp)
jmp    1250 <setPixelRGBCol+0x140>
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cmp    %ecx,%eax
jb     123b <setPixelRGBCol+0x12b>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1241 <setPixelRGBCol+0x131>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    0x4(%rcx),%ecx
shl    %cl,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x3c(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1030 <setPixelRGBRaw@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setPixelRGBCol>:
mov    %ecx,%r9d
mov    %edx,%r11d
xor    %edx,%edx
mov    $0x0,%r10d
test   %r11d,%r11d
je     113e <setPixelRGBCol+0x2e>
mov    0x10(%rsi),%cl
mov    $0x1,%eax
shl    %cl,%eax
lea    -0x1(%rax),%r10d
cmp    %r11d,%eax
cmova  %r11d,%r10d
mov    0x14(%rsi),%cl
shl    %cl,%r10d
test   %r9d,%r9d
je     115c <setPixelRGBCol+0x4c>
mov    0x8(%rsi),%cl
mov    $0x1,%eax
shl    %cl,%eax
lea    -0x1(%rax),%edx
cmp    %r9d,%eax
cmova  %r9d,%edx
mov    0xc(%rsi),%cl
shl    %cl,%edx
test   %r8d,%r8d
je     117e <setPixelRGBCol+0x6e>
mov    (%rsi),%cl
mov    $0x1,%r9d
shl    %cl,%r9d
lea    -0x1(%r9),%eax
cmp    %r8d,%r9d
cmova  %r8d,%eax
mov    0x4(%rsi),%cl
shl    %cl,%eax
jmp    1180 <setPixelRGBCol+0x70>
xor    %eax,%eax
or     %r10d,%edx
or     %eax,%edx
jmp    1030 <setPixelRGBRaw@plt>

LLVM IR (-O0):
%struct.fb_var_screeninfo = type { %struct.TYPE_6__, %struct.TYPE_5__, %struct.TYPE_4__ }
%struct.TYPE_6__ = type { i32, i32 }
%struct.TYPE_5__ = type { i32, i32 }
%struct.TYPE_4__ = type { i32, i32 }
define i8* @setPixelRGBCol(i8* %0, %struct.fb_var_screeninfo* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca %struct.fb_var_screeninfo*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store %struct.fb_var_screeninfo* %1, %struct.fb_var_screeninfo** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* %8
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %5
br label %39
15: ; preds = %5
%16 = load i32, i32* %8
%17 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%18 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %17, i32 0, i32 2
%19 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = shl i32 1, %20
%22 = icmp uge i32 %16, %21
br i1 %22, label %23, label %30
23: ; preds = %15
%24 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%25 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %24, i32 0, i32 2
%26 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = shl i32 1, %27
%29 = sub i32 %28, 1
br label %32
30: ; preds = %15
%31 = load i32, i32* %8
br label %32
32: ; preds = %30, %23
%33 = phi i32 [ %29, %23 ], [ %31, %30 ]
%34 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%35 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %34, i32 0, i32 2
%36 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %35, i32 0, i32 1
%37 = load i32, i32* %36
%38 = shl i32 %33, %37
br label %39
39: ; preds = %32, %14
%40 = phi i32 [ 0, %14 ], [ %38, %32 ]
%41 = load i32, i32* %9
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39
br label %68
44: ; preds = %39
%45 = load i32, i32* %9
%46 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%47 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %46, i32 0, i32 1
%48 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %47, i32 0, i32 0
%49 = load i32, i32* %48
%50 = shl i32 1, %49
%51 = icmp uge i32 %45, %50
br i1 %51, label %52, label %59
52: ; preds = %44
%53 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%54 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %53, i32 0, i32 1
%55 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %54, i32 0, i32 0
%56 = load i32, i32* %55
%57 = shl i32 1, %56
%58 = sub i32 %57, 1
br label %61
59: ; preds = %44
%60 = load i32, i32* %9
br label %61
61: ; preds = %59, %52
%62 = phi i32 [ %58, %52 ], [ %60, %59 ]
%63 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%64 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %63, i32 0, i32 1
%65 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %64, i32 0, i32 1
%66 = load i32, i32* %65
%67 = shl i32 %62, %66
br label %68
68: ; preds = %61, %43
%69 = phi i32 [ 0, %43 ], [ %67, %61 ]
%70 = or i32 %40, %69
%71 = load i32, i32* %10
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %68
br label %98
74: ; preds = %68
%75 = load i32, i32* %10
%76 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%77 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %76, i32 0, i32 0
%78 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %77, i32 0, i32 0
%79 = load i32, i32* %78
%80 = shl i32 1, %79
%81 = icmp uge i32 %75, %80
br i1 %81, label %82, label %89
82: ; preds = %74
%83 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%84 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %83, i32 0, i32 0
%85 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %84, i32 0, i32 0
%86 = load i32, i32* %85
%87 = shl i32 1, %86
%88 = sub i32 %87, 1
br label %91
89: ; preds = %74
%90 = load i32, i32* %10
br label %91
91: ; preds = %89, %82
%92 = phi i32 [ %88, %82 ], [ %90, %89 ]
%93 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%94 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %93, i32 0, i32 0
%95 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %94, i32 0, i32 1
%96 = load i32, i32* %95
%97 = shl i32 %92, %96
br label %98
98: ; preds = %91, %73
%99 = phi i32 [ 0, %73 ], [ %97, %91 ]
%100 = or i32 %70, %99
store i32 %100, i32* %11
%101 = load i8*, i8** %6
%102 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%103 = load i32, i32* %11
%104 = call i8* @setPixelRGBRaw(i8* %101, %struct.fb_var_screeninfo* %102, i32 %103)
ret i8* %104
}

LLVM IR (-O2):
%struct.fb_var_screeninfo = type { %struct.TYPE_6__, %struct.TYPE_5__, %struct.TYPE_4__ }
%struct.TYPE_6__ = type { i32, i32 }
%struct.TYPE_5__ = type { i32, i32 }
%struct.TYPE_4__ = type { i32, i32 }
define i8* @setPixelRGBCol(i8* %0, %struct.fb_var_screeninfo* %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %2, 0
br i1 %6, label %17, label %7
7: ; preds = %5
%8 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 2, i32 0
%9 = load i32, i32* %8
%10 = shl nuw i32 1, %9
%11 = icmp ugt i32 %10, %2
%12 = add i32 %10, -1
%13 = select i1 %11, i32 %2, i32 %12
%14 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 2, i32 1
%15 = load i32, i32* %14
%16 = shl i32 %13, %15
br label %17
17: ; preds = %5, %7
%18 = phi i32 [ %16, %7 ], [ 0, %5 ]
%19 = icmp eq i32 %3, 0
br i1 %19, label %30, label %20
20: ; preds = %17
%21 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 1, i32 0
%22 = load i32, i32* %21
%23 = shl nuw i32 1, %22
%24 = icmp ugt i32 %23, %3
%25 = add i32 %23, -1
%26 = select i1 %24, i32 %3, i32 %25
%27 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 1, i32 1
%28 = load i32, i32* %27
%29 = shl i32 %26, %28
br label %30
30: ; preds = %17, %20
%31 = phi i32 [ %29, %20 ], [ 0, %17 ]
%32 = icmp eq i32 %4, 0
br i1 %32, label %43, label %33
33: ; preds = %30
%34 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 0, i32 0
%35 = load i32, i32* %34
%36 = shl nuw i32 1, %35
%37 = icmp ugt i32 %36, %4
%38 = add i32 %36, -1
%39 = select i1 %37, i32 %4, i32 %38
%40 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 0, i32 1
%41 = load i32, i32* %40
%42 = shl i32 %39, %41
br label %43
43: ; preds = %30, %33
%44 = phi i32 [ %42, %33 ], [ 0, %30 ]
%45 = or i32 %31, %18
%46 = or i32 %45, %44
%47 = tail call i8* @setPixelRGBRaw(i8* %0, %struct.fb_var_screeninfo* %1, i32 %46)
ret i8* %47
}