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


x86 assembly (clang, -O0):
<Parse3DMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1040 <COM_MatchToken@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1191 <Parse3DMatrix+0x71>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%eax
imul   -0x14(%rbp),%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rcx
call   1030 <Parse2DMatrix@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1150 <Parse3DMatrix+0x30>
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1040 <COM_MatchToken@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Parse3DMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,(%rsp)
mov    %ecx,%r15d
mov    %edx,%r13d
mov    %esi,%ebx
mov    %rdi,%r12
lea    0xebf(%rip),%rsi
call   1040 <COM_MatchToken@plt>
test   %ebx,%ebx
jle    1182 <Parse3DMatrix+0x62>
mov    %r15d,%ebp
imul   %r13d,%ebp
mov    %ebx,%ebx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
movslq %r14d,%r14
mov    (%rsp),%rax
lea    (%rax,%r14,4),%rcx
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
call   1030 <Parse2DMatrix@plt>
add    %ebp,%r14d
add    $0xffffffffffffffff,%rbx
jne    1160 <Parse3DMatrix+0x40>
lea    0xe79(%rip),%rsi
mov    %r12,%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 @Parse3DMatrix(i8** %0, i32 %1, i32 %2, i32 %3, float* %4) {
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca float*
%11 = alloca i32
store i8** %0, i8*** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store float* %4, float** %10
%12 = load i8**, i8*** %6
%13 = call i32 @COM_MatchToken(i8** %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %11
br label %14
14: ; preds = %31, %5
%15 = load i32, i32* %11
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %34
18: ; preds = %14
%19 = load i8**, i8*** %6
%20 = load i32, i32* %8
%21 = load i32, i32* %9
%22 = load float*, float** %10
%23 = load i32, i32* %11
%24 = load i32, i32* %9
%25 = mul nsw i32 %23, %24
%26 = load i32, i32* %8
%27 = mul nsw i32 %25, %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds float, float* %22, i64 %28
%30 = call i32 @Parse2DMatrix(i8** %19, i32 %20, i32 %21, float* %29)
br label %31
31: ; preds = %18
%32 = load i32, i32* %11
%33 = add nsw i32 %32, 1
store i32 %33, i32* %11
br label %14
34: ; preds = %14
%35 = load i8**, i8*** %6
%36 = call i32 @COM_MatchToken(i8** %35, 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 @Parse3DMatrix(i8** %0, i32 %1, i32 %2, i32 %3, float* %4) {
%6 = tail call i32 @COM_MatchToken(i8** %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = mul i32 %3, %2
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %8, %11
%12 = phi i64 [ 0, %8 ], [ %18, %11 ]
%13 = trunc i64 %12 to i32
%14 = mul i32 %9, %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds float, float* %4, i64 %15
%17 = tail call i32 @Parse2DMatrix(i8** %0, i32 %2, i32 %3, float* %16)
%18 = add nuw nsw i64 %12, 1
%19 = icmp eq i64 %18, %10
br i1 %19, label %20, label %11
20: ; preds = %11, %5
%21 = tail call i32 @COM_MatchToken(i8** %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}