#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 */
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rpn(char *);
int /*<<< orphan*/ stdin;
int main(void) {
  char buffer[1024];
  for (;;) {
    printf("> ");
    if (fgets(buffer, sizeof(buffer), stdin) == NULL)
      break;
    rpn(buffer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    0x2e8c(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    1177 <main+0x47>
jmp    1188 <main+0x58>
lea    -0x410(%rbp),%rdi
call   1030 <rpn@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
lea    0xebd(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e99(%rip),%r15
mov    (%r15),%edx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1195 <main+0x65>
mov    %rsp,%rbx
lea    0xe92(%rip),%r14
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <rpn@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
store i32 0, i32* %1
br label %3
3: ; preds = %10, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32* @fgets(i8* %5, i32 1024, i32 %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %10
9: ; preds = %3
br label %13
10: ; preds = %3
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%12 = call i32 @rpn(i8* %11)
br label %3
13: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32* @fgets(i8* %2, i32 1024, i32 %4)
%6 = icmp eq i32* %5, null
br i1 %6, label %13, label %7
7: ; preds = %0, %7
%8 = call i32 @rpn(i8* %2)
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i32* @fgets(i8* %2, i32 1024, i32 %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %7
13: ; preds = %7, %0
ret i32 0
}