#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 */
int /*<<< orphan*/ strcmp(char const *, char const *);
char *strdup(char const *);
char *getAttribute(const char *name, const char **atts) {
  int i;
  char *attribute;
  attribute = NULL;
  for (i = 0; atts[i]; i = i + 2) {
    if (!strcmp(atts[i], name)) {
      attribute = strdup(atts[i + 1]);
      break;
    }
  }
  return attribute;
}


x86 assembly (clang, -O0):
<getAttribute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11a2 <getAttribute+0x82>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    118f <getAttribute+0x6f>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x20(%rbp)
jmp    11a2 <getAttribute+0x82>
jmp    1194 <getAttribute+0x74>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    113f <getAttribute+0x1f>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getAttribute>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    (%rsi),%rdi
test   %rdi,%rdi
je     115a <getAttribute+0x3a>
mov    %rsi,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1162 <getAttribute+0x42>
mov    0x10(%r14,%rbx,8),%rdi
add    $0x2,%rbx
test   %rdi,%rdi
jne    1140 <getAttribute+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %ebx,%eax
shl    $0x3,%rax
or     $0x8,%rax
mov    (%r14,%rax,1),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <strdup@plt>

LLVM IR (-O0):
define i8* @getAttribute(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8** %1, i8*** %4
store i8* null, i8** %6
store i32 0, i32* %5
br label %7
7: ; preds = %32, %2
%8 = load i8**, i8*** %4
%9 = load i32, i32* %5
%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 %35
14: ; preds = %7
%15 = load i8**, i8*** %4
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = load i8*, i8** %3
%21 = call i32 @strcmp(i8* %19, i8* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %31, label %23
23: ; preds = %14
%24 = load i8**, i8*** %4
%25 = load i32, i32* %5
%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
%30 = call i8* @strdup(i8* %29)
store i8* %30, i8** %6
br label %35
31: ; preds = %14
br label %32
32: ; preds = %31
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 2
store i32 %34, i32* %5
br label %7
35: ; preds = %23, %7
%36 = load i8*, i8** %6
ret i8* %36
}

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