#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 *q_internal(char *, char *, int);
int /*<<< orphan*/ s_internal(char *, char *, char *, int);
int strlen(char *);
char *subseq(char *, int, int /*<<< orphan*/);
char *file_namestring(char *path) {
  int i;
  char *ret;
  for (i = strlen(path) - 1; i >= 0 && path[i] != '/'; --i)
    ;
  ret = (path[i] == '/')
            ? subseq(path, i + 1, 0)
            : (q_internal(path,
                          "/scratch/repos/new/home/jordi_armengol_estape/"
                          "c-scraper/outputs/2022-01-22/02-19-57/repos/roswell/"
                          "roswell/refs/heads/master/src/util-dir.c",
                          104));
  (s_internal(path, "path",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/roswell/roswell/refs/heads/master/src/"
              "util-dir.c",
              105));
  return ret;
}


x86 assembly (clang, -O0):
<file_namestring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x19(%rbp)
jl     117f <file_namestring+0x3f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    118f <file_namestring+0x4f>
jmp    11a2 <file_namestring+0x62>
jmp    1194 <file_namestring+0x54>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <file_namestring+0x1b>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    11d1 <file_namestring+0x91>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
xor    %edx,%edx
call   1050 <subseq@plt>
mov    %rax,-0x28(%rbp)
jmp    11ea <file_namestring+0xaa>
mov    -0x8(%rbp),%rdi
lea    0xe24(%rip),%rsi
mov    $0x68,%edx
call   1060 <q_internal@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8e(%rip),%rsi
lea    0xdfc(%rip),%rdx
mov    $0x69,%ecx
call   1030 <s_internal@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_namestring>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%ecx
xor    %esi,%esi
test   %eax,%eax
cmovs  %eax,%esi
lea    -0x1(%rsi),%eax
nopl   0x0(%rax,%rax,1)
test   %ecx,%ecx
jle    1175 <file_namestring+0x35>
add    $0xffffffffffffffff,%rcx
mov    %ecx,%edx
cmpb   $0x2f,(%rbx,%rdx,1)
jne    1160 <file_namestring+0x20>
lea    0x1(%rcx),%esi
mov    %ecx,%eax
cltq
cmpb   $0x2f,(%rbx,%rax,1)
jne    1189 <file_namestring+0x49>
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <subseq@plt>
jmp    119d <file_namestring+0x5d>
lea    0xe70(%rip),%rsi
mov    %rbx,%rdi
mov    $0x68,%edx
call   1060 <q_internal@plt>
mov    %rax,%r14
lea    0xee4(%rip),%rsi
lea    0xe52(%rip),%rdx
mov    %rbx,%rdi
mov    $0x69,%ecx
call   1030 <s_internal@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/roswell/roswell/refs/heads/master/src/util-dir.c\00"
@.str.1 = [5 x i8] c"path\00"
define i8* @file_namestring(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = sub nsw i32 %6, 1
store i32 %7, i32* %3
br label %8
8: ; preds = %22, %1
%9 = load i32, i32* %3
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 47
br label %19
19: ; preds = %11, %8
%20 = phi i1 [ false, %8 ], [ %18, %11 ]
br i1 %20, label %21, label %25
21: ; preds = %19
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = add nsw i32 %23, -1
store i32 %24, i32* %3
br label %8
25: ; preds = %19
%26 = load i8*, i8** %2
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 47
br i1 %32, label %33, label %38
33: ; preds = %25
%34 = load i8*, i8** %2
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
%37 = call i8* @subseq(i8* %34, i32 %36, i32 0)
br label %41
38: ; preds = %25
%39 = load i8*, i8** %2
%40 = call i8* @q_internal(i8* %39, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 104)
br label %41
41: ; preds = %38, %33
%42 = phi i8* [ %37, %33 ], [ %40, %38 ]
store i8* %42, i8** %4
%43 = load i8*, i8** %2
%44 = call i32 @s_internal(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 105)
%45 = load i8*, i8** %4
ret i8* %45
}

LLVM IR (-O2):
@.str = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/roswell/roswell/refs/heads/master/src/util-dir.c\00"
@.str.1 = [5 x i8] c"path\00"
define i8* @file_namestring(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = zext i32 %2 to i64
%4 = call i32 @llvm.smin.i32(i32 %2, i32 0)
%5 = add i32 %4, -1
br label %6
6: ; preds = %11, %1
%7 = phi i64 [ %8, %11 ], [ %3, %1 ]
%8 = add nsw i64 %7, -1
%9 = trunc i64 %7 to i32
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %6
%12 = and i64 %8, 4294967295
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 47
br i1 %15, label %16, label %6
16: ; preds = %11
%17 = trunc i64 %7 to i32
%18 = trunc i64 %8 to i32
br label %19
19: ; preds = %6, %16
%20 = phi i32 [ %17, %16 ], [ %4, %6 ]
%21 = phi i32 [ %18, %16 ], [ %5, %6 ]
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 47
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = tail call i8* @subseq(i8* %0, i32 %20, i32 0)
br label %30
28: ; preds = %19
%29 = tail call i8* @q_internal(i8* %0, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 104)
br label %30
30: ; preds = %28, %26
%31 = phi i8* [ %27, %26 ], [ %29, %28 ]
%32 = tail call i32 @s_internal(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 105)
ret i8* %31
}