#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*/ sprintf(char *, char *);
char *strdup(char *);
int strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
char *fst_dllpath_to_infopath(char *dllpath) {
  char *retval;
  if (strstr(dllpath, ".dll") == NULL)
    return NULL;
  retval = strdup(dllpath);
  sprintf(retval + strlen(retval) - 4, ".fsi");
  return retval;
}


x86 assembly (clang, -O0):
<fst_dllpath_to_infopath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
jne    1173 <fst_dllpath_to_infopath+0x33>
movq   $0x0,-0x8(%rbp)
jmp    11b2 <fst_dllpath_to_infopath+0x72>
mov    -0x10(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe60(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fst_dllpath_to_infopath>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1168 <fst_dllpath_to_infopath+0x38>
mov    %rbx,%rdi
call   1040 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <strlen@plt>
cltq
movl   $0x6973662e,-0x4(%rbx,%rax,1)
69
movb   $0x0,(%rbx,%rax,1)
jmp    116a <fst_dllpath_to_infopath+0x3a>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c".dll\00"
@.str.1 = [5 x i8] c".fsi\00"
define i8* @fst_dllpath_to_infopath(i8* %0) {
%2 = tail call i32* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = tail call i8* @strdup(i8* %0)
%6 = tail call i32 @strlen(i8* %5)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 -4
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(5) %9, i8* align 1 dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 5, i1 false)
br label %10
10: ; preds = %1, %4
%11 = phi i8* [ %5, %4 ], [ null, %1 ]
ret i8* %11
}