#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 *append_trail_slash(int /*<<< orphan*/);
int /*<<< orphan*/ s_internal(char *, char *, char *, int);
int strlen(char *);
int /*<<< orphan*/ subseq(char *, int /*<<< orphan*/, int);
char *pathname_directory(char *path) {
  int i;
  char *ret;
  for (i = strlen(path) - 1; i >= 0 && path[i] != "/"[0]; --i)
    ;
  ret = append_trail_slash(subseq(path, 0, i));
  (s_internal(path, "path",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/JulienBoubechtoulaAmabis/roswell/refs/"
              "heads/maBranche/src/util_dir.c",
              59));
  return ret;
}


x86 assembly (clang, -O0):
<pathname_directory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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     1185 <pathname_directory+0x45>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl 0xe83(%rip),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1195 <pathname_directory+0x55>
jmp    11a8 <pathname_directory+0x68>
jmp    119a <pathname_directory+0x5a>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <pathname_directory+0x1b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
xor    %esi,%esi
call   1060 <subseq@plt>
mov    %eax,%edi
call   1050 <append_trail_slash@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe36(%rip),%rsi
lea    0xe34(%rip),%rdx
mov    $0x3b,%ecx
call   1030 <s_internal@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pathname_directory>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%ecx
xor    %edx,%edx
test   %eax,%eax
cmovs  %eax,%edx
add    $0xffffffff,%edx
nopl   0x0(%rax,%rax,1)
test   %ecx,%ecx
jle    1172 <pathname_directory+0x32>
add    $0xffffffffffffffff,%rcx
mov    %ecx,%eax
cmpb   $0x2f,(%rbx,%rax,1)
jne    1160 <pathname_directory+0x20>
mov    %ecx,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <subseq@plt>
mov    %eax,%edi
call   1050 <append_trail_slash@plt>
mov    %rax,%r14
lea    0xe73(%rip),%rsi
lea    0xe71(%rip),%rdx
mov    %rbx,%rdi
mov    $0x3b,%ecx
call   1030 <s_internal@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [5 x i8] c"path\00"
@.str.2 = [159 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/JulienBoubechtoulaAmabis/roswell/refs/heads/maBranche/src/util_dir.c\00"
define i8* @pathname_directory(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 = %24, %1
%9 = load i32, i32* %3
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %21
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 = load i8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %17, %19
br label %21
21: ; preds = %11, %8
%22 = phi i1 [ false, %8 ], [ %20, %11 ]
br i1 %22, label %23, label %27
23: ; preds = %21
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = add nsw i32 %25, -1
store i32 %26, i32* %3
br label %8
27: ; preds = %21
%28 = load i8*, i8** %2
%29 = load i32, i32* %3
%30 = call i32 @subseq(i8* %28, i32 0, i32 %29)
%31 = call i8* @append_trail_slash(i32 %30)
store i8* %31, i8** %4
%32 = load i8*, i8** %2
%33 = call i32 @s_internal(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([159 x i8], [159 x i8]* @.str.2, i64 0, i64 0), i32 59)
%34 = load i8*, i8** %4
ret i8* %34
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"path\00"
@.str.2 = [159 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/JulienBoubechtoulaAmabis/roswell/refs/heads/maBranche/src/util_dir.c\00"
define i8* @pathname_directory(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 %18
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 %8 to i32
br label %18
18: ; preds = %6, %16
%19 = phi i32 [ %17, %16 ], [ %5, %6 ]
%20 = tail call i32 @subseq(i8* %0, i32 0, i32 %19)
%21 = tail call i8* @append_trail_slash(i32 %20)
%22 = 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 ([159 x i8], [159 x i8]* @.str.2, i64 0, i64 0), i32 59)
ret i8* %21
}