#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 *get_area_start(int *, int, int *);
int **get_area(int *cell, int choice, int *grid_start) {
  int **container_area = (int **)calloc(9, sizeof(int *));
  int **container_pointer = container_area;
  int *cell_pointer = get_area_start(cell, choice, grid_start);
  int main_increment = 0, secondary_increment = 0;
  switch (choice) {
  case 1:
    main_increment = 9;
    break;
  case 2:
    main_increment = 1;
    break;
  case 3:
    main_increment = 1;
    secondary_increment = 6;
    break;
  }
  for (int secondary_loop = 0; secondary_loop < 3; ++secondary_loop) {
    for (int main_loop = 0; main_loop < 3; ++main_loop) {
      *(container_pointer++) = cell_pointer;
      cell_pointer += main_increment;
    }
    cell_pointer += secondary_increment;
  }
  return container_area;
}


x86 assembly (clang, -O0):
<get_area>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x9,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <get_area_start@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x1,%eax
je     11a6 <get_area+0x86>
jmp    1184 <get_area+0x64>
mov    -0x44(%rbp),%eax
sub    $0x2,%eax
je     11b2 <get_area+0x92>
jmp    1195 <get_area+0x75>
mov    -0x44(%rbp),%eax
sub    $0x3,%eax
je     11be <get_area+0x9e>
jmp    11cc <get_area+0xac>
movl   $0x9,-0x34(%rbp)
jmp    11cc <get_area+0xac>
movl   $0x1,-0x34(%rbp)
jmp    11cc <get_area+0xac>
movl   $0x1,-0x34(%rbp)
movl   $0x6,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x3c(%rbp)
jge    124a <get_area+0x12a>
movl   $0x0,-0x40(%rbp)
cmpl   $0x3,-0x40(%rbp)
jge    1227 <get_area+0x107>
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x28(%rbp)
mov    %rcx,(%rax)
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11e4 <get_area+0xc4>
mov    -0x38(%rbp),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11d3 <get_area+0xb3>
mov    -0x20(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_area>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r15
mov    $0x9,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
call   1040 <get_area_start@plt>
add    $0xffffffff,%ebp
cmp    $0x2,%ebp
ja     1171 <get_area+0x51>
movslq %ebp,%rdx
lea    0xea0(%rip),%rcx
mov    (%rcx,%rdx,8),%rcx
lea    0xead(%rip),%rsi
mov    (%rsi,%rdx,8),%rdx
jmp    1175 <get_area+0x55>
xor    %ecx,%ecx
xor    %edx,%edx
mov    %rax,(%rbx)
lea    (%rax,%rcx,4),%rax
mov    %rax,0x8(%rbx)
lea    (%rax,%rcx,4),%rax
mov    %rax,0x10(%rbx)
lea    (%rax,%rcx,4),%rax
lea    (%rax,%rdx,4),%rax
mov    %rax,0x18(%rbx)
lea    (%rax,%rcx,4),%rax
mov    %rax,0x20(%rbx)
lea    (%rax,%rcx,4),%rax
mov    %rax,0x28(%rbx)
lea    (%rax,%rcx,4),%rax
lea    (%rax,%rdx,4),%rax
mov    %rax,0x30(%rbx)
lea    (%rax,%rcx,4),%rax
mov    %rax,0x38(%rbx)
lea    (%rax,%rcx,4),%rax
mov    %rax,0x40(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32** @get_area(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32**
%8 = alloca i32**
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%14 = call i64 @calloc(i32 9, i32 8)
%15 = inttoptr i64 %14 to i32**
store i32** %15, i32*** %7
%16 = load i32**, i32*** %7
store i32** %16, i32*** %8
%17 = load i32*, i32** %4
%18 = load i32, i32* %5
%19 = load i32*, i32** %6
%20 = call i32* @get_area_start(i32* %17, i32 %18, i32* %19)
store i32* %20, i32** %9
store i32 0, i32* %10
store i32 0, i32* %11
%21 = load i32, i32* %5
switch i32 %21, label %25 [
i32 1, label %22
i32 2, label %23
i32 3, label %24
]
22: ; preds = %3
store i32 9, i32* %10
br label %25
23: ; preds = %3
store i32 1, i32* %10
br label %25
24: ; preds = %3
store i32 1, i32* %10
store i32 6, i32* %11
br label %25
25: ; preds = %3, %24, %23, %22
store i32 0, i32* %12
br label %26
26: ; preds = %49, %25
%27 = load i32, i32* %12
%28 = icmp slt i32 %27, 3
br i1 %28, label %29, label %52
29: ; preds = %26
store i32 0, i32* %13
br label %30
30: ; preds = %41, %29
%31 = load i32, i32* %13
%32 = icmp slt i32 %31, 3
br i1 %32, label %33, label %44
33: ; preds = %30
%34 = load i32*, i32** %9
%35 = load i32**, i32*** %8
%36 = getelementptr inbounds i32*, i32** %35, i32 1
store i32** %36, i32*** %8
store i32* %34, i32** %35
%37 = load i32, i32* %10
%38 = load i32*, i32** %9
%39 = sext i32 %37 to i64
%40 = getelementptr inbounds i32, i32* %38, i64 %39
store i32* %40, i32** %9
br label %41
41: ; preds = %33
%42 = load i32, i32* %13
%43 = add nsw i32 %42, 1
store i32 %43, i32* %13
br label %30
44: ; preds = %30
%45 = load i32, i32* %11
%46 = load i32*, i32** %9
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds i32, i32* %46, i64 %47
store i32* %48, i32** %9
br label %49
49: ; preds = %44
%50 = load i32, i32* %12
%51 = add nsw i32 %50, 1
store i32 %51, i32* %12
br label %26
52: ; preds = %26
%53 = load i32**, i32*** %7
ret i32** %53
}

LLVM IR (-O2):
@switch.table.get_area = [3 x i64] [i64 9, i64 1, i64 1]
@switch.table.get_area.1 = [3 x i64] [i64 0, i64 0, i64 6]
define i32** @get_area(i32* %0, i32 %1, i32* %2) {
%4 = tail call i64 @calloc(i32 9, i32 8)
%5 = inttoptr i64 %4 to i32**
%6 = tail call i32* @get_area_start(i32* %0, i32 %1, i32* %2)
%7 = add i32 %1, -1
%8 = icmp ult i32 %7, 3
br i1 %8, label %9, label %16
9: ; preds = %3
%10 = sext i32 %7 to i64
%11 = getelementptr inbounds [3 x i64], [3 x i64]* @switch.table.get_area, i64 0, i64 %10
%12 = load i64, i64* %11
%13 = sext i32 %7 to i64
%14 = getelementptr inbounds [3 x i64], [3 x i64]* @switch.table.get_area.1, i64 0, i64 %13
%15 = load i64, i64* %14
br label %16
16: ; preds = %9, %3
%17 = phi i64 [ 0, %3 ], [ %12, %9 ]
%18 = phi i64 [ 0, %3 ], [ %15, %9 ]
%19 = getelementptr inbounds i32*, i32** %5, i64 1
store i32* %6, i32** %5
%20 = getelementptr inbounds i32, i32* %6, i64 %17
%21 = getelementptr inbounds i32*, i32** %5, i64 2
store i32* %20, i32** %19
%22 = getelementptr inbounds i32, i32* %20, i64 %17
%23 = getelementptr inbounds i32*, i32** %5, i64 3
store i32* %22, i32** %21
%24 = getelementptr inbounds i32, i32* %22, i64 %17
%25 = getelementptr inbounds i32, i32* %24, i64 %18
%26 = getelementptr inbounds i32*, i32** %5, i64 4
store i32* %25, i32** %23
%27 = getelementptr inbounds i32, i32* %25, i64 %17
%28 = getelementptr inbounds i32*, i32** %5, i64 5
store i32* %27, i32** %26
%29 = getelementptr inbounds i32, i32* %27, i64 %17
%30 = getelementptr inbounds i32*, i32** %5, i64 6
store i32* %29, i32** %28
%31 = getelementptr inbounds i32, i32* %29, i64 %17
%32 = getelementptr inbounds i32, i32* %31, i64 %18
%33 = getelementptr inbounds i32*, i32** %5, i64 7
store i32* %32, i32** %30
%34 = getelementptr inbounds i32, i32* %32, i64 %17
%35 = getelementptr inbounds i32*, i32** %5, i64 8
store i32* %34, i32** %33
%36 = getelementptr inbounds i32, i32* %34, i64 %17
store i32* %36, i32** %35
ret i32** %5
}