#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 const *);
int strlen(char const *);
scalar_t__ strncmp(char *, char const *, int);
int check_arg(int argc, char **argv, const char *argument, int strict) {
  int i;
  int found = 0;
  for (i = 1; i < argc; i++) {
    if (strict) {
      if (strcmp(argv[i], argument) == 0) {
        found = 1;
        break;
      }
    } else {
      if (strncmp(argv[i], argument, strlen(argument)) == 0) {
        found = 1;
        break;
      }
    }
    if (strcmp(argv[i], "--") == 0)
      break;
    if (strncmp(argv[i], "--", 2) != 0)
      break;
  }
  return found;
}


x86 assembly (clang, -O0):
<check_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    124b <check_arg+0x11b>
cmpl   $0x0,-0x1c(%rbp)
je     119a <check_arg+0x6a>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1195 <check_arg+0x65>
movl   $0x1,-0x24(%rbp)
jmp    124b <check_arg+0x11b>
jmp    11e5 <check_arg+0xb5>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11e0 <check_arg+0xb0>
movl   $0x1,-0x24(%rbp)
jmp    124b <check_arg+0x11b>
jmp    11e5 <check_arg+0xb5>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe08(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    120c <check_arg+0xdc>
jmp    124b <check_arg+0x11b>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xde1(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1238 <check_arg+0x108>
jmp    124b <check_arg+0x11b>
jmp    123d <check_arg+0x10d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1154 <check_arg+0x24>
mov    -0x24(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_arg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
cmp    $0x2,%edi
jl     11e9 <check_arg+0xb9>
mov    %ecx,%r15d
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %edi,%eax
mov    %rax,(%rsp)
mov    $0x2,%r14d
lea    0xe9e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    -0x8(%rbp,%r14,8),%rbx
test   %r15d,%r15d
je     1190 <check_arg+0x60>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11aa <check_arg+0x7a>
jmp    11e4 <check_arg+0xb4>
nopl   0x0(%rax)
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11e4 <check_arg+0xb4>
mov    -0x8(%rbp,%r14,8),%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11e0 <check_arg+0xb0>
mov    -0x8(%rbp,%r14,8),%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11e0 <check_arg+0xb0>
lea    0x1(%r14),%rax
cmp    (%rsp),%r14
mov    %rax,%r14
jb     1170 <check_arg+0x40>
xor    %eax,%eax
jmp    11e9 <check_arg+0xb9>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"--\00"
define i32 @check_arg(i32 %0, i8** %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
store i32 0, i32* %10
store i32 1, i32* %9
br label %11
11: ; preds = %61, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %64
15: ; preds = %11
%16 = load i32, i32* %8
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = load i8**, i8*** %6
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = load i8*, i8** %7
%25 = call i64 @strcmp(i8* %23, i8* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %18
store i32 1, i32* %10
br label %64
28: ; preds = %18
br label %42
29: ; preds = %15
%30 = load i8**, i8*** %6
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
%35 = load i8*, i8** %7
%36 = load i8*, i8** %7
%37 = call i32 @strlen(i8* %36)
%38 = call i64 @strncmp(i8* %34, i8* %35, i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %29
store i32 1, i32* %10
br label %64
41: ; preds = %29
br label %42
42: ; preds = %41, %28
%43 = load i8**, i8*** %6
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %42
br label %64
51: ; preds = %42
%52 = load i8**, i8*** %6
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %52, i64 %54
%56 = load i8*, i8** %55
%57 = call i64 @strncmp(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %51
br label %64
60: ; preds = %51
br label %61
61: ; preds = %60
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
br label %11
64: ; preds = %59, %50, %40, %27, %11
%65 = load i32, i32* %10
ret i32 %65
}

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