#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 *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ strchr(char *, char);
scalar_t__ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *pfReadNext(FILE *in, char *inbuf, int maxchars) {
  int done = 0;
  char *retVal;
  char *eol;
  while (!done) {
    retVal = fgets(inbuf, maxchars, in);
    if (!retVal) {
      done = 1;
    }
    if ((eol = (char *)strchr(inbuf, '\n')) != NULL) {
      *eol = '\0';
    }
    if (strlen(inbuf) > 0 && strncmp(inbuf, "#", 1)) {
      done = 1;
    }
  }
  return retVal;
}


x86 assembly (clang, -O0):
<pfReadNext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1170 <pfReadNext+0x30>
jmp    11f7 <pfReadNext+0xb7>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rdx
call   1060 <fgets@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1196 <pfReadNext+0x56>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11b9 <pfReadNext+0x79>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jle    11f2 <pfReadNext+0xb2>
mov    -0x10(%rbp),%rdi
lea    0xe29(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11f2 <pfReadNext+0xb2>
movl   $0x1,-0x18(%rbp)
jmp    115a <pfReadNext+0x1a>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pfReadNext>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r12
lea    0xea8(%rip),%r15
jmp    1165 <pfReadNext+0x25>
nopw   0x0(%rax,%rax,1)
test   %rbp,%rbp
je     11b2 <pfReadNext+0x72>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     118b <pfReadNext+0x4b>
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
jle    1160 <pfReadNext+0x20>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rbp,%rbp
je     11b2 <pfReadNext+0x72>
test   %rax,%rax
je     1165 <pfReadNext+0x25>
mov    %rbp,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"#\00"
define i8* @pfReadNext(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %10
10: ; preds = %38, %3
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %39
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = load i32, i32* %6
%17 = load i32*, i32** %4
%18 = call i8* @fgets(i8* %15, i32 %16, i32* %17)
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = icmp ne i8* %19, null
br i1 %20, label %22, label %21
21: ; preds = %14
store i32 1, i32* %7
br label %22
22: ; preds = %21, %14
%23 = load i8*, i8** %5
%24 = call i64 @strchr(i8* %23, i8 signext 10)
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %9
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = load i8*, i8** %9
store i8 0, i8* %28
br label %29
29: ; preds = %27, %22
%30 = load i8*, i8** %5
%31 = call i64 @strlen(i8* %30)
%32 = icmp sgt i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i8*, i8** %5
%35 = call i64 @strncmp(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 1, i32* %7
br label %38
38: ; preds = %37, %33, %29
br label %10
39: ; preds = %10
%40 = load i8*, i8** %8
ret i8* %40
}

LLVM IR (-O2):
@.str = [2 x i8] c"#\00"
define i8* @pfReadNext(i32* nocapture %0, i8* %1, i32 %2) {
br label %4
4: ; preds = %19, %3
%5 = tail call i8* @fgets(i8* %1, i32 %2, i32* %0)
%6 = icmp eq i8* %5, null
%7 = tail call i64 @strchr(i8* %1, i8 signext 10)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = inttoptr i64 %7 to i8*
store i8 0, i8* %10
br label %11
11: ; preds = %9, %4
%12 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%16 = icmp ne i64 %15, 0
%17 = or i1 %6, %16
br i1 %17, label %20, label %19
18: ; preds = %11
br i1 %6, label %20, label %19
19: ; preds = %18, %14
br label %4
20: ; preds = %14, %18
ret i8* %5
}