#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 */
scalar_t__ readk(int);
int readnewline(void) {
  if (readk(0x000d)) {
    if (readk(0x000a)) {
      return 0xff;
    } else {
      return 0x000d;
    }
  } else if (readk(0x000a)) {
    return 0x000a;
  } else if (readk(0x0085)) {
    return 0x0085;
  } else if (readk(0x2028)) {
    return 0x2028;
  } else if (readk(0x2029)) {
    return 0x2029;
  }
  return 0;
}


x86 assembly (clang, -O0):
<readnewline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xd,%edi
call   1030 <readk@plt>
cmp    $0x0,%rax
je     1158 <readnewline+0x48>
mov    $0xa,%edi
call   1030 <readk@plt>
cmp    $0x0,%rax
je     114c <readnewline+0x3c>
movl   $0xff,-0x4(%rbp)
jmp    11f3 <readnewline+0xe3>
movl   $0xd,-0x4(%rbp)
jmp    11f3 <readnewline+0xe3>
mov    $0xa,%edi
call   1030 <readk@plt>
cmp    $0x0,%rax
je     1178 <readnewline+0x68>
movl   $0xa,-0x4(%rbp)
jmp    11f3 <readnewline+0xe3>
mov    $0x85,%edi
call   1030 <readk@plt>
cmp    $0x0,%rax
je     1198 <readnewline+0x88>
movl   $0x85,-0x4(%rbp)
jmp    11f3 <readnewline+0xe3>
mov    $0x2028,%edi
call   1030 <readk@plt>
cmp    $0x0,%rax
je     11b8 <readnewline+0xa8>
movl   $0x2028,-0x4(%rbp)
jmp    11f3 <readnewline+0xe3>
mov    $0x2029,%edi
call   1030 <readk@plt>
cmp    $0x0,%rax
je     11d8 <readnewline+0xc8>
movl   $0x2029,-0x4(%rbp)
jmp    11f3 <readnewline+0xe3>
jmp    11dd <readnewline+0xcd>
jmp    11e2 <readnewline+0xd2>
jmp    11e7 <readnewline+0xd7>
jmp    11ec <readnewline+0xdc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readnewline>:
push   %rbp
push   %r14
push   %rbx
mov    $0xd,%r14d
mov    $0xd,%edi
call   1030 <readk@plt>
mov    %rax,%rbx
mov    $0xa,%ebp
mov    $0xa,%edi
call   1030 <readk@plt>
test   %rbx,%rbx
je     1149 <readnewline+0x39>
test   %rax,%rax
mov    $0xff,%ebp
cmove  %r14d,%ebp
jmp    118d <readnewline+0x7d>
test   %rax,%rax
jne    118d <readnewline+0x7d>
mov    $0x85,%ebp
mov    $0x85,%edi
call   1030 <readk@plt>
test   %rax,%rax
jne    118d <readnewline+0x7d>
mov    $0x2028,%ebp
mov    $0x2028,%edi
call   1030 <readk@plt>
test   %rax,%rax
jne    118d <readnewline+0x7d>
mov    $0x2029,%ebx
mov    $0x2029,%edi
call   1030 <readk@plt>
xor    %ebp,%ebp
test   %rax,%rax
cmovne %ebx,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @readnewline() {
%1 = alloca i32
%2 = call i64 @readk(i32 13)
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %0
%5 = call i64 @readk(i32 10)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %4
store i32 255, i32* %1
br label %30
8: ; preds = %4
store i32 13, i32* %1
br label %30
9: ; preds = %0
%10 = call i64 @readk(i32 10)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 10, i32* %1
br label %30
13: ; preds = %9
%14 = call i64 @readk(i32 133)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
store i32 133, i32* %1
br label %30
17: ; preds = %13
%18 = call i64 @readk(i32 8232)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 8232, i32* %1
br label %30
21: ; preds = %17
%22 = call i64 @readk(i32 8233)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 8233, i32* %1
br label %30
25: ; preds = %21
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28
store i32 0, i32* %1
br label %30
30: ; preds = %29, %24, %20, %16, %12, %8, %7
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
define i32 @readnewline() {
%1 = tail call i64 @readk(i32 13)
%2 = icmp eq i64 %1, 0
%3 = tail call i64 @readk(i32 10)
%4 = icmp eq i64 %3, 0
br i1 %2, label %7, label %5
5: ; preds = %0
%6 = select i1 %4, i32 13, i32 255
br label %18
7: ; preds = %0
br i1 %4, label %8, label %18
8: ; preds = %7
%9 = tail call i64 @readk(i32 133)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = tail call i64 @readk(i32 8232)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = tail call i64 @readk(i32 8233)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i32 0, i32 8233
br label %18
18: ; preds = %14, %11, %8, %7, %5
%19 = phi i32 [ %6, %5 ], [ 10, %7 ], [ 133, %8 ], [ 8232, %11 ], [ %17, %14 ]
ret i32 %19
}