#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ infixTopostfix(char *);
int /*<<< orphan*/ postfixToinfix(char *);
int /*<<< orphan*/ printFile(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  extern char *optarg;
  int c, err = 0;
  char *filename;
  static char usage[] = "usage: %s [-b filename]\n";
  while ((c = getopt(argc, argv, "b:c:")) != -1) {
    switch (c) {
    case 'b':
      filename = optarg;
      printf("postfix expression: ");
      printFile(filename);
      printf("infix expression: ");
      postfixToinfix(filename);
      break;
    case 'c':
      filename = optarg;
      printf("infix expression: ");
      printFile(filename);
      printf("postfix expression: ");
      infixTopostfix(filename);
      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    0xe65(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1268 <main+0xf8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x3f,%eax
je     125c <main+0xec>
jmp    11c0 <main+0x50>
mov    -0x24(%rbp),%eax
sub    $0x62,%eax
je     11e2 <main+0x72>
jmp    11d1 <main+0x61>
mov    -0x24(%rbp),%eax
sub    $0x63,%eax
je     121f <main+0xaf>
jmp    1263 <main+0xf3>
mov    0x2df7(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <printFile@plt>
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1080 <postfixToinfix@plt>
jmp    1263 <main+0xf3>
mov    0x2dba(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xde6(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <printFile@plt>
lea    0xdbc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1090 <infixTopostfix@plt>
jmp    1263 <main+0xf3>
movl   $0x1,-0x18(%rbp)
jmp    118d <main+0x1d>
cmpl   $0x0,-0x18(%rbp)
je     1298 <main+0x128>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0x2dd7(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%ebp
mov    $0x1,%al
mov    %eax,0x4(%rsp)
lea    0xe73(%rip),%r14
lea    0xe71(%rip),%r15
lea    0xe7f(%rip),%r12
jmp    11cc <main+0x5c>
nopl   (%rax)
jne    120f <main+0x9f>
mov    0x2e37(%rip),%rax
mov    (%rax),%rbx
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <printFile@plt>
mov    %r12,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1080 <postfixToinfix@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r14,%rdx
call   1060 <getopt@plt>
cmp    $0x62,%eax
jle    11a0 <main+0x30>
cmp    $0x63,%eax
jne    11cc <main+0x5c>
mov    0x2df6(%rip),%rax
mov    (%rax),%rbx
mov    %r12,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <printFile@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1090 <infixTopostfix@plt>
jmp    11cc <main+0x5c>
cmp    $0x3f,%eax
je     121b <main+0xab>
cmp    $0xffffffff,%eax
jne    11cc <main+0x5c>
jmp    1225 <main+0xb5>
movl   $0x0,0x4(%rsp)
jmp    11cc <main+0x5c>
testb  $0x1,0x4(%rsp)
je     1233 <main+0xc3>
xor    %edi,%edi
call   1070 <exit@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13),%rdx
lea    0x2e19(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@main.usage = internal global [25 x i8] c"usage: %s [-b filename]\0A\00"
@.str = [5 x i8] c"b:c:\00"
@optarg = external global i8*
@.str.1 = [21 x i8] c"postfix expression: \00"
@.str.2 = [19 x i8] c"infix expression: \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 ([5 x i8], [5 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 99, label %24
i32 63, label %32
]
16: ; preds = %14
%17 = load i8*, i8** @optarg
store i8* %17, i8** %8
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%19 = load i8*, i8** %8
%20 = call i32 @printFile(i8* %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%22 = load i8*, i8** %8
%23 = call i32 @postfixToinfix(i8* %22)
br label %33
24: ; preds = %14
%25 = load i8*, i8** @optarg
store i8* %25, i8** %8
%26 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%27 = load i8*, i8** %8
%28 = call i32 @printFile(i8* %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%30 = load i8*, i8** %8
%31 = call i32 @infixTopostfix(i8* %30)
br label %33
32: ; preds = %14
store i32 1, i32* %7
br label %33
33: ; preds = %14, %32, %24, %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 ([25 x i8], [25 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 [25 x i8] c"usage: %s [-b filename]\0A\00"
@.str = [5 x i8] c"b:c:\00"
@optarg = external global i8*
@.str.1 = [21 x i8] c"postfix expression: \00"
@.str.2 = [19 x i8] c"infix expression: \00"
@stderr = global i32 0
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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %7 [
i32 -1, label %20
i32 98, label %8
i32 99, label %14
i32 63, label %3
]
7: ; preds = %5, %14, %8
br label %5
8: ; preds = %5
%9 = load i8*, i8** @optarg
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @printFile(i8* %9)
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @postfixToinfix(i8* %9)
br label %7
14: ; preds = %5
%15 = load i8*, i8** @optarg
%16 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @printFile(i8* %15)
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%19 = tail call i32 @infixTopostfix(i8* %15)
br label %7
20: ; preds = %5
br i1 %4, label %26, label %21
21: ; preds = %20
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %1
%24 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @main.usage, i64 0, i64 0), i8* %23)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %20
%27 = tail call i32 @exit(i32 0)
unreachable
}