#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 */
struct option {
  int has_arg;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int search_longopt(char *, struct option *);
char *strchr(char *, char);
int strlen(char *);
int has_argument_long(char *arg, struct option *longopts) {
  int i;
  i = search_longopt(arg, longopts);
  if (i == -1) {
    return -1;
  } else {
    int len = strlen(arg);
    char *p = strchr(arg, '=');
    if (p) {
      len = p - arg;
    }
    switch (longopts[i].has_arg) {
    case 0:
      return 0;
    case 1:
      if (arg[len] == '=')
        return 1;
      else
        return 2;
    case 2:
      if (arg[len] == '=')
        return 1;
      else
        return 0;
    default:
      assert(0);
    }
  }
}


x86 assembly (clang, -O0):
<has_argument_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <search_longopt@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1176 <has_argument_long+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    125c <has_argument_long+0x11c>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ad <has_argument_long+0x6d>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
je     11ea <has_argument_long+0xaa>
jmp    11c8 <has_argument_long+0x88>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
je     11f6 <has_argument_long+0xb6>
jmp    11d9 <has_argument_long+0x99>
mov    -0x2c(%rbp),%eax
sub    $0x2,%eax
je     1223 <has_argument_long+0xe3>
jmp    1250 <has_argument_long+0x110>
movl   $0x0,-0x4(%rbp)
jmp    125c <has_argument_long+0x11c>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    1217 <has_argument_long+0xd7>
movl   $0x1,-0x4(%rbp)
jmp    125c <has_argument_long+0x11c>
movl   $0x2,-0x4(%rbp)
jmp    125c <has_argument_long+0x11c>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    1244 <has_argument_long+0x104>
movl   $0x1,-0x4(%rbp)
jmp    125c <has_argument_long+0x11c>
movl   $0x0,-0x4(%rbp)
jmp    125c <has_argument_long+0x11c>
xor    %edi,%edi
call   1050 <assert@plt>
jmp    125c <has_argument_long+0x11c>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_argument_long>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1060 <search_longopt@plt>
cmp    $0xffffffff,%eax
je     11a6 <has_argument_long+0x66>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %eax,%ecx
sub    %ebx,%ecx
test   %rax,%rax
cmove  %r15d,%ecx
movslq %ebp,%rax
mov    (%r14,%rax,4),%eax
test   %eax,%eax
je     11c2 <has_argument_long+0x82>
cmp    $0x2,%eax
je     11ad <has_argument_long+0x6d>
cmp    $0x1,%eax
jne    11bb <has_argument_long+0x7b>
movslq %ecx,%rax
xor    %ecx,%ecx
cmpb   $0x3d,(%rbx,%rax,1)
sete   %cl
mov    $0x2,%eax
sub    %ecx,%eax
jmp    11c2 <has_argument_long+0x82>
mov    $0xffffffff,%eax
jmp    11c2 <has_argument_long+0x82>
movslq %ecx,%rcx
xor    %eax,%eax
cmpb   $0x3d,(%rbx,%rcx,1)
sete   %al
jmp    11c2 <has_argument_long+0x82>
xor    %edi,%edi
call   1050 <assert@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i32 }
define i32 @has_argument_long(i8* %0, %struct.option* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.option*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store %struct.option* %1, %struct.option** %5
%9 = load i8*, i8** %4
%10 = load %struct.option*, %struct.option** %5
%11 = call i32 @search_longopt(i8* %9, %struct.option* %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 -1, i32* %3
br label %60
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %7
%18 = load i8*, i8** %4
%19 = call i8* @strchr(i8* %18, i8 signext 61)
store i8* %19, i8** %8
%20 = load i8*, i8** %8
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %29
22: ; preds = %15
%23 = load i8*, i8** %8
%24 = load i8*, i8** %4
%25 = ptrtoint i8* %23 to i64
%26 = ptrtoint i8* %24 to i64
%27 = sub i64 %25, %26
%28 = trunc i64 %27 to i32
store i32 %28, i32* %7
br label %29
29: ; preds = %22, %15
%30 = load %struct.option*, %struct.option** %5
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds %struct.option, %struct.option* %30, i64 %32
%34 = getelementptr inbounds %struct.option, %struct.option* %33, i32 0, i32 0
%35 = load i32, i32* %34
switch i32 %35, label %57 [
i32 0, label %36
i32 1, label %37
i32 2, label %47
]
36: ; preds = %29
store i32 0, i32* %3
br label %60
37: ; preds = %29
%38 = load i8*, i8** %4
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 61
br i1 %44, label %45, label %46
45: ; preds = %37
store i32 1, i32* %3
br label %60
46: ; preds = %37
store i32 2, i32* %3
br label %60
47: ; preds = %29
%48 = load i8*, i8** %4
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 61
br i1 %54, label %55, label %56
55: ; preds = %47
store i32 1, i32* %3
br label %60
56: ; preds = %47
store i32 0, i32* %3
br label %60
57: ; preds = %29
%58 = call i32 @assert(i32 0)
br label %59
59: ; preds = %57
br label %60
60: ; preds = %14, %36, %45, %46, %55, %56, %59
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
%struct.option = type { i32 }
define i32 @has_argument_long(i8* %0, %struct.option* %1) {
%3 = tail call i32 @search_longopt(i8* %0, %struct.option* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %31, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %0)
%7 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%8 = icmp eq i8* %7, null
%9 = ptrtoint i8* %7 to i64
%10 = ptrtoint i8* %0 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = select i1 %8, i32 %6, i32 %12
%14 = sext i32 %3 to i64
%15 = getelementptr inbounds %struct.option, %struct.option* %1, i64 %14, i32 0
%16 = load i32, i32* %15
switch i32 %16, label %29 [
i32 0, label %31
i32 1, label %17
i32 2, label %23
]
17: ; preds = %5
%18 = sext i32 %13 to i64
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 61
%22 = select i1 %21, i32 1, i32 2
br label %31
23: ; preds = %5
%24 = sext i32 %13 to i64
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 61
%28 = zext i1 %27 to i32
br label %31
29: ; preds = %5
%30 = tail call i32 @assert(i32 0)
br label %31
31: ; preds = %29, %5, %17, %23, %2
%32 = phi i32 [ -1, %2 ], [ undef, %29 ], [ %16, %5 ], [ %22, %17 ], [ %28, %23 ]
ret i32 %32
}