#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ rename(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void fixDecompressExtension(char pathFile[]) {
  char *originalName = (char *)malloc(100 * sizeof(char));
  strcpy(originalName, pathFile);
  int endOfName = strlen(pathFile);
  int i = endOfName, j;
  j = 5;
  char dotHuff[6] = {'.', 'h', 'u', 'f', 'f', '\0'};
  while (i >= 0 && pathFile[i] == dotHuff[j]) {
    i--;
    j--;
    if (j == -1)
      j = 4;
  }
  pathFile[i + (5 - j)] = '\0';
  if (strcmp(originalName, pathFile) != 0)
    remove(originalName);
  rename(pathFile, originalName);
  strcpy(pathFile, originalName);
  free(originalName);
}


x86 assembly (clang, -O0):
<fixDecompressExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x5,-0x1c(%rbp)
mov    0xe4a(%rip),%eax
mov    %eax,-0x22(%rbp)
mov    0xe44(%rip),%ax
mov    %ax,-0x1e(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x23(%rbp)
jl     11f0 <fixDecompressExtension+0x80>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movslq -0x1c(%rbp),%rcx
movsbl -0x22(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x23(%rbp)
mov    -0x23(%rbp),%al
test   $0x1,%al
jne    1200 <fixDecompressExtension+0x90>
jmp    1228 <fixDecompressExtension+0xb8>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1223 <fixDecompressExtension+0xb3>
movl   $0x4,-0x1c(%rbp)
jmp    11c4 <fixDecompressExtension+0x54>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    $0x5,%edx
sub    -0x1c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1260 <fixDecompressExtension+0xf0>
mov    -0x10(%rbp),%rdi
call   1040 <remove@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <rename@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fixDecompressExtension>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    $0x5,%ecx
test   %eax,%eax
js     11d3 <fixDecompressExtension+0x63>
lea    0xe59(%rip),%rsi
mov    $0x4,%r8d
nopl   (%rax)
mov    %eax,%edi
movzbl (%rbx,%rdi,1),%edx
movslq %ecx,%rdi
cmp    (%rdi,%rsi,1),%dl
jne    11d3 <fixDecompressExtension+0x63>
lea    -0x1(%rax),%edx
sub    $0x1,%ecx
cmovb  %r8d,%ecx
test   %eax,%eax
mov    %edx,%eax
jg     11b0 <fixDecompressExtension+0x40>
mov    $0xffffffff,%eax
sub    %ecx,%eax
add    $0x5,%eax
cltq
movb   $0x0,(%rbx,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11f6 <fixDecompressExtension+0x86>
mov    %r14,%rdi
call   1040 <remove@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <rename@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcpy@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

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

LLVM IR (-O2):
@__const.fixDecompressExtension.dotHuff = [6 x i8] c".huff\00"
define void @fixDecompressExtension(i8* %0) {
%2 = tail call i64 @malloc(i32 100)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @strcpy(i8* %3, i8* %0)
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, -1
br i1 %6, label %7, label %23
7: ; preds = %1, %17
%8 = phi i32 [ %21, %17 ], [ 5, %1 ]
%9 = phi i32 [ %18, %17 ], [ %5, %1 ]
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = sext i32 %8 to i64
%14 = getelementptr inbounds [6 x i8], [6 x i8]* @__const.fixDecompressExtension.dotHuff, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %12, %15
br i1 %16, label %17, label %23
17: ; preds = %7
%18 = add nsw i32 %9, -1
%19 = add nsw i32 %8, -1
%20 = icmp eq i32 %8, 0
%21 = select i1 %20, i32 4, i32 %19
%22 = icmp sgt i32 %9, 0
br i1 %22, label %7, label %23
23: ; preds = %7, %17, %1
%24 = phi i32 [ %5, %1 ], [ -1, %17 ], [ %9, %7 ]
%25 = phi i32 [ 5, %1 ], [ %21, %17 ], [ %8, %7 ]
%26 = add i32 %24, 5
%27 = sub i32 %26, %25
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %0, i64 %28
store i8 0, i8* %29
%30 = tail call i64 @strcmp(i8* %3, i8* %0)
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %23
%33 = tail call i32 @remove(i8* %3)
br label %34
34: ; preds = %32, %23
%35 = tail call i32 @rename(i8* %0, i8* %3)
%36 = tail call i32 @strcpy(i8* %0, i8* %3)
%37 = tail call i32 @free(i8* %3)
ret void
}