#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;
struct fb_var_screeninfo {
  int xoffset;
  int bits_per_pixel;
  int yoffset;
};
struct fb_fix_screeninfo {
  int line_length;
};

/* Variables and functions */
void set_pixel(volatile uint8_t *buffer, int x, int y, uint8_t r, uint8_t g,
               uint8_t b, uint8_t a, struct fb_var_screeninfo vinfo,
               struct fb_fix_screeninfo finfo) {
  int location = ((x + vinfo.xoffset) * (vinfo.bits_per_pixel / 8) +
                  (y + vinfo.yoffset) * finfo.line_length);
  if (vinfo.bits_per_pixel == 32) {
    *(buffer + location) = r;
    *(buffer + location + 1) = g;
    *(buffer + location + 2) = b;
    *(buffer + location + 3) = a;
  }
}


x86 assembly (clang, -O0):
<set_pixel>:
push   %rbp
mov    %rsp,%rbp
mov    0x28(%rbp),%r10d
lea    0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x10(%rbp),%r11d
mov    %r10d,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x14(%rbp),%ecx
add    (%rax),%ecx
mov    0x4(%rax),%eax
mov    $0x8,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x30(%rbp),%rax
imul   %edx,%ecx
mov    -0x18(%rbp),%edx
add    0x8(%rax),%edx
imul   -0x8(%rbp),%edx
add    %edx,%ecx
mov    %ecx,-0x28(%rbp)
cmpl   $0x20,0x4(%rax)
jne    119a <set_pixel+0x9a>
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,0x4(%rax,%rcx,4)
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,0x8(%rax,%rcx,4)
mov    0x10(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,0xc(%rax,%rcx,4)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_pixel>:
cmpl   $0x20,0x14(%rsp)
jne    1132 <set_pixel+0x32>
lea    0x10(%rsp),%rax
mov    0x8(%rsp),%r10d
add    (%rax),%esi
add    0x8(%rax),%edx
imul   0x20(%rsp),%edx
lea    (%rdx,%rsi,4),%eax
cltq
mov    %ecx,(%rdi,%rax,4)
mov    %r8d,0x4(%rdi,%rax,4)
mov    %r9d,0x8(%rdi,%rax,4)
mov    %r10d,0xc(%rdi,%rax,4)
ret

LLVM IR (-O0):
%struct.fb_var_screeninfo = type { i32, i32, i32 }
%struct.fb_fix_screeninfo = type { i32 }
define void @set_pixel(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, %struct.fb_var_screeninfo* byval(%struct.fb_var_screeninfo) align 8 %7, i32 %8) {
%10 = alloca %struct.fb_fix_screeninfo
%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 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %10, i32 0, i32 0
store i32 %8, i32* %19
store i32* %0, i32** %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store i32 %3, i32* %14
store i32 %4, i32* %15
store i32 %5, i32* %16
store i32 %6, i32* %17
%20 = load i32, i32* %12
%21 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i32 0, i32 0
%22 = load i32, i32* %21
%23 = add nsw i32 %20, %22
%24 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i32 0, i32 1
%25 = load i32, i32* %24
%26 = sdiv i32 %25, 8
%27 = mul nsw i32 %23, %26
%28 = load i32, i32* %13
%29 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i32 0, i32 2
%30 = load i32, i32* %29
%31 = add nsw i32 %28, %30
%32 = getelementptr inbounds %struct.fb_fix_screeninfo, %struct.fb_fix_screeninfo* %10, i32 0, i32 0
%33 = load i32, i32* %32
%34 = mul nsw i32 %31, %33
%35 = add nsw i32 %27, %34
store i32 %35, i32* %18
%36 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i32 0, i32 1
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 32
br i1 %38, label %39, label %63
39: ; preds = %9
%40 = load i32, i32* %14
%41 = load i32*, i32** %11
%42 = load i32, i32* %18
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
store volatile i32 %40, i32* %44
%45 = load i32, i32* %15
%46 = load i32*, i32** %11
%47 = load i32, i32* %18
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = getelementptr inbounds i32, i32* %49, i64 1
store volatile i32 %45, i32* %50
%51 = load i32, i32* %16
%52 = load i32*, i32** %11
%53 = load i32, i32* %18
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %52, i64 %54
%56 = getelementptr inbounds i32, i32* %55, i64 2
store volatile i32 %51, i32* %56
%57 = load i32, i32* %17
%58 = load i32*, i32** %11
%59 = load i32, i32* %18
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %58, i64 %60
%62 = getelementptr inbounds i32, i32* %61, i64 3
store volatile i32 %57, i32* %62
br label %63
63: ; preds = %39, %9
ret void
}

LLVM IR (-O2):
%struct.fb_var_screeninfo = type { i32, i32, i32 }
define void @set_pixel(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, %struct.fb_var_screeninfo* nocapture byval(%struct.fb_var_screeninfo) align 8 %7, i32 %8) {
%10 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i64 0, i32 1
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 32
br i1 %12, label %13, label %28
13: ; preds = %9
%14 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i64 0, i32 0
%15 = load i32, i32* %14
%16 = add nsw i32 %15, %1
%17 = shl nsw i32 %16, 2
%18 = getelementptr inbounds %struct.fb_var_screeninfo, %struct.fb_var_screeninfo* %7, i64 0, i32 2
%19 = load i32, i32* %18
%20 = add nsw i32 %19, %2
%21 = mul nsw i32 %20, %8
%22 = add nsw i32 %21, %17
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %0, i64 %23
store volatile i32 %3, i32* %24
%25 = getelementptr inbounds i32, i32* %24, i64 1
store volatile i32 %4, i32* %25
%26 = getelementptr inbounds i32, i32* %24, i64 2
store volatile i32 %5, i32* %26
%27 = getelementptr inbounds i32, i32* %24, i64 3
store volatile i32 %6, i32* %27
br label %28
28: ; preds = %13, %9
ret void
}