#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 rpn();
int main(void) {
  printf("\n#---------------------------------------------------#\n");
  printf("| Program: Reverse Polish Notation (RPN) calculator |\n");
  printf("| Author: Alexander Skafte                          |\n");
  printf("|                                                   |\n");
  printf("| Enter numbers separated by spaces in RPN style.   |\n");
  printf("| For example:                                      |\n");
  printf("|          2 3 + 10 *                               |\n");
  printf("| Execute by pressing Return/Enter.                 |\n");
  printf("| Exit by pressing Ctrl+D.                          |\n");
  printf("#---------------------------------------------------#\n");
  while (1) {
    printf("\nInput> ");
    printf("> %d\n", rpn());
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xfc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xfea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x1013(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x102e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <rpn@plt>
mov    %eax,%esi
lea    0x1020(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bb <main+0x9b>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed4(%rip),%rdi
call   1040 <puts@plt>
lea    0xeff(%rip),%rdi
call   1040 <puts@plt>
lea    0xf29(%rip),%rdi
call   1040 <puts@plt>
lea    0xf53(%rip),%rdi
call   1040 <puts@plt>
lea    0xf7d(%rip),%rdi
call   1040 <puts@plt>
lea    0xfa7(%rip),%rdi
call   1040 <puts@plt>
lea    0xfd1(%rip),%rdi
call   1040 <puts@plt>
lea    0xffb(%rip),%rdi
call   1040 <puts@plt>
lea    0x1025(%rip),%rdi
call   1040 <puts@plt>
lea    0xe69(%rip),%rdi
call   1040 <puts@plt>
lea    0xe4d(%rip),%r14
lea    0xe4f(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <rpn@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c0 <main+0x90>

LLVM IR (-O0):
@.str = [56 x i8] c"\0A#---------------------------------------------------#\0A\00"
@.str.1 = [55 x i8] c"| Program: Reverse Polish Notation (RPN) calculator |\0A\00"
@.str.2 = [55 x i8] c"| Author: Alexander Skafte |\0A\00"
@.str.3 = [55 x i8] c"| |\0A\00"
@.str.4 = [55 x i8] c"| Enter numbers separated by spaces in RPN style. |\0A\00"
@.str.5 = [55 x i8] c"| For example: |\0A\00"
@.str.6 = [55 x i8] c"| 2 3 + 10 * |\0A\00"
@.str.7 = [55 x i8] c"| Execute by pressing Return/Enter. |\0A\00"
@.str.8 = [55 x i8] c"| Exit by pressing Ctrl+D. |\0A\00"
@.str.9 = [55 x i8] c"#---------------------------------------------------#\0A\00"
@.str.10 = [9 x i8] c"\0AInput> \00"
@.str.11 = [6 x i8] c"> %d\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0))
br label %12
12: ; preds = %0, %12
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
%14 = call i32 (...) @rpn()
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %14)
br label %12
}

LLVM IR (-O2):
@.str.10 = [9 x i8] c"\0AInput> \00"
@.str.11 = [6 x i8] c"> %d\0A\00"
@str = [55 x i8] c"\0A#---------------------------------------------------#\00"
@str.12 = [54 x i8] c"| Program: Reverse Polish Notation (RPN) calculator |\00"
@str.13 = [54 x i8] c"| Author: Alexander Skafte |\00"
@str.14 = [54 x i8] c"| |\00"
@str.15 = [54 x i8] c"| Enter numbers separated by spaces in RPN style. |\00"
@str.16 = [54 x i8] c"| For example: |\00"
@str.17 = [54 x i8] c"| 2 3 + 10 * |\00"
@str.18 = [54 x i8] c"| Execute by pressing Return/Enter. |\00"
@str.19 = [54 x i8] c"| Exit by pressing Ctrl+D. |\00"
@str.20 = [54 x i8] c"#---------------------------------------------------#\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.12, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.13, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.14, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.15, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.16, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.17, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.18, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.19, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.20, i64 0, i64 0))
br label %11
11: ; preds = %0, %11
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
%13 = tail call i32 (...) @rpn()
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %13)
br label %11
}