#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 IN_CREATE;
int IN_DELETE;
int IN_ISDIR;
int IN_MODIFY;
int /*<<< orphan*/ inotify_add_watch(int, char *, int);
void parseDirectoryInput(char argument[], int fd) {
  int i, x;
  x = 0;
  char buffer[255];
  buffer[0] = '\0';
  for (i = 0; argument[i] != '\0'; i++) {
    if (argument[i] == ',') {
      inotify_add_watch(fd, buffer,
                        IN_MODIFY | IN_CREATE | IN_DELETE | IN_ISDIR);
      x = 0;
    } else {
      buffer[x] = argument[i];
      buffer[++x] = '\0';
    }
    inotify_add_watch(fd, buffer, IN_MODIFY | IN_CREATE | IN_DELETE | IN_ISDIR);
  }
}


x86 assembly (clang, -O0):
<parseDirectoryInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movb   $0x0,-0x120(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     120a <parseDirectoryInput+0xfa>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2c,%eax
jne    11a0 <parseDirectoryInput+0x90>
mov    -0xc(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    0x2e7e(%rip),%rax
mov    (%rax),%edx
mov    0x2e4d(%rip),%rax
or     (%rax),%edx
mov    0x2e5c(%rip),%rax
or     (%rax),%edx
mov    0x2e4b(%rip),%rax
or     (%rax),%edx
call   1030 <inotify_add_watch@plt>
movl   $0x0,-0x14(%rbp)
jmp    11c9 <parseDirectoryInput+0xb9>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x120(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cltq
movb   $0x0,-0x120(%rbp,%rax,1)
mov    -0xc(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    0x2e16(%rip),%rax
mov    (%rax),%edx
mov    0x2de5(%rip),%rax
or     (%rax),%edx
mov    0x2df4(%rip),%rax
or     (%rax),%edx
mov    0x2de3(%rip),%rax
or     (%rax),%edx
call   1030 <inotify_add_watch@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1137 <parseDirectoryInput+0x27>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseDirectoryInput>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %esi,%r13d
mov    %rdi,%rbx
movb   $0x0,(%rsp)
xor    %r12d,%r12d
mov    0x2e93(%rip),%rbp
mov    0x2e9c(%rip),%r15
mov    %rsp,%r14
jmp    119b <parseDirectoryInput+0x8b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%edx
mov    0x2e96(%rip),%rax
or     (%rax),%edx
mov    0x2e7d(%rip),%r12
or     (%r12),%edx
or     (%r15),%edx
mov    %r13d,%edi
mov    %r14,%rsi
call   1030 <inotify_add_watch@plt>
mov    %r12,%rcx
mov    0x2e71(%rip),%rax
xor    %r12d,%r12d
mov    0x0(%rbp),%edx
or     (%rax),%edx
or     (%rcx),%edx
or     (%r15),%edx
mov    %r13d,%edi
mov    %r14,%rsi
call   1030 <inotify_add_watch@plt>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x2c,%al
je     1150 <parseDirectoryInput+0x40>
test   %al,%al
je     11c7 <parseDirectoryInput+0xb7>
movslq %r12d,%r12
mov    %al,(%rsp,%r12,1)
movb   $0x0,0x1(%rsp,%r12,1)
add    $0x1,%r12
mov    0x2e32(%rip),%rax
mov    0x2e1b(%rip),%rcx
jmp    1182 <parseDirectoryInput+0x72>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@IN_MODIFY = global i32 0
@IN_CREATE = global i32 0
@IN_DELETE = global i32 0
@IN_ISDIR = global i32 0
define void @parseDirectoryInput(i8* nocapture %0, i32 %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
store i8 0, i8* %4
br label %5
5: ; preds = %25, %2
%6 = phi i64 [ %35, %25 ], [ 0, %2 ]
%7 = phi i32 [ %26, %25 ], [ 0, %2 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %6
%9 = load i8, i8* %8
switch i8 %9, label %19 [
i8 0, label %36
i8 44, label %10
]
10: ; preds = %5
%11 = load i32, i32* @IN_MODIFY
%12 = load i32, i32* @IN_CREATE
%13 = or i32 %12, %11
%14 = load i32, i32* @IN_DELETE
%15 = or i32 %13, %14
%16 = load i32, i32* @IN_ISDIR
%17 = or i32 %15, %16
%18 = call i32 @inotify_add_watch(i32 %1, i8* %4, i32 %17)
br label %25
19: ; preds = %5
%20 = sext i32 %7 to i64
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %20
store i8 %9, i8* %21
%22 = add nsw i32 %7, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %23
store i8 0, i8* %24
br label %25
25: ; preds = %19, %10
%26 = phi i32 [ 0, %10 ], [ %22, %19 ]
%27 = load i32, i32* @IN_MODIFY
%28 = load i32, i32* @IN_CREATE
%29 = or i32 %28, %27
%30 = load i32, i32* @IN_DELETE
%31 = or i32 %29, %30
%32 = load i32, i32* @IN_ISDIR
%33 = or i32 %31, %32
%34 = call i32 @inotify_add_watch(i32 %1, i8* %4, i32 %33)
%35 = add nuw i64 %6, 1
br label %5
36: ; preds = %5
ret void
}