#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);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
void alloc_samples_array(long unsigned *samples_array[48]) {
  int i;
  for (i = 0; i < 48; i++) {
    samples_array[i] =
        (long unsigned *)calloc(1000000, sizeof(**samples_array));
    if (!samples_array[i]) {
      fprintf(stderr, "calloc(): %s\n", strerror(errno));
      exit(1);
    }
  }
}


x86 assembly (clang, -O0):
<alloc_samples_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x30,-0xc(%rbp)
jge    11d7 <alloc_samples_array+0x97>
mov    $0xf4240,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11c4 <alloc_samples_array+0x84>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x10(%rbp),%edi
mov    %rax,%rdx
lea    0xe4b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11c9 <alloc_samples_array+0x89>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1153 <alloc_samples_array+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_samples_array>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    $0xf4240,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,(%r14,%rbx,8)
test   %rax,%rax
je     117a <alloc_samples_array+0x3a>
add    $0x1,%rbx
cmp    $0x30,%rbx
jne    1150 <alloc_samples_array+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e5f(%rip),%rax
mov    (%rax),%ebx
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe68(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [14 x i8] c"calloc(): %s\0A\00"
@errno = global i32 0
define void @alloc_samples_array(i64** %0) {
%2 = alloca i64**
%3 = alloca i32
store i64** %0, i64*** %2
store i32 0, i32* %3
br label %4
4: ; preds = %27, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 48
br i1 %6, label %7, label %30
7: ; preds = %4
%8 = call i64 @calloc(i32 1000000, i32 8)
%9 = inttoptr i64 %8 to i64*
%10 = load i64**, i64*** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i64*, i64** %10, i64 %12
store i64* %9, i64** %13
%14 = load i64**, i64*** %2
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i64*, i64** %14, i64 %16
%18 = load i64*, i64** %17
%19 = icmp ne i64* %18, null
br i1 %19, label %26, label %20
20: ; preds = %7
%21 = load i32, i32* @stderr
%22 = load i32, i32* @errno
%23 = call i8* @strerror(i32 %22)
%24 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %7
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %4
30: ; preds = %4
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [14 x i8] c"calloc(): %s\0A\00"
@errno = global i32 0
define void @alloc_samples_array(i64** nocapture writeonly %0) {
br label %5
2: ; preds = %5
%3 = add nuw nsw i64 %6, 1
%4 = icmp eq i64 %3, 48
br i1 %4, label %17, label %5
5: ; preds = %1, %2
%6 = phi i64 [ 0, %1 ], [ %3, %2 ]
%7 = tail call i64 @calloc(i32 1000000, i32 8)
%8 = inttoptr i64 %7 to i64*
%9 = getelementptr inbounds i64*, i64** %0, i64 %6
store i64* %8, i64** %9
%10 = icmp eq i64 %7, 0
br i1 %10, label %11, label %2
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = load i32, i32* @errno
%14 = tail call i8* @strerror(i32 %13)
%15 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %2
ret void
}