#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*/ flag_error(char *);
int /*<<< orphan*/ free_2d_array(int **);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(int *, int /*<<< orphan*/, int);
int read_num_slices();
int /*<<< orphan*/ read_slice_dimension();
int **get_slices() {
  int num_slices = read_num_slices();
  static int **slices;
  slices = (int **)malloc((num_slices + 1) * sizeof(int *));
  int i;
  for (i = 0; i < num_slices; i++) {
    slices[i] = (int *)calloc(2, sizeof(int));
    memcpy(slices[i], read_slice_dimension(), 2 * sizeof(int));
    if (!(slices[i][0] && slices[i][1])) {
      slices[i][0] = 0;
      slices[i][1] = 0;
      goto error;
    }
  }
  slices[i] = (int *)calloc(2, sizeof(int));
  return slices;
error:
  free_2d_array(slices);
  flag_error("ERROR: Could not parse line entered into a 2 integer array "
             "representing the slice's dimensions.");
  return NULL;
}


x86 assembly (clang, -O0):
<get_slices>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1080 <read_num_slices@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,0x2ec4(%rip)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    126e <get_slices+0xfe>
mov    $0x2,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%rdx
mov    0x2e98(%rip),%rax
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    0x2e89(%rip),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <read_slice_dimension@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
mov    $0x8,%edx
call   1060 <memcpy@plt>
mov    0x2e5f(%rip),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmpl   $0x0,(%rax)
je     122b <get_slices+0xbb>
mov    0x2e47(%rip),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmpl   $0x0,0x4(%rax)
jne    125b <get_slices+0xeb>
mov    0x2e2e(%rip),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movl   $0x0,(%rax)
mov    0x2e19(%rip),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movl   $0x0,0x4(%rax)
jmp    129f <get_slices+0x12f>
jmp    1260 <get_slices+0xf0>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a3 <get_slices+0x33>
mov    $0x2,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%rdx
mov    0x2dd9(%rip),%rax
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    0x2dca(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12bf <get_slices+0x14f>
mov    0x2dba(%rip),%rdi
call   1090 <free_2d_array@plt>
lea    0xd4e(%rip),%rdi
call   1030 <flag_error@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_slices>:
push   %r15
push   %r14
push   %rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1080 <read_num_slices@plt>
mov    %eax,%ebx
lea    0x8(,%rbx,8),%edi
call   1070 <malloc@plt>
mov    %rax,0x2ecc(%rip)
test   %ebx,%ebx
jle    11f2 <get_slices+0x82>
mov    %ebx,%r14d
xor    %ebx,%ebx
nopl   (%rax)
mov    $0x2,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%r15
mov    0x2ea7(%rip),%rax
mov    %r15,(%rax,%rbx,8)
xor    %eax,%eax
call   1040 <read_slice_dimension@plt>
mov    %r15,%rdi
mov    %eax,%esi
mov    $0x8,%edx
call   1060 <memcpy@plt>
mov    0x2e86(%rip),%rdi
mov    (%rdi,%rbx,8),%rax
cmpl   $0x0,(%rax)
je     1211 <get_slices+0xa1>
cmpl   $0x0,0x4(%rax)
je     1211 <get_slices+0xa1>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11a0 <get_slices+0x30>
mov    $0x2,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    0x2e55(%rip),%rax
mov    %rcx,(%rax,%r14,8)
jmp    122b <get_slices+0xbb>
movq   $0x0,(%rax)
call   1090 <free_2d_array@plt>
lea    0xddc(%rip),%rdi
call   1030 <flag_error@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@get_slices.slices = internal global i32** null
@.str = [96 x i8] c"ERROR: Could not parse line entered into a 2 integer array representing the slice's dimensions.\00"
define i32** @get_slices() {
%1 = alloca i32**
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (...) @read_num_slices()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = add nsw i32 %5, 1
%7 = sext i32 %6 to i64
%8 = mul i64 %7, 8
%9 = trunc i64 %8 to i32
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i32**
store i32** %11, i32*** @get_slices.slices
store i32 0, i32* %3
br label %12
12: ; preds = %61, %0
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %64
16: ; preds = %12
%17 = call i64 @calloc(i32 2, i32 4)
%18 = inttoptr i64 %17 to i32*
%19 = load i32**, i32*** @get_slices.slices
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32*, i32** %19, i64 %21
store i32* %18, i32** %22
%23 = load i32**, i32*** @get_slices.slices
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32*, i32** %23, i64 %25
%27 = load i32*, i32** %26
%28 = call i32 (...) @read_slice_dimension()
%29 = call i32 @memcpy(i32* %27, i32 %28, i32 8)
%30 = load i32**, i32*** @get_slices.slices
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32*, i32** %30, i64 %32
%34 = load i32*, i32** %33
%35 = getelementptr inbounds i32, i32* %34, i64 0
%36 = load i32, i32* %35
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %47
38: ; preds = %16
%39 = load i32**, i32*** @get_slices.slices
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32*, i32** %39, i64 %41
%43 = load i32*, i32** %42
%44 = getelementptr inbounds i32, i32* %43, i64 1
%45 = load i32, i32* %44
%46 = icmp ne i32 %45, 0
br i1 %46, label %60, label %47
47: ; preds = %38, %16
%48 = load i32**, i32*** @get_slices.slices
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32*, i32** %48, i64 %50
%52 = load i32*, i32** %51
%53 = getelementptr inbounds i32, i32* %52, i64 0
store i32 0, i32* %53
%54 = load i32**, i32*** @get_slices.slices
%55 = load i32, i32* %3
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32*, i32** %54, i64 %56
%58 = load i32*, i32** %57
%59 = getelementptr inbounds i32, i32* %58, i64 1
store i32 0, i32* %59
br label %72
60: ; preds = %38
br label %61
61: ; preds = %60
%62 = load i32, i32* %3
%63 = add nsw i32 %62, 1
store i32 %63, i32* %3
br label %12
64: ; preds = %12
%65 = call i64 @calloc(i32 2, i32 4)
%66 = inttoptr i64 %65 to i32*
%67 = load i32**, i32*** @get_slices.slices
%68 = load i32, i32* %3
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32*, i32** %67, i64 %69
store i32* %66, i32** %70
%71 = load i32**, i32*** @get_slices.slices
store i32** %71, i32*** %1
br label %76
72: ; preds = %47
%73 = load i32**, i32*** @get_slices.slices
%74 = call i32 @free_2d_array(i32** %73)
%75 = call i32 @flag_error(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0))
store i32** null, i32*** %1
br label %76
76: ; preds = %72, %64
%77 = load i32**, i32*** %1
ret i32** %77
}

LLVM IR (-O2):
@get_slices.slices = internal unnamed_addr global i32** null
@.str = [96 x i8] c"ERROR: Could not parse line entered into a 2 integer array representing the slice's dimensions.\00"
define i32** @get_slices() {
%1 = tail call i32 (...) @read_num_slices()
%2 = shl i32 %1, 3
%3 = add i32 %2, 8
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to i32**
store i32** %5, i32*** @get_slices.slices
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %35
7: ; preds = %0
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %30
%10 = phi i64 [ 0, %7 ], [ %31, %30 ]
%11 = tail call i64 @calloc(i32 2, i32 4)
%12 = inttoptr i64 %11 to i32*
%13 = load i32**, i32*** @get_slices.slices
%14 = getelementptr inbounds i32*, i32** %13, i64 %10
store i32* %12, i32** %14
%15 = tail call i32 (...) @read_slice_dimension()
%16 = tail call i32 @memcpy(i32* %12, i32 %15, i32 8)
%17 = load i32**, i32*** @get_slices.slices
%18 = getelementptr inbounds i32*, i32** %17, i64 %10
%19 = load i32*, i32** %18
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %9
%23 = getelementptr inbounds i32, i32* %19, i64 1
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %22, %9
store i32 0, i32* %19
%27 = getelementptr inbounds i32, i32* %19, i64 1
store i32 0, i32* %27
%28 = tail call i32 @free_2d_array(i32** %17)
%29 = tail call i32 @flag_error(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0))
br label %41
30: ; preds = %22
%31 = add nuw nsw i64 %10, 1
%32 = icmp eq i64 %31, %8
br i1 %32, label %33, label %9
33: ; preds = %30
%34 = zext i32 %1 to i64
br label %35
35: ; preds = %0, %33
%36 = phi i64 [ %34, %33 ], [ 0, %0 ]
%37 = tail call i64 @calloc(i32 2, i32 4)
%38 = inttoptr i64 %37 to i32*
%39 = load i32**, i32*** @get_slices.slices
%40 = getelementptr inbounds i32*, i32** %39, i64 %36
store i32* %38, i32** %40
br label %41
41: ; preds = %26, %35
%42 = phi i32** [ null, %26 ], [ %39, %35 ]
ret i32** %42
}