#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 */
size_t strlen(char *);
int get_hash(char *filename) {
  char idx;
  char *cour = &filename[strlen(filename)];
  do {
    idx = *cour;
    cour--;
    if (*cour == '/')
      return ((int)idx);
  } while (cour > filename);
  return ((int)idx);
}


x86 assembly (clang, -O0):
<get_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    116c <get_hash+0x5c>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <get_hash+0x76>
jmp    1171 <get_hash+0x61>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     113b <get_hash+0x2b>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_hash>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
lea    -0x1(%rax),%rcx
cmpb   $0x2f,(%rax)
je     1131 <get_hash+0x21>
cmp    %rbx,%rax
mov    %rcx,%rax
ja     1120 <get_hash+0x10>
movsbl 0x2(%rcx),%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @get_hash(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = getelementptr inbounds i8, i8* %6, i64 %8
store i8* %9, i8** %5
br label %10
10: ; preds = %23, %1
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
store i8 %12, i8* %4
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i32 -1
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%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 = %10
%20 = load i8, i8* %4
%21 = sext i8 %20 to i32
store i32 %21, i32* %2
br label %30
22: ; preds = %10
br label %23
23: ; preds = %22
%24 = load i8*, i8** %5
%25 = load i8*, i8** %3
%26 = icmp ugt i8* %24, %25
br i1 %26, label %10, label %27
27: ; preds = %23
%28 = load i8, i8* %4
%29 = sext i8 %28 to i32
store i32 %29, i32* %2
br label %30
30: ; preds = %27, %19
%31 = load i32, i32* %2
ret i32 %31
}

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