// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x10, %rsp
movq %r8, %rbx
movq %rcx, %r15
movq %rdx, %r12
movl %esi, %ebp
movq %rdi, %r14
cmpl $0xd, %esi
ja 0xb5ff
movl $0x2f80, %eax           # imm = 0x2F80
btl %ebp, %eax
jae 0xb580
cmpl $0x13, 0x8(%r12)
jne 0xb559
movq (%r12), %rax
movq %rax, 0x8(%rsp)
jmp 0xb570
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0x10e26
testl %eax, %eax
je 0xb6cf
cmpl $0x13, 0x8(%r15)
jne 0xb5a0
movq (%r15), %rax
movq %rax, (%rsp)
jmp 0xb5b5
movl $0x30, %eax
btl %ebp, %eax
jae 0xb5ff
cmpl $0x3, 0x8(%r12)
jne 0xb5d7
movq (%r12), %xmm0
movq %xmm0, 0x8(%rsp)
jmp 0xb5ec
movq %rsp, %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x10e26
testl %eax, %eax
je 0xb6cf
movq 0x8(%rsp), %rdx
movq (%rsp), %rcx
movq %r14, %rdi
movl %ebp, %esi
callq 0xb6f3
movq %rax, (%rbx)
movl $0x13, 0x8(%rbx)
jmp 0xb6e6
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x10da8
testl %eax, %eax
je 0xb6cf
cmpl $0x3, 0x8(%r15)
jne 0xb630
movq (%r15), %xmm0
movq %xmm0, (%rsp)
jmp 0xb643
movl 0x8(%r12), %eax
cmpl $0x3, %eax
je 0xb66a
cmpl $0x13, %eax
jne 0xb678
cmpl $0x13, 0x8(%r15)
jne 0xb665
movq (%r12), %rdx
movq (%r15), %rcx
movq %r14, %rdi
movl %ebp, %esi
callq 0xb6f3
movl $0x13, %ecx
jmp 0xb6c7
movq %rsp, %rsi
movq %r15, %rdi
callq 0x10da8
testl %eax, %eax
je 0xb6cf
movq 0x8(%rsp), %xmm0
movsd (%rsp), %xmm1
movl %ebp, %edi
callq 0xb75d
movq %xmm0, (%rbx)
movl $0x3, 0x8(%rbx)
jmp 0xb6e6
cmpl $0x3, %eax
jne 0xb678
movq (%r12), %xmm0
movq %xmm0, 0x8(%rsp)
jmp 0xb689
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x10da8
testl %eax, %eax
je 0xb6cf
cmpl $0x3, 0x8(%r15)
jne 0xb69c
movq (%r15), %xmm0
movq %xmm0, (%rsp)
jmp 0xb6ab
movq %rsp, %rsi
movq %r15, %rdi
callq 0x10da8
testl %eax, %eax
je 0xb6cf
movq 0x8(%rsp), %xmm0
movsd (%rsp), %xmm1
movl %ebp, %edi
callq 0xb75d
movq %xmm0, %rax
movl $0x3, %ecx
movq %rax, (%rbx)
movl %ecx, 0x8(%rbx)
jmp 0xb6e6
addl $0x6, %ebp
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
movl %ebp, %r8d
callq 0x104cb
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq