#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 *basename(char *);
int /*<<< orphan*/ x_free(char *, char *, int);
char *x_strdup(char *, char *, unsigned int);
char *x_basename(char *path, char *file, unsigned int line) {
  char *tmpstr;
  char *rdir;
  char *retstr;
  tmpstr = x_strdup(
      path,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/rootfs/lessfs/refs/heads/master/lib_safe.c",
      659);
  rdir = basename(tmpstr);
  retstr = x_strdup(rdir, file, line);
  x_free(tmpstr,
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/rootfs/lessfs/refs/heads/master/lib_safe.c",
         662);
  return retstr;
}


x86 assembly (clang, -O0):
<x_basename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb2(%rip),%rsi
mov    $0x293,%edx
call   1050 <x_strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <basename@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <x_strdup@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe78(%rip),%rsi
mov    $0x296,%edx
call   1030 <x_free@plt>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x_basename>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%rbx
lea    0xebc(%rip),%r14
mov    %r14,%rsi
mov    $0x293,%edx
call   1050 <x_strdup@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1040 <basename@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1050 <x_strdup@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x296,%edx
call   1030 <x_free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [133 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/rootfs/lessfs/refs/heads/master/lib_safe.c\00"
define i8* @x_basename(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i8*, i8** %4
%11 = call i8* @x_strdup(i8* %10, i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str, i64 0, i64 0), i32 659)
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = call i8* @basename(i8* %12)
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = load i8*, i8** %5
%16 = load i32, i32* %6
%17 = call i8* @x_strdup(i8* %14, i8* %15, i32 %16)
store i8* %17, i8** %9
%18 = load i8*, i8** %7
%19 = call i32 @x_free(i8* %18, i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str, i64 0, i64 0), i32 662)
%20 = load i8*, i8** %9
ret i8* %20
}

LLVM IR (-O2):
@.str = [133 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/rootfs/lessfs/refs/heads/master/lib_safe.c\00"
define i8* @x_basename(i8* %0, i8* %1, i32 %2) {
%4 = tail call i8* @x_strdup(i8* %0, i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str, i64 0, i64 0), i32 659)
%5 = tail call i8* @basename(i8* %4)
%6 = tail call i8* @x_strdup(i8* %5, i8* %1, i32 %2)
%7 = tail call i32 @x_free(i8* %4, i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str, i64 0, i64 0), i32 662)
ret i8* %6
}