#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 */
int /*<<< orphan*/ strncpy(char *, char *, size_t);
char *strrchr(char *, char);
bool GetFilePath(char *full_file_path, char *file_path) {
  char *end_of_path = strrchr(full_file_path, '/');
  if (end_of_path == NULL)
    return false;
  size_t path_len = end_of_path - full_file_path + 1;
  strncpy(file_path, full_file_path, path_len);
  file_path[path_len] = '\0';
  return true;
}


x86 assembly (clang, -O0):
<GetFilePath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1159 <GetFilePath+0x39>
movl   $0x0,-0x4(%rbp)
jmp    1190 <GetFilePath+0x70>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetFilePath>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     115c <GetFilePath+0x3c>
mov    %rax,%rbx
sub    %r15,%rbx
lea    0x1(%rbx),%rdx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strncpy@plt>
movb   $0x0,0x1(%r14,%rbx,1)
mov    $0x1,%eax
jmp    115e <GetFilePath+0x3e>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @GetFilePath(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i8* @strrchr(i8* %8, i8 signext 47)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %27
13: ; preds = %2
%14 = load i8*, i8** %6
%15 = load i8*, i8** %4
%16 = ptrtoint i8* %14 to i64
%17 = ptrtoint i8* %15 to i64
%18 = sub i64 %16, %17
%19 = add nsw i64 %18, 1
store i64 %19, i64* %7
%20 = load i8*, i8** %5
%21 = load i8*, i8** %4
%22 = load i64, i64* %7
%23 = call i32 @strncpy(i8* %20, i8* %21, i64 %22)
%24 = load i8*, i8** %5
%25 = load i64, i64* %7
%26 = getelementptr inbounds i8, i8* %24, i64 %25
store i8 0, i8* %26
store i32 1, i32* %3
br label %27
27: ; preds = %13, %12
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @GetFilePath(i8* %0, i8* %1) {
%3 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%4 = icmp eq i8* %3, null
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = ptrtoint i8* %3 to i64
%7 = ptrtoint i8* %0 to i64
%8 = sub i64 %6, %7
%9 = add nsw i64 %8, 1
%10 = tail call i32 @strncpy(i8* %1, i8* %0, i64 %9)
%11 = getelementptr inbounds i8, i8* %1, i64 %9
store i8 0, i8* %11
br label %12
12: ; preds = %2, %5
%13 = phi i32 [ 1, %5 ], [ 0, %2 ]
ret i32 %13
}