#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 */
typedef int /*<<< orphan*/ flags;

/* Variables and functions */
scalar_t__ memcmp(char const *, char const *, size_t);
size_t strlen(char const *);
size_t testsensitiveflag(const char *arg) {
  static const struct {
    const char *name;
    size_t narg;
  } flags[] = {
      {"--config", 1},     {"--cwd", 1},       {"--repo", 1},
      {"--repository", 1}, {"--traceback", 0}, {"-R", 1},
  };
  size_t i;
  for (i = 0; i < sizeof(flags) / sizeof(flags[0]); ++i) {
    size_t len = strlen(flags[i].name);
    size_t narg = flags[i].narg;
    if (memcmp(arg, flags[i].name, len) == 0) {
      if (arg[len] == '\0') {
        return narg + 1;
      } else if (arg[len] == '=' && narg > 0) {
        return 1;
      } else if (flags[i].name[1] != '-') {
        return 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<testsensitiveflag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x6,-0x18(%rbp)
jae    124a <testsensitiveflag+0x12a>
mov    -0x18(%rbp),%rcx
lea    0x2c76(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rcx
lea    0x2c58(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rcx
lea    0x2c3a(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    1234 <testsensitiveflag+0x114>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    11c9 <testsensitiveflag+0xa9>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1252 <testsensitiveflag+0x132>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    11f6 <testsensitiveflag+0xd6>
cmpq   $0x0,-0x28(%rbp)
jbe    11f6 <testsensitiveflag+0xd6>
movq   $0x1,-0x8(%rbp)
jmp    1252 <testsensitiveflag+0x132>
mov    -0x18(%rbp),%rcx
lea    0x2bbf(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
je     1225 <testsensitiveflag+0x105>
movq   $0x1,-0x8(%rbp)
jmp    1252 <testsensitiveflag+0x132>
jmp    122a <testsensitiveflag+0x10a>
jmp    122f <testsensitiveflag+0x10f>
jmp    1234 <testsensitiveflag+0x114>
jmp    1239 <testsensitiveflag+0x119>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1134 <testsensitiveflag+0x14>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testsensitiveflag>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
mov    $0x8,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     11c5 <testsensitiveflag+0xb5>
lea    0xed4(%rip),%rsi
mov    $0x5,%edx
mov    %rbx,%rdi
call   1030 <memcmp@plt>
test   %rax,%rax
je     11d8 <testsensitiveflag+0xc8>
lea    0xebd(%rip),%rsi
mov    $0x6,%edx
mov    %rbx,%rdi
call   1030 <memcmp@plt>
test   %rax,%rax
je     11ef <testsensitiveflag+0xdf>
lea    0xea7(%rip),%rsi
mov    $0xc,%edx
mov    %rbx,%rdi
call   1030 <memcmp@plt>
test   %rax,%rax
je     1205 <testsensitiveflag+0xf5>
lea    0xe97(%rip),%rsi
mov    $0xb,%edx
mov    %rbx,%rdi
call   1030 <memcmp@plt>
test   %rax,%rax
jne    11a8 <testsensitiveflag+0x98>
cmpb   $0x0,0xb(%rbx)
je     1242 <testsensitiveflag+0x132>
lea    0xe80(%rip),%rsi
mov    $0x2,%edx
mov    %rbx,%rdi
call   1030 <memcmp@plt>
test   %rax,%rax
je     1222 <testsensitiveflag+0x112>
xor    %eax,%eax
pop    %rbx
ret
mov    0x8(%rbx),%al
cmp    $0x3d,%al
je     121b <testsensitiveflag+0x10b>
test   %al,%al
jne    112e <testsensitiveflag+0x1e>
xor    %eax,%eax
jmp    1247 <testsensitiveflag+0x137>
mov    0x5(%rbx),%cl
mov    $0x1,%eax
test   %cl,%cl
je     1247 <testsensitiveflag+0x137>
cmp    $0x3d,%cl
jne    114b <testsensitiveflag+0x3b>
pop    %rbx
ret
mov    0x6(%rbx),%cl
test   %cl,%cl
je     1234 <testsensitiveflag+0x124>
mov    $0x1,%eax
cmp    $0x3d,%cl
je     11ed <testsensitiveflag+0xdd>
jmp    1168 <testsensitiveflag+0x58>
mov    0xc(%rbx),%cl
test   %cl,%cl
je     123b <testsensitiveflag+0x12b>
mov    $0x1,%eax
cmp    $0x3d,%cl
je     11ed <testsensitiveflag+0xdd>
jmp    1185 <testsensitiveflag+0x75>
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x1,%eax
cmpb   $0x0,0x2(%rbx)
jne    11ed <testsensitiveflag+0xdd>
mov    $0x5,%eax
jmp    1247 <testsensitiveflag+0x137>
mov    $0x2,%eax
jmp    1247 <testsensitiveflag+0x137>
mov    $0x3,%eax
jmp    1247 <testsensitiveflag+0x137>
mov    $0x4,%eax
shl    $0x4,%rax
lea    0x2b6e(%rip),%rcx
mov    0x8(%rax,%rcx,1),%rax
add    $0x1,%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct.anon = type { i8*, i64 }
@testsensitiveflag.flags = internal constant [6 x %struct.anon] [%struct.anon { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i64 1 }, %struct.anon { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i64 1 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i64 1 }, %struct.anon { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i32 0, i32 0), i64 1 }, %struct.anon { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i32 0, i32 0), i64 0 }, %struct.anon { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i64 1 }]
@.str = [9 x i8] c"--config\00"
@.str.1 = [6 x i8] c"--cwd\00"
@.str.2 = [7 x i8] c"--repo\00"
@.str.3 = [13 x i8] c"--repository\00"
@.str.4 = [12 x i8] c"--traceback\00"
@.str.5 = [3 x i8] c"-R\00"
define i64 @testsensitiveflag(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %3
store i64 0, i64* %4
br label %7
7: ; preds = %63, %1
%8 = load i64, i64* %4
%9 = icmp ult i64 %8, 6
br i1 %9, label %10, label %66
10: ; preds = %7
%11 = load i64, i64* %4
%12 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* @testsensitiveflag.flags, i64 0, i64 %11
%13 = getelementptr inbounds %struct.anon, %struct.anon* %12, i32 0, i32 0
%14 = load i8*, i8** %13
%15 = call i64 @strlen(i8* %14)
store i64 %15, i64* %5
%16 = load i64, i64* %4
%17 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* @testsensitiveflag.flags, i64 0, i64 %16
%18 = getelementptr inbounds %struct.anon, %struct.anon* %17, i32 0, i32 1
%19 = load i64, i64* %18
store i64 %19, i64* %6
%20 = load i8*, i8** %3
%21 = load i64, i64* %4
%22 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* @testsensitiveflag.flags, i64 0, i64 %21
%23 = getelementptr inbounds %struct.anon, %struct.anon* %22, i32 0, i32 0
%24 = load i8*, i8** %23
%25 = load i64, i64* %5
%26 = call i64 @memcmp(i8* %20, i8* %24, i64 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %62
28: ; preds = %10
%29 = load i8*, i8** %3
%30 = load i64, i64* %5
%31 = getelementptr inbounds i8, i8* %29, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %28
%36 = load i64, i64* %6
%37 = add i64 %36, 1
store i64 %37, i64* %2
br label %67
38: ; preds = %28
%39 = load i8*, i8** %3
%40 = load i64, i64* %5
%41 = getelementptr inbounds i8, i8* %39, 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 %49
45: ; preds = %38
%46 = load i64, i64* %6
%47 = icmp ugt i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %45
store i64 1, i64* %2
br label %67
49: ; preds = %45, %38
%50 = load i64, i64* %4
%51 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* @testsensitiveflag.flags, i64 0, i64 %50
%52 = getelementptr inbounds %struct.anon, %struct.anon* %51, i32 0, i32 0
%53 = load i8*, i8** %52
%54 = getelementptr inbounds i8, i8* %53, i64 1
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp ne i32 %56, 45
br i1 %57, label %58, label %59
58: ; preds = %49
store i64 1, i64* %2
br label %67
59: ; preds = %49
br label %60
60: ; preds = %59
br label %61
61: ; preds = %60
br label %62
62: ; preds = %61, %10
br label %63
63: ; preds = %62
%64 = load i64, i64* %4
%65 = add i64 %64, 1
store i64 %65, i64* %4
br label %7
66: ; preds = %7
store i64 0, i64* %2
br label %67
67: ; preds = %66, %58, %48, %35
%68 = load i64, i64* %2
ret i64 %68
}

LLVM IR (-O2):
%struct.anon = type { i8*, i64 }
@testsensitiveflag.flags = internal unnamed_addr constant [6 x %struct.anon] [%struct.anon { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i64 1 }, %struct.anon { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i64 1 }, %struct.anon { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i64 1 }, %struct.anon { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i32 0, i32 0), i64 1 }, %struct.anon { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i32 0, i32 0), i64 0 }, %struct.anon { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i64 1 }]
@.str = [9 x i8] c"--config\00"
@.str.1 = [6 x i8] c"--cwd\00"
@.str.2 = [7 x i8] c"--repo\00"
@.str.3 = [13 x i8] c"--repository\00"
@.str.4 = [12 x i8] c"--traceback\00"
@.str.5 = [3 x i8] c"-R\00"
define i64 @testsensitiveflag(i8* %0) {
%2 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 8)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %12
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 8
%6 = load i8, i8* %5
switch i8 %6, label %12 [
i8 0, label %7
i8 61, label %44
]
7: ; preds = %27, %21, %15, %4, %40, %33
%8 = phi i64 [ 0, %4 ], [ 1, %15 ], [ 2, %21 ], [ 3, %27 ], [ 4, %33 ], [ 5, %40 ]
%9 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* @testsensitiveflag.flags, i64 0, i64 %8, i32 1
%10 = load i64, i64* %9
%11 = add i64 %10, 1
br label %44
12: ; preds = %4, %1
%13 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 5)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %0, i64 5
%17 = load i8, i8* %16
switch i8 %17, label %18 [
i8 0, label %7
i8 61, label %44
]
18: ; preds = %15, %12
%19 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 6)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = getelementptr inbounds i8, i8* %0, i64 6
%23 = load i8, i8* %22
switch i8 %23, label %24 [
i8 0, label %7
i8 61, label %44
]
24: ; preds = %21, %18
%25 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i64 12)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = getelementptr inbounds i8, i8* %0, i64 12
%29 = load i8, i8* %28
switch i8 %29, label %30 [
i8 0, label %7
i8 61, label %44
]
30: ; preds = %27, %24
%31 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i64 11)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = getelementptr inbounds i8, i8* %0, i64 11
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %7, label %37
37: ; preds = %33, %30
%38 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 2)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = getelementptr inbounds i8, i8* %0, i64 2
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 0
br i1 %43, label %7, label %44
44: ; preds = %40, %27, %21, %15, %4, %37, %7
%45 = phi i64 [ %11, %7 ], [ 0, %37 ], [ 1, %4 ], [ 1, %15 ], [ 1, %21 ], [ 1, %27 ], [ 1, %40 ]
ret i64 %45
}