#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*/ changecode(char *, char *);
int /*<<< orphan*/ enough_mem(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ scnprintf(char *, size_t, char *, char const *);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char const *);
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *merge_responses(const char *resp1, const char *resp2) {
  char codebuf[5];
  char *ret_str;
  size_t ret_size;
  codebuf[0] = codebuf[1] = codebuf[2] = ' ';
  strncpy(codebuf, resp2, 3);
  codebuf[3] = '-';
  codebuf[4] = '\0';
  ret_size = strlen(resp1) + strlen(resp2) + 1 + 1;
  ret_str = (char *)malloc(ret_size);
  enough_mem(ret_str);
  snprintf(ret_str, ret_size, "%s", resp1);
  changecode(ret_str, codebuf);
  scnprintf(ret_str, ret_size, "%s", resp2);
  return ret_str;
}


x86 assembly (clang, -O0):
<merge_responses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x20,-0x13(%rbp)
movb   $0x20,-0x14(%rbp)
movb   $0x20,-0x15(%rbp)
lea    -0x15(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
movb   $0x2d,-0x12(%rbp)
movb   $0x0,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <enough_mem@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%rcx
lea    0xe09(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x15(%rbp),%rsi
call   1070 <changecode@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rcx
lea    0xde4(%rip),%rdx
call   1090 <scnprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge_responses>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r15
movb   $0x20,0x5(%rsp)
movw   $0x2020,0x3(%rsp)
lea    0x3(%rsp),%r14
mov    %r14,%rdi
mov    $0x3,%edx
call   1030 <strncpy@plt>
movw   $0x2d,0x6(%rsp)
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1040 <strlen@plt>
add    %ebx,%eax
add    $0x2,%eax
movslq %eax,%r13
mov    %r13,%rdi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <enough_mem@plt>
lea    0xe26(%rip),%rbp
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %r15,%rcx
call   1050 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <changecode@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %r12,%rcx
call   1090 <scnprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i8* @merge_responses(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [5 x i8]
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 2
store i8 32, i8* %8
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 1
store i8 32, i8* %9
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
store i8 32, i8* %10
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%12 = load i8*, i8** %4
%13 = call i32 @strncpy(i8* %11, i8* %12, i32 3)
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 3
store i8 45, i8* %14
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 4
store i8 0, i8* %15
%16 = load i8*, i8** %3
%17 = call i32 @strlen(i8* %16)
%18 = load i8*, i8** %4
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %17, %19
%21 = add nsw i32 %20, 1
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
store i64 %23, i64* %7
%24 = load i64, i64* %7
%25 = call i64 @malloc(i64 %24)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = call i32 @enough_mem(i8* %27)
%29 = load i8*, i8** %6
%30 = load i64, i64* %7
%31 = load i8*, i8** %3
%32 = call i32 @snprintf(i8* %29, i64 %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %6
%34 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%35 = call i32 @changecode(i8* %33, i8* %34)
%36 = load i8*, i8** %6
%37 = load i64, i64* %7
%38 = load i8*, i8** %4
%39 = call i32 @scnprintf(i8* %36, i64 %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %6
ret i8* %40
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i8* @merge_responses(i8* %0, i8* %1) {
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 2
store i8 32, i8* %5
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 1
store i8 32, i8* %6
store i8 32, i8* %4
%7 = call i32 @strncpy(i8* %4, i8* %1, i32 3)
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 3
store i8 45, i8* %8
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 4
store i8 0, i8* %9
%10 = call i32 @strlen(i8* %0)
%11 = call i32 @strlen(i8* %1)
%12 = add i32 %10, 2
%13 = add i32 %12, %11
%14 = sext i32 %13 to i64
%15 = call i64 @malloc(i64 %14)
%16 = inttoptr i64 %15 to i8*
%17 = call i32 @enough_mem(i8* %16)
%18 = call i32 @snprintf(i8* %16, i64 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%19 = call i32 @changecode(i8* %16, i8* %4)
%20 = call i32 @scnprintf(i8* %16, i64 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
ret i8* %16
}