#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 *);
extern char *GetExt(char *name) {
  char *p;
  p = name + strlen(name);
  while ((p != name) && (*p != '\\') && (*p != '/') && (*p != '.')) {
    p--;
  }
  return (p);
}


x86 assembly (clang, -O0):
<GetExt>:
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)
je     118a <GetExt+0x7a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x5c,%ecx
mov    %al,-0x19(%rbp)
je     118a <GetExt+0x7a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0x19(%rbp)
je     118a <GetExt+0x7a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    119a <GetExt+0x8a>
jmp    11ab <GetExt+0x9b>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    113d <GetExt+0x2d>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetExt>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
test   %eax,%eax
je     114b <GetExt+0x3b>
movabs $0x400000000003,%rcx
jmp    1136 <GetExt+0x26>
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rax
je     114e <GetExt+0x3e>
movzbl (%rbx,%rax,1),%edx
add    $0xd2,%dl
cmp    $0x2e,%dl
ja     1130 <GetExt+0x20>
movzbl %dl,%edx
bt     %rdx,%rcx
jae    1130 <GetExt+0x20>
add    %rax,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @GetExt(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 = %30, %1
%10 = load i8*, i8** %3
%11 = load i8*, i8** %2
%12 = icmp ne i8* %10, %11
br i1 %12, label %13, label %28
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 92
br i1 %17, label %18, label %28
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 47
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 46
br label %28
28: ; preds = %23, %18, %13, %9
%29 = phi i1 [ false, %18 ], [ false, %13 ], [ false, %9 ], [ %27, %23 ]
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 -1
store i8* %32, i8** %3
br label %9
33: ; preds = %28
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
define i8* @GetExt(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 eq i32 %2, 0
br i1 %5, label %12, label %6
6: ; preds = %1, %9
%7 = phi i8* [ %10, %9 ], [ %4, %1 ]
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 92, label %12
i8 47, label %12
i8 46, label %12
]
9: ; preds = %6
%10 = getelementptr inbounds i8, i8* %7, i64 -1
%11 = icmp eq i8* %10, %0
br i1 %11, label %12, label %6
12: ; preds = %9, %6, %6, %6, %1
%13 = phi i8* [ %4, %1 ], [ %7, %6 ], [ %7, %6 ], [ %7, %6 ], [ %0, %9 ]
ret i8* %13
}