#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 */
char *extension(char *path) {
  char *p = NULL;
  while (*path) {
    if (*path == '.')
      p = path;
    else if (*path == '/')
      p = NULL;
    path++;
  }
  return p ? p : path;
}


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

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

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

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