#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 fgetc(int /*<<< orphan*/ *);
scalar_t__ isspace(int);
int nextToken(FILE *fp, char *buf, int buflen) {
  int n = 0;
  --buflen;
  while (n < buflen) {
    int c = fgetc(fp);
    if (isspace(c)) {
      if (n > 0)
        break;
      else
        continue;
    } else if ('#' == c) {
      do {
        c = fgetc(fp);
      } while (c != '\n' && c != '\r');
      if (n > 0)
        break;
      else
        continue;
    }
    buf[n++] = (char)c;
  }
  buf[n] = 0;
  return n;
}


x86 assembly (clang, -O0):
<nextToken>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11fc <nextToken+0xdc>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1181 <nextToken+0x61>
cmpl   $0x0,-0x18(%rbp)
jle    117c <nextToken+0x5c>
jmp    11fc <nextToken+0xdc>
jmp    1143 <nextToken+0x23>
mov    $0x23,%eax
cmp    -0x1c(%rbp),%eax
jne    11d8 <nextToken+0xb8>
jmp    1194 <nextToken+0x74>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
je     11b9 <nextToken+0x99>
cmpl   $0xd,-0x1c(%rbp)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1194 <nextToken+0x74>
cmpl   $0x0,-0x18(%rbp)
jle    11d3 <nextToken+0xb3>
jmp    11fc <nextToken+0xdc>
jmp    1143 <nextToken+0x23>
jmp    11dd <nextToken+0xbd>
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1143 <nextToken+0x23>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextToken>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
xor    %r12d,%r12d
cmp    $0x2,%edx
jl     11a4 <nextToken+0x84>
mov    %edx,%r15d
mov    %rdi,%rbx
add    $0xffffffff,%r15d
xor    %r12d,%r12d
jmp    115a <nextToken+0x3a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %r12d,%r12d
jg     11a4 <nextToken+0x84>
cmp    %r15d,%r12d
jge    11a4 <nextToken+0x84>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1150 <nextToken+0x30>
cmp    $0x23,%ebp
jne    1194 <nextToken+0x74>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0xd,%eax
je     1150 <nextToken+0x30>
cmp    $0xa,%eax
jne    1180 <nextToken+0x60>
jmp    1150 <nextToken+0x30>
movslq %r12d,%rax
add    $0x1,%r12d
mov    %bpl,(%r14,%rax,1)
cmp    %r15d,%r12d
jl     115a <nextToken+0x3a>
movslq %r12d,%rax
movb   $0x0,(%r14,%rax,1)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @nextToken(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%9 = load i32, i32* %6
%10 = add nsw i32 %9, -1
store i32 %10, i32* %6
br label %11
11: ; preds = %47, %45, %25, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %55
15: ; preds = %11
%16 = load i32*, i32** %4
%17 = call i32 @fgetc(i32* %16)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = call i64 @isspace(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = load i32, i32* %7
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
br label %55
25: ; preds = %21
br label %11
26: ; preds = %15
%27 = load i32, i32* %8
%28 = icmp eq i32 35, %27
br i1 %28, label %29, label %46
29: ; preds = %26
br label %30
30: ; preds = %39, %29
%31 = load i32*, i32** %4
%32 = call i32 @fgetc(i32* %31)
store i32 %32, i32* %8
br label %33
33: ; preds = %30
%34 = load i32, i32* %8
%35 = icmp ne i32 %34, 10
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %8
%38 = icmp ne i32 %37, 13
br label %39
39: ; preds = %36, %33
%40 = phi i1 [ false, %33 ], [ %38, %36 ]
br i1 %40, label %30, label %41
41: ; preds = %39
%42 = load i32, i32* %7
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %41
br label %55
45: ; preds = %41
br label %11
46: ; preds = %26
br label %47
47: ; preds = %46
%48 = load i32, i32* %8
%49 = trunc i32 %48 to i8
%50 = load i8*, i8** %5
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
%53 = sext i32 %51 to i64
%54 = getelementptr inbounds i8, i8* %50, i64 %53
store i8 %49, i8* %54
br label %11
55: ; preds = %44, %24, %11
%56 = load i8*, i8** %5
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 0, i8* %59
%60 = load i32, i32* %7
ret i32 %60
}

LLVM IR (-O2):
define i32 @nextToken(i32* nocapture %0, i8* nocapture writeonly %1, i32 %2) {
%4 = add nsw i32 %2, -1
%5 = icmp sgt i32 %2, 1
br i1 %5, label %6, label %27
6: ; preds = %3, %24
%7 = phi i32 [ %25, %24 ], [ 0, %3 ]
%8 = tail call i32 @fgetc(i32* %0)
%9 = tail call i64 @isspace(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = icmp sgt i32 %7, 0
br i1 %12, label %27, label %24
13: ; preds = %6
%14 = icmp eq i32 %8, 35
br i1 %14, label %15, label %19
15: ; preds = %13, %15
%16 = tail call i32 @fgetc(i32* %0)
switch i32 %16, label %15 [
i32 13, label %17
i32 10, label %17
]
17: ; preds = %15, %15
%18 = icmp sgt i32 %7, 0
br i1 %18, label %27, label %24
19: ; preds = %13
%20 = trunc i32 %8 to i8
%21 = add nsw i32 %7, 1
%22 = sext i32 %7 to i64
%23 = getelementptr inbounds i8, i8* %1, i64 %22
store i8 %20, i8* %23
br label %24
24: ; preds = %17, %11, %19
%25 = phi i32 [ %21, %19 ], [ %7, %11 ], [ %7, %17 ]
%26 = icmp slt i32 %25, %4
br i1 %26, label %6, label %27
27: ; preds = %24, %11, %17, %3
%28 = phi i32 [ 0, %3 ], [ %25, %24 ], [ %7, %11 ], [ %7, %17 ]
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %1, i64 %29
store i8 0, i8* %30
ret i32 %28
}