#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 */
const char *pt_path_ext(const char *path) {
  const char *ext, *p;
  for (p = path; *p; p++) {
    if (*p == '/') {
      ext = NULL;
    } else if (*p == '.') {
      ext = p;
    }
  }
  if (ext == NULL) {
    ext = p;
  }
  return ext;
}


x86 assembly (clang, -O0):
<pt_path_ext>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     116d <pt_path_ext+0x6d>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    113a <pt_path_ext+0x3a>
movq   $0x0,-0x10(%rbp)
jmp    1157 <pt_path_ext+0x57>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1152 <pt_path_ext+0x52>
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1157 <pt_path_ext+0x57>
jmp    115c <pt_path_ext+0x5c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1110 <pt_path_ext+0x10>
cmpq   $0x0,-0x10(%rbp)
jne    1180 <pt_path_ext+0x80>
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pt_path_ext>:
mov    %rdi,%rax
jmp    1119 <pt_path_ext+0x19>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edx,%edx
add    $0x1,%rax
mov    %rdx,%rsi
movzbl (%rax),%ecx
mov    %rax,%rdx
cmp    $0x2e,%cl
je     1112 <pt_path_ext+0x12>
cmp    $0x2f,%cl
je     1110 <pt_path_ext+0x10>
test   %cl,%cl
je     1132 <pt_path_ext+0x32>
mov    %rsi,%rdx
jmp    1112 <pt_path_ext+0x12>
test   %rsi,%rsi
cmovne %rsi,%rax
ret

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

LLVM IR (-O2):
define i8* @pt_path_ext(i8* %0) {
br label %2
2: ; preds = %8, %1
%3 = phi i8* [ undef, %1 ], [ %9, %8 ]
%4 = phi i8* [ %0, %1 ], [ %10, %8 ]
%5 = load i8, i8* %4
switch i8 %5, label %7 [
i8 0, label %11
i8 47, label %8
i8 46, label %6
]
6: ; preds = %2
br label %8
7: ; preds = %2
br label %8
8: ; preds = %2, %7, %6
%9 = phi i8* [ %4, %6 ], [ null, %2 ], [ %3, %7 ]
%10 = getelementptr inbounds i8, i8* %4, i64 1
br label %2
11: ; preds = %2
%12 = icmp eq i8* %3, null
%13 = select i1 %12, i8* %4, i8* %3
ret i8* %13
}