#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*/ my_err(char *, char *, int);
char *strsep(char **, char *);
int util_str_split(char *str, char **tokens, const size_t n_tok) {
  size_t i = 0;
  if (n_tok < 1) {
    my_err("%s:%d: number of tokens must be at least 1\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/"
           "util.c",
           930);
  }
  while (((tokens[i] = strsep(&str, " \t")) != NULL)) {
    if (tokens[i][0] != '\0') {
      i++;
      if (i == n_tok) {
        break;
      }
    }
  }
  return i;
}


x86 assembly (clang, -O0):
<util_str_split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x1,-0x18(%rbp)
jae    115f <util_str_split+0x3f>
lea    0xeb2(%rip),%rdi
lea    0xed7(%rip),%rsi
mov    $0x3a2,%edx
call   1040 <my_err@plt>
jmp    1164 <util_str_split+0x44>
lea    -0x8(%rbp),%rdi
lea    0xf46(%rip),%rsi
call   1030 <strsep@plt>
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rdx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
je     11cb <util_str_split+0xab>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c6 <util_str_split+0xa6>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11c1 <util_str_split+0xa1>
jmp    11cb <util_str_split+0xab>
jmp    11c6 <util_str_split+0xa6>
jmp    1164 <util_str_split+0x44>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_str_split>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,0x8(%rsp)
test   %rdx,%rdx
jne    1155 <util_str_split+0x35>
lea    0xebc(%rip),%rdi
lea    0xee1(%rip),%rsi
mov    $0x3a2,%edx
call   1040 <my_err@plt>
lea    0xf59(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1030 <strsep@plt>
mov    %rax,(%r15)
xor    %ebx,%ebx
test   %rax,%rax
je     11a5 <util_str_split+0x85>
lea    0xf3e(%rip),%r12
lea    0x8(%rsp),%r13
jmp    1194 <util_str_split+0x74>
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <strsep@plt>
mov    %rax,(%r15,%rbx,8)
test   %rax,%rax
je     11a5 <util_str_split+0x85>
cmpb   $0x0,(%rax)
je     1180 <util_str_split+0x60>
add    $0x1,%rbx
cmp    %r14,%rbx
jne    1180 <util_str_split+0x60>
mov    %r14,%rbx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"%s:%d: number of tokens must be at least 1\0A\00"
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/util.c\00"
@.str.2 = [3 x i8] c" \09\00"
define i32 @util_str_split(i8* %0, i8** %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i64 %2, i64* %6
store i64 0, i64* %7
%8 = load i64, i64* %6
%9 = icmp ult i64 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 @my_err(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 930)
br label %12
12: ; preds = %10, %3
br label %13
13: ; preds = %36, %12
%14 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = load i8**, i8*** %5
%16 = load i64, i64* %7
%17 = getelementptr inbounds i8*, i8** %15, i64 %16
store i8* %14, i8** %17
%18 = icmp ne i8* %14, null
br i1 %18, label %19, label %37
19: ; preds = %13
%20 = load i8**, i8*** %5
%21 = load i64, i64* %7
%22 = getelementptr inbounds i8*, i8** %20, i64 %21
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %36
28: ; preds = %19
%29 = load i64, i64* %7
%30 = add i64 %29, 1
store i64 %30, i64* %7
%31 = load i64, i64* %7
%32 = load i64, i64* %6
%33 = icmp eq i64 %31, %32
br i1 %33, label %34, label %35
34: ; preds = %28
br label %37
35: ; preds = %28
br label %36
36: ; preds = %35, %19
br label %13
37: ; preds = %34, %13
%38 = load i64, i64* %7
%39 = trunc i64 %38 to i32
ret i32 %39
}

LLVM IR (-O2):
@.str = [44 x i8] c"%s:%d: number of tokens must be at least 1\0A\00"
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/util.c\00"
@.str.2 = [3 x i8] c" \09\00"
define i32 @util_str_split(i8* %0, i8** nocapture writeonly %1, i64 %2) {
%4 = alloca i8*
store i8* %0, i8** %4
%5 = icmp eq i64 %2, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @my_err(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 930)
br label %8
8: ; preds = %6, %3
%9 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %9, i8** %1
%10 = icmp eq i8* %9, null
br i1 %10, label %24, label %11
11: ; preds = %8, %19
%12 = phi i8* [ %21, %19 ], [ %9, %8 ]
%13 = phi i64 [ %20, %19 ], [ 0, %8 ]
%14 = load i8, i8* %12
%15 = icmp eq i8 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = add i64 %13, 1
%18 = icmp eq i64 %17, %2
br i1 %18, label %24, label %19
19: ; preds = %16, %11
%20 = phi i64 [ %17, %16 ], [ %13, %11 ]
%21 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%22 = getelementptr inbounds i8*, i8** %1, i64 %20
store i8* %21, i8** %22
%23 = icmp eq i8* %21, null
br i1 %23, label %24, label %11
24: ; preds = %19, %16, %8
%25 = phi i64 [ 0, %8 ], [ %2, %16 ], [ %20, %19 ]
%26 = trunc i64 %25 to i32
ret i32 %26
}