#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_8__ TYPE_3__;
typedef struct TYPE_7__ TYPE_2__;
typedef struct TYPE_6__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  int extension;
};
struct TYPE_7__ {
  TYPE_1__ codes;
  struct TYPE_7__ *next;
};
typedef TYPE_2__ _XExtension;
struct TYPE_8__ {
  TYPE_2__ *ext_procs;
};
typedef TYPE_3__ Display;

/* Variables and functions */
_XExtension *XLookupExtension(register Display *dpy, register int extension) {
  register _XExtension *ext;
  for (ext = dpy->ext_procs; ext; ext = ext->next)
    if (ext->codes.extension == extension)
      return (ext);
  return (NULL);
}


x86 assembly (clang, -O0):
<XLookupExtension>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1153 <XLookupExtension+0x53>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cmp    -0x14(%rbp),%eax
jne    113d <XLookupExtension+0x3d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    115b <XLookupExtension+0x5b>
jmp    1142 <XLookupExtension+0x42>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1116 <XLookupExtension+0x16>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<XLookupExtension>:
mov    (%rdi),%rax
test   %rax,%rax
je     111d <XLookupExtension+0x1d>
nopl   0x0(%rax,%rax,1)
cmp    %esi,(%rax)
je     111f <XLookupExtension+0x1f>
mov    0x8(%rax),%rax
test   %rax,%rax
jne    1110 <XLookupExtension+0x10>
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.TYPE_7__ = type { %struct.TYPE_6__, %struct.TYPE_7__* }
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_8__ = type { %struct.TYPE_7__* }
define %struct.TYPE_7__* @XLookupExtension(%struct.TYPE_8__* %0, i32 %1) {
%3 = alloca %struct.TYPE_7__*
%4 = alloca %struct.TYPE_8__*
%5 = alloca i32
%6 = alloca %struct.TYPE_7__*
store %struct.TYPE_8__* %0, %struct.TYPE_8__** %4
store i32 %1, i32* %5
%7 = load %struct.TYPE_8__*, %struct.TYPE_8__** %4
%8 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %7, i32 0, i32 0
%9 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
store %struct.TYPE_7__* %9, %struct.TYPE_7__** %6
br label %10
10: ; preds = %23, %2
%11 = load %struct.TYPE_7__*, %struct.TYPE_7__** %6
%12 = icmp ne %struct.TYPE_7__* %11, null
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = load %struct.TYPE_7__*, %struct.TYPE_7__** %6
%15 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %14, i32 0, i32 0
%16 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = load i32, i32* %5
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = load %struct.TYPE_7__*, %struct.TYPE_7__** %6
store %struct.TYPE_7__* %21, %struct.TYPE_7__** %3
br label %28
22: ; preds = %13
br label %23
23: ; preds = %22
%24 = load %struct.TYPE_7__*, %struct.TYPE_7__** %6
%25 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %24, i32 0, i32 1
%26 = load %struct.TYPE_7__*, %struct.TYPE_7__** %25
store %struct.TYPE_7__* %26, %struct.TYPE_7__** %6
br label %10
27: ; preds = %10
store %struct.TYPE_7__* null, %struct.TYPE_7__** %3
br label %28
28: ; preds = %27, %20
%29 = load %struct.TYPE_7__*, %struct.TYPE_7__** %3
ret %struct.TYPE_7__* %29
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { %struct.TYPE_6__, %struct.TYPE_7__* }
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_8__ = type { %struct.TYPE_7__* }
define %struct.TYPE_7__* @XLookupExtension(%struct.TYPE_8__* nocapture %0, i32 %1) {
%3 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %0, i64 0, i32 0
%4 = load %struct.TYPE_7__*, %struct.TYPE_7__** %3
%5 = icmp eq %struct.TYPE_7__* %4, null
br i1 %5, label %15, label %6
6: ; preds = %2, %11
%7 = phi %struct.TYPE_7__* [ %13, %11 ], [ %4, %2 ]
%8 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %7, i64 0, i32 0, i32 0
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, %1
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %7, i64 0, i32 1
%13 = load %struct.TYPE_7__*, %struct.TYPE_7__** %12
%14 = icmp eq %struct.TYPE_7__* %13, null
br i1 %14, label %15, label %6
15: ; preds = %6, %11, %2
%16 = phi %struct.TYPE_7__* [ null, %2 ], [ null, %11 ], [ %7, %6 ]
ret %struct.TYPE_7__* %16
}