#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char);
int parse_comment(char *source, size_t *index) {
  if (source[*index] != '#') {
    printf("parse_comment: expected '#', got '%c'\n", source[*index]);
    return 1;
  }
  while (1) {
    switch (source[*index]) {
    case '\n':
    case '\0':
      goto EXIT;
      break;
    default:
      ++(*index);
      break;
    }
  }
EXIT:
  return 0;
}


x86 assembly (clang, -O0):
<parse_comment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x23,%eax
je     115f <parse_comment+0x4f>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
lea    0xeb6(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b3 <parse_comment+0xa3>
jmp    1164 <parse_comment+0x54>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     1194 <parse_comment+0x84>
jmp    1183 <parse_comment+0x73>
mov    -0x1c(%rbp),%eax
sub    $0xa,%eax
jne    1199 <parse_comment+0x89>
jmp    1194 <parse_comment+0x84>
jmp    11ac <parse_comment+0x9c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    1164 <parse_comment+0x54>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_comment>:
push   %rax
mov    (%rsi),%rax
mov    (%rdi,%rax,1),%cl
cmp    $0x23,%cl
jne    1149 <parse_comment+0x39>
add    $0x1,%rax
mov    $0x23,%cl
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %cl,%ecx
test   %ecx,%ecx
je     115f <parse_comment+0x4f>
cmp    $0xa,%ecx
je     115f <parse_comment+0x4f>
mov    %rax,(%rsi)
movzbl (%rdi,%rax,1),%ecx
add    $0x1,%rax
jmp    1130 <parse_comment+0x20>
movsbl %cl,%esi
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [39 x i8] c"parse_comment: expected '#', got '%c'\0A\00"
define i32 @parse_comment(i8* %0, i64* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64*
store i8* %0, i8** %4
store i64* %1, i64** %5
%6 = load i8*, i8** %4
%7 = load i64*, i64** %5
%8 = load i64, i64* %7
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 35
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = load i64*, i64** %5
%16 = load i64, i64* %15
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8 signext %18)
store i32 1, i32* %3
br label %35
20: ; preds = %2
br label %21
21: ; preds = %20, %33
%22 = load i8*, i8** %4
%23 = load i64*, i64** %5
%24 = load i64, i64* %23
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
switch i32 %27, label %29 [
i32 10, label %28
i32 0, label %28
]
28: ; preds = %21, %21
br label %34
29: ; preds = %21
%30 = load i64*, i64** %5
%31 = load i64, i64* %30
%32 = add i64 %31, 1
store i64 %32, i64* %30
br label %33
33: ; preds = %29
br label %21
34: ; preds = %28
store i32 0, i32* %3
br label %35
35: ; preds = %34, %13
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [39 x i8] c"parse_comment: expected '#', got '%c'\0A\00"
define i32 @parse_comment(i8* nocapture %0, i64* nocapture %1) {
%3 = load i64, i64* %1
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 35
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8 signext %5)
br label %17
9: ; preds = %2, %13
%10 = phi i8 [ %16, %13 ], [ 35, %2 ]
%11 = phi i64 [ %14, %13 ], [ %3, %2 ]
%12 = sext i8 %10 to i32
switch i32 %12, label %13 [
i32 10, label %17
i32 0, label %17
]
13: ; preds = %9
%14 = add i64 %11, 1
store i64 %14, i64* %1
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
br label %9
17: ; preds = %9, %9, %7
%18 = phi i32 [ 1, %7 ], [ 0, %9 ], [ 0, %9 ]
ret i32 %18
}