#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 *strstr(char *, char *);
int forum_parse(char *data, unsigned n) {
  char *s;
  data[n - 1] = 0;
  n = 0;
  s = data;
  while ((s = strstr(s, "javascript:foro"))) {
    s += sizeof("javascript:foro");
    n++;
  }
  return n;
}


x86 assembly (clang, -O0):
<forum_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1176 <forum_parse+0x66>
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113e <forum_parse+0x2e>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<forum_parse>:
push   %r14
push   %rbx
push   %rax
add    $0xffffffff,%esi
movb   $0x0,(%rdi,%rsi,1)
lea    0xede(%rip),%rsi
call   1030 <strstr@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1157 <forum_parse+0x47>
lea    0xecb(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x10,%rax
add    $0x1,%ebx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strstr@plt>
test   %rax,%rax
jne    1140 <forum_parse+0x30>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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