#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_tail(char *string) {
  char *c;
  c = string + strlen(string);
  int found = 0;
  while (c != string) {
    if (*c == '/') {
      found = 1;
      c++;
      break;
    }
    c--;
  }
  return c;
}


x86 assembly (clang, -O0):
<get_tail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     118b <get_tail+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    117a <get_tail+0x6a>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    118b <get_tail+0x7b>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1144 <get_tail+0x34>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tail>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
test   %eax,%eax
je     112e <get_tail+0x1e>
nop
cmpb   $0x2f,(%rbx,%rax,1)
je     1133 <get_tail+0x23>
add    $0xffffffffffffffff,%rax
jne    1120 <get_tail+0x10>
jmp    113a <get_tail+0x2a>
add    %rax,%rbx
jmp    113a <get_tail+0x2a>
add    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rax
pop    %rbx
ret

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

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