#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 compare2Rows(char *, char *, int);
int getBadColumnId(char **letters, int n, int m) {
  int loop;
  int compareResult;
  for (loop = 0; loop < n - 1; loop++) {
    compareResult = compare2Rows(letters[loop], letters[loop + 1], m);
    if (compareResult != -1)
      return compareResult;
  }
  return -1;
}


x86 assembly (clang, -O0):
<getBadColumnId>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    118a <getBadColumnId+0x7a>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%edx
call   1030 <compare2Rows@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
je     1177 <getBadColumnId+0x67>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1191 <getBadColumnId+0x81>
jmp    117c <getBadColumnId+0x6c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1129 <getBadColumnId+0x19>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getBadColumnId>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbp
add    $0xffffffff,%r15d
xor    %ecx,%ecx
test   %r15d,%r15d
cmovle %ecx,%r15d
nopl   (%rax)
cmp    %rcx,%r15
je     1155 <getBadColumnId+0x45>
lea    0x1(%rcx),%rbx
mov    0x0(%rbp,%rcx,8),%rdi
mov    0x8(%rbp,%rcx,8),%rsi
mov    %r14d,%edx
call   1030 <compare2Rows@plt>
mov    %rbx,%rcx
cmp    $0xffffffff,%eax
je     1130 <getBadColumnId+0x20>
jmp    115a <getBadColumnId+0x4a>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getBadColumnId(i8** %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8** %0, i8*** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %10
10: ; preds = %34, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %6
%13 = sub nsw i32 %12, 1
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %37
15: ; preds = %10
%16 = load i8**, i8*** %5
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = load i8**, i8*** %5
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %21, i64 %24
%26 = load i8*, i8** %25
%27 = load i32, i32* %7
%28 = call i32 @compare2Rows(i8* %20, i8* %26, i32 %27)
store i32 %28, i32* %9
%29 = load i32, i32* %9
%30 = icmp ne i32 %29, -1
br i1 %30, label %31, label %33
31: ; preds = %15
%32 = load i32, i32* %9
store i32 %32, i32* %4
br label %38
33: ; preds = %15
br label %34
34: ; preds = %33
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %10
37: ; preds = %10
store i32 -1, i32* %4
br label %38
38: ; preds = %37, %31
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
define i32 @getBadColumnId(i8** nocapture %0, i32 %1, i32 %2) {
%4 = add i32 %1, -1
%5 = call i32 @llvm.smax.i32(i32 %4, i32 0)
%6 = zext i32 %5 to i64
br label %7
7: ; preds = %10, %3
%8 = phi i64 [ %13, %10 ], [ 0, %3 ]
%9 = icmp eq i64 %8, %6
br i1 %9, label %18, label %10
10: ; preds = %7
%11 = getelementptr inbounds i8*, i8** %0, i64 %8
%12 = load i8*, i8** %11
%13 = add nuw nsw i64 %8, 1
%14 = getelementptr inbounds i8*, i8** %0, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 @compare2Rows(i8* %12, i8* %15, i32 %2)
%17 = icmp eq i32 %16, -1
br i1 %17, label %7, label %18
18: ; preds = %7, %10
%19 = phi i32 [ %16, %10 ], [ -1, %7 ]
ret i32 %19
}