#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 BUFSIZ;
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
void read_til_crnl(FILE *fp) {
  char buf[BUFSIZ];
  while (fgets(buf, BUFSIZ, fp) != NULL && strcmp(buf, "\r\n") != 0)
    ;
}


x86 assembly (clang, -O0):
<read_til_crnl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rdx
call   1030 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
je     119a <read_til_crnl+0x7a>
mov    -0x20(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11aa <read_til_crnl+0x8a>
jmp    11af <read_til_crnl+0x8f>
jmp    1158 <read_til_crnl+0x38>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_til_crnl>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    0x2eab(%rip),%r12
mov    (%r12),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r14,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     1194 <read_til_crnl+0x74>
lea    0xe9c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1194 <read_til_crnl+0x74>
mov    (%r12),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
jne    1170 <read_til_crnl+0x50>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [3 x i8] c"\0D\0A\00"
define void @read_til_crnl(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i64
store i32* %0, i32** %2
%5 = load i32, i32* @BUFSIZ
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %3
%8 = alloca i8, i64 %6
store i64 %6, i64* %4
br label %9
9: ; preds = %19, %1
%10 = load i32, i32* @BUFSIZ
%11 = load i32*, i32** %2
%12 = call i32* @fgets(i8* %8, i32 %10, i32* %11)
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br label %17
17: ; preds = %14, %9
%18 = phi i1 [ false, %9 ], [ %16, %14 ]
br i1 %18, label %19, label %20
19: ; preds = %17
br label %9
20: ; preds = %17
%21 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [3 x i8] c"\0D\0A\00"
define void @read_til_crnl(i32* nocapture %0) {
%2 = load i32, i32* @BUFSIZ
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32* @fgets(i8* %4, i32 %2, i32* %0)
%6 = icmp eq i32* %5, null
br i1 %6, label %14, label %7
7: ; preds = %1, %10
%8 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = load i32, i32* @BUFSIZ
%12 = call i32* @fgets(i8* %4, i32 %11, i32* %0)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %7
14: ; preds = %7, %10, %1
ret void
}