#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_buffer) {
  int index = 0;
  char current_char = EOF;
  while ((current_char = getchar()) != EOF) {
    if (index == 100000) {
      puts("This program does not support input greater than 100,000 "
           "characters in length");
      break;
    }
    input_buffer[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     1199 <read_input+0x79>
cmpl   $0x186a0,-0xc(%rbp)
jne    117c <read_input+0x5c>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
jmp    1199 <read_input+0x79>
mov    -0xd(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0xc(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    113f <read_input+0x1f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_input>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb2(%rip),%r14
cmp    (%r14),%al
je     115d <read_input+0x3d>
xor    %ebx,%ebx
nopl   (%rax)
cmp    $0x186a0,%rbx
je     1163 <read_input+0x43>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%al
jne    1140 <read_input+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe96(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [78 x i8] c"This program does not support input greater than 100,000 characters in length\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 = %17, %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 %24
12: ; preds = %6
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 100000
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @puts(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0))
br label %24
17: ; preds = %12
%18 = load i8, i8* %4
%19 = load i8*, i8** %2
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
store i8 %18, i8* %23
br label %6
24: ; preds = %15, %6
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [78 x i8] c"This program does not support input greater than 100,000 characters in length\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 %17, label %5
5: ; preds = %1, %11
%6 = phi i64 [ %12, %11 ], [ 0, %1 ]
%7 = phi i8 [ %14, %11 ], [ %2, %1 ]
%8 = icmp eq i64 %6, 100000
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0))
br label %17
11: ; preds = %5
%12 = add nuw nsw i64 %6, 1
%13 = getelementptr inbounds i8, i8* %0, i64 %6
store i8 %7, i8* %13
%14 = tail call signext i8 (...) @getchar()
%15 = load i8, i8* @EOF
%16 = icmp eq i8 %14, %15
br i1 %16, label %17, label %5
17: ; preds = %11, %1, %9
ret void
}