#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 PRINT_OPTIMAL_PARRNS(int **s, int i, int j, int row) {
  if (i == j)
    printf("A%d", i);
  else {
    printf("(");
    PRINT_OPTIMAL_PARRNS(s, i, *((int *)s + row * i + j), row);
    PRINT_OPTIMAL_PARRNS(s, *((int *)s + row * i + j) + 1, j, row);
    printf(")");
  }
}


x86 assembly (clang, -O0):
<PRINT_OPTIMAL_PARRNS>:
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    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1157 <PRINT_OPTIMAL_PARRNS+0x37>
mov    -0xc(%rbp),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11cc <PRINT_OPTIMAL_PARRNS+0xac>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0xc(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x14(%rbp),%ecx
call   1030 <PRINT_OPTIMAL_PARRNS@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0xc(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <PRINT_OPTIMAL_PARRNS@plt>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PRINT_OPTIMAL_PARRNS>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
cmp    %edx,%esi
jne    115f <PRINT_OPTIMAL_PARRNS+0x2f>
lea    0xeb8(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rdi,%r15
mov    $0x28,%edi
call   1030 <putchar@plt>
mov    %r14d,%eax
imul   %ebx,%eax
cltq
lea    (%r15,%rax,4),%r12
movslq %ebp,%r13
mov    (%r12,%r13,4),%edx
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14d,%ecx
call   1040 <PRINT_OPTIMAL_PARRNS@plt>
mov    (%r12,%r13,4),%esi
add    $0x1,%esi
mov    %r15,%rdi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1040 <PRINT_OPTIMAL_PARRNS@plt>
mov    $0x29,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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