#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *copy_string(char const *);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ print_separator(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_str(int /*<<< orphan*/ *, char const *);
char *strtok(char *, char *);
void print_space_separated_str(FILE *fp, const char *str) {
  char *copy = copy_string(str);
  const char *chunk = strtok(copy, " ");
  while (chunk != NULL) {
    print_str(fp, chunk);
    chunk = strtok((char *)NULL, " ");
    if (chunk != NULL) {
      print_separator(fp);
    }
  }
  (void)free((void *)copy);
}


x86 assembly (clang, -O0):
<print_space_separated_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <copy_string@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11c6 <print_space_separated_str+0x76>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <print_str@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe5c(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11c1 <print_space_separated_str+0x71>
mov    -0x8(%rbp),%rdi
call   1030 <print_separator@plt>
jmp    1181 <print_space_separated_str+0x31>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_space_separated_str>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
mov    %rsi,%rdi
call   1050 <copy_string@plt>
mov    %rax,%r14
lea    0xe93(%rip),%rsi
mov    %rax,%rdi
call   1070 <strtok@plt>
test   %rax,%rax
je     11d5 <print_space_separated_str+0x85>
mov    %r12,%rdi
mov    %rax,%rsi
call   1060 <print_str@plt>
lea    0xe74(%rip),%rsi
xor    %edi,%edi
call   1070 <strtok@plt>
test   %rax,%rax
je     11d5 <print_space_separated_str+0x85>
mov    %rax,%rbx
lea    0xe5e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
call   1030 <print_separator@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <print_str@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11b0 <print_space_separated_str+0x60>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <free@plt>

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

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