#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*/ free_memory(char ***, int);
int /*<<< orphan*/ get_memory(char ***, int);
int /*<<< orphan*/ printf(char *, char *);
void main() {
  char **ptr = NULL;
  int num = 5;
  int i;
  get_memory(&ptr, num);
  for (i = 0; i < num; i++)
    printf("%s\n", ptr[i]);
  free_memory(&ptr, num);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    -0x8(%rbp),%rdi
call   1040 <get_memory@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118c <main+0x5c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115a <main+0x2a>
mov    -0xc(%rbp),%esi
lea    -0x8(%rbp),%rdi
call   1050 <free_memory@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movq   $0x0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x5,%esi
call   1040 <get_memory@plt>
mov    (%rsp),%rax
mov    (%rax),%rsi
lea    0xea6(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%rsp),%rax
mov    0x8(%rax),%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%rsp),%rax
mov    0x10(%rax),%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%rsp),%rax
mov    0x18(%rax),%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%rsp),%rax
mov    0x20(%rax),%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
call   1050 <free_memory@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @main() {
%1 = alloca i8**
%2 = alloca i32
%3 = alloca i32
store i8** null, i8*** %1
store i32 5, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @get_memory(i8*** %1, i32 %4)
store i32 0, i32* %3
br label %6
6: ; preds = %17, %0
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i8**, i8*** %1
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %11, i64 %13
%15 = load i8*, i8** %14
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %10
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %6
20: ; preds = %6
%21 = load i32, i32* %2
%22 = call i32 @free_memory(i8*** %1, i32 %21)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @main() {
%1 = alloca i8**
%2 = bitcast i8*** %1 to i8*
store i8** null, i8*** %1
%3 = call i32 @get_memory(i8*** %1, i32 5)
%4 = load i8**, i8*** %1
%5 = load i8*, i8** %4
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i8**, i8*** %1
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8**, i8*** %1
%12 = getelementptr inbounds i8*, i8** %11, i64 2
%13 = load i8*, i8** %12
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8**, i8*** %1
%16 = getelementptr inbounds i8*, i8** %15, i64 3
%17 = load i8*, i8** %16
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i8**, i8*** %1
%20 = getelementptr inbounds i8*, i8** %19, i64 4
%21 = load i8*, i8** %20
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @free_memory(i8*** %1, i32 5)
ret void
}