#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 strlen(char *);
void get_cmd_arg(char **cmdname, char **arg, char *line) {
  *cmdname = line;
  int len = strlen(line);
  *(line + len - 1) = '\0';
  len--;
  for (; len > 0; len--) {
    if (*++line == ' ') {
      *line = '\0';
      while (*++line == ' ')
        ;
      *arg = line;
      return;
    }
  }
  *arg = NULL;
}


x86 assembly (clang, -O0):
<get_cmd_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,-0x1(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11c2 <get_cmd_arg+0xb2>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x20,%eax
jne    11af <get_cmd_arg+0x9f>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x20,%eax
jne    119f <get_cmd_arg+0x8f>
jmp    117e <get_cmd_arg+0x6e>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    11cd <get_cmd_arg+0xbd>
jmp    11b4 <get_cmd_arg+0xa4>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <get_cmd_arg+0x41>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cmd_arg>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdx,(%rdi)
mov    %rdx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
movb   $0x0,-0x1(%rbx,%rcx,1)
xor    %ecx,%ecx
nop
cmp    $0x2,%eax
jl     115d <get_cmd_arg+0x4d>
add    $0xffffffff,%eax
lea    0x1(%rbx),%rdx
cmpb   $0x20,0x1(%rbx)
mov    %rdx,%rbx
jne    1130 <get_cmd_arg+0x20>
movb   $0x0,(%rdx)
nopl   0x0(%rax,%rax,1)
lea    0x1(%rdx),%rcx
cmpb   $0x20,0x1(%rdx)
mov    %rcx,%rdx
je     1150 <get_cmd_arg+0x40>
mov    %rcx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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