#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*/ strcpy(char *, char *);
char *strtok(char *, char *);
void split(char select_fields[500], char select_fields_array[][500]) {
  char *char_pointer;
  char_pointer = strtok(select_fields, " ,.-");
  int i = 0;
  while (char_pointer != NULL) {
    strcpy(select_fields_array[i], char_pointer);
    char_pointer = strtok(NULL, " ,.-");
    i++;
  }
}


x86 assembly (clang, -O0):
<split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1193 <split+0x73>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
imul   $0x1f4,%rax,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe84(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114b <split+0x2b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
lea    0xed2(%rip),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     1161 <split+0x41>
lea    0xec1(%rip),%r14
nop
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
add    $0x1f4,%rbx
test   %rax,%rax
jne    1140 <split+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c" ,.-\00"
define void @split(i8* %0, [500 x i8]* %1) {
%3 = alloca i8*
%4 = alloca [500 x i8]*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store [500 x i8]* %1, [500 x i8]** %4
%7 = load i8*, i8** %3
%8 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %5
store i32 0, i32* %6
br label %9
9: ; preds = %12, %2
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = load [500 x i8]*, [500 x i8]** %4
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [500 x i8], [500 x i8]* %13, i64 %15
%17 = getelementptr inbounds [500 x i8], [500 x i8]* %16, i64 0, i64 0
%18 = load i8*, i8** %5
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %5
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %9
23: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c" ,.-\00"
define void @split(i8* %0, [500 x i8]* %1) {
%3 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %13, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %11, %5 ], [ 0, %2 ]
%7 = phi i8* [ %10, %5 ], [ %3, %2 ]
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 %6, i64 0
%9 = tail call i32 @strcpy(i8* %8, i8* %7)
%10 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = add nuw i64 %6, 1
%12 = icmp eq i8* %10, null
br i1 %12, label %13, label %5
13: ; preds = %5, %2
ret void
}