#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 */
scalar_t__ isBalanced(char const *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  int i;
  const char *msgs[4] = {"{[()]}", "{[(])}", "{{[[(())]]}}", "((((((())"};
  for (i = 0; i < 4; i++) {
    if (isBalanced(msgs[i])) {
      printf("C - YES\n");
    } else {
      printf("C - NO\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2cc3(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2cc0(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2cbd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cba(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11bb <main+0x9b>
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1040 <isBalanced@plt>
cmp    $0x0,%rax
je     119c <main+0x7c>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
jmp    11a8 <main+0x88>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
jmp    11ad <main+0x8d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1169 <main+0x49>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
call   1040 <isBalanced@plt>
test   %rax,%rax
lea    0xeeb(%rip),%r14
lea    0xeeb(%rip),%rbx
mov    %rbx,%rdi
cmove  %r14,%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%rdi
call   1040 <isBalanced@plt>
test   %rax,%rax
mov    %rbx,%rdi
cmove  %r14,%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
call   1040 <isBalanced@plt>
test   %rax,%rax
mov    %rbx,%rdi
cmove  %r14,%rdi
call   1030 <puts@plt>
lea    0xe91(%rip),%rdi
call   1040 <isBalanced@plt>
test   %rax,%rax
cmove  %r14,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"{[()]}\00"
@.str.1 = [7 x i8] c"{[(])}\00"
@.str.2 = [13 x i8] c"{{[[(())]]}}\00"
@.str.3 = [10 x i8] c"((((((())\00"
@__const.main.msgs = [4 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [9 x i8] c"C - YES\0A\00"
@.str.5 = [8 x i8] c"C - NO\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [4 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [4 x i8*]* %7 to i8*
store i32 0, i32* %6
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %14
%16 = load i8*, i8** %15
%17 = call i64 @isBalanced(i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %23
21: ; preds = %12
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
br label %24
24: ; preds = %23
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %9
27: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"{[()]}\00"
@.str.1 = [7 x i8] c"{[(])}\00"
@.str.2 = [13 x i8] c"{{[[(())]]}}\00"
@.str.3 = [10 x i8] c"((((((())\00"
@str = [7 x i8] c"C - NO\00"
@str.6 = [8 x i8] c"C - YES\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @isBalanced(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.6, i64 0, i64 0)
%6 = tail call i32 @puts(i8* dereferenceable(1) %5)
%7 = tail call i64 @isBalanced(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.6, i64 0, i64 0)
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
%11 = tail call i64 @isBalanced(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.6, i64 0, i64 0)
%14 = tail call i32 @puts(i8* dereferenceable(1) %13)
%15 = tail call i64 @isBalanced(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.6, i64 0, i64 0)
%18 = tail call i32 @puts(i8* dereferenceable(1) %17)
ret i32 0
}