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


x86 assembly (clang, -O0):
<mlr_paste_3_strings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
add    -0x20(%rbp),%edi
add    -0x24(%rbp),%edi
add    $0x1,%edi
call   1050 <mlr_malloc_or_die@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mlr_paste_3_strings>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %r12d,%ebp
lea    (%rax,%rbp,1),%edi
add    $0x1,%edi
call   1050 <mlr_malloc_or_die@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @mlr_paste_3_strings(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %7
%13 = load i8*, i8** %5
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %8
%15 = load i8*, i8** %6
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %9
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = add nsw i32 %17, %18
%20 = load i32, i32* %9
%21 = add nsw i32 %19, %20
%22 = add nsw i32 %21, 1
%23 = call i8* @mlr_malloc_or_die(i32 %22)
store i8* %23, i8** %10
%24 = load i8*, i8** %10
%25 = load i8*, i8** %4
%26 = call i32 @strcpy(i8* %24, i8* %25)
%27 = load i8*, i8** %10
%28 = load i8*, i8** %5
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = load i8*, i8** %10
%31 = load i8*, i8** %6
%32 = call i32 @strcat(i8* %30, i8* %31)
%33 = load i8*, i8** %10
ret i8* %33
}

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