#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 /*<<< orphan*/ abort();
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stderr;
int **alloc_2d_int(int n1, int n2) {
  int **ii, *i;
  int j;
  ii = (int **)calloc(n1, sizeof(int *));
  {
    if ((ii) == NULL) {
      fprintf(
          stderr,
          "ERROR! Allocation failure. Probably out of memory in %s:%d.\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/BIC-MNI/BEaST/refs/heads/master/alloc.c",
          152);
      abort();
    }
  };
  i = (int *)calloc(n1 * n2, sizeof(int));
  {
    if ((i) == NULL) {
      fprintf(
          stderr,
          "ERROR! Allocation failure. Probably out of memory in %s:%d.\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/BIC-MNI/BEaST/refs/heads/master/alloc.c",
          154);
      abort();
    }
  };
  ii[0] = i;
  for (j = 1; j < n1; j++) {
    ii[j] = ii[j - 1] + n2;
  }
  return ii;
}


x86 assembly (clang, -O0):
<alloc_2d_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1182 <alloc_2d_int+0x52>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
lea    0xecc(%rip),%rdx
mov    $0x98,%ecx
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%edi
imul   -0x8(%rbp),%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ca <alloc_2d_int+0x9a>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    0xe4e(%rip),%rsi
lea    0xe84(%rip),%rdx
mov    $0x9a,%ecx
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    121e <alloc_2d_int+0xee>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11dc <alloc_2d_int+0xac>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_2d_int>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0x8,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     1248 <alloc_2d_int+0x118>
mov    %rax,%rbx
mov    %r14d,%edi
imul   %ebp,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     1266 <alloc_2d_int+0x136>
mov    %rax,(%rbx)
cmp    $0x2,%ebp
jl     1240 <alloc_2d_int+0x110>
movslq %r14d,%r9
mov    %ebp,%ecx
lea    -0x1(%rcx),%rdi
add    $0xfffffffffffffffe,%rcx
mov    %edi,%edx
and    $0x7,%edx
cmp    $0x7,%rcx
jae    119f <alloc_2d_int+0x6f>
mov    $0x1,%esi
test   %rdx,%rdx
jne    121b <alloc_2d_int+0xeb>
jmp    1240 <alloc_2d_int+0x110>
and    $0xfffffffffffffff8,%rdi
mov    %r9,%r8
shl    $0x5,%r8
lea    0x0(,%r9,4),%rbp
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rax,%rcx
add    %rbp,%rax
mov    %rax,0x8(%rbx,%rsi,8)
add    %rbp,%rax
mov    %rax,0x10(%rbx,%rsi,8)
add    %rbp,%rax
mov    %rax,0x18(%rbx,%rsi,8)
add    %rbp,%rax
mov    %rax,0x20(%rbx,%rsi,8)
add    %rbp,%rax
mov    %rax,0x28(%rbx,%rsi,8)
add    %rbp,%rax
mov    %rax,0x30(%rbx,%rsi,8)
add    %rbp,%rax
mov    %rax,0x38(%rbx,%rsi,8)
add    %rbp,%rax
mov    %rax,0x40(%rbx,%rsi,8)
add    $0x8,%rsi
cmp    %rsi,%rdi
jne    11c0 <alloc_2d_int+0x90>
add    %r8,%rcx
add    $0x1,%rsi
mov    %rcx,%rax
test   %rdx,%rdx
je     1240 <alloc_2d_int+0x110>
lea    (%rax,%r9,4),%rax
shl    $0x2,%r9
lea    (%rbx,%rsi,8),%rcx
xor    %esi,%esi
nopl   0x0(%rax)
mov    %rax,(%rcx,%rsi,8)
add    $0x1,%rsi
add    %r9,%rax
cmp    %rsi,%rdx
jne    1230 <alloc_2d_int+0x100>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
lea    0xda8(%rip),%rsi
lea    0xdde(%rip),%rdx
mov    $0x98,%ecx
jmp    1282 <alloc_2d_int+0x152>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
lea    0xd8a(%rip),%rsi
lea    0xdc0(%rip),%rdx
mov    $0x9a,%ecx
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [61 x i8] c"ERROR! Allocation failure. Probably out of memory in %s:%d.\0A\00"
@.str.1 = [130 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/BIC-MNI/BEaST/refs/heads/master/alloc.c\00"
define i32** @alloc_2d_int(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32**
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = call i64 @calloc(i32 %8, i32 8)
%10 = inttoptr i64 %9 to i32**
store i32** %10, i32*** %5
%11 = load i32**, i32*** %5
%12 = icmp eq i32** %11, null
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 152)
%16 = call i32 (...) @abort()
unreachable
17: ; preds = %2
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = mul nsw i32 %18, %19
%21 = call i64 @calloc(i32 %20, i32 4)
%22 = inttoptr i64 %21 to i32*
store i32* %22, i32** %6
%23 = load i32*, i32** %6
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %29
25: ; preds = %17
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 154)
%28 = call i32 (...) @abort()
unreachable
29: ; preds = %17
%30 = load i32*, i32** %6
%31 = load i32**, i32*** %5
%32 = getelementptr inbounds i32*, i32** %31, i64 0
store i32* %30, i32** %32
store i32 1, i32* %7
br label %33
33: ; preds = %51, %29
%34 = load i32, i32* %7
%35 = load i32, i32* %3
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %54
37: ; preds = %33
%38 = load i32**, i32*** %5
%39 = load i32, i32* %7
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32*, i32** %38, i64 %41
%43 = load i32*, i32** %42
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32**, i32*** %5
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32*, i32** %47, i64 %49
store i32* %46, i32** %50
br label %51
51: ; preds = %37
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %33
54: ; preds = %33
%55 = load i32**, i32*** %5
ret i32** %55
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [61 x i8] c"ERROR! Allocation failure. Probably out of memory in %s:%d.\0A\00"
@.str.1 = [130 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/BIC-MNI/BEaST/refs/heads/master/alloc.c\00"
define i32** @alloc_2d_int(i32 %0, i32 %1) {
%3 = tail call i64 @calloc(i32 %0, i32 8)
%4 = inttoptr i64 %3 to i32**
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 152)
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %2
%11 = mul nsw i32 %1, %0
%12 = tail call i64 @calloc(i32 %11, i32 4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 154)
%17 = tail call i32 (...) @abort()
unreachable
18: ; preds = %10
%19 = inttoptr i64 %12 to i32*
store i32* %19, i32** %4
%20 = icmp sgt i32 %0, 1
br i1 %20, label %21, label %73
21: ; preds = %18
%22 = sext i32 %1 to i64
%23 = zext i32 %0 to i64
%24 = add nsw i64 %23, -1
%25 = add nsw i64 %23, -2
%26 = and i64 %24, 7
%27 = icmp ult i64 %25, 7
br i1 %27, label %60, label %28
28: ; preds = %21
%29 = and i64 %24, -8
br label %30
30: ; preds = %30, %28
%31 = phi i32* [ %19, %28 ], [ %55, %30 ]
%32 = phi i64 [ 1, %28 ], [ %57, %30 ]
%33 = phi i64 [ 0, %28 ], [ %58, %30 ]
%34 = getelementptr inbounds i32, i32* %31, i64 %22
%35 = getelementptr inbounds i32*, i32** %4, i64 %32
store i32* %34, i32** %35
%36 = add nuw nsw i64 %32, 1
%37 = getelementptr inbounds i32, i32* %34, i64 %22
%38 = getelementptr inbounds i32*, i32** %4, i64 %36
store i32* %37, i32** %38
%39 = add nuw nsw i64 %32, 2
%40 = getelementptr inbounds i32, i32* %37, i64 %22
%41 = getelementptr inbounds i32*, i32** %4, i64 %39
store i32* %40, i32** %41
%42 = add nuw nsw i64 %32, 3
%43 = getelementptr inbounds i32, i32* %40, i64 %22
%44 = getelementptr inbounds i32*, i32** %4, i64 %42
store i32* %43, i32** %44
%45 = add nuw nsw i64 %32, 4
%46 = getelementptr inbounds i32, i32* %43, i64 %22
%47 = getelementptr inbounds i32*, i32** %4, i64 %45
store i32* %46, i32** %47
%48 = add nuw nsw i64 %32, 5
%49 = getelementptr inbounds i32, i32* %46, i64 %22
%50 = getelementptr inbounds i32*, i32** %4, i64 %48
store i32* %49, i32** %50
%51 = add nuw nsw i64 %32, 6
%52 = getelementptr inbounds i32, i32* %49, i64 %22
%53 = getelementptr inbounds i32*, i32** %4, i64 %51
store i32* %52, i32** %53
%54 = add nuw nsw i64 %32, 7
%55 = getelementptr inbounds i32, i32* %52, i64 %22
%56 = getelementptr inbounds i32*, i32** %4, i64 %54
store i32* %55, i32** %56
%57 = add nuw nsw i64 %32, 8
%58 = add i64 %33, 8
%59 = icmp eq i64 %58, %29
br i1 %59, label %60, label %30
60: ; preds = %30, %21
%61 = phi i32* [ %19, %21 ], [ %55, %30 ]
%62 = phi i64 [ 1, %21 ], [ %57, %30 ]
%63 = icmp eq i64 %26, 0
br i1 %63, label %73, label %64
64: ; preds = %60, %64
%65 = phi i32* [ %68, %64 ], [ %61, %60 ]
%66 = phi i64 [ %70, %64 ], [ %62, %60 ]
%67 = phi i64 [ %71, %64 ], [ 0, %60 ]
%68 = getelementptr inbounds i32, i32* %65, i64 %22
%69 = getelementptr inbounds i32*, i32** %4, i64 %66
store i32* %68, i32** %69
%70 = add nuw nsw i64 %66, 1
%71 = add i64 %67, 1
%72 = icmp eq i64 %71, %26
br i1 %72, label %73, label %64
73: ; preds = %60, %64, %18
ret i32** %4
}