// File: /workspace/github_c_makefile_star2_O2/tylerneylon[P]APIsWithLua/lua/lobject.c
// Function: luaO_arith
void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2,
                 TValue *res) {
  switch (op) {
    case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
    case LUA_OPSHL: case LUA_OPSHR:
    case LUA_OPBNOT: {  /* operate only on integers */
      lua_Integer i1; lua_Integer i2;
      if (tointeger(p1, &i1) && tointeger(p2, &i2)) {
        setivalue(res, intarith(L, op, i1, i2));
        return;
      }
      else break;  /* go to the end */
    }
    case LUA_OPDIV: case LUA_OPPOW: {  /* operate only on floats */
      lua_Number n1; lua_Number n2;
      if (tonumber(p1, &n1) && tonumber(p2, &n2)) {
        setfltvalue(res, numarith(L, op, n1, n2));
        return;
      }
      else break;  /* go to the end */
    }
    default: {  /* other operations */
      lua_Number n1; lua_Number n2;
      if (ttisinteger(p1) && ttisinteger(p2)) {
        setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2)));
        return;
      }
      else if (tonumber(p1, &n1) && tonumber(p2, &n2)) {
        setfltvalue(res, numarith(L, op, n1, n2));
        return;
      }
      else break;  /* go to the end */
    }
  }
  /* could not perform raw operation; try metamethod */
  lua_assert(L != NULL);  /* should not fail when folding (compile time) */
  luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movq %rcx, %r15
movq %rdx, %r12
movl %esi, %ebp
movq %rdi, %r14
cmpl $0xd, %esi
ja 0xad4e
movl $0x2f80, %eax           # imm = 0x2F80
btl %ebp, %eax
jae 0xacd5
cmpl $0x13, 0x8(%r12)
jne 0xacad
movq (%r12), %rax
movq %rax, 0x8(%rsp)
jmp 0xacc4
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0xfed4
testl %eax, %eax
je 0xae16
cmpl $0x13, 0x8(%r15)
jne 0xacf3
movq (%r15), %rcx
movq %rcx, 0x10(%rsp)
jmp 0xad0f
pushq $0x30
popq %rax
btl %ebp, %eax
jae 0xad4e
cmpl $0x3, 0x8(%r12)
jne 0xad2d
movq (%r12), %xmm0
movq %xmm0, 0x8(%rsp)
jmp 0xad42
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0xfed4
testl %eax, %eax
je 0xae16
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rdx
movq %r14, %rdi
movl %ebp, %esi
callq 0xae3c
movq %rax, (%rbx)
movl $0x13, 0x8(%rbx)
jmp 0xae2d
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0xfe58
testl %eax, %eax
je 0xae16
cmpl $0x3, 0x8(%r15)
jne 0xad7c
movq %r15, %r13
jmp 0xad94
movl 0x8(%r12), %eax
cmpl $0x3, %eax
je 0xadc7
cmpl $0x13, %eax
jne 0xadb4
cmpl $0x13, 0x8(%r15)
jne 0xadb4
movq (%r12), %rdx
movq (%r15), %rcx
movq %r14, %rdi
movl %ebp, %esi
callq 0xae3c
pushq $0x13
jmp 0xae0d
leaq 0x10(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0xfe58
testl %eax, %eax
je 0xae16
movsd (%r13), %xmm1
movq 0x8(%rsp), %xmm0
movl %ebp, %edi
callq 0xaea6
movq %xmm0, (%rbx)
movl $0x3, 0x8(%rbx)
jmp 0xae2d
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0xfe58
testl %eax, %eax
jne 0xadd3
jmp 0xae16
movq (%r12), %xmm0
movq %xmm0, 0x8(%rsp)
cmpl $0x3, 0x8(%r15)
jne 0xaddf
movq %r15, %r13
jmp 0xadf3
leaq 0x10(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0xfe58
testl %eax, %eax
je 0xae16
movsd (%r13), %xmm1
movq 0x8(%rsp), %xmm0
movl %ebp, %edi
callq 0xaea6
movq %xmm0, %rax
pushq $0x3
popq %rcx
movq %rax, (%rbx)
movl %ecx, 0x8(%rbx)
jmp 0xae2d
addl $0x6, %ebp
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
movl %ebp, %r8d
callq 0xf674
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq