#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 /*<<< orphan*/ strcpy(char *, char *);
void strip_comments(char *p) {
  char *b;
  while ((p = strchr(p, '(')) != 0) {
    b = p++;
    if ((p = strchr(p, ')')) != 0) {
      (void)strcpy(b, ++p);
    } else {
      *b = ('\0');
      break;
    }
  }
}


x86 assembly (clang, -O0):
<strip_comments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x28,%esi
call   1040 <strchr@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     11a2 <strip_comments+0x82>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x29,%esi
call   1040 <strchr@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     1191 <strip_comments+0x71>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
mov    %rsi,-0x8(%rbp)
call   1030 <strcpy@plt>
jmp    119d <strip_comments+0x7d>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    11a2 <strip_comments+0x82>
jmp    112c <strip_comments+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_comments>:
push   %r14
push   %rbx
push   %rax
mov    $0x28,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1180 <strip_comments+0x60>
mov    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
lea    0x1(%r14),%rdi
mov    $0x29,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     117c <strip_comments+0x5c>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x28,%esi
call   1040 <strchr@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1140 <strip_comments+0x20>
jmp    1180 <strip_comments+0x60>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @strip_comments(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
br label %4
4: ; preds = %21, %1
%5 = load i8*, i8** %2
%6 = call i8* @strchr(i8* %5, i8 signext 40)
store i8* %6, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %22
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %2
store i8* %9, i8** %3
%11 = load i8*, i8** %2
%12 = call i8* @strchr(i8* %11, i8 signext 41)
store i8* %12, i8** %2
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %19
14: ; preds = %8
%15 = load i8*, i8** %3
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %2
%18 = call i32 @strcpy(i8* %15, i8* %17)
br label %21
19: ; preds = %8
%20 = load i8*, i8** %3
store i8 0, i8* %20
br label %22
21: ; preds = %14
br label %4
22: ; preds = %19, %4
ret void
}

LLVM IR (-O2):
define void @strip_comments(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 40)
%3 = icmp eq i8* %2, null
br i1 %3, label %15, label %4
4: ; preds = %1, %9
%5 = phi i8* [ %12, %9 ], [ %2, %1 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = tail call i8* @strchr(i8* %6, i8 signext 41)
%8 = icmp eq i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = tail call i32 @strcpy(i8* %5, i8* %10)
%12 = tail call i8* @strchr(i8* dereferenceable(1) %10, i8 signext 40)
%13 = icmp eq i8* %12, null
br i1 %13, label %15, label %4
14: ; preds = %4
store i8 0, i8* %5
br label %15
15: ; preds = %9, %1, %14
ret void
}