#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__ balanced(char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int main() {
  printf("is '%s' balanced? %s\n", "(a)", balanced("(a)") ? "yes" : "no");
  printf("is '%s' balanced? %s\n", "((b))", balanced("((b))") ? "yes" : "no");
  printf("is '%s' balanced? %s\n", "(c)(d)(e)",
         balanced("(c)(d)(e)") ? "yes" : "no");
  printf("is '%s' balanced? %s\n", "(f))(", balanced("(f))(") ? "yes" : "no");
  printf("is '%s' balanced? %s\n", "", balanced("") ? "yes" : "no");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee0(%rip),%rdi
call   1040 <balanced@plt>
mov    %rax,%rcx
lea    0xed9(%rip),%rdx
lea    0xece(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xea5(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
call   1040 <balanced@plt>
mov    %rax,%rcx
lea    0xea1(%rip),%rdx
lea    0xe96(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xe6d(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1030 <printf@plt>
lea    0xe81(%rip),%rdi
call   1040 <balanced@plt>
mov    %rax,%rcx
lea    0xe69(%rip),%rdx
lea    0xe5e(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xe35(%rip),%rdi
lea    0xe55(%rip),%rsi
call   1030 <printf@plt>
lea    0xe53(%rip),%rdi
call   1040 <balanced@plt>
mov    %rax,%rcx
lea    0xe31(%rip),%rdx
lea    0xe26(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xdfd(%rip),%rdi
lea    0xe27(%rip),%rsi
call   1030 <printf@plt>
lea    0xdff(%rip),%rdi
call   1040 <balanced@plt>
mov    %rax,%rcx
lea    0xdf9(%rip),%rdx
lea    0xdee(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xdc5(%rip),%rdi
lea    0xdd3(%rip),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xee7(%rip),%r15
mov    %r15,%rdi
call   1040 <balanced@plt>
test   %rax,%rax
lea    0xedd(%rip),%r12
lea    0xed2(%rip),%rbx
mov    %rbx,%rdx
cmove  %r12,%rdx
lea    0xeaa(%rip),%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
lea    0xeb9(%rip),%r15
mov    %r15,%rdi
call   1040 <balanced@plt>
test   %rax,%rax
mov    %rbx,%rdx
cmove  %r12,%rdx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
lea    0xe9b(%rip),%r15
mov    %r15,%rdi
call   1040 <balanced@plt>
test   %rax,%rax
mov    %rbx,%rdx
cmove  %r12,%rdx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
lea    0xe81(%rip),%r15
mov    %r15,%rdi
call   1040 <balanced@plt>
test   %rax,%rax
mov    %rbx,%rdx
cmove  %r12,%rdx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
lea    0xe41(%rip),%r15
mov    %r15,%rdi
call   1040 <balanced@plt>
test   %rax,%rax
cmove  %r12,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"is '%s' balanced? %s\0A\00"
@.str.1 = [4 x i8] c"(a)\00"
@.str.2 = [4 x i8] c"yes\00"
@.str.3 = [3 x i8] c"no\00"
@.str.4 = [6 x i8] c"((b))\00"
@.str.5 = [10 x i8] c"(c)(d)(e)\00"
@.str.6 = [6 x i8] c"(f))(\00"
@.str.7 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 @balanced(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp ne i64 %2, 0
%4 = zext i1 %3 to i64
%5 = select i1 %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = call i64 @balanced(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
%9 = zext i1 %8 to i64
%10 = select i1 %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%11 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%12 = call i64 @balanced(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%16 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %15)
%17 = call i64 @balanced(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i64
%20 = select i1 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%21 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %20)
%22 = call i64 @balanced(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%26 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8* %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"is '%s' balanced? %s\0A\00"
@.str.1 = [4 x i8] c"(a)\00"
@.str.2 = [4 x i8] c"yes\00"
@.str.3 = [3 x i8] c"no\00"
@.str.4 = [6 x i8] c"((b))\00"
@.str.5 = [10 x i8] c"(c)(d)(e)\00"
@.str.6 = [6 x i8] c"(f))(\00"
@.str.7 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = tail call i64 @balanced(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i64 %1, 0
%3 = select i1 %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%5 = tail call i64 @balanced(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%9 = tail call i64 @balanced(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %11)
%13 = tail call i64 @balanced(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %15)
%17 = tail call i64 @balanced(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8* %19)
ret i32 0
}