#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 cover(int **, int, int);
int /*<<< orphan*/ free(int **);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char const *argv[]) {
  int i = 0;
  int case1[][7] = {
      {1, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 1}, {1, 1, 0, 0, 0, 1, 1}};
  int **p1 = (int **)malloc(sizeof(int *) * 3);
  for (i = 0; i < 3; i++) {
    p1[i] = case1[i];
  }
  printf("%d\n", cover(p1, 3, 7));
  free(p1);
  int case2[][7] = {
      {1, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 1}, {1, 1, 0, 0, 1, 1, 1}};
  int **p2 = (int **)malloc(sizeof(int *) * 3);
  for (i = 0; i < 3; i++) {
    p2[i] = case2[i];
  }
  printf("%d\n", cover(p2, 3, 7));
  free(p2);
  int case3[][10] = {
      {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
      {1, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
      {1, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
      {1, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};
  int **p3 = (int **)malloc(sizeof(int *) * 8);
  for (i = 0; i < 8; i++) {
    p3[i] = case3[i];
  }
  printf("%d\n", cover(p3, 8, 10));
  free(p3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe85(%rip),%rsi
mov    $0x54,%edx
call   1050 <memcpy@plt>
mov    $0x18,%edi
call   1060 <malloc@plt>
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11cd <main+0x7d>
movslq -0x14(%rbp),%rax
lea    -0x70(%rbp),%rdx
imul   $0x1c,%rax,%rax
add    %rax,%rdx
mov    -0x78(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119a <main+0x4a>
mov    -0x78(%rbp),%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1070 <cover@plt>
mov    %eax,%esi
lea    0x1017(%rip),%rdi
call   1040 <printf@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
lea    -0xd0(%rbp),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x54,%edx
call   1050 <memcpy@plt>
mov    $0x18,%edi
call   1060 <malloc@plt>
mov    %rax,-0xd8(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1260 <main+0x110>
movslq -0x14(%rbp),%rax
lea    -0xd0(%rbp),%rdx
imul   $0x1c,%rax,%rax
add    %rax,%rdx
mov    -0xd8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1227 <main+0xd7>
mov    -0xd8(%rbp),%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1070 <cover@plt>
mov    %eax,%esi
lea    0xf81(%rip),%rdi
call   1040 <printf@plt>
mov    -0xd8(%rbp),%rdi
call   1030 <free@plt>
lea    -0x220(%rbp),%rdi
lea    0xe22(%rip),%rsi
mov    $0x140,%edx
call   1050 <memcpy@plt>
mov    $0x40,%edi
call   1060 <malloc@plt>
mov    %rax,-0x228(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    12f9 <main+0x1a9>
movslq -0x14(%rbp),%rax
lea    -0x220(%rbp),%rdx
imul   $0x28,%rax,%rax
add    %rax,%rdx
mov    -0x228(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12c0 <main+0x170>
mov    -0x228(%rbp),%rdi
mov    $0x8,%esi
mov    $0xa,%edx
call   1070 <cover@plt>
mov    %eax,%esi
lea    0xee8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x228(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    0xeee(%rip),%eax
mov    %eax,0xb0(%rsp)
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe92(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe73(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe57(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
mov    $0x18,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0x60(%rsp),%rax
mov    %rax,(%rbx)
lea    0x7c(%rsp),%rax
mov    %rax,0x8(%rbx)
lea    0x98(%rsp),%rax
mov    %rax,0x10(%rbx)
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1070 <cover@plt>
lea    0x100f(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0xea7(%rip),%eax
mov    %eax,0x50(%rsp)
movaps 0xe8c(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe70(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe54(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe38(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe1c(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x18,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rsp,%rax
mov    %rax,(%rbx)
lea    0x1c(%rsp),%rax
mov    %rax,0x8(%rbx)
lea    0x38(%rsp),%rax
mov    %rax,0x10(%rbx)
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1070 <cover@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe28(%rip),%rsi
lea    0xc0(%rsp),%r15
mov    $0x140,%edx
mov    %r15,%rdi
call   1050 <memcpy@plt>
mov    $0x40,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %r15,(%rax)
lea    0xe8(%rsp),%rax
mov    %rax,0x8(%rbx)
lea    0x110(%rsp),%rax
mov    %rax,0x10(%rbx)
lea    0x138(%rsp),%rax
mov    %rax,0x18(%rbx)
lea    0x160(%rsp),%rax
mov    %rax,0x20(%rbx)
lea    0x188(%rsp),%rax
mov    %rax,0x28(%rbx)
lea    0x1b0(%rsp),%rax
mov    %rax,0x30(%rbx)
lea    0x1d8(%rsp),%rax
mov    %rax,0x38(%rbx)
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0xa,%edx
call   1070 <cover@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.case1 = [3 x [7 x i32]] [[7 x i32] [i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1], [7 x i32] [i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1], [7 x i32] [i32 1, i32 1, i32 0, i32 0, i32 0, i32 1, i32 1]]
@.str = [4 x i8] c"%d\0A\00"
@__const.main.case2 = [3 x [7 x i32]] [[7 x i32] [i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1], [7 x i32] [i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1], [7 x i32] [i32 1, i32 1, i32 0, i32 0, i32 1, i32 1, i32 1]]
@__const.main.case3 = [8 x [10 x i32]] [[10 x i32] [i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1], [10 x i32] [i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1], [10 x i32] [i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1], [10 x i32] [i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1], [10 x i32] [i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1], [10 x i32] [i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1], [10 x i32] [i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1], [10 x i32] [i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1]]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x [7 x i32]]
%4 = alloca [3 x [7 x i32]]
%5 = alloca [8 x [10 x i32]]
%6 = bitcast [3 x [7 x i32]]* %3 to i8*
%7 = tail call i64 @malloc(i32 24)
%8 = inttoptr i64 %7 to i32**
%9 = getelementptr inbounds [3 x [7 x i32]], [3 x [7 x i32]]* %3, i64 0, i64 0, i64 0
store i32* %9, i32** %8
%10 = getelementptr inbounds [3 x [7 x i32]], [3 x [7 x i32]]* %3, i64 0, i64 1, i64 0
%11 = getelementptr inbounds i32*, i32** %8, i64 1
store i32* %10, i32** %11
%12 = getelementptr inbounds [3 x [7 x i32]], [3 x [7 x i32]]* %3, i64 0, i64 2, i64 0
%13 = getelementptr inbounds i32*, i32** %8, i64 2
store i32* %12, i32** %13
%14 = call i32 @cover(i32** %8, i32 3, i32 7)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = call i32 @free(i32** %8)
%17 = bitcast [3 x [7 x i32]]* %4 to i8*
%18 = call i64 @malloc(i32 24)
%19 = inttoptr i64 %18 to i32**
%20 = getelementptr inbounds [3 x [7 x i32]], [3 x [7 x i32]]* %4, i64 0, i64 0, i64 0
store i32* %20, i32** %19
%21 = getelementptr inbounds [3 x [7 x i32]], [3 x [7 x i32]]* %4, i64 0, i64 1, i64 0
%22 = getelementptr inbounds i32*, i32** %19, i64 1
store i32* %21, i32** %22
%23 = getelementptr inbounds [3 x [7 x i32]], [3 x [7 x i32]]* %4, i64 0, i64 2, i64 0
%24 = getelementptr inbounds i32*, i32** %19, i64 2
store i32* %23, i32** %24
%25 = call i32 @cover(i32** %19, i32 3, i32 7)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = call i32 @free(i32** %19)
%28 = bitcast [8 x [10 x i32]]* %5 to i8*
%29 = call i64 @malloc(i32 64)
%30 = inttoptr i64 %29 to i32**
%31 = getelementptr inbounds [8 x [10 x i32]], [8 x [10 x i32]]* %5, i64 0, i64 0, i64 0
store i32* %31, i32** %30
%32 = getelementptr inbounds [8 x [10 x i32]], [8 x [10 x i32]]* %5, i64 0, i64 1, i64 0
%33 = getelementptr inbounds i32*, i32** %30, i64 1
store i32* %32, i32** %33
%34 = getelementptr inbounds [8 x [10 x i32]], [8 x [10 x i32]]* %5, i64 0, i64 2, i64 0
%35 = getelementptr inbounds i32*, i32** %30, i64 2
store i32* %34, i32** %35
%36 = getelementptr inbounds [8 x [10 x i32]], [8 x [10 x i32]]* %5, i64 0, i64 3, i64 0
%37 = getelementptr inbounds i32*, i32** %30, i64 3
store i32* %36, i32** %37
%38 = getelementptr inbounds [8 x [10 x i32]], [8 x [10 x i32]]* %5, i64 0, i64 4, i64 0
%39 = getelementptr inbounds i32*, i32** %30, i64 4
store i32* %38, i32** %39
%40 = getelementptr inbounds [8 x [10 x i32]], [8 x [10 x i32]]* %5, i64 0, i64 5, i64 0
%41 = getelementptr inbounds i32*, i32** %30, i64 5
store i32* %40, i32** %41
%42 = getelementptr inbounds [8 x [10 x i32]], [8 x [10 x i32]]* %5, i64 0, i64 6, i64 0
%43 = getelementptr inbounds i32*, i32** %30, i64 6
store i32* %42, i32** %43
%44 = getelementptr inbounds [8 x [10 x i32]], [8 x [10 x i32]]* %5, i64 0, i64 7, i64 0
%45 = getelementptr inbounds i32*, i32** %30, i64 7
store i32* %44, i32** %45
%46 = call i32 @cover(i32** %30, i32 8, i32 10)
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %46)
%48 = call i32 @free(i32** %30)
ret i32 0
}