#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 /*<<< orphan*/ COM_MatchToken(char **, char *);
int /*<<< orphan*/ Parse1DMatrix(char **, int, float *);
void Parse2DMatrix(char **buf_p, int y, int x, float *m) {
  int i;
  COM_MatchToken(buf_p, "(");
  for (i = 0; i < y; i++) {
    Parse1DMatrix(buf_p, x, m + i * x);
  }
  COM_MatchToken(buf_p, ")");
}


x86 assembly (clang, -O0):
<Parse2DMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1040 <COM_MatchToken@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1187 <Parse2DMatrix+0x67>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
call   1030 <Parse1DMatrix@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114d <Parse2DMatrix+0x2d>
mov    -0x8(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1040 <COM_MatchToken@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Parse2DMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %edx,%r12d
mov    %esi,%r15d
mov    %rdi,%r14
lea    0xec2(%rip),%rsi
call   1040 <COM_MatchToken@plt>
test   %r15d,%r15d
jle    1177 <Parse2DMatrix+0x57>
movslq %r12d,%r13
mov    %r15d,%ebp
shl    $0x2,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
call   1030 <Parse1DMatrix@plt>
add    %r13,%rbx
add    $0xffffffffffffffff,%rbp
jne    1160 <Parse2DMatrix+0x40>
lea    0xe84(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <COM_MatchToken@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"(\00"
@.str.1 = [2 x i8] c")\00"
define void @Parse2DMatrix(i8** %0, i32 %1, i32 %2, float* %3) {
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca float*
%9 = alloca i32
store i8** %0, i8*** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store float* %3, float** %8
%10 = load i8**, i8*** %5
%11 = call i32 @COM_MatchToken(i8** %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %12
12: ; preds = %26, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = load i32, i32* %7
%19 = load float*, float** %8
%20 = load i32, i32* %9
%21 = load i32, i32* %7
%22 = mul nsw i32 %20, %21
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float, float* %19, i64 %23
%25 = call i32 @Parse1DMatrix(i8** %17, i32 %18, float* %24)
br label %26
26: ; preds = %16
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
br label %12
29: ; preds = %12
%30 = load i8**, i8*** %5
%31 = call i32 @COM_MatchToken(i8** %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"(\00"
@.str.1 = [2 x i8] c")\00"
define void @Parse2DMatrix(i8** %0, i32 %1, i32 %2, float* %3) {
%5 = tail call i32 @COM_MatchToken(i8** %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %17
7: ; preds = %4
%8 = sext i32 %2 to i64
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 0, %7 ], [ %15, %10 ]
%12 = mul nsw i64 %11, %8
%13 = getelementptr inbounds float, float* %3, i64 %12
%14 = tail call i32 @Parse1DMatrix(i8** %0, i32 %2, float* %13)
%15 = add nuw nsw i64 %11, 1
%16 = icmp eq i64 %15, %9
br i1 %16, label %17, label %10
17: ; preds = %10, %4
%18 = tail call i32 @COM_MatchToken(i8** %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}