#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 */
typedef size_t uint;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int UINT_MAX;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
char *xpairs_to_vienna(uint n, const uint *pairs, char *vienna) {
  uint i;
  for (i = 0; i < n; i++) {
    if (pairs[i] == (UINT_MAX / 2))
      vienna[i] = '.';
    else if (i < pairs[i])
      vienna[i] = '(';
    else if (i > pairs[i])
      vienna[i] = ')';
    else {
      printf("ERROR: illegal entry in pairlist\n");
      exit(EXIT_FAILURE);
    }
  }
  vienna[n] = '\0';
  return vienna;
}


x86 assembly (clang, -O0):
<xpairs_to_vienna>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    1216 <xpairs_to_vienna+0xf6>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
jne    118e <xpairs_to_vienna+0x6e>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x2e,(%rax,%rcx,1)
jmp    1200 <xpairs_to_vienna+0xe0>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rdx
cmp    (%rcx,%rdx,8),%rax
jae    11b5 <xpairs_to_vienna+0x95>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x28,(%rax,%rcx,1)
jmp    11fb <xpairs_to_vienna+0xdb>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rdx
cmp    (%rcx,%rdx,8),%rax
jbe    11dc <xpairs_to_vienna+0xbc>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x29,(%rax,%rcx,1)
jmp    11f6 <xpairs_to_vienna+0xd6>
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
jmp    11fb <xpairs_to_vienna+0xdb>
jmp    1200 <xpairs_to_vienna+0xe0>
jmp    1205 <xpairs_to_vienna+0xe5>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113c <xpairs_to_vienna+0x1c>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xpairs_to_vienna>:
push   %rax
test   %rdi,%rdi
je     118d <xpairs_to_vienna+0x6d>
xor    %eax,%eax
mov    0x2eb9(%rip),%r8
jmp    114c <xpairs_to_vienna+0x2c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %cl,(%rdx,%rax,1)
add    $0x1,%rax
cmp    %rax,%rdi
je     118d <xpairs_to_vienna+0x6d>
mov    (%rsi,%rax,8),%r9
mov    (%r8),%r10d
mov    %r10d,%ecx
shr    $0x1f,%ecx
add    %r10d,%ecx
sar    %ecx
movslq %ecx,%r10
mov    $0x2e,%cl
cmp    %r10,%r9
je     1140 <xpairs_to_vienna+0x20>
mov    $0x28,%cl
cmp    %r9,%rax
jb     1140 <xpairs_to_vienna+0x20>
mov    $0x29,%cl
ja     1140 <xpairs_to_vienna+0x20>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
movb   $0x0,(%rdx,%rdi,1)
mov    %rdx,%rax
pop    %rcx
ret

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

LLVM IR (-O2):
@UINT_MAX = global i32 0
@EXIT_FAILURE = global i32 0
@str = [33 x i8] c"ERROR: illegal entry in pairlist\00"
define i8* @xpairs_to_vienna(i64 %0, i64* nocapture %1, i8* returned writeonly %2) {
%4 = icmp eq i64 %0, 0
br i1 %4, label %26, label %5
5: ; preds = %3, %21
%6 = phi i64 [ %24, %21 ], [ 0, %3 ]
%7 = getelementptr inbounds i64, i64* %1, i64 %6
%8 = load i64, i64* %7
%9 = load i32, i32* @UINT_MAX
%10 = sdiv i32 %9, 2
%11 = sext i32 %10 to i64
%12 = icmp eq i64 %8, %11
br i1 %12, label %21, label %13
13: ; preds = %5
%14 = icmp ult i64 %6, %8
br i1 %14, label %21, label %15
15: ; preds = %13
%16 = icmp ugt i64 %6, %8
br i1 %16, label %21, label %17
17: ; preds = %15
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %15, %13, %5
%22 = phi i8 [ 46, %5 ], [ 40, %13 ], [ 41, %15 ]
%23 = getelementptr inbounds i8, i8* %2, i64 %6
store i8 %22, i8* %23
%24 = add nuw i64 %6, 1
%25 = icmp eq i64 %24, %0
br i1 %25, label %26, label %5
26: ; preds = %21, %3
%27 = getelementptr inbounds i8, i8* %2, i64 %0
store i8 0, i8* %27
ret i8* %2
}