#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 */
int /*<<< orphan*/ do_next_op(char, double, double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scan_data(char *, double *);
int main(void) {
  char operator;
  double right_operand, accumulator = 0;
  do {
    scan_data(&operator, & right_operand);
    do_next_op(operator, right_operand, &accumulator);
    if (operator== 'q')
      printf("final result is ");
    else
      printf("result so far is ");
    printf("%.1f\n", accumulator);
  } while (operator!= 'q');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x5(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scan_data@plt>
mov    -0x5(%rbp),%al
movsd  -0x10(%rbp),%xmm0
lea    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1040 <do_next_op@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x71,%eax
jne    1188 <main+0x58>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1196 <main+0x66>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xe81(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x71,%eax
jne    1147 <main+0x17>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
lea    0x7(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0xea3(%rip),%r13
lea    0xead(%rip),%rbp
lea    0xeb8(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scan_data@plt>
movsbl 0x7(%rsp),%edi
movsd  0x10(%rsp),%xmm0
mov    %r12,%rsi
call   1040 <do_next_op@plt>
cmpb   $0x71,0x7(%rsp)
mov    %rbp,%rdi
cmove  %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmpb   $0x71,0x7(%rsp)
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"final result is \00"
@.str.1 = [18 x i8] c"result so far is \00"
@.str.2 = [6 x i8] c"%.1f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %4
br label %5
5: ; preds = %20, %0
%6 = call i32 @scan_data(i8* %2, double* %3)
%7 = load i8, i8* %2
%8 = load double, double* %3
%9 = call i32 @do_next_op(i8 signext %7, double %8, double* %4)
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 113
br i1 %12, label %13, label %15
13: ; preds = %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %17
15: ; preds = %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
%18 = load double, double* %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %18)
br label %20
20: ; preds = %17
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 113
br i1 %23, label %5, label %24
24: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"final result is \00"
@.str.1 = [18 x i8] c"result so far is \00"
@.str.2 = [6 x i8] c"%.1f\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %2 to i8*
%5 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
br label %6
6: ; preds = %6, %0
%7 = call i32 @scan_data(i8* %1, double* %2)
%8 = load i8, i8* %1
%9 = load double, double* %2
%10 = call i32 @do_next_op(i8 signext %8, double %9, double* %3)
%11 = load i8, i8* %1
%12 = icmp eq i8 %11, 113
%13 = select i1 %12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %13)
%15 = load double, double* %3
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %15)
%17 = load i8, i8* %1
%18 = icmp eq i8 %17, 113
br i1 %18, label %19, label %6
19: ; preds = %6
ret i32 0
}