#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 *calloc(int, int);
int strlen(char *);
char *strrchr(char *, char);
char *get_full_name(char *path) {
  char *fullname;
  char *full_name_iter;
  char *path_iter;
  char *last_slash = strrchr(path, '/');
  fullname = calloc(strlen(path) - (last_slash - path) + 1, sizeof(char));
  full_name_iter = fullname;
  path_iter = last_slash + 1;
  while (*path_iter != '\0') {
    *full_name_iter = *path_iter;
    full_name_iter++;
    path_iter++;
  }
  *full_name_iter = '\0';
  return fullname;
}


x86 assembly (clang, -O0):
<get_full_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cltq
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%rdx
sub    %rdx,%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c8 <get_full_name+0x98>
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    118f <get_full_name+0x5f>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_full_name>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
sub    %ebx,%r14d
lea    (%rax,%r14,1),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    0x1(%rbx),%cl
mov    %rax,%rdx
test   %cl,%cl
je     1191 <get_full_name+0x61>
add    $0x2,%rbx
mov    %rax,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %cl,(%rdx)
add    $0x1,%rdx
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    1180 <get_full_name+0x50>
movb   $0x0,(%rdx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define noalias i8* @get_full_name(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%3 = tail call i32 @strlen(i8* %0)
%4 = ptrtoint i8* %2 to i64
%5 = ptrtoint i8* %0 to i64
%6 = sub i64 %5, %4
%7 = trunc i64 %6 to i32
%8 = add i32 %3, 1
%9 = add i32 %8, %7
%10 = tail call i8* @calloc(i32 %9, i32 1)
%11 = getelementptr inbounds i8, i8* %2, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %1, %14
%15 = phi i8 [ %20, %14 ], [ %12, %1 ]
%16 = phi i8* [ %19, %14 ], [ %11, %1 ]
%17 = phi i8* [ %18, %14 ], [ %10, %1 ]
store i8 %15, i8* %17
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = getelementptr inbounds i8, i8* %16, i64 1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %14
22: ; preds = %14, %1
%23 = phi i8* [ %10, %1 ], [ %18, %14 ]
store i8 0, i8* %23
ret i8* %10
}