#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 EOF;
char getchar();
int /*<<< orphan*/ puts(char *);
void read_input(char input[]) {
  unsigned current_char_index = 0;
  char current_char = EOF;
  while ((current_char = getchar()) != EOF) {
    if (current_char_index == 1024 - 1) {
      puts("Error: Maximum input size exceeded.");
      input[current_char_index] = '\0';
    } else {
      input[current_char_index++] = current_char;
    }
  }
}


x86 assembly (clang, -O0):
<read_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2eae(%rip),%rax
mov    (%rax),%al
mov    %al,-0xd(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%eax
mov    0x2e95(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11a3 <read_input+0x83>
cmpl   $0x3ff,-0xc(%rbp)
jne    1187 <read_input+0x67>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
jmp    119e <read_input+0x7e>
mov    -0xd(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0xc(%rbp)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
jmp    113f <read_input+0x1f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_input>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb0(%rip),%r15
cmp    (%r15),%al
jne    1148 <read_input+0x28>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeb1(%rip),%r14
xor    %ebp,%ebp
jmp    1174 <read_input+0x54>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%ecx
add    $0x1,%ebp
mov    %al,(%rbx,%rcx,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r15),%al
je     113d <read_input+0x1d>
cmp    $0x3ff,%ebp
jne    1160 <read_input+0x40>
mov    %r14,%rdi
call   1030 <puts@plt>
movb   $0x0,0x3ff(%rbx)
mov    $0x3ff,%ebp
jmp    1168 <read_input+0x48>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [36 x i8] c"Error: Maximum input size exceeded.\00"
define void @read_input(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = load i8, i8* @EOF
store i8 %5, i8* %4
br label %6
6: ; preds = %28, %1
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %4
%8 = sext i8 %7 to i32
%9 = load i8, i8* @EOF
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %29
12: ; preds = %6
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 1023
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = call i32 @puts(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%17 = load i8*, i8** %2
%18 = load i32, i32* %3
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 0, i8* %20
br label %28
21: ; preds = %12
%22 = load i8, i8* %4
%23 = load i8*, i8** %2
%24 = load i32, i32* %3
%25 = add i32 %24, 1
store i32 %25, i32* %3
%26 = zext i32 %24 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
store i8 %22, i8* %27
br label %28
28: ; preds = %21, %15
br label %6
29: ; preds = %6
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [36 x i8] c"Error: Maximum input size exceeded.\00"
define void @read_input(i8* nocapture writeonly %0) {
%2 = tail call signext i8 (...) @getchar()
%3 = load i8, i8* @EOF
%4 = icmp eq i8 %2, %3
br i1 %4, label %22, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1023
br label %7
7: ; preds = %5, %17
%8 = phi i8 [ %2, %5 ], [ %19, %17 ]
%9 = phi i32 [ 0, %5 ], [ %18, %17 ]
%10 = icmp eq i32 %9, 1023
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i8 0, i8* %6
br label %17
13: ; preds = %7
%14 = add i32 %9, 1
%15 = zext i32 %9 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
store i8 %8, i8* %16
br label %17
17: ; preds = %13, %11
%18 = phi i32 [ 1023, %11 ], [ %14, %13 ]
%19 = tail call signext i8 (...) @getchar()
%20 = load i8, i8* @EOF
%21 = icmp eq i8 %19, %20
br i1 %21, label %22, label %7
22: ; preds = %17, %1
ret void
}