#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 minCost(int **, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int m, n, i, j, cost[100][100];
  printf("Enter M & N: ");
  scanf("%d %d", &m, &n);
  for (i = 0; i < m; ++i) {
    for (j = 0; j < n; ++j) {
      scanf("%d", &cost[i][j]);
    }
  }
  printf("%d\n", minCost(cost, m, n));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11db <main+0xab>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c8 <main+0x98>
movslq -0x10(%rbp),%rax
lea    -0x9c60(%rbp),%rsi
imul   $0x190,%rax,%rax
add    %rax,%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1180 <main+0x50>
jmp    11cd <main+0x9d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116d <main+0x3d>
lea    -0x9c60(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <minCost@plt>
mov    %eax,%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x9c60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c50,%rsp
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
test   %esi,%esi
jle    11d5 <main+0xa5>
lea    0x10(%rsp),%r15
lea    0xe93(%rip),%r14
xor    %r12d,%r12d
jmp    11a3 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r12
movslq %esi,%rax
add    $0x190,%r15
cmp    %rax,%r12
jge    11d5 <main+0xa5>
test   %edx,%edx
jle    1190 <main+0x60>
mov    %r15,%r13
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rdx
add    $0x4,%r13
cmp    %rdx,%rbx
jl     11b0 <main+0x80>
mov    0xc(%rsp),%esi
jmp    1190 <main+0x60>
lea    0x10(%rsp),%rdi
call   1030 <minCost@plt>
lea    0xe2e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x9c50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Enter M & N: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [100 x [100 x i32]]
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
store i32 0, i32* %4
br label %9
9: ; preds = %30, %0
%10 = load i32, i32* %4
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %33
13: ; preds = %9
store i32 0, i32* %5
br label %14
14: ; preds = %26, %13
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %6, i64 0, i64 %20
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100 x i32], [100 x i32]* %21, i64 0, i64 %23
%25 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %14
29: ; preds = %14
br label %30
30: ; preds = %29
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %9
33: ; preds = %9
%34 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %6, i64 0, i64 0
%35 = bitcast [100 x i32]* %34 to i32**
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = call i32 @minCost(i32** %35, i32 %36, i32 %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %38)
ret i32 0
}

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