#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*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
char *reader();
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char const *argv[]) {
  char *str_1 = reader();
  char *str_2 = reader();
  char *str_3 = reader();
  char *str_4 = reader();
  int size_of_strings =
      strlen(str_1) + strlen(str_2) + strlen(str_3) + strlen(str_4);
  if (size_of_strings > 0) {
    char all_strings[size_of_strings];
    strcpy(all_strings, str_1);
    strcat(all_strings, str_2);
    strcat(all_strings, str_3);
    strcat(all_strings, str_4);
    printf("String content: %s, and string lenght: %i\n", all_strings,
           strlen(all_strings));
  } else {
    printf("Invalid string \n");
  }
  free(str_1);
  free(str_2);
  free(str_3);
  free(str_4);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <reader@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <reader@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1050 <reader@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <reader@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jle    1270 <main+0x110>
mov    -0x34(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x60(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x60(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x60(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
jmp    127e <main+0x11e>
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <reader@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <reader@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1060 <reader@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1060 <reader@plt>
mov    %rax,%r13
mov    %rbx,-0x30(%rbp)
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%r14d
add    %ebx,%r14d
mov    %r12,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
add    %r14d,%ebx
mov    %r13,%rdi
call   1070 <strlen@plt>
add    %ebx,%eax
jle    123e <main+0xce>
mov    %rsp,%r14
mov    %eax,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <strcat@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
lea    0xdd3(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rsp
jmp    124a <main+0xda>
lea    0xde6(%rip),%rdi
call   1050 <puts@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"String content: %s, and string lenght: %i\0A\00"
@.str.1 = [17 x i8] c"Invalid string \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i8* (...) @reader()
store i8* %13, i8** %6
%14 = call i8* (...) @reader()
store i8* %14, i8** %7
%15 = call i8* (...) @reader()
store i8* %15, i8** %8
%16 = call i8* (...) @reader()
store i8* %16, i8** %9
%17 = load i8*, i8** %6
%18 = call i32 @strlen(i8* %17)
%19 = load i8*, i8** %7
%20 = call i32 @strlen(i8* %19)
%21 = add nsw i32 %18, %20
%22 = load i8*, i8** %8
%23 = call i32 @strlen(i8* %22)
%24 = add nsw i32 %21, %23
%25 = load i8*, i8** %9
%26 = call i32 @strlen(i8* %25)
%27 = add nsw i32 %24, %26
store i32 %27, i32* %10
%28 = load i32, i32* %10
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %46
30: ; preds = %2
%31 = load i32, i32* %10
%32 = zext i32 %31 to i64
%33 = call i8* @llvm.stacksave()
store i8* %33, i8** %11
%34 = alloca i8, i64 %32
store i64 %32, i64* %12
%35 = load i8*, i8** %6
%36 = call i32 @strcpy(i8* %34, i8* %35)
%37 = load i8*, i8** %7
%38 = call i32 @strcat(i8* %34, i8* %37)
%39 = load i8*, i8** %8
%40 = call i32 @strcat(i8* %34, i8* %39)
%41 = load i8*, i8** %9
%42 = call i32 @strcat(i8* %34, i8* %41)
%43 = call i32 @strlen(i8* %34)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %34, i32 %43)
%45 = load i8*, i8** %11
br label %48
46: ; preds = %2
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %46, %30
%49 = load i8*, i8** %6
%50 = call i32 @free(i8* %49)
%51 = load i8*, i8** %7
%52 = call i32 @free(i8* %51)
%53 = load i8*, i8** %8
%54 = call i32 @free(i8* %53)
%55 = load i8*, i8** %9
%56 = call i32 @free(i8* %55)
ret i32 0
}

LLVM IR (-O2):
@.str = [43 x i8] c"String content: %s, and string lenght: %i\0A\00"
@str = [16 x i8] c"Invalid string \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* (...) @reader()
%4 = tail call i8* (...) @reader()
%5 = tail call i8* (...) @reader()
%6 = tail call i8* (...) @reader()
%7 = tail call i32 @strlen(i8* %3)
%8 = tail call i32 @strlen(i8* %4)
%9 = add nsw i32 %8, %7
%10 = tail call i32 @strlen(i8* %5)
%11 = add nsw i32 %9, %10
%12 = tail call i32 @strlen(i8* %6)
%13 = add nsw i32 %11, %12
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %2
%16 = zext i32 %13 to i64
%17 = tail call i8* @llvm.stacksave()
%18 = alloca i8, i64 %16
%19 = call i32 @strcpy(i8* %18, i8* %3)
%20 = call i32 @strcat(i8* %18, i8* %4)
%21 = call i32 @strcat(i8* %18, i8* %5)
%22 = call i32 @strcat(i8* %18, i8* %6)
%23 = call i32 @strlen(i8* %18)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %23)
br label %27
25: ; preds = %2
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %25, %15
%28 = call i32 @free(i8* %3)
%29 = call i32 @free(i8* %4)
%30 = call i32 @free(i8* %5)
%31 = call i32 @free(i8* %6)
ret i32 0
}