#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 */
char *getarg(char const *, char *, int);
int /*<<< orphan*/ strcasecmp(char const *, char *);
int hasname(const char *list, const char *name) {
  const char *p;
  char arg[2048];
  if (!list)
    return (0);
  p = getarg(list, arg, 2048);
  while (arg[0]) {
    if (!strcasecmp(name, arg))
      return 1;
    p = getarg(p, arg, 2048);
  }
  return 0;
}


x86 assembly (clang, -O0):
<hasname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114a <hasname+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11ba <hasname+0x9a>
mov    -0x10(%rbp),%rdi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1040 <getarg@plt>
mov    %rax,-0x20(%rbp)
cmpb   $0x0,-0x820(%rbp)
je     11b3 <hasname+0x93>
mov    -0x18(%rbp),%rdi
lea    -0x820(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1195 <hasname+0x75>
movl   $0x1,-0x4(%rbp)
jmp    11ba <hasname+0x9a>
mov    -0x20(%rbp),%rdi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1040 <getarg@plt>
mov    %rax,-0x20(%rbp)
jmp    1163 <hasname+0x43>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hasname>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
xor    %r14d,%r14d
test   %rdi,%rdi
je     1190 <hasname+0x70>
mov    %rsi,%r15
mov    %rsp,%rsi
mov    $0x800,%edx
call   1040 <getarg@plt>
cmpb   $0x0,(%rsp)
je     1190 <hasname+0x70>
mov    %rax,%rbx
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbp,%rsi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     118a <hasname+0x6a>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x800,%edx
call   1040 <getarg@plt>
mov    %rax,%rbx
cmpb   $0x0,(%rsp)
jne    1160 <hasname+0x40>
jmp    1190 <hasname+0x70>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @hasname(i8* %0, i8* nocapture %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %0, null
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = call i8* @getarg(i8* %0, i8* %4, i32 2048)
%8 = load i8, i8* %4
%9 = icmp eq i8 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %6, %14
%11 = phi i8* [ %15, %14 ], [ %7, %6 ]
%12 = call i32 @strcasecmp(i8* %1, i8* %4)
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = call i8* @getarg(i8* %11, i8* %4, i32 2048)
%16 = load i8, i8* %4
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %10
18: ; preds = %10, %14, %6, %2
%19 = phi i32 [ 0, %2 ], [ 0, %6 ], [ 1, %10 ], [ 0, %14 ]
ret i32 %19
}