#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_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ xcb_setup_t;
struct TYPE_5__ {
  int width_in_pixels;
  int height_in_pixels;
};
typedef TYPE_1__ xcb_screen_t;
struct TYPE_6__ {
  TYPE_1__ *data;
};
typedef TYPE_2__ xcb_screen_iterator_t;
typedef int /*<<< orphan*/ xcb_connection_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *xcb_connect(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ xcb_disconnect(int /*<<< orphan*/ *);
int /*<<< orphan*/ *xcb_get_setup(int /*<<< orphan*/ *);
int /*<<< orphan*/ xcb_screen_next(TYPE_2__ *);
TYPE_2__ xcb_setup_roots_iterator(int /*<<< orphan*/ const *);
int main(int argc, char **argv) {
  int screen_num, i;
  xcb_connection_t *xcb_conn;
  const xcb_setup_t *xcb_setup;
  xcb_screen_iterator_t xcb_screen_iter;
  xcb_screen_t *xcb_screen;
  xcb_conn = xcb_connect(NULL, &screen_num);
  xcb_setup = xcb_get_setup(xcb_conn);
  xcb_screen_iter = xcb_setup_roots_iterator(xcb_setup);
  for (i = 0; i < screen_num; i++)
    xcb_screen_next(&xcb_screen_iter);
  xcb_screen = xcb_screen_iter.data;
  printf("screen info\n");
  printf("  width........: %d\n", xcb_screen->width_in_pixels);
  printf("  height.......: %d\n", xcb_screen->height_in_pixels);
  xcb_disconnect(xcb_conn);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    -0x14(%rbp),%rsi
call   1030 <xcb_connect@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <xcb_get_setup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <xcb_setup_roots_iterator@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d3 <main+0x73>
lea    -0x30(%rbp),%rdi
call   1050 <xcb_screen_next@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b0 <main+0x50>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1070 <xcb_disconnect@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
lea    0x4(%rsp),%rsi
xor    %edi,%edi
call   1040 <xcb_connect@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1090 <xcb_get_setup@plt>
mov    %rax,%rdi
call   1070 <xcb_setup_roots_iterator@plt>
mov    %rax,0x8(%rsp)
cmpl   $0x0,0x4(%rsp)
jle    11c8 <main+0x58>
lea    0x8(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1060 <xcb_screen_next@plt>
add    $0x1,%ebx
cmp    0x4(%rsp),%ebx
jl     11b0 <main+0x40>
mov    0x8(%rsp),%r15
jmp    11cb <main+0x5b>
mov    %rax,%r15
lea    0xe58(%rip),%rdi
call   1030 <puts@plt>
mov    (%r15),%esi
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%r15),%esi
lea    0xe22(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1080 <xcb_disconnect@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i32, i32 }
@.str = [13 x i8] c"screen info\0A\00"
@.str.1 = [21 x i8] c" width........: %d\0A\00"
@.str.2 = [21 x i8] c" height.......: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca %struct.TYPE_6__
%11 = alloca %struct.TYPE_5__*
%12 = alloca %struct.TYPE_6__
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32* @xcb_connect(i32* null, i32* %6)
store i32* %13, i32** %8
%14 = load i32*, i32** %8
%15 = call i32* @xcb_get_setup(i32* %14)
store i32* %15, i32** %9
%16 = load i32*, i32** %9
%17 = call %struct.TYPE_5__* @xcb_setup_roots_iterator(i32* %16)
%18 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %12, i32 0, i32 0
store %struct.TYPE_5__* %17, %struct.TYPE_5__** %18
%19 = bitcast %struct.TYPE_6__* %10 to i8*
%20 = bitcast %struct.TYPE_6__* %12 to i8*
store i32 0, i32* %7
br label %21
21: ; preds = %27, %2
%22 = load i32, i32* %7
%23 = load i32, i32* %6
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = call i32 @xcb_screen_next(%struct.TYPE_6__* %10)
br label %27
27: ; preds = %25
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %21
30: ; preds = %21
%31 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %10, i32 0, i32 0
%32 = load %struct.TYPE_5__*, %struct.TYPE_5__** %31
store %struct.TYPE_5__* %32, %struct.TYPE_5__** %11
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%34 = load %struct.TYPE_5__*, %struct.TYPE_5__** %11
%35 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %34, i32 0, i32 0
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = load %struct.TYPE_5__*, %struct.TYPE_5__** %11
%39 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %38, i32 0, i32 1
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = load i32*, i32** %8
%43 = call i32 @xcb_disconnect(i32* %42)
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i32, i32 }
@.str.1 = [21 x i8] c" width........: %d\0A\00"
@.str.2 = [21 x i8] c" height.......: %d\0A\00"
@str = [12 x i8] c"screen info\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_6__
%5 = bitcast i32* %3 to i8*
%6 = bitcast %struct.TYPE_6__* %4 to i8*
%7 = call i32* @xcb_connect(i32* null, i32* %3)
%8 = call i32* @xcb_get_setup(i32* %7)
%9 = call %struct.TYPE_5__* @xcb_setup_roots_iterator(i32* %8)
%10 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %4, i64 0, i32 0
store %struct.TYPE_5__* %9, %struct.TYPE_5__** %10
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %2, %13
%14 = phi i32 [ %16, %13 ], [ 0, %2 ]
%15 = call i32 @xcb_screen_next(%struct.TYPE_6__* %4)
%16 = add nuw nsw i32 %14, 1
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %13, label %19
19: ; preds = %13
%20 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
br label %21
21: ; preds = %19, %2
%22 = phi %struct.TYPE_5__* [ %20, %19 ], [ %9, %2 ]
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%24 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %22, i64 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %22, i64 0, i32 1
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = call i32 @xcb_disconnect(i32* %7)
ret i32 0
}