#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 */
scalar_t__ sre_malloc(char *, int, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strrchr(char *, char);
char *FileTail(char *file, int noextension) {
  char *tail;
  char *lastslash;
  char *lastdot;
  lastslash = strrchr(file, '/');
  tail = (char *)sre_malloc(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/vinuesa/get_phylomarkers/refs/heads/master/"
      "bin/clustal-omega-1.2.4/src/squid/file.c",
      102, (sizeof(char) * (strlen(file) + 1)));
  if (lastslash == NULL)
    strcpy(tail, file);
  else
    strcpy(tail, lastslash + 1);
  if (noextension) {
    if ((lastdot = strrchr(tail, '.')) != NULL)
      *lastdot = '\0';
  }
  return tail;
}


x86 assembly (clang, -O0):
<FileTail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edx
lea    0xe84(%rip),%rdi
mov    $0x66,%esi
call   1060 <sre_malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a7 <FileTail+0x67>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11b8 <FileTail+0x78>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
cmpl   $0x0,-0xc(%rbp)
je     11ea <FileTail+0xaa>
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11e5 <FileTail+0xa5>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
jmp    11ea <FileTail+0xaa>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FileTail>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbp
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edx
lea    0xe94(%rip),%rdi
mov    $0x66,%esi
call   1060 <sre_malloc@plt>
mov    %rax,%r15
test   %rbx,%rbx
je     118a <FileTail+0x4a>
add    $0x1,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
jmp    1190 <FileTail+0x50>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
test   %r14d,%r14d
je     11af <FileTail+0x6f>
mov    %r15,%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     11af <FileTail+0x6f>
movb   $0x0,(%rax)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [174 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/vinuesa/get_phylomarkers/refs/heads/master/bin/clustal-omega-1.2.4/src/squid/file.c\00"
define i8* @FileTail(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i8*, i8** %3
%9 = call i8* @strrchr(i8* %8, i8 signext 47)
store i8* %9, i8** %6
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = mul i64 1, %13
%15 = trunc i64 %14 to i32
%16 = call i64 @sre_malloc(i8* getelementptr inbounds ([174 x i8], [174 x i8]* @.str, i64 0, i64 0), i32 102, i32 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %5
%18 = load i8*, i8** %6
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = load i8*, i8** %5
%22 = load i8*, i8** %3
%23 = call i32 @strcpy(i8* %21, i8* %22)
br label %29
24: ; preds = %2
%25 = load i8*, i8** %5
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = call i32 @strcpy(i8* %25, i8* %27)
br label %29
29: ; preds = %24, %20
%30 = load i32, i32* %4
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i8*, i8** %5
%34 = call i8* @strrchr(i8* %33, i8 signext 46)
store i8* %34, i8** %7
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load i8*, i8** %7
store i8 0, i8* %37
br label %38
38: ; preds = %36, %32
br label %39
39: ; preds = %38, %29
%40 = load i8*, i8** %5
ret i8* %40
}

LLVM IR (-O2):
@.str = [174 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/vinuesa/get_phylomarkers/refs/heads/master/bin/clustal-omega-1.2.4/src/squid/file.c\00"
define i8* @FileTail(i8* %0, i32 %1) {
%3 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%4 = tail call i32 @strlen(i8* %0)
%5 = add nsw i32 %4, 1
%6 = tail call i64 @sre_malloc(i8* getelementptr inbounds ([174 x i8], [174 x i8]* @.str, i64 0, i64 0), i32 102, i32 %5)
%7 = inttoptr i64 %6 to i8*
%8 = icmp eq i8* %3, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @strcpy(i8* %7, i8* %0)
br label %14
11: ; preds = %2
%12 = getelementptr inbounds i8, i8* %3, i64 1
%13 = tail call i32 @strcpy(i8* %7, i8* %12)
br label %14
14: ; preds = %11, %9
%15 = icmp eq i32 %1, 0
br i1 %15, label %20, label %16
16: ; preds = %14
%17 = tail call i8* @strrchr(i8* dereferenceable(1) %7, i8 signext 46)
%18 = icmp eq i8* %17, null
br i1 %18, label %20, label %19
19: ; preds = %16
store i8 0, i8* %17
br label %20
20: ; preds = %16, %19, %14
ret i8* %7
}