#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 *);
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,-0x10(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1030 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
je     119a <read_til_crnl+0x7a>
mov    -0x28(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11aa <read_til_crnl+0x8a>
jmp    11af <read_til_crnl+0x8f>
jmp    1158 <read_til_crnl+0x38>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
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 i32 @read_til_crnl(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
store i32* %0, i32** %3
%6 = load i32, i32* @BUFSIZ
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %4
%9 = alloca i8, i64 %7
store i64 %7, i64* %5
br label %10
10: ; preds = %20, %1
%11 = load i32, i32* @BUFSIZ
%12 = load i32*, i32** %3
%13 = call i32* @fgets(i8* %9, i32 %11, i32* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br label %18
18: ; preds = %15, %10
%19 = phi i1 [ false, %10 ], [ %17, %15 ]
br i1 %19, label %20, label %21
20: ; preds = %18
br label %10
21: ; preds = %18
%22 = load i8*, i8** %4
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [3 x i8] c"\0D\0A\00"
define i32 @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 i32 undef
}