#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 scalar_t__ haystack;

/* Variables and functions */
scalar_t__ strcmp(char *, char const *);
char **mod_find(char **haystack, const char *needle) {
  for (size_t i = 0; i < ((haystack) ? ((size_t *)(haystack)-2)[1] : 0); ++i) {
    if (strcmp(haystack[i], needle) == 0)
      return haystack + i;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<mod_find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114c <mod_find+0x3c>
mov    -0x10(%rbp),%rax
mov    -0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1157 <mod_find+0x47>
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
jmp    1157 <mod_find+0x47>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
cmp    %rcx,%rax
jae    11b5 <mod_find+0xa5>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    119f <mod_find+0x8f>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    11bd <mod_find+0xad>
jmp    11a4 <mod_find+0x94>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <mod_find+0x18>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod_find>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
mov    %rdi,%r12
test   %r15,%r15
je     1140 <mod_find+0x30>
nopl   0x0(%rax,%rax,1)
mov    -0x8(%r15),%rax
cmp    %rax,%rbx
jb     1147 <mod_find+0x37>
jmp    1167 <mod_find+0x57>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
cmp    %rax,%rbx
jae    1167 <mod_find+0x57>
mov    (%r12),%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     116a <mod_find+0x5a>
add    $0x1,%rbx
add    $0x8,%r12
test   %r15,%r15
jne    1130 <mod_find+0x20>
jmp    1140 <mod_find+0x30>
xor    %r12d,%r12d
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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