#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*/ xcb_window_t;
typedef int /*<<< orphan*/ xcb_void_cookie_t;
typedef int /*<<< orphan*/ xcb_screen_t;
typedef int /*<<< orphan*/ xcb_gcontext_t;
typedef int /*<<< orphan*/ xcb_connection_t;
typedef int /*<<< orphan*/ int16_t;

/* Variables and functions */
int /*<<< orphan*/ getFontGC(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                             int /*<<< orphan*/, char *);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ testCookie(int /*<<< orphan*/, int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ xcb_free_gc(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/
xcb_image_text_8_checked(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/, int /*<<< orphan*/,
                         int /*<<< orphan*/, int /*<<< orphan*/, char const *);
void drawText(xcb_connection_t *connection, xcb_screen_t *screen,
              xcb_window_t window, int16_t x1, int16_t y1, const char *label) {
  xcb_gcontext_t gc = getFontGC(connection, screen, window, "fixed");
  xcb_void_cookie_t textCookie = xcb_image_text_8_checked(
      connection, strlen(label), window, gc, x1, y1, label);
  testCookie(textCookie, connection, "can't paste text");
  xcb_void_cookie_t gcCookie = xcb_free_gc(connection, gc);
  testCookie(gcCookie, connection, "can't free gc");
}


x86 assembly (clang, -O0):
<drawText>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe80(%rip),%rcx
call   1070 <getFontGC@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
mov    -0x14(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x28(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <xcb_image_text_8_checked@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x8(%rbp),%rsi
lea    0xe3b(%rip),%rdx
call   1060 <testCookie@plt>
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1050 <xcb_free_gc@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x8(%rbp),%rsi
lea    0xe2a(%rip),%rdx
call   1060 <testCookie@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawText>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%ebp
mov    %rdi,%rbx
lea    0xe90(%rip),%rcx
call   1070 <getFontGC@plt>
mov    %eax,%r13d
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %r14,(%rsp)
mov    %rbx,%rdi
mov    %eax,%esi
mov    %ebp,%edx
mov    %r13d,%ecx
mov    %r12d,%r8d
mov    %r15d,%r9d
call   1030 <xcb_image_text_8_checked@plt>
lea    0xe66(%rip),%rdx
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <testCookie@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
call   1050 <xcb_free_gc@plt>
lea    0xe5b(%rip),%rdx
mov    %eax,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <testCookie@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"fixed\00"
@.str.1 = [17 x i8] c"can't paste text\00"
@.str.2 = [14 x i8] c"can't free gc\00"
define void @drawText(i32* %0, i32* %1, i32 %2, i32 %3, i32 %4, i8* %5) {
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i8* %5, i8** %12
%16 = load i32*, i32** %7
%17 = load i32*, i32** %8
%18 = load i32, i32* %9
%19 = call i32 @getFontGC(i32* %16, i32* %17, i32 %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %19, i32* %13
%20 = load i32*, i32** %7
%21 = load i8*, i8** %12
%22 = call i32 @strlen(i8* %21)
%23 = load i32, i32* %9
%24 = load i32, i32* %13
%25 = load i32, i32* %10
%26 = load i32, i32* %11
%27 = load i8*, i8** %12
%28 = call i32 @xcb_image_text_8_checked(i32* %20, i32 %22, i32 %23, i32 %24, i32 %25, i32 %26, i8* %27)
store i32 %28, i32* %14
%29 = load i32, i32* %14
%30 = load i32*, i32** %7
%31 = call i32 @testCookie(i32 %29, i32* %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%32 = load i32*, i32** %7
%33 = load i32, i32* %13
%34 = call i32 @xcb_free_gc(i32* %32, i32 %33)
store i32 %34, i32* %15
%35 = load i32, i32* %15
%36 = load i32*, i32** %7
%37 = call i32 @testCookie(i32 %35, i32* %36, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"fixed\00"
@.str.1 = [17 x i8] c"can't paste text\00"
@.str.2 = [14 x i8] c"can't free gc\00"
define void @drawText(i32* %0, i32* %1, i32 %2, i32 %3, i32 %4, i8* %5) {
%7 = tail call i32 @getFontGC(i32* %0, i32* %1, i32 %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @strlen(i8* %5)
%9 = tail call i32 @xcb_image_text_8_checked(i32* %0, i32 %8, i32 %2, i32 %7, i32 %3, i32 %4, i8* %5)
%10 = tail call i32 @testCookie(i32 %9, i32* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @xcb_free_gc(i32* %0, i32 %7)
%12 = tail call i32 @testCookie(i32 %11, i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
ret void
}