#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*/ abort();
unsigned int atoi(char *);
scalar_t__ colimacon(int **, unsigned int, unsigned int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ free(int *);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(int);
size_t optind;
int optopt;
int /*<<< orphan*/ print2DArray(int *, unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ run_all_tests();
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int *array = NULL;
  int c;
  int tests_flag = 0;
  int print_flag = 1;
  unsigned int rows, columns;
  while ((c = getopt(argc, argv, "tp")) != -1)
    switch (c) {
    case 't':
      tests_flag = 1;
      break;
    case 'p':
      print_flag = 0;
      break;
    case '?':
      if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      return 1;
    default:
      abort();
    }
  if (tests_flag == 1)
    run_all_tests();
  if (argc < 3) {
    printf("Usage: %s [-t -p] rows columns\n", argv[0]);
    return 1;
  }
  rows = atoi(argv[optind]);
  columns = atoi(argv[optind + 1]);
  if (rows < 1 || columns < 1) {
    printf("Usage: %s [-t -p] rows columns\n", argv[0]);
    return 1;
  }
  printf("\nComputing with %d rows and %d columns\n", rows, columns);
  if (colimacon(&array, rows, columns) == 0) {
    printf("FAILED building colimacon");
    return 1;
  }
  if (print_flag == 1)
    print2DArray(array, rows, columns);
  free(array);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe26(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     12a9 <main+0x109>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x3f,%eax
je     1239 <main+0x99>
jmp    11ff <main+0x5f>
mov    -0x30(%rbp),%eax
sub    $0x70,%eax
je     122d <main+0x8d>
jmp    1210 <main+0x70>
mov    -0x30(%rbp),%eax
sub    $0x74,%eax
jne    129d <main+0xfd>
jmp    1221 <main+0x81>
movl   $0x1,-0x20(%rbp)
jmp    12a4 <main+0x104>
movl   $0x0,-0x24(%rbp)
jmp    12a4 <main+0x104>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
call   10a0 <isprint@plt>
cmp    $0x0,%eax
je     1273 <main+0xd3>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
mov    0x2d88(%rip),%rax
mov    (%rax),%edx
lea    0xd9a(%rip),%rsi
call   1070 <fprintf@plt>
jmp    1291 <main+0xf1>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    0x2d65(%rip),%rax
mov    (%rax),%edx
lea    0xd8e(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13bf <main+0x21f>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    11cc <main+0x2c>
cmpl   $0x1,-0x20(%rbp)
jne    12ba <main+0x11a>
mov    $0x0,%al
call   1090 <run_all_tests@plt>
cmpl   $0x3,-0x8(%rbp)
jge    12e5 <main+0x145>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13bf <main+0x21f>
mov    -0x10(%rbp),%rax
mov    0x2cf0(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2cd6(%rip),%rcx
mov    (%rcx),%rcx
mov    0x8(%rax,%rcx,8),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x1,-0x28(%rbp)
jb     132e <main+0x18e>
cmpl   $0x1,-0x2c(%rbp)
jae    134f <main+0x1af>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13bf <main+0x21f>
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    -0x18(%rbp),%rdi
call   1080 <colimacon@plt>
cmp    $0x0,%rax
jne    1396 <main+0x1f6>
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13bf <main+0x21f>
cmpl   $0x1,-0x24(%rbp)
jne    13af <main+0x20f>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1060 <print2DArray@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r12
mov    %edi,%ebp
movq   $0x0,0x8(%rsp)
xor    %ebx,%ebx
mov    $0x1,%r15b
lea    0xe3a(%rip),%r14
mov    %ebx,%ecx
nopl   0x0(%rax,%rax,1)
mov    %ecx,%ebx
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r14,%rdx
call   10b0 <getopt@plt>
mov    $0x1,%ecx
cmp    $0x74,%eax
je     11d0 <main+0x30>
cmp    $0xffffffff,%eax
je     122e <main+0x8e>
cmp    $0x70,%eax
jne    11f8 <main+0x58>
xor    %r15d,%r15d
jmp    11c6 <main+0x26>
cmp    $0x3f,%eax
jne    12f5 <main+0x155>
mov    0x2de0(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10a0 <isprint@plt>
mov    0x2db8(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     12c5 <main+0x125>
lea    0xdda(%rip),%rsi
jmp    12cc <main+0x12c>
cmp    $0x1,%ebx
jne    123a <main+0x9a>
xor    %eax,%eax
call   1090 <run_all_tests@plt>
cmp    $0x2,%ebp
jle    12b1 <main+0x111>
mov    0x2d9a(%rip),%rax
mov    (%rax),%rbx
mov    (%r12,%rbx,8),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebp
mov    0x8(%r12,%rbx,8),%rdi
call   10c0 <atoi@plt>
test   %ebp,%ebp
je     12b1 <main+0x111>
mov    %eax,%r14d
test   %eax,%eax
je     12b1 <main+0x111>
lea    0xdec(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x8(%rsp),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1080 <colimacon@plt>
test   %rax,%rax
je     12e5 <main+0x145>
test   $0x1,%r15b
je     12a5 <main+0x105>
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1060 <print2DArray@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
jmp    12d3 <main+0x133>
mov    (%r12),%rsi
lea    0xd80(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12d3 <main+0x133>
lea    0xd4e(%rip),%rsi
mov    %ebx,%edx
call   1070 <fprintf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd98(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12d3 <main+0x133>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"tp\00"
@optopt = global i32 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.2 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@.str.3 = [32 x i8] c"Usage: %s [-t -p] rows columns\0A\00"
@optind = global i64 0
@.str.4 = [40 x i8] c"\0AComputing with %d rows and %d columns\0A\00"
@.str.5 = [26 x i8] c"FAILED building colimacon\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32 0, i32* %8
store i32 1, i32* %9
br label %12
12: ; preds = %36, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %7
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %37
17: ; preds = %12
%18 = load i32, i32* %7
switch i32 %18, label %34 [
i32 116, label %19
i32 112, label %20
i32 63, label %21
]
19: ; preds = %17
store i32 1, i32* %8
br label %36
20: ; preds = %17
store i32 0, i32* %9
br label %36
21: ; preds = %17
%22 = load i32, i32* @optopt
%23 = call i32 @isprint(i32 %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = load i32, i32* @optopt
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %33
29: ; preds = %21
%30 = load i32, i32* @stderr
%31 = load i32, i32* @optopt
%32 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %29, %25
store i32 1, i32* %3
br label %93
34: ; preds = %17
%35 = call i32 (...) @abort()
unreachable
36: ; preds = %20, %19
br label %12
37: ; preds = %12
%38 = load i32, i32* %8
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 (...) @run_all_tests()
br label %42
42: ; preds = %40, %37
%43 = load i32, i32* %4
%44 = icmp slt i32 %43, 3
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 0
%48 = load i8*, i8** %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %48)
store i32 1, i32* %3
br label %93
50: ; preds = %42
%51 = load i8**, i8*** %5
%52 = load i64, i64* @optind
%53 = getelementptr inbounds i8*, i8** %51, i64 %52
%54 = load i8*, i8** %53
%55 = call i32 @atoi(i8* %54)
store i32 %55, i32* %10
%56 = load i8**, i8*** %5
%57 = load i64, i64* @optind
%58 = add i64 %57, 1
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @atoi(i8* %60)
store i32 %61, i32* %11
%62 = load i32, i32* %10
%63 = icmp ult i32 %62, 1
br i1 %63, label %67, label %64
64: ; preds = %50
%65 = load i32, i32* %11
%66 = icmp ult i32 %65, 1
br i1 %66, label %67, label %72
67: ; preds = %64, %50
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 0
%70 = load i8*, i8** %69
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %70)
store i32 1, i32* %3
br label %93
72: ; preds = %64
%73 = load i32, i32* %10
%74 = load i32, i32* %11
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %73, i32 %74)
%76 = load i32, i32* %10
%77 = load i32, i32* %11
%78 = call i64 @colimacon(i32** %6, i32 %76, i32 %77)
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %72
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %93
82: ; preds = %72
%83 = load i32, i32* %9
%84 = icmp eq i32 %83, 1
br i1 %84, label %85, label %90
85: ; preds = %82
%86 = load i32*, i32** %6
%87 = load i32, i32* %10
%88 = load i32, i32* %11
%89 = call i32 @print2DArray(i32* %86, i32 %87, i32 %88)
br label %90
90: ; preds = %85, %82
%91 = load i32*, i32** %6
%92 = call i32 @free(i32* %91)
store i32 1, i32* %3
br label %93
93: ; preds = %90, %80, %67, %45, %33
%94 = load i32, i32* %3
ret i32 %94
}

LLVM IR (-O2):
@.str = [3 x i8] c"tp\00"
@optopt = global i32 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.2 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@.str.3 = [32 x i8] c"Usage: %s [-t -p] rows columns\0A\00"
@optind = global i64 0
@.str.4 = [40 x i8] c"\0AComputing with %d rows and %d columns\0A\00"
@.str.5 = [26 x i8] c"FAILED building colimacon\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32*
%4 = bitcast i32** %3 to i8*
store i32* null, i32** %3
br label %5
5: ; preds = %8, %2
%6 = phi i1 [ true, %2 ], [ false, %8 ]
%7 = phi i32 [ 0, %2 ], [ %9, %8 ]
br label %8
8: ; preds = %5, %8
%9 = phi i32 [ 1, %8 ], [ %7, %5 ]
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %10, label %20 [
i32 -1, label %22
i32 116, label %8
i32 112, label %5
i32 63, label %11
]
11: ; preds = %8
%12 = load i32, i32* @optopt
%13 = tail call i32 @isprint(i32 %12)
%14 = icmp eq i32 %13, 0
%15 = load i32, i32* @stderr
br i1 %14, label %18, label %16
16: ; preds = %11
%17 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %59
18: ; preds = %11
%19 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %59
20: ; preds = %8
%21 = tail call i32 (...) @abort()
unreachable
22: ; preds = %8
%23 = icmp eq i32 %9, 1
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = tail call i32 (...) @run_all_tests()
br label %26
26: ; preds = %24, %22
%27 = icmp slt i32 %0, 3
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = load i8*, i8** %1
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %29)
br label %59
31: ; preds = %26
%32 = load i64, i64* @optind
%33 = getelementptr inbounds i8*, i8** %1, i64 %32
%34 = load i8*, i8** %33
%35 = tail call i32 @atoi(i8* %34)
%36 = add i64 %32, 1
%37 = getelementptr inbounds i8*, i8** %1, i64 %36
%38 = load i8*, i8** %37
%39 = tail call i32 @atoi(i8* %38)
%40 = icmp eq i32 %35, 0
%41 = icmp eq i32 %39, 0
%42 = select i1 %40, i1 true, i1 %41
br i1 %42, label %43, label %46
43: ; preds = %31
%44 = load i8*, i8** %1
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %44)
br label %59
46: ; preds = %31
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %35, i32 %39)
%48 = call i64 @colimacon(i32** %3, i32 %35, i32 %39)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %59
52: ; preds = %46
br i1 %6, label %53, label %56
53: ; preds = %52
%54 = load i32*, i32** %3
%55 = call i32 @print2DArray(i32* %54, i32 %35, i32 %39)
br label %56
56: ; preds = %53, %52
%57 = load i32*, i32** %3
%58 = call i32 @free(i32* %57)
br label %59
59: ; preds = %16, %18, %56, %50, %43, %28
ret i32 1
}