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

/* Type definitions */
struct TYPE_3__ {
  int screen;
  int level;
  scalar_t__ core_visual_id;
  int /*<<< orphan*/ num_colormap_conflicts;
  int /*<<< orphan*/ max_hw_colormaps;
  int /*<<< orphan*/ min_hw_colormaps;
  int /*<<< orphan*/ transparency_value;
  int /*<<< orphan*/ transparency_type;
};
typedef TYPE_1__ ExtendedVisualInfo;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(char *);
int /*<<< orphan*/ XeviGetVisualInfo(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                     int /*<<< orphan*/, TYPE_1__ **, int *);
int /*<<< orphan*/ XeviQueryVersion(int /*<<< orphan*/ *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  Display *display = NULL;
  int major_version, minor_version;
  ExtendedVisualInfo *evi;
  int count;
  int i;
  if (argc == 2) {
    if (!(display = XOpenDisplay(argv[1]))) {
      printf("Cannot open display %s\n", argv[1]);
      return -1;
    }
  } else {
    printf("Usage: %s display\n", argv[0]);
    return -1;
  }
  if (!display && !(display = XOpenDisplay(NULL))) {
    printf("Cannot open default display\n");
    return -1;
  }
  if (!XeviQueryVersion(display, &major_version, &minor_version)) {
    printf("EVI extension not present\n");
    return -1;
  }
  printf("EVI Extension version: %d.%d\n", major_version, minor_version);
  XeviGetVisualInfo(display, NULL, 0, &evi, &count);
  for (i = 0; i < count; i++) {
    printf("%02d vid=0x%02lx screen=%d level=%d type=%u value=%u"
           " min=%u max=%u conflicts=%u\n",
           i, (long unsigned)evi[i].core_visual_id, evi[i].screen, evi[i].level,
           evi[i].transparency_type, evi[i].transparency_value,
           evi[i].min_hw_colormaps, evi[i].max_hw_colormaps,
           evi[i].num_colormap_conflicts);
  }
  XCloseDisplay(display);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
movl   $0x0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x10(%rbp)
jne    11bb <main+0x6b>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <XOpenDisplay@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11b6 <main+0x66>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    135e <main+0x20e>
jmp    11dc <main+0x8c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    135e <main+0x20e>
cmpq   $0x0,-0x20(%rbp)
jne    1218 <main+0xc8>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <XOpenDisplay@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1218 <main+0xc8>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    135e <main+0x20e>
mov    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <XeviQueryVersion@plt>
cmp    $0x0,%eax
jne    124c <main+0xfc>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    135e <main+0x20e>
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
lea    -0x30(%rbp),%rcx
lea    -0x34(%rbp),%r8
call   1060 <XeviGetVisualInfo@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    134e <main+0x1fe>
mov    -0x38(%rbp),%esi
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rdx
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rdi
imul   $0x28,%rdi,%rdi
add    %rdi,%rax
mov    0x4(%rax),%r8d
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rdi
imul   $0x28,%rdi,%rdi
add    %rdi,%rax
mov    0x20(%rax),%r9d
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rdi
imul   $0x28,%rdi,%rdi
add    %rdi,%rax
mov    0x1c(%rax),%ebx
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rdi
imul   $0x28,%rdi,%rdi
add    %rdi,%rax
mov    0x18(%rax),%r11d
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rdi
imul   $0x28,%rdi,%rdi
add    %rdi,%rax
mov    0x14(%rax),%r10d
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rdi
imul   $0x28,%rdi,%rdi
add    %rdi,%rax
mov    0x10(%rax),%eax
lea    0xd59(%rip),%rdi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    127e <main+0x12e>
mov    -0x20(%rbp),%rdi
call   1070 <XCloseDisplay@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1260 <main+0x100>
mov    0x8(%rbx),%rdi
call   1050 <XOpenDisplay@plt>
test   %rax,%rax
je     126c <main+0x10c>
mov    %rax,%rbp
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
call   1060 <XeviQueryVersion@plt>
test   %eax,%eax
je     1296 <main+0x136>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
lea    0xe73(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x20(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %rbp,0x18(%rsp)
mov    %rbp,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <XeviGetVisualInfo@plt>
cmpl   $0x0,0xc(%rsp)
jle    1254 <main+0xf4>
mov    $0x20,%ebx
lea    0xe59(%rip),%r12
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x20(%rsp),%rax
mov    -0x18(%rax,%rbx,1),%rdx
mov    -0x20(%rax,%rbx,1),%ecx
mov    -0x1c(%rax,%rbx,1),%r8d
mov    (%rax,%rbx,1),%r9d
mov    -0x4(%rax,%rbx,1),%r10d
mov    -0x8(%rax,%rbx,1),%r11d
mov    -0xc(%rax,%rbx,1),%ebp
mov    -0x10(%rax,%rbx,1),%r14d
mov    %r12,%rdi
mov    %r13d,%esi
xor    %eax,%eax
push   %r14
push   %rbp
push   %r11
push   %r10
call   1040 <printf@plt>
add    $0x20,%rsp
add    $0x1,%r13
movslq 0xc(%rsp),%rax
add    $0x28,%rbx
cmp    %rax,%r13
jl     1200 <main+0xa0>
mov    0x18(%rsp),%rdi
call   1080 <XCloseDisplay@plt>
jmp    1284 <main+0x124>
mov    (%rbx),%rsi
lea    0xdae(%rip),%rdi
jmp    1277 <main+0x117>
mov    0x8(%rbx),%rsi
lea    0xd89(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdfd(%rip),%rdi
call   1030 <puts@plt>
jmp    127e <main+0x11e>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32, i64, i32, i32, i32, i32, i32 }
@.str = [24 x i8] c"Cannot open display %s\0A\00"
@.str.1 = [19 x i8] c"Usage: %s display\0A\00"
@.str.2 = [29 x i8] c"Cannot open default display\0A\00"
@.str.3 = [27 x i8] c"EVI extension not present\0A\00"
@.str.4 = [30 x i8] c"EVI Extension version: %d.%d\0A\00"
@.str.5 = [81 x i8] c"%02d vid=0x%02lx screen=%d level=%d type=%u value=%u min=%u max=%u conflicts=%u\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 %struct.TYPE_3__*
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %26
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @XOpenDisplay(i8* %17)
store i32* %18, i32** %6
%19 = icmp ne i32* %18, null
br i1 %19, label %25, label %20
20: ; preds = %14
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %23)
store i32 -1, i32* %3
br label %112
25: ; preds = %14
br label %31
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %29)
store i32 -1, i32* %3
br label %112
31: ; preds = %25
%32 = load i32*, i32** %6
%33 = icmp ne i32* %32, null
br i1 %33, label %39, label %34
34: ; preds = %31
%35 = call i32* @XOpenDisplay(i8* null)
store i32* %35, i32** %6
%36 = icmp ne i32* %35, null
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %112
39: ; preds = %34, %31
%40 = load i32*, i32** %6
%41 = call i32 @XeviQueryVersion(i32* %40, i32* %7, i32* %8)
%42 = icmp ne i32 %41, 0
br i1 %42, label %45, label %43
43: ; preds = %39
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %112
45: ; preds = %39
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %46, i32 %47)
%49 = load i32*, i32** %6
%50 = call i32 @XeviGetVisualInfo(i32* %49, i32* null, i32 0, %struct.TYPE_3__** %9, i32* %10)
store i32 0, i32* %11
br label %51
51: ; preds = %106, %45
%52 = load i32, i32* %11
%53 = load i32, i32* %10
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %109
55: ; preds = %51
%56 = load i32, i32* %11
%57 = load %struct.TYPE_3__*, %struct.TYPE_3__** %9
%58 = load i32, i32* %11
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %57, i64 %59
%61 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %60, i32 0, i32 2
%62 = load i64, i64* %61
%63 = load %struct.TYPE_3__*, %struct.TYPE_3__** %9
%64 = load i32, i32* %11
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %63, i64 %65
%67 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %66, i32 0, i32 0
%68 = load i32, i32* %67
%69 = load %struct.TYPE_3__*, %struct.TYPE_3__** %9
%70 = load i32, i32* %11
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %69, i64 %71
%73 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %72, i32 0, i32 1
%74 = load i32, i32* %73
%75 = load %struct.TYPE_3__*, %struct.TYPE_3__** %9
%76 = load i32, i32* %11
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %75, i64 %77
%79 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %78, i32 0, i32 7
%80 = load i32, i32* %79
%81 = load %struct.TYPE_3__*, %struct.TYPE_3__** %9
%82 = load i32, i32* %11
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %81, i64 %83
%85 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %84, i32 0, i32 6
%86 = load i32, i32* %85
%87 = load %struct.TYPE_3__*, %struct.TYPE_3__** %9
%88 = load i32, i32* %11
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %87, i64 %89
%91 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %90, i32 0, i32 5
%92 = load i32, i32* %91
%93 = load %struct.TYPE_3__*, %struct.TYPE_3__** %9
%94 = load i32, i32* %11
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %93, i64 %95
%97 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %96, i32 0, i32 4
%98 = load i32, i32* %97
%99 = load %struct.TYPE_3__*, %struct.TYPE_3__** %9
%100 = load i32, i32* %11
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %99, i64 %101
%103 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %102, i32 0, i32 3
%104 = load i32, i32* %103
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.5, i64 0, i64 0), i32 %56, i64 %62, i32 %68, i32 %74, i32 %80, i32 %86, i32 %92, i32 %98, i32 %104)
br label %106
106: ; preds = %55
%107 = load i32, i32* %11
%108 = add nsw i32 %107, 1
store i32 %108, i32* %11
br label %51
109: ; preds = %51
%110 = load i32*, i32** %6
%111 = call i32 @XCloseDisplay(i32* %110)
store i32 0, i32* %3
br label %112
112: ; preds = %109, %43, %37, %26, %20
%113 = load i32, i32* %3
ret i32 %113
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32, i64, i32, i32, i32, i32, i32 }
@.str = [24 x i8] c"Cannot open display %s\0A\00"
@.str.1 = [19 x i8] c"Usage: %s display\0A\00"
@.str.4 = [30 x i8] c"EVI Extension version: %d.%d\0A\00"
@.str.5 = [81 x i8] c"%02d vid=0x%02lx screen=%d level=%d type=%u value=%u min=%u max=%u conflicts=%u\0A\00"
@str = [26 x i8] c"EVI extension not present\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.TYPE_3__*
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast %struct.TYPE_3__** %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = icmp eq i32 %0, 2
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @XOpenDisplay(i8* %14)
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %23
17: ; preds = %12
%18 = load i8*, i8** %13
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %62
20: ; preds = %2
%21 = load i8*, i8** %1
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %62
23: ; preds = %12
%24 = call i32 @XeviQueryVersion(i32* %15, i32* %3, i32* %4)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %62
28: ; preds = %23
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %29, i32 %30)
%32 = call i32 @XeviGetVisualInfo(i32* %15, i32* null, i32 0, %struct.TYPE_3__** %5, i32* %6)
%33 = load i32, i32* %6
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %60
35: ; preds = %28, %35
%36 = phi i64 [ %56, %35 ], [ 0, %28 ]
%37 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%38 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i64 %36, i32 2
%39 = load i64, i64* %38
%40 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i64 %36, i32 0
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i64 %36, i32 1
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i64 %36, i32 7
%45 = load i32, i32* %44
%46 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i64 %36, i32 6
%47 = load i32, i32* %46
%48 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i64 %36, i32 5
%49 = load i32, i32* %48
%50 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i64 %36, i32 4
%51 = load i32, i32* %50
%52 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i64 %36, i32 3
%53 = load i32, i32* %52
%54 = trunc i64 %36 to i32
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.5, i64 0, i64 0), i32 %54, i64 %39, i32 %41, i32 %43, i32 %45, i32 %47, i32 %49, i32 %51, i32 %53)
%56 = add nuw nsw i64 %36, 1
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = icmp slt i64 %56, %58
br i1 %59, label %35, label %60
60: ; preds = %35, %28
%61 = call i32 @XCloseDisplay(i32* %15)
br label %62
62: ; preds = %60, %26, %20, %17
%63 = phi i32 [ 0, %60 ], [ -1, %26 ], [ -1, %17 ], [ -1, %20 ]
ret i32 %63
}