#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char **);
int /*<<< orphan*/ toprefix(char *);
int main() {
  char infix[100], postfix[100], rev[100];
  printf("\nenter the infix expression :");
  scanf("%s", &infix);
  int i = 0;
  int top = 0;
  while (infix[i] != '\0') {
    top++;
    i++;
  }
  rev[top] = '\0';
  top--;
  i = 0;
  while (infix[i] != '\0') {
    rev[top] = infix[i];
    i++;
    top--;
  }
  toprefix(rev);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xec5(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0x154(%rbp)
movl   $0x0,-0x158(%rbp)
movslq -0x154(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11aa <main+0x7a>
mov    -0x158(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x158(%rbp)
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
jmp    1172 <main+0x42>
movslq -0x158(%rbp),%rax
movb   $0x0,-0x150(%rbp,%rax,1)
mov    -0x158(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x158(%rbp)
movl   $0x0,-0x154(%rbp)
movslq -0x154(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1223 <main+0xf3>
movslq -0x154(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0x158(%rbp),%rax
mov    %cl,-0x150(%rbp,%rax,1)
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
mov    -0x158(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x158(%rbp)
jmp    11d2 <main+0xa2>
lea    -0x150(%rbp),%rdi
call   1050 <toprefix@plt>
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xd8,%rsp
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    0x70(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x70(%rsp),%al
test   %al,%al
je     11a3 <main+0x73>
xor    %edx,%edx
xchg   %ax,%ax
cmpb   $0x0,0x71(%rsp,%rdx,1)
lea    0x1(%rdx),%rdx
jne    1160 <main+0x30>
mov    %edx,%ecx
movb   $0x0,(%rsp,%rcx,1)
test   %al,%al
je     11a7 <main+0x77>
lea    0x71(%rsp),%rcx
mov    %edx,%edx
add    %rsp,%rdx
add    $0xffffffffffffffff,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %al,(%rdx)
movzbl (%rcx),%eax
add    $0x1,%rcx
add    $0xffffffffffffffff,%rdx
test   %al,%al
jne    1190 <main+0x60>
jmp    11a7 <main+0x77>
movb   $0x0,(%rsp)
mov    %rsp,%rdi
call   1050 <toprefix@plt>
xor    %eax,%eax
add    $0xd8,%rsp
ret

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

LLVM IR (-O2):
@.str = [30 x i8] c"\0Aenter the infix expression :\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = bitcast [100 x i8]* %1 to i8**
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %6)
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
store i8 0, i8* %11
br label %31
12: ; preds = %0, %12
%13 = phi i64 [ %14, %12 ], [ 0, %0 ]
%14 = add nuw nsw i64 %13, 1
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %12
18: ; preds = %12
%19 = and i64 %14, 4294967295
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %19
store i8 0, i8* %20
br i1 %9, label %31, label %21
21: ; preds = %18, %21
%22 = phi i64 [ %27, %21 ], [ 0, %18 ]
%23 = phi i64 [ %25, %21 ], [ %19, %18 ]
%24 = phi i8 [ %29, %21 ], [ %8, %18 ]
%25 = add nsw i64 %23, -1
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %25
store i8 %24, i8* %26
%27 = add nuw nsw i64 %22, 1
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %21
31: ; preds = %21, %10, %18
%32 = call i32 @toprefix(i8* %4)
ret i32 0
}