#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 *);
int strlen(char *);
int GetFileSinExtension(char *filename, char *fileSin, char *extension) {
  int i;
  strcpy(fileSin, filename);
  strcpy(extension, "");
  int size = strlen(fileSin);
  char *p = fileSin + size;
  for (i = size; i >= 0; i--) {
    if (*(--p) == '.') {
      *p = 0;
      strcpy(extension, p + 1);
      return (i);
      break;
    }
  }
  return (-1);
}


x86 assembly (clang, -O0):
<GetFileSinExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xeb4(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     11ce <GetFileSinExtension+0xae>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x30(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0x2e,%eax
jne    11bb <GetFileSinExtension+0x9b>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d5 <GetFileSinExtension+0xb5>
jmp    11c0 <GetFileSinExtension+0xa0>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1172 <GetFileSinExtension+0x52>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetFileSinExtension>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
lea    0xec3(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
js     118b <GetFileSinExtension+0x6b>
mov    %ecx,%ebx
nopw   0x0(%rax,%rax,1)
cmpb   $0x2e,-0x1(%r15,%rbx,1)
je     1175 <GetFileSinExtension+0x55>
add    $0xffffffffffffffff,%rbx
lea    0x1(%rbx),%ecx
test   %ecx,%ecx
jg     1160 <GetFileSinExtension+0x40>
jmp    118b <GetFileSinExtension+0x6b>
movb   $0x0,-0x1(%r15,%rbx,1)
add    %rbx,%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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