#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 */
char getchar();
scalar_t__ is_empty();
int /*<<< orphan*/ pop();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ push(char);
int main(void) {
  char brace;
  printf("Enter parentheses and/or braces: ");
  for (;;) {
    brace = getchar();
    if (brace == '\n') {
      if (is_empty())
        printf("Parentheses/braces are nested properly\n");
      else
        printf("Parentheses/braces are not nested properly\n");
      break;
    } else if (brace == '(' || brace == '[' || brace == '{')
      push(brace);
    else if (brace == ')' || brace == ']' || brace == '}')
      pop();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    11b5 <main+0x65>
mov    $0x0,%al
call   1040 <is_empty@plt>
cmp    $0x0,%rax
je     11a4 <main+0x54>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
jmp    11b0 <main+0x60>
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
jmp    1227 <main+0xd7>
movsbl -0x5(%rbp),%eax
cmp    $0x28,%eax
je     11dc <main+0x8c>
movsbl -0x5(%rbp),%eax
cmp    $0x5b,%eax
je     11dc <main+0x8c>
movsbl -0x5(%rbp),%eax
cmp    $0x7b,%eax
jne    11ea <main+0x9a>
movsbl -0x5(%rbp),%edi
call   1070 <push@plt>
jmp    121d <main+0xcd>
movsbl -0x5(%rbp),%eax
cmp    $0x29,%eax
je     1211 <main+0xc1>
movsbl -0x5(%rbp),%eax
cmp    $0x5d,%eax
je     1211 <main+0xc1>
movsbl -0x5(%rbp),%eax
cmp    $0x7d,%eax
jne    1218 <main+0xc8>
mov    $0x0,%al
call   1050 <pop@plt>
jmp    121d <main+0xcd>
jmp    1222 <main+0xd2>
jmp    116b <main+0x1b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf24(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8c(%rip),%rbx
jmp    1187 <main+0x27>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <pop@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0x5a,%al
jle    11b0 <main+0x50>
lea    -0x5b(%rax),%ecx
cmp    $0x22,%cl
ja     1187 <main+0x27>
movzbl %cl,%ecx
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
cs nopw 0x0(%rax,%rax,1)
cmp    $0x28,%al
je     11c0 <main+0x60>
cmp    $0x29,%al
je     1180 <main+0x20>
cmp    $0xa,%al
jne    1187 <main+0x27>
jmp    11ca <main+0x6a>
xchg   %ax,%ax
movsbl %al,%edi
call   1080 <push@plt>
jmp    1187 <main+0x27>
xor    %eax,%eax
call   1050 <is_empty@plt>
test   %rax,%rax
lea    0xed3(%rip),%rax
lea    0xef7(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Enter parentheses and/or braces: \00"
@.str.1 = [40 x i8] c"Parentheses/braces are nested properly\0A\00"
@.str.2 = [44 x i8] c"Parentheses/braces are not nested properly\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %48, %0
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %2
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 10
br i1 %8, label %9, label %17
9: ; preds = %4
%10 = call i64 (...) @is_empty()
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
br label %49
17: ; preds = %4
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 40
br i1 %20, label %29, label %21
21: ; preds = %17
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 91
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 123
br i1 %28, label %29, label %32
29: ; preds = %25, %21, %17
%30 = load i8, i8* %2
%31 = call i32 @push(i8 signext %30)
br label %47
32: ; preds = %25
%33 = load i8, i8* %2
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 41
br i1 %35, label %44, label %36
36: ; preds = %32
%37 = load i8, i8* %2
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 93
br i1 %39, label %44, label %40
40: ; preds = %36
%41 = load i8, i8* %2
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 125
br i1 %43, label %44, label %46
44: ; preds = %40, %36, %32
%45 = call i32 (...) @pop()
br label %46
46: ; preds = %44, %40
br label %47
47: ; preds = %46, %29
br label %48
48: ; preds = %47
br label %4
49: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"Enter parentheses and/or braces: \00"
@str = [43 x i8] c"Parentheses/braces are not nested properly\00"
@str.3 = [39 x i8] c"Parentheses/braces are nested properly\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %4, %0
%3 = tail call signext i8 (...) @getchar()
switch i8 %3, label %4 [
i8 10, label %5
i8 123, label %10
i8 91, label %10
i8 40, label %10
i8 125, label %12
i8 93, label %12
i8 41, label %12
]
4: ; preds = %2, %10, %12
br label %2
5: ; preds = %2
%6 = tail call i64 (...) @is_empty()
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @str.3, i64 0, i64 0)
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
ret i32 0
10: ; preds = %2, %2, %2
%11 = tail call i32 @push(i8 signext %3)
br label %4
12: ; preds = %2, %2, %2
%13 = tail call i32 (...) @pop()
br label %4
}