#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 int int32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *);
scalar_t__ strcmp(char const *, char const *);
int32_t in_array(const char *test_string, const char *test_array[]) {
  const char **needle = test_array;
  while (*needle) {
    printf("%s\n", *needle);
    if (strcmp(test_string, *needle) == 0) {
      return 1;
    }
    needle += 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<in_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     1190 <in_array+0x70>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    117f <in_array+0x5f>
movl   $0x1,-0x4(%rbp)
jmp    1197 <in_array+0x77>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1138 <in_array+0x18>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<in_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    (%rsi),%rsi
xor    %r14d,%r14d
test   %rsi,%rsi
je     117d <in_array+0x5d>
mov    %rdi,%rbp
add    $0x8,%rbx
lea    0xebd(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1030 <printf@plt>
mov    -0x8(%rbx),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1177 <in_array+0x57>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1150 <in_array+0x30>
jmp    117d <in_array+0x5d>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @in_array(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
store i8** %7, i8*** %6
br label %8
8: ; preds = %22, %2
%9 = load i8**, i8*** %6
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = load i8**, i8*** %6
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %4
%17 = load i8**, i8*** %6
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %16, i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %12
store i32 1, i32* %3
br label %26
22: ; preds = %12
%23 = load i8**, i8*** %6
%24 = getelementptr inbounds i8*, i8** %23, i64 1
store i8** %24, i8*** %6
br label %8
25: ; preds = %8
store i32 0, i32* %3
br label %26
26: ; preds = %25, %21
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @in_array(i8* %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp eq i8* %3, null
br i1 %4, label %16, label %8
5: ; preds = %8
%6 = load i8*, i8** %15
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %2, %5
%9 = phi i8* [ %6, %5 ], [ %3, %2 ]
%10 = phi i8** [ %15, %5 ], [ %1, %2 ]
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%12 = load i8*, i8** %10
%13 = tail call i64 @strcmp(i8* %0, i8* %12)
%14 = icmp eq i64 %13, 0
%15 = getelementptr inbounds i8*, i8** %10, i64 1
br i1 %14, label %16, label %5
16: ; preds = %8, %5, %2
%17 = phi i32 [ 0, %2 ], [ 0, %5 ], [ 1, %8 ]
ret i32 %17
}