int main(int argc, char *argv[]) {
  char s[] = {"aaaaaaaa"};
  char *words[] = {"aa", "aa", "aa"};
  int size = 0;
  int *ret = findSubstring(s, words, 3, &size);
  int i;
  for (i = 0; i < size; i++)
    printf("%d\n", ret[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x19(%rbp)
mov    0xec1(%rip),%al
mov    %al,-0x11(%rbp)
mov    0x2caf(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2cac(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2ca9(%rip),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x44(%rbp)
lea    -0x19(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x3,%edx
lea    -0x44(%rbp),%rcx
mov    $0x0,%al
call   1030 <findSubstring@plt>
cltq
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    11ca <main+0xaa>
mov    -0x50(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1197 <main+0x77>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movabs $0x6161616161616161,%rax
61 61 61
mov    %rax,0x10(%rsp)
movb   $0x0,0x18(%rsp)
mov    0x2ccc(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0x2cb0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0x20(%rsp),%rsi
lea    0xc(%rsp),%rcx
mov    $0x3,%edx
xor    %eax,%eax
call   1030 <findSubstring@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ac <main+0x8c>
movslq %eax,%r15
lea    0xe80(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1190 <main+0x70>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.s = [9 x i8] c"aaaaaaaa\00"
@.str = [3 x i8] c"aa\00"
@__const.main.words = [3 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0)]
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [9 x i8]
%4 = alloca [3 x i8*]
%5 = alloca i32
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%7 = bitcast [3 x i8*]* %4 to i8*
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%9 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
%10 = call i32 (i8*, i8**, i32, i32*, ...) bitcast (i32 (...)* @findSubstring to i32 (i8*, i8**, i32, i32*, ...)*)(i8* %6, i8** %9, i32 3, i32* %5)
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i32*
%13 = load i32, i32* %5
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %2, %15
%16 = phi i64 [ %20, %15 ], [ 0, %2 ]
%17 = getelementptr inbounds i32, i32* %12, i64 %16
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i64 %16, 1
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %15, label %24
24: ; preds = %15, %2
ret i32 0
}