#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 */
char *strtok(char *, char const *);
void populate(char **names, char *str) {
  int i = 0;
  const char quotes[4] = "\",\"";
  char *token;
  token = strtok(str, quotes);
  names[i++] = token;
  while (token != NULL) {
    token = strtok(NULL, quotes);
    names[i++] = token;
  }
}


x86 assembly (clang, -O0):
<populate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xed3(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
cmpq   $0x0,-0x20(%rbp)
je     1196 <populate+0x86>
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    115b <populate+0x4b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<populate>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %rdi,%rbx
movl   $0x222c22,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    %rax,%rdi
call   1030 <strtok@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     1156 <populate+0x46>
add    $0x8,%rbx
lea    0x4(%rsp),%r14
xor    %edi,%edi
mov    %r14,%rsi
call   1030 <strtok@plt>
mov    %rax,(%rbx)
add    $0x8,%rbx
test   %rax,%rax
jne    1140 <populate+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @populate(i8** nocapture writeonly %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 2239522, i32* %3
%5 = call i8* @strtok(i8* %1, i8* %4)
store i8* %5, i8** %0
%6 = icmp eq i8* %5, null
br i1 %6, label %13, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %10, %7 ], [ 1, %2 ]
%9 = call i8* @strtok(i8* null, i8* %4)
%10 = add nuw i64 %8, 1
%11 = getelementptr inbounds i8*, i8** %0, i64 %8
store i8* %9, i8** %11
%12 = icmp eq i8* %9, null
br i1 %12, label %13, label %7
13: ; preds = %7, %2
ret void
}