#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 */
scalar_t__ isalnum(char const);
int strlen(char const *);
const char *dprintf_file_tail(const char *file) {
  const char *tail = file + strlen(file);
  while (tail > file &&
         (isalnum(tail[-1]) || tail[-1] == '.' || tail[-1] == '_'))
    --tail;
  return tail;
}


x86 assembly (clang, -O0):
<dprintf_file_tail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x19(%rbp)
jbe    11ac <dprintf_file_tail+0x8c>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%edi
call   1040 <isalnum@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1a(%rbp)
jne    11a6 <dprintf_file_tail+0x86>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%ecx
mov    $0x1,%al
cmp    $0x2e,%ecx
mov    %al,-0x1a(%rbp)
je     11a6 <dprintf_file_tail+0x86>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11bc <dprintf_file_tail+0x9c>
jmp    11cd <dprintf_file_tail+0xad>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    114d <dprintf_file_tail+0x2d>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dprintf_file_tail>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
cltq
lea    (%r14,%rax,1),%rbx
test   %eax,%eax
jg     1149 <dprintf_file_tail+0x29>
jmp    1163 <dprintf_file_tail+0x43>
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rbx
cmp    %r14,%rbx
jbe    1163 <dprintf_file_tail+0x43>
movsbl -0x1(%rbx),%edi
call   1040 <isalnum@plt>
test   %rax,%rax
jne    1140 <dprintf_file_tail+0x20>
movzbl -0x1(%rbx),%eax
cmp    $0x5f,%al
je     1140 <dprintf_file_tail+0x20>
cmp    $0x2e,%al
je     1140 <dprintf_file_tail+0x20>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @dprintf_file_tail(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %4, i64 %7
store i8* %8, i8** %3
br label %9
9: ; preds = %35, %1
%10 = load i8*, i8** %3
%11 = load i8*, i8** %2
%12 = icmp ugt i8* %10, %11
br i1 %12, label %13, label %33
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 -1
%16 = load i8, i8* %15
%17 = call i64 @isalnum(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %31, label %19
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 -1
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 46
br i1 %24, label %31, label %25
25: ; preds = %19
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 -1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 95
br label %31
31: ; preds = %25, %19, %13
%32 = phi i1 [ true, %19 ], [ true, %13 ], [ %30, %25 ]
br label %33
33: ; preds = %31, %9
%34 = phi i1 [ false, %9 ], [ %32, %31 ]
br i1 %34, label %35, label %38
35: ; preds = %33
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i32 -1
store i8* %37, i8** %3
br label %9
38: ; preds = %33
%39 = load i8*, i8** %3
ret i8* %39
}

LLVM IR (-O2):
define i8* @dprintf_file_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 sgt i32 %2, 0
br i1 %5, label %6, label %16
6: ; preds = %1, %14
%7 = phi i8* [ %8, %14 ], [ %4, %1 ]
%8 = getelementptr inbounds i8, i8* %7, i64 -1
%9 = load i8, i8* %8
%10 = tail call i64 @isalnum(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = load i8, i8* %8
switch i8 %13, label %16 [
i8 46, label %14
i8 95, label %14
]
14: ; preds = %12, %12, %6
%15 = icmp ugt i8* %8, %0
br i1 %15, label %6, label %16
16: ; preds = %14, %12, %1
%17 = phi i8* [ %4, %1 ], [ %7, %12 ], [ %8, %14 ]
ret i8* %17
}