#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 atof(char *);
scalar_t__ isdigit(char);
double pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(double);
int main(int argc, char *argv[]) {
  double op1, op2;
  char c;
  char arg;
  while (argc-- > 1) {
    *argv++;
    if (isdigit(c = **argv)) {
      push(atof(*argv));
    } else {
      printf("%c\n", c);
      switch (c) {
      case '+':
        push(pop() + pop());
        break;
      case '*':
        push(pop() * pop());
        break;
      case '/':
        op2 = pop();
        push(pop() / op2);
        break;
      case '-':
        op2 = pop();
        push(pop() - op2);
        break;
      default:
        printf("op not recognized\n");
        break;
      }
    }
  }
  printf("%.8g\n", pop());
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x1,%eax
jle    12a4 <main+0x154>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%al
mov    %al,-0x21(%rbp)
movsbl %al,%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11ba <main+0x6a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <atof@plt>
call   1070 <push@plt>
jmp    129f <main+0x14f>
movsbl -0x21(%rbp),%esi
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl -0x21(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x5,%eax
ja     128c <main+0x13c>
mov    -0x30(%rbp),%rax
lea    0xe13(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    129a <main+0x14a>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1070 <push@plt>
jmp    129a <main+0x14a>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
divsd  -0x20(%rbp),%xmm0
call   1070 <push@plt>
jmp    129a <main+0x14a>
mov    $0x0,%al
call   1060 <pop@plt>
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
subsd  -0x20(%rbp),%xmm0
call   1070 <push@plt>
jmp    129a <main+0x14a>
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    129f <main+0x14f>
jmp    1166 <main+0x16>
mov    $0x0,%al
call   1060 <pop@plt>
lea    0xd7d(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1276 <main+0x116>
mov    %rsi,%rbx
mov    %edi,%r12d
add    $0x1,%r12d
add    $0x8,%rbx
lea    0xe8f(%rip),%r14
lea    0xe92(%rip),%r15
lea    0xe69(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%rax
movsbl (%rax),%ebp
mov    %ebp,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11e0 <main+0x80>
mov    (%rbx),%rdi
call   1050 <atof@plt>
call   1080 <push@plt>
add    $0xffffffff,%r12d
add    $0x8,%rbx
cmp    $0x2,%r12d
ja     11a0 <main+0x40>
jmp    1276 <main+0x116>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0xffffffd6,%ebp
cmp    $0x5,%ebp
ja     1232 <main+0xd2>
movslq 0x0(%r13,%rbp,4),%rax
add    %r13,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
mulsd  (%rsp),%xmm0
jmp    11ba <main+0x5a>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
addsd  (%rsp),%xmm0
jmp    11ba <main+0x5a>
mov    %r15,%rdi
call   1040 <puts@plt>
jmp    11bf <main+0x5f>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
subsd  (%rsp),%xmm0
jmp    11ba <main+0x5a>
xor    %eax,%eax
call   1070 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1070 <pop@plt>
divsd  (%rsp),%xmm0
jmp    11ba <main+0x5a>
xor    %eax,%eax
call   1070 <pop@plt>
lea    0xd98(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%c\0A\00"
@.str.1 = [19 x i8] c"op not recognized\0A\00"
@.str.2 = [6 x i8] c"%.8g\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i8
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %10
10: ; preds = %59, %2
%11 = load i32, i32* %4
%12 = add nsw i32 %11, -1
store i32 %12, i32* %4
%13 = icmp sgt i32 %11, 1
br i1 %13, label %14, label %60
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i32 1
store i8** %16, i8*** %5
%17 = load i8*, i8** %15
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %18
%20 = load i8, i8* %19
store i8 %20, i8* %8
%21 = call i64 @isdigit(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %14
%24 = load i8**, i8*** %5
%25 = load i8*, i8** %24
%26 = call double @atof(i8* %25)
%27 = call i32 @push(double %26)
br label %59
28: ; preds = %14
%29 = load i8, i8* %8
%30 = sext i8 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i8, i8* %8
%33 = sext i8 %32 to i32
switch i32 %33, label %56 [
i32 43, label %34
i32 42, label %39
i32 47, label %44
i32 45, label %50
]
34: ; preds = %28
%35 = call double (...) @pop()
%36 = call double (...) @pop()
%37 = fadd double %35, %36
%38 = call i32 @push(double %37)
br label %58
39: ; preds = %28
%40 = call double (...) @pop()
%41 = call double (...) @pop()
%42 = fmul double %40, %41
%43 = call i32 @push(double %42)
br label %58
44: ; preds = %28
%45 = call double (...) @pop()
store double %45, double* %7
%46 = call double (...) @pop()
%47 = load double, double* %7
%48 = fdiv double %46, %47
%49 = call i32 @push(double %48)
br label %58
50: ; preds = %28
%51 = call double (...) @pop()
store double %51, double* %7
%52 = call double (...) @pop()
%53 = load double, double* %7
%54 = fsub double %52, %53
%55 = call i32 @push(double %54)
br label %58
56: ; preds = %28
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %58
58: ; preds = %56, %50, %44, %39, %34
br label %59
59: ; preds = %58, %23
br label %10
60: ; preds = %10
%61 = call double (...) @pop()
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %61)
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
@.str = [4 x i8] c"%c\0A\00"
@.str.2 = [6 x i8] c"%.8g\0A\00"
@str = [18 x i8] c"op not recognized\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %44
4: ; preds = %2, %42
%5 = phi i32 [ %7, %42 ], [ %0, %2 ]
%6 = phi i8** [ %8, %42 ], [ %1, %2 ]
%7 = add nsw i32 %5, -1
%8 = getelementptr inbounds i8*, i8** %6, i64 1
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = tail call i64 @isdigit(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %4
%14 = load i8*, i8** %8
%15 = tail call double @atof(i8* %14)
%16 = tail call i32 @push(double %15)
br label %42
17: ; preds = %4
%18 = sext i8 %10 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
switch i32 %18, label %40 [
i32 43, label %20
i32 42, label %25
i32 47, label %30
i32 45, label %35
]
20: ; preds = %17
%21 = tail call double (...) @pop()
%22 = tail call double (...) @pop()
%23 = fadd double %21, %22
%24 = tail call i32 @push(double %23)
br label %42
25: ; preds = %17
%26 = tail call double (...) @pop()
%27 = tail call double (...) @pop()
%28 = fmul double %26, %27
%29 = tail call i32 @push(double %28)
br label %42
30: ; preds = %17
%31 = tail call double (...) @pop()
%32 = tail call double (...) @pop()
%33 = fdiv double %32, %31
%34 = tail call i32 @push(double %33)
br label %42
35: ; preds = %17
%36 = tail call double (...) @pop()
%37 = tail call double (...) @pop()
%38 = fsub double %37, %36
%39 = tail call i32 @push(double %38)
br label %42
40: ; preds = %17
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %42
42: ; preds = %20, %25, %30, %35, %40, %13
%43 = icmp ugt i32 %5, 2
br i1 %43, label %4, label %44
44: ; preds = %42, %2
%45 = tail call double (...) @pop()
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %45)
ret i32 0
}