#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;
scalar_t__ check_end(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, long, char);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int nextline(FILE *channel) {
  char c;
  int ic;
  ic = (int)' ';
  c = (char)ic;
  while ((ic != EOF) && (ic) && (c != '}') && (c != '\r') && (c != '\n')) {
    ic = fgetc(channel);
    c = (char)ic;
  }
  if ((ic == EOF) || (!ic))
    return (-1);
  if (c == '\r') {
    ic = fgetc(channel);
    c = (char)ic;
  }
  if (c == '}') {
    ungetc((int)c, channel);
    if (check_end(channel)) {
      long tmp;
      tmp = ftell(channel);
      fprintf(stderr,
              "\nERROR: position %ld, end marker ´%c´ not followed by eol\n",
              tmp, c);
      return (-1);
    } else
      return (1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<nextline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x20,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %al,-0x11(%rbp)
mov    -0x18(%rbp),%ecx
xor    %eax,%eax
mov    0x2e73(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x21(%rbp)
je     11c0 <nextline+0x70>
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x21(%rbp)
je     11c0 <nextline+0x70>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0x7d,%ecx
mov    %al,-0x21(%rbp)
je     11c0 <nextline+0x70>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0xd,%ecx
mov    %al,-0x21(%rbp)
je     11c0 <nextline+0x70>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11d0 <nextline+0x80>
jmp    11e7 <nextline+0x97>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %al,-0x11(%rbp)
jmp    1169 <nextline+0x19>
mov    -0x18(%rbp),%eax
mov    0x2df7(%rip),%rcx
cmp    (%rcx),%eax
je     1203 <nextline+0xb3>
cmpl   $0x0,-0x18(%rbp)
jne    120f <nextline+0xbf>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a4 <nextline+0x154>
movsbl -0x11(%rbp),%eax
cmp    $0xd,%eax
jne    122e <nextline+0xde>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x7d,%eax
jne    129d <nextline+0x14d>
movsbl -0x11(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <ungetc@plt>
mov    -0x10(%rbp),%rdi
call   1030 <check_end@plt>
cmp    $0x0,%rax
je     1291 <nextline+0x141>
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd84(%rip),%rsi
movsbl -0x11(%rbp),%ecx
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a4 <nextline+0x154>
movl   $0x1,-0x4(%rbp)
jmp    12a4 <nextline+0x154>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextline>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e8d(%rip),%rbp
mov    $0xffffffff,%r14d
cmpl   $0x20,0x0(%rbp)
je     11f9 <nextline+0xa9>
mov    %rdi,%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    0x0(%rbp),%eax
setne  %dl
test   %eax,%eax
setne  %cl
and    %dl,%cl
cmp    $0xa,%al
je     1195 <nextline+0x45>
cmp    $0xd,%al
je     1195 <nextline+0x45>
cmp    $0x7d,%al
je     1195 <nextline+0x45>
test   %cl,%cl
jne    1170 <nextline+0x20>
test   %cl,%cl
je     11f9 <nextline+0xa9>
cmp    $0xd,%al
jne    11a5 <nextline+0x55>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
xor    %r14d,%r14d
cmp    $0x7d,%al
jne    11f9 <nextline+0xa9>
mov    $0x7d,%edi
mov    %rbx,%rsi
call   1070 <ungetc@plt>
mov    %rbx,%rdi
call   1030 <check_end@plt>
test   %rax,%rax
je     11f3 <nextline+0xa3>
mov    %rbx,%rdi
call   1060 <ftell@plt>
mov    0x2e03(%rip),%rcx
mov    (%rcx),%edi
lea    0xe22(%rip),%rsi
mov    %rax,%rdx
mov    $0x7d,%ecx
call   1050 <fprintf@plt>
mov    $0xffffffff,%r14d
jmp    11f9 <nextline+0xa9>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@stderr = global i32 0
@.str = [61 x i8] c"\0AERROR: position %ld, end marker \C2\B4%c\C2\B4 not followed by eol\0A\00"
define i32 @nextline(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i64
store i32* %0, i32** %3
store i32 32, i32* %5
%7 = load i32, i32* %5
%8 = trunc i32 %7 to i8
store i8 %8, i8* %4
br label %9
9: ; preds = %30, %1
%10 = load i32, i32* %5
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %28
13: ; preds = %9
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %13
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 125
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 13
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i8, i8* %4
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 10
br label %28
28: ; preds = %24, %20, %16, %13, %9
%29 = phi i1 [ false, %20 ], [ false, %16 ], [ false, %13 ], [ false, %9 ], [ %27, %24 ]
br i1 %29, label %30, label %35
30: ; preds = %28
%31 = load i32*, i32** %3
%32 = call i32 @fgetc(i32* %31)
store i32 %32, i32* %5
%33 = load i32, i32* %5
%34 = trunc i32 %33 to i8
store i8 %34, i8* %4
br label %9
35: ; preds = %28
%36 = load i32, i32* %5
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %42, label %39
39: ; preds = %35
%40 = load i32, i32* %5
%41 = icmp ne i32 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %39, %35
store i32 -1, i32* %2
br label %73
43: ; preds = %39
%44 = load i8, i8* %4
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 13
br i1 %46, label %47, label %52
47: ; preds = %43
%48 = load i32*, i32** %3
%49 = call i32 @fgetc(i32* %48)
store i32 %49, i32* %5
%50 = load i32, i32* %5
%51 = trunc i32 %50 to i8
store i8 %51, i8* %4
br label %52
52: ; preds = %47, %43
%53 = load i8, i8* %4
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 125
br i1 %55, label %56, label %72
56: ; preds = %52
%57 = load i8, i8* %4
%58 = sext i8 %57 to i32
%59 = load i32*, i32** %3
%60 = call i32 @ungetc(i32 %58, i32* %59)
%61 = load i32*, i32** %3
%62 = call i64 @check_end(i32* %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %71
64: ; preds = %56
%65 = load i32*, i32** %3
%66 = call i64 @ftell(i32* %65)
store i64 %66, i64* %6
%67 = load i32, i32* @stderr
%68 = load i64, i64* %6
%69 = load i8, i8* %4
%70 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i64 %68, i8 signext %69)
store i32 -1, i32* %2
br label %73
71: ; preds = %56
store i32 1, i32* %2
br label %73
72: ; preds = %52
store i32 0, i32* %2
br label %73
73: ; preds = %72, %71, %64, %42
%74 = load i32, i32* %2
ret i32 %74
}

LLVM IR (-O2):
@EOF = global i32 0
@stderr = global i32 0
@.str = [61 x i8] c"\0AERROR: position %ld, end marker \C2\B4%c\C2\B4 not followed by eol\0A\00"
define i32 @nextline(i32* %0) {
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %2, 32
br i1 %3, label %35, label %4
4: ; preds = %1, %4
%5 = tail call i32 @fgetc(i32* %0)
%6 = trunc i32 %5 to i8
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %5, %7
%9 = icmp ne i32 %5, 0
%10 = and i1 %9, %8
%11 = icmp ne i8 %6, 125
%12 = and i1 %11, %10
%13 = icmp ne i8 %6, 13
%14 = and i1 %13, %12
%15 = icmp ne i8 %6, 10
%16 = and i1 %15, %14
br i1 %16, label %4, label %17
17: ; preds = %4
%18 = trunc i32 %5 to i8
br i1 %10, label %19, label %35
19: ; preds = %17
%20 = icmp eq i8 %18, 13
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = tail call i32 @fgetc(i32* %0)
%23 = trunc i32 %22 to i8
br label %24
24: ; preds = %21, %19
%25 = phi i8 [ %23, %21 ], [ %18, %19 ]
%26 = icmp eq i8 %25, 125
br i1 %26, label %27, label %35
27: ; preds = %24
%28 = tail call i32 @ungetc(i32 125, i32* %0)
%29 = tail call i64 @check_end(i32* %0)
%30 = icmp eq i64 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = tail call i64 @ftell(i32* %0)
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i64 %32, i8 signext 125)
br label %35
35: ; preds = %1, %24, %27, %17, %31
%36 = phi i32 [ -1, %31 ], [ -1, %17 ], [ 1, %27 ], [ 0, %24 ], [ -1, %1 ]
ret i32 %36
}