#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__ is_path_sep(char const);
scalar_t__ strlen(char const *);
const char *ext_part(const char *path) {
  int n;
  for (n = (int)strlen(path) - 1; n >= 0; --n) {
    if (is_path_sep(path[n])) {
      break;
    }
    if (path[n] == '.') {
      return &path[n];
    }
  }
  return "";
}


x86 assembly (clang, -O0):
<ext_part>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11a1 <ext_part+0x81>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <is_path_sep@plt>
cmp    $0x0,%rax
je     1165 <ext_part+0x45>
jmp    11a1 <ext_part+0x81>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    118e <ext_part+0x6e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    11ac <ext_part+0x8c>
jmp    1193 <ext_part+0x73>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <ext_part+0x1b>
lea    0xe58(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ext_part>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %rax,%r15
lea    0xec6(%rip),%r12
nopw   0x0(%rax,%rax,1)
test   %r15d,%r15d
jle    1165 <ext_part+0x45>
add    $0xffffffff,%r15d
mov    %r15d,%ebx
movsbl (%r14,%rbx,1),%edi
call   1040 <is_path_sep@plt>
test   %rax,%rax
jne    1165 <ext_part+0x45>
add    %r14,%rbx
cmpb   $0x2e,(%rbx)
jne    1140 <ext_part+0x20>
jmp    1168 <ext_part+0x48>
mov    %r12,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @ext_part(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = trunc i64 %2 to i32
br label %4
4: ; preds = %14, %1
%5 = phi i32 [ %3, %1 ], [ %6, %14 ]
%6 = add nsw i32 %5, -1
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %17
8: ; preds = %4
%9 = zext i32 %6 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = tail call i64 @is_path_sep(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = load i8, i8* %10
%16 = icmp eq i8 %15, 46
br i1 %16, label %17, label %4
17: ; preds = %4, %8, %14
%18 = phi i8* [ %10, %14 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %8 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %4 ]
ret i8* %18
}