#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*/ sprintf(char *, char *, char *, char *);
char *strdup(char *);
char *strstr(char *, char *);
char *szCreateMapFileName(char *szFastaFile) {
  char *szMapFile = (char *)malloc(1024 * sizeof(char));
  char *szStub = strdup(szFastaFile);
  char *szTemp = NULL;
  szTemp = strstr(szStub, ".fa");
  if (szTemp != NULL) {
    *szTemp = '\0';
  }
  sprintf(szMapFile, "%s%s", szStub, ".map");
  free(szStub);
  return szMapFile;
}


x86 assembly (clang, -O0):
<szCreateMapFileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x400,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11a5 <szCreateMapFileName+0x55>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe50(%rip),%rsi
lea    0xe4e(%rip),%rcx
call   1050 <sprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<szCreateMapFileName>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x400,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
lea    0xe8a(%rip),%rsi
mov    %rax,%rdi
call   1070 <strstr@plt>
test   %rax,%rax
je     1186 <szCreateMapFileName+0x36>
movb   $0x0,(%rax)
lea    0xe77(%rip),%rsi
lea    0xe75(%rip),%rcx
mov    %r14,%rdi
mov    %rbx,%rdx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c".fa\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [5 x i8] c".map\00"
define i8* @szCreateMapFileName(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = call i64 @malloc(i32 1024)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %3
%8 = load i8*, i8** %2
%9 = call i8* @strdup(i8* %8)
store i8* %9, i8** %4
store i8* null, i8** %5
%10 = load i8*, i8** %4
%11 = call i8* @strstr(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = load i8*, i8** %5
store i8 0, i8* %15
br label %16
16: ; preds = %14, %1
%17 = load i8*, i8** %3
%18 = load i8*, i8** %4
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%20 = load i8*, i8** %4
%21 = call i32 @free(i8* %20)
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
@.str = [4 x i8] c".fa\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [5 x i8] c".map\00"
define i8* @szCreateMapFileName(i8* nocapture %0) {
%2 = tail call i64 @malloc(i32 1024)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i8* @strdup(i8* %0)
%5 = tail call i8* @strstr(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i8 0, i8* %5
br label %8
8: ; preds = %7, %1
%9 = tail call i32 @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @free(i8* %4)
ret i8* %3
}