#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 */
struct stack {
  int dummy;
};

/* Variables and functions */
int stack_pop(struct stack **);
int /*<<< orphan*/ stack_push(struct stack **, int);
int work_with2(char c, struct stack **pstack) {
  switch (c) {
  case '(':
    stack_push(pstack, 0);
    break;
  case '[':
    stack_push(pstack, 1);
    break;
  case '{':
    stack_push(pstack, 2);
    break;
  case ')':
    if (stack_pop(pstack) != 0)
      return 0 | 0x10;
    break;
  case ']':
    if (stack_pop(pstack) != 1)
      return 1 | 0x10;
    break;
  case '}':
    if (stack_pop(pstack) != 2)
      return 1 | 0x10;
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<work_with2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x28,%eax
je     119c <work_with2+0x7c>
jmp    1147 <work_with2+0x27>
mov    -0x14(%rbp),%eax
sub    $0x29,%eax
je     11d2 <work_with2+0xb2>
jmp    1158 <work_with2+0x38>
mov    -0x14(%rbp),%eax
sub    $0x5b,%eax
je     11ac <work_with2+0x8c>
jmp    1169 <work_with2+0x49>
mov    -0x14(%rbp),%eax
sub    $0x5d,%eax
je     11f5 <work_with2+0xd5>
jmp    117a <work_with2+0x5a>
mov    -0x14(%rbp),%eax
sub    $0x7b,%eax
je     11bf <work_with2+0x9f>
jmp    118b <work_with2+0x6b>
mov    -0x14(%rbp),%eax
sub    $0x7d,%eax
je     1218 <work_with2+0xf8>
jmp    123b <work_with2+0x11b>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <stack_push@plt>
jmp    123b <work_with2+0x11b>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1030 <stack_push@plt>
jmp    123b <work_with2+0x11b>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1030 <stack_push@plt>
jmp    123b <work_with2+0x11b>
mov    -0x10(%rbp),%rdi
call   1040 <stack_pop@plt>
cmp    $0x0,%eax
je     11f0 <work_with2+0xd0>
movl   $0x10,-0x4(%rbp)
jmp    1242 <work_with2+0x122>
jmp    123b <work_with2+0x11b>
mov    -0x10(%rbp),%rdi
call   1040 <stack_pop@plt>
cmp    $0x1,%eax
je     1213 <work_with2+0xf3>
movl   $0x11,-0x4(%rbp)
jmp    1242 <work_with2+0x122>
jmp    123b <work_with2+0x11b>
mov    -0x10(%rbp),%rdi
call   1040 <stack_pop@plt>
cmp    $0x2,%eax
je     1236 <work_with2+0x116>
movl   $0x11,-0x4(%rbp)
jmp    1242 <work_with2+0x122>
jmp    123b <work_with2+0x11b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<work_with2>:
push   %rax
lea    -0x5b(%rdi),%eax
cmp    $0x22,%eax
ja     1140 <work_with2+0x20>
lea    0xed0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%eax
jmp    1194 <work_with2+0x74>
cmp    $0x28,%edi
je     1192 <work_with2+0x72>
cmp    $0x29,%edi
jne    119e <work_with2+0x7e>
mov    %rsi,%rdi
call   1040 <stack_pop@plt>
mov    %eax,%ecx
mov    $0x10,%eax
test   %ecx,%ecx
je     119e <work_with2+0x7e>
pop    %rcx
ret
mov    %rsi,%rdi
call   1040 <stack_pop@plt>
mov    %eax,%ecx
mov    $0x11,%eax
cmp    $0x1,%ecx
jne    115d <work_with2+0x3d>
jmp    119e <work_with2+0x7e>
mov    $0x2,%eax
jmp    1194 <work_with2+0x74>
mov    %rsi,%rdi
call   1040 <stack_pop@plt>
mov    %eax,%ecx
mov    $0x11,%eax
cmp    $0x2,%ecx
jne    115d <work_with2+0x3d>
jmp    119e <work_with2+0x7e>
xor    %eax,%eax
mov    %rsi,%rdi
mov    %eax,%esi
call   1030 <stack_push@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.stack = type { i32 }
define i32 @work_with2(i8 signext %0, %struct.stack** %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca %struct.stack**
store i8 %0, i8* %4
store %struct.stack** %1, %struct.stack*** %5
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
switch i32 %7, label %35 [
i32 40, label %8
i32 91, label %11
i32 123, label %14
i32 41, label %17
i32 93, label %23
i32 125, label %29
]
8: ; preds = %2
%9 = load %struct.stack**, %struct.stack*** %5
%10 = call i32 @stack_push(%struct.stack** %9, i32 0)
br label %35
11: ; preds = %2
%12 = load %struct.stack**, %struct.stack*** %5
%13 = call i32 @stack_push(%struct.stack** %12, i32 1)
br label %35
14: ; preds = %2
%15 = load %struct.stack**, %struct.stack*** %5
%16 = call i32 @stack_push(%struct.stack** %15, i32 2)
br label %35
17: ; preds = %2
%18 = load %struct.stack**, %struct.stack*** %5
%19 = call i32 @stack_pop(%struct.stack** %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 16, i32* %3
br label %36
22: ; preds = %17
br label %35
23: ; preds = %2
%24 = load %struct.stack**, %struct.stack*** %5
%25 = call i32 @stack_pop(%struct.stack** %24)
%26 = icmp ne i32 %25, 1
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 17, i32* %3
br label %36
28: ; preds = %23
br label %35
29: ; preds = %2
%30 = load %struct.stack**, %struct.stack*** %5
%31 = call i32 @stack_pop(%struct.stack** %30)
%32 = icmp ne i32 %31, 2
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 17, i32* %3
br label %36
34: ; preds = %29
br label %35
35: ; preds = %2, %34, %28, %22, %14, %11, %8
store i32 0, i32* %3
br label %36
36: ; preds = %35, %33, %27, %21
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
%struct.stack = type { i32 }
define i32 @work_with2(i8 signext %0, %struct.stack** %1) {
%3 = sext i8 %0 to i32
switch i32 %3, label %18 [
i32 40, label %15
i32 91, label %4
i32 123, label %5
i32 41, label %6
i32 93, label %9
i32 125, label %12
]
4: ; preds = %2
br label %15
5: ; preds = %2
br label %15
6: ; preds = %2
%7 = tail call i32 @stack_pop(%struct.stack** %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %18, label %19
9: ; preds = %2
%10 = tail call i32 @stack_pop(%struct.stack** %1)
%11 = icmp eq i32 %10, 1
br i1 %11, label %18, label %19
12: ; preds = %2
%13 = tail call i32 @stack_pop(%struct.stack** %1)
%14 = icmp eq i32 %13, 2
br i1 %14, label %18, label %19
15: ; preds = %2, %4, %5
%16 = phi i32 [ 2, %5 ], [ 1, %4 ], [ 0, %2 ]
%17 = tail call i32 @stack_push(%struct.stack** %1, i32 %16)
br label %18
18: ; preds = %15, %12, %9, %6, %2
br label %19
19: ; preds = %12, %9, %6, %18
%20 = phi i32 [ 0, %18 ], [ 16, %6 ], [ 17, %9 ], [ 17, %12 ]
ret i32 %20
}