#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*/ printf(char *, ...);
void printMatrixList(int *pdata, int size, int left, int right) {
  if (left == right) {
    printf("M%d", left);
  } else if ((left + 1) == right) {
    printf("(M%d x M%d)", left, right);
  } else {
    int intermediate = *(pdata + left * size + right);
    printf("(");
    printMatrixList(pdata, size, left, intermediate);
    printf(" x ");
    printMatrixList(pdata, size, intermediate + 1, right);
    printf(")");
  }
}


x86 assembly (clang, -O0):
<printMatrixList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1157 <printMatrixList+0x37>
mov    -0x10(%rbp),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f4 <printMatrixList+0xd4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cmp    -0x14(%rbp),%eax
jne    117f <printMatrixList+0x5f>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ef <printMatrixList+0xcf>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0xc(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <printMatrixList@plt>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
add    $0x1,%edx
mov    -0x14(%rbp),%ecx
call   1040 <printMatrixList@plt>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f4 <printMatrixList+0xd4>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMatrixList>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
cmp    %ecx,%edx
jne    1156 <printMatrixList+0x26>
lea    0xebb(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
mov    %ecx,%ebx
lea    0x1(%rbp),%eax
cmp    %ecx,%eax
jne    1179 <printMatrixList+0x49>
lea    0xe9e(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
mov    %esi,%r14d
mov    %rdi,%r15
mov    %ebp,%eax
imul   %esi,%eax
cltq
lea    (%rdi,%rax,4),%rax
movslq %ebx,%rcx
mov    (%rax,%rcx,4),%r12d
mov    $0x28,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
call   1050 <printMatrixList@plt>
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12d
mov    %r15,%rdi
mov    %r14d,%esi
mov    %r12d,%edx
mov    %ebx,%ecx
call   1050 <printMatrixList@plt>
mov    $0x29,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"M%d\00"
@.str.1 = [12 x i8] c"(M%d x M%d)\00"
@.str.2 = [2 x i8] c"(\00"
@.str.3 = [4 x i8] c" x \00"
@.str.4 = [2 x i8] c")\00"
define void @printMatrixList(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
%11 = load i32, i32* %8
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = load i32, i32* %7
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %49
16: ; preds = %4
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 1
%19 = load i32, i32* %8
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23)
br label %48
25: ; preds = %16
%26 = load i32*, i32** %5
%27 = load i32, i32* %7
%28 = load i32, i32* %6
%29 = mul nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %26, i64 %30
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
store i32 %35, i32* %9
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32*, i32** %5
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = load i32, i32* %9
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%42 = load i32*, i32** %5
%43 = load i32, i32* %6
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
%46 = load i32, i32* %8
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %48
48: ; preds = %25, %21
br label %49
49: ; preds = %48, %13
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"M%d\00"
@.str.1 = [12 x i8] c"(M%d x M%d)\00"
@.str.3 = [4 x i8] c" x \00"
define void @printMatrixList(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %2, %3
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %13
8: ; preds = %4
%9 = add nsw i32 %2, 1
%10 = icmp eq i32 %9, %3
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %3)
br label %13
13: ; preds = %6, %11, %14
ret void
14: ; preds = %8
%15 = mul nsw i32 %2, %1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %0, i64 %16
%18 = sext i32 %3 to i64
%19 = getelementptr inbounds i32, i32* %17, i64 %18
%20 = load i32, i32* %19
%21 = tail call i32 @putchar(i32 40)
tail call void @printMatrixList(i32* %0, i32 %1, i32 %2, i32 %20)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%23 = add nsw i32 %20, 1
tail call void @printMatrixList(i32* %0, i32 %1, i32 %23, i32 %3)
%24 = tail call i32 @putchar(i32 41)
br label %13
}