#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 scalar_t__ uint8_t;
typedef int uint32_t;
struct TYPE_6__ {
  scalar_t__ length;
  int offset;
};
struct TYPE_5__ {
  scalar_t__ length;
  int offset;
};
struct TYPE_4__ {
  scalar_t__ length;
  int offset;
};
struct fb_var_screeninfo {
  TYPE_3__ blue;
  TYPE_2__ green;
  TYPE_1__ red;
};
typedef int r;
typedef int g;
typedef int b;

/* Variables and functions */
void *setPixelRGBRaw(void *, struct fb_var_screeninfo const *, int);
void *setPixelRGB(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) <= info->red.length ? (1 << ((r)-1))
                                  : ((1 << (info->red.length)) - 1))
       << (info->red.offset)) |
      (((g) == 0                    ? 0
        : (g) <= info->green.length ? (1 << ((g)-1))
                                    : ((1 << (info->green.length)) - 1))
       << (info->green.offset)) |
      (((b) == 0                   ? 0
        : (b) <= info->blue.length ? (1 << ((b)-1))
                                   : ((1 << (info->blue.length)) - 1))
       << (info->blue.offset));
  return setPixelRGBRaw(buf_v, info, val);
}


x86 assembly (clang, -O0):
<setPixelRGB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1141 <setPixelRGB+0x31>
xor    %eax,%eax
mov    %eax,-0x30(%rbp)
jmp    1189 <setPixelRGB+0x79>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    0x20(%rcx),%rax
jg     116c <setPixelRGB+0x5c>
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x34(%rbp)
jmp    1183 <setPixelRGB+0x73>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    0x28(%rcx),%ecx
shl    %cl,%eax
mov    %eax,-0x38(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ad <setPixelRGB+0x9d>
xor    %eax,%eax
mov    %eax,-0x3c(%rbp)
jmp    11f5 <setPixelRGB+0xe5>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    0x10(%rcx),%rax
jg     11d8 <setPixelRGB+0xc8>
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x40(%rbp)
jmp    11ef <setPixelRGB+0xdf>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x3c(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    0x18(%rcx),%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x44(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1220 <setPixelRGB+0x110>
xor    %eax,%eax
mov    %eax,-0x48(%rbp)
jmp    1266 <setPixelRGB+0x156>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jg     124a <setPixelRGB+0x13a>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x4c(%rbp)
jmp    1260 <setPixelRGB+0x150>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x48(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <setPixelRGBRaw@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setPixelRGB>:
mov    %rcx,%r9
xor    %eax,%eax
mov    $0x0,%r11d
test   %rdx,%rdx
je     1135 <setPixelRGB+0x25>
mov    0x20(%rsi),%rcx
cmp    %rdx,%rcx
jge    113c <setPixelRGB+0x2c>
mov    $0xffffffff,%r11d
shl    %cl,%r11d
not    %r11d
test   %r9,%r9
jne    114f <setPixelRGB+0x3f>
jmp    1171 <setPixelRGB+0x61>
add    $0xff,%dl
mov    $0x1,%r11d
mov    %edx,%ecx
shl    %cl,%r11d
test   %r9,%r9
je     1171 <setPixelRGB+0x61>
mov    0x10(%rsi),%rcx
cmp    %r9,%rcx
jge    1163 <setPixelRGB+0x53>
mov    $0xffffffff,%eax
shl    %cl,%eax
not    %eax
jmp    1171 <setPixelRGB+0x61>
add    $0xff,%r9b
mov    $0x1,%eax
mov    %r9d,%ecx
shl    %cl,%eax
mov    0x28(%rsi),%r10d
mov    0x18(%rsi),%r9d
test   %r8,%r8
je     1191 <setPixelRGB+0x81>
mov    (%rsi),%rcx
cmp    %r8,%rcx
jge    1195 <setPixelRGB+0x85>
mov    $0xffffffff,%edx
shl    %cl,%edx
not    %edx
jmp    11a3 <setPixelRGB+0x93>
xor    %edx,%edx
jmp    11a3 <setPixelRGB+0x93>
add    $0xff,%r8b
mov    $0x1,%edx
mov    %r8d,%ecx
shl    %cl,%edx
mov    %r10d,%ecx
shl    %cl,%r11d
mov    %r9d,%ecx
shl    %cl,%eax
or     %r11d,%eax
mov    0x8(%rsi),%cl
shl    %cl,%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 { i64, i32 }
%struct.TYPE_5__ = type { i64, i32 }
%struct.TYPE_4__ = type { i64, i32 }
define i8* @setPixelRGB(i8* %0, %struct.fb_var_screeninfo* %1, i64 %2, i64 %3, i64 %4) {
%6 = alloca i8*
%7 = alloca %struct.fb_var_screeninfo*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
store i8* %0, i8** %6
store %struct.fb_var_screeninfo* %1, %struct.fb_var_screeninfo** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i64 %4, i64* %10
%12 = load i64, i64* %8
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %5
br label %37
15: ; preds = %5
%16 = load i64, i64* %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 i64, i64* %19
%21 = icmp sle i64 %16, %20
br i1 %21, label %22, label %27
22: ; preds = %15
%23 = load i64, i64* %8
%24 = sub nsw i64 %23, 1
%25 = trunc i64 %24 to i32
%26 = shl i32 1, %25
br label %35
27: ; preds = %15
%28 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%29 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %28, i32 0, i32 2
%30 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %29, i32 0, i32 0
%31 = load i64, i64* %30
%32 = trunc i64 %31 to i32
%33 = shl i32 1, %32
%34 = sub nsw i32 %33, 1
br label %35
35: ; preds = %27, %22
%36 = phi i32 [ %26, %22 ], [ %34, %27 ]
br label %37
37: ; preds = %35, %14
%38 = phi i32 [ 0, %14 ], [ %36, %35 ]
%39 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%40 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %39, i32 0, i32 2
%41 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %40, i32 0, i32 1
%42 = load i32, i32* %41
%43 = shl i32 %38, %42
%44 = load i64, i64* %9
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %37
br label %69
47: ; preds = %37
%48 = load i64, i64* %9
%49 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%50 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %49, i32 0, i32 1
%51 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %50, i32 0, i32 0
%52 = load i64, i64* %51
%53 = icmp sle i64 %48, %52
br i1 %53, label %54, label %59
54: ; preds = %47
%55 = load i64, i64* %9
%56 = sub nsw i64 %55, 1
%57 = trunc i64 %56 to i32
%58 = shl i32 1, %57
br label %67
59: ; preds = %47
%60 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%61 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %60, i32 0, i32 1
%62 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %61, i32 0, i32 0
%63 = load i64, i64* %62
%64 = trunc i64 %63 to i32
%65 = shl i32 1, %64
%66 = sub nsw i32 %65, 1
br label %67
67: ; preds = %59, %54
%68 = phi i32 [ %58, %54 ], [ %66, %59 ]
br label %69
69: ; preds = %67, %46
%70 = phi i32 [ 0, %46 ], [ %68, %67 ]
%71 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%72 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %71, i32 0, i32 1
%73 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %72, i32 0, i32 1
%74 = load i32, i32* %73
%75 = shl i32 %70, %74
%76 = or i32 %43, %75
%77 = load i64, i64* %10
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %69
br label %102
80: ; preds = %69
%81 = load i64, i64* %10
%82 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%83 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %82, i32 0, i32 0
%84 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %83, i32 0, i32 0
%85 = load i64, i64* %84
%86 = icmp sle i64 %81, %85
br i1 %86, label %87, label %92
87: ; preds = %80
%88 = load i64, i64* %10
%89 = sub nsw i64 %88, 1
%90 = trunc i64 %89 to i32
%91 = shl i32 1, %90
br label %100
92: ; preds = %80
%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 0
%96 = load i64, i64* %95
%97 = trunc i64 %96 to i32
%98 = shl i32 1, %97
%99 = sub nsw i32 %98, 1
br label %100
100: ; preds = %92, %87
%101 = phi i32 [ %91, %87 ], [ %99, %92 ]
br label %102
102: ; preds = %100, %79
%103 = phi i32 [ 0, %79 ], [ %101, %100 ]
%104 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%105 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %104, i32 0, i32 0
%106 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %105, i32 0, i32 1
%107 = load i32, i32* %106
%108 = shl i32 %103, %107
%109 = or i32 %76, %108
store i32 %109, i32* %11
%110 = load i8*, i8** %6
%111 = load %struct.fb_var_screeninfo*, %struct.fb_var_screeninfo** %7
%112 = load i32, i32* %11
%113 = call i8* @setPixelRGBRaw(i8* %110, %struct.fb_var_screeninfo* %111, i32 %112)
ret i8* %113
}

LLVM IR (-O2):
%struct.fb_var_screeninfo = type { %struct.TYPE_6__, %struct.TYPE_5__, %struct.TYPE_4__ }
%struct.TYPE_6__ = type { i64, i32 }
%struct.TYPE_5__ = type { i64, i32 }
%struct.TYPE_4__ = type { i64, i32 }
define i8* @setPixelRGB(i8* %0, %struct.fb_var_screeninfo* %1, i64 %2, i64 %3, i64 %4) {
%6 = icmp eq i64 %2, 0
br i1 %6, label %19, 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 i64, i64* %8
%10 = icmp slt i64 %9, %2
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = trunc i64 %2 to i32
%13 = add i32 %12, -1
%14 = shl nuw i32 1, %13
br label %19
15: ; preds = %7
%16 = trunc i64 %9 to i32
%17 = shl nsw i32 -1, %16
%18 = xor i32 %17, -1
br label %19
19: ; preds = %11, %15, %5
%20 = phi i32 [ 0, %5 ], [ %14, %11 ], [ %18, %15 ]
%21 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 2, i32 1
%22 = load i32, i32* %21
%23 = icmp eq i64 %3, 0
br i1 %23, label %36, label %24
24: ; preds = %19
%25 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 1, i32 0
%26 = load i64, i64* %25
%27 = icmp slt i64 %26, %3
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = trunc i64 %3 to i32
%30 = add i32 %29, -1
%31 = shl nuw i32 1, %30
br label %36
32: ; preds = %24
%33 = trunc i64 %26 to i32
%34 = shl nsw i32 -1, %33
%35 = xor i32 %34, -1
br label %36
36: ; preds = %28, %32, %19
%37 = phi i32 [ 0, %19 ], [ %31, %28 ], [ %35, %32 ]
%38 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 1, i32 1
%39 = load i32, i32* %38
%40 = icmp eq i64 %4, 0
br i1 %40, label %53, label %41
41: ; preds = %36
%42 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 0, i32 0
%43 = load i64, i64* %42
%44 = icmp slt i64 %43, %4
br i1 %44, label %49, label %45
45: ; preds = %41
%46 = trunc i64 %4 to i32
%47 = add i32 %46, -1
%48 = shl nuw i32 1, %47
br label %53
49: ; preds = %41
%50 = trunc i64 %43 to i32
%51 = shl nsw i32 -1, %50
%52 = xor i32 %51, -1
br label %53
53: ; preds = %45, %49, %36
%54 = phi i32 [ 0, %36 ], [ %48, %45 ], [ %52, %49 ]
%55 = shl i32 %20, %22
%56 = shl i32 %37, %39
%57 = or i32 %56, %55
%58 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %1, i64 0, i32 0, i32 1
%59 = load i32, i32* %58
%60 = shl i32 %54, %59
%61 = or i32 %57, %60
%62 = tail call i8* @setPixelRGBRaw(i8* %0, %struct.fb_var_screeninfo* %1, i32 %61)
ret i8* %62
}