#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 islandPerimeter(int **, int, int);
char *whenTest1_ShouldReturn16() {
  int **array;
  int columns = 4;
  int rows = 4;
  int expected = 16;
  int i = 0;
  array = (int **)calloc(rows, sizeof(int *));
  for (i = 0; i < rows; i++) {
    array[i] = (int *)calloc(columns, sizeof(int));
  }
  array[0][0] = 0;
  array[0][1] = 1;
  array[0][2] = 0;
  array[0][3] = 0;
  array[1][0] = 1;
  array[1][1] = 1;
  array[1][2] = 1;
  array[1][3] = 0;
  array[2][0] = 0;
  array[2][1] = 1;
  array[2][2] = 0;
  array[2][3] = 0;
  array[3][0] = 1;
  array[3][1] = 1;
  array[3][2] = 0;
  array[3][3] = 0;
  int result = islandPerimeter(array, rows, columns);
  do {
    if (!(expected == result))
      return "Error, perimeter is wrong";
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<whenTest1_ShouldReturn16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x4,-0x14(%rbp)
movl   $0x4,-0x18(%rbp)
movl   $0x10,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1192 <whenTest1_ShouldReturn16+0x72>
mov    -0x14(%rbp),%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115c <whenTest1_ShouldReturn16+0x3c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x0,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x0,0xc(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x1,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x0,0xc(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x0,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x0,0xc(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x0,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x0,0xc(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <islandPerimeter@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     12a8 <whenTest1_ShouldReturn16+0x188>
lea    0xd61(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b5 <whenTest1_ShouldReturn16+0x195>
jmp    12ad <whenTest1_ShouldReturn16+0x18d>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<whenTest1_ShouldReturn16>:
push   %rbx
mov    $0x4,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rbx
mov    $0x4,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,(%rbx)
mov    $0x4,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,0x8(%rbx)
mov    $0x4,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,0x10(%rbx)
mov    $0x4,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,0x18(%rbx)
mov    (%rbx),%rcx
movaps 0xe78(%rip),%xmm0
movups %xmm0,(%rcx)
mov    0x8(%rbx),%rcx
movaps 0xe7a(%rip),%xmm1
movups %xmm1,(%rcx)
mov    0x10(%rbx),%rcx
movups %xmm0,(%rcx)
movaps 0xe79(%rip),%xmm0
movups %xmm0,(%rax)
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x4,%edx
call   1040 <islandPerimeter@plt>
xor    %ecx,%ecx
cmp    $0x10,%eax
lea    0xe68(%rip),%rax
cmovne %rax,%rcx
mov    %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Error, perimeter is wrong\00"
define i8* @whenTest1_ShouldReturn16() {
%1 = alloca i8*
%2 = alloca i32**
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 4, i32* %3
store i32 4, i32* %4
store i32 16, i32* %5
store i32 0, i32* %6
%8 = load i32, i32* %4
%9 = call i64 @calloc(i32 %8, i32 8)
%10 = inttoptr i64 %9 to i32**
store i32** %10, i32*** %2
store i32 0, i32* %6
br label %11
11: ; preds = %23, %0
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = load i32, i32* %3
%17 = call i64 @calloc(i32 %16, i32 4)
%18 = inttoptr i64 %17 to i32*
%19 = load i32**, i32*** %2
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32*, i32** %19, i64 %21
store i32* %18, i32** %22
br label %23
23: ; preds = %15
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %11
26: ; preds = %11
%27 = load i32**, i32*** %2
%28 = getelementptr inbounds i32*, i32** %27, i64 0
%29 = load i32*, i32** %28
%30 = getelementptr inbounds i32, i32* %29, i64 0
store i32 0, i32* %30
%31 = load i32**, i32*** %2
%32 = getelementptr inbounds i32*, i32** %31, i64 0
%33 = load i32*, i32** %32
%34 = getelementptr inbounds i32, i32* %33, i64 1
store i32 1, i32* %34
%35 = load i32**, i32*** %2
%36 = getelementptr inbounds i32*, i32** %35, i64 0
%37 = load i32*, i32** %36
%38 = getelementptr inbounds i32, i32* %37, i64 2
store i32 0, i32* %38
%39 = load i32**, i32*** %2
%40 = getelementptr inbounds i32*, i32** %39, i64 0
%41 = load i32*, i32** %40
%42 = getelementptr inbounds i32, i32* %41, i64 3
store i32 0, i32* %42
%43 = load i32**, i32*** %2
%44 = getelementptr inbounds i32*, i32** %43, i64 1
%45 = load i32*, i32** %44
%46 = getelementptr inbounds i32, i32* %45, i64 0
store i32 1, i32* %46
%47 = load i32**, i32*** %2
%48 = getelementptr inbounds i32*, i32** %47, i64 1
%49 = load i32*, i32** %48
%50 = getelementptr inbounds i32, i32* %49, i64 1
store i32 1, i32* %50
%51 = load i32**, i32*** %2
%52 = getelementptr inbounds i32*, i32** %51, i64 1
%53 = load i32*, i32** %52
%54 = getelementptr inbounds i32, i32* %53, i64 2
store i32 1, i32* %54
%55 = load i32**, i32*** %2
%56 = getelementptr inbounds i32*, i32** %55, i64 1
%57 = load i32*, i32** %56
%58 = getelementptr inbounds i32, i32* %57, i64 3
store i32 0, i32* %58
%59 = load i32**, i32*** %2
%60 = getelementptr inbounds i32*, i32** %59, i64 2
%61 = load i32*, i32** %60
%62 = getelementptr inbounds i32, i32* %61, i64 0
store i32 0, i32* %62
%63 = load i32**, i32*** %2
%64 = getelementptr inbounds i32*, i32** %63, i64 2
%65 = load i32*, i32** %64
%66 = getelementptr inbounds i32, i32* %65, i64 1
store i32 1, i32* %66
%67 = load i32**, i32*** %2
%68 = getelementptr inbounds i32*, i32** %67, i64 2
%69 = load i32*, i32** %68
%70 = getelementptr inbounds i32, i32* %69, i64 2
store i32 0, i32* %70
%71 = load i32**, i32*** %2
%72 = getelementptr inbounds i32*, i32** %71, i64 2
%73 = load i32*, i32** %72
%74 = getelementptr inbounds i32, i32* %73, i64 3
store i32 0, i32* %74
%75 = load i32**, i32*** %2
%76 = getelementptr inbounds i32*, i32** %75, i64 3
%77 = load i32*, i32** %76
%78 = getelementptr inbounds i32, i32* %77, i64 0
store i32 1, i32* %78
%79 = load i32**, i32*** %2
%80 = getelementptr inbounds i32*, i32** %79, i64 3
%81 = load i32*, i32** %80
%82 = getelementptr inbounds i32, i32* %81, i64 1
store i32 1, i32* %82
%83 = load i32**, i32*** %2
%84 = getelementptr inbounds i32*, i32** %83, i64 3
%85 = load i32*, i32** %84
%86 = getelementptr inbounds i32, i32* %85, i64 2
store i32 0, i32* %86
%87 = load i32**, i32*** %2
%88 = getelementptr inbounds i32*, i32** %87, i64 3
%89 = load i32*, i32** %88
%90 = getelementptr inbounds i32, i32* %89, i64 3
store i32 0, i32* %90
%91 = load i32**, i32*** %2
%92 = load i32, i32* %4
%93 = load i32, i32* %3
%94 = call i32 @islandPerimeter(i32** %91, i32 %92, i32 %93)
store i32 %94, i32* %7
br label %95
95: ; preds = %26
%96 = load i32, i32* %5
%97 = load i32, i32* %7
%98 = icmp eq i32 %96, %97
br i1 %98, label %100, label %99
99: ; preds = %95
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8** %1
br label %102
100: ; preds = %95
br label %101
101: ; preds = %100
store i8* null, i8** %1
br label %102
102: ; preds = %101, %99
%103 = load i8*, i8** %1
ret i8* %103
}

LLVM IR (-O2):
@.str = [26 x i8] c"Error, perimeter is wrong\00"
define i8* @whenTest1_ShouldReturn16() {
%1 = tail call i64 @calloc(i32 4, i32 8)
%2 = inttoptr i64 %1 to i32**
%3 = tail call i64 @calloc(i32 4, i32 4)
%4 = inttoptr i64 %3 to i32*
store i32* %4, i32** %2
%5 = tail call i64 @calloc(i32 4, i32 4)
%6 = inttoptr i64 %5 to i32*
%7 = getelementptr inbounds i32*, i32** %2, i64 1
store i32* %6, i32** %7
%8 = tail call i64 @calloc(i32 4, i32 4)
%9 = inttoptr i64 %8 to i32*
%10 = getelementptr inbounds i32*, i32** %2, i64 2
store i32* %9, i32** %10
%11 = tail call i64 @calloc(i32 4, i32 4)
%12 = inttoptr i64 %11 to i32*
%13 = getelementptr inbounds i32*, i32** %2, i64 3
store i32* %12, i32** %13
%14 = inttoptr i64 %1 to <4 x i32>**
%15 = load <4 x i32>*, <4 x i32>** %14
store <4 x i32> <i32 0, i32 1, i32 0, i32 0>, <4 x i32>* %15
%16 = bitcast i32** %7 to <4 x i32>**
%17 = load <4 x i32>*, <4 x i32>** %16
store <4 x i32> <i32 1, i32 1, i32 1, i32 0>, <4 x i32>* %17
%18 = bitcast i32** %10 to <4 x i32>**
%19 = load <4 x i32>*, <4 x i32>** %18
store <4 x i32> <i32 0, i32 1, i32 0, i32 0>, <4 x i32>* %19
%20 = inttoptr i64 %11 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 0, i32 0>, <4 x i32>* %20
%21 = tail call i32 @islandPerimeter(i32** %2, i32 4, i32 4)
%22 = icmp eq i32 %21, 16
%23 = select i1 %22, i8* null, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0)
ret i8* %23
}