#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 strlen(char *);
scalar_t__ strncasecmp(char const *, char *, int);
int flagopt(int argc, char *newarg[]) {
  int i;
  const char *pattern1 = "fl";
  for (i = 2; i < argc; i++) {
    if (strlen(newarg[i]) > 2 && strncasecmp(pattern1, newarg[i], 2) == 0) {
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<flagopt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11aa <flagopt+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jle    1197 <flagopt+0x77>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    $0x2,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    1197 <flagopt+0x77>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b1 <flagopt+0x91>
jmp    119c <flagopt+0x7c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <flagopt+0x21>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flagopt>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r14d,%r14d
cmp    $0x3,%edi
jl     1183 <flagopt+0x63>
mov    %rsi,%rbx
mov    %edi,%r12d
mov    $0x2,%ebp
lea    0xebe(%rip),%r15
jmp    1159 <flagopt+0x39>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbp
cmp    %rbp,%r12
je     1183 <flagopt+0x63>
mov    (%rbx,%rbp,8),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jl     1150 <flagopt+0x30>
mov    (%rbx,%rbp,8),%rsi
mov    %r15,%rdi
mov    $0x2,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
jne    1150 <flagopt+0x30>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"fl\00"
define i32 @flagopt(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %7
store i32 2, i32* %6
br label %8
8: ; preds = %31, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %34
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 @strlen(i8* %17)
%19 = icmp sgt i32 %18, 2
br i1 %19, label %20, label %30
20: ; preds = %12
%21 = load i8*, i8** %7
%22 = load i8**, i8*** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i64 @strncasecmp(i8* %21, i8* %26, i32 2)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %20
store i32 -1, i32* %3
br label %35
30: ; preds = %20, %12
br label %31
31: ; preds = %30
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %8
34: ; preds = %8
store i32 0, i32* %3
br label %35
35: ; preds = %34, %29
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [3 x i8] c"fl\00"
define i32 @flagopt(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %19
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %16
%7 = phi i64 [ 2, %4 ], [ %17, %16 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* %9)
%11 = icmp sgt i32 %10, 2
br i1 %11, label %12, label %16
12: ; preds = %6
%13 = load i8*, i8** %8
%14 = tail call i64 @strncasecmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %13, i32 2)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %6, %12
%17 = add nuw nsw i64 %7, 1
%18 = icmp eq i64 %17, %5
br i1 %18, label %19, label %6
19: ; preds = %12, %16, %2
%20 = phi i32 [ 0, %2 ], [ 0, %16 ], [ -1, %12 ]
ret i32 %20
}