#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 */
typedef int /*<<< orphan*/ doc;

/* Variables and functions */
int /*<<< orphan*/ getchar();
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *get_input_test() {
  int paragraph_count;
  scanf("%d", &paragraph_count);
  char p[5][1005], doc[1005];
  memset(doc, 0, sizeof(doc));
  getchar();
  for (int i = 0; i < paragraph_count; i++) {
    scanf("%[^\n]%*c", p[i]);
    strcat(doc, p[i]);
    if (i != paragraph_count - 1)
      strcat(doc, "\n");
  }
  char *returnDoc = (char *)malloc((strlen(doc) + 1) * sizeof(char));
  strcpy(returnDoc, doc);
  return returnDoc;
}


x86 assembly (clang, -O0):
<get_input_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x17b0,%rsp
lea    0xe7e(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    -0x17a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3ed,%edx
call   1050 <memset@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
movl   $0x0,-0x17a4(%rbp)
mov    -0x17a4(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    124a <get_input_test+0xda>
movslq -0x17a4(%rbp),%rax
lea    -0x13b0(%rbp),%rsi
imul   $0x3ed,%rax,%rax
add    %rax,%rsi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    -0x17a0(%rbp),%rdi
movslq -0x17a4(%rbp),%rax
lea    -0x13b0(%rbp),%rsi
imul   $0x3ed,%rax,%rax
add    %rax,%rsi
call   1090 <strcat@plt>
mov    -0x17a4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1231 <get_input_test+0xc1>
lea    -0x17a0(%rbp),%rdi
lea    0xde0(%rip),%rsi
call   1090 <strcat@plt>
jmp    1236 <get_input_test+0xc6>
mov    -0x17a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x17a4(%rbp)
jmp    11b1 <get_input_test+0x41>
lea    -0x17a0(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x17b0(%rbp)
mov    -0x17b0(%rbp),%rdi
lea    -0x17a0(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x17b0(%rbp),%rax
add    $0x17b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_input_test>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x17b0,%rsp
lea    0xe79(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x3ed,%edx
call   1050 <memset@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmpl   $0x0,0xc(%rsp)
jle    1227 <get_input_test+0xb7>
lea    0x400(%rsp),%r13
lea    0xe42(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe3f(%rip),%r12
xor    %ebx,%ebx
jmp    11f2 <get_input_test+0x82>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cltq
add    $0x3ed,%r13
cmp    %rax,%rbx
jge    1227 <get_input_test+0xb7>
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1090 <strcat@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    %rcx,%rbx
je     11e0 <get_input_test+0x70>
mov    %r15,%rdi
mov    %r12,%rsi
call   1090 <strcat@plt>
mov    0xc(%rsp),%eax
jmp    11e0 <get_input_test+0x70>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x17b0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"%[^\0A]%*c\00"
@.str.2 = [2 x i8] c"\0A\00"
define i8* @get_input_test() {
%1 = alloca i32
%2 = alloca [5 x [1005 x i8]]
%3 = alloca [1005 x i8]
%4 = alloca i32
%5 = alloca i8*
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = getelementptr inbounds [1005 x i8], [1005 x i8]* %3, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 1005)
%9 = call i32 (...) @getchar()
store i32 0, i32* %4
br label %10
10: ; preds = %34, %0
%11 = load i32, i32* %4
%12 = load i32, i32* %1
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %37
14: ; preds = %10
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [5 x [1005 x i8]], [5 x [1005 x i8]]* %2, i64 0, i64 %16
%18 = getelementptr inbounds [1005 x i8], [1005 x i8]* %17, i64 0, i64 0
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds [1005 x i8], [1005 x i8]* %3, i64 0, i64 0
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [5 x [1005 x i8]], [5 x [1005 x i8]]* %2, i64 0, i64 %22
%24 = getelementptr inbounds [1005 x i8], [1005 x i8]* %23, i64 0, i64 0
%25 = call i32 @strcat(i8* %20, i8* %24)
%26 = load i32, i32* %4
%27 = load i32, i32* %1
%28 = sub nsw i32 %27, 1
%29 = icmp ne i32 %26, %28
br i1 %29, label %30, label %33
30: ; preds = %14
%31 = getelementptr inbounds [1005 x i8], [1005 x i8]* %3, i64 0, i64 0
%32 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %30, %14
br label %34
34: ; preds = %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %10
37: ; preds = %10
%38 = getelementptr inbounds [1005 x i8], [1005 x i8]* %3, i64 0, i64 0
%39 = call i32 @strlen(i8* %38)
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = mul i64 %41, 1
%43 = trunc i64 %42 to i32
%44 = call i64 @malloc(i32 %43)
%45 = inttoptr i64 %44 to i8*
store i8* %45, i8** %5
%46 = load i8*, i8** %5
%47 = getelementptr inbounds [1005 x i8], [1005 x i8]* %3, i64 0, i64 0
%48 = call i32 @strcpy(i8* %46, i8* %47)
%49 = load i8*, i8** %5
ret i8* %49
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"%[^\0A]%*c\00"
@.str.2 = [2 x i8] c"\0A\00"
define i8* @get_input_test() {
%1 = alloca i32
%2 = alloca [5 x [1005 x i8]]
%3 = alloca [1005 x i8]
%4 = bitcast i32* %1 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = getelementptr inbounds [5 x [1005 x i8]], [5 x [1005 x i8]]* %2, i64 0, i64 0, i64 0
%7 = getelementptr inbounds [1005 x i8], [1005 x i8]* %3, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 1005)
%9 = call i32 (...) @getchar()
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %30, %0
%13 = call i32 @strlen(i8* %7)
%14 = add nsw i32 %13, 1
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
%17 = call i32 @strcpy(i8* %16, i8* %7)
ret i8* %16
18: ; preds = %0, %30
%19 = phi i64 [ %32, %30 ], [ 0, %0 ]
%20 = getelementptr inbounds [5 x [1005 x i8]], [5 x [1005 x i8]]* %2, i64 0, i64 %19, i64 0
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i32 @strcat(i8* %7, i8* %20)
%23 = load i32, i32* %1
%24 = add nsw i32 %23, -1
%25 = zext i32 %24 to i64
%26 = icmp eq i64 %19, %25
br i1 %26, label %30, label %27
27: ; preds = %18
%28 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32, i32* %1
br label %30
30: ; preds = %18, %27
%31 = phi i32 [ %23, %18 ], [ %29, %27 ]
%32 = add nuw nsw i64 %19, 1
%33 = sext i32 %31 to i64
%34 = icmp slt i64 %32, %33
br i1 %34, label %18, label %12
}