#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 /*<<< orphan*/ message(char *, char *, char *);
char *strdup(char *);
char *strtok(char *, char *);
void print_line_prefix(char *buf, char *prefix) {
  buf = strdup(buf);
  char *cur = strtok(buf, "\r\n");
  while (cur != NULL) {
    message("%s%s\n", prefix, cur);
    cur = strtok(NULL, "\r\n");
  }
}


x86 assembly (clang, -O0):
<print_line_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1199 <print_line_prefix+0x69>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe88(%rip),%rdi
call   1030 <message@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe75(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    1161 <print_line_prefix+0x31>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_line_prefix>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
call   1050 <strdup@plt>
lea    0xebc(%rip),%rsi
mov    %rax,%rdi
call   1040 <strtok@plt>
test   %rax,%rax
je     117d <print_line_prefix+0x4d>
lea    0xeab(%rip),%r14
lea    0xea1(%rip),%r15
nop
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1030 <message@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
jne    1160 <print_line_prefix+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [6 x i8] c"%s%s\0A\00"
define void @print_line_prefix(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i8* @strdup(i8* %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %5
br label %10
10: ; preds = %13, %2
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i8*, i8** %4
%15 = load i8*, i8** %5
%16 = call i32 @message(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %15)
%17 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %17, i8** %5
br label %10
18: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [6 x i8] c"%s%s\0A\00"
define void @print_line_prefix(i8* nocapture %0, i8* %1) {
%3 = tail call i8* @strdup(i8* %0)
%4 = tail call i8* @strtok(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %11, label %6
6: ; preds = %2, %6
%7 = phi i8* [ %9, %6 ], [ %4, %2 ]
%8 = tail call i32 @message(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %7)
%9 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %6
11: ; preds = %6, %2
ret void
}