#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 caculate(char *);
char *changeStrIfMinusIsFirst(char *);
int /*<<< orphan*/ free(char *);
char *infix2postfix(char *);
int /*<<< orphan*/ printf(char *, ...);
char *readInfixExpression();
int /*<<< orphan*/ stringTrim(char *);
int main(int argc, char **argv) {
  char *infixLine;
  char *trim;
  char *out;
  infixLine = readInfixExpression();
  stringTrim(infixLine);
  trim = changeStrIfMinusIsFirst(infixLine);
  out = infix2postfix(trim);
  printf("%s\n", out);
  int r = caculate(out);
  printf("result->%d\n", r);
  free(out);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <readInfixExpression@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <stringTrim@plt>
mov    -0x18(%rbp),%rdi
call   1080 <changeStrIfMinusIsFirst@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <infix2postfix@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <caculate@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1070 <readInfixExpression@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <stringTrim@plt>
mov    %rbx,%rdi
call   1090 <changeStrIfMinusIsFirst@plt>
mov    %rax,%rdi
call   10a0 <infix2postfix@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <caculate@plt>
lea    0xe43(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [12 x i8] c"result->%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = call i8* (...) @readInfixExpression()
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = call i32 @stringTrim(i8* %10)
%12 = load i8*, i8** %5
%13 = call i8* @changeStrIfMinusIsFirst(i8* %12)
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = call i8* @infix2postfix(i8* %14)
store i8* %15, i8** %7
%16 = load i8*, i8** %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %7
%19 = call i32 @caculate(i8* %18)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i8*, i8** %7
%23 = call i32 @free(i8* %22)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"result->%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* (...) @readInfixExpression()
%4 = tail call i32 @stringTrim(i8* %3)
%5 = tail call i8* @changeStrIfMinusIsFirst(i8* %3)
%6 = tail call i8* @infix2postfix(i8* %5)
%7 = tail call i32 @puts(i8* dereferenceable(1) %6)
%8 = tail call i32 @caculate(i8* %6)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = tail call i32 @free(i8* %6)
ret i32 0
}