#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 */
typedef int int64_t;

/* Variables and functions */
scalar_t__ strncmp(char *, char const *, int);
char *strstr(char const *, char *);
int utf8_strlen_until_trailing_whitespace(char const *);
int64_t match_c_multiline_comment(const char *str) {
  if (strncmp("/*", str, 2) == 0) {
    char *matching_comment = strstr(str, "*/");
    if (matching_comment)
      return (matching_comment - str);
    return utf8_strlen_until_trailing_whitespace(str);
  }
  return 0;
}


x86 assembly (clang, -O0):
<match_c_multiline_comment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    119e <match_c_multiline_comment+0x6e>
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118d <match_c_multiline_comment+0x5d>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
jmp    11a5 <match_c_multiline_comment+0x75>
mov    -0x10(%rbp),%rdi
call   1040 <utf8_strlen_until_trailing_whitespace@plt>
mov    %eax,-0x4(%rbp)
jmp    11a5 <match_c_multiline_comment+0x75>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_c_multiline_comment>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     1154 <match_c_multiline_comment+0x24>
pop    %rbx
ret
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     116c <match_c_multiline_comment+0x3c>
sub    %ebx,%eax
pop    %rbx
ret
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <utf8_strlen_until_trailing_whitespace@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"/*\00"
@.str.1 = [3 x i8] c"*/\00"
define i32 @match_c_multiline_comment(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5, i32 2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %23
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i8* @strstr(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = load i8*, i8** %4
%15 = load i8*, i8** %3
%16 = ptrtoint i8* %14 to i64
%17 = ptrtoint i8* %15 to i64
%18 = sub i64 %16, %17
%19 = trunc i64 %18 to i32
store i32 %19, i32* %2
br label %24
20: ; preds = %8
%21 = load i8*, i8** %3
%22 = call i32 @utf8_strlen_until_trailing_whitespace(i8* %21)
store i32 %22, i32* %2
br label %24
23: ; preds = %1
store i32 0, i32* %2
br label %24
24: ; preds = %23, %20, %13
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"/*\00"
@.str.1 = [3 x i8] c"*/\00"
define i32 @match_c_multiline_comment(i8* %0) {
%2 = tail call i64 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0, i32 2)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = 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))
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = ptrtoint i8* %5 to i64
%9 = ptrtoint i8* %0 to i64
%10 = sub i64 %8, %9
%11 = trunc i64 %10 to i32
br label %14
12: ; preds = %4
%13 = tail call i32 @utf8_strlen_until_trailing_whitespace(i8* %0)
br label %14
14: ; preds = %1, %7, %12
%15 = phi i32 [ %11, %7 ], [ %13, %12 ], [ 0, %1 ]
ret i32 %15
}