char *build_dest_name(const char *full_path) {
  assert(full_path);
  char *fname = strrchr(full_path, '/');
  assert(fname);
  fname++;
  assert(fname[0] != '\0' && (fname[0] != '.' || fname[1] != '\0'));
  char *dest;
  if (asprintf(&dest, "%s/%s", build_dest_dir(full_path), fname) == -1)
    do {
      char msgout[500];
      snprintf(msgout, 500, "Error %s: %s:%d %s", "asprintf",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/netblue30/firejail/refs/"
               "heads/master/src/firejail/fs_lib.c",
               129, __FUNCTION__);
      perror(msgout);
      exit(1);
    } while (0);
  return dest;
}


x86 assembly (clang, -O0):
<build_dest_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x211(%rbp)
je     1203 <build_dest_name+0x93>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2e,%ecx
mov    %al,-0x212(%rbp)
jne    11f7 <build_dest_name+0x87>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x212(%rbp)
mov    -0x212(%rbp),%al
mov    %al,-0x211(%rbp)
mov    -0x211(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <build_dest_dir@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rcx
lea    -0x18(%rbp),%rdi
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   1060 <asprintf@plt>
cmp    $0xffffffff,%eax
jne    1297 <build_dest_name+0x127>
jmp    1246 <build_dest_name+0xd6>
lea    -0x210(%rbp),%rdi
mov    $0x1f4,%esi
lea    0xdad(%rip),%rdx
lea    0xdb9(%rip),%rcx
lea    0xdbb(%rip),%r8
mov    $0x81,%r9d
lea    0xe43(%rip),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    -0x210(%rbp),%rdi
mov    $0x0,%al
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_dest_name>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rdi,%r15
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r15,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <assert@plt>
lea    0x1(%rbx),%r14
mov    0x1(%rbx),%al
test   %al,%al
je     11c3 <build_dest_name+0x53>
cmp    $0x2e,%al
jne    11be <build_dest_name+0x4e>
xor    %ebp,%ebp
cmpb   $0x0,0x2(%rbx)
setne  %bpl
jmp    11c3 <build_dest_name+0x53>
mov    $0x1,%ebp
mov    %ebp,%edi
xor    %eax,%eax
call   1050 <assert@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <build_dest_dir@plt>
lea    0xe23(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    %eax,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <asprintf@plt>
cmp    $0xffffffff,%eax
je     1206 <build_dest_name+0x96>
mov    0x8(%rsp),%rax
add    $0x208,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeaa(%rip),%rax
mov    %rax,(%rsp)
lea    0xdee(%rip),%rdx
lea    0xdfa(%rip),%rcx
lea    0xdfc(%rip),%r8
lea    0x10(%rsp),%rbx
mov    $0x1f4,%esi
mov    %rbx,%rdi
mov    $0x81,%r9d
xor    %eax,%eax
call   1030 <snprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [19 x i8] c"Error %s: %s:%d %s\00"
@.str.2 = [9 x i8] c"asprintf\00"
@.str.3 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/netblue30/firejail/refs/heads/master/src/firejail/fs_lib.c\00"
@__FUNCTION__.build_dest_name = [16 x i8] c"build_dest_name\00"
define i8* @build_dest_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [500 x i8]
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %6)
%8 = load i8*, i8** %2
%9 = call i8* @strrchr(i8* %8, i32 47)
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %10)
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %3
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %33
19: ; preds = %1
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 46
br i1 %24, label %31, label %25
25: ; preds = %19
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br label %31
31: ; preds = %25, %19
%32 = phi i1 [ true, %19 ], [ %30, %25 ]
br label %33
33: ; preds = %31, %1
%34 = phi i1 [ false, %1 ], [ %32, %31 ]
%35 = zext i1 %34 to i32
%36 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %35)
%37 = load i8*, i8** %2
%38 = call i32 (i8*, ...) bitcast (i32 (...)* @build_dest_dir to i32 (i8*, ...)*)(i8* %37)
%39 = load i8*, i8** %3
%40 = call i32 (i8**, i8*, i32, i8*, ...) bitcast (i32 (...)* @asprintf to i32 (i8**, i8*, i32, i8*, ...)*)(i8** %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %38, i8* %39)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %49
42: ; preds = %33
br label %43
43: ; preds = %42
%44 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%45 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %44, i64 500, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.3, i64 0, i64 0), i32 129, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__FUNCTION__.build_dest_name, i64 0, i64 0))
%46 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%47 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* %46)
unreachable
48: ; No predecessors!
br label %49
49: ; preds = %48, %33
%50 = load i8*, i8** %4
ret i8* %50
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [19 x i8] c"Error %s: %s:%d %s\00"
@.str.2 = [9 x i8] c"asprintf\00"
@.str.3 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/netblue30/firejail/refs/heads/master/src/firejail/fs_lib.c\00"
@__FUNCTION__.build_dest_name = [16 x i8] c"build_dest_name\00"
define i8* @build_dest_name(i8* %0) {
%2 = alloca i8*
%3 = alloca [500 x i8]
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %0)
%5 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i32 47)
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %5)
%7 = getelementptr inbounds i8, i8* %5, i64 1
%8 = load i8, i8* %7
switch i8 %8, label %14 [
i8 0, label %15
i8 46, label %9
]
9: ; preds = %1
%10 = getelementptr inbounds i8, i8* %5, i64 2
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
%13 = zext i1 %12 to i32
br label %15
14: ; preds = %1
br label %15
15: ; preds = %1, %14, %9
%16 = phi i32 [ 0, %1 ], [ %13, %9 ], [ 1, %14 ]
%17 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %16)
%18 = bitcast i8** %2 to i8*
%19 = tail call i32 (i8*, ...) bitcast (i32 (...)* @build_dest_dir to i32 (i8*, ...)*)(i8* %0)
%20 = call i32 (i8**, i8*, i32, i8*, ...) bitcast (i32 (...)* @asprintf to i32 (i8**, i8*, i32, i8*, ...)*)(i8** %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %19, i8* %7)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %26
22: ; preds = %15
%23 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%24 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %23, i64 500, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.3, i64 0, i64 0), i32 129, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__FUNCTION__.build_dest_name, i64 0, i64 0))
%25 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* %23)
unreachable
26: ; preds = %15
%27 = load i8*, i8** %2
ret i8* %27
}