// File: /workspace/github_c_makefile_star2_O3/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 0xbaa6
movl $0x2f80, %eax           # imm = 0x2F80
btl %ebp, %eax
jae 0xba2b
cmpl $0x13, 0x8(%r12)
jne 0xba03
movq (%r12), %rax
movq %rax, 0x8(%rsp)
jmp 0xba1a
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0x116b2
testl %eax, %eax
je 0xbb73
cmpl $0x13, 0x8(%r15)
jne 0xba4b
movq (%r15), %rcx
movq %rcx, 0x10(%rsp)
jmp 0xba67
movl $0x30, %eax
btl %ebp, %eax
jae 0xbaa6
cmpl $0x3, 0x8(%r12)
jne 0xba85
movq (%r12), %xmm0
movq %xmm0, 0x8(%rsp)
jmp 0xba9a
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x116b2
testl %eax, %eax
je 0xbb73
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rdx
movq %r14, %rdi
movl %ebp, %esi
callq 0xbb99
movq %rax, (%rbx)
movl $0x13, 0x8(%rbx)
jmp 0xbb8a
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x11634
testl %eax, %eax
je 0xbb73
cmpl $0x3, 0x8(%r15)
jne 0xbad7
movq %r15, %r13
jmp 0xbaef
movl 0x8(%r12), %eax
cmpl $0x3, %eax
je 0xbb22
cmpl $0x13, %eax
jne 0xbb0f
cmpl $0x13, 0x8(%r15)
jne 0xbb0f
movq (%r12), %rdx
movq (%r15), %rcx
movq %r14, %rdi
movl %ebp, %esi
callq 0xbb99
movl $0x13, %ecx
jmp 0xbb6b
leaq 0x10(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x11634
testl %eax, %eax
je 0xbb73
movsd (%r13), %xmm1
movq 0x8(%rsp), %xmm0
movl %ebp, %edi
callq 0xbc03
movq %xmm0, (%rbx)
movl $0x3, 0x8(%rbx)
jmp 0xbb8a
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x11634
testl %eax, %eax
jne 0xbb2e
jmp 0xbb73
movq (%r12), %xmm0
movq %xmm0, 0x8(%rsp)
cmpl $0x3, 0x8(%r15)
jne 0xbb3a
movq %r15, %r13
jmp 0xbb4e
leaq 0x10(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x11634
testl %eax, %eax
je 0xbb73
movsd (%r13), %xmm1
movq 0x8(%rsp), %xmm0
movl %ebp, %edi
callq 0xbc03
movq %xmm0, %rax
movl $0x3, %ecx
movq %rax, (%rbx)
movl %ecx, 0x8(%rbx)
jmp 0xbb8a
addl $0x6, %ebp
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
movl %ebp, %r8d
callq 0x10b3e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq