#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int fscanf(int /*<<< orphan*/ *, char *, char *);
char *xfrd_read_token(FILE *in) {
  static char buf[4000];
  buf[sizeof(buf) - 1] = 0;
  while (1) {
    if (fscanf(in, " %3990s", buf) != 1)
      return 0;
    if (buf[0] != '#')
      return buf;
    if (!fgets(buf, sizeof(buf), in))
      return 0;
  }
}


x86 assembly (clang, -O0):
<xfrd_read_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
movb   $0x0,0x3eac(%rip)
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
lea    0x2efb(%rip),%rdx
call   1030 <fscanf@plt>
cmp    $0x1,%eax
je     1160 <xfrd_read_token+0x40>
movq   $0x0,-0x8(%rbp)
jmp    11b0 <xfrd_read_token+0x90>
movsbl 0x2ed9(%rip),%eax
cmp    $0x23,%eax
je     1180 <xfrd_read_token+0x60>
lea    0x2ec9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b0 <xfrd_read_token+0x90>
mov    -0x10(%rbp),%rdx
lea    0x2eb5(%rip),%rdi
mov    $0xfa0,%esi
call   1040 <fgets@plt>
cmp    $0x0,%eax
jne    11ab <xfrd_read_token+0x8b>
movq   $0x0,-0x8(%rbp)
jmp    11b0 <xfrd_read_token+0x90>
jmp    1133 <xfrd_read_token+0x13>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xfrd_read_token>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
movb   $0x0,0x3eb0(%rip)
lea    0xeca(%rip),%r15
lea    0x2f03(%rip),%r14
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <fscanf@plt>
cmp    $0x1,%eax
jne    1170 <xfrd_read_token+0x50>
cmpb   $0x23,0x2ee6(%rip)
jne    1173 <xfrd_read_token+0x53>
mov    %r14,%rdi
mov    $0xfa0,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %eax,%eax
jne    1140 <xfrd_read_token+0x20>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@xfrd_read_token.buf = internal global [4000 x i8] zeroinitializer
@.str = [8 x i8] c" %3990s\00"
define i8* @xfrd_read_token(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i32* %0, i32** %3
store i8 0, i8* getelementptr inbounds ([4000 x i8], [4000 x i8]* @xfrd_read_token.buf, i64 0, i64 3999)
br label %4
4: ; preds = %1, %19
%5 = load i32*, i32** %3
%6 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4000 x i8], [4000 x i8]* @xfrd_read_token.buf, i64 0, i64 0))
%7 = icmp ne i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %4
store i8* null, i8** %2
br label %20
9: ; preds = %4
%10 = load i8, i8* getelementptr inbounds ([4000 x i8], [4000 x i8]* @xfrd_read_token.buf, i64 0, i64 0)
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 35
br i1 %12, label %13, label %14
13: ; preds = %9
store i8* getelementptr inbounds ([4000 x i8], [4000 x i8]* @xfrd_read_token.buf, i64 0, i64 0), i8** %2
br label %20
14: ; preds = %9
%15 = load i32*, i32** %3
%16 = call i32 @fgets(i8* getelementptr inbounds ([4000 x i8], [4000 x i8]* @xfrd_read_token.buf, i64 0, i64 0), i32 4000, i32* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %14
store i8* null, i8** %2
br label %20
19: ; preds = %14
br label %4
20: ; preds = %18, %13, %8
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@xfrd_read_token.buf = internal global [4000 x i8] zeroinitializer
@.str = [8 x i8] c" %3990s\00"
define i8* @xfrd_read_token(i32* nocapture %0) {
store i8 0, i8* getelementptr inbounds ([4000 x i8], [4000 x i8]* @xfrd_read_token.buf, i64 0, i64 3999)
br label %2
2: ; preds = %8, %1
%3 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4000 x i8], [4000 x i8]* @xfrd_read_token.buf, i64 0, i64 0))
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = load i8, i8* getelementptr inbounds ([4000 x i8], [4000 x i8]* @xfrd_read_token.buf, i64 0, i64 0)
%7 = icmp eq i8 %6, 35
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = tail call i32 @fgets(i8* getelementptr inbounds ([4000 x i8], [4000 x i8]* @xfrd_read_token.buf, i64 0, i64 0), i32 4000, i32* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %2
11: ; preds = %8, %5, %2
%12 = phi i8* [ null, %2 ], [ getelementptr inbounds ([4000 x i8], [4000 x i8]* @xfrd_read_token.buf, i64 0, i64 0), %5 ], [ null, %8 ]
ret i8* %12
}