#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 count_fucks(int argc, char **argv) {
  int i;
  int count = 1;
  for (i = 1; i < argc; i++) {
    char *slice = argv[i];
    while (slice = strstr(slice, "fuck\0")) {
      slice += 5;
      count += 1;
    }
  }
  return count;
}


x86 assembly (clang, -O0):
<count_fucks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1194 <count_fucks+0x84>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1181 <count_fucks+0x71>
mov    -0x20(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1149 <count_fucks+0x39>
jmp    1186 <count_fucks+0x76>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <count_fucks+0x1d>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_fucks>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%ebp
cmp    $0x2,%edi
jl     1169 <count_fucks+0x59>
mov    %rsi,%r14
mov    %edi,%r15d
mov    $0x1,%ebp
mov    $0x1,%r12d
lea    0xec6(%rip),%rbx
jmp    1149 <count_fucks+0x39>
nopl   0x0(%rax)
add    $0x1,%r12
cmp    %r15,%r12
je     1169 <count_fucks+0x59>
mov    (%r14,%r12,8),%rdi
nopl   (%rax)
mov    %rbx,%rsi
call   1030 <strstr@plt>
test   %rax,%rax
je     1140 <count_fucks+0x30>
add    $0x5,%rax
add    $0x1,%ebp
mov    %rax,%rdi
jmp    1150 <count_fucks+0x40>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"fuck\00\00"
define i32 @count_fucks(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 1, i32* %6
store i32 1, i32* %5
br label %8
8: ; preds = %28, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %31
12: ; preds = %8
%13 = load i8**, i8*** %4
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
store i8* %17, i8** %7
br label %18
18: ; preds = %22, %12
%19 = load i8*, i8** %7
%20 = call i8* @strstr(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %7
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = load i8*, i8** %7
%24 = getelementptr inbounds i8, i8* %23, i64 5
store i8* %24, i8** %7
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %18
27: ; preds = %18
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %8
31: ; preds = %8
%32 = load i32, i32* %6
ret i32 %32
}

LLVM IR (-O2):
@.str = [6 x i8] c"fuck\00\00"
define i32 @count_fucks(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %24
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %20
%7 = phi i64 [ 1, %4 ], [ %22, %20 ]
%8 = phi i32 [ 1, %4 ], [ %21, %20 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %7
%10 = load i8*, i8** %9
%11 = tail call i8* @strstr(i8* dereferenceable(1) %10, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %20, label %13
13: ; preds = %6, %13
%14 = phi i8* [ %18, %13 ], [ %11, %6 ]
%15 = phi i32 [ %17, %13 ], [ %8, %6 ]
%16 = getelementptr inbounds i8, i8* %14, i64 5
%17 = add nsw i32 %15, 1
%18 = tail call i8* @strstr(i8* dereferenceable(1) %16, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %13
20: ; preds = %13, %6
%21 = phi i32 [ %8, %6 ], [ %17, %13 ]
%22 = add nuw nsw i64 %7, 1
%23 = icmp eq i64 %22, %5
br i1 %23, label %24, label %6
24: ; preds = %20, %2
%25 = phi i32 [ 1, %2 ], [ %21, %20 ]
ret i32 %25
}