#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 /*<<< orphan*/ strcpy(char *, char const *);
void get_extension(const char *file_name, char *extension) {
  while (*file_name++ != '.' && *file_name)
    ;
  if (*(--file_name) == '.')
    strcpy(extension, ++file_name);
}


x86 assembly (clang, -O0):
<get_extension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2e,%ecx
mov    %al,-0x11(%rbp)
je     1150 <get_extension+0x40>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1160 <get_extension+0x50>
jmp    1165 <get_extension+0x55>
jmp    1120 <get_extension+0x10>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x8(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0x2e,%eax
jne    1196 <get_extension+0x86>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
mov    %rsi,-0x8(%rbp)
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_extension>:
mov    %rdi,%rax
mov    (%rdi),%cl
add    $0x1,%rax
nopl   0x0(%rax)
cmp    $0x2e,%cl
je     1131 <get_extension+0x21>
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1120 <get_extension+0x10>
ret
mov    %rsi,%rdi
mov    %rax,%rsi
jmp    1030 <strcpy@plt>

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

LLVM IR (-O2):
define void @get_extension(i8* %0, i8* %1) {
%3 = load i8, i8* %0
br label %4
4: ; preds = %9, %2
%5 = phi i8 [ %10, %9 ], [ %3, %2 ]
%6 = phi i8* [ %7, %9 ], [ %0, %2 ]
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = icmp eq i8 %5, 46
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = load i8, i8* %7
%11 = icmp eq i8 %10, 0
br i1 %11, label %14, label %4
12: ; preds = %4
%13 = tail call i32 @strcpy(i8* %1, i8* %7)
br label %14
14: ; preds = %9, %12
ret void
}