#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_7__ TYPE_1__;

/* Type definitions */
struct TYPE_7__ {
  char *name_len;
};
typedef TYPE_1__ xcb_get_atom_name_reply_t;
typedef int /*<<< orphan*/ xcb_get_atom_name_cookie_t;
typedef TYPE_1__ xcb_generic_error_t;
typedef int /*<<< orphan*/ xcb_connection_t;
typedef int /*<<< orphan*/ atom_name;

/* Variables and functions */
int /*<<< orphan*/ free(TYPE_1__ *);
int /*<<< orphan*/ printf(char const *, long, char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ xcb_get_atom_name(int /*<<< orphan*/ *, long);
int /*<<< orphan*/ xcb_get_atom_name_name(TYPE_1__ *);
TYPE_1__ *xcb_get_atom_name_reply(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  TYPE_1__ **);
int say_batch(xcb_connection_t *c, const char *format,
              xcb_get_atom_name_cookie_t *cookie, long low, long count) {
  xcb_generic_error_t *e;
  char atom_name[1024];
  long i;
  int done = 0;
  for (i = 0; i < count; i++)
    cookie[i] = xcb_get_atom_name(c, i + low);
  for (i = 0; i < count; i++) {
    xcb_get_atom_name_reply_t *r;
    r = xcb_get_atom_name_reply(c, cookie[i], &e);
    if (r) {
      snprintf(atom_name, sizeof(atom_name), "%.*s", r->name_len,
               xcb_get_atom_name_name(r));
      printf(format, i + low, atom_name);
      putchar('\n');
      free(r);
    }
    if (e) {
      done = 1;
      free(e);
    }
  }
  return done;
}


x86 assembly (clang, -O0):
<say_batch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x43c(%rbp)
movq   $0x0,-0x438(%rbp)
mov    -0x438(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    11f0 <say_batch+0x80>
mov    -0x8(%rbp),%rdi
mov    -0x438(%rbp),%rsi
add    -0x20(%rbp),%rsi
call   1030 <xcb_get_atom_name@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    -0x438(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x438(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x438(%rbp)
jmp    11a4 <say_batch+0x34>
movq   $0x0,-0x438(%rbp)
mov    -0x438(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    12f4 <say_batch+0x184>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x438(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    -0x30(%rbp),%rdx
call   1060 <xcb_get_atom_name_reply@plt>
mov    %rax,-0x448(%rbp)
cmpq   $0x0,-0x448(%rbp)
je     12ba <say_batch+0x14a>
lea    -0x430(%rbp),%rax
mov    %rax,-0x458(%rbp)
mov    -0x448(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x450(%rbp)
mov    -0x448(%rbp),%rdi
call   1090 <xcb_get_atom_name_name@plt>
mov    -0x458(%rbp),%rdi
mov    -0x450(%rbp),%rcx
mov    %eax,%r8d
mov    $0x400,%esi
lea    0xd7c(%rip),%rdx
call   1080 <snprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x438(%rbp),%rsi
add    -0x20(%rbp),%rsi
lea    -0x430(%rbp),%rdx
call   1070 <printf@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    -0x448(%rbp),%rdi
call   1040 <free@plt>
cmpq   $0x0,-0x30(%rbp)
je     12d8 <say_batch+0x168>
movl   $0x1,-0x43c(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
jmp    12dd <say_batch+0x16d>
mov    -0x438(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x438(%rbp)
jmp    11fb <say_batch+0x8b>
mov    -0x43c(%rbp),%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<say_batch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %rsi,0x10(%rsp)
test   %r8,%r8
jle    1283 <say_batch+0x113>
mov    %r8,%r15
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %rdi,%r13
xor    %ebp,%ebp
nopl   (%rax)
lea    (%rbx,%rbp,1),%rsi
mov    %r13,%rdi
call   1030 <xcb_get_atom_name@plt>
mov    %eax,(%r12,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11a0 <say_batch+0x30>
test   %r15,%r15
jle    1283 <say_batch+0x113>
xor    %r14d,%r14d
movl   $0x0,0x4(%rsp)
mov    %r15,0x8(%rsp)
jmp    11ed <say_batch+0x7d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r14
cmp    %r14,%r15
je     128b <say_batch+0x11b>
mov    (%r12,%r14,4),%esi
mov    %r13,%rdi
lea    0x18(%rsp),%rdx
call   1060 <xcb_get_atom_name_reply@plt>
test   %rax,%rax
je     1263 <say_batch+0xf3>
mov    %rax,%rbp
mov    %r13,%r15
mov    %r12,%r13
mov    (%rax),%r12
mov    %rax,%rdi
call   1090 <xcb_get_atom_name_name@plt>
lea    0x20(%rsp),%rdi
mov    $0x400,%esi
lea    0xdd8(%rip),%rdx
mov    %r12,%rcx
mov    %r13,%r12
mov    %r15,%r13
mov    0x8(%rsp),%r15
mov    %eax,%r8d
call   1080 <snprintf@plt>
lea    (%rbx,%r14,1),%rsi
mov    0x10(%rsp),%rdi
lea    0x20(%rsp),%rdx
call   1070 <printf@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
mov    0x18(%rsp),%rdi
test   %rdi,%rdi
je     11e0 <say_batch+0x70>
call   1040 <free@plt>
movl   $0x1,0x4(%rsp)
jmp    11e0 <say_batch+0x70>
movl   $0x0,0x4(%rsp)
mov    0x4(%rsp),%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_7__ = type { i8* }
@.str = [5 x i8] c"%.*s\00"
define i32 @say_batch(i32* %0, i8* %1, i32* %2, i64 %3, i64 %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i64
%11 = alloca %struct.TYPE_7__*
%12 = alloca [1024 x i8]
%13 = alloca i64
%14 = alloca i32
%15 = alloca %struct.TYPE_7__*
store i32* %0, i32** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i64 %3, i64* %9
store i64 %4, i64* %10
store i32 0, i32* %14
store i64 0, i64* %13
br label %16
16: ; preds = %29, %5
%17 = load i64, i64* %13
%18 = load i64, i64* %10
%19 = icmp slt i64 %17, %18
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = load i32*, i32** %6
%22 = load i64, i64* %13
%23 = load i64, i64* %9
%24 = add nsw i64 %22, %23
%25 = call i32 @xcb_get_atom_name(i32* %21, i64 %24)
%26 = load i32*, i32** %8
%27 = load i64, i64* %13
%28 = getelementptr inbounds i32, i32* %26, i64 %27
store i32 %25, i32* %28
br label %29
29: ; preds = %20
%30 = load i64, i64* %13
%31 = add nsw i64 %30, 1
store i64 %31, i64* %13
br label %16
32: ; preds = %16
store i64 0, i64* %13
br label %33
33: ; preds = %70, %32
%34 = load i64, i64* %13
%35 = load i64, i64* %10
%36 = icmp slt i64 %34, %35
br i1 %36, label %37, label %73
37: ; preds = %33
%38 = load i32*, i32** %6
%39 = load i32*, i32** %8
%40 = load i64, i64* %13
%41 = getelementptr inbounds i32, i32* %39, i64 %40
%42 = load i32, i32* %41
%43 = call %struct.TYPE_7__* @xcb_get_atom_name_reply(i32* %38, i32 %42, %struct.TYPE_7__** %11)
store %struct.TYPE_7__* %43, %struct.TYPE_7__** %15
%44 = load %struct.TYPE_7__*, %struct.TYPE_7__** %15
%45 = icmp ne %struct.TYPE_7__* %44, null
br i1 %45, label %46, label %63
46: ; preds = %37
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%48 = load %struct.TYPE_7__*, %struct.TYPE_7__** %15
%49 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %48, i32 0, i32 0
%50 = load i8*, i8** %49
%51 = load %struct.TYPE_7__*, %struct.TYPE_7__** %15
%52 = call i32 @xcb_get_atom_name_name(%struct.TYPE_7__* %51)
%53 = call i32 @snprintf(i8* %47, i32 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %50, i32 %52)
%54 = load i8*, i8** %7
%55 = load i64, i64* %13
%56 = load i64, i64* %9
%57 = add nsw i64 %55, %56
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%59 = call i32 @printf(i8* %54, i64 %57, i8* %58)
%60 = call i32 @putchar(i8 signext 10)
%61 = load %struct.TYPE_7__*, %struct.TYPE_7__** %15
%62 = call i32 @free(%struct.TYPE_7__* %61)
br label %63
63: ; preds = %46, %37
%64 = load %struct.TYPE_7__*, %struct.TYPE_7__** %11
%65 = icmp ne %struct.TYPE_7__* %64, null
br i1 %65, label %66, label %69
66: ; preds = %63
store i32 1, i32* %14
%67 = load %struct.TYPE_7__*, %struct.TYPE_7__** %11
%68 = call i32 @free(%struct.TYPE_7__* %67)
br label %69
69: ; preds = %66, %63
br label %70
70: ; preds = %69
%71 = load i64, i64* %13
%72 = add nsw i64 %71, 1
store i64 %72, i64* %13
br label %33
73: ; preds = %33
%74 = load i32, i32* %14
ret i32 %74
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { i8* }
@.str = [5 x i8] c"%.*s\00"
define i32 @say_batch(i32* %0, i8* %1, i32* nocapture %2, i64 %3, i64 %4) {
%6 = alloca %struct.TYPE_7__*
%7 = alloca [1024 x i8]
%8 = bitcast %struct.TYPE_7__** %6 to i8*
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%10 = icmp sgt i64 %4, 0
br i1 %10, label %12, label %44
11: ; preds = %12
br i1 %10, label %19, label %44
12: ; preds = %5, %12
%13 = phi i64 [ %17, %12 ], [ 0, %5 ]
%14 = add nsw i64 %13, %3
%15 = tail call i32 @xcb_get_atom_name(i32* %0, i64 %14)
%16 = getelementptr inbounds i32, i32* %2, i64 %13
store i32 %15, i32* %16
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, %4
br i1 %18, label %11, label %12
19: ; preds = %11, %40
%20 = phi i64 [ %42, %40 ], [ 0, %11 ]
%21 = phi i32 [ %41, %40 ], [ 0, %11 ]
%22 = getelementptr inbounds i32, i32* %2, i64 %20
%23 = load i32, i32* %22
%24 = call %struct.TYPE_7__* @xcb_get_atom_name_reply(i32* %0, i32 %23, %struct.TYPE_7__** %6)
%25 = icmp eq %struct.TYPE_7__* %24, null
br i1 %25, label %35, label %26
26: ; preds = %19
%27 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %24, i64 0, i32 0
%28 = load i8*, i8** %27
%29 = call i32 @xcb_get_atom_name_name(%struct.TYPE_7__* %24)
%30 = call i32 @snprintf(i8* %9, i32 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %28, i32 %29)
%31 = add nsw i64 %20, %3
%32 = call i32 @printf(i8* %1, i64 %31, i8* %9)
%33 = call i32 @putchar(i8 signext 10)
%34 = call i32 @free(%struct.TYPE_7__* %24)
br label %35
35: ; preds = %26, %19
%36 = load %struct.TYPE_7__*, %struct.TYPE_7__** %6
%37 = icmp eq %struct.TYPE_7__* %36, null
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = call i32 @free(%struct.TYPE_7__* %36)
br label %40
40: ; preds = %38, %35
%41 = phi i32 [ 1, %38 ], [ %21, %35 ]
%42 = add nuw nsw i64 %20, 1
%43 = icmp eq i64 %42, %4
br i1 %43, label %44, label %19
44: ; preds = %40, %5, %11
%45 = phi i32 [ 0, %11 ], [ 0, %5 ], [ %41, %40 ]
ret i32 %45
}