#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 */
scalar_t__ isspace(char);
char *trimComment(char *ptr, char *start) {
  char *p = ptr - 1;
  while (p > start && (isspace(*p) || *p == '/' || *p == '*'))
    --p;
  return p + 1;
}


x86 assembly (clang, -O0):
<trimComment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x19(%rbp)
jbe    1188 <trimComment+0x78>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1a(%rbp)
jne    1182 <trimComment+0x72>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2f,%ecx
mov    %al,-0x1a(%rbp)
je     1182 <trimComment+0x72>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1198 <trimComment+0x88>
jmp    11a9 <trimComment+0x99>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <trimComment+0x1c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trimComment>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rax
lea    -0x1(%rdi),%rbx
cmp    %rsi,%rbx
jbe    1158 <trimComment+0x48>
mov    %rsi,%r14
jmp    1139 <trimComment+0x29>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffffffffffff,%rbx
cmp    %r14,%rbx
jbe    1151 <trimComment+0x41>
movsbl (%rbx),%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    1130 <trimComment+0x20>
movzbl (%rbx),%eax
cmp    $0x2f,%al
je     1130 <trimComment+0x20>
cmp    $0x2a,%al
je     1130 <trimComment+0x20>
add    $0x1,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @trimComment(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 -1
store i8* %7, i8** %5
br label %8
8: ; preds = %31, %2
%9 = load i8*, i8** %5
%10 = load i8*, i8** %4
%11 = icmp ugt i8* %9, %10
br i1 %11, label %12, label %29
12: ; preds = %8
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = call i64 @isspace(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 47
br i1 %21, label %27, label %22
22: ; preds = %17
%23 = load i8*, i8** %5
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 42
br label %27
27: ; preds = %22, %17, %12
%28 = phi i1 [ true, %17 ], [ true, %12 ], [ %26, %22 ]
br label %29
29: ; preds = %27, %8
%30 = phi i1 [ false, %8 ], [ %28, %27 ]
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 -1
store i8* %33, i8** %5
br label %8
34: ; preds = %29
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i64 1
ret i8* %36
}

LLVM IR (-O2):
define i8* @trimComment(i8* %0, i8* readnone %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 -1
%4 = icmp ugt i8* %3, %1
br i1 %4, label %5, label %16
5: ; preds = %2, %13
%6 = phi i8* [ %14, %13 ], [ %3, %2 ]
%7 = phi i8* [ %6, %13 ], [ %0, %2 ]
%8 = load i8, i8* %6
%9 = tail call i64 @isspace(i8 signext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = load i8, i8* %6
switch i8 %12, label %16 [
i8 47, label %13
i8 42, label %13
]
13: ; preds = %11, %11, %5
%14 = getelementptr inbounds i8, i8* %6, i64 -1
%15 = icmp ugt i8* %14, %1
br i1 %15, label %5, label %16
16: ; preds = %13, %11, %2
%17 = phi i8* [ %0, %2 ], [ %7, %11 ], [ %6, %13 ]
ret i8* %17
}