#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strstr(char *, char *);
char *make_filename(char *in_filename, const char *extension) {
  static char out_filename[256];
  FILE *bin_file;
  int status;
  strcpy(out_filename, in_filename);
  char *end_of_root = strstr(out_filename, ".sl");
  if (end_of_root != NULL)
    strcpy(end_of_root, extension);
  else
    strcat(out_filename, extension);
  return out_filename;
}


x86 assembly (clang, -O0):
<make_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2f05(%rip),%rdi
call   1030 <strcpy@plt>
lea    0x2ef9(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1184 <make_filename+0x54>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1194 <make_filename+0x64>
mov    -0x10(%rbp),%rsi
lea    0x2ec1(%rip),%rdi
call   1040 <strcat@plt>
lea    0x2eb5(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_filename>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rsi
lea    0x2f0f(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     116a <make_filename+0x3a>
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
jmp    1179 <make_filename+0x49>
lea    0x2edf(%rip),%rdi
mov    %r14,%rsi
call   1040 <strcat@plt>
lea    0x2ed0(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@make_filename.out_filename = internal global [256 x i8] zeroinitializer
@.str = [4 x i8] c".sl\00"
define i8* @make_filename(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32 @strcpy(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @make_filename.out_filename, i64 0, i64 0), i8* %8)
%10 = call i8* @strstr(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @make_filename.out_filename, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %7
%11 = load i8*, i8** %7
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i8*, i8** %7
%15 = load i8*, i8** %4
%16 = call i32 @strcpy(i8* %14, i8* %15)
br label %20
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = call i32 @strcat(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @make_filename.out_filename, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %17, %13
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @make_filename.out_filename, i64 0, i64 0)
}

LLVM IR (-O2):
@make_filename.out_filename = internal global [256 x i8] zeroinitializer
@.str = [4 x i8] c".sl\00"
define i8* @make_filename(i8* %0, i8* %1) {
%3 = tail call i32 @strcpy(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @make_filename.out_filename, i64 0, i64 0), i8* %0)
%4 = tail call i8* @strstr(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @make_filename.out_filename, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @strcpy(i8* %4, i8* %1)
br label %10
8: ; preds = %2
%9 = tail call i32 @strcat(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @make_filename.out_filename, i64 0, i64 0), i8* %1)
br label %10
10: ; preds = %8, %6
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @make_filename.out_filename, i64 0, i64 0)
}