#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 *substr(int, int, char *);
char *parseExtension(char *fileName) {
  char *res;
  int i = 0;
  int index = -1;
  for (; i < strlen(fileName); i++) {
    if (fileName[i] != '.') {
      continue;
    } else {
      index = i;
    }
  }
  if (index != -1) {
    res = substr(++index, strlen(fileName), fileName);
  } else {
    res = "";
  }
  return res;
}


x86 assembly (clang, -O0):
<parseExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1189 <parseExtension+0x69>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     1170 <parseExtension+0x50>
jmp    117b <parseExtension+0x5b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    117b <parseExtension+0x5b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113a <parseExtension+0x1a>
cmpl   $0xffffffff,-0x18(%rbp)
je     11bf <parseExtension+0x9f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%esi
mov    -0x8(%rbp),%rdx
call   1040 <substr@plt>
mov    %rax,-0x10(%rbp)
jmp    11ca <parseExtension+0xaa>
lea    0xe3a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseExtension>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    117b <parseExtension+0x5b>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
cmpb   $0x2e,(%r14,%rbx,1)
cmove  %ebx,%ebp
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1140 <parseExtension+0x20>
cmp    $0xffffffff,%ebp
je     117b <parseExtension+0x5b>
add    $0x1,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %eax,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <substr@plt>
lea    0xe7e(%rip),%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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