#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
char *strtok(int /*<<< orphan*/, char *);
void print_buffer(FILE *dst, char *p, int newline) {
  if (p) {
    fprintf(dst, "%s", p);
    p = strtok(0, "");
    if (p)
      fprintf(dst, " %s", p);
  }
  if (newline)
    fputc('\n', dst);
}


x86 assembly (clang, -O0):
<print_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1198 <print_buffer+0x68>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xea4(%rip),%rsi
call   1040 <fprintf@plt>
xor    %edi,%edi
lea    0xe98(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1193 <print_buffer+0x63>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe72(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1198 <print_buffer+0x68>
cmpl   $0x0,-0x14(%rbp)
je     11b0 <print_buffer+0x80>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_buffer>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
test   %rsi,%rsi
je     117d <print_buffer+0x3d>
mov    %rsi,%rdi
mov    %rbx,%rsi
call   1030 <fputs@plt>
lea    0xea4(%rip),%rsi
xor    %edi,%edi
call   1060 <strtok@plt>
test   %rax,%rax
je     117d <print_buffer+0x3d>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1050 <fprintf@plt>
test   %ebp,%ebp
je     1194 <print_buffer+0x54>
mov    $0xa,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <fputc@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [4 x i8] c" %s\00"
define void @print_buffer(i32* nocapture %0, i8* %1, i32 %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = tail call i32 @fputs(i8* %1, i32* %0)
%7 = tail call i8* @strtok(i32 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %11
11: ; preds = %5, %9, %3
%12 = icmp eq i32 %2, 0
br i1 %12, label %15, label %13
13: ; preds = %11
%14 = tail call i32 @fputc(i8 signext 10, i32* %0)
br label %15
15: ; preds = %13, %11
ret void
}