#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__ calloc(int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
void getStringVector(char ***resultVector, int *sizeRes) {
  int i;
  *sizeRes = 12;
  *resultVector = (char **)malloc((*sizeRes) * sizeof(char *));
  for (i = 0; i < *sizeRes; i++) {
    char *pc = (char *)calloc(3, sizeof(char));
    sprintf(pc, "%d", i);
    (*resultVector)[i] = pc;
  }
}


x86 assembly (clang, -O0):
<getStringVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0xc,(%rax)
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    11c3 <getStringVector+0x93>
mov    $0x3,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe63(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116d <getStringVector+0x3d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getStringVector>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
movl   $0xc,(%rsi)
mov    $0x60,%edi
call   1040 <malloc@plt>
mov    %rax,(%r14)
cmpl   $0x0,(%r15)
jle    11a2 <getStringVector+0x72>
xor    %ebx,%ebx
lea    0xe9f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x3,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1050 <sprintf@plt>
mov    (%r14),%rax
mov    %r13,(%rax,%rbx,8)
add    $0x1,%rbx
movslq (%r15),%rax
cmp    %rax,%rbx
jl     1170 <getStringVector+0x40>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @getStringVector(i8*** %0, i32* %1) {
%3 = alloca i8***
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
store i8*** %0, i8**** %3
store i32* %1, i32** %4
%7 = load i32*, i32** %4
store i32 12, i32* %7
%8 = load i32*, i32** %4
%9 = load i32, i32* %8
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 8
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8**
%15 = load i8***, i8**** %3
store i8** %14, i8*** %15
store i32 0, i32* %5
br label %16
16: ; preds = %33, %2
%17 = load i32, i32* %5
%18 = load i32*, i32** %4
%19 = load i32, i32* %18
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %36
21: ; preds = %16
%22 = call i64 @calloc(i32 3, i32 1)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = load i32, i32* %5
%26 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i8*, i8** %6
%28 = load i8***, i8**** %3
%29 = load i8**, i8*** %28
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
store i8* %27, i8** %32
br label %33
33: ; preds = %21
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %16
36: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @getStringVector(i8*** nocapture %0, i32* nocapture %1) {
store i32 12, i32* %1
%3 = tail call i64 @malloc(i32 96)
%4 = inttoptr i64 %3 to i8**
store i8** %4, i8*** %0
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %2, %7
%8 = phi i64 [ %15, %7 ], [ 0, %2 ]
%9 = tail call i64 @calloc(i32 3, i32 1)
%10 = inttoptr i64 %9 to i8*
%11 = trunc i64 %8 to i32
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %10, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i8**, i8*** %0
%14 = getelementptr inbounds i8*, i8** %13, i64 %8
store i8* %10, i8** %14
%15 = add nuw nsw i64 %8, 1
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %7, label %19
19: ; preds = %7, %2
ret void
}