#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 getchar();
scalar_t__ is_empty();
int /*<<< orphan*/ pop();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ push();
int main(void) {
  int c;
  printf("Enter parentheses/braces: ");
  do {
    c = getchar();
    if (c == '{' || c == '(') {
      push();
    } else if (c == '}' || c == ')') {
      pop();
    } else {
      continue;
    }
  } while (c != '\n');
  if (is_empty()) {
    printf("Parentheses/braces are nested properly!\n");
  } else {
    printf("Parentheses/braces are not nested properly!\n");
  }
  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    %eax,-0x8(%rbp)
cmpl   $0x7b,-0x8(%rbp)
je     1189 <main+0x39>
cmpl   $0x28,-0x8(%rbp)
jne    1195 <main+0x45>
mov    $0x0,%al
call   1070 <push@plt>
jmp    11bf <main+0x6f>
cmpl   $0x7d,-0x8(%rbp)
je     11a9 <main+0x59>
cmpl   $0x29,-0x8(%rbp)
jne    11b5 <main+0x65>
mov    $0x0,%al
call   1050 <pop@plt>
jmp    11ba <main+0x6a>
jmp    11c4 <main+0x74>
jmp    11bf <main+0x6f>
jmp    11c4 <main+0x74>
cmpl   $0xa,-0x8(%rbp)
jne    116b <main+0x1b>
mov    $0x0,%al
call   1040 <is_empty@plt>
cmp    $0x0,%rax
je     11f0 <main+0xa0>
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
jmp    11fc <main+0xac>
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
jmp    1177 <main+0x17>
nop
xor    %eax,%eax
call   1060 <pop@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    $0x7a,%eax
jg     11a0 <main+0x40>
cmp    $0x28,%eax
je     11aa <main+0x4a>
cmp    $0x29,%eax
je     1170 <main+0x10>
cmp    $0xa,%eax
jne    1177 <main+0x17>
jmp    11b3 <main+0x53>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x7d,%eax
je     1170 <main+0x10>
cmp    $0x7b,%eax
jne    1177 <main+0x17>
xor    %eax,%eax
call   1080 <push@plt>
jmp    1177 <main+0x17>
xor    %eax,%eax
call   1050 <is_empty@plt>
test   %rax,%rax
lea    0xe57(%rip),%rax
lea    0xe7c(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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