#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 */
char EOF;
char getchar();
void pgetc(char *c) {
  char buf_ch;
  *c = getchar();
  if ((*c == '\n') || (*c == '\r') || (*c == EOF))
    return;
  while ((buf_ch = getchar()) != '\n' && buf_ch != EOF)
    ;
  return;
}


x86 assembly (clang, -O0):
<pgetc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1164 <pgetc+0x54>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
je     1164 <pgetc+0x54>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    0x2e8f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1169 <pgetc+0x59>
jmp    11b9 <pgetc+0xa9>
jmp    116e <pgetc+0x5e>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xa(%rbp)
je     119f <pgetc+0x8f>
movsbl -0x9(%rbp),%eax
mov    0x2e54(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    11af <pgetc+0x9f>
jmp    11b4 <pgetc+0xa4>
jmp    116e <pgetc+0x5e>
jmp    11b9 <pgetc+0xa9>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pgetc>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %al,(%rbx)
cmp    $0xa,%al
je     113f <pgetc+0x2f>
cmp    $0xd,%al
je     113f <pgetc+0x2f>
mov    0x2ebc(%rip),%rbx
nopl   0x0(%rax)
cmp    (%rbx),%al
je     113f <pgetc+0x2f>
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
jne    1130 <pgetc+0x20>
pop    %rbx
ret

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

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