#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 */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int /*<<< orphan*/ atom;
};
typedef TYPE_1__ xcb_intern_atom_reply_t;
typedef int /*<<< orphan*/ xcb_intern_atom_cookie_t;
typedef int /*<<< orphan*/ xcb_connection_t;
typedef int /*<<< orphan*/ xcb_atom_t;

/* Variables and functions */
int /*<<< orphan*/ free(TYPE_1__ *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ xcb_intern_atom(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/, char *);
TYPE_1__ *xcb_intern_atom_reply(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/ *);
void useXCBProperly(char **names, xcb_connection_t *connection) {
  xcb_atom_t atoms[500];
  xcb_intern_atom_cookie_t cookies[500];
  for (int i = 0; i < 500; i++) {
    cookies[i] = xcb_intern_atom(connection, 0, strlen(names[i]), names[i]);
  }
  for (int i = 0; i < 500; i++) {
    xcb_intern_atom_reply_t *reply =
        xcb_intern_atom_reply(connection, cookies[i], NULL);
    if (reply) {
      atoms[i] = reply->atom;
      free(reply);
    }
  }
}


x86 assembly (clang, -O0):
<useXCBProperly>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xfb4(%rbp)
cmpl   $0x1f4,-0xfb4(%rbp)
jge    11cf <useXCBProperly+0x8f>
mov    -0x10(%rbp),%rax
mov    %rax,-0xfc8(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xfb4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0xfc8(%rbp),%rdi
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0xfb4(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
xor    %esi,%esi
call   1050 <xcb_intern_atom@plt>
mov    %eax,%ecx
movslq -0xfb4(%rbp),%rax
mov    %ecx,-0xfb0(%rbp,%rax,4)
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    115d <useXCBProperly+0x1d>
movl   $0x0,-0xfb8(%rbp)
cmpl   $0x1f4,-0xfb8(%rbp)
jge    1255 <useXCBProperly+0x115>
mov    -0x10(%rbp),%rdi
movslq -0xfb8(%rbp),%rax
mov    -0xfb0(%rbp,%rax,4),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <xcb_intern_atom_reply@plt>
mov    %rax,-0xfc0(%rbp)
cmpq   $0x0,-0xfc0(%rbp)
je     123c <useXCBProperly+0xfc>
mov    -0xfc0(%rbp),%rax
mov    (%rax),%ecx
movslq -0xfb8(%rbp),%rax
mov    %ecx,-0x7e0(%rbp,%rax,4)
mov    -0xfc0(%rbp),%rdi
call   1030 <free@plt>
jmp    1241 <useXCBProperly+0x101>
mov    -0xfb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb8(%rbp)
jmp    11d9 <useXCBProperly+0x99>
add    $0xfd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<useXCBProperly>:
push   %r15
push   %r14
push   %rbx
sub    $0x7d0,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%rbx,8),%rdi
call   1040 <strlen@plt>
mov    (%r15,%rbx,8),%rcx
mov    %r14,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1050 <xcb_intern_atom@plt>
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x1f4,%rbx
jne    1160 <useXCBProperly+0x20>
xor    %ebx,%ebx
jmp    119d <useXCBProperly+0x5d>
nopl   (%rax)
add    $0x1,%rbx
cmp    $0x1f4,%rbx
je     11b9 <useXCBProperly+0x79>
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %edx,%edx
call   1060 <xcb_intern_atom_reply@plt>
test   %rax,%rax
je     1190 <useXCBProperly+0x50>
mov    %rax,%rdi
call   1030 <free@plt>
jmp    1190 <useXCBProperly+0x50>
add    $0x7d0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32 }
define void @useXCBProperly(i8** %0, i32* %1) {
%3 = alloca i8**
%4 = alloca i32*
%5 = alloca [500 x i32]
%6 = alloca [500 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.TYPE_4__*
store i8** %0, i8*** %3
store i32* %1, i32** %4
store i32 0, i32* %7
br label %10
10: ; preds = %30, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 500
br i1 %12, label %13, label %33
13: ; preds = %10
%14 = load i32*, i32** %4
%15 = load i8**, i8*** %3
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @strlen(i8* %19)
%21 = load i8**, i8*** %3
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @xcb_intern_atom(i32* %14, i32 0, i32 %20, i8* %25)
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [500 x i32], [500 x i32]* %6, i64 0, i64 %28
store i32 %26, i32* %29
br label %30
30: ; preds = %13
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %10
33: ; preds = %10
store i32 0, i32* %8
br label %34
34: ; preds = %56, %33
%35 = load i32, i32* %8
%36 = icmp slt i32 %35, 500
br i1 %36, label %37, label %59
37: ; preds = %34
%38 = load i32*, i32** %4
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [500 x i32], [500 x i32]* %6, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = call %struct.TYPE_4__* @xcb_intern_atom_reply(i32* %38, i32 %42, i32* null)
store %struct.TYPE_4__* %43, %struct.TYPE_4__** %9
%44 = load %struct.TYPE_4__*, %struct.TYPE_4__** %9
%45 = icmp ne %struct.TYPE_4__* %44, null
br i1 %45, label %46, label %55
46: ; preds = %37
%47 = load %struct.TYPE_4__*, %struct.TYPE_4__** %9
%48 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %47, i32 0, i32 0
%49 = load i32, i32* %48
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [500 x i32], [500 x i32]* %5, i64 0, i64 %51
store i32 %49, i32* %52
%53 = load %struct.TYPE_4__*, %struct.TYPE_4__** %9
%54 = call i32 @free(%struct.TYPE_4__* %53)
br label %55
55: ; preds = %46, %37
br label %56
56: ; preds = %55
%57 = load i32, i32* %8
%58 = add nsw i32 %57, 1
store i32 %58, i32* %8
br label %34
59: ; preds = %34
ret void
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32 }
define void @useXCBProperly(i8** nocapture %0, i32* %1) {
%3 = alloca [500 x i32]
%4 = bitcast [500 x i32]* %3 to i8*
br label %5
5: ; preds = %2, %5
%6 = phi i64 [ 0, %2 ], [ %13, %5 ]
%7 = getelementptr inbounds i8*, i8** %0, i64 %6
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* %8)
%10 = load i8*, i8** %7
%11 = tail call i32 @xcb_intern_atom(i32* %1, i32 0, i32 %9, i8* %10)
%12 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %6
store i32 %11, i32* %12
%13 = add nuw nsw i64 %6, 1
%14 = icmp eq i64 %13, 500
br i1 %14, label %16, label %5
15: ; preds = %24
ret void
16: ; preds = %5, %24
%17 = phi i64 [ %25, %24 ], [ 0, %5 ]
%18 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = tail call %struct.TYPE_4__* @xcb_intern_atom_reply(i32* %1, i32 %19, i32* null)
%21 = icmp eq %struct.TYPE_4__* %20, null
br i1 %21, label %24, label %22
22: ; preds = %16
%23 = tail call i32 @free(%struct.TYPE_4__* %20)
br label %24
24: ; preds = %22, %16
%25 = add nuw nsw i64 %17, 1
%26 = icmp eq i64 %25, 500
br i1 %26, label %15, label %16
}