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

/* Variables and functions */
scalar_t__ strcmp(char const *, char const *);
char *get_attr_value(const char **atts, const char *name) {
  int i = 0;
  while (atts[i] != NULL) {
    if (strcmp(atts[i], name) == 0)
      return (char *)atts[i + 1];
    i += 2;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<get_attr_value>:
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     1181 <get_attr_value+0x71>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1173 <get_attr_value+0x63>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    1189 <get_attr_value+0x79>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <get_attr_value+0x17>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_attr_value>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    (%rdi),%rdi
test   %rdi,%rdi
je     114d <get_attr_value+0x3d>
mov    %rsi,%r12
xor    %r14d,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1152 <get_attr_value+0x42>
mov    0x10(%r15,%rbx,8),%rdi
add    $0x2,%rbx
test   %rdi,%rdi
jne    1130 <get_attr_value+0x20>
jmp    1160 <get_attr_value+0x50>
xor    %r14d,%r14d
jmp    1160 <get_attr_value+0x50>
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 i8* @get_attr_value(i8** %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %7
7: ; preds = %30, %2
%8 = load i8**, i8*** %4
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8*, i8** %8, i64 %10
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %33
14: ; preds = %7
%15 = load i8**, i8*** %4
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = load i8*, i8** %5
%21 = call i64 @strcmp(i8* %19, i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %14
%24 = load i8**, i8*** %4
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %24, i64 %27
%29 = load i8*, i8** %28
store i8* %29, i8** %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 i8* null, i8** %3
br label %34
34: ; preds = %33, %23
%35 = load i8*, i8** %3
ret i8* %35
}

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