#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 atoi(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ strdup(char *);
char *strtok(char *, char *);
char **parse_track(char *track_line, int *num_track) {
  if (!track_line) {
    *num_track = 0;
    return NULL;
  }
  *num_track = atoi(strtok(track_line, "\t"));
  char **track_title = (char **)malloc(sizeof(char *) * (*num_track));
  char **tracks = track_title;
  char *track;
  while ((track = strtok(NULL, "\t")) != NULL) {
    *tracks++ = strdup(track);
  }
  return track_title;
}


x86 assembly (clang, -O0):
<parse_track>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1172 <parse_track+0x32>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    11f9 <parse_track+0xb9>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe45(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     11f1 <parse_track+0xb1>
mov    -0x30(%rbp),%rdi
call   1060 <strdup@plt>
movslq %eax,%rcx
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x28(%rbp)
mov    %rcx,(%rax)
jmp    11b0 <parse_track+0x70>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_track>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
test   %rdi,%rdi
je     11b2 <parse_track+0x72>
lea    0xeac(%rip),%r15
mov    %r15,%rsi
call   1040 <strtok@plt>
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %eax,(%rbx)
lea    0x0(,%rax,8),%edi
call   1030 <malloc@plt>
mov    %rax,%r14
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     11bb <parse_track+0x7b>
lea    0xe75(%rip),%r15
mov    %r14,%rbx
xchg   %ax,%ax
mov    %rax,%rdi
call   1060 <strdup@plt>
cltq
mov    %rax,(%rbx)
add    $0x8,%rbx
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
jne    1190 <parse_track+0x50>
jmp    11bb <parse_track+0x7b>
movl   $0x0,(%rbx)
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\09\00"
define i8** @parse_track(i8* %0, i32* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = load i32*, i32** %5
store i32 0, i32* %12
store i8** null, i8*** %3
br label %38
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @atoi(i8* %15)
%17 = load i32*, i32** %5
store i32 %16, i32* %17
%18 = load i32*, i32** %5
%19 = load i32, i32* %18
%20 = sext i32 %19 to i64
%21 = mul i64 8, %20
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i8**
store i8** %24, i8*** %6
%25 = load i8**, i8*** %6
store i8** %25, i8*** %7
br label %26
26: ; preds = %29, %13
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %27, i8** %8
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = load i8*, i8** %8
%31 = call i32 @strdup(i8* %30)
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to i8*
%34 = load i8**, i8*** %7
%35 = getelementptr inbounds i8*, i8** %34, i32 1
store i8** %35, i8*** %7
store i8* %33, i8** %34
br label %26
36: ; preds = %26
%37 = load i8**, i8*** %6
store i8** %37, i8*** %3
br label %38
38: ; preds = %36, %11
%39 = load i8**, i8*** %3
ret i8** %39
}

LLVM IR (-O2):
@.str = [2 x i8] c"\09\00"
define i8** @parse_track(i8* %0, i32* nocapture writeonly %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %4, label %5
4: ; preds = %2
store i32 0, i32* %1
br label %22
5: ; preds = %2
%6 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @atoi(i8* %6)
store i32 %7, i32* %1
%8 = shl i32 %7, 3
%9 = tail call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i8**
%11 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %22, label %13
13: ; preds = %5, %13
%14 = phi i8* [ %20, %13 ], [ %11, %5 ]
%15 = phi i8** [ %19, %13 ], [ %10, %5 ]
%16 = tail call i32 @strdup(i8* %14)
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
%19 = getelementptr inbounds i8*, i8** %15, i64 1
store i8* %18, i8** %15
%20 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %13
22: ; preds = %13, %5, %4
%23 = phi i8** [ null, %4 ], [ %10, %5 ], [ %10, %13 ]
ret i8** %23
}