#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 indexOfNameBegin(char *);
int /*<<< orphan*/ strcpy(char *, char *);
void extractExtension(char *fullName, char *extension) {
  char name[100] = {0};
  int i, j;
  int begin = indexOfNameBegin(fullName);
  for (i = begin; i < 100; i++) {
    if (fullName[i] == '.') {
      break;
    }
  }
  begin = i;
  for (j = begin, i = 0; j < 100 && fullName[i] != '\0'; j++, i++) {
    name[i] = fullName[j];
  }
  strcpy(extension, name);
}


x86 assembly (clang, -O0):
<extractExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
call   1050 <indexOfNameBegin@plt>
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0x84(%rbp)
cmpl   $0x64,-0x84(%rbp)
jge    11b1 <extractExtension+0x81>
mov    -0x8(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1198 <extractExtension+0x68>
jmp    11b1 <extractExtension+0x81>
jmp    119d <extractExtension+0x6d>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    116e <extractExtension+0x3e>
mov    -0x84(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0x88(%rbp)
movl   $0x0,-0x84(%rbp)
xor    %eax,%eax
cmpl   $0x64,-0x88(%rbp)
mov    %al,-0x8d(%rbp)
jge    1203 <extractExtension+0xd3>
mov    -0x8(%rbp),%rax
movslq -0x84(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x8d(%rbp)
mov    -0x8d(%rbp),%al
test   $0x1,%al
jne    1216 <extractExtension+0xe6>
jmp    1252 <extractExtension+0x122>
mov    -0x8(%rbp),%rax
movslq -0x88(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x84(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11d3 <extractExtension+0xa3>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractExtension>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
call   1040 <indexOfNameBegin@plt>
cmp    $0x63,%eax
jg     11b6 <extractExtension+0x96>
movslq %eax,%rsi
mov    $0x64,%ecx
sub    %eax,%ecx
add    %rbx,%rsi
xor    %edx,%edx
xchg   %ax,%ax
cmpb   $0x2e,(%rsi,%rdx,1)
je     1180 <extractExtension+0x60>
add    $0x1,%rdx
cmp    %edx,%ecx
jne    1170 <extractExtension+0x50>
jmp    11b6 <extractExtension+0x96>
mov    %eax,%esi
add    %rdx,%rsi
cmp    $0x63,%esi
jg     11b6 <extractExtension+0x96>
sub    %rdx,%rcx
mov    %ecx,%edi
movslq %esi,%rcx
add    %rbx,%rcx
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx,%rdx,1)
je     11b6 <extractExtension+0x96>
movzbl (%rcx,%rdx,1),%eax
mov    %al,(%rsp,%rdx,1)
add    $0x1,%rdx
cmp    %rdx,%rdi
jne    11a0 <extractExtension+0x80>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @extractExtension(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [100 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = bitcast [100 x i8]* %5 to i8*
%10 = load i8*, i8** %3
%11 = call i32 @indexOfNameBegin(i8* %10)
store i32 %11, i32* %8
%12 = load i32, i32* %8
store i32 %12, i32* %6
br label %13
13: ; preds = %26, %2
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 100
br i1 %15, label %16, label %29
16: ; preds = %13
%17 = load i8*, i8** %3
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 46
br i1 %23, label %24, label %25
24: ; preds = %16
br label %29
25: ; preds = %16
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %13
29: ; preds = %24, %13
%30 = load i32, i32* %6
store i32 %30, i32* %8
%31 = load i32, i32* %8
store i32 %31, i32* %7
store i32 0, i32* %6
br label %32
32: ; preds = %54, %29
%33 = load i32, i32* %7
%34 = icmp slt i32 %33, 100
br i1 %34, label %35, label %43
35: ; preds = %32
%36 = load i8*, i8** %3
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 0
br label %43
43: ; preds = %35, %32
%44 = phi i1 [ false, %32 ], [ %42, %35 ]
br i1 %44, label %45, label %59
45: ; preds = %43
%46 = load i8*, i8** %3
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %52
store i8 %50, i8* %53
br label %54
54: ; preds = %45
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %32
59: ; preds = %43
%60 = load i8*, i8** %4
%61 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%62 = call i32 @strcpy(i8* %60, i8* %61)
ret void
}

LLVM IR (-O2):
define void @extractExtension(i8* %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @indexOfNameBegin(i8* %0)
%6 = icmp slt i32 %5, 100
br i1 %6, label %7, label %39
7: ; preds = %2
%8 = sext i32 %5 to i64
br label %9
9: ; preds = %7, %14
%10 = phi i64 [ %8, %7 ], [ %15, %14 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 46
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = add nsw i64 %10, 1
%16 = trunc i64 %15 to i32
%17 = icmp eq i32 %16, 100
br i1 %17, label %39, label %9
18: ; preds = %9
%19 = trunc i64 %10 to i32
%20 = icmp slt i32 %19, 100
br i1 %20, label %21, label %39
21: ; preds = %18
%22 = shl i64 %10, 32
%23 = ashr exact i64 %22, 32
%24 = sub i64 100, %10
%25 = and i64 %24, 4294967295
br label %26
26: ; preds = %21, %32
%27 = phi i64 [ 0, %21 ], [ %37, %32 ]
%28 = phi i64 [ %23, %21 ], [ %36, %32 ]
%29 = getelementptr inbounds i8, i8* %0, i64 %27
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %39, label %32
32: ; preds = %26
%33 = getelementptr inbounds i8, i8* %0, i64 %28
%34 = load i8, i8* %33
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %27
store i8 %34, i8* %35
%36 = add nsw i64 %28, 1
%37 = add nuw nsw i64 %27, 1
%38 = icmp eq i64 %37, %25
br i1 %38, label %39, label %26
39: ; preds = %14, %26, %32, %2, %18
%40 = call i32 @strcpy(i8* %1, i8* %4)
ret void
}