#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 input {
  int dummy;
};

/* Variables and functions */
char *input_line(struct input *);
int /*<<< orphan*/ input_next(struct input *);
char *readtoken(char *, char *, char *);
int /*<<< orphan*/ startswith(char *, char *);
int read_comment(struct input *input) {
  char separator[128];
  char *line = input_line(input);
  line = readtoken(separator, line, " \n");
  input_next(input);
  while ((line = input_line(input)) && !startswith(line, separator))
    input_next(input);
  return 0;
}


x86 assembly (clang, -O0):
<read_comment>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <input_line@plt>
mov    %rax,-0x98(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
lea    0xe8c(%rip),%rdx
call   1060 <readtoken@plt>
mov    %rax,-0x98(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <input_next@plt>
mov    -0x8(%rbp),%rdi
call   1050 <input_line@plt>
mov    %rax,%rcx
mov    %rcx,-0x98(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x99(%rbp)
je     11cf <read_comment+0x8f>
mov    -0x98(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1040 <startswith@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x99(%rbp)
mov    -0x99(%rbp),%al
test   $0x1,%al
jne    11e2 <read_comment+0xa2>
jmp    11f0 <read_comment+0xb0>
mov    -0x8(%rbp),%rdi
call   1030 <input_next@plt>
jmp    1189 <read_comment+0x49>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_comment>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%rbx
call   1050 <input_line@plt>
lea    0xea7(%rip),%rdx
mov    %rsp,%rdi
mov    %rax,%rsi
call   1060 <readtoken@plt>
mov    %rbx,%rdi
call   1030 <input_next@plt>
mov    %rbx,%rdi
call   1050 <input_line@plt>
test   %rax,%rax
je     11a4 <read_comment+0x64>
mov    %rsp,%r14
nopl   0x0(%rax)
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <startswith@plt>
test   %eax,%eax
jne    11a4 <read_comment+0x64>
mov    %rbx,%rdi
call   1030 <input_next@plt>
mov    %rbx,%rdi
call   1050 <input_line@plt>
test   %rax,%rax
jne    1180 <read_comment+0x40>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.input = type { i32 }
@.str = [3 x i8] c" \0A\00"
define i32 @read_comment(%struct.input* %0) {
%2 = alloca %struct.input*
%3 = alloca [128 x i8]
%4 = alloca i8*
store %struct.input* %0, %struct.input** %2
%5 = load %struct.input*, %struct.input** %2
%6 = call i8* @input_line(%struct.input* %5)
store i8* %6, i8** %4
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%8 = load i8*, i8** %4
%9 = call i8* @readtoken(i8* %7, i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %4
%10 = load %struct.input*, %struct.input** %2
%11 = call i32 @input_next(%struct.input* %10)
br label %12
12: ; preds = %24, %1
%13 = load %struct.input*, %struct.input** %2
%14 = call i8* @input_line(%struct.input* %13)
store i8* %14, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%19 = call i32 @startswith(i8* %17, i8* %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br label %22
22: ; preds = %16, %12
%23 = phi i1 [ false, %12 ], [ %21, %16 ]
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = load %struct.input*, %struct.input** %2
%26 = call i32 @input_next(%struct.input* %25)
br label %12
27: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
%struct.input = type { i32 }
@.str = [3 x i8] c" \0A\00"
define i32 @read_comment(%struct.input* %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = tail call i8* @input_line(%struct.input* %0)
%5 = call i8* @readtoken(i8* %3, i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @input_next(%struct.input* %0)
%7 = call i8* @input_line(%struct.input* %0)
%8 = icmp eq i8* %7, null
br i1 %8, label %17, label %9
9: ; preds = %1, %13
%10 = phi i8* [ %15, %13 ], [ %7, %1 ]
%11 = call i32 @startswith(i8* %10, i8* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = call i32 @input_next(%struct.input* %0)
%15 = call i8* @input_line(%struct.input* %0)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %9
17: ; preds = %9, %13, %1
ret i32 0
}