#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 */
scalar_t__ 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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
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));
        if (data_node_array_add(doc, line))
          fprintf(stderr, "WARNING: "
                          "doc string comment truncated"
                          "\n");
        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   1060 <getc@plt>
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1236 <multiline_comment+0xe6>
cmpl   $0xa,-0x14(%rbp)
jne    11fb <multiline_comment+0xab>
mov    -0x1024(%rbp),%eax
movb   $0x0,-0x1020(%rbp,%rax,1)
lea    -0x1020(%rbp),%rdi
call   1050 <eat_asterisk_space@plt>
mov    %eax,%edi
call   1070 <data_node_string@plt>
mov    %rax,-0x1030(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1030(%rbp),%rsi
call   1030 <data_node_array_add@plt>
cmp    $0x0,%rax
je     11ec <multiline_comment+0x9c>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x1024(%rbp)
jmp    1174 <multiline_comment+0x24>
mov    -0x1024(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
cmp    $0x1000,%rax
jb     1217 <multiline_comment+0xc7>
jmp    1174 <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     1260 <multiline_comment+0x110>
jmp    124c <multiline_comment+0xfc>
mov    -0x1034(%rbp),%eax
sub    $0x1,%eax
je     1276 <multiline_comment+0x126>
jmp    12bb <multiline_comment+0x16b>
cmpl   $0x2a,-0x14(%rbp)
jne    1271 <multiline_comment+0x121>
movl   $0x1,-0x18(%rbp)
jmp    12bb <multiline_comment+0x16b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1038(%rbp)
sub    $0x2a,%eax
je     12aa <multiline_comment+0x15a>
jmp    128d <multiline_comment+0x13d>
mov    -0x1038(%rbp),%eax
sub    $0x2f,%eax
jne    12af <multiline_comment+0x15f>
jmp    12a1 <multiline_comment+0x151>
add    $0x1040,%rsp
pop    %rbp
ret
jmp    1174 <multiline_comment+0x24>
movl   $0x0,-0x18(%rbp)
jmp    12bb <multiline_comment+0x16b>
jmp    1174 <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,%r12d
lea    0x1(%r12),%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1060 <getc@plt>
test   %rbx,%rbx
je     11e9 <multiline_comment+0x99>
cmp    $0xa,%eax
je     11a0 <multiline_comment+0x50>
cmp    $0xfff,%ebp
ja     1180 <multiline_comment+0x30>
jmp    11e0 <multiline_comment+0x90>
nopl   0x0(%rax)
mov    %r12d,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1050 <eat_asterisk_space@plt>
mov    %eax,%edi
call   1070 <data_node_string@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <data_node_array_add@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     1173 <multiline_comment+0x23>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1173 <multiline_comment+0x23>
mov    %r12d,%ecx
mov    %al,(%rsp,%rcx,1)
mov    %ebp,%r15d
cmp    $0x1,%r13d
je     1210 <multiline_comment+0xc0>
test   %r13d,%r13d
jne    1170 <multiline_comment+0x20>
xor    %r13d,%r13d
cmp    $0x2a,%eax
sete   %r13b
jmp    1170 <multiline_comment+0x20>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%r13d
cmp    $0x2a,%eax
je     1170 <multiline_comment+0x20>
xor    %r13d,%r13d
cmp    $0x2f,%eax
jne    1170 <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 }
@stderr = global i32 0
@.str = [39 x i8] c"WARNING: doc string comment truncated\0A\00"
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 = %59, %56, %38, %32, %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 %46
15: ; preds = %10
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %33
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 i64 @data_node_array_add(%struct.data_node* %25, %struct.data_node* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %18
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %29, %18
store i32 0, i32* %8
br label %10
33: ; preds = %15
%34 = load i32, i32* %8
%35 = add i32 %34, 1
%36 = zext i32 %35 to i64
%37 = icmp uge i64 %36, 4096
br i1 %37, label %38, label %39
38: ; preds = %33
br label %10
39: ; preds = %33
%40 = load i32, i32* %5
%41 = trunc i32 %40 to i8
%42 = load i32, i32* %8
%43 = add i32 %42, 1
store i32 %43, i32* %8
%44 = zext i32 %42 to i64
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %44
store i8 %41, i8* %45
br label %46
46: ; preds = %39, %10
%47 = load i32, i32* %6
switch i32 %47, label %59 [
i32 0, label %48
i32 1, label %53
]
48: ; preds = %46
%49 = load i32, i32* %5
%50 = icmp eq i32 %49, 42
br i1 %50, label %51, label %52
51: ; preds = %48
store i32 1, i32* %6
br label %52
52: ; preds = %51, %48
br label %59
53: ; preds = %46
%54 = load i32, i32* %5
switch i32 %54, label %57 [
i32 47, label %55
i32 42, label %56
]
55: ; preds = %53
ret void
56: ; preds = %53
br label %10
57: ; preds = %53
store i32 0, i32* %6
br label %58
58: ; preds = %57
br label %59
59: ; preds = %46, %58, %52
br label %10
}

LLVM IR (-O2):
%struct.data_node = type { i32 }
@stderr = global i32 0
@.str = [39 x i8] c"WARNING: doc string comment truncated\0A\00"
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 = %39, %2
%7 = phi i32 [ 0, %2 ], [ %34, %39 ]
%8 = phi i32 [ 0, %2 ], [ %40, %39 ]
br label %9
9: ; preds = %27, %6
%10 = phi i32 [ %7, %6 ], [ 0, %27 ]
%11 = add i32 %10, 1
%12 = icmp ugt i32 %11, 4095
br label %13
13: ; preds = %9, %28
%14 = call i32 @getc(i32* %0)
br i1 %5, label %33, label %15
15: ; preds = %13
%16 = icmp eq i32 %14, 10
br i1 %16, label %17, label %28
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 i64 @data_node_array_add(%struct.data_node* %1, %struct.data_node* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %17
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %24, %17
br label %9
28: ; preds = %15
br i1 %12, label %13, label %29
29: ; preds = %28
%30 = trunc i32 %14 to i8
%31 = zext i32 %10 to i64
%32 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %31
store i8 %30, i8* %32
br label %33
33: ; preds = %13, %29
%34 = phi i32 [ %11, %29 ], [ %7, %13 ]
switch i32 %8, label %42 [
i32 0, label %35
i32 1, label %38
]
35: ; preds = %33
%36 = icmp eq i32 %14, 42
%37 = zext i1 %36 to i32
br label %42
38: ; preds = %33
switch i32 %14, label %42 [
i32 47, label %41
i32 42, label %39
]
39: ; preds = %38, %42
%40 = phi i32 [ 1, %38 ], [ %43, %42 ]
br label %6
41: ; preds = %38
ret void
42: ; preds = %35, %38, %33
%43 = phi i32 [ %8, %33 ], [ %37, %35 ], [ 0, %38 ]
br label %39
}