#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 EOF;
char fgetc(int /*<<< orphan*/ *);
scalar_t__ isspace(char);
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/ *);
int eat_comments(FILE *in, char delim) {
  char now;
  int ate_something = 0;
  do {
    do {
      now = fgetc(in);
    } while (isspace(now));
    if (now == delim) {
      now = fgetc(in);
      while (now != delim || now == EOF) {
        now = fgetc(in);
      }
      ate_something = 1;
    }
    if (ate_something == 0) {
      ungetc(now, in);
    }
  } while (now == delim);
  if (ate_something == 1)
    ungetc(now, in);
  return (ate_something);
}


x86 assembly (clang, -O0):
<eat_comments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    114e <eat_comments+0x1e>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0xa(%rbp)
movsbl -0xa(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
jne    114e <eat_comments+0x1e>
movsbl -0xa(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    11dc <eat_comments+0xac>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0xa(%rbp)
movsbl -0xa(%rbp),%ecx
movsbl -0x9(%rbp),%edx
mov    $0x1,%al
cmp    %edx,%ecx
mov    %al,-0x11(%rbp)
jne    11b4 <eat_comments+0x84>
movsbl -0xa(%rbp),%eax
mov    0x2e3f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11c4 <eat_comments+0x94>
jmp    11d5 <eat_comments+0xa5>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0xa(%rbp)
jmp    1189 <eat_comments+0x59>
movl   $0x1,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11f5 <eat_comments+0xc5>
mov    -0xa(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1050 <ungetc@plt>
jmp    11fa <eat_comments+0xca>
movsbl -0xa(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
je     1149 <eat_comments+0x19>
cmpl   $0x1,-0x10(%rbp)
jne    1223 <eat_comments+0xf3>
mov    -0xa(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1050 <ungetc@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eat_comments>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%r12
movl   $0x0,(%rsp)
mov    $0x1,%r13b
mov    0x2e96(%rip),%r14
movl   $0x0,0x4(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebx
movsbl %al,%ebp
mov    %ebp,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1160 <eat_comments+0x30>
cmp    %r15b,%bl
jne    11b7 <eat_comments+0x87>
mov    %r12,%rdi
call   1030 <fgetc@plt>
movl   $0x1,0x4(%rsp)
mov    $0x1,%cl
mov    %ecx,(%rsp)
cmp    %r15b,%al
jne    11a0 <eat_comments+0x70>
xor    %r13d,%r13d
cmp    (%r14),%al
jne    1160 <eat_comments+0x30>
mov    %r12,%rdi
call   1030 <fgetc@plt>
cmp    %r15b,%al
jne    11a0 <eat_comments+0x70>
cmp    (%r14),%al
je     11a0 <eat_comments+0x70>
xor    %r13d,%r13d
jmp    1160 <eat_comments+0x30>
test   $0x1,%r13b
je     11c7 <eat_comments+0x97>
mov    %ebp,%edi
mov    %r12,%rsi
call   1050 <ungetc@plt>
testb  $0x1,(%rsp)
mov    0x4(%rsp),%eax
je     11e0 <eat_comments+0xb0>
mov    %ebp,%edi
mov    %r12,%rsi
call   1050 <ungetc@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i8 0
define i32 @eat_comments(i32* nocapture %0, i8 signext %1) {
br label %3
3: ; preds = %19, %2
%4 = phi i1 [ true, %2 ], [ false, %19 ]
%5 = phi i1 [ false, %2 ], [ true, %19 ]
%6 = phi i32 [ 0, %2 ], [ 1, %19 ]
br label %7
7: ; preds = %7, %3
%8 = tail call signext i8 @fgetc(i32* %0)
%9 = tail call i64 @isspace(i8 signext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %7
11: ; preds = %7
%12 = icmp eq i8 %8, %1
br i1 %12, label %13, label %26
13: ; preds = %11
%14 = tail call signext i8 @fgetc(i32* %0)
%15 = icmp ne i8 %14, %1
%16 = load i8, i8* @EOF
%17 = icmp eq i8 %14, %16
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %20, label %19
19: ; preds = %20, %13
br label %3
20: ; preds = %13, %20
%21 = tail call signext i8 @fgetc(i32* %0)
%22 = icmp ne i8 %21, %1
%23 = load i8, i8* @EOF
%24 = icmp eq i8 %21, %23
%25 = select i1 %22, i1 true, i1 %24
br i1 %25, label %20, label %19
26: ; preds = %11
br i1 %4, label %27, label %29
27: ; preds = %26
%28 = tail call i32 @ungetc(i8 signext %8, i32* %0)
br label %29
29: ; preds = %27, %26
br i1 %5, label %30, label %32
30: ; preds = %29
%31 = tail call i32 @ungetc(i8 signext %8, i32* %0)
br label %32
32: ; preds = %30, %29
%33 = phi i32 [ 1, %30 ], [ %6, %29 ]
ret i32 %33
}