#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 *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
void combine_filename_with_new_file_extension(char *filename,
                                              char *output_filename,
                                              char *extension) {
  char *filename_prefix;
  char extension_filename[100];
  char copy_of_filename[100];
  strcpy(copy_of_filename, filename);
  filename_prefix = strtok(copy_of_filename, ".");
  strcpy(extension_filename, filename_prefix);
  strcat(extension_filename, extension);
  strcpy(output_filename, extension_filename);
}


x86 assembly (clang, -O0):
<combine_filename_with_new_file_extension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x100(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x90(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<combine_filename_with_new_file_extension>:
push   %r15
push   %r14
push   %rbx
sub    $0xe0,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strtok@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
define void @combine_filename_with_new_file_extension(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [100 x i8]
%9 = alloca [100 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = call i32 @strcpy(i8* %10, i8* %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%14 = call i8* @strtok(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %7
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%16 = load i8*, i8** %7
%17 = call i32 @strcpy(i8* %15, i8* %16)
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%19 = load i8*, i8** %6
%20 = call i32 @strcat(i8* %18, i8* %19)
%21 = load i8*, i8** %5
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%23 = call i32 @strcpy(i8* %21, i8* %22)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
define void @combine_filename_with_new_file_extension(i8* %0, i8* %1, i8* %2) {
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* %0)
%9 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strcpy(i8* %6, i8* %9)
%11 = call i32 @strcat(i8* %6, i8* %2)
%12 = call i32 @strcpy(i8* %1, i8* %6)
ret void
}