#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 */
int EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ *skip_past_newline(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
FILE *parse_comments(FILE *is, int c_type) {
  int c, aster;
  if (c_type == 1) {
    is = skip_past_newline(is);
    return is;
  } else if (c_type == 2) {
    while (1) {
      c = fgetc(is);
      if (c == '*') {
        aster = 1;
      } else if (c == '/' && aster) {
        return is;
      } else if (c == EOF) {
        fprintf(stderr, "Error in parsing a multi-line "
                        "comment. Are you sure you "
                        "terminated your last comment "
                        "correctly?\n");
        exit(EXIT_FAILURE);
      } else {
        aster = 0;
      }
    }
  } else {
    fprintf(stderr, "An error occurred.\n");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<parse_comments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1173 <parse_comments+0x33>
mov    -0x10(%rbp),%rdi
call   1030 <skip_past_newline@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1233 <parse_comments+0xf3>
cmpl   $0x2,-0x14(%rbp)
jne    1210 <parse_comments+0xd0>
jmp    1182 <parse_comments+0x42>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2a,-0x18(%rbp)
jne    11a4 <parse_comments+0x64>
movl   $0x1,-0x1c(%rbp)
jmp    120b <parse_comments+0xcb>
cmpl   $0x2f,-0x18(%rbp)
jne    11c5 <parse_comments+0x85>
cmpl   $0x0,-0x1c(%rbp)
je     11c5 <parse_comments+0x85>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1233 <parse_comments+0xf3>
mov    -0x18(%rbp),%eax
mov    0x2e19(%rip),%rcx
cmp    (%rcx),%eax
jne    11fa <parse_comments+0xba>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
movl   $0x0,-0x1c(%rbp)
jmp    1206 <parse_comments+0xc6>
jmp    120b <parse_comments+0xcb>
jmp    1182 <parse_comments+0x42>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_comments>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
cmp    $0x1,%esi
je     11a4 <parse_comments+0x64>
cmp    $0x2,%esi
jne    11ba <parse_comments+0x7a>
mov    0x2e8f(%rip),%r14
nopl   0x0(%rax)
mov    %ecx,%ebx
mov    %r15,%rdi
call   1040 <fgetc@plt>
cmp    $0x2a,%eax
sete   %cl
je     1160 <parse_comments+0x20>
cmp    $0x2f,%eax
sete   %dl
test   %bl,%dl
jne    11b1 <parse_comments+0x71>
cmp    (%r14),%eax
jne    1160 <parse_comments+0x20>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <skip_past_newline@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
jmp    1191 <parse_comments+0x51>

LLVM IR (-O0):
@EOF = global i32 0
@stderr = global i32 0
@.str = [97 x i8] c"Error in parsing a multi-line comment. Are you sure you terminated your last comment correctly?\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [20 x i8] c"An error occurred.\0A\00"
define i32* @parse_comments(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32*, i32** %4
%12 = call i32* @skip_past_newline(i32* %11)
store i32* %12, i32** %4
%13 = load i32*, i32** %4
store i32* %13, i32** %3
br label %50
14: ; preds = %2
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %45
17: ; preds = %14
br label %18
18: ; preds = %17, %44
%19 = load i32*, i32** %4
%20 = call i32 @fgetc(i32* %19)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 42
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 1, i32* %7
br label %44
24: ; preds = %18
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 47
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i32, i32* %7
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = load i32*, i32** %4
store i32* %31, i32** %3
br label %50
32: ; preds = %27, %24
%33 = load i32, i32* %6
%34 = load i32, i32* @EOF
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %32
store i32 0, i32* %7
br label %42
42: ; preds = %41
br label %43
43: ; preds = %42
br label %44
44: ; preds = %43, %23
br label %18
45: ; preds = %14
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %30, %10
%51 = load i32*, i32** %3
ret i32* %51
}

LLVM IR (-O2):
@EOF = global i32 0
@stderr = global i32 0
@.str = [97 x i8] c"Error in parsing a multi-line comment. Are you sure you terminated your last comment correctly?\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [20 x i8] c"An error occurred.\0A\00"
define i32* @parse_comments(i32* %0, i32 %1) {
switch i32 %1, label %21 [
i32 1, label %3
i32 2, label %5
]
3: ; preds = %2
%4 = tail call i32* @skip_past_newline(i32* %0)
br label %26
5: ; preds = %2, %15
%6 = phi i1 [ %8, %15 ], [ undef, %2 ]
%7 = tail call i32 @fgetc(i32* %0)
%8 = icmp eq i32 %7, 42
br i1 %8, label %15, label %9
9: ; preds = %5
%10 = icmp eq i32 %7, 47
%11 = select i1 %10, i1 %6, i1 false
br i1 %11, label %26, label %12
12: ; preds = %9
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %7, %13
br i1 %14, label %16, label %15
15: ; preds = %12, %5
br label %5
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %9, %3
%27 = phi i32* [ %4, %3 ], [ %0, %9 ]
ret i32* %27
}