#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 */

/* Type definitions */
typedef int /*<<< orphan*/ Window;
typedef scalar_t__ GLboolean;
typedef int /*<<< orphan*/ GLXContext;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ GL_EXTENSIONS;
scalar_t__ GL_FALSE;
int /*<<< orphan*/ GL_RENDERER;
scalar_t__ GL_TRUE;
int /*<<< orphan*/ GL_VENDOR;
int /*<<< orphan*/ GL_VERSION;
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XDestroyWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ XMapWindow(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *XOpenDisplay(char *);
int /*<<< orphan*/ event_loop(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ glGetString(int /*<<< orphan*/);
int /*<<< orphan*/ glXDestroyContext(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ glXMakeCurrent(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ init();
int /*<<< orphan*/ make_window(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
                               int /*<<< orphan*/, int, int,
                               int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ reshape(int, int);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  Display *dpy;
  Window win;
  GLXContext ctx;
  char *dpyName = NULL;
  GLboolean printInfo = GL_FALSE;
  int i;
  for (i = 1; i < argc; i++) {
    if (strcmp(argv[i], "-display") == 0) {
      dpyName = argv[i + 1];
      i++;
    } else if (strcmp(argv[i], "-info") == 0) {
      printInfo = GL_TRUE;
    }
  }
  dpy = XOpenDisplay(dpyName);
  if (!dpy) {
    printf("Error: couldn't open display %s\n", dpyName);
    return -1;
  }
  make_window(dpy, "glxgears", 0, 0, 300, 300, &win, &ctx);
  XMapWindow(dpy, win);
  glXMakeCurrent(dpy, win, ctx);
  reshape(300, 300);
  if (printInfo) {
    printf("GL_RENDERER   = %s\n", (char *)glGetString(GL_RENDERER));
    printf("GL_VERSION    = %s\n", (char *)glGetString(GL_VERSION));
    printf("GL_VENDOR     = %s\n", (char *)glGetString(GL_VENDOR));
    printf("GL_EXTENSIONS = %s\n", (char *)glGetString(GL_EXTENSIONS));
  }
  init();
  event_loop(dpy, win);
  glXDestroyContext(dpy, ctx);
  XDestroyWindow(dpy, win);
  XCloseDisplay(dpy);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
mov    0x2df3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    129c <main+0xcc>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdde(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1254 <main+0x84>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1289 <main+0xb9>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xda2(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1284 <main+0xb4>
mov    0x2d43(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1289 <main+0xb9>
jmp    128e <main+0xbe>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1203 <main+0x33>
mov    -0x28(%rbp),%rdi
call   1080 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12d0 <main+0x100>
mov    -0x28(%rbp),%rsi
lea    0xd50(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13df <main+0x20f>
mov    -0x18(%rbp),%rdi
lea    0xd55(%rip),%rsi
xor    %ecx,%ecx
mov    $0x12c,%r9d
lea    -0x1c(%rbp),%r10
lea    -0x20(%rbp),%rax
mov    %ecx,%edx
mov    %r9d,%r8d
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   10d0 <make_window@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10e0 <XMapWindow@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1050 <glXMakeCurrent@plt>
mov    $0x12c,%esi
mov    %esi,%edi
call   10c0 <reshape@plt>
cmpq   $0x0,-0x30(%rbp)
je     13a4 <main+0x1d4>
mov    0x2c91(%rip),%rax
mov    (%rax),%edi
call   10a0 <glGetString@plt>
mov    %rax,%rsi
lea    0xcf1(%rip),%rdi
call   1040 <printf@plt>
mov    0x2c7c(%rip),%rax
mov    (%rax),%edi
call   10a0 <glGetString@plt>
mov    %rax,%rsi
lea    0xce8(%rip),%rdi
call   1040 <printf@plt>
mov    0x2c6f(%rip),%rax
mov    (%rax),%edi
call   10a0 <glGetString@plt>
mov    %rax,%rsi
lea    0xcdf(%rip),%rdi
call   1040 <printf@plt>
mov    0x2c2a(%rip),%rax
mov    (%rax),%edi
call   10a0 <glGetString@plt>
mov    %rax,%rsi
lea    0xcd6(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1090 <init@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10b0 <event_loop@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <glXDestroyContext@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <XDestroyWindow@plt>
mov    -0x18(%rbp),%rdi
call   10f0 <XCloseDisplay@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e03(%rip),%rax
mov    (%rax),%rax
cmp    $0x2,%edi
mov    %rax,0x10(%rsp)
jl     125d <main+0x8d>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r13d
xor    %r14d,%r14d
lea    0xdf9(%rip),%r15
jmp    1223 <main+0x53>
nopl   0x0(%rax)
lea    0x1(%r12),%r13d
mov    0x8(%rbx,%r12,8),%r14
add    $0x1,%r13d
cmp    %ebp,%r13d
jge    1260 <main+0x90>
movslq %r13d,%r12
mov    (%rbx,%r12,8),%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1210 <main+0x40>
mov    (%rbx,%r12,8),%rdi
lea    0xdc7(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    121a <main+0x4a>
mov    0x2d6d(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
jmp    121a <main+0x4a>
xor    %r14d,%r14d
mov    %r14,%rdi
call   1080 <XOpenDisplay@plt>
test   %rax,%rax
je     1382 <main+0x1b2>
mov    %rax,%rbx
lea    0xc(%rsp),%rax
lea    0x8(%rsp),%rbp
lea    0xdab(%rip),%rsi
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x12c,%r8d
mov    $0x12c,%r9d
push   %rax
push   %rbp
call   10d0 <make_window@plt>
add    $0x10,%rsp
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   10e0 <XMapWindow@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
call   1050 <glXMakeCurrent@plt>
mov    $0x12c,%edi
mov    $0x12c,%esi
call   10c0 <reshape@plt>
cmpq   $0x0,0x10(%rsp)
je     134d <main+0x17d>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
call   10a0 <glGetString@plt>
lea    0xd4b(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
call   10a0 <glGetString@plt>
lea    0xd42(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
call   10a0 <glGetString@plt>
lea    0xd39(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
call   10a0 <glGetString@plt>
lea    0xd30(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
call   1090 <init@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   10b0 <event_loop@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <glXDestroyContext@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1060 <XDestroyWindow@plt>
mov    %rbx,%rdi
call   10f0 <XCloseDisplay@plt>
jmp    1397 <main+0x1c7>
lea    0xc86(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GL_FALSE = global i64 0
@.str = [9 x i8] c"-display\00"
@.str.1 = [6 x i8] c"-info\00"
@GL_TRUE = global i64 0
@.str.2 = [33 x i8] c"Error: couldn't open display %s\0A\00"
@.str.3 = [9 x i8] c"glxgears\00"
@.str.4 = [20 x i8] c"GL_RENDERER = %s\0A\00"
@GL_RENDERER = global i32 0
@.str.5 = [20 x i8] c"GL_VERSION = %s\0A\00"
@GL_VERSION = global i32 0
@.str.6 = [20 x i8] c"GL_VENDOR = %s\0A\00"
@GL_VENDOR = global i32 0
@.str.7 = [20 x i8] c"GL_EXTENSIONS = %s\0A\00"
@GL_EXTENSIONS = global i32 0
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 i8*
%10 = alloca i64
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %9
%12 = load i64, i64* @GL_FALSE
store i64 %12, i64* %10
store i32 1, i32* %11
br label %13
13: ; preds = %46, %2
%14 = load i32, i32* %11
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %49
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %17
%26 = load i8**, i8*** %5
%27 = load i32, i32* %11
%28 = add nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %26, i64 %29
%31 = load i8*, i8** %30
store i8* %31, i8** %9
%32 = load i32, i32* %11
%33 = add nsw i32 %32, 1
store i32 %33, i32* %11
br label %45
34: ; preds = %17
%35 = load i8**, i8*** %5
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %34
%43 = load i64, i64* @GL_TRUE
store i64 %43, i64* %10
br label %44
44: ; preds = %42, %34
br label %45
45: ; preds = %44, %25
br label %46
46: ; preds = %45
%47 = load i32, i32* %11
%48 = add nsw i32 %47, 1
store i32 %48, i32* %11
br label %13
49: ; preds = %13
%50 = load i8*, i8** %9
%51 = call i32* @XOpenDisplay(i8* %50)
store i32* %51, i32** %6
%52 = load i32*, i32** %6
%53 = icmp ne i32* %52, null
br i1 %53, label %57, label %54
54: ; preds = %49
%55 = load i8*, i8** %9
%56 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %55)
store i32 -1, i32* %3
br label %100
57: ; preds = %49
%58 = load i32*, i32** %6
%59 = call i32 @make_window(i32* %58, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0, i32 300, i32 300, i32* %7, i32* %8)
%60 = load i32*, i32** %6
%61 = load i32, i32* %7
%62 = call i32 @XMapWindow(i32* %60, i32 %61)
%63 = load i32*, i32** %6
%64 = load i32, i32* %7
%65 = load i32, i32* %8
%66 = call i32 @glXMakeCurrent(i32* %63, i32 %64, i32 %65)
%67 = call i32 @reshape(i32 300, i32 300)
%68 = load i64, i64* %10
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %87
70: ; preds = %57
%71 = load i32, i32* @GL_RENDERER
%72 = call i64 @glGetString(i32 %71)
%73 = inttoptr i64 %72 to i8*
%74 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %73)
%75 = load i32, i32* @GL_VERSION
%76 = call i64 @glGetString(i32 %75)
%77 = inttoptr i64 %76 to i8*
%78 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %77)
%79 = load i32, i32* @GL_VENDOR
%80 = call i64 @glGetString(i32 %79)
%81 = inttoptr i64 %80 to i8*
%82 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %81)
%83 = load i32, i32* @GL_EXTENSIONS
%84 = call i64 @glGetString(i32 %83)
%85 = inttoptr i64 %84 to i8*
%86 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %85)
br label %87
87: ; preds = %70, %57
%88 = call i32 (...) @init()
%89 = load i32*, i32** %6
%90 = load i32, i32* %7
%91 = call i32 @event_loop(i32* %89, i32 %90)
%92 = load i32*, i32** %6
%93 = load i32, i32* %8
%94 = call i32 @glXDestroyContext(i32* %92, i32 %93)
%95 = load i32*, i32** %6
%96 = load i32, i32* %7
%97 = call i32 @XDestroyWindow(i32* %95, i32 %96)
%98 = load i32*, i32** %6
%99 = call i32 @XCloseDisplay(i32* %98)
store i32 0, i32* %3
br label %100
100: ; preds = %87, %54
%101 = load i32, i32* %3
ret i32 %101
}

LLVM IR (-O2):
@GL_FALSE = global i64 0
@.str = [9 x i8] c"-display\00"
@.str.1 = [6 x i8] c"-info\00"
@GL_TRUE = global i64 0
@.str.2 = [33 x i8] c"Error: couldn't open display %s\0A\00"
@.str.3 = [9 x i8] c"glxgears\00"
@.str.4 = [20 x i8] c"GL_RENDERER = %s\0A\00"
@GL_RENDERER = global i32 0
@.str.5 = [20 x i8] c"GL_VERSION = %s\0A\00"
@GL_VERSION = global i32 0
@.str.6 = [20 x i8] c"GL_VENDOR = %s\0A\00"
@GL_VENDOR = global i32 0
@.str.7 = [20 x i8] c"GL_EXTENSIONS = %s\0A\00"
@GL_EXTENSIONS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = load i64, i64* @GL_FALSE
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %35
9: ; preds = %2, %29
%10 = phi i32 [ %33, %29 ], [ 1, %2 ]
%11 = phi i64 [ %31, %29 ], [ %7, %2 ]
%12 = phi i8* [ %30, %29 ], [ null, %2 ]
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %9
%19 = add nsw i32 %10, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
br label %29
23: ; preds = %9
%24 = load i8*, i8** %14
%25 = tail call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
%27 = load i64, i64* @GL_TRUE
%28 = select i1 %26, i64 %27, i64 %11
br label %29
29: ; preds = %23, %18
%30 = phi i8* [ %22, %18 ], [ %12, %23 ]
%31 = phi i64 [ %11, %18 ], [ %28, %23 ]
%32 = phi i32 [ %19, %18 ], [ %10, %23 ]
%33 = add nsw i32 %32, 1
%34 = icmp slt i32 %33, %0
br i1 %34, label %9, label %35
35: ; preds = %29, %2
%36 = phi i8* [ null, %2 ], [ %30, %29 ]
%37 = phi i64 [ %7, %2 ], [ %31, %29 ]
%38 = tail call i32* @XOpenDisplay(i8* %36)
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %36)
br label %77
42: ; preds = %35
%43 = call i32 @make_window(i32* %38, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0, i32 300, i32 300, i32* %3, i32* %4)
%44 = load i32, i32* %3
%45 = call i32 @XMapWindow(i32* %38, i32 %44)
%46 = load i32, i32* %3
%47 = load i32, i32* %4
%48 = call i32 @glXMakeCurrent(i32* %38, i32 %46, i32 %47)
%49 = call i32 @reshape(i32 300, i32 300)
%50 = icmp eq i64 %37, 0
br i1 %50, label %68, label %51
51: ; preds = %42
%52 = load i32, i32* @GL_RENDERER
%53 = call i64 @glGetString(i32 %52)
%54 = inttoptr i64 %53 to i8*
%55 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %54)
%56 = load i32, i32* @GL_VERSION
%57 = call i64 @glGetString(i32 %56)
%58 = inttoptr i64 %57 to i8*
%59 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %58)
%60 = load i32, i32* @GL_VENDOR
%61 = call i64 @glGetString(i32 %60)
%62 = inttoptr i64 %61 to i8*
%63 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %62)
%64 = load i32, i32* @GL_EXTENSIONS
%65 = call i64 @glGetString(i32 %64)
%66 = inttoptr i64 %65 to i8*
%67 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %66)
br label %68
68: ; preds = %51, %42
%69 = call i32 (...) @init()
%70 = load i32, i32* %3
%71 = call i32 @event_loop(i32* %38, i32 %70)
%72 = load i32, i32* %4
%73 = call i32 @glXDestroyContext(i32* %38, i32 %72)
%74 = load i32, i32* %3
%75 = call i32 @XDestroyWindow(i32* %38, i32 %74)
%76 = call i32 @XCloseDisplay(i32* %38)
br label %77
77: ; preds = %68, %40
%78 = phi i32 [ 0, %68 ], [ -1, %40 ]
ret i32 %78
}