#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 *calloc(int, int);
char *strchr(char *, char);
char *get_arg_from_pointer_malloc_ptr(char *start_ptr) {
  char *first_space = strchr(start_ptr, ' ');
  char *return_ptr = calloc(
      ((first_space ? first_space : strchr(start_ptr, '\n')) - start_ptr) + 1,
      1);
  char *rolling_ptr = return_ptr;
  while (*start_ptr != ' ' && *start_ptr != '\n' &&
         (*rolling_ptr++ = *start_ptr++))
    ;
  return return_ptr;
}


x86 assembly (clang, -O0):
<get_arg_from_pointer_malloc_ptr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1156 <get_arg_from_pointer_malloc_ptr+0x36>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1168 <get_arg_from_pointer_malloc_ptr+0x48>
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x29(%rbp)
je     11e7 <get_arg_from_pointer_malloc_ptr+0xc7>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x29(%rbp)
je     11e7 <get_arg_from_pointer_malloc_ptr+0xc7>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    -0x20(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %al,(%rcx)
movsbl %al,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11f7 <get_arg_from_pointer_malloc_ptr+0xd7>
jmp    11fc <get_arg_from_pointer_malloc_ptr+0xdc>
jmp    118f <get_arg_from_pointer_malloc_ptr+0x6f>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_arg_from_pointer_malloc_ptr>:
push   %rbx
mov    %rdi,%rbx
mov    $0x20,%esi
call   1030 <strchr@plt>
test   %rax,%rax
jne    1140 <get_arg_from_pointer_malloc_ptr+0x20>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
sub    %ebx,%eax
add    $0x1,%eax
mov    %eax,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx,%rcx,1),%edx
cmp    $0xa,%dl
je     1179 <get_arg_from_pointer_malloc_ptr+0x59>
cmp    $0x20,%dl
je     1179 <get_arg_from_pointer_malloc_ptr+0x59>
mov    %dl,(%rax,%rcx,1)
add    $0x1,%rcx
test   %dl,%dl
jne    1160 <get_arg_from_pointer_malloc_ptr+0x40>
pop    %rbx
ret

LLVM IR (-O0):
define i8* @get_arg_from_pointer_malloc_ptr(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @strchr(i8* %6, i8 signext 32)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load i8*, i8** %3
br label %15
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i8* @strchr(i8* %13, i8 signext 10)
br label %15
15: ; preds = %12, %10
%16 = phi i8* [ %11, %10 ], [ %14, %12 ]
%17 = load i8*, i8** %2
%18 = ptrtoint i8* %16 to i64
%19 = ptrtoint i8* %17 to i64
%20 = sub i64 %18, %19
%21 = add nsw i64 %20, 1
%22 = trunc i64 %21 to i32
%23 = call i8* @calloc(i32 %22, i32 1)
store i8* %23, i8** %4
%24 = load i8*, i8** %4
store i8* %24, i8** %5
br label %25
25: ; preds = %45, %15
%26 = load i8*, i8** %2
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 32
br i1 %29, label %30, label %43
30: ; preds = %25
%31 = load i8*, i8** %2
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 10
br i1 %34, label %35, label %43
35: ; preds = %30
%36 = load i8*, i8** %2
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %2
%38 = load i8, i8* %36
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %5
store i8 %38, i8* %39
%41 = sext i8 %38 to i32
%42 = icmp ne i32 %41, 0
br label %43
43: ; preds = %35, %30, %25
%44 = phi i1 [ false, %30 ], [ false, %25 ], [ %42, %35 ]
br i1 %44, label %45, label %46
45: ; preds = %43
br label %25
46: ; preds = %43
%47 = load i8*, i8** %4
ret i8* %47
}

LLVM IR (-O2):
define noalias i8* @get_arg_from_pointer_malloc_ptr(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 32)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 10)
br label %6
6: ; preds = %1, %4
%7 = phi i8* [ %5, %4 ], [ %2, %1 ]
%8 = ptrtoint i8* %7 to i64
%9 = ptrtoint i8* %0 to i64
%10 = sub i64 %8, %9
%11 = trunc i64 %10 to i32
%12 = add i32 %11, 1
%13 = tail call i8* @calloc(i32 %12, i32 1)
br label %14
14: ; preds = %18, %6
%15 = phi i8* [ %0, %6 ], [ %19, %18 ]
%16 = phi i8* [ %13, %6 ], [ %20, %18 ]
%17 = load i8, i8* %15
switch i8 %17, label %18 [
i8 32, label %22
i8 10, label %22
]
18: ; preds = %14
%19 = getelementptr inbounds i8, i8* %15, i64 1
%20 = getelementptr inbounds i8, i8* %16, i64 1
store i8 %17, i8* %16
%21 = icmp eq i8 %17, 0
br i1 %21, label %22, label %14
22: ; preds = %14, %14, %18
ret i8* %13
}