#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*/ strcpy(char *, char const *);
int strlen(char const *);
void normalize_file_name(char out_name[32], const char *full_path) {
  const char *end = full_path + strlen(full_path) - 1;
  const char *begin = end;
  while (begin > full_path && begin[-1] != '/')
    begin--;
  if (end - begin > 32 - 1) {
    begin = end - (32 - 1);
  }
  strcpy(out_name, begin);
}


x86 assembly (clang, -O0):
<normalize_file_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x29(%rbp)
jbe    1181 <normalize_file_name+0x61>
mov    -0x20(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1191 <normalize_file_name+0x71>
jmp    11a2 <normalize_file_name+0x82>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    115d <normalize_file_name+0x3d>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x1f,%rax
jle    11c3 <normalize_file_name+0xa3>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffe1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize_file_name>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
movslq %eax,%rcx
lea    (%r15,%rcx,1),%rax
add    $0xffffffffffffffff,%rax
lea    (%r15,%rcx,1),%rdi
add    $0xffffffffffffffe0,%rdi
xor    %ecx,%ecx
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
mov    %rdi,%rsi
mov    %rdx,%rbx
lea    (%rax,%rcx,1),%rdx
cmp    %r15,%rdx
jbe    1172 <normalize_file_name+0x52>
lea    -0x1(%rsi),%rdi
lea    0x1(%rbx),%rdx
cmpb   $0x2f,-0x1(%rax,%rcx,1)
lea    -0x1(%rcx),%rcx
jne    1150 <normalize_file_name+0x30>
cmp    $0x20,%rbx
mov    $0x1f,%eax
cmovge %rbx,%rax
add    %rax,%rsi
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
define void @normalize_file_name(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = getelementptr inbounds i8, i8* %11, i64 -1
store i8* %12, i8** %5
%13 = load i8*, i8** %5
store i8* %13, i8** %6
br label %14
14: ; preds = %26, %2
%15 = load i8*, i8** %6
%16 = load i8*, i8** %4
%17 = icmp ugt i8* %15, %16
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i64 -1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 47
br label %24
24: ; preds = %18, %14
%25 = phi i1 [ false, %14 ], [ %23, %18 ]
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = load i8*, i8** %6
%28 = getelementptr inbounds i8, i8* %27, i32 -1
store i8* %28, i8** %6
br label %14
29: ; preds = %24
%30 = load i8*, i8** %5
%31 = load i8*, i8** %6
%32 = ptrtoint i8* %30 to i64
%33 = ptrtoint i8* %31 to i64
%34 = sub i64 %32, %33
%35 = icmp sgt i64 %34, 31
br i1 %35, label %36, label %39
36: ; preds = %29
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i64 -31
store i8* %38, i8** %6
br label %39
39: ; preds = %36, %29
%40 = load i8*, i8** %3
%41 = load i8*, i8** %6
%42 = call i32 @strcpy(i8* %40, i8* %41)
ret void
}

LLVM IR (-O2):
define void @normalize_file_name(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %1, i64 %4
%6 = getelementptr inbounds i8, i8* %5, i64 -1
br label %7
7: ; preds = %10, %2
%8 = phi i8* [ %6, %2 ], [ %11, %10 ]
%9 = icmp ugt i8* %8, %1
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %8, i64 -1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 47
br i1 %13, label %14, label %7
14: ; preds = %7, %10
%15 = ptrtoint i8* %6 to i64
%16 = ptrtoint i8* %8 to i64
%17 = sub i64 %15, %16
%18 = icmp sgt i64 %17, 31
%19 = getelementptr inbounds i8, i8* %6, i64 -31
%20 = select i1 %18, i8* %19, i8* %8
%21 = tail call i32 @strcpy(i8* %0, i8* %20)
ret void
}