#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 */
int /*<<< orphan*/ exit(int);
int *findSubstring(char *, char **, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char *s = "wordgoodgoodgoodbestword";
  char *words[4];
  words[0] = "word";
  words[1] = "good";
  words[2] = "best";
  words[3] = "good";
  int returnSize;
  int *ret = findSubstring(s, words, 4, &returnSize);
  if (!(returnSize == 1)) {
    printf("assert fail: %s\n", "return size == 1");
    exit(-1);
  };
  if (!(ret[0] == 8)) {
    printf("assert fail: %s\n", "return 8");
    exit(-1);
  };
  printf("everything is fine!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xebc(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeb6(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xeb0(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xea0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x4,%edx
lea    -0x44(%rbp),%rcx
call   1030 <findSubstring@plt>
mov    %rax,-0x50(%rbp)
cmpl   $0x1,-0x44(%rbp)
je     11c0 <main+0x90>
lea    0xe7b(%rip),%rdi
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x50(%rbp),%rax
cmpl   $0x8,(%rax)
je     11ec <main+0xbc>
lea    0xe4f(%rip),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0xec9(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xec2(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xebb(%rip),%rcx
mov    %rcx,0x20(%rsp)
mov    %rax,0x28(%rsp)
lea    0xe8c(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rcx
mov    $0x4,%edx
call   1040 <findSubstring@plt>
cmpl   $0x1,0xc(%rsp)
jne    11a7 <main+0x67>
cmpl   $0x8,(%rax)
jne    11b7 <main+0x77>
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret
lea    0xe75(%rip),%rdi
lea    0xe7f(%rip),%rsi
jmp    11c5 <main+0x85>
lea    0xe65(%rip),%rdi
lea    0xe80(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"wordgoodgoodgoodbestword\00"
@.str.1 = [5 x i8] c"word\00"
@.str.2 = [5 x i8] c"good\00"
@.str.3 = [5 x i8] c"best\00"
@.str.4 = [17 x i8] c"assert fail: %s\0A\00"
@.str.5 = [17 x i8] c"return size == 1\00"
@.str.6 = [9 x i8] c"return 8\00"
@.str.7 = [21 x i8] c"everything is fine!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [4 x i8*]
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8** %6
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %13
%14 = load i8*, i8** %6
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
%16 = call i32* @findSubstring(i8* %14, i8** %15, i32 4, i32* %8)
store i32* %16, i32** %9
%17 = load i32, i32* %8
%18 = icmp eq i32 %17, 1
br i1 %18, label %22, label %19
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %2
%23 = load i32*, i32** %9
%24 = getelementptr inbounds i32, i32* %23, i64 0
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, 8
br i1 %26, label %30, label %27
27: ; preds = %22
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%29 = call i32 @exit(i32 -1)
unreachable
30: ; preds = %22
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"wordgoodgoodgoodbestword\00"
@.str.1 = [5 x i8] c"word\00"
@.str.2 = [5 x i8] c"good\00"
@.str.3 = [5 x i8] c"best\00"
@.str.4 = [17 x i8] c"assert fail: %s\0A\00"
@.str.5 = [17 x i8] c"return size == 1\00"
@.str.6 = [9 x i8] c"return 8\00"
@str = [20 x i8] c"everything is fine!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i8*]
%4 = alloca i32
%5 = bitcast [4 x i8*]* %3 to i8*
%6 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %9
%10 = bitcast i32* %4 to i8*
%11 = call i32* @findSubstring(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8** %6, i32 4, i32* %4)
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %2
%18 = load i32, i32* %11
%19 = icmp eq i32 %18, 8
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %17
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
ret i32 0
}