#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*/ grow(int, int, int, double *, int *, int, int,
                        int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int m, n, p;
  m = 5;
  n = 5;
  p = 1;
  double img[m * n * p];
  bool seg[m * n * p];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      img[5 * i + j] = 0.0;
    }
  }
  img[5 * 2 + 2] = 1.0;
  img[5 * 2 + 1] = 1.0;
  img[5 * 2 + 3] = 1.0;
  img[5 * 1 + 2] = 1.0;
  img[5 * 3 + 2] = 1.0;
  grow(m, n, p, img, seg, 2, 2, 0, 5);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      printf("%d ", seg[5 * i + j] ? 1 : 0);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   %ecx,%eax
mov    -0x10(%rbp),%ecx
imul   %ecx,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   %ecx,%eax
mov    -0x10(%rbp),%ecx
imul   %ecx,%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1200 <main+0xe0>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ed <main+0xcd>
mov    -0x48(%rbp),%rax
imul   $0x5,-0x2c(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11bd <main+0x9d>
jmp    11f2 <main+0xd2>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11aa <main+0x8a>
mov    -0x40(%rbp),%r8
mov    -0x48(%rbp),%rcx
movsd  0xdf0(%rip),%xmm0
movsd  %xmm0,0x60(%rcx)
movsd  0xde3(%rip),%xmm0
movsd  %xmm0,0x58(%rcx)
movsd  0xdd6(%rip),%xmm0
movsd  %xmm0,0x68(%rcx)
movsd  0xdc9(%rip),%xmm0
movsd  %xmm0,0x38(%rcx)
movsd  0xdbc(%rip),%xmm0
movsd  %xmm0,0x88(%rcx)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    $0x2,%r9d
xor    %eax,%eax
sub    $0x20,%rsp
movl   $0x2,(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x5,0x10(%rsp)
call   1030 <grow@plt>
add    $0x20,%rsp
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12fd <main+0x1dd>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12e1 <main+0x1c1>
mov    -0x40(%rbp),%rax
imul   $0x5,-0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    129b <main+0x17b>
lea    0xd24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1288 <main+0x168>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x138,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0xc0(%rsp)
movaps 0xe69(%rip),%xmm0
movups %xmm0,0x58(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x68(%rsp)
mov    %rax,0x38(%rsp)
mov    %rax,0x88(%rsp)
sub    $0x8,%rsp
lea    0x8(%rsp),%rcx
lea    0xd8(%rsp),%r8
mov    $0x5,%edi
mov    $0x5,%esi
mov    $0x1,%edx
mov    $0x2,%r9d
push   $0x5
push   $0x0
push   $0x2
call   1040 <grow@plt>
add    $0x20,%rsp
mov    $0x10,%ebx
lea    0xe17(%rip),%r14
nopl   0x0(%rax)
xor    %esi,%esi
cmpl   $0x0,0xc0(%rsp,%rbx,1)
setne  %sil
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %esi,%esi
cmpl   $0x0,0xc4(%rsp,%rbx,1)
setne  %sil
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %esi,%esi
cmpl   $0x0,0xc8(%rsp,%rbx,1)
setne  %sil
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %esi,%esi
cmpl   $0x0,0xcc(%rsp,%rbx,1)
setne  %sil
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %esi,%esi
cmpl   $0x0,0xd0(%rsp,%rbx,1)
setne  %sil
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x14,%rbx
cmp    $0x74,%rbx
jne    1200 <main+0xd0>
xor    %eax,%eax
add    $0x138,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
store i32 5, i32* %2
store i32 5, i32* %3
store i32 1, i32* %4
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = mul nsw i32 %12, %13
%15 = load i32, i32* %4
%16 = mul nsw i32 %14, %15
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %5
%19 = alloca double, i64 %17
store i64 %17, i64* %6
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = mul nsw i32 %20, %21
%23 = load i32, i32* %4
%24 = mul nsw i32 %22, %23
%25 = zext i32 %24 to i64
%26 = alloca i32, i64 %25
store i64 %25, i64* %7
store i32 0, i32* %8
br label %27
27: ; preds = %47, %0
%28 = load i32, i32* %8
%29 = load i32, i32* %2
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %50
31: ; preds = %27
store i32 0, i32* %9
br label %32
32: ; preds = %43, %31
%33 = load i32, i32* %9
%34 = load i32, i32* %3
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %46
36: ; preds = %32
%37 = load i32, i32* %8
%38 = mul nsw i32 5, %37
%39 = load i32, i32* %9
%40 = add nsw i32 %38, %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %19, i64 %41
store double 0.000000e+00, double* %42
br label %43
43: ; preds = %36
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %32
46: ; preds = %32
br label %47
47: ; preds = %46
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %27
50: ; preds = %27
%51 = getelementptr inbounds double, double* %19, i64 12
store double 1.000000e+00, double* %51
%52 = getelementptr inbounds double, double* %19, i64 11
store double 1.000000e+00, double* %52
%53 = getelementptr inbounds double, double* %19, i64 13
store double 1.000000e+00, double* %53
%54 = getelementptr inbounds double, double* %19, i64 7
store double 1.000000e+00, double* %54
%55 = getelementptr inbounds double, double* %19, i64 17
store double 1.000000e+00, double* %55
%56 = load i32, i32* %2
%57 = load i32, i32* %3
%58 = load i32, i32* %4
%59 = call i32 @grow(i32 %56, i32 %57, i32 %58, double* %19, i32* %26, i32 2, i32 2, i32 0, i32 5)
store i32 0, i32* %10
br label %60
60: ; preds = %86, %50
%61 = load i32, i32* %10
%62 = load i32, i32* %2
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %89
64: ; preds = %60
store i32 0, i32* %11
br label %65
65: ; preds = %81, %64
%66 = load i32, i32* %11
%67 = load i32, i32* %3
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %84
69: ; preds = %65
%70 = load i32, i32* %10
%71 = mul nsw i32 5, %70
%72 = load i32, i32* %11
%73 = add nsw i32 %71, %72
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %26, i64 %74
%76 = load i32, i32* %75
%77 = icmp ne i32 %76, 0
%78 = zext i1 %77 to i64
%79 = select i1 %77, i32 1, i32 0
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %79)
br label %81
81: ; preds = %69
%82 = load i32, i32* %11
%83 = add nsw i32 %82, 1
store i32 %83, i32* %11
br label %65
84: ; preds = %65
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %86
86: ; preds = %84
%87 = load i32, i32* %10
%88 = add nsw i32 %87, 1
store i32 %88, i32* %10
br label %60
89: ; preds = %60
store i32 0, i32* %1
%90 = load i8*, i8** %5
%91 = load i32, i32* %1
ret i32 %91
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [25 x double]
%2 = bitcast [25 x double]* %1 to i8*
%3 = alloca [25 x i32]
%4 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 0
%5 = getelementptr inbounds [25 x double], [25 x double]* %1, i64 0, i64 0
%6 = getelementptr inbounds [25 x double], [25 x double]* %1, i64 0, i64 11
%7 = bitcast double* %6 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %7
%8 = getelementptr inbounds [25 x double], [25 x double]* %1, i64 0, i64 13
store double 1.000000e+00, double* %8
%9 = getelementptr inbounds [25 x double], [25 x double]* %1, i64 0, i64 7
store double 1.000000e+00, double* %9
%10 = getelementptr inbounds [25 x double], [25 x double]* %1, i64 0, i64 17
store double 1.000000e+00, double* %10
%11 = call i32 @grow(i32 5, i32 5, i32 1, double* %5, i32* %4, i32 2, i32 2, i32 0, i32 5)
br label %12
12: ; preds = %0, %12
%13 = phi i64 [ 0, %0 ], [ %45, %12 ]
%14 = mul nuw nsw i64 %13, 5
%15 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = icmp ne i32 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i64 %14, 1
%21 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = icmp ne i32 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = add nuw nsw i64 %14, 2
%27 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = icmp ne i32 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = add nuw nsw i64 %14, 3
%33 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = icmp ne i32 %34, 0
%36 = zext i1 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = add nuw nsw i64 %14, 4
%39 = getelementptr inbounds [25 x i32], [25 x i32]* %3, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = icmp ne i32 %40, 0
%42 = zext i1 %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = call i32 @putchar(i32 10)
%45 = add nuw nsw i64 %13, 1
%46 = icmp eq i64 %45, 5
br i1 %46, label %47, label %12
47: ; preds = %12
ret i32 0
}