#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 */
scalar_t__ EOF;
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int input_line(FILE *in, char *s) {
  int i;
  for (i = 0;; ++i) {
    if (fscanf(in, "%d", &s[i]) == EOF)
      return EOF;
    if (s[i] == '\n')
      break;
  }
  s[i] = '\0';
  return 1;
}


x86 assembly (clang, -O0):
<input_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x1c(%rbp),%rax
add    %rax,%rdx
lea    0xec3(%rip),%rsi
call   1030 <fscanf@plt>
mov    0x2e9f(%rip),%rcx
cmp    (%rcx),%rax
jne    1164 <input_line+0x54>
mov    0x2e8f(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    11a4 <input_line+0x94>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    117e <input_line+0x6e>
jmp    1191 <input_line+0x81>
jmp    1183 <input_line+0x73>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <input_line+0x17>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_line>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xedb(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fscanf@plt>
mov    0x2eb4(%rip),%r12
cmp    (%r12),%rax
je     1179 <input_line+0x69>
add    $0x1,%rbx
lea    0xebb(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0xa,-0x1(%rbx)
je     1170 <input_line+0x60>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <fscanf@plt>
add    $0x1,%rbx
cmp    (%r12),%rax
jne    1150 <input_line+0x40>
jmp    1179 <input_line+0x69>
movb   $0x0,-0x1(%rbx)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
define i32 @input_line(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %7
7: ; preds = %29, %2
%8 = load i32*, i32** %4
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %7
%17 = load i64, i64* @EOF
%18 = trunc i64 %17 to i32
store i32 %18, i32* %3
br label %37
19: ; preds = %7
%20 = load i8*, i8** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 10
br i1 %26, label %27, label %28
27: ; preds = %19
br label %32
28: ; preds = %19
br label %29
29: ; preds = %28
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %7
32: ; preds = %27
%33 = load i8*, i8** %5
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 0, i8* %36
store i32 1, i32* %3
br label %37
37: ; preds = %32, %16
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
define i32 @input_line(i32* nocapture %0, i8* %1) {
%3 = tail call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %11, label %14
6: ; preds = %14
%7 = getelementptr inbounds i8, i8* %1, i64 %19
%8 = tail call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i64, i64* @EOF
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %6, %2
%12 = phi i64 [ %3, %2 ], [ %8, %6 ]
%13 = trunc i64 %12 to i32
br label %21
14: ; preds = %2, %6
%15 = phi i64 [ %19, %6 ], [ 0, %2 ]
%16 = phi i8* [ %7, %6 ], [ %1, %2 ]
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 10
%19 = add nuw i64 %15, 1
br i1 %18, label %20, label %6
20: ; preds = %14
store i8 0, i8* %16
br label %21
21: ; preds = %20, %11
%22 = phi i32 [ %13, %11 ], [ 1, %20 ]
ret i32 %22
}