char *strtok_r(char *s, const char *delimiters, char **save_ptr) {
  char *token;
  if (delimiters != ((void *)0)) {
  } else {
    debug_panic("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/kumarjatin/pintos-selfrr/"
                "refs/heads/master/src/lib/string.c",
                240, __func__, "assertion `%s' failed.", "delimiters != NULL");
  };
  if (save_ptr != ((void *)0)) {
  } else {
    debug_panic("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/kumarjatin/pintos-selfrr/"
                "refs/heads/master/src/lib/string.c",
                241, __func__, "assertion `%s' failed.", "save_ptr != NULL");
  };
  if (s == ((void *)0))
    s = *save_ptr;
  if (s != ((void *)0)) {
  } else {
    debug_panic("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/kumarjatin/pintos-selfrr/"
                "refs/heads/master/src/lib/string.c",
                247, __func__, "assertion `%s' failed.", "s != NULL");
  };
  while (strchr(delimiters, *s) != ((void *)0)) {
    if (*s == '\0') {
      *save_ptr = s;
      return ((void *)0);
    }
    s++;
  }
  token = s;
  while (strchr(delimiters, *s) == ((void *)0))
    s++;
  if (*s != '\0') {
    *s = '\0';
    *save_ptr = s + 1;
  } else
    *save_ptr = s;
  return token;
}


x86 assembly (clang, -O0):
<strtok_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1144 <strtok_r+0x24>
jmp    116c <strtok_r+0x4c>
lea    0xeb5(%rip),%rdi
mov    $0xf0,%esi
lea    0xf3f(%rip),%rdx
lea    0xf41(%rip),%rcx
lea    0xf51(%rip),%r8
mov    $0x0,%al
call   1040 <debug_panic@plt>
cmpq   $0x0,-0x20(%rbp)
je     117c <strtok_r+0x5c>
jmp    11a4 <strtok_r+0x84>
lea    0xe7d(%rip),%rdi
mov    $0xf1,%esi
lea    0xf07(%rip),%rdx
lea    0xf09(%rip),%rcx
lea    0xf2c(%rip),%r8
mov    $0x0,%al
call   1040 <debug_panic@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11ba <strtok_r+0x9a>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11ca <strtok_r+0xaa>
jmp    11f2 <strtok_r+0xd2>
lea    0xe2f(%rip),%rdi
mov    $0xf7,%esi
lea    0xeb9(%rip),%rdx
lea    0xebb(%rip),%rcx
lea    0xed4(%rip),%r8
mov    $0x0,%al
call   1040 <debug_panic@plt>
jmp    11f7 <strtok_r+0xd7>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     124a <strtok_r+0x12a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1239 <strtok_r+0x119>
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    12bb <strtok_r+0x19b>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11f7 <strtok_r+0xd7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
jne    127d <strtok_r+0x15d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1252 <strtok_r+0x132>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12a8 <strtok_r+0x188>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    12b3 <strtok_r+0x193>
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtok_r>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
test   %rsi,%rsi
je     1146 <strtok_r+0x26>
test   %r14,%r14
je     1173 <strtok_r+0x53>
test   %r12,%r12
jne    11d3 <strtok_r+0xb3>
jmp    11a0 <strtok_r+0x80>
lea    0xeb3(%rip),%rdi
lea    0xf42(%rip),%rdx
lea    0xf44(%rip),%rcx
lea    0xf54(%rip),%r8
mov    $0xf0,%esi
xor    %eax,%eax
call   1040 <debug_panic@plt>
test   %r14,%r14
jne    113b <strtok_r+0x1b>
lea    0xe86(%rip),%rdi
lea    0xf15(%rip),%rdx
lea    0xf17(%rip),%rcx
lea    0xf3a(%rip),%r8
mov    $0xf1,%esi
xor    %eax,%eax
call   1040 <debug_panic@plt>
test   %r12,%r12
jne    11d3 <strtok_r+0xb3>
mov    (%r14),%r12
test   %r12,%r12
jne    11d3 <strtok_r+0xb3>
lea    0xe51(%rip),%rdi
lea    0xee0(%rip),%rdx
lea    0xee2(%rip),%rcx
lea    0xefb(%rip),%r8
xor    %r12d,%r12d
mov    $0xf7,%esi
xor    %eax,%eax
call   1040 <debug_panic@plt>
mov    (%r12),%bl
nopw   0x0(%rax,%rax,1)
movsbl %bl,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1202 <strtok_r+0xe2>
test   %bl,%bl
je     1246 <strtok_r+0x126>
movzbl 0x1(%r12),%ebx
add    $0x1,%r12
jmp    11e0 <strtok_r+0xc0>
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <strchr@plt>
mov    %r12,%rbp
test   %rax,%rax
jne    1238 <strtok_r+0x118>
mov    %r12,%rbp
nopw   0x0(%rax,%rax,1)
movzbl 0x1(%rbp),%ebx
add    $0x1,%rbp
movsbl %bl,%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     1220 <strtok_r+0x100>
test   %bl,%bl
je     124c <strtok_r+0x12c>
movb   $0x0,0x0(%rbp)
add    $0x1,%rbp
jmp    124c <strtok_r+0x12c>
mov    %r12,%rbp
xor    %r12d,%r12d
mov    %rbp,(%r14)
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [150 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kumarjatin/pintos-selfrr/refs/heads/master/src/lib/string.c\00"
@__func__.strtok_r = [9 x i8] c"strtok_r\00"
@.str.1 = [23 x i8] c"assertion `%s' failed.\00"
@.str.2 = [19 x i8] c"delimiters != NULL\00"
@.str.3 = [17 x i8] c"save_ptr != NULL\00"
@.str.4 = [10 x i8] c"s != NULL\00"
define i8* @strtok_r(i8* %0, i8* %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %3
br label %14
12: ; preds = %3
%13 = call i32 (i8*, i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @debug_panic to i32 (i8*, i32, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str, i64 0, i64 0), i32 240, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.strtok_r, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %11
%15 = load i8**, i8*** %7
%16 = icmp ne i8** %15, null
br i1 %16, label %17, label %18
17: ; preds = %14
br label %20
18: ; preds = %14
%19 = call i32 (i8*, i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @debug_panic to i32 (i8*, i32, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str, i64 0, i64 0), i32 241, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.strtok_r, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %17
%21 = load i8*, i8** %5
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i8**, i8*** %7
%25 = load i8*, i8** %24
store i8* %25, i8** %5
br label %26
26: ; preds = %23, %20
%27 = load i8*, i8** %5
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %30
29: ; preds = %26
br label %32
30: ; preds = %26
%31 = call i32 (i8*, i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @debug_panic to i32 (i8*, i32, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str, i64 0, i64 0), i32 247, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.strtok_r, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %29
br label %33
33: ; preds = %48, %32
%34 = load i8*, i8** %6
%35 = load i8*, i8** %5
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = call i8* @strchr(i8* %34, i32 %37)
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %51
40: ; preds = %33
%41 = load i8*, i8** %5
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = load i8*, i8** %5
%47 = load i8**, i8*** %7
store i8* %46, i8** %47
store i8* null, i8** %4
br label %78
48: ; preds = %40
%49 = load i8*, i8** %5
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %5
br label %33
51: ; preds = %33
%52 = load i8*, i8** %5
store i8* %52, i8** %8
br label %53
53: ; preds = %60, %51
%54 = load i8*, i8** %6
%55 = load i8*, i8** %5
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = call i8* @strchr(i8* %54, i32 %57)
%59 = icmp eq i8* %58, null
br i1 %59, label %60, label %63
60: ; preds = %53
%61 = load i8*, i8** %5
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %5
br label %53
63: ; preds = %53
%64 = load i8*, i8** %5
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %73
68: ; preds = %63
%69 = load i8*, i8** %5
store i8 0, i8* %69
%70 = load i8*, i8** %5
%71 = getelementptr inbounds i8, i8* %70, i64 1
%72 = load i8**, i8*** %7
store i8* %71, i8** %72
br label %76
73: ; preds = %63
%74 = load i8*, i8** %5
%75 = load i8**, i8*** %7
store i8* %74, i8** %75
br label %76
76: ; preds = %73, %68
%77 = load i8*, i8** %8
store i8* %77, i8** %4
br label %78
78: ; preds = %76, %45
%79 = load i8*, i8** %4
ret i8* %79
}

LLVM IR (-O2):
@.str = [150 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kumarjatin/pintos-selfrr/refs/heads/master/src/lib/string.c\00"
@__func__.strtok_r = [9 x i8] c"strtok_r\00"
@.str.1 = [23 x i8] c"assertion `%s' failed.\00"
@.str.2 = [19 x i8] c"delimiters != NULL\00"
@.str.3 = [17 x i8] c"save_ptr != NULL\00"
@.str.4 = [10 x i8] c"s != NULL\00"
define i8* @strtok_r(i8* %0, i8* %1, i8** %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @debug_panic to i32 (i8*, i32, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str, i64 0, i64 0), i32 240, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.strtok_r, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %3, %5
%8 = icmp eq i8** %2, null
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @debug_panic to i32 (i8*, i32, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str, i64 0, i64 0), i32 241, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.strtok_r, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %11
11: ; preds = %7, %9
%12 = icmp eq i8* %0, null
br i1 %12, label %13, label %18
13: ; preds = %11
%14 = load i8*, i8** %2
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) bitcast (i32 (...)* @debug_panic to i32 (i8*, i32, i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str, i64 0, i64 0), i32 247, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.strtok_r, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %11, %13, %16
%19 = phi i8* [ %14, %13 ], [ null, %16 ], [ %0, %11 ]
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = tail call i8* @strchr(i8* dereferenceable(1) %1, i32 %21)
%23 = icmp eq i8* %22, null
br i1 %23, label %26, label %32
24: ; preds = %36
%25 = sext i8 %38 to i32
br label %26
26: ; preds = %24, %18
%27 = phi i32 [ %21, %18 ], [ %25, %24 ]
%28 = phi i8* [ %19, %18 ], [ %37, %24 ]
%29 = phi i8 [ %20, %18 ], [ %38, %24 ]
%30 = tail call i8* @strchr(i8* dereferenceable(1) %1, i32 %27)
%31 = icmp eq i8* %30, null
br i1 %31, label %42, label %49
32: ; preds = %18, %36
%33 = phi i8 [ %38, %36 ], [ %20, %18 ]
%34 = phi i8* [ %37, %36 ], [ %19, %18 ]
%35 = icmp eq i8 %33, 0
br i1 %35, label %55, label %36
36: ; preds = %32
%37 = getelementptr inbounds i8, i8* %34, i64 1
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = tail call i8* @strchr(i8* dereferenceable(1) %1, i32 %39)
%41 = icmp eq i8* %40, null
br i1 %41, label %24, label %32
42: ; preds = %26, %42
%43 = phi i8* [ %44, %42 ], [ %28, %26 ]
%44 = getelementptr inbounds i8, i8* %43, i64 1
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = tail call i8* @strchr(i8* dereferenceable(1) %1, i32 %46)
%48 = icmp eq i8* %47, null
br i1 %48, label %42, label %49
49: ; preds = %42, %26
%50 = phi i8 [ %29, %26 ], [ %45, %42 ]
%51 = phi i8* [ %28, %26 ], [ %44, %42 ]
%52 = icmp eq i8 %50, 0
br i1 %52, label %55, label %53
53: ; preds = %49
store i8 0, i8* %51
%54 = getelementptr inbounds i8, i8* %51, i64 1
br label %55
55: ; preds = %32, %53, %49
%56 = phi i8* [ %54, %53 ], [ %51, %49 ], [ %34, %32 ]
%57 = phi i8* [ %28, %53 ], [ %28, %49 ], [ null, %32 ]
store i8* %56, i8** %2
ret i8* %57
}