#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 */
scalar_t__ strcmp(char *, char *);
int have_flag(int argc, char **argv, char *flag) {
  char **argm = argv + argc;
  argv++;
  if (argv == argm) {
    return 1;
  }
  while (argv != NULL && argv != argm) {
    if (strcmp(*argv, flag) == 0) {
      return 1;
    }
    argv++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<have_flag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    115c <have_flag+0x4c>
movl   $0x1,-0x4(%rbp)
jmp    11cd <have_flag+0xbd>
jmp    1161 <have_flag+0x51>
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x21(%rbp)
je     117f <have_flag+0x6f>
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    118f <have_flag+0x7f>
jmp    11c6 <have_flag+0xb6>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11b5 <have_flag+0xa5>
movl   $0x1,-0x4(%rbp)
jmp    11cd <have_flag+0xbd>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1161 <have_flag+0x51>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<have_flag>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%r14d
cmp    $0x1,%edi
je     115f <have_flag+0x4f>
mov    %rdx,%r15
mov    %rsi,%r12
movslq %edi,%rbx
shl    $0x3,%rbx
mov    $0x8,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %rbp,%rbx
je     115c <have_flag+0x4c>
mov    (%r12,%rbp,1),%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
add    $0x8,%rbp
test   %rax,%rax
jne    1140 <have_flag+0x30>
jmp    115f <have_flag+0x4f>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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