#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 */
struct data_node {
  int dummy;
};
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ data_node_array_add(struct data_node *, struct data_node *);
struct data_node *data_node_string(int /*<<< orphan*/);
int /*<<< orphan*/ eat_asterisk_space(char *);
int getc(int /*<<< orphan*/ *);
void multiline_comment(FILE *f, struct data_node *doc) {
  int c;
  int state = 0;
  char buf[4096];
  unsigned int bufp = 0;
  for (;;) {
    c = getc(f);
    if (doc) {
      if (c == '\n') {
        struct data_node *line;
        buf[bufp] = 0;
        line = data_node_string(eat_asterisk_space(buf));
        data_node_array_add(doc, line);
        bufp = 0;
        continue;
      }
      if (bufp + 1 >= sizeof(buf))
        continue;
      buf[bufp++] = c;
    }
    switch (state) {
    case 0:
      if (c == '*')
        state = 1;
      break;
    case 1:
      switch (c) {
      case '/':
        return;
      case '*':
        continue;
      default:
        state = 0;
        break;
      }
      break;
    }
  }
}


x86 assembly (clang, -O0):
<multiline_comment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1024(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1207 <multiline_comment+0xc7>
cmpl   $0xa,-0x14(%rbp)
jne    11cc <multiline_comment+0x8c>
mov    -0x1024(%rbp),%eax
movb   $0x0,-0x1020(%rbp,%rax,1)
lea    -0x1020(%rbp),%rdi
call   1040 <eat_asterisk_space@plt>
mov    %eax,%edi
call   1060 <data_node_string@plt>
mov    %rax,-0x1030(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1030(%rbp),%rsi
call   1030 <data_node_array_add@plt>
movl   $0x0,-0x1024(%rbp)
jmp    1164 <multiline_comment+0x24>
mov    -0x1024(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
cmp    $0x1000,%rax
jb     11e8 <multiline_comment+0xa8>
jmp    1164 <multiline_comment+0x24>
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    -0x1024(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1024(%rbp)
mov    %eax,%eax
mov    %cl,-0x1020(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1034(%rbp)
test   %eax,%eax
je     1231 <multiline_comment+0xf1>
jmp    121d <multiline_comment+0xdd>
mov    -0x1034(%rbp),%eax
sub    $0x1,%eax
je     1247 <multiline_comment+0x107>
jmp    128c <multiline_comment+0x14c>
cmpl   $0x2a,-0x14(%rbp)
jne    1242 <multiline_comment+0x102>
movl   $0x1,-0x18(%rbp)
jmp    128c <multiline_comment+0x14c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1038(%rbp)
sub    $0x2a,%eax
je     127b <multiline_comment+0x13b>
jmp    125e <multiline_comment+0x11e>
mov    -0x1038(%rbp),%eax
sub    $0x2f,%eax
jne    1280 <multiline_comment+0x140>
jmp    1272 <multiline_comment+0x132>
add    $0x1040,%rsp
pop    %rbp
ret
jmp    1164 <multiline_comment+0x24>
movl   $0x0,-0x18(%rbp)
jmp    128c <multiline_comment+0x14c>
jmp    1164 <multiline_comment+0x24>

x86 assembly (clang, -O2):
<multiline_comment>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %r15d,%r15d
xor    %r13d,%r13d
nopl   (%rax)
mov    %r15d,%ebp
lea    0x1(%rbp),%r12d
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <getc@plt>
test   %rbx,%rbx
je     11c8 <multiline_comment+0x88>
cmp    $0xa,%eax
je     1190 <multiline_comment+0x50>
cmp    $0xfff,%r12d
ja     1170 <multiline_comment+0x30>
jmp    11c0 <multiline_comment+0x80>
nopl   (%rax)
mov    %ebp,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1040 <eat_asterisk_space@plt>
mov    %eax,%edi
call   1060 <data_node_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <data_node_array_add@plt>
xor    %ebp,%ebp
jmp    1163 <multiline_comment+0x23>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%ecx
mov    %al,(%rsp,%rcx,1)
mov    %r12d,%r15d
cmp    $0x1,%r13d
je     11e0 <multiline_comment+0xa0>
test   %r13d,%r13d
jne    1160 <multiline_comment+0x20>
xor    %r13d,%r13d
cmp    $0x2a,%eax
sete   %r13b
jmp    1160 <multiline_comment+0x20>
nop
mov    $0x1,%r13d
cmp    $0x2a,%eax
je     1160 <multiline_comment+0x20>
xor    %r13d,%r13d
cmp    $0x2f,%eax
jne    1160 <multiline_comment+0x20>
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.data_node = type { i32 }
define void @multiline_comment(i32* %0, %struct.data_node* %1) {
%3 = alloca i32*
%4 = alloca %struct.data_node*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [4096 x i8]
%8 = alloca i32
%9 = alloca %struct.data_node*
store i32* %0, i32** %3
store %struct.data_node* %1, %struct.data_node** %4
store i32 0, i32* %6
store i32 0, i32* %8
br label %10
10: ; preds = %54, %51, %33, %18, %2
%11 = load i32*, i32** %3
%12 = call i32 @getc(i32* %11)
store i32 %12, i32* %5
%13 = load %struct.data_node*, %struct.data_node** %4
%14 = icmp ne %struct.data_node* %13, null
br i1 %14, label %15, label %41
15: ; preds = %10
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32, i32* %8
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %20
store i8 0, i8* %21
%22 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%23 = call i32 @eat_asterisk_space(i8* %22)
%24 = call %struct.data_node* @data_node_string(i32 %23)
store %struct.data_node* %24, %struct.data_node** %9
%25 = load %struct.data_node*, %struct.data_node** %4
%26 = load %struct.data_node*, %struct.data_node** %9
%27 = call i32 @data_node_array_add(%struct.data_node* %25, %struct.data_node* %26)
store i32 0, i32* %8
br label %10
28: ; preds = %15
%29 = load i32, i32* %8
%30 = add i32 %29, 1
%31 = zext i32 %30 to i64
%32 = icmp uge i64 %31, 4096
br i1 %32, label %33, label %34
33: ; preds = %28
br label %10
34: ; preds = %28
%35 = load i32, i32* %5
%36 = trunc i32 %35 to i8
%37 = load i32, i32* %8
%38 = add i32 %37, 1
store i32 %38, i32* %8
%39 = zext i32 %37 to i64
%40 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %39
store i8 %36, i8* %40
br label %41
41: ; preds = %34, %10
%42 = load i32, i32* %6
switch i32 %42, label %54 [
i32 0, label %43
i32 1, label %48
]
43: ; preds = %41
%44 = load i32, i32* %5
%45 = icmp eq i32 %44, 42
br i1 %45, label %46, label %47
46: ; preds = %43
store i32 1, i32* %6
br label %47
47: ; preds = %46, %43
br label %54
48: ; preds = %41
%49 = load i32, i32* %5
switch i32 %49, label %52 [
i32 47, label %50
i32 42, label %51
]
50: ; preds = %48
ret void
51: ; preds = %48
br label %10
52: ; preds = %48
store i32 0, i32* %6
br label %53
53: ; preds = %52
br label %54
54: ; preds = %41, %53, %47
br label %10
}

LLVM IR (-O2):
%struct.data_node = type { i32 }
define void @multiline_comment(i32* nocapture %0, %struct.data_node* %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = icmp eq %struct.data_node* %1, null
br label %6
6: ; preds = %34, %2
%7 = phi i32 [ 0, %2 ], [ %29, %34 ]
%8 = phi i32 [ 0, %2 ], [ %35, %34 ]
br label %9
9: ; preds = %6, %17
%10 = phi i32 [ 0, %17 ], [ %7, %6 ]
%11 = add i32 %10, 1
%12 = icmp ugt i32 %11, 4095
br label %13
13: ; preds = %9, %23
%14 = call i32 @getc(i32* %0)
br i1 %5, label %28, label %15
15: ; preds = %13
%16 = icmp eq i32 %14, 10
br i1 %16, label %17, label %23
17: ; preds = %15
%18 = zext i32 %10 to i64
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %18
store i8 0, i8* %19
%20 = call i32 @eat_asterisk_space(i8* %4)
%21 = call %struct.data_node* @data_node_string(i32 %20)
%22 = call i32 @data_node_array_add(%struct.data_node* %1, %struct.data_node* %21)
br label %9
23: ; preds = %15
br i1 %12, label %13, label %24
24: ; preds = %23
%25 = trunc i32 %14 to i8
%26 = zext i32 %10 to i64
%27 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %26
store i8 %25, i8* %27
br label %28
28: ; preds = %13, %24
%29 = phi i32 [ %11, %24 ], [ %7, %13 ]
switch i32 %8, label %37 [
i32 0, label %30
i32 1, label %33
]
30: ; preds = %28
%31 = icmp eq i32 %14, 42
%32 = zext i1 %31 to i32
br label %37
33: ; preds = %28
switch i32 %14, label %37 [
i32 47, label %36
i32 42, label %34
]
34: ; preds = %33, %37
%35 = phi i32 [ 1, %33 ], [ %38, %37 ]
br label %6
36: ; preds = %33
ret void
37: ; preds = %30, %33, %28
%38 = phi i32 [ %8, %28 ], [ %32, %30 ], [ 0, %33 ]
br label %34
}