#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 scalar_t__ uint32_t;

/* Variables and functions */
scalar_t__ malloc(scalar_t__);
scalar_t__ strlen(char *);
void line_split(char *input, char **ptr1, char **ptr2) {
  char *word1, *word2;
  uint32_t len = strlen(input);
  word1 = (char *)malloc(len + 1);
  word2 = (char *)malloc(len + 1);
  *ptr1 = word1, *ptr2 = word2;
  while (*input && *input != ' ')
    *word1++ = *input++;
  if (*input++)
    while (*input)
      *word2++ = *input++;
  *word1 = '\0', *word2 = '\0';
}


x86 assembly (clang, -O0):
<line_split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
je     119e <line_split+0x7e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11ae <line_split+0x8e>
jmp    11d5 <line_split+0xb5>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    1179 <line_split+0x59>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
cmpb   $0x0,(%rax)
je     122b <line_split+0x10b>
jmp    11f2 <line_split+0xd2>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1226 <line_split+0x106>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
jmp    11f2 <line_split+0xd2>
jmp    122b <line_split+0x10b>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<line_split>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0x1(%rax),%r13
mov    %r13,%rdi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %r13,%rdi
call   1040 <malloc@plt>
mov    %r14,(%r12)
mov    %rax,(%r15)
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
movzbl -0x1(%rbx),%ecx
test   %cl,%cl
je     11a3 <line_split+0x83>
cmp    $0x20,%cl
je     117a <line_split+0x5a>
mov    %cl,(%r14)
add    $0x1,%r14
jmp    1160 <line_split+0x40>
mov    (%rbx),%cl
test   %cl,%cl
je     11a3 <line_split+0x83>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %cl,(%rax,%rdx,1)
movzbl 0x1(%rbx,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    1190 <line_split+0x70>
add    %rdx,%rax
movb   $0x0,(%r14)
movb   $0x0,(%rax)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @line_split(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%10 = load i8*, i8** %4
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %9
%12 = load i64, i64* %9
%13 = add nsw i64 %12, 1
%14 = call i64 @malloc(i64 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %7
%16 = load i64, i64* %9
%17 = add nsw i64 %16, 1
%18 = call i64 @malloc(i64 %17)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %8
%20 = load i8*, i8** %7
%21 = load i8**, i8*** %5
store i8* %20, i8** %21
%22 = load i8*, i8** %8
%23 = load i8**, i8*** %6
store i8* %22, i8** %23
br label %24
24: ; preds = %36, %3
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = load i8*, i8** %4
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 32
br label %34
34: ; preds = %29, %24
%35 = phi i1 [ false, %24 ], [ %33, %29 ]
br i1 %35, label %36, label %42
36: ; preds = %34
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %4
%39 = load i8, i8* %37
%40 = load i8*, i8** %7
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %7
store i8 %39, i8* %40
br label %24
42: ; preds = %34
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %4
%45 = load i8, i8* %43
%46 = icmp ne i8 %45, 0
br i1 %46, label %47, label %59
47: ; preds = %42
br label %48
48: ; preds = %52, %47
%49 = load i8*, i8** %4
%50 = load i8, i8* %49
%51 = icmp ne i8 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %48
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %4
%55 = load i8, i8* %53
%56 = load i8*, i8** %8
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %8
store i8 %55, i8* %56
br label %48
58: ; preds = %48
br label %59
59: ; preds = %58, %42
%60 = load i8*, i8** %7
store i8 0, i8* %60
%61 = load i8*, i8** %8
store i8 0, i8* %61
ret void
}

LLVM IR (-O2):
define void @line_split(i8* nocapture %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = add nsw i64 %4, 1
%6 = tail call i64 @malloc(i64 %5)
%7 = inttoptr i64 %6 to i8*
%8 = tail call i64 @malloc(i64 %5)
%9 = inttoptr i64 %8 to i8*
store i8* %7, i8** %1
store i8* %9, i8** %2
br label %10
10: ; preds = %18, %3
%11 = phi i8* [ %7, %3 ], [ %20, %18 ]
%12 = phi i8* [ %0, %3 ], [ %19, %18 ]
%13 = load i8, i8* %12
switch i8 %13, label %18 [
i8 0, label %29
i8 32, label %14
]
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %12, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %29, label %21
18: ; preds = %10
%19 = getelementptr inbounds i8, i8* %12, i64 1
%20 = getelementptr inbounds i8, i8* %11, i64 1
store i8 %13, i8* %11
br label %10
21: ; preds = %14, %21
%22 = phi i8 [ %27, %21 ], [ %16, %14 ]
%23 = phi i8* [ %26, %21 ], [ %15, %14 ]
%24 = phi i8* [ %25, %21 ], [ %9, %14 ]
%25 = getelementptr inbounds i8, i8* %24, i64 1
store i8 %22, i8* %24
%26 = getelementptr inbounds i8, i8* %23, i64 1
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %21
29: ; preds = %10, %21, %14
%30 = phi i8* [ %9, %14 ], [ %25, %21 ], [ %9, %10 ]
store i8 0, i8* %11
store i8 0, i8* %30
ret void
}