#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 /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
scalar_t__ has_zero(unsigned int);
int /*<<< orphan*/ memmove(char *, char *, int);
int read(int /*<<< orphan*/, char *, int);
const char *fgets2(FILE *stream) {
  static char buffer[(256 * 1024) + 32];
  static char *end = buffer;
  static char *line = buffer;
  char *next;
  int ret;
  next = line;
  while (1) {
    while (next < end && (((unsigned long)next) & 3) && *next != '\n')
      next++;
    while (next < end) {
      if (has_zero(*(unsigned int *)next ^ 0x0A0A0A0A))
        break;
      next += 4;
      if (has_zero(*(unsigned int *)next ^ 0x0A0A0A0A))
        break;
      next += 4;
      if (has_zero(*(unsigned int *)next ^ 0x0A0A0A0A))
        break;
      next += 4;
      if (has_zero(*(unsigned int *)next ^ 0x0A0A0A0A))
        break;
      next += 4;
      if (has_zero(*(unsigned int *)next ^ 0x0A0A0A0A))
        break;
      next += 4;
      if (has_zero(*(unsigned int *)next ^ 0x0A0A0A0A))
        break;
      next += 4;
      if (has_zero(*(unsigned int *)next ^ 0x0A0A0A0A))
        break;
      next += 4;
      if (has_zero(*(unsigned int *)next ^ 0x0A0A0A0A))
        break;
      next += 4;
    }
    while (next < end) {
      if (*next == '\n') {
        const char *start = line;
        *next = '\0';
        line = next + 1;
        return start;
      }
      next++;
    }
    if (line > buffer) {
      if (end != line)
        memmove(buffer, line, end - line);
      end = buffer + (end - line);
      next = end;
      line = buffer;
    } else {
      if (end == buffer + (256 * 1024))
        return NULL;
    }
    ret = read(fileno(stream), end, buffer + (256 * 1024) - end);
    if (ret <= 0) {
      if (end == line)
        return NULL;
      *end = '\0';
      end = line;
      return line;
    }
    end += ret;
    *end = '\n';
  }
}


x86 assembly (clang, -O0):
<fgets2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ef5(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    115c <fgets2+0x1c>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    0x2ed7(%rip),%rcx
mov    %al,-0x29(%rbp)
jae    1199 <fgets2+0x59>
mov    -0x18(%rbp),%rcx
and    $0x3,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
je     1199 <fgets2+0x59>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11a9 <fgets2+0x69>
jmp    11ba <fgets2+0x7a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115c <fgets2+0x1c>
jmp    11bf <fgets2+0x7f>
mov    -0x18(%rbp),%rax
cmp    0x2e76(%rip),%rax
jae    1335 <fgets2+0x1f5>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
xor    $0xa0a0a0a,%edi
call   1050 <has_zero@plt>
cmp    $0x0,%rax
je     11f0 <fgets2+0xb0>
jmp    1335 <fgets2+0x1f5>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
xor    $0xa0a0a0a,%edi
call   1050 <has_zero@plt>
cmp    $0x0,%rax
je     121c <fgets2+0xdc>
jmp    1335 <fgets2+0x1f5>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
xor    $0xa0a0a0a,%edi
call   1050 <has_zero@plt>
cmp    $0x0,%rax
je     1248 <fgets2+0x108>
jmp    1335 <fgets2+0x1f5>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
xor    $0xa0a0a0a,%edi
call   1050 <has_zero@plt>
cmp    $0x0,%rax
je     1274 <fgets2+0x134>
jmp    1335 <fgets2+0x1f5>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
xor    $0xa0a0a0a,%edi
call   1050 <has_zero@plt>
cmp    $0x0,%rax
je     12a0 <fgets2+0x160>
jmp    1335 <fgets2+0x1f5>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
xor    $0xa0a0a0a,%edi
call   1050 <has_zero@plt>
cmp    $0x0,%rax
je     12cc <fgets2+0x18c>
jmp    1335 <fgets2+0x1f5>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
xor    $0xa0a0a0a,%edi
call   1050 <has_zero@plt>
cmp    $0x0,%rax
je     12f8 <fgets2+0x1b8>
jmp    1335 <fgets2+0x1f5>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
xor    $0xa0a0a0a,%edi
call   1050 <has_zero@plt>
cmp    $0x0,%rax
je     1324 <fgets2+0x1e4>
jmp    1335 <fgets2+0x1f5>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    11bf <fgets2+0x7f>
jmp    133a <fgets2+0x1fa>
mov    -0x18(%rbp),%rax
cmp    0x2cfb(%rip),%rax
jae    139a <fgets2+0x25a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1389 <fgets2+0x249>
mov    0x2ce6(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,0x2ccc(%rip)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1500 <fgets2+0x3c0>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    133a <fgets2+0x1fa>
lea    0x2cbf(%rip),%rax
cmp    %rax,0x2ca0(%rip)
jbe    1428 <fgets2+0x2e8>
mov    0x2c8b(%rip),%rax
cmp    0x2c8c(%rip),%rax
je     13e8 <fgets2+0x2a8>
mov    0x2c7f(%rip),%rsi
mov    0x2c70(%rip),%rax
mov    0x2c71(%rip),%rcx
sub    %rcx,%rax
mov    %eax,%edx
lea    0x2c7d(%rip),%rdi
call   1060 <memmove@plt>
mov    0x2c51(%rip),%rcx
mov    0x2c52(%rip),%rax
sub    %rax,%rcx
lea    0x2c60(%rip),%rax
add    %rcx,%rax
mov    %rax,0x2c36(%rip)
mov    0x2c2f(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0x2c44(%rip),%rax
mov    %rax,0x2c25(%rip)
jmp    1454 <fgets2+0x314>
lea    0x2c31(%rip),%rax
add    $0x40000,%rax
cmp    %rax,0x2c04(%rip)
jne    144f <fgets2+0x30f>
movq   $0x0,-0x8(%rbp)
jmp    1500 <fgets2+0x3c0>
jmp    1454 <fgets2+0x314>
mov    -0x10(%rbp),%rdi
call   1040 <fileno@plt>
mov    %eax,%edi
mov    0x2bda(%rip),%rsi
mov    0x2bd3(%rip),%rcx
lea    0x2bec(%rip),%rax
add    $0x40000,%rax
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     14da <fgets2+0x39a>
mov    0x2ba8(%rip),%rax
cmp    0x2ba9(%rip),%rax
jne    14b2 <fgets2+0x372>
movq   $0x0,-0x8(%rbp)
jmp    1500 <fgets2+0x3c0>
mov    0x2b87(%rip),%rax
movb   $0x0,(%rax)
mov    0x2b85(%rip),%rax
mov    %rax,0x2b76(%rip)
mov    0x2b77(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1500 <fgets2+0x3c0>
mov    -0x1c(%rbp),%ecx
mov    0x2b5c(%rip),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,0x2b4f(%rip)
mov    0x2b48(%rip),%rax
movb   $0xa,(%rax)
jmp    1157 <fgets2+0x17>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fgets2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    0x2ef3(%rip),%r12
mov    0x2ee4(%rip),%rdx
mov    $0xa0a0a0a,%ebp
lea    0x2ef8(%rip),%r13
xor    %r14d,%r14d
cmp    %rdx,%r12
jae    11e0 <fgets2+0xa0>
mov    %r12d,%eax
and    $0x3,%eax
test   %rax,%rax
je     11e0 <fgets2+0xa0>
cmpb   $0xa,(%r12)
je     11e0 <fgets2+0xa0>
lea    0x1(%r12),%rbx
cmp    %rdx,%rbx
jae    11e3 <fgets2+0xa3>
mov    %ebx,%eax
and    $0x3,%eax
test   %rax,%rax
je     11e3 <fgets2+0xa3>
cmpb   $0xa,(%rbx)
je     11e3 <fgets2+0xa3>
lea    0x2(%r12),%rbx
cmp    %rdx,%rbx
jae    11e3 <fgets2+0xa3>
mov    %ebx,%eax
and    $0x3,%eax
test   %rax,%rax
je     11e3 <fgets2+0xa3>
cmpb   $0xa,(%rbx)
je     11e3 <fgets2+0xa3>
lea    0x3(%r12),%rbx
cmp    %rdx,%rbx
jae    11e3 <fgets2+0xa3>
mov    %ebx,%eax
and    $0x3,%eax
test   %rax,%rax
je     11e3 <fgets2+0xa3>
lea    0x4(%r12),%rax
cmpb   $0xa,0x3(%r12)
cmovne %rax,%rbx
jmp    11e3 <fgets2+0xa3>
nopl   0x0(%rax)
mov    %r12,%rbx
cmp    %rdx,%rbx
jae    12b7 <fgets2+0x177>
mov    (%rbx),%edi
xor    %ebp,%edi
call   1050 <has_zero@plt>
test   %rax,%rax
jne    12b0 <fgets2+0x170>
mov    0x4(%rbx),%edi
xor    %ebp,%edi
call   1050 <has_zero@plt>
test   %rax,%rax
jne    127a <fgets2+0x13a>
mov    0x8(%rbx),%edi
xor    %ebp,%edi
call   1050 <has_zero@plt>
test   %rax,%rax
jne    1280 <fgets2+0x140>
mov    0xc(%rbx),%edi
xor    %ebp,%edi
call   1050 <has_zero@plt>
test   %rax,%rax
jne    1286 <fgets2+0x146>
mov    0x10(%rbx),%edi
xor    %ebp,%edi
call   1050 <has_zero@plt>
test   %rax,%rax
jne    128c <fgets2+0x14c>
mov    0x14(%rbx),%edi
xor    %ebp,%edi
call   1050 <has_zero@plt>
test   %rax,%rax
jne    1292 <fgets2+0x152>
mov    0x18(%rbx),%edi
xor    %ebp,%edi
call   1050 <has_zero@plt>
test   %rax,%rax
jne    1298 <fgets2+0x158>
mov    0x1c(%rbx),%edi
xor    %ebp,%edi
call   1050 <has_zero@plt>
test   %rax,%rax
jne    129e <fgets2+0x15e>
add    $0x20,%rbx
cmp    0x2dce(%rip),%rbx
jb     11ec <fgets2+0xac>
jmp    12b0 <fgets2+0x170>
add    $0x4,%rbx
jmp    12b0 <fgets2+0x170>
add    $0x8,%rbx
jmp    12b0 <fgets2+0x170>
add    $0xc,%rbx
jmp    12b0 <fgets2+0x170>
add    $0x10,%rbx
jmp    12b0 <fgets2+0x170>
add    $0x14,%rbx
jmp    12b0 <fgets2+0x170>
add    $0x18,%rbx
jmp    12b0 <fgets2+0x170>
add    $0x1c,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2d89(%rip),%rdx
cmp    %rdx,%rbx
jae    12f0 <fgets2+0x1b0>
mov    %rdx,%rax
sub    %rbx,%rax
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
cmpb   $0xa,-0x1(%rbx)
je     1390 <fgets2+0x250>
add    $0x1,%rbx
add    $0xffffffffffffffff,%rax
jne    12d0 <fgets2+0x190>
mov    %rdx,%r12
jmp    12f3 <fgets2+0x1b3>
nopl   0x0(%rax)
mov    %rbx,%r12
mov    0x2d4e(%rip),%rsi
cmp    %r13,%rsi
jbe    1320 <fgets2+0x1e0>
cmp    %rsi,%rdx
je     132e <fgets2+0x1ee>
sub    %esi,%edx
mov    %r13,%rdi
call   1060 <memmove@plt>
mov    0x2d2b(%rip),%r12
mov    0x2d2c(%rip),%rdx
jmp    1331 <fgets2+0x1f1>
xchg   %ax,%ax
lea    0x42d39(%rip),%rax
cmp    %rax,%rdx
jne    1345 <fgets2+0x205>
jmp    13a2 <fgets2+0x262>
mov    %rdx,%r12
sub    %rdx,%r12
add    %r13,%r12
mov    %r12,0x2d02(%rip)
mov    %r13,0x2d03(%rip)
mov    %r15,%rdi
call   1040 <fileno@plt>
mov    0x2cec(%rip),%rsi
mov    %r13d,%edx
sub    %esi,%edx
add    $0x40000,%edx
mov    %eax,%edi
call   1030 <read@plt>
mov    0x2cd3(%rip),%rcx
test   %eax,%eax
jle    13b4 <fgets2+0x274>
mov    %eax,%eax
lea    (%rcx,%rax,1),%rdx
mov    %rdx,0x2cc2(%rip)
movb   $0xa,(%rcx,%rax,1)
cmp    %rdx,%r12
jb     1170 <fgets2+0x30>
jmp    11e0 <fgets2+0xa0>
mov    0x2cb1(%rip),%r14
movb   $0x0,-0x1(%rbx)
mov    %rbx,0x2ca6(%rip)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c8d(%rip),%r14
cmp    %r14,%rcx
je     13cc <fgets2+0x28c>
movb   $0x0,(%rcx)
mov    %r14,0x2c76(%rip)
jmp    13a2 <fgets2+0x262>
xor    %r14d,%r14d
jmp    13a2 <fgets2+0x262>

LLVM IR (-O0):
@fgets2.buffer = internal global [262176 x i8] zeroinitializer
@fgets2.end = internal global i8* getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i32 0, i32 0)
@fgets2.line = internal global i8* getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i32 0, i32 0)
define i8* @fgets2(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i32* %0, i32** %3
%7 = load i8*, i8** @fgets2.line
store i8* %7, i8** %4
br label %8
8: ; preds = %1, %182
br label %9
9: ; preds = %25, %8
%10 = load i8*, i8** %4
%11 = load i8*, i8** @fgets2.end
%12 = icmp ult i8* %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = ptrtoint i8* %14 to i64
%16 = and i64 %15, 3
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br label %23
23: ; preds = %18, %13, %9
%24 = phi i1 [ false, %13 ], [ false, %9 ], [ %22, %18 ]
br i1 %24, label %25, label %28
25: ; preds = %23
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
br label %9
28: ; preds = %23
br label %29
29: ; preds = %111, %28
%30 = load i8*, i8** %4
%31 = load i8*, i8** @fgets2.end
%32 = icmp ult i8* %30, %31
br i1 %32, label %33, label %114
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = bitcast i8* %34 to i32*
%36 = load i32, i32* %35
%37 = xor i32 %36, 168430090
%38 = call i64 @has_zero(i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %33
br label %114
41: ; preds = %33
%42 = load i8*, i8** %4
%43 = getelementptr inbounds i8, i8* %42, i64 4
store i8* %43, i8** %4
%44 = load i8*, i8** %4
%45 = bitcast i8* %44 to i32*
%46 = load i32, i32* %45
%47 = xor i32 %46, 168430090
%48 = call i64 @has_zero(i32 %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %41
br label %114
51: ; preds = %41
%52 = load i8*, i8** %4
%53 = getelementptr inbounds i8, i8* %52, i64 4
store i8* %53, i8** %4
%54 = load i8*, i8** %4
%55 = bitcast i8* %54 to i32*
%56 = load i32, i32* %55
%57 = xor i32 %56, 168430090
%58 = call i64 @has_zero(i32 %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %51
br label %114
61: ; preds = %51
%62 = load i8*, i8** %4
%63 = getelementptr inbounds i8, i8* %62, i64 4
store i8* %63, i8** %4
%64 = load i8*, i8** %4
%65 = bitcast i8* %64 to i32*
%66 = load i32, i32* %65
%67 = xor i32 %66, 168430090
%68 = call i64 @has_zero(i32 %67)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %61
br label %114
71: ; preds = %61
%72 = load i8*, i8** %4
%73 = getelementptr inbounds i8, i8* %72, i64 4
store i8* %73, i8** %4
%74 = load i8*, i8** %4
%75 = bitcast i8* %74 to i32*
%76 = load i32, i32* %75
%77 = xor i32 %76, 168430090
%78 = call i64 @has_zero(i32 %77)
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %81
80: ; preds = %71
br label %114
81: ; preds = %71
%82 = load i8*, i8** %4
%83 = getelementptr inbounds i8, i8* %82, i64 4
store i8* %83, i8** %4
%84 = load i8*, i8** %4
%85 = bitcast i8* %84 to i32*
%86 = load i32, i32* %85
%87 = xor i32 %86, 168430090
%88 = call i64 @has_zero(i32 %87)
%89 = icmp ne i64 %88, 0
br i1 %89, label %90, label %91
90: ; preds = %81
br label %114
91: ; preds = %81
%92 = load i8*, i8** %4
%93 = getelementptr inbounds i8, i8* %92, i64 4
store i8* %93, i8** %4
%94 = load i8*, i8** %4
%95 = bitcast i8* %94 to i32*
%96 = load i32, i32* %95
%97 = xor i32 %96, 168430090
%98 = call i64 @has_zero(i32 %97)
%99 = icmp ne i64 %98, 0
br i1 %99, label %100, label %101
100: ; preds = %91
br label %114
101: ; preds = %91
%102 = load i8*, i8** %4
%103 = getelementptr inbounds i8, i8* %102, i64 4
store i8* %103, i8** %4
%104 = load i8*, i8** %4
%105 = bitcast i8* %104 to i32*
%106 = load i32, i32* %105
%107 = xor i32 %106, 168430090
%108 = call i64 @has_zero(i32 %107)
%109 = icmp ne i64 %108, 0
br i1 %109, label %110, label %111
110: ; preds = %101
br label %114
111: ; preds = %101
%112 = load i8*, i8** %4
%113 = getelementptr inbounds i8, i8* %112, i64 4
store i8* %113, i8** %4
br label %29
114: ; preds = %110, %100, %90, %80, %70, %60, %50, %40, %29
br label %115
115: ; preds = %130, %114
%116 = load i8*, i8** %4
%117 = load i8*, i8** @fgets2.end
%118 = icmp ult i8* %116, %117
br i1 %118, label %119, label %133
119: ; preds = %115
%120 = load i8*, i8** %4
%121 = load i8, i8* %120
%122 = sext i8 %121 to i32
%123 = icmp eq i32 %122, 10
br i1 %123, label %124, label %130
124: ; preds = %119
%125 = load i8*, i8** @fgets2.line
store i8* %125, i8** %6
%126 = load i8*, i8** %4
store i8 0, i8* %126
%127 = load i8*, i8** %4
%128 = getelementptr inbounds i8, i8* %127, i64 1
store i8* %128, i8** @fgets2.line
%129 = load i8*, i8** %6
store i8* %129, i8** %2
br label %188
130: ; preds = %119
%131 = load i8*, i8** %4
%132 = getelementptr inbounds i8, i8* %131, i32 1
store i8* %132, i8** %4
br label %115
133: ; preds = %115
%134 = load i8*, i8** @fgets2.line
%135 = icmp ugt i8* %134, getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 0)
br i1 %135, label %136, label %157
136: ; preds = %133
%137 = load i8*, i8** @fgets2.end
%138 = load i8*, i8** @fgets2.line
%139 = icmp ne i8* %137, %138
br i1 %139, label %140, label %149
140: ; preds = %136
%141 = load i8*, i8** @fgets2.line
%142 = load i8*, i8** @fgets2.end
%143 = load i8*, i8** @fgets2.line
%144 = ptrtoint i8* %142 to i64
%145 = ptrtoint i8* %143 to i64
%146 = sub i64 %144, %145
%147 = trunc i64 %146 to i32
%148 = call i32 @memmove(i8* getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 0), i8* %141, i32 %147)
br label %149
149: ; preds = %140, %136
%150 = load i8*, i8** @fgets2.end
%151 = load i8*, i8** @fgets2.line
%152 = ptrtoint i8* %150 to i64
%153 = ptrtoint i8* %151 to i64
%154 = sub i64 %152, %153
%155 = getelementptr inbounds i8, i8* getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 0), i64 %154
store i8* %155, i8** @fgets2.end
%156 = load i8*, i8** @fgets2.end
store i8* %156, i8** %4
store i8* getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 0), i8** @fgets2.line
br label %162
157: ; preds = %133
%158 = load i8*, i8** @fgets2.end
%159 = icmp eq i8* %158, getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 262144)
br i1 %159, label %160, label %161
160: ; preds = %157
store i8* null, i8** %2
br label %188
161: ; preds = %157
br label %162
162: ; preds = %161, %149
%163 = load i32*, i32** %3
%164 = call i32 @fileno(i32* %163)
%165 = load i8*, i8** @fgets2.end
%166 = load i8*, i8** @fgets2.end
%167 = ptrtoint i8* %166 to i64
%168 = sub i64 ptrtoint (i8* getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 262144) to i64), %167
%169 = trunc i64 %168 to i32
%170 = call i32 @read(i32 %164, i8* %165, i32 %169)
store i32 %170, i32* %5
%171 = load i32, i32* %5
%172 = icmp sle i32 %171, 0
br i1 %172, label %173, label %182
173: ; preds = %162
%174 = load i8*, i8** @fgets2.end
%175 = load i8*, i8** @fgets2.line
%176 = icmp eq i8* %174, %175
br i1 %176, label %177, label %178
177: ; preds = %173
store i8* null, i8** %2
br label %188
178: ; preds = %173
%179 = load i8*, i8** @fgets2.end
store i8 0, i8* %179
%180 = load i8*, i8** @fgets2.line
store i8* %180, i8** @fgets2.end
%181 = load i8*, i8** @fgets2.line
store i8* %181, i8** %2
br label %188
182: ; preds = %162
%183 = load i32, i32* %5
%184 = load i8*, i8** @fgets2.end
%185 = sext i32 %183 to i64
%186 = getelementptr inbounds i8, i8* %184, i64 %185
store i8* %186, i8** @fgets2.end
%187 = load i8*, i8** @fgets2.end
store i8 10, i8* %187
br label %8
188: ; preds = %178, %177, %160, %124
%189 = load i8*, i8** %2
ret i8* %189
}

LLVM IR (-O2):
@fgets2.buffer = internal global [262176 x i8] zeroinitializer
@fgets2.end = internal unnamed_addr global i8* getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 0)
@fgets2.line = internal unnamed_addr global i8* getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 0)
define i8* @fgets2(i32* nocapture %0) {
%2 = load i8*, i8** @fgets2.line
%3 = load i8*, i8** @fgets2.end
br label %4
4: ; preds = %168, %1
%5 = phi i8* [ %3, %1 ], [ %170, %168 ]
%6 = phi i8* [ %2, %1 ], [ %155, %168 ]
%7 = icmp uge i8* %6, %5
%8 = ptrtoint i8* %6 to i64
%9 = and i64 %8, 3
%10 = icmp eq i64 %9, 0
%11 = select i1 %7, i1 true, i1 %10
br i1 %11, label %47, label %12
12: ; preds = %4
%13 = load i8, i8* %6
%14 = icmp eq i8 %13, 10
br i1 %14, label %47, label %15
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %6, i64 1
%17 = icmp uge i8* %16, %5
%18 = ptrtoint i8* %16 to i64
%19 = and i64 %18, 3
%20 = icmp eq i64 %19, 0
%21 = select i1 %17, i1 true, i1 %20
br i1 %21, label %47, label %22
22: ; preds = %15
%23 = load i8, i8* %16
%24 = icmp eq i8 %23, 10
br i1 %24, label %47, label %25
25: ; preds = %22
%26 = getelementptr inbounds i8, i8* %6, i64 2
%27 = icmp uge i8* %26, %5
%28 = ptrtoint i8* %26 to i64
%29 = and i64 %28, 3
%30 = icmp eq i64 %29, 0
%31 = select i1 %27, i1 true, i1 %30
br i1 %31, label %47, label %32
32: ; preds = %25
%33 = load i8, i8* %26
%34 = icmp eq i8 %33, 10
br i1 %34, label %47, label %35
35: ; preds = %32
%36 = getelementptr inbounds i8, i8* %6, i64 3
%37 = icmp uge i8* %36, %5
%38 = ptrtoint i8* %36 to i64
%39 = and i64 %38, 3
%40 = icmp eq i64 %39, 0
%41 = select i1 %37, i1 true, i1 %40
br i1 %41, label %47, label %42
42: ; preds = %35
%43 = load i8, i8* %36
%44 = icmp eq i8 %43, 10
%45 = getelementptr inbounds i8, i8* %6, i64 4
%46 = select i1 %44, i8* %36, i8* %45
br label %47
47: ; preds = %42, %12, %15, %22, %25, %32, %35, %4
%48 = phi i8* [ %6, %4 ], [ %16, %15 ], [ %6, %12 ], [ %16, %22 ], [ %26, %25 ], [ %26, %32 ], [ %36, %35 ], [ %46, %42 ]
%49 = icmp ult i8* %48, %5
br i1 %49, label %50, label %113
50: ; preds = %47, %106
%51 = phi i8* [ %107, %106 ], [ %48, %47 ]
%52 = bitcast i8* %51 to i32*
%53 = load i32, i32* %52
%54 = xor i32 %53, 168430090
%55 = tail call i64 @has_zero(i32 %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %110
57: ; preds = %50
%58 = getelementptr inbounds i8, i8* %51, i64 4
%59 = bitcast i8* %58 to i32*
%60 = load i32, i32* %59
%61 = xor i32 %60, 168430090
%62 = tail call i64 @has_zero(i32 %61)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %110
64: ; preds = %57
%65 = getelementptr inbounds i8, i8* %51, i64 8
%66 = bitcast i8* %65 to i32*
%67 = load i32, i32* %66
%68 = xor i32 %67, 168430090
%69 = tail call i64 @has_zero(i32 %68)
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %110
71: ; preds = %64
%72 = getelementptr inbounds i8, i8* %51, i64 12
%73 = bitcast i8* %72 to i32*
%74 = load i32, i32* %73
%75 = xor i32 %74, 168430090
%76 = tail call i64 @has_zero(i32 %75)
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %110
78: ; preds = %71
%79 = getelementptr inbounds i8, i8* %51, i64 16
%80 = bitcast i8* %79 to i32*
%81 = load i32, i32* %80
%82 = xor i32 %81, 168430090
%83 = tail call i64 @has_zero(i32 %82)
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %110
85: ; preds = %78
%86 = getelementptr inbounds i8, i8* %51, i64 20
%87 = bitcast i8* %86 to i32*
%88 = load i32, i32* %87
%89 = xor i32 %88, 168430090
%90 = tail call i64 @has_zero(i32 %89)
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %110
92: ; preds = %85
%93 = getelementptr inbounds i8, i8* %51, i64 24
%94 = bitcast i8* %93 to i32*
%95 = load i32, i32* %94
%96 = xor i32 %95, 168430090
%97 = tail call i64 @has_zero(i32 %96)
%98 = icmp eq i64 %97, 0
br i1 %98, label %99, label %110
99: ; preds = %92
%100 = getelementptr inbounds i8, i8* %51, i64 28
%101 = bitcast i8* %100 to i32*
%102 = load i32, i32* %101
%103 = xor i32 %102, 168430090
%104 = tail call i64 @has_zero(i32 %103)
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %110
106: ; preds = %99
%107 = getelementptr inbounds i8, i8* %51, i64 32
%108 = load i8*, i8** @fgets2.end
%109 = icmp ult i8* %107, %108
br i1 %109, label %50, label %110
110: ; preds = %99, %92, %85, %78, %71, %64, %57, %50, %106
%111 = phi i8* [ %107, %106 ], [ %51, %50 ], [ %58, %57 ], [ %65, %64 ], [ %72, %71 ], [ %79, %78 ], [ %86, %85 ], [ %93, %92 ], [ %100, %99 ]
%112 = load i8*, i8** @fgets2.end
br label %113
113: ; preds = %110, %47
%114 = phi i8* [ %5, %47 ], [ %112, %110 ]
%115 = phi i8* [ %48, %47 ], [ %111, %110 ]
%116 = ptrtoint i8* %114 to i64
%117 = icmp ult i8* %115, %114
br i1 %117, label %118, label %132
118: ; preds = %113
%119 = ptrtoint i8* %115 to i64
%120 = sub i64 %116, %119
%121 = getelementptr i8, i8* %115, i64 %120
br label %122
122: ; preds = %118, %129
%123 = phi i8* [ %130, %129 ], [ %115, %118 ]
%124 = load i8, i8* %123
%125 = icmp eq i8 %124, 10
br i1 %125, label %126, label %129
126: ; preds = %122
%127 = load i8*, i8** @fgets2.line
store i8 0, i8* %123
%128 = getelementptr inbounds i8, i8* %123, i64 1
store i8* %128, i8** @fgets2.line
br label %171
129: ; preds = %122
%130 = getelementptr inbounds i8, i8* %123, i64 1
%131 = icmp eq i8* %130, %121
br i1 %131, label %132, label %122
132: ; preds = %129, %113
%133 = phi i8* [ %115, %113 ], [ %121, %129 ]
%134 = load i8*, i8** @fgets2.line
%135 = icmp ugt i8* %134, getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 0)
br i1 %135, label %136, label %152
136: ; preds = %132
%137 = icmp eq i8* %114, %134
br i1 %137, label %147, label %138
138: ; preds = %136
%139 = ptrtoint i8* %134 to i64
%140 = sub i64 %116, %139
%141 = trunc i64 %140 to i32
%142 = tail call i32 @memmove(i8* getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 0), i8* %134, i32 %141)
%143 = load i8*, i8** @fgets2.end
%144 = load i8*, i8** @fgets2.line
%145 = ptrtoint i8* %143 to i64
%146 = ptrtoint i8* %144 to i64
br label %147
147: ; preds = %138, %136
%148 = phi i64 [ %146, %138 ], [ %116, %136 ]
%149 = phi i64 [ %145, %138 ], [ %116, %136 ]
%150 = sub i64 %149, %148
%151 = getelementptr inbounds [262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 %150
store i8* %151, i8** @fgets2.end
store i8* getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 0), i8** @fgets2.line
br label %154
152: ; preds = %132
%153 = icmp eq i8* %114, getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 262144)
br i1 %153, label %171, label %154
154: ; preds = %152, %147
%155 = phi i8* [ %151, %147 ], [ %133, %152 ]
%156 = tail call i32 @fileno(i32* %0)
%157 = load i8*, i8** @fgets2.end
%158 = ptrtoint i8* %157 to i64
%159 = trunc i64 %158 to i32
%160 = sub i32 ptrtoint (i8* getelementptr inbounds ([262176 x i8], [262176 x i8]* @fgets2.buffer, i64 0, i64 262144) to i32), %159
%161 = tail call i32 @read(i32 %156, i8* %157, i32 %160)
%162 = icmp slt i32 %161, 1
%163 = load i8*, i8** @fgets2.end
br i1 %162, label %164, label %168
164: ; preds = %154
%165 = load i8*, i8** @fgets2.line
%166 = icmp eq i8* %163, %165
br i1 %166, label %171, label %167
167: ; preds = %164
store i8 0, i8* %163
store i8* %165, i8** @fgets2.end
br label %171
168: ; preds = %154
%169 = zext i32 %161 to i64
%170 = getelementptr inbounds i8, i8* %163, i64 %169
store i8* %170, i8** @fgets2.end
store i8 10, i8* %170
br label %4
171: ; preds = %152, %164, %167, %126
%172 = phi i8* [ %127, %126 ], [ %165, %167 ], [ null, %164 ], [ null, %152 ]
ret i8* %172
}