#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 */
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ append_or_concatenate_buffer(char **, char *, int, int,
                                                unsigned int);
char **increase_tokens_array(char **, unsigned int *);
char **update_tokens_vector(char **tokens, unsigned int *tokens_length,
                            char *buf, ssize_t buf_len, const char delimiter) {
  int i;
  int start_offset = 0;
  for (i = 0; i < buf_len; i++) {
    if (buf[i] == delimiter) {
      append_or_concatenate_buffer(tokens, buf, start_offset, i,
                                   *tokens_length);
      tokens = increase_tokens_array(tokens, tokens_length);
      start_offset = i + 1;
    }
  }
  if (start_offset < i)
    append_or_concatenate_buffer(tokens, buf, start_offset, i, *tokens_length);
  return tokens;
}


x86 assembly (clang, -O0):
<update_tokens_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8b,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b6 <update_tokens_vector+0x96>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x1d(%rbp),%ecx
cmp    %ecx,%eax
jne    11a3 <update_tokens_vector+0x83>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8d
call   1040 <append_or_concatenate_buffer@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <increase_tokens_array@plt>
mov    %rax,-0x8(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a8 <update_tokens_vector+0x88>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114b <update_tokens_vector+0x2b>
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11dc <update_tokens_vector+0xbc>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8d
call   1040 <append_or_concatenate_buffer@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_tokens_vector>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
test   %ecx,%ecx
jle    119f <update_tokens_vector+0x7f>
mov    %r8d,%r12d
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %ecx,0x4(%rsp)
mov    %ecx,%r14d
xor    %ebx,%ebx
xor    %edx,%edx
jmp    1179 <update_tokens_vector+0x59>
nopl   0x0(%rax,%rax,1)
mov    (%r15),%r8d
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %ebx,%ecx
call   1040 <append_or_concatenate_buffer@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <increase_tokens_array@plt>
mov    %rax,%r13
add    $0x1,%rbx
mov    %ebx,%edx
cmp    %r14,%rbx
je     1189 <update_tokens_vector+0x69>
cmp    %r12b,0x0(%rbp,%rbx,1)
je     1150 <update_tokens_vector+0x30>
add    $0x1,%rbx
cmp    %r14,%rbx
jne    1179 <update_tokens_vector+0x59>
mov    0x4(%rsp),%ecx
cmp    %ecx,%edx
jge    119f <update_tokens_vector+0x7f>
mov    (%r15),%r8d
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <append_or_concatenate_buffer@plt>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @update_tokens_vector(i8** %0, i32* %1, i8* %2, i32 %3, i8 signext %4) {
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8
%11 = alloca i32
%12 = alloca i32
store i8** %0, i8*** %6
store i32* %1, i32** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i8 %4, i8* %10
store i32 0, i32* %12
store i32 0, i32* %11
br label %13
13: ; preds = %41, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %9
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %44
17: ; preds = %13
%18 = load i8*, i8** %8
%19 = load i32, i32* %11
%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 = load i8, i8* %10
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %23, %25
br i1 %26, label %27, label %40
27: ; preds = %17
%28 = load i8**, i8*** %6
%29 = load i8*, i8** %8
%30 = load i32, i32* %12
%31 = load i32, i32* %11
%32 = load i32*, i32** %7
%33 = load i32, i32* %32
%34 = call i32 @append_or_concatenate_buffer(i8** %28, i8* %29, i32 %30, i32 %31, i32 %33)
%35 = load i8**, i8*** %6
%36 = load i32*, i32** %7
%37 = call i8** @increase_tokens_array(i8** %35, i32* %36)
store i8** %37, i8*** %6
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %12
br label %40
40: ; preds = %27, %17
br label %41
41: ; preds = %40
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %13
44: ; preds = %13
%45 = load i32, i32* %12
%46 = load i32, i32* %11
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %56
48: ; preds = %44
%49 = load i8**, i8*** %6
%50 = load i8*, i8** %8
%51 = load i32, i32* %12
%52 = load i32, i32* %11
%53 = load i32*, i32** %7
%54 = load i32, i32* %53
%55 = call i32 @append_or_concatenate_buffer(i8** %49, i8* %50, i32 %51, i32 %52, i32 %54)
br label %56
56: ; preds = %48, %44
%57 = load i8**, i8*** %6
ret i8** %57
}

LLVM IR (-O2):
define i8** @update_tokens_vector(i8** %0, i32* %1, i8* %2, i32 %3, i8 signext %4) {
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %35
7: ; preds = %5
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %7, %25
%10 = phi i64 [ 0, %7 ], [ %26, %25 ]
%11 = phi i32 [ 0, %7 ], [ %28, %25 ]
%12 = phi i8** [ %0, %7 ], [ %27, %25 ]
%13 = getelementptr inbounds i8, i8* %2, i64 %10
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, %4
br i1 %15, label %18, label %16
16: ; preds = %9
%17 = add nuw nsw i64 %10, 1
br label %25
18: ; preds = %9
%19 = load i32, i32* %1
%20 = trunc i64 %10 to i32
%21 = tail call i32 @append_or_concatenate_buffer(i8** %12, i8* %2, i32 %11, i32 %20, i32 %19)
%22 = tail call i8** @increase_tokens_array(i8** %12, i32* %1)
%23 = add nuw nsw i64 %10, 1
%24 = trunc i64 %23 to i32
br label %25
25: ; preds = %16, %18
%26 = phi i64 [ %17, %16 ], [ %23, %18 ]
%27 = phi i8** [ %12, %16 ], [ %22, %18 ]
%28 = phi i32 [ %11, %16 ], [ %24, %18 ]
%29 = icmp eq i64 %26, %8
br i1 %29, label %30, label %9
30: ; preds = %25
%31 = icmp slt i32 %28, %3
br i1 %31, label %32, label %35
32: ; preds = %30
%33 = load i32, i32* %1
%34 = tail call i32 @append_or_concatenate_buffer(i8** %27, i8* %2, i32 %28, i32 %3, i32 %33)
br label %35
35: ; preds = %5, %32, %30
%36 = phi i8** [ %27, %32 ], [ %27, %30 ], [ %0, %5 ]
ret i8** %36
}