#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 uint8_t;
typedef int uint32_t;
typedef int uint16_t;
typedef int int32_t;

/* Variables and functions */
void GrOffScreen1BPPPixelDraw(void *pvDisplayData, int32_t i32X, int32_t i32Y,
                              uint32_t ui32Value) {
  uint8_t *pui8Data;
  int32_t i32BytesPerRow;
  ;
  pui8Data = (uint8_t *)pvDisplayData;
  i32BytesPerRow = (*(uint16_t *)(pui8Data + 1) + 7) / 8;
  pui8Data += (i32BytesPerRow * i32Y) + (i32X / 8) + 5;
  i32X = 7 - (i32X & 7);
  *pui8Data = (*pui8Data & ~(1 << i32X)) | (ui32Value << i32X);
}


x86 assembly (clang, -O0):
<GrOffScreen1BPPPixelDraw>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%eax
add    $0x7,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
imul   -0x10(%rbp),%ecx
mov    -0xc(%rbp),%eax
mov    $0x8,%esi
cltd
idiv   %esi
add    %eax,%ecx
add    $0x5,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%ecx
and    $0x7,%ecx
mov    $0x7,%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    %cl,%eax
mov    -0x28(%rbp),%ecx
or     %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<GrOffScreen1BPPPixelDraw>:
mov    %ecx,%r8d
mov    %esi,%ecx
mov    0x4(%rdi),%esi
lea    0x7(%rsi),%eax
add    $0xe,%esi
test   %eax,%eax
cmovns %eax,%esi
sar    $0x3,%esi
imul   %edx,%esi
lea    0x7(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
sar    $0x3,%eax
add    %esi,%eax
add    $0x5,%eax
cltq
not    %cl
and    $0x7,%cl
shl    %cl,%r8d
mov    (%rdi,%rax,4),%edx
btr    %ecx,%edx
or     %edx,%r8d
mov    %r8d,(%rdi,%rax,4)
ret

LLVM IR (-O0):
define void @GrOffScreen1BPPPixelDraw(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i8*, i8** %5
%12 = bitcast i8* %11 to i32*
store i32* %12, i32** %9
%13 = load i32*, i32** %9
%14 = getelementptr inbounds i32, i32* %13, i64 1
%15 = load i32, i32* %14
%16 = add nsw i32 %15, 7
%17 = sdiv i32 %16, 8
store i32 %17, i32* %10
%18 = load i32, i32* %10
%19 = load i32, i32* %7
%20 = mul nsw i32 %18, %19
%21 = load i32, i32* %6
%22 = sdiv i32 %21, 8
%23 = add nsw i32 %20, %22
%24 = add nsw i32 %23, 5
%25 = load i32*, i32** %9
%26 = sext i32 %24 to i64
%27 = getelementptr inbounds i32, i32* %25, i64 %26
store i32* %27, i32** %9
%28 = load i32, i32* %6
%29 = and i32 %28, 7
%30 = sub nsw i32 7, %29
store i32 %30, i32* %6
%31 = load i32*, i32** %9
%32 = load i32, i32* %31
%33 = load i32, i32* %6
%34 = shl i32 1, %33
%35 = xor i32 %34, -1
%36 = and i32 %32, %35
%37 = load i32, i32* %8
%38 = load i32, i32* %6
%39 = shl i32 %37, %38
%40 = or i32 %36, %39
%41 = load i32*, i32** %9
store i32 %40, i32* %41
ret void
}

LLVM IR (-O2):
define void @GrOffScreen1BPPPixelDraw(i8* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = bitcast i8* %0 to i32*
%6 = getelementptr inbounds i8, i8* %0, i64 4
%7 = bitcast i8* %6 to i32*
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 7
%10 = sdiv i32 %9, 8
%11 = mul nsw i32 %10, %2
%12 = sdiv i32 %1, 8
%13 = add nsw i32 %12, 5
%14 = add i32 %13, %11
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %5, i64 %15
%17 = and i32 %1, 7
%18 = xor i32 %17, 7
%19 = load i32, i32* %16
%20 = shl nuw i32 1, %18
%21 = xor i32 %20, -1
%22 = and i32 %19, %21
%23 = shl i32 %3, %18
%24 = or i32 %22, %23
store i32 %24, i32* %16
ret void
}