#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(char *in) {
  char *s = in, *e = in;
  while (*e != '\0') {
    if (*e == '\\') {
      s = e + 1;
    }
    e++;
  }
  int len;
  if ((len = strlen(s)) > 16)
    s += (len - 16);
  return s;
}


x86 assembly (clang, -O0):
<get_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1169 <get_file+0x59>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1158 <get_file+0x48>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <get_file+0x1c>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x10,%eax
jle    1192 <get_file+0x82>
mov    -0x1c(%rbp),%ecx
sub    $0x10,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_file>:
push   %rbx
mov    %rdi,%rbx
lea    0x1(%rdi),%rax
jmp    1127 <get_file+0x17>
nopw   0x0(%rax,%rax,1)
mov    %rax,%rbx
add    $0x1,%rax
movzbl -0x1(%rax),%ecx
cmp    $0x5c,%cl
je     1120 <get_file+0x10>
test   %cl,%cl
jne    1123 <get_file+0x13>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    -0x10(%rax),%edx
xor    %ecx,%ecx
cmp    $0x11,%eax
cmovge %edx,%ecx
add    %rbx,%rcx
mov    %rcx,%rax
pop    %rbx
ret

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

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