#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 */
int EOF;
int getchr();
char *trm_line(char *line) {
  char *p;
  int ch;
  p = line;
  while ((ch = getchr()) != EOF && ch != '\n')
    if ((p - line) < 200)
      *p++ = ch;
  *p = 0;
  return (ch == EOF ? NULL : line);
}


x86 assembly (clang, -O0):
<trm_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getchr@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
mov    0x2eaf(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x15(%rbp)
je     114e <trm_line+0x3e>
cmpl   $0xa,-0x14(%rbp)
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    115e <trm_line+0x4e>
jmp    1190 <trm_line+0x80>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
cmp    $0xc8,%rax
jge    118b <trm_line+0x7b>
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1124 <trm_line+0x14>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x14(%rbp),%eax
mov    0x2e47(%rip),%rcx
cmp    (%rcx),%eax
jne    11b4 <trm_line+0xa4>
xor    %eax,%eax
mov    %rax,-0x20(%rbp)
jmp    11bc <trm_line+0xac>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trm_line>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <getchr@plt>
mov    0x2ec2(%rip),%r14
cmp    $0xa,%eax
je     1168 <trm_line+0x58>
cmp    (%r14),%eax
je     1168 <trm_line+0x58>
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rcx
sub    %r15,%rcx
cmp    $0xc7,%rcx
jg     1155 <trm_line+0x45>
mov    %al,(%rbx)
add    $0x1,%rbx
xor    %eax,%eax
call   1030 <getchr@plt>
cmp    $0xa,%eax
je     116b <trm_line+0x5b>
cmp    (%r14),%eax
jne    1140 <trm_line+0x30>
jmp    116b <trm_line+0x5b>
mov    %r15,%rbx
movb   $0x0,(%rbx)
xor    %ecx,%ecx
cmp    (%r14),%eax
cmove  %rcx,%r15
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
define i8* @trm_line(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
br label %6
6: ; preds = %27, %1
%7 = call i32 (...) @getchr()
store i32 %7, i32* %4
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 10
br label %13
13: ; preds = %10, %6
%14 = phi i1 [ false, %6 ], [ %12, %10 ]
br i1 %14, label %15, label %28
15: ; preds = %13
%16 = load i8*, i8** %3
%17 = load i8*, i8** %2
%18 = ptrtoint i8* %16 to i64
%19 = ptrtoint i8* %17 to i64
%20 = sub i64 %18, %19
%21 = icmp slt i64 %20, 200
br i1 %21, label %22, label %27
22: ; preds = %15
%23 = load i32, i32* %4
%24 = trunc i32 %23 to i8
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
store i8 %24, i8* %25
br label %27
27: ; preds = %22, %15
br label %6
28: ; preds = %13
%29 = load i8*, i8** %3
store i8 0, i8* %29
%30 = load i32, i32* %4
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %34
33: ; preds = %28
br label %36
34: ; preds = %28
%35 = load i8*, i8** %2
br label %36
36: ; preds = %34, %33
%37 = phi i8* [ null, %33 ], [ %35, %34 ]
ret i8* %37
}

LLVM IR (-O2):
@EOF = global i32 0
define i8* @trm_line(i8* %0) {
%2 = tail call i32 (...) @getchr()
%3 = load i32, i32* @EOF
%4 = icmp ne i32 %2, %3
%5 = icmp ne i32 %2, 10
%6 = and i1 %5, %4
br i1 %6, label %7, label %25
7: ; preds = %1
%8 = ptrtoint i8* %0 to i64
br label %9
9: ; preds = %7, %18
%10 = phi i32 [ %2, %7 ], [ %20, %18 ]
%11 = phi i8* [ %0, %7 ], [ %19, %18 ]
%12 = ptrtoint i8* %11 to i64
%13 = sub i64 %12, %8
%14 = icmp slt i64 %13, 200
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = trunc i32 %10 to i8
%17 = getelementptr inbounds i8, i8* %11, i64 1
store i8 %16, i8* %11
br label %18
18: ; preds = %15, %9
%19 = phi i8* [ %17, %15 ], [ %11, %9 ]
%20 = tail call i32 (...) @getchr()
%21 = load i32, i32* @EOF
%22 = icmp ne i32 %20, %21
%23 = icmp ne i32 %20, 10
%24 = and i1 %23, %22
br i1 %24, label %9, label %25
25: ; preds = %18, %1
%26 = phi i8* [ %0, %1 ], [ %19, %18 ]
%27 = phi i32 [ %2, %1 ], [ %20, %18 ]
store i8 0, i8* %26
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
%30 = select i1 %29, i8* null, i8* %0
ret i8* %30
}