#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*/ strncpy(char *, char *, int);
char *strrchr(char *, char);
char *FileDirname(char *file) {
  char *dirname;
  char *lastslash;
  int len;
  lastslash = strrchr(file, '/');
  len = (lastslash == NULL) ? 0 : (int)(lastslash - file);
  dirname = (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",
      70, (sizeof(char) * (len + 2)));
  if (len > 0)
    strncpy(dirname, file, len);
  else if (*file != '/') {
    *dirname = '.';
    len = 1;
  } else {
    *dirname = '/';
    len = 1;
  }
  dirname[len] = '\0';
  return dirname;
}


x86 assembly (clang, -O0):
<FileDirname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1163 <FileDirname+0x33>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    1171 <FileDirname+0x41>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edx
lea    0xe74(%rip),%rdi
mov    $0x46,%esi
call   1050 <sre_malloc@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11b9 <FileDirname+0x89>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncpy@plt>
jmp    11ef <FileDirname+0xbf>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     11dc <FileDirname+0xac>
mov    -0x10(%rbp),%rax
movb   $0x2e,(%rax)
movl   $0x1,-0x1c(%rbp)
jmp    11ea <FileDirname+0xba>
mov    -0x10(%rbp),%rax
movb   $0x2f,(%rax)
movl   $0x1,-0x1c(%rbp)
jmp    11ef <FileDirname+0xbf>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FileDirname>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %eax,%ecx
sub    %r14d,%ecx
xor    %ebx,%ebx
test   %rax,%rax
cmovne %ecx,%ebx
lea    0x2(%rbx),%edx
lea    0xea7(%rip),%rdi
mov    $0x46,%esi
call   1050 <sre_malloc@plt>
mov    %rax,%r15
test   %ebx,%ebx
jle    117b <FileDirname+0x4b>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
mov    %ebx,%eax
jmp    1190 <FileDirname+0x60>
cmpb   $0x2f,(%r14)
jne    1187 <FileDirname+0x57>
movb   $0x2f,(%r15)
jmp    118b <FileDirname+0x5b>
movb   $0x2e,(%r15)
mov    $0x1,%eax
movb   $0x0,(%r15,%rax,1)
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
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* @FileDirname(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @strrchr(i8* %6, i8 signext 47)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
br label %18
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = load i8*, i8** %2
%14 = ptrtoint i8* %12 to i64
%15 = ptrtoint i8* %13 to i64
%16 = sub i64 %14, %15
%17 = trunc i64 %16 to i32
br label %18
18: ; preds = %11, %10
%19 = phi i32 [ 0, %10 ], [ %17, %11 ]
store i32 %19, i32* %5
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 2
%22 = sext i32 %21 to i64
%23 = mul i64 1, %22
%24 = trunc i64 %23 to i32
%25 = call i64 @sre_malloc(i8* getelementptr inbounds ([174 x i8], [174 x i8]* @.str, i64 0, i64 0), i32 70, i32 %24)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %3
%27 = load i32, i32* %5
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %18
%30 = load i8*, i8** %3
%31 = load i8*, i8** %2
%32 = load i32, i32* %5
%33 = call i32 @strncpy(i8* %30, i8* %31, i32 %32)
br label %44
34: ; preds = %18
%35 = load i8*, i8** %2
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 47
br i1 %38, label %39, label %41
39: ; preds = %34
%40 = load i8*, i8** %3
store i8 46, i8* %40
store i32 1, i32* %5
br label %43
41: ; preds = %34
%42 = load i8*, i8** %3
store i8 47, i8* %42
store i32 1, i32* %5
br label %43
43: ; preds = %41, %39
br label %44
44: ; preds = %43, %29
%45 = load i8*, i8** %3
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
store i8 0, i8* %48
%49 = load i8*, i8** %3
ret i8* %49
}

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* @FileDirname(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%3 = icmp eq i8* %2, null
%4 = ptrtoint i8* %2 to i64
%5 = ptrtoint i8* %0 to i64
%6 = sub i64 %4, %5
%7 = trunc i64 %6 to i32
%8 = select i1 %3, i32 0, i32 %7
%9 = add nsw i32 %8, 2
%10 = tail call i64 @sre_malloc(i8* getelementptr inbounds ([174 x i8], [174 x i8]* @.str, i64 0, i64 0), i32 70, i32 %9)
%11 = inttoptr i64 %10 to i8*
%12 = icmp sgt i32 %8, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = tail call i32 @strncpy(i8* %11, i8* %0, i32 %8)
%15 = zext i32 %8 to i64
br label %21
16: ; preds = %1
%17 = load i8, i8* %0
%18 = icmp eq i8 %17, 47
br i1 %18, label %20, label %19
19: ; preds = %16
store i8 46, i8* %11
br label %21
20: ; preds = %16
store i8 47, i8* %11
br label %21
21: ; preds = %19, %20, %13
%22 = phi i64 [ %15, %13 ], [ 1, %19 ], [ 1, %20 ]
%23 = getelementptr inbounds i8, i8* %11, i64 %22
store i8 0, i8* %23
ret i8* %11
}