#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 /*<<< orphan*/ printf(char *, char *);
char *test(char **, int, char *);
int main() {
  char **dic = (char **)malloc(sizeof(char *) * 3);
  dic[0] = "cat";
  dic[1] = "bat";
  dic[2] = "rat";
  int size = 3;
  char *sen = "the cattle was rattled by the battery";
  char *ret = test(dic, size, sen);
  printf("%s\n", ret);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    0xea8(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
lea    0xe9e(%rip),%rcx
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
lea    0xe93(%rip),%rcx
mov    %rcx,0x10(%rax)
movl   $0x3,-0x14(%rbp)
lea    0xe85(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1050 <test@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x18,%edi
call   1040 <malloc@plt>
lea    0xebe(%rip),%rcx
mov    %rcx,(%rax)
lea    0xeb8(%rip),%rcx
mov    %rcx,0x8(%rax)
lea    0xeb1(%rip),%rcx
mov    %rcx,0x10(%rax)
lea    0xeaa(%rip),%rdx
mov    %rax,%rdi
mov    $0x3,%esi
call   1050 <test@plt>
lea    0xebc(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"cat\00"
@.str.1 = [4 x i8] c"bat\00"
@.str.2 = [4 x i8] c"rat\00"
@.str.3 = [38 x i8] c"the cattle was rattled by the battery\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i64 @malloc(i32 24)
%7 = inttoptr i64 %6 to i8**
store i8** %7, i8*** %2
%8 = load i8**, i8*** %2
%9 = getelementptr inbounds i8*, i8** %8, i64 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = load i8**, i8*** %2
%11 = getelementptr inbounds i8*, i8** %10, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %11
%12 = load i8**, i8*** %2
%13 = getelementptr inbounds i8*, i8** %12, i64 2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %13
store i32 3, i32* %3
store i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8** %4
%14 = load i8**, i8*** %2
%15 = load i32, i32* %3
%16 = load i8*, i8** %4
%17 = call i8* @test(i8** %14, i32 %15, i8* %16)
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"cat\00"
@.str.1 = [4 x i8] c"bat\00"
@.str.2 = [4 x i8] c"rat\00"
@.str.3 = [38 x i8] c"the cattle was rattled by the battery\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 24)
%2 = inttoptr i64 %1 to i8**
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = getelementptr inbounds i8*, i8** %2, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %3
%4 = getelementptr inbounds i8*, i8** %2, i64 2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %4
%5 = tail call i8* @test(i8** %2, i32 3, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %5)
ret i32 0
}