#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 isBalanced(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  printf("Assignment 2\n");
  char *s = argv[1];
  int res;
  res = isBalanced(s);
  if (res)
    printf("The string %s is balanced\n", s);
  else
    printf("The string %s is not balanced\n", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <isBalanced@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     117d <main+0x5d>
mov    -0x18(%rbp),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118f <main+0x6f>
mov    -0x18(%rbp),%rsi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rbx),%rbx
mov    %rbx,%rdi
call   1050 <isBalanced@plt>
test   %eax,%eax
lea    0xec6(%rip),%rax
lea    0xea4(%rip),%rdi
cmove  %rax,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Assignment 2\0A\00"
@.str.1 = [27 x i8] c"The string %s is balanced\0A\00"
@.str.2 = [31 x i8] c"The string %s is not balanced\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = call i32 @isBalanced(i8* %12)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i8*, i8** %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %22
19: ; preds = %2
%20 = load i8*, i8** %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %19, %16
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"The string %s is balanced\0A\00"
@.str.2 = [31 x i8] c"The string %s is not balanced\0A\00"
@str = [13 x i8] c"Assignment 2\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32 @isBalanced(i8* %5)
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %8, i8* %5)
ret i32 0
}