#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__ binaryStringSearch(char *, char **, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ realloc(char **, int);
char *reverseString(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int searchPalins(char ***words_p, int num_words, char ***palins_p,
                 int lines_allocated) {
  char **palins = *palins_p;
  char **words = *words_p;
  int n = 0;
  int i;
  for (i = 0; i < num_words; i++) {
    char *rWord = (char *)malloc(sizeof(char) * 30);
    if (rWord == NULL) {
      fprintf(stderr, "Out of memory.\n");
      exit(3);
    }
    strcpy(rWord, words[i]);
    rWord = reverseString(rWord);
    if (binaryStringSearch(rWord, words, num_words) != 0) {
      if (n >= lines_allocated) {
        int new_size;
        new_size = lines_allocated * 2;
        palins = (char **)realloc(palins, sizeof(char *) * new_size);
        if (palins == NULL) {
          fprintf(stderr, "Out of memory.\n");
          exit(3);
        }
        lines_allocated = new_size;
      }
      palins[n] = (char *)malloc(sizeof(char) * 30);
      if (palins[n] == NULL) {
        fprintf(stderr, "Out of memory.\n");
        exit(4);
      }
      strcpy(palins[n], words[i]);
      printf("%s\n", palins[n]);
      n++;
    }
  }
  *palins_p = palins;
  return n;
}


x86 assembly (clang, -O0):
<searchPalins>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1332 <searchPalins+0x1b2>
mov    $0x1e,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11fe <searchPalins+0x7e>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x3,%edi
call   1090 <exit@plt>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
mov    -0x40(%rbp),%rdi
call   10a0 <reverseString@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <binaryStringSearch@plt>
cmp    $0x0,%rax
je     131f <searchPalins+0x19f>
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     1296 <searchPalins+0x116>
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rdi
movslq -0x44(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1080 <realloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1290 <searchPalins+0x110>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
lea    0xd7f(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x3,%edi
call   1090 <exit@plt>
mov    -0x44(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x1e,%edi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    12e1 <searchPalins+0x161>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
lea    0xd2e(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x4,%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x30(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xcff(%rip),%rdi
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1324 <searchPalins+0x1a4>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11ba <searchPalins+0x3a>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x34(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<searchPalins>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,0x18(%rsp)
mov    (%rdx),%rax
mov    %rax,(%rsp)
test   %esi,%esi
jle    1291 <searchPalins+0x111>
mov    %ecx,%r13d
mov    %esi,%ebp
mov    (%rdi),%rax
mov    %rax,0x10(%rsp)
mov    %esi,%eax
mov    %rax,0x20(%rsp)
xor    %r15d,%r15d
xor    %r12d,%r12d
mov    %esi,0xc(%rsp)
jmp    11e2 <searchPalins+0x62>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%r12d
add    $0x1,%r15
cmp    %r15,0x20(%rsp)
je     1294 <searchPalins+0x114>
mov    %r12d,%ebx
mov    $0x1e,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     12b2 <searchPalins+0x132>
mov    %rax,%r14
mov    0x10(%rsp),%r12
mov    (%r12,%r15,8),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   10a0 <reverseString@plt>
mov    %rax,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1060 <binaryStringSearch@plt>
test   %rax,%rax
je     11d0 <searchPalins+0x50>
mov    %ebx,%r12d
cmp    %r13d,%ebx
jl     1249 <searchPalins+0xc9>
mov    %r13d,%esi
shl    $0x4,%esi
mov    (%rsp),%rdi
call   1080 <realloc@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     12b2 <searchPalins+0x132>
add    %r13d,%r13d
mov    $0x1e,%edi
call   1070 <malloc@plt>
movslq %r12d,%rbp
mov    (%rsp),%rbx
mov    %rax,(%rbx,%rbp,8)
test   %rax,%rax
je     12d1 <searchPalins+0x151>
mov    0x10(%rsp),%rcx
mov    (%rcx,%r15,8),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    (%rbx,%rbp,8),%rsi
lea    0xd91(%rip),%rdi
call   1040 <printf@plt>
add    $0x1,%r12d
mov    0xc(%rsp),%ebp
jmp    11d3 <searchPalins+0x53>
xor    %r12d,%r12d
mov    0x18(%rsp),%rax
mov    (%rsp),%rcx
mov    %rcx,(%rax)
mov    %r12d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
lea    0xd3e(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x3,%edi
call   1090 <exit@plt>
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
lea    0xd1f(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x4,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"Out of memory.\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @searchPalins(i8*** %0, i32 %1, i8*** %2, i32 %3) {
%5 = alloca i8***
%6 = alloca i32
%7 = alloca i8***
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
store i8*** %0, i8**** %5
store i32 %1, i32* %6
store i8*** %2, i8**** %7
store i32 %3, i32* %8
%15 = load i8***, i8**** %7
%16 = load i8**, i8*** %15
store i8** %16, i8*** %9
%17 = load i8***, i8**** %5
%18 = load i8**, i8*** %17
store i8** %18, i8*** %10
store i32 0, i32* %11
store i32 0, i32* %12
br label %19
19: ; preds = %107, %4
%20 = load i32, i32* %12
%21 = load i32, i32* %6
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %110
23: ; preds = %19
%24 = call i64 @malloc(i32 30)
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %13
%26 = load i8*, i8** %13
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @exit(i32 3)
unreachable
32: ; preds = %23
%33 = load i8*, i8** %13
%34 = load i8**, i8*** %10
%35 = load i32, i32* %12
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @strcpy(i8* %33, i8* %38)
%40 = load i8*, i8** %13
%41 = call i8* @reverseString(i8* %40)
store i8* %41, i8** %13
%42 = load i8*, i8** %13
%43 = load i8**, i8*** %10
%44 = load i32, i32* %6
%45 = call i64 @binaryStringSearch(i8* %42, i8** %43, i32 %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %106
47: ; preds = %32
%48 = load i32, i32* %11
%49 = load i32, i32* %8
%50 = icmp sge i32 %48, %49
br i1 %50, label %51, label %69
51: ; preds = %47
%52 = load i32, i32* %8
%53 = mul nsw i32 %52, 2
store i32 %53, i32* %14
%54 = load i8**, i8*** %9
%55 = load i32, i32* %14
%56 = sext i32 %55 to i64
%57 = mul i64 8, %56
%58 = trunc i64 %57 to i32
%59 = call i64 @realloc(i8** %54, i32 %58)
%60 = inttoptr i64 %59 to i8**
store i8** %60, i8*** %9
%61 = load i8**, i8*** %9
%62 = icmp eq i8** %61, null
br i1 %62, label %63, label %67
63: ; preds = %51
%64 = load i32, i32* @stderr
%65 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%66 = call i32 @exit(i32 3)
unreachable
67: ; preds = %51
%68 = load i32, i32* %14
store i32 %68, i32* %8
br label %69
69: ; preds = %67, %47
%70 = call i64 @malloc(i32 30)
%71 = inttoptr i64 %70 to i8*
%72 = load i8**, i8*** %9
%73 = load i32, i32* %11
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8*, i8** %72, i64 %74
store i8* %71, i8** %75
%76 = load i8**, i8*** %9
%77 = load i32, i32* %11
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8*, i8** %76, i64 %78
%80 = load i8*, i8** %79
%81 = icmp eq i8* %80, null
br i1 %81, label %82, label %86
82: ; preds = %69
%83 = load i32, i32* @stderr
%84 = call i32 @fprintf(i32 %83, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%85 = call i32 @exit(i32 4)
unreachable
86: ; preds = %69
%87 = load i8**, i8*** %9
%88 = load i32, i32* %11
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8*, i8** %87, i64 %89
%91 = load i8*, i8** %90
%92 = load i8**, i8*** %10
%93 = load i32, i32* %12
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8*, i8** %92, i64 %94
%96 = load i8*, i8** %95
%97 = call i32 @strcpy(i8* %91, i8* %96)
%98 = load i8**, i8*** %9
%99 = load i32, i32* %11
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8*, i8** %98, i64 %100
%102 = load i8*, i8** %101
%103 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %102)
%104 = load i32, i32* %11
%105 = add nsw i32 %104, 1
store i32 %105, i32* %11
br label %106
106: ; preds = %86, %32
br label %107
107: ; preds = %106
%108 = load i32, i32* %12
%109 = add nsw i32 %108, 1
store i32 %109, i32* %12
br label %19
110: ; preds = %19
%111 = load i8**, i8*** %9
%112 = load i8***, i8**** %7
store i8** %111, i8*** %112
%113 = load i32, i32* %11
ret i32 %113
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"Out of memory.\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @searchPalins(i8*** nocapture %0, i32 %1, i8*** nocapture %2, i32 %3) {
%5 = load i8**, i8*** %2
%6 = load i8**, i8*** %0
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %66
8: ; preds = %4
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %60
%11 = phi i64 [ 0, %8 ], [ %64, %60 ]
%12 = phi i32 [ %3, %8 ], [ %63, %60 ]
%13 = phi i32 [ 0, %8 ], [ %62, %60 ]
%14 = phi i8** [ %5, %8 ], [ %61, %60 ]
%15 = tail call i64 @malloc(i32 30)
%16 = inttoptr i64 %15 to i8*
%17 = icmp eq i64 %15, 0
br i1 %17, label %18, label %22
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%21 = tail call i32 @exit(i32 3)
unreachable
22: ; preds = %10
%23 = getelementptr inbounds i8*, i8** %6, i64 %11
%24 = load i8*, i8** %23
%25 = tail call i32 @strcpy(i8* %16, i8* %24)
%26 = tail call i8* @reverseString(i8* %16)
%27 = tail call i64 @binaryStringSearch(i8* %26, i8** %6, i32 %1)
%28 = icmp eq i64 %27, 0
br i1 %28, label %60, label %29
29: ; preds = %22
%30 = icmp slt i32 %13, %12
br i1 %30, label %42, label %31
31: ; preds = %29
%32 = shl i32 %12, 4
%33 = tail call i64 @realloc(i8** %14, i32 %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i32, i32* @stderr
%37 = tail call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%38 = tail call i32 @exit(i32 3)
unreachable
39: ; preds = %31
%40 = inttoptr i64 %33 to i8**
%41 = shl nsw i32 %12, 1
br label %42
42: ; preds = %39, %29
%43 = phi i8** [ %40, %39 ], [ %14, %29 ]
%44 = phi i32 [ %41, %39 ], [ %12, %29 ]
%45 = tail call i64 @malloc(i32 30)
%46 = inttoptr i64 %45 to i8*
%47 = sext i32 %13 to i64
%48 = getelementptr inbounds i8*, i8** %43, i64 %47
store i8* %46, i8** %48
%49 = icmp eq i64 %45, 0
br i1 %49, label %50, label %54
50: ; preds = %42
%51 = load i32, i32* @stderr
%52 = tail call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%53 = tail call i32 @exit(i32 4)
unreachable
54: ; preds = %42
%55 = load i8*, i8** %23
%56 = tail call i32 @strcpy(i8* %46, i8* %55)
%57 = load i8*, i8** %48
%58 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %57)
%59 = add nsw i32 %13, 1
br label %60
60: ; preds = %54, %22
%61 = phi i8** [ %43, %54 ], [ %14, %22 ]
%62 = phi i32 [ %59, %54 ], [ %13, %22 ]
%63 = phi i32 [ %44, %54 ], [ %12, %22 ]
%64 = add nuw nsw i64 %11, 1
%65 = icmp eq i64 %64, %9
br i1 %65, label %66, label %10
66: ; preds = %60, %4
%67 = phi i8** [ %5, %4 ], [ %61, %60 ]
%68 = phi i32 [ 0, %4 ], [ %62, %60 ]
store i8** %67, i8*** %2
ret i32 %68
}