#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*/ memcpy(char *, char const *, size_t);
int /*<<< orphan*/ sprintf(char *, char *, char, char const *);
int /*<<< orphan*/ *strchr(char const *, char);
scalar_t__ strcmp(char const *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
char *strrchr(char const *, char);
void parse_argument(const char *in, char *testname, char *binname) {
  const char *basename;
  const char *suffix = "-test";
  size_t len;
  if (strchr(in, '/') == NULL) {
    strcpy(testname, in);
    sprintf(binname, "src%c%s-test", '/', in);
    return;
  }
  strcpy(binname, in);
  basename = strrchr(in, '/') + 1;
  if (strlen(basename) <= strlen(suffix)) {
    strcpy(testname, basename);
    return;
  }
  len = strlen(basename) - strlen(suffix);
  if (strcmp(&basename[len], suffix) != 0) {
    strcpy(testname, basename);
    return;
  }
  memcpy(testname, basename, len);
  testname[len] = '\0';
}


x86 assembly (clang, -O0):
<parse_argument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe7c(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    11d2 <parse_argument+0x62>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rcx
lea    0xe3d(%rip),%rsi
mov    $0x2f,%edx
call   1090 <sprintf@plt>
jmp    129b <parse_argument+0x12b>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jg     122d <parse_argument+0xbd>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    129b <parse_argument+0x12b>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
add    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     127e <parse_argument+0x10e>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    129b <parse_argument+0x12b>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1080 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_argument>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11e6 <parse_argument+0x76>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1060 <strrchr@plt>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x5,%rax
jle    11d6 <parse_argument+0x66>
mov    %rax,%r15
lea    (%rbx,%rax,1),%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xe3b(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     120d <parse_argument+0x9d>
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe08(%rip),%rsi
mov    %r15,%rdi
mov    $0x2f,%edx
mov    %rbx,%rcx
pop    %rbx
pop    %r14
pop    %r15
jmp    1090 <sprintf@plt>
add    $0xfffffffffffffffb,%r15
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1080 <memcpy@plt>
movb   $0x0,(%r14,%r15,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"-test\00"
@.str.1 = [13 x i8] c"src%c%s-test\00"
define void @parse_argument(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %8
%10 = load i8*, i8** %4
%11 = call i32* @strchr(i8* %10, i8 signext 47)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %20
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = load i8*, i8** %4
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = load i8*, i8** %6
%18 = load i8*, i8** %4
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8 signext 47, i8* %18)
br label %60
20: ; preds = %3
%21 = load i8*, i8** %6
%22 = load i8*, i8** %4
%23 = call i32 @strcpy(i8* %21, i8* %22)
%24 = load i8*, i8** %4
%25 = call i8* @strrchr(i8* %24, i8 signext 47)
%26 = getelementptr inbounds i8, i8* %25, i64 1
store i8* %26, i8** %7
%27 = load i8*, i8** %7
%28 = call i64 @strlen(i8* %27)
%29 = load i8*, i8** %8
%30 = call i64 @strlen(i8* %29)
%31 = icmp sle i64 %28, %30
br i1 %31, label %32, label %36
32: ; preds = %20
%33 = load i8*, i8** %5
%34 = load i8*, i8** %7
%35 = call i32 @strcpy(i8* %33, i8* %34)
br label %60
36: ; preds = %20
%37 = load i8*, i8** %7
%38 = call i64 @strlen(i8* %37)
%39 = load i8*, i8** %8
%40 = call i64 @strlen(i8* %39)
%41 = sub nsw i64 %38, %40
store i64 %41, i64* %9
%42 = load i8*, i8** %7
%43 = load i64, i64* %9
%44 = getelementptr inbounds i8, i8* %42, i64 %43
%45 = load i8*, i8** %8
%46 = call i64 @strcmp(i8* %44, i8* %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %36
%49 = load i8*, i8** %5
%50 = load i8*, i8** %7
%51 = call i32 @strcpy(i8* %49, i8* %50)
br label %60
52: ; preds = %36
%53 = load i8*, i8** %5
%54 = load i8*, i8** %7
%55 = load i64, i64* %9
%56 = call i32 @memcpy(i8* %53, i8* %54, i64 %55)
%57 = load i8*, i8** %5
%58 = load i64, i64* %9
%59 = getelementptr inbounds i8, i8* %57, i64 %58
store i8 0, i8* %59
br label %60
60: ; preds = %52, %48, %32, %13
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"-test\00"
@.str.1 = [13 x i8] c"src%c%s-test\00"
define void @parse_argument(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32* @strchr(i8* %0, i8 signext 47)
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i32 @strcpy(i8* %1, i8* %0)
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8 signext 47, i8* %0)
br label %27
9: ; preds = %3
%10 = tail call i32 @strcpy(i8* %2, i8* %0)
%11 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = tail call i64 @strlen(i8* %12)
%14 = icmp slt i64 %13, 6
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = tail call i32 @strcpy(i8* %1, i8* %12)
br label %27
17: ; preds = %9
%18 = add nsw i64 %13, -5
%19 = getelementptr inbounds i8, i8* %12, i64 %18
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = tail call i32 @strcpy(i8* %1, i8* %12)
br label %27
24: ; preds = %17
%25 = tail call i32 @memcpy(i8* %1, i8* %12, i64 %18)
%26 = getelementptr inbounds i8, i8* %1, i64 %18
store i8 0, i8* %26
br label %27
27: ; preds = %24, %22, %15, %6
ret void
}