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

/* Variables and functions */
int /*<<< orphan*/ strcmp(int /*<<< orphan*/ const *, char const *);
const XML_Char *_trl_findAttr(const XML_Char **atts, const char *key) {
  int i = 0;
  while (atts[i] != NULL) {
    if (!strcmp(atts[i], key))
      return atts[i + 1];
    i += 2;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<_trl_findAttr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1180 <_trl_findAttr+0x70>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1172 <_trl_findAttr+0x62>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    1188 <_trl_findAttr+0x78>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <_trl_findAttr+0x17>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_trl_findAttr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    (%rdi),%rdi
test   %rdi,%rdi
je     114c <_trl_findAttr+0x3c>
mov    %rsi,%r12
xor    %r14d,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1151 <_trl_findAttr+0x41>
mov    0x10(%r15,%rbx,8),%rdi
add    $0x2,%rbx
test   %rdi,%rdi
jne    1130 <_trl_findAttr+0x20>
jmp    115f <_trl_findAttr+0x4f>
xor    %r14d,%r14d
jmp    115f <_trl_findAttr+0x4f>
mov    %ebx,%eax
shl    $0x3,%rax
or     $0x8,%rax
mov    (%r15,%rax,1),%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32* @_trl_findAttr(i32** %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i32**
%5 = alloca i8*
%6 = alloca i32
store i32** %0, i32*** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %7
7: ; preds = %30, %2
%8 = load i32**, i32*** %4
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32*, i32** %8, i64 %10
%12 = load i32*, i32** %11
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %33
14: ; preds = %7
%15 = load i32**, i32*** %4
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32*, i32** %15, i64 %17
%19 = load i32*, i32** %18
%20 = load i8*, i8** %5
%21 = call i32 @strcmp(i32* %19, i8* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %30, label %23
23: ; preds = %14
%24 = load i32**, i32*** %4
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32*, i32** %24, i64 %27
%29 = load i32*, i32** %28
store i32* %29, i32** %3
br label %34
30: ; preds = %14
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 2
store i32 %32, i32* %6
br label %7
33: ; preds = %7
store i32* null, i32** %3
br label %34
34: ; preds = %33, %23
%35 = load i32*, i32** %3
ret i32* %35
}

LLVM IR (-O2):
define i32* @_trl_findAttr(i32** nocapture %0, i8* %1) {
%3 = load i32*, i32** %0
%4 = icmp eq i32* %3, null
br i1 %4, label %20, label %5
5: ; preds = %2, %15
%6 = phi i64 [ %16, %15 ], [ 0, %2 ]
%7 = phi i32* [ %18, %15 ], [ %3, %2 ]
%8 = tail call i32 @strcmp(i32* %7, i8* %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = and i64 %6, 4294967294
%12 = or i64 %11, 1
%13 = getelementptr inbounds i32*, i32** %0, i64 %12
%14 = load i32*, i32** %13
br label %20
15: ; preds = %5
%16 = add nuw i64 %6, 2
%17 = getelementptr inbounds i32*, i32** %0, i64 %16
%18 = load i32*, i32** %17
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %5
20: ; preds = %15, %2, %10
%21 = phi i32* [ %14, %10 ], [ null, %2 ], [ null, %15 ]
ret i32* %21
}