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

/* Variables and functions */
char **XListExtensions(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, char *);
int main(int argc, char const *argv[]) {
  Display *dpy = XOpenDisplay(NULL);
  int nextensions, i;
  char **p, **extensionList = XListExtensions(dpy, &nextensions);
  for (p = extensionList, i = 0; nextensions; i++, nextensions--, p++) {
    printf("Extension %d: %s\n", i + 1, *p);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1030 <XListExtensions@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11b9 <main+0x89>
mov    -0x20(%rbp),%esi
add    $0x1,%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%rdx
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
jmp    1173 <main+0x43>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1050 <XOpenDisplay@plt>
lea    0xc(%rsp),%rsi
mov    %rax,%rdi
call   1030 <XListExtensions@plt>
cmpl   $0x0,0xc(%rsp)
je     1179 <main+0x49>
mov    %rax,%r14
xor    %ebx,%ebx
lea    0xea0(%rip),%r15
mov    (%r14,%rbx,8),%rdx
add    $0x1,%rbx
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
addl   $0xffffffff,0xc(%rsp)
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Extension %d: %s\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 i8**
%10 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32* @XOpenDisplay(i32* null)
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = call i8** @XListExtensions(i32* %12, i32* %7)
store i8** %13, i8*** %10
%14 = load i8**, i8*** %10
store i8** %14, i8*** %9
store i32 0, i32* %8
br label %15
15: ; preds = %24, %2
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %31
18: ; preds = %15
%19 = load i32, i32* %8
%20 = add nsw i32 %19, 1
%21 = load i8**, i8*** %9
%22 = load i8*, i8** %21
%23 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %20, i8* %22)
br label %24
24: ; preds = %18
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
%27 = load i32, i32* %7
%28 = add nsw i32 %27, -1
store i32 %28, i32* %7
%29 = load i8**, i8*** %9
%30 = getelementptr inbounds i8*, i8** %29, i32 1
store i8** %30, i8*** %9
br label %15
31: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Extension %d: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i32* @XOpenDisplay(i32* null)
%5 = bitcast i32* %3 to i8*
%6 = call i8** @XListExtensions(i32* %4, i32* %3)
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %2, %9
%10 = phi i32 [ %12, %9 ], [ 0, %2 ]
%11 = phi i8** [ %17, %9 ], [ %6, %2 ]
%12 = add nuw nsw i32 %10, 1
%13 = load i8*, i8** %11
%14 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %13)
%15 = load i32, i32* %3
%16 = add nsw i32 %15, -1
store i32 %16, i32* %3
%17 = getelementptr inbounds i8*, i8** %11, i64 1
%18 = icmp eq i32 %16, 0
br i1 %18, label %19, label %9
19: ; preds = %9, %2
ret i32 0
}