#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
void *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int uniquePathsWithObstacles(int **, int, int);
int main(int argc, char **argv) {
  if (argc < 3) {
    fprintf(stderr, "Usage: ./test m n\n");
    exit(-1);
  }
  int i, j, k = 3;
  int row_size = atoi(argv[1]);
  int col_size = atoi(argv[2]);
  int **grids = malloc(row_size * sizeof(int *));
  for (i = 0; i < row_size; i++) {
    grids[i] = malloc(col_size * sizeof(int));
    int *line = grids[i];
    for (j = 0; j < col_size; j++) {
      line[j] = atoi(argv[k++]);
      printf("%d ", line[j]);
    }
    printf("\n");
  }
  printf("%d\n", uniquePathsWithObstacles(grids, row_size, col_size));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    119f <main+0x3f>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
movl   $0x3,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1298 <main+0x138>
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    127c <main+0x11c>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <atoi@plt>
mov    %eax,%edx
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1221 <main+0xc1>
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e0 <main+0x80>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1060 <uniquePathsWithObstacles@plt>
mov    %eax,%esi
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x2,%edi
jle    12a7 <main+0x137>
mov    %rsi,%r15
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%r15),%rdi
call   1080 <atoi@plt>
mov    %rax,0x8(%rsp)
lea    0x0(,%rbx,8),%edi
call   1060 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    %rbx,0x18(%rsp)
test   %ebx,%ebx
jle    1272 <main+0x102>
mov    0x8(%rsp),%rax
lea    0x0(,%rax,4),%ecx
mov    %ecx,0x10(%rsp)
mov    0x18(%rsp),%ecx
mov    %rcx,0x30(%rsp)
mov    %eax,%r12d
mov    $0x3,%r13d
lea    0xe29(%rip),%rbx
xor    %ebp,%ebp
mov    %r15,0x28(%rsp)
jmp    1215 <main+0xa5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    0x30(%rsp),%rbp
je     1272 <main+0x102>
mov    0x10(%rsp),%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    0x20(%rsp),%rax
mov    %r14,(%rax,%rbp,8)
cmpl   $0x0,0x8(%rsp)
jle    1200 <main+0x90>
mov    %r13d,0x14(%rsp)
movslq %r13d,%rax
lea    (%r15,%rax,8),%r13
xor    %r15d,%r15d
mov    0x0(%r13,%r15,8),%rdi
call   1080 <atoi@plt>
mov    %eax,(%r14,%r15,4)
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r12
jne    1240 <main+0xd0>
mov    0x14(%rsp),%r13d
add    %r15d,%r13d
mov    0x28(%rsp),%r15
jmp    1200 <main+0x90>
mov    0x20(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    0x8(%rsp),%rdx
call   1070 <uniquePathsWithObstacles@plt>
lea    0xd8a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
lea    0xd49(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: ./test m n\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"%d\0A\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**
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
store i32 3, i32* %8
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %9
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %10
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = mul i64 %29, 8
%31 = trunc i64 %30 to i32
%32 = call i8* @malloc(i32 %31)
%33 = bitcast i8* %32 to i32**
store i32** %33, i32*** %11
store i32 0, i32* %6
br label %34
34: ; preds = %81, %19
%35 = load i32, i32* %6
%36 = load i32, i32* %9
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %84
38: ; preds = %34
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = mul i64 %40, 4
%42 = trunc i64 %41 to i32
%43 = call i8* @malloc(i32 %42)
%44 = bitcast i8* %43 to i32*
%45 = load i32**, i32*** %11
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32*, i32** %45, i64 %47
store i32* %44, i32** %48
%49 = load i32**, i32*** %11
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32*, i32** %49, i64 %51
%53 = load i32*, i32** %52
store i32* %53, i32** %12
store i32 0, i32* %7
br label %54
54: ; preds = %76, %38
%55 = load i32, i32* %7
%56 = load i32, i32* %10
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %79
58: ; preds = %54
%59 = load i8**, i8*** %5
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds i8*, i8** %59, i64 %62
%64 = load i8*, i8** %63
%65 = call i32 @atoi(i8* %64)
%66 = load i32*, i32** %12
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %66, i64 %68
store i32 %65, i32* %69
%70 = load i32*, i32** %12
%71 = load i32, i32* %7
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i32, i32* %70, i64 %72
%74 = load i32, i32* %73
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %74)
br label %76
76: ; preds = %58
%77 = load i32, i32* %7
%78 = add nsw i32 %77, 1
store i32 %78, i32* %7
br label %54
79: ; preds = %54
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %81
81: ; preds = %79
%82 = load i32, i32* %6
%83 = add nsw i32 %82, 1
store i32 %83, i32* %6
br label %34
84: ; preds = %34
%85 = load i32**, i32*** %11
%86 = load i32, i32* %9
%87 = load i32, i32* %10
%88 = call i32 @uniquePathsWithObstacles(i32** %85, i32 %86, i32 %87)
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %88)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: ./test m n\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = shl i32 %11, 3
%16 = tail call i8* @malloc(i32 %15)
%17 = bitcast i8* %16 to i32**
%18 = icmp sgt i32 %11, 0
br i1 %18, label %19, label %51
19: ; preds = %8
%20 = shl i32 %14, 2
%21 = icmp sgt i32 %14, 0
%22 = zext i32 %11 to i64
%23 = zext i32 %14 to i64
br label %24
24: ; preds = %19, %46
%25 = phi i64 [ 0, %19 ], [ %49, %46 ]
%26 = phi i32 [ 3, %19 ], [ %47, %46 ]
%27 = tail call i8* @malloc(i32 %20)
%28 = bitcast i8* %27 to i32*
%29 = getelementptr inbounds i32*, i32** %17, i64 %25
%30 = bitcast i32** %29 to i8**
store i8* %27, i8** %30
br i1 %21, label %31, label %46
31: ; preds = %24
%32 = sext i32 %26 to i64
br label %33
33: ; preds = %31, %33
%34 = phi i64 [ %32, %31 ], [ %36, %33 ]
%35 = phi i64 [ 0, %31 ], [ %42, %33 ]
%36 = add nsw i64 %34, 1
%37 = getelementptr inbounds i8*, i8** %1, i64 %34
%38 = load i8*, i8** %37
%39 = tail call i32 @atoi(i8* %38)
%40 = getelementptr inbounds i32, i32* %28, i64 %35
store i32 %39, i32* %40
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%42 = add nuw nsw i64 %35, 1
%43 = icmp eq i64 %42, %23
br i1 %43, label %44, label %33
44: ; preds = %33
%45 = trunc i64 %36 to i32
br label %46
46: ; preds = %44, %24
%47 = phi i32 [ %26, %24 ], [ %45, %44 ]
%48 = tail call i32 @putchar(i32 10)
%49 = add nuw nsw i64 %25, 1
%50 = icmp eq i64 %49, %22
br i1 %50, label %51, label %24
51: ; preds = %46, %8
%52 = tail call i32 @uniquePathsWithObstacles(i32** %17, i32 %11, i32 %14)
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %52)
ret i32 0
}