#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__ my_calloc(int, int);
int initialise_roc_weights(double **a_roc_weights, int a_num_classes) {
  int the_error = 0;
  int i;
  *a_roc_weights = (double *)my_calloc((a_num_classes), sizeof(double));
  if (*a_roc_weights == NULL)
    the_error = 2;
  for (i = 0; i < a_num_classes; i++)
    (*a_roc_weights)[i] = 0;
  return the_error;
}


x86 assembly (clang, -O0):
<initialise_roc_weights>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   1030 <my_calloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1152 <initialise_roc_weights+0x42>
movl   $0x2,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1186 <initialise_roc_weights+0x76>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <initialise_roc_weights+0x49>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialise_roc_weights>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    %esi,%edi
mov    $0x8,%esi
call   1030 <my_calloc@plt>
mov    %rax,%rbx
mov    %rax,(%r14)
test   %ebp,%ebp
jle    114f <initialise_roc_weights+0x2f>
mov    %ebp,%edx
shl    $0x3,%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
xor    %eax,%eax
test   %rbx,%rbx
sete   %al
add    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @initialise_roc_weights(double** nocapture %0, i32 %1) {
%3 = tail call i64 @my_calloc(i32 %1, i32 8)
%4 = inttoptr i64 %3 to double*
store double* %4, double** %0
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = inttoptr i64 %3 to i8*
%8 = zext i32 %1 to i64
%9 = shl nuw nsw i64 %8, 3
br label %10
10: ; preds = %6, %2
%11 = icmp eq i64 %3, 0
%12 = select i1 %11, i32 2, i32 0
ret i32 %12
}