#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 */
char pop(char **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(char **, char);
char *in2post(char *infix) {
  char *p, op_stack[1000], *stackp, buff[8000], *post;
  post = buff;
  stackp = op_stack;
  *stackp = '~';
  stackp++;
  for (p = infix; *p != '\0'; p++) {
    switch (*p) {
    default:
      *post = *p;
      post++;
      break;
    case '+':
      push(&stackp, *p);
      break;
    }
  }
  while (*stackp != '~') {
    char c = pop(&stackp);
    printf("%c\n", c);
    *post = c;
    post++;
  }
  printf("Final: %s\n", buff);
  return post;
}


x86 assembly (clang, -O0):
<in2post>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2360,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x2350(%rbp),%rax
mov    %rax,-0x2358(%rbp)
lea    -0x400(%rbp),%rax
mov    %rax,-0x408(%rbp)
mov    -0x408(%rbp),%rax
movb   $0x7e,(%rax)
mov    -0x408(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x408(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11f1 <in2post+0xc1>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
sub    $0x2b,%al
je     11c8 <in2post+0x98>
jmp    11a2 <in2post+0x72>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x2358(%rbp),%rax
mov    %cl,(%rax)
mov    -0x2358(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2358(%rbp)
jmp    11db <in2post+0xab>
mov    -0x10(%rbp),%rax
lea    -0x408(%rbp),%rdi
movsbl (%rax),%esi
call   1050 <push@plt>
jmp    11e0 <in2post+0xb0>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    117f <in2post+0x4f>
jmp    11f6 <in2post+0xc6>
mov    -0x408(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7e,%eax
je     1256 <in2post+0x126>
lea    -0x408(%rbp),%rdi
call   1040 <pop@plt>
mov    %al,-0x2359(%rbp)
movsbl -0x2359(%rbp),%esi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2359(%rbp),%cl
mov    -0x2358(%rbp),%rax
mov    %cl,(%rax)
mov    -0x2358(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2358(%rbp)
jmp    11f6 <in2post+0xc6>
lea    -0x2350(%rbp),%rsi
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2358(%rbp),%rax
add    $0x2360,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<in2post>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x2348,%rsp
mov    %rdi,%rbx
lea    0x400(%rsp),%r14
movb   $0x7e,0x10(%rsp)
lea    0x11(%rsp),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%r15
jmp    1171 <in2post+0x41>
xchg   %ax,%ax
mov    %r15,%rdi
mov    $0x2b,%esi
call   1050 <push@plt>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x2b,%al
je     1160 <in2post+0x30>
test   %al,%al
je     1189 <in2post+0x59>
mov    %al,(%r14)
add    $0x1,%r14
add    $0x1,%rbx
jmp    1171 <in2post+0x41>
mov    0x8(%rsp),%rax
cmpb   $0x7e,(%rax)
je     11c8 <in2post+0x98>
lea    0x8(%rsp),%r15
lea    0xe61(%rip),%rbx
nop
mov    %r15,%rdi
call   1040 <pop@plt>
movsbl %al,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %bpl,(%r14)
add    $0x1,%r14
mov    0x8(%rsp),%rax
cmpb   $0x7e,(%rax)
jne    11a0 <in2post+0x70>
lea    0xe35(%rip),%rdi
lea    0x400(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rax
add    $0x2348,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%c\0A\00"
@.str.1 = [11 x i8] c"Final: %s\0A\00"
define i8* @in2post(i8* nocapture %0) {
%2 = alloca [1000 x i8]
%3 = alloca i8*
%4 = alloca [8000 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%6 = bitcast i8** %3 to i8*
%7 = getelementptr inbounds [8000 x i8], [8000 x i8]* %4, i64 0, i64 0
store i8 126, i8* %5
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 1
store i8* %8, i8** %3
br label %9
9: ; preds = %21, %1
%10 = phi i8* [ %7, %1 ], [ %22, %21 ]
%11 = phi i8* [ %0, %1 ], [ %23, %21 ]
%12 = load i8, i8* %11
switch i8 %12, label %17 [
i8 0, label %13
i8 43, label %19
]
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 126
br i1 %16, label %33, label %24
17: ; preds = %9
store i8 %12, i8* %10
%18 = getelementptr inbounds i8, i8* %10, i64 1
br label %21
19: ; preds = %9
%20 = call i32 @push(i8** %3, i8 signext 43)
br label %21
21: ; preds = %17, %19
%22 = phi i8* [ %10, %19 ], [ %18, %17 ]
%23 = getelementptr inbounds i8, i8* %11, i64 1
br label %9
24: ; preds = %13, %24
%25 = phi i8* [ %29, %24 ], [ %10, %13 ]
%26 = call signext i8 @pop(i8** %3)
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
store i8 %26, i8* %25
%29 = getelementptr inbounds i8, i8* %25, i64 1
%30 = load i8*, i8** %3
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 126
br i1 %32, label %33, label %24
33: ; preds = %24, %13
%34 = phi i8* [ %10, %13 ], [ %29, %24 ]
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %7)
ret i8* %34
}