#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 *, char *);
int /*<<< orphan*/ strcat(char *, char *);
void PrintBrackets(char output[], int n, int i, int j) {
  if (i == n && j == n)
    printf("\n%s", output);
  else {
    if (i < n) {
      char newoutput_open[20] = "";
      strcat(newoutput_open, output);
      strcat(newoutput_open, "{");
      PrintBrackets(newoutput_open, n, i + 1, j);
    }
    if (j < n && i > j) {
      char newoutput_close[20] = "";
      strcat(newoutput_close, output);
      strcat(newoutput_close, "}");
      PrintBrackets(newoutput_close, n, i, j + 1);
    }
  }
}


x86 assembly (clang, -O0):
<PrintBrackets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1182 <PrintBrackets+0x42>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1182 <PrintBrackets+0x42>
mov    -0x8(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
jmp    122f <PrintBrackets+0xef>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d0 <PrintBrackets+0x90>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x30(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
mov    -0x14(%rbp),%ecx
call   1030 <PrintBrackets@plt>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    122a <PrintBrackets+0xea>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    122a <PrintBrackets+0xea>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x50(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x50(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
call   1030 <PrintBrackets@plt>
jmp    122f <PrintBrackets+0xef>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintBrackets>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%r15
cmp    %esi,%edx
jne    1169 <PrintBrackets+0x39>
cmp    %ebp,%ebx
jne    1169 <PrintBrackets+0x39>
lea    0xeab(%rip),%rdi
mov    %r15,%rsi
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
cmp    %ebp,%r14d
jge    11aa <PrintBrackets+0x7a>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
lea    0xe72(%rip),%rsi
mov    %r12,%rdi
call   1050 <strcat@plt>
lea    0x1(%r14),%edx
mov    %r12,%rdi
mov    %ebp,%esi
mov    %ebx,%ecx
call   1030 <PrintBrackets@plt>
cmp    %ebp,%ebx
jge    11f1 <PrintBrackets+0xc1>
cmp    %ebx,%r14d
jle    11f1 <PrintBrackets+0xc1>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
lea    0xe2f(%rip),%rsi
mov    %r12,%rdi
call   1050 <strcat@plt>
add    $0x1,%ebx
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1030 <PrintBrackets@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"\0A%s\00"
@.str.1 = [2 x i8] c"{\00"
@.str.2 = [2 x i8] c"}\00"
define void @PrintBrackets(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [20 x i8]
%6 = alloca [20 x i8]
%7 = icmp eq i32 %2, %1
%8 = icmp eq i32 %3, %1
%9 = and i1 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %28
12: ; preds = %4
%13 = icmp slt i32 %2, %1
br i1 %13, label %14, label %19
14: ; preds = %12
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%16 = call i32 @strcat(i8* %15, i8* %0)
%17 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = add nsw i32 %2, 1
br label %19
19: ; preds = %14, %12
%20 = icmp slt i32 %3, %1
%21 = icmp sgt i32 %2, %3
%22 = and i1 %20, %21
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%25 = call i32 @strcat(i8* %24, i8* %0)
%26 = call i32 @strcat(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%27 = add nsw i32 %3, 1
br label %28
28: ; preds = %19, %23, %10
ret void
}