#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 **dispatch_line(char const *, int *, char, int /*<<< orphan*/, int,
                     int /*<<< orphan*/ *, int *, int *);
int /*<<< orphan*/ free_string_array(char **, int);
char *get_last_argument(const char cmd[], size_t *len) {
  int argc;
  char **argv;
  int last_start = 0;
  int last_end = 0;
  argv = dispatch_line(cmd, &argc, ' ', 0, 1, NULL, &last_start, &last_end);
  *len = last_end - last_start;
  free_string_array(argv, argc);
  return (char *)cmd + last_start;
}


x86 assembly (clang, -O0):
<get_last_argument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x20,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
xor    %eax,%eax
mov    %eax,%r9d
lea    -0x24(%rbp),%r10
lea    -0x28(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <dispatch_line@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
sub    -0x24(%rbp),%eax
movslq %eax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <free_string_array@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_last_argument>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
lea    0x10(%rsp),%rax
lea    0xc(%rsp),%r10
lea    0x14(%rsp),%rsi
mov    $0x20,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
xor    %r9d,%r9d
push   %rax
push   %r10
call   1030 <dispatch_line@plt>
add    $0x10,%rsp
movslq 0x10(%rsp),%rcx
movslq 0xc(%rsp),%rdx
sub    %rdx,%rcx
mov    %rcx,(%r14)
mov    0x14(%rsp),%esi
mov    %rax,%rdi
call   1040 <free_string_array@plt>
movslq 0xc(%rsp),%rax
add    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @get_last_argument(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i64*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i64* %1, i64** %4
store i32 0, i32* %7
store i32 0, i32* %8
%9 = load i8*, i8** %3
%10 = call i8** @dispatch_line(i8* %9, i32* %5, i8 signext 32, i32 0, i32 1, i32* null, i32* %7, i32* %8)
store i8** %10, i8*** %6
%11 = load i32, i32* %8
%12 = load i32, i32* %7
%13 = sub nsw i32 %11, %12
%14 = sext i32 %13 to i64
%15 = load i64*, i64** %4
store i64 %14, i64* %15
%16 = load i8**, i8*** %6
%17 = load i32, i32* %5
%18 = call i32 @free_string_array(i8** %16, i32 %17)
%19 = load i8*, i8** %3
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
ret i8* %22
}

LLVM IR (-O2):
define i8* @get_last_argument(i8* %0, i64* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%9 = call i8** @dispatch_line(i8* %0, i32* %3, i8 signext 32, i32 0, i32 1, i32* null, i32* %4, i32* %5)
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = sub nsw i32 %10, %11
%13 = sext i32 %12 to i64
store i64 %13, i64* %1
%14 = load i32, i32* %3
%15 = call i32 @free_string_array(i8** %9, i32 %14)
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
ret i8* %18
}