#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 *);
char *strstr(char *, char *);
int rm_comment(char *target, char *str) {
  char *pt;
  strcpy(target, str);
  if ((pt = strstr(target, "REMARK")) || (pt = strchr(target, '#')) ||
      (pt = strchr(target, '\n')))
    *pt = '\0';
  return 0;
}


x86 assembly (clang, -O0):
<rm_comment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a3 <rm_comment+0x73>
mov    -0x8(%rbp),%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a3 <rm_comment+0x73>
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11aa <rm_comment+0x7a>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rm_comment>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strcpy@plt>
lea    0xec0(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
jne    1171 <rm_comment+0x41>
mov    %rbx,%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1171 <rm_comment+0x41>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1174 <rm_comment+0x44>
movb   $0x0,(%rax)
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"REMARK\00"
define i32 @rm_comment(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 = load i8*, i8** %4
%8 = call i32 @strcpy(i8* %6, i8* %7)
%9 = load i8*, i8** %3
%10 = call i8* @strstr(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %20, label %12
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = call i8* @strchr(i8* %13, i8 signext 35)
store i8* %14, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i8* @strchr(i8* %17, i8 signext 10)
store i8* %18, i8** %5
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %16, %12, %2
%21 = load i8*, i8** %5
store i8 0, i8* %21
br label %22
22: ; preds = %20, %16
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"REMARK\00"
define i32 @rm_comment(i8* %0, i8* %1) {
%3 = tail call i32 @strcpy(i8* %0, i8* %1)
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 35)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 10)
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %9, %6, %2
%13 = phi i8* [ %4, %2 ], [ %7, %6 ], [ %10, %9 ]
store i8 0, i8* %13
br label %14
14: ; preds = %12, %9
ret i32 0
}