#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 */
scalar_t__ calloc(int, int);
int wordInRow(char *);
char **findWords(char **words, int wordSizes, int *returnSize, int *errorCode) {
  char **results = (char **)calloc(*returnSize, sizeof(char *));
  int resultCounter = 0;
  for (int i = 0; i < wordSizes; i++) {
    if (wordInRow(words[i]) == 1) {
      results[i] = words[i];
      resultCounter++;
    }
  }
  return results;
}


x86 assembly (clang, -O0):
<findWords>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b3 <findWords+0x93>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <wordInRow@plt>
cmp    $0x1,%eax
jne    11a0 <findWords+0x80>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a5 <findWords+0x85>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1159 <findWords+0x39>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findWords>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    (%rdx),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
test   %ebp,%ebp
jle    1171 <findWords+0x51>
mov    %ebp,%r15d
xor    %ebp,%ebp
jmp    1159 <findWords+0x39>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r15
je     1171 <findWords+0x51>
mov    (%rbx,%rbp,8),%rdi
call   1030 <wordInRow@plt>
cmp    $0x1,%eax
jne    1150 <findWords+0x30>
mov    (%rbx,%rbp,8),%rax
mov    %rax,(%r14,%rbp,8)
jmp    1150 <findWords+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @findWords(i8** %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
store i8** %0, i8*** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%12 = load i32*, i32** %7
%13 = load i32, i32* %12
%14 = call i64 @calloc(i32 %13, i32 8)
%15 = inttoptr i64 %14 to i8**
store i8** %15, i8*** %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %16
16: ; preds = %41, %4
%17 = load i32, i32* %11
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %44
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = load i32, i32* %11
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @wordInRow(i8* %25)
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %40
28: ; preds = %20
%29 = load i8**, i8*** %5
%30 = load i32, i32* %11
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = load i8**, i8*** %9
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
store i8* %33, i8** %37
%38 = load i32, i32* %10
%39 = add nsw i32 %38, 1
store i32 %39, i32* %10
br label %40
40: ; preds = %28, %20
br label %41
41: ; preds = %40
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %16
44: ; preds = %16
%45 = load i8**, i8*** %9
ret i8** %45
}

LLVM IR (-O2):
define i8** @findWords(i8** nocapture %0, i32 %1, i32* nocapture %2, i32* nocapture readnone %3) {
%5 = load i32, i32* %2
%6 = tail call i64 @calloc(i32 %5, i32 8)
%7 = inttoptr i64 %6 to i8**
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = zext i32 %1 to i64
br label %12
11: ; preds = %21, %4
ret i8** %7
12: ; preds = %9, %21
%13 = phi i64 [ 0, %9 ], [ %22, %21 ]
%14 = getelementptr inbounds i8*, i8** %0, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 @wordInRow(i8* %15)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i8*, i8** %14
%20 = getelementptr inbounds i8*, i8** %7, i64 %13
store i8* %19, i8** %20
br label %21
21: ; preds = %12, %18
%22 = add nuw nsw i64 %13, 1
%23 = icmp eq i64 %22, %10
br i1 %23, label %11, label %12
}