#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 */
char *copyString(char *const);
int /*<<< orphan*/ free(char *const);
scalar_t__ same(char *, char *);
int strlen(char *);
char *strtok(char *const, char *);
bool stringHasLongOpt(char *const string, char *opt) {
  char *const copy = copyString(string);
  char *token = strtok(copy, " ,;\n");
  while (token != NULL) {
    if (strlen(token) >= 3 && token[0] == '-' && token[1] == '-') {
      if (same(&token[2], opt)) {
        free(copy);
        return true;
      }
    }
    token = strtok(NULL, " ,;\n");
  }
  free(copy);
  return false;
}


x86 assembly (clang, -O0):
<stringHasLongOpt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <copyString@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     120d <stringHasLongOpt+0xbd>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x3,%eax
jl     11f4 <stringHasLongOpt+0xa4>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11f4 <stringHasLongOpt+0xa4>
mov    -0x28(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
jne    11f4 <stringHasLongOpt+0xa4>
mov    -0x28(%rbp),%rdi
add    $0x2,%rdi
mov    -0x18(%rbp),%rsi
call   1060 <same@plt>
cmp    $0x0,%rax
je     11ef <stringHasLongOpt+0x9f>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    121d <stringHasLongOpt+0xcd>
jmp    11f4 <stringHasLongOpt+0xa4>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe01(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    1181 <stringHasLongOpt+0x31>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringHasLongOpt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
call   1040 <copyString@plt>
mov    %rax,%r14
lea    0xe95(%rip),%rsi
mov    %rax,%rdi
call   1070 <strtok@plt>
test   %rax,%rax
je     11d9 <stringHasLongOpt+0x89>
mov    %rax,%rbx
lea    0xe7e(%rip),%r12
jmp    11a5 <stringHasLongOpt+0x55>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %r13d,%r13d
xor    %edi,%edi
mov    %r12,%rsi
call   1070 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11dc <stringHasLongOpt+0x8c>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x3,%eax
jl     1190 <stringHasLongOpt+0x40>
cmpb   $0x2d,(%rbx)
jne    1190 <stringHasLongOpt+0x40>
cmpb   $0x2d,0x1(%rbx)
jne    1190 <stringHasLongOpt+0x40>
add    $0x2,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <same@plt>
test   %rax,%rax
je     1190 <stringHasLongOpt+0x40>
mov    $0x1,%r13d
jmp    11dc <stringHasLongOpt+0x8c>
xor    %r13d,%r13d
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c" ,;\0A\00"
define i32 @stringHasLongOpt(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i8* @copyString(i8* %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = call i8* @strtok(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %7
br label %12
12: ; preds = %41, %2
%13 = load i8*, i8** %7
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %43
15: ; preds = %12
%16 = load i8*, i8** %7
%17 = call i32 @strlen(i8* %16)
%18 = icmp sge i32 %17, 3
br i1 %18, label %19, label %41
19: ; preds = %15
%20 = load i8*, i8** %7
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 45
br i1 %24, label %25, label %41
25: ; preds = %19
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 45
br i1 %30, label %31, label %41
31: ; preds = %25
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 2
%34 = load i8*, i8** %5
%35 = call i64 @same(i8* %33, i8* %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %31
%38 = load i8*, i8** %6
%39 = call i32 @free(i8* %38)
store i32 1, i32* %3
br label %46
40: ; preds = %31
br label %41
41: ; preds = %40, %25, %19, %15
%42 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %42, i8** %7
br label %12
43: ; preds = %12
%44 = load i8*, i8** %6
%45 = call i32 @free(i8* %44)
store i32 0, i32* %3
br label %46
46: ; preds = %43, %37
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [5 x i8] c" ,;\0A\00"
define i32 @stringHasLongOpt(i8* %0, i8* %1) {
%3 = tail call i8* @copyString(i8* %0)
%4 = tail call i8* @strtok(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %24, label %6
6: ; preds = %2, %21
%7 = phi i8* [ %22, %21 ], [ %4, %2 ]
%8 = tail call i32 @strlen(i8* %7)
%9 = icmp sgt i32 %8, 2
br i1 %9, label %10, label %21
10: ; preds = %6
%11 = load i8, i8* %7
%12 = icmp eq i8 %11, 45
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = getelementptr inbounds i8, i8* %7, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 45
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = getelementptr inbounds i8, i8* %7, i64 2
%19 = tail call i64 @same(i8* %18, i8* %1)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17, %13, %10, %6
%22 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %6
24: ; preds = %21, %17, %2
%25 = phi i32 [ 0, %2 ], [ 1, %17 ], [ 0, %21 ]
%26 = tail call i32 @free(i8* %3)
ret i32 %25
}