char *helper_extract_filename(const char *path) {
  char *result;
  result = rindex(path, '/');
  if (result)
    return helper_strdup(result + 1,
                         "/scratch/repos/new/home/jordi_armengol_estape/"
                         "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                         "aweeraman/debian-copyfs/refs/heads/master/helper.c",
                         310, __func__);
  else
    return helper_strdup(path,
                         "/scratch/repos/new/home/jordi_armengol_estape/"
                         "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                         "aweeraman/debian-copyfs/refs/heads/master/helper.c",
                         312, __func__);
}


x86 assembly (clang, -O0):
<helper_extract_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <rindex@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1176 <helper_extract_filename+0x56>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
lea    0xea8(%rip),%rsi
mov    $0x136,%edx
lea    0xf29(%rip),%rcx
mov    $0x0,%al
call   1030 <helper_strdup@plt>
cltq
mov    %rax,-0x8(%rbp)
jmp    119a <helper_extract_filename+0x7a>
mov    -0x10(%rbp),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x138,%edx
lea    0xf00(%rip),%rcx
mov    $0x0,%al
call   1030 <helper_strdup@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<helper_extract_filename>:
push   %rbx
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1040 <rindex@plt>
test   %rax,%rax
je     114f <helper_extract_filename+0x2f>
add    $0x1,%rax
lea    0xec2(%rip),%rsi
lea    0xf48(%rip),%rcx
mov    %rax,%rdi
mov    $0x136,%edx
jmp    1165 <helper_extract_filename+0x45>
lea    0xeaa(%rip),%rsi
lea    0xf30(%rip),%rcx
mov    %rbx,%rdi
mov    $0x138,%edx
xor    %eax,%eax
call   1030 <helper_strdup@plt>
cltq
pop    %rbx
ret

LLVM IR (-O0):
@.str = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/aweeraman/debian-copyfs/refs/heads/master/helper.c\00"
@__func__.helper_extract_filename = [24 x i8] c"helper_extract_filename\00"
define i8* @helper_extract_filename(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i8* @rindex(i8* %5, i32 47)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %15
9: ; preds = %1
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @helper_strdup to i32 (i8*, i8*, i32, i8*, ...)*)(i8* %11, i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i32 310, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @__func__.helper_extract_filename, i64 0, i64 0))
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %2
br label %20
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @helper_strdup to i32 (i8*, i8*, i32, i8*, ...)*)(i8* %16, i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i32 312, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @__func__.helper_extract_filename, i64 0, i64 0))
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %2
br label %20
20: ; preds = %15, %9
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@.str = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/aweeraman/debian-copyfs/refs/heads/master/helper.c\00"
@__func__.helper_extract_filename = [24 x i8] c"helper_extract_filename\00"
define i8* @helper_extract_filename(i8* %0) {
%2 = tail call i8* @rindex(i8* %0, i32 47)
%3 = icmp eq i8* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %2, i64 1
%6 = tail call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @helper_strdup to i32 (i8*, i8*, i32, i8*, ...)*)(i8* %5, i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i32 310, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @__func__.helper_extract_filename, i64 0, i64 0))
br label %9
7: ; preds = %1
%8 = tail call i32 (i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @helper_strdup to i32 (i8*, i8*, i32, i8*, ...)*)(i8* %0, i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i32 312, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @__func__.helper_extract_filename, i64 0, i64 0))
br label %9
9: ; preds = %7, %4
%10 = phi i32 [ %6, %4 ], [ %8, %7 ]
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i8*
ret i8* %12
}