#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_solution(int **s, int i, int j) {
  if (s[i][j] == -1)
    printf("%c", 'A' + i);
  else {
    printf("(");
    print_solution(s, i, s[i][j] - 1);
    printf("x");
    print_solution(s, s[i][j], j);
    printf(")");
  }
}


x86 assembly (clang, -O0):
<print_solution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
jne    1165 <print_solution+0x45>
mov    -0xc(%rbp),%esi
add    $0x41,%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d0 <print_solution+0xb0>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
sub    $0x1,%edx
call   1040 <print_solution@plt>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x10(%rbp),%edx
call   1040 <print_solution@plt>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_solution>:
push   %r15
push   %r14
push   %rbx
movslq %esi,%r15
mov    (%rdi,%r15,8),%rax
movslq %edx,%r14
cmpl   $0xffffffff,(%rax,%r14,4)
je     117d <print_solution+0x5d>
mov    %rdi,%rbx
mov    $0x28,%edi
call   1030 <putchar@plt>
mov    (%rbx,%r15,8),%rax
mov    (%rax,%r14,4),%edx
add    $0xffffffff,%edx
mov    %rbx,%rdi
mov    %r15d,%esi
call   1040 <print_solution@plt>
mov    $0x78,%edi
call   1030 <putchar@plt>
mov    (%rbx,%r15,8),%rax
mov    (%rax,%r14,4),%esi
mov    %rbx,%rdi
mov    %r14d,%edx
call   1040 <print_solution@plt>
mov    $0x29,%esi
jmp    1180 <print_solution+0x60>
add    $0x41,%esi
mov    %esi,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
define void @print_solution(i32** %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds i32*, i32** %0, i64 %4
%6 = load i32*, i32** %5
%7 = sext i32 %2 to i64
%8 = getelementptr inbounds i32, i32* %6, i64 %7
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = add nsw i32 %1, 65
br label %13
13: ; preds = %11, %16
%14 = phi i32 [ %12, %11 ], [ 41, %16 ]
%15 = tail call i32 @putchar(i32 %14)
ret void
16: ; preds = %3
%17 = tail call i32 @putchar(i32 40)
%18 = load i32*, i32** %5
%19 = getelementptr inbounds i32, i32* %18, i64 %7
%20 = load i32, i32* %19
%21 = add nsw i32 %20, -1
tail call void @print_solution(i32** %0, i32 %1, i32 %21)
%22 = tail call i32 @putchar(i32 120)
%23 = load i32*, i32** %5
%24 = getelementptr inbounds i32, i32* %23, i64 %7
%25 = load i32, i32* %24
tail call void @print_solution(i32** %0, i32 %25, i32 %2)
br label %13
}