#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 isBalance(char *);
int /*<<< orphan*/ printf(char *);
int main_BalanceSymbol() {
  char *str = "(1+2)-(2*(4)+2))";
  int balanced = isBalance(str);
  if (balanced == -1) {
    return 1;
  }
  if (balanced) {
    printf("Balance!\n");
  } else {
    printf("Not Balance!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main_BalanceSymbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <isBalance@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1155 <main_BalanceSymbol+0x35>
movl   $0x1,-0x4(%rbp)
jmp    1183 <main_BalanceSymbol+0x63>
cmpl   $0x0,-0x14(%rbp)
je     1170 <main_BalanceSymbol+0x50>
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
jmp    117c <main_BalanceSymbol+0x5c>
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_BalanceSymbol>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <isBalance@plt>
cmp    $0xffffffff,%eax
je     113f <main_BalanceSymbol+0x1f>
test   %eax,%eax
jne    1146 <main_BalanceSymbol+0x26>
lea    0xed4(%rip),%rdi
jmp    114d <main_BalanceSymbol+0x2d>
mov    $0x1,%eax
pop    %rcx
ret
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"(1+2)-(2*(4)+2))\00"
@.str.1 = [10 x i8] c"Balance!\0A\00"
@.str.2 = [14 x i8] c"Not Balance!\0A\00"
define i32 @main_BalanceSymbol() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @isBalance(i8* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 1, i32* %1
br label %17
9: ; preds = %0
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
store i32 0, i32* %1
br label %17
17: ; preds = %16, %8
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [17 x i8] c"(1+2)-(2*(4)+2))\00"
@str = [13 x i8] c"Not Balance!\00"
@str.3 = [9 x i8] c"Balance!\00"
define i32 @main_BalanceSymbol() {
%1 = tail call i32 @isBalance(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
switch i32 %1, label %3 [
i32 -1, label %6
i32 0, label %2
]
2: ; preds = %0
br label %3
3: ; preds = %0, %2
%4 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.3, i64 0, i64 0), %0 ]
%5 = tail call i32 @puts(i8* dereferenceable(1) %4)
br label %6
6: ; preds = %3, %0
%7 = phi i32 [ 1, %0 ], [ 0, %3 ]
ret i32 %7
}