#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 *const);
int str_in_set(const char *str, const char *const *set) {
  size_t i;
  for (i = 0; set[i] != NULL; i++)
    if (!strcmp(str, set[i]))
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<str_in_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     117b <str_in_set+0x6b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1165 <str_in_set+0x55>
movl   $0x1,-0x4(%rbp)
jmp    1182 <str_in_set+0x72>
jmp    116a <str_in_set+0x5a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <str_in_set+0x18>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_in_set>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    (%rsi),%rsi
xor    %r14d,%r14d
test   %rsi,%rsi
je     1150 <str_in_set+0x40>
mov    %rdi,%rbp
add    $0x8,%rbx
nopl   0x0(%rax)
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     114a <str_in_set+0x3a>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1130 <str_in_set+0x20>
jmp    1150 <str_in_set+0x40>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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