#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 */
scalar_t__ feof(int /*<<< orphan*/ *);
int fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ goto_nextline(int /*<<< orphan*/ *);
int get_next_token(FILE *f, char *buf) {
  int i;
  int iscomment;
  do {
    iscomment = 0;
    if (fscanf(f, "%s", buf) != 1)
      return 1;
    for (i = 0; buf[i]; i++)
      if (buf[i] == '#') {
        iscomment = 1;
        break;
      }
    if (iscomment) {
      buf[i] = 0;
      goto_nextline(f);
    }
    if (feof(f))
      return 2;
  } while (buf[0] == 0);
  return 0;
}


x86 assembly (clang, -O0):
<get_next_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xeaa(%rip),%rsi
call   1030 <fscanf@plt>
cmp    $0x1,%eax
je     1170 <get_next_token+0x40>
movl   $0x1,-0x4(%rbp)
jmp    1217 <get_next_token+0xe7>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11bd <get_next_token+0x8d>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
jne    11aa <get_next_token+0x7a>
movl   $0x1,-0x20(%rbp)
jmp    11bd <get_next_token+0x8d>
jmp    11af <get_next_token+0x7f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1177 <get_next_token+0x47>
cmpl   $0x0,-0x20(%rbp)
je     11dc <get_next_token+0xac>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1050 <goto_nextline@plt>
mov    -0x10(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%rax
je     11fb <get_next_token+0xcb>
movl   $0x2,-0x4(%rbp)
jmp    1217 <get_next_token+0xe7>
jmp    1200 <get_next_token+0xd0>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1140 <get_next_token+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_next_token>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xebe(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <fscanf@plt>
cmp    $0x1,%eax
jne    11b4 <get_next_token+0x84>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx,%rax,1),%ecx
test   %cl,%cl
je     119e <get_next_token+0x6e>
cmp    $0x23,%cl
je     1190 <get_next_token+0x60>
add    $0x1,%rax
jmp    1170 <get_next_token+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%eax
movb   $0x0,(%rbx,%rax,1)
mov    %r14,%rdi
call   1050 <goto_nextline@plt>
mov    %r14,%rdi
call   1040 <feof@plt>
test   %rax,%rax
jne    11bb <get_next_token+0x8b>
cmpb   $0x0,(%rbx)
je     1150 <get_next_token+0x20>
xor    %eax,%eax
jmp    11c0 <get_next_token+0x90>
mov    $0x1,%eax
jmp    11c0 <get_next_token+0x90>
mov    $0x2,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @get_next_token(i32* %0, i8* %1) {
br label %3
3: ; preds = %19, %2
%4 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %22
6: ; preds = %3, %10
%7 = phi i64 [ %11, %10 ], [ 0, %3 ]
%8 = getelementptr inbounds i8, i8* %1, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %10 [
i8 0, label %16
i8 35, label %12
]
10: ; preds = %6
%11 = add nuw i64 %7, 1
br label %6
12: ; preds = %6
%13 = and i64 %7, 4294967295
%14 = getelementptr inbounds i8, i8* %1, i64 %13
store i8 0, i8* %14
%15 = tail call i32 @goto_nextline(i32* %0)
br label %16
16: ; preds = %6, %12
%17 = tail call i64 @feof(i32* %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i8, i8* %1
%21 = icmp eq i8 %20, 0
br i1 %21, label %3, label %22
22: ; preds = %19, %16, %3
%23 = phi i32 [ 1, %3 ], [ 2, %16 ], [ 0, %19 ]
ret i32 %23
}