#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);
char *strstr(char *, char *);
char *vqec_config_find_comment_str(char *str) {
  char *comment, *charpound, *charslash, *charmulti;
  charpound = strchr(str, '#');
  charslash = strstr(str, "//");
  charmulti = strstr(str, "/*");
  comment = (char *)(-1);
  if (charpound && charpound < comment) {
    comment = charpound;
  }
  if (charslash && charslash < comment) {
    comment = charslash;
  }
  if (charmulti && charmulti < comment) {
    comment = charmulti;
  }
  if (comment == (char *)(-1)) {
    comment = NULL;
  }
  return (comment);
}


x86 assembly (clang, -O0):
<vqec_config_find_comment_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x23,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x28(%rbp)
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1192 <vqec_config_find_comment_str+0x72>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1192 <vqec_config_find_comment_str+0x72>
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11b3 <vqec_config_find_comment_str+0x93>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11b3 <vqec_config_find_comment_str+0x93>
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11d4 <vqec_config_find_comment_str+0xb4>
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11d4 <vqec_config_find_comment_str+0xb4>
mov    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x10(%rbp)
jne    11ed <vqec_config_find_comment_str+0xcd>
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vqec_config_find_comment_str>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0x23,%esi
call   1030 <strchr@plt>
mov    %rax,%r14
lea    0xec4(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
mov    %rax,%r15
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
mov    $0xffffffffffffffff,%rcx
lea    0x1(%r14),%rdx
cmp    $0x2,%rdx
jb     116a <vqec_config_find_comment_str+0x4a>
mov    %r14,%rcx
cmp    %rcx,%r15
mov    %rcx,%rdx
cmovb  %r15,%rdx
test   %r15,%r15
cmove  %rcx,%rdx
cmp    %rdx,%rax
mov    %rdx,%rcx
cmovb  %rax,%rcx
test   %rax,%rax
cmove  %rdx,%rcx
xor    %eax,%eax
cmp    $0xffffffffffffffff,%rcx
cmovne %rcx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"//\00"
@.str.1 = [3 x i8] c"/*\00"
define i8* @vqec_config_find_comment_str(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i8* @strchr(i8* %7, i8 signext 35)
store i8* %8, i8** %4
%9 = load i8*, i8** %2
%10 = call i8* @strstr(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %5
%11 = load i8*, i8** %2
%12 = call i8* @strstr(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %12, i8** %6
store i8* inttoptr (i64 -1 to i8*), i8** %3
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %21
15: ; preds = %1
%16 = load i8*, i8** %4
%17 = load i8*, i8** %3
%18 = icmp ult i8* %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i8*, i8** %4
store i8* %20, i8** %3
br label %21
21: ; preds = %19, %15, %1
%22 = load i8*, i8** %5
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load i8*, i8** %5
%26 = load i8*, i8** %3
%27 = icmp ult i8* %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = load i8*, i8** %5
store i8* %29, i8** %3
br label %30
30: ; preds = %28, %24, %21
%31 = load i8*, i8** %6
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i8*, i8** %6
%35 = load i8*, i8** %3
%36 = icmp ult i8* %34, %35
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = load i8*, i8** %6
store i8* %38, i8** %3
br label %39
39: ; preds = %37, %33, %30
%40 = load i8*, i8** %3
%41 = icmp eq i8* %40, inttoptr (i64 -1 to i8*)
br i1 %41, label %42, label %43
42: ; preds = %39
store i8* null, i8** %3
br label %43
43: ; preds = %42, %39
%44 = load i8*, i8** %3
ret i8* %44
}

LLVM IR (-O2):
@.str = [3 x i8] c"//\00"
@.str.1 = [3 x i8] c"/*\00"
define i8* @vqec_config_find_comment_str(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 35)
%3 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%5 = ptrtoint i8* %2 to i64
switch i64 %5, label %6 [
i64 0, label %7
i64 -1, label %7
]
6: ; preds = %1
br label %7
7: ; preds = %1, %1, %6
%8 = phi i8* [ %2, %6 ], [ inttoptr (i64 -1 to i8*), %1 ], [ inttoptr (i64 -1 to i8*), %1 ]
%9 = icmp ne i8* %3, null
%10 = icmp ult i8* %3, %8
%11 = select i1 %9, i1 %10, i1 false
%12 = select i1 %11, i8* %3, i8* %8
%13 = icmp ne i8* %4, null
%14 = icmp ult i8* %4, %12
%15 = select i1 %13, i1 %14, i1 false
%16 = select i1 %15, i8* %4, i8* %12
%17 = icmp eq i8* %16, inttoptr (i64 -1 to i8*)
%18 = select i1 %17, i8* null, i8* %16
ret i8* %18
}