#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 *extract_substring_after_str(char *, char *);
scalar_t__ malloc(int);
char *strtok(char *, char *);
char **set_dependencies(char *line, int num_dependencies) {
  if (num_dependencies == 0) {
    return NULL;
  }
  char *dependencies_string = extract_substring_after_str(line, ":");
  char **dependencies = (char **)malloc(num_dependencies * sizeof(char *));
  num_dependencies = 0;
  char *pch = strtok(dependencies_string, " ");
  if (pch != NULL) {
    dependencies[num_dependencies] = pch;
    num_dependencies++;
  }
  while (pch != NULL) {
    pch = strtok(NULL, " ");
    if (pch != NULL) {
      dependencies[num_dependencies] = pch;
    }
    num_dependencies++;
  }
  return dependencies;
}


x86 assembly (clang, -O0):
<set_dependencies>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1156 <set_dependencies+0x26>
movq   $0x0,-0x8(%rbp)
jmp    1211 <set_dependencies+0xe1>
mov    -0x10(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1050 <extract_substring_after_str@plt>
mov    %rax,-0x20(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11bc <set_dependencies+0x8c>
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c1 <set_dependencies+0x91>
cmpq   $0x0,-0x30(%rbp)
je     1209 <set_dependencies+0xd9>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe2b(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11fb <set_dependencies+0xcb>
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c1 <set_dependencies+0x91>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_dependencies>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
je     11a8 <set_dependencies+0x78>
mov    %esi,%ebx
lea    0xebe(%rip),%rsi
call   1050 <extract_substring_after_str@plt>
mov    %rax,%r15
shl    $0x3,%ebx
mov    %ebx,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
lea    0xea4(%rip),%rsi
mov    %r15,%rdi
call   1040 <strtok@plt>
test   %rax,%rax
je     11ab <set_dependencies+0x7b>
mov    %rax,(%r14)
lea    0xe8d(%rip),%rsi
xor    %edi,%edi
call   1040 <strtok@plt>
test   %rax,%rax
je     11ab <set_dependencies+0x7b>
mov    %r14,%rbx
add    $0x8,%rbx
lea    0xe73(%rip),%r15
nop
mov    %rax,(%rbx)
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    1190 <set_dependencies+0x60>
jmp    11ab <set_dependencies+0x7b>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@.str.1 = [2 x i8] c" \00"
define i8** @set_dependencies(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 i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i8** null, i8*** %3
br label %52
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i8* @extract_substring_after_str(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %6
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 8
%18 = trunc i64 %17 to i32
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8**
store i8** %20, i8*** %7
store i32 0, i32* %5
%21 = load i8*, i8** %6
%22 = call i8* @strtok(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %22, i8** %8
%23 = load i8*, i8** %8
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %33
25: ; preds = %12
%26 = load i8*, i8** %8
%27 = load i8**, i8*** %7
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
store i8* %26, i8** %30
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %33
33: ; preds = %25, %12
br label %34
34: ; preds = %47, %33
%35 = load i8*, i8** %8
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %50
37: ; preds = %34
%38 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %38, i8** %8
%39 = load i8*, i8** %8
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %47
41: ; preds = %37
%42 = load i8*, i8** %8
%43 = load i8**, i8*** %7
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
store i8* %42, i8** %46
br label %47
47: ; preds = %41, %37
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %34
50: ; preds = %34
%51 = load i8**, i8*** %7
store i8** %51, i8*** %3
br label %52
52: ; preds = %50, %11
%53 = load i8**, i8*** %3
ret i8** %53
}

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