#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*/ my_strcmp(char *, char *);
int my_strtabsearch(char **tab, char *str) {
  int i;
  if (tab == NULL || str == NULL)
    return (0);
  i = -1;
  while (tab[++i] != NULL) {
    if (!my_strcmp(tab[i], str))
      return (1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<my_strtabsearch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1136 <my_strtabsearch+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1142 <my_strtabsearch+0x32>
movl   $0x0,-0x4(%rbp)
jmp    119a <my_strtabsearch+0x8a>
movl   $0xffffffff,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
movslq %ecx,%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1193 <my_strtabsearch+0x83>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <my_strcmp@plt>
cmp    $0x0,%eax
jne    118e <my_strtabsearch+0x7e>
movl   $0x1,-0x4(%rbp)
jmp    119a <my_strtabsearch+0x8a>
jmp    1149 <my_strtabsearch+0x39>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_strtabsearch>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
test   %rdi,%rdi
je     114f <my_strtabsearch+0x3f>
mov    %rsi,%rbx
test   %rsi,%rsi
je     114f <my_strtabsearch+0x3f>
mov    %rdi,%rbp
nopw   0x0(%rax,%rax,1)
mov    0x0(%rbp),%rdi
test   %rdi,%rdi
je     114f <my_strtabsearch+0x3f>
mov    %rbx,%rsi
call   1030 <my_strcmp@plt>
add    $0x8,%rbp
test   %eax,%eax
jne    1130 <my_strtabsearch+0x20>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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