#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 *mutilsBasename(char *);
int strlen(char *);
char *mutilsExtension(char *path) {
  char *base, *cptr;
  base = mutilsBasename(path);
  for (cptr = base + strlen(base); cptr >= base; --cptr) {
    switch (*cptr) {
    case '.': {
      return ++cptr;
    }
    }
  }
  return path;
}


x86 assembly (clang, -O0):
<mutilsExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <mutilsBasename@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jb     11a6 <mutilsExtension+0x86>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
sub    $0x2e,%al
jne    1190 <mutilsExtension+0x70>
jmp    117b <mutilsExtension+0x5b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    %rax,-0x8(%rbp)
jmp    11ae <mutilsExtension+0x8e>
jmp    1195 <mutilsExtension+0x75>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    115a <mutilsExtension+0x3a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mutilsExtension>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <mutilsBasename@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
js     1157 <mutilsExtension+0x37>
mov    %eax,%eax
add    %rbx,%rax
cmpb   $0x2e,(%rax)
je     1150 <mutilsExtension+0x30>
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
jae    1140 <mutilsExtension+0x20>
jmp    1157 <mutilsExtension+0x37>
add    $0x1,%rax
mov    %rax,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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