#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*/ printf(char *, double);
int /*<<< orphan*/ push(char const);
int strlen(char const *);
int main(int argc, char *argv[]) {
  const char *str = "12-45+/5*\0";
  double op2 = 0;
  for (int i = 0, length = strlen(str); i < length; i++) {
    switch (str[i]) {
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
      push(str[i] - '0');
      break;
    case '+':
      push(pop() + pop());
      break;
    case '-':
      op2 = pop();
      push(pop() - op2);
      break;
    case '*':
      push(pop() * pop());
      break;
    case '/':
      op2 = pop();
      push(pop() / op2);
      break;
    }
  }
  printf("the result is %lf\n", pop());
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xee3(%rip),%rax
mov    %rax,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12ae <main+0x16e>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0xf,%eax
ja     129b <main+0x15b>
mov    -0x30(%rbp),%rax
lea    0xe4f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
movsbl %al,%edi
call   1060 <push@plt>
jmp    129b <main+0x15b>
xor    %eax,%eax
mov    %al,-0x39(%rbp)
call   1050 <pop@plt>
mov    -0x39(%rbp),%al
movsd  %xmm0,-0x38(%rbp)
call   1050 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movsbl %al,%edi
call   1060 <push@plt>
jmp    129b <main+0x15b>
xor    %eax,%eax
mov    %al,-0x3a(%rbp)
call   1050 <pop@plt>
mov    -0x3a(%rbp),%al
movsd  %xmm0,-0x20(%rbp)
call   1050 <pop@plt>
movsd  -0x20(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movsbl %al,%edi
call   1060 <push@plt>
jmp    129b <main+0x15b>
xor    %eax,%eax
mov    %al,-0x49(%rbp)
call   1050 <pop@plt>
mov    -0x49(%rbp),%al
movsd  %xmm0,-0x48(%rbp)
call   1050 <pop@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movsbl %al,%edi
call   1060 <push@plt>
jmp    129b <main+0x15b>
xor    %eax,%eax
mov    %al,-0x4a(%rbp)
call   1050 <pop@plt>
mov    -0x4a(%rbp),%al
movsd  %xmm0,-0x20(%rbp)
call   1050 <pop@plt>
movsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
movsbl %al,%edi
call   1060 <push@plt>
jmp    12a0 <main+0x160>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117c <main+0x3c>
mov    $0x0,%al
call   1050 <pop@plt>
lea    0xd8f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec9(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1220 <main+0xe0>
mov    %eax,%r12d
lea    0xe97(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%rbx,%r14,1),%eax
movsbl %al,%ecx
lea    -0x30(%rcx),%edx
cmp    $0xa,%edx
jae    1190 <main+0x50>
add    $0xd0,%al
jmp    120b <main+0xcb>
nopw   0x0(%rax,%rax,1)
add    $0xffffffd6,%ecx
cmp    $0x5,%ecx
ja     1213 <main+0xd3>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
xor    %eax,%eax
call   1050 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <pop@plt>
mulsd  (%rsp),%xmm0
jmp    1207 <main+0xc7>
xor    %eax,%eax
call   1050 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <pop@plt>
addsd  (%rsp),%xmm0
jmp    1207 <main+0xc7>
xor    %eax,%eax
call   1050 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <pop@plt>
subsd  (%rsp),%xmm0
jmp    1207 <main+0xc7>
xor    %eax,%eax
call   1050 <pop@plt>
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <pop@plt>
divsd  (%rsp),%xmm0
cvttsd2si %xmm0,%eax
movsbl %al,%edi
call   1060 <push@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <main+0x30>
xor    %eax,%eax
call   1050 <pop@plt>
lea    0xdf5(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"12-45+/5*\00\00"
@.str.1 = [19 x i8] c"the result is %lf\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = zext i32 %3 to i64
br label %10
7: ; preds = %40, %2
%8 = tail call double (...) @pop()
%9 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %8)
ret i32 0
10: ; preds = %5, %40
%11 = phi i64 [ 0, %5 ], [ %41, %40 ]
%12 = getelementptr inbounds [11 x i8], [11 x i8]* @.str, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
switch i32 %14, label %40 [
i32 48, label %15
i32 49, label %15
i32 50, label %15
i32 51, label %15
i32 52, label %15
i32 53, label %15
i32 54, label %15
i32 55, label %15
i32 56, label %15
i32 57, label %15
i32 43, label %17
i32 45, label %22
i32 42, label %27
i32 47, label %32
]
15: ; preds = %10, %10, %10, %10, %10, %10, %10, %10, %10, %10
%16 = add i8 %13, -48
br label %37
17: ; preds = %10
%18 = tail call double (...) @pop()
%19 = tail call double (...) @pop()
%20 = fadd double %18, %19
%21 = fptosi double %20 to i8
br label %37
22: ; preds = %10
%23 = tail call double (...) @pop()
%24 = tail call double (...) @pop()
%25 = fsub double %24, %23
%26 = fptosi double %25 to i8
br label %37
27: ; preds = %10
%28 = tail call double (...) @pop()
%29 = tail call double (...) @pop()
%30 = fmul double %28, %29
%31 = fptosi double %30 to i8
br label %37
32: ; preds = %10
%33 = tail call double (...) @pop()
%34 = tail call double (...) @pop()
%35 = fdiv double %34, %33
%36 = fptosi double %35 to i8
br label %37
37: ; preds = %32, %27, %22, %17, %15
%38 = phi i8 [ %16, %15 ], [ %21, %17 ], [ %26, %22 ], [ %31, %27 ], [ %36, %32 ]
%39 = tail call i32 @push(i8 signext %38)
br label %40
40: ; preds = %37, %10
%41 = add nuw nsw i64 %11, 1
%42 = icmp eq i64 %41, %6
br i1 %42, label %7, label %10
}