#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 *, char const *);
char **string_pack_find(char **packed, const char *str) {
  char **ptr = packed;
  while (*ptr != NULL) {
    if ((strcmp(*ptr, str) == 0))
      return ptr;
    ++ptr;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<string_pack_find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     116e <string_pack_find+0x5e>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    115d <string_pack_find+0x4d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1176 <string_pack_find+0x66>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <string_pack_find+0x18>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_pack_find>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     114a <string_pack_find+0x3a>
mov    %rsi,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     114c <string_pack_find+0x3c>
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1130 <string_pack_find+0x20>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8** @string_pack_find(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8**
store i8** %0, i8*** %4
store i8* %1, i8** %5
%7 = load i8**, i8*** %4
store i8** %7, i8*** %6
br label %8
8: ; preds = %20, %2
%9 = load i8**, i8*** %6
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load i8**, i8*** %6
%14 = load i8*, i8** %13
%15 = load i8*, i8** %5
%16 = call i64 @strcmp(i8* %14, i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = load i8**, i8*** %6
store i8** %19, i8*** %3
br label %24
20: ; preds = %12
%21 = load i8**, i8*** %6
%22 = getelementptr inbounds i8*, i8** %21, i32 1
store i8** %22, i8*** %6
br label %8
23: ; preds = %8
store i8** null, i8*** %3
br label %24
24: ; preds = %23, %18
%25 = load i8**, i8*** %3
ret i8** %25
}

LLVM IR (-O2):
define i8** @string_pack_find(i8** %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %14, label %5
5: ; preds = %2, %10
%6 = phi i8* [ %12, %10 ], [ %3, %2 ]
%7 = phi i8** [ %11, %10 ], [ %0, %2 ]
%8 = tail call i64 @strcmp(i8* %6, i8* %1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %5
%11 = getelementptr inbounds i8*, i8** %7, i64 1
%12 = load i8*, i8** %11
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %5
14: ; preds = %5, %10, %2
%15 = phi i8** [ null, %2 ], [ null, %10 ], [ %7, %5 ]
ret i8** %15
}