#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*/ FILE;

/* Variables and functions */
int EOF;
int fgetc(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ readdefine(char *);
int strlen(char *);
void readinput(FILE *file) {
  char buf[1024];
  int n;
  while (fgets(buf, sizeof buf, file)) {
    readdefine(buf);
    n = strlen(buf);
    if (n == sizeof buf - 1 && buf[n - 1] != '\n') {
      int ch;
      while ((ch = fgetc(file)) != EOF && ch != '\n')
        ;
    }
  }
}


x86 assembly (clang, -O0):
<readinput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     121a <readinput+0xda>
lea    -0x410(%rbp),%rdi
call   1040 <readdefine@plt>
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x414(%rbp)
movslq -0x414(%rbp),%rax
cmp    $0x3ff,%rax
jne    1215 <readinput+0xd5>
mov    -0x414(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     1215 <readinput+0xd5>
jmp    11c0 <readinput+0x80>
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0x418(%rbp)
xor    %eax,%eax
mov    0x2e0e(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x419(%rbp)
je     11f8 <readinput+0xb8>
cmpl   $0xa,-0x418(%rbp)
setne  %al
mov    %al,-0x419(%rbp)
mov    -0x419(%rbp),%al
test   $0x1,%al
jne    120b <readinput+0xcb>
jmp    1210 <readinput+0xd0>
jmp    11c0 <readinput+0x80>
jmp    1215 <readinput+0xd5>
jmp    114f <readinput+0xf>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readinput>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11c4 <readinput+0x84>
mov    %rsp,%r14
mov    0x2e7a(%rip),%r15
jmp    1185 <readinput+0x45>
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11c4 <readinput+0x84>
mov    %r14,%rdi
call   1040 <readdefine@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x3ff,%eax
jne    1170 <readinput+0x30>
cmpb   $0xa,0x3fe(%rsp)
0a
je     1170 <readinput+0x30>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    $0xa,%eax
je     1170 <readinput+0x30>
cmp    (%r15),%eax
jne    11b0 <readinput+0x70>
jmp    1170 <readinput+0x30>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
define void @readinput(i32* %0) {
%2 = alloca i32*
%3 = alloca [1024 x i8]
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
br label %6
6: ; preds = %40, %1
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = load i32*, i32** %2
%9 = call i64 @fgets(i8* %7, i32 1024, i32* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %41
11: ; preds = %6
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = call i32 @readdefine(i8* %12)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = icmp eq i64 %17, 1023
br i1 %18, label %19, label %40
19: ; preds = %11
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 10
br i1 %26, label %27, label %40
27: ; preds = %19
br label %28
28: ; preds = %38, %27
%29 = load i32*, i32** %2
%30 = call i32 @fgetc(i32* %29)
store i32 %30, i32* %5
%31 = load i32, i32* @EOF
%32 = icmp ne i32 %30, %31
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load i32, i32* %5
%35 = icmp ne i32 %34, 10
br label %36
36: ; preds = %33, %28
%37 = phi i1 [ false, %28 ], [ %35, %33 ]
br i1 %37, label %38, label %39
38: ; preds = %36
br label %28
39: ; preds = %36
br label %40
40: ; preds = %39, %19, %11
br label %6
41: ; preds = %6
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @readinput(i32* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i64 @fgets(i8* %3, i32 1024, i32* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %24, label %6
6: ; preds = %1
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 1022
br label %8
8: ; preds = %6, %21
%9 = call i32 @readdefine(i8* %3)
%10 = call i32 @strlen(i8* %3)
%11 = icmp ne i32 %10, 1023
%12 = load i8, i8* %7
%13 = icmp eq i8 %12, 10
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %21, label %15
15: ; preds = %8, %15
%16 = call i32 @fgetc(i32* %0)
%17 = load i32, i32* @EOF
%18 = icmp ne i32 %16, %17
%19 = icmp ne i32 %16, 10
%20 = and i1 %19, %18
br i1 %20, label %15, label %21
21: ; preds = %15, %8
%22 = call i64 @fgets(i8* %3, i32 1024, i32* %0)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %8
24: ; preds = %21, %1
ret void
}