#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 strlen(char *);
void taka_tstring_delete_file_name_from_path(char *str) {
  char *p = str + strlen(str);
  for (; p != str; p--) {
    if (*p == '/') {
      p[1] = '\0';
      break;
    }
  }
}


x86 assembly (clang, -O0):
<taka_tstring_delete_file_name_from_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     117e <taka_tstring_delete_file_name_from_path+0x6e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1168 <taka_tstring_delete_file_name_from_path+0x58>
mov    -0x10(%rbp),%rax
movb   $0x0,0x1(%rax)
jmp    117e <taka_tstring_delete_file_name_from_path+0x6e>
jmp    116d <taka_tstring_delete_file_name_from_path+0x5d>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    113d <taka_tstring_delete_file_name_from_path+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<taka_tstring_delete_file_name_from_path>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
je     112c <taka_tstring_delete_file_name_from_path+0x1c>
cltq
nop
cmpb   $0x2f,(%rbx,%rax,1)
je     112e <taka_tstring_delete_file_name_from_path+0x1e>
add    $0xffffffffffffffff,%rax
jne    1120 <taka_tstring_delete_file_name_from_path+0x10>
pop    %rbx
ret
movb   $0x0,0x1(%rbx,%rax,1)
pop    %rbx
ret

LLVM IR (-O0):
define void @taka_tstring_delete_file_name_from_path(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %4, i64 %7
store i8* %8, i8** %3
br label %9
9: ; preds = %22, %1
%10 = load i8*, i8** %3
%11 = load i8*, i8** %2
%12 = icmp ne i8* %10, %11
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 47
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8 0, i8* %20
br label %25
21: ; preds = %13
br label %22
22: ; preds = %21
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i32 -1
store i8* %24, i8** %3
br label %9
25: ; preds = %18, %9
ret void
}

LLVM IR (-O2):
define void @taka_tstring_delete_file_name_from_path(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
br label %7
7: ; preds = %4, %13
%8 = phi i8* [ %14, %13 ], [ %6, %4 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 47
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %8, i64 1
store i8 0, i8* %12
br label %16
13: ; preds = %7
%14 = getelementptr inbounds i8, i8* %8, i64 -1
%15 = icmp eq i8* %14, %0
br i1 %15, label %16, label %7
16: ; preds = %13, %1, %11
ret void
}