#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*/ strlen(char const *);
scalar_t__ strncmp(char *, char const *, int /*<<< orphan*/);
int eval_flag(int argc, char *argv[], const char *arg) {
  for (int i = 1; i < argc; i++)
    if (strncmp(argv[i], arg, strlen(arg)) == 0)
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<eval_flag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119f <eval_flag+0x7f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    118c <eval_flag+0x6c>
movl   $0x1,-0x4(%rbp)
jmp    11a6 <eval_flag+0x86>
jmp    1191 <eval_flag+0x71>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <eval_flag+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_flag>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
cmp    $0x2,%edi
jl     1199 <eval_flag+0x79>
mov    %rdx,%r12
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x8(%rsi),%r15
mov    %rdx,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1194 <eval_flag+0x74>
mov    %ebp,%r15d
mov    $0x2,%ecx
nopl   (%rax)
mov    %rcx,%rbx
cmp    %rcx,%r15
je     118a <eval_flag+0x6a>
mov    (%r14,%rbx,8),%rbp
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
lea    0x1(%rbx),%rcx
test   %rax,%rax
jne    1160 <eval_flag+0x40>
xor    %eax,%eax
cmp    %r15,%rbx
setb   %al
jmp    1199 <eval_flag+0x79>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @eval_flag(i32 %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
store i32 1, i32* %8
br label %9
9: ; preds = %26, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i8**, i8*** %6
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = load i8*, i8** %7
%20 = load i8*, i8** %7
%21 = call i32 @strlen(i8* %20)
%22 = call i64 @strncmp(i8* %18, i8* %19, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %13
store i32 1, i32* %4
br label %30
25: ; preds = %13
br label %26
26: ; preds = %25
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %9
29: ; preds = %9
store i32 0, i32* %4
br label %30
30: ; preds = %29, %24
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
define i32 @eval_flag(i32 %0, i8** nocapture %1, i8* %2) {
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %26
5: ; preds = %3
%6 = zext i32 %0 to i64
%7 = zext i32 %0 to i64
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* %2)
%11 = tail call i64 @strncmp(i8* %9, i8* %2, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %5, %16
%14 = phi i64 [ %22, %16 ], [ 2, %5 ]
%15 = icmp eq i64 %14, %7
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = getelementptr inbounds i8*, i8** %1, i64 %14
%18 = load i8*, i8** %17
%19 = tail call i32 @strlen(i8* %2)
%20 = tail call i64 @strncmp(i8* %18, i8* %2, i32 %19)
%21 = icmp eq i64 %20, 0
%22 = add nuw nsw i64 %14, 1
br i1 %21, label %23, label %13
23: ; preds = %13, %16
%24 = icmp ult i64 %14, %6
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %23, %5, %3
%27 = phi i32 [ 0, %3 ], [ 1, %5 ], [ %25, %23 ]
ret i32 %27
}