#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*/ strcat(char *, char *);
scalar_t__ strcmp(char const *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
void makeExtention(char *bufferName, const char *name, const char *extension) {
  int i = 0;
  const char *name_char;
  strcpy(bufferName, name);
  if (strlen(bufferName) < strlen(extension)) {
    strcat(bufferName, ".PAK");
    return;
  }
  name_char = bufferName;
  name_char += strlen(bufferName) - strlen(extension);
  if (strcmp(name_char, extension) != 0)
    strcat(bufferName, ".PAK");
}


x86 assembly (clang, -O0):
<makeExtention>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jge    11a3 <makeExtention+0x63>
mov    -0x8(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1060 <strcat@plt>
jmp    11fa <makeExtention+0xba>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
sub    %rcx,%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11fa <makeExtention+0xba>
mov    -0x8(%rbp),%rdi
lea    0xe0b(%rip),%rsi
call   1060 <strcat@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeExtention>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rdi,%r15
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
sub    %rax,%rbx
jl     117b <makeExtention+0x3b>
add    %r15,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     118f <makeExtention+0x4f>
lea    0xe7e(%rip),%rsi
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <strcat@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c".PAK\00"
define void @makeExtention(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = load i8*, i8** %4
%13 = call i64 @strlen(i8* %12)
%14 = load i8*, i8** %6
%15 = call i64 @strlen(i8* %14)
%16 = icmp slt i64 %13, %15
br i1 %16, label %17, label %20
17: ; preds = %3
%18 = load i8*, i8** %4
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %36
20: ; preds = %3
%21 = load i8*, i8** %4
store i8* %21, i8** %8
%22 = load i8*, i8** %4
%23 = call i64 @strlen(i8* %22)
%24 = load i8*, i8** %6
%25 = call i64 @strlen(i8* %24)
%26 = sub nsw i64 %23, %25
%27 = load i8*, i8** %8
%28 = getelementptr inbounds i8, i8* %27, i64 %26
store i8* %28, i8** %8
%29 = load i8*, i8** %8
%30 = load i8*, i8** %6
%31 = call i64 @strcmp(i8* %29, i8* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %20
%34 = load i8*, i8** %4
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %36
36: ; preds = %17, %33, %20
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".PAK\00"
define void @makeExtention(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @strcpy(i8* %0, i8* %1)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%7 = icmp slt i64 %5, %6
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = sub nsw i64 %5, %6
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = tail call i64 @strcmp(i8* %10, i8* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %8, %3
%14 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %8
ret void
}