#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 */
double POP();
int /*<<< orphan*/ PUSH(double);
int /*<<< orphan*/ clear();
int /*<<< orphan*/ duplicate();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
double sqrt(double);
int sscanf(char *, char *, double *);
scalar_t__ strcmp(char *, char *);
void parse_word(char word[]) {
  int string_s;
  double x;
  if (strcmp(word, "dup") == 0)
    duplicate();
  else if (strcmp(word, "clear") == 0)
    clear();
  else if (strcmp(word, "exit") == 0)
    exit(0);
  else if (strcmp(word, "quit") == 0)
    exit(0);
  else if (strcmp(word, "sqrt") == 0)
    PUSH(sqrt(POP()));
  else if (strcmp(word, "+") == 0)
    PUSH(POP() + POP());
  else if (strcmp(word, "-") == 0) {
    x = POP();
    PUSH(POP() - x);
  } else if (strcmp(word, "*") == 0)
    PUSH(POP() * POP());
  else if (strcmp(word, "/") == 0) {
    x = POP();
    PUSH(POP() / x);
  } else {
    string_s = sscanf(word, "%lf", &x);
    if (string_s < 0)
      return;
    if (string_s == 0) {
      printf("Invalid Input\n");
      return;
    }
    PUSH(x);
  }
  return;
}


x86 assembly (clang, -O0):
<parse_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c2 <parse_word+0x32>
mov    $0x0,%al
call   1080 <duplicate@plt>
jmp    13cb <parse_word+0x23b>
mov    -0x8(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11e8 <parse_word+0x58>
mov    $0x0,%al
call   10b0 <clear@plt>
jmp    13c6 <parse_word+0x236>
mov    -0x8(%rbp),%rdi
lea    0xe17(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1209 <parse_word+0x79>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xdfb(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    122a <parse_word+0x9a>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xddf(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    125a <parse_word+0xca>
mov    $0x0,%al
call   1040 <POP@plt>
call   1090 <sqrt@plt>
call   1060 <PUSH@plt>
jmp    13b7 <parse_word+0x227>
mov    -0x8(%rbp),%rdi
lea    0xdb4(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    129d <parse_word+0x10d>
mov    $0x0,%al
call   1040 <POP@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1040 <POP@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  %xmm1,%xmm0
call   1060 <PUSH@plt>
jmp    13b2 <parse_word+0x222>
mov    -0x8(%rbp),%rdi
lea    0xd73(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12d9 <parse_word+0x149>
mov    $0x0,%al
call   1040 <POP@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <POP@plt>
subsd  -0x18(%rbp),%xmm0
call   1060 <PUSH@plt>
jmp    13ad <parse_word+0x21d>
mov    -0x8(%rbp),%rdi
lea    0xd39(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    131c <parse_word+0x18c>
mov    $0x0,%al
call   1040 <POP@plt>
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1040 <POP@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <PUSH@plt>
jmp    13a8 <parse_word+0x218>
mov    -0x8(%rbp),%rdi
lea    0xcf8(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1358 <parse_word+0x1c8>
mov    $0x0,%al
call   1040 <POP@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <POP@plt>
divsd  -0x18(%rbp),%xmm0
call   1060 <PUSH@plt>
jmp    13a3 <parse_word+0x213>
mov    -0x8(%rbp),%rdi
lea    0xcbe(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <sscanf@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    137e <parse_word+0x1ee>
jmp    13d0 <parse_word+0x240>
cmpl   $0x0,-0xc(%rbp)
jne    1399 <parse_word+0x209>
lea    0xc96(%rip),%rdi
call   1030 <printf@plt>
jmp    13d0 <parse_word+0x240>
movsd  -0x18(%rbp),%xmm0
call   1060 <PUSH@plt>
jmp    13a8 <parse_word+0x218>
jmp    13ad <parse_word+0x21d>
jmp    13b2 <parse_word+0x222>
jmp    13b7 <parse_word+0x227>
jmp    13bc <parse_word+0x22c>
jmp    13c1 <parse_word+0x231>
jmp    13c6 <parse_word+0x236>
jmp    13cb <parse_word+0x23b>
jmp    13d0 <parse_word+0x240>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_word>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe61(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     129f <parse_word+0x10f>
lea    0xe50(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12ab <parse_word+0x11b>
lea    0xe3e(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1363 <parse_word+0x1d3>
lea    0xe2b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1363 <parse_word+0x1d3>
lea    0xe18(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12b7 <parse_word+0x127>
lea    0xe05(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12ce <parse_word+0x13e>
lea    0xdef(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12ef <parse_word+0x15f>
lea    0xdd9(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     130f <parse_word+0x17f>
lea    0xdc3(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1329 <parse_word+0x199>
lea    0xdad(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1070 <sscanf@plt>
test   %eax,%eax
js     135d <parse_word+0x1cd>
je     1351 <parse_word+0x1c1>
movsd  0x8(%rsp),%xmm0
call   1060 <PUSH@plt>
jmp    135d <parse_word+0x1cd>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
jmp    1080 <duplicate@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
jmp    10b0 <clear@plt>
xor    %eax,%eax
call   1040 <POP@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     12e8 <parse_word+0x158>
sqrtsd %xmm0,%xmm0
jmp    1347 <parse_word+0x1b7>
xor    %eax,%eax
call   1040 <POP@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1040 <POP@plt>
addsd  (%rsp),%xmm0
jmp    1347 <parse_word+0x1b7>
call   1090 <sqrt@plt>
jmp    1347 <parse_word+0x1b7>
xor    %eax,%eax
call   1040 <POP@plt>
movsd  %xmm0,(%rsp)
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <POP@plt>
subsd  (%rsp),%xmm0
jmp    1347 <parse_word+0x1b7>
xor    %eax,%eax
call   1040 <POP@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1040 <POP@plt>
mulsd  (%rsp),%xmm0
jmp    1347 <parse_word+0x1b7>
xor    %eax,%eax
call   1040 <POP@plt>
movsd  %xmm0,(%rsp)
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <POP@plt>
divsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
jmp    1060 <PUSH@plt>
lea    0xccd(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbx
ret
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"dup\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [5 x i8] c"exit\00"
@.str.3 = [5 x i8] c"quit\00"
@.str.4 = [5 x i8] c"sqrt\00"
@.str.5 = [2 x i8] c"+\00"
@.str.6 = [2 x i8] c"-\00"
@.str.7 = [2 x i8] c"*\00"
@.str.8 = [2 x i8] c"/\00"
@.str.9 = [4 x i8] c"%lf\00"
@.str.10 = [15 x i8] c"Invalid Input\0A\00"
define void @parse_word(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca double
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 (...) @duplicate()
br label %96
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 (...) @clear()
br label %95
16: ; preds = %10
%17 = load i8*, i8** %2
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %16
%23 = load i8*, i8** %2
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @exit(i32 0)
unreachable
28: ; preds = %22
%29 = load i8*, i8** %2
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = call double (...) @POP()
%34 = call double @sqrt(double %33)
%35 = call i32 @PUSH(double %34)
br label %92
36: ; preds = %28
%37 = load i8*, i8** %2
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = call double (...) @POP()
%42 = call double (...) @POP()
%43 = fadd double %41, %42
%44 = call i32 @PUSH(double %43)
br label %91
45: ; preds = %36
%46 = load i8*, i8** %2
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %55
49: ; preds = %45
%50 = call double (...) @POP()
store double %50, double* %4
%51 = call double (...) @POP()
%52 = load double, double* %4
%53 = fsub double %51, %52
%54 = call i32 @PUSH(double %53)
br label %90
55: ; preds = %45
%56 = load i8*, i8** %2
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %55
%60 = call double (...) @POP()
%61 = call double (...) @POP()
%62 = fmul double %60, %61
%63 = call i32 @PUSH(double %62)
br label %89
64: ; preds = %55
%65 = load i8*, i8** %2
%66 = call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %74
68: ; preds = %64
%69 = call double (...) @POP()
store double %69, double* %4
%70 = call double (...) @POP()
%71 = load double, double* %4
%72 = fdiv double %70, %71
%73 = call i32 @PUSH(double %72)
br label %88
74: ; preds = %64
%75 = load i8*, i8** %2
%76 = call i32 @sscanf(i8* %75, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), double* %4)
store i32 %76, i32* %3
%77 = load i32, i32* %3
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %74
br label %97
80: ; preds = %74
%81 = load i32, i32* %3
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %80
%84 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
br label %97
85: ; preds = %80
%86 = load double, double* %4
%87 = call i32 @PUSH(double %86)
br label %88
88: ; preds = %85, %68
br label %89
89: ; preds = %88, %59
br label %90
90: ; preds = %89, %49
br label %91
91: ; preds = %90, %40
br label %92
92: ; preds = %91, %32
br label %93
93: ; preds = %92
br label %94
94: ; preds = %93
br label %95
95: ; preds = %94, %14
br label %96
96: ; preds = %95, %8
br label %97
97: ; preds = %96, %83, %79
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"dup\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [5 x i8] c"exit\00"
@.str.3 = [5 x i8] c"quit\00"
@.str.4 = [5 x i8] c"sqrt\00"
@.str.5 = [2 x i8] c"+\00"
@.str.6 = [2 x i8] c"-\00"
@.str.7 = [2 x i8] c"*\00"
@.str.8 = [2 x i8] c"/\00"
@.str.9 = [4 x i8] c"%lf\00"
@str = [14 x i8] c"Invalid Input\00"
define void @parse_word(i8* %0) {
%2 = alloca double
%3 = bitcast double* %2 to i8*
%4 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 (...) @duplicate()
br label %72
8: ; preds = %1
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 (...) @clear()
br label %72
13: ; preds = %8
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @exit(i32 0)
unreachable
18: ; preds = %13
%19 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @exit(i32 0)
unreachable
23: ; preds = %18
%24 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = tail call double (...) @POP()
%28 = tail call double @sqrt(double %27)
%29 = tail call i32 @PUSH(double %28)
br label %72
30: ; preds = %23
%31 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = tail call double (...) @POP()
%35 = tail call double (...) @POP()
%36 = fadd double %34, %35
%37 = tail call i32 @PUSH(double %36)
br label %72
38: ; preds = %30
%39 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %38
%42 = tail call double (...) @POP()
store double %42, double* %2
%43 = tail call double (...) @POP()
%44 = fsub double %43, %42
%45 = tail call i32 @PUSH(double %44)
br label %72
46: ; preds = %38
%47 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = tail call double (...) @POP()
%51 = tail call double (...) @POP()
%52 = fmul double %50, %51
%53 = tail call i32 @PUSH(double %52)
br label %72
54: ; preds = %46
%55 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %54
%58 = tail call double (...) @POP()
store double %58, double* %2
%59 = tail call double (...) @POP()
%60 = fdiv double %59, %58
%61 = tail call i32 @PUSH(double %60)
br label %72
62: ; preds = %54
%63 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), double* %2)
%64 = icmp slt i32 %63, 0
br i1 %64, label %72, label %65
65: ; preds = %62
%66 = icmp eq i32 %63, 0
br i1 %66, label %67, label %69
67: ; preds = %65
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %72
69: ; preds = %65
%70 = load double, double* %2
%71 = call i32 @PUSH(double %70)
br label %72
72: ; preds = %6, %26, %41, %57, %69, %49, %33, %11, %62, %67
ret void
}