#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 stripExtension(char *str, char *result) {
  int index;
  strcpy(result, str);
  index = strlen(result) - 1;
  while (index >= 0) {
    if (*(result + index) == '.')
      break;
    --index;
  }
  if (index < 0)
    *result = 0x00;
  else
    *(result + index + 1) = 0x00;
  return (0);
}


x86 assembly (clang, -O0):
<stripExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     117e <stripExtension+0x5e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1170 <stripExtension+0x50>
jmp    117e <stripExtension+0x5e>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    114c <stripExtension+0x2c>
cmpl   $0x0,-0x14(%rbp)
jge    1194 <stripExtension+0x74>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    11a1 <stripExtension+0x81>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,0x1(%rax,%rcx,1)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stripExtension>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
nopl   0x0(%rax)
test   %eax,%eax
jle    115b <stripExtension+0x3b>
lea    -0x1(%rax),%rcx
cmpb   $0x2e,-0x1(%rbx,%rax,1)
mov    %rcx,%rax
jne    1140 <stripExtension+0x20>
mov    %ecx,%eax
add    %rax,%rbx
add    $0x1,%rbx
movb   $0x0,(%rbx)
xor    %eax,%eax
pop    %rbx
ret

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

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