#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 const *);
const char *sub0_path_suffix(const char *path_) {
  const char *p = path_ + strlen(path_);
  const char *end = p;
  const char *suffix = NULL;
  do {
    if ((*p == '.') && (p != end)) {
      suffix = p + 1;
      return suffix;
    }
    --p;
  } while (p != path_);
  return NULL;
}


x86 assembly (clang, -O0):
<sub0_path_suffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1184 <sub0_path_suffix+0x74>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     1184 <sub0_path_suffix+0x74>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a6 <sub0_path_suffix+0x96>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    114d <sub0_path_suffix+0x3d>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sub0_path_suffix>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
movslq %eax,%rcx
lea    (%rcx,%rbx,1),%rax
add    $0x1,%rax
xor    %edx,%edx
jmp    113d <sub0_path_suffix+0x2d>
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rax
add    $0x1,%rdx
cmp    %rdx,%rcx
je     114a <sub0_path_suffix+0x3a>
cmpb   $0x2e,-0x1(%rax)
jne    1130 <sub0_path_suffix+0x20>
test   %rdx,%rdx
je     1130 <sub0_path_suffix+0x20>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @sub0_path_suffix(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 = %13, %1
%6 = phi i8* [ %4, %1 ], [ %14, %13 ]
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 46
%9 = icmp eq i8* %6, %4
%10 = select i1 %8, i1 true, i1 %9
br i1 %10, label %13, label %11
11: ; preds = %5
%12 = getelementptr inbounds i8, i8* %6, i64 1
br label %16
13: ; preds = %5
%14 = getelementptr inbounds i8, i8* %6, i64 -1
%15 = icmp eq i8* %14, %0
br i1 %15, label %16, label %5
16: ; preds = %13, %11
%17 = phi i8* [ %12, %11 ], [ null, %13 ]
ret i8* %17
}