#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*/ free(char *);
char *parse_repo_name(char const *);
char *strchr(char const *, char);
char *strdup(char const *);
scalar_t__ strlen(char const *);
char *parse_repo_version(const char *slug, const char *fallback) {
  if (NULL == slug)
    return NULL;
  if (0 == strlen(slug))
    return NULL;
  char *name = parse_repo_name(slug);
  if (NULL == name)
    return NULL;
  free(name);
  char *version = strchr(slug, '@');
  if (version) {
    version++;
    if (0 == strlen(version))
      return NULL;
    if ('*' == version[0])
      return strdup("master");
    return strdup(version);
  }
  version = NULL;
  if (fallback)
    version = strdup(fallback);
  return version;
}


x86 assembly (clang, -O0):
<parse_repo_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1179 <parse_repo_version+0x29>
movq   $0x0,-0x8(%rbp)
jmp    127c <parse_repo_version+0x12c>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    119d <parse_repo_version+0x4d>
movq   $0x0,-0x8(%rbp)
jmp    127c <parse_repo_version+0x12c>
mov    -0x10(%rbp),%rdi
call   1060 <parse_repo_name@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    11c3 <parse_repo_version+0x73>
movq   $0x0,-0x8(%rbp)
jmp    127c <parse_repo_version+0x12c>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
mov    $0x40,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1254 <parse_repo_version+0x104>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1219 <parse_repo_version+0xc9>
movq   $0x0,-0x8(%rbp)
jmp    127c <parse_repo_version+0x12c>
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x2a,%eax
cmp    %ecx,%eax
jne    1242 <parse_repo_version+0xf2>
lea    0xdcc(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    127c <parse_repo_version+0x12c>
mov    -0x28(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    127c <parse_repo_version+0x12c>
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1274 <parse_repo_version+0x124>
mov    -0x18(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_repo_version>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     11b7 <parse_repo_version+0x67>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     11b7 <parse_repo_version+0x67>
mov    %rsi,%r14
mov    %rbx,%rdi
call   1060 <parse_repo_name@plt>
test   %rax,%rax
je     11b7 <parse_repo_version+0x67>
mov    %rax,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
mov    $0x40,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11ad <parse_repo_version+0x5d>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     11b7 <parse_repo_version+0x67>
cmpb   $0x2a,(%rbx)
jne    11c1 <parse_repo_version+0x71>
lea    0xe55(%rip),%rdi
jmp    11c4 <parse_repo_version+0x74>
test   %r14,%r14
je     11b7 <parse_repo_version+0x67>
mov    %r14,%rdi
jmp    11c4 <parse_repo_version+0x74>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <strdup@plt>

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

LLVM IR (-O2):
@.str = [7 x i8] c"master\00"
define noalias i8* @parse_repo_version(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %29, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %29, label %7
7: ; preds = %4
%8 = tail call i8* @parse_repo_name(i8* %0)
%9 = icmp eq i8* %8, null
br i1 %9, label %29, label %10
10: ; preds = %7
%11 = tail call i32 @free(i8* %8)
%12 = tail call i8* @strchr(i8* %0, i8 signext 64)
%13 = icmp eq i8* %12, null
br i1 %13, label %25, label %14
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %12, i64 1
%16 = tail call i64 @strlen(i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %29, label %18
18: ; preds = %14
%19 = load i8, i8* %15
%20 = icmp eq i8 %19, 42
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call dereferenceable_or_null(7) i8* @strdup(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %29
23: ; preds = %18
%24 = tail call i8* @strdup(i8* %15)
br label %29
25: ; preds = %10
%26 = icmp eq i8* %1, null
br i1 %26, label %29, label %27
27: ; preds = %25
%28 = tail call i8* @strdup(i8* %1)
br label %29
29: ; preds = %7, %25, %27, %14, %23, %21, %4, %2
%30 = phi i8* [ null, %2 ], [ null, %4 ], [ null, %7 ], [ %22, %21 ], [ %24, %23 ], [ null, %14 ], [ %28, %27 ], [ null, %25 ]
ret i8* %30
}