#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void modify_output_name(char *file_name, char *suffix, char **output_name) {
  *output_name =
      (char *)malloc(sizeof(char) * (strlen(file_name) + strlen(suffix)));
  if (!file_name) {
    printf("memmory allocation failed\n");
    return;
  }
  strcpy(*output_name, file_name);
  strcat(*output_name, suffix);
}


x86 assembly (clang, -O0):
<modify_output_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x8(%rbp)
jne    11b3 <modify_output_name+0x63>
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
jmp    11d3 <modify_output_name+0x83>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modify_output_name>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1050 <strlen@plt>
add    %eax,%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,(%r15)
test   %rbx,%rbx
je     11a0 <modify_output_name+0x50>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    (%r15),%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <strcat@plt>
lea    0xe59(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"memmory allocation failed\0A\00"
define void @modify_output_name(i8* %0, i8* %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8**
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8** %2, i8*** %6
%7 = load i8*, i8** %4
%8 = call i32 @strlen(i8* %7)
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %8, %10
%12 = sext i32 %11 to i64
%13 = mul i64 1, %12
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
%17 = load i8**, i8*** %6
store i8* %16, i8** %17
%18 = load i8*, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %22, label %20
20: ; preds = %3
%21 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %31
22: ; preds = %3
%23 = load i8**, i8*** %6
%24 = load i8*, i8** %23
%25 = load i8*, i8** %4
%26 = call i32 @strcpy(i8* %24, i8* %25)
%27 = load i8**, i8*** %6
%28 = load i8*, i8** %27
%29 = load i8*, i8** %5
%30 = call i32 @strcat(i8* %28, i8* %29)
br label %31
31: ; preds = %22, %20
ret void
}

LLVM IR (-O2):
@str = [26 x i8] c"memmory allocation failed\00"
define void @modify_output_name(i8* %0, i8* %1, i8** nocapture %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = add nsw i32 %5, %4
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %2
%9 = icmp eq i8* %0, null
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %16
12: ; preds = %3
%13 = tail call i32 @strcpy(i8* %8, i8* %0)
%14 = load i8*, i8** %2
%15 = tail call i32 @strcat(i8* %14, i8* %1)
br label %16
16: ; preds = %12, %10
ret void
}