#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*/ assert(int /*<<< orphan*/);
size_t get_assigned_to(int *, int);
size_t get_operand_left(int *, int);
size_t get_operand_right(int *, int);
int get_operator(int *, int);
__attribute__((visibility("default"))) void
evaluate_double(double *variables, int *program, int num_statements,
                double *numbers, double *point) {
  for (int statement = 0; statement < num_statements; statement++) {
    int operator= get_operator(program, statement);
    double value = variables[get_assigned_to(program, statement)];
    switch (operator) {
    case 1:
      value = numbers[get_operand_left(program, statement)];
      break;
    case 0:
      value = point[get_operand_left(program, statement) * 2];
      break;
    case 2:
      value = -variables[get_operand_left(program, statement)];
      break;
    case 3:
      value = 1.0 / variables[get_operand_left(program, statement)];
      break;
    case 4:
      value = variables[get_operand_left(program, statement)] +
              variables[get_operand_right(program, statement)];
      break;
    case 5:
      value = variables[get_operand_left(program, statement)] *
              variables[get_operand_right(program, statement)];
      break;
    default:
      assert(0);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<evaluate_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1379 <evaluate_double+0x229>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1060 <get_operator@plt>
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1070 <get_assigned_to@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x30(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0x5,%rax
ja     135f <evaluate_double+0x20f>
mov    -0x40(%rbp),%rax
lea    0xe37(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1040 <get_operand_left@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1366 <evaluate_double+0x216>
mov    -0x28(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1040 <get_operand_left@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
shl    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1366 <evaluate_double+0x216>
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1040 <get_operand_left@plt>
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1366 <evaluate_double+0x216>
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1040 <get_operand_left@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
movsd  0xd6a(%rip),%xmm0
divsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1366 <evaluate_double+0x216>
mov    -0x8(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1040 <get_operand_left@plt>
mov    %rax,%rcx
mov    -0x80(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1030 <get_operand_right@plt>
movsd  -0x78(%rbp),%xmm0
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1366 <evaluate_double+0x216>
mov    -0x8(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1040 <get_operand_left@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1030 <get_operand_right@plt>
movsd  -0x90(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1366 <evaluate_double+0x216>
xor    %edi,%edi
call   1050 <assert@plt>
jmp    136b <evaluate_double+0x21b>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1175 <evaluate_double+0x25>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evaluate_double>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
jle    11c7 <evaluate_double+0x77>
mov    %edx,%r14d
mov    %rsi,%r15
xor    %ebp,%ebp
lea    0xe95(%rip),%r12
jmp    118c <evaluate_double+0x3c>
nopl   (%rax)
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <get_operand_left@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <get_operand_right@plt>
add    $0x1,%ebp
cmp    %ebp,%r14d
je     11c7 <evaluate_double+0x77>
mov    %r15,%rdi
mov    %ebp,%esi
call   1060 <get_operator@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %ebp,%esi
call   1070 <get_assigned_to@plt>
cmp    $0x5,%ebx
ja     11be <evaluate_double+0x6e>
mov    %ebx,%eax
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <get_operand_left@plt>
jmp    1184 <evaluate_double+0x34>
xor    %edi,%edi
call   1050 <assert@plt>
jmp    1184 <evaluate_double+0x34>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @evaluate_double(double* %0, i32* %1, i32 %2, double* %3, double* %4) {
%6 = alloca double*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
store double* %0, double** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store double* %3, double** %9
store double* %4, double** %10
store i32 0, i32* %11
br label %14
14: ; preds = %91, %5
%15 = load i32, i32* %11
%16 = load i32, i32* %8
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %94
18: ; preds = %14
%19 = load i32*, i32** %7
%20 = load i32, i32* %11
%21 = call i32 @get_operator(i32* %19, i32 %20)
store i32 %21, i32* %12
%22 = load double*, double** %6
%23 = load i32*, i32** %7
%24 = load i32, i32* %11
%25 = call i64 @get_assigned_to(i32* %23, i32 %24)
%26 = getelementptr inbounds double, double* %22, i64 %25
%27 = load double, double* %26
store double %27, double* %13
%28 = load i32, i32* %12
switch i32 %28, label %88 [
i32 1, label %29
i32 0, label %36
i32 2, label %44
i32 3, label %52
i32 4, label %60
i32 5, label %74
]
29: ; preds = %18
%30 = load double*, double** %9
%31 = load i32*, i32** %7
%32 = load i32, i32* %11
%33 = call i64 @get_operand_left(i32* %31, i32 %32)
%34 = getelementptr inbounds double, double* %30, i64 %33
%35 = load double, double* %34
store double %35, double* %13
br label %90
36: ; preds = %18
%37 = load double*, double** %10
%38 = load i32*, i32** %7
%39 = load i32, i32* %11
%40 = call i64 @get_operand_left(i32* %38, i32 %39)
%41 = mul i64 %40, 2
%42 = getelementptr inbounds double, double* %37, i64 %41
%43 = load double, double* %42
store double %43, double* %13
br label %90
44: ; preds = %18
%45 = load double*, double** %6
%46 = load i32*, i32** %7
%47 = load i32, i32* %11
%48 = call i64 @get_operand_left(i32* %46, i32 %47)
%49 = getelementptr inbounds double, double* %45, i64 %48
%50 = load double, double* %49
%51 = fneg double %50
store double %51, double* %13
br label %90
52: ; preds = %18
%53 = load double*, double** %6
%54 = load i32*, i32** %7
%55 = load i32, i32* %11
%56 = call i64 @get_operand_left(i32* %54, i32 %55)
%57 = getelementptr inbounds double, double* %53, i64 %56
%58 = load double, double* %57
%59 = fdiv double 1.000000e+00, %58
store double %59, double* %13
br label %90
60: ; preds = %18
%61 = load double*, double** %6
%62 = load i32*, i32** %7
%63 = load i32, i32* %11
%64 = call i64 @get_operand_left(i32* %62, i32 %63)
%65 = getelementptr inbounds double, double* %61, i64 %64
%66 = load double, double* %65
%67 = load double*, double** %6
%68 = load i32*, i32** %7
%69 = load i32, i32* %11
%70 = call i64 @get_operand_right(i32* %68, i32 %69)
%71 = getelementptr inbounds double, double* %67, i64 %70
%72 = load double, double* %71
%73 = fadd double %66, %72
store double %73, double* %13
br label %90
74: ; preds = %18
%75 = load double*, double** %6
%76 = load i32*, i32** %7
%77 = load i32, i32* %11
%78 = call i64 @get_operand_left(i32* %76, i32 %77)
%79 = getelementptr inbounds double, double* %75, i64 %78
%80 = load double, double* %79
%81 = load double*, double** %6
%82 = load i32*, i32** %7
%83 = load i32, i32* %11
%84 = call i64 @get_operand_right(i32* %82, i32 %83)
%85 = getelementptr inbounds double, double* %81, i64 %84
%86 = load double, double* %85
%87 = fmul double %80, %86
store double %87, double* %13
br label %90
88: ; preds = %18
%89 = call i32 @assert(i32 0)
br label %90
90: ; preds = %88, %74, %60, %52, %44, %36, %29
br label %91
91: ; preds = %90
%92 = load i32, i32* %11
%93 = add nsw i32 %92, 1
store i32 %93, i32* %11
br label %14
94: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @evaluate_double(double* nocapture readnone %0, i32* %1, i32 %2, double* nocapture readnone %3, double* nocapture readnone %4) {
%6 = icmp sgt i32 %2, 0
br i1 %6, label %8, label %7
7: ; preds = %28, %5
ret void
8: ; preds = %5, %28
%9 = phi i32 [ %29, %28 ], [ 0, %5 ]
%10 = tail call i32 @get_operator(i32* %1, i32 %9)
%11 = tail call i64 @get_assigned_to(i32* %1, i32 %9)
switch i32 %10, label %26 [
i32 1, label %12
i32 0, label %14
i32 2, label %16
i32 3, label %18
i32 4, label %20
i32 5, label %23
]
12: ; preds = %8
%13 = tail call i64 @get_operand_left(i32* %1, i32 %9)
br label %28
14: ; preds = %8
%15 = tail call i64 @get_operand_left(i32* %1, i32 %9)
br label %28
16: ; preds = %8
%17 = tail call i64 @get_operand_left(i32* %1, i32 %9)
br label %28
18: ; preds = %8
%19 = tail call i64 @get_operand_left(i32* %1, i32 %9)
br label %28
20: ; preds = %8
%21 = tail call i64 @get_operand_left(i32* %1, i32 %9)
%22 = tail call i64 @get_operand_right(i32* %1, i32 %9)
br label %28
23: ; preds = %8
%24 = tail call i64 @get_operand_left(i32* %1, i32 %9)
%25 = tail call i64 @get_operand_right(i32* %1, i32 %9)
br label %28
26: ; preds = %8
%27 = tail call i32 @assert(i32 0)
br label %28
28: ; preds = %26, %23, %20, %18, %16, %14, %12
%29 = add nuw nsw i32 %9, 1
%30 = icmp eq i32 %29, %2
br i1 %30, label %7, label %8
}