#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 *);
int /*<<< orphan*/ ptrcreation(char **, char *, char *, char *, char *, char *);
int main(int argc, char **argv) {
  char *arr1 = (char *)malloc(100);
  char *arr2 = (char *)malloc(110);
  char *arr3 = (char *)malloc(120);
  char *arr4 = (char *)malloc(130);
  char *arr5 = (char *)malloc(140);
  char **ptrs = (char **)malloc(128 * 1024 * 1024 * sizeof(char *));
  ptrcreation(ptrs, arr1, arr2, arr3, arr4, arr5);
  printf("r = %hd\n", ptrs[0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x64,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x6e,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x78,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x82,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x8c,%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x40000000,%edi
call   1050 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
call   1030 <ptrcreation@plt>
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x64,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x6e,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    $0x78,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    $0x82,%edi
call   1050 <malloc@plt>
mov    %rax,%r13
mov    $0x8c,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0x40000000,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %rbx,%r9
call   1030 <ptrcreation@plt>
mov    0x0(%rbp),%rsi
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"r = %hd\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i64 @malloc(i32 100)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %6
%14 = call i64 @malloc(i32 110)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %7
%16 = call i64 @malloc(i32 120)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %8
%18 = call i64 @malloc(i32 130)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %9
%20 = call i64 @malloc(i32 140)
%21 = inttoptr i64 %20 to i8*
store i8* %21, i8** %10
%22 = call i64 @malloc(i32 1073741824)
%23 = inttoptr i64 %22 to i8**
store i8** %23, i8*** %11
%24 = load i8**, i8*** %11
%25 = load i8*, i8** %6
%26 = load i8*, i8** %7
%27 = load i8*, i8** %8
%28 = load i8*, i8** %9
%29 = load i8*, i8** %10
%30 = call i32 @ptrcreation(i8** %24, i8* %25, i8* %26, i8* %27, i8* %28, i8* %29)
%31 = load i8**, i8*** %11
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"r = %hd\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 100)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i64 @malloc(i32 110)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i64 @malloc(i32 120)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i64 @malloc(i32 130)
%10 = inttoptr i64 %9 to i8*
%11 = tail call i64 @malloc(i32 140)
%12 = inttoptr i64 %11 to i8*
%13 = tail call i64 @malloc(i32 1073741824)
%14 = inttoptr i64 %13 to i8**
%15 = tail call i32 @ptrcreation(i8** %14, i8* %4, i8* %6, i8* %8, i8* %10, i8* %12)
%16 = load i8*, i8** %14
%17 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %16)
ret i32 0
}