#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 *);
char *strdup(char *);
char *strtok(char *, char *);
void parseOpts(char *opts, char *opts_array[]) {
  int i;
  char *cur;
  cur = strtok(opts, ",");
  i = 0;
  while (cur != NULL && i < 8 - 1) {
    opts_array[i] = strdup(cur);
    printf("param: %s\n", cur);
    cur = strtok(NULL, ",");
    ++i;
  }
  opts_array[i] = NULL;
}


x86 assembly (clang, -O0):
<parseOpts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x21(%rbp)
je     1175 <parseOpts+0x45>
cmpl   $0x7,-0x14(%rbp)
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1185 <parseOpts+0x55>
jmp    11cf <parseOpts+0x9f>
mov    -0x20(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe48(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <parseOpts+0x2b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseOpts>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r12
lea    0xebd(%rip),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     11a8 <parseOpts+0x78>
mov    %rax,%rbx
xor    %r13d,%r13d
lea    0xea8(%rip),%r14
lea    0xe9f(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <strdup@plt>
mov    %rax,(%r12,%r13,8)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
mov    %rax,%rbx
lea    0x1(%r13),%rax
test   %rbx,%rbx
je     11aa <parseOpts+0x7a>
cmp    $0x6,%r13
mov    %rax,%r13
jb     1170 <parseOpts+0x40>
jmp    11aa <parseOpts+0x7a>
xor    %eax,%eax
movq   $0x0,(%r12,%rax,8)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
@.str.1 = [11 x i8] c"param: %s\0A\00"
define void @parseOpts(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8** %1, i8*** %4
%7 = load i8*, i8** %3
%8 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %6
store i32 0, i32* %5
br label %9
9: ; preds = %17, %2
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 7
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ false, %9 ], [ %14, %12 ]
br i1 %16, label %17, label %29
17: ; preds = %15
%18 = load i8*, i8** %6
%19 = call i8* @strdup(i8* %18)
%20 = load i8**, i8*** %4
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
store i8* %19, i8** %23
%24 = load i8*, i8** %6
%25 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %26, i8** %6
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %9
29: ; preds = %15
%30 = load i8**, i8*** %4
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
store i8* null, i8** %33
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
@.str.1 = [11 x i8] c"param: %s\0A\00"
define void @parseOpts(i8* %0, i8** nocapture writeonly %1) {
%3 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %16, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %12, %5 ], [ 0, %2 ]
%7 = phi i8* [ %11, %5 ], [ %3, %2 ]
%8 = tail call i8* @strdup(i8* %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 %6
store i8* %8, i8** %9
%10 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%11 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = add nuw nsw i64 %6, 1
%13 = icmp ne i8* %11, null
%14 = icmp ult i64 %6, 6
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %5, label %16
16: ; preds = %5, %2
%17 = phi i64 [ 0, %2 ], [ %12, %5 ]
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
store i8* null, i8** %18
ret void
}