#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*/ printf(char *, char *, int, int, char *);
char *strdup(char const *);
char *tt_strdelim(char *, int *, char, char);
void test_strdelim(const char *str) {
  char *s = NULL;
  char *start = NULL;
  char *end = NULL;
  int done = 0;
  int cnt = 0;
  s = strdup(str);
  start = s;
  while (!done) {
    end = tt_strdelim(start, &cnt, ',', '\\');
    if (*end == '\0') {
      printf("%s:%d - |%d.) %s|\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/slsuse/tt/refs/heads/master/test.c",
             23, cnt, start);
      done = 1;
    } else {
      *end = '\0';
      printf("%s:%d - |%d.) %s|\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/slsuse/tt/refs/heads/master/test.c",
             28, cnt, start);
      if (cnt > 0)
        if ('\0' == end[cnt])
          done = 1;
      start = end + cnt;
      ++start;
    }
  }
}


x86 assembly (clang, -O0):
<test_strdelim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x24(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118d <test_strdelim+0x5d>
jmp    1255 <test_strdelim+0x125>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x2c,%edx
mov    $0x5c,%ecx
call   1030 <tt_strdelim@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11e3 <test_strdelim+0xb3>
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%r8
lea    0xe3a(%rip),%rdi
lea    0xe46(%rip),%rsi
mov    $0x17,%edx
call   1040 <printf@plt>
movl   $0x1,-0x24(%rbp)
jmp    1250 <test_strdelim+0x120>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%r8
lea    0xe08(%rip),%rdi
lea    0xe14(%rip),%rsi
mov    $0x1c,%edx
call   1040 <printf@plt>
cmpl   $0x0,-0x28(%rbp)
jle    1235 <test_strdelim+0x105>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1230 <test_strdelim+0x100>
movl   $0x1,-0x24(%rbp)
jmp    1235 <test_strdelim+0x105>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1177 <test_strdelim+0x47>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strdelim>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
call   1050 <strdup@plt>
mov    %rax,%r13
lea    0xc(%rsp),%r14
lea    0xea7(%rip),%r15
lea    0xeb3(%rip),%r12
jmp    117e <test_strdelim+0x4e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cltq
lea    (%rbx,%rax,1),%r13
add    $0x1,%r13
test   %ecx,%ecx
jne    11e7 <test_strdelim+0xb7>
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x2c,%edx
mov    $0x5c,%ecx
call   1030 <tt_strdelim@plt>
cmpb   $0x0,(%rax)
je     11c8 <test_strdelim+0x98>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    0xc(%rsp),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x1c,%edx
mov    %r13,%r8
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
xor    %ecx,%ecx
test   %eax,%eax
jle    1170 <test_strdelim+0x40>
cmpb   $0x0,(%rbx,%rax,1)
sete   %cl
jmp    1170 <test_strdelim+0x40>
mov    0xc(%rsp),%ecx
lea    0xe2d(%rip),%rdi
lea    0xe39(%rip),%rsi
mov    $0x17,%edx
mov    %r13,%r8
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"%s:%d - |%d.) %s|\0A\00"
@.str.1 = [125 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/slsuse/tt/refs/heads/master/test.c\00"
define void @test_strdelim(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
store i8* null, i8** %4
store i8* null, i8** %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load i8*, i8** %2
%9 = call i8* @strdup(i8* %8)
store i8* %9, i8** %3
%10 = load i8*, i8** %3
store i8* %10, i8** %4
br label %11
11: ; preds = %50, %1
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %15, label %51
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = call i8* @tt_strdelim(i8* %16, i32* %7, i8 signext 44, i8 signext 92)
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %15
%23 = load i32, i32* %7
%24 = load i8*, i8** %4
%25 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.1, i64 0, i64 0), i32 23, i32 %23, i8* %24)
store i32 1, i32* %6
br label %50
26: ; preds = %15
%27 = load i8*, i8** %5
store i8 0, i8* %27
%28 = load i32, i32* %7
%29 = load i8*, i8** %4
%30 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.1, i64 0, i64 0), i32 28, i32 %28, i8* %29)
%31 = load i32, i32* %7
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %43
33: ; preds = %26
%34 = load i8*, i8** %5
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 0, %39
br i1 %40, label %41, label %42
41: ; preds = %33
store i32 1, i32* %6
br label %42
42: ; preds = %41, %33
br label %43
43: ; preds = %42, %26
%44 = load i8*, i8** %5
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
store i8* %47, i8** %4
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %4
br label %50
50: ; preds = %43, %22
br label %11
51: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"%s:%d - |%d.) %s|\0A\00"
@.str.1 = [125 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/slsuse/tt/refs/heads/master/test.c\00"
define void @test_strdelim(i8* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = tail call i8* @strdup(i8* %0)
br label %5
5: ; preds = %1, %24
%6 = phi i8* [ %4, %1 ], [ %28, %24 ]
%7 = call i8* @tt_strdelim(i8* %6, i32* %2, i8 signext 44, i8 signext 92)
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = load i32, i32* %2
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.1, i64 0, i64 0), i32 23, i32 %11, i8* %6)
br label %30
13: ; preds = %5
store i8 0, i8* %7
%14 = load i32, i32* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.1, i64 0, i64 0), i32 28, i32 %14, i8* %6)
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = zext i32 %16 to i64
%20 = getelementptr inbounds i8, i8* %7, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %13, %18
%25 = phi i32 [ 0, %13 ], [ %23, %18 ]
%26 = sext i32 %16 to i64
%27 = getelementptr inbounds i8, i8* %7, i64 1
%28 = getelementptr inbounds i8, i8* %27, i64 %26
%29 = icmp eq i32 %25, 0
br i1 %29, label %5, label %30
30: ; preds = %24, %10
ret void
}