#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*/ memcpy(char *, char *, int);
char *uwsgi_malloc(int);
char *uwsgi_concat2nn(char *one, int s1, char *two, int s2, int *len) {
  char *buf;
  *len = s1 + s2 + 1;
  buf = uwsgi_malloc(*len);
  buf[*len - 1] = 0;
  memcpy(buf, one, s1);
  memcpy(buf + s1, two, s2);
  return buf;
}


x86 assembly (clang, -O0):
<uwsgi_concat2nn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0xc(%rbp),%ecx
add    -0x1c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
call   1040 <uwsgi_malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x30(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uwsgi_concat2nn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r12
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %esi,%ebx
mov    %rdi,%r13
lea    (%rbx,%r14,1),%edi
add    $0x1,%edi
mov    %edi,(%r8)
call   1040 <uwsgi_malloc@plt>
mov    %rax,%rbp
movslq (%r12),%rax
movb   $0x0,-0x1(%rax,%rbp,1)
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1030 <memcpy@plt>
movslq %ebx,%rdi
add    %rbp,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1030 <memcpy@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @uwsgi_concat2nn(i8* %0, i32 %1, i8* %2, i32 %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32* %4, i32** %10
%12 = load i32, i32* %7
%13 = load i32, i32* %9
%14 = add nsw i32 %12, %13
%15 = add nsw i32 %14, 1
%16 = load i32*, i32** %10
store i32 %15, i32* %16
%17 = load i32*, i32** %10
%18 = load i32, i32* %17
%19 = call i8* @uwsgi_malloc(i32 %18)
store i8* %19, i8** %11
%20 = load i8*, i8** %11
%21 = load i32*, i32** %10
%22 = load i32, i32* %21
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %20, i64 %24
store i8 0, i8* %25
%26 = load i8*, i8** %11
%27 = load i8*, i8** %6
%28 = load i32, i32* %7
%29 = call i32 @memcpy(i8* %26, i8* %27, i32 %28)
%30 = load i8*, i8** %11
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8*, i8** %8
%35 = load i32, i32* %9
%36 = call i32 @memcpy(i8* %33, i8* %34, i32 %35)
%37 = load i8*, i8** %11
ret i8* %37
}

LLVM IR (-O2):
define i8* @uwsgi_concat2nn(i8* %0, i32 %1, i8* %2, i32 %3, i32* nocapture %4) {
%6 = add i32 %1, 1
%7 = add i32 %6, %3
store i32 %7, i32* %4
%8 = tail call i8* @uwsgi_malloc(i32 %7)
%9 = load i32, i32* %4
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
store i8 0, i8* %12
%13 = tail call i32 @memcpy(i8* %8, i8* %0, i32 %1)
%14 = sext i32 %1 to i64
%15 = getelementptr inbounds i8, i8* %8, i64 %14
%16 = tail call i32 @memcpy(i8* %15, i8* %2, i32 %3)
ret i8* %8
}