#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_connection_t;
typedef int /*<<< orphan*/ xcb_atom_t;

/* Variables and functions */
int /*<<< orphan*/ XCB_NONE;
int /*<<< orphan*/ free(TYPE_1__ *);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ xcb_intern_atom(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/, char const *);
TYPE_1__ *xcb_intern_atom_reply(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/ *);
xcb_atom_t xcb_atom_get(xcb_connection_t *connection, const char *atom_name) {
  if (atom_name == NULL)
    return XCB_NONE;
  xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(
      connection, xcb_intern_atom(connection, 0, strlen(atom_name), atom_name),
      NULL);
  if (!reply)
    return XCB_NONE;
  xcb_atom_t atom = reply->atom;
  free(reply);
  return atom;
}


x86 assembly (clang, -O0):
<xcb_atom_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116c <xcb_atom_get+0x2c>
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11dd <xcb_atom_get+0x9d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%edx
mov    -0x18(%rbp),%rcx
xor    %esi,%esi
call   1050 <xcb_intern_atom@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <xcb_intern_atom_reply@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c5 <xcb_atom_get+0x85>
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11dd <xcb_atom_get+0x9d>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xcb_atom_get>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     1183 <xcb_atom_get+0x43>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1050 <xcb_intern_atom@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1060 <xcb_intern_atom_reply@plt>
test   %rax,%rax
je     1183 <xcb_atom_get+0x43>
mov    (%rax),%ebx
mov    %rax,%rdi
call   1030 <free@plt>
jmp    118c <xcb_atom_get+0x4c>
mov    0x2e6e(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32 }
@XCB_NONE = global i32 0
define i32 @xcb_atom_get(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca %struct.TYPE_4__*
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load i32, i32* @XCB_NONE
store i32 %11, i32* %3
br label %31
12: ; preds = %2
%13 = load i32*, i32** %4
%14 = load i32*, i32** %4
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
%17 = load i8*, i8** %5
%18 = call i32 @xcb_intern_atom(i32* %14, i32 0, i32 %16, i8* %17)
%19 = call %struct.TYPE_4__* @xcb_intern_atom_reply(i32* %13, i32 %18, i32* null)
store %struct.TYPE_4__* %19, %struct.TYPE_4__** %6
%20 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%21 = icmp ne %struct.TYPE_4__* %20, null
br i1 %21, label %24, label %22
22: ; preds = %12
%23 = load i32, i32* @XCB_NONE
store i32 %23, i32* %3
br label %31
24: ; preds = %12
%25 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%26 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %25, i32 0, i32 0
%27 = load i32, i32* %26
store i32 %27, i32* %7
%28 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%29 = call i32 @free(%struct.TYPE_4__* %28)
%30 = load i32, i32* %7
store i32 %30, i32* %3
br label %31
31: ; preds = %24, %22, %10
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32 }
@XCB_NONE = global i32 0
define i32 @xcb_atom_get(i32* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = load i32, i32* @XCB_NONE
br label %17
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %1)
%8 = tail call i32 @xcb_intern_atom(i32* %0, i32 0, i32 %7, i8* %1)
%9 = tail call %struct.TYPE_4__* @xcb_intern_atom_reply(i32* %0, i32 %8, i32* null)
%10 = icmp eq %struct.TYPE_4__* %9, null
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = load i32, i32* @XCB_NONE
br label %17
13: ; preds = %6
%14 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %9, i64 0, i32 0
%15 = load i32, i32* %14
%16 = tail call i32 @free(%struct.TYPE_4__* %9)
br label %17
17: ; preds = %11, %13, %4
%18 = phi i32 [ %5, %4 ], [ %15, %13 ], [ %12, %11 ]
ret i32 %18
}