#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__ malloc(int);
int maximalSquare(char **, int, int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  char arr[][5] = {{'1', '0', '1', '0', '0'},
                   {'1', '0', '1', '1', '1'},
                   {'1', '1', '1', '1', '1'},
                   {'1', '0', '0', '1', '0'}};
  char **matrix = (char **)malloc(sizeof(char *) * 4);
  for (int i = 0; i < 4; i++) {
    matrix[i] = arr[i];
  }
  printf("%d\n", maximalSquare(matrix, 4, 5));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    $0x20,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jge    11a6 <main+0x76>
movslq -0x2c(%rbp),%rax
lea    -0x20(%rbp),%rdx
imul   $0x5,%rax,%rax
add    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1173 <main+0x43>
mov    -0x28(%rbp),%rdi
mov    $0x4,%esi
mov    $0x5,%edx
call   1040 <maximalSquare@plt>
mov    %eax,%esi
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    0xed6(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xebb(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x20,%edi
call   1050 <malloc@plt>
mov    %rsp,%rcx
mov    %rcx,(%rax)
lea    0x5(%rsp),%rcx
mov    %rcx,0x8(%rax)
lea    0xa(%rsp),%rcx
mov    %rcx,0x10(%rax)
lea    0xf(%rsp),%rcx
mov    %rcx,0x18(%rax)
mov    %rax,%rdi
mov    $0x4,%esi
mov    $0x5,%edx
call   1040 <maximalSquare@plt>
lea    0xe87(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.arr = [4 x [5 x i8]] [[5 x i8] c"10100", [5 x i8] c"10111", [5 x i8] c"11111", [5 x i8] c"10010"]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x [5 x i8]]
%3 = alloca i8**
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [4 x [5 x i8]]* %2 to i8*
%6 = call i64 @malloc(i32 32)
%7 = inttoptr i64 %6 to i8**
store i8** %7, i8*** %3
store i32 0, i32* %4
br label %8
8: ; preds = %20, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [4 x [5 x i8]], [4 x [5 x i8]]* %2, i64 0, i64 %13
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %14, i64 0, i64 0
%16 = load i8**, i8*** %3
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
store i8* %15, i8** %19
br label %20
20: ; preds = %11
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %8
23: ; preds = %8
%24 = load i8**, i8*** %3
%25 = call i32 @maximalSquare(i8** %24, i32 4, i32 5)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [4 x [5 x i8]] [[5 x i8] c"10100", [5 x i8] c"10111", [5 x i8] c"11111", [5 x i8] c"10010"]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [4 x [5 x i8]]
%2 = getelementptr inbounds [4 x [5 x i8]], [4 x [5 x i8]]* %1, i64 0, i64 0, i64 0
%3 = tail call i64 @malloc(i32 32)
%4 = inttoptr i64 %3 to i8**
store i8* %2, i8** %4
%5 = getelementptr inbounds [4 x [5 x i8]], [4 x [5 x i8]]* %1, i64 0, i64 1, i64 0
%6 = getelementptr inbounds i8*, i8** %4, i64 1
store i8* %5, i8** %6
%7 = getelementptr inbounds [4 x [5 x i8]], [4 x [5 x i8]]* %1, i64 0, i64 2, i64 0
%8 = getelementptr inbounds i8*, i8** %4, i64 2
store i8* %7, i8** %8
%9 = getelementptr inbounds [4 x [5 x i8]], [4 x [5 x i8]]* %1, i64 0, i64 3, i64 0
%10 = getelementptr inbounds i8*, i8** %4, i64 3
store i8* %9, i8** %10
%11 = call i32 @maximalSquare(i8** %4, i32 4, i32 5)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
ret i32 0
}