#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 */
scalar_t__ matExtract1D(char const *, int, double *);
scalar_t__ matExtract2D(char const *, int, int, double *);
int matExtractMatrix(const char *s, int *d1, int *d2, double *res) {
  int ret = -1;
  if (matExtract1D(s, 3, res) == 0) {
    (*d1) = 3;
    (*d2) = 1;
    ret = 0;
  } else if (matExtract1D(s, 4, res) == 0) {
    (*d1) = 4;
    (*d2) = 1;
    ret = 0;
  } else if (matExtract2D(s, 2, 3, res) == 0) {
    (*d1) = 3;
    (*d2) = 2;
    ret = 0;
  } else if (matExtract2D(s, 3, 3, res) == 0) {
    (*d1) = 3;
    (*d2) = 3;
    ret = 0;
  } else if (matExtract2D(s, 4, 3, res) == 0) {
    (*d1) = 3;
    (*d2) = 4;
    ret = 0;
  } else if (matExtract2D(s, 4, 4, res) == 0) {
    (*d1) = 4;
    (*d2) = 4;
    ret = 0;
  }
  return ret;
}


x86 assembly (clang, -O0):
<matExtractMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x3,%esi
call   1030 <matExtract1D@plt>
cmp    $0x0,%rax
jne    117b <matExtractMatrix+0x5b>
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x0,-0x24(%rbp)
jmp    12c9 <matExtractMatrix+0x1a9>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x4,%esi
call   1030 <matExtract1D@plt>
cmp    $0x0,%rax
jne    11b7 <matExtractMatrix+0x97>
mov    -0x10(%rbp),%rax
movl   $0x4,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x0,-0x24(%rbp)
jmp    12c4 <matExtractMatrix+0x1a4>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x2,%esi
mov    $0x3,%edx
call   1040 <matExtract2D@plt>
cmp    $0x0,%rax
jne    11f8 <matExtractMatrix+0xd8>
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
movl   $0x0,-0x24(%rbp)
jmp    12bf <matExtractMatrix+0x19f>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x3,%edx
mov    %edx,%esi
call   1040 <matExtract2D@plt>
cmp    $0x0,%rax
jne    1236 <matExtractMatrix+0x116>
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
movl   $0x0,-0x24(%rbp)
jmp    12ba <matExtractMatrix+0x19a>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x4,%esi
mov    $0x3,%edx
call   1040 <matExtract2D@plt>
cmp    $0x0,%rax
jne    1277 <matExtractMatrix+0x157>
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x4,(%rax)
movl   $0x0,-0x24(%rbp)
jmp    12b5 <matExtractMatrix+0x195>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x4,%edx
mov    %edx,%esi
call   1040 <matExtract2D@plt>
cmp    $0x0,%rax
jne    12b0 <matExtractMatrix+0x190>
mov    -0x10(%rbp),%rax
movl   $0x4,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x4,(%rax)
movl   $0x0,-0x24(%rbp)
jmp    12b5 <matExtractMatrix+0x195>
jmp    12ba <matExtractMatrix+0x19a>
jmp    12bf <matExtractMatrix+0x19f>
jmp    12c4 <matExtractMatrix+0x1a4>
jmp    12c9 <matExtractMatrix+0x1a9>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matExtractMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x3,%r13d
mov    $0x3,%esi
mov    %rcx,%rdx
call   1030 <matExtract1D@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1213 <matExtractMatrix+0xf3>
mov    $0x4,%r13d
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r12,%rdx
call   1030 <matExtract1D@plt>
test   %rax,%rax
je     1213 <matExtractMatrix+0xf3>
mov    $0x2,%ebp
mov    $0x3,%r13d
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
mov    %r12,%rcx
call   1040 <matExtract2D@plt>
test   %rax,%rax
je     1213 <matExtractMatrix+0xf3>
mov    $0x3,%r13d
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
mov    %r12,%rcx
call   1040 <matExtract2D@plt>
mov    $0x3,%ebp
test   %rax,%rax
je     1213 <matExtractMatrix+0xf3>
mov    $0x4,%ebp
mov    $0x3,%r13d
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x3,%edx
mov    %r12,%rcx
call   1040 <matExtract2D@plt>
test   %rax,%rax
je     1213 <matExtractMatrix+0xf3>
mov    $0x4,%r13d
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x4,%edx
mov    %r12,%rcx
call   1040 <matExtract2D@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
mov    $0x4,%ebp
test   %rcx,%rcx
jne    121b <matExtractMatrix+0xfb>
mov    %r13d,(%r15)
mov    %ebp,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @matExtractMatrix(i8* %0, i32* %1, i32* %2, double* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca double*
%9 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store double* %3, double** %8
store i32 -1, i32* %9
%10 = load i8*, i8** %5
%11 = load double*, double** %8
%12 = call i64 @matExtract1D(i8* %10, i32 3, double* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = load i32*, i32** %6
store i32 3, i32* %15
%16 = load i32*, i32** %7
store i32 1, i32* %16
store i32 0, i32* %9
br label %62
17: ; preds = %4
%18 = load i8*, i8** %5
%19 = load double*, double** %8
%20 = call i64 @matExtract1D(i8* %18, i32 4, double* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i32*, i32** %6
store i32 4, i32* %23
%24 = load i32*, i32** %7
store i32 1, i32* %24
store i32 0, i32* %9
br label %61
25: ; preds = %17
%26 = load i8*, i8** %5
%27 = load double*, double** %8
%28 = call i64 @matExtract2D(i8* %26, i32 2, i32 3, double* %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load i32*, i32** %6
store i32 3, i32* %31
%32 = load i32*, i32** %7
store i32 2, i32* %32
store i32 0, i32* %9
br label %60
33: ; preds = %25
%34 = load i8*, i8** %5
%35 = load double*, double** %8
%36 = call i64 @matExtract2D(i8* %34, i32 3, i32 3, double* %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i32*, i32** %6
store i32 3, i32* %39
%40 = load i32*, i32** %7
store i32 3, i32* %40
store i32 0, i32* %9
br label %59
41: ; preds = %33
%42 = load i8*, i8** %5
%43 = load double*, double** %8
%44 = call i64 @matExtract2D(i8* %42, i32 4, i32 3, double* %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %41
%47 = load i32*, i32** %6
store i32 3, i32* %47
%48 = load i32*, i32** %7
store i32 4, i32* %48
store i32 0, i32* %9
br label %58
49: ; preds = %41
%50 = load i8*, i8** %5
%51 = load double*, double** %8
%52 = call i64 @matExtract2D(i8* %50, i32 4, i32 4, double* %51)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = load i32*, i32** %6
store i32 4, i32* %55
%56 = load i32*, i32** %7
store i32 4, i32* %56
store i32 0, i32* %9
br label %57
57: ; preds = %54, %49
br label %58
58: ; preds = %57, %46
br label %59
59: ; preds = %58, %38
br label %60
60: ; preds = %59, %30
br label %61
61: ; preds = %60, %22
br label %62
62: ; preds = %61, %14
%63 = load i32, i32* %9
ret i32 %63
}

LLVM IR (-O2):
define i32 @matExtractMatrix(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, double* %3) {
%5 = tail call i64 @matExtract1D(i8* %0, i32 3, double* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %22, label %7
7: ; preds = %4
%8 = tail call i64 @matExtract1D(i8* %0, i32 4, double* %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %7
%11 = tail call i64 @matExtract2D(i8* %0, i32 2, i32 3, double* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = tail call i64 @matExtract2D(i8* %0, i32 3, i32 3, double* %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = tail call i64 @matExtract2D(i8* %0, i32 4, i32 3, double* %3)
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call i64 @matExtract2D(i8* %0, i32 4, i32 4, double* %3)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19, %16, %13, %10, %7, %4
%23 = phi i32 [ 3, %4 ], [ 4, %7 ], [ 3, %10 ], [ 3, %13 ], [ 3, %16 ], [ 4, %19 ]
%24 = phi i32 [ 1, %4 ], [ 1, %7 ], [ 2, %10 ], [ 3, %13 ], [ 4, %16 ], [ 4, %19 ]
store i32 %23, i32* %1
store i32 %24, i32* %2
br label %25
25: ; preds = %22, %19
%26 = phi i32 [ -1, %19 ], [ 0, %22 ]
ret i32 %26
}