#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_PARENS(int s[][100], int i, int j) {
  if (i == j)
    printf("A%d ", i);
  else {
    printf("(");
    PRINT_OPTIMAL_PARENS(s, i, s[i][j]);
    PRINT_OPTIMAL_PARENS(s, s[i][j] + 1, j);
    printf(")");
  }
}


x86 assembly (clang, -O0):
<PRINT_OPTIMAL_PARENS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1154 <PRINT_OPTIMAL_PARENS+0x34>
mov    -0xc(%rbp),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bd <PRINT_OPTIMAL_PARENS+0x9d>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
call   1030 <PRINT_OPTIMAL_PARENS@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1030 <PRINT_OPTIMAL_PARENS@plt>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

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

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