#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 */
typedef int /*<<< orphan*/ level;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int shortestLadder(char **, int, int, int, int);
int strlen(char *);
void main() {
  char *level[] = {"XXXX....", "...X.XXX", "XXX..X..", "......X.", "XXXXXXXX"};
  int coinRow = 2;
  int coinCol = 5;
  int rows = sizeof(level) / sizeof(level[0]);
  int cols = strlen(level[0]);
  int res = shortestLadder(level, rows, cols, coinRow, coinCol);
  printf("Min ladder length is %d", res);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
lea    0xea1(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe9f(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe9d(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe9b(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe99(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x2,-0x34(%rbp)
movl   $0x5,-0x38(%rbp)
movl   $0x5,-0x3c(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%r8d
call   1060 <shortestLadder@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%esi
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xec5(%rip),%rdi
mov    %rdi,(%rsp)
lea    0xec3(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xec0(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xebd(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xeba(%rip),%rax
mov    %rax,0x20(%rsp)
call   1030 <strlen@plt>
mov    %rsp,%rdi
mov    $0x5,%esi
mov    %eax,%edx
mov    $0x2,%ecx
mov    $0x5,%r8d
call   1050 <shortestLadder@plt>
lea    0xe98(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"XXXX....\00"
@.str.1 = [9 x i8] c"...X.XXX\00"
@.str.2 = [9 x i8] c"XXX..X..\00"
@.str.3 = [9 x i8] c"......X.\00"
@.str.4 = [9 x i8] c"XXXXXXXX\00"
@.str.5 = [24 x i8] c"Min ladder length is %d\00"
define void @main() {
%1 = alloca [5 x i8*]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast [5 x i8*]* %1 to i8*
%8 = bitcast i8* %7 to [5 x i8*]*
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %8, i32 0, i32 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %8, i32 0, i32 1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %8, i32 0, i32 2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %8, i32 0, i32 3
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %8, i32 0, i32 4
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i32 0, i32 0), i8** %13
store i32 2, i32* %2
store i32 5, i32* %3
store i32 5, i32* %4
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %5
%17 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 0
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = call i32 @shortestLadder(i8** %17, i32 %18, i32 %19, i32 %20, i32 %21)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %23)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"XXXX....\00"
@.str.1 = [9 x i8] c"...X.XXX\00"
@.str.2 = [9 x i8] c"XXX..X..\00"
@.str.3 = [9 x i8] c"......X.\00"
@.str.4 = [9 x i8] c"XXXXXXXX\00"
@.str.5 = [24 x i8] c"Min ladder length is %d\00"
define void @main() {
%1 = alloca [5 x i8*]
%2 = bitcast [5 x i8*]* %1 to i8*
%3 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 3
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %1, i64 0, i64 4
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8** %7
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @shortestLadder(i8** %3, i32 5, i32 %8, i32 2, i32 5)
%10 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %9)
ret void
}