#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 */
char *strchr(char *, char);
int ProcessComments(char *line) {
  char *cp;
  int i = 0;
  if (line == NULL)
    return (-1);
  if ((cp = strchr(line, '-')) != NULL) {
    if (*(cp + 1) == '-')
      *cp = '\0';
  }
  cp = line;
  while (*cp && (*cp == ' ' || *cp == '\t' || *cp == '\r')) {
    i += 1;
    cp += 1;
  }
  return (i);
}


x86 assembly (clang, -O0):
<ProcessComments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113a <ProcessComments+0x2a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <ProcessComments+0xf0>
mov    -0x10(%rbp),%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1173 <ProcessComments+0x63>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
jne    116e <ProcessComments+0x5e>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    1173 <ProcessComments+0x63>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     11d0 <ProcessComments+0xc0>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x1e(%rbp)
je     11ca <ProcessComments+0xba>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x1e(%rbp)
je     11ca <ProcessComments+0xba>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
sete   %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11e0 <ProcessComments+0xd0>
jmp    11fa <ProcessComments+0xea>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    117b <ProcessComments+0x6b>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ProcessComments>:
push   %rbx
test   %rdi,%rdi
je     1156 <ProcessComments+0x46>
mov    %rdi,%rbx
mov    $0x2d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1131 <ProcessComments+0x21>
cmpb   $0x2d,0x1(%rax)
jne    1131 <ProcessComments+0x21>
movb   $0x0,(%rax)
xor    %eax,%eax
movabs $0x100002200,%rcx
nopl   (%rax)
movzbl (%rbx,%rax,1),%edx
cmp    $0x20,%rdx
ja     115b <ProcessComments+0x4b>
bt     %rdx,%rcx
jae    115b <ProcessComments+0x4b>
add    $0x1,%rax
jmp    1140 <ProcessComments+0x30>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ProcessComments(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 -1, i32* %2
br label %55
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i8* @strchr(i8* %10, i8 signext 45)
store i8* %11, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 45
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = load i8*, i8** %4
store i8 0, i8* %20
br label %21
21: ; preds = %19, %13
br label %22
22: ; preds = %21, %9
%23 = load i8*, i8** %3
store i8* %23, i8** %4
br label %24
24: ; preds = %48, %22
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %46
29: ; preds = %24
%30 = load i8*, i8** %4
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 32
br i1 %33, label %44, label %34
34: ; preds = %29
%35 = load i8*, i8** %4
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 9
br i1 %38, label %44, label %39
39: ; preds = %34
%40 = load i8*, i8** %4
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 13
br label %44
44: ; preds = %39, %34, %29
%45 = phi i1 [ true, %34 ], [ true, %29 ], [ %43, %39 ]
br label %46
46: ; preds = %44, %24
%47 = phi i1 [ false, %24 ], [ %45, %44 ]
br i1 %47, label %48, label %53
48: ; preds = %46
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i64 1
store i8* %52, i8** %4
br label %24
53: ; preds = %46
%54 = load i32, i32* %5
store i32 %54, i32* %2
br label %55
55: ; preds = %53, %8
%56 = load i32, i32* %2
ret i32 %56
}

LLVM IR (-O2):
define i32 @ProcessComments(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = tail call i8* @strchr(i8* %0, i8 signext 45)
%5 = icmp eq i8* %4, null
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 45
br i1 %9, label %10, label %11
10: ; preds = %6
store i8 0, i8* %4
br label %11
11: ; preds = %6, %10, %3
br label %12
12: ; preds = %11, %16
%13 = phi i8* [ %18, %16 ], [ %0, %11 ]
%14 = phi i32 [ %17, %16 ], [ 0, %11 ]
%15 = load i8, i8* %13
switch i8 %15, label %19 [
i8 13, label %16
i8 32, label %16
i8 9, label %16
]
16: ; preds = %12, %12, %12
%17 = add nuw nsw i32 %14, 1
%18 = getelementptr inbounds i8, i8* %13, i64 1
br label %12
19: ; preds = %12, %1
%20 = phi i32 [ -1, %1 ], [ %14, %12 ]
ret i32 %20
}