#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 */
typedef int /*<<< orphan*/ ITEM;

/* Variables and functions */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ *new_item(char *, int /*<<< orphan*/ *);
ITEM **load_item_array(char **choices, int nr_of_choices) {
  ITEM **my_items;
  int i;
  my_items = (ITEM **)calloc(nr_of_choices + 1, sizeof(ITEM *));
  for (i = 0; i < nr_of_choices; ++i) {
    my_items[i] = new_item(choices[i + 1], NULL);
  }
  my_items[nr_of_choices] = (ITEM *)NULL;
  return my_items;
}


x86 assembly (clang, -O0):
<load_item_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118d <load_item_array+0x6d>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <new_item@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <load_item_array+0x2a>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_item_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
lea    0x1(%r14),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%r12
test   %r14d,%r14d
jle    116c <load_item_array+0x4c>
mov    %r14d,%r13d
xor    %ebx,%ebx
nopl   0x0(%rax)
lea    0x1(%rbx),%rbp
mov    0x8(%r15,%rbx,8),%rdi
xor    %esi,%esi
call   1040 <new_item@plt>
mov    %rax,(%r12,%rbx,8)
mov    %rbp,%rbx
cmp    %rbp,%r13
jne    1150 <load_item_array+0x30>
movslq %r14d,%rax
movq   $0x0,(%r12,%rax,8)
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32** @load_item_array(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32**
%6 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = add nsw i32 %7, 1
%9 = call i64 @calloc(i32 %8, i32 8)
%10 = inttoptr i64 %9 to i32**
store i32** %10, i32*** %5
store i32 0, i32* %6
br label %11
11: ; preds = %27, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = load i8**, i8*** %3
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %16, i64 %19
%21 = load i8*, i8** %20
%22 = call i32* @new_item(i8* %21, i32* null)
%23 = load i32**, i32*** %5
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32*, i32** %23, i64 %25
store i32* %22, i32** %26
br label %27
27: ; preds = %15
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %11
30: ; preds = %11
%31 = load i32**, i32*** %5
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32*, i32** %31, i64 %33
store i32* null, i32** %34
%35 = load i32**, i32*** %5
ret i32** %35
}

LLVM IR (-O2):
define i32** @load_item_array(i8** nocapture %0, i32 %1) {
%3 = add nsw i32 %1, 1
%4 = tail call i64 @calloc(i32 %3, i32 8)
%5 = inttoptr i64 %4 to i32**
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %17
7: ; preds = %2
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %11, %9 ]
%11 = add nuw nsw i64 %10, 1
%12 = getelementptr inbounds i8*, i8** %0, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i32* @new_item(i8* %13, i32* null)
%15 = getelementptr inbounds i32*, i32** %5, i64 %10
store i32* %14, i32** %15
%16 = icmp eq i64 %11, %8
br i1 %16, label %17, label %9
17: ; preds = %9, %2
%18 = sext i32 %1 to i64
%19 = getelementptr inbounds i32*, i32** %5, i64 %18
store i32* null, i32** %19
ret i32** %5
}