#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*/ assert(int);
int /*<<< orphan*/ convert(char *, char *);
int evaluate(char *);
int /*<<< orphan*/ strcpy(char *, char *);
void test(char *infix, char *postfix) {
  strcpy(infix, "2+2-1-1*2/2");
  convert(infix, postfix);
  assert(2 == evaluate(postfix));
  strcpy(infix, "(2+2)/2*2-1");
  convert(infix, postfix);
  assert(3 == evaluate(postfix));
  strcpy(infix, "2+2/2*2");
  convert(infix, postfix);
  assert(4 == evaluate(postfix));
  strcpy(infix, "2+2+2*(2-1)");
  convert(infix, postfix);
  assert(6 == evaluate(postfix));
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <convert@plt>
mov    -0x10(%rbp),%rdi
call   1060 <evaluate@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <convert@plt>
mov    -0x10(%rbp),%rdi
call   1060 <evaluate@plt>
mov    %eax,%ecx
mov    $0x3,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <convert@plt>
mov    -0x10(%rbp),%rdi
call   1060 <evaluate@plt>
mov    %eax,%ecx
mov    $0x4,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <convert@plt>
mov    -0x10(%rbp),%rdi
call   1060 <evaluate@plt>
mov    %eax,%ecx
mov    $0x6,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeaf(%rip),%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <convert@plt>
mov    %r14,%rdi
call   1060 <evaluate@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <convert@plt>
mov    %r14,%rdi
call   1060 <evaluate@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <convert@plt>
mov    %r14,%rdi
call   1060 <evaluate@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <convert@plt>
mov    %r14,%rdi
call   1060 <evaluate@plt>
xor    %edi,%edi
cmp    $0x6,%eax
sete   %dil
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <assert@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"2+2-1-1*2/2\00"
@.str.1 = [12 x i8] c"(2+2)/2*2-1\00"
@.str.2 = [8 x i8] c"2+2/2*2\00"
@.str.3 = [12 x i8] c"2+2+2*(2-1)\00"
define void @test(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %3
%8 = load i8*, i8** %4
%9 = call i32 @convert(i8* %7, i8* %8)
%10 = load i8*, i8** %4
%11 = call i32 @evaluate(i8* %10)
%12 = icmp eq i32 2, %11
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8*, i8** %3
%16 = call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%17 = load i8*, i8** %3
%18 = load i8*, i8** %4
%19 = call i32 @convert(i8* %17, i8* %18)
%20 = load i8*, i8** %4
%21 = call i32 @evaluate(i8* %20)
%22 = icmp eq i32 3, %21
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i8*, i8** %3
%26 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%27 = load i8*, i8** %3
%28 = load i8*, i8** %4
%29 = call i32 @convert(i8* %27, i8* %28)
%30 = load i8*, i8** %4
%31 = call i32 @evaluate(i8* %30)
%32 = icmp eq i32 4, %31
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i8*, i8** %3
%36 = call i32 @strcpy(i8* %35, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%37 = load i8*, i8** %3
%38 = load i8*, i8** %4
%39 = call i32 @convert(i8* %37, i8* %38)
%40 = load i8*, i8** %4
%41 = call i32 @evaluate(i8* %40)
%42 = icmp eq i32 6, %41
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"2+2-1-1*2/2\00"
@.str.1 = [12 x i8] c"(2+2)/2*2-1\00"
@.str.2 = [8 x i8] c"2+2/2*2\00"
@.str.3 = [12 x i8] c"2+2+2*(2-1)\00"
define void @test(i8* %0, i8* %1) {
%3 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @convert(i8* %0, i8* %1)
%5 = tail call i32 @evaluate(i8* %1)
%6 = icmp eq i32 %5, 2
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @convert(i8* %0, i8* %1)
%11 = tail call i32 @evaluate(i8* %1)
%12 = icmp eq i32 %11, 3
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @convert(i8* %0, i8* %1)
%17 = tail call i32 @evaluate(i8* %1)
%18 = icmp eq i32 %17, 4
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%22 = tail call i32 @convert(i8* %0, i8* %1)
%23 = tail call i32 @evaluate(i8* %1)
%24 = icmp eq i32 %23, 6
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
ret void
}