#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*/ expression;

/* Variables and functions */
int evaluate_RPN_expression(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ is_empty();
int /*<<< orphan*/ make_empty();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(void) {
  char expression[100];
  while (true) {
    printf("Enter an RPN expression: ");
    fgets(expression, sizeof(expression), stdin);
    printf("Total: %d\n", evaluate_RPN_expression(expression));
    if (is_empty()) {
      break;
    }
    make_empty();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1050 <fgets@plt>
lea    -0x70(%rbp),%rdi
call   1060 <evaluate_RPN_expression@plt>
mov    %eax,%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <is_empty@plt>
cmp    $0x0,%rax
je     11b3 <main+0x63>
jmp    11bf <main+0x6f>
mov    $0x0,%al
call   1070 <make_empty@plt>
jmp    115f <main+0xf>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e78(%rip),%r12
mov    (%r12),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <evaluate_RPN_expression@plt>
lea    0xe87(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <is_empty@plt>
test   %rax,%rax
jne    1202 <main+0xb2>
lea    0xe51(%rip),%r14
mov    %rsp,%rbx
lea    0xe61(%rip),%r15
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <make_empty@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <evaluate_RPN_expression@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <is_empty@plt>
test   %rax,%rax
je     11c0 <main+0x70>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Enter an RPN expression: \00"
@stdin = global i32 0
@.str.1 = [11 x i8] c"Total: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
store i32 0, i32* %1
br label %3
3: ; preds = %0, %14
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 100, i32 %6)
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i32 @evaluate_RPN_expression(i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = call i64 (...) @is_empty()
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %3
br label %16
14: ; preds = %3
%15 = call i32 (...) @make_empty()
br label %3
16: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Enter an RPN expression: \00"
@stdin = global i32 0
@.str.1 = [11 x i8] c"Total: %d\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 100, i32 %4)
%6 = call i32 @evaluate_RPN_expression(i8* %2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i64 (...) @is_empty()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %0, %10
%11 = call i32 (...) @make_empty()
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %2, i32 100, i32 %13)
%15 = call i32 @evaluate_RPN_expression(i8* %2)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i64 (...) @is_empty()
%18 = icmp eq i64 %17, 0
br i1 %18, label %10, label %19
19: ; preds = %10, %0
ret i32 0
}