#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 */
struct dynamic_buffer {
  int dummy;
};

/* Variables and functions */
char *dynbuffer_data(struct dynamic_buffer *);
int /*<<< orphan*/ dynbuffer_free(struct dynamic_buffer *);
struct dynamic_buffer *dynbuffer_unattached_mode_new();
int /*<<< orphan*/ dynbuffer_write(struct dynamic_buffer *, char const *, int);
char *parse_token_cmdarg(const char **pp) {
  const char *p = *pp;
  struct dynamic_buffer *token_buff = dynbuffer_unattached_mode_new();
  while (*p != '\0' && *p != ' ' && *p != '\t') {
    if (*p == '\\') {
      p++;
      if (*p != '\0') {
        dynbuffer_write(token_buff, p, 1);
        p++;
      } else
        break;
    } else {
      dynbuffer_write(token_buff, p, 1);
      p++;
    }
  }
  *pp = p;
  char *data = dynbuffer_data(token_buff);
  dynbuffer_free(token_buff);
  return data;
}


x86 assembly (clang, -O0):
<parse_token_cmdarg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <dynbuffer_unattached_mode_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     119c <parse_token_cmdarg+0x5c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x21(%rbp)
je     119c <parse_token_cmdarg+0x5c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11ac <parse_token_cmdarg+0x6c>
jmp    1228 <parse_token_cmdarg+0xe8>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1205 <parse_token_cmdarg+0xc5>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11fb <parse_token_cmdarg+0xbb>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
call   1040 <dynbuffer_write@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1200 <parse_token_cmdarg+0xc0>
jmp    1228 <parse_token_cmdarg+0xe8>
jmp    1223 <parse_token_cmdarg+0xe3>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
call   1040 <dynbuffer_write@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1162 <parse_token_cmdarg+0x22>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <dynbuffer_data@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <dynbuffer_free@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_token_cmdarg>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%rbx
xor    %eax,%eax
call   1060 <dynbuffer_unattached_mode_new@plt>
mov    %rax,%r15
movabs $0x100000201,%r12
jmp    1190 <parse_token_cmdarg+0x50>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rbx),%rsi
mov    $0x2,%r13d
cmpb   $0x0,0x1(%rbx)
je     11b8 <parse_token_cmdarg+0x78>
mov    %r15,%rdi
mov    $0x1,%edx
call   1040 <dynbuffer_write@plt>
add    %r13,%rbx
movzbl (%rbx),%eax
cmp    $0x5c,%al
je     1170 <parse_token_cmdarg+0x30>
mov    $0x1,%r13d
cmp    $0x20,%al
ja     11b0 <parse_token_cmdarg+0x70>
movzbl %al,%eax
bt     %rax,%r12
mov    %rbx,%rsi
jae    1180 <parse_token_cmdarg+0x40>
jmp    11b5 <parse_token_cmdarg+0x75>
nop
mov    %rbx,%rsi
jmp    1180 <parse_token_cmdarg+0x40>
mov    %rbx,%rsi
mov    %rsi,(%r14)
mov    %r15,%rdi
call   1030 <dynbuffer_data@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1050 <dynbuffer_free@plt>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.dynamic_buffer = type { i32 }
define i8* @parse_token_cmdarg(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = tail call %struct.dynamic_buffer* (...) @dynbuffer_unattached_mode_new()
br label %4
4: ; preds = %11, %1
%5 = phi i8* [ %2, %1 ], [ %15, %11 ]
%6 = load i8, i8* %5
switch i8 %6, label %11 [
i8 0, label %16
i8 32, label %16
i8 9, label %16
i8 92, label %7
]
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %5, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %4, %7
%12 = phi i8* [ %8, %7 ], [ %5, %4 ]
%13 = phi i64 [ 2, %7 ], [ 1, %4 ]
%14 = tail call i32 @dynbuffer_write(%struct.dynamic_buffer* %3, i8* %12, i32 1)
%15 = getelementptr inbounds i8, i8* %5, i64 %13
br label %4
16: ; preds = %4, %4, %4, %7
%17 = phi i8* [ %8, %7 ], [ %5, %4 ], [ %5, %4 ], [ %5, %4 ]
store i8* %17, i8** %0
%18 = tail call i8* @dynbuffer_data(%struct.dynamic_buffer* %3)
%19 = tail call i32 @dynbuffer_free(%struct.dynamic_buffer* %3)
ret i8* %18
}