#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__ malloc(int);
int *numSmallerByFrequency(char **, int, char **, int, int *);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int queriesSize = 2;
  int wordsSize = 4;
  char **queries = (char **)malloc(sizeof(char *) * 2);
  char a[4] = "bbb";
  char b[3] = "cc";
  queries[0] = a;
  queries[1] = b;
  char **words = (char **)malloc(sizeof(char *) * 4);
  char c[2] = "a";
  char d[3] = "aa";
  char e[4] = "aaa";
  char f[5] = "aaaa";
  words[0] = c;
  words[1] = d;
  words[2] = e;
  words[3] = f;
  int ret_size = 0;
  int *ret =
      numSmallerByFrequency(queries, queriesSize, words, wordsSize, &ret_size);
  for (int i = 0; i < ret_size; i++)
    printf("len %d\n", ret[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x4,-0xc(%rbp)
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    0xe9f(%rip),%eax
mov    %eax,-0x1c(%rbp)
mov    0xe99(%rip),%ax
mov    %ax,-0x1f(%rbp)
mov    0xe91(%rip),%al
mov    %al,-0x1d(%rbp)
lea    -0x1c(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x1f(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    $0x20,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    0xe66(%rip),%ax
mov    %ax,-0x2a(%rbp)
mov    0xe5a(%rip),%ax
mov    %ax,-0x2d(%rbp)
mov    0xe52(%rip),%al
mov    %al,-0x2b(%rbp)
mov    0xe46(%rip),%eax
mov    %eax,-0x31(%rbp)
mov    0xe3c(%rip),%eax
mov    %eax,-0x36(%rbp)
mov    0xe37(%rip),%al
mov    %al,-0x32(%rbp)
lea    -0x2a(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x2d(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,0x8(%rax)
lea    -0x31(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,0x10(%rax)
lea    -0x36(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,0x18(%rax)
movl   $0x0,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    -0x3c(%rbp),%r8
call   1040 <numSmallerByFrequency@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1260 <main+0x130>
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdbf(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    122f <main+0xff>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movl   $0x626262,0x1c(%rsp)
movb   $0x0,0xe(%rsp)
movw   $0x6363,0xc(%rsp)
lea    0x1c(%rsp),%rax
mov    %rax,(%rbx)
lea    0xc(%rsp),%rax
mov    %rax,0x8(%rbx)
mov    $0x20,%edi
call   1050 <malloc@plt>
movw   $0x61,0xa(%rsp)
movb   $0x0,0x8(%rsp)
movw   $0x6161,0x6(%rsp)
movl   $0x616161,0x18(%rsp)
movb   $0x0,0x14(%rsp)
movl   $0x61616161,0x10(%rsp)
61
lea    0xa(%rsp),%rcx
mov    %rcx,(%rax)
lea    0x6(%rsp),%rcx
mov    %rcx,0x8(%rax)
lea    0x18(%rsp),%rcx
mov    %rcx,0x10(%rax)
lea    0x10(%rsp),%rcx
mov    %rcx,0x18(%rax)
movl   $0x0,(%rsp)
mov    %rsp,%r8
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %rax,%rdx
mov    $0x4,%ecx
call   1040 <numSmallerByFrequency@plt>
cmpl   $0x0,(%rsp)
jle    1219 <main+0xe9>
mov    %rax,%r15
xor    %ebx,%ebx
lea    0xe17(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
movslq (%rsp),%rax
cmp    %rax,%rbx
jl     1200 <main+0xd0>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.a = [4 x i8] c"bbb\00"
@__const.main.b = [3 x i8] c"cc\00"
@__const.main.c = [2 x i8] c"a\00"
@__const.main.d = [3 x i8] c"aa\00"
@__const.main.e = [4 x i8] c"aaa\00"
@__const.main.f = [5 x i8] c"aaaa\00"
@.str = [8 x i8] c"len %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [4 x i8]
%6 = alloca [3 x i8]
%7 = alloca i8**
%8 = alloca [2 x i8]
%9 = alloca [3 x i8]
%10 = alloca [4 x i8]
%11 = alloca [5 x i8]
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %2
store i32 4, i32* %3
%15 = call i64 @malloc(i32 16)
%16 = inttoptr i64 %15 to i8**
store i8** %16, i8*** %4
%17 = bitcast [4 x i8]* %5 to i8*
%18 = bitcast [3 x i8]* %6 to i8*
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%20 = load i8**, i8*** %4
%21 = getelementptr inbounds i8*, i8** %20, i64 0
store i8* %19, i8** %21
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%23 = load i8**, i8*** %4
%24 = getelementptr inbounds i8*, i8** %23, i64 1
store i8* %22, i8** %24
%25 = call i64 @malloc(i32 32)
%26 = inttoptr i64 %25 to i8**
store i8** %26, i8*** %7
%27 = bitcast [2 x i8]* %8 to i8*
%28 = bitcast [3 x i8]* %9 to i8*
%29 = bitcast [4 x i8]* %10 to i8*
%30 = bitcast [5 x i8]* %11 to i8*
%31 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%32 = load i8**, i8*** %7
%33 = getelementptr inbounds i8*, i8** %32, i64 0
store i8* %31, i8** %33
%34 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%35 = load i8**, i8*** %7
%36 = getelementptr inbounds i8*, i8** %35, i64 1
store i8* %34, i8** %36
%37 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%38 = load i8**, i8*** %7
%39 = getelementptr inbounds i8*, i8** %38, i64 2
store i8* %37, i8** %39
%40 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 0
%41 = load i8**, i8*** %7
%42 = getelementptr inbounds i8*, i8** %41, i64 3
store i8* %40, i8** %42
store i32 0, i32* %12
%43 = load i8**, i8*** %4
%44 = load i32, i32* %2
%45 = load i8**, i8*** %7
%46 = load i32, i32* %3
%47 = call i32* @numSmallerByFrequency(i8** %43, i32 %44, i8** %45, i32 %46, i32* %12)
store i32* %47, i32** %13
store i32 0, i32* %14
br label %48
48: ; preds = %59, %0
%49 = load i32, i32* %14
%50 = load i32, i32* %12
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %62
52: ; preds = %48
%53 = load i32*, i32** %13
%54 = load i32, i32* %14
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %53, i64 %55
%57 = load i32, i32* %56
%58 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %52
%60 = load i32, i32* %14
%61 = add nsw i32 %60, 1
store i32 %61, i32* %14
br label %48
62: ; preds = %48
ret i32 0
}

LLVM IR (-O2):
@__const.main.b = [3 x i8] c"cc\00"
@__const.main.d = [3 x i8] c"aa\00"
@__const.main.f = [5 x i8] c"aaaa\00"
@.str = [8 x i8] c"len %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8]
%3 = alloca i16
%4 = alloca [3 x i8]
%5 = alloca i32
%6 = alloca [5 x i8]
%7 = alloca i32
%8 = tail call i64 @malloc(i32 16)
%9 = inttoptr i64 %8 to i8**
%10 = bitcast i32* %1 to i8*
store i32 6447714, i32* %1
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%12 = inttoptr i64 %8 to i32**
store i32* %1, i32** %12
%13 = getelementptr inbounds i8*, i8** %9, i64 1
store i8* %11, i8** %13
%14 = call i64 @malloc(i32 32)
%15 = inttoptr i64 %14 to i8**
%16 = bitcast i16* %3 to i8*
store i16 97, i16* %3
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%18 = bitcast i32* %5 to i8*
store i32 6381921, i32* %5
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%20 = inttoptr i64 %14 to i16**
store i16* %3, i16** %20
%21 = getelementptr inbounds i8*, i8** %15, i64 1
store i8* %17, i8** %21
%22 = getelementptr inbounds i8*, i8** %15, i64 2
%23 = bitcast i8** %22 to i32**
store i32* %5, i32** %23
%24 = getelementptr inbounds i8*, i8** %15, i64 3
store i8* %19, i8** %24
%25 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%26 = call i32* @numSmallerByFrequency(i8** %9, i32 2, i8** %15, i32 4, i32* %7)
%27 = load i32, i32* %7
%28 = icmp sgt i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %30, %0
ret i32 0
30: ; preds = %0, %30
%31 = phi i64 [ %35, %30 ], [ 0, %0 ]
%32 = getelementptr inbounds i32, i32* %26, i64 %31
%33 = load i32, i32* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = add nuw nsw i64 %31, 1
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %35, %37
br i1 %38, label %30, label %29
}