#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 *calloc(int, unsigned int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ outArrInt(int *, unsigned int);
int /*<<< orphan*/ outArrStr(char **, unsigned int);
void testArrayPrint() {
  unsigned n = 5;
  int *xs = calloc(sizeof(int), n);
  for (unsigned i = 0; i < n; i++)
    xs[i] = i + 1;
  outArrInt(xs, n);
  char *css[] = {"he", "hell", "hello", "helium", "helios"};
  outArrStr(css, n);
  free(xs);
}


x86 assembly (clang, -O0):
<testArrayPrint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x5,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x4,%edi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    11a1 <testArrayPrint+0x51>
mov    -0x14(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1177 <testArrayPrint+0x27>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1070 <outArrInt@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xe3c(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe34(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe2e(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe29(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe25(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1060 <outArrStr@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testArrayPrint>:
push   %rbx
sub    $0x30,%rsp
mov    $0x4,%edi
mov    $0x5,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
movaps 0xea2(%rip),%xmm0
movups %xmm0,(%rax)
movl   $0x5,0x10(%rax)
mov    %rax,%rdi
mov    $0x5,%esi
call   1060 <outArrInt@plt>
lea    0xe94(%rip),%rax
mov    %rax,(%rsp)
lea    0xe8c(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xe85(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xe7f(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xe7a(%rip),%rax
mov    %rax,0x20(%rsp)
mov    %rsp,%rdi
mov    $0x5,%esi
call   1050 <outArrStr@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"he\00"
@.str.1 = [5 x i8] c"hell\00"
@.str.2 = [6 x i8] c"hello\00"
@.str.3 = [7 x i8] c"helium\00"
@.str.4 = [7 x i8] c"helios\00"
define void @testArrayPrint() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [5 x i8*]
store i32 5, i32* %1
%5 = load i32, i32* %1
%6 = call i32* @calloc(i32 4, i32 %5)
store i32* %6, i32** %2
store i32 0, i32* %3
br label %7
7: ; preds = %18, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %1
%10 = icmp ult i32 %8, %9
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i32, i32* %3
%13 = add i32 %12, 1
%14 = load i32*, i32** %2
%15 = load i32, i32* %3
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
store i32 %13, i32* %17
br label %18
18: ; preds = %11
%19 = load i32, i32* %3
%20 = add i32 %19, 1
store i32 %20, i32* %3
br label %7
21: ; preds = %7
%22 = load i32*, i32** %2
%23 = load i32, i32* %1
%24 = call i32 @outArrInt(i32* %22, i32 %23)
%25 = bitcast [5 x i8*]* %4 to i8*
%26 = bitcast i8* %25 to [5 x i8*]*
%27 = getelementptr inbounds [5 x i8*], [5 x i8*]* %26, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %27
%28 = getelementptr inbounds [5 x i8*], [5 x i8*]* %26, i32 0, i32 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8** %28
%29 = getelementptr inbounds [5 x i8*], [5 x i8*]* %26, i32 0, i32 2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8** %29
%30 = getelementptr inbounds [5 x i8*], [5 x i8*]* %26, i32 0, i32 3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8** %30
%31 = getelementptr inbounds [5 x i8*], [5 x i8*]* %26, i32 0, i32 4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8** %31
%32 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 0
%33 = load i32, i32* %1
%34 = call i32 @outArrStr(i8** %32, i32 %33)
%35 = load i32*, i32** %2
%36 = call i32 @free(i32* %35)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"he\00"
@.str.1 = [5 x i8] c"hell\00"
@.str.2 = [6 x i8] c"hello\00"
@.str.3 = [7 x i8] c"helium\00"
@.str.4 = [7 x i8] c"helios\00"
define void @testArrayPrint() {
%1 = alloca [5 x i8*]
%2 = tail call i32* @calloc(i32 4, i32 5)
%3 = bitcast i32* %2 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %3
%4 = getelementptr inbounds i32, i32* %2, i64 4
store i32 5, i32* %4
%5 = tail call i32 @outArrInt(i32* %2, i32 5)
%6 = bitcast [5 x i8*]* %1 to i8*
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %11
%12 = call i32 @outArrStr(i8** %7, i32 5)
%13 = call i32 @free(i32* %2)
ret void
}