#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*/ strcpy(char *, char *);
int strlen(char *);
char *strstr(char *, char *);
int /*<<< orphan*/ trim(char *);
int splitwatch(char *line, char *regexp, int *excludematchflag, int *newfile) {
  char *startmatch, *regexpStart;
  if (line == (char *)NULL || regexp == (char *)NULL) {
    return (-1);
  }
  if (!strlen(line)) {
    return (-1);
  }
  startmatch = strstr(line, "path=");
  if (startmatch) {
    *excludematchflag = 0;
    *newfile = 0;
  } else {
    startmatch = strstr(line, "path!=");
    if (startmatch) {
      *excludematchflag = 1;
      *newfile = 0;
    } else {
      startmatch = strstr(line, "path~=");
      if (startmatch) {
        *excludematchflag = 0;
        *newfile = 1;
      } else {
        return -1;
      }
    }
  }
  regexpStart = startmatch + strlen("path=") + *excludematchflag + *newfile;
  strcpy(regexp, regexpStart);
  trim(regexp);
  return 1;
}


x86 assembly (clang, -O0):
<splitwatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     116e <splitwatch+0x2e>
cmpq   $0x0,-0x18(%rbp)
jne    117a <splitwatch+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ab <splitwatch+0x16b>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jne    1198 <splitwatch+0x58>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ab <splitwatch+0x16b>
mov    -0x10(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11d0 <splitwatch+0x90>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
jmp    1256 <splitwatch+0x116>
mov    -0x10(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1208 <splitwatch+0xc8>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
jmp    1251 <splitwatch+0x111>
mov    -0x10(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1240 <splitwatch+0x100>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
jmp    124c <splitwatch+0x10c>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ab <splitwatch+0x16b>
jmp    1251 <splitwatch+0x111>
jmp    1256 <splitwatch+0x116>
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0xd9b(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%rcx
movslq (%rcx),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1050 <trim@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<splitwatch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     11ea <splitwatch+0xaa>
mov    %rsi,%r13
test   %rsi,%rsi
je     11ea <splitwatch+0xaa>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%rbx
call   1040 <strlen@plt>
test   %eax,%eax
je     11ea <splitwatch+0xaa>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
xor    %ecx,%ecx
test   %rax,%rax
je     1194 <splitwatch+0x54>
mov    %rax,%r12
xor    %eax,%eax
jmp    11b2 <splitwatch+0x72>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     11fb <splitwatch+0xbb>
mov    %rax,%r12
mov    $0x1,%eax
xor    %ecx,%ecx
mov    %eax,(%r15)
mov    %ecx,(%r14)
lea    0xe41(%rip),%rdi
call   1040 <strlen@plt>
cltq
add    %r12,%rax
movslq (%r15),%rcx
add    %rax,%rcx
movslq (%r14),%rsi
add    %rcx,%rsi
mov    %r13,%rdi
call   1030 <strcpy@plt>
mov    %r13,%rdi
call   1050 <trim@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe0b(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     11ea <splitwatch+0xaa>
mov    %rax,%r12
mov    $0x1,%ecx
jmp    1190 <splitwatch+0x50>

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

LLVM IR (-O2):
@.str = [6 x i8] c"path=\00"
@.str.1 = [7 x i8] c"path!=\00"
@.str.2 = [7 x i8] c"path~=\00"
define i32 @splitwatch(i8* %0, i8* %1, i32* nocapture %2, i32* nocapture %3) {
%5 = icmp eq i8* %0, null
%6 = icmp eq i8* %1, null
%7 = or i1 %5, %6
br i1 %7, label %35, label %8
8: ; preds = %4
%9 = tail call i32 @strlen(i8* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %35, label %11
11: ; preds = %8
%12 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %35, label %20
20: ; preds = %17, %14, %11
%21 = phi i32 [ 0, %11 ], [ 1, %14 ], [ 0, %17 ]
%22 = phi i32 [ 0, %11 ], [ 0, %14 ], [ 1, %17 ]
%23 = phi i8* [ %12, %11 ], [ %15, %14 ], [ %18, %17 ]
store i32 %21, i32* %2
store i32 %22, i32* %3
%24 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = tail call i32 @strcpy(i8* %1, i8* %32)
%34 = tail call i32 @trim(i8* %1)
br label %35
35: ; preds = %17, %8, %4, %20
%36 = phi i32 [ 1, %20 ], [ -1, %4 ], [ -1, %8 ], [ -1, %17 ]
ret i32 %36
}