#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*/ operand(char);
char pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(char);
int strlen(char *);
void postfix_to_infix(char postfix[]) {
  int length;
  char element, operator;
  length = strlen(postfix);
  printf("\nInfix Expression: ");
  printf("%c", postfix[0]);
  for (int count = 1; count < length; count++) {
    if (!operand(postfix[count])) {
      push(postfix[count]);
    } else {
      element = pop();
      operator= postfix[count];
      printf(" %c %c", operator, element);
    }
  }
}


x86 assembly (clang, -O0):
<postfix_to_infix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120f <postfix_to_infix+0xbf>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1070 <operand@plt>
cmp    $0x0,%eax
jne    11ce <postfix_to_infix+0x7e>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <push@plt>
jmp    11fc <postfix_to_infix+0xac>
mov    $0x0,%al
call   1050 <pop@plt>
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xe(%rbp)
movsbl -0xe(%rbp),%esi
movsbl -0xd(%rbp),%edx
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1201 <postfix_to_infix+0xb1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1192 <postfix_to_infix+0x42>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<postfix_to_infix>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl (%rbx),%edi
call   1030 <putchar@plt>
cmp    $0x2,%ebp
jl     11d9 <postfix_to_infix+0x79>
mov    %ebp,%r15d
mov    $0x1,%ebp
lea    0xe79(%rip),%r14
jmp    11c1 <postfix_to_infix+0x61>
nopl   (%rax)
xor    %eax,%eax
call   1060 <pop@plt>
movsbl (%rbx,%rbp,1),%esi
movsbl %al,%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
je     11d9 <postfix_to_infix+0x79>
movsbl (%rbx,%rbp,1),%edi
call   1080 <operand@plt>
test   %eax,%eax
jne    11a0 <postfix_to_infix+0x40>
movsbl (%rbx,%rbp,1),%edi
call   1070 <push@plt>
jmp    11b8 <postfix_to_infix+0x58>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0AInfix Expression: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [7 x i8] c" %c %c\00"
define void @postfix_to_infix(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %13)
store i32 1, i32* %6
br label %15
15: ; preds = %47, %1
%16 = load i32, i32* %6
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %50
19: ; preds = %15
%20 = load i8*, i8** %2
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = call i32 @operand(i8 signext %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %19
%28 = load i8*, i8** %2
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = call i32 @push(i8 signext %32)
br label %46
34: ; preds = %19
%35 = call signext i8 (...) @pop()
store i8 %35, i8* %4
%36 = load i8*, i8** %2
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
store i8 %40, i8* %5
%41 = load i8, i8* %5
%42 = sext i8 %41 to i32
%43 = load i8, i8* %4
%44 = sext i8 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %42, i32 %44)
br label %46
46: ; preds = %34, %27
br label %47
47: ; preds = %46
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %15
50: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"\0AInfix Expression: \00"
@.str.2 = [7 x i8] c" %c %c\00"
define void @postfix_to_infix(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = load i8, i8* %0
%5 = sext i8 %4 to i32
%6 = tail call i32 @putchar(i32 %5)
%7 = icmp sgt i32 %2, 1
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = zext i32 %2 to i64
br label %11
10: ; preds = %26, %1
ret void
11: ; preds = %8, %26
%12 = phi i64 [ 1, %8 ], [ %27, %26 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = tail call i32 @operand(i8 signext %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i8, i8* %13
%19 = tail call i32 @push(i8 signext %18)
br label %26
20: ; preds = %11
%21 = tail call signext i8 (...) @pop()
%22 = load i8, i8* %13
%23 = sext i8 %22 to i32
%24 = sext i8 %21 to i32
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %24)
br label %26
26: ; preds = %17, %20
%27 = add nuw nsw i64 %12, 1
%28 = icmp eq i64 %27, %9
br i1 %28, label %10, label %11
}