#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 EOF;
int fgetc(int /*<<< orphan*/ *);
char *fgets(char *, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ *strchr(char *, char);
char *next(FILE *fp, char *buf, size_t sz) {
  char *rt = NULL;
  while (1) {
    int i;
    rt = fgets(buf, sz, fp);
    if (rt == NULL)
      break;
    if (strchr(buf, '\n') == NULL) {
      while (1) {
        int ch = fgetc(fp);
        if (ch == '\n' || ch == EOF)
          break;
      }
    }
    for (i = 0; buf[i] == ' ' || buf[i] == '\t'; i++)
      ;
    if (buf[i] != '#') {
      rt = buf + i;
      break;
    }
  }
  return rt;
}


x86 assembly (clang, -O0):
<next>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1050 <fgets@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1171 <next+0x41>
jmp    124c <next+0x11c>
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
jne    11c5 <next+0x95>
jmp    118e <next+0x5e>
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xa,-0x28(%rbp)
je     11b6 <next+0x86>
mov    -0x28(%rbp),%eax
mov    0x2e3a(%rip),%rcx
cmp    (%rcx),%eax
jne    11bb <next+0x8b>
jmp    11c0 <next+0x90>
jmp    118e <next+0x5e>
jmp    11c5 <next+0x95>
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x29(%rbp)
je     11fb <next+0xcb>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    120b <next+0xdb>
jmp    121e <next+0xee>
jmp    1210 <next+0xe0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11cc <next+0x9c>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
je     1247 <next+0x117>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    124c <next+0x11c>
jmp    114c <next+0x1c>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11e6 <next+0xb6>
mov    0x2e88(%rip),%r13
xor    %r12d,%r12d
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
test   %rax,%rax
jne    11a0 <next+0x70>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
call   1040 <fgetc@plt>
cmp    $0xa,%eax
je     11a0 <next+0x70>
cmp    0x0(%r13),%eax
jne    1180 <next+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
jmp    11b4 <next+0x84>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rax
movzbl (%rbx,%rax,1),%ecx
cmp    $0x9,%cl
je     11b0 <next+0x80>
cmp    $0x20,%cl
je     11b0 <next+0x80>
cmp    $0x23,%cl
jne    11dc <next+0xac>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    1163 <next+0x33>
jmp    11e9 <next+0xb9>
mov    %eax,%eax
add    %rax,%rbx
mov    %rbx,%r12
jmp    11e9 <next+0xb9>
xor    %r12d,%r12d
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
define i8* @next(i32* %0, i8* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
store i8* null, i8** %7
br label %10
10: ; preds = %3, %71
%11 = load i8*, i8** %5
%12 = load i64, i64* %6
%13 = load i32*, i32** %4
%14 = call i8* @fgets(i8* %11, i64 %12, i32* %13)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %18
17: ; preds = %10
br label %72
18: ; preds = %10
%19 = load i8*, i8** %5
%20 = call i32* @strchr(i8* %19, i8 signext 10)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %35
22: ; preds = %18
br label %23
23: ; preds = %22, %33
%24 = load i32*, i32** %4
%25 = call i32 @fgetc(i32* %24)
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = icmp eq i32 %26, 10
br i1 %27, label %32, label %28
28: ; preds = %23
%29 = load i32, i32* %9
%30 = load i32, i32* @EOF
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %33
32: ; preds = %28, %23
br label %34
33: ; preds = %28
br label %23
34: ; preds = %32
br label %35
35: ; preds = %34, %18
store i32 0, i32* %8
br label %36
36: ; preds = %55, %35
%37 = load i8*, i8** %5
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 32
br i1 %43, label %52, label %44
44: ; preds = %36
%45 = load i8*, i8** %5
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 9
br label %52
52: ; preds = %44, %36
%53 = phi i1 [ true, %36 ], [ %51, %44 ]
br i1 %53, label %54, label %58
54: ; preds = %52
br label %55
55: ; preds = %54
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
br label %36
58: ; preds = %52
%59 = load i8*, i8** %5
%60 = load i32, i32* %8
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp ne i32 %64, 35
br i1 %65, label %66, label %71
66: ; preds = %58
%67 = load i8*, i8** %5
%68 = load i32, i32* %8
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
store i8* %70, i8** %7
br label %72
71: ; preds = %58
br label %10
72: ; preds = %66, %17
%73 = load i8*, i8** %7
ret i8* %73
}

LLVM IR (-O2):
@EOF = global i32 0
define i8* @next(i32* nocapture %0, i8* %1, i64 %2) {
%4 = tail call i8* @fgets(i8* %1, i64 %2, i32* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %28, label %9
6: ; preds = %19
%7 = tail call i8* @fgets(i8* %1, i64 %2, i32* %0)
%8 = icmp eq i8* %7, null
br i1 %8, label %28, label %9
9: ; preds = %3, %6
%10 = tail call i32* @strchr(i8* %1, i8 signext 10)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %18
12: ; preds = %9, %12
%13 = tail call i32 @fgetc(i32* %0)
%14 = icmp eq i32 %13, 10
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %13, %15
%17 = select i1 %14, i1 true, i1 %16
br i1 %17, label %18, label %12
18: ; preds = %12, %9
br label %19
19: ; preds = %18, %23
%20 = phi i64 [ %24, %23 ], [ 0, %18 ]
%21 = getelementptr inbounds i8, i8* %1, i64 %20
%22 = load i8, i8* %21
switch i8 %22, label %25 [
i8 32, label %23
i8 9, label %23
i8 35, label %6
]
23: ; preds = %19, %19
%24 = add nuw i64 %20, 1
br label %19
25: ; preds = %19
%26 = and i64 %20, 4294967295
%27 = getelementptr inbounds i8, i8* %1, i64 %26
br label %28
28: ; preds = %6, %3, %25
%29 = phi i8* [ %27, %25 ], [ null, %3 ], [ null, %6 ]
ret i8* %29
}