#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 *);
void bracket(int pos, int n, int close, int open) {
  static char a[100];
  if (close == n) {
    printf("%s \n", a);
    return;
  } else {
    if (open > close) {
      a[pos] = '}';
      bracket(pos + 1, n, open, close + 1);
    }
    if (open < n) {
      a[pos] = '{';
      bracket(pos + 1, n, open + 1, close);
    }
  }
}


x86 assembly (clang, -O0):
<bracket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1158 <bracket+0x38>
lea    0xeb9(%rip),%rdi
lea    0x2ef2(%rip),%rsi
call   1030 <printf@plt>
jmp    11c1 <bracket+0xa1>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    118a <bracket+0x6a>
movslq -0x4(%rbp),%rcx
lea    0x2ed1(%rip),%rax
movb   $0x7d,(%rax,%rcx,1)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
call   1040 <bracket@plt>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bc <bracket+0x9c>
movslq -0x4(%rbp),%rcx
lea    0x2e9f(%rip),%rax
movb   $0x7b,(%rax,%rcx,1)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
mov    -0xc(%rbp),%ecx
call   1040 <bracket@plt>
jmp    11c1 <bracket+0xa1>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bracket>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    %esi,%edx
je     118b <bracket+0x6b>
mov    %ecx,%r12d
mov    %edx,%r15d
mov    %esi,%r14d
movslq %edi,%rax
lea    0x1(%rax),%ebx
lea    0x2efe(%rip),%rbp
add    %rax,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %r15d,%r12d
jle    116a <bracket+0x4a>
movb   $0x7d,0x0(%rbp)
lea    0x1(%r15),%ecx
mov    %ebx,%edi
mov    %r14d,%esi
mov    %r12d,%edx
call   1040 <bracket@plt>
cmp    %r14d,%r12d
jge    11a6 <bracket+0x86>
movb   $0x7b,0x0(%rbp)
mov    %r12d,%eax
add    $0x1,%eax
add    $0x1,%ebx
add    $0x1,%rbp
mov    %r15d,%r12d
mov    %eax,%r15d
cmp    %r14d,%eax
jne    1150 <bracket+0x30>
lea    0xe6e(%rip),%rdi
lea    0x2ea7(%rip),%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@bracket.a = internal global [100 x i8] zeroinitializer
@.str = [5 x i8] c"%s \0A\00"
define void @bracket(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* %7
%10 = load i32, i32* %6
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([100 x i8], [100 x i8]* @bracket.a, i64 0, i64 0))
br label %43
14: ; preds = %4
%15 = load i32, i32* %8
%16 = load i32, i32* %7
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i8], [100 x i8]* @bracket.a, i64 0, i64 %20
store i8 125, i8* %21
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
%24 = load i32, i32* %6
%25 = load i32, i32* %8
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
br label %28
28: ; preds = %18, %14
%29 = load i32, i32* %8
%30 = load i32, i32* %6
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i8], [100 x i8]* @bracket.a, i64 0, i64 %34
store i8 123, i8* %35
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
%38 = load i32, i32* %6
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
%41 = load i32, i32* %7
br label %42
42: ; preds = %32, %28
br label %43
43: ; preds = %12, %42
ret void
}

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