#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 /*<<< orphan*/ balance_symbols(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ test_createStack();
int /*<<< orphan*/ test_pop();
int /*<<< orphan*/ test_push();
int /*<<< orphan*/ test_top();
int main(int argc, char *argv[]) {
  extern char *optarg;
  int c, err = 0;
  char *filename;
  static char usage[] = "usage: %s [-b filename] [-s]\n";
  while ((c = getopt(argc, argv, "b:s")) != -1) {
    switch (c) {
    case 'b':
      filename = optarg;
      balance_symbols(filename);
      break;
    case 's':
      printf("///////////////////////\n");
      printf("// STACK2 TEST\n");
      printf("///////////////////////\n\n");
      test_createStack();
      printf("\n");
      test_push();
      printf("\n");
      test_top();
      printf("\n");
      test_pop();
      printf("\n");
      break;
    case '?':
      err = 1;
      break;
    }
  }
  if (err) {
    fprintf(stderr, usage, argv[0]);
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe45(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     129f <main+0x10f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x3f,%eax
je     1293 <main+0x103>
jmp    11e0 <main+0x50>
mov    -0x24(%rbp),%eax
sub    $0x62,%eax
je     1202 <main+0x72>
jmp    11f1 <main+0x61>
mov    -0x24(%rbp),%eax
sub    $0x73,%eax
je     121e <main+0x8e>
jmp    129a <main+0x10a>
mov    0x2dd7(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <balance_symbols@plt>
jmp    129a <main+0x10a>
lea    0xddf(%rip),%rdi
call   1030 <printf@plt>
lea    0xdec(%rip),%rdi
call   1030 <printf@plt>
lea    0xdf0(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <test_createStack@plt>
lea    0xdf5(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <test_push@plt>
lea    0xde2(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   10b0 <test_top@plt>
lea    0xdcf(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <test_pop@plt>
lea    0xdbc(%rip),%rdi
call   1030 <printf@plt>
jmp    129a <main+0x10a>
movl   $0x1,-0x18(%rbp)
jmp    11ad <main+0x1d>
cmpl   $0x0,-0x18(%rbp)
je     12cf <main+0x13f>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0x2db0(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%al
mov    %eax,0x4(%rsp)
lea    0xe43(%rip),%r14
lea    0xe40(%rip),%r15
lea    0xe51(%rip),%r12
lea    0xe59(%rip),%r13
jmp    11f8 <main+0x58>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x62,%eax
jne    126d <main+0xcd>
mov    0x2df0(%rip),%rax
mov    (%rax),%rdi
call   1070 <balance_symbols@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10a0 <getopt@plt>
cmp    $0x72,%eax
jle    11e0 <main+0x40>
cmp    $0x73,%eax
jne    11f8 <main+0x58>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <test_createStack@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1090 <test_push@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   10c0 <test_top@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <test_pop@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11f8 <main+0x58>
cmp    $0x3f,%eax
je     1279 <main+0xd9>
cmp    $0xffffffff,%eax
jne    11f8 <main+0x58>
jmp    1286 <main+0xe6>
movl   $0x0,0x4(%rsp)
jmp    11f8 <main+0x58>
testb  $0x1,0x4(%rsp)
je     1294 <main+0xf4>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0x2dd9(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@main.usage = internal global [30 x i8] c"usage: %s [-b filename] [-s]\0A\00"
@.str = [4 x i8] c"b:s\00"
@optarg = external global i8*
@.str.1 = [25 x i8] c"///////////////////////\0A\00"
@.str.2 = [16 x i8] c"// STACK2 TEST\0A\00"
@.str.3 = [26 x i8] c"///////////////////////\0A\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@stderr = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %9
9: ; preds = %33, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %6
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %34
14: ; preds = %9
%15 = load i32, i32* %6
switch i32 %15, label %33 [
i32 98, label %16
i32 115, label %20
i32 63, label %32
]
16: ; preds = %14
%17 = load i8*, i8** @optarg
store i8* %17, i8** %8
%18 = load i8*, i8** %8
%19 = call i32 @balance_symbols(i8* %18)
br label %33
20: ; preds = %14
%21 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 (...) @test_createStack()
%25 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 (...) @test_push()
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 (...) @test_top()
%29 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 (...) @test_pop()
%31 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %33
32: ; preds = %14
store i32 1, i32* %7
br label %33
33: ; preds = %14, %32, %20, %16
br label %9
34: ; preds = %9
%35 = load i32, i32* %7
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i32, i32* @stderr
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @main.usage, i64 0, i64 0), i8* %41)
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %34
%45 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@main.usage = internal global [30 x i8] c"usage: %s [-b filename] [-s]\0A\00"
@.str = [4 x i8] c"b:s\00"
@optarg = external global i8*
@stderr = global i32 0
@str = [24 x i8] c"///////////////////////\00"
@str.5 = [15 x i8] c"// STACK2 TEST\00"
@str.6 = [25 x i8] c"///////////////////////\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = phi i1 [ true, %2 ], [ false, %5 ]
br label %5
5: ; preds = %7, %3
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %7 [
i32 -1, label %23
i32 98, label %8
i32 115, label %11
i32 63, label %3
]
7: ; preds = %5, %11, %8
br label %5
8: ; preds = %5
%9 = load i8*, i8** @optarg
%10 = tail call i32 @balance_symbols(i8* %9)
br label %7
11: ; preds = %5
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
%15 = tail call i32 (...) @test_createStack()
%16 = tail call i32 @putchar(i32 10)
%17 = tail call i32 (...) @test_push()
%18 = tail call i32 @putchar(i32 10)
%19 = tail call i32 (...) @test_top()
%20 = tail call i32 @putchar(i32 10)
%21 = tail call i32 (...) @test_pop()
%22 = tail call i32 @putchar(i32 10)
br label %7
23: ; preds = %5
br i1 %4, label %29, label %24
24: ; preds = %23
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %1
%27 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @main.usage, i64 0, i64 0), i8* %26)
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %23
%30 = tail call i32 @exit(i32 0)
unreachable
}