#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 */
char *mlr_malloc_or_die(int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *mlr_paste_4_strings(char *s1, char *s2, char *s3, char *s4) {
  int n1 = strlen(s1);
  int n2 = strlen(s2);
  int n3 = strlen(s3);
  int n4 = strlen(s4);
  char *s = mlr_malloc_or_die(n1 + n2 + n3 + n4 + 1);
  strcpy(s, s1);
  strcat(s, s2);
  strcat(s, s3);
  strcat(s, s4);
  return s;
}


x86 assembly (clang, -O0):
<mlr_paste_4_strings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
add    -0x28(%rbp),%edi
add    -0x2c(%rbp),%edi
add    -0x30(%rbp),%edi
add    $0x1,%edi
call   1050 <mlr_malloc_or_die@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mlr_paste_4_strings>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rsi,(%rsp)
mov    %rdi,%r12
call   1040 <strlen@plt>
mov    %eax,%r13d
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %r13d,%ebp
add    %r14d,%ebp
lea    (%rax,%rbp,1),%edi
add    $0x1,%edi
call   1050 <mlr_malloc_or_die@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    (%rsp),%rsi
call   1060 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <strcat@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* @mlr_paste_4_strings(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%14 = load i8*, i8** %5
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %9
%16 = load i8*, i8** %6
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %10
%18 = load i8*, i8** %7
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %11
%20 = load i8*, i8** %8
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %12
%22 = load i32, i32* %9
%23 = load i32, i32* %10
%24 = add nsw i32 %22, %23
%25 = load i32, i32* %11
%26 = add nsw i32 %24, %25
%27 = load i32, i32* %12
%28 = add nsw i32 %26, %27
%29 = add nsw i32 %28, 1
%30 = call i8* @mlr_malloc_or_die(i32 %29)
store i8* %30, i8** %13
%31 = load i8*, i8** %13
%32 = load i8*, i8** %5
%33 = call i32 @strcpy(i8* %31, i8* %32)
%34 = load i8*, i8** %13
%35 = load i8*, i8** %6
%36 = call i32 @strcat(i8* %34, i8* %35)
%37 = load i8*, i8** %13
%38 = load i8*, i8** %7
%39 = call i32 @strcat(i8* %37, i8* %38)
%40 = load i8*, i8** %13
%41 = load i8*, i8** %8
%42 = call i32 @strcat(i8* %40, i8* %41)
%43 = load i8*, i8** %13
ret i8* %43
}

LLVM IR (-O2):
define i8* @mlr_paste_4_strings(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @strlen(i8* %0)
%6 = tail call i32 @strlen(i8* %1)
%7 = tail call i32 @strlen(i8* %2)
%8 = tail call i32 @strlen(i8* %3)
%9 = add i32 %5, 1
%10 = add i32 %9, %6
%11 = add i32 %10, %7
%12 = add i32 %11, %8
%13 = tail call i8* @mlr_malloc_or_die(i32 %12)
%14 = tail call i32 @strcpy(i8* %13, i8* %0)
%15 = tail call i32 @strcat(i8* %13, i8* %1)
%16 = tail call i32 @strcat(i8* %13, i8* %2)
%17 = tail call i32 @strcat(i8* %13, i8* %3)
ret i8* %13
}