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

/* Variables and functions */
int /*<<< orphan*/ BlackPixel(int /*<<< orphan*/ *, int);
int CapButt;
int DefaultScreen(int /*<<< orphan*/ *);
int /*<<< orphan*/ FillSolid;
int JoinBevel;
int LineSolid;
int /*<<< orphan*/ WhitePixel(int /*<<< orphan*/ *, int);
scalar_t__ XCreateGC(int /*<<< orphan*/ *, int /*<<< orphan*/, unsigned long,
                     int /*<<< orphan*/ *);
int /*<<< orphan*/ XSetBackground(int /*<<< orphan*/ *, scalar_t__,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ XSetFillStyle(int /*<<< orphan*/ *, scalar_t__,
                                 int /*<<< orphan*/);
int /*<<< orphan*/ XSetForeground(int /*<<< orphan*/ *, scalar_t__,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ XSetLineAttributes(int /*<<< orphan*/ *, scalar_t__,
                                      unsigned int, int, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
GC create_gc(Display *display, Window win, int reverse_video) {
  GC gc;
  unsigned long valuemask = 0;
  XGCValues values;
  unsigned int line_width = 2;
  int line_style = LineSolid;
  int cap_style = CapButt;
  int join_style = JoinBevel;
  int screen_num = DefaultScreen(display);
  gc = XCreateGC(display, win, valuemask, &values);
  if (gc < 0) {
    fprintf(stderr, "XCreateGC: \n");
  }
  if (reverse_video) {
    XSetForeground(display, gc, WhitePixel(display, screen_num));
    XSetBackground(display, gc, BlackPixel(display, screen_num));
  } else {
    XSetForeground(display, gc, BlackPixel(display, screen_num));
    XSetBackground(display, gc, WhitePixel(display, screen_num));
  }
  XSetLineAttributes(display, gc, line_width, line_style, cap_style,
                     join_style);
  XSetFillStyle(display, gc, FillSolid);
  return gc;
}


x86 assembly (clang, -O0):
<create_gc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x2,-0x28(%rbp)
mov    0x2e0d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2e21(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2ded(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
call   10a0 <DefaultScreen@plt>
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1070 <XCreateGC@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    121c <create_gc+0x8c>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
lea    0xde9(%rip),%rsi
call   1050 <fprintf@plt>
cmpl   $0x0,-0x10(%rbp)
je     1281 <create_gc+0xf1>
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1030 <WhitePixel@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
call   1090 <XSetForeground@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1080 <BlackPixel@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   10b0 <XSetBackground@plt>
jmp    12d7 <create_gc+0x147>
mov    -0x8(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1080 <BlackPixel@plt>
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
call   1090 <XSetForeground@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1030 <WhitePixel@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
call   10b0 <XSetBackground@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x34(%rbp),%r9d
call   1040 <XSetLineAttributes@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2cdf(%rip),%rax
mov    (%rax),%edx
call   1060 <XSetFillStyle@plt>
mov    -0x18(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_gc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2e1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    0x2e32(%rip),%rax
mov    (%rax),%r15d
mov    0x2e00(%rip),%rax
mov    (%rax),%r12d
call   10a0 <DefaultScreen@plt>
mov    %eax,%r13d
lea    0x4(%rsp),%rcx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
call   1070 <XCreateGC@plt>
mov    %rax,%rbp
test   %rax,%rax
jns    11f9 <create_gc+0x69>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
test   %r14d,%r14d
je     1223 <create_gc+0x93>
call   1030 <WhitePixel@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1090 <XSetForeground@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
call   1080 <BlackPixel@plt>
jmp    1240 <create_gc+0xb0>
call   1080 <BlackPixel@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1090 <XSetForeground@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
call   1030 <WhitePixel@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   10b0 <XSetBackground@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x2,%edx
mov    (%rsp),%ecx
mov    %r15d,%r8d
mov    %r12d,%r9d
call   1040 <XSetLineAttributes@plt>
mov    0x2d73(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <XSetFillStyle@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@LineSolid = global i32 0
@CapButt = global i32 0
@JoinBevel = global i32 0
@stderr = global i32 0
@.str = [13 x i8] c"XCreateGC: \0A\00"
@FillSolid = global i32 0
define i64 @create_gc(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i64 0, i64* %8
store i32 2, i32* %10
%15 = load i32, i32* @LineSolid
store i32 %15, i32* %11
%16 = load i32, i32* @CapButt
store i32 %16, i32* %12
%17 = load i32, i32* @JoinBevel
store i32 %17, i32* %13
%18 = load i32*, i32** %4
%19 = call i32 @DefaultScreen(i32* %18)
store i32 %19, i32* %14
%20 = load i32*, i32** %4
%21 = load i32, i32* %5
%22 = load i64, i64* %8
%23 = call i64 @XCreateGC(i32* %20, i32 %21, i64 %22, i32* %9)
store i64 %23, i64* %7
%24 = load i64, i64* %7
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %3
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %26, %3
%30 = load i32, i32* %6
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %45
32: ; preds = %29
%33 = load i32*, i32** %4
%34 = load i64, i64* %7
%35 = load i32*, i32** %4
%36 = load i32, i32* %14
%37 = call i32 @WhitePixel(i32* %35, i32 %36)
%38 = call i32 @XSetForeground(i32* %33, i64 %34, i32 %37)
%39 = load i32*, i32** %4
%40 = load i64, i64* %7
%41 = load i32*, i32** %4
%42 = load i32, i32* %14
%43 = call i32 @BlackPixel(i32* %41, i32 %42)
%44 = call i32 @XSetBackground(i32* %39, i64 %40, i32 %43)
br label %58
45: ; preds = %29
%46 = load i32*, i32** %4
%47 = load i64, i64* %7
%48 = load i32*, i32** %4
%49 = load i32, i32* %14
%50 = call i32 @BlackPixel(i32* %48, i32 %49)
%51 = call i32 @XSetForeground(i32* %46, i64 %47, i32 %50)
%52 = load i32*, i32** %4
%53 = load i64, i64* %7
%54 = load i32*, i32** %4
%55 = load i32, i32* %14
%56 = call i32 @WhitePixel(i32* %54, i32 %55)
%57 = call i32 @XSetBackground(i32* %52, i64 %53, i32 %56)
br label %58
58: ; preds = %45, %32
%59 = load i32*, i32** %4
%60 = load i64, i64* %7
%61 = load i32, i32* %10
%62 = load i32, i32* %11
%63 = load i32, i32* %12
%64 = load i32, i32* %13
%65 = call i32 @XSetLineAttributes(i32* %59, i64 %60, i32 %61, i32 %62, i32 %63, i32 %64)
%66 = load i32*, i32** %4
%67 = load i64, i64* %7
%68 = load i32, i32* @FillSolid
%69 = call i32 @XSetFillStyle(i32* %66, i64 %67, i32 %68)
%70 = load i64, i64* %7
ret i64 %70
}

LLVM IR (-O2):
@LineSolid = global i32 0
@CapButt = global i32 0
@JoinBevel = global i32 0
@stderr = global i32 0
@.str = [13 x i8] c"XCreateGC: \0A\00"
@FillSolid = global i32 0
define i64 @create_gc(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = load i32, i32* @LineSolid
%7 = load i32, i32* @CapButt
%8 = load i32, i32* @JoinBevel
%9 = tail call i32 @DefaultScreen(i32* %0)
%10 = call i64 @XCreateGC(i32* %0, i32 %1, i64 0, i32* %4)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %12, %3
%16 = icmp eq i32 %2, 0
br i1 %16, label %21, label %17
17: ; preds = %15
%18 = call i32 @WhitePixel(i32* %0, i32 %9)
%19 = call i32 @XSetForeground(i32* %0, i64 %10, i32 %18)
%20 = call i32 @BlackPixel(i32* %0, i32 %9)
br label %25
21: ; preds = %15
%22 = call i32 @BlackPixel(i32* %0, i32 %9)
%23 = call i32 @XSetForeground(i32* %0, i64 %10, i32 %22)
%24 = call i32 @WhitePixel(i32* %0, i32 %9)
br label %25
25: ; preds = %21, %17
%26 = phi i32 [ %24, %21 ], [ %20, %17 ]
%27 = call i32 @XSetBackground(i32* %0, i64 %10, i32 %26)
%28 = call i32 @XSetLineAttributes(i32* %0, i64 %10, i32 2, i32 %6, i32 %7, i32 %8)
%29 = load i32, i32* @FillSolid
%30 = call i32 @XSetFillStyle(i32* %0, i64 %10, i32 %29)
ret i64 %10
}