#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 */
char EOF;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/ *);
void goto_nextline(FILE *f) {
  char c, c2;
  while ((c = fgetc(f)) != EOF) {
    if ((c == '\n') || (c == '\r')) {
      c2 = fgetc(f);
      if (((c2 == '\r') || (c2 == '\n')) && (c2 != c)) {
      } else {
        ungetc(c2, f);
      }
      break;
    }
    c++;
  }
}


x86 assembly (clang, -O0):
<goto_nextline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%eax
mov    0x2ea6(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11c3 <goto_nextline+0xa3>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     1167 <goto_nextline+0x47>
movsbl -0x9(%rbp),%eax
cmp    $0xd,%eax
jne    11b6 <goto_nextline+0x96>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0xa(%rbp)
movsbl -0xa(%rbp),%eax
cmp    $0xd,%eax
je     118d <goto_nextline+0x6d>
movsbl -0xa(%rbp),%eax
cmp    $0xa,%eax
jne    11a2 <goto_nextline+0x82>
movsbl -0xa(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
je     11a2 <goto_nextline+0x82>
jmp    11b1 <goto_nextline+0x91>
mov    -0xa(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1040 <ungetc@plt>
jmp    11c3 <goto_nextline+0xa3>
mov    -0x9(%rbp),%al
add    $0x1,%al
mov    %al,-0x9(%rbp)
jmp    112c <goto_nextline+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<goto_nextline>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    0x2eb9(%rip),%r15
nop
mov    %r14,%rdi
call   1030 <fgetc@plt>
cmp    (%r15),%al
je     116c <goto_nextline+0x4c>
mov    %eax,%ebx
cmp    $0xd,%al
je     1148 <goto_nextline+0x28>
cmp    $0xa,%bl
jne    1130 <goto_nextline+0x10>
mov    %r14,%rdi
call   1030 <fgetc@plt>
cmp    $0xd,%al
je     1158 <goto_nextline+0x38>
cmp    $0xa,%al
jne    115c <goto_nextline+0x3c>
cmp    %bl,%al
jne    116c <goto_nextline+0x4c>
movsbl %al,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <ungetc@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i8 0
define void @goto_nextline(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
%4 = alloca i8
store i32* %0, i32** %2
br label %5
5: ; preds = %42, %1
%6 = load i32*, i32** %2
%7 = call signext i8 @fgetc(i32* %6)
store i8 %7, i8* %3
%8 = sext i8 %7 to i32
%9 = load i8, i8* @EOF
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %45
12: ; preds = %5
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 10
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 13
br i1 %19, label %20, label %42
20: ; preds = %16, %12
%21 = load i32*, i32** %2
%22 = call signext i8 @fgetc(i32* %21)
store i8 %22, i8* %4
%23 = load i8, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 13
br i1 %25, label %30, label %26
26: ; preds = %20
%27 = load i8, i8* %4
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 10
br i1 %29, label %30, label %37
30: ; preds = %26, %20
%31 = load i8, i8* %4
%32 = sext i8 %31 to i32
%33 = load i8, i8* %3
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %32, %34
br i1 %35, label %36, label %37
36: ; preds = %30
br label %41
37: ; preds = %30, %26
%38 = load i8, i8* %4
%39 = load i32*, i32** %2
%40 = call i32 @ungetc(i8 signext %38, i32* %39)
br label %41
41: ; preds = %37, %36
br label %45
42: ; preds = %16
%43 = load i8, i8* %3
%44 = add i8 %43, 1
store i8 %44, i8* %3
br label %5
45: ; preds = %41, %5
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
define void @goto_nextline(i32* nocapture %0) {
br label %2
2: ; preds = %6, %1
%3 = tail call signext i8 @fgetc(i32* %0)
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %13, label %6
6: ; preds = %2
switch i8 %3, label %2 [
i8 13, label %7
i8 10, label %7
]
7: ; preds = %6, %6
%8 = tail call signext i8 @fgetc(i32* %0)
switch i8 %8, label %11 [
i8 13, label %9
i8 10, label %9
]
9: ; preds = %7, %7
%10 = icmp eq i8 %8, %3
br i1 %10, label %11, label %13
11: ; preds = %7, %9
%12 = tail call i32 @ungetc(i8 signext %8, i32* %0)
br label %13
13: ; preds = %2, %11, %9
ret void
}