#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 /*<<< orphan*/, int);
char *get_pointer_to_arg(char *, int);
int /*<<< orphan*/ strlen(char *);
char *get_arg_from_command(char *start, int arg) {
  char *buffer = calloc(strlen(start), 1);
  char *rolling = buffer;
  start = get_pointer_to_arg(start, arg);
  while (*start != '\n' && *start != ' ' && (*rolling++ = *start++))
    ;
  return buffer;
}


x86 assembly (clang, -O0):
<get_arg_from_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <get_pointer_to_arg@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x21(%rbp)
je     11c8 <get_arg_from_command+0x98>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x21(%rbp)
je     11c8 <get_arg_from_command+0x98>
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,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11d8 <get_arg_from_command+0xa8>
jmp    11dd <get_arg_from_command+0xad>
jmp    1170 <get_arg_from_command+0x40>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_arg_from_command>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbp
call   1040 <strlen@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %r14d,%esi
call   1030 <get_pointer_to_arg@plt>
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
movzbl (%rax,%rcx,1),%edx
cmp    $0xa,%dl
je     1179 <get_arg_from_command+0x49>
cmp    $0x20,%dl
je     1179 <get_arg_from_command+0x49>
mov    %dl,(%rbx,%rcx,1)
add    $0x1,%rcx
test   %dl,%dl
jne    1160 <get_arg_from_command+0x30>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @get_arg_from_command(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = call i8* @calloc(i32 %8, i32 1)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
store i8* %10, i8** %6
%11 = load i8*, i8** %3
%12 = load i32, i32* %4
%13 = call i8* @get_pointer_to_arg(i8* %11, i32 %12)
store i8* %13, i8** %3
br label %14
14: ; preds = %34, %2
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 10
br i1 %18, label %19, label %32
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 32
br i1 %23, label %24, label %32
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
%27 = load i8, i8* %25
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %6
store i8 %27, i8* %28
%30 = sext i8 %27 to i32
%31 = icmp ne i32 %30, 0
br label %32
32: ; preds = %24, %19, %14
%33 = phi i1 [ false, %19 ], [ false, %14 ], [ %31, %24 ]
br i1 %33, label %34, label %35
34: ; preds = %32
br label %14
35: ; preds = %32
%36 = load i8*, i8** %5
ret i8* %36
}

LLVM IR (-O2):
define noalias i8* @get_arg_from_command(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i8* @calloc(i32 %3, i32 1)
%5 = tail call i8* @get_pointer_to_arg(i8* %0, i32 %1)
br label %6
6: ; preds = %10, %2
%7 = phi i8* [ %5, %2 ], [ %11, %10 ]
%8 = phi i8* [ %4, %2 ], [ %12, %10 ]
%9 = load i8, i8* %7
switch i8 %9, label %10 [
i8 10, label %14
i8 32, label %14
]
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %9, i8* %8
%13 = icmp eq i8 %9, 0
br i1 %13, label %14, label %6
14: ; preds = %6, %6, %10
ret i8* %4
}