#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 const *);
const char *sk_file_extname(const char *path) {
  int n = strlen(path);
  for (int i = n - 1; i >= 0; i--) {
    if (path[i] == '.') {
      return &path[i + 1];
    }
  }
  return "";
}


x86 assembly (clang, -O0):
<sk_file_extname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     117c <sk_file_extname+0x6c>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1169 <sk_file_extname+0x59>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1187 <sk_file_extname+0x77>
jmp    116e <sk_file_extname+0x5e>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1131 <sk_file_extname+0x21>
lea    0xe7d(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

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

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

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