#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*/ strcpy(char *, char *);
char *strstr(char *, char *);
int parse_parameter(char *cmd_buffer, char *cmd_param) {
  int parsedParam = 0;
  char *spacep = strstr(cmd_buffer, " ");
  char *cmd_buffer_p = cmd_buffer;
  if (spacep) {
    while (cmd_buffer_p != spacep) {
      cmd_buffer_p++;
    }
    *cmd_buffer_p = '\0';
    spacep++;
    strcpy(cmd_param, spacep);
    parsedParam = 1;
  }
}


x86 assembly (clang, -O0):
<parse_parameter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a9 <parse_parameter+0x89>
jmp    1163 <parse_parameter+0x43>
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     1182 <parse_parameter+0x62>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1163 <parse_parameter+0x43>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_parameter>:
push   %rbx
mov    %rsi,%rbx
mov    $0x20,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1145 <parse_parameter+0x25>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i32 @parse_parameter(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
%9 = load i8*, i8** %4
%10 = call i8* @strstr(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %7
%11 = load i8*, i8** %4
store i8* %11, i8** %8
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %29
14: ; preds = %2
br label %15
15: ; preds = %19, %14
%16 = load i8*, i8** %8
%17 = load i8*, i8** %7
%18 = icmp ne i8* %16, %17
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i8*, i8** %8
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %8
br label %15
22: ; preds = %15
%23 = load i8*, i8** %8
store i8 0, i8* %23
%24 = load i8*, i8** %7
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %7
%26 = load i8*, i8** %5
%27 = load i8*, i8** %7
%28 = call i32 @strcpy(i8* %26, i8* %27)
store i32 1, i32* %6
br label %29
29: ; preds = %22, %2
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @parse_parameter(i8* %0, i8* %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 32)
%4 = icmp eq i8* %3, null
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = ptrtoint i8* %3 to i64
%7 = ptrtoint i8* %0 to i64
%8 = sub i64 %6, %7
%9 = getelementptr i8, i8* %0, i64 %8
store i8 0, i8* %9
%10 = getelementptr inbounds i8, i8* %3, i64 1
%11 = tail call i32 @strcpy(i8* %1, i8* %10)
br label %12
12: ; preds = %5, %2
ret i32 undef
}