void xDeleteComments(char *buffer) {
  char c;
  while (*buffer != '\0') {
    if (*buffer == '\'' || *buffer == '"') {
      c = *buffer;
      buffer++;
      while (*buffer != '\0' && *buffer != c)
        buffer++;
    } else if (*buffer == '\\')
      buffer++;
    else if (*buffer == '#') {
      *buffer = '\0';
      return;
    }
    buffer++;
  }
}


x86 assembly (clang, -O0):
<xDeleteComments>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f3 <xDeleteComments+0xf3>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
je     1138 <xDeleteComments+0x38>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    119b <xDeleteComments+0x9b>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xa(%rbp)
je     1175 <xDeleteComments+0x75>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    1185 <xDeleteComments+0x85>
jmp    1196 <xDeleteComments+0x96>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    114d <xDeleteComments+0x4d>
jmp    11e2 <xDeleteComments+0xe2>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11bc <xDeleteComments+0xbc>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11dd <xDeleteComments+0xdd>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    11d8 <xDeleteComments+0xd8>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
jmp    11f3 <xDeleteComments+0xf3>
jmp    11dd <xDeleteComments+0xdd>
jmp    11e2 <xDeleteComments+0xe2>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1108 <xDeleteComments+0x8>
pop    %rbp
ret

x86 assembly (clang, -O2):
<xDeleteComments>:
lea    0xef9(%rip),%rax
jmp    1114 <xDeleteComments+0x14>
nopl   0x0(%rax)
add    $0x1,%rdi
movzbl (%rdi),%ecx
cmp    $0x27,%rcx
ja     1150 <xDeleteComments+0x50>
movslq (%rax,%rcx,4),%rdx
add    %rax,%rdx
jmp    *%rdx
cs nopw 0x0(%rax,%rax,1)
movzbl 0x1(%rdi),%edx
add    $0x1,%rdi
test   %dl,%dl
je     1110 <xDeleteComments+0x10>
cmp    %cl,%dl
jne    1130 <xDeleteComments+0x30>
jmp    1110 <xDeleteComments+0x10>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x5c,%cl
jne    1110 <xDeleteComments+0x10>
add    $0x1,%rdi
add    $0x1,%rdi
jmp    1114 <xDeleteComments+0x14>
movb   $0x0,(%rdi)
ret

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

LLVM IR (-O2):
define void @xDeleteComments(i8* nocapture %0) {
br label %2
2: ; preds = %16, %1
%3 = phi i8* [ %0, %1 ], [ %18, %16 ]
%4 = load i8, i8* %3
switch i8 %4, label %16 [
i8 0, label %19
i8 39, label %5
i8 34, label %5
i8 92, label %13
i8 35, label %15
]
5: ; preds = %2, %2
br label %6
6: ; preds = %5, %6
%7 = phi i8* [ %8, %6 ], [ %3, %5 ]
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
%11 = icmp eq i8 %9, %4
%12 = select i1 %10, i1 true, i1 %11
br i1 %12, label %16, label %6
13: ; preds = %2
%14 = getelementptr inbounds i8, i8* %3, i64 1
br label %16
15: ; preds = %2
store i8 0, i8* %3
br label %19
16: ; preds = %6, %2, %13
%17 = phi i8* [ %14, %13 ], [ %3, %2 ], [ %8, %6 ]
%18 = getelementptr inbounds i8, i8* %17, i64 1
br label %2
19: ; preds = %2, %15
ret void
}