#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 */
unsigned int strlen(char const *);
const char *FindExt(const char *Name) {
  const char *S;
  unsigned Len = strlen(Name);
  if (Len < 2) {
    return 0;
  }
  S = Name + Len - 1;
  while (S >= Name && *S != '.' && *S != '\\' && *S != '/') {
    --S;
  }
  if (*S == '.') {
    return S;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<FindExt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jae    113f <FindExt+0x2f>
movq   $0x0,-0x8(%rbp)
jmp    11e4 <FindExt+0xd4>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x1d(%rbp)
jb     119e <FindExt+0x8e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2e,%ecx
mov    %al,-0x1d(%rbp)
je     119e <FindExt+0x8e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x5c,%ecx
mov    %al,-0x1d(%rbp)
je     119e <FindExt+0x8e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11ae <FindExt+0x9e>
jmp    11bf <FindExt+0xaf>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1151 <FindExt+0x41>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11dc <FindExt+0xcc>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e4 <FindExt+0xd4>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FindExt>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x2,%eax
jae    1122 <FindExt+0x12>
xor    %eax,%eax
pop    %rbx
ret
mov    %eax,%eax
lea    (%rax,%rbx,1),%rsi
add    $0xffffffffffffffff,%rsi
movabs $0x400000000003,%rax
cs nopw 0x0(%rax,%rax,1)
mov    %rsi,%rcx
movzbl (%rsi),%edx
cmp    %rbx,%rsi
jb     1162 <FindExt+0x52>
lea    -0x1(%rcx),%rsi
lea    -0x2e(%rdx),%edi
cmp    $0x2e,%dil
ja     1140 <FindExt+0x30>
movzbl %dil,%edi
bt     %rdi,%rax
jae    1140 <FindExt+0x30>
xor    %eax,%eax
cmp    $0x2e,%dl
cmove  %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @FindExt(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ult i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %1
store i8* null, i8** %2
br label %49
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = load i32, i32* %5
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = getelementptr inbounds i8, i8* %15, i64 -1
store i8* %16, i8** %4
br label %17
17: ; preds = %38, %11
%18 = load i8*, i8** %4
%19 = load i8*, i8** %3
%20 = icmp uge i8* %18, %19
br i1 %20, label %21, label %36
21: ; preds = %17
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 46
br i1 %25, label %26, label %36
26: ; preds = %21
%27 = load i8*, i8** %4
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 92
br i1 %30, label %31, label %36
31: ; preds = %26
%32 = load i8*, i8** %4
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 47
br label %36
36: ; preds = %31, %26, %21, %17
%37 = phi i1 [ false, %26 ], [ false, %21 ], [ false, %17 ], [ %35, %31 ]
br i1 %37, label %38, label %41
38: ; preds = %36
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 -1
store i8* %40, i8** %4
br label %17
41: ; preds = %36
%42 = load i8*, i8** %4
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 46
br i1 %45, label %46, label %48
46: ; preds = %41
%47 = load i8*, i8** %4
store i8* %47, i8** %2
br label %49
48: ; preds = %41
store i8* null, i8** %2
br label %49
49: ; preds = %48, %46, %10
%50 = load i8*, i8** %2
ret i8* %50
}

LLVM IR (-O2):
define i8* @FindExt(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp ult i32 %2, 2
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
br label %7
7: ; preds = %12, %4
%8 = phi i8* [ %6, %4 ], [ %9, %12 ]
%9 = getelementptr inbounds i8, i8* %8, i64 -1
%10 = icmp ult i8* %9, %0
%11 = load i8, i8* %9
br i1 %10, label %13, label %12
12: ; preds = %7
switch i8 %11, label %7 [
i8 46, label %13
i8 92, label %13
i8 47, label %13
]
13: ; preds = %12, %12, %12, %7
%14 = icmp eq i8 %11, 46
%15 = select i1 %14, i8* %9, i8* null
br label %16
16: ; preds = %13, %1
%17 = phi i8* [ null, %1 ], [ %15, %13 ]
ret i8* %17
}