#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(int /*<<< orphan*/, char *);
bool exists(char *argv[], char *name) {
  while (name && argv && *argv)
    if (!strcmp(*argv++, name))
      return true;
  return false;
}


x86 assembly (clang, -O0):
<exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
je     114e <exists+0x3e>
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x19(%rbp)
je     114e <exists+0x3e>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    115e <exists+0x4e>
jmp    1195 <exists+0x85>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rax
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1190 <exists+0x80>
movl   $0x1,-0x4(%rbp)
jmp    119c <exists+0x8c>
jmp    1120 <exists+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exists>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
test   %rsi,%rsi
je     1154 <exists+0x44>
mov    %rsi,%rbx
mov    %rdi,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %rbp,%rbp
je     1154 <exists+0x44>
mov    0x0(%rbp),%rdi
test   %rdi,%rdi
je     1154 <exists+0x44>
add    $0x8,%rbp
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    1130 <exists+0x20>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @exists(i8** %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
store i8** %0, i8*** %4
store i8* %1, i8** %5
br label %6
6: ; preds = %27, %2
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i8**, i8*** %4
%11 = icmp ne i8** %10, null
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i8**, i8*** %4
%14 = load i8*, i8** %13
%15 = icmp ne i8* %14, null
br label %16
16: ; preds = %12, %9, %6
%17 = phi i1 [ false, %9 ], [ false, %6 ], [ %15, %12 ]
br i1 %17, label %18, label %28
18: ; preds = %16
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds i8*, i8** %19, i32 1
store i8** %20, i8*** %4
%21 = load i8*, i8** %19
%22 = ptrtoint i8* %21 to i32
%23 = load i8*, i8** %5
%24 = call i32 @strcmp(i32 %22, i8* %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %18
store i32 1, i32* %3
br label %29
27: ; preds = %18
br label %6
28: ; preds = %16
store i32 0, i32* %3
br label %29
29: ; preds = %28, %26
%30 = load i32, i32* %3
ret i32 %30
}

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