#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 getBadColumnId(char **, int, int);
int /*<<< orphan*/ printLetters(char **, int, int);
int /*<<< orphan*/ printf(char *, ...);
char **readArgs(int *, int *, int, char **);
char **removeColumn(int, char **, int *, int *);
int main(int argc, char *argv[]) {
  char **letters;
  int n;
  int m;
  int result = 0;
  int badTableColumnId;
  if (1 == 0)
    printf("\nP3 - Removing Columns:\n");
  letters = readArgs(&n, &m, argc, argv);
  if (1 == 0)
    printLetters(letters, n, m);
  if (n < 1 || m < 1 || n > 100 || m > 100) {
    printf("Invalid table size. Aborting...\n");
    printf("\n--------------------\n");
    return 1;
  }
  if (1 == 0)
    printf("\nProblem Solution:\n");
  badTableColumnId = getBadColumnId(letters, n, m);
  while (badTableColumnId > -1) {
    letters = removeColumn(badTableColumnId, letters, &n, &m);
    badTableColumnId = getBadColumnId(letters, n, m);
    result++;
    if (1 == 0)
      printLetters(letters, n, m);
  }
  printf("%d", result);
  if (1 == 0)
    printf("\n--------------------\n");
  return 0;
}


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)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <readArgs@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jl     119d <main+0x5d>
cmpl   $0x1,-0x20(%rbp)
jl     119d <main+0x5d>
cmpl   $0x64,-0x1c(%rbp)
jg     119d <main+0x5d>
cmpl   $0x64,-0x20(%rbp)
jle    11c5 <main+0x85>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1231 <main+0xf1>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <getBadColumnId@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jle    1219 <main+0xd9>
mov    -0x28(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1050 <removeColumn@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <getBadColumnId@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d7 <main+0x97>
mov    -0x24(%rbp),%esi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-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,%rcx
mov    %edi,%edx
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1070 <readArgs@plt>
mov    0xc(%rsp),%esi
cmp    $0x64,%esi
jg     11ec <main+0x9c>
test   %esi,%esi
jle    11ec <main+0x9c>
mov    0x8(%rsp),%edx
test   %edx,%edx
jle    11ec <main+0x9c>
cmp    $0x65,%edx
jge    11ec <main+0x9c>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <getBadColumnId@plt>
xor    %r14d,%r14d
mov    $0x0,%ebp
test   %eax,%eax
js     11da <main+0x8a>
xor    %ebp,%ebp
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
nopl   (%rax)
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1060 <removeColumn@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %rax,%rdi
call   1050 <getBadColumnId@plt>
add    $0x1,%ebp
test   %eax,%eax
jns    11b0 <main+0x60>
lea    0xe1f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    120a <main+0xba>
lea    0xe10(%rip),%rdi
call   1030 <puts@plt>
lea    0xe24(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Invalid table size. Aborting...\0A\00"
@.str.1 = [23 x i8] c"\0A--------------------\0A\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i8** @readArgs(i32* %7, i32* %8, i32 %11, i8** %12)
store i8** %13, i8*** %6
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 1
br i1 %15, label %25, label %16
16: ; preds = %2
%17 = load i32, i32* %8
%18 = icmp slt i32 %17, 1
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = load i32, i32* %7
%21 = icmp sgt i32 %20, 100
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = load i32, i32* %8
%24 = icmp sgt i32 %23, 100
br i1 %24, label %25, label %28
25: ; preds = %22, %19, %16, %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %49
28: ; preds = %22
%29 = load i8**, i8*** %6
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = call i32 @getBadColumnId(i8** %29, i32 %30, i32 %31)
store i32 %32, i32* %10
br label %33
33: ; preds = %36, %28
%34 = load i32, i32* %10
%35 = icmp sgt i32 %34, -1
br i1 %35, label %36, label %46
36: ; preds = %33
%37 = load i32, i32* %10
%38 = load i8**, i8*** %6
%39 = call i8** @removeColumn(i32 %37, i8** %38, i32* %7, i32* %8)
store i8** %39, i8*** %6
%40 = load i8**, i8*** %6
%41 = load i32, i32* %7
%42 = load i32, i32* %8
%43 = call i32 @getBadColumnId(i8** %40, i32 %41, i32 %42)
store i32 %43, i32* %10
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %33
46: ; preds = %33
%47 = load i32, i32* %9
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %47)
store i32 0, i32* %3
br label %49
49: ; preds = %46, %25
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@str = [32 x i8] c"Invalid table size. Aborting...\00"
@str.3 = [22 x i8] c"\0A--------------------\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i8** @readArgs(i32* %3, i32* %4, i32 %0, i8** %1)
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 1
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 1
%12 = select i1 %9, i1 true, i1 %11
%13 = icmp sgt i32 %8, 100
%14 = or i1 %13, %12
%15 = icmp sgt i32 %10, 100
%16 = select i1 %14, i1 true, i1 %15
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.3, i64 0, i64 0))
br label %36
20: ; preds = %2
%21 = call i32 @getBadColumnId(i8** %7, i32 %8, i32 %10)
%22 = icmp sgt i32 %21, -1
br i1 %22, label %23, label %33
23: ; preds = %20, %23
%24 = phi i32 [ %30, %23 ], [ %21, %20 ]
%25 = phi i32 [ %31, %23 ], [ 0, %20 ]
%26 = phi i8** [ %27, %23 ], [ %7, %20 ]
%27 = call i8** @removeColumn(i32 %24, i8** %26, i32* %3, i32* %4)
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = call i32 @getBadColumnId(i8** %27, i32 %28, i32 %29)
%31 = add nuw nsw i32 %25, 1
%32 = icmp sgt i32 %30, -1
br i1 %32, label %23, label %33
33: ; preds = %23, %20
%34 = phi i32 [ 0, %20 ], [ %31, %23 ]
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %17
%37 = phi i32 [ 1, %17 ], [ 0, %33 ]
ret i32 %37
}