#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*/ Window;
typedef int /*<<< orphan*/ Pixmap;
typedef int /*<<< orphan*/ GC;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
unsigned long BlackPixel(int /*<<< orphan*/ *, int);
int DefaultScreen(int /*<<< orphan*/ *);
unsigned long WhitePixel(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ XCopyPlane(int /*<<< orphan*/ *, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/, int, int,
                              int, int, int);
int /*<<< orphan*/ XCreatePixmap(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                                 int, int /*<<< orphan*/);
int /*<<< orphan*/ XDefaultDepth(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XDefaultRootWindow(int /*<<< orphan*/ *);
int /*<<< orphan*/ XDefaultScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ XDrawPoint(int /*<<< orphan*/ *, int /*<<< orphan*/,
                              int /*<<< orphan*/, int, int);
int /*<<< orphan*/ XFillRectangle(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  int /*<<< orphan*/, int /*<<< orphan*/,
                                  int /*<<< orphan*/, int, int);
int /*<<< orphan*/ XSetForeground(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  unsigned long);
void drawbmp(Display *display, Window win, GC gc) {
  Pixmap bitmap;
  unsigned int bitmap_width, bitmap_height;
  int hotspot_x, hotspot_y;
  bitmap = XCreatePixmap(display, XDefaultRootWindow(display), 30, 40,
                         XDefaultDepth(display, XDefaultScreen(display)));
  int screenNumber = DefaultScreen(display);
  unsigned long white = WhitePixel(display, screenNumber);
  unsigned long black = BlackPixel(display, screenNumber);
  XSetForeground(display, gc, black);
  XFillRectangle(display, bitmap, gc, 0, 0, 15, 20);
  XSetForeground(display, gc, white);
  XDrawPoint(display, bitmap, gc, 10, 10);
  XCopyPlane(display, bitmap, win, gc, 0, 0, 15, 20, 15, 20, 1);
}


x86 assembly (clang, -O0):
<drawbmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
call   1090 <XDefaultRootWindow@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <XDefaultScreen@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1080 <XDefaultDepth@plt>
mov    -0x48(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    %eax,%r8d
mov    $0x1e,%edx
mov    $0x28,%ecx
call   10d0 <XCreatePixmap@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   10c0 <DefaultScreen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1060 <WhitePixel@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   10a0 <BlackPixel@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x38(%rbp),%rdx
call   10b0 <XSetForeground@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
xor    %r8d,%r8d
mov    $0xf,%r9d
mov    %r8d,%ecx
movl   $0x14,(%rsp)
call   1050 <XFillRectangle@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   10b0 <XSetForeground@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    $0xa,%r8d
mov    %r8d,%ecx
call   1040 <XDrawPoint@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
xor    %r9d,%r9d
mov    %r9d,%r8d
movl   $0xf,(%rsp)
movl   $0x14,0x8(%rsp)
movl   $0xf,0x10(%rsp)
movl   $0x14,0x18(%rsp)
movl   $0x1,0x20(%rsp)
call   1030 <XCopyPlane@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawbmp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%r14d
mov    %rdi,%rbp
call   1090 <XDefaultRootWindow@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
call   1070 <XDefaultScreen@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1080 <XDefaultDepth@plt>
mov    %rbp,%rdi
mov    %r15d,%esi
mov    $0x1e,%edx
mov    $0x28,%ecx
mov    %eax,%r8d
call   10d0 <XCreatePixmap@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
call   10c0 <DefaultScreen@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
mov    %eax,%esi
call   1060 <WhitePixel@plt>
mov    %rax,%r13
mov    %rbp,%rdi
mov    %ebx,%esi
call   10a0 <BlackPixel@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %rax,%rdx
call   10b0 <XSetForeground@plt>
sub    $0x8,%rsp
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r12d,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    $0xf,%r9d
push   $0x14
call   1050 <XFillRectangle@plt>
add    $0x10,%rsp
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r13,%rdx
call   10b0 <XSetForeground@plt>
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r12d,%edx
mov    $0xa,%ecx
mov    $0xa,%r8d
call   1040 <XDrawPoint@plt>
sub    $0x8,%rsp
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %r12d,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   $0x1
push   $0x14
push   $0xf
push   $0x14
push   $0xf
call   1030 <XCopyPlane@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @drawbmp(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca i64
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%15 = load i32*, i32** %4
%16 = load i32*, i32** %4
%17 = call i32 @XDefaultRootWindow(i32* %16)
%18 = load i32*, i32** %4
%19 = load i32*, i32** %4
%20 = call i32 @XDefaultScreen(i32* %19)
%21 = call i32 @XDefaultDepth(i32* %18, i32 %20)
%22 = call i32 @XCreatePixmap(i32* %15, i32 %17, i32 30, i32 40, i32 %21)
store i32 %22, i32* %7
%23 = load i32*, i32** %4
%24 = call i32 @DefaultScreen(i32* %23)
store i32 %24, i32* %12
%25 = load i32*, i32** %4
%26 = load i32, i32* %12
%27 = call i64 @WhitePixel(i32* %25, i32 %26)
store i64 %27, i64* %13
%28 = load i32*, i32** %4
%29 = load i32, i32* %12
%30 = call i64 @BlackPixel(i32* %28, i32 %29)
store i64 %30, i64* %14
%31 = load i32*, i32** %4
%32 = load i32, i32* %6
%33 = load i64, i64* %14
%34 = call i32 @XSetForeground(i32* %31, i32 %32, i64 %33)
%35 = load i32*, i32** %4
%36 = load i32, i32* %7
%37 = load i32, i32* %6
%38 = call i32 @XFillRectangle(i32* %35, i32 %36, i32 %37, i32 0, i32 0, i32 15, i32 20)
%39 = load i32*, i32** %4
%40 = load i32, i32* %6
%41 = load i64, i64* %13
%42 = call i32 @XSetForeground(i32* %39, i32 %40, i64 %41)
%43 = load i32*, i32** %4
%44 = load i32, i32* %7
%45 = load i32, i32* %6
%46 = call i32 @XDrawPoint(i32* %43, i32 %44, i32 %45, i32 10, i32 10)
%47 = load i32*, i32** %4
%48 = load i32, i32* %7
%49 = load i32, i32* %5
%50 = load i32, i32* %6
%51 = call i32 @XCopyPlane(i32* %47, i32 %48, i32 %49, i32 %50, i32 0, i32 0, i32 15, i32 20, i32 15, i32 20, i32 1)
ret void
}

LLVM IR (-O2):
define void @drawbmp(i32* %0, i32 %1, i32 %2) {
%4 = tail call i32 @XDefaultRootWindow(i32* %0)
%5 = tail call i32 @XDefaultScreen(i32* %0)
%6 = tail call i32 @XDefaultDepth(i32* %0, i32 %5)
%7 = tail call i32 @XCreatePixmap(i32* %0, i32 %4, i32 30, i32 40, i32 %6)
%8 = tail call i32 @DefaultScreen(i32* %0)
%9 = tail call i64 @WhitePixel(i32* %0, i32 %8)
%10 = tail call i64 @BlackPixel(i32* %0, i32 %8)
%11 = tail call i32 @XSetForeground(i32* %0, i32 %2, i64 %10)
%12 = tail call i32 @XFillRectangle(i32* %0, i32 %7, i32 %2, i32 0, i32 0, i32 15, i32 20)
%13 = tail call i32 @XSetForeground(i32* %0, i32 %2, i64 %9)
%14 = tail call i32 @XDrawPoint(i32* %0, i32 %7, i32 %2, i32 10, i32 10)
%15 = tail call i32 @XCopyPlane(i32* %0, i32 %7, i32 %1, i32 %2, i32 0, i32 0, i32 15, i32 20, i32 15, i32 20, i32 1)
ret void
}