#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 *);
char *GetExtensionFromFilename(char *Filename) {
  int i;
  char *pExtension = 0;
  int FilenameLength = strlen(Filename);
  if (FilenameLength != 0) {
    for (i = FilenameLength - 1; i >= 0; i--) {
      char ch;
      ch = Filename[i];
      if (ch == '.') {
        pExtension = &Filename[i + 1];
        break;
      }
    }
  }
  return pExtension;
}


x86 assembly (clang, -O0):
<GetExtensionFromFilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1199 <GetExtensionFromFilename+0x89>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1194 <GetExtensionFromFilename+0x84>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0x2e,%eax
jne    1181 <GetExtensionFromFilename+0x71>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    1194 <GetExtensionFromFilename+0x84>
jmp    1186 <GetExtensionFromFilename+0x76>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <GetExtensionFromFilename+0x33>
jmp    1199 <GetExtensionFromFilename+0x89>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetExtensionFromFilename>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
je     1146 <GetExtensionFromFilename+0x36>
mov    %eax,%ecx
lea    (%rcx,%rbx,1),%rdx
add    $0x1,%rdx
nopw   0x0(%rax,%rax,1)
test   %eax,%eax
jle    1146 <GetExtensionFromFilename+0x36>
lea    -0x1(%rdx),%rcx
add    $0xffffffff,%eax
cmpb   $0x2e,-0x2(%rdx)
mov    %rcx,%rdx
jne    1130 <GetExtensionFromFilename+0x20>
jmp    1148 <GetExtensionFromFilename+0x38>
xor    %ecx,%ecx
mov    %rcx,%rax
pop    %rbx
ret

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

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