#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 *last_component(char *name) {
  char *slash;
  for (slash = name + strlen(name); slash > name;) {
    --slash;
    if (*slash == '/')
      return (slash + 1);
  }
  return (name);
}


x86 assembly (clang, -O0):
<last_component>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jbe    117d <last_component+0x6d>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1178 <last_component+0x68>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1185 <last_component+0x75>
jmp    113d <last_component+0x2d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<last_component>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
xchg   %ax,%ax
cmp    %rbx,%rax
jbe    1139 <last_component+0x29>
lea    -0x1(%rax),%rcx
cmpb   $0x2f,-0x1(%rax)
mov    %rcx,%rax
jne    1120 <last_component+0x10>
add    $0x1,%rcx
mov    %rcx,%rbx
mov    %rbx,%rax
pop    %rbx
ret

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

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