#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*/ printf(char *, ...);
char ***suggestedProducts(char **, int, char *, int *, int **);
int main() {
  char *pro[5] = {"mobile", "mouse", "moneypot", "monitor", "mousepad"};
  int size = 5;
  char *search = "mouse";
  int rs = 0;
  int *rcs = NULL;
  char ***ret = suggestedProducts(pro, size, search, &rs, &rcs);
  for (int i = 0; i < rs; i++) {
    for (int j = 0; j < rcs[i]; j++)
      printf("%s\n", ret[i][j]);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xeaa(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xea6(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xea1(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe9f(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe9c(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x5,-0x34(%rbp)
lea    0xe73(%rip),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x40(%rbp),%rdx
lea    -0x44(%rbp),%rcx
lea    -0x50(%rbp),%r8
call   1050 <suggestedProducts@plt>
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    123d <main+0x10d>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    -0x50(%rbp),%rcx
movslq -0x5c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1221 <main+0xf1>
mov    -0x58(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x60(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    11dd <main+0xad>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11ca <main+0x9a>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xec0(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xebb(%rip),%rdx
mov    %rdx,0x18(%rsp)
lea    0xeb5(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xeb2(%rip),%rax
mov    %rax,0x28(%rsp)
lea    0xeae(%rip),%rax
mov    %rax,0x30(%rsp)
movl   $0x0,0x4(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rdi
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    $0x5,%esi
call   1050 <suggestedProducts@plt>
cmpl   $0x0,0x4(%rsp)
jle    1201 <main+0xd1>
mov    %rax,%r14
xor    %r15d,%r15d
jmp    11c8 <main+0x98>
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
movslq 0x4(%rsp),%rax
cmp    %rax,%r15
jge    1201 <main+0xd1>
mov    0x8(%rsp),%rax
cmpl   $0x0,(%rax,%r15,4)
jle    11b0 <main+0x80>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%r15,8),%rax
mov    (%rax,%rbx,8),%rdi
call   1040 <puts@plt>
add    $0x1,%rbx
mov    0x8(%rsp),%rax
movslq (%rax,%r15,4),%rax
cmp    %rax,%rbx
jl     11e0 <main+0xb0>
jmp    11b0 <main+0x80>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"mobile\00"
@.str.1 = [6 x i8] c"mouse\00"
@.str.2 = [9 x i8] c"moneypot\00"
@.str.3 = [8 x i8] c"monitor\00"
@.str.4 = [9 x i8] c"mousepad\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8*]
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8***
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = bitcast [5 x i8*]* %2 to i8*
%11 = bitcast i8* %10 to [5 x i8*]*
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8** %15
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 4
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i32 0, i32 0), i8** %16
store i32 5, i32* %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %4
store i32 0, i32* %5
store i32* null, i32** %6
%17 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
%18 = load i32, i32* %3
%19 = load i8*, i8** %4
%20 = call i8*** @suggestedProducts(i8** %17, i32 %18, i8* %19, i32* %5, i32** %6)
store i8*** %20, i8**** %7
store i32 0, i32* %8
br label %21
21: ; preds = %50, %0
%22 = load i32, i32* %8
%23 = load i32, i32* %5
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %53
25: ; preds = %21
store i32 0, i32* %9
br label %26
26: ; preds = %45, %25
%27 = load i32, i32* %9
%28 = load i32*, i32** %6
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i32, i32* %31
%33 = icmp slt i32 %27, %32
br i1 %33, label %34, label %48
34: ; preds = %26
%35 = load i8***, i8**** %7
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8**, i8*** %35, i64 %37
%39 = load i8**, i8*** %38
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %34
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %26
48: ; preds = %26
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %50
50: ; preds = %48
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
store i32 %52, i32* %8
br label %21
53: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"mobile\00"
@.str.1 = [6 x i8] c"mouse\00"
@.str.2 = [9 x i8] c"moneypot\00"
@.str.3 = [8 x i8] c"monitor\00"
@.str.4 = [9 x i8] c"mousepad\00"
define i32 @main() {
%1 = alloca [5 x i8*]
%2 = alloca i32
%3 = alloca i32*
%4 = bitcast [5 x i8*]* %1 to i8*
%5 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 4
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8** %9
%10 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%11 = bitcast i32** %3 to i8*
store i32* null, i32** %3
%12 = call i8*** @suggestedProducts(i8** %5, i32 5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32** %3)
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %0, %24
%16 = phi i64 [ %26, %24 ], [ 0, %0 ]
%17 = load i32*, i32** %3
%18 = getelementptr inbounds i32, i32* %17, i64 %16
%19 = load i32, i32* %18
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = getelementptr inbounds i8**, i8*** %12, i64 %16
br label %30
23: ; preds = %24, %0
ret i32 0
24: ; preds = %30, %15
%25 = call i32 @putchar(i32 10)
%26 = add nuw nsw i64 %16, 1
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = icmp slt i64 %26, %28
br i1 %29, label %15, label %23
30: ; preds = %21, %30
%31 = phi i64 [ 0, %21 ], [ %36, %30 ]
%32 = load i8**, i8*** %22
%33 = getelementptr inbounds i8*, i8** %32, i64 %31
%34 = load i8*, i8** %33
%35 = call i32 @puts(i8* dereferenceable(1) %34)
%36 = add nuw nsw i64 %31, 1
%37 = load i32*, i32** %3
%38 = getelementptr inbounds i32, i32* %37, i64 %16
%39 = load i32, i32* %38
%40 = sext i32 %39 to i64
%41 = icmp slt i64 %36, %40
br i1 %41, label %30, label %24
}