#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 *basename(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
char *get_file_name(char *full_path) {
  char file_name[256];
  sprintf(file_name, "%s", basename(full_path));
  int i = strlen(file_name) - 1;
  while ((i > 0) && (file_name[i] != '.'))
    i--;
  if (i > 0)
    file_name[i] = 0;
  return file_name;
}


x86 assembly (clang, -O0):
<get_file_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <basename@plt>
mov    -0x120(%rbp),%rdi
mov    %rax,%rdx
lea    0xe99(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x114(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x114(%rbp)
mov    %al,-0x121(%rbp)
jle    11b1 <get_file_name+0x81>
movslq -0x114(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x121(%rbp)
mov    -0x121(%rbp),%al
test   $0x1,%al
jne    11c4 <get_file_name+0x94>
jmp    11d8 <get_file_name+0xa8>
mov    -0x114(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x114(%rbp)
jmp    1181 <get_file_name+0x51>
cmpl   $0x0,-0x114(%rbp)
jle    11f4 <get_file_name+0xc4>
movslq -0x114(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_file_name>:
push   %rbx
sub    $0x100,%rsp
call   1050 <basename@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
add    $0xffffffff,%eax
add    %rbx,%rax
add    $0x1,%rax
nop
cmp    $0x2,%ecx
jl     1177 <get_file_name+0x47>
add    $0xffffffffffffffff,%rax
cmpb   $0x2e,-0x1(%rsp,%rcx,1)
lea    -0x1(%rcx),%rcx
jne    1160 <get_file_name+0x30>
movb   $0x0,(%rax)
mov    %rsp,%rax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i8* @get_file_name(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i32
store i8* %0, i8** %2
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = load i8*, i8** %2
%7 = call i8* @basename(i8* %6)
%8 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %4
br label %12
12: ; preds = %24, %1
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 46
br label %22
22: ; preds = %15, %12
%23 = phi i1 [ false, %12 ], [ %21, %15 ]
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = load i32, i32* %4
%26 = add nsw i32 %25, -1
store i32 %26, i32* %4
br label %12
27: ; preds = %22
%28 = load i32, i32* %4
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %32
store i8 0, i8* %33
br label %34
34: ; preds = %30, %27
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
ret i8* %35
}

LLVM IR (-O2):
define i8* @get_file_name(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i8* @basename(i8* %0)
%5 = call i8* @strcpy(i8* %3, i8* dereferenceable(1) %4)
%6 = call i32 @strlen(i8* %3)
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %13, %1
%9 = phi i64 [ %10, %13 ], [ %7, %1 ]
%10 = add nsw i64 %9, -1
%11 = trunc i64 %9 to i32
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %10
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 46
br i1 %16, label %17, label %8
17: ; preds = %13
%18 = and i64 %10, 4294967295
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %18
store i8 0, i8* %19
br label %20
20: ; preds = %8, %17
ret i8* %3
}