#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 *);
char *get_file_name_from_path(char *in) {
  int i = 0;
  for (i = strlen(in) - 1; i > 0; i--) {
    if (in[i] == '/') {
      return (in + i + 1);
    }
  }
  return in;
}


x86 assembly (clang, -O0):
<get_file_name_from_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    117c <get_file_name_from_path+0x6c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1169 <get_file_name_from_path+0x59>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1184 <get_file_name_from_path+0x74>
jmp    116e <get_file_name_from_path+0x5e>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1132 <get_file_name_from_path+0x22>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_file_name_from_path>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ecx
add    $0xffffffff,%eax
add    %rbx,%rax
add    $0x2,%rax
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x2,%ecx
jl     1146 <get_file_name_from_path+0x36>
add    $0xffffffffffffffff,%rax
cmpb   $0x2f,-0x1(%rbx,%rcx,1)
lea    -0x1(%rcx),%rcx
jne    1130 <get_file_name_from_path+0x20>
pop    %rbx
ret
mov    %rbx,%rax
pop    %rbx
ret

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

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