aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-11-12 18:00:00 +0000
committerTorne (Richard Coles) <torne@google.com>2014-11-12 18:00:00 +0000
commitea6e97ca4a9c08d180c9ea5a8c3e6524cc3c5e12 (patch)
treec7a2c40173c3580552bf9be3f44d0f03dc34c253
parent6d79040b1fb5bac7bec6b92844b93d80566445e7 (diff)
parent1be894bddf75cd9c7c7fb70be799509a9bb5db67 (diff)
downloadv8-ea6e97ca4a9c08d180c9ea5a8c3e6524cc3c5e12.tar.gz
Merge from Chromium at DEPS revision 03655fd3f6d7
This commit was generated by merge_to_master.py. Change-Id: Ia558e0c489f9a1ed34ff225277d99e9230a38883
-rw-r--r--src/arm/assembler-arm.cc29
-rw-r--r--src/arm64/delayed-masm-arm64.cc4
-rw-r--r--src/ast.cc21
-rw-r--r--src/ast.h191
-rw-r--r--src/base/atomicops_internals_mac.h23
-rw-r--r--src/base/platform/platform-linux.cc2
-rw-r--r--src/compiler/access-builder.cc4
-rw-r--r--src/compiler/arm64/code-generator-arm64.cc3
-rw-r--r--src/compiler/ast-graph-builder.cc20
-rw-r--r--src/compiler/ast-graph-builder.h4
-rw-r--r--src/compiler/instruction-selector.cc4
-rw-r--r--src/compiler/instruction.cc2
-rw-r--r--src/compiler/register-allocator.cc304
-rw-r--r--src/compiler/register-allocator.h18
-rw-r--r--src/compiler/schedule.cc15
-rw-r--r--src/compiler/schedule.h14
-rw-r--r--src/compiler/scheduler.cc583
-rw-r--r--src/compiler/scheduler.h7
-rw-r--r--src/debug-debugger.js3
-rw-r--r--src/debug.cc101
-rw-r--r--src/debug.h31
-rw-r--r--src/globals.h5
-rw-r--r--src/heap-snapshot-generator-inl.h2
-rw-r--r--src/heap-snapshot-generator.cc6
-rw-r--r--src/heap-snapshot-generator.h18
-rw-r--r--src/heap/heap.cc12
-rw-r--r--src/hydrogen-instructions.cc252
-rw-r--r--src/hydrogen-instructions.h351
-rw-r--r--src/hydrogen.cc2
-rw-r--r--src/object-observe.js5
-rw-r--r--src/objects-debug.cc43
-rw-r--r--src/objects-inl.h53
-rw-r--r--src/objects-printer.cc9
-rw-r--r--src/objects.cc124
-rw-r--r--src/objects.h28
-rw-r--r--src/profile-generator-inl.h15
-rw-r--r--src/profile-generator.cc20
-rw-r--r--src/profile-generator.h13
-rw-r--r--src/runtime/runtime-array.cc36
-rw-r--r--src/runtime/runtime-debug.cc2
-rw-r--r--src/runtime/runtime-observe.cc22
-rw-r--r--src/runtime/runtime.h1
-rw-r--r--src/scanner.cc25
-rw-r--r--src/transitions-inl.h69
-rw-r--r--src/transitions.cc62
-rw-r--r--src/transitions.h41
-rw-r--r--src/unicode-inl.h2
-rw-r--r--src/unicode.h23
-rw-r--r--src/utils.h8
-rw-r--r--src/version.cc2
-rw-r--r--test/cctest/cctest.gyp1
-rw-r--r--test/cctest/compiler/test-instruction.cc2
-rw-r--r--test/cctest/compiler/test-scheduler.cc28
-rw-r--r--test/cctest/test-api.cc27
-rw-r--r--test/cctest/test-debug.cc26
-rw-r--r--test/cctest/test-object-observe.cc53
-rw-r--r--test/cctest/test-transitions.cc283
-rw-r--r--test/mjsunit/asm/embenchen/box2d.js20326
-rw-r--r--test/mjsunit/asm/embenchen/copy.js5980
-rw-r--r--test/mjsunit/asm/embenchen/corrections.js5987
-rw-r--r--test/mjsunit/asm/embenchen/fannkuch.js8439
-rw-r--r--test/mjsunit/asm/embenchen/fasta.js8609
-rw-r--r--test/mjsunit/asm/embenchen/lua_binarytrees.js42714
-rw-r--r--test/mjsunit/asm/embenchen/memops.js8091
-rw-r--r--test/mjsunit/asm/embenchen/primes.js5988
-rw-r--r--test/mjsunit/asm/embenchen/zlib.js14756
-rw-r--r--test/mjsunit/asm/float32array-store-div.js16
-rw-r--r--test/mjsunit/asm/float64array-store-div.js16
-rw-r--r--test/mjsunit/debug-stepframe.js111
-rw-r--r--test/mjsunit/mjsunit.status8
-rw-r--r--test/mjsunit/regress/regress-assignment-in-test-context.js20
-rw-r--r--test/mjsunit/regress/regress-crbug-137689.js3
-rw-r--r--test/unittests/compiler/mips/instruction-selector-mips-unittest.cc10
-rw-r--r--test/unittests/compiler/register-allocator-unittest.cc2
-rw-r--r--tools/gyp/v8.gyp12
-rw-r--r--tools/gyp/v8_base.host.darwin-x86_64.mk8
-rw-r--r--tools/gyp/v8_base.host.linux-x86_64.mk8
-rw-r--r--tools/gyp/v8_base.target.darwin-x86_64.mk8
-rw-r--r--tools/gyp/v8_base.target.linux-x86_64.mk8
-rwxr-xr-xtools/push-to-trunk/merge_to_branch.py89
-rwxr-xr-xtools/push-to-trunk/releases.py25
-rw-r--r--tools/push-to-trunk/test_scripts.py220
-rwxr-xr-xtools/run-tests.py8
-rw-r--r--tools/testrunner/local/statusfile.py7
-rw-r--r--tools/testrunner/local/testsuite.py13
-rw-r--r--tools/whitespace.txt2
86 files changed, 123260 insertions, 1278 deletions
diff --git a/src/arm/assembler-arm.cc b/src/arm/assembler-arm.cc
index 17bf4f93a..eae38be6e 100644
--- a/src/arm/assembler-arm.cc
+++ b/src/arm/assembler-arm.cc
@@ -2545,27 +2545,20 @@ void Assembler::vmov(const DwVfpRegister dst,
uint32_t lo, hi;
DoubleAsTwoUInt32(imm, &lo, &hi);
- if (scratch.is(no_reg)) {
- if (dst.code() < 16) {
- const LowDwVfpRegister loc = LowDwVfpRegister::from_code(dst.code());
- // Move the low part of the double into the lower of the corresponsing S
- // registers of D register dst.
- mov(ip, Operand(lo));
- vmov(loc.low(), ip);
-
- // Move the high part of the double into the higher of the
- // corresponsing S registers of D register dst.
- mov(ip, Operand(hi));
- vmov(loc.high(), ip);
+ if (lo == hi) {
+ // Move the low and high parts of the double to a D register in one
+ // instruction.
+ mov(ip, Operand(lo));
+ vmov(dst, ip, ip);
+ } else if (scratch.is(no_reg)) {
+ mov(ip, Operand(lo));
+ vmov(dst, VmovIndexLo, ip);
+ if ((lo & 0xffff) == (hi & 0xffff)) {
+ movt(ip, hi >> 16);
} else {
- // D16-D31 does not have S registers, so move the low and high parts
- // directly to the D register using vmov.32.
- // Note: This may be slower, so we only do this when we have to.
- mov(ip, Operand(lo));
- vmov(dst, VmovIndexLo, ip);
mov(ip, Operand(hi));
- vmov(dst, VmovIndexHi, ip);
}
+ vmov(dst, VmovIndexHi, ip);
} else {
// Move the low and high parts of the double to a D register in one
// instruction.
diff --git a/src/arm64/delayed-masm-arm64.cc b/src/arm64/delayed-masm-arm64.cc
index c3bda915e..b51e77ec8 100644
--- a/src/arm64/delayed-masm-arm64.cc
+++ b/src/arm64/delayed-masm-arm64.cc
@@ -16,8 +16,8 @@ namespace internal {
void DelayedMasm::StackSlotMove(LOperand* src, LOperand* dst) {
- DCHECK(src->IsStackSlot());
- DCHECK(dst->IsStackSlot());
+ DCHECK((src->IsStackSlot() && dst->IsStackSlot()) ||
+ (src->IsDoubleStackSlot() && dst->IsDoubleStackSlot()));
MemOperand src_operand = cgen_->ToMemOperand(src);
MemOperand dst_operand = cgen_->ToMemOperand(dst);
if (pending_ == kStackSlotMove) {
diff --git a/src/ast.cc b/src/ast.cc
index 1df668ddf..26bc49155 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -61,9 +61,9 @@ bool Expression::IsUndefinedLiteral(Isolate* isolate) const {
VariableProxy::VariableProxy(Zone* zone, Variable* var, int position)
: Expression(zone, position),
- is_this_(var->is_this()),
- is_assigned_(false),
- is_resolved_(false),
+ bit_field_(IsThisField::encode(var->is_this()) |
+ IsAssignedField::encode(false) |
+ IsResolvedField::encode(false)),
variable_feedback_slot_(FeedbackVectorICSlot::Invalid()),
raw_name_(var->raw_name()),
interface_(var->interface()) {
@@ -74,9 +74,8 @@ VariableProxy::VariableProxy(Zone* zone, Variable* var, int position)
VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
Interface* interface, int position)
: Expression(zone, position),
- is_this_(is_this),
- is_assigned_(false),
- is_resolved_(false),
+ bit_field_(IsThisField::encode(is_this) | IsAssignedField::encode(false) |
+ IsResolvedField::encode(false)),
variable_feedback_slot_(FeedbackVectorICSlot::Invalid()),
raw_name_(name),
interface_(interface) {}
@@ -99,17 +98,17 @@ void VariableProxy::BindTo(Variable* var) {
Assignment::Assignment(Zone* zone, Token::Value op, Expression* target,
Expression* value, int pos)
: Expression(zone, pos),
- is_uninitialized_(false),
- key_type_(ELEMENT),
- store_mode_(STANDARD_STORE),
- op_(op),
+ bit_field_(IsUninitializedField::encode(false) |
+ KeyTypeField::encode(ELEMENT) |
+ StoreModeField::encode(STANDARD_STORE) |
+ TokenField::encode(op)),
target_(target),
value_(value),
binary_operation_(NULL) {}
Token::Value Assignment::binary_op() const {
- switch (op_) {
+ switch (op()) {
case Token::ASSIGN_BIT_OR: return Token::BIT_OR;
case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR;
case Token::ASSIGN_BIT_AND: return Token::BIT_AND;
diff --git a/src/ast.h b/src/ast.h
index aa23b4e23..749e57999 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -359,11 +359,16 @@ class Expression : public AstNode {
void set_bounds(Bounds bounds) { bounds_ = bounds; }
// Whether the expression is parenthesized
- bool is_parenthesized() const { return is_parenthesized_; }
- bool is_multi_parenthesized() const { return is_multi_parenthesized_; }
+ bool is_parenthesized() const {
+ return IsParenthesizedField::decode(bit_field_);
+ }
+ bool is_multi_parenthesized() const {
+ return IsMultiParenthesizedField::decode(bit_field_);
+ }
void increase_parenthesization_level() {
- is_multi_parenthesized_ = is_parenthesized_;
- is_parenthesized_ = true;
+ bit_field_ =
+ IsMultiParenthesizedField::update(bit_field_, is_parenthesized());
+ bit_field_ = IsParenthesizedField::update(bit_field_, true);
}
// Type feedback information for assignments and properties.
@@ -375,18 +380,20 @@ class Expression : public AstNode {
UNREACHABLE();
return NULL;
}
- virtual KeyedAccessStoreMode GetStoreMode() {
+ virtual KeyedAccessStoreMode GetStoreMode() const {
UNREACHABLE();
return STANDARD_STORE;
}
- virtual IcCheckType GetKeyType() {
+ virtual IcCheckType GetKeyType() const {
UNREACHABLE();
return ELEMENT;
}
// TODO(rossberg): this should move to its own AST node eventually.
virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
- byte to_boolean_types() const { return to_boolean_types_; }
+ byte to_boolean_types() const {
+ return ToBooleanTypesField::decode(bit_field_);
+ }
void set_base_id(int id) { base_id_ = id; }
static int num_ids() { return parent_num_ids() + 2; }
@@ -398,10 +405,11 @@ class Expression : public AstNode {
: AstNode(pos),
base_id_(BailoutId::None().ToInt()),
bounds_(Bounds::Unbounded(zone)),
- is_parenthesized_(false),
- is_multi_parenthesized_(false) {}
+ bit_field_(0) {}
static int parent_num_ids() { return 0; }
- void set_to_boolean_types(byte types) { to_boolean_types_ = types; }
+ void set_to_boolean_types(byte types) {
+ bit_field_ = ToBooleanTypesField::update(bit_field_, types);
+ }
int base_id() const {
DCHECK(!BailoutId(base_id_).IsNone());
@@ -413,9 +421,12 @@ class Expression : public AstNode {
int base_id_;
Bounds bounds_;
- byte to_boolean_types_;
- bool is_parenthesized_ : 1;
- bool is_multi_parenthesized_ : 1;
+ class ToBooleanTypesField : public BitField16<byte, 0, 8> {};
+ class IsParenthesizedField : public BitField16<bool, 8, 1> {};
+ class IsMultiParenthesizedField : public BitField16<bool, 9, 1> {};
+ uint16_t bit_field_;
+ // Ends with 16-bit field; deriving classes in turn begin with
+ // 16-bit fields for optimum packing efficiency.
};
@@ -1697,13 +1708,17 @@ class VariableProxy FINAL : public Expression {
var_ = v;
}
- bool is_this() const { return is_this_; }
+ bool is_this() const { return IsThisField::decode(bit_field_); }
- bool is_assigned() const { return is_assigned_; }
- void set_is_assigned() { is_assigned_ = true; }
+ bool is_assigned() const { return IsAssignedField::decode(bit_field_); }
+ void set_is_assigned() {
+ bit_field_ = IsAssignedField::update(bit_field_, true);
+ }
- bool is_resolved() const { return is_resolved_; }
- void set_is_resolved() { is_resolved_ = true; }
+ bool is_resolved() const { return IsResolvedField::decode(bit_field_); }
+ void set_is_resolved() {
+ bit_field_ = IsResolvedField::update(bit_field_, true);
+ }
Interface* interface() const { return interface_; }
@@ -1727,9 +1742,13 @@ class VariableProxy FINAL : public Expression {
VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
Interface* interface, int position);
- bool is_this_ : 1;
- bool is_assigned_ : 1;
- bool is_resolved_ : 1;
+ class IsThisField : public BitField8<bool, 0, 1> {};
+ class IsAssignedField : public BitField8<bool, 1, 1> {};
+ class IsResolvedField : public BitField8<bool, 2, 1> {};
+
+ // Start with 16-bit (or smaller) field, which should get packed together
+ // with Expression's trailing 16-bit field.
+ uint8_t bit_field_;
FeedbackVectorICSlot variable_feedback_slot_;
union {
const AstRawString* raw_name_; // if !is_resolved_
@@ -1752,7 +1771,9 @@ class Property FINAL : public Expression {
BailoutId LoadId() const { return BailoutId(local_id(0)); }
TypeFeedbackId PropertyFeedbackId() { return TypeFeedbackId(local_id(1)); }
- bool IsStringAccess() const { return is_string_access_; }
+ bool IsStringAccess() const {
+ return IsStringAccessField::decode(bit_field_);
+ }
// Type feedback information.
virtual bool IsMonomorphic() OVERRIDE {
@@ -1761,21 +1782,29 @@ class Property FINAL : public Expression {
virtual SmallMapList* GetReceiverTypes() OVERRIDE {
return &receiver_types_;
}
- virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE {
+ virtual KeyedAccessStoreMode GetStoreMode() const OVERRIDE {
return STANDARD_STORE;
}
- virtual IcCheckType GetKeyType() OVERRIDE {
+ virtual IcCheckType GetKeyType() const OVERRIDE {
// PROPERTY key types currently aren't implemented for KeyedLoadICs.
return ELEMENT;
}
- bool IsUninitialized() { return !is_for_call_ && is_uninitialized_; }
- bool HasNoTypeInformation() {
- return is_uninitialized_;
+ bool IsUninitialized() const {
+ return !is_for_call() && HasNoTypeInformation();
+ }
+ bool HasNoTypeInformation() const {
+ return IsUninitializedField::decode(bit_field_);
+ }
+ void set_is_uninitialized(bool b) {
+ bit_field_ = IsUninitializedField::update(bit_field_, b);
}
- void set_is_uninitialized(bool b) { is_uninitialized_ = b; }
- void set_is_string_access(bool b) { is_string_access_ = b; }
- void mark_for_call() { is_for_call_ = true; }
- bool IsForCall() { return is_for_call_; }
+ void set_is_string_access(bool b) {
+ bit_field_ = IsStringAccessField::update(bit_field_, b);
+ }
+ void mark_for_call() {
+ bit_field_ = IsForCallField::update(bit_field_, true);
+ }
+ bool is_for_call() const { return IsForCallField::decode(bit_field_); }
bool IsSuperAccess() {
return obj()->IsSuperReference();
@@ -1795,9 +1824,9 @@ class Property FINAL : public Expression {
protected:
Property(Zone* zone, Expression* obj, Expression* key, int pos)
: Expression(zone, pos),
- is_for_call_(false),
- is_uninitialized_(false),
- is_string_access_(false),
+ bit_field_(IsForCallField::encode(false) |
+ IsUninitializedField::encode(false) |
+ IsStringAccessField::encode(false)),
property_feedback_slot_(FeedbackVectorICSlot::Invalid()),
obj_(obj),
key_(key) {}
@@ -1806,9 +1835,10 @@ class Property FINAL : public Expression {
private:
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
- bool is_for_call_ : 1;
- bool is_uninitialized_ : 1;
- bool is_string_access_ : 1;
+ class IsForCallField : public BitField8<bool, 0, 1> {};
+ class IsUninitializedField : public BitField8<bool, 1, 1> {};
+ class IsStringAccessField : public BitField8<bool, 2, 1> {};
+ uint8_t bit_field_;
FeedbackVectorICSlot property_feedback_slot_;
Expression* obj_;
Expression* key_;
@@ -2120,10 +2150,10 @@ class CountOperation FINAL : public Expression {
public:
DECLARE_NODE_TYPE(CountOperation)
- bool is_prefix() const { return is_prefix_; }
- bool is_postfix() const { return !is_prefix_; }
+ bool is_prefix() const { return IsPrefixField::decode(bit_field_); }
+ bool is_postfix() const { return !is_prefix(); }
- Token::Value op() const { return op_; }
+ Token::Value op() const { return TokenField::decode(bit_field_); }
Token::Value binary_op() {
return (op() == Token::INC) ? Token::ADD : Token::SUB;
}
@@ -2136,13 +2166,19 @@ class CountOperation FINAL : public Expression {
virtual SmallMapList* GetReceiverTypes() OVERRIDE {
return &receiver_types_;
}
- virtual IcCheckType GetKeyType() OVERRIDE { return key_type_; }
- virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE {
- return store_mode_;
+ virtual IcCheckType GetKeyType() const OVERRIDE {
+ return KeyTypeField::decode(bit_field_);
+ }
+ virtual KeyedAccessStoreMode GetStoreMode() const OVERRIDE {
+ return StoreModeField::decode(bit_field_);
}
Type* type() const { return type_; }
- void set_key_type(IcCheckType type) { key_type_ = type; }
- void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; }
+ void set_key_type(IcCheckType type) {
+ bit_field_ = KeyTypeField::update(bit_field_, type);
+ }
+ void set_store_mode(KeyedAccessStoreMode mode) {
+ bit_field_ = StoreModeField::update(bit_field_, mode);
+ }
void set_type(Type* type) { type_ = type; }
static int num_ids() { return parent_num_ids() + 3; }
@@ -2158,21 +2194,25 @@ class CountOperation FINAL : public Expression {
CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr,
int pos)
: Expression(zone, pos),
- op_(op),
- is_prefix_(is_prefix),
- key_type_(ELEMENT),
- store_mode_(STANDARD_STORE),
+ bit_field_(IsPrefixField::encode(is_prefix) |
+ KeyTypeField::encode(ELEMENT) |
+ StoreModeField::encode(STANDARD_STORE) |
+ TokenField::encode(op)),
+ type_(NULL),
expression_(expr) {}
static int parent_num_ids() { return Expression::num_ids(); }
private:
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
- Token::Value op_;
- bool is_prefix_ : 1;
- IcCheckType key_type_ : 1;
- KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
- // must have extra bit.
+ class IsPrefixField : public BitField16<bool, 0, 1> {};
+ class KeyTypeField : public BitField16<IcCheckType, 1, 1> {};
+ class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 4> {};
+ class TokenField : public BitField16<Token::Value, 6, 8> {};
+
+ // Starts with 16-bit field, which should get packed together with
+ // Expression's trailing 16-bit field.
+ uint16_t bit_field_;
Type* type_;
Expression* expression_;
SmallMapList receiver_types_;
@@ -2261,7 +2301,7 @@ class Assignment FINAL : public Expression {
Token::Value binary_op() const;
- Token::Value op() const { return op_; }
+ Token::Value op() const { return TokenField::decode(bit_field_); }
Expression* target() const { return target_; }
Expression* value() const { return value_; }
BinaryOperation* binary_operation() const { return binary_operation_; }
@@ -2277,20 +2317,30 @@ class Assignment FINAL : public Expression {
virtual bool IsMonomorphic() OVERRIDE {
return receiver_types_.length() == 1;
}
- bool IsUninitialized() { return is_uninitialized_; }
+ bool IsUninitialized() const {
+ return IsUninitializedField::decode(bit_field_);
+ }
bool HasNoTypeInformation() {
- return is_uninitialized_;
+ return IsUninitializedField::decode(bit_field_);
}
virtual SmallMapList* GetReceiverTypes() OVERRIDE {
return &receiver_types_;
}
- virtual IcCheckType GetKeyType() OVERRIDE { return key_type_; }
- virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE {
- return store_mode_;
+ virtual IcCheckType GetKeyType() const OVERRIDE {
+ return KeyTypeField::decode(bit_field_);
+ }
+ virtual KeyedAccessStoreMode GetStoreMode() const OVERRIDE {
+ return StoreModeField::decode(bit_field_);
+ }
+ void set_is_uninitialized(bool b) {
+ bit_field_ = IsUninitializedField::update(bit_field_, b);
+ }
+ void set_key_type(IcCheckType key_type) {
+ bit_field_ = KeyTypeField::update(bit_field_, key_type);
+ }
+ void set_store_mode(KeyedAccessStoreMode mode) {
+ bit_field_ = StoreModeField::update(bit_field_, mode);
}
- void set_is_uninitialized(bool b) { is_uninitialized_ = b; }
- void set_key_type(IcCheckType key_type) { key_type_ = key_type; }
- void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; }
protected:
Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value,
@@ -2299,7 +2349,7 @@ class Assignment FINAL : public Expression {
template <class Visitor>
void Init(AstNodeFactory<Visitor>* factory) {
- DCHECK(Token::IsAssignmentOp(op_));
+ DCHECK(Token::IsAssignmentOp(op()));
if (is_compound()) {
binary_operation_ = factory->NewBinaryOperation(
binary_op(), target_, value_, position() + 1);
@@ -2309,11 +2359,14 @@ class Assignment FINAL : public Expression {
private:
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
- bool is_uninitialized_ : 1;
- IcCheckType key_type_ : 1;
- KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
- // must have extra bit.
- Token::Value op_;
+ class IsUninitializedField : public BitField16<bool, 0, 1> {};
+ class KeyTypeField : public BitField16<IcCheckType, 1, 1> {};
+ class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 4> {};
+ class TokenField : public BitField16<Token::Value, 6, 8> {};
+
+ // Starts with 16-bit field, which should get packed together with
+ // Expression's trailing 16-bit field.
+ uint16_t bit_field_;
Expression* target_;
Expression* value_;
BinaryOperation* binary_operation_;
diff --git a/src/base/atomicops_internals_mac.h b/src/base/atomicops_internals_mac.h
index a046872e4..84f9dbcd7 100644
--- a/src/base/atomicops_internals_mac.h
+++ b/src/base/atomicops_internals_mac.h
@@ -12,6 +12,20 @@
namespace v8 {
namespace base {
+#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory")
+
+inline void MemoryBarrier() { OSMemoryBarrier(); }
+
+inline void AcquireMemoryBarrier() {
+// On x86 processors, loads already have acquire semantics, so
+// there is no need to put a full barrier here.
+#if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
+ ATOMICOPS_COMPILER_BARRIER();
+#else
+ MemoryBarrier();
+#endif
+}
+
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
@@ -46,10 +60,6 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
return OSAtomicAdd32Barrier(increment, const_cast<Atomic32*>(ptr));
}
-inline void MemoryBarrier() {
- OSMemoryBarrier();
-}
-
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
@@ -98,7 +108,7 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
Atomic32 value = *ptr;
- MemoryBarrier();
+ AcquireMemoryBarrier();
return value;
}
@@ -188,7 +198,7 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
Atomic64 value = *ptr;
- MemoryBarrier();
+ AcquireMemoryBarrier();
return value;
}
@@ -199,6 +209,7 @@ inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
#endif // defined(__LP64__)
+#undef ATOMICOPS_COMPILER_BARRIER
} } // namespace v8::base
#endif // V8_BASE_ATOMICOPS_INTERNALS_MAC_H_
diff --git a/src/base/platform/platform-linux.cc b/src/base/platform/platform-linux.cc
index eff5ced3b..b13a1e85c 100644
--- a/src/base/platform/platform-linux.cc
+++ b/src/base/platform/platform-linux.cc
@@ -109,7 +109,7 @@ const char* OS::LocalTimezone(double time, TimezoneCache* cache) {
if (std::isnan(time)) return "";
time_t tv = static_cast<time_t>(std::floor(time/msPerSecond));
struct tm* t = localtime(&tv);
- if (NULL == t) return "";
+ if (!t || !t->tm_zone) return "";
return t->tm_zone;
#endif
}
diff --git a/src/compiler/access-builder.cc b/src/compiler/access-builder.cc
index 2c270220d..583bd3aaa 100644
--- a/src/compiler/access-builder.cc
+++ b/src/compiler/access-builder.cc
@@ -106,10 +106,10 @@ ElementAccess AccessBuilder::ForTypedArrayElement(ExternalArrayType type,
Type::Unsigned32(), kMachUint32};
case kExternalFloat32Array:
return {kTypedArrayBoundsCheck, taggedness, header_size, Type::Number(),
- kRepFloat32};
+ kMachFloat32};
case kExternalFloat64Array:
return {kTypedArrayBoundsCheck, taggedness, header_size, Type::Number(),
- kRepFloat64};
+ kMachFloat64};
}
UNREACHABLE();
return {kTypedArrayBoundsCheck, kUntaggedBase, 0, Type::None(), kMachNone};
diff --git a/src/compiler/arm64/code-generator-arm64.cc b/src/compiler/arm64/code-generator-arm64.cc
index 58886ae19..0c75b7c38 100644
--- a/src/compiler/arm64/code-generator-arm64.cc
+++ b/src/compiler/arm64/code-generator-arm64.cc
@@ -100,8 +100,7 @@ class Arm64OperandConverter FINAL : public InstructionOperandConverter {
return MemOperand(InputRegister(index + 0), InputInt32(index + 1));
case kMode_MRR:
*first_index += 2;
- return MemOperand(InputRegister(index + 0), InputRegister(index + 1),
- SXTW);
+ return MemOperand(InputRegister(index + 0), InputRegister(index + 1));
}
UNREACHABLE();
return MemOperand(no_reg);
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 7b5abd191..805afc5a3 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -1173,8 +1173,8 @@ void AstGraphBuilder::VisitAssignment(Assignment* expr) {
switch (assign_type) {
case VARIABLE: {
Variable* variable = expr->target()->AsVariableProxy()->var();
- BuildVariableAssignment(variable, value, expr->op(),
- expr->AssignmentId());
+ BuildVariableAssignment(variable, value, expr->op(), expr->AssignmentId(),
+ ast_context()->GetStateCombine());
break;
}
case NAMED_PROPERTY: {
@@ -1183,7 +1183,8 @@ void AstGraphBuilder::VisitAssignment(Assignment* expr) {
MakeUnique(property->key()->AsLiteral()->AsPropertyName());
Node* store =
NewNode(javascript()->StoreNamed(strict_mode(), name), object, value);
- PrepareFrameState(store, expr->AssignmentId());
+ PrepareFrameState(store, expr->AssignmentId(),
+ ast_context()->GetStateCombine());
break;
}
case KEYED_PROPERTY: {
@@ -1191,7 +1192,8 @@ void AstGraphBuilder::VisitAssignment(Assignment* expr) {
Node* object = environment()->Pop();
Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object,
key, value);
- PrepareFrameState(store, expr->AssignmentId());
+ PrepareFrameState(store, expr->AssignmentId(),
+ ast_context()->GetStateCombine());
break;
}
}
@@ -1957,9 +1959,9 @@ Node* AstGraphBuilder::BuildVariableDelete(
}
-Node* AstGraphBuilder::BuildVariableAssignment(Variable* variable, Node* value,
- Token::Value op,
- BailoutId bailout_id) {
+Node* AstGraphBuilder::BuildVariableAssignment(
+ Variable* variable, Node* value, Token::Value op, BailoutId bailout_id,
+ OutputFrameStateCombine combine) {
Node* the_hole = jsgraph()->TheHoleConstant();
VariableMode mode = variable->mode();
switch (variable->location()) {
@@ -1969,7 +1971,7 @@ Node* AstGraphBuilder::BuildVariableAssignment(Variable* variable, Node* value,
Unique<Name> name = MakeUnique(variable->name());
const Operator* op = javascript()->StoreNamed(strict_mode(), name);
Node* store = NewNode(op, global, value);
- PrepareFrameState(store, bailout_id);
+ PrepareFrameState(store, bailout_id, combine);
return store;
}
case Variable::PARAMETER:
@@ -2035,7 +2037,7 @@ Node* AstGraphBuilder::BuildVariableAssignment(Variable* variable, Node* value,
const Operator* op =
javascript()->CallRuntime(Runtime::kStoreLookupSlot, 4);
Node* store = NewNode(op, value, current_context(), name, strict);
- PrepareFrameState(store, bailout_id);
+ PrepareFrameState(store, bailout_id, combine);
return store;
}
}
diff --git a/src/compiler/ast-graph-builder.h b/src/compiler/ast-graph-builder.h
index 6e51723e0..518f23f46 100644
--- a/src/compiler/ast-graph-builder.h
+++ b/src/compiler/ast-graph-builder.h
@@ -80,7 +80,9 @@ class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
// Builders for variable load and assignment.
Node* BuildVariableAssignment(Variable* var, Node* value, Token::Value op,
- BailoutId bailout_id);
+ BailoutId bailout_id,
+ OutputFrameStateCombine state_combine =
+ OutputFrameStateCombine::Ignore());
Node* BuildVariableDelete(Variable* var, BailoutId bailout_id,
OutputFrameStateCombine state_combine);
Node* BuildVariableLoad(Variable* var, BailoutId bailout_id,
diff --git a/src/compiler/instruction-selector.cc b/src/compiler/instruction-selector.cc
index 877230ca2..ffbf2a301 100644
--- a/src/compiler/instruction-selector.cc
+++ b/src/compiler/instruction-selector.cc
@@ -833,7 +833,7 @@ void InstructionSelector::VisitLoadStackPointer(Node* node) {
#endif // V8_TURBOFAN_BACKEND
// 32 bit targets do not implement the following instructions.
-#if V8_TARGET_ARCH_32_BIT && V8_TURBOFAN_BACKEND
+#if V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_X64 && V8_TURBOFAN_BACKEND
void InstructionSelector::VisitWord64And(Node* node) { UNIMPLEMENTED(); }
@@ -905,7 +905,7 @@ void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) {
UNIMPLEMENTED();
}
-#endif // V8_TARGET_ARCH_32_BIT && V8_TURBOFAN_BACKEND
+#endif // V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_X64 && V8_TURBOFAN_BACKEND
void InstructionSelector::VisitFinish(Node* node) {
diff --git a/src/compiler/instruction.cc b/src/compiler/instruction.cc
index 76a695052..ad7a5ee05 100644
--- a/src/compiler/instruction.cc
+++ b/src/compiler/instruction.cc
@@ -346,7 +346,7 @@ static BasicBlock::RpoNumber GetRpo(BasicBlock* block) {
static BasicBlock::RpoNumber GetLoopEndRpo(const BasicBlock* block) {
if (!block->IsLoopHeader()) return BasicBlock::RpoNumber::Invalid();
- return BasicBlock::RpoNumber::FromInt(block->loop_end());
+ return block->loop_end()->GetRpoNumber();
}
diff --git a/src/compiler/register-allocator.cc b/src/compiler/register-allocator.cc
index 7a8276849..c65b906bb 100644
--- a/src/compiler/register-allocator.cc
+++ b/src/compiler/register-allocator.cc
@@ -199,7 +199,7 @@ bool LiveRange::CanBeSpilled(LifetimePosition pos) {
}
-InstructionOperand* LiveRange::CreateAssignedOperand(Zone* zone) {
+InstructionOperand* LiveRange::CreateAssignedOperand(Zone* zone) const {
InstructionOperand* op = NULL;
if (HasRegisterAssigned()) {
DCHECK(!IsSpilled());
@@ -507,23 +507,24 @@ LifetimePosition LiveRange::FirstIntersection(LiveRange* other) {
RegisterAllocator::RegisterAllocator(const RegisterConfiguration* config,
- Zone* local_zone, Frame* frame,
+ Zone* zone, Frame* frame,
InstructionSequence* code,
const char* debug_name)
- : zone_(local_zone),
+ : local_zone_(zone),
frame_(frame),
code_(code),
debug_name_(debug_name),
config_(config),
- live_in_sets_(code->InstructionBlockCount(), zone()),
- live_ranges_(code->VirtualRegisterCount() * 2, zone()),
- fixed_live_ranges_(this->config()->num_general_registers(), NULL, zone()),
+ live_in_sets_(code->InstructionBlockCount(), local_zone()),
+ live_ranges_(code->VirtualRegisterCount() * 2, local_zone()),
+ fixed_live_ranges_(this->config()->num_general_registers(), NULL,
+ local_zone()),
fixed_double_live_ranges_(this->config()->num_double_registers(), NULL,
- zone()),
- unhandled_live_ranges_(code->VirtualRegisterCount() * 2, zone()),
- active_live_ranges_(8, zone()),
- inactive_live_ranges_(8, zone()),
- reusable_slots_(8, zone()),
+ local_zone()),
+ unhandled_live_ranges_(code->VirtualRegisterCount() * 2, local_zone()),
+ active_live_ranges_(8, local_zone()),
+ inactive_live_ranges_(8, local_zone()),
+ reusable_slots_(8, local_zone()),
mode_(UNALLOCATED_REGISTERS),
num_registers_(-1),
allocation_ok_(true) {
@@ -541,16 +542,16 @@ RegisterAllocator::RegisterAllocator(const RegisterConfiguration* config,
void RegisterAllocator::InitializeLivenessAnalysis() {
// Initialize the live_in sets for each block to NULL.
int block_count = code()->InstructionBlockCount();
- live_in_sets_.Initialize(block_count, zone());
- live_in_sets_.AddBlock(NULL, block_count, zone());
+ live_in_sets_.Initialize(block_count, local_zone());
+ live_in_sets_.AddBlock(NULL, block_count, local_zone());
}
BitVector* RegisterAllocator::ComputeLiveOut(const InstructionBlock* block) {
// Compute live out for the given block, except not including backward
// successor edges.
- BitVector* live_out =
- new (zone()) BitVector(code()->VirtualRegisterCount(), zone());
+ BitVector* live_out = new (local_zone())
+ BitVector(code()->VirtualRegisterCount(), local_zone());
// Process all successor blocks.
for (auto succ : block->successors()) {
@@ -584,7 +585,7 @@ void RegisterAllocator::AddInitialIntervals(const InstructionBlock* block,
while (!iterator.Done()) {
int operand_index = iterator.Current();
LiveRange* range = LiveRangeFor(operand_index);
- range->AddUseInterval(start, end, zone());
+ range->AddUseInterval(start, end, local_zone());
iterator.Advance();
}
}
@@ -630,7 +631,7 @@ LiveRange* RegisterAllocator::FixedLiveRangeFor(int index) {
// The LiveRange object itself can go in this zone, but the
// InstructionOperand needs
// to go in the code zone, since it may survive register allocation.
- result = new (zone()) LiveRange(FixedLiveRangeID(index), code_zone());
+ result = new (local_zone()) LiveRange(FixedLiveRangeID(index), code_zone());
DCHECK(result->IsFixed());
result->kind_ = GENERAL_REGISTERS;
SetLiveRangeAssignedRegister(result, index);
@@ -644,7 +645,8 @@ LiveRange* RegisterAllocator::FixedDoubleLiveRangeFor(int index) {
DCHECK(index < config()->num_aliased_double_registers());
LiveRange* result = fixed_double_live_ranges_[index];
if (result == NULL) {
- result = new (zone()) LiveRange(FixedDoubleLiveRangeID(index), code_zone());
+ result = new (local_zone())
+ LiveRange(FixedDoubleLiveRangeID(index), code_zone());
DCHECK(result->IsFixed());
result->kind_ = DOUBLE_REGISTERS;
SetLiveRangeAssignedRegister(result, index);
@@ -656,11 +658,12 @@ LiveRange* RegisterAllocator::FixedDoubleLiveRangeFor(int index) {
LiveRange* RegisterAllocator::LiveRangeFor(int index) {
if (index >= live_ranges_.length()) {
- live_ranges_.AddBlock(NULL, index - live_ranges_.length() + 1, zone());
+ live_ranges_.AddBlock(NULL, index - live_ranges_.length() + 1,
+ local_zone());
}
LiveRange* result = live_ranges_[index];
if (result == NULL) {
- result = new (zone()) LiveRange(index, code_zone());
+ result = new (local_zone()) LiveRange(index, code_zone());
live_ranges_[index] = result;
}
return result;
@@ -694,15 +697,15 @@ void RegisterAllocator::Define(LifetimePosition position,
if (range->IsEmpty() || range->Start().Value() > position.Value()) {
// Can happen if there is a definition without use.
- range->AddUseInterval(position, position.NextInstruction(), zone());
- range->AddUsePosition(position.NextInstruction(), NULL, NULL, zone());
+ range->AddUseInterval(position, position.NextInstruction(), local_zone());
+ range->AddUsePosition(position.NextInstruction(), NULL, NULL, local_zone());
} else {
range->ShortenTo(position);
}
if (operand->IsUnallocated()) {
UnallocatedOperand* unalloc_operand = UnallocatedOperand::cast(operand);
- range->AddUsePosition(position, unalloc_operand, hint, zone());
+ range->AddUsePosition(position, unalloc_operand, hint, local_zone());
}
}
@@ -715,9 +718,9 @@ void RegisterAllocator::Use(LifetimePosition block_start,
if (range == NULL) return;
if (operand->IsUnallocated()) {
UnallocatedOperand* unalloc_operand = UnallocatedOperand::cast(operand);
- range->AddUsePosition(position, unalloc_operand, hint, zone());
+ range->AddUsePosition(position, unalloc_operand, hint, local_zone());
}
- range->AddUseInterval(block_start, position, zone());
+ range->AddUseInterval(block_start, position, local_zone());
}
@@ -1023,7 +1026,7 @@ void RegisterAllocator::ProcessInstructions(const InstructionBlock* block,
if (!IsOutputRegisterOf(instr, i)) {
LiveRange* range = FixedLiveRangeFor(i);
range->AddUseInterval(curr_position, curr_position.InstructionEnd(),
- zone());
+ local_zone());
}
}
}
@@ -1033,7 +1036,7 @@ void RegisterAllocator::ProcessInstructions(const InstructionBlock* block,
if (!IsOutputDoubleRegisterOf(instr, i)) {
LiveRange* range = FixedDoubleLiveRangeFor(i);
range->AddUseInterval(curr_position, curr_position.InstructionEnd(),
- zone());
+ local_zone());
}
}
}
@@ -1160,9 +1163,8 @@ bool RegisterAllocator::Allocate(PipelineStatistics* stats) {
void RegisterAllocator::MeetRegisterConstraints() {
- for (int i = 0; i < code()->InstructionBlockCount(); ++i) {
- MeetRegisterConstraints(
- code()->InstructionBlockAt(BasicBlock::RpoNumber::FromInt(i)));
+ for (auto block : code()->instruction_blocks()) {
+ MeetRegisterConstraints(block);
if (!AllocationOk()) return;
}
}
@@ -1170,55 +1172,9 @@ void RegisterAllocator::MeetRegisterConstraints() {
void RegisterAllocator::ResolvePhis() {
// Process the blocks in reverse order.
- for (int i = code()->InstructionBlockCount() - 1; i >= 0; --i) {
- ResolvePhis(code()->InstructionBlockAt(BasicBlock::RpoNumber::FromInt(i)));
- }
-}
-
-
-void RegisterAllocator::ResolveControlFlow(LiveRange* range,
- const InstructionBlock* block,
- const InstructionBlock* pred) {
- LifetimePosition pred_end =
- LifetimePosition::FromInstructionIndex(pred->last_instruction_index());
- LifetimePosition cur_start =
- LifetimePosition::FromInstructionIndex(block->first_instruction_index());
- LiveRange* pred_cover = NULL;
- LiveRange* cur_cover = NULL;
- LiveRange* cur_range = range;
- while (cur_range != NULL && (cur_cover == NULL || pred_cover == NULL)) {
- if (cur_range->CanCover(cur_start)) {
- DCHECK(cur_cover == NULL);
- cur_cover = cur_range;
- }
- if (cur_range->CanCover(pred_end)) {
- DCHECK(pred_cover == NULL);
- pred_cover = cur_range;
- }
- cur_range = cur_range->next();
- }
-
- if (cur_cover->IsSpilled()) return;
- DCHECK(pred_cover != NULL && cur_cover != NULL);
- if (pred_cover != cur_cover) {
- InstructionOperand* pred_op =
- pred_cover->CreateAssignedOperand(code_zone());
- InstructionOperand* cur_op = cur_cover->CreateAssignedOperand(code_zone());
- if (!pred_op->Equals(cur_op)) {
- GapInstruction* gap = NULL;
- if (block->PredecessorCount() == 1) {
- gap = code()->GapAt(block->first_instruction_index());
- } else {
- DCHECK(pred->SuccessorCount() == 1);
- gap = GetLastGap(pred);
-
- Instruction* branch = InstructionAt(pred->last_instruction_index());
- DCHECK(!branch->HasPointerMap());
- USE(branch);
- }
- gap->GetOrCreateParallelMove(GapInstruction::START, code_zone())
- ->AddMove(pred_op, cur_op, code_zone());
- }
+ for (auto i = code()->instruction_blocks().rbegin();
+ i != code()->instruction_blocks().rend(); ++i) {
+ ResolvePhis(*i);
}
}
@@ -1288,20 +1244,146 @@ bool RegisterAllocator::CanEagerlyResolveControlFlow(
}
+namespace {
+
+class LiveRangeBound {
+ public:
+ explicit LiveRangeBound(const LiveRange* range)
+ : range_(range), start_(range->Start()), end_(range->End()) {
+ DCHECK(!range->IsEmpty());
+ }
+
+ bool CanCover(LifetimePosition position) {
+ return start_.Value() <= position.Value() &&
+ position.Value() < end_.Value();
+ }
+
+ const LiveRange* const range_;
+ const LifetimePosition start_;
+ const LifetimePosition end_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(LiveRangeBound);
+};
+
+
+struct FindResult {
+ const LiveRange* cur_cover_;
+ const LiveRange* pred_cover_;
+};
+
+
+class LiveRangeBoundArray {
+ public:
+ LiveRangeBoundArray() : length_(0), start_(nullptr) {}
+
+ bool ShouldInitialize() { return start_ == NULL; }
+
+ void Initialize(Zone* zone, const LiveRange* const range) {
+ size_t length = 0;
+ for (const LiveRange* i = range; i != NULL; i = i->next()) length++;
+ start_ = zone->NewArray<LiveRangeBound>(static_cast<int>(length));
+ length_ = length;
+ LiveRangeBound* curr = start_;
+ for (const LiveRange* i = range; i != NULL; i = i->next(), ++curr) {
+ new (curr) LiveRangeBound(i);
+ }
+ }
+
+ LiveRangeBound* Find(const LifetimePosition position) const {
+ size_t left_index = 0;
+ size_t right_index = length_;
+ while (true) {
+ size_t current_index = left_index + (right_index - left_index) / 2;
+ DCHECK(right_index > current_index);
+ LiveRangeBound* bound = &start_[current_index];
+ if (bound->start_.Value() <= position.Value()) {
+ if (position.Value() < bound->end_.Value()) return bound;
+ DCHECK(left_index < current_index);
+ left_index = current_index;
+ } else {
+ right_index = current_index;
+ }
+ }
+ }
+
+ void Find(const InstructionBlock* block, const InstructionBlock* pred,
+ FindResult* result) const {
+ const LifetimePosition pred_end =
+ LifetimePosition::FromInstructionIndex(pred->last_instruction_index());
+ LiveRangeBound* bound = Find(pred_end);
+ result->pred_cover_ = bound->range_;
+ const LifetimePosition cur_start = LifetimePosition::FromInstructionIndex(
+ block->first_instruction_index());
+ // Common case.
+ if (bound->CanCover(cur_start)) {
+ result->cur_cover_ = bound->range_;
+ return;
+ }
+ result->cur_cover_ = Find(cur_start)->range_;
+ DCHECK(result->pred_cover_ != NULL && result->cur_cover_ != NULL);
+ }
+
+ private:
+ size_t length_;
+ LiveRangeBound* start_;
+
+ DISALLOW_COPY_AND_ASSIGN(LiveRangeBoundArray);
+};
+
+
+class LiveRangeFinder {
+ public:
+ explicit LiveRangeFinder(const RegisterAllocator& allocator)
+ : allocator_(allocator),
+ bounds_length_(allocator.live_ranges().length()),
+ bounds_(allocator.local_zone()->NewArray<LiveRangeBoundArray>(
+ bounds_length_)) {
+ for (int i = 0; i < bounds_length_; ++i) {
+ new (&bounds_[i]) LiveRangeBoundArray();
+ }
+ }
+
+ LiveRangeBoundArray* ArrayFor(int operand_index) {
+ DCHECK(operand_index < bounds_length_);
+ const LiveRange* range = allocator_.live_ranges()[operand_index];
+ DCHECK(range != nullptr && !range->IsEmpty());
+ LiveRangeBoundArray* array = &bounds_[operand_index];
+ if (array->ShouldInitialize()) {
+ array->Initialize(allocator_.local_zone(), range);
+ }
+ return array;
+ }
+
+ private:
+ const RegisterAllocator& allocator_;
+ const int bounds_length_;
+ LiveRangeBoundArray* const bounds_;
+
+ DISALLOW_COPY_AND_ASSIGN(LiveRangeFinder);
+};
+
+} // namespace
+
+
void RegisterAllocator::ResolveControlFlow() {
- for (int block_id = 1; block_id < code()->InstructionBlockCount();
- ++block_id) {
- const InstructionBlock* block =
- code()->InstructionBlockAt(BasicBlock::RpoNumber::FromInt(block_id));
+ // Lazily linearize live ranges in memory for fast lookup.
+ LiveRangeFinder finder(*this);
+ for (auto block : code()->instruction_blocks()) {
if (CanEagerlyResolveControlFlow(block)) continue;
BitVector* live = live_in_sets_[block->rpo_number().ToInt()];
BitVector::Iterator iterator(live);
while (!iterator.Done()) {
- int operand_index = iterator.Current();
+ LiveRangeBoundArray* array = finder.ArrayFor(iterator.Current());
for (auto pred : block->predecessors()) {
- const InstructionBlock* cur = code()->InstructionBlockAt(pred);
- LiveRange* cur_range = LiveRangeFor(operand_index);
- ResolveControlFlow(cur_range, block, cur);
+ FindResult result;
+ const InstructionBlock* pred_block = code()->InstructionBlockAt(pred);
+ array->Find(block, pred_block, &result);
+ if (result.cur_cover_ == result.pred_cover_ ||
+ result.cur_cover_->IsSpilled())
+ continue;
+ ResolveControlFlow(block, result.cur_cover_, pred_block,
+ result.pred_cover_);
}
iterator.Advance();
}
@@ -1309,6 +1391,30 @@ void RegisterAllocator::ResolveControlFlow() {
}
+void RegisterAllocator::ResolveControlFlow(const InstructionBlock* block,
+ const LiveRange* cur_cover,
+ const InstructionBlock* pred,
+ const LiveRange* pred_cover) {
+ InstructionOperand* pred_op = pred_cover->CreateAssignedOperand(code_zone());
+ InstructionOperand* cur_op = cur_cover->CreateAssignedOperand(code_zone());
+ if (!pred_op->Equals(cur_op)) {
+ GapInstruction* gap = NULL;
+ if (block->PredecessorCount() == 1) {
+ gap = code()->GapAt(block->first_instruction_index());
+ } else {
+ DCHECK(pred->SuccessorCount() == 1);
+ gap = GetLastGap(pred);
+
+ Instruction* branch = InstructionAt(pred->last_instruction_index());
+ DCHECK(!branch->HasPointerMap());
+ USE(branch);
+ }
+ gap->GetOrCreateParallelMove(GapInstruction::START, code_zone())
+ ->AddMove(pred_op, cur_op, code_zone());
+ }
+}
+
+
void RegisterAllocator::BuildLiveRanges() {
InitializeLivenessAnalysis();
// Process the blocks in reverse order.
@@ -1371,7 +1477,7 @@ void RegisterAllocator::BuildLiveRanges() {
while (!iterator.Done()) {
int operand_index = iterator.Current();
LiveRange* range = LiveRangeFor(operand_index);
- range->EnsureInterval(start, end, zone());
+ range->EnsureInterval(start, end, local_zone());
iterator.Advance();
}
@@ -1667,13 +1773,13 @@ RegisterKind RegisterAllocator::RequiredRegisterKind(
void RegisterAllocator::AddToActive(LiveRange* range) {
TraceAlloc("Add live range %d to active\n", range->id());
- active_live_ranges_.Add(range, zone());
+ active_live_ranges_.Add(range, local_zone());
}
void RegisterAllocator::AddToInactive(LiveRange* range) {
TraceAlloc("Add live range %d to inactive\n", range->id());
- inactive_live_ranges_.Add(range, zone());
+ inactive_live_ranges_.Add(range, local_zone());
}
@@ -1685,13 +1791,13 @@ void RegisterAllocator::AddToUnhandledSorted(LiveRange* range) {
LiveRange* cur_range = unhandled_live_ranges_.at(i);
if (range->ShouldBeAllocatedBefore(cur_range)) {
TraceAlloc("Add live range %d to unhandled at %d\n", range->id(), i + 1);
- unhandled_live_ranges_.InsertAt(i + 1, range, zone());
+ unhandled_live_ranges_.InsertAt(i + 1, range, local_zone());
DCHECK(UnhandledIsSorted());
return;
}
}
TraceAlloc("Add live range %d to unhandled at start\n", range->id());
- unhandled_live_ranges_.InsertAt(0, range, zone());
+ unhandled_live_ranges_.InsertAt(0, range, local_zone());
DCHECK(UnhandledIsSorted());
}
@@ -1700,7 +1806,7 @@ void RegisterAllocator::AddToUnhandledUnsorted(LiveRange* range) {
if (range == NULL || range->IsEmpty()) return;
DCHECK(!range->HasRegisterAssigned() && !range->IsSpilled());
TraceAlloc("Add live range %d to unhandled unsorted at end\n", range->id());
- unhandled_live_ranges_.Add(range, zone());
+ unhandled_live_ranges_.Add(range, local_zone());
}
@@ -1742,7 +1848,7 @@ void RegisterAllocator::FreeSpillSlot(LiveRange* range) {
InstructionOperand* spill_operand = range->TopLevel()->GetSpillOperand();
if (spill_operand->IsConstant()) return;
if (spill_operand->index() >= 0) {
- reusable_slots_.Add(range, zone());
+ reusable_slots_.Add(range, local_zone());
}
}
@@ -1771,7 +1877,7 @@ void RegisterAllocator::ActiveToHandled(LiveRange* range) {
void RegisterAllocator::ActiveToInactive(LiveRange* range) {
DCHECK(active_live_ranges_.Contains(range));
active_live_ranges_.RemoveElement(range);
- inactive_live_ranges_.Add(range, zone());
+ inactive_live_ranges_.Add(range, local_zone());
TraceAlloc("Moving live range %d from active to inactive\n", range->id());
}
@@ -1787,7 +1893,7 @@ void RegisterAllocator::InactiveToHandled(LiveRange* range) {
void RegisterAllocator::InactiveToActive(LiveRange* range) {
DCHECK(inactive_live_ranges_.Contains(range));
inactive_live_ranges_.RemoveElement(range);
- active_live_ranges_.Add(range, zone());
+ active_live_ranges_.Add(range, local_zone());
TraceAlloc("Moving live range %d from inactive to active\n", range->id());
}
@@ -2063,7 +2169,7 @@ LiveRange* RegisterAllocator::SplitRangeAt(LiveRange* range,
int vreg = GetVirtualRegister();
if (!AllocationOk()) return NULL;
LiveRange* result = LiveRangeFor(vreg);
- range->SplitAt(pos, result, zone());
+ range->SplitAt(pos, result, local_zone());
return result;
}
@@ -2171,10 +2277,10 @@ void RegisterAllocator::Spill(LiveRange* range) {
RegisterKind kind = range->Kind();
int index = frame()->AllocateSpillSlot(kind == DOUBLE_REGISTERS);
if (kind == DOUBLE_REGISTERS) {
- op = DoubleStackSlotOperand::Create(index, zone());
+ op = DoubleStackSlotOperand::Create(index, local_zone());
} else {
DCHECK(kind == GENERAL_REGISTERS);
- op = StackSlotOperand::Create(index, zone());
+ op = StackSlotOperand::Create(index, local_zone());
}
}
first->SetSpillOperand(op);
diff --git a/src/compiler/register-allocator.h b/src/compiler/register-allocator.h
index b167437c5..a6578af7e 100644
--- a/src/compiler/register-allocator.h
+++ b/src/compiler/register-allocator.h
@@ -186,12 +186,15 @@ class LiveRange FINAL : public ZoneObject {
UsePosition* first_pos() const { return first_pos_; }
LiveRange* parent() const { return parent_; }
LiveRange* TopLevel() { return (parent_ == NULL) ? this : parent_; }
+ const LiveRange* TopLevel() const {
+ return (parent_ == NULL) ? this : parent_;
+ }
LiveRange* next() const { return next_; }
bool IsChild() const { return parent() != NULL; }
int id() const { return id_; }
bool IsFixed() const { return id_ < 0; }
bool IsEmpty() const { return first_interval() == NULL; }
- InstructionOperand* CreateAssignedOperand(Zone* zone);
+ InstructionOperand* CreateAssignedOperand(Zone* zone) const;
int assigned_register() const { return assigned_register_; }
int spill_start_index() const { return spill_start_index_; }
void set_assigned_register(int reg, Zone* zone);
@@ -337,6 +340,8 @@ class RegisterAllocator FINAL {
return fixed_double_live_ranges_;
}
InstructionSequence* code() const { return code_; }
+ // This zone is for datastructures only needed during register allocation.
+ Zone* local_zone() const { return local_zone_; }
private:
int GetVirtualRegister() {
@@ -356,9 +361,6 @@ class RegisterAllocator FINAL {
// Returns the register kind required by the given virtual register.
RegisterKind RequiredRegisterKind(int virtual_register) const;
- // This zone is for datastructures only needed during register allocation.
- Zone* zone() const { return zone_; }
-
// This zone is for InstructionOperands and moves that live beyond register
// allocation.
Zone* code_zone() const { return code()->zone(); }
@@ -465,8 +467,10 @@ class RegisterAllocator FINAL {
bool IsBlockBoundary(LifetimePosition pos);
// Helper methods for resolving control flow.
- void ResolveControlFlow(LiveRange* range, const InstructionBlock* block,
- const InstructionBlock* pred);
+ void ResolveControlFlow(const InstructionBlock* block,
+ const LiveRange* cur_cover,
+ const InstructionBlock* pred,
+ const LiveRange* pred_cover);
void SetLiveRangeAssignedRegister(LiveRange* range, int reg);
@@ -494,7 +498,7 @@ class RegisterAllocator FINAL {
const char* debug_name() const { return debug_name_; }
const RegisterConfiguration* config() const { return config_; }
- Zone* const zone_;
+ Zone* const local_zone_;
Frame* const frame_;
InstructionSequence* const code_;
const char* const debug_name_;
diff --git a/src/compiler/schedule.cc b/src/compiler/schedule.cc
index 51400cf04..50ece951d 100644
--- a/src/compiler/schedule.cc
+++ b/src/compiler/schedule.cc
@@ -16,10 +16,11 @@ BasicBlock::BasicBlock(Zone* zone, Id id)
: ao_number_(-1),
rpo_number_(-1),
deferred_(false),
+ dominator_depth_(-1),
dominator_(NULL),
loop_header_(NULL),
+ loop_end_(NULL),
loop_depth_(0),
- loop_end_(-1),
control_(kNone),
control_input_(NULL),
nodes_(zone),
@@ -32,8 +33,9 @@ bool BasicBlock::LoopContains(BasicBlock* block) const {
// RPO numbers must be initialized.
DCHECK(rpo_number_ >= 0);
DCHECK(block->rpo_number_ >= 0);
- if (loop_end_ < 0) return false; // This is not a loop.
- return block->rpo_number_ >= rpo_number_ && block->rpo_number_ < loop_end_;
+ if (loop_end_ == NULL) return false; // This is not a loop.
+ return block->rpo_number_ >= rpo_number_ &&
+ block->rpo_number_ < loop_end_->rpo_number_;
}
@@ -60,6 +62,11 @@ void BasicBlock::set_control_input(Node* control_input) {
}
+void BasicBlock::set_dominator_depth(int32_t dominator_depth) {
+ dominator_depth_ = dominator_depth;
+}
+
+
void BasicBlock::set_dominator(BasicBlock* dominator) {
dominator_ = dominator;
}
@@ -75,7 +82,7 @@ void BasicBlock::set_rpo_number(int32_t rpo_number) {
}
-void BasicBlock::set_loop_end(int32_t loop_end) { loop_end_ = loop_end; }
+void BasicBlock::set_loop_end(BasicBlock* loop_end) { loop_end_ = loop_end; }
void BasicBlock::set_loop_header(BasicBlock* loop_header) {
diff --git a/src/compiler/schedule.h b/src/compiler/schedule.h
index 797418298..b65a50719 100644
--- a/src/compiler/schedule.h
+++ b/src/compiler/schedule.h
@@ -145,18 +145,21 @@ class BasicBlock FINAL : public ZoneObject {
bool deferred() const { return deferred_; }
void set_deferred(bool deferred) { deferred_ = deferred; }
+ int32_t dominator_depth() const { return dominator_depth_; }
+ void set_dominator_depth(int32_t dominator_depth);
+
BasicBlock* dominator() const { return dominator_; }
void set_dominator(BasicBlock* dominator);
BasicBlock* loop_header() const { return loop_header_; }
void set_loop_header(BasicBlock* loop_header);
+ BasicBlock* loop_end() const { return loop_end_; }
+ void set_loop_end(BasicBlock* loop_end);
+
int32_t loop_depth() const { return loop_depth_; }
void set_loop_depth(int32_t loop_depth);
- int32_t loop_end() const { return loop_end_; }
- void set_loop_end(int32_t loop_end);
-
RpoNumber GetAoNumber() const { return RpoNumber::FromInt(ao_number_); }
int32_t ao_number() const { return ao_number_; }
void set_ao_number(int32_t ao_number) { ao_number_ = ao_number; }
@@ -166,19 +169,20 @@ class BasicBlock FINAL : public ZoneObject {
void set_rpo_number(int32_t rpo_number);
// Loop membership helpers.
- inline bool IsLoopHeader() const { return loop_end_ >= 0; }
+ inline bool IsLoopHeader() const { return loop_end_ != NULL; }
bool LoopContains(BasicBlock* block) const;
private:
int32_t ao_number_; // assembly order number of the block.
int32_t rpo_number_; // special RPO number of the block.
bool deferred_; // true if the block contains deferred code.
+ int32_t dominator_depth_; // Depth within the dominator tree.
BasicBlock* dominator_; // Immediate dominator of the block.
BasicBlock* loop_header_; // Pointer to dominating loop header basic block,
// NULL if none. For loop headers, this points to
// enclosing loop header.
+ BasicBlock* loop_end_; // end of the loop, if this block is a loop header.
int32_t loop_depth_; // loop nesting, 0 is top-level
- int32_t loop_end_; // end of the loop, if this block is a loop header.
Control control_; // Control at the end of the block.
Node* control_input_; // Input value for control.
diff --git a/src/compiler/scheduler.cc b/src/compiler/scheduler.cc
index 1599152f9..92e05cb45 100644
--- a/src/compiler/scheduler.cc
+++ b/src/compiler/scheduler.cc
@@ -52,6 +52,8 @@ Schedule* Scheduler::ComputeSchedule(ZonePool* zone_pool, Graph* graph) {
scheduler.ScheduleEarly();
scheduler.ScheduleLate();
+ scheduler.SealFinalSchedule();
+
return schedule;
}
@@ -211,20 +213,11 @@ void Scheduler::DecrementUnscheduledUseCount(Node* node, int index,
}
-int Scheduler::GetRPONumber(BasicBlock* block) {
- DCHECK(block->rpo_number() >= 0 &&
- block->rpo_number() < static_cast<int>(schedule_->rpo_order_.size()));
- DCHECK(schedule_->rpo_order_[block->rpo_number()] == block);
- return block->rpo_number();
-}
-
-
BasicBlock* Scheduler::GetCommonDominator(BasicBlock* b1, BasicBlock* b2) {
while (b1 != b2) {
- int b1_rpo = GetRPONumber(b1);
- int b2_rpo = GetRPONumber(b2);
- DCHECK(b1_rpo != b2_rpo);
- if (b1_rpo < b2_rpo) {
+ int32_t b1_depth = b1->dominator_depth();
+ int32_t b2_depth = b2->dominator_depth();
+ if (b1_depth < b2_depth) {
b2 = b2->dominator();
} else {
b1 = b1->dominator();
@@ -422,8 +415,6 @@ class CFGBuilder {
IrOpcode::kIfFalse);
// Consider branch hints.
- // TODO(turbofan): Propagate the deferred flag to all blocks dominated by
- // this IfTrue/IfFalse later.
switch (BranchHintOf(branch->op())) {
case BranchHint::kNone:
break;
@@ -529,23 +520,164 @@ void Scheduler::BuildCFG() {
// 2. All loops are contiguous in the order (i.e. no intervening blocks that
// do not belong to the loop.)
// Note a simple RPO traversal satisfies (1) but not (2).
-class SpecialRPONumberer {
+class SpecialRPONumberer : public ZoneObject {
public:
SpecialRPONumberer(Zone* zone, Schedule* schedule)
- : zone_(zone), schedule_(schedule) {}
-
+ : zone_(zone),
+ schedule_(schedule),
+ order_(NULL),
+ loops_(zone),
+ beyond_end_(NULL) {}
+
+ // Computes the special reverse-post-order for the main control flow graph,
+ // that is for the graph spanned between the schedule's start and end blocks.
void ComputeSpecialRPO() {
- // RPO should not have been computed for this schedule yet.
+ DCHECK_EQ(NULL, order_); // Main order does not exist yet.
+ // TODO(mstarzinger): Should use Schedule::end() after tests are fixed.
+ ComputeAndInsertSpecialRPO(schedule_->start(), NULL);
+ }
+
+ // Computes the special reverse-post-order for a partial control flow graph,
+ // that is for the graph spanned between the given {entry} and {end} blocks,
+ // then updates the existing ordering with this new information.
+ void UpdateSpecialRPO(BasicBlock* entry, BasicBlock* end) {
+ DCHECK_NE(NULL, order_); // Main order to be updated is present.
+ ComputeAndInsertSpecialRPO(entry, end);
+ }
+
+ // Serialize the previously computed order as an assembly order (non-deferred
+ // code first, deferred code afterwards) into the final schedule.
+ void SerializeAOIntoSchedule() {
+ int32_t number = 0;
+ for (BlockList* l = order_; l != NULL; l = l->next) {
+ if (l->block->deferred()) continue;
+ l->block->set_ao_number(number++);
+ }
+ for (BlockList* l = order_; l != NULL; l = l->next) {
+ if (!l->block->deferred()) continue;
+ l->block->set_ao_number(number++);
+ }
+ }
+
+ // Serialize the previously computed order as a special reverse-post-order
+ // numbering for basic blocks into the final schedule.
+ void SerializeRPOIntoSchedule() {
+ int32_t number = 0;
+ for (BlockList* l = order_; l != NULL; l = l->next) {
+ l->block->set_rpo_number(number++);
+ schedule_->rpo_order()->push_back(l->block);
+ }
+ BeyondEndSentinel()->set_rpo_number(number);
+ }
+
+ // Print and verify the special reverse-post-order.
+ void PrintAndVerifySpecialRPO() {
+#if DEBUG
+ if (FLAG_trace_turbo_scheduler) PrintRPO();
+ VerifySpecialRPO();
+#endif
+ }
+
+ private:
+ // TODO(mstarzinger): Only for Scheduler::GenerateImmediateDominatorTree.
+ friend class Scheduler;
+
+ // Numbering for BasicBlockData.rpo_number_ for this block traversal:
+ static const int kBlockOnStack = -2;
+ static const int kBlockVisited1 = -3;
+ static const int kBlockVisited2 = -4;
+ static const int kBlockUnvisited1 = -1;
+ static const int kBlockUnvisited2 = kBlockVisited1;
+
+ struct SpecialRPOStackFrame {
+ BasicBlock* block;
+ size_t index;
+ };
+
+ struct BlockList {
+ BasicBlock* block;
+ BlockList* next;
+
+ BlockList* Add(Zone* zone, BasicBlock* b) {
+ BlockList* list = static_cast<BlockList*>(zone->New(sizeof(BlockList)));
+ list->block = b;
+ list->next = this;
+ return list;
+ }
+
+ BlockList* FindForBlock(BasicBlock* b) {
+ for (BlockList* l = this; l != NULL; l = l->next) {
+ if (l->block == b) return l;
+ }
+ return NULL;
+ }
+ };
+
+ struct LoopInfo {
+ BasicBlock* header;
+ ZoneList<BasicBlock*>* outgoing;
+ BitVector* members;
+ LoopInfo* prev;
+ BlockList* end;
+ BlockList* start;
+
+ void AddOutgoing(Zone* zone, BasicBlock* block) {
+ if (outgoing == NULL) {
+ outgoing = new (zone) ZoneList<BasicBlock*>(2, zone);
+ }
+ outgoing->Add(block, zone);
+ }
+ };
+
+ int Push(SpecialRPOStackFrame* stack, int depth, BasicBlock* child,
+ int unvisited) {
+ if (child->rpo_number() == unvisited) {
+ stack[depth].block = child;
+ stack[depth].index = 0;
+ child->set_rpo_number(kBlockOnStack);
+ return depth + 1;
+ }
+ return depth;
+ }
+
+ // We are hijacking the {ao_number} to enumerate loops temporarily. Note that
+ // these numbers are only valid within this class.
+ static int GetLoopNumber(BasicBlock* block) { return block->ao_number(); }
+ static void SetLoopNumber(BasicBlock* block, int loop_number) {
+ return block->set_ao_number(loop_number);
+ }
+ static bool HasLoopNumber(BasicBlock* block) {
+ return block->ao_number() >= 0;
+ }
+
+ // TODO(mstarzinger): We only need this special sentinel because some tests
+ // use the schedule's end block in actual control flow (e.g. with end having
+ // successors). Once this has been cleaned up we can use the end block here.
+ BasicBlock* BeyondEndSentinel() {
+ if (beyond_end_ == NULL) {
+ BasicBlock::Id id = BasicBlock::Id::FromInt(-1);
+ beyond_end_ = new (schedule_->zone()) BasicBlock(schedule_->zone(), id);
+ }
+ return beyond_end_;
+ }
+
+ // Compute special RPO for the control flow graph between {entry} and {end},
+ // mutating any existing order so that the result is still valid.
+ void ComputeAndInsertSpecialRPO(BasicBlock* entry, BasicBlock* end) {
+ // RPO should not have been serialized for this schedule yet.
+ CHECK_EQ(kBlockUnvisited1, schedule_->start()->ao_number());
CHECK_EQ(kBlockUnvisited1, schedule_->start()->rpo_number());
CHECK_EQ(0, static_cast<int>(schedule_->rpo_order()->size()));
+ // Find correct insertion point within existing order.
+ BlockList* insert_before = order_->FindForBlock(entry);
+ BlockList* insert_after = insert_before ? insert_before->next : NULL;
+
// Perform an iterative RPO traversal using an explicit stack,
// recording backedges that form cycles. O(|B|).
ZoneList<std::pair<BasicBlock*, size_t> > backedges(1, zone_);
SpecialRPOStackFrame* stack = zone_->NewArray<SpecialRPOStackFrame>(
static_cast<int>(schedule_->BasicBlockCount()));
- BasicBlock* entry = schedule_->start();
- BlockList* order = NULL;
int stack_depth = Push(stack, 0, entry, kBlockUnvisited1);
int num_loops = 0;
@@ -553,7 +685,8 @@ class SpecialRPONumberer {
int current = stack_depth - 1;
SpecialRPOStackFrame* frame = stack + current;
- if (frame->index < frame->block->SuccessorCount()) {
+ if (frame->block != end &&
+ frame->index < frame->block->SuccessorCount()) {
// Process the next successor.
BasicBlock* succ = frame->block->SuccessorAt(frame->index++);
if (succ->rpo_number() == kBlockVisited1) continue;
@@ -562,9 +695,9 @@ class SpecialRPONumberer {
backedges.Add(
std::pair<BasicBlock*, size_t>(frame->block, frame->index - 1),
zone_);
- if (succ->loop_end() < 0) {
+ if (!HasLoopNumber(succ)) {
// Assign a new loop number to the header if it doesn't have one.
- succ->set_loop_end(num_loops++);
+ SetLoopNumber(succ, num_loops++);
}
} else {
// Push the successor onto the stack.
@@ -573,23 +706,32 @@ class SpecialRPONumberer {
}
} else {
// Finished with all successors; pop the stack and add the block.
- order = order->Add(zone_, frame->block);
+ insert_after = insert_after->Add(zone_, frame->block);
frame->block->set_rpo_number(kBlockVisited1);
stack_depth--;
}
}
+ // Insert the result into any existing order.
+ if (insert_before == NULL) {
+ order_ = insert_after;
+ } else {
+ // There already is a list element for the entry block in the list, hence
+ // we skip the first element of the sub-list to compensate duplication.
+ DCHECK_EQ(insert_before->block, insert_after->block);
+ insert_before->next = insert_after->next;
+ }
+
// If no loops were encountered, then the order we computed was correct.
- LoopInfo* loops = NULL;
if (num_loops != 0) {
// Otherwise, compute the loop information from the backedges in order
// to perform a traversal that groups loop bodies together.
- loops = ComputeLoopInfo(stack, num_loops, schedule_->BasicBlockCount(),
- &backedges);
+ ComputeLoopInfo(stack, num_loops, &backedges);
// Initialize the "loop stack". Note the entry could be a loop header.
- LoopInfo* loop = entry->IsLoopHeader() ? &loops[entry->loop_end()] : NULL;
- order = NULL;
+ LoopInfo* loop =
+ HasLoopNumber(entry) ? &loops_[GetLoopNumber(entry)] : NULL;
+ order_ = NULL;
// Perform an iterative post-order traversal, visiting loop bodies before
// edges that lead out of loops. Visits each block once, but linking loop
@@ -604,14 +746,14 @@ class SpecialRPONumberer {
if (frame->index < block->SuccessorCount()) {
// Process the next normal successor.
succ = block->SuccessorAt(frame->index++);
- } else if (block->IsLoopHeader()) {
+ } else if (HasLoopNumber(block)) {
// Process additional outgoing edges from the loop header.
if (block->rpo_number() == kBlockOnStack) {
// Finish the loop body the first time the header is left on the
// stack.
DCHECK(loop != NULL && loop->header == block);
- loop->start = order->Add(zone_, block);
- order = loop->end;
+ loop->start = order_->Add(zone_, block);
+ order_ = loop->end;
block->set_rpo_number(kBlockVisited2);
// Pop the loop stack and continue visiting outgoing edges within
// the context of the outer loop, if any.
@@ -623,7 +765,7 @@ class SpecialRPONumberer {
// Use the next outgoing edge if there are any.
int outgoing_index =
static_cast<int>(frame->index - block->SuccessorCount());
- LoopInfo* info = &loops[block->loop_end()];
+ LoopInfo* info = &loops_[GetLoopNumber(block)];
DCHECK(loop != info);
if (info->outgoing != NULL &&
outgoing_index < info->outgoing->length()) {
@@ -644,31 +786,31 @@ class SpecialRPONumberer {
} else {
// Push the successor onto the stack.
stack_depth = Push(stack, stack_depth, succ, kBlockUnvisited2);
- if (succ->IsLoopHeader()) {
+ if (HasLoopNumber(succ)) {
// Push the inner loop onto the loop stack.
- DCHECK(succ->loop_end() >= 0 && succ->loop_end() < num_loops);
- LoopInfo* next = &loops[succ->loop_end()];
- next->end = order;
+ DCHECK(GetLoopNumber(succ) < num_loops);
+ LoopInfo* next = &loops_[GetLoopNumber(succ)];
+ next->end = order_;
next->prev = loop;
loop = next;
}
}
} else {
// Finished with all successors of the current block.
- if (block->IsLoopHeader()) {
+ if (HasLoopNumber(block)) {
// If we are going to pop a loop header, then add its entire body.
- LoopInfo* info = &loops[block->loop_end()];
+ LoopInfo* info = &loops_[GetLoopNumber(block)];
for (BlockList* l = info->start; true; l = l->next) {
if (l->next == info->end) {
- l->next = order;
- info->end = order;
+ l->next = order_;
+ info->end = order_;
break;
}
}
- order = info->start;
+ order_ = info->start;
} else {
// Pop a single node off the stack and add it to the order.
- order = order->Add(zone_, block);
+ order_ = order_->Add(zone_, block);
block->set_rpo_number(kBlockVisited2);
}
stack_depth--;
@@ -676,21 +818,15 @@ class SpecialRPONumberer {
}
}
- // Construct the final order from the list.
- BasicBlockVector* final_order = schedule_->rpo_order();
- order->Serialize(final_order);
-
// Compute the correct loop headers and set the correct loop ends.
LoopInfo* current_loop = NULL;
BasicBlock* current_header = NULL;
int loop_depth = 0;
- for (BasicBlockVectorIter i = final_order->begin(); i != final_order->end();
- ++i) {
- BasicBlock* current = *i;
+ for (BlockList* l = order_; l != NULL; l = l->next) {
+ BasicBlock* current = l->block;
// Finish the previous loop(s) if we just exited them.
- while (current_header != NULL &&
- current->rpo_number() >= current_header->loop_end()) {
+ while (current_header != NULL && current == current_header->loop_end()) {
DCHECK(current_header->IsLoopHeader());
DCHECK(current_loop != NULL);
current_loop = current_loop->prev;
@@ -700,13 +836,11 @@ class SpecialRPONumberer {
current->set_loop_header(current_header);
// Push a new loop onto the stack if this loop is a loop header.
- if (current->IsLoopHeader()) {
+ if (HasLoopNumber(current)) {
loop_depth++;
- current_loop = &loops[current->loop_end()];
+ current_loop = &loops_[GetLoopNumber(current)];
BlockList* end = current_loop->end;
- current->set_loop_end(end == NULL
- ? static_cast<int>(final_order->size())
- : end->block->rpo_number());
+ current->set_loop_end(end == NULL ? BeyondEndSentinel() : end->block);
current_header = current_loop->header;
Trace("B%d is a loop header, increment loop depth to %d\n",
current->id().ToInt(), loop_depth);
@@ -722,109 +856,31 @@ class SpecialRPONumberer {
current->loop_header()->id().ToInt(), current->loop_depth());
}
}
-
- // Compute the assembly order (non-deferred code first, deferred code
- // afterwards).
- int32_t number = 0;
- for (auto block : *final_order) {
- if (block->deferred()) continue;
- block->set_ao_number(number++);
- }
- for (auto block : *final_order) {
- if (!block->deferred()) continue;
- block->set_ao_number(number++);
- }
-
-#if DEBUG
- if (FLAG_trace_turbo_scheduler) PrintRPO(num_loops, loops, final_order);
- VerifySpecialRPO(num_loops, loops, final_order);
-#endif
- }
-
- private:
- // Numbering for BasicBlockData.rpo_number_ for this block traversal:
- static const int kBlockOnStack = -2;
- static const int kBlockVisited1 = -3;
- static const int kBlockVisited2 = -4;
- static const int kBlockUnvisited1 = -1;
- static const int kBlockUnvisited2 = kBlockVisited1;
-
- struct SpecialRPOStackFrame {
- BasicBlock* block;
- size_t index;
- };
-
- struct BlockList {
- BasicBlock* block;
- BlockList* next;
-
- BlockList* Add(Zone* zone, BasicBlock* b) {
- BlockList* list = static_cast<BlockList*>(zone->New(sizeof(BlockList)));
- list->block = b;
- list->next = this;
- return list;
- }
-
- void Serialize(BasicBlockVector* final_order) {
- for (BlockList* l = this; l != NULL; l = l->next) {
- l->block->set_rpo_number(static_cast<int>(final_order->size()));
- final_order->push_back(l->block);
- }
- }
- };
-
- struct LoopInfo {
- BasicBlock* header;
- ZoneList<BasicBlock*>* outgoing;
- BitVector* members;
- LoopInfo* prev;
- BlockList* end;
- BlockList* start;
-
- void AddOutgoing(Zone* zone, BasicBlock* block) {
- if (outgoing == NULL) {
- outgoing = new (zone) ZoneList<BasicBlock*>(2, zone);
- }
- outgoing->Add(block, zone);
- }
- };
-
- int Push(SpecialRPOStackFrame* stack, int depth, BasicBlock* child,
- int unvisited) {
- if (child->rpo_number() == unvisited) {
- stack[depth].block = child;
- stack[depth].index = 0;
- child->set_rpo_number(kBlockOnStack);
- return depth + 1;
- }
- return depth;
}
// Computes loop membership from the backedges of the control flow graph.
- LoopInfo* ComputeLoopInfo(
- SpecialRPOStackFrame* queue, int num_loops, size_t num_blocks,
- ZoneList<std::pair<BasicBlock*, size_t> >* backedges) {
- LoopInfo* loops = zone_->NewArray<LoopInfo>(num_loops);
- memset(loops, 0, num_loops * sizeof(LoopInfo));
+ void ComputeLoopInfo(SpecialRPOStackFrame* queue, size_t num_loops,
+ ZoneList<std::pair<BasicBlock*, size_t> >* backedges) {
+ loops_.resize(num_loops, LoopInfo());
// Compute loop membership starting from backedges.
// O(max(loop_depth) * max(|loop|)
for (int i = 0; i < backedges->length(); i++) {
BasicBlock* member = backedges->at(i).first;
BasicBlock* header = member->SuccessorAt(backedges->at(i).second);
- int loop_num = header->loop_end();
- if (loops[loop_num].header == NULL) {
- loops[loop_num].header = header;
- loops[loop_num].members =
- new (zone_) BitVector(static_cast<int>(num_blocks), zone_);
+ size_t loop_num = GetLoopNumber(header);
+ if (loops_[loop_num].header == NULL) {
+ loops_[loop_num].header = header;
+ loops_[loop_num].members = new (zone_)
+ BitVector(static_cast<int>(schedule_->BasicBlockCount()), zone_);
}
int queue_length = 0;
if (member != header) {
// As long as the header doesn't have a backedge to itself,
// Push the member onto the queue and process its predecessors.
- if (!loops[loop_num].members->Contains(member->id().ToInt())) {
- loops[loop_num].members->Add(member->id().ToInt());
+ if (!loops_[loop_num].members->Contains(member->id().ToInt())) {
+ loops_[loop_num].members->Add(member->id().ToInt());
}
queue[queue_length++].block = member;
}
@@ -836,47 +892,46 @@ class SpecialRPONumberer {
for (size_t i = 0; i < block->PredecessorCount(); i++) {
BasicBlock* pred = block->PredecessorAt(i);
if (pred != header) {
- if (!loops[loop_num].members->Contains(pred->id().ToInt())) {
- loops[loop_num].members->Add(pred->id().ToInt());
+ if (!loops_[loop_num].members->Contains(pred->id().ToInt())) {
+ loops_[loop_num].members->Add(pred->id().ToInt());
queue[queue_length++].block = pred;
}
}
}
}
}
- return loops;
}
#if DEBUG
- void PrintRPO(int num_loops, LoopInfo* loops, BasicBlockVector* order) {
+ void PrintRPO() {
OFStream os(stdout);
- os << "-- RPO with " << num_loops << " loops ";
- if (num_loops > 0) {
- os << "(";
- for (int i = 0; i < num_loops; i++) {
+ os << "RPO with " << loops_.size() << " loops";
+ if (loops_.size() > 0) {
+ os << " (";
+ for (size_t i = 0; i < loops_.size(); i++) {
if (i > 0) os << " ";
- os << "B" << loops[i].header->id();
+ os << "B" << loops_[i].header->id();
}
- os << ") ";
+ os << ")";
}
- os << "-- \n";
+ os << ":\n";
- for (size_t i = 0; i < order->size(); i++) {
- BasicBlock* block = (*order)[i];
+ for (BlockList* l = order_; l != NULL; l = l->next) {
+ BasicBlock* block = l->block;
BasicBlock::Id bid = block->id();
// TODO(jarin,svenpanne): Add formatting here once we have support for
- // that in streams (we want an equivalent of PrintF("%5d:", i) here).
- os << i << ":";
- for (int j = 0; j < num_loops; j++) {
- bool membership = loops[j].members->Contains(bid.ToInt());
- bool range = loops[j].header->LoopContains(block);
+ // that in streams (we want an equivalent of PrintF("%5d:", x) here).
+ os << " " << block->rpo_number() << ":";
+ for (size_t i = 0; i < loops_.size(); i++) {
+ bool range = loops_[i].header->LoopContains(block);
+ bool membership = loops_[i].header != block && range;
os << (membership ? " |" : " ");
os << (range ? "x" : " ");
}
os << " B" << bid << ": ";
- if (block->loop_end() >= 0) {
- os << " range: [" << block->rpo_number() << ", " << block->loop_end()
- << ")";
+ if (block->loop_end() != NULL) {
+ os << " range: [" << block->rpo_number() << ", "
+ << block->loop_end()->rpo_number() << ")";
}
if (block->loop_header() != NULL) {
os << " header: B" << block->loop_header()->id();
@@ -888,21 +943,22 @@ class SpecialRPONumberer {
}
}
- void VerifySpecialRPO(int num_loops, LoopInfo* loops,
- BasicBlockVector* order) {
+ void VerifySpecialRPO() {
+ BasicBlockVector* order = schedule_->rpo_order();
DCHECK(order->size() > 0);
DCHECK((*order)[0]->id().ToInt() == 0); // entry should be first.
- for (int i = 0; i < num_loops; i++) {
- LoopInfo* loop = &loops[i];
+ for (size_t i = 0; i < loops_.size(); i++) {
+ LoopInfo* loop = &loops_[i];
BasicBlock* header = loop->header;
+ BasicBlock* end = header->loop_end();
DCHECK(header != NULL);
DCHECK(header->rpo_number() >= 0);
DCHECK(header->rpo_number() < static_cast<int>(order->size()));
- DCHECK(header->loop_end() >= 0);
- DCHECK(header->loop_end() <= static_cast<int>(order->size()));
- DCHECK(header->loop_end() > header->rpo_number());
+ DCHECK(end != NULL);
+ DCHECK(end->rpo_number() <= static_cast<int>(order->size()));
+ DCHECK(end->rpo_number() > header->rpo_number());
DCHECK(header->loop_header() != header);
// Verify the start ... end list relationship.
@@ -922,7 +978,7 @@ class SpecialRPONumberer {
DCHECK(links < static_cast<int>(2 * order->size())); // cycle?
}
DCHECK(links > 0);
- DCHECK(links == (header->loop_end() - header->rpo_number()));
+ DCHECK(links == end->rpo_number() - header->rpo_number());
DCHECK(end_found);
// Check the contiguousness of loops.
@@ -930,14 +986,10 @@ class SpecialRPONumberer {
for (int j = 0; j < static_cast<int>(order->size()); j++) {
BasicBlock* block = order->at(j);
DCHECK(block->rpo_number() == j);
- if (j < header->rpo_number() || j >= header->loop_end()) {
- DCHECK(!loop->members->Contains(block->id().ToInt()));
+ if (j < header->rpo_number() || j >= end->rpo_number()) {
+ DCHECK(!header->LoopContains(block));
} else {
- if (block == header) {
- DCHECK(!loop->members->Contains(block->id().ToInt()));
- } else {
- DCHECK(loop->members->Contains(block->id().ToInt()));
- }
+ DCHECK(header->LoopContains(block));
count++;
}
}
@@ -948,6 +1000,9 @@ class SpecialRPONumberer {
Zone* zone_;
Schedule* schedule_;
+ BlockList* order_;
+ ZoneVector<LoopInfo> loops_;
+ BasicBlock* beyond_end_;
};
@@ -958,6 +1013,9 @@ BasicBlockVector* Scheduler::ComputeSpecialRPO(ZonePool* zone_pool,
SpecialRPONumberer numberer(zone, schedule);
numberer.ComputeSpecialRPO();
+ numberer.SerializeAOIntoSchedule();
+ numberer.SerializeRPOIntoSchedule();
+ numberer.PrintAndVerifySpecialRPO();
return schedule->rpo_order();
}
@@ -965,40 +1023,41 @@ BasicBlockVector* Scheduler::ComputeSpecialRPO(ZonePool* zone_pool,
void Scheduler::ComputeSpecialRPONumbering() {
Trace("--- COMPUTING SPECIAL RPO ----------------------------------\n");
- SpecialRPONumberer numberer(zone_, schedule_);
- numberer.ComputeSpecialRPO();
+ // Compute the special reverse-post-order for basic blocks.
+ special_rpo_ = new (zone_) SpecialRPONumberer(zone_, schedule_);
+ special_rpo_->ComputeSpecialRPO();
}
void Scheduler::GenerateImmediateDominatorTree() {
Trace("--- IMMEDIATE BLOCK DOMINATORS -----------------------------\n");
- // Build the dominator graph.
- // TODO(danno): consider using Lengauer & Tarjan's if this becomes too slow.
- for (size_t i = 0; i < schedule_->rpo_order_.size(); i++) {
- BasicBlock* current_rpo = schedule_->rpo_order_[i];
- if (current_rpo != schedule_->start()) {
- BasicBlock::Predecessors::iterator current_pred =
- current_rpo->predecessors_begin();
- BasicBlock::Predecessors::iterator end = current_rpo->predecessors_end();
- DCHECK(current_pred != end);
- BasicBlock* dominator = *current_pred;
- ++current_pred;
- // For multiple predecessors, walk up the RPO ordering until a common
- // dominator is found.
- int current_rpo_pos = GetRPONumber(current_rpo);
- while (current_pred != end) {
- // Don't examine backwards edges
- BasicBlock* pred = *current_pred;
- if (GetRPONumber(pred) < current_rpo_pos) {
- dominator = GetCommonDominator(dominator, *current_pred);
- }
- ++current_pred;
- }
- current_rpo->set_dominator(dominator);
- Trace("Block %d's idom is %d\n", current_rpo->id().ToInt(),
- dominator->id().ToInt());
+ // TODO(danno): Consider using Lengauer & Tarjan's if this becomes too slow.
+
+ // Build the block dominator tree.
+ schedule_->start()->set_dominator_depth(0);
+ typedef SpecialRPONumberer::BlockList BlockList;
+ for (BlockList* l = special_rpo_->order_; l != NULL; l = l->next) {
+ BasicBlock* current = l->block;
+ if (current == schedule_->start()) continue;
+ BasicBlock::Predecessors::iterator pred = current->predecessors_begin();
+ BasicBlock::Predecessors::iterator end = current->predecessors_end();
+ DCHECK(pred != end); // All blocks except start have predecessors.
+ BasicBlock* dominator = *pred;
+ // For multiple predecessors, walk up the dominator tree until a common
+ // dominator is found. Visitation order guarantees that all predecessors
+ // except for backwards edges have been visited.
+ for (++pred; pred != end; ++pred) {
+ // Don't examine backwards edges.
+ if ((*pred)->dominator_depth() < 0) continue;
+ dominator = GetCommonDominator(dominator, *pred);
}
+ current->set_dominator(dominator);
+ current->set_dominator_depth(dominator->dominator_depth() + 1);
+ // Propagate "deferredness" of the dominator.
+ if (dominator->deferred()) current->set_deferred(true);
+ Trace("Block B%d's idom is B%d, depth = %d\n", current->id().ToInt(),
+ dominator->id().ToInt(), current->dominator_depth());
}
}
@@ -1087,8 +1146,10 @@ class ScheduleEarlyNodeVisitor {
if (scheduler_->GetPlacement(node) == Scheduler::kFixed) {
DCHECK_EQ(schedule_->start(), data->minimum_block_);
data->minimum_block_ = schedule_->block(node);
- Trace("Fixing #%d:%s minimum_rpo = %d\n", node->id(),
- node->op()->mnemonic(), data->minimum_block_->rpo_number());
+ Trace("Fixing #%d:%s minimum_block = B%d, dominator_depth = %d\n",
+ node->id(), node->op()->mnemonic(),
+ data->minimum_block_->id().ToInt(),
+ data->minimum_block_->dominator_depth());
}
// No need to propagate unconstrained schedule early positions.
@@ -1098,14 +1159,14 @@ class ScheduleEarlyNodeVisitor {
DCHECK(data->minimum_block_ != NULL);
Node::Uses uses = node->uses();
for (Node::Uses::iterator i = uses.begin(); i != uses.end(); ++i) {
- PropagateMinimumRPOToNode(data->minimum_block_, *i);
+ PropagateMinimumPositionToNode(data->minimum_block_, *i);
}
}
- // Propagates {block} as another minimum RPO placement into the given {node}.
- // This has the net effect of computing the maximum of the minimum RPOs for
- // all inputs to {node} when the queue has been fully processed.
- void PropagateMinimumRPOToNode(BasicBlock* block, Node* node) {
+ // Propagates {block} as another minimum position into the given {node}. This
+ // has the net effect of computing the minimum dominator block of {node} that
+ // still post-dominates all inputs to {node} when the queue is processed.
+ void PropagateMinimumPositionToNode(BasicBlock* block, Node* node) {
Scheduler::SchedulerData* data = scheduler_->GetData(node);
// No need to propagate to fixed node, it's guaranteed to be a root.
@@ -1114,18 +1175,30 @@ class ScheduleEarlyNodeVisitor {
// Coupled nodes influence schedule early position of their control.
if (scheduler_->GetPlacement(node) == Scheduler::kCoupled) {
Node* control = NodeProperties::GetControlInput(node);
- PropagateMinimumRPOToNode(block, control);
+ PropagateMinimumPositionToNode(block, control);
}
- // Propagate new position if it is larger than the current.
- if (block->rpo_number() > data->minimum_block_->rpo_number()) {
+ // Propagate new position if it is deeper down the dominator tree than the
+ // current. Note that all inputs need to have minimum block position inside
+ // the dominator chain of {node}'s minimum block position.
+ DCHECK(InsideSameDominatorChain(block, data->minimum_block_));
+ if (block->dominator_depth() > data->minimum_block_->dominator_depth()) {
data->minimum_block_ = block;
queue_.push(node);
- Trace("Propagating #%d:%s minimum_rpo = %d\n", node->id(),
- node->op()->mnemonic(), data->minimum_block_->rpo_number());
+ Trace("Propagating #%d:%s minimum_block = B%d, dominator_depth = %d\n",
+ node->id(), node->op()->mnemonic(),
+ data->minimum_block_->id().ToInt(),
+ data->minimum_block_->dominator_depth());
}
}
+#if DEBUG
+ bool InsideSameDominatorChain(BasicBlock* b1, BasicBlock* b2) {
+ BasicBlock* dominator = scheduler_->GetCommonDominator(b1, b2);
+ return dominator == b1 || dominator == b2;
+ }
+#endif
+
Scheduler* scheduler_;
Schedule* schedule_;
ZoneQueue<Node*> queue_;
@@ -1136,14 +1209,13 @@ void Scheduler::ScheduleEarly() {
Trace("--- SCHEDULE EARLY -----------------------------------------\n");
if (FLAG_trace_turbo_scheduler) {
Trace("roots: ");
- for (NodeVectorIter i = schedule_root_nodes_.begin();
- i != schedule_root_nodes_.end(); ++i) {
- Trace("#%d:%s ", (*i)->id(), (*i)->op()->mnemonic());
+ for (Node* node : schedule_root_nodes_) {
+ Trace("#%d:%s ", node->id(), node->op()->mnemonic());
}
Trace("\n");
}
- // Compute the minimum RPO for each node thereby determining the earliest
+ // Compute the minimum block for each node thereby determining the earliest
// position each node could be placed within a valid schedule.
ScheduleEarlyNodeVisitor schedule_early_visitor(zone_, this);
schedule_early_visitor.Run(&schedule_root_nodes_);
@@ -1204,17 +1276,20 @@ class ScheduleLateNodeVisitor {
BasicBlock* block = GetCommonDominatorOfUses(node);
DCHECK_NOT_NULL(block);
- int min_rpo = scheduler_->GetData(node)->minimum_block_->rpo_number();
- Trace("Schedule late of #%d:%s is B%d at loop depth %d, minimum_rpo = %d\n",
+ // The schedule early block dominates the schedule late block.
+ BasicBlock* min_block = scheduler_->GetData(node)->minimum_block_;
+ DCHECK_EQ(min_block, scheduler_->GetCommonDominator(block, min_block));
+ Trace("Schedule late of #%d:%s is B%d at loop depth %d, minimum = B%d\n",
node->id(), node->op()->mnemonic(), block->id().ToInt(),
- block->loop_depth(), min_rpo);
+ block->loop_depth(), min_block->id().ToInt());
// Hoist nodes out of loops if possible. Nodes can be hoisted iteratively
- // into enclosing loop pre-headers until they would preceed their
- // ScheduleEarly position.
+ // into enclosing loop pre-headers until they would preceed their schedule
+ // early position.
BasicBlock* hoist_block = GetPreHeader(block);
- while (hoist_block != NULL && hoist_block->rpo_number() >= min_rpo) {
- Trace(" hoisting #%d:%s to block %d\n", node->id(),
+ while (hoist_block != NULL &&
+ hoist_block->dominator_depth() >= min_block->dominator_depth()) {
+ Trace(" hoisting #%d:%s to block B%d\n", node->id(),
node->op()->mnemonic(), hoist_block->id().ToInt());
DCHECK_LT(hoist_block->loop_depth(), block->loop_depth());
block = hoist_block;
@@ -1302,9 +1377,8 @@ void Scheduler::ScheduleLate() {
Trace("--- SCHEDULE LATE ------------------------------------------\n");
if (FLAG_trace_turbo_scheduler) {
Trace("roots: ");
- for (NodeVectorIter i = schedule_root_nodes_.begin();
- i != schedule_root_nodes_.end(); ++i) {
- Trace("#%d:%s ", (*i)->id(), (*i)->op()->mnemonic());
+ for (Node* node : schedule_root_nodes_) {
+ Trace("#%d:%s ", node->id(), node->op()->mnemonic());
}
Trace("\n");
}
@@ -1312,15 +1386,29 @@ void Scheduler::ScheduleLate() {
// Schedule: Places nodes in dominator block of all their uses.
ScheduleLateNodeVisitor schedule_late_visitor(zone_, this);
schedule_late_visitor.Run(&schedule_root_nodes_);
+}
+
+
+// -----------------------------------------------------------------------------
+// Phase 6: Seal the final schedule.
+
+
+void Scheduler::SealFinalSchedule() {
+ Trace("--- SEAL FINAL SCHEDULE ------------------------------------\n");
+
+ // Serialize the assembly order and reverse-post-order numbering.
+ special_rpo_->SerializeAOIntoSchedule();
+ special_rpo_->SerializeRPOIntoSchedule();
+ special_rpo_->PrintAndVerifySpecialRPO();
// Add collected nodes for basic blocks to their blocks in the right order.
int block_num = 0;
- for (NodeVectorVectorIter i = scheduled_nodes_.begin();
- i != scheduled_nodes_.end(); ++i) {
- for (NodeVectorRIter j = i->rbegin(); j != i->rend(); ++j) {
- schedule_->AddNode(schedule_->all_blocks_.at(block_num), *j);
+ for (NodeVector& nodes : scheduled_nodes_) {
+ BasicBlock::Id id = BasicBlock::Id::FromInt(block_num++);
+ BasicBlock* block = schedule_->GetBlockById(id);
+ for (NodeVectorRIter i = nodes.rbegin(); i != nodes.rend(); ++i) {
+ schedule_->AddNode(block, *i);
}
- block_num++;
}
}
@@ -1341,27 +1429,22 @@ void Scheduler::FuseFloatingControl(BasicBlock* block, Node* node) {
// Iterate on phase 2: Compute special RPO and dominator tree.
// TODO(mstarzinger): Currently "iterate on" means "re-run". Fix that.
- BasicBlockVector* rpo = schedule_->rpo_order();
- for (BasicBlockVectorIter i = rpo->begin(); i != rpo->end(); ++i) {
- BasicBlock* block = *i;
+ for (BasicBlock* block : schedule_->all_blocks_) {
block->set_rpo_number(-1);
- block->set_loop_header(NULL);
- block->set_loop_depth(0);
- block->set_loop_end(-1);
+ block->set_dominator_depth(-1);
+ block->set_dominator(NULL);
}
- schedule_->rpo_order()->clear();
- SpecialRPONumberer numberer(zone_, schedule_);
- numberer.ComputeSpecialRPO();
+ special_rpo_->UpdateSpecialRPO(block, schedule_->block(node));
GenerateImmediateDominatorTree();
- scheduled_nodes_.resize(schedule_->BasicBlockCount(), NodeVector(zone_));
// Move previously planned nodes.
// TODO(mstarzinger): Improve that by supporting bulk moves.
+ scheduled_nodes_.resize(schedule_->BasicBlockCount(), NodeVector(zone_));
MovePlannedNodes(block, schedule_->block(node));
if (FLAG_trace_turbo_scheduler) {
OFStream os(stdout);
- os << "Schedule after control flow fusion:" << *schedule_;
+ os << "Schedule after control flow fusion:\n" << *schedule_;
}
}
diff --git a/src/compiler/scheduler.h b/src/compiler/scheduler.h
index b73d1bb19..2839a0cb7 100644
--- a/src/compiler/scheduler.h
+++ b/src/compiler/scheduler.h
@@ -16,6 +16,8 @@ namespace v8 {
namespace internal {
namespace compiler {
+class SpecialRPONumberer;
+
// Computes a schedule from a graph, placing nodes into basic blocks and
// ordering the basic blocks in the special RPO order.
class Scheduler {
@@ -60,6 +62,7 @@ class Scheduler {
NodeVector schedule_root_nodes_; // Fixed root nodes seed the worklist.
ZoneQueue<Node*> schedule_queue_; // Worklist of schedulable nodes.
ZoneVector<SchedulerData> node_data_; // Per-node data for all nodes.
+ SpecialRPONumberer* special_rpo_; // Special RPO numbering of blocks.
Scheduler(Zone* zone, Graph* graph, Schedule* schedule);
@@ -73,7 +76,6 @@ class Scheduler {
void IncrementUnscheduledUseCount(Node* node, int index, Node* from);
void DecrementUnscheduledUseCount(Node* node, int index, Node* from);
- inline int GetRPONumber(BasicBlock* block);
BasicBlock* GetCommonDominator(BasicBlock* b1, BasicBlock* b2);
// Phase 1: Build control-flow graph.
@@ -97,6 +99,9 @@ class Scheduler {
friend class ScheduleLateNodeVisitor;
void ScheduleLate();
+ // Phase 6: Seal the final schedule.
+ void SealFinalSchedule();
+
void FuseFloatingControl(BasicBlock* block, Node* node);
void MovePlannedNodes(BasicBlock* from, BasicBlock* to);
};
diff --git a/src/debug-debugger.js b/src/debug-debugger.js
index a1468a02b..fc4c5da5b 100644
--- a/src/debug-debugger.js
+++ b/src/debug-debugger.js
@@ -33,7 +33,8 @@ Debug.StepAction = { StepOut: 0,
StepNext: 1,
StepIn: 2,
StepMin: 3,
- StepInMin: 4 };
+ StepInMin: 4,
+ StepFrame: 5 };
// The different types of scripts matching enum ScriptType in objects.h.
Debug.ScriptType = { Native: 0,
diff --git a/src/debug.cc b/src/debug.cc
index 841b6cfa8..7fe9064e9 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -120,21 +120,37 @@ void BreakLocationIterator::Next() {
DCHECK(statement_position_ >= 0);
}
- if (IsDebugBreakSlot()) {
- // There is always a possible break point at a debug break slot.
+ // Check for break at return.
+ if (RelocInfo::IsJSReturn(rmode())) {
+ // Set the positions to the end of the function.
+ if (debug_info_->shared()->HasSourceCode()) {
+ position_ = debug_info_->shared()->end_position() -
+ debug_info_->shared()->start_position() - 1;
+ } else {
+ position_ = 0;
+ }
+ statement_position_ = position_;
break_point_++;
return;
- } else if (RelocInfo::IsCodeTarget(rmode())) {
+ }
+
+ if (RelocInfo::IsCodeTarget(rmode())) {
// Check for breakable code target. Look in the original code as setting
// break points can cause the code targets in the running (debugged) code
// to be of a different kind than in the original code.
Address target = original_rinfo()->target_address();
Code* code = Code::GetCodeFromTargetAddress(target);
- if ((code->is_inline_cache_stub() &&
- !code->is_binary_op_stub() &&
- !code->is_compare_ic_stub() &&
- !code->is_to_boolean_ic_stub()) ||
- RelocInfo::IsConstructCall(rmode())) {
+
+ if (RelocInfo::IsConstructCall(rmode()) || code->is_call_stub()) {
+ break_point_++;
+ return;
+ }
+
+ // Skip below if we only want locations for calls and returns.
+ if (type_ == CALLS_AND_RETURNS) continue;
+
+ if ((code->is_inline_cache_stub() && !code->is_binary_op_stub() &&
+ !code->is_compare_ic_stub() && !code->is_to_boolean_ic_stub())) {
break_point_++;
return;
}
@@ -157,16 +173,8 @@ void BreakLocationIterator::Next() {
}
}
- // Check for break at return.
- if (RelocInfo::IsJSReturn(rmode())) {
- // Set the positions to the end of the function.
- if (debug_info_->shared()->HasSourceCode()) {
- position_ = debug_info_->shared()->end_position() -
- debug_info_->shared()->start_position() - 1;
- } else {
- position_ = 0;
- }
- statement_position_ = position_;
+ if (IsDebugBreakSlot() && type_ != CALLS_AND_RETURNS) {
+ // There is always a possible break point at a debug break slot.
break_point_++;
return;
}
@@ -1189,7 +1197,8 @@ void Debug::ClearAllBreakPoints() {
}
-void Debug::FloodWithOneShot(Handle<JSFunction> function) {
+void Debug::FloodWithOneShot(Handle<JSFunction> function,
+ BreakLocatorType type) {
PrepareForBreakPoints();
// Make sure the function is compiled and has set up the debug info.
@@ -1200,7 +1209,7 @@ void Debug::FloodWithOneShot(Handle<JSFunction> function) {
}
// Flood the function with break points.
- BreakLocationIterator it(GetDebugInfo(shared), ALL_BREAK_LOCATIONS);
+ BreakLocationIterator it(GetDebugInfo(shared), type);
while (!it.Done()) {
it.SetOneShot();
it.Next();
@@ -1216,7 +1225,7 @@ void Debug::FloodBoundFunctionWithOneShot(Handle<JSFunction> function) {
if (!bindee.is_null() && bindee->IsJSFunction() &&
!JSFunction::cast(*bindee)->IsFromNativeScript()) {
Handle<JSFunction> bindee_function(JSFunction::cast(*bindee));
- Debug::FloodWithOneShot(bindee_function);
+ FloodWithOneShot(bindee_function);
}
}
@@ -1296,7 +1305,7 @@ void Debug::PrepareStep(StepAction step_action,
FloodHandlerWithOneShot();
// If the function on the top frame is unresolved perform step out. This will
- // be the case when calling unknown functions and having the debugger stopped
+ // be the case when calling unknown function and having the debugger stopped
// in an unhandled exception.
if (!frame->function()->IsJSFunction()) {
// Step out: Find the calling JavaScript frame and flood it with
@@ -1354,7 +1363,7 @@ void Debug::PrepareStep(StepAction step_action,
if ((maybe_call_function_stub->kind() == Code::STUB &&
CodeStub::GetMajorKey(maybe_call_function_stub) ==
CodeStub::CallFunction) ||
- maybe_call_function_stub->kind() == Code::CALL_IC) {
+ maybe_call_function_stub->is_call_stub()) {
// Save reference to the code as we may need it to find out arguments
// count for 'step in' later.
call_function_stub = Handle<Code>(maybe_call_function_stub);
@@ -1395,7 +1404,9 @@ void Debug::PrepareStep(StepAction step_action,
// Step next or step min.
// Fill the current function with one-shot break points.
- FloodWithOneShot(function);
+ // If we are stepping into another frame, only fill calls and returns.
+ FloodWithOneShot(function, step_action == StepFrame ? CALLS_AND_RETURNS
+ : ALL_BREAK_LOCATIONS);
// Remember source position and frame to handle step next.
thread_local_.last_statement_position_ =
@@ -1454,7 +1465,7 @@ void Debug::PrepareStep(StepAction step_action,
if (fun->IsJSFunction()) {
Handle<JSFunction> js_function(JSFunction::cast(fun));
if (js_function->shared()->bound()) {
- Debug::FloodBoundFunctionWithOneShot(js_function);
+ FloodBoundFunctionWithOneShot(js_function);
} else if (!js_function->IsFromNativeScript()) {
// Don't step into builtins.
// It will also compile target function if it's not compiled yet.
@@ -1467,7 +1478,9 @@ void Debug::PrepareStep(StepAction step_action,
// a call target as the function called might be a native function for
// which step in will not stop. It also prepares for stepping in
// getters/setters.
- FloodWithOneShot(function);
+ // If we are stepping into another frame, only fill calls and returns.
+ FloodWithOneShot(function, step_action == StepFrame ? CALLS_AND_RETURNS
+ : ALL_BREAK_LOCATIONS);
if (is_load_or_store) {
// Remember source position and frame to handle step in getter/setter. If
@@ -1496,15 +1509,20 @@ bool Debug::StepNextContinue(BreakLocationIterator* break_location_iterator,
JavaScriptFrame* frame) {
// StepNext and StepOut shouldn't bring us deeper in code, so last frame
// shouldn't be a parent of current frame.
- if (thread_local_.last_step_action_ == StepNext ||
- thread_local_.last_step_action_ == StepOut) {
+ StepAction step_action = thread_local_.last_step_action_;
+
+ if (step_action == StepNext || step_action == StepOut) {
if (frame->fp() < thread_local_.last_fp_) return true;
}
+ // We stepped into a new frame if the frame pointer changed.
+ if (step_action == StepFrame) {
+ return frame->UnpaddedFP() == thread_local_.last_fp_;
+ }
+
// If the step last action was step next or step in make sure that a new
// statement is hit.
- if (thread_local_.last_step_action_ == StepNext ||
- thread_local_.last_step_action_ == StepIn) {
+ if (step_action == StepNext || step_action == StepIn) {
// Never continue if returning from function.
if (break_location_iterator->IsExit()) return false;
@@ -1571,10 +1589,13 @@ Handle<Object> Debug::GetSourceBreakLocations(
// Handle stepping into a function.
-void Debug::HandleStepIn(Handle<JSFunction> function,
- Handle<Object> holder,
- Address fp,
- bool is_constructor) {
+void Debug::HandleStepIn(Handle<Object> function_obj, Handle<Object> holder,
+ Address fp, bool is_constructor) {
+ // Flood getter/setter if we either step in or step to another frame.
+ bool step_frame = thread_local_.last_step_action_ == StepFrame;
+ if (!StepInActive() && !step_frame) return;
+ if (!function_obj->IsJSFunction()) return;
+ Handle<JSFunction> function = Handle<JSFunction>::cast(function_obj);
Isolate* isolate = function->GetIsolate();
// If the frame pointer is not supplied by the caller find it.
if (fp == 0) {
@@ -1589,11 +1610,11 @@ void Debug::HandleStepIn(Handle<JSFunction> function,
}
// Flood the function with one-shot break points if it is called from where
- // step into was requested.
- if (fp == thread_local_.step_into_fp_) {
+ // step into was requested, or when stepping into a new frame.
+ if (fp == thread_local_.step_into_fp_ || step_frame) {
if (function->shared()->bound()) {
// Handle Function.prototype.bind
- Debug::FloodBoundFunctionWithOneShot(function);
+ FloodBoundFunctionWithOneShot(function);
} else if (!function->IsFromNativeScript()) {
// Don't allow step into functions in the native context.
if (function->shared()->code() ==
@@ -1607,14 +1628,14 @@ void Debug::HandleStepIn(Handle<JSFunction> function,
if (!holder.is_null() && holder->IsJSFunction()) {
Handle<JSFunction> js_function = Handle<JSFunction>::cast(holder);
if (!js_function->IsFromNativeScript()) {
- Debug::FloodWithOneShot(js_function);
+ FloodWithOneShot(js_function);
} else if (js_function->shared()->bound()) {
// Handle Function.prototype.bind
- Debug::FloodBoundFunctionWithOneShot(js_function);
+ FloodBoundFunctionWithOneShot(js_function);
}
}
} else {
- Debug::FloodWithOneShot(function);
+ FloodWithOneShot(function);
}
}
}
diff --git a/src/debug.h b/src/debug.h
index 2afe0f621..e486d9780 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -32,13 +32,14 @@ class DebugScope;
// Step actions. NOTE: These values are in macros.py as well.
enum StepAction {
StepNone = -1, // Stepping not prepared.
- StepOut = 0, // Step out of the current function.
- StepNext = 1, // Step to the next statement in the current function.
- StepIn = 2, // Step into new functions invoked or the next statement
- // in the current function.
- StepMin = 3, // Perform a minimum step in the current function.
- StepInMin = 4 // Step into new functions invoked or perform a minimum step
- // in the current function.
+ StepOut = 0, // Step out of the current function.
+ StepNext = 1, // Step to the next statement in the current function.
+ StepIn = 2, // Step into new functions invoked or the next statement
+ // in the current function.
+ StepMin = 3, // Perform a minimum step in the current function.
+ StepInMin = 4, // Step into new functions invoked or perform a minimum step
+ // in the current function.
+ StepFrame = 5 // Step into a new frame or return to previous frame.
};
@@ -49,10 +50,11 @@ enum ExceptionBreakType {
};
-// Type of exception break. NOTE: These values are in macros.py as well.
+// Type of exception break.
enum BreakLocatorType {
ALL_BREAK_LOCATIONS = 0,
- SOURCE_BREAK_LOCATIONS = 1
+ SOURCE_BREAK_LOCATIONS = 1,
+ CALLS_AND_RETURNS = 2
};
@@ -385,7 +387,8 @@ class Debug {
BreakPositionAlignment alignment);
void ClearBreakPoint(Handle<Object> break_point_object);
void ClearAllBreakPoints();
- void FloodWithOneShot(Handle<JSFunction> function);
+ void FloodWithOneShot(Handle<JSFunction> function,
+ BreakLocatorType type = ALL_BREAK_LOCATIONS);
void FloodBoundFunctionWithOneShot(Handle<JSFunction> function);
void FloodHandlerWithOneShot();
void ChangeBreakOnException(ExceptionBreakType type, bool enable);
@@ -401,10 +404,8 @@ class Debug {
bool StepNextContinue(BreakLocationIterator* break_location_iterator,
JavaScriptFrame* frame);
bool StepInActive() { return thread_local_.step_into_fp_ != 0; }
- void HandleStepIn(Handle<JSFunction> function,
- Handle<Object> holder,
- Address fp,
- bool is_constructor);
+ void HandleStepIn(Handle<Object> function_obj, Handle<Object> holder,
+ Address fp, bool is_constructor);
bool StepOutActive() { return thread_local_.step_out_fp_ != 0; }
// Purge all code objects that have no debug break slots.
@@ -623,7 +624,7 @@ class Debug {
// Number of steps left to perform before debug event.
int step_count_;
- // Frame pointer from last step next action.
+ // Frame pointer from last step next or step frame action.
Address last_fp_;
// Number of queued steps left to perform before debug event.
diff --git a/src/globals.h b/src/globals.h
index ae7903826..c6ba010fc 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -26,8 +26,8 @@
# define V8_INFINITY INFINITY
#endif
-#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM || \
- V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS
+#if V8_TARGET_ARCH_IA32 || (V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_32_BIT) || \
+ V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS
#define V8_TURBOFAN_BACKEND 1
#else
#define V8_TURBOFAN_BACKEND 0
@@ -354,6 +354,7 @@ template <typename Config, class Allocator = FreeStoreAllocationPolicy>
class String;
class Name;
class Struct;
+class Symbol;
class Variable;
class RelocInfo;
class Deserializer;
diff --git a/src/heap-snapshot-generator-inl.h b/src/heap-snapshot-generator-inl.h
index 3f7e62216..ad95776cb 100644
--- a/src/heap-snapshot-generator-inl.h
+++ b/src/heap-snapshot-generator-inl.h
@@ -12,7 +12,7 @@ namespace internal {
HeapEntry* HeapGraphEdge::from() const {
- return &snapshot()->entries()[from_index_];
+ return &snapshot()->entries()[from_index()];
}
diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc
index 68522fcce..7f217bb8d 100644
--- a/src/heap-snapshot-generator.cc
+++ b/src/heap-snapshot-generator.cc
@@ -18,8 +18,7 @@ namespace internal {
HeapGraphEdge::HeapGraphEdge(Type type, const char* name, int from, int to)
- : type_(type),
- from_index_(from),
+ : bit_field_(TypeField::encode(type) | FromIndexField::encode(from)),
to_index_(to),
name_(name) {
DCHECK(type == kContextVariable
@@ -31,8 +30,7 @@ HeapGraphEdge::HeapGraphEdge(Type type, const char* name, int from, int to)
HeapGraphEdge::HeapGraphEdge(Type type, int index, int from, int to)
- : type_(type),
- from_index_(from),
+ : bit_field_(TypeField::encode(type) | FromIndexField::encode(from)),
to_index_(to),
index_(index) {
DCHECK(type == kElement || type == kHidden);
diff --git a/src/heap-snapshot-generator.h b/src/heap-snapshot-generator.h
index 646d49708..fb4387617 100644
--- a/src/heap-snapshot-generator.h
+++ b/src/heap-snapshot-generator.h
@@ -28,22 +28,18 @@ class HeapGraphEdge BASE_EMBEDDED {
kWeak = v8::HeapGraphEdge::kWeak
};
- HeapGraphEdge() { }
HeapGraphEdge(Type type, const char* name, int from, int to);
HeapGraphEdge(Type type, int index, int from, int to);
void ReplaceToIndexWithEntry(HeapSnapshot* snapshot);
- Type type() const { return static_cast<Type>(type_); }
+ Type type() const { return TypeField::decode(bit_field_); }
int index() const {
- DCHECK(type_ == kElement || type_ == kHidden);
+ DCHECK(type() == kElement || type() == kHidden);
return index_;
}
const char* name() const {
- DCHECK(type_ == kContextVariable
- || type_ == kProperty
- || type_ == kInternal
- || type_ == kShortcut
- || type_ == kWeak);
+ DCHECK(type() == kContextVariable || type() == kProperty ||
+ type() == kInternal || type() == kShortcut || type() == kWeak);
return name_;
}
INLINE(HeapEntry* from() const);
@@ -51,9 +47,11 @@ class HeapGraphEdge BASE_EMBEDDED {
private:
INLINE(HeapSnapshot* snapshot() const);
+ int from_index() const { return FromIndexField::decode(bit_field_); }
- unsigned type_ : 3;
- int from_index_ : 29;
+ class TypeField : public BitField<Type, 0, 3> {};
+ class FromIndexField : public BitField<int, 3, 29> {};
+ uint32_t bit_field_;
union {
// During entries population |to_index_| is used for storing the index,
// afterwards it is replaced with a pointer to the entry.
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 5c8cd4528..c4eed9ce2 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -2038,7 +2038,17 @@ class ScavengingVisitor : public StaticVisitorBase {
// Order is important: slot might be inside of the target if target
// was allocated over a dead object and slot comes from the store
// buffer.
- *slot = target;
+
+ // Unfortunately, the allocation can also write over the slot if the slot
+ // was in free space and the allocation wrote free list data (such as the
+ // free list map or entry size) over the slot. We guard against this by
+ // checking that the slot still points to the object being moved. This
+ // should be sufficient because neither the free list map nor the free
+ // list entry size should look like a new space pointer (the former is an
+ // old space pointer, the latter is word-aligned).
+ if (*slot == object) {
+ *slot = target;
+ }
MigrateObject(heap, object, target, object_size);
if (object_contents == POINTER_OBJECT) {
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 188119d66..ce76fbeca 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -1789,7 +1789,7 @@ Range* HChange::InferRange(Zone* zone) {
Range* HConstant::InferRange(Zone* zone) {
- if (has_int32_value_) {
+ if (HasInteger32Value()) {
Range* result = new(zone) Range(int32_value_, int32_value_);
result->set_can_be_minus_zero(false);
return result;
@@ -2606,7 +2606,7 @@ std::ostream& HSimulate::PrintDataTo(std::ostream& os) const { // NOLINT
void HSimulate::ReplayEnvironment(HEnvironment* env) {
- if (done_with_replay_) return;
+ if (is_done_with_replay()) return;
DCHECK(env != NULL);
env->set_ast_id(ast_id());
env->Drop(pop_count());
@@ -2618,7 +2618,7 @@ void HSimulate::ReplayEnvironment(HEnvironment* env) {
env->Push(value);
}
}
- done_with_replay_ = true;
+ set_done_with_replay();
}
@@ -2674,36 +2674,41 @@ static bool IsInteger32(double value) {
HConstant::HConstant(Handle<Object> object, Representation r)
- : HTemplateInstruction<0>(HType::FromValue(object)),
- object_(Unique<Object>::CreateUninitialized(object)),
- object_map_(Handle<Map>::null()),
- has_stable_map_value_(false),
- has_smi_value_(false),
- has_int32_value_(false),
- has_double_value_(false),
- has_external_reference_value_(false),
- is_not_in_new_space_(true),
- boolean_value_(object->BooleanValue()),
- is_undetectable_(false),
- instance_type_(kUnknownInstanceType) {
+ : HTemplateInstruction<0>(HType::FromValue(object)),
+ object_(Unique<Object>::CreateUninitialized(object)),
+ object_map_(Handle<Map>::null()),
+ bit_field_(HasStableMapValueField::encode(false) |
+ HasSmiValueField::encode(false) |
+ HasInt32ValueField::encode(false) |
+ HasDoubleValueField::encode(false) |
+ HasExternalReferenceValueField::encode(false) |
+ IsNotInNewSpaceField::encode(true) |
+ BooleanValueField::encode(object->BooleanValue()) |
+ IsUndetectableField::encode(false) |
+ InstanceTypeField::encode(kUnknownInstanceType)) {
if (object->IsHeapObject()) {
Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object);
Isolate* isolate = heap_object->GetIsolate();
Handle<Map> map(heap_object->map(), isolate);
- is_not_in_new_space_ = !isolate->heap()->InNewSpace(*object);
- instance_type_ = map->instance_type();
- is_undetectable_ = map->is_undetectable();
+ bit_field_ = IsNotInNewSpaceField::update(
+ bit_field_, !isolate->heap()->InNewSpace(*object));
+ bit_field_ = InstanceTypeField::update(bit_field_, map->instance_type());
+ bit_field_ =
+ IsUndetectableField::update(bit_field_, map->is_undetectable());
if (map->is_stable()) object_map_ = Unique<Map>::CreateImmovable(map);
- has_stable_map_value_ = (instance_type_ == MAP_TYPE &&
- Handle<Map>::cast(heap_object)->is_stable());
+ bit_field_ = HasStableMapValueField::update(
+ bit_field_,
+ HasMapValue() && Handle<Map>::cast(heap_object)->is_stable());
}
if (object->IsNumber()) {
double n = object->Number();
- has_int32_value_ = IsInteger32(n);
+ bool has_int32_value = IsInteger32(n);
+ bit_field_ = HasInt32ValueField::update(bit_field_, has_int32_value);
int32_value_ = DoubleToInt32(n);
- has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
+ bit_field_ = HasSmiValueField::update(
+ bit_field_, has_int32_value && Smi::IsValid(int32_value_));
double_value_ = n;
- has_double_value_ = true;
+ bit_field_ = HasDoubleValueField::update(bit_field_, true);
// TODO(titzer): if this heap number is new space, tenure a new one.
}
@@ -2711,112 +2716,104 @@ HConstant::HConstant(Handle<Object> object, Representation r)
}
-HConstant::HConstant(Unique<Object> object,
- Unique<Map> object_map,
- bool has_stable_map_value,
- Representation r,
- HType type,
- bool is_not_in_new_space,
- bool boolean_value,
- bool is_undetectable,
- InstanceType instance_type)
- : HTemplateInstruction<0>(type),
- object_(object),
- object_map_(object_map),
- has_stable_map_value_(has_stable_map_value),
- has_smi_value_(false),
- has_int32_value_(false),
- has_double_value_(false),
- has_external_reference_value_(false),
- is_not_in_new_space_(is_not_in_new_space),
- boolean_value_(boolean_value),
- is_undetectable_(is_undetectable),
- instance_type_(instance_type) {
+HConstant::HConstant(Unique<Object> object, Unique<Map> object_map,
+ bool has_stable_map_value, Representation r, HType type,
+ bool is_not_in_new_space, bool boolean_value,
+ bool is_undetectable, InstanceType instance_type)
+ : HTemplateInstruction<0>(type),
+ object_(object),
+ object_map_(object_map),
+ bit_field_(HasStableMapValueField::encode(has_stable_map_value) |
+ HasSmiValueField::encode(false) |
+ HasInt32ValueField::encode(false) |
+ HasDoubleValueField::encode(false) |
+ HasExternalReferenceValueField::encode(false) |
+ IsNotInNewSpaceField::encode(is_not_in_new_space) |
+ BooleanValueField::encode(boolean_value) |
+ IsUndetectableField::encode(is_undetectable) |
+ InstanceTypeField::encode(instance_type)) {
DCHECK(!object.handle().is_null());
DCHECK(!type.IsTaggedNumber() || type.IsNone());
Initialize(r);
}
-HConstant::HConstant(int32_t integer_value,
- Representation r,
- bool is_not_in_new_space,
- Unique<Object> object)
- : object_(object),
- object_map_(Handle<Map>::null()),
- has_stable_map_value_(false),
- has_smi_value_(Smi::IsValid(integer_value)),
- has_int32_value_(true),
- has_double_value_(true),
- has_external_reference_value_(false),
- is_not_in_new_space_(is_not_in_new_space),
- boolean_value_(integer_value != 0),
- is_undetectable_(false),
- int32_value_(integer_value),
- double_value_(FastI2D(integer_value)),
- instance_type_(kUnknownInstanceType) {
+HConstant::HConstant(int32_t integer_value, Representation r,
+ bool is_not_in_new_space, Unique<Object> object)
+ : object_(object),
+ object_map_(Handle<Map>::null()),
+ bit_field_(HasStableMapValueField::encode(false) |
+ HasSmiValueField::encode(Smi::IsValid(integer_value)) |
+ HasInt32ValueField::encode(true) |
+ HasDoubleValueField::encode(true) |
+ HasExternalReferenceValueField::encode(false) |
+ IsNotInNewSpaceField::encode(is_not_in_new_space) |
+ BooleanValueField::encode(integer_value != 0) |
+ IsUndetectableField::encode(false) |
+ InstanceTypeField::encode(kUnknownInstanceType)),
+ int32_value_(integer_value),
+ double_value_(FastI2D(integer_value)) {
// It's possible to create a constant with a value in Smi-range but stored
// in a (pre-existing) HeapNumber. See crbug.com/349878.
bool could_be_heapobject = r.IsTagged() && !object.handle().is_null();
- bool is_smi = has_smi_value_ && !could_be_heapobject;
+ bool is_smi = HasSmiValue() && !could_be_heapobject;
set_type(is_smi ? HType::Smi() : HType::TaggedNumber());
Initialize(r);
}
-HConstant::HConstant(double double_value,
- Representation r,
- bool is_not_in_new_space,
- Unique<Object> object)
- : object_(object),
- object_map_(Handle<Map>::null()),
- has_stable_map_value_(false),
- has_int32_value_(IsInteger32(double_value)),
- has_double_value_(true),
- has_external_reference_value_(false),
- is_not_in_new_space_(is_not_in_new_space),
- boolean_value_(double_value != 0 && !std::isnan(double_value)),
- is_undetectable_(false),
- int32_value_(DoubleToInt32(double_value)),
- double_value_(double_value),
- instance_type_(kUnknownInstanceType) {
- has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
+HConstant::HConstant(double double_value, Representation r,
+ bool is_not_in_new_space, Unique<Object> object)
+ : object_(object),
+ object_map_(Handle<Map>::null()),
+ bit_field_(HasStableMapValueField::encode(false) |
+ HasInt32ValueField::encode(IsInteger32(double_value)) |
+ HasDoubleValueField::encode(true) |
+ HasExternalReferenceValueField::encode(false) |
+ IsNotInNewSpaceField::encode(is_not_in_new_space) |
+ BooleanValueField::encode(double_value != 0 &&
+ !std::isnan(double_value)) |
+ IsUndetectableField::encode(false) |
+ InstanceTypeField::encode(kUnknownInstanceType)),
+ int32_value_(DoubleToInt32(double_value)),
+ double_value_(double_value) {
+ bit_field_ = HasSmiValueField::update(
+ bit_field_, HasInteger32Value() && Smi::IsValid(int32_value_));
// It's possible to create a constant with a value in Smi-range but stored
// in a (pre-existing) HeapNumber. See crbug.com/349878.
bool could_be_heapobject = r.IsTagged() && !object.handle().is_null();
- bool is_smi = has_smi_value_ && !could_be_heapobject;
+ bool is_smi = HasSmiValue() && !could_be_heapobject;
set_type(is_smi ? HType::Smi() : HType::TaggedNumber());
Initialize(r);
}
HConstant::HConstant(ExternalReference reference)
- : HTemplateInstruction<0>(HType::Any()),
- object_(Unique<Object>(Handle<Object>::null())),
- object_map_(Handle<Map>::null()),
- has_stable_map_value_(false),
- has_smi_value_(false),
- has_int32_value_(false),
- has_double_value_(false),
- has_external_reference_value_(true),
- is_not_in_new_space_(true),
- boolean_value_(true),
- is_undetectable_(false),
- external_reference_value_(reference),
- instance_type_(kUnknownInstanceType) {
+ : HTemplateInstruction<0>(HType::Any()),
+ object_(Unique<Object>(Handle<Object>::null())),
+ object_map_(Handle<Map>::null()),
+ bit_field_(
+ HasStableMapValueField::encode(false) |
+ HasSmiValueField::encode(false) | HasInt32ValueField::encode(false) |
+ HasDoubleValueField::encode(false) |
+ HasExternalReferenceValueField::encode(true) |
+ IsNotInNewSpaceField::encode(true) | BooleanValueField::encode(true) |
+ IsUndetectableField::encode(false) |
+ InstanceTypeField::encode(kUnknownInstanceType)),
+ external_reference_value_(reference) {
Initialize(Representation::External());
}
void HConstant::Initialize(Representation r) {
if (r.IsNone()) {
- if (has_smi_value_ && SmiValuesAre31Bits()) {
+ if (HasSmiValue() && SmiValuesAre31Bits()) {
r = Representation::Smi();
- } else if (has_int32_value_) {
+ } else if (HasInteger32Value()) {
r = Representation::Integer32();
- } else if (has_double_value_) {
+ } else if (HasDoubleValue()) {
r = Representation::Double();
- } else if (has_external_reference_value_) {
+ } else if (HasExternalReferenceValue()) {
r = Representation::External();
} else {
Handle<Object> object = object_.handle();
@@ -2843,16 +2840,16 @@ void HConstant::Initialize(Representation r) {
bool HConstant::ImmortalImmovable() const {
- if (has_int32_value_) {
+ if (HasInteger32Value()) {
return false;
}
- if (has_double_value_) {
+ if (HasDoubleValue()) {
if (IsSpecialDouble()) {
return true;
}
return false;
}
- if (has_external_reference_value_) {
+ if (HasExternalReferenceValue()) {
return false;
}
@@ -2893,44 +2890,35 @@ bool HConstant::EmitAtUses() {
HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const {
- if (r.IsSmi() && !has_smi_value_) return NULL;
- if (r.IsInteger32() && !has_int32_value_) return NULL;
- if (r.IsDouble() && !has_double_value_) return NULL;
- if (r.IsExternal() && !has_external_reference_value_) return NULL;
- if (has_int32_value_) {
- return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, object_);
+ if (r.IsSmi() && !HasSmiValue()) return NULL;
+ if (r.IsInteger32() && !HasInteger32Value()) return NULL;
+ if (r.IsDouble() && !HasDoubleValue()) return NULL;
+ if (r.IsExternal() && !HasExternalReferenceValue()) return NULL;
+ if (HasInteger32Value()) {
+ return new (zone) HConstant(int32_value_, r, NotInNewSpace(), object_);
}
- if (has_double_value_) {
- return new(zone) HConstant(double_value_, r, is_not_in_new_space_, object_);
+ if (HasDoubleValue()) {
+ return new (zone) HConstant(double_value_, r, NotInNewSpace(), object_);
}
- if (has_external_reference_value_) {
+ if (HasExternalReferenceValue()) {
return new(zone) HConstant(external_reference_value_);
}
DCHECK(!object_.handle().is_null());
- return new(zone) HConstant(object_,
- object_map_,
- has_stable_map_value_,
- r,
- type_,
- is_not_in_new_space_,
- boolean_value_,
- is_undetectable_,
- instance_type_);
+ return new (zone) HConstant(object_, object_map_, HasStableMapValue(), r,
+ type_, NotInNewSpace(), BooleanValue(),
+ IsUndetectable(), GetInstanceType());
}
Maybe<HConstant*> HConstant::CopyToTruncatedInt32(Zone* zone) {
HConstant* res = NULL;
- if (has_int32_value_) {
- res = new(zone) HConstant(int32_value_,
- Representation::Integer32(),
- is_not_in_new_space_,
- object_);
- } else if (has_double_value_) {
- res = new(zone) HConstant(DoubleToInt32(double_value_),
- Representation::Integer32(),
- is_not_in_new_space_,
- object_);
+ if (HasInteger32Value()) {
+ res = new (zone) HConstant(int32_value_, Representation::Integer32(),
+ NotInNewSpace(), object_);
+ } else if (HasDoubleValue()) {
+ res = new (zone)
+ HConstant(DoubleToInt32(double_value_), Representation::Integer32(),
+ NotInNewSpace(), object_);
}
return Maybe<HConstant*>(res != NULL, res);
}
@@ -2952,11 +2940,11 @@ Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) {
std::ostream& HConstant::PrintDataTo(std::ostream& os) const { // NOLINT
- if (has_int32_value_) {
+ if (HasInteger32Value()) {
os << int32_value_ << " ";
- } else if (has_double_value_) {
+ } else if (HasDoubleValue()) {
os << double_value_ << " ";
- } else if (has_external_reference_value_) {
+ } else if (HasExternalReferenceValue()) {
os << reinterpret_cast<void*>(external_reference_value_.address()) << " ";
} else {
// The handle() method is silently and lazily mutating the object.
@@ -2965,7 +2953,7 @@ std::ostream& HConstant::PrintDataTo(std::ostream& os) const { // NOLINT
if (HasStableMapValue()) os << "[stable-map] ";
if (HasObjectMap()) os << "[map " << *ObjectMap().handle() << "] ";
}
- if (!is_not_in_new_space_) os << "[new space] ";
+ if (!NotInNewSpace()) os << "[new space] ";
return os;
}
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 810a2fdd5..233ca42f1 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -1497,13 +1497,18 @@ class HCompareMap FINAL : public HUnaryControlInstruction {
virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
static const int kNoKnownSuccessorIndex = -1;
- int known_successor_index() const { return known_successor_index_; }
- void set_known_successor_index(int known_successor_index) {
- known_successor_index_ = known_successor_index;
+ int known_successor_index() const {
+ return KnownSuccessorIndexField::decode(bit_field_) -
+ kInternalKnownSuccessorOffset;
+ }
+ void set_known_successor_index(int index) {
+ DCHECK(index >= 0 - kInternalKnownSuccessorOffset);
+ bit_field_ = KnownSuccessorIndexField::update(
+ bit_field_, index + kInternalKnownSuccessorOffset);
}
Unique<Map> map() const { return map_; }
- bool map_is_stable() const { return map_is_stable_; }
+ bool map_is_stable() const { return MapIsStableField::decode(bit_field_); }
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
return Representation::Tagged();
@@ -1515,19 +1520,25 @@ class HCompareMap FINAL : public HUnaryControlInstruction {
virtual int RedefinedOperandIndex() OVERRIDE { return 0; }
private:
- HCompareMap(HValue* value,
- Handle<Map> map,
- HBasicBlock* true_target = NULL,
+ HCompareMap(HValue* value, Handle<Map> map, HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target),
- known_successor_index_(kNoKnownSuccessorIndex),
- map_is_stable_(map->is_stable()),
+ bit_field_(KnownSuccessorIndexField::encode(
+ kNoKnownSuccessorIndex + kInternalKnownSuccessorOffset) |
+ MapIsStableField::encode(map->is_stable())),
map_(Unique<Map>::CreateImmovable(map)) {
set_representation(Representation::Tagged());
}
- int known_successor_index_ : 31;
- bool map_is_stable_ : 1;
+ // BitFields can only store unsigned values, so use an offset.
+ // Adding kInternalKnownSuccessorOffset must yield an unsigned value.
+ static const int kInternalKnownSuccessorOffset = 1;
+ STATIC_ASSERT(kNoKnownSuccessorIndex + kInternalKnownSuccessorOffset >= 0);
+
+ class KnownSuccessorIndexField : public BitField<int, 0, 31> {};
+ class MapIsStableField : public BitField<bool, 31, 1> {};
+
+ uint32_t bit_field_;
Unique<Map> map_;
};
@@ -1803,17 +1814,15 @@ enum RemovableSimulate {
class HSimulate FINAL : public HInstruction {
public:
- HSimulate(BailoutId ast_id,
- int pop_count,
- Zone* zone,
+ HSimulate(BailoutId ast_id, int pop_count, Zone* zone,
RemovableSimulate removable)
: ast_id_(ast_id),
pop_count_(pop_count),
values_(2, zone),
assigned_indexes_(2, zone),
zone_(zone),
- removable_(removable),
- done_with_replay_(false) {}
+ bit_field_(RemovableField::encode(removable) |
+ DoneWithReplayField::encode(false)) {}
~HSimulate() {}
virtual std::ostream& PrintDataTo(std::ostream& os) const OVERRIDE; // NOLINT
@@ -1857,7 +1866,9 @@ class HSimulate FINAL : public HInstruction {
}
void MergeWith(ZoneList<HSimulate*>* list);
- bool is_candidate_for_removal() { return removable_ == REMOVABLE_SIMULATE; }
+ bool is_candidate_for_removal() {
+ return RemovableField::decode(bit_field_) == REMOVABLE_SIMULATE;
+ }
// Replay effects of this instruction on the given environment.
void ReplayEnvironment(HEnvironment* env);
@@ -1891,13 +1902,22 @@ class HSimulate FINAL : public HInstruction {
}
return false;
}
+ bool is_done_with_replay() const {
+ return DoneWithReplayField::decode(bit_field_);
+ }
+ void set_done_with_replay() {
+ bit_field_ = DoneWithReplayField::update(bit_field_, true);
+ }
+
+ class RemovableField : public BitField<RemovableSimulate, 0, 1> {};
+ class DoneWithReplayField : public BitField<bool, 1, 1> {};
+
BailoutId ast_id_;
int pop_count_;
ZoneList<HValue*> values_;
ZoneList<int> assigned_indexes_;
Zone* zone_;
- RemovableSimulate removable_ : 2;
- bool done_with_replay_ : 1;
+ uint32_t bit_field_;
#ifdef DEBUG
Handle<JSFunction> closure_;
@@ -2742,11 +2762,13 @@ class HCheckMaps FINAL : public HTemplateInstruction<2> {
return new(zone) HCheckMaps(value, maps, typecheck);
}
- bool IsStabilityCheck() const { return is_stability_check_; }
+ bool IsStabilityCheck() const {
+ return IsStabilityCheckField::decode(bit_field_);
+ }
void MarkAsStabilityCheck() {
- maps_are_stable_ = true;
- has_migration_target_ = false;
- is_stability_check_ = true;
+ bit_field_ = MapsAreStableField::encode(true) |
+ HasMigrationTargetField::encode(false) |
+ IsStabilityCheckField::encode(true);
ClearChangesFlag(kNewSpacePromotion);
ClearDependsOnFlag(kElementsKind);
ClearDependsOnFlag(kMaps);
@@ -2770,9 +2792,13 @@ class HCheckMaps FINAL : public HTemplateInstruction<2> {
const UniqueSet<Map>* maps() const { return maps_; }
void set_maps(const UniqueSet<Map>* maps) { maps_ = maps; }
- bool maps_are_stable() const { return maps_are_stable_; }
+ bool maps_are_stable() const {
+ return MapsAreStableField::decode(bit_field_);
+ }
- bool HasMigrationTarget() const { return has_migration_target_; }
+ bool HasMigrationTarget() const {
+ return HasMigrationTargetField::decode(bit_field_);
+ }
virtual HValue* Canonicalize() OVERRIDE;
@@ -2804,9 +2830,11 @@ class HCheckMaps FINAL : public HTemplateInstruction<2> {
private:
HCheckMaps(HValue* value, const UniqueSet<Map>* maps, bool maps_are_stable)
- : HTemplateInstruction<2>(HType::HeapObject()), maps_(maps),
- has_migration_target_(false), is_stability_check_(false),
- maps_are_stable_(maps_are_stable) {
+ : HTemplateInstruction<2>(HType::HeapObject()),
+ maps_(maps),
+ bit_field_(HasMigrationTargetField::encode(false) |
+ IsStabilityCheckField::encode(false) |
+ MapsAreStableField::encode(maps_are_stable)) {
DCHECK_NE(0, maps->size());
SetOperandAt(0, value);
// Use the object value for the dependency.
@@ -2818,9 +2846,11 @@ class HCheckMaps FINAL : public HTemplateInstruction<2> {
}
HCheckMaps(HValue* value, const UniqueSet<Map>* maps, HValue* typecheck)
- : HTemplateInstruction<2>(HType::HeapObject()), maps_(maps),
- has_migration_target_(false), is_stability_check_(false),
- maps_are_stable_(true) {
+ : HTemplateInstruction<2>(HType::HeapObject()),
+ maps_(maps),
+ bit_field_(HasMigrationTargetField::encode(false) |
+ IsStabilityCheckField::encode(false) |
+ MapsAreStableField::encode(true)) {
DCHECK_NE(0, maps->size());
SetOperandAt(0, value);
// Use the object value for the dependency if NULL is passed.
@@ -2831,16 +2861,22 @@ class HCheckMaps FINAL : public HTemplateInstruction<2> {
SetDependsOnFlag(kElementsKind);
for (int i = 0; i < maps->size(); ++i) {
Handle<Map> map = maps->at(i).handle();
- if (map->is_migration_target()) has_migration_target_ = true;
- if (!map->is_stable()) maps_are_stable_ = false;
+ if (map->is_migration_target()) {
+ bit_field_ = HasMigrationTargetField::update(bit_field_, true);
+ }
+ if (!map->is_stable()) {
+ bit_field_ = MapsAreStableField::update(bit_field_, false);
+ }
}
- if (has_migration_target_) SetChangesFlag(kNewSpacePromotion);
+ if (HasMigrationTarget()) SetChangesFlag(kNewSpacePromotion);
}
+ class HasMigrationTargetField : public BitField<bool, 0, 1> {};
+ class IsStabilityCheckField : public BitField<bool, 1, 1> {};
+ class MapsAreStableField : public BitField<bool, 2, 1> {};
+
const UniqueSet<Map>* maps_;
- bool has_migration_target_ : 1;
- bool is_stability_check_ : 1;
- bool maps_are_stable_ : 1;
+ uint32_t bit_field_;
};
@@ -3537,29 +3573,26 @@ class HConstant FINAL : public HTemplateInstruction<0> {
isolate->factory()->NewNumber(double_value_, TENURED));
}
AllowDeferredHandleDereference smi_check;
- DCHECK(has_int32_value_ || !object_.handle()->IsSmi());
+ DCHECK(HasInteger32Value() || !object_.handle()->IsSmi());
return object_.handle();
}
bool IsSpecialDouble() const {
- return has_double_value_ &&
+ return HasDoubleValue() &&
(bit_cast<int64_t>(double_value_) == bit_cast<int64_t>(-0.0) ||
FixedDoubleArray::is_the_hole_nan(double_value_) ||
std::isnan(double_value_));
}
bool NotInNewSpace() const {
- return is_not_in_new_space_;
+ return IsNotInNewSpaceField::decode(bit_field_);
}
bool ImmortalImmovable() const;
bool IsCell() const {
- return instance_type_ == CELL_TYPE || instance_type_ == PROPERTY_CELL_TYPE;
- }
-
- bool IsMap() const {
- return instance_type_ == MAP_TYPE;
+ InstanceType instance_type = GetInstanceType();
+ return instance_type == CELL_TYPE || instance_type == PROPERTY_CELL_TYPE;
}
virtual Representation RequiredInputRepresentation(int index) OVERRIDE {
@@ -3579,13 +3612,17 @@ class HConstant FINAL : public HTemplateInstruction<0> {
HConstant* CopyToRepresentation(Representation r, Zone* zone) const;
Maybe<HConstant*> CopyToTruncatedInt32(Zone* zone);
Maybe<HConstant*> CopyToTruncatedNumber(Zone* zone);
- bool HasInteger32Value() const { return has_int32_value_; }
+ bool HasInteger32Value() const {
+ return HasInt32ValueField::decode(bit_field_);
+ }
int32_t Integer32Value() const {
DCHECK(HasInteger32Value());
return int32_value_;
}
- bool HasSmiValue() const { return has_smi_value_; }
- bool HasDoubleValue() const { return has_double_value_; }
+ bool HasSmiValue() const { return HasSmiValueField::decode(bit_field_); }
+ bool HasDoubleValue() const {
+ return HasDoubleValueField::decode(bit_field_);
+ }
double DoubleValue() const {
DCHECK(HasDoubleValue());
return double_value_;
@@ -3597,7 +3634,7 @@ class HConstant FINAL : public HTemplateInstruction<0> {
return object_.IsInitialized() &&
object_.IsKnownGlobal(isolate()->heap()->the_hole_value());
}
- bool HasNumberValue() const { return has_double_value_; }
+ bool HasNumberValue() const { return HasDoubleValue(); }
int32_t NumberValueAsInteger32() const {
DCHECK(HasNumberValue());
// Irrespective of whether a numeric HConstant can be safely
@@ -3606,38 +3643,42 @@ class HConstant FINAL : public HTemplateInstruction<0> {
return int32_value_;
}
bool HasStringValue() const {
- if (has_double_value_ || has_int32_value_) return false;
+ if (HasNumberValue()) return false;
DCHECK(!object_.handle().is_null());
- return instance_type_ < FIRST_NONSTRING_TYPE;
+ return GetInstanceType() < FIRST_NONSTRING_TYPE;
}
Handle<String> StringValue() const {
DCHECK(HasStringValue());
return Handle<String>::cast(object_.handle());
}
bool HasInternalizedStringValue() const {
- return HasStringValue() && StringShape(instance_type_).IsInternalized();
+ return HasStringValue() && StringShape(GetInstanceType()).IsInternalized();
}
bool HasExternalReferenceValue() const {
- return has_external_reference_value_;
+ return HasExternalReferenceValueField::decode(bit_field_);
}
ExternalReference ExternalReferenceValue() const {
return external_reference_value_;
}
bool HasBooleanValue() const { return type_.IsBoolean(); }
- bool BooleanValue() const { return boolean_value_; }
- bool IsUndetectable() const { return is_undetectable_; }
- InstanceType GetInstanceType() const { return instance_type_; }
+ bool BooleanValue() const { return BooleanValueField::decode(bit_field_); }
+ bool IsUndetectable() const {
+ return IsUndetectableField::decode(bit_field_);
+ }
+ InstanceType GetInstanceType() const {
+ return InstanceTypeField::decode(bit_field_);
+ }
- bool HasMapValue() const { return instance_type_ == MAP_TYPE; }
+ bool HasMapValue() const { return GetInstanceType() == MAP_TYPE; }
Unique<Map> MapValue() const {
DCHECK(HasMapValue());
return Unique<Map>::cast(GetUnique());
}
bool HasStableMapValue() const {
- DCHECK(HasMapValue() || !has_stable_map_value_);
- return has_stable_map_value_;
+ DCHECK(HasMapValue() || !HasStableMapValueField::decode(bit_field_));
+ return HasStableMapValueField::decode(bit_field_);
}
bool HasObjectMap() const { return !object_map_.IsNull(); }
@@ -3647,11 +3688,11 @@ class HConstant FINAL : public HTemplateInstruction<0> {
}
virtual intptr_t Hashcode() OVERRIDE {
- if (has_int32_value_) {
+ if (HasInteger32Value()) {
return static_cast<intptr_t>(int32_value_);
- } else if (has_double_value_) {
+ } else if (HasDoubleValue()) {
return static_cast<intptr_t>(bit_cast<int64_t>(double_value_));
- } else if (has_external_reference_value_) {
+ } else if (HasExternalReferenceValue()) {
return reinterpret_cast<intptr_t>(external_reference_value_.address());
} else {
DCHECK(!object_.handle().is_null());
@@ -3660,7 +3701,7 @@ class HConstant FINAL : public HTemplateInstruction<0> {
}
virtual void FinalizeUniqueness() OVERRIDE {
- if (!has_double_value_ && !has_external_reference_value_) {
+ if (!HasDoubleValue() && !HasExternalReferenceValue()) {
DCHECK(!object_.handle().is_null());
object_ = Unique<Object>(object_.handle());
}
@@ -3676,21 +3717,21 @@ class HConstant FINAL : public HTemplateInstruction<0> {
virtual bool DataEquals(HValue* other) OVERRIDE {
HConstant* other_constant = HConstant::cast(other);
- if (has_int32_value_) {
- return other_constant->has_int32_value_ &&
- int32_value_ == other_constant->int32_value_;
- } else if (has_double_value_) {
- return other_constant->has_double_value_ &&
+ if (HasInteger32Value()) {
+ return other_constant->HasInteger32Value() &&
+ int32_value_ == other_constant->int32_value_;
+ } else if (HasDoubleValue()) {
+ return other_constant->HasDoubleValue() &&
bit_cast<int64_t>(double_value_) ==
bit_cast<int64_t>(other_constant->double_value_);
- } else if (has_external_reference_value_) {
- return other_constant->has_external_reference_value_ &&
- external_reference_value_ ==
- other_constant->external_reference_value_;
+ } else if (HasExternalReferenceValue()) {
+ return other_constant->HasExternalReferenceValue() &&
+ external_reference_value_ ==
+ other_constant->external_reference_value_;
} else {
- if (other_constant->has_int32_value_ ||
- other_constant->has_double_value_ ||
- other_constant->has_external_reference_value_) {
+ if (other_constant->HasInteger32Value() ||
+ other_constant->HasDoubleValue() ||
+ other_constant->HasExternalReferenceValue()) {
return false;
}
DCHECK(!object_.handle().is_null());
@@ -3735,6 +3776,25 @@ class HConstant FINAL : public HTemplateInstruction<0> {
virtual bool IsDeletable() const OVERRIDE { return true; }
+ // If object_ is a map, this indicates whether the map is stable.
+ class HasStableMapValueField : public BitField<bool, 0, 1> {};
+
+ // We store the HConstant in the most specific form safely possible.
+ // These flags tell us if the respective member fields hold valid, safe
+ // representations of the constant. More specific flags imply more general
+ // flags, but not the converse (i.e. smi => int32 => double).
+ class HasSmiValueField : public BitField<bool, 1, 1> {};
+ class HasInt32ValueField : public BitField<bool, 2, 1> {};
+ class HasDoubleValueField : public BitField<bool, 3, 1> {};
+
+ class HasExternalReferenceValueField : public BitField<bool, 4, 1> {};
+ class IsNotInNewSpaceField : public BitField<bool, 5, 1> {};
+ class BooleanValueField : public BitField<bool, 6, 1> {};
+ class IsUndetectableField : public BitField<bool, 7, 1> {};
+
+ static const InstanceType kUnknownInstanceType = FILLER_TYPE;
+ class InstanceTypeField : public BitField<InstanceType, 8, 8> {};
+
// If this is a numerical constant, object_ either points to the
// HeapObject the constant originated from or is null. If the
// constant is non-numeric, object_ always points to a valid
@@ -3744,27 +3804,11 @@ class HConstant FINAL : public HTemplateInstruction<0> {
// If object_ is a heap object, this points to the stable map of the object.
Unique<Map> object_map_;
- // If object_ is a map, this indicates whether the map is stable.
- bool has_stable_map_value_ : 1;
+ uint32_t bit_field_;
- // We store the HConstant in the most specific form safely possible.
- // The two flags, has_int32_value_ and has_double_value_ tell us if
- // int32_value_ and double_value_ hold valid, safe representations
- // of the constant. has_int32_value_ implies has_double_value_ but
- // not the converse.
- bool has_smi_value_ : 1;
- bool has_int32_value_ : 1;
- bool has_double_value_ : 1;
- bool has_external_reference_value_ : 1;
- bool is_not_in_new_space_ : 1;
- bool boolean_value_ : 1;
- bool is_undetectable_: 1;
int32_t int32_value_;
double double_value_;
ExternalReference external_reference_value_;
-
- static const InstanceType kUnknownInstanceType = FILLER_TYPE;
- InstanceType instance_type_;
};
@@ -5312,6 +5356,12 @@ class HParameter FINAL : public HTemplateInstruction<0> {
return Representation::None();
}
+ virtual Representation KnownOptimalRepresentation() OVERRIDE {
+ // If a parameter is an input to a phi, that phi should not
+ // choose any more optimistic representation than Tagged.
+ return Representation::Tagged();
+ }
+
DECLARE_CONCRETE_INSTRUCTION(Parameter)
private:
@@ -6739,8 +6789,8 @@ class HLoadKeyed FINAL
kStartIsDehoisted = kStartBaseOffset + kBitsForBaseOffset
};
- STATIC_ASSERT((kBitsForElementsKind + kBitsForBaseOffset +
- kBitsForIsDehoisted) <= sizeof(uint32_t)*8);
+ STATIC_ASSERT((kBitsForElementsKind + kBitsForHoleMode + kBitsForBaseOffset +
+ kBitsForIsDehoisted) <= sizeof(uint32_t) * 8);
STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind));
class ElementsKindField:
public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind>
@@ -6845,7 +6895,8 @@ class HStoreNamedField FINAL : public HTemplateInstruction<3> {
} else if (field_representation().IsDouble()) {
return field_representation();
} else if (field_representation().IsSmi()) {
- if (SmiValuesAre32Bits() && store_mode_ == STORE_TO_INITIALIZED_ENTRY) {
+ if (SmiValuesAre32Bits() &&
+ store_mode() == STORE_TO_INITIALIZED_ENTRY) {
return Representation::Integer32();
}
return field_representation();
@@ -6870,8 +6921,10 @@ class HStoreNamedField FINAL : public HTemplateInstruction<3> {
HObjectAccess access() const { return access_; }
HValue* dominator() const { return dominator_; }
- bool has_transition() const { return has_transition_; }
- StoreFieldOrKeyedMode store_mode() const { return store_mode_; }
+ bool has_transition() const { return HasTransitionField::decode(bit_field_); }
+ StoreFieldOrKeyedMode store_mode() const {
+ return StoreModeField::decode(bit_field_);
+ }
Handle<Map> transition_map() const {
if (has_transition()) {
@@ -6885,7 +6938,7 @@ class HStoreNamedField FINAL : public HTemplateInstruction<3> {
void SetTransition(HConstant* transition) {
DCHECK(!has_transition()); // Only set once.
SetOperandAt(2, transition);
- has_transition_ = true;
+ bit_field_ = HasTransitionField::update(bit_field_, true);
SetChangesFlag(kMaps);
}
@@ -6936,14 +6989,12 @@ class HStoreNamedField FINAL : public HTemplateInstruction<3> {
}
private:
- HStoreNamedField(HValue* obj,
- HObjectAccess access,
- HValue* val,
+ HStoreNamedField(HValue* obj, HObjectAccess access, HValue* val,
StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE)
: access_(access),
dominator_(NULL),
- has_transition_(false),
- store_mode_(store_mode) {
+ bit_field_(HasTransitionField::encode(false) |
+ StoreModeField::encode(store_mode)) {
// Stores to a non existing in-object property are allowed only to the
// newly allocated objects (via HAllocate or HInnerAllocatedObject).
DCHECK(!access.IsInobject() || access.existing_inobject_property() ||
@@ -6954,10 +7005,12 @@ class HStoreNamedField FINAL : public HTemplateInstruction<3> {
access.SetGVNFlags(this, STORE);
}
+ class HasTransitionField : public BitField<bool, 0, 1> {};
+ class StoreModeField : public BitField<StoreFieldOrKeyedMode, 1, 1> {};
+
HObjectAccess access_;
HValue* dominator_;
- bool has_transition_ : 1;
- StoreFieldOrKeyedMode store_mode_ : 1;
+ uint32_t bit_field_;
};
@@ -7024,7 +7077,7 @@ class HStoreKeyed FINAL
}
DCHECK_EQ(index, 2);
- return RequiredValueRepresentation(elements_kind_, store_mode_);
+ return RequiredValueRepresentation(elements_kind(), store_mode());
}
static Representation RequiredValueRepresentation(
@@ -7065,7 +7118,8 @@ class HStoreKeyed FINAL
if (IsUninitialized()) {
return Representation::None();
}
- Representation r = RequiredValueRepresentation(elements_kind_, store_mode_);
+ Representation r =
+ RequiredValueRepresentation(elements_kind(), store_mode());
// For fast object elements kinds, don't assume anything.
if (r.IsTagged()) return Representation::None();
return r;
@@ -7074,22 +7128,26 @@ class HStoreKeyed FINAL
HValue* elements() const { return OperandAt(0); }
HValue* key() const { return OperandAt(1); }
HValue* value() const { return OperandAt(2); }
- bool value_is_smi() const {
- return IsFastSmiElementsKind(elements_kind_);
+ bool value_is_smi() const { return IsFastSmiElementsKind(elements_kind()); }
+ StoreFieldOrKeyedMode store_mode() const {
+ return StoreModeField::decode(bit_field_);
+ }
+ ElementsKind elements_kind() const OVERRIDE {
+ return ElementsKindField::decode(bit_field_);
}
- StoreFieldOrKeyedMode store_mode() const { return store_mode_; }
- ElementsKind elements_kind() const OVERRIDE { return elements_kind_; }
uint32_t base_offset() const { return base_offset_; }
bool TryIncreaseBaseOffset(uint32_t increase_by_value) OVERRIDE;
HValue* GetKey() OVERRIDE { return key(); }
void SetKey(HValue* key) OVERRIDE { SetOperandAt(1, key); }
- bool IsDehoisted() const OVERRIDE { return is_dehoisted_; }
+ bool IsDehoisted() const OVERRIDE {
+ return IsDehoistedField::decode(bit_field_);
+ }
void SetDehoisted(bool is_dehoisted) OVERRIDE {
- is_dehoisted_ = is_dehoisted;
+ bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted);
}
- bool IsUninitialized() { return is_uninitialized_; }
+ bool IsUninitialized() { return IsUninitializedField::decode(bit_field_); }
void SetUninitialized(bool is_uninitialized) {
- is_uninitialized_ = is_uninitialized;
+ bit_field_ = IsUninitializedField::update(bit_field_, is_uninitialized);
}
bool IsConstantHoleStore() {
@@ -7125,18 +7183,17 @@ class HStoreKeyed FINAL
DECLARE_CONCRETE_INSTRUCTION(StoreKeyed)
private:
- HStoreKeyed(HValue* obj, HValue* key, HValue* val,
- ElementsKind elements_kind,
+ HStoreKeyed(HValue* obj, HValue* key, HValue* val, ElementsKind elements_kind,
StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE,
int offset = kDefaultKeyedHeaderOffsetSentinel)
- : elements_kind_(elements_kind),
- base_offset_(offset == kDefaultKeyedHeaderOffsetSentinel
- ? GetDefaultHeaderSizeForElementsKind(elements_kind)
- : offset),
- is_dehoisted_(false),
- is_uninitialized_(false),
- store_mode_(store_mode),
- dominator_(NULL) {
+ : base_offset_(offset == kDefaultKeyedHeaderOffsetSentinel
+ ? GetDefaultHeaderSizeForElementsKind(elements_kind)
+ : offset),
+ bit_field_(IsDehoistedField::encode(false) |
+ IsUninitializedField::encode(false) |
+ StoreModeField::encode(store_mode) |
+ ElementsKindField::encode(elements_kind)),
+ dominator_(NULL) {
SetOperandAt(0, obj);
SetOperandAt(1, key);
SetOperandAt(2, val);
@@ -7168,11 +7225,13 @@ class HStoreKeyed FINAL
}
}
- ElementsKind elements_kind_;
+ class IsDehoistedField : public BitField<bool, 0, 1> {};
+ class IsUninitializedField : public BitField<bool, 1, 1> {};
+ class StoreModeField : public BitField<StoreFieldOrKeyedMode, 2, 1> {};
+ class ElementsKindField : public BitField<ElementsKind, 3, 5> {};
+
uint32_t base_offset_;
- bool is_dehoisted_ : 1;
- bool is_uninitialized_ : 1;
- StoreFieldOrKeyedMode store_mode_: 1;
+ uint32_t bit_field_;
HValue* dominator_;
};
@@ -7496,23 +7555,25 @@ class HFunctionLiteral FINAL : public HTemplateInstruction<1> {
DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral)
Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
- bool pretenure() const { return pretenure_; }
- bool has_no_literals() const { return has_no_literals_; }
- bool is_arrow() const { return IsArrowFunction(kind_); }
- bool is_generator() const { return IsGeneratorFunction(kind_); }
- bool is_concise_method() const { return IsConciseMethod(kind_); }
- FunctionKind kind() const { return kind_; }
- StrictMode strict_mode() const { return strict_mode_; }
+ bool pretenure() const { return PretenureField::decode(bit_field_); }
+ bool has_no_literals() const {
+ return HasNoLiteralsField::decode(bit_field_);
+ }
+ bool is_arrow() const { return IsArrowFunction(kind()); }
+ bool is_generator() const { return IsGeneratorFunction(kind()); }
+ bool is_concise_method() const { return IsConciseMethod(kind()); }
+ FunctionKind kind() const { return FunctionKindField::decode(bit_field_); }
+ StrictMode strict_mode() const { return StrictModeField::decode(bit_field_); }
private:
HFunctionLiteral(HValue* context, Handle<SharedFunctionInfo> shared,
bool pretenure)
: HTemplateInstruction<1>(HType::JSObject()),
shared_info_(shared),
- kind_(shared->kind()),
- pretenure_(pretenure),
- has_no_literals_(shared->num_literals() == 0),
- strict_mode_(shared->strict_mode()) {
+ bit_field_(FunctionKindField::encode(shared->kind()) |
+ PretenureField::encode(pretenure) |
+ HasNoLiteralsField::encode(shared->num_literals() == 0) |
+ StrictModeField::encode(shared->strict_mode())) {
SetOperandAt(0, context);
set_representation(Representation::Tagged());
SetChangesFlag(kNewSpacePromotion);
@@ -7520,11 +7581,13 @@ class HFunctionLiteral FINAL : public HTemplateInstruction<1> {
virtual bool IsDeletable() const OVERRIDE { return true; }
+ class FunctionKindField : public BitField<FunctionKind, 0, 3> {};
+ class PretenureField : public BitField<bool, 3, 1> {};
+ class HasNoLiteralsField : public BitField<bool, 4, 1> {};
+ class StrictModeField : public BitField<StrictMode, 5, 1> {};
+
Handle<SharedFunctionInfo> shared_info_;
- FunctionKind kind_;
- bool pretenure_ : 1;
- bool has_no_literals_ : 1;
- StrictMode strict_mode_;
+ uint32_t bit_field_;
};
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 31fcd4ca4..6184bb9e4 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -6114,7 +6114,7 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::CanAccessMonomorphic() {
if (IsAccessor()) return true;
Handle<Map> map = this->map();
- map->LookupTransition(NULL, *name_, &lookup_);
+ map->LookupTransition(NULL, *name_, NONE, &lookup_);
if (lookup_.IsTransitionToField() && map->unused_property_fields() > 0) {
// Construct the object field access.
int descriptor = transition()->LastAdded();
diff --git a/src/object-observe.js b/src/object-observe.js
index 3af2d5120..01ce8054f 100644
--- a/src/object-observe.js
+++ b/src/object-observe.js
@@ -567,12 +567,11 @@ function CallbackDeliverPending(callback) {
if (!IS_NULL(pendingObservers))
delete pendingObservers[priority];
+ // TODO: combine the following runtime calls for perf optimization.
var delivered = [];
%MoveArrayContents(callbackInfo, delivered);
+ %DeliverObservationChangeRecords(callback, delivered);
- try {
- %_CallFunction(UNDEFINED, delivered, callback);
- } catch (ex) {} // TODO(rossberg): perhaps log uncaught exceptions.
return true;
}
diff --git a/src/objects-debug.cc b/src/objects-debug.cc
index 353cfdaa4..ca649c723 100644
--- a/src/objects-debug.cc
+++ b/src/objects-debug.cc
@@ -1164,15 +1164,13 @@ bool DescriptorArray::IsSortedNoDuplicates(int valid_entries) {
for (int i = 0; i < number_of_descriptors(); i++) {
Name* key = GetSortedKey(i);
if (key == current_key) {
- OFStream os(stdout);
- PrintDescriptors(os);
+ Print();
return false;
}
current_key = key;
uint32_t hash = GetSortedKey(i)->Hash();
if (hash < current) {
- OFStream os(stdout);
- PrintDescriptors(os);
+ Print();
return false;
}
current = hash;
@@ -1183,23 +1181,36 @@ bool DescriptorArray::IsSortedNoDuplicates(int valid_entries) {
bool TransitionArray::IsSortedNoDuplicates(int valid_entries) {
DCHECK(valid_entries == -1);
- Name* current_key = NULL;
- uint32_t current = 0;
+ Name* prev_key = NULL;
+ bool prev_is_data_property = false;
+ PropertyAttributes prev_attributes = NONE;
+ uint32_t prev_hash = 0;
for (int i = 0; i < number_of_transitions(); i++) {
Name* key = GetSortedKey(i);
- if (key == current_key) {
- OFStream os(stdout);
- PrintTransitions(os);
- return false;
+ uint32_t hash = key->Hash();
+ bool is_data_property = false;
+ PropertyAttributes attributes = NONE;
+ if (!IsSpecialTransition(key)) {
+ Map* target = GetTarget(i);
+ PropertyDetails details = GetTargetDetails(key, target);
+ is_data_property = details.type() == FIELD || details.type() == CONSTANT;
+ attributes = details.attributes();
+ } else {
+ // Duplicate entries are not allowed for non-property transitions.
+ CHECK_NE(prev_key, key);
}
- current_key = key;
- uint32_t hash = GetSortedKey(i)->Hash();
- if (hash < current) {
- OFStream os(stdout);
- PrintTransitions(os);
+
+ int cmp =
+ CompareKeys(prev_key, prev_hash, prev_is_data_property, prev_attributes,
+ key, hash, is_data_property, attributes);
+ if (cmp >= 0) {
+ Print();
return false;
}
- current = hash;
+ prev_key = key;
+ prev_hash = hash;
+ prev_attributes = attributes;
+ prev_is_data_property = is_data_property;
}
return true;
}
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 6d0f8d4e6..85584c43e 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1884,11 +1884,10 @@ Handle<Map> Map::FindTransitionToField(Handle<Map> map, Handle<Name> key) {
DisallowHeapAllocation no_allocation;
if (!map->HasTransitionArray()) return Handle<Map>::null();
TransitionArray* transitions = map->transitions();
- int transition = transitions->Search(*key);
+ int transition = transitions->Search(FIELD, *key, NONE);
if (transition == TransitionArray::kNotFound) return Handle<Map>::null();
- PropertyDetails target_details = transitions->GetTargetDetails(transition);
- if (target_details.type() != FIELD) return Handle<Map>::null();
- if (target_details.attributes() != NONE) return Handle<Map>::null();
+ DCHECK_EQ(FIELD, transitions->GetTargetDetails(transition).type());
+ DCHECK_EQ(NONE, transitions->GetTargetDetails(transition).attributes());
return Handle<Map>(transitions->GetTarget(transition));
}
@@ -2943,10 +2942,10 @@ void Map::LookupDescriptor(JSObject* holder,
}
-void Map::LookupTransition(JSObject* holder,
- Name* name,
+void Map::LookupTransition(JSObject* holder, Name* name,
+ PropertyAttributes attributes,
LookupResult* result) {
- int transition_index = this->SearchTransition(name);
+ int transition_index = this->SearchTransition(FIELD, name, attributes);
if (transition_index == TransitionArray::kNotFound) return result->NotFound();
result->TransitionResult(holder, this->GetTransition(transition_index));
}
@@ -4331,8 +4330,10 @@ int HeapObject::SizeFromMap(Map* map) {
}
if (instance_type == ONE_BYTE_STRING_TYPE ||
instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) {
+ // Strings may get concurrently truncated, hence we have to access its
+ // length synchronized.
return SeqOneByteString::SizeFor(
- reinterpret_cast<SeqOneByteString*>(this)->length());
+ reinterpret_cast<SeqOneByteString*>(this)->synchronized_length());
}
if (instance_type == BYTE_ARRAY_TYPE) {
return reinterpret_cast<ByteArray*>(this)->ByteArraySize();
@@ -4342,8 +4343,10 @@ int HeapObject::SizeFromMap(Map* map) {
}
if (instance_type == STRING_TYPE ||
instance_type == INTERNALIZED_STRING_TYPE) {
+ // Strings may get concurrently truncated, hence we have to access its
+ // length synchronized.
return SeqTwoByteString::SizeFor(
- reinterpret_cast<SeqTwoByteString*>(this)->length());
+ reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length());
}
if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
return FixedDoubleArray::SizeFor(
@@ -5217,7 +5220,8 @@ bool Map::HasTransitionArray() const {
Map* Map::elements_transition_map() {
- int index = transitions()->Search(GetHeap()->elements_transition_symbol());
+ int index =
+ transitions()->SearchSpecial(GetHeap()->elements_transition_symbol());
return transitions()->GetTarget(index);
}
@@ -5234,8 +5238,19 @@ Map* Map::GetTransition(int transition_index) {
}
-int Map::SearchTransition(Name* name) {
- if (HasTransitionArray()) return transitions()->Search(name);
+int Map::SearchSpecialTransition(Symbol* name) {
+ if (HasTransitionArray()) {
+ return transitions()->SearchSpecial(name);
+ }
+ return TransitionArray::kNotFound;
+}
+
+
+int Map::SearchTransition(PropertyType type, Name* name,
+ PropertyAttributes attributes) {
+ if (HasTransitionArray()) {
+ return transitions()->Search(type, name, attributes);
+ }
return TransitionArray::kNotFound;
}
@@ -5288,9 +5303,17 @@ void Map::set_transitions(TransitionArray* transition_array,
Map* target = transitions()->GetTarget(i);
if (target->instance_descriptors() == instance_descriptors()) {
Name* key = transitions()->GetKey(i);
- int new_target_index = transition_array->Search(key);
- DCHECK(new_target_index != TransitionArray::kNotFound);
- DCHECK(transition_array->GetTarget(new_target_index) == target);
+ int new_target_index;
+ if (TransitionArray::IsSpecialTransition(key)) {
+ new_target_index = transition_array->SearchSpecial(Symbol::cast(key));
+ } else {
+ PropertyDetails details =
+ TransitionArray::GetTargetDetails(key, target);
+ new_target_index = transition_array->Search(details.type(), key,
+ details.attributes());
+ }
+ DCHECK_NE(TransitionArray::kNotFound, new_target_index);
+ DCHECK_EQ(target, transition_array->GetTarget(new_target_index));
}
}
#endif
diff --git a/src/objects-printer.cc b/src/objects-printer.cc
index cce2b8b28..ba05b474e 100644
--- a/src/objects-printer.cc
+++ b/src/objects-printer.cc
@@ -1090,18 +1090,19 @@ void TransitionArray::PrintTransitions(std::ostream& os,
}
for (int i = 0; i < number_of_transitions(); i++) {
Name* key = GetKey(i);
+ Map* target = GetTarget(i);
os << " ";
key->NamePrint(os);
os << ": ";
if (key == GetHeap()->frozen_symbol()) {
os << " (transition to frozen)";
} else if (key == GetHeap()->elements_transition_symbol()) {
- os << " (transition to "
- << ElementsKindToString(GetTarget(i)->elements_kind()) << ")";
+ os << " (transition to " << ElementsKindToString(target->elements_kind())
+ << ")";
} else if (key == GetHeap()->observed_symbol()) {
os << " (transition to Object.observe)";
} else {
- PropertyDetails details = GetTargetDetails(i);
+ PropertyDetails details = GetTargetDetails(key, target);
switch (details.type()) {
case FIELD: {
os << " (transition to field)";
@@ -1120,7 +1121,7 @@ void TransitionArray::PrintTransitions(std::ostream& os,
}
os << ", attrs: " << details.attributes();
}
- os << " -> " << Brief(GetTarget(i)) << "\n";
+ os << " -> " << Brief(target) << "\n";
}
}
diff --git a/src/objects.cc b/src/objects.cc
index 9933e9c61..258390c4d 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -542,9 +542,8 @@ MaybeHandle<Object> Object::GetPropertyWithDefinedGetter(
Debug* debug = isolate->debug();
// Handle stepping into a getter if step into is active.
// TODO(rossberg): should this apply to getters that are function proxies?
- if (debug->StepInActive() && getter->IsJSFunction()) {
- debug->HandleStepIn(
- Handle<JSFunction>::cast(getter), Handle<Object>::null(), 0, false);
+ if (debug->is_active()) {
+ debug->HandleStepIn(getter, Handle<Object>::null(), 0, false);
}
return Execution::Call(isolate, getter, receiver, 0, NULL, true);
@@ -560,9 +559,8 @@ MaybeHandle<Object> Object::SetPropertyWithDefinedSetter(
Debug* debug = isolate->debug();
// Handle stepping into a setter if step into is active.
// TODO(rossberg): should this apply to getters that are function proxies?
- if (debug->StepInActive() && setter->IsJSFunction()) {
- debug->HandleStepIn(
- Handle<JSFunction>::cast(setter), Handle<Object>::null(), 0, false);
+ if (debug->is_active()) {
+ debug->HandleStepIn(setter, Handle<Object>::null(), 0, false);
}
Handle<Object> argv[] = { value };
@@ -1934,7 +1932,7 @@ bool Map::InstancesNeedRewriting(Map* target, int target_number_of_fields,
void Map::ConnectElementsTransition(Handle<Map> parent, Handle<Map> child) {
Isolate* isolate = parent->GetIsolate();
Handle<Name> name = isolate->factory()->elements_transition_symbol();
- ConnectTransition(parent, child, name, FULL_TRANSITION);
+ ConnectTransition(parent, child, name, SPECIAL_TRANSITION);
}
@@ -2228,10 +2226,12 @@ void Map::DeprecateTransitionTree() {
// Invalidates a transition target at |key|, and installs |new_descriptors| over
// the current instance_descriptors to ensure proper sharing of descriptor
// arrays.
-void Map::DeprecateTarget(Name* key, DescriptorArray* new_descriptors) {
+void Map::DeprecateTarget(PropertyType type, Name* key,
+ PropertyAttributes attributes,
+ DescriptorArray* new_descriptors) {
if (HasTransitionArray()) {
TransitionArray* transitions = this->transitions();
- int transition = transitions->Search(key);
+ int transition = transitions->Search(type, key, attributes);
if (transition != TransitionArray::kNotFound) {
transitions->GetTarget(transition)->DeprecateTransitionTree();
}
@@ -2278,14 +2278,15 @@ Map* Map::FindLastMatchMap(int verbatim,
for (int i = verbatim; i < length; i++) {
if (!current->HasTransitionArray()) break;
Name* name = descriptors->GetKey(i);
+ PropertyDetails details = descriptors->GetDetails(i);
TransitionArray* transitions = current->transitions();
- int transition = transitions->Search(name);
+ int transition =
+ transitions->Search(details.type(), name, details.attributes());
if (transition == TransitionArray::kNotFound) break;
Map* next = transitions->GetTarget(transition);
DescriptorArray* next_descriptors = next->instance_descriptors();
- PropertyDetails details = descriptors->GetDetails(i);
PropertyDetails next_details = next_descriptors->GetDetails(i);
if (details.type() != next_details.type()) break;
if (details.attributes() != next_details.attributes()) break;
@@ -2475,21 +2476,23 @@ Handle<Map> Map::GeneralizeRepresentation(Handle<Map> old_map,
Handle<Map> target_map = root_map;
for (int i = root_nof; i < old_nof; ++i) {
- int j = target_map->SearchTransition(old_descriptors->GetKey(i));
+ PropertyDetails old_details = old_descriptors->GetDetails(i);
+ int j = target_map->SearchTransition(old_details.type(),
+ old_descriptors->GetKey(i),
+ old_details.attributes());
if (j == TransitionArray::kNotFound) break;
Handle<Map> tmp_map(target_map->GetTransition(j), isolate);
Handle<DescriptorArray> tmp_descriptors = handle(
tmp_map->instance_descriptors(), isolate);
// Check if target map is incompatible.
- PropertyDetails old_details = old_descriptors->GetDetails(i);
PropertyDetails tmp_details = tmp_descriptors->GetDetails(i);
PropertyType old_type = old_details.type();
PropertyType tmp_type = tmp_details.type();
- if (tmp_details.attributes() != old_details.attributes() ||
- ((tmp_type == CALLBACKS || old_type == CALLBACKS) &&
- (tmp_type != old_type ||
- tmp_descriptors->GetValue(i) != old_descriptors->GetValue(i)))) {
+ DCHECK_EQ(old_details.attributes(), tmp_details.attributes());
+ if ((tmp_type == CALLBACKS || old_type == CALLBACKS) &&
+ (tmp_type != old_type ||
+ tmp_descriptors->GetValue(i) != old_descriptors->GetValue(i))) {
return CopyGeneralizeAllRepresentations(
old_map, modify_index, store_mode, "incompatible");
}
@@ -2541,19 +2544,21 @@ Handle<Map> Map::GeneralizeRepresentation(Handle<Map> old_map,
// Find the last compatible target map in the transition tree.
for (int i = target_nof; i < old_nof; ++i) {
- int j = target_map->SearchTransition(old_descriptors->GetKey(i));
+ PropertyDetails old_details = old_descriptors->GetDetails(i);
+ int j = target_map->SearchTransition(old_details.type(),
+ old_descriptors->GetKey(i),
+ old_details.attributes());
if (j == TransitionArray::kNotFound) break;
Handle<Map> tmp_map(target_map->GetTransition(j), isolate);
Handle<DescriptorArray> tmp_descriptors(
tmp_map->instance_descriptors(), isolate);
// Check if target map is compatible.
- PropertyDetails old_details = old_descriptors->GetDetails(i);
PropertyDetails tmp_details = tmp_descriptors->GetDetails(i);
- if (tmp_details.attributes() != old_details.attributes() ||
- ((tmp_details.type() == CALLBACKS || old_details.type() == CALLBACKS) &&
- (tmp_details.type() != old_details.type() ||
- tmp_descriptors->GetValue(i) != old_descriptors->GetValue(i)))) {
+ DCHECK_EQ(old_details.attributes(), tmp_details.attributes());
+ if ((tmp_details.type() == CALLBACKS || old_details.type() == CALLBACKS) &&
+ (tmp_details.type() != old_details.type() ||
+ tmp_descriptors->GetValue(i) != old_descriptors->GetValue(i))) {
return CopyGeneralizeAllRepresentations(
old_map, modify_index, store_mode, "incompatible");
}
@@ -2685,8 +2690,10 @@ Handle<Map> Map::GeneralizeRepresentation(Handle<Map> old_map,
int split_nof = split_map->NumberOfOwnDescriptors();
DCHECK_NE(old_nof, split_nof);
- split_map->DeprecateTarget(
- old_descriptors->GetKey(split_nof), *new_descriptors);
+ PropertyDetails split_prop_details = old_descriptors->GetDetails(split_nof);
+ split_map->DeprecateTarget(split_prop_details.type(),
+ old_descriptors->GetKey(split_nof),
+ split_prop_details.attributes(), *new_descriptors);
if (FLAG_trace_generalization) {
PropertyDetails old_details = old_descriptors->GetDetails(modify_index);
@@ -2775,13 +2782,15 @@ MaybeHandle<Map> Map::TryUpdateInternal(Handle<Map> old_map) {
Map* new_map = root_map;
for (int i = root_nof; i < old_nof; ++i) {
- int j = new_map->SearchTransition(old_descriptors->GetKey(i));
+ PropertyDetails old_details = old_descriptors->GetDetails(i);
+ int j = new_map->SearchTransition(old_details.type(),
+ old_descriptors->GetKey(i),
+ old_details.attributes());
if (j == TransitionArray::kNotFound) return MaybeHandle<Map>();
new_map = new_map->GetTransition(j);
DescriptorArray* new_descriptors = new_map->instance_descriptors();
PropertyDetails new_details = new_descriptors->GetDetails(i);
- PropertyDetails old_details = old_descriptors->GetDetails(i);
if (old_details.attributes() != new_details.attributes() ||
!old_details.representation().fits_into(new_details.representation())) {
return MaybeHandle<Map>();
@@ -5380,8 +5389,8 @@ MaybeHandle<Object> JSObject::Freeze(Handle<JSObject> object) {
}
Handle<Map> old_map(object->map(), isolate);
- int transition_index = old_map->SearchTransition(
- isolate->heap()->frozen_symbol());
+ int transition_index =
+ old_map->SearchSpecialTransition(isolate->heap()->frozen_symbol());
if (transition_index != TransitionArray::kNotFound) {
Handle<Map> transition_map(old_map->GetTransition(transition_index));
DCHECK(transition_map->has_dictionary_elements());
@@ -5433,8 +5442,8 @@ void JSObject::SetObserved(Handle<JSObject> object) {
Handle<Map> new_map;
Handle<Map> old_map(object->map(), isolate);
DCHECK(!old_map->is_observed());
- int transition_index = old_map->SearchTransition(
- isolate->heap()->observed_symbol());
+ int transition_index =
+ old_map->SearchSpecialTransition(isolate->heap()->observed_symbol());
if (transition_index != TransitionArray::kNotFound) {
new_map = handle(old_map->GetTransition(transition_index), isolate);
DCHECK(new_map->is_observed());
@@ -6601,7 +6610,7 @@ Handle<Map> Map::ShareDescriptor(Handle<Map> map,
}
DCHECK(result->NumberOfOwnDescriptors() == map->NumberOfOwnDescriptors() + 1);
- ConnectTransition(map, result, name, SIMPLE_TRANSITION);
+ ConnectTransition(map, result, name, SIMPLE_PROPERTY_TRANSITION);
return result;
}
@@ -6677,7 +6686,7 @@ Handle<Map> Map::CopyInstallDescriptors(Handle<Map> map,
result->set_unused_property_fields(unused_property_fields);
Handle<Name> name = handle(descriptors->GetKey(new_descriptor));
- ConnectTransition(map, result, name, SIMPLE_TRANSITION);
+ ConnectTransition(map, result, name, SIMPLE_PROPERTY_TRANSITION);
return result;
}
@@ -6751,7 +6760,7 @@ Handle<Map> Map::CopyForObserved(Handle<Map> map) {
if (map->CanHaveMoreTransitions()) {
Handle<Name> name = isolate->factory()->observed_symbol();
- ConnectTransition(map, new_map, name, FULL_TRANSITION);
+ ConnectTransition(map, new_map, name, SPECIAL_TRANSITION);
}
return new_map;
}
@@ -6762,8 +6771,8 @@ Handle<Map> Map::Copy(Handle<Map> map) {
int number_of_own_descriptors = map->NumberOfOwnDescriptors();
Handle<DescriptorArray> new_descriptors =
DescriptorArray::CopyUpTo(descriptors, number_of_own_descriptors);
- return CopyReplaceDescriptors(
- map, new_descriptors, OMIT_TRANSITION, MaybeHandle<Name>());
+ return CopyReplaceDescriptors(map, new_descriptors, OMIT_TRANSITION,
+ MaybeHandle<Name>(), SPECIAL_TRANSITION);
}
@@ -6798,7 +6807,8 @@ Handle<Map> Map::CopyForFreeze(Handle<Map> map) {
Handle<DescriptorArray> new_desc = DescriptorArray::CopyUpToAddAttributes(
handle(map->instance_descriptors(), isolate), num_descriptors, FROZEN);
Handle<Map> new_map = CopyReplaceDescriptors(
- map, new_desc, INSERT_TRANSITION, isolate->factory()->frozen_symbol());
+ map, new_desc, INSERT_TRANSITION, isolate->factory()->frozen_symbol(),
+ SPECIAL_TRANSITION);
new_map->freeze();
new_map->set_is_extensible(false);
new_map->set_elements_kind(DICTIONARY_ELEMENTS);
@@ -6862,16 +6872,14 @@ Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name,
// Migrate to the newest map before storing the property.
map = Update(map);
- int index = map->SearchTransition(*name);
+ int index = map->SearchTransition(FIELD, *name, attributes);
if (index != TransitionArray::kNotFound) {
Handle<Map> transition(map->GetTransition(index));
int descriptor = transition->LastAdded();
- // TODO(verwaest): Handle attributes better.
- DescriptorArray* descriptors = transition->instance_descriptors();
- if (descriptors->GetDetails(descriptor).attributes() != attributes) {
- return Map::Normalize(map, CLEAR_INOBJECT_PROPERTIES);
- }
+ DCHECK_EQ(attributes, transition->instance_descriptors()
+ ->GetDetails(descriptor)
+ .attributes());
return Map::PrepareForDataProperty(transition, descriptor, value);
}
@@ -6931,25 +6939,15 @@ Handle<Map> Map::TransitionToAccessorProperty(Handle<Map> map,
? KEEP_INOBJECT_PROPERTIES
: CLEAR_INOBJECT_PROPERTIES;
- int index = map->SearchTransition(*name);
+ int index = map->SearchTransition(CALLBACKS, *name, attributes);
if (index != TransitionArray::kNotFound) {
Handle<Map> transition(map->GetTransition(index));
DescriptorArray* descriptors = transition->instance_descriptors();
- // Fast path, assume that we're modifying the last added descriptor.
int descriptor = transition->LastAdded();
- if (descriptors->GetKey(descriptor) != *name) {
- // If not, search for the descriptor.
- descriptor = descriptors->SearchWithCache(*name, *transition);
- }
+ DCHECK(descriptors->GetKey(descriptor)->Equals(*name));
- if (descriptors->GetDetails(descriptor).type() != CALLBACKS) {
- return Map::Normalize(map, mode);
- }
-
- // TODO(verwaest): Handle attributes better.
- if (descriptors->GetDetails(descriptor).attributes() != attributes) {
- return Map::Normalize(map, mode);
- }
+ DCHECK_EQ(CALLBACKS, descriptors->GetDetails(descriptor).type());
+ DCHECK_EQ(attributes, descriptors->GetDetails(descriptor).attributes());
Handle<Object> maybe_pair(descriptors->GetValue(descriptor), isolate);
if (!maybe_pair->IsAccessorPair()) {
@@ -6968,6 +6966,9 @@ Handle<Map> Map::TransitionToAccessorProperty(Handle<Map> map,
DescriptorArray* old_descriptors = map->instance_descriptors();
int descriptor = old_descriptors->SearchWithCache(*name, *map);
if (descriptor != DescriptorArray::kNotFound) {
+ if (descriptor != map->LastAdded()) {
+ return Map::Normalize(map, mode);
+ }
PropertyDetails old_details = old_descriptors->GetDetails(descriptor);
if (old_details.type() != CALLBACKS) {
return Map::Normalize(map, mode);
@@ -7022,8 +7023,9 @@ Handle<Map> Map::CopyAddDescriptor(Handle<Map> map,
descriptors, map->NumberOfOwnDescriptors(), 1);
new_descriptors->Append(descriptor);
- return CopyReplaceDescriptors(
- map, new_descriptors, flag, descriptor->GetKey(), SIMPLE_TRANSITION);
+ return CopyReplaceDescriptors(map, new_descriptors, flag,
+ descriptor->GetKey(),
+ SIMPLE_PROPERTY_TRANSITION);
}
@@ -7117,8 +7119,8 @@ Handle<Map> Map::CopyReplaceDescriptor(Handle<Map> map,
SimpleTransitionFlag simple_flag =
(insertion_index == descriptors->number_of_descriptors() - 1)
- ? SIMPLE_TRANSITION
- : FULL_TRANSITION;
+ ? SIMPLE_PROPERTY_TRANSITION
+ : PROPERTY_TRANSITION;
return CopyReplaceDescriptors(map, new_descriptors, flag, key, simple_flag);
}
diff --git a/src/objects.h b/src/objects.h
index d12896fb9..9333e9edc 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -280,8 +280,9 @@ enum DebugExtraICState {
// either extends the current map with a new property, or it modifies the
// property that was added last to the current map.
enum SimpleTransitionFlag {
- SIMPLE_TRANSITION,
- FULL_TRANSITION
+ SIMPLE_PROPERTY_TRANSITION,
+ PROPERTY_TRANSITION,
+ SPECIAL_TRANSITION
};
@@ -5820,7 +5821,9 @@ class Map: public HeapObject {
inline Map* elements_transition_map();
inline Map* GetTransition(int transition_index);
- inline int SearchTransition(Name* name);
+ inline int SearchSpecialTransition(Symbol* name);
+ inline int SearchTransition(PropertyType type, Name* name,
+ PropertyAttributes attributes);
inline FixedArrayBase* GetInitialElements();
DECL_ACCESSORS(transitions, TransitionArray)
@@ -5958,8 +5961,8 @@ class Map: public HeapObject {
Name* name,
LookupResult* result);
- inline void LookupTransition(JSObject* holder,
- Name* name,
+ inline void LookupTransition(JSObject* holder, Name* name,
+ PropertyAttributes attributes,
LookupResult* result);
inline PropertyDetails GetLastDescriptorDetails();
@@ -6329,12 +6332,11 @@ class Map: public HeapObject {
static Handle<Map> CopyAddDescriptor(Handle<Map> map,
Descriptor* descriptor,
TransitionFlag flag);
- static Handle<Map> CopyReplaceDescriptors(
- Handle<Map> map,
- Handle<DescriptorArray> descriptors,
- TransitionFlag flag,
- MaybeHandle<Name> maybe_name,
- SimpleTransitionFlag simple_flag = FULL_TRANSITION);
+ static Handle<Map> CopyReplaceDescriptors(Handle<Map> map,
+ Handle<DescriptorArray> descriptors,
+ TransitionFlag flag,
+ MaybeHandle<Name> maybe_name,
+ SimpleTransitionFlag simple_flag);
static Handle<Map> CopyReplaceDescriptor(Handle<Map> map,
Handle<DescriptorArray> descriptors,
Descriptor* descriptor,
@@ -6362,7 +6364,9 @@ class Map: public HeapObject {
void ZapTransitions();
void DeprecateTransitionTree();
- void DeprecateTarget(Name* key, DescriptorArray* new_descriptors);
+ void DeprecateTarget(PropertyType type, Name* key,
+ PropertyAttributes attributes,
+ DescriptorArray* new_descriptors);
Map* FindLastMatchMap(int verbatim, int length, DescriptorArray* descriptors);
diff --git a/src/profile-generator-inl.h b/src/profile-generator-inl.h
index 58c124fe6..b638857cc 100644
--- a/src/profile-generator-inl.h
+++ b/src/profile-generator-inl.h
@@ -10,14 +10,11 @@
namespace v8 {
namespace internal {
-CodeEntry::CodeEntry(Logger::LogEventsAndTags tag,
- const char* name,
- const char* name_prefix,
- const char* resource_name,
- int line_number,
- int column_number)
- : tag_(tag),
- builtin_id_(Builtins::builtin_count),
+CodeEntry::CodeEntry(Logger::LogEventsAndTags tag, const char* name,
+ const char* name_prefix, const char* resource_name,
+ int line_number, int column_number)
+ : bit_field_(TagField::encode(tag) |
+ BuiltinIdField::encode(Builtins::builtin_count)),
name_prefix_(name_prefix),
name_(name),
resource_name_(resource_name),
@@ -26,7 +23,7 @@ CodeEntry::CodeEntry(Logger::LogEventsAndTags tag,
shared_id_(0),
script_id_(v8::UnboundScript::kNoScriptId),
no_frame_ranges_(NULL),
- bailout_reason_(kEmptyBailoutReason) { }
+ bailout_reason_(kEmptyBailoutReason) {}
bool CodeEntry::is_js_function_tag(Logger::LogEventsAndTags tag) {
diff --git a/src/profile-generator.cc b/src/profile-generator.cc
index 6017f12dc..4607156a4 100644
--- a/src/profile-generator.cc
+++ b/src/profile-generator.cc
@@ -143,7 +143,7 @@ CodeEntry::~CodeEntry() {
uint32_t CodeEntry::GetCallUid() const {
- uint32_t hash = ComputeIntegerHash(tag_, v8::internal::kZeroHashSeed);
+ uint32_t hash = ComputeIntegerHash(tag(), v8::internal::kZeroHashSeed);
if (shared_id_ != 0) {
hash ^= ComputeIntegerHash(static_cast<uint32_t>(shared_id_),
v8::internal::kZeroHashSeed);
@@ -164,20 +164,18 @@ uint32_t CodeEntry::GetCallUid() const {
bool CodeEntry::IsSameAs(CodeEntry* entry) const {
- return this == entry
- || (tag_ == entry->tag_
- && shared_id_ == entry->shared_id_
- && (shared_id_ != 0
- || (name_prefix_ == entry->name_prefix_
- && name_ == entry->name_
- && resource_name_ == entry->resource_name_
- && line_number_ == entry->line_number_)));
+ return this == entry ||
+ (tag() == entry->tag() && shared_id_ == entry->shared_id_ &&
+ (shared_id_ != 0 ||
+ (name_prefix_ == entry->name_prefix_ && name_ == entry->name_ &&
+ resource_name_ == entry->resource_name_ &&
+ line_number_ == entry->line_number_)));
}
void CodeEntry::SetBuiltinId(Builtins::Name id) {
- tag_ = Logger::BUILTIN_TAG;
- builtin_id_ = id;
+ bit_field_ = TagField::update(bit_field_, Logger::BUILTIN_TAG);
+ bit_field_ = BuiltinIdField::update(bit_field_, id);
}
diff --git a/src/profile-generator.h b/src/profile-generator.h
index 5ebb92bba..f78beb041 100644
--- a/src/profile-generator.h
+++ b/src/profile-generator.h
@@ -55,7 +55,7 @@ class CodeEntry {
int column_number = v8::CpuProfileNode::kNoColumnNumberInfo);
~CodeEntry();
- bool is_js_function() const { return is_js_function_tag(tag_); }
+ bool is_js_function() const { return is_js_function_tag(tag()); }
const char* name_prefix() const { return name_prefix_; }
bool has_name_prefix() const { return name_prefix_[0] != '\0'; }
const char* name() const { return name_; }
@@ -78,7 +78,9 @@ class CodeEntry {
}
void SetBuiltinId(Builtins::Name id);
- Builtins::Name builtin_id() const { return builtin_id_; }
+ Builtins::Name builtin_id() const {
+ return BuiltinIdField::decode(bit_field_);
+ }
uint32_t GetCallUid() const;
bool IsSameAs(CodeEntry* entry) const;
@@ -88,8 +90,11 @@ class CodeEntry {
static const char* const kEmptyBailoutReason;
private:
- Logger::LogEventsAndTags tag_ : 8;
- Builtins::Name builtin_id_ : 8;
+ class TagField : public BitField<Logger::LogEventsAndTags, 0, 8> {};
+ class BuiltinIdField : public BitField<Builtins::Name, 8, 8> {};
+ Logger::LogEventsAndTags tag() const { return TagField::decode(bit_field_); }
+
+ uint32_t bit_field_;
const char* name_prefix_;
const char* name_;
const char* resource_name_;
diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc
index c3a6d80ec..523d8f5fa 100644
--- a/src/runtime/runtime-array.cc
+++ b/src/runtime/runtime-array.cc
@@ -104,19 +104,19 @@ class ArrayConcatVisitor {
storage_(Handle<FixedArray>::cast(
isolate->global_handles()->Create(*storage))),
index_offset_(0u),
- fast_elements_(fast_elements),
- exceeds_array_limit_(false) {}
+ bit_field_(FastElementsField::encode(fast_elements) |
+ ExceedsLimitField::encode(false)) {}
~ArrayConcatVisitor() { clear_storage(); }
void visit(uint32_t i, Handle<Object> elm) {
if (i > JSObject::kMaxElementCount - index_offset_) {
- exceeds_array_limit_ = true;
+ set_exceeds_array_limit(true);
return;
}
uint32_t index = index_offset_ + i;
- if (fast_elements_) {
+ if (fast_elements()) {
if (index < static_cast<uint32_t>(storage_->length())) {
storage_->set(index, *elm);
return;
@@ -128,7 +128,7 @@ class ArrayConcatVisitor {
SetDictionaryMode();
// Fall-through to dictionary mode.
}
- DCHECK(!fast_elements_);
+ DCHECK(!fast_elements());
Handle<SeededNumberDictionary> dict(
SeededNumberDictionary::cast(*storage_));
Handle<SeededNumberDictionary> result =
@@ -149,21 +149,23 @@ class ArrayConcatVisitor {
// If the initial length estimate was off (see special case in visit()),
// but the array blowing the limit didn't contain elements beyond the
// provided-for index range, go to dictionary mode now.
- if (fast_elements_ &&
+ if (fast_elements() &&
index_offset_ >
static_cast<uint32_t>(FixedArrayBase::cast(*storage_)->length())) {
SetDictionaryMode();
}
}
- bool exceeds_array_limit() { return exceeds_array_limit_; }
+ bool exceeds_array_limit() const {
+ return ExceedsLimitField::decode(bit_field_);
+ }
Handle<JSArray> ToArray() {
Handle<JSArray> array = isolate_->factory()->NewJSArray(0);
Handle<Object> length =
isolate_->factory()->NewNumber(static_cast<double>(index_offset_));
Handle<Map> map = JSObject::GetElementsTransitionMap(
- array, fast_elements_ ? FAST_HOLEY_ELEMENTS : DICTIONARY_ELEMENTS);
+ array, fast_elements() ? FAST_HOLEY_ELEMENTS : DICTIONARY_ELEMENTS);
array->set_map(*map);
array->set_length(*length);
array->set_elements(*storage_);
@@ -173,7 +175,7 @@ class ArrayConcatVisitor {
private:
// Convert storage to dictionary mode.
void SetDictionaryMode() {
- DCHECK(fast_elements_);
+ DCHECK(fast_elements());
Handle<FixedArray> current_storage(*storage_);
Handle<SeededNumberDictionary> slow_storage(
SeededNumberDictionary::New(isolate_, current_storage->length()));
@@ -191,7 +193,7 @@ class ArrayConcatVisitor {
}
clear_storage();
set_storage(*slow_storage);
- fast_elements_ = false;
+ set_fast_elements(false);
}
inline void clear_storage() {
@@ -203,13 +205,23 @@ class ArrayConcatVisitor {
Handle<FixedArray>::cast(isolate_->global_handles()->Create(storage));
}
+ class FastElementsField : public BitField<bool, 0, 1> {};
+ class ExceedsLimitField : public BitField<bool, 1, 1> {};
+
+ bool fast_elements() const { return FastElementsField::decode(bit_field_); }
+ void set_fast_elements(bool fast) {
+ bit_field_ = FastElementsField::update(bit_field_, fast);
+ }
+ void set_exceeds_array_limit(bool exceeds) {
+ bit_field_ = ExceedsLimitField::update(bit_field_, exceeds);
+ }
+
Isolate* isolate_;
Handle<FixedArray> storage_; // Always a global handle.
// Index after last seen index. Always less than or equal to
// JSObject::kMaxElementCount.
uint32_t index_offset_;
- bool fast_elements_ : 1;
- bool exceeds_array_limit_ : 1;
+ uint32_t bit_field_;
};
diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc
index 2de372f66..95ac77bb1 100644
--- a/src/runtime/runtime-debug.cc
+++ b/src/runtime/runtime-debug.cc
@@ -1984,7 +1984,7 @@ RUNTIME_FUNCTION(Runtime_PrepareStep) {
StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1]));
if (step_action != StepIn && step_action != StepNext &&
step_action != StepOut && step_action != StepInMin &&
- step_action != StepMin) {
+ step_action != StepMin && step_action != StepFrame) {
return isolate->Throw(isolate->heap()->illegal_argument_string());
}
diff --git a/src/runtime/runtime-observe.cc b/src/runtime/runtime-observe.cc
index ab7f2503b..4579136d9 100644
--- a/src/runtime/runtime-observe.cc
+++ b/src/runtime/runtime-observe.cc
@@ -52,6 +52,28 @@ RUNTIME_FUNCTION(Runtime_RunMicrotasks) {
}
+RUNTIME_FUNCTION(Runtime_DeliverObservationChangeRecords) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 2);
+ CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, argument, 1);
+ v8::TryCatch catcher;
+ // We should send a message on uncaught exception thrown during
+ // Object.observe delivery while not interrupting further delivery, thus
+ // we make a call inside a verbose TryCatch.
+ catcher.SetVerbose(true);
+ Handle<Object> argv[] = {argument};
+ USE(Execution::Call(isolate, callback, isolate->factory()->undefined_value(),
+ arraysize(argv), argv));
+ if (isolate->has_pending_exception()) {
+ isolate->ReportPendingMessages();
+ isolate->clear_pending_exception();
+ isolate->set_external_caught_exception(false);
+ }
+ return isolate->heap()->undefined_value();
+}
+
+
RUNTIME_FUNCTION(Runtime_GetObservationState) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 0);
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
index 448010a1a..5d6ccac70 100644
--- a/src/runtime/runtime.h
+++ b/src/runtime/runtime.h
@@ -350,6 +350,7 @@ namespace internal {
F(GetObjectContextObjectObserve, 1, 1) \
F(GetObjectContextObjectGetNotifier, 1, 1) \
F(GetObjectContextNotifierPerformChange, 1, 1) \
+ F(DeliverObservationChangeRecords, 2, 1) \
\
/* Harmony typed arrays */ \
F(ArrayBufferInitialize, 2, 1) \
diff --git a/src/scanner.cc b/src/scanner.cc
index 8062faa24..e63239d6e 100644
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -245,6 +245,8 @@ bool Scanner::SkipWhiteSpace() {
while (true) {
while (true) {
+ // The unicode cache accepts unsigned inputs.
+ if (c0_ < 0) break;
// Advance as long as character is a WhiteSpace or LineTerminator.
// Remember if the latter is the case.
if (unicode_cache_->IsLineTerminator(c0_)) {
@@ -365,7 +367,7 @@ Token::Value Scanner::SkipMultiLineComment() {
while (c0_ >= 0) {
uc32 ch = c0_;
Advance();
- if (unicode_cache_->IsLineTerminator(ch)) {
+ if (c0_ >= 0 && unicode_cache_->IsLineTerminator(ch)) {
// Following ECMA-262, section 7.4, a comment containing
// a newline will make the comment count as a line-terminator.
has_multiline_comment_before_next_ = true;
@@ -625,14 +627,14 @@ void Scanner::Scan() {
break;
default:
- if (unicode_cache_->IsIdentifierStart(c0_)) {
+ if (c0_ < 0) {
+ token = Token::EOS;
+ } else if (unicode_cache_->IsIdentifierStart(c0_)) {
token = ScanIdentifierOrKeyword();
} else if (IsDecimalDigit(c0_)) {
token = ScanNumber(false);
} else if (SkipWhiteSpace()) {
token = Token::WHITESPACE;
- } else if (c0_ < 0) {
- token = Token::EOS;
} else {
token = Select(Token::ILLEGAL);
}
@@ -674,7 +676,7 @@ bool Scanner::ScanEscape() {
Advance();
// Skip escaped newlines.
- if (unicode_cache_->IsLineTerminator(c)) {
+ if (c0_ >= 0 && unicode_cache_->IsLineTerminator(c)) {
// Allow CR+LF newlines in multiline string literals.
if (IsCarriageReturn(c) && IsLineFeed(c0_)) Advance();
// Allow LF+CR newlines in multiline string literals.
@@ -871,7 +873,8 @@ Token::Value Scanner::ScanNumber(bool seen_period) {
// not be an identifier start or a decimal digit; see ECMA-262
// section 7.8.3, page 17 (note that we read only one decimal digit
// if the value is 0).
- if (IsDecimalDigit(c0_) || unicode_cache_->IsIdentifierStart(c0_))
+ if (IsDecimalDigit(c0_) ||
+ (c0_ >= 0 && unicode_cache_->IsIdentifierStart(c0_)))
return Token::ILLEGAL;
literal.Complete();
@@ -1039,7 +1042,7 @@ Token::Value Scanner::ScanIdentifierOrKeyword() {
AddLiteralChar(first_char);
// Scan the rest of the identifier characters.
- while (unicode_cache_->IsIdentifierPart(c0_)) {
+ while (c0_ >= 0 && unicode_cache_->IsIdentifierPart(c0_)) {
if (c0_ != '\\') {
uc32 next_char = c0_;
Advance();
@@ -1067,7 +1070,7 @@ Token::Value Scanner::ScanIdentifierOrKeyword() {
Token::Value Scanner::ScanIdentifierSuffix(LiteralScope* literal) {
// Scan the rest of the identifier characters.
- while (unicode_cache_->IsIdentifierPart(c0_)) {
+ while (c0_ >= 0 && unicode_cache_->IsIdentifierPart(c0_)) {
if (c0_ == '\\') {
uc32 c = ScanIdentifierUnicodeEscape();
// Only allow legal identifier part characters.
@@ -1106,10 +1109,10 @@ bool Scanner::ScanRegExpPattern(bool seen_equal) {
}
while (c0_ != '/' || in_character_class) {
- if (unicode_cache_->IsLineTerminator(c0_) || c0_ < 0) return false;
+ if (c0_ < 0 || unicode_cache_->IsLineTerminator(c0_)) return false;
if (c0_ == '\\') { // Escape sequence.
AddLiteralCharAdvance();
- if (unicode_cache_->IsLineTerminator(c0_) || c0_ < 0) return false;
+ if (c0_ < 0 || unicode_cache_->IsLineTerminator(c0_)) return false;
AddLiteralCharAdvance();
// If the escape allows more characters, i.e., \x??, \u????, or \c?,
// only "safe" characters are allowed (letters, digits, underscore),
@@ -1156,7 +1159,7 @@ bool Scanner::ScanLiteralUnicodeEscape() {
bool Scanner::ScanRegExpFlags() {
// Scan regular expression flags.
LiteralScope literal(this);
- while (unicode_cache_->IsIdentifierPart(c0_)) {
+ while (c0_ >= 0 && unicode_cache_->IsIdentifierPart(c0_)) {
if (c0_ != '\\') {
AddLiteralCharAdvance();
} else {
diff --git a/src/transitions-inl.h b/src/transitions-inl.h
index 087755d1b..8a6d1bba1 100644
--- a/src/transitions-inl.h
+++ b/src/transitions-inl.h
@@ -34,7 +34,7 @@ TransitionArray* TransitionArray::cast(Object* object) {
bool TransitionArray::HasElementsTransition() {
- return Search(GetHeap()->elements_transition_symbol()) != kNotFound;
+ return SearchSpecial(GetHeap()->elements_transition_symbol()) != kNotFound;
}
@@ -140,7 +140,7 @@ Object* TransitionArray::GetTargetValue(int transition_number) {
}
-int TransitionArray::Search(Name* name, int* out_insertion_index) {
+int TransitionArray::SearchName(Name* name, int* out_insertion_index) {
if (IsSimpleTransition()) {
Name* key = GetKey(kSimpleTransitionIndex);
if (key->Equals(name)) return kSimpleTransitionIndex;
@@ -153,6 +153,71 @@ int TransitionArray::Search(Name* name, int* out_insertion_index) {
}
+#ifdef DEBUG
+bool TransitionArray::IsSpecialTransition(Name* name) {
+ if (!name->IsSymbol()) return false;
+ Heap* heap = name->GetHeap();
+ return name == heap->frozen_symbol() ||
+ name == heap->elements_transition_symbol() ||
+ name == heap->observed_symbol();
+}
+#endif
+
+
+int TransitionArray::CompareKeys(Name* key1, uint32_t hash1,
+ bool is_data_property1,
+ PropertyAttributes attributes1, Name* key2,
+ uint32_t hash2, bool is_data_property2,
+ PropertyAttributes attributes2) {
+ int cmp = CompareNames(key1, hash1, key2, hash2);
+ if (cmp != 0) return cmp;
+
+ return CompareDetails(is_data_property1, attributes1, is_data_property2,
+ attributes2);
+}
+
+
+int TransitionArray::CompareNames(Name* key1, uint32_t hash1, Name* key2,
+ uint32_t hash2) {
+ if (key1 != key2) {
+ // In case of hash collisions key1 is always "less" than key2.
+ return hash1 <= hash2 ? -1 : 1;
+ }
+
+ return 0;
+}
+
+
+int TransitionArray::CompareDetails(bool is_data_property1,
+ PropertyAttributes attributes1,
+ bool is_data_property2,
+ PropertyAttributes attributes2) {
+ if (is_data_property1 != is_data_property2) {
+ return static_cast<int>(is_data_property1) <
+ static_cast<int>(is_data_property2)
+ ? -1
+ : 1;
+ }
+
+ if (attributes1 != attributes2) {
+ return static_cast<int>(attributes1) < static_cast<int>(attributes2) ? -1
+ : 1;
+ }
+
+ return 0;
+}
+
+
+PropertyDetails TransitionArray::GetTargetDetails(Name* name, Map* target) {
+ DCHECK(!IsSpecialTransition(name));
+ int descriptor = target->LastAdded();
+ DescriptorArray* descriptors = target->instance_descriptors();
+ // Transitions are allowed only for the last added property.
+ DCHECK(descriptors->GetKey(descriptor)->Equals(name));
+ return descriptors->GetDetails(descriptor);
+}
+
+
void TransitionArray::NoIncrementalWriteBarrierSet(int transition_number,
Name* key,
Map* target) {
diff --git a/src/transitions.cc b/src/transitions.cc
index ec1b7f4fc..51eee6f98 100644
--- a/src/transitions.cc
+++ b/src/transitions.cc
@@ -48,7 +48,7 @@ Handle<TransitionArray> TransitionArray::NewWith(Handle<Map> map,
Handle<TransitionArray> result;
Isolate* isolate = name->GetIsolate();
- if (flag == SIMPLE_TRANSITION) {
+ if (flag == SIMPLE_PROPERTY_TRANSITION) {
result = AllocateSimple(isolate, target);
} else {
result = Allocate(isolate, 1);
@@ -94,9 +94,19 @@ Handle<TransitionArray> TransitionArray::Insert(Handle<Map> map,
int number_of_transitions = map->transitions()->number_of_transitions();
int new_nof = number_of_transitions;
- int insertion_index = kNotFound;
- int index = map->transitions()->Search(*name, &insertion_index);
+ bool is_special_transition = flag == SPECIAL_TRANSITION;
+ DCHECK_EQ(is_special_transition, IsSpecialTransition(*name));
+ PropertyDetails details = is_special_transition
+ ? PropertyDetails(NONE, NORMAL, 0)
+ : GetTargetDetails(*name, *target);
+ int insertion_index = kNotFound;
+ int index =
+ is_special_transition
+ ? map->transitions()->SearchSpecial(Symbol::cast(*name),
+ &insertion_index)
+ : map->transitions()->Search(details.type(), *name,
+ details.attributes(), &insertion_index);
if (index == kNotFound) {
++new_nof;
} else {
@@ -118,12 +128,12 @@ Handle<TransitionArray> TransitionArray::Insert(Handle<Map> map,
array->SetNumberOfTransitions(new_nof);
for (index = number_of_transitions; index > insertion_index; --index) {
Name* key = array->GetKey(index - 1);
- DCHECK(key->Hash() > name->Hash());
array->SetKey(index, key);
array->SetTarget(index, array->GetTarget(index - 1));
}
array->SetKey(index, *name);
array->SetTarget(index, *target);
+ SLOW_DCHECK(array->IsSortedNoDuplicates());
return handle(array);
}
@@ -144,7 +154,11 @@ Handle<TransitionArray> TransitionArray::Insert(Handle<Map> map,
new_nof = number_of_transitions;
insertion_index = kNotFound;
- index = array->Search(*name, &insertion_index);
+ index = is_special_transition ? map->transitions()->SearchSpecial(
+ Symbol::cast(*name), &insertion_index)
+ : map->transitions()->Search(
+ details.type(), *name,
+ details.attributes(), &insertion_index);
if (index == kNotFound) {
++new_nof;
} else {
@@ -170,8 +184,46 @@ Handle<TransitionArray> TransitionArray::Insert(Handle<Map> map,
}
result->set_back_pointer_storage(array->back_pointer_storage());
+ SLOW_DCHECK(result->IsSortedNoDuplicates());
return result;
}
+int TransitionArray::SearchDetails(int transition, PropertyType type,
+ PropertyAttributes attributes,
+ int* out_insertion_index) {
+ int nof_transitions = number_of_transitions();
+ DCHECK(transition < nof_transitions);
+ Name* key = GetKey(transition);
+ bool is_data = type == FIELD || type == CONSTANT;
+ for (; transition < nof_transitions && GetKey(transition) == key;
+ transition++) {
+ Map* target = GetTarget(transition);
+ PropertyDetails target_details = GetTargetDetails(key, target);
+
+ bool target_is_data =
+ target_details.type() == FIELD || target_details.type() == CONSTANT;
+
+ int cmp = CompareDetails(is_data, attributes, target_is_data,
+ target_details.attributes());
+ if (cmp == 0) {
+ return transition;
+ } else if (cmp < 0) {
+ break;
+ }
+ }
+ if (out_insertion_index != NULL) *out_insertion_index = transition;
+ return kNotFound;
+}
+
+
+int TransitionArray::Search(PropertyType type, Name* name,
+ PropertyAttributes attributes,
+ int* out_insertion_index) {
+ int transition = SearchName(name, out_insertion_index);
+ if (transition == kNotFound) {
+ return kNotFound;
+ }
+ return SearchDetails(transition, type, attributes, out_insertion_index);
+}
} } // namespace v8::internal
diff --git a/src/transitions.h b/src/transitions.h
index c5f9a3001..ef74b4df8 100644
--- a/src/transitions.h
+++ b/src/transitions.h
@@ -98,9 +98,17 @@ class TransitionArray: public FixedArray {
static Handle<TransitionArray> Insert(Handle<Map> map, Handle<Name> name,
Handle<Map> target,
SimpleTransitionFlag flag);
+ // Search a transition for a given type, property name and attributes.
+ int Search(PropertyType type, Name* name, PropertyAttributes attributes,
+ int* out_insertion_index = NULL);
+
+ // Search a non-property transition (like elements kind, observe or frozen
+ // transitions).
+ inline int SearchSpecial(Symbol* symbol, int* out_insertion_index = NULL) {
+ return SearchName(symbol, out_insertion_index);
+ }
- // Search a transition for a given property name.
- inline int Search(Name* name, int* out_insertion_index = NULL);
+ static inline PropertyDetails GetTargetDetails(Name* name, Map* target);
// Allocates a TransitionArray.
static Handle<TransitionArray> Allocate(Isolate* isolate,
@@ -167,6 +175,10 @@ class TransitionArray: public FixedArray {
bool IsSortedNoDuplicates(int valid_entries = -1);
bool IsConsistentWithBackPointers(Map* current_map);
bool IsEqualTo(TransitionArray* other);
+
+ // Returns true for a non-property transitions like elements kind, observed
+ // or frozen transitions.
+ static inline bool IsSpecialTransition(Name* name);
#endif
// The maximum number of transitions we want in a transition array (should
@@ -202,6 +214,31 @@ class TransitionArray: public FixedArray {
Handle<Map> target,
SimpleTransitionFlag flag);
+ // Search a first transition for a given property name.
+ inline int SearchName(Name* name, int* out_insertion_index = NULL);
+ int SearchDetails(int transition, PropertyType type,
+ PropertyAttributes attributes, int* out_insertion_index);
+
+ // Compares two tuples <key, is_data_property, attributes>, returns -1 if
+ // tuple1 is "less" than tuple2, 0 if tuple1 equal to tuple2 and 1 otherwise.
+ static inline int CompareKeys(Name* key1, uint32_t hash1,
+ bool is_data_property1,
+ PropertyAttributes attributes1, Name* key2,
+ uint32_t hash2, bool is_data_property2,
+ PropertyAttributes attributes2);
+
+ // Compares keys, returns -1 if key1 is "less" than key2,
+ // 0 if key1 equal to key2 and 1 otherwise.
+ static inline int CompareNames(Name* key1, uint32_t hash1, Name* key2,
+ uint32_t hash2);
+
+ // Compares two details, returns -1 if details1 is "less" than details2,
+ // 0 if details1 equal to details2 and 1 otherwise.
+ static inline int CompareDetails(bool is_data_property1,
+ PropertyAttributes attributes1,
+ bool is_data_property2,
+ PropertyAttributes attributes2);
+
inline void NoIncrementalWriteBarrierSet(int transition_number,
Name* key,
Map* target);
diff --git a/src/unicode-inl.h b/src/unicode-inl.h
index d47ee3e0c..0f78d39e0 100644
--- a/src/unicode-inl.h
+++ b/src/unicode-inl.h
@@ -13,7 +13,7 @@ namespace unibrow {
template <class T, int s> bool Predicate<T, s>::get(uchar code_point) {
CacheEntry entry = entries_[code_point & kMask];
- if (entry.code_point_ == code_point) return entry.value_;
+ if (entry.code_point() == code_point) return entry.value();
return CalculateValue(code_point);
}
diff --git a/src/unicode.h b/src/unicode.h
index 1af6170fc..166681426 100644
--- a/src/unicode.h
+++ b/src/unicode.h
@@ -7,6 +7,7 @@
#include <sys/types.h>
#include "src/globals.h"
+#include "src/utils.h"
/**
* \file
* Definitions and convenience functions for working with unicode.
@@ -28,16 +29,26 @@ class Predicate {
public:
inline Predicate() { }
inline bool get(uchar c);
+
private:
friend class Test;
bool CalculateValue(uchar c);
- struct CacheEntry {
- inline CacheEntry() : code_point_(0), value_(0) { }
+ class CacheEntry {
+ public:
+ inline CacheEntry()
+ : bit_field_(CodePointField::encode(0) | ValueField::encode(0)) {}
inline CacheEntry(uchar code_point, bool value)
- : code_point_(code_point),
- value_(value) { }
- uchar code_point_ : 21;
- bool value_ : 1;
+ : bit_field_(CodePointField::encode(code_point) |
+ ValueField::encode(value)) {}
+
+ uchar code_point() const { return CodePointField::decode(bit_field_); }
+ bool value() const { return ValueField::decode(bit_field_); }
+
+ private:
+ class CodePointField : public v8::internal::BitField<uchar, 0, 21> {};
+ class ValueField : public v8::internal::BitField<bool, 21, 1> {};
+
+ uint32_t bit_field_;
};
static const int kSize = size;
static const int kMask = kSize - 1;
diff --git a/src/utils.h b/src/utils.h
index dcefa4407..d5685c982 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -230,6 +230,14 @@ class BitFieldBase {
};
+template <class T, int shift, int size>
+class BitField8 : public BitFieldBase<T, shift, size, uint8_t> {};
+
+
+template <class T, int shift, int size>
+class BitField16 : public BitFieldBase<T, shift, size, uint16_t> {};
+
+
template<class T, int shift, int size>
class BitField : public BitFieldBase<T, shift, size, uint32_t> { };
diff --git a/src/version.cc b/src/version.cc
index 5366111dc..6b9481c55 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -34,7 +34,7 @@
// system so their names cannot be changed without changing the scripts.
#define MAJOR_VERSION 3
#define MINOR_VERSION 30
-#define BUILD_NUMBER 34
+#define BUILD_NUMBER 36
#define PATCH_LEVEL 0
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
diff --git a/test/cctest/cctest.gyp b/test/cctest/cctest.gyp
index 5e7ab99d0..b05f0a7ea 100644
--- a/test/cctest/cctest.gyp
+++ b/test/cctest/cctest.gyp
@@ -156,6 +156,7 @@
'test-strtod.cc',
'test-thread-termination.cc',
'test-threads.cc',
+ 'test-transitions.cc',
'test-types.cc',
'test-unbound-queue.cc',
'test-unique.cc',
diff --git a/test/cctest/compiler/test-instruction.cc b/test/cctest/compiler/test-instruction.cc
index 54babfe78..e0fa34640 100644
--- a/test/cctest/compiler/test-instruction.cc
+++ b/test/cctest/compiler/test-instruction.cc
@@ -139,7 +139,7 @@ TEST(InstructionBasic) {
BasicBlock* block = *i;
CHECK_EQ(block->rpo_number(), R.BlockAt(block)->rpo_number().ToInt());
CHECK_EQ(block->id().ToInt(), R.BlockAt(block)->id().ToInt());
- CHECK_EQ(-1, block->loop_end());
+ CHECK_EQ(NULL, block->loop_end());
}
}
diff --git a/test/cctest/compiler/test-scheduler.cc b/test/cctest/compiler/test-scheduler.cc
index 0ade4d15e..5f5c9d190 100644
--- a/test/cctest/compiler/test-scheduler.cc
+++ b/test/cctest/compiler/test-scheduler.cc
@@ -30,29 +30,42 @@ static void CheckRPONumbers(BasicBlockVector* order, size_t expected,
for (int i = 0; i < static_cast<int>(order->size()); i++) {
CHECK(order->at(i)->rpo_number() == i);
if (!loops_allowed) {
- CHECK_LT(order->at(i)->loop_end(), 0);
+ CHECK_EQ(NULL, order->at(i)->loop_end());
CHECK_EQ(NULL, order->at(i)->loop_header());
}
}
+ int number = 0;
+ for (auto const block : *order) {
+ if (block->deferred()) continue;
+ CHECK_EQ(number, block->ao_number());
+ ++number;
+ }
+ for (auto const block : *order) {
+ if (!block->deferred()) continue;
+ CHECK_EQ(number, block->ao_number());
+ ++number;
+ }
}
static void CheckLoop(BasicBlockVector* order, BasicBlock** blocks,
int body_size) {
BasicBlock* header = blocks[0];
- CHECK_GT(header->loop_end(), 0);
- CHECK_EQ(body_size, (header->loop_end() - header->rpo_number()));
+ BasicBlock* end = header->loop_end();
+ CHECK_NE(NULL, end);
+ CHECK_GT(end->rpo_number(), 0);
+ CHECK_EQ(body_size, end->rpo_number() - header->rpo_number());
for (int i = 0; i < body_size; i++) {
- int num = blocks[i]->rpo_number();
- CHECK(num >= header->rpo_number() && num < header->loop_end());
+ CHECK_GE(blocks[i]->rpo_number(), header->rpo_number());
+ CHECK_LT(blocks[i]->rpo_number(), end->rpo_number());
CHECK(header->LoopContains(blocks[i]));
CHECK(header->IsLoopHeader() || blocks[i]->loop_header() == header);
}
if (header->rpo_number() > 0) {
CHECK_NE(order->at(header->rpo_number() - 1)->loop_header(), header);
}
- if (header->loop_end() < static_cast<int>(order->size())) {
- CHECK_NE(order->at(header->loop_end())->loop_header(), header);
+ if (end->rpo_number() < static_cast<int>(order->size())) {
+ CHECK_NE(order->at(end->rpo_number())->loop_header(), header);
}
}
@@ -153,6 +166,7 @@ TEST(RPOLine) {
BasicBlock* last = schedule.start();
for (int j = 0; j < i; j++) {
BasicBlock* block = schedule.NewBasicBlock();
+ block->set_deferred(i & 1);
schedule.AddGoto(last, block);
last = block;
}
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 068a07ee7..5fa2a2fb3 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -8810,6 +8810,33 @@ TEST(ApiUncaughtException) {
v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener);
}
+
+TEST(ApiUncaughtExceptionInObjectObserve) {
+ v8::internal::FLAG_stack_size = 150;
+ report_count = 0;
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener);
+ CompileRun(
+ "var obj = {};"
+ "var observe_count = 0;"
+ "function observer1() { ++observe_count; };"
+ "function observer2() { ++observe_count; };"
+ "function observer_throws() { throw new Error(); };"
+ "function stack_overflow() { return (function f(x) { f(x+1); })(0); };"
+ "Object.observe(obj, observer_throws.bind());"
+ "Object.observe(obj, observer1);"
+ "Object.observe(obj, stack_overflow);"
+ "Object.observe(obj, observer2);"
+ "Object.observe(obj, observer_throws.bind());"
+ "obj.foo = 'bar';");
+ CHECK_EQ(3, report_count);
+ ExpectInt32("observe_count", 2);
+ v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener);
+}
+
+
static const char* script_resource_name = "ExceptionInNativeScript.js";
static void ExceptionInNativeScriptTestListener(v8::Handle<v8::Message> message,
v8::Handle<Value>) {
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 575f93859..5d38a16ae 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -7594,3 +7594,29 @@ TEST(DebugPromiseRejectedByCallback) {
CHECK(CompileRun("r")->Equals(v8_str("rejectedrejection")));
CHECK_EQ(1, exception_event_counter);
}
+
+
+TEST(DebugBreakOnExceptionInObserveCallback) {
+ DebugLocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::Debug::SetDebugEventListener(&DebugEventCountException);
+ // Break on uncaught exception
+ ChangeBreakOnException(false, true);
+ exception_event_counter = 0;
+
+ v8::Handle<v8::FunctionTemplate> fun =
+ v8::FunctionTemplate::New(isolate, ThrowCallback);
+ env->Global()->Set(v8_str("fun"), fun->GetFunction());
+
+ CompileRun(
+ "var obj = {};"
+ "var callbackRan = false;"
+ "Object.observe(obj, function() {"
+ " callbackRan = true;"
+ " throw Error('foo');"
+ "});"
+ "obj.prop = 1");
+ CHECK(CompileRun("callbackRan")->BooleanValue());
+ CHECK_EQ(1, exception_event_counter);
+}
diff --git a/test/cctest/test-object-observe.cc b/test/cctest/test-object-observe.cc
index d208a2692..8851d8889 100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -130,6 +130,59 @@ TEST(DeliveryOrdering) {
}
+TEST(DeliveryCallbackThrows) {
+ HandleScope scope(CcTest::isolate());
+ LocalContext context(CcTest::isolate());
+ CompileRun(
+ "var obj = {};"
+ "var ordering = [];"
+ "function observer1() { ordering.push(1); };"
+ "function observer2() { ordering.push(2); };"
+ "function observer_throws() {"
+ " ordering.push(0);"
+ " throw new Error();"
+ " ordering.push(-1);"
+ "};"
+ "Object.observe(obj, observer_throws.bind());"
+ "Object.observe(obj, observer1);"
+ "Object.observe(obj, observer_throws.bind());"
+ "Object.observe(obj, observer2);"
+ "Object.observe(obj, observer_throws.bind());"
+ "obj.foo = 'bar';");
+ CHECK_EQ(5, CompileRun("ordering.length")->Int32Value());
+ CHECK_EQ(0, CompileRun("ordering[0]")->Int32Value());
+ CHECK_EQ(1, CompileRun("ordering[1]")->Int32Value());
+ CHECK_EQ(0, CompileRun("ordering[2]")->Int32Value());
+ CHECK_EQ(2, CompileRun("ordering[3]")->Int32Value());
+ CHECK_EQ(0, CompileRun("ordering[4]")->Int32Value());
+}
+
+
+TEST(DeliveryChangesMutationInCallback) {
+ HandleScope scope(CcTest::isolate());
+ LocalContext context(CcTest::isolate());
+ CompileRun(
+ "var obj = {};"
+ "var ordering = [];"
+ "function observer1(records) {"
+ " ordering.push(100 + records.length);"
+ " records.push(11);"
+ " records.push(22);"
+ "};"
+ "function observer2(records) {"
+ " ordering.push(200 + records.length);"
+ " records.push(33);"
+ " records.push(44);"
+ "};"
+ "Object.observe(obj, observer1);"
+ "Object.observe(obj, observer2);"
+ "obj.foo = 'bar';");
+ CHECK_EQ(2, CompileRun("ordering.length")->Int32Value());
+ CHECK_EQ(101, CompileRun("ordering[0]")->Int32Value());
+ CHECK_EQ(201, CompileRun("ordering[1]")->Int32Value());
+}
+
+
TEST(DeliveryOrderingReentrant) {
HandleScope scope(CcTest::isolate());
LocalContext context(CcTest::isolate());
diff --git a/test/cctest/test-transitions.cc b/test/cctest/test-transitions.cc
new file mode 100644
index 000000000..94e230c04
--- /dev/null
+++ b/test/cctest/test-transitions.cc
@@ -0,0 +1,283 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stdlib.h>
+#include <utility>
+
+#include "src/v8.h"
+
+#include "src/compilation-cache.h"
+#include "src/execution.h"
+#include "src/factory.h"
+#include "src/global-handles.h"
+#include "test/cctest/cctest.h"
+
+using namespace v8::internal;
+
+
+//
+// Helper functions.
+//
+
+static void ConnectTransition(Handle<Map> parent,
+ Handle<TransitionArray> transitions,
+ Handle<Map> child) {
+ if (!parent->HasTransitionArray() || *transitions != parent->transitions()) {
+ parent->set_transitions(*transitions);
+ }
+ child->SetBackPointer(*parent);
+}
+
+
+TEST(TransitionArray_SimpleFieldTransitions) {
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Isolate* isolate = CcTest::i_isolate();
+ Factory* factory = isolate->factory();
+
+ Handle<String> name1 = factory->InternalizeUtf8String("foo");
+ Handle<String> name2 = factory->InternalizeUtf8String("bar");
+ PropertyAttributes attributes = NONE;
+
+ Handle<Map> map0 = Map::Create(isolate, 0);
+ Handle<Map> map1 =
+ Map::CopyWithField(map0, name1, handle(HeapType::Any(), isolate),
+ attributes, Representation::Tagged(),
+ OMIT_TRANSITION).ToHandleChecked();
+ Handle<Map> map2 =
+ Map::CopyWithField(map0, name2, handle(HeapType::Any(), isolate),
+ attributes, Representation::Tagged(),
+ OMIT_TRANSITION).ToHandleChecked();
+
+ CHECK(!map0->HasTransitionArray());
+ Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0);
+ CHECK(transitions->IsFullTransitionArray());
+
+ int transition;
+ transitions =
+ transitions->Insert(map0, name1, map1, SIMPLE_PROPERTY_TRANSITION);
+ ConnectTransition(map0, transitions, map1);
+ CHECK(transitions->IsSimpleTransition());
+ transition = transitions->Search(FIELD, *name1, attributes);
+ CHECK_EQ(TransitionArray::kSimpleTransitionIndex, transition);
+ CHECK_EQ(*name1, transitions->GetKey(transition));
+ CHECK_EQ(*map1, transitions->GetTarget(transition));
+
+ transitions =
+ transitions->Insert(map0, name2, map2, SIMPLE_PROPERTY_TRANSITION);
+ ConnectTransition(map0, transitions, map2);
+ CHECK(transitions->IsFullTransitionArray());
+
+ transition = transitions->Search(FIELD, *name1, attributes);
+ CHECK_EQ(*name1, transitions->GetKey(transition));
+ CHECK_EQ(*map1, transitions->GetTarget(transition));
+
+ transition = transitions->Search(FIELD, *name2, attributes);
+ CHECK_EQ(*name2, transitions->GetKey(transition));
+ CHECK_EQ(*map2, transitions->GetTarget(transition));
+
+ DCHECK(transitions->IsSortedNoDuplicates());
+}
+
+
+TEST(TransitionArray_FullFieldTransitions) {
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Isolate* isolate = CcTest::i_isolate();
+ Factory* factory = isolate->factory();
+
+ Handle<String> name1 = factory->InternalizeUtf8String("foo");
+ Handle<String> name2 = factory->InternalizeUtf8String("bar");
+ PropertyAttributes attributes = NONE;
+
+ Handle<Map> map0 = Map::Create(isolate, 0);
+ Handle<Map> map1 =
+ Map::CopyWithField(map0, name1, handle(HeapType::Any(), isolate),
+ attributes, Representation::Tagged(),
+ OMIT_TRANSITION).ToHandleChecked();
+ Handle<Map> map2 =
+ Map::CopyWithField(map0, name2, handle(HeapType::Any(), isolate),
+ attributes, Representation::Tagged(),
+ OMIT_TRANSITION).ToHandleChecked();
+
+ CHECK(!map0->HasTransitionArray());
+ Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0);
+ CHECK(transitions->IsFullTransitionArray());
+
+ int transition;
+ transitions = transitions->Insert(map0, name1, map1, PROPERTY_TRANSITION);
+ ConnectTransition(map0, transitions, map1);
+ CHECK(transitions->IsFullTransitionArray());
+ transition = transitions->Search(FIELD, *name1, attributes);
+ CHECK_EQ(*name1, transitions->GetKey(transition));
+ CHECK_EQ(*map1, transitions->GetTarget(transition));
+
+ transitions = transitions->Insert(map0, name2, map2, PROPERTY_TRANSITION);
+ ConnectTransition(map0, transitions, map2);
+ CHECK(transitions->IsFullTransitionArray());
+
+ transition = transitions->Search(FIELD, *name1, attributes);
+ CHECK_EQ(*name1, transitions->GetKey(transition));
+ CHECK_EQ(*map1, transitions->GetTarget(transition));
+
+ transition = transitions->Search(FIELD, *name2, attributes);
+ CHECK_EQ(*name2, transitions->GetKey(transition));
+ CHECK_EQ(*map2, transitions->GetTarget(transition));
+
+ DCHECK(transitions->IsSortedNoDuplicates());
+}
+
+
+TEST(TransitionArray_DifferentFieldNames) {
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Isolate* isolate = CcTest::i_isolate();
+ Factory* factory = isolate->factory();
+
+ const int PROPS_COUNT = 10;
+ Handle<String> names[PROPS_COUNT];
+ Handle<Map> maps[PROPS_COUNT];
+ PropertyAttributes attributes = NONE;
+
+ Handle<Map> map0 = Map::Create(isolate, 0);
+ CHECK(!map0->HasTransitionArray());
+ Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0);
+ CHECK(transitions->IsFullTransitionArray());
+
+ for (int i = 0; i < PROPS_COUNT; i++) {
+ EmbeddedVector<char, 64> buffer;
+ SNPrintF(buffer, "prop%d", i);
+ Handle<String> name = factory->InternalizeUtf8String(buffer.start());
+ Handle<Map> map =
+ Map::CopyWithField(map0, name, handle(HeapType::Any(), isolate),
+ attributes, Representation::Tagged(),
+ OMIT_TRANSITION).ToHandleChecked();
+ names[i] = name;
+ maps[i] = map;
+
+ transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION);
+ ConnectTransition(map0, transitions, map);
+ }
+
+ for (int i = 0; i < PROPS_COUNT; i++) {
+ int transition = transitions->Search(FIELD, *names[i], attributes);
+ CHECK_EQ(*names[i], transitions->GetKey(transition));
+ CHECK_EQ(*maps[i], transitions->GetTarget(transition));
+ }
+
+ DCHECK(transitions->IsSortedNoDuplicates());
+}
+
+
+TEST(TransitionArray_SameFieldNamesDifferentAttributesSimple) {
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Isolate* isolate = CcTest::i_isolate();
+ Factory* factory = isolate->factory();
+
+ Handle<Map> map0 = Map::Create(isolate, 0);
+ CHECK(!map0->HasTransitionArray());
+ Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0);
+ CHECK(transitions->IsFullTransitionArray());
+
+ const int ATTRS_COUNT = (READ_ONLY | DONT_ENUM | DONT_DELETE) + 1;
+ STATIC_ASSERT(ATTRS_COUNT == 8);
+ Handle<Map> attr_maps[ATTRS_COUNT];
+ Handle<String> name = factory->InternalizeUtf8String("foo");
+
+ // Add transitions for same field name but different attributes.
+ for (int i = 0; i < ATTRS_COUNT; i++) {
+ PropertyAttributes attributes = static_cast<PropertyAttributes>(i);
+
+ Handle<Map> map =
+ Map::CopyWithField(map0, name, handle(HeapType::Any(), isolate),
+ attributes, Representation::Tagged(),
+ OMIT_TRANSITION).ToHandleChecked();
+ attr_maps[i] = map;
+
+ transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION);
+ ConnectTransition(map0, transitions, map);
+ }
+
+ // Ensure that transitions for |name| field are valid.
+ for (int i = 0; i < ATTRS_COUNT; i++) {
+ PropertyAttributes attributes = static_cast<PropertyAttributes>(i);
+
+ int transition = transitions->Search(FIELD, *name, attributes);
+ CHECK_EQ(*name, transitions->GetKey(transition));
+ CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition));
+ }
+
+ DCHECK(transitions->IsSortedNoDuplicates());
+}
+
+
+TEST(TransitionArray_SameFieldNamesDifferentAttributes) {
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Isolate* isolate = CcTest::i_isolate();
+ Factory* factory = isolate->factory();
+
+ const int PROPS_COUNT = 10;
+ Handle<String> names[PROPS_COUNT];
+ Handle<Map> maps[PROPS_COUNT];
+
+ Handle<Map> map0 = Map::Create(isolate, 0);
+ CHECK(!map0->HasTransitionArray());
+ Handle<TransitionArray> transitions = TransitionArray::Allocate(isolate, 0);
+ CHECK(transitions->IsFullTransitionArray());
+
+ // Some number of fields.
+ for (int i = 0; i < PROPS_COUNT; i++) {
+ EmbeddedVector<char, 64> buffer;
+ SNPrintF(buffer, "prop%d", i);
+ Handle<String> name = factory->InternalizeUtf8String(buffer.start());
+ Handle<Map> map =
+ Map::CopyWithField(map0, name, handle(HeapType::Any(), isolate), NONE,
+ Representation::Tagged(),
+ OMIT_TRANSITION).ToHandleChecked();
+ names[i] = name;
+ maps[i] = map;
+
+ transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION);
+ ConnectTransition(map0, transitions, map);
+ }
+
+ const int ATTRS_COUNT = (READ_ONLY | DONT_ENUM | DONT_DELETE) + 1;
+ STATIC_ASSERT(ATTRS_COUNT == 8);
+ Handle<Map> attr_maps[ATTRS_COUNT];
+ Handle<String> name = factory->InternalizeUtf8String("foo");
+
+ // Add transitions for same field name but different attributes.
+ for (int i = 0; i < ATTRS_COUNT; i++) {
+ PropertyAttributes attributes = static_cast<PropertyAttributes>(i);
+
+ Handle<Map> map =
+ Map::CopyWithField(map0, name, handle(HeapType::Any(), isolate),
+ attributes, Representation::Tagged(),
+ OMIT_TRANSITION).ToHandleChecked();
+ attr_maps[i] = map;
+
+ transitions = transitions->Insert(map0, name, map, PROPERTY_TRANSITION);
+ ConnectTransition(map0, transitions, map);
+ }
+
+ // Ensure that transitions for |name| field are valid.
+ for (int i = 0; i < ATTRS_COUNT; i++) {
+ PropertyAttributes attributes = static_cast<PropertyAttributes>(i);
+
+ int transition = transitions->Search(FIELD, *name, attributes);
+ CHECK_EQ(*name, transitions->GetKey(transition));
+ CHECK_EQ(*attr_maps[i], transitions->GetTarget(transition));
+ }
+
+ // Ensure that info about the other fields still valid.
+ for (int i = 0; i < PROPS_COUNT; i++) {
+ int transition = transitions->Search(FIELD, *names[i], NONE);
+ CHECK_EQ(*names[i], transitions->GetKey(transition));
+ CHECK_EQ(*maps[i], transitions->GetTarget(transition));
+ }
+
+ DCHECK(transitions->IsSortedNoDuplicates());
+}
diff --git a/test/mjsunit/asm/embenchen/box2d.js b/test/mjsunit/asm/embenchen/box2d.js
new file mode 100644
index 000000000..d524af2d7
--- /dev/null
+++ b/test/mjsunit/asm/embenchen/box2d.js
@@ -0,0 +1,20326 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var EXPECTED_OUTPUT =
+ /frame averages: .+ \+- .+, range: .+ to .+ \n/;
+var Module = {
+ arguments: [1],
+ print: function(x) {Module.printBuffer += x + '\n';},
+ preRun: [function() {Module.printBuffer = ''}],
+ postRun: [function() {
+ assertTrue(EXPECTED_OUTPUT.test(Module.printBuffer));
+ }],
+};
+// The Module object: Our interface to the outside world. We import
+// and export values on it, and do the work to get that through
+// closure compiler if necessary. There are various ways Module can be used:
+// 1. Not defined. We create it here
+// 2. A function parameter, function(Module) { ..generated code.. }
+// 3. pre-run appended it, var Module = {}; ..generated code..
+// 4. External script tag defines var Module.
+// We need to do an eval in order to handle the closure compiler
+// case, where this code here is minified but Module was defined
+// elsewhere (e.g. case 4 above). We also need to check if Module
+// already exists (e.g. case 3 above).
+// Note that if you want to run closure, and also to use Module
+// after the generated code, you will need to define var Module = {};
+// before the code. Then that object will be used in the code, and you
+// can continue to use Module afterwards as well.
+var Module;
+if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {};
+
+// Sometimes an existing Module object exists with properties
+// meant to overwrite the default module functionality. Here
+// we collect those properties and reapply _after_ we configure
+// the current environment's defaults to avoid having to be so
+// defensive during initialization.
+var moduleOverrides = {};
+for (var key in Module) {
+ if (Module.hasOwnProperty(key)) {
+ moduleOverrides[key] = Module[key];
+ }
+}
+
+// The environment setup code below is customized to use Module.
+// *** Environment setup code ***
+var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
+var ENVIRONMENT_IS_WEB = typeof window === 'object';
+var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
+var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+
+if (ENVIRONMENT_IS_NODE) {
+ // Expose functionality in the same simple way that the shells work
+ // Note that we pollute the global namespace here, otherwise we break in node
+ if (!Module['print']) Module['print'] = function print(x) {
+ process['stdout'].write(x + '\n');
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ process['stderr'].write(x + '\n');
+ };
+
+ var nodeFS = require('fs');
+ var nodePath = require('path');
+
+ Module['read'] = function read(filename, binary) {
+ filename = nodePath['normalize'](filename);
+ var ret = nodeFS['readFileSync'](filename);
+ // The path is absolute if the normalized version is the same as the resolved.
+ if (!ret && filename != nodePath['resolve'](filename)) {
+ filename = path.join(__dirname, '..', 'src', filename);
+ ret = nodeFS['readFileSync'](filename);
+ }
+ if (ret && !binary) ret = ret.toString();
+ return ret;
+ };
+
+ Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
+
+ Module['load'] = function load(f) {
+ globalEval(read(f));
+ };
+
+ Module['arguments'] = process['argv'].slice(2);
+
+ module['exports'] = Module;
+}
+else if (ENVIRONMENT_IS_SHELL) {
+ if (!Module['print']) Module['print'] = print;
+ if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
+
+ if (typeof read != 'undefined') {
+ Module['read'] = read;
+ } else {
+ Module['read'] = function read() { throw 'no read() available (jsc?)' };
+ }
+
+ Module['readBinary'] = function readBinary(f) {
+ return read(f, 'binary');
+ };
+
+ if (typeof scriptArgs != 'undefined') {
+ Module['arguments'] = scriptArgs;
+ } else if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ this['Module'] = Module;
+
+ eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
+}
+else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
+ Module['read'] = function read(url) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ xhr.send(null);
+ return xhr.responseText;
+ };
+
+ if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ if (typeof console !== 'undefined') {
+ if (!Module['print']) Module['print'] = function print(x) {
+ console.log(x);
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ console.log(x);
+ };
+ } else {
+ // Probably a worker, and without console.log. We can do very little here...
+ var TRY_USE_DUMP = false;
+ if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
+ dump(x);
+ }) : (function(x) {
+ // self.postMessage(x); // enable this if you want stdout to be sent as messages
+ }));
+ }
+
+ if (ENVIRONMENT_IS_WEB) {
+ window['Module'] = Module;
+ } else {
+ Module['load'] = importScripts;
+ }
+}
+else {
+ // Unreachable because SHELL is dependant on the others
+ throw 'Unknown runtime environment. Where are we?';
+}
+
+function globalEval(x) {
+ eval.call(null, x);
+}
+if (!Module['load'] == 'undefined' && Module['read']) {
+ Module['load'] = function load(f) {
+ globalEval(Module['read'](f));
+ };
+}
+if (!Module['print']) {
+ Module['print'] = function(){};
+}
+if (!Module['printErr']) {
+ Module['printErr'] = Module['print'];
+}
+if (!Module['arguments']) {
+ Module['arguments'] = [];
+}
+// *** Environment setup code ***
+
+// Closure helpers
+Module.print = Module['print'];
+Module.printErr = Module['printErr'];
+
+// Callbacks
+Module['preRun'] = [];
+Module['postRun'] = [];
+
+// Merge back in the overrides
+for (var key in moduleOverrides) {
+ if (moduleOverrides.hasOwnProperty(key)) {
+ Module[key] = moduleOverrides[key];
+ }
+}
+
+
+
+// === Auto-generated preamble library stuff ===
+
+//========================================
+// Runtime code shared with compiler
+//========================================
+
+var Runtime = {
+ stackSave: function () {
+ return STACKTOP;
+ },
+ stackRestore: function (stackTop) {
+ STACKTOP = stackTop;
+ },
+ forceAlign: function (target, quantum) {
+ quantum = quantum || 4;
+ if (quantum == 1) return target;
+ if (isNumber(target) && isNumber(quantum)) {
+ return Math.ceil(target/quantum)*quantum;
+ } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
+ return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')';
+ }
+ return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
+ },
+ isNumberType: function (type) {
+ return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
+ },
+ isPointerType: function isPointerType(type) {
+ return type[type.length-1] == '*';
+},
+ isStructType: function isStructType(type) {
+ if (isPointerType(type)) return false;
+ if (isArrayType(type)) return true;
+ if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
+ // See comment in isStructPointerType()
+ return type[0] == '%';
+},
+ INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
+ FLOAT_TYPES: {"float":0,"double":0},
+ or64: function (x, y) {
+ var l = (x | 0) | (y | 0);
+ var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ and64: function (x, y) {
+ var l = (x | 0) & (y | 0);
+ var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ xor64: function (x, y) {
+ var l = (x | 0) ^ (y | 0);
+ var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ getNativeTypeSize: function (type) {
+ switch (type) {
+ case 'i1': case 'i8': return 1;
+ case 'i16': return 2;
+ case 'i32': return 4;
+ case 'i64': return 8;
+ case 'float': return 4;
+ case 'double': return 8;
+ default: {
+ if (type[type.length-1] === '*') {
+ return Runtime.QUANTUM_SIZE; // A pointer
+ } else if (type[0] === 'i') {
+ var bits = parseInt(type.substr(1));
+ assert(bits % 8 === 0);
+ return bits/8;
+ } else {
+ return 0;
+ }
+ }
+ }
+ },
+ getNativeFieldSize: function (type) {
+ return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
+ },
+ dedup: function dedup(items, ident) {
+ var seen = {};
+ if (ident) {
+ return items.filter(function(item) {
+ if (seen[item[ident]]) return false;
+ seen[item[ident]] = true;
+ return true;
+ });
+ } else {
+ return items.filter(function(item) {
+ if (seen[item]) return false;
+ seen[item] = true;
+ return true;
+ });
+ }
+},
+ set: function set() {
+ var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
+ var ret = {};
+ for (var i = 0; i < args.length; i++) {
+ ret[args[i]] = 0;
+ }
+ return ret;
+},
+ STACK_ALIGN: 8,
+ getAlignSize: function (type, size, vararg) {
+ // we align i64s and doubles on 64-bit boundaries, unlike x86
+ if (!vararg && (type == 'i64' || type == 'double')) return 8;
+ if (!type) return Math.min(size, 8); // align structures internally to 64 bits
+ return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
+ },
+ calculateStructAlignment: function calculateStructAlignment(type) {
+ type.flatSize = 0;
+ type.alignSize = 0;
+ var diffs = [];
+ var prev = -1;
+ var index = 0;
+ type.flatIndexes = type.fields.map(function(field) {
+ index++;
+ var size, alignSize;
+ if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
+ size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
+ alignSize = Runtime.getAlignSize(field, size);
+ } else if (Runtime.isStructType(field)) {
+ if (field[1] === '0') {
+ // this is [0 x something]. When inside another structure like here, it must be at the end,
+ // and it adds no size
+ // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');
+ size = 0;
+ if (Types.types[field]) {
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ } else {
+ alignSize = type.alignSize || QUANTUM_SIZE;
+ }
+ } else {
+ size = Types.types[field].flatSize;
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ }
+ } else if (field[0] == 'b') {
+ // bN, large number field, like a [N x i8]
+ size = field.substr(1)|0;
+ alignSize = 1;
+ } else if (field[0] === '<') {
+ // vector type
+ size = alignSize = Types.types[field].flatSize; // fully aligned
+ } else if (field[0] === 'i') {
+ // illegal integer field, that could not be legalized because it is an internal structure field
+ // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
+ size = alignSize = parseInt(field.substr(1))/8;
+ assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
+ } else {
+ assert(false, 'invalid type for calculateStructAlignment');
+ }
+ if (type.packed) alignSize = 1;
+ type.alignSize = Math.max(type.alignSize, alignSize);
+ var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
+ type.flatSize = curr + size;
+ if (prev >= 0) {
+ diffs.push(curr-prev);
+ }
+ prev = curr;
+ return curr;
+ });
+ if (type.name_ && type.name_[0] === '[') {
+ // arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
+ // allocating a potentially huge array for [999999 x i8] etc.
+ type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
+ }
+ type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
+ if (diffs.length == 0) {
+ type.flatFactor = type.flatSize;
+ } else if (Runtime.dedup(diffs).length == 1) {
+ type.flatFactor = diffs[0];
+ }
+ type.needsFlattening = (type.flatFactor != 1);
+ return type.flatIndexes;
+ },
+ generateStructInfo: function (struct, typeName, offset) {
+ var type, alignment;
+ if (typeName) {
+ offset = offset || 0;
+ type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
+ if (!type) return null;
+ if (type.fields.length != struct.length) {
+ printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');
+ return null;
+ }
+ alignment = type.flatIndexes;
+ } else {
+ var type = { fields: struct.map(function(item) { return item[0] }) };
+ alignment = Runtime.calculateStructAlignment(type);
+ }
+ var ret = {
+ __size__: type.flatSize
+ };
+ if (typeName) {
+ struct.forEach(function(item, i) {
+ if (typeof item === 'string') {
+ ret[item] = alignment[i] + offset;
+ } else {
+ // embedded struct
+ var key;
+ for (var k in item) key = k;
+ ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
+ }
+ });
+ } else {
+ struct.forEach(function(item, i) {
+ ret[item[1]] = alignment[i];
+ });
+ }
+ return ret;
+ },
+ dynCall: function (sig, ptr, args) {
+ if (args && args.length) {
+ if (!args.splice) args = Array.prototype.slice.call(args);
+ args.splice(0, 0, ptr);
+ return Module['dynCall_' + sig].apply(null, args);
+ } else {
+ return Module['dynCall_' + sig].call(null, ptr);
+ }
+ },
+ functionPointers: [],
+ addFunction: function (func) {
+ for (var i = 0; i < Runtime.functionPointers.length; i++) {
+ if (!Runtime.functionPointers[i]) {
+ Runtime.functionPointers[i] = func;
+ return 2*(1 + i);
+ }
+ }
+ throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
+ },
+ removeFunction: function (index) {
+ Runtime.functionPointers[(index-2)/2] = null;
+ },
+ getAsmConst: function (code, numArgs) {
+ // code is a constant string on the heap, so we can cache these
+ if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
+ var func = Runtime.asmConstCache[code];
+ if (func) return func;
+ var args = [];
+ for (var i = 0; i < numArgs; i++) {
+ args.push(String.fromCharCode(36) + i); // $0, $1 etc
+ }
+ var source = Pointer_stringify(code);
+ if (source[0] === '"') {
+ // tolerate EM_ASM("..code..") even though EM_ASM(..code..) is correct
+ if (source.indexOf('"', 1) === source.length-1) {
+ source = source.substr(1, source.length-2);
+ } else {
+ // something invalid happened, e.g. EM_ASM("..code($0)..", input)
+ abort('invalid EM_ASM input |' + source + '|. Please use EM_ASM(..code..) (no quotes) or EM_ASM({ ..code($0).. }, input) (to input values)');
+ }
+ }
+ try {
+ var evalled = eval('(function(' + args.join(',') + '){ ' + source + ' })'); // new Function does not allow upvars in node
+ } catch(e) {
+ Module.printErr('error in executing inline EM_ASM code: ' + e + ' on: \n\n' + source + '\n\nwith args |' + args + '| (make sure to use the right one out of EM_ASM, EM_ASM_ARGS, etc.)');
+ throw e;
+ }
+ return Runtime.asmConstCache[code] = evalled;
+ },
+ warnOnce: function (text) {
+ if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
+ if (!Runtime.warnOnce.shown[text]) {
+ Runtime.warnOnce.shown[text] = 1;
+ Module.printErr(text);
+ }
+ },
+ funcWrappers: {},
+ getFuncWrapper: function (func, sig) {
+ assert(sig);
+ if (!Runtime.funcWrappers[func]) {
+ Runtime.funcWrappers[func] = function dynCall_wrapper() {
+ return Runtime.dynCall(sig, func, arguments);
+ };
+ }
+ return Runtime.funcWrappers[func];
+ },
+ UTF8Processor: function () {
+ var buffer = [];
+ var needed = 0;
+ this.processCChar = function (code) {
+ code = code & 0xFF;
+
+ if (buffer.length == 0) {
+ if ((code & 0x80) == 0x00) { // 0xxxxxxx
+ return String.fromCharCode(code);
+ }
+ buffer.push(code);
+ if ((code & 0xE0) == 0xC0) { // 110xxxxx
+ needed = 1;
+ } else if ((code & 0xF0) == 0xE0) { // 1110xxxx
+ needed = 2;
+ } else { // 11110xxx
+ needed = 3;
+ }
+ return '';
+ }
+
+ if (needed) {
+ buffer.push(code);
+ needed--;
+ if (needed > 0) return '';
+ }
+
+ var c1 = buffer[0];
+ var c2 = buffer[1];
+ var c3 = buffer[2];
+ var c4 = buffer[3];
+ var ret;
+ if (buffer.length == 2) {
+ ret = String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ } else if (buffer.length == 3) {
+ ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ } else {
+ // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |
+ ((c3 & 0x3F) << 6) | (c4 & 0x3F);
+ ret = String.fromCharCode(
+ Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,
+ (codePoint - 0x10000) % 0x400 + 0xDC00);
+ }
+ buffer.length = 0;
+ return ret;
+ }
+ this.processJSString = function processJSString(string) {
+ /* TODO: use TextEncoder when present,
+ var encoder = new TextEncoder();
+ encoder['encoding'] = "utf-8";
+ var utf8Array = encoder['encode'](aMsg.data);
+ */
+ string = unescape(encodeURIComponent(string));
+ var ret = [];
+ for (var i = 0; i < string.length; i++) {
+ ret.push(string.charCodeAt(i));
+ }
+ return ret;
+ }
+ },
+ getCompilerSetting: function (name) {
+ throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
+ },
+ stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+7)&-8); return ret; },
+ staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = (((STATICTOP)+7)&-8); return ret; },
+ dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = (((DYNAMICTOP)+7)&-8); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
+ alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },
+ makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*(+4294967296))) : ((+((low>>>0)))+((+((high|0)))*(+4294967296)))); return ret; },
+ GLOBAL_BASE: 8,
+ QUANTUM_SIZE: 4,
+ __dummy__: 0
+}
+
+
+Module['Runtime'] = Runtime;
+
+
+
+
+
+
+
+
+
+//========================================
+// Runtime essentials
+//========================================
+
+var __THREW__ = 0; // Used in checking for thrown exceptions.
+
+var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()
+var EXITSTATUS = 0;
+
+var undef = 0;
+// tempInt is used for 32-bit signed values or smaller. tempBigInt is used
+// for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
+var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
+var tempI64, tempI64b;
+var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
+
+function assert(condition, text) {
+ if (!condition) {
+ abort('Assertion failed: ' + text);
+ }
+}
+
+var globalScope = this;
+
+// C calling interface. A convenient way to call C functions (in C files, or
+// defined with extern "C").
+//
+// Note: LLVM optimizations can inline and remove functions, after which you will not be
+// able to call them. Closure can also do so. To avoid that, add your function to
+// the exports using something like
+//
+// -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]'
+//
+// @param ident The name of the C function (note that C++ functions will be name-mangled - use extern "C")
+// @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and
+// 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).
+// @param argTypes An array of the types of arguments for the function (if there are no arguments, this can be ommitted). Types are as in returnType,
+// except that 'array' is not possible (there is no way for us to know the length of the array)
+// @param args An array of the arguments to the function, as native JS values (as in returnType)
+// Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).
+// @return The return value, as a native JS value (as in returnType)
+function ccall(ident, returnType, argTypes, args) {
+ return ccallFunc(getCFunc(ident), returnType, argTypes, args);
+}
+Module["ccall"] = ccall;
+
+// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
+function getCFunc(ident) {
+ try {
+ var func = Module['_' + ident]; // closure exported function
+ if (!func) func = eval('_' + ident); // explicit lookup
+ } catch(e) {
+ }
+ assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
+ return func;
+}
+
+// Internal function that does a C call using a function, not an identifier
+function ccallFunc(func, returnType, argTypes, args) {
+ var stack = 0;
+ function toC(value, type) {
+ if (type == 'string') {
+ if (value === null || value === undefined || value === 0) return 0; // null string
+ value = intArrayFromString(value);
+ type = 'array';
+ }
+ if (type == 'array') {
+ if (!stack) stack = Runtime.stackSave();
+ var ret = Runtime.stackAlloc(value.length);
+ writeArrayToMemory(value, ret);
+ return ret;
+ }
+ return value;
+ }
+ function fromC(value, type) {
+ if (type == 'string') {
+ return Pointer_stringify(value);
+ }
+ assert(type != 'array');
+ return value;
+ }
+ var i = 0;
+ var cArgs = args ? args.map(function(arg) {
+ return toC(arg, argTypes[i++]);
+ }) : [];
+ var ret = fromC(func.apply(null, cArgs), returnType);
+ if (stack) Runtime.stackRestore(stack);
+ return ret;
+}
+
+// Returns a native JS wrapper for a C function. This is similar to ccall, but
+// returns a function you can call repeatedly in a normal way. For example:
+//
+// var my_function = cwrap('my_c_function', 'number', ['number', 'number']);
+// alert(my_function(5, 22));
+// alert(my_function(99, 12));
+//
+function cwrap(ident, returnType, argTypes) {
+ var func = getCFunc(ident);
+ return function() {
+ return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));
+ }
+}
+Module["cwrap"] = cwrap;
+
+// Sets a value in memory in a dynamic way at run-time. Uses the
+// type data. This is the same as makeSetValue, except that
+// makeSetValue is done at compile-time and generates the needed
+// code then, whereas this function picks the right code at
+// run-time.
+// Note that setValue and getValue only do *aligned* writes and reads!
+// Note that ccall uses JS types as for defining types, while setValue and
+// getValue need LLVM types ('i8', 'i32') - this is a lower-level operation
+function setValue(ptr, value, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': HEAP8[(ptr)]=value; break;
+ case 'i8': HEAP8[(ptr)]=value; break;
+ case 'i16': HEAP16[((ptr)>>1)]=value; break;
+ case 'i32': HEAP32[((ptr)>>2)]=value; break;
+ case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= (+1) ? (tempDouble > (+0) ? ((Math_min((+(Math_floor((tempDouble)/(+4294967296)))), (+4294967295)))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+4294967296))))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
+ case 'float': HEAPF32[((ptr)>>2)]=value; break;
+ case 'double': HEAPF64[((ptr)>>3)]=value; break;
+ default: abort('invalid type for setValue: ' + type);
+ }
+}
+Module['setValue'] = setValue;
+
+// Parallel to setValue.
+function getValue(ptr, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': return HEAP8[(ptr)];
+ case 'i8': return HEAP8[(ptr)];
+ case 'i16': return HEAP16[((ptr)>>1)];
+ case 'i32': return HEAP32[((ptr)>>2)];
+ case 'i64': return HEAP32[((ptr)>>2)];
+ case 'float': return HEAPF32[((ptr)>>2)];
+ case 'double': return HEAPF64[((ptr)>>3)];
+ default: abort('invalid type for setValue: ' + type);
+ }
+ return null;
+}
+Module['getValue'] = getValue;
+
+var ALLOC_NORMAL = 0; // Tries to use _malloc()
+var ALLOC_STACK = 1; // Lives for the duration of the current function call
+var ALLOC_STATIC = 2; // Cannot be freed
+var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
+var ALLOC_NONE = 4; // Do not allocate
+Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
+Module['ALLOC_STACK'] = ALLOC_STACK;
+Module['ALLOC_STATIC'] = ALLOC_STATIC;
+Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;
+Module['ALLOC_NONE'] = ALLOC_NONE;
+
+// allocate(): This is for internal use. You can use it yourself as well, but the interface
+// is a little tricky (see docs right below). The reason is that it is optimized
+// for multiple syntaxes to save space in generated code. So you should
+// normally not use allocate(), and instead allocate memory using _malloc(),
+// initialize it with setValue(), and so forth.
+// @slab: An array of data, or a number. If a number, then the size of the block to allocate,
+// in *bytes* (note that this is sometimes confusing: the next parameter does not
+// affect this!)
+// @types: Either an array of types, one for each byte (or 0 if no type at that position),
+// or a single type which is used for the entire block. This only matters if there
+// is initial data - if @slab is a number, then this does not matter at all and is
+// ignored.
+// @allocator: How to allocate memory, see ALLOC_*
+function allocate(slab, types, allocator, ptr) {
+ var zeroinit, size;
+ if (typeof slab === 'number') {
+ zeroinit = true;
+ size = slab;
+ } else {
+ zeroinit = false;
+ size = slab.length;
+ }
+
+ var singleType = typeof types === 'string' ? types : null;
+
+ var ret;
+ if (allocator == ALLOC_NONE) {
+ ret = ptr;
+ } else {
+ ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
+ }
+
+ if (zeroinit) {
+ var ptr = ret, stop;
+ assert((ret & 3) == 0);
+ stop = ret + (size & ~3);
+ for (; ptr < stop; ptr += 4) {
+ HEAP32[((ptr)>>2)]=0;
+ }
+ stop = ret + size;
+ while (ptr < stop) {
+ HEAP8[((ptr++)|0)]=0;
+ }
+ return ret;
+ }
+
+ if (singleType === 'i8') {
+ if (slab.subarray || slab.slice) {
+ HEAPU8.set(slab, ret);
+ } else {
+ HEAPU8.set(new Uint8Array(slab), ret);
+ }
+ return ret;
+ }
+
+ var i = 0, type, typeSize, previousType;
+ while (i < size) {
+ var curr = slab[i];
+
+ if (typeof curr === 'function') {
+ curr = Runtime.getFunctionIndex(curr);
+ }
+
+ type = singleType || types[i];
+ if (type === 0) {
+ i++;
+ continue;
+ }
+
+ if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
+
+ setValue(ret+i, curr, type);
+
+ // no need to look up size unless type changes, so cache it
+ if (previousType !== type) {
+ typeSize = Runtime.getNativeTypeSize(type);
+ previousType = type;
+ }
+ i += typeSize;
+ }
+
+ return ret;
+}
+Module['allocate'] = allocate;
+
+function Pointer_stringify(ptr, /* optional */ length) {
+ // TODO: use TextDecoder
+ // Find the length, and check for UTF while doing so
+ var hasUtf = false;
+ var t;
+ var i = 0;
+ while (1) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ if (t >= 128) hasUtf = true;
+ else if (t == 0 && !length) break;
+ i++;
+ if (length && i == length) break;
+ }
+ if (!length) length = i;
+
+ var ret = '';
+
+ if (!hasUtf) {
+ var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
+ var curr;
+ while (length > 0) {
+ curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
+ ret = ret ? ret + curr : curr;
+ ptr += MAX_CHUNK;
+ length -= MAX_CHUNK;
+ }
+ return ret;
+ }
+
+ var utf8 = new Runtime.UTF8Processor();
+ for (i = 0; i < length; i++) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ ret += utf8.processCChar(t);
+ }
+ return ret;
+}
+Module['Pointer_stringify'] = Pointer_stringify;
+
+// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF16ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
+ if (codeUnit == 0)
+ return str;
+ ++i;
+ // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
+ str += String.fromCharCode(codeUnit);
+ }
+}
+Module['UTF16ToString'] = UTF16ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
+function stringToUTF16(str, outPtr) {
+ for(var i = 0; i < str.length; ++i) {
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
+ HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP16[(((outPtr)+(str.length*2))>>1)]=0;
+}
+Module['stringToUTF16'] = stringToUTF16;
+
+// Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF32ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
+ if (utf32 == 0)
+ return str;
+ ++i;
+ // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
+ if (utf32 >= 0x10000) {
+ var ch = utf32 - 0x10000;
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
+ } else {
+ str += String.fromCharCode(utf32);
+ }
+ }
+}
+Module['UTF32ToString'] = UTF32ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
+// but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.
+function stringToUTF32(str, outPtr) {
+ var iChar = 0;
+ for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
+ var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
+ var trailSurrogate = str.charCodeAt(++iCodeUnit);
+ codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
+ }
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit;
+ ++iChar;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=0;
+}
+Module['stringToUTF32'] = stringToUTF32;
+
+function demangle(func) {
+ var i = 3;
+ // params, etc.
+ var basicTypes = {
+ 'v': 'void',
+ 'b': 'bool',
+ 'c': 'char',
+ 's': 'short',
+ 'i': 'int',
+ 'l': 'long',
+ 'f': 'float',
+ 'd': 'double',
+ 'w': 'wchar_t',
+ 'a': 'signed char',
+ 'h': 'unsigned char',
+ 't': 'unsigned short',
+ 'j': 'unsigned int',
+ 'm': 'unsigned long',
+ 'x': 'long long',
+ 'y': 'unsigned long long',
+ 'z': '...'
+ };
+ var subs = [];
+ var first = true;
+ function dump(x) {
+ //return;
+ if (x) Module.print(x);
+ Module.print(func);
+ var pre = '';
+ for (var a = 0; a < i; a++) pre += ' ';
+ Module.print (pre + '^');
+ }
+ function parseNested() {
+ i++;
+ if (func[i] === 'K') i++; // ignore const
+ var parts = [];
+ while (func[i] !== 'E') {
+ if (func[i] === 'S') { // substitution
+ i++;
+ var next = func.indexOf('_', i);
+ var num = func.substring(i, next) || 0;
+ parts.push(subs[num] || '?');
+ i = next+1;
+ continue;
+ }
+ if (func[i] === 'C') { // constructor
+ parts.push(parts[parts.length-1]);
+ i += 2;
+ continue;
+ }
+ var size = parseInt(func.substr(i));
+ var pre = size.toString().length;
+ if (!size || !pre) { i--; break; } // counter i++ below us
+ var curr = func.substr(i + pre, size);
+ parts.push(curr);
+ subs.push(curr);
+ i += pre + size;
+ }
+ i++; // skip E
+ return parts;
+ }
+ function parse(rawList, limit, allowVoid) { // main parser
+ limit = limit || Infinity;
+ var ret = '', list = [];
+ function flushList() {
+ return '(' + list.join(', ') + ')';
+ }
+ var name;
+ if (func[i] === 'N') {
+ // namespaced N-E
+ name = parseNested().join('::');
+ limit--;
+ if (limit === 0) return rawList ? [name] : name;
+ } else {
+ // not namespaced
+ if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
+ var size = parseInt(func.substr(i));
+ if (size) {
+ var pre = size.toString().length;
+ name = func.substr(i + pre, size);
+ i += pre + size;
+ }
+ }
+ first = false;
+ if (func[i] === 'I') {
+ i++;
+ var iList = parse(true);
+ var iRet = parse(true, 1, true);
+ ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
+ } else {
+ ret = name;
+ }
+ paramLoop: while (i < func.length && limit-- > 0) {
+ //dump('paramLoop');
+ var c = func[i++];
+ if (c in basicTypes) {
+ list.push(basicTypes[c]);
+ } else {
+ switch (c) {
+ case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
+ case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
+ case 'L': { // literal
+ i++; // skip basic type
+ var end = func.indexOf('E', i);
+ var size = end - i;
+ list.push(func.substr(i, size));
+ i += size + 2; // size + 'EE'
+ break;
+ }
+ case 'A': { // array
+ var size = parseInt(func.substr(i));
+ i += size.toString().length;
+ if (func[i] !== '_') throw '?';
+ i++; // skip _
+ list.push(parse(true, 1, true)[0] + ' [' + size + ']');
+ break;
+ }
+ case 'E': break paramLoop;
+ default: ret += '?' + c; break paramLoop;
+ }
+ }
+ }
+ if (!allowVoid && list.length === 1 && list[0] === 'void') list = []; // avoid (void)
+ if (rawList) {
+ if (ret) {
+ list.push(ret + '?');
+ }
+ return list;
+ } else {
+ return ret + flushList();
+ }
+ }
+ try {
+ // Special-case the entry point, since its name differs from other name mangling.
+ if (func == 'Object._main' || func == '_main') {
+ return 'main()';
+ }
+ if (typeof func === 'number') func = Pointer_stringify(func);
+ if (func[0] !== '_') return func;
+ if (func[1] !== '_') return func; // C function
+ if (func[2] !== 'Z') return func;
+ switch (func[3]) {
+ case 'n': return 'operator new()';
+ case 'd': return 'operator delete()';
+ }
+ return parse();
+ } catch(e) {
+ return func;
+ }
+}
+
+function demangleAll(text) {
+ return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });
+}
+
+function stackTrace() {
+ var stack = new Error().stack;
+ return stack ? demangleAll(stack) : '(no stack trace available)'; // Stack trace is not available at least on IE10 and Safari 6.
+}
+
+// Memory management
+
+var PAGE_SIZE = 4096;
+function alignMemoryPage(x) {
+ return (x+4095)&-4096;
+}
+
+var HEAP;
+var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
+
+var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area
+var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area
+var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk
+
+function enlargeMemory() {
+ abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
+}
+
+var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
+var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 134217728;
+var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
+
+var totalMemory = 4096;
+while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
+ if (totalMemory < 16*1024*1024) {
+ totalMemory *= 2;
+ } else {
+ totalMemory += 16*1024*1024
+ }
+}
+if (totalMemory !== TOTAL_MEMORY) {
+ Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
+ TOTAL_MEMORY = totalMemory;
+}
+
+// Initialize the runtime's memory
+// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
+assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
+ 'JS engine does not provide full typed array support');
+
+var buffer = new ArrayBuffer(TOTAL_MEMORY);
+HEAP8 = new Int8Array(buffer);
+HEAP16 = new Int16Array(buffer);
+HEAP32 = new Int32Array(buffer);
+HEAPU8 = new Uint8Array(buffer);
+HEAPU16 = new Uint16Array(buffer);
+HEAPU32 = new Uint32Array(buffer);
+HEAPF32 = new Float32Array(buffer);
+HEAPF64 = new Float64Array(buffer);
+
+// Endianness check (note: assumes compiler arch was little-endian)
+HEAP32[0] = 255;
+assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
+
+Module['HEAP'] = HEAP;
+Module['HEAP8'] = HEAP8;
+Module['HEAP16'] = HEAP16;
+Module['HEAP32'] = HEAP32;
+Module['HEAPU8'] = HEAPU8;
+Module['HEAPU16'] = HEAPU16;
+Module['HEAPU32'] = HEAPU32;
+Module['HEAPF32'] = HEAPF32;
+Module['HEAPF64'] = HEAPF64;
+
+function callRuntimeCallbacks(callbacks) {
+ while(callbacks.length > 0) {
+ var callback = callbacks.shift();
+ if (typeof callback == 'function') {
+ callback();
+ continue;
+ }
+ var func = callback.func;
+ if (typeof func === 'number') {
+ if (callback.arg === undefined) {
+ Runtime.dynCall('v', func);
+ } else {
+ Runtime.dynCall('vi', func, [callback.arg]);
+ }
+ } else {
+ func(callback.arg === undefined ? null : callback.arg);
+ }
+ }
+}
+
+var __ATPRERUN__ = []; // functions called before the runtime is initialized
+var __ATINIT__ = []; // functions called during startup
+var __ATMAIN__ = []; // functions called when main() is to be run
+var __ATEXIT__ = []; // functions called during shutdown
+var __ATPOSTRUN__ = []; // functions called after the runtime has exited
+
+var runtimeInitialized = false;
+
+function preRun() {
+ // compatibility - merge in anything from Module['preRun'] at this time
+ if (Module['preRun']) {
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
+ while (Module['preRun'].length) {
+ addOnPreRun(Module['preRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPRERUN__);
+}
+
+function ensureInitRuntime() {
+ if (runtimeInitialized) return;
+ runtimeInitialized = true;
+ callRuntimeCallbacks(__ATINIT__);
+}
+
+function preMain() {
+ callRuntimeCallbacks(__ATMAIN__);
+}
+
+function exitRuntime() {
+ callRuntimeCallbacks(__ATEXIT__);
+}
+
+function postRun() {
+ // compatibility - merge in anything from Module['postRun'] at this time
+ if (Module['postRun']) {
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
+ while (Module['postRun'].length) {
+ addOnPostRun(Module['postRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPOSTRUN__);
+}
+
+function addOnPreRun(cb) {
+ __ATPRERUN__.unshift(cb);
+}
+Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;
+
+function addOnInit(cb) {
+ __ATINIT__.unshift(cb);
+}
+Module['addOnInit'] = Module.addOnInit = addOnInit;
+
+function addOnPreMain(cb) {
+ __ATMAIN__.unshift(cb);
+}
+Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;
+
+function addOnExit(cb) {
+ __ATEXIT__.unshift(cb);
+}
+Module['addOnExit'] = Module.addOnExit = addOnExit;
+
+function addOnPostRun(cb) {
+ __ATPOSTRUN__.unshift(cb);
+}
+Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;
+
+// Tools
+
+// This processes a JS string into a C-line array of numbers, 0-terminated.
+// For LLVM-originating strings, see parser.js:parseLLVMString function
+function intArrayFromString(stringy, dontAddNull, length /* optional */) {
+ var ret = (new Runtime.UTF8Processor()).processJSString(stringy);
+ if (length) {
+ ret.length = length;
+ }
+ if (!dontAddNull) {
+ ret.push(0);
+ }
+ return ret;
+}
+Module['intArrayFromString'] = intArrayFromString;
+
+function intArrayToString(array) {
+ var ret = [];
+ for (var i = 0; i < array.length; i++) {
+ var chr = array[i];
+ if (chr > 0xFF) {
+ chr &= 0xFF;
+ }
+ ret.push(String.fromCharCode(chr));
+ }
+ return ret.join('');
+}
+Module['intArrayToString'] = intArrayToString;
+
+// Write a Javascript array to somewhere in the heap
+function writeStringToMemory(string, buffer, dontAddNull) {
+ var array = intArrayFromString(string, dontAddNull);
+ var i = 0;
+ while (i < array.length) {
+ var chr = array[i];
+ HEAP8[(((buffer)+(i))|0)]=chr;
+ i = i + 1;
+ }
+}
+Module['writeStringToMemory'] = writeStringToMemory;
+
+function writeArrayToMemory(array, buffer) {
+ for (var i = 0; i < array.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=array[i];
+ }
+}
+Module['writeArrayToMemory'] = writeArrayToMemory;
+
+function writeAsciiToMemory(str, buffer, dontAddNull) {
+ for (var i = 0; i < str.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=str.charCodeAt(i);
+ }
+ if (!dontAddNull) HEAP8[(((buffer)+(str.length))|0)]=0;
+}
+Module['writeAsciiToMemory'] = writeAsciiToMemory;
+
+function unSign(value, bits, ignore) {
+ if (value >= 0) {
+ return value;
+ }
+ return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
+ : Math.pow(2, bits) + value;
+}
+function reSign(value, bits, ignore) {
+ if (value <= 0) {
+ return value;
+ }
+ var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
+ : Math.pow(2, bits-1);
+ if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
+ // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
+ // TODO: In i64 mode 1, resign the two parts separately and safely
+ value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
+ }
+ return value;
+}
+
+// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
+if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
+ var ah = a >>> 16;
+ var al = a & 0xffff;
+ var bh = b >>> 16;
+ var bl = b & 0xffff;
+ return (al*bl + ((ah*bl + al*bh) << 16))|0;
+};
+Math.imul = Math['imul'];
+
+
+var Math_abs = Math.abs;
+var Math_cos = Math.cos;
+var Math_sin = Math.sin;
+var Math_tan = Math.tan;
+var Math_acos = Math.acos;
+var Math_asin = Math.asin;
+var Math_atan = Math.atan;
+var Math_atan2 = Math.atan2;
+var Math_exp = Math.exp;
+var Math_log = Math.log;
+var Math_sqrt = Math.sqrt;
+var Math_ceil = Math.ceil;
+var Math_floor = Math.floor;
+var Math_pow = Math.pow;
+var Math_imul = Math.imul;
+var Math_fround = Math.fround;
+var Math_min = Math.min;
+
+// A counter of dependencies for calling run(). If we need to
+// do asynchronous work before running, increment this and
+// decrement it. Incrementing must happen in a place like
+// PRE_RUN_ADDITIONS (used by emcc to add file preloading).
+// Note that you can add dependencies in preRun, even though
+// it happens right before run - run will be postponed until
+// the dependencies are met.
+var runDependencies = 0;
+var runDependencyWatcher = null;
+var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
+
+function addRunDependency(id) {
+ runDependencies++;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+}
+Module['addRunDependency'] = addRunDependency;
+function removeRunDependency(id) {
+ runDependencies--;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+ if (runDependencies == 0) {
+ if (runDependencyWatcher !== null) {
+ clearInterval(runDependencyWatcher);
+ runDependencyWatcher = null;
+ }
+ if (dependenciesFulfilled) {
+ var callback = dependenciesFulfilled;
+ dependenciesFulfilled = null;
+ callback(); // can add another dependenciesFulfilled
+ }
+ }
+}
+Module['removeRunDependency'] = removeRunDependency;
+
+Module["preloadedImages"] = {}; // maps url to image data
+Module["preloadedAudios"] = {}; // maps url to audio data
+
+
+var memoryInitializer = null;
+
+// === Body ===
+var __ZTVN10__cxxabiv117__class_type_infoE = 7024;
+var __ZTVN10__cxxabiv120__si_class_type_infoE = 7064;
+
+
+
+
+STATIC_BASE = 8;
+
+STATICTOP = STATIC_BASE + Runtime.alignMemory(7731);
+/* global initializers */ __ATINIT__.push();
+
+
+/* memory initializer */ allocate([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,232,118,72,0,0,0,0,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,114,114,111,114,58,32,37,100,92,110,0,0,0,0,0,102,114,97,109,101,32,97,118,101,114,97,103,101,115,58,32,37,46,51,102,32,43,45,32,37,46,51,102,44,32,114,97,110,103,101,58,32,37,46,51,102,32,116,111,32,37,46,51,102,32,10,0,0,0,0,0,105,102,32,40,77,111,100,117,108,101,46,114,101,112,111,114,116,67,111,109,112,108,101,116,105,111,110,41,32,77,111,100,117,108,101,46,114,101,112,111,114,116,67,111,109,112,108,101,116,105,111,110,40,41,0,0,114,101,115,112,111,110,115,105,118,101,32,109,97,105,110,32,108,111,111,112,0,0,0,0,0,0,0,0,56,1,0,0,1,0,0,0,2,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,49,49,98,50,69,100,103,101,83,104,97,112,101,0,0,0,55,98,50,83,104,97,112,101,0,0,0,0,0,0,0,0,120,27,0,0,32,1,0,0,160,27,0,0,16,1,0,0,48,1,0,0,0,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,83,104,97,112,101,115,47,98,50,80,111,108,121,103,111,110,83,104,97,112,101,46,99,112,112,0,0,0,0,0,0,0,48,46,48,102,32,60,61,32,108,111,119,101,114,32,38,38,32,108,111,119,101,114,32,60,61,32,105,110,112,117,116,46,109,97,120,70,114,97,99,116,105,111,110,0,0,0,0,0,82,97,121,67,97,115,116,0,109,95,118,101,114,116,101,120,67,111,117,110,116,32,62,61,32,51,0,0,0,0,0,0,67,111,109,112,117,116,101,77,97,115,115,0,0,0,0,0,97,114,101,97,32,62,32,49,46,49,57,50,48,57,50,57,48,101,45,48,55,70,0,0,0,0,0,0,48,2,0,0,3,0,0,0,4,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,49,52,98,50,80,111,108,121,103,111,110,83,104,97,112,101,0,0,0,0,0,0,0,0,160,27,0,0,24,2,0,0,48,1,0,0,0,0,0,0,16,0,0,0,32,0,0,0,64,0,0,0,96,0,0,0,128,0,0,0,160,0,0,0,192,0,0,0,224,0,0,0,0,1,0,0,64,1,0,0,128,1,0,0,192,1,0,0,0,2,0,0,128,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,106,32,60,32,98,50,95,98,108,111,99,107,83,105,122,101,115,0,0,0,0,0,0,0,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,46,99,112,112,0,0,0,0,0,0,0,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,0,0,0,0,0,0,0,0,48,32,60,32,115,105,122,101,0,0,0,0,0,0,0,0,65,108,108,111,99,97,116,101,0,0,0,0,0,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,98,50,95,98,108,111,99,107,83,105,122,101,115,0,0,0,0,0,98,108,111,99,107,67,111,117,110,116,32,42,32,98,108,111,99,107,83,105,122,101,32,60,61,32,98,50,95,99,104,117,110,107,83,105,122,101,0,0,70,114,101,101,0,0,0,0,98,100,45,62,112,111,115,105,116,105,111,110,46,73,115,86,97,108,105,100,40,41,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,66,111,100,121,46,99,112,112,0,0,0,0,0,0,0,98,50,66,111,100,121,0,0,98,100,45,62,108,105,110,101,97,114,86,101,108,111,99,105,116,121,46,73,115,86,97,108,105,100,40,41,0,0,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,97,110,103,108,101,41,0,0,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,97,110,103,117,108,97,114,86,101,108,111,99,105,116,121,41,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,97,110,103,117,108,97,114,68,97,109,112,105,110,103,41,32,38,38,32,98,100,45,62,97,110,103,117,108,97,114,68,97,109,112,105,110,103,32,62,61,32,48,46,48,102,0,0,0,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,108,105,110,101,97,114,68,97,109,112,105,110,103,41,32,38,38,32,98,100,45,62,108,105,110,101,97,114,68,97,109,112,105,110,103,32,62,61,32,48,46,48,102,0,0,0,0,0,0,0,109,95,119,111,114,108,100,45,62,73,115,76,111,99,107,101,100,40,41,32,61,61,32,102,97,108,115,101,0,0,0,0,67,114,101,97,116,101,70,105,120,116,117,114,101,0,0,0,109,95,116,121,112,101,32,61,61,32,98,50,95,100,121,110,97,109,105,99,66,111,100,121,0,0,0,0,0,0,0,0,82,101,115,101,116,77,97,115,115,68,97,116,97,0,0,0,109,95,73,32,62,32,48,46,48,102,0,0,0,0,0,0,0,10,0,0,0,0,0,0,240,7,0,0,0,0,0,0,48,32,60,61,32,112,114,111,120,121,73,100,32,38,38,32,112,114,111,120,121,73,100,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,0,0,0,0,0,0,46,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,121,110,97,109,105,99,84,114,101,101,46,104,0,0,0,0,0,0,0,71,101,116,85,115,101,114,68,97,116,97,0,0,0,0,0,71,101,116,70,97,116,65,65,66,66,0,0,0,0,0,0,0,0,0,0,32,8,0,0,5,0,0,0,6,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,49,55,98,50,67,111,110,116,97,99,116,76,105,115,116,101,110,101,114,0,0,0,0,0,120,27,0,0,8,8,0,0,109,95,112,114,111,120,121,67,111,117,110,116,32,61,61,32,48,0,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,70,105,120,116,117,114,101,46,99,112,112,0,0,0,0,67,114,101,97,116,101,80,114,111,120,105,101,115,0,0,0,73,115,76,111,99,107,101,100,40,41,32,61,61,32,102,97,108,115,101,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,87,111,114,108,100,46,99,112,112,0,0,0,0,0,0,67,114,101,97,116,101,66,111,100,121,0,0,0,0,0,0,98,45,62,73,115,65,99,116,105,118,101,40,41,32,61,61,32,116,114,117,101,0,0,0,83,111,108,118,101,0,0,0,115,116,97,99,107,67,111,117,110,116,32,60,32,115,116,97,99,107,83,105,122,101,0,0,116,121,112,101,65,32,61,61,32,98,50,95,100,121,110,97,109,105,99,66,111,100,121,32,124,124,32,116,121,112,101,66,32,61,61,32,98,50,95,100,121,110,97,109,105,99,66,111,100,121,0,0,0,0,0,0,83,111,108,118,101,84,79,73,0,0,0,0,0,0,0,0,97,108,112,104,97,48,32,60,32,49,46,48,102,0,0,0,46,47,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,77,97,116,104,46,104,0,65,100,118,97,110,99,101,0,109,95,106,111,105,110,116,67,111,117,110,116,32,60,32,109,95,106,111,105,110,116,67,97,112,97,99,105,116,121,0,0,46,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,73,115,108,97,110,100,46,104,0,0,0,0,0,65,100,100,0,0,0,0,0,109,95,99,111,110,116,97,99,116,67,111,117,110,116,32,60,32,109,95,99,111,110,116,97,99,116,67,97,112,97,99,105,116,121,0,0,0,0,0,0,109,95,98,111,100,121,67,111,117,110,116,32,60,32,109,95,98,111,100,121,67,97,112,97,99,105,116,121,0,0,0,0,0,0,0,0,40,10,0,0,7,0,0,0,8,0,0,0,3,0,0,0,0,0,0,0,49,53,98,50,67,111,110,116,97,99,116,70,105,108,116,101,114,0,0,0,0,0,0,0,120,27,0,0,16,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,99,104,97,105,110,45,62,109,95,99,111,117,110,116,0,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,105,115,116,97,110,99,101,46,99,112,112,0,0,83,101,116,0,0,0,0,0,102,97,108,115,101,0,0,0,98,50,68,105,115,116,97,110,99,101,0,0,0,0,0,0,71,101,116,77,101,116,114,105,99,0,0,0,0,0,0,0,71,101,116,87,105,116,110,101,115,115,80,111,105,110,116,115,0,0,0,0,0,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,109,95,99,111,117,110,116,0,0,0,46,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,105,115,116,97,110,99,101,46,104,0,0,71,101,116,86,101,114,116,101,120,0,0,0,0,0,0,0,71,101,116,67,108,111,115,101,115,116,80,111,105,110,116,0,99,97,99,104,101,45,62,99,111,117,110,116,32,60,61,32,51,0,0,0,0,0,0,0,82,101,97,100,67,97,99,104,101,0,0,0,0,0,0,0,109,95,110,111,100,101,67,111,117,110,116,32,61,61,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,121,110,97,109,105,99,84,114,101,101,46,99,112,112,0,0,0,0,0,0,0,65,108,108,111,99,97,116,101,78,111,100,101,0,0,0,0,48,32,60,61,32,110,111,100,101,73,100,32,38,38,32,110,111,100,101,73,100,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,70,114,101,101,78,111,100,101,0,0,0,0,0,0,0,0,48,32,60,32,109,95,110,111,100,101,67,111,117,110,116,0,48,32,60,61,32,112,114,111,120,121,73,100,32,38,38,32,112,114,111,120,121,73,100,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,0,0,0,0,0,0,109,95,110,111,100,101,115,91,112,114,111,120,121,73,100,93,46,73,115,76,101,97,102,40,41,0,0,0,0,0,0,0,77,111,118,101,80,114,111,120,121,0,0,0,0,0,0,0,99,104,105,108,100,49,32,33,61,32,40,45,49,41,0,0,73,110,115,101,114,116,76,101,97,102,0,0,0,0,0,0,99,104,105,108,100,50,32,33,61,32,40,45,49,41,0,0,105,65,32,33,61,32,40,45,49,41,0,0,0,0,0,0,66,97,108,97,110,99,101,0,48,32,60,61,32,105,66,32,38,38,32,105,66,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,48,32,60,61,32,105,67,32,38,38,32,105,67,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,48,32,60,61,32,105,70,32,38,38,32,105,70,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,48,32,60,61,32,105,71,32,38,38,32,105,71,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,109,95,110,111,100,101,115,91,67,45,62,112,97,114,101,110,116,93,46,99,104,105,108,100,50,32,61,61,32,105,65,0,48,32,60,61,32,105,68,32,38,38,32,105,68,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,48,32,60,61,32,105,69,32,38,38,32,105,69,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,109,95,110,111,100,101,115,91,66,45,62,112,97,114,101,110,116,93,46,99,104,105,108,100,50,32,61,61,32,105,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,97,114,103,101,116,32,62,32,116,111,108,101,114,97,110,99,101,0,0,0,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,84,105,109,101,79,102,73,109,112,97,99,116,46,99,112,112,0,0,0,0,0,0,98,50,84,105,109,101,79,102,73,109,112,97,99,116,0,0,102,97,108,115,101,0,0,0,69,118,97,108,117,97,116,101,0,0,0,0,0,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,109,95,99,111,117,110,116,0,0,0,46,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,105,115,116,97,110,99,101,46,104,0,0,71,101,116,86,101,114,116,101,120,0,0,0,0,0,0,0,70,105,110,100,77,105,110,83,101,112,97,114,97,116,105,111,110,0,0,0,0,0,0,0,48,32,60,32,99,111,117,110,116,32,38,38,32,99,111,117,110,116,32,60,32,51,0,0,73,110,105,116,105,97,108,105,122,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,109,95,105,110,100,101,120,32,61,61,32,48,0,0,0,0,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,83,116,97,99,107,65,108,108,111,99,97,116,111,114,46,99,112,112,0,0,0,0,0,0,0,126,98,50,83,116,97,99,107,65,108,108,111,99,97,116,111,114,0,0,0,0,0,0,0,109,95,101,110,116,114,121,67,111,117,110,116,32,61,61,32,48,0,0,0,0,0,0,0,109,95,101,110,116,114,121,67,111,117,110,116,32,60,32,98,50,95,109,97,120,83,116,97,99,107,69,110,116,114,105,101,115,0,0,0,0,0,0,0,65,108,108,111,99,97,116,101,0,0,0,0,0,0,0,0,109,95,101,110,116,114,121,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,0,0,70,114,101,101,0,0,0,0,112,32,61,61,32,101,110,116,114,121,45,62,100,97,116,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,32,60,61,32,116,121,112,101,49,32,38,38,32,116,121,112,101,49,32,60,32,98,50,83,104,97,112,101,58,58,101,95,116,121,112,101,67,111,117,110,116,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,111,110,116,97,99,116,46,99,112,112,0,0,0,48,32,60,61,32,116,121,112,101,50,32,38,38,32,116,121,112,101,50,32,60,32,98,50,83,104,97,112,101,58,58,101,95,116,121,112,101,67,111,117,110,116,0,0,0,0,0,0,67,114,101,97,116,101,0,0,115,95,105,110,105,116,105,97,108,105,122,101,100,32,61,61,32,116,114,117,101,0,0,0,68,101,115,116,114,111,121,0,48,32,60,61,32,116,121,112,101,65,32,38,38,32,116,121,112,101,66,32,60,32,98,50,83,104,97,112,101,58,58,101,95,116,121,112,101,67,111,117,110,116,0,0,0,0,0,0,0,0,0,0,120,17,0,0,1,0,0,0,9,0,0,0,10,0,0,0,0,0,0,0,57,98,50,67,111,110,116,97,99,116,0,0,0,0,0,0,120,27,0,0,104,17,0,0,0,0,0,0,104,18,0,0,3,0,0,0,11,0,0,0,12,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,101,100,103,101,0,0,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,50,50,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,0,160,27,0,0,72,18,0,0,120,17,0,0,0,0,0,0,0,0,0,0,96,19,0,0,4,0,0,0,13,0,0,0,14,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,101,100,103,101,0,0,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,69,100,103,101,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,98,50,69,100,103,101,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,50,51,98,50,69,100,103,101,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,0,160,27,0,0,64,19,0,0,120,17,0,0,0,0,0,0,0,0,0,0,96,20,0,0,5,0,0,0,15,0,0,0,16,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,80,111,108,121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,98,50,80,111,108,121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,50,53,98,50,80,111,108,121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,160,27,0,0,64,20,0,0,120,17,0,0,0,0,0,0,0,0,0,0,72,21,0,0,6,0,0,0,17,0,0,0,18,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,49,54,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,160,27,0,0,48,21,0,0,120,17,0,0,0,0,0,0,116,111,105,73,110,100,101,120,65,32,60,32,109,95,98,111,100,121,67,111,117,110,116,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,73,115,108,97,110,100,46,99,112,112,0,0,0,0,0,83,111,108,118,101,84,79,73,0,0,0,0,0,0,0,0,116,111,105,73,110,100,101,120,66,32,60,32,109,95,98,111,100,121,67,111,117,110,116,0,100,101,110,32,62,32,48,46,48,102,0,0,0,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,67,111,108,108,105,100,101,69,100,103,101,46,99,112,112,0,0,0,0,0,0,0,98,50,67,111,108,108,105,100,101,69,100,103,101,65,110,100,67,105,114,99,108,101,0,0,48,32,60,61,32,101,100,103,101,49,32,38,38,32,101,100,103,101,49,32,60,32,112,111,108,121,49,45,62,109,95,118,101,114,116,101,120,67,111,117,110,116,0,0,0,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,67,111,108,108,105,100,101,80,111,108,121,103,111,110,46,99,112,112,0,0,0,0,98,50,70,105,110,100,73,110,99,105,100,101,110,116,69,100,103,101,0,0,0,0,0,0,98,50,69,100,103,101,83,101,112,97,114,97,116,105,111,110,0,0,0,0,0,0,0,0,0,0,0,0,120,23,0,0,7,0,0,0,19,0,0,0,20,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,104,97,105,110,0,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,104,97,105,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,98,50,67,104,97,105,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,50,51,98,50,67,104,97,105,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,160,27,0,0,88,23,0,0,120,17,0,0,0,0,0,0,0,0,0,0,120,24,0,0,8,0,0,0,21,0,0,0,22,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,104,97,105,110,0,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,104,97,105,110,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,98,50,67,104,97,105,110,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,50,52,98,50,67,104,97,105,110,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,160,27,0,0,88,24,0,0,120,17,0,0,0,0,0,0,0,0,0,0,88,25,0,0,9,0,0,0,23,0,0,0,24,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,49,53,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,160,27,0,0,64,25,0,0,120,17,0,0,0,0,0,0,112,111,105,110,116,67,111,117,110,116,32,62,32,48,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,111,110,116,97,99,116,83,111,108,118,101,114,46,99,112,112,0,0,0,0,0,98,50,67,111,110,116,97,99,116,83,111,108,118,101,114,0,109,97,110,105,102,111,108,100,45,62,112,111,105,110,116,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,0,0,73,110,105,116,105,97,108,105,122,101,86,101,108,111,99,105,116,121,67,111,110,115,116,114,97,105,110,116,115,0,0,0,112,111,105,110,116,67,111,117,110,116,32,61,61,32,49,32,124,124,32,112,111,105,110,116,67,111,117,110,116,32,61,61,32,50,0,0,0,0,0,0,83,111,108,118,101,86,101,108,111,99,105,116,121,67,111,110,115,116,114,97,105,110,116,115,0,0,0,0,0,0,0,0,97,46,120,32,62,61,32,48,46,48,102,32,38,38,32,97,46,121,32,62,61,32,48,46,48,102,0,0,0,0,0,0,112,99,45,62,112,111,105,110,116,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,73,110,105,116,105,97,108,105,122,101,0,0,0,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,83,104,97,112,101,115,47,98,50,67,104,97,105,110,83,104,97,112,101,46,99,112,112,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,109,95,99,111,117,110,116,32,45,32,49,0,0,0,0,0,0,0,71,101,116,67,104,105,108,100,69,100,103,101,0,0,0,0,83,116,57,116,121,112,101,95,105,110,102,111,0,0,0,0,120,27,0,0,232,26,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,0,160,27,0,0,0,27,0,0,248,26,0,0,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,160,27,0,0,56,27,0,0,40,27,0,0,0,0,0,0,0,0,0,0,96,27,0,0,25,0,0,0,26,0,0,0,27,0,0,0,28,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,10,0,0,0,0,0,0,0,232,27,0,0,25,0,0,0,29,0,0,0,27,0,0,0,28,0,0,0,4,0,0,0,2,0,0,0,2,0,0,0,11,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,160,27,0,0,192,27,0,0,96,27,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,30,0,0,30,0,0,0,31,0,0,0,3,0,0,0,0,0,0,0,115,116,100,58,58,98,97,100,95,97,108,108,111,99,0,0,83,116,57,98,97,100,95,97,108,108,111,99,0,0,0,0,160,27,0,0,24,30,0,0,0,0,0,0,0,0,0,0], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
+
+
+
+
+var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8);
+
+assert(tempDoublePtr % 8 == 0);
+
+function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+}
+
+function copyTempDouble(ptr) {
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+ HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
+
+ HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
+
+ HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
+
+ HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
+
+}
+
+
+ function _emscripten_set_main_loop(func, fps, simulateInfiniteLoop, arg) {
+ Module['noExitRuntime'] = true;
+
+ Browser.mainLoop.runner = function Browser_mainLoop_runner() {
+ if (ABORT) return;
+ if (Browser.mainLoop.queue.length > 0) {
+ var start = Date.now();
+ var blocker = Browser.mainLoop.queue.shift();
+ blocker.func(blocker.arg);
+ if (Browser.mainLoop.remainingBlockers) {
+ var remaining = Browser.mainLoop.remainingBlockers;
+ var next = remaining%1 == 0 ? remaining-1 : Math.floor(remaining);
+ if (blocker.counted) {
+ Browser.mainLoop.remainingBlockers = next;
+ } else {
+ // not counted, but move the progress along a tiny bit
+ next = next + 0.5; // do not steal all the next one's progress
+ Browser.mainLoop.remainingBlockers = (8*remaining + next)/9;
+ }
+ }
+ console.log('main loop blocker "' + blocker.name + '" took ' + (Date.now() - start) + ' ms'); //, left: ' + Browser.mainLoop.remainingBlockers);
+ Browser.mainLoop.updateStatus();
+ setTimeout(Browser.mainLoop.runner, 0);
+ return;
+ }
+ if (Browser.mainLoop.shouldPause) {
+ // catch pauses from non-main loop sources
+ Browser.mainLoop.paused = true;
+ Browser.mainLoop.shouldPause = false;
+ return;
+ }
+
+ // Signal GL rendering layer that processing of a new frame is about to start. This helps it optimize
+ // VBO double-buffering and reduce GPU stalls.
+
+ if (Browser.mainLoop.method === 'timeout' && Module.ctx) {
+ Module.printErr('Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!');
+ Browser.mainLoop.method = ''; // just warn once per call to set main loop
+ }
+
+ if (Module['preMainLoop']) {
+ Module['preMainLoop']();
+ }
+
+ try {
+ if (typeof arg !== 'undefined') {
+ Runtime.dynCall('vi', func, [arg]);
+ } else {
+ Runtime.dynCall('v', func);
+ }
+ } catch (e) {
+ if (e instanceof ExitStatus) {
+ return;
+ } else {
+ if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
+ throw e;
+ }
+ }
+
+ if (Module['postMainLoop']) {
+ Module['postMainLoop']();
+ }
+
+ if (Browser.mainLoop.shouldPause) {
+ // catch pauses from the main loop itself
+ Browser.mainLoop.paused = true;
+ Browser.mainLoop.shouldPause = false;
+ return;
+ }
+ Browser.mainLoop.scheduler();
+ }
+ if (fps && fps > 0) {
+ Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler() {
+ setTimeout(Browser.mainLoop.runner, 1000/fps); // doing this each time means that on exception, we stop
+ };
+ Browser.mainLoop.method = 'timeout';
+ } else {
+ Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler() {
+ Browser.requestAnimationFrame(Browser.mainLoop.runner);
+ };
+ Browser.mainLoop.method = 'rAF';
+ }
+ Browser.mainLoop.scheduler();
+
+ if (simulateInfiniteLoop) {
+ throw 'SimulateInfiniteLoop';
+ }
+ }
+
+ var _cosf=Math_cos;
+
+ function ___cxa_pure_virtual() {
+ ABORT = true;
+ throw 'Pure virtual function called!';
+ }
+
+ function _time(ptr) {
+ var ret = Math.floor(Date.now()/1000);
+ if (ptr) {
+ HEAP32[((ptr)>>2)]=ret;
+ }
+ return ret;
+ }
+
+ function ___assert_fail(condition, filename, line, func) {
+ ABORT = true;
+ throw 'Assertion failed: ' + Pointer_stringify(condition) + ', at: ' + [filename ? Pointer_stringify(filename) : 'unknown filename', line, func ? Pointer_stringify(func) : 'unknown function'] + ' at ' + stackTrace();
+ }
+
+
+ function __ZSt18uncaught_exceptionv() { // std::uncaught_exception()
+ return !!__ZSt18uncaught_exceptionv.uncaught_exception;
+ }
+
+
+
+ function ___cxa_is_number_type(type) {
+ var isNumber = false;
+ try { if (type == __ZTIi) isNumber = true } catch(e){}
+ try { if (type == __ZTIj) isNumber = true } catch(e){}
+ try { if (type == __ZTIl) isNumber = true } catch(e){}
+ try { if (type == __ZTIm) isNumber = true } catch(e){}
+ try { if (type == __ZTIx) isNumber = true } catch(e){}
+ try { if (type == __ZTIy) isNumber = true } catch(e){}
+ try { if (type == __ZTIf) isNumber = true } catch(e){}
+ try { if (type == __ZTId) isNumber = true } catch(e){}
+ try { if (type == __ZTIe) isNumber = true } catch(e){}
+ try { if (type == __ZTIc) isNumber = true } catch(e){}
+ try { if (type == __ZTIa) isNumber = true } catch(e){}
+ try { if (type == __ZTIh) isNumber = true } catch(e){}
+ try { if (type == __ZTIs) isNumber = true } catch(e){}
+ try { if (type == __ZTIt) isNumber = true } catch(e){}
+ return isNumber;
+ }function ___cxa_does_inherit(definiteType, possibilityType, possibility) {
+ if (possibility == 0) return false;
+ if (possibilityType == 0 || possibilityType == definiteType)
+ return true;
+ var possibility_type_info;
+ if (___cxa_is_number_type(possibilityType)) {
+ possibility_type_info = possibilityType;
+ } else {
+ var possibility_type_infoAddr = HEAP32[((possibilityType)>>2)] - 8;
+ possibility_type_info = HEAP32[((possibility_type_infoAddr)>>2)];
+ }
+ switch (possibility_type_info) {
+ case 0: // possibility is a pointer
+ // See if definite type is a pointer
+ var definite_type_infoAddr = HEAP32[((definiteType)>>2)] - 8;
+ var definite_type_info = HEAP32[((definite_type_infoAddr)>>2)];
+ if (definite_type_info == 0) {
+ // Also a pointer; compare base types of pointers
+ var defPointerBaseAddr = definiteType+8;
+ var defPointerBaseType = HEAP32[((defPointerBaseAddr)>>2)];
+ var possPointerBaseAddr = possibilityType+8;
+ var possPointerBaseType = HEAP32[((possPointerBaseAddr)>>2)];
+ return ___cxa_does_inherit(defPointerBaseType, possPointerBaseType, possibility);
+ } else
+ return false; // one pointer and one non-pointer
+ case 1: // class with no base class
+ return false;
+ case 2: // class with base class
+ var parentTypeAddr = possibilityType + 8;
+ var parentType = HEAP32[((parentTypeAddr)>>2)];
+ return ___cxa_does_inherit(definiteType, parentType, possibility);
+ default:
+ return false; // some unencountered type
+ }
+ }
+
+
+
+ var ___cxa_last_thrown_exception=0;function ___resumeException(ptr) {
+ if (!___cxa_last_thrown_exception) { ___cxa_last_thrown_exception = ptr; }
+ throw ptr + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";
+ }
+
+ var ___cxa_exception_header_size=8;function ___cxa_find_matching_catch(thrown, throwntype) {
+ if (thrown == -1) thrown = ___cxa_last_thrown_exception;
+ header = thrown - ___cxa_exception_header_size;
+ if (throwntype == -1) throwntype = HEAP32[((header)>>2)];
+ var typeArray = Array.prototype.slice.call(arguments, 2);
+
+ // If throwntype is a pointer, this means a pointer has been
+ // thrown. When a pointer is thrown, actually what's thrown
+ // is a pointer to the pointer. We'll dereference it.
+ if (throwntype != 0 && !___cxa_is_number_type(throwntype)) {
+ var throwntypeInfoAddr= HEAP32[((throwntype)>>2)] - 8;
+ var throwntypeInfo= HEAP32[((throwntypeInfoAddr)>>2)];
+ if (throwntypeInfo == 0)
+ thrown = HEAP32[((thrown)>>2)];
+ }
+ // The different catch blocks are denoted by different types.
+ // Due to inheritance, those types may not precisely match the
+ // type of the thrown object. Find one which matches, and
+ // return the type of the catch block which should be called.
+ for (var i = 0; i < typeArray.length; i++) {
+ if (___cxa_does_inherit(typeArray[i], throwntype, thrown))
+ return ((asm["setTempRet0"](typeArray[i]),thrown)|0);
+ }
+ // Shouldn't happen unless we have bogus data in typeArray
+ // or encounter a type for which emscripten doesn't have suitable
+ // typeinfo defined. Best-efforts match just in case.
+ return ((asm["setTempRet0"](throwntype),thrown)|0);
+ }function ___cxa_throw(ptr, type, destructor) {
+ if (!___cxa_throw.initialized) {
+ try {
+ HEAP32[((__ZTVN10__cxxabiv119__pointer_type_infoE)>>2)]=0; // Workaround for libcxxabi integration bug
+ } catch(e){}
+ try {
+ HEAP32[((__ZTVN10__cxxabiv117__class_type_infoE)>>2)]=1; // Workaround for libcxxabi integration bug
+ } catch(e){}
+ try {
+ HEAP32[((__ZTVN10__cxxabiv120__si_class_type_infoE)>>2)]=2; // Workaround for libcxxabi integration bug
+ } catch(e){}
+ ___cxa_throw.initialized = true;
+ }
+ var header = ptr - ___cxa_exception_header_size;
+ HEAP32[((header)>>2)]=type;
+ HEAP32[(((header)+(4))>>2)]=destructor;
+ ___cxa_last_thrown_exception = ptr;
+ if (!("uncaught_exception" in __ZSt18uncaught_exceptionv)) {
+ __ZSt18uncaught_exceptionv.uncaught_exception = 1;
+ } else {
+ __ZSt18uncaught_exceptionv.uncaught_exception++;
+ }
+ throw ptr + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";
+ }
+
+
+ Module["_memset"] = _memset;
+
+
+
+ function __exit(status) {
+ // void _exit(int status);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html
+ Module['exit'](status);
+ }function _exit(status) {
+ __exit(status);
+ }function __ZSt9terminatev() {
+ _exit(-1234);
+ }
+
+ function _abort() {
+ Module['abort']();
+ }
+
+
+
+
+
+ var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};
+
+ var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
+
+
+ var ___errno_state=0;function ___setErrNo(value) {
+ // For convenient setting and returning of errno.
+ HEAP32[((___errno_state)>>2)]=value;
+ return value;
+ }
+
+ var PATH={splitPath:function (filename) {
+ var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
+ return splitPathRe.exec(filename).slice(1);
+ },normalizeArray:function (parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length - 1; i >= 0; i--) {
+ var last = parts[i];
+ if (last === '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+ return parts;
+ },normalize:function (path) {
+ var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.substr(-1) === '/';
+ // Normalize the path
+ path = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+ return (isAbsolute ? '/' : '') + path;
+ },dirname:function (path) {
+ var result = PATH.splitPath(path),
+ root = result[0],
+ dir = result[1];
+ if (!root && !dir) {
+ // No dirname whatsoever
+ return '.';
+ }
+ if (dir) {
+ // It has a dirname, strip trailing slash
+ dir = dir.substr(0, dir.length - 1);
+ }
+ return root + dir;
+ },basename:function (path) {
+ // EMSCRIPTEN return '/'' for '/', not an empty string
+ if (path === '/') return '/';
+ var lastSlash = path.lastIndexOf('/');
+ if (lastSlash === -1) return path;
+ return path.substr(lastSlash+1);
+ },extname:function (path) {
+ return PATH.splitPath(path)[3];
+ },join:function () {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return PATH.normalize(paths.join('/'));
+ },join2:function (l, r) {
+ return PATH.normalize(l + '/' + r);
+ },resolve:function () {
+ var resolvedPath = '',
+ resolvedAbsolute = false;
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0) ? arguments[i] : FS.cwd();
+ // Skip empty and invalid entries
+ if (typeof path !== 'string') {
+ throw new TypeError('Arguments to path.resolve must be strings');
+ } else if (!path) {
+ continue;
+ }
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+ }
+ // At this point the path should be resolved to a full absolute path, but
+ // handle relative paths to be safe (might happen when process.cwd() fails)
+ resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+ },relative:function (from, to) {
+ from = PATH.resolve(from).substr(1);
+ to = PATH.resolve(to).substr(1);
+ function trim(arr) {
+ var start = 0;
+ for (; start < arr.length; start++) {
+ if (arr[start] !== '') break;
+ }
+ var end = arr.length - 1;
+ for (; end >= 0; end--) {
+ if (arr[end] !== '') break;
+ }
+ if (start > end) return [];
+ return arr.slice(start, end - start + 1);
+ }
+ var fromParts = trim(from.split('/'));
+ var toParts = trim(to.split('/'));
+ var length = Math.min(fromParts.length, toParts.length);
+ var samePartsLength = length;
+ for (var i = 0; i < length; i++) {
+ if (fromParts[i] !== toParts[i]) {
+ samePartsLength = i;
+ break;
+ }
+ }
+ var outputParts = [];
+ for (var i = samePartsLength; i < fromParts.length; i++) {
+ outputParts.push('..');
+ }
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
+ return outputParts.join('/');
+ }};
+
+ var TTY={ttys:[],init:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // currently, FS.init does not distinguish if process.stdin is a file or TTY
+ // // device, it always assumes it's a TTY device. because of this, we're forcing
+ // // process.stdin to UTF8 encoding to at least make stdin reading compatible
+ // // with text files until FS.init can be refactored.
+ // process['stdin']['setEncoding']('utf8');
+ // }
+ },shutdown:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
+ // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
+ // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
+ // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
+ // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
+ // process['stdin']['pause']();
+ // }
+ },register:function (dev, ops) {
+ TTY.ttys[dev] = { input: [], output: [], ops: ops };
+ FS.registerDevice(dev, TTY.stream_ops);
+ },stream_ops:{open:function (stream) {
+ var tty = TTY.ttys[stream.node.rdev];
+ if (!tty) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ stream.tty = tty;
+ stream.seekable = false;
+ },close:function (stream) {
+ // flush any pending line data
+ if (stream.tty.output.length) {
+ stream.tty.ops.put_char(stream.tty, 10);
+ }
+ },read:function (stream, buffer, offset, length, pos /* ignored */) {
+ if (!stream.tty || !stream.tty.ops.get_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = stream.tty.ops.get_char(stream.tty);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, pos) {
+ if (!stream.tty || !stream.tty.ops.put_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ for (var i = 0; i < length; i++) {
+ try {
+ stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }},default_tty_ops:{get_char:function (tty) {
+ if (!tty.input.length) {
+ var result = null;
+ if (ENVIRONMENT_IS_NODE) {
+ result = process['stdin']['read']();
+ if (!result) {
+ if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
+ return null; // EOF
+ }
+ return undefined; // no data available
+ }
+ } else if (typeof window != 'undefined' &&
+ typeof window.prompt == 'function') {
+ // Browser.
+ result = window.prompt('Input: '); // returns null on cancel
+ if (result !== null) {
+ result += '\n';
+ }
+ } else if (typeof readline == 'function') {
+ // Command line.
+ result = readline();
+ if (result !== null) {
+ result += '\n';
+ }
+ }
+ if (!result) {
+ return null;
+ }
+ tty.input = intArrayFromString(result, true);
+ }
+ return tty.input.shift();
+ },put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['print'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }},default_tty1_ops:{put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['printErr'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }}};
+
+ var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
+ return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
+ // no supported
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (!MEMFS.ops_table) {
+ MEMFS.ops_table = {
+ dir: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ lookup: MEMFS.node_ops.lookup,
+ mknod: MEMFS.node_ops.mknod,
+ rename: MEMFS.node_ops.rename,
+ unlink: MEMFS.node_ops.unlink,
+ rmdir: MEMFS.node_ops.rmdir,
+ readdir: MEMFS.node_ops.readdir,
+ symlink: MEMFS.node_ops.symlink
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek
+ }
+ },
+ file: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek,
+ read: MEMFS.stream_ops.read,
+ write: MEMFS.stream_ops.write,
+ allocate: MEMFS.stream_ops.allocate,
+ mmap: MEMFS.stream_ops.mmap
+ }
+ },
+ link: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ readlink: MEMFS.node_ops.readlink
+ },
+ stream: {}
+ },
+ chrdev: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: FS.chrdev_stream_ops
+ },
+ };
+ }
+ var node = FS.createNode(parent, name, mode, dev);
+ if (FS.isDir(node.mode)) {
+ node.node_ops = MEMFS.ops_table.dir.node;
+ node.stream_ops = MEMFS.ops_table.dir.stream;
+ node.contents = {};
+ } else if (FS.isFile(node.mode)) {
+ node.node_ops = MEMFS.ops_table.file.node;
+ node.stream_ops = MEMFS.ops_table.file.stream;
+ node.contents = [];
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ } else if (FS.isLink(node.mode)) {
+ node.node_ops = MEMFS.ops_table.link.node;
+ node.stream_ops = MEMFS.ops_table.link.stream;
+ } else if (FS.isChrdev(node.mode)) {
+ node.node_ops = MEMFS.ops_table.chrdev.node;
+ node.stream_ops = MEMFS.ops_table.chrdev.stream;
+ }
+ node.timestamp = Date.now();
+ // add the new node to the parent
+ if (parent) {
+ parent.contents[name] = node;
+ }
+ return node;
+ },ensureFlexible:function (node) {
+ if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
+ var contents = node.contents;
+ node.contents = Array.prototype.slice.call(contents);
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ }
+ },node_ops:{getattr:function (node) {
+ var attr = {};
+ // device numbers reuse inode numbers.
+ attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
+ attr.ino = node.id;
+ attr.mode = node.mode;
+ attr.nlink = 1;
+ attr.uid = 0;
+ attr.gid = 0;
+ attr.rdev = node.rdev;
+ if (FS.isDir(node.mode)) {
+ attr.size = 4096;
+ } else if (FS.isFile(node.mode)) {
+ attr.size = node.contents.length;
+ } else if (FS.isLink(node.mode)) {
+ attr.size = node.link.length;
+ } else {
+ attr.size = 0;
+ }
+ attr.atime = new Date(node.timestamp);
+ attr.mtime = new Date(node.timestamp);
+ attr.ctime = new Date(node.timestamp);
+ // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
+ // but this is not required by the standard.
+ attr.blksize = 4096;
+ attr.blocks = Math.ceil(attr.size / attr.blksize);
+ return attr;
+ },setattr:function (node, attr) {
+ if (attr.mode !== undefined) {
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ node.timestamp = attr.timestamp;
+ }
+ if (attr.size !== undefined) {
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ if (attr.size < contents.length) contents.length = attr.size;
+ else while (attr.size > contents.length) contents.push(0);
+ }
+ },lookup:function (parent, name) {
+ throw FS.genericErrors[ERRNO_CODES.ENOENT];
+ },mknod:function (parent, name, mode, dev) {
+ return MEMFS.createNode(parent, name, mode, dev);
+ },rename:function (old_node, new_dir, new_name) {
+ // if we're overwriting a directory at new_name, make sure it's empty.
+ if (FS.isDir(old_node.mode)) {
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ }
+ if (new_node) {
+ for (var i in new_node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ }
+ }
+ // do the internal rewiring
+ delete old_node.parent.contents[old_node.name];
+ old_node.name = new_name;
+ new_dir.contents[new_name] = old_node;
+ old_node.parent = new_dir;
+ },unlink:function (parent, name) {
+ delete parent.contents[name];
+ },rmdir:function (parent, name) {
+ var node = FS.lookupNode(parent, name);
+ for (var i in node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ delete parent.contents[name];
+ },readdir:function (node) {
+ var entries = ['.', '..']
+ for (var key in node.contents) {
+ if (!node.contents.hasOwnProperty(key)) {
+ continue;
+ }
+ entries.push(key);
+ }
+ return entries;
+ },symlink:function (parent, newname, oldpath) {
+ var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
+ node.link = oldpath;
+ return node;
+ },readlink:function (node) {
+ if (!FS.isLink(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return node.link;
+ }},stream_ops:{read:function (stream, buffer, offset, length, position) {
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (size > 8 && contents.subarray) { // non-trivial, and typed array
+ buffer.set(contents.subarray(position, position + size), offset);
+ } else
+ {
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ }
+ return size;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ var node = stream.node;
+ node.timestamp = Date.now();
+ var contents = node.contents;
+ if (length && contents.length === 0 && position === 0 && buffer.subarray) {
+ // just replace it with the new data
+ if (canOwn && offset === 0) {
+ node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
+ node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
+ } else {
+ node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
+ node.contentMode = MEMFS.CONTENT_FIXED;
+ }
+ return length;
+ }
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ while (contents.length < position) contents.push(0);
+ for (var i = 0; i < length; i++) {
+ contents[position + i] = buffer[offset + i];
+ }
+ return length;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ position += stream.node.contents.length;
+ }
+ }
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ stream.ungotten = [];
+ stream.position = position;
+ return position;
+ },allocate:function (stream, offset, length) {
+ MEMFS.ensureFlexible(stream.node);
+ var contents = stream.node.contents;
+ var limit = offset + length;
+ while (limit > contents.length) contents.push(0);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ if (!FS.isFile(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ var ptr;
+ var allocated;
+ var contents = stream.node.contents;
+ // Only make a new copy when MAP_PRIVATE is specified.
+ if ( !(flags & 2) &&
+ (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
+ // We can't emulate MAP_SHARED when the file is not backed by the buffer
+ // we're mapping to (e.g. the HEAP buffer).
+ allocated = false;
+ ptr = contents.byteOffset;
+ } else {
+ // Try to avoid unnecessary slices.
+ if (position > 0 || position + length < contents.length) {
+ if (contents.subarray) {
+ contents = contents.subarray(position, position + length);
+ } else {
+ contents = Array.prototype.slice.call(contents, position, position + length);
+ }
+ }
+ allocated = true;
+ ptr = _malloc(length);
+ if (!ptr) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
+ }
+ buffer.set(contents, ptr);
+ }
+ return { ptr: ptr, allocated: allocated };
+ }}};
+
+ var IDBFS={dbs:{},indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
+ // reuse all of the core MEMFS functionality
+ return MEMFS.mount.apply(null, arguments);
+ },syncfs:function (mount, populate, callback) {
+ IDBFS.getLocalSet(mount, function(err, local) {
+ if (err) return callback(err);
+
+ IDBFS.getRemoteSet(mount, function(err, remote) {
+ if (err) return callback(err);
+
+ var src = populate ? remote : local;
+ var dst = populate ? local : remote;
+
+ IDBFS.reconcile(src, dst, callback);
+ });
+ });
+ },getDB:function (name, callback) {
+ // check the cache first
+ var db = IDBFS.dbs[name];
+ if (db) {
+ return callback(null, db);
+ }
+
+ var req;
+ try {
+ req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
+ } catch (e) {
+ return callback(e);
+ }
+ req.onupgradeneeded = function(e) {
+ var db = e.target.result;
+ var transaction = e.target.transaction;
+
+ var fileStore;
+
+ if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
+ fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ } else {
+ fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
+ }
+
+ fileStore.createIndex('timestamp', 'timestamp', { unique: false });
+ };
+ req.onsuccess = function() {
+ db = req.result;
+
+ // add to the cache
+ IDBFS.dbs[name] = db;
+ callback(null, db);
+ };
+ req.onerror = function() {
+ callback(this.error);
+ };
+ },getLocalSet:function (mount, callback) {
+ var entries = {};
+
+ function isRealDir(p) {
+ return p !== '.' && p !== '..';
+ };
+ function toAbsolute(root) {
+ return function(p) {
+ return PATH.join2(root, p);
+ }
+ };
+
+ var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
+
+ while (check.length) {
+ var path = check.pop();
+ var stat;
+
+ try {
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
+ }
+
+ entries[path] = { timestamp: stat.mtime };
+ }
+
+ return callback(null, { type: 'local', entries: entries });
+ },getRemoteSet:function (mount, callback) {
+ var entries = {};
+
+ IDBFS.getDB(mount.mountpoint, function(err, db) {
+ if (err) return callback(err);
+
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
+ transaction.onerror = function() { callback(this.error); };
+
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ var index = store.index('timestamp');
+
+ index.openKeyCursor().onsuccess = function(event) {
+ var cursor = event.target.result;
+
+ if (!cursor) {
+ return callback(null, { type: 'remote', db: db, entries: entries });
+ }
+
+ entries[cursor.primaryKey] = { timestamp: cursor.key };
+
+ cursor.continue();
+ };
+ });
+ },loadLocalEntry:function (path, callback) {
+ var stat, node;
+
+ try {
+ var lookup = FS.lookupPath(path);
+ node = lookup.node;
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode });
+ } else if (FS.isFile(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+ },storeLocalEntry:function (path, entry, callback) {
+ try {
+ if (FS.isDir(entry.mode)) {
+ FS.mkdir(path, entry.mode);
+ } else if (FS.isFile(entry.mode)) {
+ FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+
+ FS.utime(path, entry.timestamp, entry.timestamp);
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },removeLocalEntry:function (path, callback) {
+ try {
+ var lookup = FS.lookupPath(path);
+ var stat = FS.stat(path);
+
+ if (FS.isDir(stat.mode)) {
+ FS.rmdir(path);
+ } else if (FS.isFile(stat.mode)) {
+ FS.unlink(path);
+ }
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },loadRemoteEntry:function (store, path, callback) {
+ var req = store.get(path);
+ req.onsuccess = function(event) { callback(null, event.target.result); };
+ req.onerror = function() { callback(this.error); };
+ },storeRemoteEntry:function (store, path, entry, callback) {
+ var req = store.put(entry, path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },removeRemoteEntry:function (store, path, callback) {
+ var req = store.delete(path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },reconcile:function (src, dst, callback) {
+ var total = 0;
+
+ var create = [];
+ Object.keys(src.entries).forEach(function (key) {
+ var e = src.entries[key];
+ var e2 = dst.entries[key];
+ if (!e2 || e.timestamp > e2.timestamp) {
+ create.push(key);
+ total++;
+ }
+ });
+
+ var remove = [];
+ Object.keys(dst.entries).forEach(function (key) {
+ var e = dst.entries[key];
+ var e2 = src.entries[key];
+ if (!e2) {
+ remove.push(key);
+ total++;
+ }
+ });
+
+ if (!total) {
+ return callback(null);
+ }
+
+ var errored = false;
+ var completed = 0;
+ var db = src.type === 'remote' ? src.db : dst.db;
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= total) {
+ return callback(null);
+ }
+ };
+
+ transaction.onerror = function() { done(this.error); };
+
+ // sort paths in ascending order so directory entries are created
+ // before the files inside them
+ create.sort().forEach(function (path) {
+ if (dst.type === 'local') {
+ IDBFS.loadRemoteEntry(store, path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeLocalEntry(path, entry, done);
+ });
+ } else {
+ IDBFS.loadLocalEntry(path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeRemoteEntry(store, path, entry, done);
+ });
+ }
+ });
+
+ // sort paths in descending order so files are deleted before their
+ // parent directories
+ remove.sort().reverse().forEach(function(path) {
+ if (dst.type === 'local') {
+ IDBFS.removeLocalEntry(path, done);
+ } else {
+ IDBFS.removeRemoteEntry(store, path, done);
+ }
+ });
+ }};
+
+ var NODEFS={isWindows:false,staticInit:function () {
+ NODEFS.isWindows = !!process.platform.match(/^win/);
+ },mount:function (mount) {
+ assert(ENVIRONMENT_IS_NODE);
+ return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node = FS.createNode(parent, name, mode);
+ node.node_ops = NODEFS.node_ops;
+ node.stream_ops = NODEFS.stream_ops;
+ return node;
+ },getMode:function (path) {
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ if (NODEFS.isWindows) {
+ // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so
+ // propagate write bits to execute bits.
+ stat.mode = stat.mode | ((stat.mode & 146) >> 1);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return stat.mode;
+ },realPath:function (node) {
+ var parts = [];
+ while (node.parent !== node) {
+ parts.push(node.name);
+ node = node.parent;
+ }
+ parts.push(node.mount.opts.root);
+ parts.reverse();
+ return PATH.join.apply(null, parts);
+ },flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function (flags) {
+ if (flags in NODEFS.flagsToPermissionStringMap) {
+ return NODEFS.flagsToPermissionStringMap[flags];
+ } else {
+ return flags;
+ }
+ },node_ops:{getattr:function (node) {
+ var path = NODEFS.realPath(node);
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
+ // See http://support.microsoft.com/kb/140365
+ if (NODEFS.isWindows && !stat.blksize) {
+ stat.blksize = 4096;
+ }
+ if (NODEFS.isWindows && !stat.blocks) {
+ stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
+ }
+ return {
+ dev: stat.dev,
+ ino: stat.ino,
+ mode: stat.mode,
+ nlink: stat.nlink,
+ uid: stat.uid,
+ gid: stat.gid,
+ rdev: stat.rdev,
+ size: stat.size,
+ atime: stat.atime,
+ mtime: stat.mtime,
+ ctime: stat.ctime,
+ blksize: stat.blksize,
+ blocks: stat.blocks
+ };
+ },setattr:function (node, attr) {
+ var path = NODEFS.realPath(node);
+ try {
+ if (attr.mode !== undefined) {
+ fs.chmodSync(path, attr.mode);
+ // update the common node structure mode as well
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ var date = new Date(attr.timestamp);
+ fs.utimesSync(path, date, date);
+ }
+ if (attr.size !== undefined) {
+ fs.truncateSync(path, attr.size);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },lookup:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ var mode = NODEFS.getMode(path);
+ return NODEFS.createNode(parent, name, mode);
+ },mknod:function (parent, name, mode, dev) {
+ var node = NODEFS.createNode(parent, name, mode, dev);
+ // create the backing node for this in the fs root as well
+ var path = NODEFS.realPath(node);
+ try {
+ if (FS.isDir(node.mode)) {
+ fs.mkdirSync(path, node.mode);
+ } else {
+ fs.writeFileSync(path, '', { mode: node.mode });
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return node;
+ },rename:function (oldNode, newDir, newName) {
+ var oldPath = NODEFS.realPath(oldNode);
+ var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
+ try {
+ fs.renameSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },unlink:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.unlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },rmdir:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.rmdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readdir:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },symlink:function (parent, newName, oldPath) {
+ var newPath = PATH.join2(NODEFS.realPath(parent), newName);
+ try {
+ fs.symlinkSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readlink:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }},stream_ops:{open:function (stream) {
+ var path = NODEFS.realPath(stream.node);
+ try {
+ if (FS.isFile(stream.node.mode)) {
+ stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },close:function (stream) {
+ try {
+ if (FS.isFile(stream.node.mode) && stream.nfd) {
+ fs.closeSync(stream.nfd);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },read:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(length);
+ var res;
+ try {
+ res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ if (res > 0) {
+ for (var i = 0; i < res; i++) {
+ buffer[offset + i] = nbuffer[i];
+ }
+ }
+ return res;
+ },write:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
+ var res;
+ try {
+ res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return res;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ try {
+ var stat = fs.fstatSync(stream.nfd);
+ position += stat.size;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }
+ }
+
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ stream.position = position;
+ return position;
+ }}};
+
+ var _stdin=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stdout=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stderr=allocate(1, "i32*", ALLOC_STATIC);
+
+ function _fflush(stream) {
+ // int fflush(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html
+ // we don't currently perform any user-space buffering of data
+ }var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},handleFSError:function (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
+ return ___setErrNo(e.errno);
+ },lookupPath:function (path, opts) {
+ path = PATH.resolve(FS.cwd(), path);
+ opts = opts || {};
+
+ var defaults = {
+ follow_mount: true,
+ recurse_count: 0
+ };
+ for (var key in defaults) {
+ if (opts[key] === undefined) {
+ opts[key] = defaults[key];
+ }
+ }
+
+ if (opts.recurse_count > 8) { // max recursive lookup of 8
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+
+ // split the path
+ var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), false);
+
+ // start at the root
+ var current = FS.root;
+ var current_path = '/';
+
+ for (var i = 0; i < parts.length; i++) {
+ var islast = (i === parts.length-1);
+ if (islast && opts.parent) {
+ // stop resolving
+ break;
+ }
+
+ current = FS.lookupNode(current, parts[i]);
+ current_path = PATH.join2(current_path, parts[i]);
+
+ // jump to the mount's root node if this is a mountpoint
+ if (FS.isMountpoint(current)) {
+ if (!islast || (islast && opts.follow_mount)) {
+ current = current.mounted.root;
+ }
+ }
+
+ // by default, lookupPath will not follow a symlink if it is the final path component.
+ // setting opts.follow = true will override this behavior.
+ if (!islast || opts.follow) {
+ var count = 0;
+ while (FS.isLink(current.mode)) {
+ var link = FS.readlink(current_path);
+ current_path = PATH.resolve(PATH.dirname(current_path), link);
+
+ var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
+ current = lookup.node;
+
+ if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+ }
+ }
+ }
+
+ return { path: current_path, node: current };
+ },getPath:function (node) {
+ var path;
+ while (true) {
+ if (FS.isRoot(node)) {
+ var mount = node.mount.mountpoint;
+ if (!path) return mount;
+ return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
+ }
+ path = path ? node.name + '/' + path : node.name;
+ node = node.parent;
+ }
+ },hashName:function (parentid, name) {
+ var hash = 0;
+
+
+ for (var i = 0; i < name.length; i++) {
+ hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
+ }
+ return ((parentid + hash) >>> 0) % FS.nameTable.length;
+ },hashAddNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ node.name_next = FS.nameTable[hash];
+ FS.nameTable[hash] = node;
+ },hashRemoveNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ if (FS.nameTable[hash] === node) {
+ FS.nameTable[hash] = node.name_next;
+ } else {
+ var current = FS.nameTable[hash];
+ while (current) {
+ if (current.name_next === node) {
+ current.name_next = node.name_next;
+ break;
+ }
+ current = current.name_next;
+ }
+ }
+ },lookupNode:function (parent, name) {
+ var err = FS.mayLookup(parent);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ var hash = FS.hashName(parent.id, name);
+ for (var node = FS.nameTable[hash]; node; node = node.name_next) {
+ var nodeName = node.name;
+ if (node.parent.id === parent.id && nodeName === name) {
+ return node;
+ }
+ }
+ // if we failed to find it in the cache, call into the VFS
+ return FS.lookup(parent, name);
+ },createNode:function (parent, name, mode, rdev) {
+ if (!FS.FSNode) {
+ FS.FSNode = function(parent, name, mode, rdev) {
+ if (!parent) {
+ parent = this; // root node sets parent to itself
+ }
+ this.parent = parent;
+ this.mount = parent.mount;
+ this.mounted = null;
+ this.id = FS.nextInode++;
+ this.name = name;
+ this.mode = mode;
+ this.node_ops = {};
+ this.stream_ops = {};
+ this.rdev = rdev;
+ };
+
+ FS.FSNode.prototype = {};
+
+ // compatibility
+ var readMode = 292 | 73;
+ var writeMode = 146;
+
+ // NOTE we must use Object.defineProperties instead of individual calls to
+ // Object.defineProperty in order to make closure compiler happy
+ Object.defineProperties(FS.FSNode.prototype, {
+ read: {
+ get: function() { return (this.mode & readMode) === readMode; },
+ set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
+ },
+ write: {
+ get: function() { return (this.mode & writeMode) === writeMode; },
+ set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
+ },
+ isFolder: {
+ get: function() { return FS.isDir(this.mode); },
+ },
+ isDevice: {
+ get: function() { return FS.isChrdev(this.mode); },
+ },
+ });
+ }
+
+ var node = new FS.FSNode(parent, name, mode, rdev);
+
+ FS.hashAddNode(node);
+
+ return node;
+ },destroyNode:function (node) {
+ FS.hashRemoveNode(node);
+ },isRoot:function (node) {
+ return node === node.parent;
+ },isMountpoint:function (node) {
+ return !!node.mounted;
+ },isFile:function (mode) {
+ return (mode & 61440) === 32768;
+ },isDir:function (mode) {
+ return (mode & 61440) === 16384;
+ },isLink:function (mode) {
+ return (mode & 61440) === 40960;
+ },isChrdev:function (mode) {
+ return (mode & 61440) === 8192;
+ },isBlkdev:function (mode) {
+ return (mode & 61440) === 24576;
+ },isFIFO:function (mode) {
+ return (mode & 61440) === 4096;
+ },isSocket:function (mode) {
+ return (mode & 49152) === 49152;
+ },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
+ var flags = FS.flagModes[str];
+ if (typeof flags === 'undefined') {
+ throw new Error('Unknown file open mode: ' + str);
+ }
+ return flags;
+ },flagsToPermissionString:function (flag) {
+ var accmode = flag & 2097155;
+ var perms = ['r', 'w', 'rw'][accmode];
+ if ((flag & 512)) {
+ perms += 'w';
+ }
+ return perms;
+ },nodePermissions:function (node, perms) {
+ if (FS.ignorePermissions) {
+ return 0;
+ }
+ // return 0 if any user, group or owner bits are set.
+ if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
+ return ERRNO_CODES.EACCES;
+ }
+ return 0;
+ },mayLookup:function (dir) {
+ return FS.nodePermissions(dir, 'x');
+ },mayCreate:function (dir, name) {
+ try {
+ var node = FS.lookupNode(dir, name);
+ return ERRNO_CODES.EEXIST;
+ } catch (e) {
+ }
+ return FS.nodePermissions(dir, 'wx');
+ },mayDelete:function (dir, name, isdir) {
+ var node;
+ try {
+ node = FS.lookupNode(dir, name);
+ } catch (e) {
+ return e.errno;
+ }
+ var err = FS.nodePermissions(dir, 'wx');
+ if (err) {
+ return err;
+ }
+ if (isdir) {
+ if (!FS.isDir(node.mode)) {
+ return ERRNO_CODES.ENOTDIR;
+ }
+ if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
+ return ERRNO_CODES.EBUSY;
+ }
+ } else {
+ if (FS.isDir(node.mode)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return 0;
+ },mayOpen:function (node, flags) {
+ if (!node) {
+ return ERRNO_CODES.ENOENT;
+ }
+ if (FS.isLink(node.mode)) {
+ return ERRNO_CODES.ELOOP;
+ } else if (FS.isDir(node.mode)) {
+ if ((flags & 2097155) !== 0 || // opening for write
+ (flags & 512)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
+ },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
+ fd_start = fd_start || 0;
+ fd_end = fd_end || FS.MAX_OPEN_FDS;
+ for (var fd = fd_start; fd <= fd_end; fd++) {
+ if (!FS.streams[fd]) {
+ return fd;
+ }
+ }
+ throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
+ },getStream:function (fd) {
+ return FS.streams[fd];
+ },createStream:function (stream, fd_start, fd_end) {
+ if (!FS.FSStream) {
+ FS.FSStream = function(){};
+ FS.FSStream.prototype = {};
+ // compatibility
+ Object.defineProperties(FS.FSStream.prototype, {
+ object: {
+ get: function() { return this.node; },
+ set: function(val) { this.node = val; }
+ },
+ isRead: {
+ get: function() { return (this.flags & 2097155) !== 1; }
+ },
+ isWrite: {
+ get: function() { return (this.flags & 2097155) !== 0; }
+ },
+ isAppend: {
+ get: function() { return (this.flags & 1024); }
+ }
+ });
+ }
+ if (0) {
+ // reuse the object
+ stream.__proto__ = FS.FSStream.prototype;
+ } else {
+ var newStream = new FS.FSStream();
+ for (var p in stream) {
+ newStream[p] = stream[p];
+ }
+ stream = newStream;
+ }
+ var fd = FS.nextfd(fd_start, fd_end);
+ stream.fd = fd;
+ FS.streams[fd] = stream;
+ return stream;
+ },closeStream:function (fd) {
+ FS.streams[fd] = null;
+ },getStreamFromPtr:function (ptr) {
+ return FS.streams[ptr - 1];
+ },getPtrForStream:function (stream) {
+ return stream ? stream.fd + 1 : 0;
+ },chrdev_stream_ops:{open:function (stream) {
+ var device = FS.getDevice(stream.node.rdev);
+ // override node's stream ops with the device's
+ stream.stream_ops = device.stream_ops;
+ // forward the open call
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ },llseek:function () {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }},major:function (dev) {
+ return ((dev) >> 8);
+ },minor:function (dev) {
+ return ((dev) & 0xff);
+ },makedev:function (ma, mi) {
+ return ((ma) << 8 | (mi));
+ },registerDevice:function (dev, ops) {
+ FS.devices[dev] = { stream_ops: ops };
+ },getDevice:function (dev) {
+ return FS.devices[dev];
+ },getMounts:function (mount) {
+ var mounts = [];
+ var check = [mount];
+
+ while (check.length) {
+ var m = check.pop();
+
+ mounts.push(m);
+
+ check.push.apply(check, m.mounts);
+ }
+
+ return mounts;
+ },syncfs:function (populate, callback) {
+ if (typeof(populate) === 'function') {
+ callback = populate;
+ populate = false;
+ }
+
+ var mounts = FS.getMounts(FS.root.mount);
+ var completed = 0;
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= mounts.length) {
+ callback(null);
+ }
+ };
+
+ // sync all mounts
+ mounts.forEach(function (mount) {
+ if (!mount.type.syncfs) {
+ return done(null);
+ }
+ mount.type.syncfs(mount, populate, done);
+ });
+ },mount:function (type, opts, mountpoint) {
+ var root = mountpoint === '/';
+ var pseudo = !mountpoint;
+ var node;
+
+ if (root && FS.root) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ } else if (!root && !pseudo) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ mountpoint = lookup.path; // use the absolute path
+ node = lookup.node;
+
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+
+ if (!FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ }
+
+ var mount = {
+ type: type,
+ opts: opts,
+ mountpoint: mountpoint,
+ mounts: []
+ };
+
+ // create a root node for the fs
+ var mountRoot = type.mount(mount);
+ mountRoot.mount = mount;
+ mount.root = mountRoot;
+
+ if (root) {
+ FS.root = mountRoot;
+ } else if (node) {
+ // set as a mountpoint
+ node.mounted = mount;
+
+ // add the new mount to the current mount's children
+ if (node.mount) {
+ node.mount.mounts.push(mount);
+ }
+ }
+
+ return mountRoot;
+ },unmount:function (mountpoint) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ if (!FS.isMountpoint(lookup.node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ // destroy the nodes for this mount, and all its child mounts
+ var node = lookup.node;
+ var mount = node.mounted;
+ var mounts = FS.getMounts(mount);
+
+ Object.keys(FS.nameTable).forEach(function (hash) {
+ var current = FS.nameTable[hash];
+
+ while (current) {
+ var next = current.name_next;
+
+ if (mounts.indexOf(current.mount) !== -1) {
+ FS.destroyNode(current);
+ }
+
+ current = next;
+ }
+ });
+
+ // no longer a mountpoint
+ node.mounted = null;
+
+ // remove this mount from the child mounts
+ var idx = node.mount.mounts.indexOf(mount);
+ assert(idx !== -1);
+ node.mount.mounts.splice(idx, 1);
+ },lookup:function (parent, name) {
+ return parent.node_ops.lookup(parent, name);
+ },mknod:function (path, mode, dev) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var err = FS.mayCreate(parent, name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.mknod) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.mknod(parent, name, mode, dev);
+ },create:function (path, mode) {
+ mode = mode !== undefined ? mode : 438 /* 0666 */;
+ mode &= 4095;
+ mode |= 32768;
+ return FS.mknod(path, mode, 0);
+ },mkdir:function (path, mode) {
+ mode = mode !== undefined ? mode : 511 /* 0777 */;
+ mode &= 511 | 512;
+ mode |= 16384;
+ return FS.mknod(path, mode, 0);
+ },mkdev:function (path, mode, dev) {
+ if (typeof(dev) === 'undefined') {
+ dev = mode;
+ mode = 438 /* 0666 */;
+ }
+ mode |= 8192;
+ return FS.mknod(path, mode, dev);
+ },symlink:function (oldpath, newpath) {
+ var lookup = FS.lookupPath(newpath, { parent: true });
+ var parent = lookup.node;
+ var newname = PATH.basename(newpath);
+ var err = FS.mayCreate(parent, newname);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.symlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.symlink(parent, newname, oldpath);
+ },rename:function (old_path, new_path) {
+ var old_dirname = PATH.dirname(old_path);
+ var new_dirname = PATH.dirname(new_path);
+ var old_name = PATH.basename(old_path);
+ var new_name = PATH.basename(new_path);
+ // parents must exist
+ var lookup, old_dir, new_dir;
+ try {
+ lookup = FS.lookupPath(old_path, { parent: true });
+ old_dir = lookup.node;
+ lookup = FS.lookupPath(new_path, { parent: true });
+ new_dir = lookup.node;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // need to be part of the same mount
+ if (old_dir.mount !== new_dir.mount) {
+ throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
+ }
+ // source must exist
+ var old_node = FS.lookupNode(old_dir, old_name);
+ // old path should not be an ancestor of the new path
+ var relative = PATH.relative(old_path, new_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ // new path should not be an ancestor of the old path
+ relative = PATH.relative(new_path, old_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ // see if the new path already exists
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ // not fatal
+ }
+ // early out if nothing needs to change
+ if (old_node === new_node) {
+ return;
+ }
+ // we'll need to delete the old entry
+ var isdir = FS.isDir(old_node.mode);
+ var err = FS.mayDelete(old_dir, old_name, isdir);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // need delete permissions if we'll be overwriting.
+ // need create permissions if new doesn't already exist.
+ err = new_node ?
+ FS.mayDelete(new_dir, new_name, isdir) :
+ FS.mayCreate(new_dir, new_name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!old_dir.node_ops.rename) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // if we are going to change the parent, check write permissions
+ if (new_dir !== old_dir) {
+ err = FS.nodePermissions(old_dir, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ }
+ // remove the node from the lookup hash
+ FS.hashRemoveNode(old_node);
+ // do the underlying fs rename
+ try {
+ old_dir.node_ops.rename(old_node, new_dir, new_name);
+ } catch (e) {
+ throw e;
+ } finally {
+ // add the node back to the hash (in case node_ops.rename
+ // changed its name)
+ FS.hashAddNode(old_node);
+ }
+ },rmdir:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, true);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.rmdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.rmdir(parent, name);
+ FS.destroyNode(node);
+ },readdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ if (!node.node_ops.readdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ return node.node_ops.readdir(node);
+ },unlink:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, false);
+ if (err) {
+ // POSIX says unlink should set EPERM, not EISDIR
+ if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.unlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.unlink(parent, name);
+ FS.destroyNode(node);
+ },readlink:function (path) {
+ var lookup = FS.lookupPath(path);
+ var link = lookup.node;
+ if (!link.node_ops.readlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return link.node_ops.readlink(link);
+ },stat:function (path, dontFollow) {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ var node = lookup.node;
+ if (!node.node_ops.getattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return node.node_ops.getattr(node);
+ },lstat:function (path) {
+ return FS.stat(path, true);
+ },chmod:function (path, mode, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ mode: (mode & 4095) | (node.mode & ~4095),
+ timestamp: Date.now()
+ });
+ },lchmod:function (path, mode) {
+ FS.chmod(path, mode, true);
+ },fchmod:function (fd, mode) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chmod(stream.node, mode);
+ },chown:function (path, uid, gid, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ timestamp: Date.now()
+ // we ignore the uid / gid for now
+ });
+ },lchown:function (path, uid, gid) {
+ FS.chown(path, uid, gid, true);
+ },fchown:function (fd, uid, gid) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chown(stream.node, uid, gid);
+ },truncate:function (path, len) {
+ if (len < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: true });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!FS.isFile(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var err = FS.nodePermissions(node, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ node.node_ops.setattr(node, {
+ size: len,
+ timestamp: Date.now()
+ });
+ },ftruncate:function (fd, len) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ FS.truncate(stream.node, len);
+ },utime:function (path, atime, mtime) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ node.node_ops.setattr(node, {
+ timestamp: Math.max(atime, mtime)
+ });
+ },open:function (path, flags, mode, fd_start, fd_end) {
+ flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
+ mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
+ if ((flags & 64)) {
+ mode = (mode & 4095) | 32768;
+ } else {
+ mode = 0;
+ }
+ var node;
+ if (typeof path === 'object') {
+ node = path;
+ } else {
+ path = PATH.normalize(path);
+ try {
+ var lookup = FS.lookupPath(path, {
+ follow: !(flags & 131072)
+ });
+ node = lookup.node;
+ } catch (e) {
+ // ignore
+ }
+ }
+ // perhaps we need to create the node
+ if ((flags & 64)) {
+ if (node) {
+ // if O_CREAT and O_EXCL are set, error out if the node already exists
+ if ((flags & 128)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
+ }
+ } else {
+ // node doesn't exist, try to create it
+ node = FS.mknod(path, mode, 0);
+ }
+ }
+ if (!node) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
+ }
+ // can't truncate a device
+ if (FS.isChrdev(node.mode)) {
+ flags &= ~512;
+ }
+ // check permissions
+ var err = FS.mayOpen(node, flags);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // do truncation if necessary
+ if ((flags & 512)) {
+ FS.truncate(node, 0);
+ }
+ // we've already handled these, don't pass down to the underlying vfs
+ flags &= ~(128 | 512);
+
+ // register the stream with the filesystem
+ var stream = FS.createStream({
+ node: node,
+ path: FS.getPath(node), // we want the absolute path to the node
+ flags: flags,
+ seekable: true,
+ position: 0,
+ stream_ops: node.stream_ops,
+ // used by the file family libc calls (fopen, fwrite, ferror, etc.)
+ ungotten: [],
+ error: false
+ }, fd_start, fd_end);
+ // call the new stream's open function
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ if (Module['logReadFiles'] && !(flags & 1)) {
+ if (!FS.readFiles) FS.readFiles = {};
+ if (!(path in FS.readFiles)) {
+ FS.readFiles[path] = 1;
+ Module['printErr']('read file: ' + path);
+ }
+ }
+ return stream;
+ },close:function (stream) {
+ try {
+ if (stream.stream_ops.close) {
+ stream.stream_ops.close(stream);
+ }
+ } catch (e) {
+ throw e;
+ } finally {
+ FS.closeStream(stream.fd);
+ }
+ },llseek:function (stream, offset, whence) {
+ if (!stream.seekable || !stream.stream_ops.llseek) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ return stream.stream_ops.llseek(stream, offset, whence);
+ },read:function (stream, buffer, offset, length, position) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.read) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
+ if (!seeking) stream.position += bytesRead;
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.write) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ if (stream.flags & 1024) {
+ // seek to the end before writing in append mode
+ FS.llseek(stream, 0, 2);
+ }
+ var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
+ if (!seeking) stream.position += bytesWritten;
+ return bytesWritten;
+ },allocate:function (stream, offset, length) {
+ if (offset < 0 || length <= 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ if (!stream.stream_ops.allocate) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ stream.stream_ops.allocate(stream, offset, length);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ // TODO if PROT is PROT_WRITE, make sure we have write access
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EACCES);
+ }
+ if (!stream.stream_ops.mmap) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
+ },ioctl:function (stream, cmd, arg) {
+ if (!stream.stream_ops.ioctl) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
+ }
+ return stream.stream_ops.ioctl(stream, cmd, arg);
+ },readFile:function (path, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'r';
+ opts.encoding = opts.encoding || 'binary';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var ret;
+ var stream = FS.open(path, opts.flags);
+ var stat = FS.stat(path);
+ var length = stat.size;
+ var buf = new Uint8Array(length);
+ FS.read(stream, buf, 0, length, 0);
+ if (opts.encoding === 'utf8') {
+ ret = '';
+ var utf8 = new Runtime.UTF8Processor();
+ for (var i = 0; i < length; i++) {
+ ret += utf8.processCChar(buf[i]);
+ }
+ } else if (opts.encoding === 'binary') {
+ ret = buf;
+ }
+ FS.close(stream);
+ return ret;
+ },writeFile:function (path, data, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'w';
+ opts.encoding = opts.encoding || 'utf8';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var stream = FS.open(path, opts.flags, opts.mode);
+ if (opts.encoding === 'utf8') {
+ var utf8 = new Runtime.UTF8Processor();
+ var buf = new Uint8Array(utf8.processJSString(data));
+ FS.write(stream, buf, 0, buf.length, 0, opts.canOwn);
+ } else if (opts.encoding === 'binary') {
+ FS.write(stream, data, 0, data.length, 0, opts.canOwn);
+ }
+ FS.close(stream);
+ },cwd:function () {
+ return FS.currentPath;
+ },chdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ if (!FS.isDir(lookup.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ var err = FS.nodePermissions(lookup.node, 'x');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ FS.currentPath = lookup.path;
+ },createDefaultDirectories:function () {
+ FS.mkdir('/tmp');
+ },createDefaultDevices:function () {
+ // create /dev
+ FS.mkdir('/dev');
+ // setup /dev/null
+ FS.registerDevice(FS.makedev(1, 3), {
+ read: function() { return 0; },
+ write: function() { return 0; }
+ });
+ FS.mkdev('/dev/null', FS.makedev(1, 3));
+ // setup /dev/tty and /dev/tty1
+ // stderr needs to print output using Module['printErr']
+ // so we register a second tty just for it.
+ TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
+ TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
+ FS.mkdev('/dev/tty', FS.makedev(5, 0));
+ FS.mkdev('/dev/tty1', FS.makedev(6, 0));
+ // we're not going to emulate the actual shm device,
+ // just create the tmp dirs that reside in it commonly
+ FS.mkdir('/dev/shm');
+ FS.mkdir('/dev/shm/tmp');
+ },createStandardStreams:function () {
+ // TODO deprecate the old functionality of a single
+ // input / output callback and that utilizes FS.createDevice
+ // and instead require a unique set of stream ops
+
+ // by default, we symlink the standard streams to the
+ // default tty devices. however, if the standard streams
+ // have been overwritten we create a unique device for
+ // them instead.
+ if (Module['stdin']) {
+ FS.createDevice('/dev', 'stdin', Module['stdin']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdin');
+ }
+ if (Module['stdout']) {
+ FS.createDevice('/dev', 'stdout', null, Module['stdout']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdout');
+ }
+ if (Module['stderr']) {
+ FS.createDevice('/dev', 'stderr', null, Module['stderr']);
+ } else {
+ FS.symlink('/dev/tty1', '/dev/stderr');
+ }
+
+ // open default streams for the stdin, stdout and stderr devices
+ var stdin = FS.open('/dev/stdin', 'r');
+ HEAP32[((_stdin)>>2)]=FS.getPtrForStream(stdin);
+ assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
+
+ var stdout = FS.open('/dev/stdout', 'w');
+ HEAP32[((_stdout)>>2)]=FS.getPtrForStream(stdout);
+ assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
+
+ var stderr = FS.open('/dev/stderr', 'w');
+ HEAP32[((_stderr)>>2)]=FS.getPtrForStream(stderr);
+ assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
+ },ensureErrnoError:function () {
+ if (FS.ErrnoError) return;
+ FS.ErrnoError = function ErrnoError(errno) {
+ this.errno = errno;
+ for (var key in ERRNO_CODES) {
+ if (ERRNO_CODES[key] === errno) {
+ this.code = key;
+ break;
+ }
+ }
+ this.message = ERRNO_MESSAGES[errno];
+ };
+ FS.ErrnoError.prototype = new Error();
+ FS.ErrnoError.prototype.constructor = FS.ErrnoError;
+ // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
+ [ERRNO_CODES.ENOENT].forEach(function(code) {
+ FS.genericErrors[code] = new FS.ErrnoError(code);
+ FS.genericErrors[code].stack = '<generic error, no stack>';
+ });
+ },staticInit:function () {
+ FS.ensureErrnoError();
+
+ FS.nameTable = new Array(4096);
+
+ FS.mount(MEMFS, {}, '/');
+
+ FS.createDefaultDirectories();
+ FS.createDefaultDevices();
+ },init:function (input, output, error) {
+ assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
+ FS.init.initialized = true;
+
+ FS.ensureErrnoError();
+
+ // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
+ Module['stdin'] = input || Module['stdin'];
+ Module['stdout'] = output || Module['stdout'];
+ Module['stderr'] = error || Module['stderr'];
+
+ FS.createStandardStreams();
+ },quit:function () {
+ FS.init.initialized = false;
+ for (var i = 0; i < FS.streams.length; i++) {
+ var stream = FS.streams[i];
+ if (!stream) {
+ continue;
+ }
+ FS.close(stream);
+ }
+ },getMode:function (canRead, canWrite) {
+ var mode = 0;
+ if (canRead) mode |= 292 | 73;
+ if (canWrite) mode |= 146;
+ return mode;
+ },joinPath:function (parts, forceRelative) {
+ var path = PATH.join.apply(null, parts);
+ if (forceRelative && path[0] == '/') path = path.substr(1);
+ return path;
+ },absolutePath:function (relative, base) {
+ return PATH.resolve(base, relative);
+ },standardizePath:function (path) {
+ return PATH.normalize(path);
+ },findObject:function (path, dontResolveLastLink) {
+ var ret = FS.analyzePath(path, dontResolveLastLink);
+ if (ret.exists) {
+ return ret.object;
+ } else {
+ ___setErrNo(ret.error);
+ return null;
+ }
+ },analyzePath:function (path, dontResolveLastLink) {
+ // operate from within the context of the symlink's target
+ try {
+ var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ path = lookup.path;
+ } catch (e) {
+ }
+ var ret = {
+ isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
+ parentExists: false, parentPath: null, parentObject: null
+ };
+ try {
+ var lookup = FS.lookupPath(path, { parent: true });
+ ret.parentExists = true;
+ ret.parentPath = lookup.path;
+ ret.parentObject = lookup.node;
+ ret.name = PATH.basename(path);
+ lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ ret.exists = true;
+ ret.path = lookup.path;
+ ret.object = lookup.node;
+ ret.name = lookup.node.name;
+ ret.isRoot = lookup.path === '/';
+ } catch (e) {
+ ret.error = e.errno;
+ };
+ return ret;
+ },createFolder:function (parent, name, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.mkdir(path, mode);
+ },createPath:function (parent, path, canRead, canWrite) {
+ parent = typeof parent === 'string' ? parent : FS.getPath(parent);
+ var parts = path.split('/').reverse();
+ while (parts.length) {
+ var part = parts.pop();
+ if (!part) continue;
+ var current = PATH.join2(parent, part);
+ try {
+ FS.mkdir(current);
+ } catch (e) {
+ // ignore EEXIST
+ }
+ parent = current;
+ }
+ return current;
+ },createFile:function (parent, name, properties, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.create(path, mode);
+ },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
+ var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
+ var mode = FS.getMode(canRead, canWrite);
+ var node = FS.create(path, mode);
+ if (data) {
+ if (typeof data === 'string') {
+ var arr = new Array(data.length);
+ for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
+ data = arr;
+ }
+ // make sure we can write to the file
+ FS.chmod(node, mode | 146);
+ var stream = FS.open(node, 'w');
+ FS.write(stream, data, 0, data.length, 0, canOwn);
+ FS.close(stream);
+ FS.chmod(node, mode);
+ }
+ return node;
+ },createDevice:function (parent, name, input, output) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(!!input, !!output);
+ if (!FS.createDevice.major) FS.createDevice.major = 64;
+ var dev = FS.makedev(FS.createDevice.major++, 0);
+ // Create a fake device that a set of stream ops to emulate
+ // the old behavior.
+ FS.registerDevice(dev, {
+ open: function(stream) {
+ stream.seekable = false;
+ },
+ close: function(stream) {
+ // flush any pending line data
+ if (output && output.buffer && output.buffer.length) {
+ output(10);
+ }
+ },
+ read: function(stream, buffer, offset, length, pos /* ignored */) {
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = input();
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },
+ write: function(stream, buffer, offset, length, pos) {
+ for (var i = 0; i < length; i++) {
+ try {
+ output(buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }
+ });
+ return FS.mkdev(path, mode, dev);
+ },createLink:function (parent, name, target, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ return FS.symlink(target, path);
+ },forceLoadFile:function (obj) {
+ if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
+ var success = true;
+ if (typeof XMLHttpRequest !== 'undefined') {
+ throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
+ } else if (Module['read']) {
+ // Command-line.
+ try {
+ // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
+ // read() will try to parse UTF8.
+ obj.contents = intArrayFromString(Module['read'](obj.url), true);
+ } catch (e) {
+ success = false;
+ }
+ } else {
+ throw new Error('Cannot load without read() or XMLHttpRequest.');
+ }
+ if (!success) ___setErrNo(ERRNO_CODES.EIO);
+ return success;
+ },createLazyFile:function (parent, name, url, canRead, canWrite) {
+ // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
+ function LazyUint8Array() {
+ this.lengthKnown = false;
+ this.chunks = []; // Loaded chunks. Index is the chunk number
+ }
+ LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
+ if (idx > this.length-1 || idx < 0) {
+ return undefined;
+ }
+ var chunkOffset = idx % this.chunkSize;
+ var chunkNum = Math.floor(idx / this.chunkSize);
+ return this.getter(chunkNum)[chunkOffset];
+ }
+ LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
+ this.getter = getter;
+ }
+ LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
+ // Find length
+ var xhr = new XMLHttpRequest();
+ xhr.open('HEAD', url, false);
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ var datalength = Number(xhr.getResponseHeader("Content-length"));
+ var header;
+ var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
+ var chunkSize = 1024*1024; // Chunk size in bytes
+
+ if (!hasByteServing) chunkSize = datalength;
+
+ // Function to get a range from the remote URL.
+ var doXHR = (function(from, to) {
+ if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
+ if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
+
+ // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
+
+ // Some hints to the browser that we want binary data.
+ if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
+ if (xhr.overrideMimeType) {
+ xhr.overrideMimeType('text/plain; charset=x-user-defined');
+ }
+
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ if (xhr.response !== undefined) {
+ return new Uint8Array(xhr.response || []);
+ } else {
+ return intArrayFromString(xhr.responseText || '', true);
+ }
+ });
+ var lazyArray = this;
+ lazyArray.setDataGetter(function(chunkNum) {
+ var start = chunkNum * chunkSize;
+ var end = (chunkNum+1) * chunkSize - 1; // including this byte
+ end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
+ lazyArray.chunks[chunkNum] = doXHR(start, end);
+ }
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
+ return lazyArray.chunks[chunkNum];
+ });
+
+ this._length = datalength;
+ this._chunkSize = chunkSize;
+ this.lengthKnown = true;
+ }
+ if (typeof XMLHttpRequest !== 'undefined') {
+ if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
+ var lazyArray = new LazyUint8Array();
+ Object.defineProperty(lazyArray, "length", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._length;
+ }
+ });
+ Object.defineProperty(lazyArray, "chunkSize", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._chunkSize;
+ }
+ });
+
+ var properties = { isDevice: false, contents: lazyArray };
+ } else {
+ var properties = { isDevice: false, url: url };
+ }
+
+ var node = FS.createFile(parent, name, properties, canRead, canWrite);
+ // This is a total hack, but I want to get this lazy file code out of the
+ // core of MEMFS. If we want to keep this lazy file concept I feel it should
+ // be its own thin LAZYFS proxying calls to MEMFS.
+ if (properties.contents) {
+ node.contents = properties.contents;
+ } else if (properties.url) {
+ node.contents = null;
+ node.url = properties.url;
+ }
+ // override each stream op with one that tries to force load the lazy file first
+ var stream_ops = {};
+ var keys = Object.keys(node.stream_ops);
+ keys.forEach(function(key) {
+ var fn = node.stream_ops[key];
+ stream_ops[key] = function forceLoadLazyFile() {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ return fn.apply(null, arguments);
+ };
+ });
+ // use a custom read function
+ stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (contents.slice) { // normal array
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ } else {
+ for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
+ buffer[offset + i] = contents.get(position + i);
+ }
+ }
+ return size;
+ };
+ node.stream_ops = stream_ops;
+ return node;
+ },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {
+ Browser.init();
+ // TODO we should allow people to just pass in a complete filename instead
+ // of parent and name being that we just join them anyways
+ var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
+ function processData(byteArray) {
+ function finish(byteArray) {
+ if (!dontCreateFile) {
+ FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
+ }
+ if (onload) onload();
+ removeRunDependency('cp ' + fullname);
+ }
+ var handled = false;
+ Module['preloadPlugins'].forEach(function(plugin) {
+ if (handled) return;
+ if (plugin['canHandle'](fullname)) {
+ plugin['handle'](byteArray, fullname, finish, function() {
+ if (onerror) onerror();
+ removeRunDependency('cp ' + fullname);
+ });
+ handled = true;
+ }
+ });
+ if (!handled) finish(byteArray);
+ }
+ addRunDependency('cp ' + fullname);
+ if (typeof url == 'string') {
+ Browser.asyncLoad(url, function(byteArray) {
+ processData(byteArray);
+ }, onerror);
+ } else {
+ processData(url);
+ }
+ },indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_NAME:function () {
+ return 'EM_FS_' + window.location.pathname;
+ },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
+ console.log('creating db');
+ var db = openRequest.result;
+ db.createObjectStore(FS.DB_STORE_NAME);
+ };
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var putRequest = files.put(FS.analyzePath(path).object.contents, path);
+ putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
+ putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ },loadFilesFromDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = onerror; // no database to load from
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ try {
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
+ } catch(e) {
+ onerror(e);
+ return;
+ }
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var getRequest = files.get(path);
+ getRequest.onsuccess = function getRequest_onsuccess() {
+ if (FS.analyzePath(path).exists) {
+ FS.unlink(path);
+ }
+ FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
+ ok++;
+ if (ok + fail == total) finish();
+ };
+ getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ }};
+
+
+
+
+ function _mkport() { throw 'TODO' }var SOCKFS={mount:function (mount) {
+ return FS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createSocket:function (family, type, protocol) {
+ var streaming = type == 1;
+ if (protocol) {
+ assert(streaming == (protocol == 6)); // if SOCK_STREAM, must be tcp
+ }
+
+ // create our internal socket structure
+ var sock = {
+ family: family,
+ type: type,
+ protocol: protocol,
+ server: null,
+ peers: {},
+ pending: [],
+ recv_queue: [],
+ sock_ops: SOCKFS.websocket_sock_ops
+ };
+
+ // create the filesystem node to store the socket structure
+ var name = SOCKFS.nextname();
+ var node = FS.createNode(SOCKFS.root, name, 49152, 0);
+ node.sock = sock;
+
+ // and the wrapping stream that enables library functions such
+ // as read and write to indirectly interact with the socket
+ var stream = FS.createStream({
+ path: name,
+ node: node,
+ flags: FS.modeStringToFlags('r+'),
+ seekable: false,
+ stream_ops: SOCKFS.stream_ops
+ });
+
+ // map the new stream to the socket structure (sockets have a 1:1
+ // relationship with a stream)
+ sock.stream = stream;
+
+ return sock;
+ },getSocket:function (fd) {
+ var stream = FS.getStream(fd);
+ if (!stream || !FS.isSocket(stream.node.mode)) {
+ return null;
+ }
+ return stream.node.sock;
+ },stream_ops:{poll:function (stream) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.poll(sock);
+ },ioctl:function (stream, request, varargs) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.ioctl(sock, request, varargs);
+ },read:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ var msg = sock.sock_ops.recvmsg(sock, length);
+ if (!msg) {
+ // socket is closed
+ return 0;
+ }
+ buffer.set(msg.buffer, offset);
+ return msg.buffer.length;
+ },write:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.sendmsg(sock, buffer, offset, length);
+ },close:function (stream) {
+ var sock = stream.node.sock;
+ sock.sock_ops.close(sock);
+ }},nextname:function () {
+ if (!SOCKFS.nextname.current) {
+ SOCKFS.nextname.current = 0;
+ }
+ return 'socket[' + (SOCKFS.nextname.current++) + ']';
+ },websocket_sock_ops:{createPeer:function (sock, addr, port) {
+ var ws;
+
+ if (typeof addr === 'object') {
+ ws = addr;
+ addr = null;
+ port = null;
+ }
+
+ if (ws) {
+ // for sockets that've already connected (e.g. we're the server)
+ // we can inspect the _socket property for the address
+ if (ws._socket) {
+ addr = ws._socket.remoteAddress;
+ port = ws._socket.remotePort;
+ }
+ // if we're just now initializing a connection to the remote,
+ // inspect the url property
+ else {
+ var result = /ws[s]?:\/\/([^:]+):(\d+)/.exec(ws.url);
+ if (!result) {
+ throw new Error('WebSocket URL must be in the format ws(s)://address:port');
+ }
+ addr = result[1];
+ port = parseInt(result[2], 10);
+ }
+ } else {
+ // create the actual websocket object and connect
+ try {
+ // runtimeConfig gets set to true if WebSocket runtime configuration is available.
+ var runtimeConfig = (Module['websocket'] && ('object' === typeof Module['websocket']));
+
+ // The default value is 'ws://' the replace is needed because the compiler replaces "//" comments with '#'
+ // comments without checking context, so we'd end up with ws:#, the replace swaps the "#" for "//" again.
+ var url = 'ws:#'.replace('#', '//');
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['url']) {
+ url = Module['websocket']['url']; // Fetch runtime WebSocket URL config.
+ }
+ }
+
+ if (url === 'ws://' || url === 'wss://') { // Is the supplied URL config just a prefix, if so complete it.
+ url = url + addr + ':' + port;
+ }
+
+ // Make the WebSocket subprotocol (Sec-WebSocket-Protocol) default to binary if no configuration is set.
+ var subProtocols = 'binary'; // The default value is 'binary'
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['subprotocol']) {
+ subProtocols = Module['websocket']['subprotocol']; // Fetch runtime WebSocket subprotocol config.
+ }
+ }
+
+ // The regex trims the string (removes spaces at the beginning and end, then splits the string by
+ // <any space>,<any space> into an Array. Whitespace removal is important for Websockify and ws.
+ subProtocols = subProtocols.replace(/^ +| +$/g,"").split(/ *, */);
+
+ // The node ws library API for specifying optional subprotocol is slightly different than the browser's.
+ var opts = ENVIRONMENT_IS_NODE ? {'protocol': subProtocols.toString()} : subProtocols;
+
+ // If node we use the ws library.
+ var WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : window['WebSocket'];
+ ws = new WebSocket(url, opts);
+ ws.binaryType = 'arraybuffer';
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EHOSTUNREACH);
+ }
+ }
+
+
+ var peer = {
+ addr: addr,
+ port: port,
+ socket: ws,
+ dgram_send_queue: []
+ };
+
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);
+
+ // if this is a bound dgram socket, send the port number first to allow
+ // us to override the ephemeral port reported to us by remotePort on the
+ // remote end.
+ if (sock.type === 2 && typeof sock.sport !== 'undefined') {
+ peer.dgram_send_queue.push(new Uint8Array([
+ 255, 255, 255, 255,
+ 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),
+ ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)
+ ]));
+ }
+
+ return peer;
+ },getPeer:function (sock, addr, port) {
+ return sock.peers[addr + ':' + port];
+ },addPeer:function (sock, peer) {
+ sock.peers[peer.addr + ':' + peer.port] = peer;
+ },removePeer:function (sock, peer) {
+ delete sock.peers[peer.addr + ':' + peer.port];
+ },handlePeerEvents:function (sock, peer) {
+ var first = true;
+
+ var handleOpen = function () {
+ try {
+ var queued = peer.dgram_send_queue.shift();
+ while (queued) {
+ peer.socket.send(queued);
+ queued = peer.dgram_send_queue.shift();
+ }
+ } catch (e) {
+ // not much we can do here in the way of proper error handling as we've already
+ // lied and said this data was sent. shut it down.
+ peer.socket.close();
+ }
+ };
+
+ function handleMessage(data) {
+ assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer
+ data = new Uint8Array(data); // make a typed array view on the array buffer
+
+
+ // if this is the port message, override the peer's port with it
+ var wasfirst = first;
+ first = false;
+ if (wasfirst &&
+ data.length === 10 &&
+ data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&
+ data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {
+ // update the peer's port and it's key in the peer map
+ var newport = ((data[8] << 8) | data[9]);
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ peer.port = newport;
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ return;
+ }
+
+ sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });
+ };
+
+ if (ENVIRONMENT_IS_NODE) {
+ peer.socket.on('open', handleOpen);
+ peer.socket.on('message', function(data, flags) {
+ if (!flags.binary) {
+ return;
+ }
+ handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
+ });
+ peer.socket.on('error', function() {
+ // don't throw
+ });
+ } else {
+ peer.socket.onopen = handleOpen;
+ peer.socket.onmessage = function peer_socket_onmessage(event) {
+ handleMessage(event.data);
+ };
+ }
+ },poll:function (sock) {
+ if (sock.type === 1 && sock.server) {
+ // listen sockets should only say they're available for reading
+ // if there are pending clients.
+ return sock.pending.length ? (64 | 1) : 0;
+ }
+
+ var mask = 0;
+ var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets
+ SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :
+ null;
+
+ if (sock.recv_queue.length ||
+ !dest || // connection-less sockets are always ready to read
+ (dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed
+ mask |= (64 | 1);
+ }
+
+ if (!dest || // connection-less sockets are always ready to write
+ (dest && dest.socket.readyState === dest.socket.OPEN)) {
+ mask |= 4;
+ }
+
+ if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) {
+ mask |= 16;
+ }
+
+ return mask;
+ },ioctl:function (sock, request, arg) {
+ switch (request) {
+ case 21531:
+ var bytes = 0;
+ if (sock.recv_queue.length) {
+ bytes = sock.recv_queue[0].data.length;
+ }
+ HEAP32[((arg)>>2)]=bytes;
+ return 0;
+ default:
+ return ERRNO_CODES.EINVAL;
+ }
+ },close:function (sock) {
+ // if we've spawned a listen server, close it
+ if (sock.server) {
+ try {
+ sock.server.close();
+ } catch (e) {
+ }
+ sock.server = null;
+ }
+ // close any peer connections
+ var peers = Object.keys(sock.peers);
+ for (var i = 0; i < peers.length; i++) {
+ var peer = sock.peers[peers[i]];
+ try {
+ peer.socket.close();
+ } catch (e) {
+ }
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ }
+ return 0;
+ },bind:function (sock, addr, port) {
+ if (typeof sock.saddr !== 'undefined' || typeof sock.sport !== 'undefined') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already bound
+ }
+ sock.saddr = addr;
+ sock.sport = port || _mkport();
+ // in order to emulate dgram sockets, we need to launch a listen server when
+ // binding on a connection-less socket
+ // note: this is only required on the server side
+ if (sock.type === 2) {
+ // close the existing server if it exists
+ if (sock.server) {
+ sock.server.close();
+ sock.server = null;
+ }
+ // swallow error operation not supported error that occurs when binding in the
+ // browser where this isn't supported
+ try {
+ sock.sock_ops.listen(sock, 0);
+ } catch (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e;
+ if (e.errno !== ERRNO_CODES.EOPNOTSUPP) throw e;
+ }
+ }
+ },connect:function (sock, addr, port) {
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODS.EOPNOTSUPP);
+ }
+
+ // TODO autobind
+ // if (!sock.addr && sock.type == 2) {
+ // }
+
+ // early out if we're already connected / in the middle of connecting
+ if (typeof sock.daddr !== 'undefined' && typeof sock.dport !== 'undefined') {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+ if (dest) {
+ if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EALREADY);
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EISCONN);
+ }
+ }
+ }
+
+ // add the socket to our peer list and set our
+ // destination address / port to match
+ var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ sock.daddr = peer.addr;
+ sock.dport = peer.port;
+
+ // always "fail" in non-blocking mode
+ throw new FS.ErrnoError(ERRNO_CODES.EINPROGRESS);
+ },listen:function (sock, backlog) {
+ if (!ENVIRONMENT_IS_NODE) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already listening
+ }
+ var WebSocketServer = require('ws').Server;
+ var host = sock.saddr;
+ sock.server = new WebSocketServer({
+ host: host,
+ port: sock.sport
+ // TODO support backlog
+ });
+
+ sock.server.on('connection', function(ws) {
+ if (sock.type === 1) {
+ var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);
+
+ // create a peer on the new socket
+ var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);
+ newsock.daddr = peer.addr;
+ newsock.dport = peer.port;
+
+ // push to queue for accept to pick up
+ sock.pending.push(newsock);
+ } else {
+ // create a peer on the listen socket so calling sendto
+ // with the listen socket and an address will resolve
+ // to the correct client
+ SOCKFS.websocket_sock_ops.createPeer(sock, ws);
+ }
+ });
+ sock.server.on('closed', function() {
+ sock.server = null;
+ });
+ sock.server.on('error', function() {
+ // don't throw
+ });
+ },accept:function (listensock) {
+ if (!listensock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var newsock = listensock.pending.shift();
+ newsock.stream.flags = listensock.stream.flags;
+ return newsock;
+ },getname:function (sock, peer) {
+ var addr, port;
+ if (peer) {
+ if (sock.daddr === undefined || sock.dport === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ addr = sock.daddr;
+ port = sock.dport;
+ } else {
+ // TODO saddr and sport will be set for bind()'d UDP sockets, but what
+ // should we be returning for TCP sockets that've been connect()'d?
+ addr = sock.saddr || 0;
+ port = sock.sport || 0;
+ }
+ return { addr: addr, port: port };
+ },sendmsg:function (sock, buffer, offset, length, addr, port) {
+ if (sock.type === 2) {
+ // connection-less sockets will honor the message address,
+ // and otherwise fall back to the bound destination address
+ if (addr === undefined || port === undefined) {
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+ // if there was no address to fall back to, error out
+ if (addr === undefined || port === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.EDESTADDRREQ);
+ }
+ } else {
+ // connection-based sockets will only use the bound
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+
+ // find the peer for the destination address
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);
+
+ // early out if not connected with a connection-based socket
+ if (sock.type === 1) {
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ } else if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // create a copy of the incoming data to send, as the WebSocket API
+ // doesn't work entirely with an ArrayBufferView, it'll just send
+ // the entire underlying buffer
+ var data;
+ if (buffer instanceof Array || buffer instanceof ArrayBuffer) {
+ data = buffer.slice(offset, offset + length);
+ } else { // ArrayBufferView
+ data = buffer.buffer.slice(buffer.byteOffset + offset, buffer.byteOffset + offset + length);
+ }
+
+ // if we're emulating a connection-less dgram socket and don't have
+ // a cached connection, queue the buffer to send upon connect and
+ // lie, saying the data was sent now.
+ if (sock.type === 2) {
+ if (!dest || dest.socket.readyState !== dest.socket.OPEN) {
+ // if we're not connected, open a new connection
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ }
+ dest.dgram_send_queue.push(data);
+ return length;
+ }
+ }
+
+ try {
+ // send the actual data
+ dest.socket.send(data);
+ return length;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ },recvmsg:function (sock, length) {
+ // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html
+ if (sock.type === 1 && sock.server) {
+ // tcp servers should not be recv()'ing on the listen socket
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+
+ var queued = sock.recv_queue.shift();
+ if (!queued) {
+ if (sock.type === 1) {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+
+ if (!dest) {
+ // if we have a destination address but are not connected, error out
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ else if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ // return null if the socket has closed
+ return null;
+ }
+ else {
+ // else, our socket is in a valid state but truly has nothing available
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // queued.data will be an ArrayBuffer if it's unadulterated, but if it's
+ // requeued TCP data it'll be an ArrayBufferView
+ var queuedLength = queued.data.byteLength || queued.data.length;
+ var queuedOffset = queued.data.byteOffset || 0;
+ var queuedBuffer = queued.data.buffer || queued.data;
+ var bytesRead = Math.min(length, queuedLength);
+ var res = {
+ buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),
+ addr: queued.addr,
+ port: queued.port
+ };
+
+
+ // push back any unread data for TCP connections
+ if (sock.type === 1 && bytesRead < queuedLength) {
+ var bytesRemaining = queuedLength - bytesRead;
+ queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
+ sock.recv_queue.unshift(queued);
+ }
+
+ return res;
+ }}};function _send(fd, buf, len, flags) {
+ var sock = SOCKFS.getSocket(fd);
+ if (!sock) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ // TODO honor flags
+ return _write(fd, buf, len);
+ }
+
+ function _pwrite(fildes, buf, nbyte, offset) {
+ // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte, offset);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _write(fildes, buf, nbyte) {
+ // ssize_t write(int fildes, const void *buf, size_t nbyte);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+
+
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }
+
+ function _fileno(stream) {
+ // int fileno(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fileno.html
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) return -1;
+ return stream.fd;
+ }function _fwrite(ptr, size, nitems, stream) {
+ // size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html
+ var bytesToWrite = nitems * size;
+ if (bytesToWrite == 0) return 0;
+ var fd = _fileno(stream);
+ var bytesWritten = _write(fd, ptr, bytesToWrite);
+ if (bytesWritten == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return 0;
+ } else {
+ return Math.floor(bytesWritten / size);
+ }
+ }
+
+
+
+ Module["_strlen"] = _strlen;
+
+ function __reallyNegative(x) {
+ return x < 0 || (x === 0 && (1/x) === -Infinity);
+ }function __formatString(format, varargs) {
+ var textIndex = format;
+ var argIndex = 0;
+ function getNextArg(type) {
+ // NOTE: Explicitly ignoring type safety. Otherwise this fails:
+ // int x = 4; printf("%c\n", (char)x);
+ var ret;
+ if (type === 'double') {
+ ret = HEAPF64[(((varargs)+(argIndex))>>3)];
+ } else if (type == 'i64') {
+ ret = [HEAP32[(((varargs)+(argIndex))>>2)],
+ HEAP32[(((varargs)+(argIndex+4))>>2)]];
+
+ } else {
+ type = 'i32'; // varargs are always i32, i64, or double
+ ret = HEAP32[(((varargs)+(argIndex))>>2)];
+ }
+ argIndex += Runtime.getNativeFieldSize(type);
+ return ret;
+ }
+
+ var ret = [];
+ var curr, next, currArg;
+ while(1) {
+ var startTextIndex = textIndex;
+ curr = HEAP8[(textIndex)];
+ if (curr === 0) break;
+ next = HEAP8[((textIndex+1)|0)];
+ if (curr == 37) {
+ // Handle flags.
+ var flagAlwaysSigned = false;
+ var flagLeftAlign = false;
+ var flagAlternative = false;
+ var flagZeroPad = false;
+ var flagPadSign = false;
+ flagsLoop: while (1) {
+ switch (next) {
+ case 43:
+ flagAlwaysSigned = true;
+ break;
+ case 45:
+ flagLeftAlign = true;
+ break;
+ case 35:
+ flagAlternative = true;
+ break;
+ case 48:
+ if (flagZeroPad) {
+ break flagsLoop;
+ } else {
+ flagZeroPad = true;
+ break;
+ }
+ case 32:
+ flagPadSign = true;
+ break;
+ default:
+ break flagsLoop;
+ }
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+
+ // Handle width.
+ var width = 0;
+ if (next == 42) {
+ width = getNextArg('i32');
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ } else {
+ while (next >= 48 && next <= 57) {
+ width = width * 10 + (next - 48);
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ }
+
+ // Handle precision.
+ var precisionSet = false, precision = -1;
+ if (next == 46) {
+ precision = 0;
+ precisionSet = true;
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ if (next == 42) {
+ precision = getNextArg('i32');
+ textIndex++;
+ } else {
+ while(1) {
+ var precisionChr = HEAP8[((textIndex+1)|0)];
+ if (precisionChr < 48 ||
+ precisionChr > 57) break;
+ precision = precision * 10 + (precisionChr - 48);
+ textIndex++;
+ }
+ }
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ if (precision < 0) {
+ precision = 6; // Standard default.
+ precisionSet = false;
+ }
+
+ // Handle integer sizes. WARNING: These assume a 32-bit architecture!
+ var argSize;
+ switch (String.fromCharCode(next)) {
+ case 'h':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 104) {
+ textIndex++;
+ argSize = 1; // char (actually i32 in varargs)
+ } else {
+ argSize = 2; // short (actually i32 in varargs)
+ }
+ break;
+ case 'l':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 108) {
+ textIndex++;
+ argSize = 8; // long long
+ } else {
+ argSize = 4; // long
+ }
+ break;
+ case 'L': // long long
+ case 'q': // int64_t
+ case 'j': // intmax_t
+ argSize = 8;
+ break;
+ case 'z': // size_t
+ case 't': // ptrdiff_t
+ case 'I': // signed ptrdiff_t or unsigned size_t
+ argSize = 4;
+ break;
+ default:
+ argSize = null;
+ }
+ if (argSize) textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+
+ // Handle type specifier.
+ switch (String.fromCharCode(next)) {
+ case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {
+ // Integer.
+ var signed = next == 100 || next == 105;
+ argSize = argSize || 4;
+ var currArg = getNextArg('i' + (argSize * 8));
+ var argText;
+ // Flatten i64-1 [low, high] into a (slightly rounded) double
+ if (argSize == 8) {
+ currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);
+ }
+ // Truncate to requested size.
+ if (argSize <= 4) {
+ var limit = Math.pow(256, argSize) - 1;
+ currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);
+ }
+ // Format the number.
+ var currAbsArg = Math.abs(currArg);
+ var prefix = '';
+ if (next == 100 || next == 105) {
+ argText = reSign(currArg, 8 * argSize, 1).toString(10);
+ } else if (next == 117) {
+ argText = unSign(currArg, 8 * argSize, 1).toString(10);
+ currArg = Math.abs(currArg);
+ } else if (next == 111) {
+ argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
+ } else if (next == 120 || next == 88) {
+ prefix = (flagAlternative && currArg != 0) ? '0x' : '';
+ if (currArg < 0) {
+ // Represent negative numbers in hex as 2's complement.
+ currArg = -currArg;
+ argText = (currAbsArg - 1).toString(16);
+ var buffer = [];
+ for (var i = 0; i < argText.length; i++) {
+ buffer.push((0xF - parseInt(argText[i], 16)).toString(16));
+ }
+ argText = buffer.join('');
+ while (argText.length < argSize * 2) argText = 'f' + argText;
+ } else {
+ argText = currAbsArg.toString(16);
+ }
+ if (next == 88) {
+ prefix = prefix.toUpperCase();
+ argText = argText.toUpperCase();
+ }
+ } else if (next == 112) {
+ if (currAbsArg === 0) {
+ argText = '(nil)';
+ } else {
+ prefix = '0x';
+ argText = currAbsArg.toString(16);
+ }
+ }
+ if (precisionSet) {
+ while (argText.length < precision) {
+ argText = '0' + argText;
+ }
+ }
+
+ // Add sign if needed
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ prefix = '+' + prefix;
+ } else if (flagPadSign) {
+ prefix = ' ' + prefix;
+ }
+ }
+
+ // Move sign to prefix so we zero-pad after the sign
+ if (argText.charAt(0) == '-') {
+ prefix = '-' + prefix;
+ argText = argText.substr(1);
+ }
+
+ // Add padding.
+ while (prefix.length + argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad) {
+ argText = '0' + argText;
+ } else {
+ prefix = ' ' + prefix;
+ }
+ }
+ }
+
+ // Insert the result into the buffer.
+ argText = prefix + argText;
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {
+ // Float.
+ var currArg = getNextArg('double');
+ var argText;
+ if (isNaN(currArg)) {
+ argText = 'nan';
+ flagZeroPad = false;
+ } else if (!isFinite(currArg)) {
+ argText = (currArg < 0 ? '-' : '') + 'inf';
+ flagZeroPad = false;
+ } else {
+ var isGeneral = false;
+ var effectivePrecision = Math.min(precision, 20);
+
+ // Convert g/G to f/F or e/E, as per:
+ // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
+ if (next == 103 || next == 71) {
+ isGeneral = true;
+ precision = precision || 1;
+ var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);
+ if (precision > exponent && exponent >= -4) {
+ next = ((next == 103) ? 'f' : 'F').charCodeAt(0);
+ precision -= exponent + 1;
+ } else {
+ next = ((next == 103) ? 'e' : 'E').charCodeAt(0);
+ precision--;
+ }
+ effectivePrecision = Math.min(precision, 20);
+ }
+
+ if (next == 101 || next == 69) {
+ argText = currArg.toExponential(effectivePrecision);
+ // Make sure the exponent has at least 2 digits.
+ if (/[eE][-+]\d$/.test(argText)) {
+ argText = argText.slice(0, -1) + '0' + argText.slice(-1);
+ }
+ } else if (next == 102 || next == 70) {
+ argText = currArg.toFixed(effectivePrecision);
+ if (currArg === 0 && __reallyNegative(currArg)) {
+ argText = '-' + argText;
+ }
+ }
+
+ var parts = argText.split('e');
+ if (isGeneral && !flagAlternative) {
+ // Discard trailing zeros and periods.
+ while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&
+ (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {
+ parts[0] = parts[0].slice(0, -1);
+ }
+ } else {
+ // Make sure we have a period in alternative mode.
+ if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';
+ // Zero pad until required precision.
+ while (precision > effectivePrecision++) parts[0] += '0';
+ }
+ argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');
+
+ // Capitalize 'E' if needed.
+ if (next == 69) argText = argText.toUpperCase();
+
+ // Add sign.
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ argText = '+' + argText;
+ } else if (flagPadSign) {
+ argText = ' ' + argText;
+ }
+ }
+ }
+
+ // Add padding.
+ while (argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {
+ argText = argText[0] + '0' + argText.slice(1);
+ } else {
+ argText = (flagZeroPad ? '0' : ' ') + argText;
+ }
+ }
+ }
+
+ // Adjust case.
+ if (next < 97) argText = argText.toUpperCase();
+
+ // Insert the result into the buffer.
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 's': {
+ // String.
+ var arg = getNextArg('i8*');
+ var argLength = arg ? _strlen(arg) : '(null)'.length;
+ if (precisionSet) argLength = Math.min(argLength, precision);
+ if (!flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ if (arg) {
+ for (var i = 0; i < argLength; i++) {
+ ret.push(HEAPU8[((arg++)|0)]);
+ }
+ } else {
+ ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true));
+ }
+ if (flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ break;
+ }
+ case 'c': {
+ // Character.
+ if (flagLeftAlign) ret.push(getNextArg('i8'));
+ while (--width > 0) {
+ ret.push(32);
+ }
+ if (!flagLeftAlign) ret.push(getNextArg('i8'));
+ break;
+ }
+ case 'n': {
+ // Write the length written so far to the next parameter.
+ var ptr = getNextArg('i32*');
+ HEAP32[((ptr)>>2)]=ret.length;
+ break;
+ }
+ case '%': {
+ // Literal percent sign.
+ ret.push(curr);
+ break;
+ }
+ default: {
+ // Unknown specifiers remain untouched.
+ for (var i = startTextIndex; i < textIndex + 2; i++) {
+ ret.push(HEAP8[(i)]);
+ }
+ }
+ }
+ textIndex += 2;
+ // TODO: Support a/A (hex float) and m (last error) specifiers.
+ // TODO: Support %1${specifier} for arg selection.
+ } else {
+ ret.push(curr);
+ textIndex += 1;
+ }
+ }
+ return ret;
+ }function _fprintf(stream, format, varargs) {
+ // int fprintf(FILE *restrict stream, const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var result = __formatString(format, varargs);
+ var stack = Runtime.stackSave();
+ var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);
+ Runtime.stackRestore(stack);
+ return ret;
+ }function _printf(format, varargs) {
+ // int printf(const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var stdout = HEAP32[((_stdout)>>2)];
+ return _fprintf(stdout, format, varargs);
+ }
+
+ var _sinf=Math_sin;
+
+
+ var _sqrtf=Math_sqrt;
+
+ var _floorf=Math_floor;
+
+
+ function _fputs(s, stream) {
+ // int fputs(const char *restrict s, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputs.html
+ var fd = _fileno(stream);
+ return _write(fd, s, _strlen(s));
+ }
+
+ function _fputc(c, stream) {
+ // int fputc(int c, FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputc.html
+ var chr = unSign(c & 0xFF);
+ HEAP8[((_fputc.ret)|0)]=chr;
+ var fd = _fileno(stream);
+ var ret = _write(fd, _fputc.ret, 1);
+ if (ret == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return -1;
+ } else {
+ return chr;
+ }
+ }function _puts(s) {
+ // int puts(const char *s);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/puts.html
+ // NOTE: puts() always writes an extra newline.
+ var stdout = HEAP32[((_stdout)>>2)];
+ var ret = _fputs(s, stdout);
+ if (ret < 0) {
+ return ret;
+ } else {
+ var newlineRet = _fputc(10, stdout);
+ return (newlineRet < 0) ? -1 : ret + 1;
+ }
+ }
+
+ function _clock() {
+ if (_clock.start === undefined) _clock.start = Date.now();
+ return Math.floor((Date.now() - _clock.start) * (1000000/1000));
+ }
+
+
+ var ___cxa_caught_exceptions=[];function ___cxa_begin_catch(ptr) {
+ __ZSt18uncaught_exceptionv.uncaught_exception--;
+ ___cxa_caught_exceptions.push(___cxa_last_thrown_exception);
+ return ptr;
+ }
+
+ function ___errno_location() {
+ return ___errno_state;
+ }
+
+
+ function _emscripten_memcpy_big(dest, src, num) {
+ HEAPU8.set(HEAPU8.subarray(src, src+num), dest);
+ return dest;
+ }
+ Module["_memcpy"] = _memcpy;
+
+ function __ZNSt9exceptionD2Ev() {}
+
+ var Browser={mainLoop:{scheduler:null,method:"",shouldPause:false,paused:false,queue:[],pause:function () {
+ Browser.mainLoop.shouldPause = true;
+ },resume:function () {
+ if (Browser.mainLoop.paused) {
+ Browser.mainLoop.paused = false;
+ Browser.mainLoop.scheduler();
+ }
+ Browser.mainLoop.shouldPause = false;
+ },updateStatus:function () {
+ if (Module['setStatus']) {
+ var message = Module['statusMessage'] || 'Please wait...';
+ var remaining = Browser.mainLoop.remainingBlockers;
+ var expected = Browser.mainLoop.expectedBlockers;
+ if (remaining) {
+ if (remaining < expected) {
+ Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');
+ } else {
+ Module['setStatus'](message);
+ }
+ } else {
+ Module['setStatus']('');
+ }
+ }
+ }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {
+ if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers
+
+ if (Browser.initted || ENVIRONMENT_IS_WORKER) return;
+ Browser.initted = true;
+
+ try {
+ new Blob();
+ Browser.hasBlobConstructor = true;
+ } catch(e) {
+ Browser.hasBlobConstructor = false;
+ console.log("warning: no blob constructor, cannot create blobs with mimetypes");
+ }
+ Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null));
+ Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
+ if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {
+ console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
+ Module.noImageDecoding = true;
+ }
+
+ // Support for plugins that can process preloaded files. You can add more of these to
+ // your app by creating and appending to Module.preloadPlugins.
+ //
+ // Each plugin is asked if it can handle a file based on the file's name. If it can,
+ // it is given the file's raw data. When it is done, it calls a callback with the file's
+ // (possibly modified) data. For example, a plugin might decompress a file, or it
+ // might create some side data structure for use later (like an Image element, etc.).
+
+ var imagePlugin = {};
+ imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
+ return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
+ };
+ imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
+ var b = null;
+ if (Browser.hasBlobConstructor) {
+ try {
+ b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ if (b.size !== byteArray.length) { // Safari bug #118630
+ // Safari's Blob can only take an ArrayBuffer
+ b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
+ }
+ } catch(e) {
+ Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');
+ }
+ }
+ if (!b) {
+ var bb = new Browser.BlobBuilder();
+ bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range
+ b = bb.getBlob();
+ }
+ var url = Browser.URLObject.createObjectURL(b);
+ var img = new Image();
+ img.onload = function img_onload() {
+ assert(img.complete, 'Image ' + name + ' could not be decoded');
+ var canvas = document.createElement('canvas');
+ canvas.width = img.width;
+ canvas.height = img.height;
+ var ctx = canvas.getContext('2d');
+ ctx.drawImage(img, 0, 0);
+ Module["preloadedImages"][name] = canvas;
+ Browser.URLObject.revokeObjectURL(url);
+ if (onload) onload(byteArray);
+ };
+ img.onerror = function img_onerror(event) {
+ console.log('Image ' + url + ' could not be decoded');
+ if (onerror) onerror();
+ };
+ img.src = url;
+ };
+ Module['preloadPlugins'].push(imagePlugin);
+
+ var audioPlugin = {};
+ audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
+ return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
+ };
+ audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
+ var done = false;
+ function finish(audio) {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = audio;
+ if (onload) onload(byteArray);
+ }
+ function fail() {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = new Audio(); // empty shim
+ if (onerror) onerror();
+ }
+ if (Browser.hasBlobConstructor) {
+ try {
+ var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ } catch(e) {
+ return fail();
+ }
+ var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
+ var audio = new Audio();
+ audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
+ audio.onerror = function audio_onerror(event) {
+ if (done) return;
+ console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
+ function encode64(data) {
+ var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ var PAD = '=';
+ var ret = '';
+ var leftchar = 0;
+ var leftbits = 0;
+ for (var i = 0; i < data.length; i++) {
+ leftchar = (leftchar << 8) | data[i];
+ leftbits += 8;
+ while (leftbits >= 6) {
+ var curr = (leftchar >> (leftbits-6)) & 0x3f;
+ leftbits -= 6;
+ ret += BASE[curr];
+ }
+ }
+ if (leftbits == 2) {
+ ret += BASE[(leftchar&3) << 4];
+ ret += PAD + PAD;
+ } else if (leftbits == 4) {
+ ret += BASE[(leftchar&0xf) << 2];
+ ret += PAD;
+ }
+ return ret;
+ }
+ audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);
+ finish(audio); // we don't wait for confirmation this worked - but it's worth trying
+ };
+ audio.src = url;
+ // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror
+ Browser.safeSetTimeout(function() {
+ finish(audio); // try to use it even though it is not necessarily ready to play
+ }, 10000);
+ } else {
+ return fail();
+ }
+ };
+ Module['preloadPlugins'].push(audioPlugin);
+
+ // Canvas event setup
+
+ var canvas = Module['canvas'];
+
+ // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module
+ // Module['forcedAspectRatio'] = 4 / 3;
+
+ canvas.requestPointerLock = canvas['requestPointerLock'] ||
+ canvas['mozRequestPointerLock'] ||
+ canvas['webkitRequestPointerLock'] ||
+ canvas['msRequestPointerLock'] ||
+ function(){};
+ canvas.exitPointerLock = document['exitPointerLock'] ||
+ document['mozExitPointerLock'] ||
+ document['webkitExitPointerLock'] ||
+ document['msExitPointerLock'] ||
+ function(){}; // no-op if function does not exist
+ canvas.exitPointerLock = canvas.exitPointerLock.bind(document);
+
+ function pointerLockChange() {
+ Browser.pointerLock = document['pointerLockElement'] === canvas ||
+ document['mozPointerLockElement'] === canvas ||
+ document['webkitPointerLockElement'] === canvas ||
+ document['msPointerLockElement'] === canvas;
+ }
+
+ document.addEventListener('pointerlockchange', pointerLockChange, false);
+ document.addEventListener('mozpointerlockchange', pointerLockChange, false);
+ document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
+ document.addEventListener('mspointerlockchange', pointerLockChange, false);
+
+ if (Module['elementPointerLock']) {
+ canvas.addEventListener("click", function(ev) {
+ if (!Browser.pointerLock && canvas.requestPointerLock) {
+ canvas.requestPointerLock();
+ ev.preventDefault();
+ }
+ }, false);
+ }
+ },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) {
+ var ctx;
+ var errorInfo = '?';
+ function onContextCreationError(event) {
+ errorInfo = event.statusMessage || errorInfo;
+ }
+ try {
+ if (useWebGL) {
+ var contextAttributes = {
+ antialias: false,
+ alpha: false
+ };
+
+ if (webGLContextAttributes) {
+ for (var attribute in webGLContextAttributes) {
+ contextAttributes[attribute] = webGLContextAttributes[attribute];
+ }
+ }
+
+
+ canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
+ try {
+ ['experimental-webgl', 'webgl'].some(function(webglId) {
+ return ctx = canvas.getContext(webglId, contextAttributes);
+ });
+ } finally {
+ canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
+ }
+ } else {
+ ctx = canvas.getContext('2d');
+ }
+ if (!ctx) throw ':(';
+ } catch (e) {
+ Module.print('Could not create canvas: ' + [errorInfo, e]);
+ return null;
+ }
+ if (useWebGL) {
+ // Set the background of the WebGL canvas to black
+ canvas.style.backgroundColor = "black";
+
+ // Warn on context loss
+ canvas.addEventListener('webglcontextlost', function(event) {
+ alert('WebGL context lost. You will need to reload the page.');
+ }, false);
+ }
+ if (setInModule) {
+ GLctx = Module.ctx = ctx;
+ Module.useWebGL = useWebGL;
+ Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
+ Browser.init();
+ }
+ return ctx;
+ },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {
+ Browser.lockPointer = lockPointer;
+ Browser.resizeCanvas = resizeCanvas;
+ if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;
+ if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;
+
+ var canvas = Module['canvas'];
+ function fullScreenChange() {
+ Browser.isFullScreen = false;
+ var canvasContainer = canvas.parentNode;
+ if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvasContainer) {
+ canvas.cancelFullScreen = document['cancelFullScreen'] ||
+ document['mozCancelFullScreen'] ||
+ document['webkitCancelFullScreen'] ||
+ document['msExitFullscreen'] ||
+ document['exitFullscreen'] ||
+ function() {};
+ canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);
+ if (Browser.lockPointer) canvas.requestPointerLock();
+ Browser.isFullScreen = true;
+ if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();
+ } else {
+
+ // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen
+ canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
+ canvasContainer.parentNode.removeChild(canvasContainer);
+
+ if (Browser.resizeCanvas) Browser.setWindowedCanvasSize();
+ }
+ if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);
+ Browser.updateCanvasDimensions(canvas);
+ }
+
+ if (!Browser.fullScreenHandlersInstalled) {
+ Browser.fullScreenHandlersInstalled = true;
+ document.addEventListener('fullscreenchange', fullScreenChange, false);
+ document.addEventListener('mozfullscreenchange', fullScreenChange, false);
+ document.addEventListener('webkitfullscreenchange', fullScreenChange, false);
+ document.addEventListener('MSFullscreenChange', fullScreenChange, false);
+ }
+
+ // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root
+ var canvasContainer = document.createElement("div");
+ canvas.parentNode.insertBefore(canvasContainer, canvas);
+ canvasContainer.appendChild(canvas);
+
+ // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size)
+ canvasContainer.requestFullScreen = canvasContainer['requestFullScreen'] ||
+ canvasContainer['mozRequestFullScreen'] ||
+ canvasContainer['msRequestFullscreen'] ||
+ (canvasContainer['webkitRequestFullScreen'] ? function() { canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);
+ canvasContainer.requestFullScreen();
+ },requestAnimationFrame:function requestAnimationFrame(func) {
+ if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
+ setTimeout(func, 1000/60);
+ } else {
+ if (!window.requestAnimationFrame) {
+ window.requestAnimationFrame = window['requestAnimationFrame'] ||
+ window['mozRequestAnimationFrame'] ||
+ window['webkitRequestAnimationFrame'] ||
+ window['msRequestAnimationFrame'] ||
+ window['oRequestAnimationFrame'] ||
+ window['setTimeout'];
+ }
+ window.requestAnimationFrame(func);
+ }
+ },safeCallback:function (func) {
+ return function() {
+ if (!ABORT) return func.apply(null, arguments);
+ };
+ },safeRequestAnimationFrame:function (func) {
+ return Browser.requestAnimationFrame(function() {
+ if (!ABORT) func();
+ });
+ },safeSetTimeout:function (func, timeout) {
+ return setTimeout(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },safeSetInterval:function (func, timeout) {
+ return setInterval(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },getMimetype:function (name) {
+ return {
+ 'jpg': 'image/jpeg',
+ 'jpeg': 'image/jpeg',
+ 'png': 'image/png',
+ 'bmp': 'image/bmp',
+ 'ogg': 'audio/ogg',
+ 'wav': 'audio/wav',
+ 'mp3': 'audio/mpeg'
+ }[name.substr(name.lastIndexOf('.')+1)];
+ },getUserMedia:function (func) {
+ if(!window.getUserMedia) {
+ window.getUserMedia = navigator['getUserMedia'] ||
+ navigator['mozGetUserMedia'];
+ }
+ window.getUserMedia(func);
+ },getMovementX:function (event) {
+ return event['movementX'] ||
+ event['mozMovementX'] ||
+ event['webkitMovementX'] ||
+ 0;
+ },getMovementY:function (event) {
+ return event['movementY'] ||
+ event['mozMovementY'] ||
+ event['webkitMovementY'] ||
+ 0;
+ },getMouseWheelDelta:function (event) {
+ return Math.max(-1, Math.min(1, event.type === 'DOMMouseScroll' ? event.detail : -event.wheelDelta));
+ },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup
+ if (Browser.pointerLock) {
+ // When the pointer is locked, calculate the coordinates
+ // based on the movement of the mouse.
+ // Workaround for Firefox bug 764498
+ if (event.type != 'mousemove' &&
+ ('mozMovementX' in event)) {
+ Browser.mouseMovementX = Browser.mouseMovementY = 0;
+ } else {
+ Browser.mouseMovementX = Browser.getMovementX(event);
+ Browser.mouseMovementY = Browser.getMovementY(event);
+ }
+
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
+ Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
+ } else {
+ // just add the mouse delta to the current absolut mouse position
+ // FIXME: ideally this should be clamped against the canvas size and zero
+ Browser.mouseX += Browser.mouseMovementX;
+ Browser.mouseY += Browser.mouseMovementY;
+ }
+ } else {
+ // Otherwise, calculate the movement based on the changes
+ // in the coordinates.
+ var rect = Module["canvas"].getBoundingClientRect();
+ var x, y;
+
+ // Neither .scrollX or .pageXOffset are defined in a spec, but
+ // we prefer .scrollX because it is currently in a spec draft.
+ // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
+ var scrollX = ((typeof window.scrollX !== 'undefined') ? window.scrollX : window.pageXOffset);
+ var scrollY = ((typeof window.scrollY !== 'undefined') ? window.scrollY : window.pageYOffset);
+ if (event.type == 'touchstart' ||
+ event.type == 'touchend' ||
+ event.type == 'touchmove') {
+ var t = event.touches.item(0);
+ if (t) {
+ x = t.pageX - (scrollX + rect.left);
+ y = t.pageY - (scrollY + rect.top);
+ } else {
+ return;
+ }
+ } else {
+ x = event.pageX - (scrollX + rect.left);
+ y = event.pageY - (scrollY + rect.top);
+ }
+
+ // the canvas might be CSS-scaled compared to its backbuffer;
+ // SDL-using content will want mouse coordinates in terms
+ // of backbuffer units.
+ var cw = Module["canvas"].width;
+ var ch = Module["canvas"].height;
+ x = x * (cw / rect.width);
+ y = y * (ch / rect.height);
+
+ Browser.mouseMovementX = x - Browser.mouseX;
+ Browser.mouseMovementY = y - Browser.mouseY;
+ Browser.mouseX = x;
+ Browser.mouseY = y;
+ }
+ },xhrLoad:function (url, onload, onerror) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, true);
+ xhr.responseType = 'arraybuffer';
+ xhr.onload = function xhr_onload() {
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
+ onload(xhr.response);
+ } else {
+ onerror();
+ }
+ };
+ xhr.onerror = onerror;
+ xhr.send(null);
+ },asyncLoad:function (url, onload, onerror, noRunDep) {
+ Browser.xhrLoad(url, function(arrayBuffer) {
+ assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
+ onload(new Uint8Array(arrayBuffer));
+ if (!noRunDep) removeRunDependency('al ' + url);
+ }, function(event) {
+ if (onerror) {
+ onerror();
+ } else {
+ throw 'Loading data file "' + url + '" failed.';
+ }
+ });
+ if (!noRunDep) addRunDependency('al ' + url);
+ },resizeListeners:[],updateResizeListeners:function () {
+ var canvas = Module['canvas'];
+ Browser.resizeListeners.forEach(function(listener) {
+ listener(canvas.width, canvas.height);
+ });
+ },setCanvasSize:function (width, height, noUpdates) {
+ var canvas = Module['canvas'];
+ Browser.updateCanvasDimensions(canvas, width, height);
+ if (!noUpdates) Browser.updateResizeListeners();
+ },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },setWindowedCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },updateCanvasDimensions:function (canvas, wNative, hNative) {
+ if (wNative && hNative) {
+ canvas.widthNative = wNative;
+ canvas.heightNative = hNative;
+ } else {
+ wNative = canvas.widthNative;
+ hNative = canvas.heightNative;
+ }
+ var w = wNative;
+ var h = hNative;
+ if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) {
+ if (w/h < Module['forcedAspectRatio']) {
+ w = Math.round(h * Module['forcedAspectRatio']);
+ } else {
+ h = Math.round(w / Module['forcedAspectRatio']);
+ }
+ }
+ if (((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
+ var factor = Math.min(screen.width / w, screen.height / h);
+ w = Math.round(w * factor);
+ h = Math.round(h * factor);
+ }
+ if (Browser.resizeCanvas) {
+ if (canvas.width != w) canvas.width = w;
+ if (canvas.height != h) canvas.height = h;
+ if (typeof canvas.style != 'undefined') {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ } else {
+ if (canvas.width != wNative) canvas.width = wNative;
+ if (canvas.height != hNative) canvas.height = hNative;
+ if (typeof canvas.style != 'undefined') {
+ if (w != wNative || h != hNative) {
+ canvas.style.setProperty( "width", w + "px", "important");
+ canvas.style.setProperty("height", h + "px", "important");
+ } else {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ }
+ }
+ }};
+
+ function _sbrk(bytes) {
+ // Implement a Linux-like 'memory area' for our 'process'.
+ // Changes the size of the memory area by |bytes|; returns the
+ // address of the previous top ('break') of the memory area
+ // We control the "dynamic" memory - DYNAMIC_BASE to DYNAMICTOP
+ var self = _sbrk;
+ if (!self.called) {
+ DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned
+ self.called = true;
+ assert(Runtime.dynamicAlloc);
+ self.alloc = Runtime.dynamicAlloc;
+ Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') };
+ }
+ var ret = DYNAMICTOP;
+ if (bytes != 0) self.alloc(bytes);
+ return ret; // Previous break location.
+ }
+
+ function _sysconf(name) {
+ // long sysconf(int name);
+ // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html
+ switch(name) {
+ case 30: return PAGE_SIZE;
+ case 132:
+ case 133:
+ case 12:
+ case 137:
+ case 138:
+ case 15:
+ case 235:
+ case 16:
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ case 149:
+ case 13:
+ case 10:
+ case 236:
+ case 153:
+ case 9:
+ case 21:
+ case 22:
+ case 159:
+ case 154:
+ case 14:
+ case 77:
+ case 78:
+ case 139:
+ case 80:
+ case 81:
+ case 79:
+ case 82:
+ case 68:
+ case 67:
+ case 164:
+ case 11:
+ case 29:
+ case 47:
+ case 48:
+ case 95:
+ case 52:
+ case 51:
+ case 46:
+ return 200809;
+ case 27:
+ case 246:
+ case 127:
+ case 128:
+ case 23:
+ case 24:
+ case 160:
+ case 161:
+ case 181:
+ case 182:
+ case 242:
+ case 183:
+ case 184:
+ case 243:
+ case 244:
+ case 245:
+ case 165:
+ case 178:
+ case 179:
+ case 49:
+ case 50:
+ case 168:
+ case 169:
+ case 175:
+ case 170:
+ case 171:
+ case 172:
+ case 97:
+ case 76:
+ case 32:
+ case 173:
+ case 35:
+ return -1;
+ case 176:
+ case 177:
+ case 7:
+ case 155:
+ case 8:
+ case 157:
+ case 125:
+ case 126:
+ case 92:
+ case 93:
+ case 129:
+ case 130:
+ case 131:
+ case 94:
+ case 91:
+ return 1;
+ case 74:
+ case 60:
+ case 69:
+ case 70:
+ case 4:
+ return 1024;
+ case 31:
+ case 42:
+ case 72:
+ return 32;
+ case 87:
+ case 26:
+ case 33:
+ return 2147483647;
+ case 34:
+ case 1:
+ return 47839;
+ case 38:
+ case 36:
+ return 99;
+ case 43:
+ case 37:
+ return 2048;
+ case 0: return 2097152;
+ case 3: return 65536;
+ case 28: return 32768;
+ case 44: return 32767;
+ case 75: return 16384;
+ case 39: return 1000;
+ case 89: return 700;
+ case 71: return 256;
+ case 40: return 255;
+ case 2: return 100;
+ case 180: return 64;
+ case 25: return 20;
+ case 5: return 16;
+ case 6: return 6;
+ case 73: return 4;
+ case 84: return 1;
+ }
+ ___setErrNo(ERRNO_CODES.EINVAL);
+ return -1;
+ }
+
+ function _emscripten_run_script(ptr) {
+ eval(Pointer_stringify(ptr));
+ }
+
+
+ function _malloc(bytes) {
+ /* Over-allocate to make sure it is byte-aligned by 8.
+ * This will leak memory, but this is only the dummy
+ * implementation (replaced by dlmalloc normally) so
+ * not an issue.
+ */
+ var ptr = Runtime.dynamicAlloc(bytes + 8);
+ return (ptr+8) & 0xFFFFFFF8;
+ }
+ Module["_malloc"] = _malloc;function ___cxa_allocate_exception(size) {
+ var ptr = _malloc(size + ___cxa_exception_header_size);
+ return ptr + ___cxa_exception_header_size;
+ }
+
+ function _emscripten_cancel_main_loop() {
+ Browser.mainLoop.scheduler = null;
+ Browser.mainLoop.shouldPause = true;
+ }
+
+ var __ZTISt9exception=allocate([allocate([1,0,0,0,0,0,0], "i8", ALLOC_STATIC)+8, 0], "i32", ALLOC_STATIC);
+FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;
+___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;
+__ATINIT__.unshift({ func: function() { TTY.init() } });__ATEXIT__.push({ func: function() { TTY.shutdown() } });TTY.utf8 = new Runtime.UTF8Processor();
+if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); NODEFS.staticInit(); }
+__ATINIT__.push({ func: function() { SOCKFS.root = FS.mount(SOCKFS, {}, null); } });
+_fputc.ret = allocate([0], "i8", ALLOC_STATIC);
+Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };
+ Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };
+ Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };
+ Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };
+ Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };
+ Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }
+STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);
+
+staticSealed = true; // seal the static portion of memory
+
+STACK_MAX = STACK_BASE + 5242880;
+
+DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);
+
+assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");
+
+
+var Math_min = Math.min;
+function invoke_iiii(index,a1,a2,a3) {
+ try {
+ return Module["dynCall_iiii"](index,a1,a2,a3);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_viiiii(index,a1,a2,a3,a4,a5) {
+ try {
+ Module["dynCall_viiiii"](index,a1,a2,a3,a4,a5);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_vi(index,a1) {
+ try {
+ Module["dynCall_vi"](index,a1);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_vii(index,a1,a2) {
+ try {
+ Module["dynCall_vii"](index,a1,a2);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_ii(index,a1) {
+ try {
+ return Module["dynCall_ii"](index,a1);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_viii(index,a1,a2,a3) {
+ try {
+ Module["dynCall_viii"](index,a1,a2,a3);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_v(index) {
+ try {
+ Module["dynCall_v"](index);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_viid(index,a1,a2,a3) {
+ try {
+ Module["dynCall_viid"](index,a1,a2,a3);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6) {
+ try {
+ Module["dynCall_viiiiii"](index,a1,a2,a3,a4,a5,a6);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_iii(index,a1,a2) {
+ try {
+ return Module["dynCall_iii"](index,a1,a2);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_iiiiii(index,a1,a2,a3,a4,a5) {
+ try {
+ return Module["dynCall_iiiiii"](index,a1,a2,a3,a4,a5);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_viiii(index,a1,a2,a3,a4) {
+ try {
+ Module["dynCall_viiii"](index,a1,a2,a3,a4);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function asmPrintInt(x, y) {
+ Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+function asmPrintFloat(x, y) {
+ Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+// EMSCRIPTEN_START_ASM
+var asm = (function(global, env, buffer) {
+ 'use asm';
+ var HEAP8 = new global.Int8Array(buffer);
+ var HEAP16 = new global.Int16Array(buffer);
+ var HEAP32 = new global.Int32Array(buffer);
+ var HEAPU8 = new global.Uint8Array(buffer);
+ var HEAPU16 = new global.Uint16Array(buffer);
+ var HEAPU32 = new global.Uint32Array(buffer);
+ var HEAPF32 = new global.Float32Array(buffer);
+ var HEAPF64 = new global.Float64Array(buffer);
+
+ var STACKTOP=env.STACKTOP|0;
+ var STACK_MAX=env.STACK_MAX|0;
+ var tempDoublePtr=env.tempDoublePtr|0;
+ var ABORT=env.ABORT|0;
+ var __ZTISt9exception=env.__ZTISt9exception|0;
+
+ var __THREW__ = 0;
+ var threwValue = 0;
+ var setjmpId = 0;
+ var undef = 0;
+ var nan = +env.NaN, inf = +env.Infinity;
+ var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0;
+
+ var tempRet0 = 0;
+ var tempRet1 = 0;
+ var tempRet2 = 0;
+ var tempRet3 = 0;
+ var tempRet4 = 0;
+ var tempRet5 = 0;
+ var tempRet6 = 0;
+ var tempRet7 = 0;
+ var tempRet8 = 0;
+ var tempRet9 = 0;
+ var Math_floor=global.Math.floor;
+ var Math_abs=global.Math.abs;
+ var Math_sqrt=global.Math.sqrt;
+ var Math_pow=global.Math.pow;
+ var Math_cos=global.Math.cos;
+ var Math_sin=global.Math.sin;
+ var Math_tan=global.Math.tan;
+ var Math_acos=global.Math.acos;
+ var Math_asin=global.Math.asin;
+ var Math_atan=global.Math.atan;
+ var Math_atan2=global.Math.atan2;
+ var Math_exp=global.Math.exp;
+ var Math_log=global.Math.log;
+ var Math_ceil=global.Math.ceil;
+ var Math_imul=global.Math.imul;
+ var abort=env.abort;
+ var assert=env.assert;
+ var asmPrintInt=env.asmPrintInt;
+ var asmPrintFloat=env.asmPrintFloat;
+ var Math_min=env.min;
+ var invoke_iiii=env.invoke_iiii;
+ var invoke_viiiii=env.invoke_viiiii;
+ var invoke_vi=env.invoke_vi;
+ var invoke_vii=env.invoke_vii;
+ var invoke_ii=env.invoke_ii;
+ var invoke_viii=env.invoke_viii;
+ var invoke_v=env.invoke_v;
+ var invoke_viid=env.invoke_viid;
+ var invoke_viiiiii=env.invoke_viiiiii;
+ var invoke_iii=env.invoke_iii;
+ var invoke_iiiiii=env.invoke_iiiiii;
+ var invoke_viiii=env.invoke_viiii;
+ var ___cxa_throw=env.___cxa_throw;
+ var _emscripten_run_script=env._emscripten_run_script;
+ var _cosf=env._cosf;
+ var _send=env._send;
+ var __ZSt9terminatev=env.__ZSt9terminatev;
+ var __reallyNegative=env.__reallyNegative;
+ var ___cxa_is_number_type=env.___cxa_is_number_type;
+ var ___assert_fail=env.___assert_fail;
+ var ___cxa_allocate_exception=env.___cxa_allocate_exception;
+ var ___cxa_find_matching_catch=env.___cxa_find_matching_catch;
+ var _fflush=env._fflush;
+ var _pwrite=env._pwrite;
+ var ___setErrNo=env.___setErrNo;
+ var _sbrk=env._sbrk;
+ var ___cxa_begin_catch=env.___cxa_begin_catch;
+ var _sinf=env._sinf;
+ var _fileno=env._fileno;
+ var ___resumeException=env.___resumeException;
+ var __ZSt18uncaught_exceptionv=env.__ZSt18uncaught_exceptionv;
+ var _sysconf=env._sysconf;
+ var _clock=env._clock;
+ var _emscripten_memcpy_big=env._emscripten_memcpy_big;
+ var _puts=env._puts;
+ var _mkport=env._mkport;
+ var _floorf=env._floorf;
+ var _sqrtf=env._sqrtf;
+ var _write=env._write;
+ var _emscripten_set_main_loop=env._emscripten_set_main_loop;
+ var ___errno_location=env.___errno_location;
+ var __ZNSt9exceptionD2Ev=env.__ZNSt9exceptionD2Ev;
+ var _printf=env._printf;
+ var ___cxa_does_inherit=env.___cxa_does_inherit;
+ var __exit=env.__exit;
+ var _fputc=env._fputc;
+ var _abort=env._abort;
+ var _fwrite=env._fwrite;
+ var _time=env._time;
+ var _fprintf=env._fprintf;
+ var _emscripten_cancel_main_loop=env._emscripten_cancel_main_loop;
+ var __formatString=env.__formatString;
+ var _fputs=env._fputs;
+ var _exit=env._exit;
+ var ___cxa_pure_virtual=env.___cxa_pure_virtual;
+ var tempFloat = 0.0;
+
+// EMSCRIPTEN_START_FUNCS
+function _malloc(i12) {
+ i12 = i12 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0;
+ i1 = STACKTOP;
+ do {
+ if (i12 >>> 0 < 245) {
+ if (i12 >>> 0 < 11) {
+ i12 = 16;
+ } else {
+ i12 = i12 + 11 & -8;
+ }
+ i20 = i12 >>> 3;
+ i18 = HEAP32[1790] | 0;
+ i21 = i18 >>> i20;
+ if ((i21 & 3 | 0) != 0) {
+ i6 = (i21 & 1 ^ 1) + i20 | 0;
+ i5 = i6 << 1;
+ i3 = 7200 + (i5 << 2) | 0;
+ i5 = 7200 + (i5 + 2 << 2) | 0;
+ i7 = HEAP32[i5 >> 2] | 0;
+ i2 = i7 + 8 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ do {
+ if ((i3 | 0) != (i4 | 0)) {
+ if (i4 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i4 + 12 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i7 | 0)) {
+ HEAP32[i8 >> 2] = i3;
+ HEAP32[i5 >> 2] = i4;
+ break;
+ } else {
+ _abort();
+ }
+ } else {
+ HEAP32[1790] = i18 & ~(1 << i6);
+ }
+ } while (0);
+ i32 = i6 << 3;
+ HEAP32[i7 + 4 >> 2] = i32 | 3;
+ i32 = i7 + (i32 | 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ i32 = i2;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ if (i12 >>> 0 > (HEAP32[7168 >> 2] | 0) >>> 0) {
+ if ((i21 | 0) != 0) {
+ i7 = 2 << i20;
+ i7 = i21 << i20 & (i7 | 0 - i7);
+ i7 = (i7 & 0 - i7) + -1 | 0;
+ i2 = i7 >>> 12 & 16;
+ i7 = i7 >>> i2;
+ i6 = i7 >>> 5 & 8;
+ i7 = i7 >>> i6;
+ i5 = i7 >>> 2 & 4;
+ i7 = i7 >>> i5;
+ i4 = i7 >>> 1 & 2;
+ i7 = i7 >>> i4;
+ i3 = i7 >>> 1 & 1;
+ i3 = (i6 | i2 | i5 | i4 | i3) + (i7 >>> i3) | 0;
+ i7 = i3 << 1;
+ i4 = 7200 + (i7 << 2) | 0;
+ i7 = 7200 + (i7 + 2 << 2) | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ i2 = i5 + 8 | 0;
+ i6 = HEAP32[i2 >> 2] | 0;
+ do {
+ if ((i4 | 0) != (i6 | 0)) {
+ if (i6 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i6 + 12 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i5 | 0)) {
+ HEAP32[i8 >> 2] = i4;
+ HEAP32[i7 >> 2] = i6;
+ break;
+ } else {
+ _abort();
+ }
+ } else {
+ HEAP32[1790] = i18 & ~(1 << i3);
+ }
+ } while (0);
+ i6 = i3 << 3;
+ i4 = i6 - i12 | 0;
+ HEAP32[i5 + 4 >> 2] = i12 | 3;
+ i3 = i5 + i12 | 0;
+ HEAP32[i5 + (i12 | 4) >> 2] = i4 | 1;
+ HEAP32[i5 + i6 >> 2] = i4;
+ i6 = HEAP32[7168 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i5 = HEAP32[7180 >> 2] | 0;
+ i8 = i6 >>> 3;
+ i9 = i8 << 1;
+ i6 = 7200 + (i9 << 2) | 0;
+ i7 = HEAP32[1790] | 0;
+ i8 = 1 << i8;
+ if ((i7 & i8 | 0) != 0) {
+ i7 = 7200 + (i9 + 2 << 2) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i28 = i7;
+ i27 = i8;
+ }
+ } else {
+ HEAP32[1790] = i7 | i8;
+ i28 = 7200 + (i9 + 2 << 2) | 0;
+ i27 = i6;
+ }
+ HEAP32[i28 >> 2] = i5;
+ HEAP32[i27 + 12 >> 2] = i5;
+ HEAP32[i5 + 8 >> 2] = i27;
+ HEAP32[i5 + 12 >> 2] = i6;
+ }
+ HEAP32[7168 >> 2] = i4;
+ HEAP32[7180 >> 2] = i3;
+ i32 = i2;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i18 = HEAP32[7164 >> 2] | 0;
+ if ((i18 | 0) != 0) {
+ i2 = (i18 & 0 - i18) + -1 | 0;
+ i31 = i2 >>> 12 & 16;
+ i2 = i2 >>> i31;
+ i30 = i2 >>> 5 & 8;
+ i2 = i2 >>> i30;
+ i32 = i2 >>> 2 & 4;
+ i2 = i2 >>> i32;
+ i6 = i2 >>> 1 & 2;
+ i2 = i2 >>> i6;
+ i3 = i2 >>> 1 & 1;
+ i3 = HEAP32[7464 + ((i30 | i31 | i32 | i6 | i3) + (i2 >>> i3) << 2) >> 2] | 0;
+ i2 = (HEAP32[i3 + 4 >> 2] & -8) - i12 | 0;
+ i6 = i3;
+ while (1) {
+ i5 = HEAP32[i6 + 16 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i5 = HEAP32[i6 + 20 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ }
+ i6 = (HEAP32[i5 + 4 >> 2] & -8) - i12 | 0;
+ i4 = i6 >>> 0 < i2 >>> 0;
+ i2 = i4 ? i6 : i2;
+ i6 = i5;
+ i3 = i4 ? i5 : i3;
+ }
+ i6 = HEAP32[7176 >> 2] | 0;
+ if (i3 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ i4 = i3 + i12 | 0;
+ if (!(i3 >>> 0 < i4 >>> 0)) {
+ _abort();
+ }
+ i5 = HEAP32[i3 + 24 >> 2] | 0;
+ i7 = HEAP32[i3 + 12 >> 2] | 0;
+ do {
+ if ((i7 | 0) == (i3 | 0)) {
+ i8 = i3 + 20 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i8 = i3 + 16 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i26 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i10 = i7 + 20 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ i7 = i9;
+ i8 = i10;
+ continue;
+ }
+ i10 = i7 + 16 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ } else {
+ i7 = i9;
+ i8 = i10;
+ }
+ }
+ if (i8 >>> 0 < i6 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i8 >> 2] = 0;
+ i26 = i7;
+ break;
+ }
+ } else {
+ i8 = HEAP32[i3 + 8 >> 2] | 0;
+ if (i8 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ i6 = i8 + 12 | 0;
+ if ((HEAP32[i6 >> 2] | 0) != (i3 | 0)) {
+ _abort();
+ }
+ i9 = i7 + 8 | 0;
+ if ((HEAP32[i9 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i6 >> 2] = i7;
+ HEAP32[i9 >> 2] = i8;
+ i26 = i7;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ do {
+ if ((i5 | 0) != 0) {
+ i7 = HEAP32[i3 + 28 >> 2] | 0;
+ i6 = 7464 + (i7 << 2) | 0;
+ if ((i3 | 0) == (HEAP32[i6 >> 2] | 0)) {
+ HEAP32[i6 >> 2] = i26;
+ if ((i26 | 0) == 0) {
+ HEAP32[7164 >> 2] = HEAP32[7164 >> 2] & ~(1 << i7);
+ break;
+ }
+ } else {
+ if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i6 = i5 + 16 | 0;
+ if ((HEAP32[i6 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i6 >> 2] = i26;
+ } else {
+ HEAP32[i5 + 20 >> 2] = i26;
+ }
+ if ((i26 | 0) == 0) {
+ break;
+ }
+ }
+ if (i26 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i26 + 24 >> 2] = i5;
+ i5 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i26 + 16 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i26;
+ break;
+ }
+ }
+ } while (0);
+ i5 = HEAP32[i3 + 20 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i26 + 20 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i26;
+ break;
+ }
+ }
+ }
+ } while (0);
+ if (i2 >>> 0 < 16) {
+ i32 = i2 + i12 | 0;
+ HEAP32[i3 + 4 >> 2] = i32 | 3;
+ i32 = i3 + (i32 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ } else {
+ HEAP32[i3 + 4 >> 2] = i12 | 3;
+ HEAP32[i3 + (i12 | 4) >> 2] = i2 | 1;
+ HEAP32[i3 + (i2 + i12) >> 2] = i2;
+ i6 = HEAP32[7168 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i5 = HEAP32[7180 >> 2] | 0;
+ i8 = i6 >>> 3;
+ i9 = i8 << 1;
+ i6 = 7200 + (i9 << 2) | 0;
+ i7 = HEAP32[1790] | 0;
+ i8 = 1 << i8;
+ if ((i7 & i8 | 0) != 0) {
+ i7 = 7200 + (i9 + 2 << 2) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i25 = i7;
+ i24 = i8;
+ }
+ } else {
+ HEAP32[1790] = i7 | i8;
+ i25 = 7200 + (i9 + 2 << 2) | 0;
+ i24 = i6;
+ }
+ HEAP32[i25 >> 2] = i5;
+ HEAP32[i24 + 12 >> 2] = i5;
+ HEAP32[i5 + 8 >> 2] = i24;
+ HEAP32[i5 + 12 >> 2] = i6;
+ }
+ HEAP32[7168 >> 2] = i2;
+ HEAP32[7180 >> 2] = i4;
+ }
+ i32 = i3 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ } else {
+ if (!(i12 >>> 0 > 4294967231)) {
+ i24 = i12 + 11 | 0;
+ i12 = i24 & -8;
+ i26 = HEAP32[7164 >> 2] | 0;
+ if ((i26 | 0) != 0) {
+ i25 = 0 - i12 | 0;
+ i24 = i24 >>> 8;
+ if ((i24 | 0) != 0) {
+ if (i12 >>> 0 > 16777215) {
+ i27 = 31;
+ } else {
+ i31 = (i24 + 1048320 | 0) >>> 16 & 8;
+ i32 = i24 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i27 = (i32 + 245760 | 0) >>> 16 & 2;
+ i27 = 14 - (i30 | i31 | i27) + (i32 << i27 >>> 15) | 0;
+ i27 = i12 >>> (i27 + 7 | 0) & 1 | i27 << 1;
+ }
+ } else {
+ i27 = 0;
+ }
+ i30 = HEAP32[7464 + (i27 << 2) >> 2] | 0;
+ L126 : do {
+ if ((i30 | 0) == 0) {
+ i29 = 0;
+ i24 = 0;
+ } else {
+ if ((i27 | 0) == 31) {
+ i24 = 0;
+ } else {
+ i24 = 25 - (i27 >>> 1) | 0;
+ }
+ i29 = 0;
+ i28 = i12 << i24;
+ i24 = 0;
+ while (1) {
+ i32 = HEAP32[i30 + 4 >> 2] & -8;
+ i31 = i32 - i12 | 0;
+ if (i31 >>> 0 < i25 >>> 0) {
+ if ((i32 | 0) == (i12 | 0)) {
+ i25 = i31;
+ i29 = i30;
+ i24 = i30;
+ break L126;
+ } else {
+ i25 = i31;
+ i24 = i30;
+ }
+ }
+ i31 = HEAP32[i30 + 20 >> 2] | 0;
+ i30 = HEAP32[i30 + (i28 >>> 31 << 2) + 16 >> 2] | 0;
+ i29 = (i31 | 0) == 0 | (i31 | 0) == (i30 | 0) ? i29 : i31;
+ if ((i30 | 0) == 0) {
+ break;
+ } else {
+ i28 = i28 << 1;
+ }
+ }
+ }
+ } while (0);
+ if ((i29 | 0) == 0 & (i24 | 0) == 0) {
+ i32 = 2 << i27;
+ i26 = i26 & (i32 | 0 - i32);
+ if ((i26 | 0) == 0) {
+ break;
+ }
+ i32 = (i26 & 0 - i26) + -1 | 0;
+ i28 = i32 >>> 12 & 16;
+ i32 = i32 >>> i28;
+ i27 = i32 >>> 5 & 8;
+ i32 = i32 >>> i27;
+ i30 = i32 >>> 2 & 4;
+ i32 = i32 >>> i30;
+ i31 = i32 >>> 1 & 2;
+ i32 = i32 >>> i31;
+ i29 = i32 >>> 1 & 1;
+ i29 = HEAP32[7464 + ((i27 | i28 | i30 | i31 | i29) + (i32 >>> i29) << 2) >> 2] | 0;
+ }
+ if ((i29 | 0) != 0) {
+ while (1) {
+ i27 = (HEAP32[i29 + 4 >> 2] & -8) - i12 | 0;
+ i26 = i27 >>> 0 < i25 >>> 0;
+ i25 = i26 ? i27 : i25;
+ i24 = i26 ? i29 : i24;
+ i26 = HEAP32[i29 + 16 >> 2] | 0;
+ if ((i26 | 0) != 0) {
+ i29 = i26;
+ continue;
+ }
+ i29 = HEAP32[i29 + 20 >> 2] | 0;
+ if ((i29 | 0) == 0) {
+ break;
+ }
+ }
+ }
+ if ((i24 | 0) != 0 ? i25 >>> 0 < ((HEAP32[7168 >> 2] | 0) - i12 | 0) >>> 0 : 0) {
+ i4 = HEAP32[7176 >> 2] | 0;
+ if (i24 >>> 0 < i4 >>> 0) {
+ _abort();
+ }
+ i2 = i24 + i12 | 0;
+ if (!(i24 >>> 0 < i2 >>> 0)) {
+ _abort();
+ }
+ i3 = HEAP32[i24 + 24 >> 2] | 0;
+ i6 = HEAP32[i24 + 12 >> 2] | 0;
+ do {
+ if ((i6 | 0) == (i24 | 0)) {
+ i6 = i24 + 20 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i6 = i24 + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i22 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i8 = i5 + 20 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) != 0) {
+ i5 = i7;
+ i6 = i8;
+ continue;
+ }
+ i7 = i5 + 16 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if ((i8 | 0) == 0) {
+ break;
+ } else {
+ i5 = i8;
+ i6 = i7;
+ }
+ }
+ if (i6 >>> 0 < i4 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = 0;
+ i22 = i5;
+ break;
+ }
+ } else {
+ i5 = HEAP32[i24 + 8 >> 2] | 0;
+ if (i5 >>> 0 < i4 >>> 0) {
+ _abort();
+ }
+ i7 = i5 + 12 | 0;
+ if ((HEAP32[i7 >> 2] | 0) != (i24 | 0)) {
+ _abort();
+ }
+ i4 = i6 + 8 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
+ HEAP32[i7 >> 2] = i6;
+ HEAP32[i4 >> 2] = i5;
+ i22 = i6;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ do {
+ if ((i3 | 0) != 0) {
+ i4 = HEAP32[i24 + 28 >> 2] | 0;
+ i5 = 7464 + (i4 << 2) | 0;
+ if ((i24 | 0) == (HEAP32[i5 >> 2] | 0)) {
+ HEAP32[i5 >> 2] = i22;
+ if ((i22 | 0) == 0) {
+ HEAP32[7164 >> 2] = HEAP32[7164 >> 2] & ~(1 << i4);
+ break;
+ }
+ } else {
+ if (i3 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i4 = i3 + 16 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
+ HEAP32[i4 >> 2] = i22;
+ } else {
+ HEAP32[i3 + 20 >> 2] = i22;
+ }
+ if ((i22 | 0) == 0) {
+ break;
+ }
+ }
+ if (i22 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i22 + 24 >> 2] = i3;
+ i3 = HEAP32[i24 + 16 >> 2] | 0;
+ do {
+ if ((i3 | 0) != 0) {
+ if (i3 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i22 + 16 >> 2] = i3;
+ HEAP32[i3 + 24 >> 2] = i22;
+ break;
+ }
+ }
+ } while (0);
+ i3 = HEAP32[i24 + 20 >> 2] | 0;
+ if ((i3 | 0) != 0) {
+ if (i3 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i22 + 20 >> 2] = i3;
+ HEAP32[i3 + 24 >> 2] = i22;
+ break;
+ }
+ }
+ }
+ } while (0);
+ L204 : do {
+ if (!(i25 >>> 0 < 16)) {
+ HEAP32[i24 + 4 >> 2] = i12 | 3;
+ HEAP32[i24 + (i12 | 4) >> 2] = i25 | 1;
+ HEAP32[i24 + (i25 + i12) >> 2] = i25;
+ i4 = i25 >>> 3;
+ if (i25 >>> 0 < 256) {
+ i6 = i4 << 1;
+ i3 = 7200 + (i6 << 2) | 0;
+ i5 = HEAP32[1790] | 0;
+ i4 = 1 << i4;
+ if ((i5 & i4 | 0) != 0) {
+ i5 = 7200 + (i6 + 2 << 2) | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ if (i4 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i21 = i5;
+ i20 = i4;
+ }
+ } else {
+ HEAP32[1790] = i5 | i4;
+ i21 = 7200 + (i6 + 2 << 2) | 0;
+ i20 = i3;
+ }
+ HEAP32[i21 >> 2] = i2;
+ HEAP32[i20 + 12 >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i20;
+ HEAP32[i24 + (i12 + 12) >> 2] = i3;
+ break;
+ }
+ i3 = i25 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i25 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i25 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i6 = 7464 + (i3 << 2) | 0;
+ HEAP32[i24 + (i12 + 28) >> 2] = i3;
+ HEAP32[i24 + (i12 + 20) >> 2] = 0;
+ HEAP32[i24 + (i12 + 16) >> 2] = 0;
+ i4 = HEAP32[7164 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i4 & i5 | 0) == 0) {
+ HEAP32[7164 >> 2] = i4 | i5;
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i24 + (i12 + 24) >> 2] = i6;
+ HEAP32[i24 + (i12 + 12) >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i2;
+ break;
+ }
+ i4 = HEAP32[i6 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L225 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i25 | 0)) {
+ i3 = i25 << i3;
+ while (1) {
+ i6 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i25 | 0)) {
+ i18 = i5;
+ break L225;
+ } else {
+ i3 = i3 << 1;
+ i4 = i5;
+ }
+ }
+ if (i6 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i24 + (i12 + 24) >> 2] = i4;
+ HEAP32[i24 + (i12 + 12) >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i2;
+ break L204;
+ }
+ } else {
+ i18 = i4;
+ }
+ } while (0);
+ i4 = i18 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[7176 >> 2] | 0;
+ if (i18 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i2;
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i3;
+ HEAP32[i24 + (i12 + 12) >> 2] = i18;
+ HEAP32[i24 + (i12 + 24) >> 2] = 0;
+ break;
+ }
+ } else {
+ i32 = i25 + i12 | 0;
+ HEAP32[i24 + 4 >> 2] = i32 | 3;
+ i32 = i24 + (i32 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ }
+ } while (0);
+ i32 = i24 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ } else {
+ i12 = -1;
+ }
+ }
+ } while (0);
+ i18 = HEAP32[7168 >> 2] | 0;
+ if (!(i12 >>> 0 > i18 >>> 0)) {
+ i3 = i18 - i12 | 0;
+ i2 = HEAP32[7180 >> 2] | 0;
+ if (i3 >>> 0 > 15) {
+ HEAP32[7180 >> 2] = i2 + i12;
+ HEAP32[7168 >> 2] = i3;
+ HEAP32[i2 + (i12 + 4) >> 2] = i3 | 1;
+ HEAP32[i2 + i18 >> 2] = i3;
+ HEAP32[i2 + 4 >> 2] = i12 | 3;
+ } else {
+ HEAP32[7168 >> 2] = 0;
+ HEAP32[7180 >> 2] = 0;
+ HEAP32[i2 + 4 >> 2] = i18 | 3;
+ i32 = i2 + (i18 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ }
+ i32 = i2 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i18 = HEAP32[7172 >> 2] | 0;
+ if (i12 >>> 0 < i18 >>> 0) {
+ i31 = i18 - i12 | 0;
+ HEAP32[7172 >> 2] = i31;
+ i32 = HEAP32[7184 >> 2] | 0;
+ HEAP32[7184 >> 2] = i32 + i12;
+ HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
+ HEAP32[i32 + 4 >> 2] = i12 | 3;
+ i32 = i32 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ do {
+ if ((HEAP32[1908] | 0) == 0) {
+ i18 = _sysconf(30) | 0;
+ if ((i18 + -1 & i18 | 0) == 0) {
+ HEAP32[7640 >> 2] = i18;
+ HEAP32[7636 >> 2] = i18;
+ HEAP32[7644 >> 2] = -1;
+ HEAP32[7648 >> 2] = -1;
+ HEAP32[7652 >> 2] = 0;
+ HEAP32[7604 >> 2] = 0;
+ HEAP32[1908] = (_time(0) | 0) & -16 ^ 1431655768;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ i20 = i12 + 48 | 0;
+ i25 = HEAP32[7640 >> 2] | 0;
+ i21 = i12 + 47 | 0;
+ i22 = i25 + i21 | 0;
+ i25 = 0 - i25 | 0;
+ i18 = i22 & i25;
+ if (!(i18 >>> 0 > i12 >>> 0)) {
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i24 = HEAP32[7600 >> 2] | 0;
+ if ((i24 | 0) != 0 ? (i31 = HEAP32[7592 >> 2] | 0, i32 = i31 + i18 | 0, i32 >>> 0 <= i31 >>> 0 | i32 >>> 0 > i24 >>> 0) : 0) {
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ L269 : do {
+ if ((HEAP32[7604 >> 2] & 4 | 0) == 0) {
+ i26 = HEAP32[7184 >> 2] | 0;
+ L271 : do {
+ if ((i26 | 0) != 0) {
+ i24 = 7608 | 0;
+ while (1) {
+ i27 = HEAP32[i24 >> 2] | 0;
+ if (!(i27 >>> 0 > i26 >>> 0) ? (i23 = i24 + 4 | 0, (i27 + (HEAP32[i23 >> 2] | 0) | 0) >>> 0 > i26 >>> 0) : 0) {
+ break;
+ }
+ i24 = HEAP32[i24 + 8 >> 2] | 0;
+ if ((i24 | 0) == 0) {
+ i13 = 182;
+ break L271;
+ }
+ }
+ if ((i24 | 0) != 0) {
+ i25 = i22 - (HEAP32[7172 >> 2] | 0) & i25;
+ if (i25 >>> 0 < 2147483647) {
+ i13 = _sbrk(i25 | 0) | 0;
+ i26 = (i13 | 0) == ((HEAP32[i24 >> 2] | 0) + (HEAP32[i23 >> 2] | 0) | 0);
+ i22 = i13;
+ i24 = i25;
+ i23 = i26 ? i13 : -1;
+ i25 = i26 ? i25 : 0;
+ i13 = 191;
+ } else {
+ i25 = 0;
+ }
+ } else {
+ i13 = 182;
+ }
+ } else {
+ i13 = 182;
+ }
+ } while (0);
+ do {
+ if ((i13 | 0) == 182) {
+ i23 = _sbrk(0) | 0;
+ if ((i23 | 0) != (-1 | 0)) {
+ i24 = i23;
+ i22 = HEAP32[7636 >> 2] | 0;
+ i25 = i22 + -1 | 0;
+ if ((i25 & i24 | 0) == 0) {
+ i25 = i18;
+ } else {
+ i25 = i18 - i24 + (i25 + i24 & 0 - i22) | 0;
+ }
+ i24 = HEAP32[7592 >> 2] | 0;
+ i26 = i24 + i25 | 0;
+ if (i25 >>> 0 > i12 >>> 0 & i25 >>> 0 < 2147483647) {
+ i22 = HEAP32[7600 >> 2] | 0;
+ if ((i22 | 0) != 0 ? i26 >>> 0 <= i24 >>> 0 | i26 >>> 0 > i22 >>> 0 : 0) {
+ i25 = 0;
+ break;
+ }
+ i22 = _sbrk(i25 | 0) | 0;
+ i13 = (i22 | 0) == (i23 | 0);
+ i24 = i25;
+ i23 = i13 ? i23 : -1;
+ i25 = i13 ? i25 : 0;
+ i13 = 191;
+ } else {
+ i25 = 0;
+ }
+ } else {
+ i25 = 0;
+ }
+ }
+ } while (0);
+ L291 : do {
+ if ((i13 | 0) == 191) {
+ i13 = 0 - i24 | 0;
+ if ((i23 | 0) != (-1 | 0)) {
+ i17 = i23;
+ i14 = i25;
+ i13 = 202;
+ break L269;
+ }
+ do {
+ if ((i22 | 0) != (-1 | 0) & i24 >>> 0 < 2147483647 & i24 >>> 0 < i20 >>> 0 ? (i19 = HEAP32[7640 >> 2] | 0, i19 = i21 - i24 + i19 & 0 - i19, i19 >>> 0 < 2147483647) : 0) {
+ if ((_sbrk(i19 | 0) | 0) == (-1 | 0)) {
+ _sbrk(i13 | 0) | 0;
+ break L291;
+ } else {
+ i24 = i19 + i24 | 0;
+ break;
+ }
+ }
+ } while (0);
+ if ((i22 | 0) != (-1 | 0)) {
+ i17 = i22;
+ i14 = i24;
+ i13 = 202;
+ break L269;
+ }
+ }
+ } while (0);
+ HEAP32[7604 >> 2] = HEAP32[7604 >> 2] | 4;
+ i13 = 199;
+ } else {
+ i25 = 0;
+ i13 = 199;
+ }
+ } while (0);
+ if ((((i13 | 0) == 199 ? i18 >>> 0 < 2147483647 : 0) ? (i17 = _sbrk(i18 | 0) | 0, i16 = _sbrk(0) | 0, (i16 | 0) != (-1 | 0) & (i17 | 0) != (-1 | 0) & i17 >>> 0 < i16 >>> 0) : 0) ? (i15 = i16 - i17 | 0, i14 = i15 >>> 0 > (i12 + 40 | 0) >>> 0, i14) : 0) {
+ i14 = i14 ? i15 : i25;
+ i13 = 202;
+ }
+ if ((i13 | 0) == 202) {
+ i15 = (HEAP32[7592 >> 2] | 0) + i14 | 0;
+ HEAP32[7592 >> 2] = i15;
+ if (i15 >>> 0 > (HEAP32[7596 >> 2] | 0) >>> 0) {
+ HEAP32[7596 >> 2] = i15;
+ }
+ i15 = HEAP32[7184 >> 2] | 0;
+ L311 : do {
+ if ((i15 | 0) != 0) {
+ i21 = 7608 | 0;
+ while (1) {
+ i16 = HEAP32[i21 >> 2] | 0;
+ i19 = i21 + 4 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i17 | 0) == (i16 + i20 | 0)) {
+ i13 = 214;
+ break;
+ }
+ i18 = HEAP32[i21 + 8 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ break;
+ } else {
+ i21 = i18;
+ }
+ }
+ if (((i13 | 0) == 214 ? (HEAP32[i21 + 12 >> 2] & 8 | 0) == 0 : 0) ? i15 >>> 0 >= i16 >>> 0 & i15 >>> 0 < i17 >>> 0 : 0) {
+ HEAP32[i19 >> 2] = i20 + i14;
+ i2 = (HEAP32[7172 >> 2] | 0) + i14 | 0;
+ i3 = i15 + 8 | 0;
+ if ((i3 & 7 | 0) == 0) {
+ i3 = 0;
+ } else {
+ i3 = 0 - i3 & 7;
+ }
+ i32 = i2 - i3 | 0;
+ HEAP32[7184 >> 2] = i15 + i3;
+ HEAP32[7172 >> 2] = i32;
+ HEAP32[i15 + (i3 + 4) >> 2] = i32 | 1;
+ HEAP32[i15 + (i2 + 4) >> 2] = 40;
+ HEAP32[7188 >> 2] = HEAP32[7648 >> 2];
+ break;
+ }
+ if (i17 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ HEAP32[7176 >> 2] = i17;
+ }
+ i19 = i17 + i14 | 0;
+ i16 = 7608 | 0;
+ while (1) {
+ if ((HEAP32[i16 >> 2] | 0) == (i19 | 0)) {
+ i13 = 224;
+ break;
+ }
+ i18 = HEAP32[i16 + 8 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ break;
+ } else {
+ i16 = i18;
+ }
+ }
+ if ((i13 | 0) == 224 ? (HEAP32[i16 + 12 >> 2] & 8 | 0) == 0 : 0) {
+ HEAP32[i16 >> 2] = i17;
+ i6 = i16 + 4 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + i14;
+ i6 = i17 + 8 | 0;
+ if ((i6 & 7 | 0) == 0) {
+ i6 = 0;
+ } else {
+ i6 = 0 - i6 & 7;
+ }
+ i7 = i17 + (i14 + 8) | 0;
+ if ((i7 & 7 | 0) == 0) {
+ i13 = 0;
+ } else {
+ i13 = 0 - i7 & 7;
+ }
+ i15 = i17 + (i13 + i14) | 0;
+ i8 = i6 + i12 | 0;
+ i7 = i17 + i8 | 0;
+ i10 = i15 - (i17 + i6) - i12 | 0;
+ HEAP32[i17 + (i6 + 4) >> 2] = i12 | 3;
+ L348 : do {
+ if ((i15 | 0) != (HEAP32[7184 >> 2] | 0)) {
+ if ((i15 | 0) == (HEAP32[7180 >> 2] | 0)) {
+ i32 = (HEAP32[7168 >> 2] | 0) + i10 | 0;
+ HEAP32[7168 >> 2] = i32;
+ HEAP32[7180 >> 2] = i7;
+ HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i32 + i8) >> 2] = i32;
+ break;
+ }
+ i12 = i14 + 4 | 0;
+ i18 = HEAP32[i17 + (i12 + i13) >> 2] | 0;
+ if ((i18 & 3 | 0) == 1) {
+ i11 = i18 & -8;
+ i16 = i18 >>> 3;
+ do {
+ if (!(i18 >>> 0 < 256)) {
+ i9 = HEAP32[i17 + ((i13 | 24) + i14) >> 2] | 0;
+ i19 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
+ do {
+ if ((i19 | 0) == (i15 | 0)) {
+ i19 = i13 | 16;
+ i18 = i17 + (i12 + i19) | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ if ((i16 | 0) == 0) {
+ i18 = i17 + (i19 + i14) | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ if ((i16 | 0) == 0) {
+ i5 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i20 = i16 + 20 | 0;
+ i19 = HEAP32[i20 >> 2] | 0;
+ if ((i19 | 0) != 0) {
+ i16 = i19;
+ i18 = i20;
+ continue;
+ }
+ i19 = i16 + 16 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i20 | 0) == 0) {
+ break;
+ } else {
+ i16 = i20;
+ i18 = i19;
+ }
+ }
+ if (i18 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i18 >> 2] = 0;
+ i5 = i16;
+ break;
+ }
+ } else {
+ i18 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
+ if (i18 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i18 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != (i15 | 0)) {
+ _abort();
+ }
+ i20 = i19 + 8 | 0;
+ if ((HEAP32[i20 >> 2] | 0) == (i15 | 0)) {
+ HEAP32[i16 >> 2] = i19;
+ HEAP32[i20 >> 2] = i18;
+ i5 = i19;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i9 | 0) != 0) {
+ i16 = HEAP32[i17 + (i14 + 28 + i13) >> 2] | 0;
+ i18 = 7464 + (i16 << 2) | 0;
+ if ((i15 | 0) == (HEAP32[i18 >> 2] | 0)) {
+ HEAP32[i18 >> 2] = i5;
+ if ((i5 | 0) == 0) {
+ HEAP32[7164 >> 2] = HEAP32[7164 >> 2] & ~(1 << i16);
+ break;
+ }
+ } else {
+ if (i9 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i9 + 16 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
+ HEAP32[i16 >> 2] = i5;
+ } else {
+ HEAP32[i9 + 20 >> 2] = i5;
+ }
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i5 + 24 >> 2] = i9;
+ i15 = i13 | 16;
+ i9 = HEAP32[i17 + (i15 + i14) >> 2] | 0;
+ do {
+ if ((i9 | 0) != 0) {
+ if (i9 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 + 16 >> 2] = i9;
+ HEAP32[i9 + 24 >> 2] = i5;
+ break;
+ }
+ }
+ } while (0);
+ i9 = HEAP32[i17 + (i12 + i15) >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ if (i9 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 + 20 >> 2] = i9;
+ HEAP32[i9 + 24 >> 2] = i5;
+ break;
+ }
+ }
+ }
+ } else {
+ i5 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
+ i12 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
+ i18 = 7200 + (i16 << 1 << 2) | 0;
+ if ((i5 | 0) != (i18 | 0)) {
+ if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i5 + 12 >> 2] | 0) != (i15 | 0)) {
+ _abort();
+ }
+ }
+ if ((i12 | 0) == (i5 | 0)) {
+ HEAP32[1790] = HEAP32[1790] & ~(1 << i16);
+ break;
+ }
+ if ((i12 | 0) != (i18 | 0)) {
+ if (i12 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i12 + 8 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
+ i9 = i16;
+ } else {
+ _abort();
+ }
+ } else {
+ i9 = i12 + 8 | 0;
+ }
+ HEAP32[i5 + 12 >> 2] = i12;
+ HEAP32[i9 >> 2] = i5;
+ }
+ } while (0);
+ i15 = i17 + ((i11 | i13) + i14) | 0;
+ i10 = i11 + i10 | 0;
+ }
+ i5 = i15 + 4 | 0;
+ HEAP32[i5 >> 2] = HEAP32[i5 >> 2] & -2;
+ HEAP32[i17 + (i8 + 4) >> 2] = i10 | 1;
+ HEAP32[i17 + (i10 + i8) >> 2] = i10;
+ i5 = i10 >>> 3;
+ if (i10 >>> 0 < 256) {
+ i10 = i5 << 1;
+ i2 = 7200 + (i10 << 2) | 0;
+ i9 = HEAP32[1790] | 0;
+ i5 = 1 << i5;
+ if ((i9 & i5 | 0) != 0) {
+ i9 = 7200 + (i10 + 2 << 2) | 0;
+ i5 = HEAP32[i9 >> 2] | 0;
+ if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i3 = i9;
+ i4 = i5;
+ }
+ } else {
+ HEAP32[1790] = i9 | i5;
+ i3 = 7200 + (i10 + 2 << 2) | 0;
+ i4 = i2;
+ }
+ HEAP32[i3 >> 2] = i7;
+ HEAP32[i4 + 12 >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i2;
+ break;
+ }
+ i3 = i10 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i10 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i10 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i4 = 7464 + (i3 << 2) | 0;
+ HEAP32[i17 + (i8 + 28) >> 2] = i3;
+ HEAP32[i17 + (i8 + 20) >> 2] = 0;
+ HEAP32[i17 + (i8 + 16) >> 2] = 0;
+ i9 = HEAP32[7164 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i9 & i5 | 0) == 0) {
+ HEAP32[7164 >> 2] = i9 | i5;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i17 + (i8 + 24) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i7;
+ break;
+ }
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L444 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i10 | 0)) {
+ i3 = i10 << i3;
+ while (1) {
+ i5 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i9 = HEAP32[i5 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i9 + 4 >> 2] & -8 | 0) == (i10 | 0)) {
+ i2 = i9;
+ break L444;
+ } else {
+ i3 = i3 << 1;
+ i4 = i9;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 >> 2] = i7;
+ HEAP32[i17 + (i8 + 24) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i7;
+ break L348;
+ }
+ } else {
+ i2 = i4;
+ }
+ } while (0);
+ i4 = i2 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[7176 >> 2] | 0;
+ if (i2 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i7;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i3;
+ HEAP32[i17 + (i8 + 12) >> 2] = i2;
+ HEAP32[i17 + (i8 + 24) >> 2] = 0;
+ break;
+ }
+ } else {
+ i32 = (HEAP32[7172 >> 2] | 0) + i10 | 0;
+ HEAP32[7172 >> 2] = i32;
+ HEAP32[7184 >> 2] = i7;
+ HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
+ }
+ } while (0);
+ i32 = i17 + (i6 | 8) | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i3 = 7608 | 0;
+ while (1) {
+ i2 = HEAP32[i3 >> 2] | 0;
+ if (!(i2 >>> 0 > i15 >>> 0) ? (i11 = HEAP32[i3 + 4 >> 2] | 0, i10 = i2 + i11 | 0, i10 >>> 0 > i15 >>> 0) : 0) {
+ break;
+ }
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ }
+ i3 = i2 + (i11 + -39) | 0;
+ if ((i3 & 7 | 0) == 0) {
+ i3 = 0;
+ } else {
+ i3 = 0 - i3 & 7;
+ }
+ i2 = i2 + (i11 + -47 + i3) | 0;
+ i2 = i2 >>> 0 < (i15 + 16 | 0) >>> 0 ? i15 : i2;
+ i3 = i2 + 8 | 0;
+ i4 = i17 + 8 | 0;
+ if ((i4 & 7 | 0) == 0) {
+ i4 = 0;
+ } else {
+ i4 = 0 - i4 & 7;
+ }
+ i32 = i14 + -40 - i4 | 0;
+ HEAP32[7184 >> 2] = i17 + i4;
+ HEAP32[7172 >> 2] = i32;
+ HEAP32[i17 + (i4 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i14 + -36) >> 2] = 40;
+ HEAP32[7188 >> 2] = HEAP32[7648 >> 2];
+ HEAP32[i2 + 4 >> 2] = 27;
+ HEAP32[i3 + 0 >> 2] = HEAP32[7608 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[7612 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[7616 >> 2];
+ HEAP32[i3 + 12 >> 2] = HEAP32[7620 >> 2];
+ HEAP32[7608 >> 2] = i17;
+ HEAP32[7612 >> 2] = i14;
+ HEAP32[7620 >> 2] = 0;
+ HEAP32[7616 >> 2] = i3;
+ i4 = i2 + 28 | 0;
+ HEAP32[i4 >> 2] = 7;
+ if ((i2 + 32 | 0) >>> 0 < i10 >>> 0) {
+ while (1) {
+ i3 = i4 + 4 | 0;
+ HEAP32[i3 >> 2] = 7;
+ if ((i4 + 8 | 0) >>> 0 < i10 >>> 0) {
+ i4 = i3;
+ } else {
+ break;
+ }
+ }
+ }
+ if ((i2 | 0) != (i15 | 0)) {
+ i2 = i2 - i15 | 0;
+ i3 = i15 + (i2 + 4) | 0;
+ HEAP32[i3 >> 2] = HEAP32[i3 >> 2] & -2;
+ HEAP32[i15 + 4 >> 2] = i2 | 1;
+ HEAP32[i15 + i2 >> 2] = i2;
+ i3 = i2 >>> 3;
+ if (i2 >>> 0 < 256) {
+ i4 = i3 << 1;
+ i2 = 7200 + (i4 << 2) | 0;
+ i5 = HEAP32[1790] | 0;
+ i3 = 1 << i3;
+ if ((i5 & i3 | 0) != 0) {
+ i4 = 7200 + (i4 + 2 << 2) | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ if (i3 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i7 = i4;
+ i8 = i3;
+ }
+ } else {
+ HEAP32[1790] = i5 | i3;
+ i7 = 7200 + (i4 + 2 << 2) | 0;
+ i8 = i2;
+ }
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i8 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i8;
+ HEAP32[i15 + 12 >> 2] = i2;
+ break;
+ }
+ i3 = i2 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i2 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i2 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i7 = 7464 + (i3 << 2) | 0;
+ HEAP32[i15 + 28 >> 2] = i3;
+ HEAP32[i15 + 20 >> 2] = 0;
+ HEAP32[i15 + 16 >> 2] = 0;
+ i4 = HEAP32[7164 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i4 & i5 | 0) == 0) {
+ HEAP32[7164 >> 2] = i4 | i5;
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i7;
+ HEAP32[i15 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i15;
+ break;
+ }
+ i4 = HEAP32[i7 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L499 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i2 | 0)) {
+ i3 = i2 << i3;
+ while (1) {
+ i7 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i2 | 0)) {
+ i6 = i5;
+ break L499;
+ } else {
+ i3 = i3 << 1;
+ i4 = i5;
+ }
+ }
+ if (i7 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i4;
+ HEAP32[i15 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i15;
+ break L311;
+ }
+ } else {
+ i6 = i4;
+ }
+ } while (0);
+ i4 = i6 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i2 = HEAP32[7176 >> 2] | 0;
+ if (i6 >>> 0 < i2 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i2 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i15;
+ HEAP32[i4 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i3;
+ HEAP32[i15 + 12 >> 2] = i6;
+ HEAP32[i15 + 24 >> 2] = 0;
+ break;
+ }
+ }
+ } else {
+ i32 = HEAP32[7176 >> 2] | 0;
+ if ((i32 | 0) == 0 | i17 >>> 0 < i32 >>> 0) {
+ HEAP32[7176 >> 2] = i17;
+ }
+ HEAP32[7608 >> 2] = i17;
+ HEAP32[7612 >> 2] = i14;
+ HEAP32[7620 >> 2] = 0;
+ HEAP32[7196 >> 2] = HEAP32[1908];
+ HEAP32[7192 >> 2] = -1;
+ i2 = 0;
+ do {
+ i32 = i2 << 1;
+ i31 = 7200 + (i32 << 2) | 0;
+ HEAP32[7200 + (i32 + 3 << 2) >> 2] = i31;
+ HEAP32[7200 + (i32 + 2 << 2) >> 2] = i31;
+ i2 = i2 + 1 | 0;
+ } while ((i2 | 0) != 32);
+ i2 = i17 + 8 | 0;
+ if ((i2 & 7 | 0) == 0) {
+ i2 = 0;
+ } else {
+ i2 = 0 - i2 & 7;
+ }
+ i32 = i14 + -40 - i2 | 0;
+ HEAP32[7184 >> 2] = i17 + i2;
+ HEAP32[7172 >> 2] = i32;
+ HEAP32[i17 + (i2 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i14 + -36) >> 2] = 40;
+ HEAP32[7188 >> 2] = HEAP32[7648 >> 2];
+ }
+ } while (0);
+ i2 = HEAP32[7172 >> 2] | 0;
+ if (i2 >>> 0 > i12 >>> 0) {
+ i31 = i2 - i12 | 0;
+ HEAP32[7172 >> 2] = i31;
+ i32 = HEAP32[7184 >> 2] | 0;
+ HEAP32[7184 >> 2] = i32 + i12;
+ HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
+ HEAP32[i32 + 4 >> 2] = i12 | 3;
+ i32 = i32 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ HEAP32[(___errno_location() | 0) >> 2] = 12;
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+}
+function __ZN12b2EPCollider7CollideEP10b2ManifoldPK11b2EdgeShapeRK11b2TransformPK14b2PolygonShapeS7_(i12, i2, i16, i5, i8, i6) {
+ i12 = i12 | 0;
+ i2 = i2 | 0;
+ i16 = i16 | 0;
+ i5 = i5 | 0;
+ i8 = i8 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i7 = 0, i9 = 0, i10 = 0, i11 = 0, i13 = 0, i14 = 0, i15 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, d22 = 0.0, d23 = 0.0, d24 = 0.0, d25 = 0.0, d26 = 0.0, d27 = 0.0, d28 = 0.0, i29 = 0, d30 = 0.0, d31 = 0.0, d32 = 0.0, d33 = 0.0, i34 = 0, i35 = 0, d36 = 0.0, d37 = 0.0, i38 = 0, d39 = 0.0, i40 = 0, i41 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 144 | 0;
+ i18 = i1 + 128 | 0;
+ i11 = i1 + 24 | 0;
+ i9 = i1 + 72 | 0;
+ i10 = i1 + 48 | 0;
+ i3 = i1;
+ i4 = i12 + 132 | 0;
+ d28 = +HEAPF32[i5 + 12 >> 2];
+ d37 = +HEAPF32[i6 + 8 >> 2];
+ d23 = +HEAPF32[i5 + 8 >> 2];
+ d27 = +HEAPF32[i6 + 12 >> 2];
+ d22 = d28 * d37 - d23 * d27;
+ d27 = d37 * d23 + d28 * d27;
+ d37 = +d22;
+ d26 = +d27;
+ d25 = +HEAPF32[i6 >> 2] - +HEAPF32[i5 >> 2];
+ d36 = +HEAPF32[i6 + 4 >> 2] - +HEAPF32[i5 + 4 >> 2];
+ d24 = d28 * d25 + d23 * d36;
+ d25 = d28 * d36 - d23 * d25;
+ d23 = +d24;
+ d36 = +d25;
+ i5 = i4;
+ HEAPF32[i5 >> 2] = d23;
+ HEAPF32[i5 + 4 >> 2] = d36;
+ i5 = i12 + 140 | 0;
+ HEAPF32[i5 >> 2] = d37;
+ HEAPF32[i5 + 4 >> 2] = d26;
+ i5 = i12 + 144 | 0;
+ d26 = +HEAPF32[i8 + 12 >> 2];
+ i7 = i12 + 140 | 0;
+ d37 = +HEAPF32[i8 + 16 >> 2];
+ d24 = d24 + (d27 * d26 - d22 * d37);
+ i6 = i12 + 136 | 0;
+ d25 = d26 * d22 + d27 * d37 + d25;
+ d37 = +d24;
+ d27 = +d25;
+ i34 = i12 + 148 | 0;
+ HEAPF32[i34 >> 2] = d37;
+ HEAPF32[i34 + 4 >> 2] = d27;
+ i34 = i16 + 28 | 0;
+ i29 = HEAP32[i34 >> 2] | 0;
+ i34 = HEAP32[i34 + 4 >> 2] | 0;
+ i14 = i12 + 156 | 0;
+ HEAP32[i14 >> 2] = i29;
+ HEAP32[i14 + 4 >> 2] = i34;
+ i14 = i12 + 164 | 0;
+ i17 = i16 + 12 | 0;
+ i40 = HEAP32[i17 >> 2] | 0;
+ i17 = HEAP32[i17 + 4 >> 2] | 0;
+ i13 = i14;
+ HEAP32[i13 >> 2] = i40;
+ HEAP32[i13 + 4 >> 2] = i17;
+ i13 = i12 + 172 | 0;
+ i20 = i16 + 20 | 0;
+ i41 = HEAP32[i20 >> 2] | 0;
+ i20 = HEAP32[i20 + 4 >> 2] | 0;
+ i38 = i13;
+ HEAP32[i38 >> 2] = i41;
+ HEAP32[i38 + 4 >> 2] = i20;
+ i38 = i16 + 36 | 0;
+ i35 = HEAP32[i38 >> 2] | 0;
+ i38 = HEAP32[i38 + 4 >> 2] | 0;
+ i19 = i12 + 180 | 0;
+ HEAP32[i19 >> 2] = i35;
+ HEAP32[i19 + 4 >> 2] = i38;
+ i19 = (HEAP8[i16 + 44 | 0] | 0) != 0;
+ i21 = (HEAP8[i16 + 45 | 0] | 0) != 0;
+ d27 = (HEAP32[tempDoublePtr >> 2] = i41, +HEAPF32[tempDoublePtr >> 2]);
+ d37 = (HEAP32[tempDoublePtr >> 2] = i40, +HEAPF32[tempDoublePtr >> 2]);
+ d22 = d27 - d37;
+ d26 = (HEAP32[tempDoublePtr >> 2] = i20, +HEAPF32[tempDoublePtr >> 2]);
+ i20 = i12 + 168 | 0;
+ d36 = (HEAP32[tempDoublePtr >> 2] = i17, +HEAPF32[tempDoublePtr >> 2]);
+ d23 = d26 - d36;
+ d28 = +Math_sqrt(+(d22 * d22 + d23 * d23));
+ d33 = (HEAP32[tempDoublePtr >> 2] = i29, +HEAPF32[tempDoublePtr >> 2]);
+ d32 = (HEAP32[tempDoublePtr >> 2] = i34, +HEAPF32[tempDoublePtr >> 2]);
+ d31 = (HEAP32[tempDoublePtr >> 2] = i35, +HEAPF32[tempDoublePtr >> 2]);
+ d30 = (HEAP32[tempDoublePtr >> 2] = i38, +HEAPF32[tempDoublePtr >> 2]);
+ if (!(d28 < 1.1920928955078125e-7)) {
+ d39 = 1.0 / d28;
+ d22 = d22 * d39;
+ d23 = d23 * d39;
+ }
+ i16 = i12 + 196 | 0;
+ d28 = -d22;
+ HEAPF32[i16 >> 2] = d23;
+ i17 = i12 + 200 | 0;
+ HEAPF32[i17 >> 2] = d28;
+ d28 = (d24 - d37) * d23 + (d25 - d36) * d28;
+ if (i19) {
+ d37 = d37 - d33;
+ d36 = d36 - d32;
+ d39 = +Math_sqrt(+(d37 * d37 + d36 * d36));
+ if (!(d39 < 1.1920928955078125e-7)) {
+ d39 = 1.0 / d39;
+ d37 = d37 * d39;
+ d36 = d36 * d39;
+ }
+ d39 = -d37;
+ HEAPF32[i12 + 188 >> 2] = d36;
+ HEAPF32[i12 + 192 >> 2] = d39;
+ i29 = d23 * d37 - d22 * d36 >= 0.0;
+ d32 = (d24 - d33) * d36 + (d25 - d32) * d39;
+ } else {
+ i29 = 0;
+ d32 = 0.0;
+ }
+ L10 : do {
+ if (!i21) {
+ if (!i19) {
+ i41 = d28 >= 0.0;
+ HEAP8[i12 + 248 | 0] = i41 & 1;
+ i19 = i12 + 212 | 0;
+ if (i41) {
+ i15 = 64;
+ break;
+ } else {
+ i15 = 65;
+ break;
+ }
+ }
+ i19 = d32 >= 0.0;
+ if (i29) {
+ if (!i19) {
+ i41 = d28 >= 0.0;
+ HEAP8[i12 + 248 | 0] = i41 & 1;
+ i19 = i12 + 212 | 0;
+ if (!i41) {
+ d37 = +-d23;
+ d39 = +d22;
+ i38 = i19;
+ HEAPF32[i38 >> 2] = d37;
+ HEAPF32[i38 + 4 >> 2] = d39;
+ i38 = i16;
+ i40 = HEAP32[i38 >> 2] | 0;
+ i38 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i12 + 228 | 0;
+ HEAP32[i41 >> 2] = i40;
+ HEAP32[i41 + 4 >> 2] = i38;
+ i41 = i12 + 236 | 0;
+ HEAPF32[i41 >> 2] = -(HEAP32[tempDoublePtr >> 2] = i40, +HEAPF32[tempDoublePtr >> 2]);
+ HEAPF32[i41 + 4 >> 2] = d39;
+ break;
+ }
+ } else {
+ HEAP8[i12 + 248 | 0] = 1;
+ i19 = i12 + 212 | 0;
+ }
+ i41 = i16;
+ i40 = HEAP32[i41 + 4 >> 2] | 0;
+ i38 = i19;
+ HEAP32[i38 >> 2] = HEAP32[i41 >> 2];
+ HEAP32[i38 + 4 >> 2] = i40;
+ i38 = i12 + 188 | 0;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i12 + 228 | 0;
+ HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i41 + 4 >> 2] = i40;
+ d37 = +-+HEAPF32[i16 >> 2];
+ d39 = +-+HEAPF32[i17 >> 2];
+ i41 = i12 + 236 | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ break;
+ } else {
+ if (i19) {
+ i41 = d28 >= 0.0;
+ HEAP8[i12 + 248 | 0] = i41 & 1;
+ i19 = i12 + 212 | 0;
+ if (i41) {
+ i38 = i16;
+ i41 = HEAP32[i38 >> 2] | 0;
+ i38 = HEAP32[i38 + 4 >> 2] | 0;
+ i40 = i19;
+ HEAP32[i40 >> 2] = i41;
+ HEAP32[i40 + 4 >> 2] = i38;
+ i40 = i12 + 228 | 0;
+ HEAP32[i40 >> 2] = i41;
+ HEAP32[i40 + 4 >> 2] = i38;
+ d37 = +-(HEAP32[tempDoublePtr >> 2] = i41, +HEAPF32[tempDoublePtr >> 2]);
+ d39 = +d22;
+ i41 = i12 + 236 | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ break;
+ }
+ } else {
+ HEAP8[i12 + 248 | 0] = 0;
+ i19 = i12 + 212 | 0;
+ }
+ d39 = +-d23;
+ d37 = +d22;
+ i38 = i19;
+ HEAPF32[i38 >> 2] = d39;
+ HEAPF32[i38 + 4 >> 2] = d37;
+ i38 = i16;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i12 + 228 | 0;
+ HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i41 + 4 >> 2] = i40;
+ d37 = +-+HEAPF32[i12 + 188 >> 2];
+ d39 = +-+HEAPF32[i12 + 192 >> 2];
+ i41 = i12 + 236 | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ break;
+ }
+ } else {
+ d33 = d31 - d27;
+ d31 = d30 - d26;
+ d30 = +Math_sqrt(+(d33 * d33 + d31 * d31));
+ if (d30 < 1.1920928955078125e-7) {
+ d30 = d33;
+ } else {
+ d39 = 1.0 / d30;
+ d30 = d33 * d39;
+ d31 = d31 * d39;
+ }
+ d39 = -d30;
+ i34 = i12 + 204 | 0;
+ HEAPF32[i34 >> 2] = d31;
+ i35 = i12 + 208 | 0;
+ HEAPF32[i35 >> 2] = d39;
+ i38 = d22 * d31 - d23 * d30 > 0.0;
+ d24 = (d24 - d27) * d31 + (d25 - d26) * d39;
+ if (!i19) {
+ i19 = d28 >= 0.0;
+ if (!i21) {
+ HEAP8[i12 + 248 | 0] = i19 & 1;
+ i15 = i12 + 212 | 0;
+ if (i19) {
+ i19 = i15;
+ i15 = 64;
+ break;
+ } else {
+ i19 = i15;
+ i15 = 65;
+ break;
+ }
+ }
+ if (i38) {
+ if (!i19) {
+ i41 = d24 >= 0.0;
+ HEAP8[i12 + 248 | 0] = i41 & 1;
+ i19 = i12 + 212 | 0;
+ if (!i41) {
+ d37 = +-d23;
+ d39 = +d22;
+ i38 = i19;
+ HEAPF32[i38 >> 2] = d37;
+ HEAPF32[i38 + 4 >> 2] = d39;
+ i38 = i12 + 228 | 0;
+ HEAPF32[i38 >> 2] = d37;
+ HEAPF32[i38 + 4 >> 2] = d39;
+ i38 = i16;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i12 + 236 | 0;
+ HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i41 + 4 >> 2] = i40;
+ break;
+ }
+ } else {
+ HEAP8[i12 + 248 | 0] = 1;
+ i19 = i12 + 212 | 0;
+ }
+ i41 = i16;
+ i40 = HEAP32[i41 + 4 >> 2] | 0;
+ i38 = i19;
+ HEAP32[i38 >> 2] = HEAP32[i41 >> 2];
+ HEAP32[i38 + 4 >> 2] = i40;
+ d37 = +-+HEAPF32[i16 >> 2];
+ d39 = +-+HEAPF32[i17 >> 2];
+ i38 = i12 + 228 | 0;
+ HEAPF32[i38 >> 2] = d37;
+ HEAPF32[i38 + 4 >> 2] = d39;
+ i38 = i12 + 204 | 0;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i12 + 236 | 0;
+ HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i41 + 4 >> 2] = i40;
+ break;
+ } else {
+ if (i19) {
+ i41 = d24 >= 0.0;
+ HEAP8[i12 + 248 | 0] = i41 & 1;
+ i19 = i12 + 212 | 0;
+ if (i41) {
+ i40 = i16;
+ i38 = HEAP32[i40 >> 2] | 0;
+ i40 = HEAP32[i40 + 4 >> 2] | 0;
+ i41 = i19;
+ HEAP32[i41 >> 2] = i38;
+ HEAP32[i41 + 4 >> 2] = i40;
+ d37 = +-(HEAP32[tempDoublePtr >> 2] = i38, +HEAPF32[tempDoublePtr >> 2]);
+ d39 = +d22;
+ i41 = i12 + 228 | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ i41 = i12 + 236 | 0;
+ HEAP32[i41 >> 2] = i38;
+ HEAP32[i41 + 4 >> 2] = i40;
+ break;
+ }
+ } else {
+ HEAP8[i12 + 248 | 0] = 0;
+ i19 = i12 + 212 | 0;
+ }
+ d39 = +-d23;
+ d37 = +d22;
+ i38 = i19;
+ HEAPF32[i38 >> 2] = d39;
+ HEAPF32[i38 + 4 >> 2] = d37;
+ d37 = +-+HEAPF32[i12 + 204 >> 2];
+ d39 = +-+HEAPF32[i12 + 208 >> 2];
+ i38 = i12 + 228 | 0;
+ HEAPF32[i38 >> 2] = d37;
+ HEAPF32[i38 + 4 >> 2] = d39;
+ i38 = i16;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i12 + 236 | 0;
+ HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i41 + 4 >> 2] = i40;
+ break;
+ }
+ }
+ if (i29 & i38) {
+ if (!(d32 >= 0.0) & !(d28 >= 0.0)) {
+ i41 = d24 >= 0.0;
+ HEAP8[i12 + 248 | 0] = i41 & 1;
+ i19 = i12 + 212 | 0;
+ if (!i41) {
+ d37 = +-d23;
+ d39 = +d22;
+ i41 = i19;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ i41 = i12 + 228 | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ i41 = i12 + 236 | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ break;
+ }
+ } else {
+ HEAP8[i12 + 248 | 0] = 1;
+ i19 = i12 + 212 | 0;
+ }
+ i38 = i16;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i19;
+ HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i41 + 4 >> 2] = i40;
+ i41 = i12 + 188 | 0;
+ i40 = HEAP32[i41 + 4 >> 2] | 0;
+ i38 = i12 + 228 | 0;
+ HEAP32[i38 >> 2] = HEAP32[i41 >> 2];
+ HEAP32[i38 + 4 >> 2] = i40;
+ i38 = i12 + 204 | 0;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i12 + 236 | 0;
+ HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i41 + 4 >> 2] = i40;
+ break;
+ }
+ if (i29) {
+ do {
+ if (!(d32 >= 0.0)) {
+ if (d28 >= 0.0) {
+ i41 = d24 >= 0.0;
+ HEAP8[i12 + 248 | 0] = i41 & 1;
+ i19 = i12 + 212 | 0;
+ if (i41) {
+ break;
+ }
+ } else {
+ HEAP8[i12 + 248 | 0] = 0;
+ i19 = i12 + 212 | 0;
+ }
+ d37 = +-d23;
+ d39 = +d22;
+ i41 = i19;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ d39 = +-+HEAPF32[i34 >> 2];
+ d37 = +-+HEAPF32[i35 >> 2];
+ i41 = i12 + 228 | 0;
+ HEAPF32[i41 >> 2] = d39;
+ HEAPF32[i41 + 4 >> 2] = d37;
+ d37 = +-+HEAPF32[i16 >> 2];
+ d39 = +-+HEAPF32[i17 >> 2];
+ i41 = i12 + 236 | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ break L10;
+ } else {
+ HEAP8[i12 + 248 | 0] = 1;
+ i19 = i12 + 212 | 0;
+ }
+ } while (0);
+ i38 = i16;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i19;
+ HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i41 + 4 >> 2] = i40;
+ i41 = i12 + 188 | 0;
+ i40 = HEAP32[i41 + 4 >> 2] | 0;
+ i38 = i12 + 228 | 0;
+ HEAP32[i38 >> 2] = HEAP32[i41 >> 2];
+ HEAP32[i38 + 4 >> 2] = i40;
+ i38 = i16;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i12 + 236 | 0;
+ HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i41 + 4 >> 2] = i40;
+ break;
+ }
+ if (!i38) {
+ if (!(!(d32 >= 0.0) | !(d28 >= 0.0))) {
+ i41 = d24 >= 0.0;
+ HEAP8[i12 + 248 | 0] = i41 & 1;
+ i19 = i12 + 212 | 0;
+ if (i41) {
+ i40 = i16;
+ i38 = HEAP32[i40 >> 2] | 0;
+ i40 = HEAP32[i40 + 4 >> 2] | 0;
+ i41 = i19;
+ HEAP32[i41 >> 2] = i38;
+ HEAP32[i41 + 4 >> 2] = i40;
+ i41 = i12 + 228 | 0;
+ HEAP32[i41 >> 2] = i38;
+ HEAP32[i41 + 4 >> 2] = i40;
+ i41 = i12 + 236 | 0;
+ HEAP32[i41 >> 2] = i38;
+ HEAP32[i41 + 4 >> 2] = i40;
+ break;
+ }
+ } else {
+ HEAP8[i12 + 248 | 0] = 0;
+ i19 = i12 + 212 | 0;
+ }
+ d37 = +-d23;
+ d39 = +d22;
+ i41 = i19;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ d39 = +-+HEAPF32[i34 >> 2];
+ d37 = +-+HEAPF32[i35 >> 2];
+ i41 = i12 + 228 | 0;
+ HEAPF32[i41 >> 2] = d39;
+ HEAPF32[i41 + 4 >> 2] = d37;
+ d37 = +-+HEAPF32[i12 + 188 >> 2];
+ d39 = +-+HEAPF32[i12 + 192 >> 2];
+ i41 = i12 + 236 | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ break;
+ }
+ do {
+ if (!(d24 >= 0.0)) {
+ if (d32 >= 0.0) {
+ i41 = d28 >= 0.0;
+ HEAP8[i12 + 248 | 0] = i41 & 1;
+ i19 = i12 + 212 | 0;
+ if (i41) {
+ break;
+ }
+ } else {
+ HEAP8[i12 + 248 | 0] = 0;
+ i19 = i12 + 212 | 0;
+ }
+ d37 = +-d23;
+ d39 = +d22;
+ i41 = i19;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ d39 = +-+HEAPF32[i16 >> 2];
+ d37 = +-+HEAPF32[i17 >> 2];
+ i41 = i12 + 228 | 0;
+ HEAPF32[i41 >> 2] = d39;
+ HEAPF32[i41 + 4 >> 2] = d37;
+ d37 = +-+HEAPF32[i12 + 188 >> 2];
+ d39 = +-+HEAPF32[i12 + 192 >> 2];
+ i41 = i12 + 236 | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ break L10;
+ } else {
+ HEAP8[i12 + 248 | 0] = 1;
+ i19 = i12 + 212 | 0;
+ }
+ } while (0);
+ i38 = i16;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i19;
+ HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i41 + 4 >> 2] = i40;
+ i41 = i16;
+ i40 = HEAP32[i41 + 4 >> 2] | 0;
+ i38 = i12 + 228 | 0;
+ HEAP32[i38 >> 2] = HEAP32[i41 >> 2];
+ HEAP32[i38 + 4 >> 2] = i40;
+ i38 = i12 + 204 | 0;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i12 + 236 | 0;
+ HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i41 + 4 >> 2] = i40;
+ }
+ } while (0);
+ if ((i15 | 0) == 64) {
+ i38 = i16;
+ i41 = HEAP32[i38 >> 2] | 0;
+ i38 = HEAP32[i38 + 4 >> 2] | 0;
+ i40 = i19;
+ HEAP32[i40 >> 2] = i41;
+ HEAP32[i40 + 4 >> 2] = i38;
+ d37 = +-(HEAP32[tempDoublePtr >> 2] = i41, +HEAPF32[tempDoublePtr >> 2]);
+ d39 = +d22;
+ i41 = i12 + 228 | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ i41 = i12 + 236 | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ } else if ((i15 | 0) == 65) {
+ d37 = +-d23;
+ d39 = +d22;
+ i40 = i19;
+ HEAPF32[i40 >> 2] = d37;
+ HEAPF32[i40 + 4 >> 2] = d39;
+ i40 = i16;
+ i38 = HEAP32[i40 >> 2] | 0;
+ i40 = HEAP32[i40 + 4 >> 2] | 0;
+ i41 = i12 + 228 | 0;
+ HEAP32[i41 >> 2] = i38;
+ HEAP32[i41 + 4 >> 2] = i40;
+ i41 = i12 + 236 | 0;
+ HEAP32[i41 >> 2] = i38;
+ HEAP32[i41 + 4 >> 2] = i40;
+ }
+ i21 = i8 + 148 | 0;
+ i34 = i12 + 128 | 0;
+ HEAP32[i34 >> 2] = HEAP32[i21 >> 2];
+ if ((HEAP32[i21 >> 2] | 0) > 0) {
+ i19 = 0;
+ do {
+ d33 = +HEAPF32[i5 >> 2];
+ d37 = +HEAPF32[i8 + (i19 << 3) + 20 >> 2];
+ d39 = +HEAPF32[i7 >> 2];
+ d36 = +HEAPF32[i8 + (i19 << 3) + 24 >> 2];
+ d32 = +(+HEAPF32[i4 >> 2] + (d33 * d37 - d39 * d36));
+ d36 = +(d37 * d39 + d33 * d36 + +HEAPF32[i6 >> 2]);
+ i41 = i12 + (i19 << 3) | 0;
+ HEAPF32[i41 >> 2] = d32;
+ HEAPF32[i41 + 4 >> 2] = d36;
+ d36 = +HEAPF32[i5 >> 2];
+ d32 = +HEAPF32[i8 + (i19 << 3) + 84 >> 2];
+ d33 = +HEAPF32[i7 >> 2];
+ d39 = +HEAPF32[i8 + (i19 << 3) + 88 >> 2];
+ d37 = +(d36 * d32 - d33 * d39);
+ d39 = +(d32 * d33 + d36 * d39);
+ i41 = i12 + (i19 << 3) + 64 | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ i19 = i19 + 1 | 0;
+ } while ((i19 | 0) < (HEAP32[i21 >> 2] | 0));
+ }
+ i21 = i12 + 244 | 0;
+ HEAPF32[i21 >> 2] = .019999999552965164;
+ i19 = i2 + 60 | 0;
+ HEAP32[i19 >> 2] = 0;
+ i29 = i12 + 248 | 0;
+ i35 = HEAP32[i34 >> 2] | 0;
+ if ((i35 | 0) <= 0) {
+ STACKTOP = i1;
+ return;
+ }
+ d23 = +HEAPF32[i12 + 164 >> 2];
+ d26 = +HEAPF32[i20 >> 2];
+ d24 = +HEAPF32[i12 + 212 >> 2];
+ d27 = +HEAPF32[i12 + 216 >> 2];
+ d22 = 3.4028234663852886e+38;
+ i20 = 0;
+ do {
+ d25 = d24 * (+HEAPF32[i12 + (i20 << 3) >> 2] - d23) + d27 * (+HEAPF32[i12 + (i20 << 3) + 4 >> 2] - d26);
+ d22 = d25 < d22 ? d25 : d22;
+ i20 = i20 + 1 | 0;
+ } while ((i20 | 0) != (i35 | 0));
+ if (d22 > .019999999552965164) {
+ STACKTOP = i1;
+ return;
+ }
+ __ZN12b2EPCollider24ComputePolygonSeparationEv(i18, i12);
+ i20 = HEAP32[i18 >> 2] | 0;
+ if ((i20 | 0) != 0) {
+ d23 = +HEAPF32[i18 + 8 >> 2];
+ if (d23 > +HEAPF32[i21 >> 2]) {
+ STACKTOP = i1;
+ return;
+ }
+ if (d23 > d22 * .9800000190734863 + .0010000000474974513) {
+ i18 = HEAP32[i18 + 4 >> 2] | 0;
+ i35 = i2 + 56 | 0;
+ if ((i20 | 0) == 1) {
+ i18 = i11;
+ i15 = 77;
+ } else {
+ HEAP32[i35 >> 2] = 2;
+ i40 = i14;
+ i41 = HEAP32[i40 + 4 >> 2] | 0;
+ i38 = i11;
+ HEAP32[i38 >> 2] = HEAP32[i40 >> 2];
+ HEAP32[i38 + 4 >> 2] = i41;
+ i38 = i11 + 8 | 0;
+ HEAP8[i38] = 0;
+ i41 = i18 & 255;
+ HEAP8[i38 + 1 | 0] = i41;
+ HEAP8[i38 + 2 | 0] = 0;
+ HEAP8[i38 + 3 | 0] = 1;
+ i38 = i13;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i13 = i11 + 12 | 0;
+ HEAP32[i13 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i13 + 4 >> 2] = i40;
+ i13 = i11 + 20 | 0;
+ HEAP8[i13] = 0;
+ HEAP8[i13 + 1 | 0] = i41;
+ HEAP8[i13 + 2 | 0] = 0;
+ HEAP8[i13 + 3 | 0] = 1;
+ HEAP32[i9 >> 2] = i18;
+ i13 = i18 + 1 | 0;
+ i16 = (i13 | 0) < (HEAP32[i34 >> 2] | 0) ? i13 : 0;
+ HEAP32[i9 + 4 >> 2] = i16;
+ i17 = i12 + (i18 << 3) | 0;
+ i13 = HEAP32[i17 >> 2] | 0;
+ i17 = HEAP32[i17 + 4 >> 2] | 0;
+ i29 = i9 + 8 | 0;
+ HEAP32[i29 >> 2] = i13;
+ HEAP32[i29 + 4 >> 2] = i17;
+ i16 = i12 + (i16 << 3) | 0;
+ i29 = HEAP32[i16 >> 2] | 0;
+ i16 = HEAP32[i16 + 4 >> 2] | 0;
+ i20 = i9 + 16 | 0;
+ HEAP32[i20 >> 2] = i29;
+ HEAP32[i20 + 4 >> 2] = i16;
+ i20 = i12 + (i18 << 3) + 64 | 0;
+ i12 = HEAP32[i20 >> 2] | 0;
+ i20 = HEAP32[i20 + 4 >> 2] | 0;
+ i14 = i9 + 24 | 0;
+ HEAP32[i14 >> 2] = i12;
+ HEAP32[i14 + 4 >> 2] = i20;
+ i14 = 0;
+ }
+ } else {
+ i15 = 75;
+ }
+ } else {
+ i15 = 75;
+ }
+ if ((i15 | 0) == 75) {
+ i18 = i11;
+ i35 = i2 + 56 | 0;
+ i15 = 77;
+ }
+ do {
+ if ((i15 | 0) == 77) {
+ HEAP32[i35 >> 2] = 1;
+ i15 = HEAP32[i34 >> 2] | 0;
+ if ((i15 | 0) > 1) {
+ d23 = +HEAPF32[i12 + 216 >> 2];
+ d22 = +HEAPF32[i12 + 212 >> 2];
+ i34 = 0;
+ d24 = d22 * +HEAPF32[i12 + 64 >> 2] + d23 * +HEAPF32[i12 + 68 >> 2];
+ i35 = 1;
+ while (1) {
+ d25 = d22 * +HEAPF32[i12 + (i35 << 3) + 64 >> 2] + d23 * +HEAPF32[i12 + (i35 << 3) + 68 >> 2];
+ i20 = d25 < d24;
+ i34 = i20 ? i35 : i34;
+ i35 = i35 + 1 | 0;
+ if ((i35 | 0) < (i15 | 0)) {
+ d24 = i20 ? d25 : d24;
+ } else {
+ break;
+ }
+ }
+ } else {
+ i34 = 0;
+ }
+ i20 = i34 + 1 | 0;
+ i40 = (i20 | 0) < (i15 | 0) ? i20 : 0;
+ i41 = i12 + (i34 << 3) | 0;
+ i38 = HEAP32[i41 + 4 >> 2] | 0;
+ i35 = i11;
+ HEAP32[i35 >> 2] = HEAP32[i41 >> 2];
+ HEAP32[i35 + 4 >> 2] = i38;
+ i35 = i11 + 8 | 0;
+ HEAP8[i35] = 0;
+ HEAP8[i35 + 1 | 0] = i34;
+ HEAP8[i35 + 2 | 0] = 1;
+ HEAP8[i35 + 3 | 0] = 0;
+ i35 = i12 + (i40 << 3) | 0;
+ i38 = HEAP32[i35 + 4 >> 2] | 0;
+ i41 = i11 + 12 | 0;
+ HEAP32[i41 >> 2] = HEAP32[i35 >> 2];
+ HEAP32[i41 + 4 >> 2] = i38;
+ i41 = i11 + 20 | 0;
+ HEAP8[i41] = 0;
+ HEAP8[i41 + 1 | 0] = i40;
+ HEAP8[i41 + 2 | 0] = 1;
+ HEAP8[i41 + 3 | 0] = 0;
+ if ((HEAP8[i29] | 0) == 0) {
+ HEAP32[i9 >> 2] = 1;
+ HEAP32[i9 + 4 >> 2] = 0;
+ i11 = i13;
+ i13 = HEAP32[i11 >> 2] | 0;
+ i11 = HEAP32[i11 + 4 >> 2] | 0;
+ i29 = i9 + 8 | 0;
+ HEAP32[i29 >> 2] = i13;
+ HEAP32[i29 + 4 >> 2] = i11;
+ i29 = HEAP32[i14 >> 2] | 0;
+ i14 = HEAP32[i14 + 4 >> 2] | 0;
+ i12 = i9 + 16 | 0;
+ HEAP32[i12 >> 2] = i29;
+ HEAP32[i12 + 4 >> 2] = i14;
+ i12 = (HEAPF32[tempDoublePtr >> 2] = -+HEAPF32[i16 >> 2], HEAP32[tempDoublePtr >> 2] | 0);
+ i20 = (HEAPF32[tempDoublePtr >> 2] = -+HEAPF32[i17 >> 2], HEAP32[tempDoublePtr >> 2] | 0);
+ i16 = i9 + 24 | 0;
+ HEAP32[i16 >> 2] = i12;
+ HEAP32[i16 + 4 >> 2] = i20;
+ i16 = i14;
+ i17 = i11;
+ i11 = i18;
+ i18 = 1;
+ i14 = 1;
+ break;
+ } else {
+ HEAP32[i9 >> 2] = 0;
+ HEAP32[i9 + 4 >> 2] = 1;
+ i17 = i14;
+ i11 = HEAP32[i17 >> 2] | 0;
+ i17 = HEAP32[i17 + 4 >> 2] | 0;
+ i29 = i9 + 8 | 0;
+ HEAP32[i29 >> 2] = i11;
+ HEAP32[i29 + 4 >> 2] = i17;
+ i29 = HEAP32[i13 >> 2] | 0;
+ i13 = HEAP32[i13 + 4 >> 2] | 0;
+ i20 = i9 + 16 | 0;
+ HEAP32[i20 >> 2] = i29;
+ HEAP32[i20 + 4 >> 2] = i13;
+ i20 = i16;
+ i12 = HEAP32[i20 >> 2] | 0;
+ i20 = HEAP32[i20 + 4 >> 2] | 0;
+ i16 = i9 + 24 | 0;
+ HEAP32[i16 >> 2] = i12;
+ HEAP32[i16 + 4 >> 2] = i20;
+ i16 = i13;
+ i13 = i11;
+ i11 = i18;
+ i18 = 0;
+ i14 = 1;
+ break;
+ }
+ }
+ } while (0);
+ d30 = (HEAP32[tempDoublePtr >> 2] = i20, +HEAPF32[tempDoublePtr >> 2]);
+ d39 = (HEAP32[tempDoublePtr >> 2] = i12, +HEAPF32[tempDoublePtr >> 2]);
+ d31 = (HEAP32[tempDoublePtr >> 2] = i13, +HEAPF32[tempDoublePtr >> 2]);
+ d32 = (HEAP32[tempDoublePtr >> 2] = i17, +HEAPF32[tempDoublePtr >> 2]);
+ d33 = (HEAP32[tempDoublePtr >> 2] = i29, +HEAPF32[tempDoublePtr >> 2]);
+ d37 = (HEAP32[tempDoublePtr >> 2] = i16, +HEAPF32[tempDoublePtr >> 2]);
+ i41 = i9 + 32 | 0;
+ i16 = i9 + 24 | 0;
+ i13 = i9 + 28 | 0;
+ d39 = -d39;
+ HEAPF32[i41 >> 2] = d30;
+ HEAPF32[i9 + 36 >> 2] = d39;
+ i20 = i9 + 44 | 0;
+ d36 = -d30;
+ i17 = i20;
+ HEAPF32[i17 >> 2] = d36;
+ HEAP32[i17 + 4 >> 2] = i12;
+ i17 = i9 + 8 | 0;
+ i15 = i9 + 12 | 0;
+ d39 = d30 * d31 + d32 * d39;
+ HEAPF32[i9 + 40 >> 2] = d39;
+ i29 = i9 + 52 | 0;
+ HEAPF32[i29 >> 2] = d33 * d36 + (HEAP32[tempDoublePtr >> 2] = i12, +HEAPF32[tempDoublePtr >> 2]) * d37;
+ if ((__Z19b2ClipSegmentToLineP12b2ClipVertexPKS_RK6b2Vec2fi(i10, i11, i41, d39, i18) | 0) < 2) {
+ STACKTOP = i1;
+ return;
+ }
+ if ((__Z19b2ClipSegmentToLineP12b2ClipVertexPKS_RK6b2Vec2fi(i3, i10, i20, +HEAPF32[i29 >> 2], HEAP32[i9 + 4 >> 2] | 0) | 0) < 2) {
+ STACKTOP = i1;
+ return;
+ }
+ i10 = i2 + 40 | 0;
+ if (i14) {
+ i40 = i16;
+ i41 = HEAP32[i40 >> 2] | 0;
+ i40 = HEAP32[i40 + 4 >> 2] | 0;
+ i35 = i10;
+ HEAP32[i35 >> 2] = i41;
+ HEAP32[i35 + 4 >> 2] = i40;
+ i35 = i17;
+ i40 = HEAP32[i35 >> 2] | 0;
+ i35 = HEAP32[i35 + 4 >> 2] | 0;
+ i38 = i2 + 48 | 0;
+ HEAP32[i38 >> 2] = i40;
+ HEAP32[i38 + 4 >> 2] = i35;
+ d23 = (HEAP32[tempDoublePtr >> 2] = i40, +HEAPF32[tempDoublePtr >> 2]);
+ d22 = (HEAP32[tempDoublePtr >> 2] = i41, +HEAPF32[tempDoublePtr >> 2]);
+ d24 = +HEAPF32[i15 >> 2];
+ d25 = +HEAPF32[i13 >> 2];
+ d28 = +HEAPF32[i3 >> 2];
+ d27 = +HEAPF32[i3 + 4 >> 2];
+ d26 = +HEAPF32[i21 >> 2];
+ if (!((d28 - d23) * d22 + (d27 - d24) * d25 <= d26)) {
+ d28 = d26;
+ i8 = 0;
+ } else {
+ d37 = d28 - +HEAPF32[i4 >> 2];
+ d36 = d27 - +HEAPF32[i6 >> 2];
+ d33 = +HEAPF32[i5 >> 2];
+ d28 = +HEAPF32[i7 >> 2];
+ d39 = +(d37 * d33 + d36 * d28);
+ d28 = +(d33 * d36 - d37 * d28);
+ i8 = i2;
+ HEAPF32[i8 >> 2] = d39;
+ HEAPF32[i8 + 4 >> 2] = d28;
+ HEAP32[i2 + 16 >> 2] = HEAP32[i3 + 8 >> 2];
+ d28 = +HEAPF32[i21 >> 2];
+ i8 = 1;
+ }
+ d26 = +HEAPF32[i3 + 12 >> 2];
+ d27 = +HEAPF32[i3 + 16 >> 2];
+ if ((d26 - d23) * d22 + (d27 - d24) * d25 <= d28) {
+ d36 = d26 - +HEAPF32[i4 >> 2];
+ d33 = d27 - +HEAPF32[i6 >> 2];
+ d32 = +HEAPF32[i5 >> 2];
+ d39 = +HEAPF32[i7 >> 2];
+ d37 = +(d36 * d32 + d33 * d39);
+ d39 = +(d32 * d33 - d36 * d39);
+ i41 = i2 + (i8 * 20 | 0) | 0;
+ HEAPF32[i41 >> 2] = d37;
+ HEAPF32[i41 + 4 >> 2] = d39;
+ HEAP32[i2 + (i8 * 20 | 0) + 16 >> 2] = HEAP32[i3 + 20 >> 2];
+ i8 = i8 + 1 | 0;
+ }
+ } else {
+ i38 = HEAP32[i9 >> 2] | 0;
+ i35 = i8 + (i38 << 3) + 84 | 0;
+ i41 = HEAP32[i35 + 4 >> 2] | 0;
+ i40 = i10;
+ HEAP32[i40 >> 2] = HEAP32[i35 >> 2];
+ HEAP32[i40 + 4 >> 2] = i41;
+ i38 = i8 + (i38 << 3) + 20 | 0;
+ i40 = HEAP32[i38 + 4 >> 2] | 0;
+ i41 = i2 + 48 | 0;
+ HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i41 + 4 >> 2] = i40;
+ d22 = +HEAPF32[i17 >> 2];
+ d23 = +HEAPF32[i16 >> 2];
+ d24 = +HEAPF32[i15 >> 2];
+ d25 = +HEAPF32[i13 >> 2];
+ d26 = +HEAPF32[i21 >> 2];
+ if (!((+HEAPF32[i3 >> 2] - d22) * d23 + (+HEAPF32[i3 + 4 >> 2] - d24) * d25 <= d26)) {
+ i8 = 0;
+ } else {
+ i40 = i3;
+ i8 = HEAP32[i40 + 4 >> 2] | 0;
+ i41 = i2;
+ HEAP32[i41 >> 2] = HEAP32[i40 >> 2];
+ HEAP32[i41 + 4 >> 2] = i8;
+ i41 = i3 + 8 | 0;
+ i8 = i2 + 16 | 0;
+ HEAP8[i8 + 2 | 0] = HEAP8[i41 + 3 | 0] | 0;
+ HEAP8[i8 + 3 | 0] = HEAP8[i41 + 2 | 0] | 0;
+ HEAP8[i8] = HEAP8[i41 + 1 | 0] | 0;
+ HEAP8[i8 + 1 | 0] = HEAP8[i41] | 0;
+ d26 = +HEAPF32[i21 >> 2];
+ i8 = 1;
+ }
+ i4 = i3 + 12 | 0;
+ if ((+HEAPF32[i4 >> 2] - d22) * d23 + (+HEAPF32[i3 + 16 >> 2] - d24) * d25 <= d26) {
+ i38 = i4;
+ i41 = HEAP32[i38 + 4 >> 2] | 0;
+ i40 = i2 + (i8 * 20 | 0) | 0;
+ HEAP32[i40 >> 2] = HEAP32[i38 >> 2];
+ HEAP32[i40 + 4 >> 2] = i41;
+ i40 = i3 + 20 | 0;
+ i41 = i2 + (i8 * 20 | 0) + 16 | 0;
+ HEAP8[i41 + 2 | 0] = HEAP8[i40 + 3 | 0] | 0;
+ HEAP8[i41 + 3 | 0] = HEAP8[i40 + 2 | 0] | 0;
+ HEAP8[i41] = HEAP8[i40 + 1 | 0] | 0;
+ HEAP8[i41 + 1 | 0] = HEAP8[i40] | 0;
+ i8 = i8 + 1 | 0;
+ }
+ }
+ HEAP32[i19 >> 2] = i8;
+ STACKTOP = i1;
+ return;
+}
+function __ZN7b2World8SolveTOIERK10b2TimeStep(i30, i11) {
+ i30 = i30 | 0;
+ i11 = i11 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0, i37 = 0, i38 = 0, i39 = 0, i40 = 0, i41 = 0, d42 = 0.0, i43 = 0, i44 = 0, i45 = 0, i46 = 0, i47 = 0, i48 = 0, i49 = 0, i50 = 0, i51 = 0, i52 = 0, i53 = 0, i54 = 0, i55 = 0, i56 = 0, i57 = 0, i58 = 0, i59 = 0, i60 = 0, i61 = 0, i62 = 0, i63 = 0, i64 = 0, i65 = 0, i66 = 0, d67 = 0.0, d68 = 0.0, d69 = 0.0, d70 = 0.0, d71 = 0.0, d72 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 336 | 0;
+ i3 = i1 + 284 | 0;
+ i6 = i1 + 152 | 0;
+ i5 = i1 + 144 | 0;
+ i4 = i1 + 108 | 0;
+ i8 = i1 + 72 | 0;
+ i7 = i1 + 64 | 0;
+ i14 = i1 + 24 | 0;
+ i9 = i1;
+ i10 = i30 + 102872 | 0;
+ i13 = i30 + 102944 | 0;
+ __ZN8b2IslandC2EiiiP16b2StackAllocatorP17b2ContactListener(i3, 64, 32, 0, i30 + 68 | 0, HEAP32[i13 >> 2] | 0);
+ i2 = i30 + 102995 | 0;
+ if ((HEAP8[i2] | 0) != 0) {
+ i15 = HEAP32[i30 + 102952 >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ do {
+ i66 = i15 + 4 | 0;
+ HEAP16[i66 >> 1] = HEAP16[i66 >> 1] & 65534;
+ HEAPF32[i15 + 60 >> 2] = 0.0;
+ i15 = HEAP32[i15 + 96 >> 2] | 0;
+ } while ((i15 | 0) != 0);
+ }
+ i15 = i30 + 102932 | 0;
+ i16 = HEAP32[i15 >> 2] | 0;
+ if ((i16 | 0) != 0) {
+ do {
+ i66 = i16 + 4 | 0;
+ HEAP32[i66 >> 2] = HEAP32[i66 >> 2] & -34;
+ HEAP32[i16 + 128 >> 2] = 0;
+ HEAPF32[i16 + 132 >> 2] = 1.0;
+ i16 = HEAP32[i16 + 12 >> 2] | 0;
+ } while ((i16 | 0) != 0);
+ }
+ } else {
+ i15 = i30 + 102932 | 0;
+ }
+ i25 = i3 + 28 | 0;
+ i26 = i3 + 36 | 0;
+ i27 = i3 + 32 | 0;
+ i28 = i3 + 40 | 0;
+ i29 = i3 + 8 | 0;
+ i24 = i3 + 44 | 0;
+ i23 = i3 + 12 | 0;
+ i22 = i7 + 4 | 0;
+ i21 = i9 + 4 | 0;
+ i20 = i9 + 8 | 0;
+ i19 = i9 + 16 | 0;
+ i18 = i11 + 12 | 0;
+ i17 = i9 + 12 | 0;
+ i16 = i9 + 20 | 0;
+ i39 = i30 + 102994 | 0;
+ i37 = i6 + 16 | 0;
+ i36 = i6 + 20 | 0;
+ i35 = i6 + 24 | 0;
+ i34 = i6 + 44 | 0;
+ i33 = i6 + 48 | 0;
+ i32 = i6 + 52 | 0;
+ i41 = i6 + 28 | 0;
+ i31 = i6 + 56 | 0;
+ i40 = i6 + 92 | 0;
+ i30 = i6 + 128 | 0;
+ i38 = i5 + 4 | 0;
+ L11 : while (1) {
+ i47 = HEAP32[i15 >> 2] | 0;
+ if ((i47 | 0) == 0) {
+ i4 = 36;
+ break;
+ } else {
+ d42 = 1.0;
+ i44 = 0;
+ }
+ do {
+ i48 = i47 + 4 | 0;
+ i43 = HEAP32[i48 >> 2] | 0;
+ do {
+ if ((i43 & 4 | 0) != 0 ? (HEAP32[i47 + 128 >> 2] | 0) <= 8 : 0) {
+ if ((i43 & 32 | 0) == 0) {
+ i43 = HEAP32[i47 + 48 >> 2] | 0;
+ i45 = HEAP32[i47 + 52 >> 2] | 0;
+ if ((HEAP8[i43 + 38 | 0] | 0) != 0) {
+ break;
+ }
+ if ((HEAP8[i45 + 38 | 0] | 0) != 0) {
+ break;
+ }
+ i46 = HEAP32[i43 + 8 >> 2] | 0;
+ i50 = HEAP32[i45 + 8 >> 2] | 0;
+ i53 = HEAP32[i46 >> 2] | 0;
+ i52 = HEAP32[i50 >> 2] | 0;
+ if (!((i53 | 0) == 2 | (i52 | 0) == 2)) {
+ i4 = 16;
+ break L11;
+ }
+ i51 = HEAP16[i46 + 4 >> 1] | 0;
+ i49 = HEAP16[i50 + 4 >> 1] | 0;
+ if (!((i51 & 2) != 0 & (i53 | 0) != 0 | (i49 & 2) != 0 & (i52 | 0) != 0)) {
+ break;
+ }
+ if (!((i51 & 8) != 0 | (i53 | 0) != 2 | ((i49 & 8) != 0 | (i52 | 0) != 2))) {
+ break;
+ }
+ i51 = i46 + 28 | 0;
+ i52 = i46 + 60 | 0;
+ d68 = +HEAPF32[i52 >> 2];
+ i49 = i50 + 28 | 0;
+ i53 = i50 + 60 | 0;
+ d67 = +HEAPF32[i53 >> 2];
+ if (!(d68 < d67)) {
+ if (d67 < d68) {
+ if (!(d67 < 1.0)) {
+ i4 = 25;
+ break L11;
+ }
+ d67 = (d68 - d67) / (1.0 - d67);
+ i66 = i50 + 36 | 0;
+ d69 = 1.0 - d67;
+ d71 = +(+HEAPF32[i66 >> 2] * d69 + d67 * +HEAPF32[i50 + 44 >> 2]);
+ d70 = +(d69 * +HEAPF32[i50 + 40 >> 2] + d67 * +HEAPF32[i50 + 48 >> 2]);
+ HEAPF32[i66 >> 2] = d71;
+ HEAPF32[i66 + 4 >> 2] = d70;
+ i66 = i50 + 52 | 0;
+ HEAPF32[i66 >> 2] = d69 * +HEAPF32[i66 >> 2] + d67 * +HEAPF32[i50 + 56 >> 2];
+ HEAPF32[i53 >> 2] = d68;
+ d67 = d68;
+ } else {
+ d67 = d68;
+ }
+ } else {
+ if (!(d68 < 1.0)) {
+ i4 = 21;
+ break L11;
+ }
+ d71 = (d67 - d68) / (1.0 - d68);
+ i66 = i46 + 36 | 0;
+ d70 = 1.0 - d71;
+ d68 = +(+HEAPF32[i66 >> 2] * d70 + d71 * +HEAPF32[i46 + 44 >> 2]);
+ d69 = +(d70 * +HEAPF32[i46 + 40 >> 2] + d71 * +HEAPF32[i46 + 48 >> 2]);
+ HEAPF32[i66 >> 2] = d68;
+ HEAPF32[i66 + 4 >> 2] = d69;
+ i66 = i46 + 52 | 0;
+ HEAPF32[i66 >> 2] = d70 * +HEAPF32[i66 >> 2] + d71 * +HEAPF32[i46 + 56 >> 2];
+ HEAPF32[i52 >> 2] = d67;
+ }
+ if (!(d67 < 1.0)) {
+ i4 = 28;
+ break L11;
+ }
+ i66 = HEAP32[i47 + 56 >> 2] | 0;
+ i46 = HEAP32[i47 + 60 >> 2] | 0;
+ HEAP32[i37 >> 2] = 0;
+ HEAP32[i36 >> 2] = 0;
+ HEAPF32[i35 >> 2] = 0.0;
+ HEAP32[i34 >> 2] = 0;
+ HEAP32[i33 >> 2] = 0;
+ HEAPF32[i32 >> 2] = 0.0;
+ __ZN15b2DistanceProxy3SetEPK7b2Shapei(i6, HEAP32[i43 + 12 >> 2] | 0, i66);
+ __ZN15b2DistanceProxy3SetEPK7b2Shapei(i41, HEAP32[i45 + 12 >> 2] | 0, i46);
+ i43 = i31 + 0 | 0;
+ i45 = i51 + 0 | 0;
+ i46 = i43 + 36 | 0;
+ do {
+ HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
+ i43 = i43 + 4 | 0;
+ i45 = i45 + 4 | 0;
+ } while ((i43 | 0) < (i46 | 0));
+ i43 = i40 + 0 | 0;
+ i45 = i49 + 0 | 0;
+ i46 = i43 + 36 | 0;
+ do {
+ HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
+ i43 = i43 + 4 | 0;
+ i45 = i45 + 4 | 0;
+ } while ((i43 | 0) < (i46 | 0));
+ HEAPF32[i30 >> 2] = 1.0;
+ __Z14b2TimeOfImpactP11b2TOIOutputPK10b2TOIInput(i5, i6);
+ if ((HEAP32[i5 >> 2] | 0) == 3) {
+ d67 = d67 + (1.0 - d67) * +HEAPF32[i38 >> 2];
+ d67 = d67 < 1.0 ? d67 : 1.0;
+ } else {
+ d67 = 1.0;
+ }
+ HEAPF32[i47 + 132 >> 2] = d67;
+ HEAP32[i48 >> 2] = HEAP32[i48 >> 2] | 32;
+ } else {
+ d67 = +HEAPF32[i47 + 132 >> 2];
+ }
+ if (d67 < d42) {
+ d42 = d67;
+ i44 = i47;
+ }
+ }
+ } while (0);
+ i47 = HEAP32[i47 + 12 >> 2] | 0;
+ } while ((i47 | 0) != 0);
+ if ((i44 | 0) == 0 | d42 > .9999988079071045) {
+ i4 = 36;
+ break;
+ }
+ i47 = HEAP32[(HEAP32[i44 + 48 >> 2] | 0) + 8 >> 2] | 0;
+ i48 = HEAP32[(HEAP32[i44 + 52 >> 2] | 0) + 8 >> 2] | 0;
+ i49 = i47 + 28 | 0;
+ i43 = i4 + 0 | 0;
+ i45 = i49 + 0 | 0;
+ i46 = i43 + 36 | 0;
+ do {
+ HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
+ i43 = i43 + 4 | 0;
+ i45 = i45 + 4 | 0;
+ } while ((i43 | 0) < (i46 | 0));
+ i50 = i48 + 28 | 0;
+ i43 = i8 + 0 | 0;
+ i45 = i50 + 0 | 0;
+ i46 = i43 + 36 | 0;
+ do {
+ HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
+ i43 = i43 + 4 | 0;
+ i45 = i45 + 4 | 0;
+ } while ((i43 | 0) < (i46 | 0));
+ i43 = i47 + 60 | 0;
+ d67 = +HEAPF32[i43 >> 2];
+ if (!(d67 < 1.0)) {
+ i4 = 38;
+ break;
+ }
+ d70 = (d42 - d67) / (1.0 - d67);
+ i57 = i47 + 36 | 0;
+ d67 = 1.0 - d70;
+ i52 = i47 + 44 | 0;
+ i53 = i47 + 48 | 0;
+ d71 = +HEAPF32[i57 >> 2] * d67 + d70 * +HEAPF32[i52 >> 2];
+ d72 = d67 * +HEAPF32[i47 + 40 >> 2] + d70 * +HEAPF32[i53 >> 2];
+ d69 = +d71;
+ d68 = +d72;
+ HEAPF32[i57 >> 2] = d69;
+ HEAPF32[i57 + 4 >> 2] = d68;
+ i57 = i47 + 52 | 0;
+ i51 = i47 + 56 | 0;
+ d70 = d67 * +HEAPF32[i57 >> 2] + d70 * +HEAPF32[i51 >> 2];
+ HEAPF32[i57 >> 2] = d70;
+ HEAPF32[i43 >> 2] = d42;
+ i57 = i47 + 44 | 0;
+ HEAPF32[i57 >> 2] = d69;
+ HEAPF32[i57 + 4 >> 2] = d68;
+ HEAPF32[i51 >> 2] = d70;
+ d68 = +Math_sin(+d70);
+ i57 = i47 + 20 | 0;
+ HEAPF32[i57 >> 2] = d68;
+ d70 = +Math_cos(+d70);
+ i56 = i47 + 24 | 0;
+ HEAPF32[i56 >> 2] = d70;
+ i58 = i47 + 12 | 0;
+ i55 = i47 + 28 | 0;
+ d69 = +HEAPF32[i55 >> 2];
+ i54 = i47 + 32 | 0;
+ d67 = +HEAPF32[i54 >> 2];
+ d71 = +(d71 - (d70 * d69 - d68 * d67));
+ d67 = +(d72 - (d68 * d69 + d70 * d67));
+ i43 = i58;
+ HEAPF32[i43 >> 2] = d71;
+ HEAPF32[i43 + 4 >> 2] = d67;
+ i43 = i48 + 60 | 0;
+ d67 = +HEAPF32[i43 >> 2];
+ if (!(d67 < 1.0)) {
+ i4 = 40;
+ break;
+ }
+ d70 = (d42 - d67) / (1.0 - d67);
+ i64 = i48 + 36 | 0;
+ d72 = 1.0 - d70;
+ i61 = i48 + 44 | 0;
+ i60 = i48 + 48 | 0;
+ d71 = +HEAPF32[i64 >> 2] * d72 + d70 * +HEAPF32[i61 >> 2];
+ d67 = d72 * +HEAPF32[i48 + 40 >> 2] + d70 * +HEAPF32[i60 >> 2];
+ d69 = +d71;
+ d68 = +d67;
+ HEAPF32[i64 >> 2] = d69;
+ HEAPF32[i64 + 4 >> 2] = d68;
+ i64 = i48 + 52 | 0;
+ i59 = i48 + 56 | 0;
+ d70 = d72 * +HEAPF32[i64 >> 2] + d70 * +HEAPF32[i59 >> 2];
+ HEAPF32[i64 >> 2] = d70;
+ HEAPF32[i43 >> 2] = d42;
+ i64 = i48 + 44 | 0;
+ HEAPF32[i64 >> 2] = d69;
+ HEAPF32[i64 + 4 >> 2] = d68;
+ HEAPF32[i59 >> 2] = d70;
+ d68 = +Math_sin(+d70);
+ i64 = i48 + 20 | 0;
+ HEAPF32[i64 >> 2] = d68;
+ d70 = +Math_cos(+d70);
+ i63 = i48 + 24 | 0;
+ HEAPF32[i63 >> 2] = d70;
+ i65 = i48 + 12 | 0;
+ i62 = i48 + 28 | 0;
+ d69 = +HEAPF32[i62 >> 2];
+ i66 = i48 + 32 | 0;
+ d72 = +HEAPF32[i66 >> 2];
+ d71 = +(d71 - (d70 * d69 - d68 * d72));
+ d72 = +(d67 - (d68 * d69 + d70 * d72));
+ i43 = i65;
+ HEAPF32[i43 >> 2] = d71;
+ HEAPF32[i43 + 4 >> 2] = d72;
+ __ZN9b2Contact6UpdateEP17b2ContactListener(i44, HEAP32[i13 >> 2] | 0);
+ i43 = i44 + 4 | 0;
+ i45 = HEAP32[i43 >> 2] | 0;
+ HEAP32[i43 >> 2] = i45 & -33;
+ i46 = i44 + 128 | 0;
+ HEAP32[i46 >> 2] = (HEAP32[i46 >> 2] | 0) + 1;
+ if ((i45 & 6 | 0) != 6) {
+ HEAP32[i43 >> 2] = i45 & -37;
+ i43 = i49 + 0 | 0;
+ i45 = i4 + 0 | 0;
+ i46 = i43 + 36 | 0;
+ do {
+ HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
+ i43 = i43 + 4 | 0;
+ i45 = i45 + 4 | 0;
+ } while ((i43 | 0) < (i46 | 0));
+ i43 = i50 + 0 | 0;
+ i45 = i8 + 0 | 0;
+ i46 = i43 + 36 | 0;
+ do {
+ HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
+ i43 = i43 + 4 | 0;
+ i45 = i45 + 4 | 0;
+ } while ((i43 | 0) < (i46 | 0));
+ d69 = +HEAPF32[i51 >> 2];
+ d71 = +Math_sin(+d69);
+ HEAPF32[i57 >> 2] = d71;
+ d69 = +Math_cos(+d69);
+ HEAPF32[i56 >> 2] = d69;
+ d72 = +HEAPF32[i55 >> 2];
+ d70 = +HEAPF32[i54 >> 2];
+ d68 = +(+HEAPF32[i52 >> 2] - (d69 * d72 - d71 * d70));
+ d70 = +(+HEAPF32[i53 >> 2] - (d71 * d72 + d69 * d70));
+ HEAPF32[i58 >> 2] = d68;
+ HEAPF32[i58 + 4 >> 2] = d70;
+ d70 = +HEAPF32[i59 >> 2];
+ d68 = +Math_sin(+d70);
+ HEAPF32[i64 >> 2] = d68;
+ d70 = +Math_cos(+d70);
+ HEAPF32[i63 >> 2] = d70;
+ d69 = +HEAPF32[i62 >> 2];
+ d72 = +HEAPF32[i66 >> 2];
+ d71 = +(+HEAPF32[i61 >> 2] - (d70 * d69 - d68 * d72));
+ d72 = +(+HEAPF32[i60 >> 2] - (d68 * d69 + d70 * d72));
+ i66 = i65;
+ HEAPF32[i66 >> 2] = d71;
+ HEAPF32[i66 + 4 >> 2] = d72;
+ continue;
+ }
+ i45 = i47 + 4 | 0;
+ i46 = HEAPU16[i45 >> 1] | 0;
+ if ((i46 & 2 | 0) == 0) {
+ HEAP16[i45 >> 1] = i46 | 2;
+ HEAPF32[i47 + 144 >> 2] = 0.0;
+ }
+ i46 = i48 + 4 | 0;
+ i49 = HEAPU16[i46 >> 1] | 0;
+ if ((i49 & 2 | 0) == 0) {
+ HEAP16[i46 >> 1] = i49 | 2;
+ HEAPF32[i48 + 144 >> 2] = 0.0;
+ }
+ HEAP32[i25 >> 2] = 0;
+ HEAP32[i26 >> 2] = 0;
+ HEAP32[i27 >> 2] = 0;
+ if ((HEAP32[i28 >> 2] | 0) <= 0) {
+ i4 = 48;
+ break;
+ }
+ i49 = i47 + 8 | 0;
+ HEAP32[i49 >> 2] = 0;
+ i51 = HEAP32[i25 >> 2] | 0;
+ HEAP32[(HEAP32[i29 >> 2] | 0) + (i51 << 2) >> 2] = i47;
+ i51 = i51 + 1 | 0;
+ HEAP32[i25 >> 2] = i51;
+ if ((i51 | 0) >= (HEAP32[i28 >> 2] | 0)) {
+ i4 = 50;
+ break;
+ }
+ i50 = i48 + 8 | 0;
+ HEAP32[i50 >> 2] = i51;
+ i51 = HEAP32[i25 >> 2] | 0;
+ HEAP32[(HEAP32[i29 >> 2] | 0) + (i51 << 2) >> 2] = i48;
+ HEAP32[i25 >> 2] = i51 + 1;
+ i51 = HEAP32[i26 >> 2] | 0;
+ if ((i51 | 0) >= (HEAP32[i24 >> 2] | 0)) {
+ i4 = 52;
+ break;
+ }
+ HEAP32[i26 >> 2] = i51 + 1;
+ HEAP32[(HEAP32[i23 >> 2] | 0) + (i51 << 2) >> 2] = i44;
+ HEAP16[i45 >> 1] = HEAPU16[i45 >> 1] | 1;
+ HEAP16[i46 >> 1] = HEAPU16[i46 >> 1] | 1;
+ HEAP32[i43 >> 2] = HEAP32[i43 >> 2] | 1;
+ HEAP32[i7 >> 2] = i47;
+ HEAP32[i22 >> 2] = i48;
+ i44 = 1;
+ while (1) {
+ L58 : do {
+ if ((HEAP32[i47 >> 2] | 0) == 2 ? (i12 = HEAP32[i47 + 112 >> 2] | 0, (i12 | 0) != 0) : 0) {
+ i47 = i47 + 4 | 0;
+ i51 = i12;
+ do {
+ if ((HEAP32[i25 >> 2] | 0) == (HEAP32[i28 >> 2] | 0)) {
+ break L58;
+ }
+ if ((HEAP32[i26 >> 2] | 0) == (HEAP32[i24 >> 2] | 0)) {
+ break L58;
+ }
+ i52 = HEAP32[i51 + 4 >> 2] | 0;
+ i53 = i52 + 4 | 0;
+ do {
+ if ((HEAP32[i53 >> 2] & 1 | 0) == 0) {
+ i48 = HEAP32[i51 >> 2] | 0;
+ if (((HEAP32[i48 >> 2] | 0) == 2 ? (HEAP16[i47 >> 1] & 8) == 0 : 0) ? (HEAP16[i48 + 4 >> 1] & 8) == 0 : 0) {
+ break;
+ }
+ if ((HEAP8[(HEAP32[i52 + 48 >> 2] | 0) + 38 | 0] | 0) == 0 ? (HEAP8[(HEAP32[i52 + 52 >> 2] | 0) + 38 | 0] | 0) == 0 : 0) {
+ i54 = i48 + 28 | 0;
+ i43 = i14 + 0 | 0;
+ i45 = i54 + 0 | 0;
+ i46 = i43 + 36 | 0;
+ do {
+ HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
+ i43 = i43 + 4 | 0;
+ i45 = i45 + 4 | 0;
+ } while ((i43 | 0) < (i46 | 0));
+ i43 = i48 + 4 | 0;
+ if ((HEAP16[i43 >> 1] & 1) == 0) {
+ i45 = i48 + 60 | 0;
+ d67 = +HEAPF32[i45 >> 2];
+ if (!(d67 < 1.0)) {
+ i4 = 67;
+ break L11;
+ }
+ d70 = (d42 - d67) / (1.0 - d67);
+ i65 = i48 + 36 | 0;
+ d72 = 1.0 - d70;
+ d71 = +HEAPF32[i65 >> 2] * d72 + d70 * +HEAPF32[i48 + 44 >> 2];
+ d67 = d72 * +HEAPF32[i48 + 40 >> 2] + d70 * +HEAPF32[i48 + 48 >> 2];
+ d69 = +d71;
+ d68 = +d67;
+ HEAPF32[i65 >> 2] = d69;
+ HEAPF32[i65 + 4 >> 2] = d68;
+ i65 = i48 + 52 | 0;
+ i66 = i48 + 56 | 0;
+ d70 = d72 * +HEAPF32[i65 >> 2] + d70 * +HEAPF32[i66 >> 2];
+ HEAPF32[i65 >> 2] = d70;
+ HEAPF32[i45 >> 2] = d42;
+ i65 = i48 + 44 | 0;
+ HEAPF32[i65 >> 2] = d69;
+ HEAPF32[i65 + 4 >> 2] = d68;
+ HEAPF32[i66 >> 2] = d70;
+ d68 = +Math_sin(+d70);
+ HEAPF32[i48 + 20 >> 2] = d68;
+ d70 = +Math_cos(+d70);
+ HEAPF32[i48 + 24 >> 2] = d70;
+ d69 = +HEAPF32[i48 + 28 >> 2];
+ d72 = +HEAPF32[i48 + 32 >> 2];
+ d71 = +(d71 - (d70 * d69 - d68 * d72));
+ d72 = +(d67 - (d68 * d69 + d70 * d72));
+ i66 = i48 + 12 | 0;
+ HEAPF32[i66 >> 2] = d71;
+ HEAPF32[i66 + 4 >> 2] = d72;
+ }
+ __ZN9b2Contact6UpdateEP17b2ContactListener(i52, HEAP32[i13 >> 2] | 0);
+ i45 = HEAP32[i53 >> 2] | 0;
+ if ((i45 & 4 | 0) == 0) {
+ i43 = i54 + 0 | 0;
+ i45 = i14 + 0 | 0;
+ i46 = i43 + 36 | 0;
+ do {
+ HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
+ i43 = i43 + 4 | 0;
+ i45 = i45 + 4 | 0;
+ } while ((i43 | 0) < (i46 | 0));
+ d70 = +HEAPF32[i48 + 56 >> 2];
+ d68 = +Math_sin(+d70);
+ HEAPF32[i48 + 20 >> 2] = d68;
+ d70 = +Math_cos(+d70);
+ HEAPF32[i48 + 24 >> 2] = d70;
+ d69 = +HEAPF32[i48 + 28 >> 2];
+ d72 = +HEAPF32[i48 + 32 >> 2];
+ d71 = +(+HEAPF32[i48 + 44 >> 2] - (d70 * d69 - d68 * d72));
+ d72 = +(+HEAPF32[i48 + 48 >> 2] - (d68 * d69 + d70 * d72));
+ i66 = i48 + 12 | 0;
+ HEAPF32[i66 >> 2] = d71;
+ HEAPF32[i66 + 4 >> 2] = d72;
+ break;
+ }
+ if ((i45 & 2 | 0) == 0) {
+ i43 = i54 + 0 | 0;
+ i45 = i14 + 0 | 0;
+ i46 = i43 + 36 | 0;
+ do {
+ HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
+ i43 = i43 + 4 | 0;
+ i45 = i45 + 4 | 0;
+ } while ((i43 | 0) < (i46 | 0));
+ d70 = +HEAPF32[i48 + 56 >> 2];
+ d68 = +Math_sin(+d70);
+ HEAPF32[i48 + 20 >> 2] = d68;
+ d70 = +Math_cos(+d70);
+ HEAPF32[i48 + 24 >> 2] = d70;
+ d69 = +HEAPF32[i48 + 28 >> 2];
+ d72 = +HEAPF32[i48 + 32 >> 2];
+ d71 = +(+HEAPF32[i48 + 44 >> 2] - (d70 * d69 - d68 * d72));
+ d72 = +(+HEAPF32[i48 + 48 >> 2] - (d68 * d69 + d70 * d72));
+ i66 = i48 + 12 | 0;
+ HEAPF32[i66 >> 2] = d71;
+ HEAPF32[i66 + 4 >> 2] = d72;
+ break;
+ }
+ HEAP32[i53 >> 2] = i45 | 1;
+ i45 = HEAP32[i26 >> 2] | 0;
+ if ((i45 | 0) >= (HEAP32[i24 >> 2] | 0)) {
+ i4 = 74;
+ break L11;
+ }
+ HEAP32[i26 >> 2] = i45 + 1;
+ HEAP32[(HEAP32[i23 >> 2] | 0) + (i45 << 2) >> 2] = i52;
+ i45 = HEAPU16[i43 >> 1] | 0;
+ if ((i45 & 1 | 0) == 0) {
+ HEAP16[i43 >> 1] = i45 | 1;
+ if ((HEAP32[i48 >> 2] | 0) != 0 ? (i45 & 2 | 0) == 0 : 0) {
+ HEAP16[i43 >> 1] = i45 | 3;
+ HEAPF32[i48 + 144 >> 2] = 0.0;
+ }
+ i43 = HEAP32[i25 >> 2] | 0;
+ if ((i43 | 0) >= (HEAP32[i28 >> 2] | 0)) {
+ i4 = 80;
+ break L11;
+ }
+ HEAP32[i48 + 8 >> 2] = i43;
+ i66 = HEAP32[i25 >> 2] | 0;
+ HEAP32[(HEAP32[i29 >> 2] | 0) + (i66 << 2) >> 2] = i48;
+ HEAP32[i25 >> 2] = i66 + 1;
+ }
+ }
+ }
+ } while (0);
+ i51 = HEAP32[i51 + 12 >> 2] | 0;
+ } while ((i51 | 0) != 0);
+ }
+ } while (0);
+ if ((i44 | 0) >= 2) {
+ break;
+ }
+ i47 = HEAP32[i7 + (i44 << 2) >> 2] | 0;
+ i44 = i44 + 1 | 0;
+ }
+ d72 = (1.0 - d42) * +HEAPF32[i11 >> 2];
+ HEAPF32[i9 >> 2] = d72;
+ HEAPF32[i21 >> 2] = 1.0 / d72;
+ HEAPF32[i20 >> 2] = 1.0;
+ HEAP32[i19 >> 2] = 20;
+ HEAP32[i17 >> 2] = HEAP32[i18 >> 2];
+ HEAP8[i16] = 0;
+ __ZN8b2Island8SolveTOIERK10b2TimeStepii(i3, i9, HEAP32[i49 >> 2] | 0, HEAP32[i50 >> 2] | 0);
+ i44 = HEAP32[i25 >> 2] | 0;
+ if ((i44 | 0) > 0) {
+ i43 = 0;
+ do {
+ i45 = HEAP32[(HEAP32[i29 >> 2] | 0) + (i43 << 2) >> 2] | 0;
+ i66 = i45 + 4 | 0;
+ HEAP16[i66 >> 1] = HEAP16[i66 >> 1] & 65534;
+ if ((HEAP32[i45 >> 2] | 0) == 2) {
+ __ZN6b2Body19SynchronizeFixturesEv(i45);
+ i44 = HEAP32[i45 + 112 >> 2] | 0;
+ if ((i44 | 0) != 0) {
+ do {
+ i66 = (HEAP32[i44 + 4 >> 2] | 0) + 4 | 0;
+ HEAP32[i66 >> 2] = HEAP32[i66 >> 2] & -34;
+ i44 = HEAP32[i44 + 12 >> 2] | 0;
+ } while ((i44 | 0) != 0);
+ }
+ i44 = HEAP32[i25 >> 2] | 0;
+ }
+ i43 = i43 + 1 | 0;
+ } while ((i43 | 0) < (i44 | 0));
+ }
+ __ZN16b2ContactManager15FindNewContactsEv(i10);
+ if ((HEAP8[i39] | 0) != 0) {
+ i4 = 92;
+ break;
+ }
+ }
+ if ((i4 | 0) == 16) {
+ ___assert_fail(2288, 2184, 641, 2344);
+ } else if ((i4 | 0) == 21) {
+ ___assert_fail(2360, 2376, 723, 2400);
+ } else if ((i4 | 0) == 25) {
+ ___assert_fail(2360, 2376, 723, 2400);
+ } else if ((i4 | 0) == 28) {
+ ___assert_fail(2360, 2184, 676, 2344);
+ } else if ((i4 | 0) == 36) {
+ HEAP8[i2] = 1;
+ __ZN8b2IslandD2Ev(i3);
+ STACKTOP = i1;
+ return;
+ } else if ((i4 | 0) == 38) {
+ ___assert_fail(2360, 2376, 723, 2400);
+ } else if ((i4 | 0) == 40) {
+ ___assert_fail(2360, 2376, 723, 2400);
+ } else if ((i4 | 0) == 48) {
+ ___assert_fail(2520, 2440, 54, 2472);
+ } else if ((i4 | 0) == 50) {
+ ___assert_fail(2520, 2440, 54, 2472);
+ } else if ((i4 | 0) == 52) {
+ ___assert_fail(2480, 2440, 62, 2472);
+ } else if ((i4 | 0) == 67) {
+ ___assert_fail(2360, 2376, 723, 2400);
+ } else if ((i4 | 0) == 74) {
+ ___assert_fail(2480, 2440, 62, 2472);
+ } else if ((i4 | 0) == 80) {
+ ___assert_fail(2520, 2440, 54, 2472);
+ } else if ((i4 | 0) == 92) {
+ HEAP8[i2] = 0;
+ __ZN8b2IslandD2Ev(i3);
+ STACKTOP = i1;
+ return;
+ }
+}
+function __ZNSt3__16__sortIRPFbRK6b2PairS3_EPS1_EEvT0_S8_T_(i5, i8, i1) {
+ i5 = i5 | 0;
+ i8 = i8 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i3;
+ L1 : while (1) {
+ i7 = i8;
+ i4 = i8 + -12 | 0;
+ L3 : while (1) {
+ i9 = i5;
+ i11 = i7 - i9 | 0;
+ switch ((i11 | 0) / 12 | 0 | 0) {
+ case 4:
+ {
+ i6 = 14;
+ break L1;
+ }
+ case 2:
+ {
+ i6 = 4;
+ break L1;
+ }
+ case 3:
+ {
+ i6 = 6;
+ break L1;
+ }
+ case 5:
+ {
+ i6 = 15;
+ break L1;
+ }
+ case 1:
+ case 0:
+ {
+ i6 = 67;
+ break L1;
+ }
+ default:
+ {}
+ }
+ if ((i11 | 0) < 372) {
+ i6 = 21;
+ break L1;
+ }
+ i12 = (i11 | 0) / 24 | 0;
+ i10 = i5 + (i12 * 12 | 0) | 0;
+ do {
+ if ((i11 | 0) > 11988) {
+ i14 = (i11 | 0) / 48 | 0;
+ i11 = i5 + (i14 * 12 | 0) | 0;
+ i14 = i5 + ((i14 + i12 | 0) * 12 | 0) | 0;
+ i12 = __ZNSt3__17__sort4IRPFbRK6b2PairS3_EPS1_EEjT0_S8_S8_S8_T_(i5, i11, i10, i14, i1) | 0;
+ if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i14) | 0) {
+ HEAP32[i2 + 0 >> 2] = HEAP32[i14 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i14 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i14 + 8 >> 2];
+ HEAP32[i14 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i14 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i14 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ i13 = i12 + 1 | 0;
+ if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i14, i10) | 0) {
+ HEAP32[i2 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i14 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i14 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i14 + 8 >> 2];
+ HEAP32[i14 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i14 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i14 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ i13 = i12 + 2 | 0;
+ if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i10, i11) | 0) {
+ HEAP32[i2 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
+ HEAP32[i11 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i11 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i11 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i11, i5) | 0) {
+ HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
+ HEAP32[i11 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i11 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i11 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ i12 = i12 + 4 | 0;
+ } else {
+ i12 = i12 + 3 | 0;
+ }
+ } else {
+ i12 = i13;
+ }
+ } else {
+ i12 = i13;
+ }
+ }
+ } else {
+ i15 = FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i10, i5) | 0;
+ i11 = FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i10) | 0;
+ if (!i15) {
+ if (!i11) {
+ i12 = 0;
+ break;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i10, i5) | 0)) {
+ i12 = 1;
+ break;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ i12 = 2;
+ break;
+ }
+ if (i11) {
+ HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ i12 = 1;
+ break;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i10) | 0) {
+ HEAP32[i2 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ i12 = 2;
+ } else {
+ i12 = 1;
+ }
+ }
+ } while (0);
+ do {
+ if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i10) | 0) {
+ i13 = i4;
+ } else {
+ i13 = i4;
+ while (1) {
+ i13 = i13 + -12 | 0;
+ if ((i5 | 0) == (i13 | 0)) {
+ break;
+ }
+ if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i13, i10) | 0) {
+ i6 = 50;
+ break;
+ }
+ }
+ if ((i6 | 0) == 50) {
+ i6 = 0;
+ HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i13 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i13 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i13 + 8 >> 2];
+ HEAP32[i13 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i13 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i13 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ i12 = i12 + 1 | 0;
+ break;
+ }
+ i10 = i5 + 12 | 0;
+ if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i4) | 0)) {
+ if ((i10 | 0) == (i4 | 0)) {
+ i6 = 67;
+ break L1;
+ }
+ while (1) {
+ i9 = i10 + 12 | 0;
+ if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i10) | 0) {
+ break;
+ }
+ if ((i9 | 0) == (i4 | 0)) {
+ i6 = 67;
+ break L1;
+ } else {
+ i10 = i9;
+ }
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ i10 = i9;
+ }
+ if ((i10 | 0) == (i4 | 0)) {
+ i6 = 67;
+ break L1;
+ } else {
+ i9 = i4;
+ }
+ while (1) {
+ while (1) {
+ i11 = i10 + 12 | 0;
+ if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i10) | 0) {
+ break;
+ } else {
+ i10 = i11;
+ }
+ }
+ do {
+ i9 = i9 + -12 | 0;
+ } while (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i9) | 0);
+ if (!(i10 >>> 0 < i9 >>> 0)) {
+ i5 = i10;
+ continue L3;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i9 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i9 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i9 + 8 >> 2];
+ HEAP32[i9 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i9 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i9 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ i10 = i11;
+ }
+ }
+ } while (0);
+ i11 = i5 + 12 | 0;
+ L47 : do {
+ if (i11 >>> 0 < i13 >>> 0) {
+ while (1) {
+ i15 = i11;
+ while (1) {
+ i11 = i15 + 12 | 0;
+ if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i15, i10) | 0) {
+ i15 = i11;
+ } else {
+ i14 = i13;
+ break;
+ }
+ }
+ do {
+ i14 = i14 + -12 | 0;
+ } while (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i14, i10) | 0));
+ if (i15 >>> 0 > i14 >>> 0) {
+ i11 = i15;
+ break L47;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i15 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i15 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i15 + 8 >> 2];
+ HEAP32[i15 + 0 >> 2] = HEAP32[i14 + 0 >> 2];
+ HEAP32[i15 + 4 >> 2] = HEAP32[i14 + 4 >> 2];
+ HEAP32[i15 + 8 >> 2] = HEAP32[i14 + 8 >> 2];
+ HEAP32[i14 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i14 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i14 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ i13 = i14;
+ i10 = (i10 | 0) == (i15 | 0) ? i14 : i10;
+ i12 = i12 + 1 | 0;
+ }
+ }
+ } while (0);
+ if ((i11 | 0) != (i10 | 0) ? FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i10, i11) | 0 : 0) {
+ HEAP32[i2 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
+ HEAP32[i11 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i11 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i11 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ i12 = i12 + 1 | 0;
+ }
+ if ((i12 | 0) == 0) {
+ i12 = __ZNSt3__127__insertion_sort_incompleteIRPFbRK6b2PairS3_EPS1_EEbT0_S8_T_(i5, i11, i1) | 0;
+ i10 = i11 + 12 | 0;
+ if (__ZNSt3__127__insertion_sort_incompleteIRPFbRK6b2PairS3_EPS1_EEbT0_S8_T_(i10, i8, i1) | 0) {
+ i6 = 62;
+ break;
+ }
+ if (i12) {
+ i5 = i10;
+ continue;
+ }
+ }
+ i15 = i11;
+ if ((i15 - i9 | 0) >= (i7 - i15 | 0)) {
+ i6 = 66;
+ break;
+ }
+ __ZNSt3__16__sortIRPFbRK6b2PairS3_EPS1_EEvT0_S8_T_(i5, i11, i1);
+ i5 = i11 + 12 | 0;
+ }
+ if ((i6 | 0) == 62) {
+ i6 = 0;
+ if (i12) {
+ i6 = 67;
+ break;
+ } else {
+ i8 = i11;
+ continue;
+ }
+ } else if ((i6 | 0) == 66) {
+ i6 = 0;
+ __ZNSt3__16__sortIRPFbRK6b2PairS3_EPS1_EEvT0_S8_T_(i11 + 12 | 0, i8, i1);
+ i8 = i11;
+ continue;
+ }
+ }
+ if ((i6 | 0) == 4) {
+ if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i5) | 0)) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ STACKTOP = i3;
+ return;
+ } else if ((i6 | 0) == 6) {
+ i6 = i5 + 12 | 0;
+ i15 = FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i6, i5) | 0;
+ i7 = FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i6) | 0;
+ if (!i15) {
+ if (!i7) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i6 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i6, i5) | 0)) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i6 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ STACKTOP = i3;
+ return;
+ }
+ if (i7) {
+ HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i6 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i6) | 0)) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i6 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ STACKTOP = i3;
+ return;
+ } else if ((i6 | 0) == 14) {
+ __ZNSt3__17__sort4IRPFbRK6b2PairS3_EPS1_EEjT0_S8_S8_S8_T_(i5, i5 + 12 | 0, i5 + 24 | 0, i4, i1) | 0;
+ STACKTOP = i3;
+ return;
+ } else if ((i6 | 0) == 15) {
+ i6 = i5 + 12 | 0;
+ i7 = i5 + 24 | 0;
+ i8 = i5 + 36 | 0;
+ __ZNSt3__17__sort4IRPFbRK6b2PairS3_EPS1_EEjT0_S8_S8_S8_T_(i5, i6, i7, i8, i1) | 0;
+ if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i8) | 0)) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i8 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i8 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i8 + 8 >> 2];
+ HEAP32[i8 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i8 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i8 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i8, i7) | 0)) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ HEAP32[i7 + 0 >> 2] = HEAP32[i8 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i8 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i8 + 8 >> 2];
+ HEAP32[i8 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i8 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i8 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i7, i6) | 0)) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i6 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ HEAP32[i7 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i6, i5) | 0)) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i6 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ STACKTOP = i3;
+ return;
+ } else if ((i6 | 0) == 21) {
+ __ZNSt3__118__insertion_sort_3IRPFbRK6b2PairS3_EPS1_EEvT0_S8_T_(i5, i8, i1);
+ STACKTOP = i3;
+ return;
+ } else if ((i6 | 0) == 67) {
+ STACKTOP = i3;
+ return;
+ }
+}
+function _free(i7) {
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0;
+ i1 = STACKTOP;
+ if ((i7 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i15 = i7 + -8 | 0;
+ i16 = HEAP32[7176 >> 2] | 0;
+ if (i15 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i13 = HEAP32[i7 + -4 >> 2] | 0;
+ i12 = i13 & 3;
+ if ((i12 | 0) == 1) {
+ _abort();
+ }
+ i8 = i13 & -8;
+ i6 = i7 + (i8 + -8) | 0;
+ do {
+ if ((i13 & 1 | 0) == 0) {
+ i19 = HEAP32[i15 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i15 = -8 - i19 | 0;
+ i13 = i7 + i15 | 0;
+ i12 = i19 + i8 | 0;
+ if (i13 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ if ((i13 | 0) == (HEAP32[7180 >> 2] | 0)) {
+ i2 = i7 + (i8 + -4) | 0;
+ if ((HEAP32[i2 >> 2] & 3 | 0) != 3) {
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ HEAP32[7168 >> 2] = i12;
+ HEAP32[i2 >> 2] = HEAP32[i2 >> 2] & -2;
+ HEAP32[i7 + (i15 + 4) >> 2] = i12 | 1;
+ HEAP32[i6 >> 2] = i12;
+ STACKTOP = i1;
+ return;
+ }
+ i18 = i19 >>> 3;
+ if (i19 >>> 0 < 256) {
+ i2 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
+ i11 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
+ i14 = 7200 + (i18 << 1 << 2) | 0;
+ if ((i2 | 0) != (i14 | 0)) {
+ if (i2 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i2 + 12 >> 2] | 0) != (i13 | 0)) {
+ _abort();
+ }
+ }
+ if ((i11 | 0) == (i2 | 0)) {
+ HEAP32[1790] = HEAP32[1790] & ~(1 << i18);
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ if ((i11 | 0) != (i14 | 0)) {
+ if (i11 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i14 = i11 + 8 | 0;
+ if ((HEAP32[i14 >> 2] | 0) == (i13 | 0)) {
+ i17 = i14;
+ } else {
+ _abort();
+ }
+ } else {
+ i17 = i11 + 8 | 0;
+ }
+ HEAP32[i2 + 12 >> 2] = i11;
+ HEAP32[i17 >> 2] = i2;
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ i17 = HEAP32[i7 + (i15 + 24) >> 2] | 0;
+ i18 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
+ do {
+ if ((i18 | 0) == (i13 | 0)) {
+ i19 = i7 + (i15 + 20) | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ i19 = i7 + (i15 + 16) | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ i14 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i21 = i18 + 20 | 0;
+ i20 = HEAP32[i21 >> 2] | 0;
+ if ((i20 | 0) != 0) {
+ i18 = i20;
+ i19 = i21;
+ continue;
+ }
+ i20 = i18 + 16 | 0;
+ i21 = HEAP32[i20 >> 2] | 0;
+ if ((i21 | 0) == 0) {
+ break;
+ } else {
+ i18 = i21;
+ i19 = i20;
+ }
+ }
+ if (i19 >>> 0 < i16 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i19 >> 2] = 0;
+ i14 = i18;
+ break;
+ }
+ } else {
+ i19 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
+ if (i19 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i16 = i19 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != (i13 | 0)) {
+ _abort();
+ }
+ i20 = i18 + 8 | 0;
+ if ((HEAP32[i20 >> 2] | 0) == (i13 | 0)) {
+ HEAP32[i16 >> 2] = i18;
+ HEAP32[i20 >> 2] = i19;
+ i14 = i18;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i17 | 0) != 0) {
+ i18 = HEAP32[i7 + (i15 + 28) >> 2] | 0;
+ i16 = 7464 + (i18 << 2) | 0;
+ if ((i13 | 0) == (HEAP32[i16 >> 2] | 0)) {
+ HEAP32[i16 >> 2] = i14;
+ if ((i14 | 0) == 0) {
+ HEAP32[7164 >> 2] = HEAP32[7164 >> 2] & ~(1 << i18);
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ } else {
+ if (i17 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i17 + 16 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i13 | 0)) {
+ HEAP32[i16 >> 2] = i14;
+ } else {
+ HEAP32[i17 + 20 >> 2] = i14;
+ }
+ if ((i14 | 0) == 0) {
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ }
+ if (i14 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i14 + 24 >> 2] = i17;
+ i16 = HEAP32[i7 + (i15 + 16) >> 2] | 0;
+ do {
+ if ((i16 | 0) != 0) {
+ if (i16 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i14 + 16 >> 2] = i16;
+ HEAP32[i16 + 24 >> 2] = i14;
+ break;
+ }
+ }
+ } while (0);
+ i15 = HEAP32[i7 + (i15 + 20) >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ if (i15 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i14 + 20 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i14;
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ } else {
+ i2 = i13;
+ i11 = i12;
+ }
+ } else {
+ i2 = i13;
+ i11 = i12;
+ }
+ } else {
+ i2 = i15;
+ i11 = i8;
+ }
+ } while (0);
+ if (!(i2 >>> 0 < i6 >>> 0)) {
+ _abort();
+ }
+ i12 = i7 + (i8 + -4) | 0;
+ i13 = HEAP32[i12 >> 2] | 0;
+ if ((i13 & 1 | 0) == 0) {
+ _abort();
+ }
+ if ((i13 & 2 | 0) == 0) {
+ if ((i6 | 0) == (HEAP32[7184 >> 2] | 0)) {
+ i21 = (HEAP32[7172 >> 2] | 0) + i11 | 0;
+ HEAP32[7172 >> 2] = i21;
+ HEAP32[7184 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i21 | 1;
+ if ((i2 | 0) != (HEAP32[7180 >> 2] | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[7180 >> 2] = 0;
+ HEAP32[7168 >> 2] = 0;
+ STACKTOP = i1;
+ return;
+ }
+ if ((i6 | 0) == (HEAP32[7180 >> 2] | 0)) {
+ i21 = (HEAP32[7168 >> 2] | 0) + i11 | 0;
+ HEAP32[7168 >> 2] = i21;
+ HEAP32[7180 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i21 | 1;
+ HEAP32[i2 + i21 >> 2] = i21;
+ STACKTOP = i1;
+ return;
+ }
+ i11 = (i13 & -8) + i11 | 0;
+ i12 = i13 >>> 3;
+ do {
+ if (!(i13 >>> 0 < 256)) {
+ i10 = HEAP32[i7 + (i8 + 16) >> 2] | 0;
+ i15 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
+ do {
+ if ((i15 | 0) == (i6 | 0)) {
+ i13 = i7 + (i8 + 12) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i13 = i7 + (i8 + 8) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i9 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i14 = i12 + 20 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ i12 = i15;
+ i13 = i14;
+ continue;
+ }
+ i14 = i12 + 16 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) == 0) {
+ break;
+ } else {
+ i12 = i15;
+ i13 = i14;
+ }
+ }
+ if (i13 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i13 >> 2] = 0;
+ i9 = i12;
+ break;
+ }
+ } else {
+ i13 = HEAP32[i7 + i8 >> 2] | 0;
+ if (i13 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i14 = i13 + 12 | 0;
+ if ((HEAP32[i14 >> 2] | 0) != (i6 | 0)) {
+ _abort();
+ }
+ i12 = i15 + 8 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i14 >> 2] = i15;
+ HEAP32[i12 >> 2] = i13;
+ i9 = i15;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i10 | 0) != 0) {
+ i12 = HEAP32[i7 + (i8 + 20) >> 2] | 0;
+ i13 = 7464 + (i12 << 2) | 0;
+ if ((i6 | 0) == (HEAP32[i13 >> 2] | 0)) {
+ HEAP32[i13 >> 2] = i9;
+ if ((i9 | 0) == 0) {
+ HEAP32[7164 >> 2] = HEAP32[7164 >> 2] & ~(1 << i12);
+ break;
+ }
+ } else {
+ if (i10 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i12 = i10 + 16 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i12 >> 2] = i9;
+ } else {
+ HEAP32[i10 + 20 >> 2] = i9;
+ }
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ }
+ if (i9 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i9 + 24 >> 2] = i10;
+ i6 = HEAP32[i7 + (i8 + 8) >> 2] | 0;
+ do {
+ if ((i6 | 0) != 0) {
+ if (i6 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 16 >> 2] = i6;
+ HEAP32[i6 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ } while (0);
+ i6 = HEAP32[i7 + (i8 + 12) >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ if (i6 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 20 >> 2] = i6;
+ HEAP32[i6 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ }
+ } else {
+ i9 = HEAP32[i7 + i8 >> 2] | 0;
+ i7 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
+ i8 = 7200 + (i12 << 1 << 2) | 0;
+ if ((i9 | 0) != (i8 | 0)) {
+ if (i9 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i9 + 12 >> 2] | 0) != (i6 | 0)) {
+ _abort();
+ }
+ }
+ if ((i7 | 0) == (i9 | 0)) {
+ HEAP32[1790] = HEAP32[1790] & ~(1 << i12);
+ break;
+ }
+ if ((i7 | 0) != (i8 | 0)) {
+ if (i7 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i7 + 8 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i6 | 0)) {
+ i10 = i8;
+ } else {
+ _abort();
+ }
+ } else {
+ i10 = i7 + 8 | 0;
+ }
+ HEAP32[i9 + 12 >> 2] = i7;
+ HEAP32[i10 >> 2] = i9;
+ }
+ } while (0);
+ HEAP32[i2 + 4 >> 2] = i11 | 1;
+ HEAP32[i2 + i11 >> 2] = i11;
+ if ((i2 | 0) == (HEAP32[7180 >> 2] | 0)) {
+ HEAP32[7168 >> 2] = i11;
+ STACKTOP = i1;
+ return;
+ }
+ } else {
+ HEAP32[i12 >> 2] = i13 & -2;
+ HEAP32[i2 + 4 >> 2] = i11 | 1;
+ HEAP32[i2 + i11 >> 2] = i11;
+ }
+ i6 = i11 >>> 3;
+ if (i11 >>> 0 < 256) {
+ i7 = i6 << 1;
+ i3 = 7200 + (i7 << 2) | 0;
+ i8 = HEAP32[1790] | 0;
+ i6 = 1 << i6;
+ if ((i8 & i6 | 0) != 0) {
+ i6 = 7200 + (i7 + 2 << 2) | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ if (i7 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i4 = i6;
+ i5 = i7;
+ }
+ } else {
+ HEAP32[1790] = i8 | i6;
+ i4 = 7200 + (i7 + 2 << 2) | 0;
+ i5 = i3;
+ }
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i5 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i5;
+ HEAP32[i2 + 12 >> 2] = i3;
+ STACKTOP = i1;
+ return;
+ }
+ i4 = i11 >>> 8;
+ if ((i4 | 0) != 0) {
+ if (i11 >>> 0 > 16777215) {
+ i4 = 31;
+ } else {
+ i20 = (i4 + 1048320 | 0) >>> 16 & 8;
+ i21 = i4 << i20;
+ i19 = (i21 + 520192 | 0) >>> 16 & 4;
+ i21 = i21 << i19;
+ i4 = (i21 + 245760 | 0) >>> 16 & 2;
+ i4 = 14 - (i19 | i20 | i4) + (i21 << i4 >>> 15) | 0;
+ i4 = i11 >>> (i4 + 7 | 0) & 1 | i4 << 1;
+ }
+ } else {
+ i4 = 0;
+ }
+ i5 = 7464 + (i4 << 2) | 0;
+ HEAP32[i2 + 28 >> 2] = i4;
+ HEAP32[i2 + 20 >> 2] = 0;
+ HEAP32[i2 + 16 >> 2] = 0;
+ i7 = HEAP32[7164 >> 2] | 0;
+ i6 = 1 << i4;
+ L199 : do {
+ if ((i7 & i6 | 0) != 0) {
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((i4 | 0) == 31) {
+ i4 = 0;
+ } else {
+ i4 = 25 - (i4 >>> 1) | 0;
+ }
+ L204 : do {
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) != (i11 | 0)) {
+ i4 = i11 << i4;
+ i7 = i5;
+ while (1) {
+ i6 = i7 + (i4 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i11 | 0)) {
+ i3 = i5;
+ break L204;
+ } else {
+ i4 = i4 << 1;
+ i7 = i5;
+ }
+ }
+ if (i6 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i7;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ break L199;
+ }
+ } else {
+ i3 = i5;
+ }
+ } while (0);
+ i5 = i3 + 8 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i6 = HEAP32[7176 >> 2] | 0;
+ if (i3 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ if (i4 >>> 0 < i6 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i4 + 12 >> 2] = i2;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i4;
+ HEAP32[i2 + 12 >> 2] = i3;
+ HEAP32[i2 + 24 >> 2] = 0;
+ break;
+ }
+ } else {
+ HEAP32[7164 >> 2] = i7 | i6;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i5;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ }
+ } while (0);
+ i21 = (HEAP32[7192 >> 2] | 0) + -1 | 0;
+ HEAP32[7192 >> 2] = i21;
+ if ((i21 | 0) == 0) {
+ i2 = 7616 | 0;
+ } else {
+ STACKTOP = i1;
+ return;
+ }
+ while (1) {
+ i2 = HEAP32[i2 >> 2] | 0;
+ if ((i2 | 0) == 0) {
+ break;
+ } else {
+ i2 = i2 + 8 | 0;
+ }
+ }
+ HEAP32[7192 >> 2] = -1;
+ STACKTOP = i1;
+ return;
+}
+function __ZNSt3__127__insertion_sort_incompleteIRPFbRK6b2PairS3_EPS1_EEbT0_S8_T_(i3, i4, i2) {
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i7 = i1 + 12 | 0;
+ i6 = i1;
+ switch ((i4 - i3 | 0) / 12 | 0 | 0) {
+ case 5:
+ {
+ i6 = i3 + 12 | 0;
+ i8 = i3 + 24 | 0;
+ i5 = i3 + 36 | 0;
+ i4 = i4 + -12 | 0;
+ __ZNSt3__17__sort4IRPFbRK6b2PairS3_EPS1_EEjT0_S8_S8_S8_T_(i3, i6, i8, i5, i2) | 0;
+ if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i4, i5) | 0)) {
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i5, i8) | 0)) {
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ HEAP32[i7 + 0 >> 2] = HEAP32[i8 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i8 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i8 + 8 >> 2];
+ HEAP32[i8 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i8 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i8 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i8, i6) | 0)) {
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ HEAP32[i7 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i6 + 0 >> 2] = HEAP32[i8 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i8 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i8 + 8 >> 2];
+ HEAP32[i8 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i8 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i8 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i6, i3) | 0)) {
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ HEAP32[i3 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i6 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ case 4:
+ {
+ __ZNSt3__17__sort4IRPFbRK6b2PairS3_EPS1_EEjT0_S8_S8_S8_T_(i3, i3 + 12 | 0, i3 + 24 | 0, i4 + -12 | 0, i2) | 0;
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ case 3:
+ {
+ i5 = i3 + 12 | 0;
+ i4 = i4 + -12 | 0;
+ i10 = FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i5, i3) | 0;
+ i6 = FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i4, i5) | 0;
+ if (!i10) {
+ if (!i6) {
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i5, i3) | 0)) {
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ HEAP32[i3 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ if (i6) {
+ HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ HEAP32[i3 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ HEAP32[i3 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i4, i5) | 0)) {
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ case 2:
+ {
+ i4 = i4 + -12 | 0;
+ if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i4, i3) | 0)) {
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ HEAP32[i3 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ case 1:
+ case 0:
+ {
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ default:
+ {
+ i9 = i3 + 24 | 0;
+ i10 = i3 + 12 | 0;
+ i11 = FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i10, i3) | 0;
+ i8 = FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i9, i10) | 0;
+ do {
+ if (i11) {
+ if (i8) {
+ HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ HEAP32[i3 + 0 >> 2] = HEAP32[i9 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i9 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i9 + 8 >> 2];
+ HEAP32[i9 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i9 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i9 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ break;
+ }
+ HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ HEAP32[i3 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ if (FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i9, i10) | 0) {
+ HEAP32[i7 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i9 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i9 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i9 + 8 >> 2];
+ HEAP32[i9 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i9 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i9 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ }
+ } else {
+ if (i8) {
+ HEAP32[i7 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i9 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i9 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i9 + 8 >> 2];
+ HEAP32[i9 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i9 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i9 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ if (FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i10, i3) | 0) {
+ HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ HEAP32[i3 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ }
+ }
+ }
+ } while (0);
+ i7 = i3 + 36 | 0;
+ if ((i7 | 0) == (i4 | 0)) {
+ i11 = 1;
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ i8 = 0;
+ while (1) {
+ if (FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i7, i9) | 0) {
+ HEAP32[i6 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ i10 = i7;
+ while (1) {
+ HEAP32[i10 + 0 >> 2] = HEAP32[i9 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i9 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i9 + 8 >> 2];
+ if ((i9 | 0) == (i3 | 0)) {
+ break;
+ }
+ i10 = i9 + -12 | 0;
+ if (FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i6, i10) | 0) {
+ i11 = i9;
+ i9 = i10;
+ i10 = i11;
+ } else {
+ break;
+ }
+ }
+ HEAP32[i9 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i9 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i9 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ i8 = i8 + 1 | 0;
+ if ((i8 | 0) == 8) {
+ break;
+ }
+ }
+ i9 = i7 + 12 | 0;
+ if ((i9 | 0) == (i4 | 0)) {
+ i2 = 1;
+ i5 = 35;
+ break;
+ } else {
+ i11 = i7;
+ i7 = i9;
+ i9 = i11;
+ }
+ }
+ if ((i5 | 0) == 35) {
+ STACKTOP = i1;
+ return i2 | 0;
+ }
+ i11 = (i7 + 12 | 0) == (i4 | 0);
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ }
+ return 0;
+}
+function __ZN13b2DynamicTree7BalanceEi(i11, i6) {
+ i11 = i11 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, d19 = 0.0, i20 = 0, i21 = 0, d22 = 0.0, d23 = 0.0, d24 = 0.0, d25 = 0.0;
+ i1 = STACKTOP;
+ if ((i6 | 0) == -1) {
+ ___assert_fail(3216, 2944, 382, 3232);
+ }
+ i5 = HEAP32[i11 + 4 >> 2] | 0;
+ i13 = i5 + (i6 * 36 | 0) | 0;
+ i18 = i5 + (i6 * 36 | 0) + 24 | 0;
+ i8 = HEAP32[i18 >> 2] | 0;
+ if ((i8 | 0) == -1) {
+ i21 = i6;
+ STACKTOP = i1;
+ return i21 | 0;
+ }
+ i2 = i5 + (i6 * 36 | 0) + 32 | 0;
+ if ((HEAP32[i2 >> 2] | 0) < 2) {
+ i21 = i6;
+ STACKTOP = i1;
+ return i21 | 0;
+ }
+ i20 = i5 + (i6 * 36 | 0) + 28 | 0;
+ i7 = HEAP32[i20 >> 2] | 0;
+ if (!((i8 | 0) > -1)) {
+ ___assert_fail(3240, 2944, 392, 3232);
+ }
+ i12 = HEAP32[i11 + 12 >> 2] | 0;
+ if ((i8 | 0) >= (i12 | 0)) {
+ ___assert_fail(3240, 2944, 392, 3232);
+ }
+ if (!((i7 | 0) > -1 & (i7 | 0) < (i12 | 0))) {
+ ___assert_fail(3272, 2944, 393, 3232);
+ }
+ i9 = i5 + (i8 * 36 | 0) | 0;
+ i10 = i5 + (i7 * 36 | 0) | 0;
+ i3 = i5 + (i7 * 36 | 0) + 32 | 0;
+ i4 = i5 + (i8 * 36 | 0) + 32 | 0;
+ i14 = (HEAP32[i3 >> 2] | 0) - (HEAP32[i4 >> 2] | 0) | 0;
+ if ((i14 | 0) > 1) {
+ i21 = i5 + (i7 * 36 | 0) + 24 | 0;
+ i14 = HEAP32[i21 >> 2] | 0;
+ i18 = i5 + (i7 * 36 | 0) + 28 | 0;
+ i15 = HEAP32[i18 >> 2] | 0;
+ i16 = i5 + (i14 * 36 | 0) | 0;
+ i17 = i5 + (i15 * 36 | 0) | 0;
+ if (!((i14 | 0) > -1 & (i14 | 0) < (i12 | 0))) {
+ ___assert_fail(3304, 2944, 407, 3232);
+ }
+ if (!((i15 | 0) > -1 & (i15 | 0) < (i12 | 0))) {
+ ___assert_fail(3336, 2944, 408, 3232);
+ }
+ HEAP32[i21 >> 2] = i6;
+ i21 = i5 + (i6 * 36 | 0) + 20 | 0;
+ i12 = i5 + (i7 * 36 | 0) + 20 | 0;
+ HEAP32[i12 >> 2] = HEAP32[i21 >> 2];
+ HEAP32[i21 >> 2] = i7;
+ i12 = HEAP32[i12 >> 2] | 0;
+ do {
+ if (!((i12 | 0) == -1)) {
+ i11 = i5 + (i12 * 36 | 0) + 24 | 0;
+ if ((HEAP32[i11 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i11 >> 2] = i7;
+ break;
+ }
+ i11 = i5 + (i12 * 36 | 0) + 28 | 0;
+ if ((HEAP32[i11 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i11 >> 2] = i7;
+ break;
+ } else {
+ ___assert_fail(3368, 2944, 424, 3232);
+ }
+ } else {
+ HEAP32[i11 >> 2] = i7;
+ }
+ } while (0);
+ i11 = i5 + (i14 * 36 | 0) + 32 | 0;
+ i12 = i5 + (i15 * 36 | 0) + 32 | 0;
+ if ((HEAP32[i11 >> 2] | 0) > (HEAP32[i12 >> 2] | 0)) {
+ HEAP32[i18 >> 2] = i14;
+ HEAP32[i20 >> 2] = i15;
+ HEAP32[i5 + (i15 * 36 | 0) + 20 >> 2] = i6;
+ d19 = +HEAPF32[i9 >> 2];
+ d22 = +HEAPF32[i17 >> 2];
+ d19 = d19 < d22 ? d19 : d22;
+ d23 = +HEAPF32[i5 + (i8 * 36 | 0) + 4 >> 2];
+ d22 = +HEAPF32[i5 + (i15 * 36 | 0) + 4 >> 2];
+ d24 = +d19;
+ d23 = +(d23 < d22 ? d23 : d22);
+ i21 = i13;
+ HEAPF32[i21 >> 2] = d24;
+ HEAPF32[i21 + 4 >> 2] = d23;
+ d23 = +HEAPF32[i5 + (i8 * 36 | 0) + 8 >> 2];
+ d24 = +HEAPF32[i5 + (i15 * 36 | 0) + 8 >> 2];
+ d22 = +HEAPF32[i5 + (i8 * 36 | 0) + 12 >> 2];
+ d25 = +HEAPF32[i5 + (i15 * 36 | 0) + 12 >> 2];
+ d23 = +(d23 > d24 ? d23 : d24);
+ d24 = +(d22 > d25 ? d22 : d25);
+ i21 = i5 + (i6 * 36 | 0) + 8 | 0;
+ HEAPF32[i21 >> 2] = d23;
+ HEAPF32[i21 + 4 >> 2] = d24;
+ d24 = +HEAPF32[i16 >> 2];
+ d22 = +HEAPF32[i5 + (i6 * 36 | 0) + 4 >> 2];
+ d23 = +HEAPF32[i5 + (i14 * 36 | 0) + 4 >> 2];
+ d19 = +(d19 < d24 ? d19 : d24);
+ d22 = +(d22 < d23 ? d22 : d23);
+ i21 = i10;
+ HEAPF32[i21 >> 2] = d19;
+ HEAPF32[i21 + 4 >> 2] = d22;
+ d22 = +HEAPF32[i5 + (i6 * 36 | 0) + 8 >> 2];
+ d19 = +HEAPF32[i5 + (i14 * 36 | 0) + 8 >> 2];
+ d23 = +HEAPF32[i5 + (i6 * 36 | 0) + 12 >> 2];
+ d24 = +HEAPF32[i5 + (i14 * 36 | 0) + 12 >> 2];
+ d19 = +(d22 > d19 ? d22 : d19);
+ d25 = +(d23 > d24 ? d23 : d24);
+ i5 = i5 + (i7 * 36 | 0) + 8 | 0;
+ HEAPF32[i5 >> 2] = d19;
+ HEAPF32[i5 + 4 >> 2] = d25;
+ i4 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[i12 >> 2] | 0;
+ i4 = ((i4 | 0) > (i5 | 0) ? i4 : i5) + 1 | 0;
+ HEAP32[i2 >> 2] = i4;
+ i2 = HEAP32[i11 >> 2] | 0;
+ i2 = (i4 | 0) > (i2 | 0) ? i4 : i2;
+ } else {
+ HEAP32[i18 >> 2] = i15;
+ HEAP32[i20 >> 2] = i14;
+ HEAP32[i5 + (i14 * 36 | 0) + 20 >> 2] = i6;
+ d19 = +HEAPF32[i9 >> 2];
+ d22 = +HEAPF32[i16 >> 2];
+ d19 = d19 < d22 ? d19 : d22;
+ d23 = +HEAPF32[i5 + (i8 * 36 | 0) + 4 >> 2];
+ d24 = +HEAPF32[i5 + (i14 * 36 | 0) + 4 >> 2];
+ d22 = +d19;
+ d23 = +(d23 < d24 ? d23 : d24);
+ i21 = i13;
+ HEAPF32[i21 >> 2] = d22;
+ HEAPF32[i21 + 4 >> 2] = d23;
+ d23 = +HEAPF32[i5 + (i8 * 36 | 0) + 8 >> 2];
+ d24 = +HEAPF32[i5 + (i14 * 36 | 0) + 8 >> 2];
+ d22 = +HEAPF32[i5 + (i8 * 36 | 0) + 12 >> 2];
+ d25 = +HEAPF32[i5 + (i14 * 36 | 0) + 12 >> 2];
+ d23 = +(d23 > d24 ? d23 : d24);
+ d24 = +(d22 > d25 ? d22 : d25);
+ i21 = i5 + (i6 * 36 | 0) + 8 | 0;
+ HEAPF32[i21 >> 2] = d23;
+ HEAPF32[i21 + 4 >> 2] = d24;
+ d24 = +HEAPF32[i17 >> 2];
+ d22 = +HEAPF32[i5 + (i6 * 36 | 0) + 4 >> 2];
+ d23 = +HEAPF32[i5 + (i15 * 36 | 0) + 4 >> 2];
+ d19 = +(d19 < d24 ? d19 : d24);
+ d23 = +(d22 < d23 ? d22 : d23);
+ i21 = i10;
+ HEAPF32[i21 >> 2] = d19;
+ HEAPF32[i21 + 4 >> 2] = d23;
+ d23 = +HEAPF32[i5 + (i6 * 36 | 0) + 8 >> 2];
+ d19 = +HEAPF32[i5 + (i15 * 36 | 0) + 8 >> 2];
+ d22 = +HEAPF32[i5 + (i6 * 36 | 0) + 12 >> 2];
+ d24 = +HEAPF32[i5 + (i15 * 36 | 0) + 12 >> 2];
+ d19 = +(d23 > d19 ? d23 : d19);
+ d25 = +(d22 > d24 ? d22 : d24);
+ i5 = i5 + (i7 * 36 | 0) + 8 | 0;
+ HEAPF32[i5 >> 2] = d19;
+ HEAPF32[i5 + 4 >> 2] = d25;
+ i4 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[i11 >> 2] | 0;
+ i4 = ((i4 | 0) > (i5 | 0) ? i4 : i5) + 1 | 0;
+ HEAP32[i2 >> 2] = i4;
+ i2 = HEAP32[i12 >> 2] | 0;
+ i2 = (i4 | 0) > (i2 | 0) ? i4 : i2;
+ }
+ HEAP32[i3 >> 2] = i2 + 1;
+ i21 = i7;
+ STACKTOP = i1;
+ return i21 | 0;
+ }
+ if (!((i14 | 0) < -1)) {
+ i21 = i6;
+ STACKTOP = i1;
+ return i21 | 0;
+ }
+ i21 = i5 + (i8 * 36 | 0) + 24 | 0;
+ i14 = HEAP32[i21 >> 2] | 0;
+ i20 = i5 + (i8 * 36 | 0) + 28 | 0;
+ i15 = HEAP32[i20 >> 2] | 0;
+ i17 = i5 + (i14 * 36 | 0) | 0;
+ i16 = i5 + (i15 * 36 | 0) | 0;
+ if (!((i14 | 0) > -1 & (i14 | 0) < (i12 | 0))) {
+ ___assert_fail(3400, 2944, 467, 3232);
+ }
+ if (!((i15 | 0) > -1 & (i15 | 0) < (i12 | 0))) {
+ ___assert_fail(3432, 2944, 468, 3232);
+ }
+ HEAP32[i21 >> 2] = i6;
+ i21 = i5 + (i6 * 36 | 0) + 20 | 0;
+ i12 = i5 + (i8 * 36 | 0) + 20 | 0;
+ HEAP32[i12 >> 2] = HEAP32[i21 >> 2];
+ HEAP32[i21 >> 2] = i8;
+ i12 = HEAP32[i12 >> 2] | 0;
+ do {
+ if (!((i12 | 0) == -1)) {
+ i11 = i5 + (i12 * 36 | 0) + 24 | 0;
+ if ((HEAP32[i11 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i11 >> 2] = i8;
+ break;
+ }
+ i11 = i5 + (i12 * 36 | 0) + 28 | 0;
+ if ((HEAP32[i11 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i11 >> 2] = i8;
+ break;
+ } else {
+ ___assert_fail(3464, 2944, 484, 3232);
+ }
+ } else {
+ HEAP32[i11 >> 2] = i8;
+ }
+ } while (0);
+ i12 = i5 + (i14 * 36 | 0) + 32 | 0;
+ i11 = i5 + (i15 * 36 | 0) + 32 | 0;
+ if ((HEAP32[i12 >> 2] | 0) > (HEAP32[i11 >> 2] | 0)) {
+ HEAP32[i20 >> 2] = i14;
+ HEAP32[i18 >> 2] = i15;
+ HEAP32[i5 + (i15 * 36 | 0) + 20 >> 2] = i6;
+ d19 = +HEAPF32[i10 >> 2];
+ d22 = +HEAPF32[i16 >> 2];
+ d19 = d19 < d22 ? d19 : d22;
+ d23 = +HEAPF32[i5 + (i7 * 36 | 0) + 4 >> 2];
+ d22 = +HEAPF32[i5 + (i15 * 36 | 0) + 4 >> 2];
+ d24 = +d19;
+ d23 = +(d23 < d22 ? d23 : d22);
+ i21 = i13;
+ HEAPF32[i21 >> 2] = d24;
+ HEAPF32[i21 + 4 >> 2] = d23;
+ d23 = +HEAPF32[i5 + (i7 * 36 | 0) + 8 >> 2];
+ d22 = +HEAPF32[i5 + (i15 * 36 | 0) + 8 >> 2];
+ d24 = +HEAPF32[i5 + (i7 * 36 | 0) + 12 >> 2];
+ d25 = +HEAPF32[i5 + (i15 * 36 | 0) + 12 >> 2];
+ d22 = +(d23 > d22 ? d23 : d22);
+ d24 = +(d24 > d25 ? d24 : d25);
+ i21 = i5 + (i6 * 36 | 0) + 8 | 0;
+ HEAPF32[i21 >> 2] = d22;
+ HEAPF32[i21 + 4 >> 2] = d24;
+ d24 = +HEAPF32[i17 >> 2];
+ d23 = +HEAPF32[i5 + (i6 * 36 | 0) + 4 >> 2];
+ d22 = +HEAPF32[i5 + (i14 * 36 | 0) + 4 >> 2];
+ d19 = +(d19 < d24 ? d19 : d24);
+ d22 = +(d23 < d22 ? d23 : d22);
+ i21 = i9;
+ HEAPF32[i21 >> 2] = d19;
+ HEAPF32[i21 + 4 >> 2] = d22;
+ d22 = +HEAPF32[i5 + (i6 * 36 | 0) + 8 >> 2];
+ d23 = +HEAPF32[i5 + (i14 * 36 | 0) + 8 >> 2];
+ d19 = +HEAPF32[i5 + (i6 * 36 | 0) + 12 >> 2];
+ d24 = +HEAPF32[i5 + (i14 * 36 | 0) + 12 >> 2];
+ d22 = +(d22 > d23 ? d22 : d23);
+ d25 = +(d19 > d24 ? d19 : d24);
+ i5 = i5 + (i8 * 36 | 0) + 8 | 0;
+ HEAPF32[i5 >> 2] = d22;
+ HEAPF32[i5 + 4 >> 2] = d25;
+ i3 = HEAP32[i3 >> 2] | 0;
+ i5 = HEAP32[i11 >> 2] | 0;
+ i3 = ((i3 | 0) > (i5 | 0) ? i3 : i5) + 1 | 0;
+ HEAP32[i2 >> 2] = i3;
+ i2 = HEAP32[i12 >> 2] | 0;
+ i2 = (i3 | 0) > (i2 | 0) ? i3 : i2;
+ } else {
+ HEAP32[i20 >> 2] = i15;
+ HEAP32[i18 >> 2] = i14;
+ HEAP32[i5 + (i14 * 36 | 0) + 20 >> 2] = i6;
+ d19 = +HEAPF32[i10 >> 2];
+ d22 = +HEAPF32[i17 >> 2];
+ d19 = d19 < d22 ? d19 : d22;
+ d23 = +HEAPF32[i5 + (i7 * 36 | 0) + 4 >> 2];
+ d24 = +HEAPF32[i5 + (i14 * 36 | 0) + 4 >> 2];
+ d22 = +d19;
+ d24 = +(d23 < d24 ? d23 : d24);
+ i21 = i13;
+ HEAPF32[i21 >> 2] = d22;
+ HEAPF32[i21 + 4 >> 2] = d24;
+ d24 = +HEAPF32[i5 + (i7 * 36 | 0) + 8 >> 2];
+ d23 = +HEAPF32[i5 + (i14 * 36 | 0) + 8 >> 2];
+ d22 = +HEAPF32[i5 + (i7 * 36 | 0) + 12 >> 2];
+ d25 = +HEAPF32[i5 + (i14 * 36 | 0) + 12 >> 2];
+ d23 = +(d24 > d23 ? d24 : d23);
+ d24 = +(d22 > d25 ? d22 : d25);
+ i21 = i5 + (i6 * 36 | 0) + 8 | 0;
+ HEAPF32[i21 >> 2] = d23;
+ HEAPF32[i21 + 4 >> 2] = d24;
+ d24 = +HEAPF32[i16 >> 2];
+ d23 = +HEAPF32[i5 + (i6 * 36 | 0) + 4 >> 2];
+ d22 = +HEAPF32[i5 + (i15 * 36 | 0) + 4 >> 2];
+ d19 = +(d19 < d24 ? d19 : d24);
+ d22 = +(d23 < d22 ? d23 : d22);
+ i21 = i9;
+ HEAPF32[i21 >> 2] = d19;
+ HEAPF32[i21 + 4 >> 2] = d22;
+ d22 = +HEAPF32[i5 + (i6 * 36 | 0) + 8 >> 2];
+ d23 = +HEAPF32[i5 + (i15 * 36 | 0) + 8 >> 2];
+ d19 = +HEAPF32[i5 + (i6 * 36 | 0) + 12 >> 2];
+ d24 = +HEAPF32[i5 + (i15 * 36 | 0) + 12 >> 2];
+ d22 = +(d22 > d23 ? d22 : d23);
+ d25 = +(d19 > d24 ? d19 : d24);
+ i5 = i5 + (i8 * 36 | 0) + 8 | 0;
+ HEAPF32[i5 >> 2] = d22;
+ HEAPF32[i5 + 4 >> 2] = d25;
+ i3 = HEAP32[i3 >> 2] | 0;
+ i5 = HEAP32[i12 >> 2] | 0;
+ i3 = ((i3 | 0) > (i5 | 0) ? i3 : i5) + 1 | 0;
+ HEAP32[i2 >> 2] = i3;
+ i2 = HEAP32[i11 >> 2] | 0;
+ i2 = (i3 | 0) > (i2 | 0) ? i3 : i2;
+ }
+ HEAP32[i4 >> 2] = i2 + 1;
+ i21 = i8;
+ STACKTOP = i1;
+ return i21 | 0;
+}
+function __Z10b2DistanceP16b2DistanceOutputP14b2SimplexCachePK15b2DistanceInput(i2, i5, i3) {
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i4 = 0, i6 = 0, d7 = 0.0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0, i20 = 0, d21 = 0.0, d22 = 0.0, i23 = 0, d24 = 0.0, d25 = 0.0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, d36 = 0.0, d37 = 0.0, d38 = 0.0, i39 = 0, i40 = 0, i41 = 0, i42 = 0, d43 = 0.0, d44 = 0.0, d45 = 0.0, i46 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 176 | 0;
+ i11 = i1 + 152 | 0;
+ i10 = i1 + 136 | 0;
+ i4 = i1 + 24 | 0;
+ i14 = i1 + 12 | 0;
+ i15 = i1;
+ HEAP32[652] = (HEAP32[652] | 0) + 1;
+ i9 = i3 + 28 | 0;
+ i31 = i3 + 56 | 0;
+ HEAP32[i11 + 0 >> 2] = HEAP32[i31 + 0 >> 2];
+ HEAP32[i11 + 4 >> 2] = HEAP32[i31 + 4 >> 2];
+ HEAP32[i11 + 8 >> 2] = HEAP32[i31 + 8 >> 2];
+ HEAP32[i11 + 12 >> 2] = HEAP32[i31 + 12 >> 2];
+ i31 = i3 + 72 | 0;
+ HEAP32[i10 + 0 >> 2] = HEAP32[i31 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i31 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i31 + 8 >> 2];
+ HEAP32[i10 + 12 >> 2] = HEAP32[i31 + 12 >> 2];
+ __ZN9b2Simplex9ReadCacheEPK14b2SimplexCachePK15b2DistanceProxyRK11b2TransformS5_S8_(i4, i5, i3, i11, i9, i10);
+ i9 = i4 + 108 | 0;
+ i31 = HEAP32[i9 >> 2] | 0;
+ if ((i31 | 0) == 3 | (i31 | 0) == 2 | (i31 | 0) == 1) {
+ i8 = i4 + 16 | 0;
+ i6 = i4 + 20 | 0;
+ d17 = +HEAPF32[i11 + 12 >> 2];
+ d18 = +HEAPF32[i11 + 8 >> 2];
+ i13 = i3 + 16 | 0;
+ i12 = i3 + 20 | 0;
+ d16 = +HEAPF32[i11 >> 2];
+ d21 = +HEAPF32[i11 + 4 >> 2];
+ d19 = +HEAPF32[i10 + 12 >> 2];
+ d22 = +HEAPF32[i10 + 8 >> 2];
+ i23 = i3 + 44 | 0;
+ i20 = i3 + 48 | 0;
+ d24 = +HEAPF32[i10 >> 2];
+ d25 = +HEAPF32[i10 + 4 >> 2];
+ i11 = i4 + 52 | 0;
+ i10 = i4 + 56 | 0;
+ i30 = i4 + 16 | 0;
+ i27 = i4 + 36 | 0;
+ i26 = i4 + 52 | 0;
+ i29 = i4 + 24 | 0;
+ i28 = i4 + 60 | 0;
+ i33 = 0;
+ L3 : while (1) {
+ i32 = (i31 | 0) > 0;
+ if (i32) {
+ i34 = 0;
+ do {
+ HEAP32[i14 + (i34 << 2) >> 2] = HEAP32[i4 + (i34 * 36 | 0) + 28 >> 2];
+ HEAP32[i15 + (i34 << 2) >> 2] = HEAP32[i4 + (i34 * 36 | 0) + 32 >> 2];
+ i34 = i34 + 1 | 0;
+ } while ((i34 | 0) != (i31 | 0));
+ }
+ do {
+ if ((i31 | 0) == 2) {
+ i46 = i30;
+ d45 = +HEAPF32[i46 >> 2];
+ d36 = +HEAPF32[i46 + 4 >> 2];
+ i46 = i26;
+ d38 = +HEAPF32[i46 >> 2];
+ d37 = +HEAPF32[i46 + 4 >> 2];
+ d43 = d38 - d45;
+ d44 = d37 - d36;
+ d36 = d45 * d43 + d36 * d44;
+ if (d36 >= -0.0) {
+ HEAPF32[i29 >> 2] = 1.0;
+ HEAP32[i9 >> 2] = 1;
+ i35 = 17;
+ break;
+ }
+ d37 = d38 * d43 + d37 * d44;
+ if (!(d37 <= 0.0)) {
+ d45 = 1.0 / (d37 - d36);
+ HEAPF32[i29 >> 2] = d37 * d45;
+ HEAPF32[i28 >> 2] = -(d36 * d45);
+ HEAP32[i9 >> 2] = 2;
+ i35 = 18;
+ break;
+ } else {
+ HEAPF32[i28 >> 2] = 1.0;
+ HEAP32[i9 >> 2] = 1;
+ i34 = i4 + 0 | 0;
+ i39 = i27 + 0 | 0;
+ i35 = i34 + 36 | 0;
+ do {
+ HEAP32[i34 >> 2] = HEAP32[i39 >> 2];
+ i34 = i34 + 4 | 0;
+ i39 = i39 + 4 | 0;
+ } while ((i34 | 0) < (i35 | 0));
+ i35 = 17;
+ break;
+ }
+ } else if ((i31 | 0) == 3) {
+ __ZN9b2Simplex6Solve3Ev(i4);
+ i34 = HEAP32[i9 >> 2] | 0;
+ if ((i34 | 0) == 1) {
+ i35 = 17;
+ } else if ((i34 | 0) == 0) {
+ i35 = 15;
+ break L3;
+ } else if ((i34 | 0) == 2) {
+ i35 = 18;
+ } else if ((i34 | 0) == 3) {
+ i35 = 42;
+ break L3;
+ } else {
+ i35 = 16;
+ break L3;
+ }
+ } else if ((i31 | 0) == 1) {
+ i35 = 17;
+ } else {
+ i35 = 13;
+ break L3;
+ }
+ } while (0);
+ do {
+ if ((i35 | 0) == 17) {
+ d36 = -+HEAPF32[i8 >> 2];
+ d37 = -+HEAPF32[i6 >> 2];
+ i34 = 1;
+ } else if ((i35 | 0) == 18) {
+ d44 = +HEAPF32[i8 >> 2];
+ d37 = +HEAPF32[i11 >> 2] - d44;
+ d45 = +HEAPF32[i6 >> 2];
+ d36 = +HEAPF32[i10 >> 2] - d45;
+ if (d44 * d36 - d37 * d45 > 0.0) {
+ d36 = -d36;
+ i34 = 2;
+ break;
+ } else {
+ d37 = -d37;
+ i34 = 2;
+ break;
+ }
+ }
+ } while (0);
+ if (d37 * d37 + d36 * d36 < 1.4210854715202004e-14) {
+ i35 = 42;
+ break;
+ }
+ i39 = i4 + (i34 * 36 | 0) | 0;
+ d44 = -d36;
+ d45 = -d37;
+ d43 = d17 * d44 + d18 * d45;
+ d44 = d17 * d45 - d18 * d44;
+ i40 = HEAP32[i13 >> 2] | 0;
+ i41 = HEAP32[i12 >> 2] | 0;
+ if ((i41 | 0) > 1) {
+ i42 = 0;
+ d45 = d44 * +HEAPF32[i40 + 4 >> 2] + d43 * +HEAPF32[i40 >> 2];
+ i46 = 1;
+ while (1) {
+ d38 = d43 * +HEAPF32[i40 + (i46 << 3) >> 2] + d44 * +HEAPF32[i40 + (i46 << 3) + 4 >> 2];
+ i35 = d38 > d45;
+ i42 = i35 ? i46 : i42;
+ i46 = i46 + 1 | 0;
+ if ((i46 | 0) == (i41 | 0)) {
+ break;
+ } else {
+ d45 = i35 ? d38 : d45;
+ }
+ }
+ i35 = i4 + (i34 * 36 | 0) + 28 | 0;
+ HEAP32[i35 >> 2] = i42;
+ if (!((i42 | 0) > -1)) {
+ i35 = 28;
+ break;
+ }
+ } else {
+ i35 = i4 + (i34 * 36 | 0) + 28 | 0;
+ HEAP32[i35 >> 2] = 0;
+ i42 = 0;
+ }
+ if ((i41 | 0) <= (i42 | 0)) {
+ i35 = 28;
+ break;
+ }
+ d45 = +HEAPF32[i40 + (i42 << 3) >> 2];
+ d43 = +HEAPF32[i40 + (i42 << 3) + 4 >> 2];
+ d38 = d16 + (d17 * d45 - d18 * d43);
+ d44 = +d38;
+ d43 = +(d45 * d18 + d17 * d43 + d21);
+ i40 = i39;
+ HEAPF32[i40 >> 2] = d44;
+ HEAPF32[i40 + 4 >> 2] = d43;
+ d43 = d36 * d19 + d37 * d22;
+ d44 = d37 * d19 - d36 * d22;
+ i40 = HEAP32[i23 >> 2] | 0;
+ i39 = HEAP32[i20 >> 2] | 0;
+ if ((i39 | 0) > 1) {
+ i41 = 0;
+ d37 = d44 * +HEAPF32[i40 + 4 >> 2] + d43 * +HEAPF32[i40 >> 2];
+ i42 = 1;
+ while (1) {
+ d36 = d43 * +HEAPF32[i40 + (i42 << 3) >> 2] + d44 * +HEAPF32[i40 + (i42 << 3) + 4 >> 2];
+ i46 = d36 > d37;
+ i41 = i46 ? i42 : i41;
+ i42 = i42 + 1 | 0;
+ if ((i42 | 0) == (i39 | 0)) {
+ break;
+ } else {
+ d37 = i46 ? d36 : d37;
+ }
+ }
+ i42 = i4 + (i34 * 36 | 0) + 32 | 0;
+ HEAP32[i42 >> 2] = i41;
+ if (!((i41 | 0) > -1)) {
+ i35 = 35;
+ break;
+ }
+ } else {
+ i42 = i4 + (i34 * 36 | 0) + 32 | 0;
+ HEAP32[i42 >> 2] = 0;
+ i41 = 0;
+ }
+ if ((i39 | 0) <= (i41 | 0)) {
+ i35 = 35;
+ break;
+ }
+ d37 = +HEAPF32[i40 + (i41 << 3) >> 2];
+ d45 = +HEAPF32[i40 + (i41 << 3) + 4 >> 2];
+ d44 = d24 + (d19 * d37 - d22 * d45);
+ d43 = +d44;
+ d45 = +(d37 * d22 + d19 * d45 + d25);
+ i46 = i4 + (i34 * 36 | 0) + 8 | 0;
+ HEAPF32[i46 >> 2] = d43;
+ HEAPF32[i46 + 4 >> 2] = d45;
+ d44 = +(d44 - d38);
+ d45 = +(+HEAPF32[i4 + (i34 * 36 | 0) + 12 >> 2] - +HEAPF32[i4 + (i34 * 36 | 0) + 4 >> 2]);
+ i46 = i4 + (i34 * 36 | 0) + 16 | 0;
+ HEAPF32[i46 >> 2] = d44;
+ HEAPF32[i46 + 4 >> 2] = d45;
+ i33 = i33 + 1 | 0;
+ HEAP32[654] = (HEAP32[654] | 0) + 1;
+ if (i32) {
+ i34 = HEAP32[i35 >> 2] | 0;
+ i32 = 0;
+ do {
+ if ((i34 | 0) == (HEAP32[i14 + (i32 << 2) >> 2] | 0) ? (HEAP32[i42 >> 2] | 0) == (HEAP32[i15 + (i32 << 2) >> 2] | 0) : 0) {
+ i35 = 42;
+ break L3;
+ }
+ i32 = i32 + 1 | 0;
+ } while ((i32 | 0) < (i31 | 0));
+ }
+ i31 = (HEAP32[i9 >> 2] | 0) + 1 | 0;
+ HEAP32[i9 >> 2] = i31;
+ if ((i33 | 0) >= 20) {
+ i35 = 42;
+ break;
+ }
+ }
+ if ((i35 | 0) == 13) {
+ ___assert_fail(2712, 2672, 498, 2720);
+ } else if ((i35 | 0) == 15) {
+ ___assert_fail(2712, 2672, 194, 2856);
+ } else if ((i35 | 0) == 16) {
+ ___assert_fail(2712, 2672, 207, 2856);
+ } else if ((i35 | 0) == 28) {
+ ___assert_fail(2776, 2808, 103, 2840);
+ } else if ((i35 | 0) == 35) {
+ ___assert_fail(2776, 2808, 103, 2840);
+ } else if ((i35 | 0) == 42) {
+ i12 = HEAP32[656] | 0;
+ HEAP32[656] = (i12 | 0) > (i33 | 0) ? i12 : i33;
+ i14 = i2 + 8 | 0;
+ __ZNK9b2Simplex16GetWitnessPointsEP6b2Vec2S1_(i4, i2, i14);
+ d44 = +HEAPF32[i2 >> 2] - +HEAPF32[i14 >> 2];
+ i13 = i2 + 4 | 0;
+ i12 = i2 + 12 | 0;
+ d45 = +HEAPF32[i13 >> 2] - +HEAPF32[i12 >> 2];
+ i15 = i2 + 16 | 0;
+ HEAPF32[i15 >> 2] = +Math_sqrt(+(d44 * d44 + d45 * d45));
+ HEAP32[i2 + 20 >> 2] = i33;
+ i9 = HEAP32[i9 >> 2] | 0;
+ if ((i9 | 0) == 2) {
+ d45 = +HEAPF32[i8 >> 2] - +HEAPF32[i11 >> 2];
+ d7 = +HEAPF32[i6 >> 2] - +HEAPF32[i10 >> 2];
+ d7 = +Math_sqrt(+(d45 * d45 + d7 * d7));
+ } else if ((i9 | 0) == 3) {
+ d7 = +HEAPF32[i8 >> 2];
+ d45 = +HEAPF32[i6 >> 2];
+ d7 = (+HEAPF32[i11 >> 2] - d7) * (+HEAPF32[i4 + 92 >> 2] - d45) - (+HEAPF32[i10 >> 2] - d45) * (+HEAPF32[i4 + 88 >> 2] - d7);
+ } else if ((i9 | 0) == 1) {
+ d7 = 0.0;
+ } else if ((i9 | 0) == 0) {
+ ___assert_fail(2712, 2672, 246, 2736);
+ } else {
+ ___assert_fail(2712, 2672, 259, 2736);
+ }
+ HEAPF32[i5 >> 2] = d7;
+ HEAP16[i5 + 4 >> 1] = i9;
+ i6 = 0;
+ do {
+ HEAP8[i5 + i6 + 6 | 0] = HEAP32[i4 + (i6 * 36 | 0) + 28 >> 2];
+ HEAP8[i5 + i6 + 9 | 0] = HEAP32[i4 + (i6 * 36 | 0) + 32 >> 2];
+ i6 = i6 + 1 | 0;
+ } while ((i6 | 0) < (i9 | 0));
+ if ((HEAP8[i3 + 88 | 0] | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ d7 = +HEAPF32[i3 + 24 >> 2];
+ d16 = +HEAPF32[i3 + 52 >> 2];
+ d18 = +HEAPF32[i15 >> 2];
+ d17 = d7 + d16;
+ if (!(d18 > d17 & d18 > 1.1920928955078125e-7)) {
+ d44 = +((+HEAPF32[i2 >> 2] + +HEAPF32[i14 >> 2]) * .5);
+ d45 = +((+HEAPF32[i13 >> 2] + +HEAPF32[i12 >> 2]) * .5);
+ i46 = i2;
+ HEAPF32[i46 >> 2] = d44;
+ HEAPF32[i46 + 4 >> 2] = d45;
+ i46 = i14;
+ HEAPF32[i46 >> 2] = d44;
+ HEAPF32[i46 + 4 >> 2] = d45;
+ HEAPF32[i15 >> 2] = 0.0;
+ STACKTOP = i1;
+ return;
+ }
+ HEAPF32[i15 >> 2] = d18 - d17;
+ d18 = +HEAPF32[i14 >> 2];
+ d21 = +HEAPF32[i2 >> 2];
+ d24 = d18 - d21;
+ d17 = +HEAPF32[i12 >> 2];
+ d19 = +HEAPF32[i13 >> 2];
+ d22 = d17 - d19;
+ d25 = +Math_sqrt(+(d24 * d24 + d22 * d22));
+ if (!(d25 < 1.1920928955078125e-7)) {
+ d45 = 1.0 / d25;
+ d24 = d24 * d45;
+ d22 = d22 * d45;
+ }
+ HEAPF32[i2 >> 2] = d7 * d24 + d21;
+ HEAPF32[i13 >> 2] = d7 * d22 + d19;
+ HEAPF32[i14 >> 2] = d18 - d16 * d24;
+ HEAPF32[i12 >> 2] = d17 - d16 * d22;
+ STACKTOP = i1;
+ return;
+ }
+ } else if ((i31 | 0) == 0) {
+ ___assert_fail(2712, 2672, 194, 2856);
+ } else {
+ ___assert_fail(2712, 2672, 207, 2856);
+ }
+}
+function __ZN8b2Island5SolveEP9b2ProfileRK10b2TimeStepRK6b2Vec2b(i4, i8, i11, i17, i7) {
+ i4 = i4 | 0;
+ i8 = i8 | 0;
+ i11 = i11 | 0;
+ i17 = i17 | 0;
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, d5 = 0.0, i6 = 0, i9 = 0, i10 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i18 = 0, i19 = 0, i20 = 0, d21 = 0.0, i22 = 0, d23 = 0.0, d24 = 0.0, d25 = 0.0, d26 = 0.0, d27 = 0.0, d28 = 0.0, d29 = 0.0, i30 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 160 | 0;
+ i6 = i3 + 128 | 0;
+ i9 = i3 + 148 | 0;
+ i10 = i3 + 96 | 0;
+ i16 = i3 + 52 | 0;
+ i2 = i3;
+ __ZN7b2TimerC2Ev(i9);
+ d5 = +HEAPF32[i11 >> 2];
+ i1 = i4 + 28 | 0;
+ if ((HEAP32[i1 >> 2] | 0) > 0) {
+ i13 = i4 + 8 | 0;
+ i12 = i17 + 4 | 0;
+ i15 = i4 + 20 | 0;
+ i14 = i4 + 24 | 0;
+ i19 = 0;
+ do {
+ i22 = HEAP32[(HEAP32[i13 >> 2] | 0) + (i19 << 2) >> 2] | 0;
+ i18 = i22 + 44 | 0;
+ i20 = HEAP32[i18 >> 2] | 0;
+ i18 = HEAP32[i18 + 4 >> 2] | 0;
+ d21 = +HEAPF32[i22 + 56 >> 2];
+ i30 = i22 + 64 | 0;
+ d27 = +HEAPF32[i30 >> 2];
+ d24 = +HEAPF32[i30 + 4 >> 2];
+ d23 = +HEAPF32[i22 + 72 >> 2];
+ i30 = i22 + 36 | 0;
+ HEAP32[i30 >> 2] = i20;
+ HEAP32[i30 + 4 >> 2] = i18;
+ HEAPF32[i22 + 52 >> 2] = d21;
+ if ((HEAP32[i22 >> 2] | 0) == 2) {
+ d25 = +HEAPF32[i22 + 140 >> 2];
+ d26 = +HEAPF32[i22 + 120 >> 2];
+ d28 = 1.0 - d5 * +HEAPF32[i22 + 132 >> 2];
+ d28 = d28 < 1.0 ? d28 : 1.0;
+ d28 = d28 < 0.0 ? 0.0 : d28;
+ d29 = 1.0 - d5 * +HEAPF32[i22 + 136 >> 2];
+ d29 = d29 < 1.0 ? d29 : 1.0;
+ d27 = (d27 + d5 * (d25 * +HEAPF32[i17 >> 2] + d26 * +HEAPF32[i22 + 76 >> 2])) * d28;
+ d24 = (d24 + d5 * (d25 * +HEAPF32[i12 >> 2] + d26 * +HEAPF32[i22 + 80 >> 2])) * d28;
+ d23 = (d23 + d5 * +HEAPF32[i22 + 128 >> 2] * +HEAPF32[i22 + 84 >> 2]) * (d29 < 0.0 ? 0.0 : d29);
+ }
+ i30 = (HEAP32[i15 >> 2] | 0) + (i19 * 12 | 0) | 0;
+ HEAP32[i30 >> 2] = i20;
+ HEAP32[i30 + 4 >> 2] = i18;
+ HEAPF32[(HEAP32[i15 >> 2] | 0) + (i19 * 12 | 0) + 8 >> 2] = d21;
+ d28 = +d27;
+ d29 = +d24;
+ i30 = (HEAP32[i14 >> 2] | 0) + (i19 * 12 | 0) | 0;
+ HEAPF32[i30 >> 2] = d28;
+ HEAPF32[i30 + 4 >> 2] = d29;
+ HEAPF32[(HEAP32[i14 >> 2] | 0) + (i19 * 12 | 0) + 8 >> 2] = d23;
+ i19 = i19 + 1 | 0;
+ } while ((i19 | 0) < (HEAP32[i1 >> 2] | 0));
+ } else {
+ i14 = i4 + 24 | 0;
+ i15 = i4 + 20 | 0;
+ }
+ HEAP32[i10 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
+ HEAP32[i10 + 12 >> 2] = HEAP32[i11 + 12 >> 2];
+ HEAP32[i10 + 16 >> 2] = HEAP32[i11 + 16 >> 2];
+ HEAP32[i10 + 20 >> 2] = HEAP32[i11 + 20 >> 2];
+ i22 = HEAP32[i15 >> 2] | 0;
+ HEAP32[i10 + 24 >> 2] = i22;
+ i30 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i10 + 28 >> 2] = i30;
+ HEAP32[i16 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
+ HEAP32[i16 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
+ HEAP32[i16 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
+ HEAP32[i16 + 12 >> 2] = HEAP32[i11 + 12 >> 2];
+ HEAP32[i16 + 16 >> 2] = HEAP32[i11 + 16 >> 2];
+ HEAP32[i16 + 20 >> 2] = HEAP32[i11 + 20 >> 2];
+ i13 = i4 + 12 | 0;
+ HEAP32[i16 + 24 >> 2] = HEAP32[i13 >> 2];
+ i12 = i4 + 36 | 0;
+ HEAP32[i16 + 28 >> 2] = HEAP32[i12 >> 2];
+ HEAP32[i16 + 32 >> 2] = i22;
+ HEAP32[i16 + 36 >> 2] = i30;
+ HEAP32[i16 + 40 >> 2] = HEAP32[i4 >> 2];
+ __ZN15b2ContactSolverC2EP18b2ContactSolverDef(i2, i16);
+ __ZN15b2ContactSolver29InitializeVelocityConstraintsEv(i2);
+ if ((HEAP8[i11 + 20 | 0] | 0) != 0) {
+ __ZN15b2ContactSolver9WarmStartEv(i2);
+ }
+ i16 = i4 + 32 | 0;
+ if ((HEAP32[i16 >> 2] | 0) > 0) {
+ i18 = i4 + 16 | 0;
+ i17 = 0;
+ do {
+ i30 = HEAP32[(HEAP32[i18 >> 2] | 0) + (i17 << 2) >> 2] | 0;
+ FUNCTION_TABLE_vii[HEAP32[(HEAP32[i30 >> 2] | 0) + 28 >> 2] & 15](i30, i10);
+ i17 = i17 + 1 | 0;
+ } while ((i17 | 0) < (HEAP32[i16 >> 2] | 0));
+ }
+ HEAPF32[i8 + 12 >> 2] = +__ZNK7b2Timer15GetMillisecondsEv(i9);
+ i17 = i11 + 12 | 0;
+ if ((HEAP32[i17 >> 2] | 0) > 0) {
+ i20 = i4 + 16 | 0;
+ i19 = 0;
+ do {
+ if ((HEAP32[i16 >> 2] | 0) > 0) {
+ i18 = 0;
+ do {
+ i30 = HEAP32[(HEAP32[i20 >> 2] | 0) + (i18 << 2) >> 2] | 0;
+ FUNCTION_TABLE_vii[HEAP32[(HEAP32[i30 >> 2] | 0) + 32 >> 2] & 15](i30, i10);
+ i18 = i18 + 1 | 0;
+ } while ((i18 | 0) < (HEAP32[i16 >> 2] | 0));
+ }
+ __ZN15b2ContactSolver24SolveVelocityConstraintsEv(i2);
+ i19 = i19 + 1 | 0;
+ } while ((i19 | 0) < (HEAP32[i17 >> 2] | 0));
+ }
+ __ZN15b2ContactSolver13StoreImpulsesEv(i2);
+ HEAPF32[i8 + 16 >> 2] = +__ZNK7b2Timer15GetMillisecondsEv(i9);
+ if ((HEAP32[i1 >> 2] | 0) > 0) {
+ i19 = HEAP32[i14 >> 2] | 0;
+ i18 = 0;
+ do {
+ i30 = HEAP32[i15 >> 2] | 0;
+ i17 = i30 + (i18 * 12 | 0) | 0;
+ i22 = i17;
+ d23 = +HEAPF32[i22 >> 2];
+ d21 = +HEAPF32[i22 + 4 >> 2];
+ d24 = +HEAPF32[i30 + (i18 * 12 | 0) + 8 >> 2];
+ i30 = i19 + (i18 * 12 | 0) | 0;
+ d26 = +HEAPF32[i30 >> 2];
+ d27 = +HEAPF32[i30 + 4 >> 2];
+ d25 = +HEAPF32[i19 + (i18 * 12 | 0) + 8 >> 2];
+ d29 = d5 * d26;
+ d28 = d5 * d27;
+ d28 = d29 * d29 + d28 * d28;
+ if (d28 > 4.0) {
+ d29 = 2.0 / +Math_sqrt(+d28);
+ d26 = d26 * d29;
+ d27 = d27 * d29;
+ }
+ d28 = d5 * d25;
+ if (d28 * d28 > 2.4674012660980225) {
+ if (!(d28 > 0.0)) {
+ d28 = -d28;
+ }
+ d25 = d25 * (1.5707963705062866 / d28);
+ }
+ d29 = +(d23 + d5 * d26);
+ d28 = +(d21 + d5 * d27);
+ i19 = i17;
+ HEAPF32[i19 >> 2] = d29;
+ HEAPF32[i19 + 4 >> 2] = d28;
+ HEAPF32[(HEAP32[i15 >> 2] | 0) + (i18 * 12 | 0) + 8 >> 2] = d24 + d5 * d25;
+ d28 = +d26;
+ d29 = +d27;
+ i19 = (HEAP32[i14 >> 2] | 0) + (i18 * 12 | 0) | 0;
+ HEAPF32[i19 >> 2] = d28;
+ HEAPF32[i19 + 4 >> 2] = d29;
+ i19 = HEAP32[i14 >> 2] | 0;
+ HEAPF32[i19 + (i18 * 12 | 0) + 8 >> 2] = d25;
+ i18 = i18 + 1 | 0;
+ } while ((i18 | 0) < (HEAP32[i1 >> 2] | 0));
+ }
+ i11 = i11 + 16 | 0;
+ L41 : do {
+ if ((HEAP32[i11 >> 2] | 0) > 0) {
+ i17 = i4 + 16 | 0;
+ i19 = 0;
+ while (1) {
+ i18 = __ZN15b2ContactSolver24SolvePositionConstraintsEv(i2) | 0;
+ if ((HEAP32[i16 >> 2] | 0) > 0) {
+ i20 = 0;
+ i22 = 1;
+ do {
+ i30 = HEAP32[(HEAP32[i17 >> 2] | 0) + (i20 << 2) >> 2] | 0;
+ i22 = i22 & (FUNCTION_TABLE_iii[HEAP32[(HEAP32[i30 >> 2] | 0) + 36 >> 2] & 3](i30, i10) | 0);
+ i20 = i20 + 1 | 0;
+ } while ((i20 | 0) < (HEAP32[i16 >> 2] | 0));
+ } else {
+ i22 = 1;
+ }
+ i19 = i19 + 1 | 0;
+ if (i18 & i22) {
+ i10 = 0;
+ break L41;
+ }
+ if ((i19 | 0) >= (HEAP32[i11 >> 2] | 0)) {
+ i10 = 1;
+ break;
+ }
+ }
+ } else {
+ i10 = 1;
+ }
+ } while (0);
+ if ((HEAP32[i1 >> 2] | 0) > 0) {
+ i11 = i4 + 8 | 0;
+ i16 = 0;
+ do {
+ i30 = HEAP32[(HEAP32[i11 >> 2] | 0) + (i16 << 2) >> 2] | 0;
+ i22 = (HEAP32[i15 >> 2] | 0) + (i16 * 12 | 0) | 0;
+ i20 = HEAP32[i22 >> 2] | 0;
+ i22 = HEAP32[i22 + 4 >> 2] | 0;
+ i17 = i30 + 44 | 0;
+ HEAP32[i17 >> 2] = i20;
+ HEAP32[i17 + 4 >> 2] = i22;
+ d27 = +HEAPF32[(HEAP32[i15 >> 2] | 0) + (i16 * 12 | 0) + 8 >> 2];
+ HEAPF32[i30 + 56 >> 2] = d27;
+ i17 = (HEAP32[i14 >> 2] | 0) + (i16 * 12 | 0) | 0;
+ i18 = HEAP32[i17 + 4 >> 2] | 0;
+ i19 = i30 + 64 | 0;
+ HEAP32[i19 >> 2] = HEAP32[i17 >> 2];
+ HEAP32[i19 + 4 >> 2] = i18;
+ HEAPF32[i30 + 72 >> 2] = +HEAPF32[(HEAP32[i14 >> 2] | 0) + (i16 * 12 | 0) + 8 >> 2];
+ d25 = +Math_sin(+d27);
+ HEAPF32[i30 + 20 >> 2] = d25;
+ d27 = +Math_cos(+d27);
+ HEAPF32[i30 + 24 >> 2] = d27;
+ d26 = +HEAPF32[i30 + 28 >> 2];
+ d29 = +HEAPF32[i30 + 32 >> 2];
+ d28 = (HEAP32[tempDoublePtr >> 2] = i20, +HEAPF32[tempDoublePtr >> 2]) - (d27 * d26 - d25 * d29);
+ d29 = (HEAP32[tempDoublePtr >> 2] = i22, +HEAPF32[tempDoublePtr >> 2]) - (d25 * d26 + d27 * d29);
+ d28 = +d28;
+ d29 = +d29;
+ i30 = i30 + 12 | 0;
+ HEAPF32[i30 >> 2] = d28;
+ HEAPF32[i30 + 4 >> 2] = d29;
+ i16 = i16 + 1 | 0;
+ } while ((i16 | 0) < (HEAP32[i1 >> 2] | 0));
+ }
+ HEAPF32[i8 + 20 >> 2] = +__ZNK7b2Timer15GetMillisecondsEv(i9);
+ i9 = HEAP32[i2 + 40 >> 2] | 0;
+ i8 = i4 + 4 | 0;
+ if ((HEAP32[i8 >> 2] | 0) != 0 ? (HEAP32[i12 >> 2] | 0) > 0 : 0) {
+ i11 = i6 + 16 | 0;
+ i14 = 0;
+ do {
+ i15 = HEAP32[(HEAP32[i13 >> 2] | 0) + (i14 << 2) >> 2] | 0;
+ i16 = HEAP32[i9 + (i14 * 152 | 0) + 144 >> 2] | 0;
+ HEAP32[i11 >> 2] = i16;
+ if ((i16 | 0) > 0) {
+ i17 = 0;
+ do {
+ HEAPF32[i6 + (i17 << 2) >> 2] = +HEAPF32[i9 + (i14 * 152 | 0) + (i17 * 36 | 0) + 16 >> 2];
+ HEAPF32[i6 + (i17 << 2) + 8 >> 2] = +HEAPF32[i9 + (i14 * 152 | 0) + (i17 * 36 | 0) + 20 >> 2];
+ i17 = i17 + 1 | 0;
+ } while ((i17 | 0) != (i16 | 0));
+ }
+ i30 = HEAP32[i8 >> 2] | 0;
+ FUNCTION_TABLE_viii[HEAP32[(HEAP32[i30 >> 2] | 0) + 20 >> 2] & 3](i30, i15, i6);
+ i14 = i14 + 1 | 0;
+ } while ((i14 | 0) < (HEAP32[i12 >> 2] | 0));
+ }
+ if (!i7) {
+ __ZN15b2ContactSolverD2Ev(i2);
+ STACKTOP = i3;
+ return;
+ }
+ i7 = HEAP32[i1 >> 2] | 0;
+ i6 = (i7 | 0) > 0;
+ if (i6) {
+ i8 = HEAP32[i4 + 8 >> 2] | 0;
+ i9 = 0;
+ d21 = 3.4028234663852886e+38;
+ do {
+ i11 = HEAP32[i8 + (i9 << 2) >> 2] | 0;
+ do {
+ if ((HEAP32[i11 >> 2] | 0) != 0) {
+ if ((!((HEAP16[i11 + 4 >> 1] & 4) == 0) ? (d29 = +HEAPF32[i11 + 72 >> 2], !(d29 * d29 > .001218469929881394)) : 0) ? (d28 = +HEAPF32[i11 + 64 >> 2], d29 = +HEAPF32[i11 + 68 >> 2], !(d28 * d28 + d29 * d29 > 9999999747378752.0e-20)) : 0) {
+ i30 = i11 + 144 | 0;
+ d23 = d5 + +HEAPF32[i30 >> 2];
+ HEAPF32[i30 >> 2] = d23;
+ d21 = d21 < d23 ? d21 : d23;
+ break;
+ }
+ HEAPF32[i11 + 144 >> 2] = 0.0;
+ d21 = 0.0;
+ }
+ } while (0);
+ i9 = i9 + 1 | 0;
+ } while ((i9 | 0) < (i7 | 0));
+ } else {
+ d21 = 3.4028234663852886e+38;
+ }
+ if (!(d21 >= .5) | i10 | i6 ^ 1) {
+ __ZN15b2ContactSolverD2Ev(i2);
+ STACKTOP = i3;
+ return;
+ }
+ i4 = i4 + 8 | 0;
+ i6 = 0;
+ do {
+ i30 = HEAP32[(HEAP32[i4 >> 2] | 0) + (i6 << 2) >> 2] | 0;
+ i22 = i30 + 4 | 0;
+ HEAP16[i22 >> 1] = HEAP16[i22 >> 1] & 65533;
+ HEAPF32[i30 + 144 >> 2] = 0.0;
+ i30 = i30 + 64 | 0;
+ HEAP32[i30 + 0 >> 2] = 0;
+ HEAP32[i30 + 4 >> 2] = 0;
+ HEAP32[i30 + 8 >> 2] = 0;
+ HEAP32[i30 + 12 >> 2] = 0;
+ HEAP32[i30 + 16 >> 2] = 0;
+ HEAP32[i30 + 20 >> 2] = 0;
+ i6 = i6 + 1 | 0;
+ } while ((i6 | 0) < (HEAP32[i1 >> 2] | 0));
+ __ZN15b2ContactSolverD2Ev(i2);
+ STACKTOP = i3;
+ return;
+}
+function __ZN15b2ContactSolver24SolveVelocityConstraintsEv(i4) {
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, d9 = 0.0, d10 = 0.0, d11 = 0.0, d12 = 0.0, d13 = 0.0, d14 = 0.0, d15 = 0.0, d16 = 0.0, d17 = 0.0, d18 = 0.0, i19 = 0, d20 = 0.0, d21 = 0.0, i22 = 0, d23 = 0.0, d24 = 0.0, d25 = 0.0, d26 = 0.0, d27 = 0.0, d28 = 0.0, d29 = 0.0, d30 = 0.0, d31 = 0.0, i32 = 0, i33 = 0, d34 = 0.0, d35 = 0.0, d36 = 0.0, d37 = 0.0, d38 = 0.0, d39 = 0.0, d40 = 0.0, i41 = 0, i42 = 0, d43 = 0.0, d44 = 0.0;
+ i1 = STACKTOP;
+ i2 = i4 + 48 | 0;
+ if ((HEAP32[i2 >> 2] | 0) <= 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i3 = i4 + 40 | 0;
+ i4 = i4 + 28 | 0;
+ i42 = HEAP32[i4 >> 2] | 0;
+ i5 = 0;
+ L4 : while (1) {
+ i19 = HEAP32[i3 >> 2] | 0;
+ i22 = i19 + (i5 * 152 | 0) | 0;
+ i8 = HEAP32[i19 + (i5 * 152 | 0) + 112 >> 2] | 0;
+ i6 = HEAP32[i19 + (i5 * 152 | 0) + 116 >> 2] | 0;
+ d12 = +HEAPF32[i19 + (i5 * 152 | 0) + 120 >> 2];
+ d10 = +HEAPF32[i19 + (i5 * 152 | 0) + 128 >> 2];
+ d11 = +HEAPF32[i19 + (i5 * 152 | 0) + 124 >> 2];
+ d9 = +HEAPF32[i19 + (i5 * 152 | 0) + 132 >> 2];
+ i32 = i19 + (i5 * 152 | 0) + 144 | 0;
+ i33 = HEAP32[i32 >> 2] | 0;
+ i7 = i42 + (i8 * 12 | 0) | 0;
+ i41 = i7;
+ d21 = +HEAPF32[i41 >> 2];
+ d20 = +HEAPF32[i41 + 4 >> 2];
+ i41 = i42 + (i6 * 12 | 0) | 0;
+ d14 = +HEAPF32[i41 >> 2];
+ d13 = +HEAPF32[i41 + 4 >> 2];
+ i41 = i19 + (i5 * 152 | 0) + 72 | 0;
+ d17 = +HEAPF32[i41 >> 2];
+ d16 = +HEAPF32[i41 + 4 >> 2];
+ d23 = -d17;
+ d24 = +HEAPF32[i19 + (i5 * 152 | 0) + 136 >> 2];
+ if ((i33 + -1 | 0) >>> 0 < 2) {
+ i41 = 0;
+ d18 = +HEAPF32[i42 + (i8 * 12 | 0) + 8 >> 2];
+ d15 = +HEAPF32[i42 + (i6 * 12 | 0) + 8 >> 2];
+ } else {
+ i2 = 4;
+ break;
+ }
+ do {
+ d30 = +HEAPF32[i19 + (i5 * 152 | 0) + (i41 * 36 | 0) + 12 >> 2];
+ d25 = +HEAPF32[i19 + (i5 * 152 | 0) + (i41 * 36 | 0) + 8 >> 2];
+ d26 = +HEAPF32[i19 + (i5 * 152 | 0) + (i41 * 36 | 0) + 4 >> 2];
+ d27 = +HEAPF32[i19 + (i5 * 152 | 0) + (i41 * 36 | 0) >> 2];
+ d34 = d24 * +HEAPF32[i19 + (i5 * 152 | 0) + (i41 * 36 | 0) + 16 >> 2];
+ i42 = i19 + (i5 * 152 | 0) + (i41 * 36 | 0) + 20 | 0;
+ d28 = +HEAPF32[i42 >> 2];
+ d31 = d28 - +HEAPF32[i19 + (i5 * 152 | 0) + (i41 * 36 | 0) + 28 >> 2] * (d16 * (d14 - d15 * d30 - d21 + d18 * d26) + (d13 + d15 * d25 - d20 - d18 * d27) * d23);
+ d29 = -d34;
+ d31 = d31 < d34 ? d31 : d34;
+ d40 = d31 < d29 ? d29 : d31;
+ d39 = d40 - d28;
+ HEAPF32[i42 >> 2] = d40;
+ d40 = d16 * d39;
+ d39 = d39 * d23;
+ d21 = d21 - d12 * d40;
+ d20 = d20 - d12 * d39;
+ d18 = d18 - d10 * (d27 * d39 - d26 * d40);
+ d14 = d14 + d11 * d40;
+ d13 = d13 + d11 * d39;
+ d15 = d15 + d9 * (d25 * d39 - d30 * d40);
+ i41 = i41 + 1 | 0;
+ } while ((i41 | 0) != (i33 | 0));
+ do {
+ if ((HEAP32[i32 >> 2] | 0) != 1) {
+ i32 = i19 + (i5 * 152 | 0) + 16 | 0;
+ d31 = +HEAPF32[i32 >> 2];
+ i33 = i19 + (i5 * 152 | 0) + 52 | 0;
+ d34 = +HEAPF32[i33 >> 2];
+ if (!(d31 >= 0.0) | !(d34 >= 0.0)) {
+ i2 = 9;
+ break L4;
+ }
+ d23 = +HEAPF32[i19 + (i5 * 152 | 0) + 12 >> 2];
+ d24 = +HEAPF32[i19 + (i5 * 152 | 0) + 8 >> 2];
+ d26 = +HEAPF32[i19 + (i5 * 152 | 0) + 4 >> 2];
+ d30 = +HEAPF32[i22 >> 2];
+ d27 = +HEAPF32[i19 + (i5 * 152 | 0) + 48 >> 2];
+ d25 = +HEAPF32[i19 + (i5 * 152 | 0) + 44 >> 2];
+ d28 = +HEAPF32[i19 + (i5 * 152 | 0) + 40 >> 2];
+ d29 = +HEAPF32[i19 + (i5 * 152 | 0) + 36 >> 2];
+ d37 = +HEAPF32[i19 + (i5 * 152 | 0) + 104 >> 2];
+ d38 = +HEAPF32[i19 + (i5 * 152 | 0) + 100 >> 2];
+ d35 = d17 * (d14 - d15 * d23 - d21 + d18 * d26) + d16 * (d13 + d15 * d24 - d20 - d18 * d30) - +HEAPF32[i19 + (i5 * 152 | 0) + 32 >> 2] - (d31 * +HEAPF32[i19 + (i5 * 152 | 0) + 96 >> 2] + d34 * d37);
+ d36 = d17 * (d14 - d15 * d27 - d21 + d18 * d28) + d16 * (d13 + d15 * d25 - d20 - d18 * d29) - +HEAPF32[i19 + (i5 * 152 | 0) + 68 >> 2] - (d31 * d38 + d34 * +HEAPF32[i19 + (i5 * 152 | 0) + 108 >> 2]);
+ d44 = +HEAPF32[i19 + (i5 * 152 | 0) + 80 >> 2] * d35 + +HEAPF32[i19 + (i5 * 152 | 0) + 88 >> 2] * d36;
+ d43 = d35 * +HEAPF32[i19 + (i5 * 152 | 0) + 84 >> 2] + d36 * +HEAPF32[i19 + (i5 * 152 | 0) + 92 >> 2];
+ d40 = -d44;
+ d39 = -d43;
+ if (!(!(d44 <= -0.0) | !(d43 <= -0.0))) {
+ d37 = d40 - d31;
+ d43 = d39 - d34;
+ d38 = d17 * d37;
+ d37 = d16 * d37;
+ d44 = d17 * d43;
+ d43 = d16 * d43;
+ d35 = d38 + d44;
+ d36 = d37 + d43;
+ HEAPF32[i32 >> 2] = d40;
+ HEAPF32[i33 >> 2] = d39;
+ d21 = d21 - d12 * d35;
+ d20 = d20 - d12 * d36;
+ d14 = d14 + d11 * d35;
+ d13 = d13 + d11 * d36;
+ d18 = d18 - d10 * (d30 * d37 - d26 * d38 + (d29 * d43 - d28 * d44));
+ d15 = d15 + d9 * (d24 * d37 - d23 * d38 + (d25 * d43 - d27 * d44));
+ break;
+ }
+ d44 = d35 * +HEAPF32[i19 + (i5 * 152 | 0) + 24 >> 2];
+ d39 = -d44;
+ if (d44 <= -0.0 ? d36 + d38 * d39 >= 0.0 : 0) {
+ d38 = d39 - d31;
+ d43 = 0.0 - d34;
+ d40 = d17 * d38;
+ d38 = d16 * d38;
+ d44 = d17 * d43;
+ d43 = d16 * d43;
+ d36 = d44 + d40;
+ d37 = d43 + d38;
+ HEAPF32[i32 >> 2] = d39;
+ HEAPF32[i33 >> 2] = 0.0;
+ d21 = d21 - d12 * d36;
+ d20 = d20 - d12 * d37;
+ d14 = d14 + d11 * d36;
+ d13 = d13 + d11 * d37;
+ d18 = d18 - d10 * (d38 * d30 - d40 * d26 + (d43 * d29 - d44 * d28));
+ d15 = d15 + d9 * (d38 * d24 - d40 * d23 + (d43 * d25 - d44 * d27));
+ break;
+ }
+ d44 = d36 * +HEAPF32[i19 + (i5 * 152 | 0) + 60 >> 2];
+ d38 = -d44;
+ if (d44 <= -0.0 ? d35 + d37 * d38 >= 0.0 : 0) {
+ d39 = 0.0 - d31;
+ d43 = d38 - d34;
+ d40 = d17 * d39;
+ d39 = d16 * d39;
+ d44 = d17 * d43;
+ d43 = d16 * d43;
+ d36 = d40 + d44;
+ d37 = d39 + d43;
+ HEAPF32[i32 >> 2] = 0.0;
+ HEAPF32[i33 >> 2] = d38;
+ d21 = d21 - d12 * d36;
+ d20 = d20 - d12 * d37;
+ d14 = d14 + d11 * d36;
+ d13 = d13 + d11 * d37;
+ d18 = d18 - d10 * (d39 * d30 - d40 * d26 + (d43 * d29 - d44 * d28));
+ d15 = d15 + d9 * (d39 * d24 - d40 * d23 + (d43 * d25 - d44 * d27));
+ break;
+ }
+ if (!(!(d35 >= 0.0) | !(d36 >= 0.0))) {
+ d39 = 0.0 - d31;
+ d43 = 0.0 - d34;
+ d40 = d17 * d39;
+ d39 = d16 * d39;
+ d44 = d17 * d43;
+ d43 = d16 * d43;
+ d37 = d40 + d44;
+ d38 = d39 + d43;
+ HEAPF32[i32 >> 2] = 0.0;
+ HEAPF32[i33 >> 2] = 0.0;
+ d21 = d21 - d12 * d37;
+ d20 = d20 - d12 * d38;
+ d14 = d14 + d11 * d37;
+ d13 = d13 + d11 * d38;
+ d18 = d18 - d10 * (d39 * d30 - d40 * d26 + (d43 * d29 - d44 * d28));
+ d15 = d15 + d9 * (d39 * d24 - d40 * d23 + (d43 * d25 - d44 * d27));
+ }
+ } else {
+ d23 = +HEAPF32[i19 + (i5 * 152 | 0) + 12 >> 2];
+ d24 = +HEAPF32[i19 + (i5 * 152 | 0) + 8 >> 2];
+ d25 = +HEAPF32[i19 + (i5 * 152 | 0) + 4 >> 2];
+ d26 = +HEAPF32[i22 >> 2];
+ i22 = i19 + (i5 * 152 | 0) + 16 | 0;
+ d27 = +HEAPF32[i22 >> 2];
+ d28 = d27 - +HEAPF32[i19 + (i5 * 152 | 0) + 24 >> 2] * (d17 * (d14 - d15 * d23 - d21 + d18 * d25) + d16 * (d13 + d15 * d24 - d20 - d18 * d26) - +HEAPF32[i19 + (i5 * 152 | 0) + 32 >> 2]);
+ d44 = d28 > 0.0 ? d28 : 0.0;
+ d43 = d44 - d27;
+ HEAPF32[i22 >> 2] = d44;
+ d44 = d17 * d43;
+ d43 = d16 * d43;
+ d21 = d21 - d12 * d44;
+ d20 = d20 - d12 * d43;
+ d14 = d14 + d11 * d44;
+ d13 = d13 + d11 * d43;
+ d18 = d18 - d10 * (d26 * d43 - d25 * d44);
+ d15 = d15 + d9 * (d24 * d43 - d23 * d44);
+ }
+ } while (0);
+ d44 = +d21;
+ d43 = +d20;
+ i42 = i7;
+ HEAPF32[i42 >> 2] = d44;
+ HEAPF32[i42 + 4 >> 2] = d43;
+ i42 = HEAP32[i4 >> 2] | 0;
+ HEAPF32[i42 + (i8 * 12 | 0) + 8 >> 2] = d18;
+ d43 = +d14;
+ d44 = +d13;
+ i42 = i42 + (i6 * 12 | 0) | 0;
+ HEAPF32[i42 >> 2] = d43;
+ HEAPF32[i42 + 4 >> 2] = d44;
+ i42 = HEAP32[i4 >> 2] | 0;
+ HEAPF32[i42 + (i6 * 12 | 0) + 8 >> 2] = d15;
+ i5 = i5 + 1 | 0;
+ if ((i5 | 0) >= (HEAP32[i2 >> 2] | 0)) {
+ i2 = 21;
+ break;
+ }
+ }
+ if ((i2 | 0) == 4) {
+ ___assert_fail(6648, 6520, 311, 6688);
+ } else if ((i2 | 0) == 9) {
+ ___assert_fail(6720, 6520, 406, 6688);
+ } else if ((i2 | 0) == 21) {
+ STACKTOP = i1;
+ return;
+ }
+}
+function __Z14b2TimeOfImpactP11b2TOIOutputPK10b2TOIInput(i3, i11) {
+ i3 = i3 | 0;
+ i11 = i11 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i12 = 0, i13 = 0, d14 = 0.0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, d28 = 0.0, i29 = 0, d30 = 0.0, d31 = 0.0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0, i37 = 0, i38 = 0, i39 = 0, d40 = 0.0, i41 = 0, d42 = 0.0, d43 = 0.0, i44 = 0, i45 = 0, d46 = 0.0, i47 = 0, d48 = 0.0, d49 = 0.0, d50 = 0.0, d51 = 0.0, i52 = 0, d53 = 0.0, d54 = 0.0, d55 = 0.0, d56 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 320 | 0;
+ i12 = i1 + 276 | 0;
+ i10 = i1 + 240 | 0;
+ i13 = i1 + 228 | 0;
+ i5 = i1 + 136 | 0;
+ i7 = i1 + 112 | 0;
+ i8 = i1 + 8 | 0;
+ i9 = i1 + 4 | 0;
+ i4 = i1;
+ HEAP32[874] = (HEAP32[874] | 0) + 1;
+ HEAP32[i3 >> 2] = 0;
+ i19 = i11 + 128 | 0;
+ i2 = i3 + 4 | 0;
+ HEAPF32[i2 >> 2] = +HEAPF32[i19 >> 2];
+ i6 = i11 + 28 | 0;
+ i16 = i12 + 0 | 0;
+ i15 = i11 + 56 | 0;
+ i17 = i16 + 36 | 0;
+ do {
+ HEAP32[i16 >> 2] = HEAP32[i15 >> 2];
+ i16 = i16 + 4 | 0;
+ i15 = i15 + 4 | 0;
+ } while ((i16 | 0) < (i17 | 0));
+ i16 = i10 + 0 | 0;
+ i15 = i11 + 92 | 0;
+ i17 = i16 + 36 | 0;
+ do {
+ HEAP32[i16 >> 2] = HEAP32[i15 >> 2];
+ i16 = i16 + 4 | 0;
+ i15 = i15 + 4 | 0;
+ } while ((i16 | 0) < (i17 | 0));
+ i15 = i12 + 24 | 0;
+ d42 = +HEAPF32[i15 >> 2];
+ d43 = +Math_floor(+(d42 / 6.2831854820251465)) * 6.2831854820251465;
+ d42 = d42 - d43;
+ HEAPF32[i15 >> 2] = d42;
+ i16 = i12 + 28 | 0;
+ d43 = +HEAPF32[i16 >> 2] - d43;
+ HEAPF32[i16 >> 2] = d43;
+ i17 = i10 + 24 | 0;
+ d46 = +HEAPF32[i17 >> 2];
+ d40 = +Math_floor(+(d46 / 6.2831854820251465)) * 6.2831854820251465;
+ d46 = d46 - d40;
+ HEAPF32[i17 >> 2] = d46;
+ i18 = i10 + 28 | 0;
+ d40 = +HEAPF32[i18 >> 2] - d40;
+ HEAPF32[i18 >> 2] = d40;
+ d14 = +HEAPF32[i19 >> 2];
+ d28 = +HEAPF32[i11 + 24 >> 2] + +HEAPF32[i11 + 52 >> 2] + -.014999999664723873;
+ d28 = d28 < .004999999888241291 ? .004999999888241291 : d28;
+ if (!(d28 > .0012499999720603228)) {
+ ___assert_fail(3536, 3560, 280, 3600);
+ }
+ HEAP16[i13 + 4 >> 1] = 0;
+ HEAP32[i5 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
+ HEAP32[i5 + 12 >> 2] = HEAP32[i11 + 12 >> 2];
+ HEAP32[i5 + 16 >> 2] = HEAP32[i11 + 16 >> 2];
+ HEAP32[i5 + 20 >> 2] = HEAP32[i11 + 20 >> 2];
+ HEAP32[i5 + 24 >> 2] = HEAP32[i11 + 24 >> 2];
+ i38 = i5 + 28 | 0;
+ HEAP32[i38 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i38 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i38 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i38 + 12 >> 2] = HEAP32[i6 + 12 >> 2];
+ HEAP32[i38 + 16 >> 2] = HEAP32[i6 + 16 >> 2];
+ HEAP32[i38 + 20 >> 2] = HEAP32[i6 + 20 >> 2];
+ HEAP32[i38 + 24 >> 2] = HEAP32[i6 + 24 >> 2];
+ HEAP8[i5 + 88 | 0] = 0;
+ i38 = i12 + 8 | 0;
+ i27 = i12 + 12 | 0;
+ i29 = i12 + 16 | 0;
+ i22 = i12 + 20 | 0;
+ i32 = i12 + 4 | 0;
+ i34 = i10 + 8 | 0;
+ i36 = i10 + 12 | 0;
+ i35 = i10 + 16 | 0;
+ i37 = i10 + 20 | 0;
+ i33 = i10 + 4 | 0;
+ i26 = i5 + 56 | 0;
+ i25 = i5 + 64 | 0;
+ i24 = i5 + 68 | 0;
+ i23 = i5 + 72 | 0;
+ i20 = i5 + 80 | 0;
+ i19 = i5 + 84 | 0;
+ i21 = i7 + 16 | 0;
+ d30 = d28 + .0012499999720603228;
+ d31 = d28 + -.0012499999720603228;
+ d48 = d40;
+ i39 = 0;
+ d40 = 0.0;
+ L4 : while (1) {
+ d56 = 1.0 - d40;
+ d49 = d56 * d42 + d40 * d43;
+ d43 = +Math_sin(+d49);
+ d49 = +Math_cos(+d49);
+ d55 = +HEAPF32[i12 >> 2];
+ d54 = +HEAPF32[i32 >> 2];
+ d42 = d56 * d46 + d40 * d48;
+ d53 = +Math_sin(+d42);
+ d42 = +Math_cos(+d42);
+ d46 = +HEAPF32[i10 >> 2];
+ d51 = +HEAPF32[i33 >> 2];
+ d50 = d56 * +HEAPF32[i34 >> 2] + d40 * +HEAPF32[i35 >> 2] - (d42 * d46 - d53 * d51);
+ d51 = d56 * +HEAPF32[i36 >> 2] + d40 * +HEAPF32[i37 >> 2] - (d53 * d46 + d42 * d51);
+ d46 = +(d56 * +HEAPF32[i38 >> 2] + d40 * +HEAPF32[i29 >> 2] - (d49 * d55 - d43 * d54));
+ d48 = +(d56 * +HEAPF32[i27 >> 2] + d40 * +HEAPF32[i22 >> 2] - (d43 * d55 + d49 * d54));
+ i52 = i26;
+ HEAPF32[i52 >> 2] = d46;
+ HEAPF32[i52 + 4 >> 2] = d48;
+ HEAPF32[i25 >> 2] = d43;
+ HEAPF32[i24 >> 2] = d49;
+ d50 = +d50;
+ d51 = +d51;
+ i52 = i23;
+ HEAPF32[i52 >> 2] = d50;
+ HEAPF32[i52 + 4 >> 2] = d51;
+ HEAPF32[i20 >> 2] = d53;
+ HEAPF32[i19 >> 2] = d42;
+ __Z10b2DistanceP16b2DistanceOutputP14b2SimplexCachePK15b2DistanceInput(i7, i13, i5);
+ d42 = +HEAPF32[i21 >> 2];
+ if (d42 <= 0.0) {
+ i4 = 5;
+ break;
+ }
+ if (d42 < d30) {
+ i4 = 7;
+ break;
+ }
+ +__ZN20b2SeparationFunction10InitializeEPK14b2SimplexCachePK15b2DistanceProxyRK7b2SweepS5_S8_f(i8, i13, i11, i12, i6, i10, d40);
+ i41 = 0;
+ d42 = d14;
+ do {
+ d50 = +__ZNK20b2SeparationFunction17FindMinSeparationEPiS0_f(i8, i9, i4, d42);
+ if (d50 > d30) {
+ i4 = 10;
+ break L4;
+ }
+ if (d50 > d31) {
+ d40 = d42;
+ break;
+ }
+ i45 = HEAP32[i9 >> 2] | 0;
+ i44 = HEAP32[i4 >> 2] | 0;
+ d48 = +__ZNK20b2SeparationFunction8EvaluateEiif(i8, i45, i44, d40);
+ if (d48 < d31) {
+ i4 = 13;
+ break L4;
+ }
+ if (!(d48 <= d30)) {
+ d43 = d40;
+ d46 = d42;
+ i47 = 0;
+ } else {
+ i4 = 15;
+ break L4;
+ }
+ while (1) {
+ if ((i47 & 1 | 0) == 0) {
+ d49 = (d43 + d46) * .5;
+ } else {
+ d49 = d43 + (d28 - d48) * (d46 - d43) / (d50 - d48);
+ }
+ d51 = +__ZNK20b2SeparationFunction8EvaluateEiif(i8, i45, i44, d49);
+ d53 = d51 - d28;
+ if (!(d53 > 0.0)) {
+ d53 = -d53;
+ }
+ if (d53 < .0012499999720603228) {
+ d42 = d49;
+ break;
+ }
+ i52 = d51 > d28;
+ i47 = i47 + 1 | 0;
+ HEAP32[880] = (HEAP32[880] | 0) + 1;
+ if ((i47 | 0) == 50) {
+ i47 = 50;
+ break;
+ } else {
+ d43 = i52 ? d49 : d43;
+ d46 = i52 ? d46 : d49;
+ d48 = i52 ? d51 : d48;
+ d50 = i52 ? d50 : d51;
+ }
+ }
+ i44 = HEAP32[882] | 0;
+ HEAP32[882] = (i44 | 0) > (i47 | 0) ? i44 : i47;
+ i41 = i41 + 1 | 0;
+ } while ((i41 | 0) != 8);
+ i39 = i39 + 1 | 0;
+ HEAP32[876] = (HEAP32[876] | 0) + 1;
+ if ((i39 | 0) == 20) {
+ i4 = 27;
+ break;
+ }
+ d42 = +HEAPF32[i15 >> 2];
+ d43 = +HEAPF32[i16 >> 2];
+ d46 = +HEAPF32[i17 >> 2];
+ d48 = +HEAPF32[i18 >> 2];
+ }
+ if ((i4 | 0) == 5) {
+ HEAP32[i3 >> 2] = 2;
+ HEAPF32[i2 >> 2] = 0.0;
+ i2 = HEAP32[878] | 0;
+ i52 = (i2 | 0) > (i39 | 0);
+ i52 = i52 ? i2 : i39;
+ HEAP32[878] = i52;
+ STACKTOP = i1;
+ return;
+ } else if ((i4 | 0) == 7) {
+ HEAP32[i3 >> 2] = 3;
+ HEAPF32[i2 >> 2] = d40;
+ i2 = HEAP32[878] | 0;
+ i52 = (i2 | 0) > (i39 | 0);
+ i52 = i52 ? i2 : i39;
+ HEAP32[878] = i52;
+ STACKTOP = i1;
+ return;
+ } else if ((i4 | 0) == 10) {
+ HEAP32[i3 >> 2] = 4;
+ HEAPF32[i2 >> 2] = d14;
+ } else if ((i4 | 0) == 13) {
+ HEAP32[i3 >> 2] = 1;
+ HEAPF32[i2 >> 2] = d40;
+ } else if ((i4 | 0) == 15) {
+ HEAP32[i3 >> 2] = 3;
+ HEAPF32[i2 >> 2] = d40;
+ } else if ((i4 | 0) == 27) {
+ HEAP32[i3 >> 2] = 1;
+ HEAPF32[i2 >> 2] = d40;
+ i39 = 20;
+ i2 = HEAP32[878] | 0;
+ i52 = (i2 | 0) > (i39 | 0);
+ i52 = i52 ? i2 : i39;
+ HEAP32[878] = i52;
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[876] = (HEAP32[876] | 0) + 1;
+ i39 = i39 + 1 | 0;
+ i2 = HEAP32[878] | 0;
+ i52 = (i2 | 0) > (i39 | 0);
+ i52 = i52 ? i2 : i39;
+ HEAP32[878] = i52;
+ STACKTOP = i1;
+ return;
+}
+function __ZN7b2World5SolveERK10b2TimeStep(i5, i15) {
+ i5 = i5 | 0;
+ i15 = i15 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0, i37 = 0, i38 = 0, d39 = 0.0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 96 | 0;
+ i4 = i3 + 32 | 0;
+ i9 = i3;
+ i2 = i3 + 84 | 0;
+ i11 = i5 + 103008 | 0;
+ HEAPF32[i11 >> 2] = 0.0;
+ i14 = i5 + 103012 | 0;
+ HEAPF32[i14 >> 2] = 0.0;
+ i8 = i5 + 103016 | 0;
+ HEAPF32[i8 >> 2] = 0.0;
+ i16 = i5 + 102960 | 0;
+ i1 = i5 + 102872 | 0;
+ i6 = i5 + 68 | 0;
+ __ZN8b2IslandC2EiiiP16b2StackAllocatorP17b2ContactListener(i4, HEAP32[i16 >> 2] | 0, HEAP32[i5 + 102936 >> 2] | 0, HEAP32[i5 + 102964 >> 2] | 0, i6, HEAP32[i5 + 102944 >> 2] | 0);
+ i7 = i5 + 102952 | 0;
+ i17 = HEAP32[i7 >> 2] | 0;
+ if ((i17 | 0) != 0) {
+ do {
+ i38 = i17 + 4 | 0;
+ HEAP16[i38 >> 1] = HEAP16[i38 >> 1] & 65534;
+ i17 = HEAP32[i17 + 96 >> 2] | 0;
+ } while ((i17 | 0) != 0);
+ }
+ i17 = HEAP32[i5 + 102932 >> 2] | 0;
+ if ((i17 | 0) != 0) {
+ do {
+ i38 = i17 + 4 | 0;
+ HEAP32[i38 >> 2] = HEAP32[i38 >> 2] & -2;
+ i17 = HEAP32[i17 + 12 >> 2] | 0;
+ } while ((i17 | 0) != 0);
+ }
+ i17 = HEAP32[i5 + 102956 >> 2] | 0;
+ if ((i17 | 0) != 0) {
+ do {
+ HEAP8[i17 + 60 | 0] = 0;
+ i17 = HEAP32[i17 + 12 >> 2] | 0;
+ } while ((i17 | 0) != 0);
+ }
+ i24 = HEAP32[i16 >> 2] | 0;
+ i16 = __ZN16b2StackAllocator8AllocateEi(i6, i24 << 2) | 0;
+ i32 = HEAP32[i7 >> 2] | 0;
+ L13 : do {
+ if ((i32 | 0) != 0) {
+ i18 = i4 + 28 | 0;
+ i30 = i4 + 36 | 0;
+ i27 = i4 + 32 | 0;
+ i17 = i4 + 40 | 0;
+ i23 = i4 + 8 | 0;
+ i29 = i4 + 48 | 0;
+ i28 = i4 + 16 | 0;
+ i26 = i4 + 44 | 0;
+ i31 = i4 + 12 | 0;
+ i25 = i5 + 102968 | 0;
+ i22 = i5 + 102976 | 0;
+ i21 = i9 + 12 | 0;
+ i20 = i9 + 16 | 0;
+ i19 = i9 + 20 | 0;
+ L15 : while (1) {
+ i33 = i32 + 4 | 0;
+ i34 = HEAP16[i33 >> 1] | 0;
+ if ((i34 & 35) == 34 ? (HEAP32[i32 >> 2] | 0) != 0 : 0) {
+ HEAP32[i18 >> 2] = 0;
+ HEAP32[i30 >> 2] = 0;
+ HEAP32[i27 >> 2] = 0;
+ HEAP32[i16 >> 2] = i32;
+ HEAP16[i33 >> 1] = i34 & 65535 | 1;
+ i35 = 1;
+ do {
+ i35 = i35 + -1 | 0;
+ i33 = HEAP32[i16 + (i35 << 2) >> 2] | 0;
+ i34 = i33 + 4 | 0;
+ i36 = HEAP16[i34 >> 1] | 0;
+ if ((i36 & 32) == 0) {
+ i8 = 13;
+ break L15;
+ }
+ i37 = HEAP32[i18 >> 2] | 0;
+ if ((i37 | 0) >= (HEAP32[i17 >> 2] | 0)) {
+ i8 = 15;
+ break L15;
+ }
+ HEAP32[i33 + 8 >> 2] = i37;
+ i38 = HEAP32[i18 >> 2] | 0;
+ HEAP32[(HEAP32[i23 >> 2] | 0) + (i38 << 2) >> 2] = i33;
+ HEAP32[i18 >> 2] = i38 + 1;
+ i36 = i36 & 65535;
+ if ((i36 & 2 | 0) == 0) {
+ HEAP16[i34 >> 1] = i36 | 2;
+ HEAPF32[i33 + 144 >> 2] = 0.0;
+ }
+ if ((HEAP32[i33 >> 2] | 0) != 0) {
+ i34 = HEAP32[i33 + 112 >> 2] | 0;
+ if ((i34 | 0) != 0) {
+ do {
+ i38 = HEAP32[i34 + 4 >> 2] | 0;
+ i36 = i38 + 4 | 0;
+ if (((HEAP32[i36 >> 2] & 7 | 0) == 6 ? (HEAP8[(HEAP32[i38 + 48 >> 2] | 0) + 38 | 0] | 0) == 0 : 0) ? (HEAP8[(HEAP32[i38 + 52 >> 2] | 0) + 38 | 0] | 0) == 0 : 0) {
+ i37 = HEAP32[i30 >> 2] | 0;
+ if ((i37 | 0) >= (HEAP32[i26 >> 2] | 0)) {
+ i8 = 25;
+ break L15;
+ }
+ HEAP32[i30 >> 2] = i37 + 1;
+ HEAP32[(HEAP32[i31 >> 2] | 0) + (i37 << 2) >> 2] = i38;
+ HEAP32[i36 >> 2] = HEAP32[i36 >> 2] | 1;
+ i38 = HEAP32[i34 >> 2] | 0;
+ i36 = i38 + 4 | 0;
+ i37 = HEAP16[i36 >> 1] | 0;
+ if ((i37 & 1) == 0) {
+ if ((i35 | 0) >= (i24 | 0)) {
+ i8 = 28;
+ break L15;
+ }
+ HEAP32[i16 + (i35 << 2) >> 2] = i38;
+ HEAP16[i36 >> 1] = i37 & 65535 | 1;
+ i35 = i35 + 1 | 0;
+ }
+ }
+ i34 = HEAP32[i34 + 12 >> 2] | 0;
+ } while ((i34 | 0) != 0);
+ }
+ i33 = HEAP32[i33 + 108 >> 2] | 0;
+ if ((i33 | 0) != 0) {
+ do {
+ i37 = i33 + 4 | 0;
+ i36 = HEAP32[i37 >> 2] | 0;
+ if ((HEAP8[i36 + 60 | 0] | 0) == 0 ? (i10 = HEAP32[i33 >> 2] | 0, i13 = i10 + 4 | 0, i12 = HEAP16[i13 >> 1] | 0, !((i12 & 32) == 0)) : 0) {
+ i34 = HEAP32[i27 >> 2] | 0;
+ if ((i34 | 0) >= (HEAP32[i29 >> 2] | 0)) {
+ i8 = 35;
+ break L15;
+ }
+ HEAP32[i27 >> 2] = i34 + 1;
+ HEAP32[(HEAP32[i28 >> 2] | 0) + (i34 << 2) >> 2] = i36;
+ HEAP8[(HEAP32[i37 >> 2] | 0) + 60 | 0] = 1;
+ if ((i12 & 1) == 0) {
+ if ((i35 | 0) >= (i24 | 0)) {
+ i8 = 38;
+ break L15;
+ }
+ HEAP32[i16 + (i35 << 2) >> 2] = i10;
+ HEAP16[i13 >> 1] = i12 & 65535 | 1;
+ i35 = i35 + 1 | 0;
+ }
+ }
+ i33 = HEAP32[i33 + 12 >> 2] | 0;
+ } while ((i33 | 0) != 0);
+ }
+ }
+ } while ((i35 | 0) > 0);
+ __ZN8b2Island5SolveEP9b2ProfileRK10b2TimeStepRK6b2Vec2b(i4, i9, i15, i25, (HEAP8[i22] | 0) != 0);
+ HEAPF32[i11 >> 2] = +HEAPF32[i21 >> 2] + +HEAPF32[i11 >> 2];
+ HEAPF32[i14 >> 2] = +HEAPF32[i20 >> 2] + +HEAPF32[i14 >> 2];
+ HEAPF32[i8 >> 2] = +HEAPF32[i19 >> 2] + +HEAPF32[i8 >> 2];
+ i35 = HEAP32[i18 >> 2] | 0;
+ if ((i35 | 0) > 0) {
+ i33 = HEAP32[i23 >> 2] | 0;
+ i36 = 0;
+ do {
+ i34 = HEAP32[i33 + (i36 << 2) >> 2] | 0;
+ if ((HEAP32[i34 >> 2] | 0) == 0) {
+ i38 = i34 + 4 | 0;
+ HEAP16[i38 >> 1] = HEAP16[i38 >> 1] & 65534;
+ }
+ i36 = i36 + 1 | 0;
+ } while ((i36 | 0) < (i35 | 0));
+ }
+ }
+ i32 = HEAP32[i32 + 96 >> 2] | 0;
+ if ((i32 | 0) == 0) {
+ break L13;
+ }
+ }
+ if ((i8 | 0) == 13) {
+ ___assert_fail(2232, 2184, 445, 2256);
+ } else if ((i8 | 0) == 15) {
+ ___assert_fail(2520, 2440, 54, 2472);
+ } else if ((i8 | 0) == 25) {
+ ___assert_fail(2480, 2440, 62, 2472);
+ } else if ((i8 | 0) == 28) {
+ ___assert_fail(2264, 2184, 495, 2256);
+ } else if ((i8 | 0) == 35) {
+ ___assert_fail(2408, 2440, 68, 2472);
+ } else if ((i8 | 0) == 38) {
+ ___assert_fail(2264, 2184, 524, 2256);
+ }
+ }
+ } while (0);
+ __ZN16b2StackAllocator4FreeEPv(i6, i16);
+ __ZN7b2TimerC2Ev(i2);
+ i6 = HEAP32[i7 >> 2] | 0;
+ if ((i6 | 0) == 0) {
+ __ZN16b2ContactManager15FindNewContactsEv(i1);
+ d39 = +__ZNK7b2Timer15GetMillisecondsEv(i2);
+ i38 = i5 + 103020 | 0;
+ HEAPF32[i38 >> 2] = d39;
+ __ZN8b2IslandD2Ev(i4);
+ STACKTOP = i3;
+ return;
+ }
+ do {
+ if (!((HEAP16[i6 + 4 >> 1] & 1) == 0) ? (HEAP32[i6 >> 2] | 0) != 0 : 0) {
+ __ZN6b2Body19SynchronizeFixturesEv(i6);
+ }
+ i6 = HEAP32[i6 + 96 >> 2] | 0;
+ } while ((i6 | 0) != 0);
+ __ZN16b2ContactManager15FindNewContactsEv(i1);
+ d39 = +__ZNK7b2Timer15GetMillisecondsEv(i2);
+ i38 = i5 + 103020 | 0;
+ HEAPF32[i38 >> 2] = d39;
+ __ZN8b2IslandD2Ev(i4);
+ STACKTOP = i3;
+ return;
+}
+function __ZN15b2ContactSolver29InitializeVelocityConstraintsEv(i10) {
+ i10 = i10 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, d21 = 0.0, d22 = 0.0, d23 = 0.0, d24 = 0.0, d25 = 0.0, d26 = 0.0, d27 = 0.0, d28 = 0.0, d29 = 0.0, d30 = 0.0, i31 = 0, d32 = 0.0, i33 = 0, i34 = 0, i35 = 0, i36 = 0, i37 = 0, d38 = 0.0, d39 = 0.0, d40 = 0.0, d41 = 0.0, i42 = 0, d43 = 0.0, d44 = 0.0, d45 = 0.0, d46 = 0.0, d47 = 0.0, d48 = 0.0, i49 = 0, i50 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i8 = i1 + 40 | 0;
+ i3 = i1 + 24 | 0;
+ i5 = i1;
+ i4 = i10 + 48 | 0;
+ if ((HEAP32[i4 >> 2] | 0) <= 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i9 = i10 + 40 | 0;
+ i2 = i10 + 36 | 0;
+ i7 = i10 + 44 | 0;
+ i6 = i10 + 24 | 0;
+ i13 = i10 + 28 | 0;
+ i14 = i8 + 8 | 0;
+ i12 = i8 + 12 | 0;
+ i11 = i3 + 8 | 0;
+ i10 = i3 + 12 | 0;
+ i16 = 0;
+ while (1) {
+ i15 = HEAP32[i9 >> 2] | 0;
+ i33 = HEAP32[i2 >> 2] | 0;
+ i31 = HEAP32[(HEAP32[i7 >> 2] | 0) + (HEAP32[i15 + (i16 * 152 | 0) + 148 >> 2] << 2) >> 2] | 0;
+ i35 = HEAP32[i15 + (i16 * 152 | 0) + 112 >> 2] | 0;
+ i42 = HEAP32[i15 + (i16 * 152 | 0) + 116 >> 2] | 0;
+ d30 = +HEAPF32[i15 + (i16 * 152 | 0) + 120 >> 2];
+ d24 = +HEAPF32[i15 + (i16 * 152 | 0) + 124 >> 2];
+ d17 = +HEAPF32[i15 + (i16 * 152 | 0) + 128 >> 2];
+ d18 = +HEAPF32[i15 + (i16 * 152 | 0) + 132 >> 2];
+ i36 = i33 + (i16 * 88 | 0) + 48 | 0;
+ d39 = +HEAPF32[i36 >> 2];
+ d40 = +HEAPF32[i36 + 4 >> 2];
+ i36 = i33 + (i16 * 88 | 0) + 56 | 0;
+ d41 = +HEAPF32[i36 >> 2];
+ d43 = +HEAPF32[i36 + 4 >> 2];
+ i36 = HEAP32[i6 >> 2] | 0;
+ i37 = i36 + (i35 * 12 | 0) | 0;
+ d26 = +HEAPF32[i37 >> 2];
+ d27 = +HEAPF32[i37 + 4 >> 2];
+ d32 = +HEAPF32[i36 + (i35 * 12 | 0) + 8 >> 2];
+ i37 = HEAP32[i13 >> 2] | 0;
+ i34 = i37 + (i35 * 12 | 0) | 0;
+ d22 = +HEAPF32[i34 >> 2];
+ d25 = +HEAPF32[i34 + 4 >> 2];
+ d23 = +HEAPF32[i37 + (i35 * 12 | 0) + 8 >> 2];
+ i35 = i36 + (i42 * 12 | 0) | 0;
+ d28 = +HEAPF32[i35 >> 2];
+ d29 = +HEAPF32[i35 + 4 >> 2];
+ d38 = +HEAPF32[i36 + (i42 * 12 | 0) + 8 >> 2];
+ i36 = i37 + (i42 * 12 | 0) | 0;
+ d20 = +HEAPF32[i36 >> 2];
+ d19 = +HEAPF32[i36 + 4 >> 2];
+ d21 = +HEAPF32[i37 + (i42 * 12 | 0) + 8 >> 2];
+ if ((HEAP32[i31 + 124 >> 2] | 0) <= 0) {
+ i2 = 4;
+ break;
+ }
+ d44 = +HEAPF32[i33 + (i16 * 88 | 0) + 80 >> 2];
+ d45 = +HEAPF32[i33 + (i16 * 88 | 0) + 76 >> 2];
+ d47 = +Math_sin(+d32);
+ HEAPF32[i14 >> 2] = d47;
+ d48 = +Math_cos(+d32);
+ HEAPF32[i12 >> 2] = d48;
+ d32 = +Math_sin(+d38);
+ HEAPF32[i11 >> 2] = d32;
+ d38 = +Math_cos(+d38);
+ HEAPF32[i10 >> 2] = d38;
+ d46 = +(d26 - (d39 * d48 - d40 * d47));
+ d40 = +(d27 - (d40 * d48 + d39 * d47));
+ i37 = i8;
+ HEAPF32[i37 >> 2] = d46;
+ HEAPF32[i37 + 4 >> 2] = d40;
+ d40 = +(d28 - (d41 * d38 - d43 * d32));
+ d43 = +(d29 - (d43 * d38 + d41 * d32));
+ i37 = i3;
+ HEAPF32[i37 >> 2] = d40;
+ HEAPF32[i37 + 4 >> 2] = d43;
+ __ZN15b2WorldManifold10InitializeEPK10b2ManifoldRK11b2TransformfS5_f(i5, i31 + 64 | 0, i8, d45, i3, d44);
+ i37 = i15 + (i16 * 152 | 0) + 72 | 0;
+ i42 = i5;
+ i33 = HEAP32[i42 + 4 >> 2] | 0;
+ i31 = i37;
+ HEAP32[i31 >> 2] = HEAP32[i42 >> 2];
+ HEAP32[i31 + 4 >> 2] = i33;
+ i31 = i15 + (i16 * 152 | 0) + 144 | 0;
+ i33 = HEAP32[i31 >> 2] | 0;
+ do {
+ if ((i33 | 0) > 0) {
+ i36 = i15 + (i16 * 152 | 0) + 76 | 0;
+ d32 = d30 + d24;
+ i35 = i15 + (i16 * 152 | 0) + 140 | 0;
+ i34 = 0;
+ do {
+ i49 = i5 + (i34 << 3) + 8 | 0;
+ d41 = +HEAPF32[i49 >> 2] - d26;
+ i42 = i5 + (i34 << 3) + 12 | 0;
+ d39 = +d41;
+ d40 = +(+HEAPF32[i42 >> 2] - d27);
+ i50 = i15 + (i16 * 152 | 0) + (i34 * 36 | 0) | 0;
+ HEAPF32[i50 >> 2] = d39;
+ HEAPF32[i50 + 4 >> 2] = d40;
+ d40 = +HEAPF32[i49 >> 2] - d28;
+ d39 = +d40;
+ d47 = +(+HEAPF32[i42 >> 2] - d29);
+ i42 = i15 + (i16 * 152 | 0) + (i34 * 36 | 0) + 8 | 0;
+ HEAPF32[i42 >> 2] = d39;
+ HEAPF32[i42 + 4 >> 2] = d47;
+ d47 = +HEAPF32[i36 >> 2];
+ d39 = +HEAPF32[i15 + (i16 * 152 | 0) + (i34 * 36 | 0) + 4 >> 2];
+ d43 = +HEAPF32[i37 >> 2];
+ d48 = d41 * d47 - d39 * d43;
+ d38 = +HEAPF32[i15 + (i16 * 152 | 0) + (i34 * 36 | 0) + 12 >> 2];
+ d43 = d47 * d40 - d43 * d38;
+ d43 = d32 + d48 * d17 * d48 + d43 * d18 * d43;
+ if (d43 > 0.0) {
+ d43 = 1.0 / d43;
+ } else {
+ d43 = 0.0;
+ }
+ HEAPF32[i15 + (i16 * 152 | 0) + (i34 * 36 | 0) + 24 >> 2] = d43;
+ d43 = +HEAPF32[i36 >> 2];
+ d47 = -+HEAPF32[i37 >> 2];
+ d48 = d41 * d47 - d43 * d39;
+ d43 = d40 * d47 - d43 * d38;
+ d43 = d32 + d48 * d17 * d48 + d43 * d18 * d43;
+ if (d43 > 0.0) {
+ d43 = 1.0 / d43;
+ } else {
+ d43 = 0.0;
+ }
+ HEAPF32[i15 + (i16 * 152 | 0) + (i34 * 36 | 0) + 28 >> 2] = d43;
+ i42 = i15 + (i16 * 152 | 0) + (i34 * 36 | 0) + 32 | 0;
+ HEAPF32[i42 >> 2] = 0.0;
+ d38 = +HEAPF32[i37 >> 2] * (d20 - d21 * d38 - d22 + d23 * d39) + +HEAPF32[i36 >> 2] * (d19 + d21 * d40 - d25 - d23 * d41);
+ if (d38 < -1.0) {
+ HEAPF32[i42 >> 2] = -(d38 * +HEAPF32[i35 >> 2]);
+ }
+ i34 = i34 + 1 | 0;
+ } while ((i34 | 0) != (i33 | 0));
+ if ((HEAP32[i31 >> 2] | 0) == 2) {
+ d45 = +HEAPF32[i15 + (i16 * 152 | 0) + 76 >> 2];
+ d20 = +HEAPF32[i37 >> 2];
+ d44 = +HEAPF32[i15 + (i16 * 152 | 0) >> 2] * d45 - +HEAPF32[i15 + (i16 * 152 | 0) + 4 >> 2] * d20;
+ d19 = d45 * +HEAPF32[i15 + (i16 * 152 | 0) + 8 >> 2] - d20 * +HEAPF32[i15 + (i16 * 152 | 0) + 12 >> 2];
+ d47 = d45 * +HEAPF32[i15 + (i16 * 152 | 0) + 36 >> 2] - d20 * +HEAPF32[i15 + (i16 * 152 | 0) + 40 >> 2];
+ d20 = d45 * +HEAPF32[i15 + (i16 * 152 | 0) + 44 >> 2] - d20 * +HEAPF32[i15 + (i16 * 152 | 0) + 48 >> 2];
+ d45 = d30 + d24;
+ d46 = d17 * d44;
+ d48 = d18 * d19;
+ d19 = d45 + d44 * d46 + d19 * d48;
+ d18 = d45 + d47 * d17 * d47 + d20 * d18 * d20;
+ d17 = d45 + d46 * d47 + d48 * d20;
+ d20 = d19 * d18 - d17 * d17;
+ if (!(d19 * d19 < d20 * 1.0e3)) {
+ HEAP32[i31 >> 2] = 1;
+ break;
+ }
+ HEAPF32[i15 + (i16 * 152 | 0) + 96 >> 2] = d19;
+ HEAPF32[i15 + (i16 * 152 | 0) + 100 >> 2] = d17;
+ HEAPF32[i15 + (i16 * 152 | 0) + 104 >> 2] = d17;
+ HEAPF32[i15 + (i16 * 152 | 0) + 108 >> 2] = d18;
+ if (d20 != 0.0) {
+ d20 = 1.0 / d20;
+ }
+ d48 = -(d20 * d17);
+ HEAPF32[i15 + (i16 * 152 | 0) + 80 >> 2] = d18 * d20;
+ HEAPF32[i15 + (i16 * 152 | 0) + 84 >> 2] = d48;
+ HEAPF32[i15 + (i16 * 152 | 0) + 88 >> 2] = d48;
+ HEAPF32[i15 + (i16 * 152 | 0) + 92 >> 2] = d19 * d20;
+ }
+ }
+ } while (0);
+ i16 = i16 + 1 | 0;
+ if ((i16 | 0) >= (HEAP32[i4 >> 2] | 0)) {
+ i2 = 21;
+ break;
+ }
+ }
+ if ((i2 | 0) == 4) {
+ ___assert_fail(6584, 6520, 168, 6616);
+ } else if ((i2 | 0) == 21) {
+ STACKTOP = i1;
+ return;
+ }
+}
+function __Z17b2CollidePolygonsP10b2ManifoldPK14b2PolygonShapeRK11b2TransformS3_S6_(i5, i27, i28, i24, i14) {
+ i5 = i5 | 0;
+ i27 = i27 | 0;
+ i28 = i28 | 0;
+ i24 = i24 | 0;
+ i14 = i14 | 0;
+ var i1 = 0, i2 = 0, d3 = 0.0, i4 = 0, d6 = 0.0, d7 = 0.0, d8 = 0.0, d9 = 0.0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, d15 = 0.0, d16 = 0.0, i17 = 0, d18 = 0.0, d19 = 0.0, i20 = 0, d21 = 0.0, d22 = 0.0, d23 = 0.0, d25 = 0.0, d26 = 0.0, d29 = 0.0, d30 = 0.0, i31 = 0, d32 = 0.0, i33 = 0, i34 = 0, d35 = 0.0, d36 = 0.0, d37 = 0.0, d38 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 96 | 0;
+ i17 = i1 + 92 | 0;
+ i20 = i1 + 88 | 0;
+ i13 = i1;
+ i11 = i1 + 80 | 0;
+ i12 = i1 + 56 | 0;
+ i4 = i1 + 32 | 0;
+ i10 = i1 + 24 | 0;
+ i2 = i5 + 60 | 0;
+ HEAP32[i2 >> 2] = 0;
+ d3 = +HEAPF32[i27 + 8 >> 2] + +HEAPF32[i24 + 8 >> 2];
+ HEAP32[i17 >> 2] = 0;
+ d7 = +__ZL19b2FindMaxSeparationPiPK14b2PolygonShapeRK11b2TransformS2_S5_(i17, i27, i28, i24, i14);
+ if (d7 > d3) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[i20 >> 2] = 0;
+ d6 = +__ZL19b2FindMaxSeparationPiPK14b2PolygonShapeRK11b2TransformS2_S5_(i20, i24, i14, i27, i28);
+ if (d6 > d3) {
+ STACKTOP = i1;
+ return;
+ }
+ if (d6 > d7 * .9800000190734863 + .0010000000474974513) {
+ d18 = +HEAPF32[i14 >> 2];
+ d19 = +HEAPF32[i14 + 4 >> 2];
+ d15 = +HEAPF32[i14 + 8 >> 2];
+ d16 = +HEAPF32[i14 + 12 >> 2];
+ d9 = +HEAPF32[i28 >> 2];
+ d6 = +HEAPF32[i28 + 4 >> 2];
+ d7 = +HEAPF32[i28 + 8 >> 2];
+ d8 = +HEAPF32[i28 + 12 >> 2];
+ i17 = HEAP32[i20 >> 2] | 0;
+ HEAP32[i5 + 56 >> 2] = 2;
+ i14 = 1;
+ i20 = i24;
+ } else {
+ d18 = +HEAPF32[i28 >> 2];
+ d19 = +HEAPF32[i28 + 4 >> 2];
+ d15 = +HEAPF32[i28 + 8 >> 2];
+ d16 = +HEAPF32[i28 + 12 >> 2];
+ d9 = +HEAPF32[i14 >> 2];
+ d6 = +HEAPF32[i14 + 4 >> 2];
+ d7 = +HEAPF32[i14 + 8 >> 2];
+ d8 = +HEAPF32[i14 + 12 >> 2];
+ i17 = HEAP32[i17 >> 2] | 0;
+ HEAP32[i5 + 56 >> 2] = 1;
+ i14 = 0;
+ i20 = i27;
+ i27 = i24;
+ }
+ i28 = HEAP32[i27 + 148 >> 2] | 0;
+ if (!((i17 | 0) > -1)) {
+ ___assert_fail(5640, 5688, 151, 5728);
+ }
+ i24 = HEAP32[i20 + 148 >> 2] | 0;
+ if ((i24 | 0) <= (i17 | 0)) {
+ ___assert_fail(5640, 5688, 151, 5728);
+ }
+ d21 = +HEAPF32[i20 + (i17 << 3) + 84 >> 2];
+ d36 = +HEAPF32[i20 + (i17 << 3) + 88 >> 2];
+ d22 = d16 * d21 - d15 * d36;
+ d36 = d15 * d21 + d16 * d36;
+ d21 = d8 * d22 + d7 * d36;
+ d22 = d8 * d36 - d7 * d22;
+ if ((i28 | 0) > 0) {
+ i33 = 0;
+ i34 = 0;
+ d23 = 3.4028234663852886e+38;
+ while (1) {
+ d25 = d21 * +HEAPF32[i27 + (i33 << 3) + 84 >> 2] + d22 * +HEAPF32[i27 + (i33 << 3) + 88 >> 2];
+ i31 = d25 < d23;
+ i34 = i31 ? i33 : i34;
+ i33 = i33 + 1 | 0;
+ if ((i33 | 0) == (i28 | 0)) {
+ break;
+ } else {
+ d23 = i31 ? d25 : d23;
+ }
+ }
+ } else {
+ i34 = 0;
+ }
+ i31 = i34 + 1 | 0;
+ i33 = (i31 | 0) < (i28 | 0) ? i31 : 0;
+ d35 = +HEAPF32[i27 + (i34 << 3) + 20 >> 2];
+ d32 = +HEAPF32[i27 + (i34 << 3) + 24 >> 2];
+ d36 = +(d9 + (d8 * d35 - d7 * d32));
+ d32 = +(d6 + (d7 * d35 + d8 * d32));
+ i31 = i13;
+ HEAPF32[i31 >> 2] = d36;
+ HEAPF32[i31 + 4 >> 2] = d32;
+ i31 = i17 & 255;
+ i28 = i13 + 8 | 0;
+ HEAP8[i28] = i31;
+ HEAP8[i28 + 1 | 0] = i34;
+ HEAP8[i28 + 2 | 0] = 1;
+ HEAP8[i28 + 3 | 0] = 0;
+ d32 = +HEAPF32[i27 + (i33 << 3) + 20 >> 2];
+ d36 = +HEAPF32[i27 + (i33 << 3) + 24 >> 2];
+ d35 = +(d9 + (d8 * d32 - d7 * d36));
+ d36 = +(d6 + (d7 * d32 + d8 * d36));
+ i27 = i13 + 12 | 0;
+ HEAPF32[i27 >> 2] = d35;
+ HEAPF32[i27 + 4 >> 2] = d36;
+ i27 = i13 + 20 | 0;
+ HEAP8[i27] = i31;
+ HEAP8[i27 + 1 | 0] = i33;
+ HEAP8[i27 + 2 | 0] = 1;
+ HEAP8[i27 + 3 | 0] = 0;
+ i27 = i17 + 1 | 0;
+ i24 = (i27 | 0) < (i24 | 0) ? i27 : 0;
+ i34 = i20 + (i17 << 3) + 20 | 0;
+ d26 = +HEAPF32[i34 >> 2];
+ d25 = +HEAPF32[i34 + 4 >> 2];
+ i34 = i20 + (i24 << 3) + 20 | 0;
+ d30 = +HEAPF32[i34 >> 2];
+ d29 = +HEAPF32[i34 + 4 >> 2];
+ d32 = d30 - d26;
+ d35 = d29 - d25;
+ d21 = +Math_sqrt(+(d32 * d32 + d35 * d35));
+ if (!(d21 < 1.1920928955078125e-7)) {
+ d36 = 1.0 / d21;
+ d32 = d32 * d36;
+ d35 = d35 * d36;
+ }
+ d36 = d16 * d32 - d15 * d35;
+ d21 = d16 * d35 + d15 * d32;
+ HEAPF32[i11 >> 2] = d36;
+ HEAPF32[i11 + 4 >> 2] = d21;
+ d22 = -d36;
+ d38 = d18 + (d16 * d26 - d15 * d25);
+ d37 = d19 + (d15 * d26 + d16 * d25);
+ d23 = d38 * d21 + d37 * d22;
+ HEAPF32[i10 >> 2] = d22;
+ HEAPF32[i10 + 4 >> 2] = -d21;
+ if ((__Z19b2ClipSegmentToLineP12b2ClipVertexPKS_RK6b2Vec2fi(i12, i13, i10, d3 - (d38 * d36 + d37 * d21), i17) | 0) < 2) {
+ STACKTOP = i1;
+ return;
+ }
+ if ((__Z19b2ClipSegmentToLineP12b2ClipVertexPKS_RK6b2Vec2fi(i4, i12, i11, d3 + ((d18 + (d16 * d30 - d15 * d29)) * d36 + (d19 + (d15 * d30 + d16 * d29)) * d21), i24) | 0) < 2) {
+ STACKTOP = i1;
+ return;
+ }
+ d16 = +d35;
+ d15 = +-d32;
+ i10 = i5 + 40 | 0;
+ HEAPF32[i10 >> 2] = d16;
+ HEAPF32[i10 + 4 >> 2] = d15;
+ d15 = +((d26 + d30) * .5);
+ d16 = +((d25 + d29) * .5);
+ i10 = i5 + 48 | 0;
+ HEAPF32[i10 >> 2] = d15;
+ HEAPF32[i10 + 4 >> 2] = d16;
+ d16 = +HEAPF32[i4 >> 2];
+ d15 = +HEAPF32[i4 + 4 >> 2];
+ i10 = !(d21 * d16 + d15 * d22 - d23 <= d3);
+ if (i14 << 24 >> 24 == 0) {
+ if (i10) {
+ i10 = 0;
+ } else {
+ d38 = d16 - d9;
+ d36 = d15 - d6;
+ d37 = +(d8 * d38 + d7 * d36);
+ d38 = +(d8 * d36 - d7 * d38);
+ i10 = i5;
+ HEAPF32[i10 >> 2] = d37;
+ HEAPF32[i10 + 4 >> 2] = d38;
+ HEAP32[i5 + 16 >> 2] = HEAP32[i4 + 8 >> 2];
+ i10 = 1;
+ }
+ d16 = +HEAPF32[i4 + 12 >> 2];
+ d15 = +HEAPF32[i4 + 16 >> 2];
+ if (d21 * d16 + d15 * d22 - d23 <= d3) {
+ d38 = d16 - d9;
+ d36 = d15 - d6;
+ d37 = +(d8 * d38 + d7 * d36);
+ d38 = +(d8 * d36 - d7 * d38);
+ i34 = i5 + (i10 * 20 | 0) | 0;
+ HEAPF32[i34 >> 2] = d37;
+ HEAPF32[i34 + 4 >> 2] = d38;
+ HEAP32[i5 + (i10 * 20 | 0) + 16 >> 2] = HEAP32[i4 + 20 >> 2];
+ i10 = i10 + 1 | 0;
+ }
+ } else {
+ if (i10) {
+ i10 = 0;
+ } else {
+ d38 = d16 - d9;
+ d36 = d15 - d6;
+ d37 = +(d8 * d38 + d7 * d36);
+ d38 = +(d8 * d36 - d7 * d38);
+ i10 = i5;
+ HEAPF32[i10 >> 2] = d37;
+ HEAPF32[i10 + 4 >> 2] = d38;
+ i10 = i5 + 16 | 0;
+ i34 = HEAP32[i4 + 8 >> 2] | 0;
+ HEAP32[i10 >> 2] = i34;
+ HEAP8[i10] = i34 >>> 8;
+ HEAP8[i10 + 1 | 0] = i34;
+ HEAP8[i10 + 2 | 0] = i34 >>> 24;
+ HEAP8[i10 + 3 | 0] = i34 >>> 16;
+ i10 = 1;
+ }
+ d16 = +HEAPF32[i4 + 12 >> 2];
+ d15 = +HEAPF32[i4 + 16 >> 2];
+ if (d21 * d16 + d15 * d22 - d23 <= d3) {
+ d38 = d16 - d9;
+ d36 = d15 - d6;
+ d37 = +(d8 * d38 + d7 * d36);
+ d38 = +(d8 * d36 - d7 * d38);
+ i34 = i5 + (i10 * 20 | 0) | 0;
+ HEAPF32[i34 >> 2] = d37;
+ HEAPF32[i34 + 4 >> 2] = d38;
+ i34 = i5 + (i10 * 20 | 0) + 16 | 0;
+ i33 = HEAP32[i4 + 20 >> 2] | 0;
+ HEAP32[i34 >> 2] = i33;
+ HEAP8[i34] = i33 >>> 8;
+ HEAP8[i34 + 1 | 0] = i33;
+ HEAP8[i34 + 2 | 0] = i33 >>> 24;
+ HEAP8[i34 + 3 | 0] = i33 >>> 16;
+ i10 = i10 + 1 | 0;
+ }
+ }
+ HEAP32[i2 >> 2] = i10;
+ STACKTOP = i1;
+ return;
+}
+function __ZN8b2Island8SolveTOIERK10b2TimeStepii(i4, i11, i15, i18) {
+ i4 = i4 | 0;
+ i11 = i11 | 0;
+ i15 = i15 | 0;
+ i18 = i18 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, d12 = 0.0, d13 = 0.0, d14 = 0.0, d16 = 0.0, d17 = 0.0, d19 = 0.0, d20 = 0.0, d21 = 0.0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, d26 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 128 | 0;
+ i2 = i1 + 96 | 0;
+ i10 = i1 + 52 | 0;
+ i3 = i1;
+ i6 = i4 + 28 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) <= (i15 | 0)) {
+ ___assert_fail(5464, 5488, 386, 5520);
+ }
+ if ((i5 | 0) <= (i18 | 0)) {
+ ___assert_fail(5536, 5488, 387, 5520);
+ }
+ if ((i5 | 0) > 0) {
+ i9 = i4 + 8 | 0;
+ i8 = i4 + 20 | 0;
+ i7 = i4 + 24 | 0;
+ i22 = 0;
+ while (1) {
+ i23 = HEAP32[(HEAP32[i9 >> 2] | 0) + (i22 << 2) >> 2] | 0;
+ i5 = i23 + 44 | 0;
+ i24 = HEAP32[i5 + 4 >> 2] | 0;
+ i25 = (HEAP32[i8 >> 2] | 0) + (i22 * 12 | 0) | 0;
+ HEAP32[i25 >> 2] = HEAP32[i5 >> 2];
+ HEAP32[i25 + 4 >> 2] = i24;
+ HEAPF32[(HEAP32[i8 >> 2] | 0) + (i22 * 12 | 0) + 8 >> 2] = +HEAPF32[i23 + 56 >> 2];
+ i25 = i23 + 64 | 0;
+ i24 = HEAP32[i25 + 4 >> 2] | 0;
+ i5 = (HEAP32[i7 >> 2] | 0) + (i22 * 12 | 0) | 0;
+ HEAP32[i5 >> 2] = HEAP32[i25 >> 2];
+ HEAP32[i5 + 4 >> 2] = i24;
+ i5 = HEAP32[i7 >> 2] | 0;
+ HEAPF32[i5 + (i22 * 12 | 0) + 8 >> 2] = +HEAPF32[i23 + 72 >> 2];
+ i22 = i22 + 1 | 0;
+ if ((i22 | 0) >= (HEAP32[i6 >> 2] | 0)) {
+ i22 = i5;
+ break;
+ }
+ }
+ } else {
+ i8 = i4 + 20 | 0;
+ i22 = HEAP32[i4 + 24 >> 2] | 0;
+ }
+ i5 = i4 + 12 | 0;
+ HEAP32[i10 + 24 >> 2] = HEAP32[i5 >> 2];
+ i7 = i4 + 36 | 0;
+ HEAP32[i10 + 28 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i10 + 40 >> 2] = HEAP32[i4 >> 2];
+ HEAP32[i10 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
+ HEAP32[i10 + 12 >> 2] = HEAP32[i11 + 12 >> 2];
+ HEAP32[i10 + 16 >> 2] = HEAP32[i11 + 16 >> 2];
+ HEAP32[i10 + 20 >> 2] = HEAP32[i11 + 20 >> 2];
+ HEAP32[i10 + 32 >> 2] = HEAP32[i8 >> 2];
+ i9 = i4 + 24 | 0;
+ HEAP32[i10 + 36 >> 2] = i22;
+ __ZN15b2ContactSolverC2EP18b2ContactSolverDef(i3, i10);
+ i10 = i11 + 16 | 0;
+ L13 : do {
+ if ((HEAP32[i10 >> 2] | 0) > 0) {
+ i22 = 0;
+ do {
+ i22 = i22 + 1 | 0;
+ if (__ZN15b2ContactSolver27SolveTOIPositionConstraintsEii(i3, i15, i18) | 0) {
+ break L13;
+ }
+ } while ((i22 | 0) < (HEAP32[i10 >> 2] | 0));
+ }
+ } while (0);
+ i10 = i4 + 8 | 0;
+ i24 = (HEAP32[i8 >> 2] | 0) + (i15 * 12 | 0) | 0;
+ i25 = HEAP32[i24 + 4 >> 2] | 0;
+ i23 = (HEAP32[(HEAP32[i10 >> 2] | 0) + (i15 << 2) >> 2] | 0) + 36 | 0;
+ HEAP32[i23 >> 2] = HEAP32[i24 >> 2];
+ HEAP32[i23 + 4 >> 2] = i25;
+ i23 = HEAP32[i8 >> 2] | 0;
+ i25 = HEAP32[i10 >> 2] | 0;
+ HEAPF32[(HEAP32[i25 + (i15 << 2) >> 2] | 0) + 52 >> 2] = +HEAPF32[i23 + (i15 * 12 | 0) + 8 >> 2];
+ i23 = i23 + (i18 * 12 | 0) | 0;
+ i24 = HEAP32[i23 + 4 >> 2] | 0;
+ i25 = (HEAP32[i25 + (i18 << 2) >> 2] | 0) + 36 | 0;
+ HEAP32[i25 >> 2] = HEAP32[i23 >> 2];
+ HEAP32[i25 + 4 >> 2] = i24;
+ HEAPF32[(HEAP32[(HEAP32[i10 >> 2] | 0) + (i18 << 2) >> 2] | 0) + 52 >> 2] = +HEAPF32[(HEAP32[i8 >> 2] | 0) + (i18 * 12 | 0) + 8 >> 2];
+ __ZN15b2ContactSolver29InitializeVelocityConstraintsEv(i3);
+ i18 = i11 + 12 | 0;
+ if ((HEAP32[i18 >> 2] | 0) > 0) {
+ i15 = 0;
+ do {
+ __ZN15b2ContactSolver24SolveVelocityConstraintsEv(i3);
+ i15 = i15 + 1 | 0;
+ } while ((i15 | 0) < (HEAP32[i18 >> 2] | 0));
+ }
+ d16 = +HEAPF32[i11 >> 2];
+ if ((HEAP32[i6 >> 2] | 0) > 0) {
+ i15 = 0;
+ do {
+ i25 = HEAP32[i8 >> 2] | 0;
+ i11 = i25 + (i15 * 12 | 0) | 0;
+ i24 = i11;
+ d12 = +HEAPF32[i24 >> 2];
+ d14 = +HEAPF32[i24 + 4 >> 2];
+ d13 = +HEAPF32[i25 + (i15 * 12 | 0) + 8 >> 2];
+ i25 = HEAP32[i9 >> 2] | 0;
+ i24 = i25 + (i15 * 12 | 0) | 0;
+ d19 = +HEAPF32[i24 >> 2];
+ d20 = +HEAPF32[i24 + 4 >> 2];
+ d17 = +HEAPF32[i25 + (i15 * 12 | 0) + 8 >> 2];
+ d26 = d16 * d19;
+ d21 = d16 * d20;
+ d21 = d26 * d26 + d21 * d21;
+ if (d21 > 4.0) {
+ d26 = 2.0 / +Math_sqrt(+d21);
+ d19 = d19 * d26;
+ d20 = d20 * d26;
+ }
+ d21 = d16 * d17;
+ if (d21 * d21 > 2.4674012660980225) {
+ if (!(d21 > 0.0)) {
+ d21 = -d21;
+ }
+ d17 = d17 * (1.5707963705062866 / d21);
+ }
+ d21 = d12 + d16 * d19;
+ d14 = d14 + d16 * d20;
+ d26 = d13 + d16 * d17;
+ d12 = +d21;
+ d13 = +d14;
+ i25 = i11;
+ HEAPF32[i25 >> 2] = d12;
+ HEAPF32[i25 + 4 >> 2] = d13;
+ HEAPF32[(HEAP32[i8 >> 2] | 0) + (i15 * 12 | 0) + 8 >> 2] = d26;
+ d19 = +d19;
+ d20 = +d20;
+ i25 = (HEAP32[i9 >> 2] | 0) + (i15 * 12 | 0) | 0;
+ HEAPF32[i25 >> 2] = d19;
+ HEAPF32[i25 + 4 >> 2] = d20;
+ HEAPF32[(HEAP32[i9 >> 2] | 0) + (i15 * 12 | 0) + 8 >> 2] = d17;
+ i25 = HEAP32[(HEAP32[i10 >> 2] | 0) + (i15 << 2) >> 2] | 0;
+ i24 = i25 + 44 | 0;
+ HEAPF32[i24 >> 2] = d12;
+ HEAPF32[i24 + 4 >> 2] = d13;
+ HEAPF32[i25 + 56 >> 2] = d26;
+ i24 = i25 + 64 | 0;
+ HEAPF32[i24 >> 2] = d19;
+ HEAPF32[i24 + 4 >> 2] = d20;
+ HEAPF32[i25 + 72 >> 2] = d17;
+ d17 = +Math_sin(+d26);
+ HEAPF32[i25 + 20 >> 2] = d17;
+ d20 = +Math_cos(+d26);
+ HEAPF32[i25 + 24 >> 2] = d20;
+ d19 = +HEAPF32[i25 + 28 >> 2];
+ d26 = +HEAPF32[i25 + 32 >> 2];
+ d21 = +(d21 - (d20 * d19 - d17 * d26));
+ d26 = +(d14 - (d17 * d19 + d20 * d26));
+ i25 = i25 + 12 | 0;
+ HEAPF32[i25 >> 2] = d21;
+ HEAPF32[i25 + 4 >> 2] = d26;
+ i15 = i15 + 1 | 0;
+ } while ((i15 | 0) < (HEAP32[i6 >> 2] | 0));
+ }
+ i6 = HEAP32[i3 + 40 >> 2] | 0;
+ i4 = i4 + 4 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == 0) {
+ __ZN15b2ContactSolverD2Ev(i3);
+ STACKTOP = i1;
+ return;
+ }
+ if ((HEAP32[i7 >> 2] | 0) <= 0) {
+ __ZN15b2ContactSolverD2Ev(i3);
+ STACKTOP = i1;
+ return;
+ }
+ i8 = i2 + 16 | 0;
+ i9 = 0;
+ do {
+ i10 = HEAP32[(HEAP32[i5 >> 2] | 0) + (i9 << 2) >> 2] | 0;
+ i11 = HEAP32[i6 + (i9 * 152 | 0) + 144 >> 2] | 0;
+ HEAP32[i8 >> 2] = i11;
+ if ((i11 | 0) > 0) {
+ i15 = 0;
+ do {
+ HEAPF32[i2 + (i15 << 2) >> 2] = +HEAPF32[i6 + (i9 * 152 | 0) + (i15 * 36 | 0) + 16 >> 2];
+ HEAPF32[i2 + (i15 << 2) + 8 >> 2] = +HEAPF32[i6 + (i9 * 152 | 0) + (i15 * 36 | 0) + 20 >> 2];
+ i15 = i15 + 1 | 0;
+ } while ((i15 | 0) != (i11 | 0));
+ }
+ i25 = HEAP32[i4 >> 2] | 0;
+ FUNCTION_TABLE_viii[HEAP32[(HEAP32[i25 >> 2] | 0) + 20 >> 2] & 3](i25, i10, i2);
+ i9 = i9 + 1 | 0;
+ } while ((i9 | 0) < (HEAP32[i7 >> 2] | 0));
+ __ZN15b2ContactSolverD2Ev(i3);
+ STACKTOP = i1;
+ return;
+}
+function __ZN20b2SeparationFunction10InitializeEPK14b2SimplexCachePK15b2DistanceProxyRK7b2SweepS5_S8_f(i2, i11, i13, i21, i12, i24, d9) {
+ i2 = i2 | 0;
+ i11 = i11 | 0;
+ i13 = i13 | 0;
+ i21 = i21 | 0;
+ i12 = i12 | 0;
+ i24 = i24 | 0;
+ d9 = +d9;
+ var i1 = 0, d3 = 0.0, d4 = 0.0, d5 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 0.0, d10 = 0.0, i14 = 0, d15 = 0.0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, d22 = 0.0, i23 = 0, i25 = 0, i26 = 0, i27 = 0, d28 = 0.0, d29 = 0.0;
+ i1 = STACKTOP;
+ HEAP32[i2 >> 2] = i13;
+ HEAP32[i2 + 4 >> 2] = i12;
+ i14 = HEAP16[i11 + 4 >> 1] | 0;
+ if (!(i14 << 16 >> 16 != 0 & (i14 & 65535) < 3)) {
+ ___assert_fail(3744, 3560, 50, 3768);
+ }
+ i23 = i2 + 8 | 0;
+ i25 = i23 + 0 | 0;
+ i27 = i21 + 0 | 0;
+ i26 = i25 + 36 | 0;
+ do {
+ HEAP32[i25 >> 2] = HEAP32[i27 >> 2];
+ i25 = i25 + 4 | 0;
+ i27 = i27 + 4 | 0;
+ } while ((i25 | 0) < (i26 | 0));
+ i21 = i2 + 44 | 0;
+ i25 = i21 + 0 | 0;
+ i27 = i24 + 0 | 0;
+ i26 = i25 + 36 | 0;
+ do {
+ HEAP32[i25 >> 2] = HEAP32[i27 >> 2];
+ i25 = i25 + 4 | 0;
+ i27 = i27 + 4 | 0;
+ } while ((i25 | 0) < (i26 | 0));
+ d19 = 1.0 - d9;
+ d4 = d19 * +HEAPF32[i2 + 32 >> 2] + +HEAPF32[i2 + 36 >> 2] * d9;
+ d3 = +Math_sin(+d4);
+ d4 = +Math_cos(+d4);
+ d7 = +HEAPF32[i23 >> 2];
+ d5 = +HEAPF32[i2 + 12 >> 2];
+ d8 = d19 * +HEAPF32[i2 + 16 >> 2] + +HEAPF32[i2 + 24 >> 2] * d9 - (d4 * d7 - d3 * d5);
+ d5 = d19 * +HEAPF32[i2 + 20 >> 2] + +HEAPF32[i2 + 28 >> 2] * d9 - (d3 * d7 + d4 * d5);
+ d7 = d19 * +HEAPF32[i2 + 68 >> 2] + +HEAPF32[i2 + 72 >> 2] * d9;
+ d6 = +Math_sin(+d7);
+ d7 = +Math_cos(+d7);
+ d20 = +HEAPF32[i21 >> 2];
+ d22 = +HEAPF32[i2 + 48 >> 2];
+ d10 = d19 * +HEAPF32[i2 + 52 >> 2] + +HEAPF32[i2 + 60 >> 2] * d9 - (d7 * d20 - d6 * d22);
+ d9 = d19 * +HEAPF32[i2 + 56 >> 2] + +HEAPF32[i2 + 64 >> 2] * d9 - (d6 * d20 + d7 * d22);
+ if (i14 << 16 >> 16 == 1) {
+ HEAP32[i2 + 80 >> 2] = 0;
+ i14 = HEAPU8[i11 + 6 | 0] | 0;
+ if ((HEAP32[i13 + 20 >> 2] | 0) <= (i14 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i27 = (HEAP32[i13 + 16 >> 2] | 0) + (i14 << 3) | 0;
+ d15 = +HEAPF32[i27 >> 2];
+ d16 = +HEAPF32[i27 + 4 >> 2];
+ i11 = HEAPU8[i11 + 9 | 0] | 0;
+ if ((HEAP32[i12 + 20 >> 2] | 0) <= (i11 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i11 = (HEAP32[i12 + 16 >> 2] | 0) + (i11 << 3) | 0;
+ d20 = +HEAPF32[i11 >> 2];
+ d22 = +HEAPF32[i11 + 4 >> 2];
+ i11 = i2 + 92 | 0;
+ d8 = d10 + (d7 * d20 - d6 * d22) - (d8 + (d4 * d15 - d3 * d16));
+ d4 = d9 + (d6 * d20 + d7 * d22) - (d5 + (d3 * d15 + d4 * d16));
+ d22 = +d8;
+ d3 = +d4;
+ i27 = i11;
+ HEAPF32[i27 >> 2] = d22;
+ HEAPF32[i27 + 4 >> 2] = d3;
+ d3 = +Math_sqrt(+(d8 * d8 + d4 * d4));
+ if (d3 < 1.1920928955078125e-7) {
+ d22 = 0.0;
+ STACKTOP = i1;
+ return +d22;
+ }
+ d22 = 1.0 / d3;
+ HEAPF32[i11 >> 2] = d8 * d22;
+ HEAPF32[i2 + 96 >> 2] = d4 * d22;
+ d22 = d3;
+ STACKTOP = i1;
+ return +d22;
+ }
+ i14 = i11 + 6 | 0;
+ i21 = i11 + 7 | 0;
+ i23 = i2 + 80 | 0;
+ if ((HEAP8[i14] | 0) == (HEAP8[i21] | 0)) {
+ HEAP32[i23 >> 2] = 2;
+ i23 = HEAPU8[i11 + 9 | 0] | 0;
+ i21 = HEAP32[i12 + 20 >> 2] | 0;
+ if ((i21 | 0) <= (i23 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i12 = HEAP32[i12 + 16 >> 2] | 0;
+ i27 = i12 + (i23 << 3) | 0;
+ d16 = +HEAPF32[i27 >> 2];
+ d15 = +HEAPF32[i27 + 4 >> 2];
+ i11 = HEAPU8[i11 + 10 | 0] | 0;
+ if ((i21 | 0) <= (i11 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i11 = i12 + (i11 << 3) | 0;
+ d20 = +HEAPF32[i11 >> 2];
+ d18 = +HEAPF32[i11 + 4 >> 2];
+ i11 = i2 + 92 | 0;
+ d22 = d20 - d16;
+ d19 = d18 - d15;
+ d17 = -d22;
+ d29 = +d19;
+ d28 = +d17;
+ i27 = i11;
+ HEAPF32[i27 >> 2] = d29;
+ HEAPF32[i27 + 4 >> 2] = d28;
+ d22 = +Math_sqrt(+(d19 * d19 + d22 * d22));
+ if (!(d22 < 1.1920928955078125e-7)) {
+ d29 = 1.0 / d22;
+ d19 = d19 * d29;
+ HEAPF32[i11 >> 2] = d19;
+ d17 = d29 * d17;
+ HEAPF32[i2 + 96 >> 2] = d17;
+ }
+ d16 = (d16 + d20) * .5;
+ d15 = (d15 + d18) * .5;
+ d28 = +d16;
+ d29 = +d15;
+ i2 = i2 + 84 | 0;
+ HEAPF32[i2 >> 2] = d28;
+ HEAPF32[i2 + 4 >> 2] = d29;
+ i2 = HEAPU8[i14] | 0;
+ if ((HEAP32[i13 + 20 >> 2] | 0) <= (i2 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i27 = (HEAP32[i13 + 16 >> 2] | 0) + (i2 << 3) | 0;
+ d28 = +HEAPF32[i27 >> 2];
+ d29 = +HEAPF32[i27 + 4 >> 2];
+ d3 = (d7 * d19 - d6 * d17) * (d8 + (d4 * d28 - d3 * d29) - (d10 + (d7 * d16 - d6 * d15))) + (d6 * d19 + d7 * d17) * (d5 + (d3 * d28 + d4 * d29) - (d9 + (d6 * d16 + d7 * d15)));
+ if (!(d3 < 0.0)) {
+ d29 = d3;
+ STACKTOP = i1;
+ return +d29;
+ }
+ d28 = +-d19;
+ d29 = +-d17;
+ i27 = i11;
+ HEAPF32[i27 >> 2] = d28;
+ HEAPF32[i27 + 4 >> 2] = d29;
+ d29 = -d3;
+ STACKTOP = i1;
+ return +d29;
+ } else {
+ HEAP32[i23 >> 2] = 1;
+ i23 = HEAPU8[i14] | 0;
+ i14 = HEAP32[i13 + 20 >> 2] | 0;
+ if ((i14 | 0) <= (i23 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i13 = HEAP32[i13 + 16 >> 2] | 0;
+ i27 = i13 + (i23 << 3) | 0;
+ d16 = +HEAPF32[i27 >> 2];
+ d15 = +HEAPF32[i27 + 4 >> 2];
+ i21 = HEAPU8[i21] | 0;
+ if ((i14 | 0) <= (i21 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i13 = i13 + (i21 << 3) | 0;
+ d20 = +HEAPF32[i13 >> 2];
+ d18 = +HEAPF32[i13 + 4 >> 2];
+ i13 = i2 + 92 | 0;
+ d22 = d20 - d16;
+ d19 = d18 - d15;
+ d17 = -d22;
+ d28 = +d19;
+ d29 = +d17;
+ i27 = i13;
+ HEAPF32[i27 >> 2] = d28;
+ HEAPF32[i27 + 4 >> 2] = d29;
+ d22 = +Math_sqrt(+(d19 * d19 + d22 * d22));
+ if (!(d22 < 1.1920928955078125e-7)) {
+ d29 = 1.0 / d22;
+ d19 = d19 * d29;
+ HEAPF32[i13 >> 2] = d19;
+ d17 = d29 * d17;
+ HEAPF32[i2 + 96 >> 2] = d17;
+ }
+ d16 = (d16 + d20) * .5;
+ d15 = (d15 + d18) * .5;
+ d28 = +d16;
+ d29 = +d15;
+ i2 = i2 + 84 | 0;
+ HEAPF32[i2 >> 2] = d28;
+ HEAPF32[i2 + 4 >> 2] = d29;
+ i2 = HEAPU8[i11 + 9 | 0] | 0;
+ if ((HEAP32[i12 + 20 >> 2] | 0) <= (i2 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i27 = (HEAP32[i12 + 16 >> 2] | 0) + (i2 << 3) | 0;
+ d28 = +HEAPF32[i27 >> 2];
+ d29 = +HEAPF32[i27 + 4 >> 2];
+ d3 = (d4 * d19 - d3 * d17) * (d10 + (d7 * d28 - d6 * d29) - (d8 + (d4 * d16 - d3 * d15))) + (d3 * d19 + d4 * d17) * (d9 + (d6 * d28 + d7 * d29) - (d5 + (d3 * d16 + d4 * d15)));
+ if (!(d3 < 0.0)) {
+ d29 = d3;
+ STACKTOP = i1;
+ return +d29;
+ }
+ d28 = +-d19;
+ d29 = +-d17;
+ i27 = i13;
+ HEAPF32[i27 >> 2] = d28;
+ HEAPF32[i27 + 4 >> 2] = d29;
+ d29 = -d3;
+ STACKTOP = i1;
+ return +d29;
+ }
+ return 0.0;
+}
+function __ZNK20b2SeparationFunction17FindMinSeparationEPiS0_f(i12, i10, i9, d5) {
+ i12 = i12 | 0;
+ i10 = i10 | 0;
+ i9 = i9 | 0;
+ d5 = +d5;
+ var i1 = 0, d2 = 0.0, d3 = 0.0, d4 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 0.0, d11 = 0.0, d13 = 0.0, d14 = 0.0, i15 = 0, i16 = 0, d17 = 0.0, d18 = 0.0, i19 = 0, d20 = 0.0, d21 = 0.0, i22 = 0, d23 = 0.0, d24 = 0.0, i25 = 0, i26 = 0, i27 = 0;
+ i1 = STACKTOP;
+ d21 = 1.0 - d5;
+ d6 = d21 * +HEAPF32[i12 + 32 >> 2] + +HEAPF32[i12 + 36 >> 2] * d5;
+ d7 = +Math_sin(+d6);
+ d6 = +Math_cos(+d6);
+ d3 = +HEAPF32[i12 + 8 >> 2];
+ d8 = +HEAPF32[i12 + 12 >> 2];
+ d11 = d21 * +HEAPF32[i12 + 16 >> 2] + +HEAPF32[i12 + 24 >> 2] * d5 - (d6 * d3 - d7 * d8);
+ d8 = d21 * +HEAPF32[i12 + 20 >> 2] + +HEAPF32[i12 + 28 >> 2] * d5 - (d7 * d3 + d6 * d8);
+ d3 = d21 * +HEAPF32[i12 + 68 >> 2] + +HEAPF32[i12 + 72 >> 2] * d5;
+ d2 = +Math_sin(+d3);
+ d3 = +Math_cos(+d3);
+ d23 = +HEAPF32[i12 + 44 >> 2];
+ d24 = +HEAPF32[i12 + 48 >> 2];
+ d4 = d21 * +HEAPF32[i12 + 52 >> 2] + +HEAPF32[i12 + 60 >> 2] * d5 - (d3 * d23 - d2 * d24);
+ d5 = d21 * +HEAPF32[i12 + 56 >> 2] + +HEAPF32[i12 + 64 >> 2] * d5 - (d2 * d23 + d3 * d24);
+ i19 = HEAP32[i12 + 80 >> 2] | 0;
+ if ((i19 | 0) == 1) {
+ d23 = +HEAPF32[i12 + 92 >> 2];
+ d14 = +HEAPF32[i12 + 96 >> 2];
+ d13 = d6 * d23 - d7 * d14;
+ d14 = d7 * d23 + d6 * d14;
+ d23 = +HEAPF32[i12 + 84 >> 2];
+ d24 = +HEAPF32[i12 + 88 >> 2];
+ d11 = d11 + (d6 * d23 - d7 * d24);
+ d6 = d8 + (d7 * d23 + d6 * d24);
+ d7 = -d13;
+ d24 = -d14;
+ d8 = d3 * d7 + d2 * d24;
+ d7 = d3 * d24 - d2 * d7;
+ HEAP32[i10 >> 2] = -1;
+ i25 = i12 + 4 | 0;
+ i22 = HEAP32[i25 >> 2] | 0;
+ i19 = HEAP32[i22 + 16 >> 2] | 0;
+ i22 = HEAP32[i22 + 20 >> 2] | 0;
+ if ((i22 | 0) > 1) {
+ i10 = 0;
+ d18 = d7 * +HEAPF32[i19 + 4 >> 2] + d8 * +HEAPF32[i19 >> 2];
+ i12 = 1;
+ while (1) {
+ d17 = d8 * +HEAPF32[i19 + (i12 << 3) >> 2] + d7 * +HEAPF32[i19 + (i12 << 3) + 4 >> 2];
+ i16 = d17 > d18;
+ i10 = i16 ? i12 : i10;
+ i12 = i12 + 1 | 0;
+ if ((i12 | 0) == (i22 | 0)) {
+ break;
+ } else {
+ d18 = i16 ? d17 : d18;
+ }
+ }
+ HEAP32[i9 >> 2] = i10;
+ if ((i10 | 0) > -1) {
+ i15 = i10;
+ } else {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ } else {
+ HEAP32[i9 >> 2] = 0;
+ i15 = 0;
+ }
+ i9 = HEAP32[i25 >> 2] | 0;
+ if ((HEAP32[i9 + 20 >> 2] | 0) <= (i15 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i27 = (HEAP32[i9 + 16 >> 2] | 0) + (i15 << 3) | 0;
+ d23 = +HEAPF32[i27 >> 2];
+ d24 = +HEAPF32[i27 + 4 >> 2];
+ d24 = d13 * (d4 + (d3 * d23 - d2 * d24) - d11) + d14 * (d5 + (d2 * d23 + d3 * d24) - d6);
+ STACKTOP = i1;
+ return +d24;
+ } else if ((i19 | 0) == 0) {
+ d13 = +HEAPF32[i12 + 92 >> 2];
+ d14 = +HEAPF32[i12 + 96 >> 2];
+ d21 = d6 * d13 + d7 * d14;
+ d24 = d6 * d14 - d7 * d13;
+ d17 = -d13;
+ d23 = -d14;
+ d18 = d3 * d17 + d2 * d23;
+ d17 = d3 * d23 - d2 * d17;
+ i15 = HEAP32[i12 >> 2] | 0;
+ i16 = HEAP32[i15 + 16 >> 2] | 0;
+ i15 = i15 + 20 | 0;
+ i19 = HEAP32[i15 >> 2] | 0;
+ if ((i19 | 0) > 1) {
+ i25 = 0;
+ d23 = d24 * +HEAPF32[i16 + 4 >> 2] + d21 * +HEAPF32[i16 >> 2];
+ i26 = 1;
+ while (1) {
+ d20 = d21 * +HEAPF32[i16 + (i26 << 3) >> 2] + d24 * +HEAPF32[i16 + (i26 << 3) + 4 >> 2];
+ i22 = d20 > d23;
+ i25 = i22 ? i26 : i25;
+ i26 = i26 + 1 | 0;
+ if ((i26 | 0) == (i19 | 0)) {
+ break;
+ } else {
+ d23 = i22 ? d20 : d23;
+ }
+ }
+ } else {
+ i25 = 0;
+ }
+ HEAP32[i10 >> 2] = i25;
+ i19 = HEAP32[i12 + 4 >> 2] | 0;
+ i12 = HEAP32[i19 + 16 >> 2] | 0;
+ i19 = i19 + 20 | 0;
+ i25 = HEAP32[i19 >> 2] | 0;
+ if ((i25 | 0) > 1) {
+ i27 = 0;
+ d20 = d17 * +HEAPF32[i12 + 4 >> 2] + d18 * +HEAPF32[i12 >> 2];
+ i26 = 1;
+ while (1) {
+ d21 = d18 * +HEAPF32[i12 + (i26 << 3) >> 2] + d17 * +HEAPF32[i12 + (i26 << 3) + 4 >> 2];
+ i22 = d21 > d20;
+ i27 = i22 ? i26 : i27;
+ i26 = i26 + 1 | 0;
+ if ((i26 | 0) == (i25 | 0)) {
+ break;
+ } else {
+ d20 = i22 ? d21 : d20;
+ }
+ }
+ } else {
+ i27 = 0;
+ }
+ HEAP32[i9 >> 2] = i27;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if (!((i9 | 0) > -1)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ if ((HEAP32[i15 >> 2] | 0) <= (i9 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i26 = i16 + (i9 << 3) | 0;
+ d18 = +HEAPF32[i26 >> 2];
+ d17 = +HEAPF32[i26 + 4 >> 2];
+ if (!((i27 | 0) > -1)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ if ((HEAP32[i19 >> 2] | 0) <= (i27 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i27 = i12 + (i27 << 3) | 0;
+ d23 = +HEAPF32[i27 >> 2];
+ d24 = +HEAPF32[i27 + 4 >> 2];
+ d24 = d13 * (d4 + (d3 * d23 - d2 * d24) - (d11 + (d6 * d18 - d7 * d17))) + d14 * (d5 + (d2 * d23 + d3 * d24) - (d8 + (d7 * d18 + d6 * d17)));
+ STACKTOP = i1;
+ return +d24;
+ } else if ((i19 | 0) == 2) {
+ d23 = +HEAPF32[i12 + 92 >> 2];
+ d13 = +HEAPF32[i12 + 96 >> 2];
+ d14 = d3 * d23 - d2 * d13;
+ d13 = d2 * d23 + d3 * d13;
+ d23 = +HEAPF32[i12 + 84 >> 2];
+ d24 = +HEAPF32[i12 + 88 >> 2];
+ d4 = d4 + (d3 * d23 - d2 * d24);
+ d2 = d5 + (d2 * d23 + d3 * d24);
+ d3 = -d14;
+ d24 = -d13;
+ d5 = d6 * d3 + d7 * d24;
+ d3 = d6 * d24 - d7 * d3;
+ HEAP32[i9 >> 2] = -1;
+ i22 = HEAP32[i12 >> 2] | 0;
+ i15 = HEAP32[i22 + 16 >> 2] | 0;
+ i22 = HEAP32[i22 + 20 >> 2] | 0;
+ if ((i22 | 0) > 1) {
+ i9 = 0;
+ d17 = d3 * +HEAPF32[i15 + 4 >> 2] + d5 * +HEAPF32[i15 >> 2];
+ i19 = 1;
+ while (1) {
+ d18 = d5 * +HEAPF32[i15 + (i19 << 3) >> 2] + d3 * +HEAPF32[i15 + (i19 << 3) + 4 >> 2];
+ i25 = d18 > d17;
+ i9 = i25 ? i19 : i9;
+ i19 = i19 + 1 | 0;
+ if ((i19 | 0) == (i22 | 0)) {
+ break;
+ } else {
+ d17 = i25 ? d18 : d17;
+ }
+ }
+ HEAP32[i10 >> 2] = i9;
+ if ((i9 | 0) > -1) {
+ i16 = i9;
+ } else {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ } else {
+ HEAP32[i10 >> 2] = 0;
+ i16 = 0;
+ }
+ i9 = HEAP32[i12 >> 2] | 0;
+ if ((HEAP32[i9 + 20 >> 2] | 0) <= (i16 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i27 = (HEAP32[i9 + 16 >> 2] | 0) + (i16 << 3) | 0;
+ d23 = +HEAPF32[i27 >> 2];
+ d24 = +HEAPF32[i27 + 4 >> 2];
+ d24 = d14 * (d11 + (d6 * d23 - d7 * d24) - d4) + d13 * (d8 + (d7 * d23 + d6 * d24) - d2);
+ STACKTOP = i1;
+ return +d24;
+ } else {
+ ___assert_fail(3616, 3560, 183, 3720);
+ }
+ return 0.0;
+}
+function __ZN13b2DynamicTree10InsertLeafEi(i3, i4) {
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, d5 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 0.0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, d13 = 0.0, d14 = 0.0, d15 = 0.0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, d21 = 0.0, d22 = 0.0, d23 = 0.0, i24 = 0;
+ i1 = STACKTOP;
+ i11 = i3 + 24 | 0;
+ HEAP32[i11 >> 2] = (HEAP32[i11 >> 2] | 0) + 1;
+ i11 = HEAP32[i3 >> 2] | 0;
+ if ((i11 | 0) == -1) {
+ HEAP32[i3 >> 2] = i4;
+ HEAP32[(HEAP32[i3 + 4 >> 2] | 0) + (i4 * 36 | 0) + 20 >> 2] = -1;
+ STACKTOP = i1;
+ return;
+ }
+ i2 = i3 + 4 | 0;
+ i9 = HEAP32[i2 >> 2] | 0;
+ d8 = +HEAPF32[i9 + (i4 * 36 | 0) >> 2];
+ d7 = +HEAPF32[i9 + (i4 * 36 | 0) + 4 >> 2];
+ d6 = +HEAPF32[i9 + (i4 * 36 | 0) + 8 >> 2];
+ d5 = +HEAPF32[i9 + (i4 * 36 | 0) + 12 >> 2];
+ i10 = HEAP32[i9 + (i11 * 36 | 0) + 24 >> 2] | 0;
+ L5 : do {
+ if (!((i10 | 0) == -1)) {
+ do {
+ i12 = HEAP32[i9 + (i11 * 36 | 0) + 28 >> 2] | 0;
+ d14 = +HEAPF32[i9 + (i11 * 36 | 0) + 8 >> 2];
+ d15 = +HEAPF32[i9 + (i11 * 36 | 0) >> 2];
+ d17 = +HEAPF32[i9 + (i11 * 36 | 0) + 12 >> 2];
+ d16 = +HEAPF32[i9 + (i11 * 36 | 0) + 4 >> 2];
+ d21 = ((d14 > d6 ? d14 : d6) - (d15 < d8 ? d15 : d8) + ((d17 > d5 ? d17 : d5) - (d16 < d7 ? d16 : d7))) * 2.0;
+ d13 = d21 * 2.0;
+ d14 = (d21 - (d14 - d15 + (d17 - d16)) * 2.0) * 2.0;
+ d21 = +HEAPF32[i9 + (i10 * 36 | 0) >> 2];
+ d16 = d8 < d21 ? d8 : d21;
+ d17 = +HEAPF32[i9 + (i10 * 36 | 0) + 4 >> 2];
+ d18 = d7 < d17 ? d7 : d17;
+ d19 = +HEAPF32[i9 + (i10 * 36 | 0) + 8 >> 2];
+ d20 = d6 > d19 ? d6 : d19;
+ d15 = +HEAPF32[i9 + (i10 * 36 | 0) + 12 >> 2];
+ d22 = d5 > d15 ? d5 : d15;
+ if ((HEAP32[i9 + (i10 * 36 | 0) + 24 >> 2] | 0) == -1) {
+ d15 = (d20 - d16 + (d22 - d18)) * 2.0;
+ } else {
+ d15 = (d20 - d16 + (d22 - d18)) * 2.0 - (d19 - d21 + (d15 - d17)) * 2.0;
+ }
+ d15 = d14 + d15;
+ d17 = +HEAPF32[i9 + (i12 * 36 | 0) >> 2];
+ d18 = d8 < d17 ? d8 : d17;
+ d23 = +HEAPF32[i9 + (i12 * 36 | 0) + 4 >> 2];
+ d22 = d7 < d23 ? d7 : d23;
+ d21 = +HEAPF32[i9 + (i12 * 36 | 0) + 8 >> 2];
+ d20 = d6 > d21 ? d6 : d21;
+ d19 = +HEAPF32[i9 + (i12 * 36 | 0) + 12 >> 2];
+ d16 = d5 > d19 ? d5 : d19;
+ if ((HEAP32[i9 + (i12 * 36 | 0) + 24 >> 2] | 0) == -1) {
+ d16 = (d20 - d18 + (d16 - d22)) * 2.0;
+ } else {
+ d16 = (d20 - d18 + (d16 - d22)) * 2.0 - (d21 - d17 + (d19 - d23)) * 2.0;
+ }
+ d14 = d14 + d16;
+ if (d13 < d15 & d13 < d14) {
+ break L5;
+ }
+ i11 = d15 < d14 ? i10 : i12;
+ i10 = HEAP32[i9 + (i11 * 36 | 0) + 24 >> 2] | 0;
+ } while (!((i10 | 0) == -1));
+ }
+ } while (0);
+ i9 = HEAP32[i9 + (i11 * 36 | 0) + 20 >> 2] | 0;
+ i10 = __ZN13b2DynamicTree12AllocateNodeEv(i3) | 0;
+ i12 = HEAP32[i2 >> 2] | 0;
+ HEAP32[i12 + (i10 * 36 | 0) + 20 >> 2] = i9;
+ HEAP32[i12 + (i10 * 36 | 0) + 16 >> 2] = 0;
+ i12 = HEAP32[i2 >> 2] | 0;
+ d14 = +HEAPF32[i12 + (i11 * 36 | 0) >> 2];
+ d13 = +HEAPF32[i12 + (i11 * 36 | 0) + 4 >> 2];
+ d8 = +(d8 < d14 ? d8 : d14);
+ d7 = +(d7 < d13 ? d7 : d13);
+ i24 = i12 + (i10 * 36 | 0) | 0;
+ HEAPF32[i24 >> 2] = d8;
+ HEAPF32[i24 + 4 >> 2] = d7;
+ d8 = +HEAPF32[i12 + (i11 * 36 | 0) + 8 >> 2];
+ d7 = +HEAPF32[i12 + (i11 * 36 | 0) + 12 >> 2];
+ d6 = +(d6 > d8 ? d6 : d8);
+ d23 = +(d5 > d7 ? d5 : d7);
+ i12 = i12 + (i10 * 36 | 0) + 8 | 0;
+ HEAPF32[i12 >> 2] = d6;
+ HEAPF32[i12 + 4 >> 2] = d23;
+ i12 = HEAP32[i2 >> 2] | 0;
+ HEAP32[i12 + (i10 * 36 | 0) + 32 >> 2] = (HEAP32[i12 + (i11 * 36 | 0) + 32 >> 2] | 0) + 1;
+ if ((i9 | 0) == -1) {
+ HEAP32[i12 + (i10 * 36 | 0) + 24 >> 2] = i11;
+ HEAP32[i12 + (i10 * 36 | 0) + 28 >> 2] = i4;
+ HEAP32[i12 + (i11 * 36 | 0) + 20 >> 2] = i10;
+ i24 = i12 + (i4 * 36 | 0) + 20 | 0;
+ HEAP32[i24 >> 2] = i10;
+ HEAP32[i3 >> 2] = i10;
+ i10 = HEAP32[i24 >> 2] | 0;
+ } else {
+ i24 = i12 + (i9 * 36 | 0) + 24 | 0;
+ if ((HEAP32[i24 >> 2] | 0) == (i11 | 0)) {
+ HEAP32[i24 >> 2] = i10;
+ } else {
+ HEAP32[i12 + (i9 * 36 | 0) + 28 >> 2] = i10;
+ }
+ HEAP32[i12 + (i10 * 36 | 0) + 24 >> 2] = i11;
+ HEAP32[i12 + (i10 * 36 | 0) + 28 >> 2] = i4;
+ HEAP32[i12 + (i11 * 36 | 0) + 20 >> 2] = i10;
+ HEAP32[i12 + (i4 * 36 | 0) + 20 >> 2] = i10;
+ }
+ if ((i10 | 0) == -1) {
+ STACKTOP = i1;
+ return;
+ }
+ while (1) {
+ i9 = __ZN13b2DynamicTree7BalanceEi(i3, i10) | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ i11 = HEAP32[i4 + (i9 * 36 | 0) + 24 >> 2] | 0;
+ i10 = HEAP32[i4 + (i9 * 36 | 0) + 28 >> 2] | 0;
+ if ((i11 | 0) == -1) {
+ i2 = 20;
+ break;
+ }
+ if ((i10 | 0) == -1) {
+ i2 = 22;
+ break;
+ }
+ i12 = HEAP32[i4 + (i11 * 36 | 0) + 32 >> 2] | 0;
+ i24 = HEAP32[i4 + (i10 * 36 | 0) + 32 >> 2] | 0;
+ HEAP32[i4 + (i9 * 36 | 0) + 32 >> 2] = ((i12 | 0) > (i24 | 0) ? i12 : i24) + 1;
+ d7 = +HEAPF32[i4 + (i11 * 36 | 0) >> 2];
+ d8 = +HEAPF32[i4 + (i10 * 36 | 0) >> 2];
+ d5 = +HEAPF32[i4 + (i11 * 36 | 0) + 4 >> 2];
+ d6 = +HEAPF32[i4 + (i10 * 36 | 0) + 4 >> 2];
+ d7 = +(d7 < d8 ? d7 : d8);
+ d5 = +(d5 < d6 ? d5 : d6);
+ i24 = i4 + (i9 * 36 | 0) | 0;
+ HEAPF32[i24 >> 2] = d7;
+ HEAPF32[i24 + 4 >> 2] = d5;
+ d5 = +HEAPF32[i4 + (i11 * 36 | 0) + 8 >> 2];
+ d6 = +HEAPF32[i4 + (i10 * 36 | 0) + 8 >> 2];
+ d7 = +HEAPF32[i4 + (i11 * 36 | 0) + 12 >> 2];
+ d8 = +HEAPF32[i4 + (i10 * 36 | 0) + 12 >> 2];
+ d5 = +(d5 > d6 ? d5 : d6);
+ d23 = +(d7 > d8 ? d7 : d8);
+ i10 = i4 + (i9 * 36 | 0) + 8 | 0;
+ HEAPF32[i10 >> 2] = d5;
+ HEAPF32[i10 + 4 >> 2] = d23;
+ i10 = HEAP32[(HEAP32[i2 >> 2] | 0) + (i9 * 36 | 0) + 20 >> 2] | 0;
+ if ((i10 | 0) == -1) {
+ i2 = 24;
+ break;
+ }
+ }
+ if ((i2 | 0) == 20) {
+ ___assert_fail(3168, 2944, 307, 3184);
+ } else if ((i2 | 0) == 22) {
+ ___assert_fail(3200, 2944, 308, 3184);
+ } else if ((i2 | 0) == 24) {
+ STACKTOP = i1;
+ return;
+ }
+}
+function __ZN15b2ContactSolverC2EP18b2ContactSolverDef(i7, i5) {
+ i7 = i7 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, d15 = 0.0, d16 = 0.0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0;
+ i1 = STACKTOP;
+ HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i7 + 12 >> 2] = HEAP32[i5 + 12 >> 2];
+ HEAP32[i7 + 16 >> 2] = HEAP32[i5 + 16 >> 2];
+ HEAP32[i7 + 20 >> 2] = HEAP32[i5 + 20 >> 2];
+ i14 = HEAP32[i5 + 40 >> 2] | 0;
+ i9 = i7 + 32 | 0;
+ HEAP32[i9 >> 2] = i14;
+ i2 = HEAP32[i5 + 28 >> 2] | 0;
+ i4 = i7 + 48 | 0;
+ HEAP32[i4 >> 2] = i2;
+ i3 = i7 + 36 | 0;
+ HEAP32[i3 >> 2] = __ZN16b2StackAllocator8AllocateEi(i14, i2 * 88 | 0) | 0;
+ i2 = i7 + 40 | 0;
+ HEAP32[i2 >> 2] = __ZN16b2StackAllocator8AllocateEi(HEAP32[i9 >> 2] | 0, (HEAP32[i4 >> 2] | 0) * 152 | 0) | 0;
+ HEAP32[i7 + 24 >> 2] = HEAP32[i5 + 32 >> 2];
+ HEAP32[i7 + 28 >> 2] = HEAP32[i5 + 36 >> 2];
+ i9 = HEAP32[i5 + 24 >> 2] | 0;
+ i5 = i7 + 44 | 0;
+ HEAP32[i5 >> 2] = i9;
+ if ((HEAP32[i4 >> 2] | 0) <= 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i6 = i7 + 20 | 0;
+ i7 = i7 + 8 | 0;
+ i8 = 0;
+ while (1) {
+ i10 = HEAP32[i9 + (i8 << 2) >> 2] | 0;
+ i11 = HEAP32[i10 + 48 >> 2] | 0;
+ i12 = HEAP32[i10 + 52 >> 2] | 0;
+ i14 = HEAP32[i11 + 8 >> 2] | 0;
+ i13 = HEAP32[i12 + 8 >> 2] | 0;
+ i9 = HEAP32[i10 + 124 >> 2] | 0;
+ if ((i9 | 0) <= 0) {
+ i2 = 4;
+ break;
+ }
+ d15 = +HEAPF32[(HEAP32[i12 + 12 >> 2] | 0) + 8 >> 2];
+ d16 = +HEAPF32[(HEAP32[i11 + 12 >> 2] | 0) + 8 >> 2];
+ i12 = HEAP32[i2 >> 2] | 0;
+ HEAPF32[i12 + (i8 * 152 | 0) + 136 >> 2] = +HEAPF32[i10 + 136 >> 2];
+ HEAPF32[i12 + (i8 * 152 | 0) + 140 >> 2] = +HEAPF32[i10 + 140 >> 2];
+ i22 = i14 + 8 | 0;
+ HEAP32[i12 + (i8 * 152 | 0) + 112 >> 2] = HEAP32[i22 >> 2];
+ i21 = i13 + 8 | 0;
+ HEAP32[i12 + (i8 * 152 | 0) + 116 >> 2] = HEAP32[i21 >> 2];
+ i19 = i14 + 120 | 0;
+ HEAPF32[i12 + (i8 * 152 | 0) + 120 >> 2] = +HEAPF32[i19 >> 2];
+ i20 = i13 + 120 | 0;
+ HEAPF32[i12 + (i8 * 152 | 0) + 124 >> 2] = +HEAPF32[i20 >> 2];
+ i18 = i14 + 128 | 0;
+ HEAPF32[i12 + (i8 * 152 | 0) + 128 >> 2] = +HEAPF32[i18 >> 2];
+ i17 = i13 + 128 | 0;
+ HEAPF32[i12 + (i8 * 152 | 0) + 132 >> 2] = +HEAPF32[i17 >> 2];
+ HEAP32[i12 + (i8 * 152 | 0) + 148 >> 2] = i8;
+ HEAP32[i12 + (i8 * 152 | 0) + 144 >> 2] = i9;
+ i11 = i12 + (i8 * 152 | 0) + 80 | 0;
+ HEAP32[i11 + 0 >> 2] = 0;
+ HEAP32[i11 + 4 >> 2] = 0;
+ HEAP32[i11 + 8 >> 2] = 0;
+ HEAP32[i11 + 12 >> 2] = 0;
+ HEAP32[i11 + 16 >> 2] = 0;
+ HEAP32[i11 + 20 >> 2] = 0;
+ HEAP32[i11 + 24 >> 2] = 0;
+ HEAP32[i11 + 28 >> 2] = 0;
+ i11 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i11 + (i8 * 88 | 0) + 32 >> 2] = HEAP32[i22 >> 2];
+ HEAP32[i11 + (i8 * 88 | 0) + 36 >> 2] = HEAP32[i21 >> 2];
+ HEAPF32[i11 + (i8 * 88 | 0) + 40 >> 2] = +HEAPF32[i19 >> 2];
+ HEAPF32[i11 + (i8 * 88 | 0) + 44 >> 2] = +HEAPF32[i20 >> 2];
+ i20 = i14 + 28 | 0;
+ i14 = HEAP32[i20 + 4 >> 2] | 0;
+ i19 = i11 + (i8 * 88 | 0) + 48 | 0;
+ HEAP32[i19 >> 2] = HEAP32[i20 >> 2];
+ HEAP32[i19 + 4 >> 2] = i14;
+ i19 = i13 + 28 | 0;
+ i14 = HEAP32[i19 + 4 >> 2] | 0;
+ i13 = i11 + (i8 * 88 | 0) + 56 | 0;
+ HEAP32[i13 >> 2] = HEAP32[i19 >> 2];
+ HEAP32[i13 + 4 >> 2] = i14;
+ HEAPF32[i11 + (i8 * 88 | 0) + 64 >> 2] = +HEAPF32[i18 >> 2];
+ HEAPF32[i11 + (i8 * 88 | 0) + 68 >> 2] = +HEAPF32[i17 >> 2];
+ i13 = i10 + 104 | 0;
+ i14 = HEAP32[i13 + 4 >> 2] | 0;
+ i17 = i11 + (i8 * 88 | 0) + 16 | 0;
+ HEAP32[i17 >> 2] = HEAP32[i13 >> 2];
+ HEAP32[i17 + 4 >> 2] = i14;
+ i17 = i10 + 112 | 0;
+ i14 = HEAP32[i17 + 4 >> 2] | 0;
+ i13 = i11 + (i8 * 88 | 0) + 24 | 0;
+ HEAP32[i13 >> 2] = HEAP32[i17 >> 2];
+ HEAP32[i13 + 4 >> 2] = i14;
+ HEAP32[i11 + (i8 * 88 | 0) + 84 >> 2] = i9;
+ HEAPF32[i11 + (i8 * 88 | 0) + 76 >> 2] = d16;
+ HEAPF32[i11 + (i8 * 88 | 0) + 80 >> 2] = d15;
+ HEAP32[i11 + (i8 * 88 | 0) + 72 >> 2] = HEAP32[i10 + 120 >> 2];
+ i13 = 0;
+ do {
+ i14 = i10 + (i13 * 20 | 0) + 64 | 0;
+ if ((HEAP8[i6] | 0) == 0) {
+ HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 16 >> 2] = 0.0;
+ HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 20 >> 2] = 0.0;
+ } else {
+ HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 16 >> 2] = +HEAPF32[i7 >> 2] * +HEAPF32[i10 + (i13 * 20 | 0) + 72 >> 2];
+ HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 20 >> 2] = +HEAPF32[i7 >> 2] * +HEAPF32[i10 + (i13 * 20 | 0) + 76 >> 2];
+ }
+ i20 = i12 + (i8 * 152 | 0) + (i13 * 36 | 0) | 0;
+ HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 24 >> 2] = 0.0;
+ HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 28 >> 2] = 0.0;
+ HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 32 >> 2] = 0.0;
+ i22 = i11 + (i8 * 88 | 0) + (i13 << 3) | 0;
+ HEAP32[i20 + 0 >> 2] = 0;
+ HEAP32[i20 + 4 >> 2] = 0;
+ HEAP32[i20 + 8 >> 2] = 0;
+ HEAP32[i20 + 12 >> 2] = 0;
+ i20 = i14;
+ i21 = HEAP32[i20 + 4 >> 2] | 0;
+ HEAP32[i22 >> 2] = HEAP32[i20 >> 2];
+ HEAP32[i22 + 4 >> 2] = i21;
+ i13 = i13 + 1 | 0;
+ } while ((i13 | 0) != (i9 | 0));
+ i8 = i8 + 1 | 0;
+ if ((i8 | 0) >= (HEAP32[i4 >> 2] | 0)) {
+ i2 = 12;
+ break;
+ }
+ i9 = HEAP32[i5 >> 2] | 0;
+ }
+ if ((i2 | 0) == 4) {
+ ___assert_fail(6504, 6520, 71, 6568);
+ } else if ((i2 | 0) == 12) {
+ STACKTOP = i1;
+ return;
+ }
+}
+function __Z25b2CollidePolygonAndCircleP10b2ManifoldPK14b2PolygonShapeRK11b2TransformPK13b2CircleShapeS6_(i1, i4, i11, i9, i10) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i11 = i11 | 0;
+ i9 = i9 | 0;
+ i10 = i10 | 0;
+ var i2 = 0, i3 = 0, i5 = 0, d6 = 0.0, d7 = 0.0, d8 = 0.0, i12 = 0, d13 = 0.0, d14 = 0.0, i15 = 0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, d21 = 0.0, i22 = 0;
+ i3 = STACKTOP;
+ i5 = i1 + 60 | 0;
+ HEAP32[i5 >> 2] = 0;
+ i2 = i9 + 12 | 0;
+ d20 = +HEAPF32[i10 + 12 >> 2];
+ d7 = +HEAPF32[i2 >> 2];
+ d6 = +HEAPF32[i10 + 8 >> 2];
+ d21 = +HEAPF32[i9 + 16 >> 2];
+ d8 = +HEAPF32[i10 >> 2] + (d20 * d7 - d6 * d21) - +HEAPF32[i11 >> 2];
+ d21 = d7 * d6 + d20 * d21 + +HEAPF32[i10 + 4 >> 2] - +HEAPF32[i11 + 4 >> 2];
+ d20 = +HEAPF32[i11 + 12 >> 2];
+ d6 = +HEAPF32[i11 + 8 >> 2];
+ d7 = d8 * d20 + d21 * d6;
+ d6 = d20 * d21 - d8 * d6;
+ d8 = +HEAPF32[i4 + 8 >> 2] + +HEAPF32[i9 + 8 >> 2];
+ i12 = HEAP32[i4 + 148 >> 2] | 0;
+ do {
+ if ((i12 | 0) > 0) {
+ i10 = 0;
+ i9 = 0;
+ d13 = -3.4028234663852886e+38;
+ while (1) {
+ d14 = (d7 - +HEAPF32[i4 + (i10 << 3) + 20 >> 2]) * +HEAPF32[i4 + (i10 << 3) + 84 >> 2] + (d6 - +HEAPF32[i4 + (i10 << 3) + 24 >> 2]) * +HEAPF32[i4 + (i10 << 3) + 88 >> 2];
+ if (d14 > d8) {
+ i10 = 19;
+ break;
+ }
+ i11 = d14 > d13;
+ d13 = i11 ? d14 : d13;
+ i9 = i11 ? i10 : i9;
+ i10 = i10 + 1 | 0;
+ if ((i10 | 0) >= (i12 | 0)) {
+ i10 = 4;
+ break;
+ }
+ }
+ if ((i10 | 0) == 4) {
+ i22 = d13 < 1.1920928955078125e-7;
+ break;
+ } else if ((i10 | 0) == 19) {
+ STACKTOP = i3;
+ return;
+ }
+ } else {
+ i9 = 0;
+ i22 = 1;
+ }
+ } while (0);
+ i15 = i9 + 1 | 0;
+ i11 = i4 + (i9 << 3) + 20 | 0;
+ i10 = HEAP32[i11 >> 2] | 0;
+ i11 = HEAP32[i11 + 4 >> 2] | 0;
+ d14 = (HEAP32[tempDoublePtr >> 2] = i10, +HEAPF32[tempDoublePtr >> 2]);
+ d13 = (HEAP32[tempDoublePtr >> 2] = i11, +HEAPF32[tempDoublePtr >> 2]);
+ i12 = i4 + (((i15 | 0) < (i12 | 0) ? i15 : 0) << 3) + 20 | 0;
+ i15 = HEAP32[i12 >> 2] | 0;
+ i12 = HEAP32[i12 + 4 >> 2] | 0;
+ d21 = (HEAP32[tempDoublePtr >> 2] = i15, +HEAPF32[tempDoublePtr >> 2]);
+ d18 = (HEAP32[tempDoublePtr >> 2] = i12, +HEAPF32[tempDoublePtr >> 2]);
+ if (i22) {
+ HEAP32[i5 >> 2] = 1;
+ HEAP32[i1 + 56 >> 2] = 1;
+ i22 = i4 + (i9 << 3) + 84 | 0;
+ i15 = HEAP32[i22 + 4 >> 2] | 0;
+ i12 = i1 + 40 | 0;
+ HEAP32[i12 >> 2] = HEAP32[i22 >> 2];
+ HEAP32[i12 + 4 >> 2] = i15;
+ d20 = +((d14 + d21) * .5);
+ d21 = +((d13 + d18) * .5);
+ i12 = i1 + 48 | 0;
+ HEAPF32[i12 >> 2] = d20;
+ HEAPF32[i12 + 4 >> 2] = d21;
+ i12 = i2;
+ i15 = HEAP32[i12 + 4 >> 2] | 0;
+ i22 = i1;
+ HEAP32[i22 >> 2] = HEAP32[i12 >> 2];
+ HEAP32[i22 + 4 >> 2] = i15;
+ HEAP32[i1 + 16 >> 2] = 0;
+ STACKTOP = i3;
+ return;
+ }
+ d16 = d7 - d14;
+ d20 = d6 - d13;
+ d19 = d7 - d21;
+ d17 = d6 - d18;
+ if (d16 * (d21 - d14) + d20 * (d18 - d13) <= 0.0) {
+ if (d16 * d16 + d20 * d20 > d8 * d8) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i5 >> 2] = 1;
+ HEAP32[i1 + 56 >> 2] = 1;
+ i4 = i1 + 40 | 0;
+ d21 = +d16;
+ d6 = +d20;
+ i22 = i4;
+ HEAPF32[i22 >> 2] = d21;
+ HEAPF32[i22 + 4 >> 2] = d6;
+ d6 = +Math_sqrt(+(d16 * d16 + d20 * d20));
+ if (!(d6 < 1.1920928955078125e-7)) {
+ d21 = 1.0 / d6;
+ HEAPF32[i4 >> 2] = d16 * d21;
+ HEAPF32[i1 + 44 >> 2] = d20 * d21;
+ }
+ i12 = i1 + 48 | 0;
+ HEAP32[i12 >> 2] = i10;
+ HEAP32[i12 + 4 >> 2] = i11;
+ i12 = i2;
+ i15 = HEAP32[i12 + 4 >> 2] | 0;
+ i22 = i1;
+ HEAP32[i22 >> 2] = HEAP32[i12 >> 2];
+ HEAP32[i22 + 4 >> 2] = i15;
+ HEAP32[i1 + 16 >> 2] = 0;
+ STACKTOP = i3;
+ return;
+ }
+ if (!(d19 * (d14 - d21) + d17 * (d13 - d18) <= 0.0)) {
+ d14 = (d14 + d21) * .5;
+ d13 = (d13 + d18) * .5;
+ i10 = i4 + (i9 << 3) + 84 | 0;
+ if ((d7 - d14) * +HEAPF32[i10 >> 2] + (d6 - d13) * +HEAPF32[i4 + (i9 << 3) + 88 >> 2] > d8) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i5 >> 2] = 1;
+ HEAP32[i1 + 56 >> 2] = 1;
+ i22 = i10;
+ i15 = HEAP32[i22 + 4 >> 2] | 0;
+ i12 = i1 + 40 | 0;
+ HEAP32[i12 >> 2] = HEAP32[i22 >> 2];
+ HEAP32[i12 + 4 >> 2] = i15;
+ d20 = +d14;
+ d21 = +d13;
+ i12 = i1 + 48 | 0;
+ HEAPF32[i12 >> 2] = d20;
+ HEAPF32[i12 + 4 >> 2] = d21;
+ i12 = i2;
+ i15 = HEAP32[i12 + 4 >> 2] | 0;
+ i22 = i1;
+ HEAP32[i22 >> 2] = HEAP32[i12 >> 2];
+ HEAP32[i22 + 4 >> 2] = i15;
+ HEAP32[i1 + 16 >> 2] = 0;
+ STACKTOP = i3;
+ return;
+ }
+ if (d19 * d19 + d17 * d17 > d8 * d8) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i5 >> 2] = 1;
+ HEAP32[i1 + 56 >> 2] = 1;
+ i4 = i1 + 40 | 0;
+ d21 = +d19;
+ d6 = +d17;
+ i22 = i4;
+ HEAPF32[i22 >> 2] = d21;
+ HEAPF32[i22 + 4 >> 2] = d6;
+ d6 = +Math_sqrt(+(d19 * d19 + d17 * d17));
+ if (!(d6 < 1.1920928955078125e-7)) {
+ d21 = 1.0 / d6;
+ HEAPF32[i4 >> 2] = d19 * d21;
+ HEAPF32[i1 + 44 >> 2] = d17 * d21;
+ }
+ i22 = i1 + 48 | 0;
+ HEAP32[i22 >> 2] = i15;
+ HEAP32[i22 + 4 >> 2] = i12;
+ i12 = i2;
+ i15 = HEAP32[i12 + 4 >> 2] | 0;
+ i22 = i1;
+ HEAP32[i22 >> 2] = HEAP32[i12 >> 2];
+ HEAP32[i22 + 4 >> 2] = i15;
+ HEAP32[i1 + 16 >> 2] = 0;
+ STACKTOP = i3;
+ return;
+}
+function __ZN15b2WorldManifold10InitializeEPK10b2ManifoldRK11b2TransformfS5_f(i1, i5, i7, d4, i8, d3) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i7 = i7 | 0;
+ d4 = +d4;
+ i8 = i8 | 0;
+ d3 = +d3;
+ var i2 = 0, i6 = 0, d9 = 0.0, d10 = 0.0, i11 = 0, i12 = 0, i13 = 0, d14 = 0.0, d15 = 0.0, i16 = 0, d17 = 0.0, d18 = 0.0, d19 = 0.0, i20 = 0, d21 = 0.0, d22 = 0.0;
+ i2 = STACKTOP;
+ i6 = i5 + 60 | 0;
+ if ((HEAP32[i6 >> 2] | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i11 = HEAP32[i5 + 56 >> 2] | 0;
+ if ((i11 | 0) == 2) {
+ i13 = i8 + 12 | 0;
+ d17 = +HEAPF32[i13 >> 2];
+ d18 = +HEAPF32[i5 + 40 >> 2];
+ i16 = i8 + 8 | 0;
+ d19 = +HEAPF32[i16 >> 2];
+ d15 = +HEAPF32[i5 + 44 >> 2];
+ d14 = d17 * d18 - d19 * d15;
+ d15 = d18 * d19 + d17 * d15;
+ d17 = +d14;
+ d19 = +d15;
+ i12 = i1;
+ HEAPF32[i12 >> 2] = d17;
+ HEAPF32[i12 + 4 >> 2] = d19;
+ d19 = +HEAPF32[i13 >> 2];
+ d17 = +HEAPF32[i5 + 48 >> 2];
+ d18 = +HEAPF32[i16 >> 2];
+ d10 = +HEAPF32[i5 + 52 >> 2];
+ d9 = +HEAPF32[i8 >> 2] + (d19 * d17 - d18 * d10);
+ d10 = d17 * d18 + d19 * d10 + +HEAPF32[i8 + 4 >> 2];
+ if ((HEAP32[i6 >> 2] | 0) > 0) {
+ i8 = i7 + 12 | 0;
+ i11 = i7 + 8 | 0;
+ i12 = i7 + 4 | 0;
+ i13 = i1 + 4 | 0;
+ i16 = 0;
+ do {
+ d18 = +HEAPF32[i8 >> 2];
+ d22 = +HEAPF32[i5 + (i16 * 20 | 0) >> 2];
+ d21 = +HEAPF32[i11 >> 2];
+ d17 = +HEAPF32[i5 + (i16 * 20 | 0) + 4 >> 2];
+ d19 = +HEAPF32[i7 >> 2] + (d18 * d22 - d21 * d17);
+ d17 = d22 * d21 + d18 * d17 + +HEAPF32[i12 >> 2];
+ d18 = d3 - (d14 * (d19 - d9) + (d17 - d10) * d15);
+ d19 = +((d19 - d14 * d4 + (d19 + d14 * d18)) * .5);
+ d14 = +((d17 - d15 * d4 + (d17 + d15 * d18)) * .5);
+ i20 = i1 + (i16 << 3) + 8 | 0;
+ HEAPF32[i20 >> 2] = d19;
+ HEAPF32[i20 + 4 >> 2] = d14;
+ i16 = i16 + 1 | 0;
+ d14 = +HEAPF32[i1 >> 2];
+ d15 = +HEAPF32[i13 >> 2];
+ } while ((i16 | 0) < (HEAP32[i6 >> 2] | 0));
+ }
+ d21 = +-d14;
+ d22 = +-d15;
+ i20 = i1;
+ HEAPF32[i20 >> 2] = d21;
+ HEAPF32[i20 + 4 >> 2] = d22;
+ STACKTOP = i2;
+ return;
+ } else if ((i11 | 0) == 1) {
+ i16 = i7 + 12 | 0;
+ d19 = +HEAPF32[i16 >> 2];
+ d21 = +HEAPF32[i5 + 40 >> 2];
+ i20 = i7 + 8 | 0;
+ d22 = +HEAPF32[i20 >> 2];
+ d15 = +HEAPF32[i5 + 44 >> 2];
+ d14 = d19 * d21 - d22 * d15;
+ d15 = d21 * d22 + d19 * d15;
+ d19 = +d14;
+ d22 = +d15;
+ i13 = i1;
+ HEAPF32[i13 >> 2] = d19;
+ HEAPF32[i13 + 4 >> 2] = d22;
+ d22 = +HEAPF32[i16 >> 2];
+ d19 = +HEAPF32[i5 + 48 >> 2];
+ d21 = +HEAPF32[i20 >> 2];
+ d10 = +HEAPF32[i5 + 52 >> 2];
+ d9 = +HEAPF32[i7 >> 2] + (d22 * d19 - d21 * d10);
+ d10 = d19 * d21 + d22 * d10 + +HEAPF32[i7 + 4 >> 2];
+ if ((HEAP32[i6 >> 2] | 0) <= 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i12 = i8 + 12 | 0;
+ i11 = i8 + 8 | 0;
+ i7 = i8 + 4 | 0;
+ i13 = i1 + 4 | 0;
+ i16 = 0;
+ while (1) {
+ d22 = +HEAPF32[i12 >> 2];
+ d17 = +HEAPF32[i5 + (i16 * 20 | 0) >> 2];
+ d18 = +HEAPF32[i11 >> 2];
+ d19 = +HEAPF32[i5 + (i16 * 20 | 0) + 4 >> 2];
+ d21 = +HEAPF32[i8 >> 2] + (d22 * d17 - d18 * d19);
+ d19 = d17 * d18 + d22 * d19 + +HEAPF32[i7 >> 2];
+ d22 = d4 - (d14 * (d21 - d9) + (d19 - d10) * d15);
+ d21 = +((d21 - d14 * d3 + (d21 + d14 * d22)) * .5);
+ d22 = +((d19 - d15 * d3 + (d19 + d15 * d22)) * .5);
+ i20 = i1 + (i16 << 3) + 8 | 0;
+ HEAPF32[i20 >> 2] = d21;
+ HEAPF32[i20 + 4 >> 2] = d22;
+ i16 = i16 + 1 | 0;
+ if ((i16 | 0) >= (HEAP32[i6 >> 2] | 0)) {
+ break;
+ }
+ d14 = +HEAPF32[i1 >> 2];
+ d15 = +HEAPF32[i13 >> 2];
+ }
+ STACKTOP = i2;
+ return;
+ } else if ((i11 | 0) == 0) {
+ HEAPF32[i1 >> 2] = 1.0;
+ i6 = i1 + 4 | 0;
+ HEAPF32[i6 >> 2] = 0.0;
+ d21 = +HEAPF32[i7 + 12 >> 2];
+ d22 = +HEAPF32[i5 + 48 >> 2];
+ d19 = +HEAPF32[i7 + 8 >> 2];
+ d10 = +HEAPF32[i5 + 52 >> 2];
+ d9 = +HEAPF32[i7 >> 2] + (d21 * d22 - d19 * d10);
+ d10 = d22 * d19 + d21 * d10 + +HEAPF32[i7 + 4 >> 2];
+ d21 = +HEAPF32[i8 + 12 >> 2];
+ d19 = +HEAPF32[i5 >> 2];
+ d22 = +HEAPF32[i8 + 8 >> 2];
+ d15 = +HEAPF32[i5 + 4 >> 2];
+ d14 = +HEAPF32[i8 >> 2] + (d21 * d19 - d22 * d15);
+ d15 = d19 * d22 + d21 * d15 + +HEAPF32[i8 + 4 >> 2];
+ d21 = d9 - d14;
+ d22 = d10 - d15;
+ if (d21 * d21 + d22 * d22 > 1.4210854715202004e-14) {
+ d19 = d14 - d9;
+ d17 = d15 - d10;
+ d22 = +d19;
+ d18 = +d17;
+ i20 = i1;
+ HEAPF32[i20 >> 2] = d22;
+ HEAPF32[i20 + 4 >> 2] = d18;
+ d18 = +Math_sqrt(+(d19 * d19 + d17 * d17));
+ if (!(d18 < 1.1920928955078125e-7)) {
+ d22 = 1.0 / d18;
+ d19 = d19 * d22;
+ HEAPF32[i1 >> 2] = d19;
+ d17 = d17 * d22;
+ HEAPF32[i6 >> 2] = d17;
+ }
+ } else {
+ d19 = 1.0;
+ d17 = 0.0;
+ }
+ d21 = +((d9 + d19 * d4 + (d14 - d19 * d3)) * .5);
+ d22 = +((d10 + d17 * d4 + (d15 - d17 * d3)) * .5);
+ i20 = i1 + 8 | 0;
+ HEAPF32[i20 >> 2] = d21;
+ HEAPF32[i20 + 4 >> 2] = d22;
+ STACKTOP = i2;
+ return;
+ } else {
+ STACKTOP = i2;
+ return;
+ }
+}
+function _main(i3, i2) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i4 = 0, i5 = 0, d6 = 0.0, d7 = 0.0, i8 = 0, i9 = 0, d10 = 0.0, d11 = 0.0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, d22 = 0.0, d23 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 240 | 0;
+ i5 = i1;
+ i12 = i1 + 224 | 0;
+ i4 = i1 + 168 | 0;
+ i9 = i1 + 160 | 0;
+ i8 = i1 + 152 | 0;
+ L1 : do {
+ if ((i3 | 0) > 1) {
+ i14 = HEAP8[HEAP32[i2 + 4 >> 2] | 0] | 0;
+ switch (i14 | 0) {
+ case 49:
+ {
+ HEAP32[2] = 5;
+ HEAP32[4] = 35;
+ i15 = 35;
+ i14 = 5;
+ break L1;
+ }
+ case 50:
+ {
+ HEAP32[2] = 32;
+ HEAP32[4] = 161;
+ i15 = 161;
+ i14 = 32;
+ break L1;
+ }
+ case 51:
+ {
+ i13 = 5;
+ break L1;
+ }
+ case 52:
+ {
+ HEAP32[2] = 320;
+ HEAP32[4] = 2331;
+ i15 = 2331;
+ i14 = 320;
+ break L1;
+ }
+ case 53:
+ {
+ HEAP32[2] = 640;
+ HEAP32[4] = 5661;
+ i15 = 5661;
+ i14 = 640;
+ break L1;
+ }
+ case 48:
+ {
+ i20 = 0;
+ STACKTOP = i1;
+ return i20 | 0;
+ }
+ default:
+ {
+ HEAP32[i5 >> 2] = i14 + -48;
+ _printf(80, i5 | 0) | 0;
+ i20 = -1;
+ STACKTOP = i1;
+ return i20 | 0;
+ }
+ }
+ } else {
+ i13 = 5;
+ }
+ } while (0);
+ if ((i13 | 0) == 5) {
+ HEAP32[2] = 64;
+ HEAP32[4] = 333;
+ i15 = 333;
+ i14 = 64;
+ }
+ i13 = i15 + i14 | 0;
+ HEAP32[4] = i13;
+ HEAP32[2] = 0;
+ HEAP32[8] = __Znaj(i13 >>> 0 > 1073741823 ? -1 : i13 << 2) | 0;
+ HEAPF32[i12 >> 2] = 0.0;
+ HEAPF32[i12 + 4 >> 2] = -10.0;
+ i15 = __Znwj(103028) | 0;
+ __ZN7b2WorldC2ERK6b2Vec2(i15, i12);
+ HEAP32[6] = i15;
+ __ZN7b2World16SetAllowSleepingEb(i15, 0);
+ HEAP32[i5 + 44 >> 2] = 0;
+ i15 = i5 + 4 | 0;
+ i14 = i5 + 36 | 0;
+ HEAP32[i15 + 0 >> 2] = 0;
+ HEAP32[i15 + 4 >> 2] = 0;
+ HEAP32[i15 + 8 >> 2] = 0;
+ HEAP32[i15 + 12 >> 2] = 0;
+ HEAP32[i15 + 16 >> 2] = 0;
+ HEAP32[i15 + 20 >> 2] = 0;
+ HEAP32[i15 + 24 >> 2] = 0;
+ HEAP32[i15 + 28 >> 2] = 0;
+ HEAP8[i14] = 1;
+ HEAP8[i5 + 37 | 0] = 1;
+ HEAP8[i5 + 38 | 0] = 0;
+ HEAP8[i5 + 39 | 0] = 0;
+ HEAP32[i5 >> 2] = 0;
+ HEAP8[i5 + 40 | 0] = 1;
+ HEAPF32[i5 + 48 >> 2] = 1.0;
+ i14 = __ZN7b2World10CreateBodyEPK9b2BodyDef(HEAP32[6] | 0, i5) | 0;
+ HEAP32[i4 >> 2] = 240;
+ HEAP32[i4 + 4 >> 2] = 1;
+ HEAPF32[i4 + 8 >> 2] = .009999999776482582;
+ i15 = i4 + 28 | 0;
+ HEAP32[i15 + 0 >> 2] = 0;
+ HEAP32[i15 + 4 >> 2] = 0;
+ HEAP32[i15 + 8 >> 2] = 0;
+ HEAP32[i15 + 12 >> 2] = 0;
+ HEAP16[i15 + 16 >> 1] = 0;
+ HEAPF32[i9 >> 2] = -40.0;
+ HEAPF32[i9 + 4 >> 2] = 0.0;
+ HEAPF32[i8 >> 2] = 40.0;
+ HEAPF32[i8 + 4 >> 2] = 0.0;
+ __ZN11b2EdgeShape3SetERK6b2Vec2S2_(i4, i9, i8);
+ __ZN6b2Body13CreateFixtureEPK7b2Shapef(i14, i4, 0.0) | 0;
+ HEAP32[i5 >> 2] = 504;
+ HEAP32[i5 + 4 >> 2] = 2;
+ HEAPF32[i5 + 8 >> 2] = .009999999776482582;
+ HEAP32[i5 + 148 >> 2] = 0;
+ HEAPF32[i5 + 12 >> 2] = 0.0;
+ HEAPF32[i5 + 16 >> 2] = 0.0;
+ __ZN14b2PolygonShape8SetAsBoxEff(i5, .5, .5);
+ i14 = i4 + 44 | 0;
+ i15 = i4 + 4 | 0;
+ i8 = i4 + 36 | 0;
+ i17 = i4 + 37 | 0;
+ i18 = i4 + 38 | 0;
+ i19 = i4 + 39 | 0;
+ i20 = i4 + 40 | 0;
+ i13 = i4 + 48 | 0;
+ i12 = i4 + 4 | 0;
+ d11 = -7.0;
+ d10 = .75;
+ i9 = 0;
+ while (1) {
+ d7 = d11;
+ d6 = d10;
+ i16 = i9;
+ while (1) {
+ HEAP32[i14 >> 2] = 0;
+ HEAP32[i15 + 0 >> 2] = 0;
+ HEAP32[i15 + 4 >> 2] = 0;
+ HEAP32[i15 + 8 >> 2] = 0;
+ HEAP32[i15 + 12 >> 2] = 0;
+ HEAP32[i15 + 16 >> 2] = 0;
+ HEAP32[i15 + 20 >> 2] = 0;
+ HEAP32[i15 + 24 >> 2] = 0;
+ HEAP32[i15 + 28 >> 2] = 0;
+ HEAP8[i8] = 1;
+ HEAP8[i17] = 1;
+ HEAP8[i18] = 0;
+ HEAP8[i19] = 0;
+ HEAP8[i20] = 1;
+ HEAPF32[i13 >> 2] = 1.0;
+ HEAP32[i4 >> 2] = 2;
+ d23 = +d7;
+ d22 = +d6;
+ i21 = i12;
+ HEAPF32[i21 >> 2] = d23;
+ HEAPF32[i21 + 4 >> 2] = d22;
+ i21 = __ZN7b2World10CreateBodyEPK9b2BodyDef(HEAP32[6] | 0, i4) | 0;
+ __ZN6b2Body13CreateFixtureEPK7b2Shapef(i21, i5, 5.0) | 0;
+ HEAP32[14] = i21;
+ i16 = i16 + 1 | 0;
+ if ((i16 | 0) >= 40) {
+ break;
+ } else {
+ d7 = d7 + 1.125;
+ d6 = d6 + 0.0;
+ }
+ }
+ i9 = i9 + 1 | 0;
+ if ((i9 | 0) >= 40) {
+ break;
+ } else {
+ d11 = d11 + .5625;
+ d10 = d10 + 1.0;
+ }
+ }
+ if ((HEAP32[2] | 0) > 0) {
+ i4 = 0;
+ do {
+ __ZN7b2World4StepEfii(HEAP32[6] | 0, .01666666753590107, 3, 3);
+ i4 = i4 + 1 | 0;
+ } while ((i4 | 0) < (HEAP32[2] | 0));
+ }
+ if ((i3 | 0) > 2) {
+ i21 = (HEAP8[HEAP32[i2 + 8 >> 2] | 0] | 0) + -48 | 0;
+ HEAP32[18] = i21;
+ if ((i21 | 0) != 0) {
+ _puts(208) | 0;
+ _emscripten_set_main_loop(2, 60, 1);
+ i21 = 0;
+ STACKTOP = i1;
+ return i21 | 0;
+ }
+ } else {
+ HEAP32[18] = 0;
+ }
+ while (1) {
+ __Z4iterv();
+ if ((HEAP32[16] | 0) > (HEAP32[4] | 0)) {
+ i2 = 0;
+ break;
+ }
+ }
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function __ZN9b2Simplex9ReadCacheEPK14b2SimplexCachePK15b2DistanceProxyRK11b2TransformS5_S8_(i2, i11, i10, i4, i3, i5) {
+ i2 = i2 | 0;
+ i11 = i11 | 0;
+ i10 = i10 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i6 = 0, i7 = 0, d8 = 0.0, i9 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, d24 = 0.0, d25 = 0.0, i26 = 0, d27 = 0.0, d28 = 0.0, d29 = 0.0, d30 = 0.0, d31 = 0.0, d32 = 0.0;
+ i1 = STACKTOP;
+ i13 = HEAP16[i11 + 4 >> 1] | 0;
+ if (!((i13 & 65535) < 4)) {
+ ___assert_fail(2872, 2672, 102, 2896);
+ }
+ i12 = i13 & 65535;
+ i6 = i2 + 108 | 0;
+ HEAP32[i6 >> 2] = i12;
+ L4 : do {
+ if (!(i13 << 16 >> 16 == 0)) {
+ i17 = i10 + 20 | 0;
+ i21 = i10 + 16 | 0;
+ i13 = i3 + 20 | 0;
+ i14 = i3 + 16 | 0;
+ i15 = i4 + 12 | 0;
+ i16 = i4 + 8 | 0;
+ i12 = i4 + 4 | 0;
+ i18 = i5 + 12 | 0;
+ i19 = i5 + 8 | 0;
+ i20 = i5 + 4 | 0;
+ i22 = 0;
+ while (1) {
+ i26 = HEAPU8[i11 + i22 + 6 | 0] | 0;
+ HEAP32[i2 + (i22 * 36 | 0) + 28 >> 2] = i26;
+ i23 = HEAPU8[i11 + i22 + 9 | 0] | 0;
+ HEAP32[i2 + (i22 * 36 | 0) + 32 >> 2] = i23;
+ if ((HEAP32[i17 >> 2] | 0) <= (i26 | 0)) {
+ i9 = 6;
+ break;
+ }
+ i26 = (HEAP32[i21 >> 2] | 0) + (i26 << 3) | 0;
+ d25 = +HEAPF32[i26 >> 2];
+ d24 = +HEAPF32[i26 + 4 >> 2];
+ if ((HEAP32[i13 >> 2] | 0) <= (i23 | 0)) {
+ i9 = 8;
+ break;
+ }
+ i23 = (HEAP32[i14 >> 2] | 0) + (i23 << 3) | 0;
+ d29 = +HEAPF32[i23 >> 2];
+ d31 = +HEAPF32[i23 + 4 >> 2];
+ d32 = +HEAPF32[i15 >> 2];
+ d30 = +HEAPF32[i16 >> 2];
+ d27 = +HEAPF32[i4 >> 2] + (d25 * d32 - d24 * d30);
+ d28 = +d27;
+ d30 = +(d24 * d32 + d25 * d30 + +HEAPF32[i12 >> 2]);
+ i23 = i2 + (i22 * 36 | 0) | 0;
+ HEAPF32[i23 >> 2] = d28;
+ HEAPF32[i23 + 4 >> 2] = d30;
+ d30 = +HEAPF32[i18 >> 2];
+ d25 = +HEAPF32[i19 >> 2];
+ d24 = +HEAPF32[i5 >> 2] + (d29 * d30 - d31 * d25);
+ d28 = +d24;
+ d25 = +(d31 * d30 + d29 * d25 + +HEAPF32[i20 >> 2]);
+ i23 = i2 + (i22 * 36 | 0) + 8 | 0;
+ HEAPF32[i23 >> 2] = d28;
+ HEAPF32[i23 + 4 >> 2] = d25;
+ d24 = +(d24 - d27);
+ d25 = +(+HEAPF32[i2 + (i22 * 36 | 0) + 12 >> 2] - +HEAPF32[i2 + (i22 * 36 | 0) + 4 >> 2]);
+ i23 = i2 + (i22 * 36 | 0) + 16 | 0;
+ HEAPF32[i23 >> 2] = d24;
+ HEAPF32[i23 + 4 >> 2] = d25;
+ HEAPF32[i2 + (i22 * 36 | 0) + 24 >> 2] = 0.0;
+ i22 = i22 + 1 | 0;
+ i23 = HEAP32[i6 >> 2] | 0;
+ if ((i22 | 0) >= (i23 | 0)) {
+ i7 = i23;
+ break L4;
+ }
+ }
+ if ((i9 | 0) == 6) {
+ ___assert_fail(2776, 2808, 103, 2840);
+ } else if ((i9 | 0) == 8) {
+ ___assert_fail(2776, 2808, 103, 2840);
+ }
+ } else {
+ i7 = i12;
+ }
+ } while (0);
+ do {
+ if ((i7 | 0) > 1) {
+ d24 = +HEAPF32[i11 >> 2];
+ if ((i7 | 0) == 2) {
+ d32 = +HEAPF32[i2 + 16 >> 2] - +HEAPF32[i2 + 52 >> 2];
+ d8 = +HEAPF32[i2 + 20 >> 2] - +HEAPF32[i2 + 56 >> 2];
+ d8 = +Math_sqrt(+(d32 * d32 + d8 * d8));
+ } else if ((i7 | 0) == 3) {
+ d8 = +HEAPF32[i2 + 16 >> 2];
+ d32 = +HEAPF32[i2 + 20 >> 2];
+ d8 = (+HEAPF32[i2 + 52 >> 2] - d8) * (+HEAPF32[i2 + 92 >> 2] - d32) - (+HEAPF32[i2 + 56 >> 2] - d32) * (+HEAPF32[i2 + 88 >> 2] - d8);
+ } else {
+ ___assert_fail(2712, 2672, 259, 2736);
+ }
+ if (!(d8 < d24 * .5) ? !(d24 * 2.0 < d8 | d8 < 1.1920928955078125e-7) : 0) {
+ i9 = 18;
+ break;
+ }
+ HEAP32[i6 >> 2] = 0;
+ } else {
+ i9 = 18;
+ }
+ } while (0);
+ if ((i9 | 0) == 18 ? (i7 | 0) != 0 : 0) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[i2 + 28 >> 2] = 0;
+ HEAP32[i2 + 32 >> 2] = 0;
+ if ((HEAP32[i10 + 20 >> 2] | 0) <= 0) {
+ ___assert_fail(2776, 2808, 103, 2840);
+ }
+ i26 = HEAP32[i10 + 16 >> 2] | 0;
+ d8 = +HEAPF32[i26 >> 2];
+ d24 = +HEAPF32[i26 + 4 >> 2];
+ if ((HEAP32[i3 + 20 >> 2] | 0) <= 0) {
+ ___assert_fail(2776, 2808, 103, 2840);
+ }
+ i26 = HEAP32[i3 + 16 >> 2] | 0;
+ d27 = +HEAPF32[i26 >> 2];
+ d25 = +HEAPF32[i26 + 4 >> 2];
+ d30 = +HEAPF32[i4 + 12 >> 2];
+ d32 = +HEAPF32[i4 + 8 >> 2];
+ d31 = +HEAPF32[i4 >> 2] + (d8 * d30 - d24 * d32);
+ d32 = d24 * d30 + d8 * d32 + +HEAPF32[i4 + 4 >> 2];
+ d30 = +d31;
+ d28 = +d32;
+ i26 = i2;
+ HEAPF32[i26 >> 2] = d30;
+ HEAPF32[i26 + 4 >> 2] = d28;
+ d28 = +HEAPF32[i5 + 12 >> 2];
+ d30 = +HEAPF32[i5 + 8 >> 2];
+ d29 = +HEAPF32[i5 >> 2] + (d27 * d28 - d25 * d30);
+ d30 = d25 * d28 + d27 * d30 + +HEAPF32[i5 + 4 >> 2];
+ d27 = +d29;
+ d28 = +d30;
+ i26 = i2 + 8 | 0;
+ HEAPF32[i26 >> 2] = d27;
+ HEAPF32[i26 + 4 >> 2] = d28;
+ d31 = +(d29 - d31);
+ d32 = +(d30 - d32);
+ i26 = i2 + 16 | 0;
+ HEAPF32[i26 >> 2] = d31;
+ HEAPF32[i26 + 4 >> 2] = d32;
+ HEAP32[i6 >> 2] = 1;
+ STACKTOP = i1;
+ return;
+}
+function __ZNSt3__17__sort4IRPFbRK6b2PairS3_EPS1_EEjT0_S8_S8_S8_T_(i6, i7, i5, i4, i1) {
+ i6 = i6 | 0;
+ i7 = i7 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i8 = 0, i9 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ i9 = FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i7, i6) | 0;
+ i8 = FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i7) | 0;
+ do {
+ if (i9) {
+ if (i8) {
+ HEAP32[i3 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i6 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ i8 = 1;
+ break;
+ }
+ HEAP32[i3 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i6 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i7) | 0) {
+ HEAP32[i3 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ i8 = 2;
+ } else {
+ i8 = 1;
+ }
+ } else {
+ if (i8) {
+ HEAP32[i3 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i7, i6) | 0) {
+ HEAP32[i3 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i6 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ i8 = 2;
+ } else {
+ i8 = 1;
+ }
+ } else {
+ i8 = 0;
+ }
+ }
+ } while (0);
+ if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i5) | 0)) {
+ i9 = i8;
+ STACKTOP = i2;
+ return i9 | 0;
+ }
+ HEAP32[i3 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i4 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i7) | 0)) {
+ i9 = i8 + 1 | 0;
+ STACKTOP = i2;
+ return i9 | 0;
+ }
+ HEAP32[i3 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i7, i6) | 0)) {
+ i9 = i8 + 2 | 0;
+ STACKTOP = i2;
+ return i9 | 0;
+ }
+ HEAP32[i3 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ HEAP32[i6 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ i9 = i8 + 3 | 0;
+ STACKTOP = i2;
+ return i9 | 0;
+}
+function __ZN15b2ContactSolver27SolveTOIPositionConstraintsEii(i9, i2, i5) {
+ i9 = i9 | 0;
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, d21 = 0.0, d22 = 0.0, d23 = 0.0, d24 = 0.0, d25 = 0.0, d26 = 0.0, d27 = 0.0, d28 = 0.0, d29 = 0.0, d30 = 0.0, d31 = 0.0, d32 = 0.0, d33 = 0.0, d34 = 0.0, d35 = 0.0, d36 = 0.0, i37 = 0, d38 = 0.0, d39 = 0.0, d40 = 0.0, d41 = 0.0, d42 = 0.0, d43 = 0.0, d44 = 0.0, d45 = 0.0, i46 = 0, d47 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i8 = i1 + 40 | 0;
+ i3 = i1 + 24 | 0;
+ i4 = i1;
+ i6 = i9 + 48 | 0;
+ if ((HEAP32[i6 >> 2] | 0) <= 0) {
+ d45 = 0.0;
+ i37 = d45 >= -.007499999832361937;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ i7 = i9 + 36 | 0;
+ i14 = i9 + 24 | 0;
+ i9 = i8 + 8 | 0;
+ i15 = i8 + 12 | 0;
+ i10 = i3 + 8 | 0;
+ i11 = i3 + 12 | 0;
+ i12 = i4 + 8 | 0;
+ i13 = i4 + 16 | 0;
+ i16 = 0;
+ d34 = 0.0;
+ do {
+ i37 = HEAP32[i7 >> 2] | 0;
+ i19 = i37 + (i16 * 88 | 0) | 0;
+ i17 = HEAP32[i37 + (i16 * 88 | 0) + 32 >> 2] | 0;
+ i18 = HEAP32[i37 + (i16 * 88 | 0) + 36 >> 2] | 0;
+ i20 = i37 + (i16 * 88 | 0) + 48 | 0;
+ d21 = +HEAPF32[i20 >> 2];
+ d22 = +HEAPF32[i20 + 4 >> 2];
+ i20 = i37 + (i16 * 88 | 0) + 56 | 0;
+ d23 = +HEAPF32[i20 >> 2];
+ d24 = +HEAPF32[i20 + 4 >> 2];
+ i20 = HEAP32[i37 + (i16 * 88 | 0) + 84 >> 2] | 0;
+ if ((i17 | 0) == (i2 | 0) | (i17 | 0) == (i5 | 0)) {
+ d26 = +HEAPF32[i37 + (i16 * 88 | 0) + 64 >> 2];
+ d27 = +HEAPF32[i37 + (i16 * 88 | 0) + 40 >> 2];
+ } else {
+ d26 = 0.0;
+ d27 = 0.0;
+ }
+ d25 = +HEAPF32[i37 + (i16 * 88 | 0) + 44 >> 2];
+ d28 = +HEAPF32[i37 + (i16 * 88 | 0) + 68 >> 2];
+ i37 = HEAP32[i14 >> 2] | 0;
+ i46 = i37 + (i17 * 12 | 0) | 0;
+ d33 = +HEAPF32[i46 >> 2];
+ d35 = +HEAPF32[i46 + 4 >> 2];
+ d29 = +HEAPF32[i37 + (i17 * 12 | 0) + 8 >> 2];
+ i46 = i37 + (i18 * 12 | 0) | 0;
+ d32 = +HEAPF32[i46 >> 2];
+ d36 = +HEAPF32[i46 + 4 >> 2];
+ d31 = +HEAPF32[i37 + (i18 * 12 | 0) + 8 >> 2];
+ if ((i20 | 0) > 0) {
+ d30 = d27 + d25;
+ i37 = 0;
+ do {
+ d38 = +Math_sin(+d29);
+ HEAPF32[i9 >> 2] = d38;
+ d44 = +Math_cos(+d29);
+ HEAPF32[i15 >> 2] = d44;
+ d43 = +Math_sin(+d31);
+ HEAPF32[i10 >> 2] = d43;
+ d41 = +Math_cos(+d31);
+ HEAPF32[i11 >> 2] = d41;
+ d40 = +(d33 - (d21 * d44 - d22 * d38));
+ d38 = +(d35 - (d22 * d44 + d21 * d38));
+ i46 = i8;
+ HEAPF32[i46 >> 2] = d40;
+ HEAPF32[i46 + 4 >> 2] = d38;
+ d38 = +(d32 - (d23 * d41 - d24 * d43));
+ d43 = +(d36 - (d24 * d41 + d23 * d43));
+ i46 = i3;
+ HEAPF32[i46 >> 2] = d38;
+ HEAPF32[i46 + 4 >> 2] = d43;
+ __ZN24b2PositionSolverManifold10InitializeEP27b2ContactPositionConstraintRK11b2TransformS4_i(i4, i19, i8, i3, i37);
+ i46 = i4;
+ d43 = +HEAPF32[i46 >> 2];
+ d38 = +HEAPF32[i46 + 4 >> 2];
+ i46 = i12;
+ d41 = +HEAPF32[i46 >> 2];
+ d40 = +HEAPF32[i46 + 4 >> 2];
+ d44 = +HEAPF32[i13 >> 2];
+ d39 = d41 - d33;
+ d42 = d40 - d35;
+ d41 = d41 - d32;
+ d40 = d40 - d36;
+ d34 = d34 < d44 ? d34 : d44;
+ d44 = (d44 + .004999999888241291) * .75;
+ d44 = d44 < 0.0 ? d44 : 0.0;
+ d45 = d38 * d39 - d43 * d42;
+ d47 = d38 * d41 - d43 * d40;
+ d45 = d47 * d28 * d47 + (d30 + d45 * d26 * d45);
+ if (d45 > 0.0) {
+ d44 = -(d44 < -.20000000298023224 ? -.20000000298023224 : d44) / d45;
+ } else {
+ d44 = 0.0;
+ }
+ d47 = d43 * d44;
+ d45 = d38 * d44;
+ d33 = d33 - d27 * d47;
+ d35 = d35 - d27 * d45;
+ d29 = d29 - d26 * (d39 * d45 - d42 * d47);
+ d32 = d32 + d25 * d47;
+ d36 = d36 + d25 * d45;
+ d31 = d31 + d28 * (d41 * d45 - d40 * d47);
+ i37 = i37 + 1 | 0;
+ } while ((i37 | 0) != (i20 | 0));
+ i37 = HEAP32[i14 >> 2] | 0;
+ }
+ d47 = +d33;
+ d45 = +d35;
+ i46 = i37 + (i17 * 12 | 0) | 0;
+ HEAPF32[i46 >> 2] = d47;
+ HEAPF32[i46 + 4 >> 2] = d45;
+ i46 = HEAP32[i14 >> 2] | 0;
+ HEAPF32[i46 + (i17 * 12 | 0) + 8 >> 2] = d29;
+ d45 = +d32;
+ d47 = +d36;
+ i46 = i46 + (i18 * 12 | 0) | 0;
+ HEAPF32[i46 >> 2] = d45;
+ HEAPF32[i46 + 4 >> 2] = d47;
+ HEAPF32[(HEAP32[i14 >> 2] | 0) + (i18 * 12 | 0) + 8 >> 2] = d31;
+ i16 = i16 + 1 | 0;
+ } while ((i16 | 0) < (HEAP32[i6 >> 2] | 0));
+ i46 = d34 >= -.007499999832361937;
+ STACKTOP = i1;
+ return i46 | 0;
+}
+function __ZN15b2ContactSolver24SolvePositionConstraintsEv(i7) {
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, i21 = 0, d22 = 0.0, d23 = 0.0, d24 = 0.0, d25 = 0.0, i26 = 0, d27 = 0.0, d28 = 0.0, d29 = 0.0, d30 = 0.0, d31 = 0.0, d32 = 0.0, d33 = 0.0, d34 = 0.0, i35 = 0, d36 = 0.0, d37 = 0.0, d38 = 0.0, d39 = 0.0, d40 = 0.0, d41 = 0.0, d42 = 0.0, d43 = 0.0, i44 = 0, d45 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i4 = i1 + 40 | 0;
+ i5 = i1 + 24 | 0;
+ i3 = i1;
+ i2 = i7 + 48 | 0;
+ if ((HEAP32[i2 >> 2] | 0) <= 0) {
+ d43 = 0.0;
+ i35 = d43 >= -.014999999664723873;
+ STACKTOP = i1;
+ return i35 | 0;
+ }
+ i6 = i7 + 36 | 0;
+ i9 = i7 + 24 | 0;
+ i13 = i4 + 8 | 0;
+ i7 = i4 + 12 | 0;
+ i8 = i5 + 8 | 0;
+ i12 = i5 + 12 | 0;
+ i10 = i3 + 8 | 0;
+ i11 = i3 + 16 | 0;
+ i35 = HEAP32[i9 >> 2] | 0;
+ i15 = 0;
+ d32 = 0.0;
+ do {
+ i21 = HEAP32[i6 >> 2] | 0;
+ i26 = i21 + (i15 * 88 | 0) | 0;
+ i16 = HEAP32[i21 + (i15 * 88 | 0) + 32 >> 2] | 0;
+ i14 = HEAP32[i21 + (i15 * 88 | 0) + 36 >> 2] | 0;
+ i44 = i21 + (i15 * 88 | 0) + 48 | 0;
+ d22 = +HEAPF32[i44 >> 2];
+ d23 = +HEAPF32[i44 + 4 >> 2];
+ d25 = +HEAPF32[i21 + (i15 * 88 | 0) + 40 >> 2];
+ d18 = +HEAPF32[i21 + (i15 * 88 | 0) + 64 >> 2];
+ i44 = i21 + (i15 * 88 | 0) + 56 | 0;
+ d24 = +HEAPF32[i44 >> 2];
+ d19 = +HEAPF32[i44 + 4 >> 2];
+ d17 = +HEAPF32[i21 + (i15 * 88 | 0) + 44 >> 2];
+ d20 = +HEAPF32[i21 + (i15 * 88 | 0) + 68 >> 2];
+ i21 = HEAP32[i21 + (i15 * 88 | 0) + 84 >> 2] | 0;
+ i44 = i35 + (i16 * 12 | 0) | 0;
+ d28 = +HEAPF32[i44 >> 2];
+ d33 = +HEAPF32[i44 + 4 >> 2];
+ d29 = +HEAPF32[i35 + (i16 * 12 | 0) + 8 >> 2];
+ i44 = i35 + (i14 * 12 | 0) | 0;
+ d30 = +HEAPF32[i44 >> 2];
+ d34 = +HEAPF32[i44 + 4 >> 2];
+ d31 = +HEAPF32[i35 + (i14 * 12 | 0) + 8 >> 2];
+ if ((i21 | 0) > 0) {
+ d27 = d25 + d17;
+ i35 = 0;
+ do {
+ d41 = +Math_sin(+d29);
+ HEAPF32[i13 >> 2] = d41;
+ d42 = +Math_cos(+d29);
+ HEAPF32[i7 >> 2] = d42;
+ d39 = +Math_sin(+d31);
+ HEAPF32[i8 >> 2] = d39;
+ d38 = +Math_cos(+d31);
+ HEAPF32[i12 >> 2] = d38;
+ d40 = +(d28 - (d22 * d42 - d23 * d41));
+ d41 = +(d33 - (d23 * d42 + d22 * d41));
+ i44 = i4;
+ HEAPF32[i44 >> 2] = d40;
+ HEAPF32[i44 + 4 >> 2] = d41;
+ d41 = +(d30 - (d24 * d38 - d19 * d39));
+ d39 = +(d34 - (d19 * d38 + d24 * d39));
+ i44 = i5;
+ HEAPF32[i44 >> 2] = d41;
+ HEAPF32[i44 + 4 >> 2] = d39;
+ __ZN24b2PositionSolverManifold10InitializeEP27b2ContactPositionConstraintRK11b2TransformS4_i(i3, i26, i4, i5, i35);
+ i44 = i3;
+ d39 = +HEAPF32[i44 >> 2];
+ d41 = +HEAPF32[i44 + 4 >> 2];
+ i44 = i10;
+ d38 = +HEAPF32[i44 >> 2];
+ d40 = +HEAPF32[i44 + 4 >> 2];
+ d42 = +HEAPF32[i11 >> 2];
+ d36 = d38 - d28;
+ d37 = d40 - d33;
+ d38 = d38 - d30;
+ d40 = d40 - d34;
+ d32 = d32 < d42 ? d32 : d42;
+ d42 = (d42 + .004999999888241291) * .20000000298023224;
+ d43 = d42 < 0.0 ? d42 : 0.0;
+ d42 = d41 * d36 - d39 * d37;
+ d45 = d41 * d38 - d39 * d40;
+ d42 = d45 * d20 * d45 + (d27 + d42 * d18 * d42);
+ if (d42 > 0.0) {
+ d42 = -(d43 < -.20000000298023224 ? -.20000000298023224 : d43) / d42;
+ } else {
+ d42 = 0.0;
+ }
+ d45 = d39 * d42;
+ d43 = d41 * d42;
+ d28 = d28 - d25 * d45;
+ d33 = d33 - d25 * d43;
+ d29 = d29 - d18 * (d36 * d43 - d37 * d45);
+ d30 = d30 + d17 * d45;
+ d34 = d34 + d17 * d43;
+ d31 = d31 + d20 * (d38 * d43 - d40 * d45);
+ i35 = i35 + 1 | 0;
+ } while ((i35 | 0) != (i21 | 0));
+ i35 = HEAP32[i9 >> 2] | 0;
+ }
+ d45 = +d28;
+ d43 = +d33;
+ i35 = i35 + (i16 * 12 | 0) | 0;
+ HEAPF32[i35 >> 2] = d45;
+ HEAPF32[i35 + 4 >> 2] = d43;
+ i35 = HEAP32[i9 >> 2] | 0;
+ HEAPF32[i35 + (i16 * 12 | 0) + 8 >> 2] = d29;
+ d43 = +d30;
+ d45 = +d34;
+ i35 = i35 + (i14 * 12 | 0) | 0;
+ HEAPF32[i35 >> 2] = d43;
+ HEAPF32[i35 + 4 >> 2] = d45;
+ i35 = HEAP32[i9 >> 2] | 0;
+ HEAPF32[i35 + (i14 * 12 | 0) + 8 >> 2] = d31;
+ i15 = i15 + 1 | 0;
+ } while ((i15 | 0) < (HEAP32[i2 >> 2] | 0));
+ i44 = d32 >= -.014999999664723873;
+ STACKTOP = i1;
+ return i44 | 0;
+}
+function __Z22b2CollideEdgeAndCircleP10b2ManifoldPK11b2EdgeShapeRK11b2TransformPK13b2CircleShapeS6_(i1, i7, i6, i22, i5) {
+ i1 = i1 | 0;
+ i7 = i7 | 0;
+ i6 = i6 | 0;
+ i22 = i22 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, d8 = 0.0, d9 = 0.0, d10 = 0.0, d11 = 0.0, d12 = 0.0, d13 = 0.0, i14 = 0, i15 = 0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, d21 = 0.0, d23 = 0.0, d24 = 0.0;
+ i4 = STACKTOP;
+ i2 = i1 + 60 | 0;
+ HEAP32[i2 >> 2] = 0;
+ i3 = i22 + 12 | 0;
+ d9 = +HEAPF32[i5 + 12 >> 2];
+ d23 = +HEAPF32[i3 >> 2];
+ d17 = +HEAPF32[i5 + 8 >> 2];
+ d18 = +HEAPF32[i22 + 16 >> 2];
+ d21 = +HEAPF32[i5 >> 2] + (d9 * d23 - d17 * d18) - +HEAPF32[i6 >> 2];
+ d18 = d23 * d17 + d9 * d18 + +HEAPF32[i5 + 4 >> 2] - +HEAPF32[i6 + 4 >> 2];
+ d9 = +HEAPF32[i6 + 12 >> 2];
+ d17 = +HEAPF32[i6 + 8 >> 2];
+ d23 = d21 * d9 + d18 * d17;
+ d17 = d9 * d18 - d21 * d17;
+ i6 = i7 + 12 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ i6 = HEAP32[i6 + 4 >> 2] | 0;
+ d21 = (HEAP32[tempDoublePtr >> 2] = i5, +HEAPF32[tempDoublePtr >> 2]);
+ d18 = (HEAP32[tempDoublePtr >> 2] = i6, +HEAPF32[tempDoublePtr >> 2]);
+ i15 = i7 + 20 | 0;
+ i14 = HEAP32[i15 >> 2] | 0;
+ i15 = HEAP32[i15 + 4 >> 2] | 0;
+ d9 = (HEAP32[tempDoublePtr >> 2] = i14, +HEAPF32[tempDoublePtr >> 2]);
+ d10 = (HEAP32[tempDoublePtr >> 2] = i15, +HEAPF32[tempDoublePtr >> 2]);
+ d8 = d9 - d21;
+ d16 = d10 - d18;
+ d19 = d8 * (d9 - d23) + d16 * (d10 - d17);
+ d13 = d23 - d21;
+ d12 = d17 - d18;
+ d20 = d13 * d8 + d12 * d16;
+ d11 = +HEAPF32[i7 + 8 >> 2] + +HEAPF32[i22 + 8 >> 2];
+ if (d20 <= 0.0) {
+ if (d13 * d13 + d12 * d12 > d11 * d11) {
+ STACKTOP = i4;
+ return;
+ }
+ if ((HEAP8[i7 + 44 | 0] | 0) != 0 ? (i22 = i7 + 28 | 0, d24 = +HEAPF32[i22 >> 2], (d21 - d23) * (d21 - d24) + (d18 - d17) * (d18 - +HEAPF32[i22 + 4 >> 2]) > 0.0) : 0) {
+ STACKTOP = i4;
+ return;
+ }
+ HEAP32[i2 >> 2] = 1;
+ HEAP32[i1 + 56 >> 2] = 0;
+ HEAPF32[i1 + 40 >> 2] = 0.0;
+ HEAPF32[i1 + 44 >> 2] = 0.0;
+ i14 = i1 + 48 | 0;
+ HEAP32[i14 >> 2] = i5;
+ HEAP32[i14 + 4 >> 2] = i6;
+ i14 = i1 + 16 | 0;
+ HEAP32[i14 >> 2] = 0;
+ HEAP8[i14] = 0;
+ HEAP8[i14 + 1 | 0] = 0;
+ HEAP8[i14 + 2 | 0] = 0;
+ HEAP8[i14 + 3 | 0] = 0;
+ i14 = i3;
+ i15 = HEAP32[i14 + 4 >> 2] | 0;
+ i22 = i1;
+ HEAP32[i22 >> 2] = HEAP32[i14 >> 2];
+ HEAP32[i22 + 4 >> 2] = i15;
+ STACKTOP = i4;
+ return;
+ }
+ if (d19 <= 0.0) {
+ d8 = d23 - d9;
+ d12 = d17 - d10;
+ if (d8 * d8 + d12 * d12 > d11 * d11) {
+ STACKTOP = i4;
+ return;
+ }
+ if ((HEAP8[i7 + 45 | 0] | 0) != 0 ? (i22 = i7 + 36 | 0, d24 = +HEAPF32[i22 >> 2], d8 * (d24 - d9) + d12 * (+HEAPF32[i22 + 4 >> 2] - d10) > 0.0) : 0) {
+ STACKTOP = i4;
+ return;
+ }
+ HEAP32[i2 >> 2] = 1;
+ HEAP32[i1 + 56 >> 2] = 0;
+ HEAPF32[i1 + 40 >> 2] = 0.0;
+ HEAPF32[i1 + 44 >> 2] = 0.0;
+ i22 = i1 + 48 | 0;
+ HEAP32[i22 >> 2] = i14;
+ HEAP32[i22 + 4 >> 2] = i15;
+ i14 = i1 + 16 | 0;
+ HEAP32[i14 >> 2] = 0;
+ HEAP8[i14] = 1;
+ HEAP8[i14 + 1 | 0] = 0;
+ HEAP8[i14 + 2 | 0] = 0;
+ HEAP8[i14 + 3 | 0] = 0;
+ i14 = i3;
+ i15 = HEAP32[i14 + 4 >> 2] | 0;
+ i22 = i1;
+ HEAP32[i22 >> 2] = HEAP32[i14 >> 2];
+ HEAP32[i22 + 4 >> 2] = i15;
+ STACKTOP = i4;
+ return;
+ }
+ d24 = d8 * d8 + d16 * d16;
+ if (!(d24 > 0.0)) {
+ ___assert_fail(5560, 5576, 127, 5616);
+ }
+ d24 = 1.0 / d24;
+ d23 = d23 - (d21 * d19 + d9 * d20) * d24;
+ d24 = d17 - (d18 * d19 + d10 * d20) * d24;
+ if (d23 * d23 + d24 * d24 > d11 * d11) {
+ STACKTOP = i4;
+ return;
+ }
+ d9 = -d16;
+ if (d8 * d12 + d13 * d9 < 0.0) {
+ d8 = -d8;
+ } else {
+ d16 = d9;
+ }
+ d9 = +Math_sqrt(+(d8 * d8 + d16 * d16));
+ if (!(d9 < 1.1920928955078125e-7)) {
+ d24 = 1.0 / d9;
+ d16 = d16 * d24;
+ d8 = d8 * d24;
+ }
+ HEAP32[i2 >> 2] = 1;
+ HEAP32[i1 + 56 >> 2] = 1;
+ d23 = +d16;
+ d24 = +d8;
+ i14 = i1 + 40 | 0;
+ HEAPF32[i14 >> 2] = d23;
+ HEAPF32[i14 + 4 >> 2] = d24;
+ i14 = i1 + 48 | 0;
+ HEAP32[i14 >> 2] = i5;
+ HEAP32[i14 + 4 >> 2] = i6;
+ i14 = i1 + 16 | 0;
+ HEAP32[i14 >> 2] = 0;
+ HEAP8[i14] = 0;
+ HEAP8[i14 + 1 | 0] = 0;
+ HEAP8[i14 + 2 | 0] = 1;
+ HEAP8[i14 + 3 | 0] = 0;
+ i14 = i3;
+ i15 = HEAP32[i14 + 4 >> 2] | 0;
+ i22 = i1;
+ HEAP32[i22 >> 2] = HEAP32[i14 >> 2];
+ HEAP32[i22 + 4 >> 2] = i15;
+ STACKTOP = i4;
+ return;
+}
+function __ZN6b2BodyC2EPK9b2BodyDefP7b2World(i1, i2, i5) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ var i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, d13 = 0.0;
+ i3 = STACKTOP;
+ i9 = i2 + 4 | 0;
+ d13 = +HEAPF32[i9 >> 2];
+ if (!(d13 == d13 & 0.0 == 0.0 & d13 > -inf & d13 < inf)) {
+ ___assert_fail(1496, 1520, 27, 1552);
+ }
+ d13 = +HEAPF32[i2 + 8 >> 2];
+ if (!(d13 == d13 & 0.0 == 0.0 & d13 > -inf & d13 < inf)) {
+ ___assert_fail(1496, 1520, 27, 1552);
+ }
+ i6 = i2 + 16 | 0;
+ d13 = +HEAPF32[i6 >> 2];
+ if (!(d13 == d13 & 0.0 == 0.0 & d13 > -inf & d13 < inf)) {
+ ___assert_fail(1560, 1520, 28, 1552);
+ }
+ d13 = +HEAPF32[i2 + 20 >> 2];
+ if (!(d13 == d13 & 0.0 == 0.0 & d13 > -inf & d13 < inf)) {
+ ___assert_fail(1560, 1520, 28, 1552);
+ }
+ i7 = i2 + 12 | 0;
+ d13 = +HEAPF32[i7 >> 2];
+ if (!(d13 == d13 & 0.0 == 0.0 & d13 > -inf & d13 < inf)) {
+ ___assert_fail(1592, 1520, 29, 1552);
+ }
+ i8 = i2 + 24 | 0;
+ d13 = +HEAPF32[i8 >> 2];
+ if (!(d13 == d13 & 0.0 == 0.0 & d13 > -inf & d13 < inf)) {
+ ___assert_fail(1616, 1520, 30, 1552);
+ }
+ i4 = i2 + 32 | 0;
+ d13 = +HEAPF32[i4 >> 2];
+ if (!(d13 >= 0.0) | d13 == d13 & 0.0 == 0.0 & d13 > -inf & d13 < inf ^ 1) {
+ ___assert_fail(1648, 1520, 31, 1552);
+ }
+ i10 = i2 + 28 | 0;
+ d13 = +HEAPF32[i10 >> 2];
+ if (!(d13 >= 0.0) | d13 == d13 & 0.0 == 0.0 & d13 > -inf & d13 < inf ^ 1) {
+ ___assert_fail(1712, 1520, 32, 1552);
+ }
+ i11 = i1 + 4 | 0;
+ i12 = (HEAP8[i2 + 39 | 0] | 0) == 0 ? 0 : 8;
+ HEAP16[i11 >> 1] = i12;
+ if ((HEAP8[i2 + 38 | 0] | 0) != 0) {
+ i12 = (i12 & 65535 | 16) & 65535;
+ HEAP16[i11 >> 1] = i12;
+ }
+ if ((HEAP8[i2 + 36 | 0] | 0) != 0) {
+ i12 = (i12 & 65535 | 4) & 65535;
+ HEAP16[i11 >> 1] = i12;
+ }
+ if ((HEAP8[i2 + 37 | 0] | 0) != 0) {
+ i12 = (i12 & 65535 | 2) & 65535;
+ HEAP16[i11 >> 1] = i12;
+ }
+ if ((HEAP8[i2 + 40 | 0] | 0) != 0) {
+ HEAP16[i11 >> 1] = i12 & 65535 | 32;
+ }
+ HEAP32[i1 + 88 >> 2] = i5;
+ i11 = i9;
+ i12 = HEAP32[i11 >> 2] | 0;
+ i11 = HEAP32[i11 + 4 >> 2] | 0;
+ i9 = i1 + 12 | 0;
+ HEAP32[i9 >> 2] = i12;
+ HEAP32[i9 + 4 >> 2] = i11;
+ d13 = +HEAPF32[i7 >> 2];
+ HEAPF32[i1 + 20 >> 2] = +Math_sin(+d13);
+ HEAPF32[i1 + 24 >> 2] = +Math_cos(+d13);
+ HEAPF32[i1 + 28 >> 2] = 0.0;
+ HEAPF32[i1 + 32 >> 2] = 0.0;
+ i9 = i1 + 36 | 0;
+ HEAP32[i9 >> 2] = i12;
+ HEAP32[i9 + 4 >> 2] = i11;
+ i9 = i1 + 44 | 0;
+ HEAP32[i9 >> 2] = i12;
+ HEAP32[i9 + 4 >> 2] = i11;
+ HEAPF32[i1 + 52 >> 2] = +HEAPF32[i7 >> 2];
+ HEAPF32[i1 + 56 >> 2] = +HEAPF32[i7 >> 2];
+ HEAPF32[i1 + 60 >> 2] = 0.0;
+ HEAP32[i1 + 108 >> 2] = 0;
+ HEAP32[i1 + 112 >> 2] = 0;
+ HEAP32[i1 + 92 >> 2] = 0;
+ HEAP32[i1 + 96 >> 2] = 0;
+ i9 = i6;
+ i11 = HEAP32[i9 + 4 >> 2] | 0;
+ i12 = i1 + 64 | 0;
+ HEAP32[i12 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i12 + 4 >> 2] = i11;
+ HEAPF32[i1 + 72 >> 2] = +HEAPF32[i8 >> 2];
+ HEAPF32[i1 + 132 >> 2] = +HEAPF32[i10 >> 2];
+ HEAPF32[i1 + 136 >> 2] = +HEAPF32[i4 >> 2];
+ HEAPF32[i1 + 140 >> 2] = +HEAPF32[i2 + 48 >> 2];
+ HEAPF32[i1 + 76 >> 2] = 0.0;
+ HEAPF32[i1 + 80 >> 2] = 0.0;
+ HEAPF32[i1 + 84 >> 2] = 0.0;
+ HEAPF32[i1 + 144 >> 2] = 0.0;
+ i12 = HEAP32[i2 >> 2] | 0;
+ HEAP32[i1 >> 2] = i12;
+ i4 = i1 + 116 | 0;
+ if ((i12 | 0) == 2) {
+ HEAPF32[i4 >> 2] = 1.0;
+ HEAPF32[i1 + 120 >> 2] = 1.0;
+ i11 = i1 + 124 | 0;
+ HEAPF32[i11 >> 2] = 0.0;
+ i11 = i1 + 128 | 0;
+ HEAPF32[i11 >> 2] = 0.0;
+ i11 = i2 + 44 | 0;
+ i11 = HEAP32[i11 >> 2] | 0;
+ i12 = i1 + 148 | 0;
+ HEAP32[i12 >> 2] = i11;
+ i12 = i1 + 100 | 0;
+ HEAP32[i12 >> 2] = 0;
+ i12 = i1 + 104 | 0;
+ HEAP32[i12 >> 2] = 0;
+ STACKTOP = i3;
+ return;
+ } else {
+ HEAPF32[i4 >> 2] = 0.0;
+ HEAPF32[i1 + 120 >> 2] = 0.0;
+ i11 = i1 + 124 | 0;
+ HEAPF32[i11 >> 2] = 0.0;
+ i11 = i1 + 128 | 0;
+ HEAPF32[i11 >> 2] = 0.0;
+ i11 = i2 + 44 | 0;
+ i11 = HEAP32[i11 >> 2] | 0;
+ i12 = i1 + 148 | 0;
+ HEAP32[i12 >> 2] = i11;
+ i12 = i1 + 100 | 0;
+ HEAP32[i12 >> 2] = 0;
+ i12 = i1 + 104 | 0;
+ HEAP32[i12 >> 2] = 0;
+ STACKTOP = i3;
+ return;
+ }
+}
+function __ZN24b2PositionSolverManifold10InitializeEP27b2ContactPositionConstraintRK11b2TransformS4_i(i2, i1, i13, i12, i15) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ i13 = i13 | 0;
+ i12 = i12 | 0;
+ i15 = i15 | 0;
+ var i3 = 0, d4 = 0.0, d5 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 0.0, d9 = 0.0, d10 = 0.0, d11 = 0.0, i14 = 0, d16 = 0.0, d17 = 0.0, d18 = 0.0, i19 = 0, i20 = 0;
+ i3 = STACKTOP;
+ if ((HEAP32[i1 + 84 >> 2] | 0) <= 0) {
+ ___assert_fail(6752, 6520, 617, 6776);
+ }
+ i14 = HEAP32[i1 + 72 >> 2] | 0;
+ if ((i14 | 0) == 1) {
+ i19 = i13 + 12 | 0;
+ d5 = +HEAPF32[i19 >> 2];
+ d6 = +HEAPF32[i1 + 16 >> 2];
+ i14 = i13 + 8 | 0;
+ d7 = +HEAPF32[i14 >> 2];
+ d9 = +HEAPF32[i1 + 20 >> 2];
+ d4 = d5 * d6 - d7 * d9;
+ d9 = d6 * d7 + d5 * d9;
+ d5 = +d4;
+ d7 = +d9;
+ i20 = i2;
+ HEAPF32[i20 >> 2] = d5;
+ HEAPF32[i20 + 4 >> 2] = d7;
+ d7 = +HEAPF32[i19 >> 2];
+ d5 = +HEAPF32[i1 + 24 >> 2];
+ d6 = +HEAPF32[i14 >> 2];
+ d8 = +HEAPF32[i1 + 28 >> 2];
+ d16 = +HEAPF32[i12 + 12 >> 2];
+ d18 = +HEAPF32[i1 + (i15 << 3) >> 2];
+ d17 = +HEAPF32[i12 + 8 >> 2];
+ d11 = +HEAPF32[i1 + (i15 << 3) + 4 >> 2];
+ d10 = +HEAPF32[i12 >> 2] + (d16 * d18 - d17 * d11);
+ d11 = d18 * d17 + d16 * d11 + +HEAPF32[i12 + 4 >> 2];
+ HEAPF32[i2 + 16 >> 2] = d4 * (d10 - (+HEAPF32[i13 >> 2] + (d7 * d5 - d6 * d8))) + (d11 - (d5 * d6 + d7 * d8 + +HEAPF32[i13 + 4 >> 2])) * d9 - +HEAPF32[i1 + 76 >> 2] - +HEAPF32[i1 + 80 >> 2];
+ d10 = +d10;
+ d11 = +d11;
+ i15 = i2 + 8 | 0;
+ HEAPF32[i15 >> 2] = d10;
+ HEAPF32[i15 + 4 >> 2] = d11;
+ STACKTOP = i3;
+ return;
+ } else if ((i14 | 0) == 2) {
+ i19 = i12 + 12 | 0;
+ d7 = +HEAPF32[i19 >> 2];
+ d8 = +HEAPF32[i1 + 16 >> 2];
+ i20 = i12 + 8 | 0;
+ d9 = +HEAPF32[i20 >> 2];
+ d18 = +HEAPF32[i1 + 20 >> 2];
+ d17 = d7 * d8 - d9 * d18;
+ d18 = d8 * d9 + d7 * d18;
+ d7 = +d17;
+ d9 = +d18;
+ i14 = i2;
+ HEAPF32[i14 >> 2] = d7;
+ HEAPF32[i14 + 4 >> 2] = d9;
+ d9 = +HEAPF32[i19 >> 2];
+ d7 = +HEAPF32[i1 + 24 >> 2];
+ d8 = +HEAPF32[i20 >> 2];
+ d10 = +HEAPF32[i1 + 28 >> 2];
+ d6 = +HEAPF32[i13 + 12 >> 2];
+ d4 = +HEAPF32[i1 + (i15 << 3) >> 2];
+ d5 = +HEAPF32[i13 + 8 >> 2];
+ d16 = +HEAPF32[i1 + (i15 << 3) + 4 >> 2];
+ d11 = +HEAPF32[i13 >> 2] + (d6 * d4 - d5 * d16);
+ d16 = d4 * d5 + d6 * d16 + +HEAPF32[i13 + 4 >> 2];
+ HEAPF32[i2 + 16 >> 2] = d17 * (d11 - (+HEAPF32[i12 >> 2] + (d9 * d7 - d8 * d10))) + (d16 - (d7 * d8 + d9 * d10 + +HEAPF32[i12 + 4 >> 2])) * d18 - +HEAPF32[i1 + 76 >> 2] - +HEAPF32[i1 + 80 >> 2];
+ d11 = +d11;
+ d16 = +d16;
+ i20 = i2 + 8 | 0;
+ HEAPF32[i20 >> 2] = d11;
+ HEAPF32[i20 + 4 >> 2] = d16;
+ d17 = +-d17;
+ d18 = +-d18;
+ i20 = i2;
+ HEAPF32[i20 >> 2] = d17;
+ HEAPF32[i20 + 4 >> 2] = d18;
+ STACKTOP = i3;
+ return;
+ } else if ((i14 | 0) == 0) {
+ d7 = +HEAPF32[i13 + 12 >> 2];
+ d8 = +HEAPF32[i1 + 24 >> 2];
+ d18 = +HEAPF32[i13 + 8 >> 2];
+ d6 = +HEAPF32[i1 + 28 >> 2];
+ d4 = +HEAPF32[i13 >> 2] + (d7 * d8 - d18 * d6);
+ d6 = d8 * d18 + d7 * d6 + +HEAPF32[i13 + 4 >> 2];
+ d7 = +HEAPF32[i12 + 12 >> 2];
+ d18 = +HEAPF32[i1 >> 2];
+ d8 = +HEAPF32[i12 + 8 >> 2];
+ d9 = +HEAPF32[i1 + 4 >> 2];
+ d5 = +HEAPF32[i12 >> 2] + (d7 * d18 - d8 * d9);
+ d9 = d18 * d8 + d7 * d9 + +HEAPF32[i12 + 4 >> 2];
+ d7 = d5 - d4;
+ d8 = d9 - d6;
+ d18 = +d7;
+ d10 = +d8;
+ i20 = i2;
+ HEAPF32[i20 >> 2] = d18;
+ HEAPF32[i20 + 4 >> 2] = d10;
+ d10 = +Math_sqrt(+(d7 * d7 + d8 * d8));
+ if (d10 < 1.1920928955078125e-7) {
+ d10 = d7;
+ d11 = d8;
+ } else {
+ d11 = 1.0 / d10;
+ d10 = d7 * d11;
+ HEAPF32[i2 >> 2] = d10;
+ d11 = d8 * d11;
+ HEAPF32[i2 + 4 >> 2] = d11;
+ }
+ d17 = +((d4 + d5) * .5);
+ d18 = +((d6 + d9) * .5);
+ i20 = i2 + 8 | 0;
+ HEAPF32[i20 >> 2] = d17;
+ HEAPF32[i20 + 4 >> 2] = d18;
+ HEAPF32[i2 + 16 >> 2] = d7 * d10 + d8 * d11 - +HEAPF32[i1 + 76 >> 2] - +HEAPF32[i1 + 80 >> 2];
+ STACKTOP = i3;
+ return;
+ } else {
+ STACKTOP = i3;
+ return;
+ }
+}
+function __ZNSt3__118__insertion_sort_3IRPFbRK6b2PairS3_EPS1_EEvT0_S8_T_(i5, i1, i2) {
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i6 = i4 + 12 | 0;
+ i3 = i4;
+ i7 = i5 + 24 | 0;
+ i8 = i5 + 12 | 0;
+ i10 = FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i8, i5) | 0;
+ i9 = FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i7, i8) | 0;
+ do {
+ if (i10) {
+ if (i9) {
+ HEAP32[i6 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ HEAP32[i7 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ break;
+ }
+ HEAP32[i6 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i8 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i8 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i8 + 8 >> 2];
+ HEAP32[i8 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i8 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i8 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ if (FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i7, i8) | 0) {
+ HEAP32[i6 + 0 >> 2] = HEAP32[i8 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i8 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i8 + 8 >> 2];
+ HEAP32[i8 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i8 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i8 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ HEAP32[i7 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ }
+ } else {
+ if (i9) {
+ HEAP32[i6 + 0 >> 2] = HEAP32[i8 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i8 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i8 + 8 >> 2];
+ HEAP32[i8 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i8 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i8 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ HEAP32[i7 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ if (FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i8, i5) | 0) {
+ HEAP32[i6 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ HEAP32[i5 + 0 >> 2] = HEAP32[i8 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i8 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i8 + 8 >> 2];
+ HEAP32[i8 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i8 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i8 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ }
+ }
+ }
+ } while (0);
+ i6 = i5 + 36 | 0;
+ if ((i6 | 0) == (i1 | 0)) {
+ STACKTOP = i4;
+ return;
+ }
+ while (1) {
+ if (FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i6, i7) | 0) {
+ HEAP32[i3 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ i8 = i6;
+ while (1) {
+ HEAP32[i8 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
+ HEAP32[i8 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
+ HEAP32[i8 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ if ((i7 | 0) == (i5 | 0)) {
+ break;
+ }
+ i8 = i7 + -12 | 0;
+ if (FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i3, i8) | 0) {
+ i10 = i7;
+ i7 = i8;
+ i8 = i10;
+ } else {
+ break;
+ }
+ }
+ HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ }
+ i7 = i6 + 12 | 0;
+ if ((i7 | 0) == (i1 | 0)) {
+ break;
+ } else {
+ i10 = i6;
+ i6 = i7;
+ i7 = i10;
+ }
+ }
+ STACKTOP = i4;
+ return;
+}
+function __ZNK20b2SeparationFunction8EvaluateEiif(i10, i12, i11, d9) {
+ i10 = i10 | 0;
+ i12 = i12 | 0;
+ i11 = i11 | 0;
+ d9 = +d9;
+ var d1 = 0.0, d2 = 0.0, d3 = 0.0, d4 = 0.0, d5 = 0.0, d6 = 0.0, i7 = 0, d8 = 0.0, d13 = 0.0, d14 = 0.0, d15 = 0.0, d16 = 0.0, i17 = 0, d18 = 0.0, d19 = 0.0;
+ i7 = STACKTOP;
+ d14 = 1.0 - d9;
+ d3 = d14 * +HEAPF32[i10 + 32 >> 2] + +HEAPF32[i10 + 36 >> 2] * d9;
+ d4 = +Math_sin(+d3);
+ d3 = +Math_cos(+d3);
+ d5 = +HEAPF32[i10 + 8 >> 2];
+ d6 = +HEAPF32[i10 + 12 >> 2];
+ d2 = d14 * +HEAPF32[i10 + 16 >> 2] + +HEAPF32[i10 + 24 >> 2] * d9 - (d3 * d5 - d4 * d6);
+ d6 = d14 * +HEAPF32[i10 + 20 >> 2] + +HEAPF32[i10 + 28 >> 2] * d9 - (d4 * d5 + d3 * d6);
+ d5 = d14 * +HEAPF32[i10 + 68 >> 2] + +HEAPF32[i10 + 72 >> 2] * d9;
+ d1 = +Math_sin(+d5);
+ d5 = +Math_cos(+d5);
+ d15 = +HEAPF32[i10 + 44 >> 2];
+ d16 = +HEAPF32[i10 + 48 >> 2];
+ d8 = d14 * +HEAPF32[i10 + 52 >> 2] + +HEAPF32[i10 + 60 >> 2] * d9 - (d5 * d15 - d1 * d16);
+ d9 = d14 * +HEAPF32[i10 + 56 >> 2] + +HEAPF32[i10 + 64 >> 2] * d9 - (d1 * d15 + d5 * d16);
+ i17 = HEAP32[i10 + 80 >> 2] | 0;
+ if ((i17 | 0) == 0) {
+ d14 = +HEAPF32[i10 + 92 >> 2];
+ d13 = +HEAPF32[i10 + 96 >> 2];
+ i17 = HEAP32[i10 >> 2] | 0;
+ if (!((i12 | 0) > -1)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ if ((HEAP32[i17 + 20 >> 2] | 0) <= (i12 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i17 = (HEAP32[i17 + 16 >> 2] | 0) + (i12 << 3) | 0;
+ d15 = +HEAPF32[i17 >> 2];
+ d16 = +HEAPF32[i17 + 4 >> 2];
+ i10 = HEAP32[i10 + 4 >> 2] | 0;
+ if (!((i11 | 0) > -1)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ if ((HEAP32[i10 + 20 >> 2] | 0) <= (i11 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i17 = (HEAP32[i10 + 16 >> 2] | 0) + (i11 << 3) | 0;
+ d19 = +HEAPF32[i17 >> 2];
+ d18 = +HEAPF32[i17 + 4 >> 2];
+ d16 = d14 * (d8 + (d5 * d19 - d1 * d18) - (d2 + (d3 * d15 - d4 * d16))) + d13 * (d9 + (d1 * d19 + d5 * d18) - (d6 + (d4 * d15 + d3 * d16)));
+ STACKTOP = i7;
+ return +d16;
+ } else if ((i17 | 0) == 1) {
+ d14 = +HEAPF32[i10 + 92 >> 2];
+ d13 = +HEAPF32[i10 + 96 >> 2];
+ d16 = +HEAPF32[i10 + 84 >> 2];
+ d15 = +HEAPF32[i10 + 88 >> 2];
+ i10 = HEAP32[i10 + 4 >> 2] | 0;
+ if (!((i11 | 0) > -1)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ if ((HEAP32[i10 + 20 >> 2] | 0) <= (i11 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i17 = (HEAP32[i10 + 16 >> 2] | 0) + (i11 << 3) | 0;
+ d18 = +HEAPF32[i17 >> 2];
+ d19 = +HEAPF32[i17 + 4 >> 2];
+ d19 = (d3 * d14 - d4 * d13) * (d8 + (d5 * d18 - d1 * d19) - (d2 + (d3 * d16 - d4 * d15))) + (d4 * d14 + d3 * d13) * (d9 + (d1 * d18 + d5 * d19) - (d6 + (d4 * d16 + d3 * d15)));
+ STACKTOP = i7;
+ return +d19;
+ } else if ((i17 | 0) == 2) {
+ d16 = +HEAPF32[i10 + 92 >> 2];
+ d15 = +HEAPF32[i10 + 96 >> 2];
+ d14 = +HEAPF32[i10 + 84 >> 2];
+ d13 = +HEAPF32[i10 + 88 >> 2];
+ i10 = HEAP32[i10 >> 2] | 0;
+ if (!((i12 | 0) > -1)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ if ((HEAP32[i10 + 20 >> 2] | 0) <= (i12 | 0)) {
+ ___assert_fail(3640, 3672, 103, 3704);
+ }
+ i17 = (HEAP32[i10 + 16 >> 2] | 0) + (i12 << 3) | 0;
+ d18 = +HEAPF32[i17 >> 2];
+ d19 = +HEAPF32[i17 + 4 >> 2];
+ d19 = (d5 * d16 - d1 * d15) * (d2 + (d3 * d18 - d4 * d19) - (d8 + (d5 * d14 - d1 * d13))) + (d1 * d16 + d5 * d15) * (d6 + (d4 * d18 + d3 * d19) - (d9 + (d1 * d14 + d5 * d13)));
+ STACKTOP = i7;
+ return +d19;
+ } else {
+ ___assert_fail(3616, 3560, 242, 3624);
+ }
+ return 0.0;
+}
+function __ZN6b2Body13ResetMassDataEv(i2) {
+ i2 = i2 | 0;
+ var d1 = 0.0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, d14 = 0.0, d15 = 0.0, d16 = 0.0, i17 = 0, d18 = 0.0, d19 = 0.0, i20 = 0, d21 = 0.0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i10 = i3;
+ i8 = i2 + 116 | 0;
+ i9 = i2 + 120 | 0;
+ i4 = i2 + 124 | 0;
+ i5 = i2 + 128 | 0;
+ i6 = i2 + 28 | 0;
+ HEAPF32[i6 >> 2] = 0.0;
+ HEAPF32[i2 + 32 >> 2] = 0.0;
+ HEAP32[i8 + 0 >> 2] = 0;
+ HEAP32[i8 + 4 >> 2] = 0;
+ HEAP32[i8 + 8 >> 2] = 0;
+ HEAP32[i8 + 12 >> 2] = 0;
+ i11 = HEAP32[i2 >> 2] | 0;
+ if ((i11 | 0) == 2) {
+ i17 = 3784;
+ d16 = +HEAPF32[i17 >> 2];
+ d18 = +HEAPF32[i17 + 4 >> 2];
+ i17 = HEAP32[i2 + 100 >> 2] | 0;
+ if ((i17 | 0) != 0) {
+ i11 = i10 + 4 | 0;
+ i12 = i10 + 8 | 0;
+ i13 = i10 + 12 | 0;
+ d14 = 0.0;
+ d15 = 0.0;
+ do {
+ d19 = +HEAPF32[i17 >> 2];
+ if (!(d19 == 0.0)) {
+ i20 = HEAP32[i17 + 12 >> 2] | 0;
+ FUNCTION_TABLE_viid[HEAP32[(HEAP32[i20 >> 2] | 0) + 28 >> 2] & 3](i20, i10, d19);
+ d14 = +HEAPF32[i10 >> 2];
+ d15 = d14 + +HEAPF32[i8 >> 2];
+ HEAPF32[i8 >> 2] = d15;
+ d16 = d16 + d14 * +HEAPF32[i11 >> 2];
+ d18 = d18 + d14 * +HEAPF32[i12 >> 2];
+ d14 = +HEAPF32[i13 >> 2] + +HEAPF32[i4 >> 2];
+ HEAPF32[i4 >> 2] = d14;
+ }
+ i17 = HEAP32[i17 + 4 >> 2] | 0;
+ } while ((i17 | 0) != 0);
+ if (d15 > 0.0) {
+ d19 = 1.0 / d15;
+ HEAPF32[i9 >> 2] = d19;
+ d16 = d16 * d19;
+ d18 = d18 * d19;
+ } else {
+ i7 = 11;
+ }
+ } else {
+ d14 = 0.0;
+ i7 = 11;
+ }
+ if ((i7 | 0) == 11) {
+ HEAPF32[i8 >> 2] = 1.0;
+ HEAPF32[i9 >> 2] = 1.0;
+ d15 = 1.0;
+ }
+ do {
+ if (d14 > 0.0 ? (HEAP16[i2 + 4 >> 1] & 16) == 0 : 0) {
+ d14 = d14 - (d18 * d18 + d16 * d16) * d15;
+ HEAPF32[i4 >> 2] = d14;
+ if (d14 > 0.0) {
+ d1 = 1.0 / d14;
+ break;
+ } else {
+ ___assert_fail(1872, 1520, 319, 1856);
+ }
+ } else {
+ i7 = 17;
+ }
+ } while (0);
+ if ((i7 | 0) == 17) {
+ HEAPF32[i4 >> 2] = 0.0;
+ d1 = 0.0;
+ }
+ HEAPF32[i5 >> 2] = d1;
+ i20 = i2 + 44 | 0;
+ i17 = i20;
+ d19 = +HEAPF32[i17 >> 2];
+ d14 = +HEAPF32[i17 + 4 >> 2];
+ d21 = +d16;
+ d1 = +d18;
+ i17 = i6;
+ HEAPF32[i17 >> 2] = d21;
+ HEAPF32[i17 + 4 >> 2] = d1;
+ d1 = +HEAPF32[i2 + 24 >> 2];
+ d21 = +HEAPF32[i2 + 20 >> 2];
+ d15 = +HEAPF32[i2 + 12 >> 2] + (d1 * d16 - d21 * d18);
+ d16 = d16 * d21 + d1 * d18 + +HEAPF32[i2 + 16 >> 2];
+ d1 = +d15;
+ d18 = +d16;
+ HEAPF32[i20 >> 2] = d1;
+ HEAPF32[i20 + 4 >> 2] = d18;
+ i20 = i2 + 36 | 0;
+ HEAPF32[i20 >> 2] = d1;
+ HEAPF32[i20 + 4 >> 2] = d18;
+ d18 = +HEAPF32[i2 + 72 >> 2];
+ i20 = i2 + 64 | 0;
+ HEAPF32[i20 >> 2] = +HEAPF32[i20 >> 2] - d18 * (d16 - d14);
+ i20 = i2 + 68 | 0;
+ HEAPF32[i20 >> 2] = d18 * (d15 - d19) + +HEAPF32[i20 >> 2];
+ STACKTOP = i3;
+ return;
+ } else if ((i11 | 0) == 1 | (i11 | 0) == 0) {
+ i17 = i2 + 12 | 0;
+ i13 = HEAP32[i17 >> 2] | 0;
+ i17 = HEAP32[i17 + 4 >> 2] | 0;
+ i20 = i2 + 36 | 0;
+ HEAP32[i20 >> 2] = i13;
+ HEAP32[i20 + 4 >> 2] = i17;
+ i20 = i2 + 44 | 0;
+ HEAP32[i20 >> 2] = i13;
+ HEAP32[i20 + 4 >> 2] = i17;
+ HEAPF32[i2 + 52 >> 2] = +HEAPF32[i2 + 56 >> 2];
+ STACKTOP = i3;
+ return;
+ } else {
+ ___assert_fail(1824, 1520, 284, 1856);
+ }
+}
+function __ZN9b2Contact6UpdateEP17b2ContactListener(i1, i4) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i2 = i3;
+ i10 = i1 + 64 | 0;
+ i6 = i2 + 0 | 0;
+ i7 = i10 + 0 | 0;
+ i5 = i6 + 64 | 0;
+ do {
+ HEAP32[i6 >> 2] = HEAP32[i7 >> 2];
+ i6 = i6 + 4 | 0;
+ i7 = i7 + 4 | 0;
+ } while ((i6 | 0) < (i5 | 0));
+ i6 = i1 + 4 | 0;
+ i11 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i11 | 4;
+ i11 = i11 >>> 1;
+ i14 = HEAP32[i1 + 48 >> 2] | 0;
+ i15 = HEAP32[i1 + 52 >> 2] | 0;
+ i5 = (HEAP8[i15 + 38 | 0] | HEAP8[i14 + 38 | 0]) << 24 >> 24 != 0;
+ i8 = HEAP32[i14 + 8 >> 2] | 0;
+ i7 = HEAP32[i15 + 8 >> 2] | 0;
+ i12 = i8 + 12 | 0;
+ i13 = i7 + 12 | 0;
+ if (!i5) {
+ FUNCTION_TABLE_viiii[HEAP32[HEAP32[i1 >> 2] >> 2] & 15](i1, i10, i12, i13);
+ i12 = i1 + 124 | 0;
+ i10 = (HEAP32[i12 >> 2] | 0) > 0;
+ L4 : do {
+ if (i10) {
+ i19 = HEAP32[i2 + 60 >> 2] | 0;
+ if ((i19 | 0) > 0) {
+ i18 = 0;
+ } else {
+ i9 = 0;
+ while (1) {
+ HEAPF32[i1 + (i9 * 20 | 0) + 72 >> 2] = 0.0;
+ HEAPF32[i1 + (i9 * 20 | 0) + 76 >> 2] = 0.0;
+ i9 = i9 + 1 | 0;
+ if ((i9 | 0) >= (HEAP32[i12 >> 2] | 0)) {
+ break L4;
+ }
+ }
+ }
+ do {
+ i16 = i1 + (i18 * 20 | 0) + 72 | 0;
+ HEAPF32[i16 >> 2] = 0.0;
+ i15 = i1 + (i18 * 20 | 0) + 76 | 0;
+ HEAPF32[i15 >> 2] = 0.0;
+ i14 = HEAP32[i1 + (i18 * 20 | 0) + 80 >> 2] | 0;
+ i17 = 0;
+ while (1) {
+ i13 = i17 + 1 | 0;
+ if ((HEAP32[i2 + (i17 * 20 | 0) + 16 >> 2] | 0) == (i14 | 0)) {
+ i9 = 7;
+ break;
+ }
+ if ((i13 | 0) < (i19 | 0)) {
+ i17 = i13;
+ } else {
+ break;
+ }
+ }
+ if ((i9 | 0) == 7) {
+ i9 = 0;
+ HEAPF32[i16 >> 2] = +HEAPF32[i2 + (i17 * 20 | 0) + 8 >> 2];
+ HEAPF32[i15 >> 2] = +HEAPF32[i2 + (i17 * 20 | 0) + 12 >> 2];
+ }
+ i18 = i18 + 1 | 0;
+ } while ((i18 | 0) < (HEAP32[i12 >> 2] | 0));
+ }
+ } while (0);
+ i9 = i11 & 1;
+ if (i10 ^ (i9 | 0) != 0) {
+ i11 = i8 + 4 | 0;
+ i12 = HEAPU16[i11 >> 1] | 0;
+ if ((i12 & 2 | 0) == 0) {
+ HEAP16[i11 >> 1] = i12 | 2;
+ HEAPF32[i8 + 144 >> 2] = 0.0;
+ }
+ i8 = i7 + 4 | 0;
+ i11 = HEAPU16[i8 >> 1] | 0;
+ if ((i11 & 2 | 0) == 0) {
+ HEAP16[i8 >> 1] = i11 | 2;
+ HEAPF32[i7 + 144 >> 2] = 0.0;
+ }
+ }
+ } else {
+ i10 = __Z13b2TestOverlapPK7b2ShapeiS1_iRK11b2TransformS4_(HEAP32[i14 + 12 >> 2] | 0, HEAP32[i1 + 56 >> 2] | 0, HEAP32[i15 + 12 >> 2] | 0, HEAP32[i1 + 60 >> 2] | 0, i12, i13) | 0;
+ HEAP32[i1 + 124 >> 2] = 0;
+ i9 = i11 & 1;
+ }
+ i7 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i10 ? i7 | 2 : i7 & -3;
+ i8 = (i9 | 0) == 0;
+ i6 = i10 ^ 1;
+ i7 = (i4 | 0) == 0;
+ if (!(i8 ^ 1 | i6 | i7)) {
+ FUNCTION_TABLE_vii[HEAP32[(HEAP32[i4 >> 2] | 0) + 8 >> 2] & 15](i4, i1);
+ }
+ if (!(i8 | i10 | i7)) {
+ FUNCTION_TABLE_vii[HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] & 15](i4, i1);
+ }
+ if (i5 | i6 | i7) {
+ STACKTOP = i3;
+ return;
+ }
+ FUNCTION_TABLE_viii[HEAP32[(HEAP32[i4 >> 2] | 0) + 16 >> 2] & 3](i4, i1, i2);
+ STACKTOP = i3;
+ return;
+}
+function __ZN13b2DynamicTree10RemoveLeafEi(i1, i12) {
+ i1 = i1 | 0;
+ i12 = i12 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, d8 = 0.0, d9 = 0.0, d10 = 0.0, d11 = 0.0, i13 = 0;
+ i2 = STACKTOP;
+ if ((HEAP32[i1 >> 2] | 0) == (i12 | 0)) {
+ HEAP32[i1 >> 2] = -1;
+ STACKTOP = i2;
+ return;
+ }
+ i3 = i1 + 4 | 0;
+ i5 = HEAP32[i3 >> 2] | 0;
+ i6 = HEAP32[i5 + (i12 * 36 | 0) + 20 >> 2] | 0;
+ i4 = i5 + (i6 * 36 | 0) + 20 | 0;
+ i7 = HEAP32[i4 >> 2] | 0;
+ i13 = HEAP32[i5 + (i6 * 36 | 0) + 24 >> 2] | 0;
+ if ((i13 | 0) == (i12 | 0)) {
+ i13 = HEAP32[i5 + (i6 * 36 | 0) + 28 >> 2] | 0;
+ }
+ if ((i7 | 0) == -1) {
+ HEAP32[i1 >> 2] = i13;
+ HEAP32[i5 + (i13 * 36 | 0) + 20 >> 2] = -1;
+ if (!((i6 | 0) > -1)) {
+ ___assert_fail(3e3, 2944, 97, 3040);
+ }
+ if ((HEAP32[i1 + 12 >> 2] | 0) <= (i6 | 0)) {
+ ___assert_fail(3e3, 2944, 97, 3040);
+ }
+ i3 = i1 + 8 | 0;
+ if ((HEAP32[i3 >> 2] | 0) <= 0) {
+ ___assert_fail(3056, 2944, 98, 3040);
+ }
+ i13 = i1 + 16 | 0;
+ HEAP32[i4 >> 2] = HEAP32[i13 >> 2];
+ HEAP32[i5 + (i6 * 36 | 0) + 32 >> 2] = -1;
+ HEAP32[i13 >> 2] = i6;
+ HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + -1;
+ STACKTOP = i2;
+ return;
+ }
+ i12 = i5 + (i7 * 36 | 0) + 24 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i12 >> 2] = i13;
+ } else {
+ HEAP32[i5 + (i7 * 36 | 0) + 28 >> 2] = i13;
+ }
+ HEAP32[i5 + (i13 * 36 | 0) + 20 >> 2] = i7;
+ if (!((i6 | 0) > -1)) {
+ ___assert_fail(3e3, 2944, 97, 3040);
+ }
+ if ((HEAP32[i1 + 12 >> 2] | 0) <= (i6 | 0)) {
+ ___assert_fail(3e3, 2944, 97, 3040);
+ }
+ i12 = i1 + 8 | 0;
+ if ((HEAP32[i12 >> 2] | 0) <= 0) {
+ ___assert_fail(3056, 2944, 98, 3040);
+ }
+ i13 = i1 + 16 | 0;
+ HEAP32[i4 >> 2] = HEAP32[i13 >> 2];
+ HEAP32[i5 + (i6 * 36 | 0) + 32 >> 2] = -1;
+ HEAP32[i13 >> 2] = i6;
+ HEAP32[i12 >> 2] = (HEAP32[i12 >> 2] | 0) + -1;
+ do {
+ i4 = __ZN13b2DynamicTree7BalanceEi(i1, i7) | 0;
+ i7 = HEAP32[i3 >> 2] | 0;
+ i6 = HEAP32[i7 + (i4 * 36 | 0) + 24 >> 2] | 0;
+ i5 = HEAP32[i7 + (i4 * 36 | 0) + 28 >> 2] | 0;
+ d10 = +HEAPF32[i7 + (i6 * 36 | 0) >> 2];
+ d11 = +HEAPF32[i7 + (i5 * 36 | 0) >> 2];
+ d9 = +HEAPF32[i7 + (i6 * 36 | 0) + 4 >> 2];
+ d8 = +HEAPF32[i7 + (i5 * 36 | 0) + 4 >> 2];
+ d10 = +(d10 < d11 ? d10 : d11);
+ d11 = +(d9 < d8 ? d9 : d8);
+ i13 = i7 + (i4 * 36 | 0) | 0;
+ HEAPF32[i13 >> 2] = d10;
+ HEAPF32[i13 + 4 >> 2] = d11;
+ d11 = +HEAPF32[i7 + (i6 * 36 | 0) + 8 >> 2];
+ d10 = +HEAPF32[i7 + (i5 * 36 | 0) + 8 >> 2];
+ d9 = +HEAPF32[i7 + (i6 * 36 | 0) + 12 >> 2];
+ d8 = +HEAPF32[i7 + (i5 * 36 | 0) + 12 >> 2];
+ d10 = +(d11 > d10 ? d11 : d10);
+ d11 = +(d9 > d8 ? d9 : d8);
+ i7 = i7 + (i4 * 36 | 0) + 8 | 0;
+ HEAPF32[i7 >> 2] = d10;
+ HEAPF32[i7 + 4 >> 2] = d11;
+ i7 = HEAP32[i3 >> 2] | 0;
+ i6 = HEAP32[i7 + (i6 * 36 | 0) + 32 >> 2] | 0;
+ i5 = HEAP32[i7 + (i5 * 36 | 0) + 32 >> 2] | 0;
+ HEAP32[i7 + (i4 * 36 | 0) + 32 >> 2] = ((i6 | 0) > (i5 | 0) ? i6 : i5) + 1;
+ i7 = HEAP32[i7 + (i4 * 36 | 0) + 20 >> 2] | 0;
+ } while (!((i7 | 0) == -1));
+ STACKTOP = i2;
+ return;
+}
+function __ZN9b2Simplex6Solve3Ev(i7) {
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, d4 = 0.0, d5 = 0.0, d6 = 0.0, d8 = 0.0, d9 = 0.0, d10 = 0.0, d11 = 0.0, d12 = 0.0, d13 = 0.0, d14 = 0.0, d15 = 0.0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, d21 = 0.0, i22 = 0;
+ i1 = STACKTOP;
+ i2 = i7 + 16 | 0;
+ d17 = +HEAPF32[i2 >> 2];
+ d15 = +HEAPF32[i2 + 4 >> 2];
+ i2 = i7 + 36 | 0;
+ i3 = i7 + 52 | 0;
+ d14 = +HEAPF32[i3 >> 2];
+ d16 = +HEAPF32[i3 + 4 >> 2];
+ i3 = i7 + 72 | 0;
+ i22 = i7 + 88 | 0;
+ d18 = +HEAPF32[i22 >> 2];
+ d11 = +HEAPF32[i22 + 4 >> 2];
+ d20 = d14 - d17;
+ d10 = d16 - d15;
+ d9 = d17 * d20 + d15 * d10;
+ d8 = d14 * d20 + d16 * d10;
+ d4 = d18 - d17;
+ d19 = d11 - d15;
+ d6 = d17 * d4 + d15 * d19;
+ d5 = d18 * d4 + d11 * d19;
+ d21 = d18 - d14;
+ d12 = d11 - d16;
+ d13 = d14 * d21 + d16 * d12;
+ d12 = d18 * d21 + d11 * d12;
+ d4 = d20 * d19 - d10 * d4;
+ d10 = (d14 * d11 - d16 * d18) * d4;
+ d11 = (d15 * d18 - d17 * d11) * d4;
+ d4 = (d17 * d16 - d15 * d14) * d4;
+ if (!(!(d9 >= -0.0) | !(d6 >= -0.0))) {
+ HEAPF32[i7 + 24 >> 2] = 1.0;
+ HEAP32[i7 + 108 >> 2] = 1;
+ STACKTOP = i1;
+ return;
+ }
+ if (!(!(d9 < -0.0) | !(d8 > 0.0) | !(d4 <= 0.0))) {
+ d21 = 1.0 / (d8 - d9);
+ HEAPF32[i7 + 24 >> 2] = d8 * d21;
+ HEAPF32[i7 + 60 >> 2] = -(d9 * d21);
+ HEAP32[i7 + 108 >> 2] = 2;
+ STACKTOP = i1;
+ return;
+ }
+ if (!(!(d6 < -0.0) | !(d5 > 0.0) | !(d11 <= 0.0))) {
+ d21 = 1.0 / (d5 - d6);
+ HEAPF32[i7 + 24 >> 2] = d5 * d21;
+ HEAPF32[i7 + 96 >> 2] = -(d6 * d21);
+ HEAP32[i7 + 108 >> 2] = 2;
+ i7 = i2 + 0 | 0;
+ i3 = i3 + 0 | 0;
+ i2 = i7 + 36 | 0;
+ do {
+ HEAP32[i7 >> 2] = HEAP32[i3 >> 2];
+ i7 = i7 + 4 | 0;
+ i3 = i3 + 4 | 0;
+ } while ((i7 | 0) < (i2 | 0));
+ STACKTOP = i1;
+ return;
+ }
+ if (!(!(d8 <= 0.0) | !(d13 >= -0.0))) {
+ HEAPF32[i7 + 60 >> 2] = 1.0;
+ HEAP32[i7 + 108 >> 2] = 1;
+ i7 = i7 + 0 | 0;
+ i3 = i2 + 0 | 0;
+ i2 = i7 + 36 | 0;
+ do {
+ HEAP32[i7 >> 2] = HEAP32[i3 >> 2];
+ i7 = i7 + 4 | 0;
+ i3 = i3 + 4 | 0;
+ } while ((i7 | 0) < (i2 | 0));
+ STACKTOP = i1;
+ return;
+ }
+ if (!(!(d5 <= 0.0) | !(d12 <= 0.0))) {
+ HEAPF32[i7 + 96 >> 2] = 1.0;
+ HEAP32[i7 + 108 >> 2] = 1;
+ i7 = i7 + 0 | 0;
+ i3 = i3 + 0 | 0;
+ i2 = i7 + 36 | 0;
+ do {
+ HEAP32[i7 >> 2] = HEAP32[i3 >> 2];
+ i7 = i7 + 4 | 0;
+ i3 = i3 + 4 | 0;
+ } while ((i7 | 0) < (i2 | 0));
+ STACKTOP = i1;
+ return;
+ }
+ if (!(d13 < -0.0) | !(d12 > 0.0) | !(d10 <= 0.0)) {
+ d21 = 1.0 / (d4 + (d10 + d11));
+ HEAPF32[i7 + 24 >> 2] = d10 * d21;
+ HEAPF32[i7 + 60 >> 2] = d11 * d21;
+ HEAPF32[i7 + 96 >> 2] = d4 * d21;
+ HEAP32[i7 + 108 >> 2] = 3;
+ STACKTOP = i1;
+ return;
+ } else {
+ d21 = 1.0 / (d12 - d13);
+ HEAPF32[i7 + 60 >> 2] = d12 * d21;
+ HEAPF32[i7 + 96 >> 2] = -(d13 * d21);
+ HEAP32[i7 + 108 >> 2] = 2;
+ i7 = i7 + 0 | 0;
+ i3 = i3 + 0 | 0;
+ i2 = i7 + 36 | 0;
+ do {
+ HEAP32[i7 >> 2] = HEAP32[i3 >> 2];
+ i7 = i7 + 4 | 0;
+ i3 = i3 + 4 | 0;
+ } while ((i7 | 0) < (i2 | 0));
+ STACKTOP = i1;
+ return;
+ }
+}
+function __ZN16b2ContactManager7CollideEv(i3) {
+ i3 = i3 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0;
+ i2 = STACKTOP;
+ i8 = HEAP32[i3 + 60 >> 2] | 0;
+ if ((i8 | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i7 = i3 + 12 | 0;
+ i6 = i3 + 4 | 0;
+ i5 = i3 + 72 | 0;
+ i4 = i3 + 68 | 0;
+ L4 : while (1) {
+ i12 = HEAP32[i8 + 48 >> 2] | 0;
+ i10 = HEAP32[i8 + 52 >> 2] | 0;
+ i11 = HEAP32[i8 + 56 >> 2] | 0;
+ i9 = HEAP32[i8 + 60 >> 2] | 0;
+ i15 = HEAP32[i12 + 8 >> 2] | 0;
+ i13 = HEAP32[i10 + 8 >> 2] | 0;
+ i16 = i8 + 4 | 0;
+ do {
+ if ((HEAP32[i16 >> 2] & 8 | 0) == 0) {
+ i1 = 11;
+ } else {
+ if (!(__ZNK6b2Body13ShouldCollideEPKS_(i13, i15) | 0)) {
+ i16 = HEAP32[i8 + 12 >> 2] | 0;
+ __ZN16b2ContactManager7DestroyEP9b2Contact(i3, i8);
+ i8 = i16;
+ break;
+ }
+ i14 = HEAP32[i4 >> 2] | 0;
+ if ((i14 | 0) != 0 ? !(FUNCTION_TABLE_iiii[HEAP32[(HEAP32[i14 >> 2] | 0) + 8 >> 2] & 7](i14, i12, i10) | 0) : 0) {
+ i16 = HEAP32[i8 + 12 >> 2] | 0;
+ __ZN16b2ContactManager7DestroyEP9b2Contact(i3, i8);
+ i8 = i16;
+ break;
+ }
+ HEAP32[i16 >> 2] = HEAP32[i16 >> 2] & -9;
+ i1 = 11;
+ }
+ } while (0);
+ do {
+ if ((i1 | 0) == 11) {
+ i1 = 0;
+ if ((HEAP16[i15 + 4 >> 1] & 2) == 0) {
+ i14 = 0;
+ } else {
+ i14 = (HEAP32[i15 >> 2] | 0) != 0;
+ }
+ if ((HEAP16[i13 + 4 >> 1] & 2) == 0) {
+ i13 = 0;
+ } else {
+ i13 = (HEAP32[i13 >> 2] | 0) != 0;
+ }
+ if (!(i14 | i13)) {
+ i8 = HEAP32[i8 + 12 >> 2] | 0;
+ break;
+ }
+ i11 = HEAP32[(HEAP32[i12 + 24 >> 2] | 0) + (i11 * 28 | 0) + 24 >> 2] | 0;
+ i9 = HEAP32[(HEAP32[i10 + 24 >> 2] | 0) + (i9 * 28 | 0) + 24 >> 2] | 0;
+ if (!((i11 | 0) > -1)) {
+ i1 = 19;
+ break L4;
+ }
+ i10 = HEAP32[i7 >> 2] | 0;
+ if ((i10 | 0) <= (i11 | 0)) {
+ i1 = 19;
+ break L4;
+ }
+ i12 = HEAP32[i6 >> 2] | 0;
+ if (!((i9 | 0) > -1 & (i10 | 0) > (i9 | 0))) {
+ i1 = 21;
+ break L4;
+ }
+ if (+HEAPF32[i12 + (i9 * 36 | 0) >> 2] - +HEAPF32[i12 + (i11 * 36 | 0) + 8 >> 2] > 0.0 | +HEAPF32[i12 + (i9 * 36 | 0) + 4 >> 2] - +HEAPF32[i12 + (i11 * 36 | 0) + 12 >> 2] > 0.0 | +HEAPF32[i12 + (i11 * 36 | 0) >> 2] - +HEAPF32[i12 + (i9 * 36 | 0) + 8 >> 2] > 0.0 | +HEAPF32[i12 + (i11 * 36 | 0) + 4 >> 2] - +HEAPF32[i12 + (i9 * 36 | 0) + 12 >> 2] > 0.0) {
+ i16 = HEAP32[i8 + 12 >> 2] | 0;
+ __ZN16b2ContactManager7DestroyEP9b2Contact(i3, i8);
+ i8 = i16;
+ break;
+ } else {
+ __ZN9b2Contact6UpdateEP17b2ContactListener(i8, HEAP32[i5 >> 2] | 0);
+ i8 = HEAP32[i8 + 12 >> 2] | 0;
+ break;
+ }
+ }
+ } while (0);
+ if ((i8 | 0) == 0) {
+ i1 = 25;
+ break;
+ }
+ }
+ if ((i1 | 0) == 19) {
+ ___assert_fail(1904, 1952, 159, 2008);
+ } else if ((i1 | 0) == 21) {
+ ___assert_fail(1904, 1952, 159, 2008);
+ } else if ((i1 | 0) == 25) {
+ STACKTOP = i2;
+ return;
+ }
+}
+function __ZN16b2ContactManager7AddPairEPvS0_(i1, i5, i6) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i5 + 16 >> 2] | 0;
+ i3 = HEAP32[i6 + 16 >> 2] | 0;
+ i5 = HEAP32[i5 + 20 >> 2] | 0;
+ i6 = HEAP32[i6 + 20 >> 2] | 0;
+ i8 = HEAP32[i4 + 8 >> 2] | 0;
+ i7 = HEAP32[i3 + 8 >> 2] | 0;
+ if ((i8 | 0) == (i7 | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ i10 = HEAP32[i7 + 112 >> 2] | 0;
+ L4 : do {
+ if ((i10 | 0) != 0) {
+ while (1) {
+ if ((HEAP32[i10 >> 2] | 0) == (i8 | 0)) {
+ i9 = HEAP32[i10 + 4 >> 2] | 0;
+ i12 = HEAP32[i9 + 48 >> 2] | 0;
+ i13 = HEAP32[i9 + 52 >> 2] | 0;
+ i11 = HEAP32[i9 + 56 >> 2] | 0;
+ i9 = HEAP32[i9 + 60 >> 2] | 0;
+ if ((i12 | 0) == (i4 | 0) & (i13 | 0) == (i3 | 0) & (i11 | 0) == (i5 | 0) & (i9 | 0) == (i6 | 0)) {
+ i9 = 22;
+ break;
+ }
+ if ((i12 | 0) == (i3 | 0) & (i13 | 0) == (i4 | 0) & (i11 | 0) == (i6 | 0) & (i9 | 0) == (i5 | 0)) {
+ i9 = 22;
+ break;
+ }
+ }
+ i10 = HEAP32[i10 + 12 >> 2] | 0;
+ if ((i10 | 0) == 0) {
+ break L4;
+ }
+ }
+ if ((i9 | 0) == 22) {
+ STACKTOP = i2;
+ return;
+ }
+ }
+ } while (0);
+ if (!(__ZNK6b2Body13ShouldCollideEPKS_(i7, i8) | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ i7 = HEAP32[i1 + 68 >> 2] | 0;
+ if ((i7 | 0) != 0 ? !(FUNCTION_TABLE_iiii[HEAP32[(HEAP32[i7 >> 2] | 0) + 8 >> 2] & 7](i7, i4, i3) | 0) : 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i5 = __ZN9b2Contact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator(i4, i5, i3, i6, HEAP32[i1 + 76 >> 2] | 0) | 0;
+ if ((i5 | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i4 = HEAP32[(HEAP32[i5 + 48 >> 2] | 0) + 8 >> 2] | 0;
+ i3 = HEAP32[(HEAP32[i5 + 52 >> 2] | 0) + 8 >> 2] | 0;
+ HEAP32[i5 + 8 >> 2] = 0;
+ i7 = i1 + 60 | 0;
+ HEAP32[i5 + 12 >> 2] = HEAP32[i7 >> 2];
+ i6 = HEAP32[i7 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ HEAP32[i6 + 8 >> 2] = i5;
+ }
+ HEAP32[i7 >> 2] = i5;
+ i8 = i5 + 16 | 0;
+ HEAP32[i5 + 20 >> 2] = i5;
+ HEAP32[i8 >> 2] = i3;
+ HEAP32[i5 + 24 >> 2] = 0;
+ i6 = i4 + 112 | 0;
+ HEAP32[i5 + 28 >> 2] = HEAP32[i6 >> 2];
+ i7 = HEAP32[i6 >> 2] | 0;
+ if ((i7 | 0) != 0) {
+ HEAP32[i7 + 8 >> 2] = i8;
+ }
+ HEAP32[i6 >> 2] = i8;
+ i6 = i5 + 32 | 0;
+ HEAP32[i5 + 36 >> 2] = i5;
+ HEAP32[i6 >> 2] = i4;
+ HEAP32[i5 + 40 >> 2] = 0;
+ i7 = i3 + 112 | 0;
+ HEAP32[i5 + 44 >> 2] = HEAP32[i7 >> 2];
+ i5 = HEAP32[i7 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ HEAP32[i5 + 8 >> 2] = i6;
+ }
+ HEAP32[i7 >> 2] = i6;
+ i5 = i4 + 4 | 0;
+ i6 = HEAPU16[i5 >> 1] | 0;
+ if ((i6 & 2 | 0) == 0) {
+ HEAP16[i5 >> 1] = i6 | 2;
+ HEAPF32[i4 + 144 >> 2] = 0.0;
+ }
+ i4 = i3 + 4 | 0;
+ i5 = HEAPU16[i4 >> 1] | 0;
+ if ((i5 & 2 | 0) == 0) {
+ HEAP16[i4 >> 1] = i5 | 2;
+ HEAPF32[i3 + 144 >> 2] = 0.0;
+ }
+ i13 = i1 + 64 | 0;
+ HEAP32[i13 >> 2] = (HEAP32[i13 >> 2] | 0) + 1;
+ STACKTOP = i2;
+ return;
+}
+function __ZN12b2BroadPhase11UpdatePairsI16b2ContactManagerEEvPT_(i5, i2) {
+ i5 = i5 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i6 = i3;
+ i1 = i5 + 52 | 0;
+ HEAP32[i1 >> 2] = 0;
+ i4 = i5 + 40 | 0;
+ i12 = HEAP32[i4 >> 2] | 0;
+ do {
+ if ((i12 | 0) > 0) {
+ i9 = i5 + 32 | 0;
+ i11 = i5 + 56 | 0;
+ i8 = i5 + 12 | 0;
+ i10 = i5 + 4 | 0;
+ i13 = 0;
+ while (1) {
+ i14 = HEAP32[(HEAP32[i9 >> 2] | 0) + (i13 << 2) >> 2] | 0;
+ HEAP32[i11 >> 2] = i14;
+ if (!((i14 | 0) == -1)) {
+ if (!((i14 | 0) > -1)) {
+ i8 = 6;
+ break;
+ }
+ if ((HEAP32[i8 >> 2] | 0) <= (i14 | 0)) {
+ i8 = 6;
+ break;
+ }
+ __ZNK13b2DynamicTree5QueryI12b2BroadPhaseEEvPT_RK6b2AABB(i5, i5, (HEAP32[i10 >> 2] | 0) + (i14 * 36 | 0) | 0);
+ i12 = HEAP32[i4 >> 2] | 0;
+ }
+ i13 = i13 + 1 | 0;
+ if ((i13 | 0) >= (i12 | 0)) {
+ i8 = 9;
+ break;
+ }
+ }
+ if ((i8 | 0) == 6) {
+ ___assert_fail(1904, 1952, 159, 2008);
+ } else if ((i8 | 0) == 9) {
+ i7 = HEAP32[i1 >> 2] | 0;
+ break;
+ }
+ } else {
+ i7 = 0;
+ }
+ } while (0);
+ HEAP32[i4 >> 2] = 0;
+ i4 = i5 + 44 | 0;
+ i14 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i6 >> 2] = 3;
+ __ZNSt3__16__sortIRPFbRK6b2PairS3_EPS1_EEvT0_S8_T_(i14, i14 + (i7 * 12 | 0) | 0, i6);
+ if ((HEAP32[i1 >> 2] | 0) <= 0) {
+ STACKTOP = i3;
+ return;
+ }
+ i6 = i5 + 12 | 0;
+ i7 = i5 + 4 | 0;
+ i9 = 0;
+ L18 : while (1) {
+ i8 = HEAP32[i4 >> 2] | 0;
+ i5 = i8 + (i9 * 12 | 0) | 0;
+ i10 = HEAP32[i5 >> 2] | 0;
+ if (!((i10 | 0) > -1)) {
+ i8 = 14;
+ break;
+ }
+ i12 = HEAP32[i6 >> 2] | 0;
+ if ((i12 | 0) <= (i10 | 0)) {
+ i8 = 14;
+ break;
+ }
+ i11 = HEAP32[i7 >> 2] | 0;
+ i8 = i8 + (i9 * 12 | 0) + 4 | 0;
+ i13 = HEAP32[i8 >> 2] | 0;
+ if (!((i13 | 0) > -1 & (i12 | 0) > (i13 | 0))) {
+ i8 = 16;
+ break;
+ }
+ __ZN16b2ContactManager7AddPairEPvS0_(i2, HEAP32[i11 + (i10 * 36 | 0) + 16 >> 2] | 0, HEAP32[i11 + (i13 * 36 | 0) + 16 >> 2] | 0);
+ i10 = HEAP32[i1 >> 2] | 0;
+ while (1) {
+ i9 = i9 + 1 | 0;
+ if ((i9 | 0) >= (i10 | 0)) {
+ i8 = 21;
+ break L18;
+ }
+ i11 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i11 + (i9 * 12 | 0) >> 2] | 0) != (HEAP32[i5 >> 2] | 0)) {
+ continue L18;
+ }
+ if ((HEAP32[i11 + (i9 * 12 | 0) + 4 >> 2] | 0) != (HEAP32[i8 >> 2] | 0)) {
+ continue L18;
+ }
+ }
+ }
+ if ((i8 | 0) == 14) {
+ ___assert_fail(1904, 1952, 153, 1992);
+ } else if ((i8 | 0) == 16) {
+ ___assert_fail(1904, 1952, 153, 1992);
+ } else if ((i8 | 0) == 21) {
+ STACKTOP = i3;
+ return;
+ }
+}
+function __ZNK13b2DynamicTree5QueryI12b2BroadPhaseEEvPT_RK6b2AABB(i9, i4, i7) {
+ i9 = i9 | 0;
+ i4 = i4 | 0;
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i8 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 1040 | 0;
+ i3 = i2;
+ i1 = i3 + 4 | 0;
+ HEAP32[i3 >> 2] = i1;
+ i5 = i3 + 1028 | 0;
+ HEAP32[i5 >> 2] = 0;
+ i6 = i3 + 1032 | 0;
+ HEAP32[i6 >> 2] = 256;
+ i14 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i14 + (HEAP32[i5 >> 2] << 2) >> 2] = HEAP32[i9 >> 2];
+ i15 = HEAP32[i5 >> 2] | 0;
+ i16 = i15 + 1 | 0;
+ HEAP32[i5 >> 2] = i16;
+ L1 : do {
+ if ((i15 | 0) > -1) {
+ i9 = i9 + 4 | 0;
+ i11 = i7 + 4 | 0;
+ i12 = i7 + 8 | 0;
+ i10 = i7 + 12 | 0;
+ while (1) {
+ i16 = i16 + -1 | 0;
+ HEAP32[i5 >> 2] = i16;
+ i13 = HEAP32[i14 + (i16 << 2) >> 2] | 0;
+ do {
+ if (!((i13 | 0) == -1) ? (i8 = HEAP32[i9 >> 2] | 0, !(+HEAPF32[i7 >> 2] - +HEAPF32[i8 + (i13 * 36 | 0) + 8 >> 2] > 0.0 | +HEAPF32[i11 >> 2] - +HEAPF32[i8 + (i13 * 36 | 0) + 12 >> 2] > 0.0 | +HEAPF32[i8 + (i13 * 36 | 0) >> 2] - +HEAPF32[i12 >> 2] > 0.0 | +HEAPF32[i8 + (i13 * 36 | 0) + 4 >> 2] - +HEAPF32[i10 >> 2] > 0.0)) : 0) {
+ i15 = i8 + (i13 * 36 | 0) + 24 | 0;
+ if ((HEAP32[i15 >> 2] | 0) == -1) {
+ if (!(__ZN12b2BroadPhase13QueryCallbackEi(i4, i13) | 0)) {
+ break L1;
+ }
+ i16 = HEAP32[i5 >> 2] | 0;
+ break;
+ }
+ if ((i16 | 0) == (HEAP32[i6 >> 2] | 0) ? (HEAP32[i6 >> 2] = i16 << 1, i16 = __Z7b2Alloci(i16 << 3) | 0, HEAP32[i3 >> 2] = i16, _memcpy(i16 | 0, i14 | 0, HEAP32[i5 >> 2] << 2 | 0) | 0, (i14 | 0) != (i1 | 0)) : 0) {
+ __Z6b2FreePv(i14);
+ }
+ i14 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i14 + (HEAP32[i5 >> 2] << 2) >> 2] = HEAP32[i15 >> 2];
+ i15 = (HEAP32[i5 >> 2] | 0) + 1 | 0;
+ HEAP32[i5 >> 2] = i15;
+ i13 = i8 + (i13 * 36 | 0) + 28 | 0;
+ if ((i15 | 0) == (HEAP32[i6 >> 2] | 0) ? (HEAP32[i6 >> 2] = i15 << 1, i16 = __Z7b2Alloci(i15 << 3) | 0, HEAP32[i3 >> 2] = i16, _memcpy(i16 | 0, i14 | 0, HEAP32[i5 >> 2] << 2 | 0) | 0, (i14 | 0) != (i1 | 0)) : 0) {
+ __Z6b2FreePv(i14);
+ }
+ HEAP32[(HEAP32[i3 >> 2] | 0) + (HEAP32[i5 >> 2] << 2) >> 2] = HEAP32[i13 >> 2];
+ i16 = (HEAP32[i5 >> 2] | 0) + 1 | 0;
+ HEAP32[i5 >> 2] = i16;
+ }
+ } while (0);
+ if ((i16 | 0) <= 0) {
+ break L1;
+ }
+ i14 = HEAP32[i3 >> 2] | 0;
+ }
+ }
+ } while (0);
+ i4 = HEAP32[i3 >> 2] | 0;
+ if ((i4 | 0) == (i1 | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ __Z6b2FreePv(i4);
+ HEAP32[i3 >> 2] = 0;
+ STACKTOP = i2;
+ return;
+}
+function __ZN15b2ContactSolver9WarmStartEv(i4) {
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, d10 = 0.0, d11 = 0.0, d12 = 0.0, i13 = 0, d14 = 0.0, d15 = 0.0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, d21 = 0.0, i22 = 0, d23 = 0.0, i24 = 0, d25 = 0.0, d26 = 0.0, d27 = 0.0;
+ i1 = STACKTOP;
+ i2 = i4 + 48 | 0;
+ if ((HEAP32[i2 >> 2] | 0) <= 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i3 = i4 + 40 | 0;
+ i5 = i4 + 28 | 0;
+ i22 = HEAP32[i5 >> 2] | 0;
+ i8 = 0;
+ do {
+ i9 = HEAP32[i3 >> 2] | 0;
+ i7 = HEAP32[i9 + (i8 * 152 | 0) + 112 >> 2] | 0;
+ i6 = HEAP32[i9 + (i8 * 152 | 0) + 116 >> 2] | 0;
+ d10 = +HEAPF32[i9 + (i8 * 152 | 0) + 120 >> 2];
+ d14 = +HEAPF32[i9 + (i8 * 152 | 0) + 128 >> 2];
+ d12 = +HEAPF32[i9 + (i8 * 152 | 0) + 124 >> 2];
+ d11 = +HEAPF32[i9 + (i8 * 152 | 0) + 132 >> 2];
+ i13 = HEAP32[i9 + (i8 * 152 | 0) + 144 >> 2] | 0;
+ i4 = i22 + (i7 * 12 | 0) | 0;
+ i24 = i4;
+ d17 = +HEAPF32[i24 >> 2];
+ d19 = +HEAPF32[i24 + 4 >> 2];
+ d20 = +HEAPF32[i22 + (i7 * 12 | 0) + 8 >> 2];
+ i24 = i22 + (i6 * 12 | 0) | 0;
+ d21 = +HEAPF32[i24 >> 2];
+ d23 = +HEAPF32[i24 + 4 >> 2];
+ d18 = +HEAPF32[i22 + (i6 * 12 | 0) + 8 >> 2];
+ i22 = i9 + (i8 * 152 | 0) + 72 | 0;
+ d15 = +HEAPF32[i22 >> 2];
+ d16 = +HEAPF32[i22 + 4 >> 2];
+ if ((i13 | 0) > 0) {
+ i22 = 0;
+ do {
+ d27 = +HEAPF32[i9 + (i8 * 152 | 0) + (i22 * 36 | 0) + 16 >> 2];
+ d25 = +HEAPF32[i9 + (i8 * 152 | 0) + (i22 * 36 | 0) + 20 >> 2];
+ d26 = d15 * d27 + d16 * d25;
+ d25 = d16 * d27 - d15 * d25;
+ d20 = d20 - d14 * (+HEAPF32[i9 + (i8 * 152 | 0) + (i22 * 36 | 0) >> 2] * d25 - +HEAPF32[i9 + (i8 * 152 | 0) + (i22 * 36 | 0) + 4 >> 2] * d26);
+ d17 = d17 - d10 * d26;
+ d19 = d19 - d10 * d25;
+ d18 = d18 + d11 * (d25 * +HEAPF32[i9 + (i8 * 152 | 0) + (i22 * 36 | 0) + 8 >> 2] - d26 * +HEAPF32[i9 + (i8 * 152 | 0) + (i22 * 36 | 0) + 12 >> 2]);
+ d21 = d21 + d12 * d26;
+ d23 = d23 + d12 * d25;
+ i22 = i22 + 1 | 0;
+ } while ((i22 | 0) != (i13 | 0));
+ }
+ d27 = +d17;
+ d26 = +d19;
+ i22 = i4;
+ HEAPF32[i22 >> 2] = d27;
+ HEAPF32[i22 + 4 >> 2] = d26;
+ i22 = HEAP32[i5 >> 2] | 0;
+ HEAPF32[i22 + (i7 * 12 | 0) + 8 >> 2] = d20;
+ d26 = +d21;
+ d27 = +d23;
+ i22 = i22 + (i6 * 12 | 0) | 0;
+ HEAPF32[i22 >> 2] = d26;
+ HEAPF32[i22 + 4 >> 2] = d27;
+ i22 = HEAP32[i5 >> 2] | 0;
+ HEAPF32[i22 + (i6 * 12 | 0) + 8 >> 2] = d18;
+ i8 = i8 + 1 | 0;
+ } while ((i8 | 0) < (HEAP32[i2 >> 2] | 0));
+ STACKTOP = i1;
+ return;
+}
+function __ZNK14b2PolygonShape7RayCastEP15b2RayCastOutputRK14b2RayCastInputRK11b2Transformi(i1, i5, i8, i7, i4) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i8 = i8 | 0;
+ i7 = i7 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, d3 = 0.0, i6 = 0, d9 = 0.0, d10 = 0.0, d11 = 0.0, d12 = 0.0, d13 = 0.0, i14 = 0, i15 = 0, i16 = 0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0;
+ i4 = STACKTOP;
+ d10 = +HEAPF32[i7 >> 2];
+ d9 = +HEAPF32[i8 >> 2] - d10;
+ d18 = +HEAPF32[i7 + 4 >> 2];
+ d11 = +HEAPF32[i8 + 4 >> 2] - d18;
+ i6 = i7 + 12 | 0;
+ d17 = +HEAPF32[i6 >> 2];
+ i7 = i7 + 8 | 0;
+ d19 = +HEAPF32[i7 >> 2];
+ d12 = d9 * d17 + d11 * d19;
+ d9 = d17 * d11 - d9 * d19;
+ d10 = +HEAPF32[i8 + 8 >> 2] - d10;
+ d18 = +HEAPF32[i8 + 12 >> 2] - d18;
+ d11 = d17 * d10 + d19 * d18 - d12;
+ d10 = d17 * d18 - d19 * d10 - d9;
+ i8 = i8 + 16 | 0;
+ i14 = HEAP32[i1 + 148 >> 2] | 0;
+ do {
+ if ((i14 | 0) > 0) {
+ i16 = 0;
+ i15 = -1;
+ d13 = 0.0;
+ d17 = +HEAPF32[i8 >> 2];
+ L3 : while (1) {
+ d20 = +HEAPF32[i1 + (i16 << 3) + 84 >> 2];
+ d19 = +HEAPF32[i1 + (i16 << 3) + 88 >> 2];
+ d18 = (+HEAPF32[i1 + (i16 << 3) + 20 >> 2] - d12) * d20 + (+HEAPF32[i1 + (i16 << 3) + 24 >> 2] - d9) * d19;
+ d19 = d11 * d20 + d10 * d19;
+ do {
+ if (d19 == 0.0) {
+ if (d18 < 0.0) {
+ i1 = 0;
+ i14 = 18;
+ break L3;
+ }
+ } else {
+ if (d19 < 0.0 ? d18 < d13 * d19 : 0) {
+ i15 = i16;
+ d13 = d18 / d19;
+ break;
+ }
+ if (d19 > 0.0 ? d18 < d17 * d19 : 0) {
+ d17 = d18 / d19;
+ }
+ }
+ } while (0);
+ i16 = i16 + 1 | 0;
+ if (d17 < d13) {
+ i1 = 0;
+ i14 = 18;
+ break;
+ }
+ if ((i16 | 0) >= (i14 | 0)) {
+ i14 = 13;
+ break;
+ }
+ }
+ if ((i14 | 0) == 13) {
+ if (d13 >= 0.0) {
+ i2 = i15;
+ d3 = d13;
+ break;
+ }
+ ___assert_fail(376, 328, 249, 424);
+ } else if ((i14 | 0) == 18) {
+ STACKTOP = i4;
+ return i1 | 0;
+ }
+ } else {
+ i2 = -1;
+ d3 = 0.0;
+ }
+ } while (0);
+ if (!(d3 <= +HEAPF32[i8 >> 2])) {
+ ___assert_fail(376, 328, 249, 424);
+ }
+ if (!((i2 | 0) > -1)) {
+ i16 = 0;
+ STACKTOP = i4;
+ return i16 | 0;
+ }
+ HEAPF32[i5 + 8 >> 2] = d3;
+ d18 = +HEAPF32[i6 >> 2];
+ d13 = +HEAPF32[i1 + (i2 << 3) + 84 >> 2];
+ d17 = +HEAPF32[i7 >> 2];
+ d20 = +HEAPF32[i1 + (i2 << 3) + 88 >> 2];
+ d19 = +(d18 * d13 - d17 * d20);
+ d20 = +(d13 * d17 + d18 * d20);
+ i16 = i5;
+ HEAPF32[i16 >> 2] = d19;
+ HEAPF32[i16 + 4 >> 2] = d20;
+ i16 = 1;
+ STACKTOP = i4;
+ return i16 | 0;
+}
+function __ZN7b2World4StepEfii(i1, d9, i11, i12) {
+ i1 = i1 | 0;
+ d9 = +d9;
+ i11 = i11 | 0;
+ i12 = i12 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i10 = 0, i13 = 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i3 = i4 + 27 | 0;
+ i5 = i4;
+ i8 = i4 + 26 | 0;
+ i10 = i4 + 25 | 0;
+ i7 = i4 + 24 | 0;
+ __ZN7b2TimerC2Ev(i3);
+ i2 = i1 + 102868 | 0;
+ i13 = HEAP32[i2 >> 2] | 0;
+ if ((i13 & 1 | 0) != 0) {
+ __ZN16b2ContactManager15FindNewContactsEv(i1 + 102872 | 0);
+ i13 = HEAP32[i2 >> 2] & -2;
+ HEAP32[i2 >> 2] = i13;
+ }
+ HEAP32[i2 >> 2] = i13 | 2;
+ HEAPF32[i5 >> 2] = d9;
+ HEAP32[i5 + 12 >> 2] = i11;
+ HEAP32[i5 + 16 >> 2] = i12;
+ if (d9 > 0.0) {
+ HEAPF32[i5 + 4 >> 2] = 1.0 / d9;
+ } else {
+ HEAPF32[i5 + 4 >> 2] = 0.0;
+ }
+ i11 = i1 + 102988 | 0;
+ HEAPF32[i5 + 8 >> 2] = +HEAPF32[i11 >> 2] * d9;
+ HEAP8[i5 + 20 | 0] = HEAP8[i1 + 102992 | 0] | 0;
+ __ZN7b2TimerC2Ev(i8);
+ __ZN16b2ContactManager7CollideEv(i1 + 102872 | 0);
+ HEAPF32[i1 + 103e3 >> 2] = +__ZNK7b2Timer15GetMillisecondsEv(i8);
+ if ((HEAP8[i1 + 102995 | 0] | 0) != 0 ? +HEAPF32[i5 >> 2] > 0.0 : 0) {
+ __ZN7b2TimerC2Ev(i10);
+ __ZN7b2World5SolveERK10b2TimeStep(i1, i5);
+ HEAPF32[i1 + 103004 >> 2] = +__ZNK7b2Timer15GetMillisecondsEv(i10);
+ }
+ if ((HEAP8[i1 + 102993 | 0] | 0) != 0) {
+ d9 = +HEAPF32[i5 >> 2];
+ if (d9 > 0.0) {
+ __ZN7b2TimerC2Ev(i7);
+ __ZN7b2World8SolveTOIERK10b2TimeStep(i1, i5);
+ HEAPF32[i1 + 103024 >> 2] = +__ZNK7b2Timer15GetMillisecondsEv(i7);
+ i6 = 12;
+ }
+ } else {
+ i6 = 12;
+ }
+ if ((i6 | 0) == 12) {
+ d9 = +HEAPF32[i5 >> 2];
+ }
+ if (d9 > 0.0) {
+ HEAPF32[i11 >> 2] = +HEAPF32[i5 + 4 >> 2];
+ }
+ i5 = HEAP32[i2 >> 2] | 0;
+ if ((i5 & 4 | 0) == 0) {
+ i13 = i5 & -3;
+ HEAP32[i2 >> 2] = i13;
+ d9 = +__ZNK7b2Timer15GetMillisecondsEv(i3);
+ i13 = i1 + 102996 | 0;
+ HEAPF32[i13 >> 2] = d9;
+ STACKTOP = i4;
+ return;
+ }
+ i6 = HEAP32[i1 + 102952 >> 2] | 0;
+ if ((i6 | 0) == 0) {
+ i13 = i5 & -3;
+ HEAP32[i2 >> 2] = i13;
+ d9 = +__ZNK7b2Timer15GetMillisecondsEv(i3);
+ i13 = i1 + 102996 | 0;
+ HEAPF32[i13 >> 2] = d9;
+ STACKTOP = i4;
+ return;
+ }
+ do {
+ HEAPF32[i6 + 76 >> 2] = 0.0;
+ HEAPF32[i6 + 80 >> 2] = 0.0;
+ HEAPF32[i6 + 84 >> 2] = 0.0;
+ i6 = HEAP32[i6 + 96 >> 2] | 0;
+ } while ((i6 | 0) != 0);
+ i13 = i5 & -3;
+ HEAP32[i2 >> 2] = i13;
+ d9 = +__ZNK7b2Timer15GetMillisecondsEv(i3);
+ i13 = i1 + 102996 | 0;
+ HEAPF32[i13 >> 2] = d9;
+ STACKTOP = i4;
+ return;
+}
+function __ZL19b2FindMaxSeparationPiPK14b2PolygonShapeRK11b2TransformS2_S5_(i1, i5, i6, i3, i4) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i7 = 0, d8 = 0.0, d9 = 0.0, d10 = 0.0, d11 = 0.0, i12 = 0, i13 = 0, i14 = 0, d15 = 0.0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0;
+ i2 = STACKTOP;
+ i7 = HEAP32[i5 + 148 >> 2] | 0;
+ d17 = +HEAPF32[i4 + 12 >> 2];
+ d19 = +HEAPF32[i3 + 12 >> 2];
+ d18 = +HEAPF32[i4 + 8 >> 2];
+ d16 = +HEAPF32[i3 + 16 >> 2];
+ d15 = +HEAPF32[i6 + 12 >> 2];
+ d10 = +HEAPF32[i5 + 12 >> 2];
+ d8 = +HEAPF32[i6 + 8 >> 2];
+ d9 = +HEAPF32[i5 + 16 >> 2];
+ d11 = +HEAPF32[i4 >> 2] + (d17 * d19 - d18 * d16) - (+HEAPF32[i6 >> 2] + (d15 * d10 - d8 * d9));
+ d9 = d19 * d18 + d17 * d16 + +HEAPF32[i4 + 4 >> 2] - (d10 * d8 + d15 * d9 + +HEAPF32[i6 + 4 >> 2]);
+ d10 = d15 * d11 + d8 * d9;
+ d8 = d15 * d9 - d11 * d8;
+ if ((i7 | 0) > 0) {
+ i14 = 0;
+ i13 = 0;
+ d9 = -3.4028234663852886e+38;
+ while (1) {
+ d11 = d10 * +HEAPF32[i5 + (i13 << 3) + 84 >> 2] + d8 * +HEAPF32[i5 + (i13 << 3) + 88 >> 2];
+ i12 = d11 > d9;
+ i14 = i12 ? i13 : i14;
+ i13 = i13 + 1 | 0;
+ if ((i13 | 0) == (i7 | 0)) {
+ break;
+ } else {
+ d9 = i12 ? d11 : d9;
+ }
+ }
+ } else {
+ i14 = 0;
+ }
+ d9 = +__ZL16b2EdgeSeparationPK14b2PolygonShapeRK11b2TransformiS1_S4_(i5, i6, i14, i3, i4);
+ i12 = ((i14 | 0) > 0 ? i14 : i7) + -1 | 0;
+ d8 = +__ZL16b2EdgeSeparationPK14b2PolygonShapeRK11b2TransformiS1_S4_(i5, i6, i12, i3, i4);
+ i13 = i14 + 1 | 0;
+ i13 = (i13 | 0) < (i7 | 0) ? i13 : 0;
+ d10 = +__ZL16b2EdgeSeparationPK14b2PolygonShapeRK11b2TransformiS1_S4_(i5, i6, i13, i3, i4);
+ if (d8 > d9 & d8 > d10) {
+ while (1) {
+ i13 = ((i12 | 0) > 0 ? i12 : i7) + -1 | 0;
+ d9 = +__ZL16b2EdgeSeparationPK14b2PolygonShapeRK11b2TransformiS1_S4_(i5, i6, i13, i3, i4);
+ if (d9 > d8) {
+ i12 = i13;
+ d8 = d9;
+ } else {
+ break;
+ }
+ }
+ HEAP32[i1 >> 2] = i12;
+ STACKTOP = i2;
+ return +d8;
+ }
+ if (d10 > d9) {
+ i12 = i13;
+ d8 = d10;
+ } else {
+ d19 = d9;
+ HEAP32[i1 >> 2] = i14;
+ STACKTOP = i2;
+ return +d19;
+ }
+ while (1) {
+ i13 = i12 + 1 | 0;
+ i13 = (i13 | 0) < (i7 | 0) ? i13 : 0;
+ d9 = +__ZL16b2EdgeSeparationPK14b2PolygonShapeRK11b2TransformiS1_S4_(i5, i6, i13, i3, i4);
+ if (d9 > d8) {
+ i12 = i13;
+ d8 = d9;
+ } else {
+ break;
+ }
+ }
+ HEAP32[i1 >> 2] = i12;
+ STACKTOP = i2;
+ return +d8;
+}
+function __ZN9b2Fixture11SynchronizeEP12b2BroadPhaseRK11b2TransformS4_(i10, i8, i7, i2) {
+ i10 = i10 | 0;
+ i8 = i8 | 0;
+ i7 = i7 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i9 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, d23 = 0.0, d24 = 0.0, d25 = 0.0, d26 = 0.0, i27 = 0;
+ i9 = STACKTOP;
+ STACKTOP = STACKTOP + 48 | 0;
+ i5 = i9 + 24 | 0;
+ i6 = i9 + 8 | 0;
+ i3 = i9;
+ i4 = i10 + 28 | 0;
+ if ((HEAP32[i4 >> 2] | 0) <= 0) {
+ STACKTOP = i9;
+ return;
+ }
+ i1 = i10 + 24 | 0;
+ i18 = i10 + 12 | 0;
+ i19 = i5 + 4 | 0;
+ i20 = i6 + 4 | 0;
+ i13 = i5 + 8 | 0;
+ i14 = i6 + 8 | 0;
+ i15 = i5 + 12 | 0;
+ i16 = i6 + 12 | 0;
+ i11 = i2 + 4 | 0;
+ i22 = i7 + 4 | 0;
+ i12 = i3 + 4 | 0;
+ i21 = 0;
+ do {
+ i10 = HEAP32[i1 >> 2] | 0;
+ i27 = HEAP32[i18 >> 2] | 0;
+ i17 = i10 + (i21 * 28 | 0) + 20 | 0;
+ FUNCTION_TABLE_viiii[HEAP32[(HEAP32[i27 >> 2] | 0) + 24 >> 2] & 15](i27, i5, i7, HEAP32[i17 >> 2] | 0);
+ i27 = HEAP32[i18 >> 2] | 0;
+ FUNCTION_TABLE_viiii[HEAP32[(HEAP32[i27 >> 2] | 0) + 24 >> 2] & 15](i27, i6, i2, HEAP32[i17 >> 2] | 0);
+ i17 = i10 + (i21 * 28 | 0) | 0;
+ d25 = +HEAPF32[i5 >> 2];
+ d26 = +HEAPF32[i6 >> 2];
+ d24 = +HEAPF32[i19 >> 2];
+ d23 = +HEAPF32[i20 >> 2];
+ d25 = +(d25 < d26 ? d25 : d26);
+ d26 = +(d24 < d23 ? d24 : d23);
+ i27 = i17;
+ HEAPF32[i27 >> 2] = d25;
+ HEAPF32[i27 + 4 >> 2] = d26;
+ d25 = +HEAPF32[i13 >> 2];
+ d26 = +HEAPF32[i14 >> 2];
+ d23 = +HEAPF32[i15 >> 2];
+ d24 = +HEAPF32[i16 >> 2];
+ d25 = +(d25 > d26 ? d25 : d26);
+ d26 = +(d23 > d24 ? d23 : d24);
+ i27 = i10 + (i21 * 28 | 0) + 8 | 0;
+ HEAPF32[i27 >> 2] = d25;
+ HEAPF32[i27 + 4 >> 2] = d26;
+ d26 = +HEAPF32[i11 >> 2] - +HEAPF32[i22 >> 2];
+ HEAPF32[i3 >> 2] = +HEAPF32[i2 >> 2] - +HEAPF32[i7 >> 2];
+ HEAPF32[i12 >> 2] = d26;
+ __ZN12b2BroadPhase9MoveProxyEiRK6b2AABBRK6b2Vec2(i8, HEAP32[i10 + (i21 * 28 | 0) + 24 >> 2] | 0, i17, i3);
+ i21 = i21 + 1 | 0;
+ } while ((i21 | 0) < (HEAP32[i4 >> 2] | 0));
+ STACKTOP = i9;
+ return;
+}
+function __ZN12b2EPCollider24ComputePolygonSeparationEv(i2, i9) {
+ i2 = i2 | 0;
+ i9 = i9 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, d6 = 0.0, d7 = 0.0, i8 = 0, d10 = 0.0, d11 = 0.0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0, i20 = 0, d21 = 0.0, d22 = 0.0, d23 = 0.0, d24 = 0.0, d25 = 0.0, d26 = 0.0;
+ i15 = STACKTOP;
+ HEAP32[i2 >> 2] = 0;
+ i3 = i2 + 4 | 0;
+ HEAP32[i3 >> 2] = -1;
+ i4 = i2 + 8 | 0;
+ HEAPF32[i4 >> 2] = -3.4028234663852886e+38;
+ d7 = +HEAPF32[i9 + 216 >> 2];
+ d6 = +HEAPF32[i9 + 212 >> 2];
+ i5 = HEAP32[i9 + 128 >> 2] | 0;
+ if ((i5 | 0) <= 0) {
+ STACKTOP = i15;
+ return;
+ }
+ d17 = +HEAPF32[i9 + 164 >> 2];
+ d18 = +HEAPF32[i9 + 168 >> 2];
+ d11 = +HEAPF32[i9 + 172 >> 2];
+ d10 = +HEAPF32[i9 + 176 >> 2];
+ d16 = +HEAPF32[i9 + 244 >> 2];
+ i12 = i9 + 228 | 0;
+ i13 = i9 + 232 | 0;
+ i14 = i9 + 236 | 0;
+ i1 = i9 + 240 | 0;
+ d19 = -3.4028234663852886e+38;
+ i20 = 0;
+ while (1) {
+ d23 = +HEAPF32[i9 + (i20 << 3) + 64 >> 2];
+ d21 = -d23;
+ d22 = -+HEAPF32[i9 + (i20 << 3) + 68 >> 2];
+ d26 = +HEAPF32[i9 + (i20 << 3) >> 2];
+ d25 = +HEAPF32[i9 + (i20 << 3) + 4 >> 2];
+ d24 = (d26 - d17) * d21 + (d25 - d18) * d22;
+ d25 = (d26 - d11) * d21 + (d25 - d10) * d22;
+ d24 = d24 < d25 ? d24 : d25;
+ if (d24 > d16) {
+ break;
+ }
+ if (!(d7 * d23 + d6 * d22 >= 0.0)) {
+ if (!((d21 - +HEAPF32[i12 >> 2]) * d6 + (d22 - +HEAPF32[i13 >> 2]) * d7 < -.03490658849477768) & d24 > d19) {
+ i8 = 8;
+ }
+ } else {
+ if (!((d21 - +HEAPF32[i14 >> 2]) * d6 + (d22 - +HEAPF32[i1 >> 2]) * d7 < -.03490658849477768) & d24 > d19) {
+ i8 = 8;
+ }
+ }
+ if ((i8 | 0) == 8) {
+ i8 = 0;
+ HEAP32[i2 >> 2] = 2;
+ HEAP32[i3 >> 2] = i20;
+ HEAPF32[i4 >> 2] = d24;
+ d19 = d24;
+ }
+ i20 = i20 + 1 | 0;
+ if ((i20 | 0) >= (i5 | 0)) {
+ i8 = 10;
+ break;
+ }
+ }
+ if ((i8 | 0) == 10) {
+ STACKTOP = i15;
+ return;
+ }
+ HEAP32[i2 >> 2] = 2;
+ HEAP32[i3 >> 2] = i20;
+ HEAPF32[i4 >> 2] = d24;
+ STACKTOP = i15;
+ return;
+}
+function __ZNK11b2EdgeShape7RayCastEP15b2RayCastOutputRK14b2RayCastInputRK11b2Transformi(i17, i1, i2, i18, i3) {
+ i17 = i17 | 0;
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i18 = i18 | 0;
+ i3 = i3 | 0;
+ var d4 = 0.0, d5 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 0.0, d9 = 0.0, d10 = 0.0, d11 = 0.0, d12 = 0.0, d13 = 0.0, d14 = 0.0, d15 = 0.0, d16 = 0.0;
+ i3 = STACKTOP;
+ d6 = +HEAPF32[i18 >> 2];
+ d7 = +HEAPF32[i2 >> 2] - d6;
+ d9 = +HEAPF32[i18 + 4 >> 2];
+ d4 = +HEAPF32[i2 + 4 >> 2] - d9;
+ d11 = +HEAPF32[i18 + 12 >> 2];
+ d5 = +HEAPF32[i18 + 8 >> 2];
+ d8 = d7 * d11 + d4 * d5;
+ d7 = d11 * d4 - d7 * d5;
+ d6 = +HEAPF32[i2 + 8 >> 2] - d6;
+ d9 = +HEAPF32[i2 + 12 >> 2] - d9;
+ d4 = d11 * d6 + d5 * d9 - d8;
+ d6 = d11 * d9 - d5 * d6 - d7;
+ i18 = i17 + 12 | 0;
+ d5 = +HEAPF32[i18 >> 2];
+ d9 = +HEAPF32[i18 + 4 >> 2];
+ i18 = i17 + 20 | 0;
+ d11 = +HEAPF32[i18 >> 2];
+ d11 = d11 - d5;
+ d12 = +HEAPF32[i18 + 4 >> 2] - d9;
+ d15 = -d11;
+ d10 = d11 * d11 + d12 * d12;
+ d13 = +Math_sqrt(+d10);
+ if (d13 < 1.1920928955078125e-7) {
+ d13 = d12;
+ } else {
+ d16 = 1.0 / d13;
+ d13 = d12 * d16;
+ d15 = d16 * d15;
+ }
+ d14 = (d9 - d7) * d15 + (d5 - d8) * d13;
+ d16 = d6 * d15 + d4 * d13;
+ if (d16 == 0.0) {
+ i18 = 0;
+ STACKTOP = i3;
+ return i18 | 0;
+ }
+ d16 = d14 / d16;
+ if (d16 < 0.0) {
+ i18 = 0;
+ STACKTOP = i3;
+ return i18 | 0;
+ }
+ if (+HEAPF32[i2 + 16 >> 2] < d16 | d10 == 0.0) {
+ i18 = 0;
+ STACKTOP = i3;
+ return i18 | 0;
+ }
+ d12 = (d11 * (d8 + d4 * d16 - d5) + d12 * (d7 + d6 * d16 - d9)) / d10;
+ if (d12 < 0.0 | d12 > 1.0) {
+ i18 = 0;
+ STACKTOP = i3;
+ return i18 | 0;
+ }
+ HEAPF32[i1 + 8 >> 2] = d16;
+ if (d14 > 0.0) {
+ d14 = +-d13;
+ d16 = +-d15;
+ i18 = i1;
+ HEAPF32[i18 >> 2] = d14;
+ HEAPF32[i18 + 4 >> 2] = d16;
+ i18 = 1;
+ STACKTOP = i3;
+ return i18 | 0;
+ } else {
+ d14 = +d13;
+ d16 = +d15;
+ i18 = i1;
+ HEAPF32[i18 >> 2] = d14;
+ HEAPF32[i18 + 4 >> 2] = d16;
+ i18 = 1;
+ STACKTOP = i3;
+ return i18 | 0;
+ }
+ return 0;
+}
+function ___dynamic_cast(i7, i6, i11, i5) {
+ i7 = i7 | 0;
+ i6 = i6 | 0;
+ i11 = i11 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i8 = 0, i9 = 0, i10 = 0, i12 = 0, i13 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i2 = i1;
+ i3 = HEAP32[i7 >> 2] | 0;
+ i4 = i7 + (HEAP32[i3 + -8 >> 2] | 0) | 0;
+ i3 = HEAP32[i3 + -4 >> 2] | 0;
+ HEAP32[i2 >> 2] = i11;
+ HEAP32[i2 + 4 >> 2] = i7;
+ HEAP32[i2 + 8 >> 2] = i6;
+ HEAP32[i2 + 12 >> 2] = i5;
+ i9 = i2 + 16 | 0;
+ i10 = i2 + 20 | 0;
+ i6 = i2 + 24 | 0;
+ i8 = i2 + 28 | 0;
+ i5 = i2 + 32 | 0;
+ i7 = i2 + 40 | 0;
+ i12 = (i3 | 0) == (i11 | 0);
+ i13 = i9 + 0 | 0;
+ i11 = i13 + 36 | 0;
+ do {
+ HEAP32[i13 >> 2] = 0;
+ i13 = i13 + 4 | 0;
+ } while ((i13 | 0) < (i11 | 0));
+ HEAP16[i9 + 36 >> 1] = 0;
+ HEAP8[i9 + 38 | 0] = 0;
+ if (i12) {
+ HEAP32[i2 + 48 >> 2] = 1;
+ FUNCTION_TABLE_viiiiii[HEAP32[(HEAP32[i3 >> 2] | 0) + 20 >> 2] & 3](i3, i2, i4, i4, 1, 0);
+ i13 = (HEAP32[i6 >> 2] | 0) == 1 ? i4 : 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ FUNCTION_TABLE_viiiii[HEAP32[(HEAP32[i3 >> 2] | 0) + 24 >> 2] & 3](i3, i2, i4, 1, 0);
+ i2 = HEAP32[i2 + 36 >> 2] | 0;
+ if ((i2 | 0) == 0) {
+ if ((HEAP32[i7 >> 2] | 0) != 1) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ if ((HEAP32[i8 >> 2] | 0) != 1) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ i13 = (HEAP32[i5 >> 2] | 0) == 1 ? HEAP32[i10 >> 2] | 0 : 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ } else if ((i2 | 0) == 1) {
+ if ((HEAP32[i6 >> 2] | 0) != 1) {
+ if ((HEAP32[i7 >> 2] | 0) != 0) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ if ((HEAP32[i8 >> 2] | 0) != 1) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ if ((HEAP32[i5 >> 2] | 0) != 1) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ }
+ i13 = HEAP32[i9 >> 2] | 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ } else {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ return 0;
+}
+function __ZNK14b2PolygonShape11ComputeMassEP10b2MassDataf(i4, i1, d2) {
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ d2 = +d2;
+ var i3 = 0, i5 = 0, d6 = 0.0, d7 = 0.0, d8 = 0.0, d9 = 0.0, d10 = 0.0, d11 = 0.0, i12 = 0, d13 = 0.0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, d18 = 0.0, i19 = 0, d20 = 0.0, d21 = 0.0, d22 = 0.0, d23 = 0.0;
+ i3 = STACKTOP;
+ i5 = HEAP32[i4 + 148 >> 2] | 0;
+ if ((i5 | 0) > 2) {
+ d7 = 0.0;
+ d6 = 0.0;
+ i12 = 0;
+ } else {
+ ___assert_fail(432, 328, 306, 456);
+ }
+ do {
+ d6 = d6 + +HEAPF32[i4 + (i12 << 3) + 20 >> 2];
+ d7 = d7 + +HEAPF32[i4 + (i12 << 3) + 24 >> 2];
+ i12 = i12 + 1 | 0;
+ } while ((i12 | 0) < (i5 | 0));
+ d11 = 1.0 / +(i5 | 0);
+ d6 = d6 * d11;
+ d11 = d7 * d11;
+ i16 = i4 + 20 | 0;
+ i19 = i4 + 24 | 0;
+ d9 = 0.0;
+ d10 = 0.0;
+ d7 = 0.0;
+ d8 = 0.0;
+ i17 = 0;
+ do {
+ d18 = +HEAPF32[i4 + (i17 << 3) + 20 >> 2] - d6;
+ d13 = +HEAPF32[i4 + (i17 << 3) + 24 >> 2] - d11;
+ i17 = i17 + 1 | 0;
+ i12 = (i17 | 0) < (i5 | 0);
+ if (i12) {
+ i14 = i4 + (i17 << 3) + 20 | 0;
+ i15 = i4 + (i17 << 3) + 24 | 0;
+ } else {
+ i14 = i16;
+ i15 = i19;
+ }
+ d21 = +HEAPF32[i14 >> 2] - d6;
+ d20 = +HEAPF32[i15 >> 2] - d11;
+ d22 = d18 * d20 - d13 * d21;
+ d23 = d22 * .5;
+ d8 = d8 + d23;
+ d23 = d23 * .3333333432674408;
+ d9 = d9 + (d18 + d21) * d23;
+ d10 = d10 + (d13 + d20) * d23;
+ d7 = d7 + d22 * .0833333358168602 * (d21 * d21 + (d18 * d18 + d18 * d21) + (d20 * d20 + (d13 * d13 + d13 * d20)));
+ } while (i12);
+ d13 = d8 * d2;
+ HEAPF32[i1 >> 2] = d13;
+ if (d8 > 1.1920928955078125e-7) {
+ d23 = 1.0 / d8;
+ d22 = d9 * d23;
+ d23 = d10 * d23;
+ d20 = d6 + d22;
+ d21 = d11 + d23;
+ d11 = +d20;
+ d18 = +d21;
+ i19 = i1 + 4 | 0;
+ HEAPF32[i19 >> 2] = d11;
+ HEAPF32[i19 + 4 >> 2] = d18;
+ HEAPF32[i1 + 12 >> 2] = d7 * d2 + d13 * (d20 * d20 + d21 * d21 - (d22 * d22 + d23 * d23));
+ STACKTOP = i3;
+ return;
+ } else {
+ ___assert_fail(472, 328, 352, 456);
+ }
+}
+function __ZN16b2ContactManager7DestroyEP9b2Contact(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i3 = STACKTOP;
+ i5 = HEAP32[(HEAP32[i2 + 48 >> 2] | 0) + 8 >> 2] | 0;
+ i4 = HEAP32[(HEAP32[i2 + 52 >> 2] | 0) + 8 >> 2] | 0;
+ i6 = HEAP32[i1 + 72 >> 2] | 0;
+ if ((i6 | 0) != 0 ? (HEAP32[i2 + 4 >> 2] & 2 | 0) != 0 : 0) {
+ FUNCTION_TABLE_vii[HEAP32[(HEAP32[i6 >> 2] | 0) + 12 >> 2] & 15](i6, i2);
+ }
+ i7 = i2 + 8 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ i6 = i2 + 12 | 0;
+ if ((i8 | 0) != 0) {
+ HEAP32[i8 + 12 >> 2] = HEAP32[i6 >> 2];
+ }
+ i8 = HEAP32[i6 >> 2] | 0;
+ if ((i8 | 0) != 0) {
+ HEAP32[i8 + 8 >> 2] = HEAP32[i7 >> 2];
+ }
+ i7 = i1 + 60 | 0;
+ if ((HEAP32[i7 >> 2] | 0) == (i2 | 0)) {
+ HEAP32[i7 >> 2] = HEAP32[i6 >> 2];
+ }
+ i7 = i2 + 24 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ i6 = i2 + 28 | 0;
+ if ((i8 | 0) != 0) {
+ HEAP32[i8 + 12 >> 2] = HEAP32[i6 >> 2];
+ }
+ i8 = HEAP32[i6 >> 2] | 0;
+ if ((i8 | 0) != 0) {
+ HEAP32[i8 + 8 >> 2] = HEAP32[i7 >> 2];
+ }
+ i5 = i5 + 112 | 0;
+ if ((i2 + 16 | 0) == (HEAP32[i5 >> 2] | 0)) {
+ HEAP32[i5 >> 2] = HEAP32[i6 >> 2];
+ }
+ i6 = i2 + 40 | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ i5 = i2 + 44 | 0;
+ if ((i7 | 0) != 0) {
+ HEAP32[i7 + 12 >> 2] = HEAP32[i5 >> 2];
+ }
+ i7 = HEAP32[i5 >> 2] | 0;
+ if ((i7 | 0) != 0) {
+ HEAP32[i7 + 8 >> 2] = HEAP32[i6 >> 2];
+ }
+ i4 = i4 + 112 | 0;
+ if ((i2 + 32 | 0) != (HEAP32[i4 >> 2] | 0)) {
+ i8 = i1 + 76 | 0;
+ i8 = HEAP32[i8 >> 2] | 0;
+ __ZN9b2Contact7DestroyEPS_P16b2BlockAllocator(i2, i8);
+ i8 = i1 + 64 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ i7 = i7 + -1 | 0;
+ HEAP32[i8 >> 2] = i7;
+ STACKTOP = i3;
+ return;
+ }
+ HEAP32[i4 >> 2] = HEAP32[i5 >> 2];
+ i8 = i1 + 76 | 0;
+ i8 = HEAP32[i8 >> 2] | 0;
+ __ZN9b2Contact7DestroyEPS_P16b2BlockAllocator(i2, i8);
+ i8 = i1 + 64 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ i7 = i7 + -1 | 0;
+ HEAP32[i8 >> 2] = i7;
+ STACKTOP = i3;
+ return;
+}
+function __ZNK10__cxxabiv120__si_class_type_info16search_below_dstEPNS_19__dynamic_cast_infoEPKvib(i6, i3, i4, i8, i7) {
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i8 = i8 | 0;
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i5 = 0, i9 = 0, i10 = 0;
+ i1 = STACKTOP;
+ if ((i6 | 0) == (HEAP32[i3 + 8 >> 2] | 0)) {
+ if ((HEAP32[i3 + 4 >> 2] | 0) != (i4 | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ i2 = i3 + 28 | 0;
+ if ((HEAP32[i2 >> 2] | 0) == 1) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[i2 >> 2] = i8;
+ STACKTOP = i1;
+ return;
+ }
+ if ((i6 | 0) != (HEAP32[i3 >> 2] | 0)) {
+ i9 = HEAP32[i6 + 8 >> 2] | 0;
+ FUNCTION_TABLE_viiiii[HEAP32[(HEAP32[i9 >> 2] | 0) + 24 >> 2] & 3](i9, i3, i4, i8, i7);
+ STACKTOP = i1;
+ return;
+ }
+ if ((HEAP32[i3 + 16 >> 2] | 0) != (i4 | 0) ? (i5 = i3 + 20 | 0, (HEAP32[i5 >> 2] | 0) != (i4 | 0)) : 0) {
+ HEAP32[i3 + 32 >> 2] = i8;
+ i8 = i3 + 44 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == 4) {
+ STACKTOP = i1;
+ return;
+ }
+ i9 = i3 + 52 | 0;
+ HEAP8[i9] = 0;
+ i10 = i3 + 53 | 0;
+ HEAP8[i10] = 0;
+ i6 = HEAP32[i6 + 8 >> 2] | 0;
+ FUNCTION_TABLE_viiiiii[HEAP32[(HEAP32[i6 >> 2] | 0) + 20 >> 2] & 3](i6, i3, i4, i4, 1, i7);
+ if ((HEAP8[i10] | 0) != 0) {
+ if ((HEAP8[i9] | 0) == 0) {
+ i6 = 1;
+ i2 = 13;
+ }
+ } else {
+ i6 = 0;
+ i2 = 13;
+ }
+ do {
+ if ((i2 | 0) == 13) {
+ HEAP32[i5 >> 2] = i4;
+ i10 = i3 + 40 | 0;
+ HEAP32[i10 >> 2] = (HEAP32[i10 >> 2] | 0) + 1;
+ if ((HEAP32[i3 + 36 >> 2] | 0) == 1 ? (HEAP32[i3 + 24 >> 2] | 0) == 2 : 0) {
+ HEAP8[i3 + 54 | 0] = 1;
+ if (i6) {
+ break;
+ }
+ } else {
+ i2 = 16;
+ }
+ if ((i2 | 0) == 16 ? i6 : 0) {
+ break;
+ }
+ HEAP32[i8 >> 2] = 4;
+ STACKTOP = i1;
+ return;
+ }
+ } while (0);
+ HEAP32[i8 >> 2] = 3;
+ STACKTOP = i1;
+ return;
+ }
+ if ((i8 | 0) != 1) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[i3 + 32 >> 2] = 1;
+ STACKTOP = i1;
+ return;
+}
+function __ZN16b2BlockAllocator8AllocateEi(i4, i2) {
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i1 = STACKTOP;
+ if ((i2 | 0) == 0) {
+ i9 = 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ if ((i2 | 0) <= 0) {
+ ___assert_fail(1376, 1312, 104, 1392);
+ }
+ if ((i2 | 0) > 640) {
+ i9 = __Z7b2Alloci(i2) | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ i9 = HEAP8[632 + i2 | 0] | 0;
+ i5 = i9 & 255;
+ if (!((i9 & 255) < 14)) {
+ ___assert_fail(1408, 1312, 112, 1392);
+ }
+ i2 = i4 + (i5 << 2) + 12 | 0;
+ i3 = HEAP32[i2 >> 2] | 0;
+ if ((i3 | 0) != 0) {
+ HEAP32[i2 >> 2] = HEAP32[i3 >> 2];
+ i9 = i3;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ i3 = i4 + 4 | 0;
+ i6 = HEAP32[i3 >> 2] | 0;
+ i7 = i4 + 8 | 0;
+ if ((i6 | 0) == (HEAP32[i7 >> 2] | 0)) {
+ i9 = HEAP32[i4 >> 2] | 0;
+ i6 = i6 + 128 | 0;
+ HEAP32[i7 >> 2] = i6;
+ i6 = __Z7b2Alloci(i6 << 3) | 0;
+ HEAP32[i4 >> 2] = i6;
+ _memcpy(i6 | 0, i9 | 0, HEAP32[i3 >> 2] << 3 | 0) | 0;
+ _memset((HEAP32[i4 >> 2] | 0) + (HEAP32[i3 >> 2] << 3) | 0, 0, 1024) | 0;
+ __Z6b2FreePv(i9);
+ i6 = HEAP32[i3 >> 2] | 0;
+ }
+ i9 = HEAP32[i4 >> 2] | 0;
+ i7 = __Z7b2Alloci(16384) | 0;
+ i4 = i9 + (i6 << 3) + 4 | 0;
+ HEAP32[i4 >> 2] = i7;
+ i5 = HEAP32[576 + (i5 << 2) >> 2] | 0;
+ HEAP32[i9 + (i6 << 3) >> 2] = i5;
+ i6 = 16384 / (i5 | 0) | 0;
+ if ((Math_imul(i6, i5) | 0) >= 16385) {
+ ___assert_fail(1448, 1312, 140, 1392);
+ }
+ i6 = i6 + -1 | 0;
+ if ((i6 | 0) > 0) {
+ i9 = 0;
+ while (1) {
+ i8 = i9 + 1 | 0;
+ HEAP32[i7 + (Math_imul(i9, i5) | 0) >> 2] = i7 + (Math_imul(i8, i5) | 0);
+ i7 = HEAP32[i4 >> 2] | 0;
+ if ((i8 | 0) == (i6 | 0)) {
+ break;
+ } else {
+ i9 = i8;
+ }
+ }
+ }
+ HEAP32[i7 + (Math_imul(i6, i5) | 0) >> 2] = 0;
+ HEAP32[i2 >> 2] = HEAP32[HEAP32[i4 >> 2] >> 2];
+ HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + 1;
+ i9 = HEAP32[i4 >> 2] | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+}
+function __ZN9b2Contact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator(i4, i5, i1, i3, i6) {
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ var i2 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i2 = STACKTOP;
+ if ((HEAP8[4200] | 0) == 0) {
+ HEAP32[1002] = 3;
+ HEAP32[4012 >> 2] = 3;
+ HEAP8[4016 | 0] = 1;
+ HEAP32[4104 >> 2] = 4;
+ HEAP32[4108 >> 2] = 4;
+ HEAP8[4112 | 0] = 1;
+ HEAP32[4032 >> 2] = 4;
+ HEAP32[4036 >> 2] = 4;
+ HEAP8[4040 | 0] = 0;
+ HEAP32[4128 >> 2] = 5;
+ HEAP32[4132 >> 2] = 5;
+ HEAP8[4136 | 0] = 1;
+ HEAP32[4056 >> 2] = 6;
+ HEAP32[4060 >> 2] = 6;
+ HEAP8[4064 | 0] = 1;
+ HEAP32[4020 >> 2] = 6;
+ HEAP32[4024 >> 2] = 6;
+ HEAP8[4028 | 0] = 0;
+ HEAP32[4080 >> 2] = 7;
+ HEAP32[4084 >> 2] = 7;
+ HEAP8[4088 | 0] = 1;
+ HEAP32[4116 >> 2] = 7;
+ HEAP32[4120 >> 2] = 7;
+ HEAP8[4124 | 0] = 0;
+ HEAP32[4152 >> 2] = 8;
+ HEAP32[4156 >> 2] = 8;
+ HEAP8[4160 | 0] = 1;
+ HEAP32[4044 >> 2] = 8;
+ HEAP32[4048 >> 2] = 8;
+ HEAP8[4052 | 0] = 0;
+ HEAP32[4176 >> 2] = 9;
+ HEAP32[4180 >> 2] = 9;
+ HEAP8[4184 | 0] = 1;
+ HEAP32[4140 >> 2] = 9;
+ HEAP32[4144 >> 2] = 9;
+ HEAP8[4148 | 0] = 0;
+ HEAP8[4200] = 1;
+ }
+ i7 = HEAP32[(HEAP32[i4 + 12 >> 2] | 0) + 4 >> 2] | 0;
+ i8 = HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 4 >> 2] | 0;
+ if (!(i7 >>> 0 < 4)) {
+ ___assert_fail(4208, 4256, 80, 4344);
+ }
+ if (!(i8 >>> 0 < 4)) {
+ ___assert_fail(4296, 4256, 81, 4344);
+ }
+ i9 = HEAP32[4008 + (i7 * 48 | 0) + (i8 * 12 | 0) >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ i9 = 0;
+ STACKTOP = i2;
+ return i9 | 0;
+ }
+ if ((HEAP8[4008 + (i7 * 48 | 0) + (i8 * 12 | 0) + 8 | 0] | 0) == 0) {
+ i9 = FUNCTION_TABLE_iiiiii[i9 & 15](i1, i3, i4, i5, i6) | 0;
+ STACKTOP = i2;
+ return i9 | 0;
+ } else {
+ i9 = FUNCTION_TABLE_iiiiii[i9 & 15](i4, i5, i1, i3, i6) | 0;
+ STACKTOP = i2;
+ return i9 | 0;
+ }
+ return 0;
+}
+function __ZN13b2DynamicTree9MoveProxyEiRK6b2AABBRK6b2Vec2(i1, i2, i13, i9) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i13 = i13 | 0;
+ i9 = i9 | 0;
+ var i3 = 0, i4 = 0, d5 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 0.0, d10 = 0.0, d11 = 0.0, i12 = 0;
+ i4 = STACKTOP;
+ if (!((i2 | 0) > -1)) {
+ ___assert_fail(3072, 2944, 135, 3152);
+ }
+ if ((HEAP32[i1 + 12 >> 2] | 0) <= (i2 | 0)) {
+ ___assert_fail(3072, 2944, 135, 3152);
+ }
+ i3 = i1 + 4 | 0;
+ i12 = HEAP32[i3 >> 2] | 0;
+ if (!((HEAP32[i12 + (i2 * 36 | 0) + 24 >> 2] | 0) == -1)) {
+ ___assert_fail(3120, 2944, 137, 3152);
+ }
+ if (((+HEAPF32[i12 + (i2 * 36 | 0) >> 2] <= +HEAPF32[i13 >> 2] ? +HEAPF32[i12 + (i2 * 36 | 0) + 4 >> 2] <= +HEAPF32[i13 + 4 >> 2] : 0) ? +HEAPF32[i13 + 8 >> 2] <= +HEAPF32[i12 + (i2 * 36 | 0) + 8 >> 2] : 0) ? +HEAPF32[i13 + 12 >> 2] <= +HEAPF32[i12 + (i2 * 36 | 0) + 12 >> 2] : 0) {
+ i13 = 0;
+ STACKTOP = i4;
+ return i13 | 0;
+ }
+ __ZN13b2DynamicTree10RemoveLeafEi(i1, i2);
+ i12 = i13;
+ d6 = +HEAPF32[i12 >> 2];
+ d8 = +HEAPF32[i12 + 4 >> 2];
+ i13 = i13 + 8 | 0;
+ d10 = +HEAPF32[i13 >> 2];
+ d6 = d6 + -.10000000149011612;
+ d8 = d8 + -.10000000149011612;
+ d10 = d10 + .10000000149011612;
+ d5 = +HEAPF32[i13 + 4 >> 2] + .10000000149011612;
+ d11 = +HEAPF32[i9 >> 2] * 2.0;
+ d7 = +HEAPF32[i9 + 4 >> 2] * 2.0;
+ if (d11 < 0.0) {
+ d6 = d6 + d11;
+ } else {
+ d10 = d11 + d10;
+ }
+ if (d7 < 0.0) {
+ d8 = d8 + d7;
+ } else {
+ d5 = d7 + d5;
+ }
+ i13 = HEAP32[i3 >> 2] | 0;
+ d7 = +d6;
+ d11 = +d8;
+ i12 = i13 + (i2 * 36 | 0) | 0;
+ HEAPF32[i12 >> 2] = d7;
+ HEAPF32[i12 + 4 >> 2] = d11;
+ d10 = +d10;
+ d11 = +d5;
+ i13 = i13 + (i2 * 36 | 0) + 8 | 0;
+ HEAPF32[i13 >> 2] = d10;
+ HEAPF32[i13 + 4 >> 2] = d11;
+ __ZN13b2DynamicTree10InsertLeafEi(i1, i2);
+ i13 = 1;
+ STACKTOP = i4;
+ return i13 | 0;
+}
+function __ZNK9b2Simplex16GetWitnessPointsEP6b2Vec2S1_(i1, i4, i5) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, d6 = 0.0, d7 = 0.0, d8 = 0.0, i9 = 0, i10 = 0, d11 = 0.0;
+ i2 = STACKTOP;
+ i3 = HEAP32[i1 + 108 >> 2] | 0;
+ if ((i3 | 0) == 2) {
+ i9 = i1 + 24 | 0;
+ d7 = +HEAPF32[i9 >> 2];
+ i3 = i1 + 60 | 0;
+ d8 = +HEAPF32[i3 >> 2];
+ d6 = +(d7 * +HEAPF32[i1 >> 2] + d8 * +HEAPF32[i1 + 36 >> 2]);
+ d8 = +(d7 * +HEAPF32[i1 + 4 >> 2] + d8 * +HEAPF32[i1 + 40 >> 2]);
+ HEAPF32[i4 >> 2] = d6;
+ HEAPF32[i4 + 4 >> 2] = d8;
+ d8 = +HEAPF32[i9 >> 2];
+ d6 = +HEAPF32[i3 >> 2];
+ d7 = +(d8 * +HEAPF32[i1 + 8 >> 2] + d6 * +HEAPF32[i1 + 44 >> 2]);
+ d6 = +(d8 * +HEAPF32[i1 + 12 >> 2] + d6 * +HEAPF32[i1 + 48 >> 2]);
+ HEAPF32[i5 >> 2] = d7;
+ HEAPF32[i5 + 4 >> 2] = d6;
+ STACKTOP = i2;
+ return;
+ } else if ((i3 | 0) == 1) {
+ i10 = i1;
+ i9 = HEAP32[i10 + 4 >> 2] | 0;
+ i3 = i4;
+ HEAP32[i3 >> 2] = HEAP32[i10 >> 2];
+ HEAP32[i3 + 4 >> 2] = i9;
+ i3 = i1 + 8 | 0;
+ i4 = HEAP32[i3 + 4 >> 2] | 0;
+ i9 = i5;
+ HEAP32[i9 >> 2] = HEAP32[i3 >> 2];
+ HEAP32[i9 + 4 >> 2] = i4;
+ STACKTOP = i2;
+ return;
+ } else if ((i3 | 0) == 0) {
+ ___assert_fail(2712, 2672, 217, 2752);
+ } else if ((i3 | 0) == 3) {
+ d11 = +HEAPF32[i1 + 24 >> 2];
+ d6 = +HEAPF32[i1 + 60 >> 2];
+ d8 = +HEAPF32[i1 + 96 >> 2];
+ d7 = +(d11 * +HEAPF32[i1 >> 2] + d6 * +HEAPF32[i1 + 36 >> 2] + d8 * +HEAPF32[i1 + 72 >> 2]);
+ d8 = +(d11 * +HEAPF32[i1 + 4 >> 2] + d6 * +HEAPF32[i1 + 40 >> 2] + d8 * +HEAPF32[i1 + 76 >> 2]);
+ i10 = i4;
+ HEAPF32[i10 >> 2] = d7;
+ HEAPF32[i10 + 4 >> 2] = d8;
+ i10 = i5;
+ HEAPF32[i10 >> 2] = d7;
+ HEAPF32[i10 + 4 >> 2] = d8;
+ STACKTOP = i2;
+ return;
+ } else {
+ ___assert_fail(2712, 2672, 236, 2752);
+ }
+}
+function __ZNK12b2ChainShape12GetChildEdgeEP11b2EdgeShapei(i4, i3, i1) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i2 = STACKTOP;
+ if (!((i1 | 0) > -1)) {
+ ___assert_fail(6832, 6792, 89, 6872);
+ }
+ i5 = i4 + 16 | 0;
+ if (((HEAP32[i5 >> 2] | 0) + -1 | 0) <= (i1 | 0)) {
+ ___assert_fail(6832, 6792, 89, 6872);
+ }
+ HEAP32[i3 + 4 >> 2] = 1;
+ HEAPF32[i3 + 8 >> 2] = +HEAPF32[i4 + 8 >> 2];
+ i6 = i4 + 12 | 0;
+ i7 = (HEAP32[i6 >> 2] | 0) + (i1 << 3) | 0;
+ i8 = HEAP32[i7 + 4 >> 2] | 0;
+ i9 = i3 + 12 | 0;
+ HEAP32[i9 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i9 + 4 >> 2] = i8;
+ i9 = (HEAP32[i6 >> 2] | 0) + (i1 + 1 << 3) | 0;
+ i8 = HEAP32[i9 + 4 >> 2] | 0;
+ i7 = i3 + 20 | 0;
+ HEAP32[i7 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i7 + 4 >> 2] = i8;
+ i7 = i3 + 28 | 0;
+ if ((i1 | 0) > 0) {
+ i10 = (HEAP32[i6 >> 2] | 0) + (i1 + -1 << 3) | 0;
+ i8 = HEAP32[i10 + 4 >> 2] | 0;
+ i9 = i7;
+ HEAP32[i9 >> 2] = HEAP32[i10 >> 2];
+ HEAP32[i9 + 4 >> 2] = i8;
+ HEAP8[i3 + 44 | 0] = 1;
+ } else {
+ i8 = i4 + 20 | 0;
+ i9 = HEAP32[i8 + 4 >> 2] | 0;
+ i10 = i7;
+ HEAP32[i10 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i10 + 4 >> 2] = i9;
+ HEAP8[i3 + 44 | 0] = HEAP8[i4 + 36 | 0] | 0;
+ }
+ i7 = i3 + 36 | 0;
+ if (((HEAP32[i5 >> 2] | 0) + -2 | 0) > (i1 | 0)) {
+ i8 = (HEAP32[i6 >> 2] | 0) + (i1 + 2 << 3) | 0;
+ i9 = HEAP32[i8 + 4 >> 2] | 0;
+ i10 = i7;
+ HEAP32[i10 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i10 + 4 >> 2] = i9;
+ HEAP8[i3 + 45 | 0] = 1;
+ STACKTOP = i2;
+ return;
+ } else {
+ i8 = i4 + 28 | 0;
+ i9 = HEAP32[i8 + 4 >> 2] | 0;
+ i10 = i7;
+ HEAP32[i10 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i10 + 4 >> 2] = i9;
+ HEAP8[i3 + 45 | 0] = HEAP8[i4 + 37 | 0] | 0;
+ STACKTOP = i2;
+ return;
+ }
+}
+function __ZN15b2DistanceProxy3SetEPK7b2Shapei(i3, i1, i5) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i1 + 4 >> 2] | 0;
+ if ((i4 | 0) == 1) {
+ HEAP32[i3 + 16 >> 2] = i1 + 12;
+ HEAP32[i3 + 20 >> 2] = 2;
+ HEAPF32[i3 + 24 >> 2] = +HEAPF32[i1 + 8 >> 2];
+ STACKTOP = i2;
+ return;
+ } else if ((i4 | 0) == 3) {
+ if (!((i5 | 0) > -1)) {
+ ___assert_fail(2632, 2672, 53, 2704);
+ }
+ i4 = i1 + 16 | 0;
+ if ((HEAP32[i4 >> 2] | 0) <= (i5 | 0)) {
+ ___assert_fail(2632, 2672, 53, 2704);
+ }
+ i7 = i1 + 12 | 0;
+ i9 = (HEAP32[i7 >> 2] | 0) + (i5 << 3) | 0;
+ i8 = HEAP32[i9 + 4 >> 2] | 0;
+ i6 = i3;
+ HEAP32[i6 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i6 + 4 >> 2] = i8;
+ i6 = i5 + 1 | 0;
+ i5 = i3 + 8 | 0;
+ i7 = HEAP32[i7 >> 2] | 0;
+ if ((i6 | 0) < (HEAP32[i4 >> 2] | 0)) {
+ i7 = i7 + (i6 << 3) | 0;
+ i8 = HEAP32[i7 + 4 >> 2] | 0;
+ i9 = i5;
+ HEAP32[i9 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i9 + 4 >> 2] = i8;
+ } else {
+ i8 = HEAP32[i7 + 4 >> 2] | 0;
+ i9 = i5;
+ HEAP32[i9 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i9 + 4 >> 2] = i8;
+ }
+ HEAP32[i3 + 16 >> 2] = i3;
+ HEAP32[i3 + 20 >> 2] = 2;
+ HEAPF32[i3 + 24 >> 2] = +HEAPF32[i1 + 8 >> 2];
+ STACKTOP = i2;
+ return;
+ } else if ((i4 | 0) == 2) {
+ HEAP32[i3 + 16 >> 2] = i1 + 20;
+ HEAP32[i3 + 20 >> 2] = HEAP32[i1 + 148 >> 2];
+ HEAPF32[i3 + 24 >> 2] = +HEAPF32[i1 + 8 >> 2];
+ STACKTOP = i2;
+ return;
+ } else if ((i4 | 0) == 0) {
+ HEAP32[i3 + 16 >> 2] = i1 + 12;
+ HEAP32[i3 + 20 >> 2] = 1;
+ HEAPF32[i3 + 24 >> 2] = +HEAPF32[i1 + 8 >> 2];
+ STACKTOP = i2;
+ return;
+ } else {
+ ___assert_fail(2712, 2672, 81, 2704);
+ }
+}
+function __ZL16b2EdgeSeparationPK14b2PolygonShapeRK11b2TransformiS1_S4_(i2, i7, i4, i5, i6) {
+ i2 = i2 | 0;
+ i7 = i7 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ var d1 = 0.0, d3 = 0.0, d8 = 0.0, d9 = 0.0, d10 = 0.0, d11 = 0.0, i12 = 0, i13 = 0, d14 = 0.0, d15 = 0.0, d16 = 0.0, d17 = 0.0, i18 = 0, i19 = 0, i20 = 0;
+ i12 = STACKTOP;
+ i13 = HEAP32[i5 + 148 >> 2] | 0;
+ if (!((i4 | 0) > -1)) {
+ ___assert_fail(5640, 5688, 32, 5752);
+ }
+ if ((HEAP32[i2 + 148 >> 2] | 0) <= (i4 | 0)) {
+ ___assert_fail(5640, 5688, 32, 5752);
+ }
+ d11 = +HEAPF32[i7 + 12 >> 2];
+ d9 = +HEAPF32[i2 + (i4 << 3) + 84 >> 2];
+ d1 = +HEAPF32[i7 + 8 >> 2];
+ d3 = +HEAPF32[i2 + (i4 << 3) + 88 >> 2];
+ d8 = d11 * d9 - d1 * d3;
+ d3 = d9 * d1 + d11 * d3;
+ d9 = +HEAPF32[i6 + 12 >> 2];
+ d10 = +HEAPF32[i6 + 8 >> 2];
+ d16 = d9 * d8 + d10 * d3;
+ d14 = d9 * d3 - d8 * d10;
+ if ((i13 | 0) > 0) {
+ i19 = 0;
+ i20 = 0;
+ d15 = 3.4028234663852886e+38;
+ while (1) {
+ d17 = d16 * +HEAPF32[i5 + (i19 << 3) + 20 >> 2] + d14 * +HEAPF32[i5 + (i19 << 3) + 24 >> 2];
+ i18 = d17 < d15;
+ i20 = i18 ? i19 : i20;
+ i19 = i19 + 1 | 0;
+ if ((i19 | 0) == (i13 | 0)) {
+ break;
+ } else {
+ d15 = i18 ? d17 : d15;
+ }
+ }
+ } else {
+ i20 = 0;
+ }
+ d16 = +HEAPF32[i2 + (i4 << 3) + 20 >> 2];
+ d17 = +HEAPF32[i2 + (i4 << 3) + 24 >> 2];
+ d14 = +HEAPF32[i5 + (i20 << 3) + 20 >> 2];
+ d15 = +HEAPF32[i5 + (i20 << 3) + 24 >> 2];
+ STACKTOP = i12;
+ return +(d8 * (+HEAPF32[i6 >> 2] + (d9 * d14 - d10 * d15) - (+HEAPF32[i7 >> 2] + (d11 * d16 - d1 * d17))) + d3 * (d14 * d10 + d9 * d15 + +HEAPF32[i6 + 4 >> 2] - (d16 * d1 + d11 * d17 + +HEAPF32[i7 + 4 >> 2])));
+}
+function __Z4iterv() {
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, d5 = 0.0, d6 = 0.0, d7 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 48 | 0;
+ i2 = i1;
+ i3 = i1 + 32 | 0;
+ i4 = HEAP32[16] | 0;
+ if ((i4 | 0) >= (HEAP32[4] | 0)) {
+ HEAP32[16] = i4 + 1;
+ __Z7measurePl(i3, HEAP32[8] | 0);
+ d7 = +HEAPF32[i3 + 4 >> 2];
+ d6 = +(HEAP32[10] | 0) / 1.0e6 * 1.0e3;
+ d5 = +(HEAP32[12] | 0) / 1.0e6 * 1.0e3;
+ HEAPF64[tempDoublePtr >> 3] = +HEAPF32[i3 >> 2];
+ HEAP32[i2 >> 2] = HEAP32[tempDoublePtr >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[tempDoublePtr + 4 >> 2];
+ i4 = i2 + 8 | 0;
+ HEAPF64[tempDoublePtr >> 3] = d7;
+ HEAP32[i4 >> 2] = HEAP32[tempDoublePtr >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[tempDoublePtr + 4 >> 2];
+ i4 = i2 + 16 | 0;
+ HEAPF64[tempDoublePtr >> 3] = d6;
+ HEAP32[i4 >> 2] = HEAP32[tempDoublePtr >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[tempDoublePtr + 4 >> 2];
+ i4 = i2 + 24 | 0;
+ HEAPF64[tempDoublePtr >> 3] = d5;
+ HEAP32[i4 >> 2] = HEAP32[tempDoublePtr >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[tempDoublePtr + 4 >> 2];
+ _printf(96, i2 | 0) | 0;
+ _emscripten_run_script(152);
+ if ((HEAP32[18] | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ _emscripten_cancel_main_loop();
+ STACKTOP = i1;
+ return;
+ }
+ i3 = _clock() | 0;
+ __ZN7b2World4StepEfii(HEAP32[6] | 0, .01666666753590107, 3, 3);
+ i3 = (_clock() | 0) - i3 | 0;
+ i2 = HEAP32[16] | 0;
+ HEAP32[(HEAP32[8] | 0) + (i2 << 2) >> 2] = i3;
+ if ((i3 | 0) < (HEAP32[10] | 0)) {
+ HEAP32[10] = i3;
+ }
+ if ((i3 | 0) > (HEAP32[12] | 0)) {
+ HEAP32[12] = i3;
+ }
+ HEAP32[16] = i2 + 1;
+ STACKTOP = i1;
+ return;
+}
+function __ZN13b2DynamicTree12AllocateNodeEv(i5) {
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i1 = STACKTOP;
+ i2 = i5 + 16 | 0;
+ i3 = HEAP32[i2 >> 2] | 0;
+ if ((i3 | 0) == -1) {
+ i4 = i5 + 8 | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ i3 = i5 + 12 | 0;
+ if ((i6 | 0) != (HEAP32[i3 >> 2] | 0)) {
+ ___assert_fail(2912, 2944, 61, 2984);
+ }
+ i5 = i5 + 4 | 0;
+ i7 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i3 >> 2] = i6 << 1;
+ i6 = __Z7b2Alloci(i6 * 72 | 0) | 0;
+ HEAP32[i5 >> 2] = i6;
+ _memcpy(i6 | 0, i7 | 0, (HEAP32[i4 >> 2] | 0) * 36 | 0) | 0;
+ __Z6b2FreePv(i7);
+ i6 = HEAP32[i4 >> 2] | 0;
+ i7 = (HEAP32[i3 >> 2] | 0) + -1 | 0;
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) < (i7 | 0)) {
+ i7 = i6;
+ while (1) {
+ i6 = i7 + 1 | 0;
+ HEAP32[i5 + (i7 * 36 | 0) + 20 >> 2] = i6;
+ HEAP32[i5 + (i7 * 36 | 0) + 32 >> 2] = -1;
+ i7 = (HEAP32[i3 >> 2] | 0) + -1 | 0;
+ if ((i6 | 0) < (i7 | 0)) {
+ i7 = i6;
+ } else {
+ break;
+ }
+ }
+ }
+ HEAP32[i5 + (i7 * 36 | 0) + 20 >> 2] = -1;
+ HEAP32[i5 + (((HEAP32[i3 >> 2] | 0) + -1 | 0) * 36 | 0) + 32 >> 2] = -1;
+ i3 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i2 >> 2] = i3;
+ } else {
+ i4 = i5 + 8 | 0;
+ i5 = HEAP32[i5 + 4 >> 2] | 0;
+ }
+ i7 = i5 + (i3 * 36 | 0) + 20 | 0;
+ HEAP32[i2 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i7 >> 2] = -1;
+ HEAP32[i5 + (i3 * 36 | 0) + 24 >> 2] = -1;
+ HEAP32[i5 + (i3 * 36 | 0) + 28 >> 2] = -1;
+ HEAP32[i5 + (i3 * 36 | 0) + 32 >> 2] = 0;
+ HEAP32[i5 + (i3 * 36 | 0) + 16 >> 2] = 0;
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + 1;
+ STACKTOP = i1;
+ return i3 | 0;
+}
+function __ZN9b2Fixture6CreateEP16b2BlockAllocatorP6b2BodyPK12b2FixtureDef(i1, i5, i4, i3) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i6 = 0, i7 = 0, d8 = 0.0;
+ i2 = STACKTOP;
+ HEAP32[i1 + 40 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAPF32[i1 + 16 >> 2] = +HEAPF32[i3 + 8 >> 2];
+ HEAPF32[i1 + 20 >> 2] = +HEAPF32[i3 + 12 >> 2];
+ HEAP32[i1 + 8 >> 2] = i4;
+ HEAP32[i1 + 4 >> 2] = 0;
+ i4 = i1 + 32 | 0;
+ i6 = i3 + 22 | 0;
+ HEAP16[i4 + 0 >> 1] = HEAP16[i6 + 0 >> 1] | 0;
+ HEAP16[i4 + 2 >> 1] = HEAP16[i6 + 2 >> 1] | 0;
+ HEAP16[i4 + 4 >> 1] = HEAP16[i6 + 4 >> 1] | 0;
+ HEAP8[i1 + 38 | 0] = HEAP8[i3 + 20 | 0] | 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ i4 = FUNCTION_TABLE_iii[HEAP32[(HEAP32[i4 >> 2] | 0) + 8 >> 2] & 3](i4, i5) | 0;
+ HEAP32[i1 + 12 >> 2] = i4;
+ i4 = FUNCTION_TABLE_ii[HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] & 3](i4) | 0;
+ i6 = __ZN16b2BlockAllocator8AllocateEi(i5, i4 * 28 | 0) | 0;
+ i5 = i1 + 24 | 0;
+ HEAP32[i5 >> 2] = i6;
+ if ((i4 | 0) > 0) {
+ i7 = 0;
+ } else {
+ i7 = i1 + 28 | 0;
+ HEAP32[i7 >> 2] = 0;
+ i7 = i3 + 16 | 0;
+ d8 = +HEAPF32[i7 >> 2];
+ HEAPF32[i1 >> 2] = d8;
+ STACKTOP = i2;
+ return;
+ }
+ do {
+ HEAP32[i6 + (i7 * 28 | 0) + 16 >> 2] = 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i6 + (i7 * 28 | 0) + 24 >> 2] = -1;
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) != (i4 | 0));
+ i7 = i1 + 28 | 0;
+ HEAP32[i7 >> 2] = 0;
+ i7 = i3 + 16 | 0;
+ d8 = +HEAPF32[i7 >> 2];
+ HEAPF32[i1 >> 2] = d8;
+ STACKTOP = i2;
+ return;
+}
+function __Z19b2ClipSegmentToLineP12b2ClipVertexPKS_RK6b2Vec2fi(i4, i1, i5, d9, i2) {
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ d9 = +d9;
+ i2 = i2 | 0;
+ var i3 = 0, i6 = 0, d7 = 0.0, i8 = 0, i10 = 0, d11 = 0.0, d12 = 0.0, i13 = 0;
+ i3 = STACKTOP;
+ d12 = +HEAPF32[i5 >> 2];
+ d11 = +HEAPF32[i5 + 4 >> 2];
+ i5 = i1 + 4 | 0;
+ d7 = d12 * +HEAPF32[i1 >> 2] + d11 * +HEAPF32[i5 >> 2] - d9;
+ i6 = i1 + 12 | 0;
+ i8 = i1 + 16 | 0;
+ d9 = d12 * +HEAPF32[i6 >> 2] + d11 * +HEAPF32[i8 >> 2] - d9;
+ if (!(d7 <= 0.0)) {
+ i10 = 0;
+ } else {
+ HEAP32[i4 + 0 >> 2] = HEAP32[i1 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i1 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i1 + 8 >> 2];
+ i10 = 1;
+ }
+ if (d9 <= 0.0) {
+ i13 = i10 + 1 | 0;
+ i10 = i4 + (i10 * 12 | 0) | 0;
+ HEAP32[i10 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
+ HEAP32[i10 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
+ HEAP32[i10 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ i10 = i13;
+ }
+ if (!(d7 * d9 < 0.0)) {
+ i13 = i10;
+ STACKTOP = i3;
+ return i13 | 0;
+ }
+ d9 = d7 / (d7 - d9);
+ d11 = +HEAPF32[i1 >> 2];
+ d12 = +HEAPF32[i5 >> 2];
+ d11 = +(d11 + d9 * (+HEAPF32[i6 >> 2] - d11));
+ d12 = +(d12 + d9 * (+HEAPF32[i8 >> 2] - d12));
+ i13 = i4 + (i10 * 12 | 0) | 0;
+ HEAPF32[i13 >> 2] = d11;
+ HEAPF32[i13 + 4 >> 2] = d12;
+ i13 = i4 + (i10 * 12 | 0) + 8 | 0;
+ HEAP8[i13] = i2;
+ HEAP8[i13 + 1 | 0] = HEAP8[i1 + 9 | 0] | 0;
+ HEAP8[i13 + 2 | 0] = 0;
+ HEAP8[i13 + 3 | 0] = 1;
+ i13 = i10 + 1 | 0;
+ STACKTOP = i3;
+ return i13 | 0;
+}
+function __Z16b2CollideCirclesP10b2ManifoldPK13b2CircleShapeRK11b2TransformS3_S6_(i1, i7, i8, i6, i9) {
+ i1 = i1 | 0;
+ i7 = i7 | 0;
+ i8 = i8 | 0;
+ i6 = i6 | 0;
+ i9 = i9 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, d10 = 0.0, d11 = 0.0, d12 = 0.0, d13 = 0.0, d14 = 0.0, d15 = 0.0, d16 = 0.0, d17 = 0.0, d18 = 0.0;
+ i2 = STACKTOP;
+ i4 = i1 + 60 | 0;
+ HEAP32[i4 >> 2] = 0;
+ i3 = i7 + 12 | 0;
+ d10 = +HEAPF32[i8 + 12 >> 2];
+ d14 = +HEAPF32[i3 >> 2];
+ d13 = +HEAPF32[i8 + 8 >> 2];
+ d11 = +HEAPF32[i7 + 16 >> 2];
+ i5 = i6 + 12 | 0;
+ d16 = +HEAPF32[i9 + 12 >> 2];
+ d18 = +HEAPF32[i5 >> 2];
+ d17 = +HEAPF32[i9 + 8 >> 2];
+ d15 = +HEAPF32[i6 + 16 >> 2];
+ d12 = +HEAPF32[i9 >> 2] + (d16 * d18 - d17 * d15) - (+HEAPF32[i8 >> 2] + (d10 * d14 - d13 * d11));
+ d11 = d18 * d17 + d16 * d15 + +HEAPF32[i9 + 4 >> 2] - (d14 * d13 + d10 * d11 + +HEAPF32[i8 + 4 >> 2]);
+ d10 = +HEAPF32[i7 + 8 >> 2] + +HEAPF32[i6 + 8 >> 2];
+ if (d12 * d12 + d11 * d11 > d10 * d10) {
+ STACKTOP = i2;
+ return;
+ }
+ HEAP32[i1 + 56 >> 2] = 0;
+ i9 = i3;
+ i8 = HEAP32[i9 + 4 >> 2] | 0;
+ i7 = i1 + 48 | 0;
+ HEAP32[i7 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i7 + 4 >> 2] = i8;
+ HEAPF32[i1 + 40 >> 2] = 0.0;
+ HEAPF32[i1 + 44 >> 2] = 0.0;
+ HEAP32[i4 >> 2] = 1;
+ i7 = i5;
+ i8 = HEAP32[i7 + 4 >> 2] | 0;
+ i9 = i1;
+ HEAP32[i9 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i9 + 4 >> 2] = i8;
+ HEAP32[i1 + 16 >> 2] = 0;
+ STACKTOP = i2;
+ return;
+}
+function __ZNK14b2PolygonShape11ComputeAABBEP6b2AABBRK11b2Transformi(i1, i2, i7, i3) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i7 = i7 | 0;
+ i3 = i3 | 0;
+ var d4 = 0.0, d5 = 0.0, d6 = 0.0, d8 = 0.0, d9 = 0.0, d10 = 0.0, d11 = 0.0, d12 = 0.0, i13 = 0, d14 = 0.0, d15 = 0.0, d16 = 0.0;
+ i3 = STACKTOP;
+ d4 = +HEAPF32[i7 + 12 >> 2];
+ d15 = +HEAPF32[i1 + 20 >> 2];
+ d5 = +HEAPF32[i7 + 8 >> 2];
+ d12 = +HEAPF32[i1 + 24 >> 2];
+ d6 = +HEAPF32[i7 >> 2];
+ d9 = d6 + (d4 * d15 - d5 * d12);
+ d8 = +HEAPF32[i7 + 4 >> 2];
+ d12 = d15 * d5 + d4 * d12 + d8;
+ i7 = HEAP32[i1 + 148 >> 2] | 0;
+ if ((i7 | 0) > 1) {
+ d10 = d9;
+ d11 = d12;
+ i13 = 1;
+ do {
+ d16 = +HEAPF32[i1 + (i13 << 3) + 20 >> 2];
+ d14 = +HEAPF32[i1 + (i13 << 3) + 24 >> 2];
+ d15 = d6 + (d4 * d16 - d5 * d14);
+ d14 = d16 * d5 + d4 * d14 + d8;
+ d10 = d10 < d15 ? d10 : d15;
+ d11 = d11 < d14 ? d11 : d14;
+ d9 = d9 > d15 ? d9 : d15;
+ d12 = d12 > d14 ? d12 : d14;
+ i13 = i13 + 1 | 0;
+ } while ((i13 | 0) < (i7 | 0));
+ } else {
+ d11 = d12;
+ d10 = d9;
+ }
+ d16 = +HEAPF32[i1 + 8 >> 2];
+ d14 = +(d10 - d16);
+ d15 = +(d11 - d16);
+ i13 = i2;
+ HEAPF32[i13 >> 2] = d14;
+ HEAPF32[i13 + 4 >> 2] = d15;
+ d15 = +(d9 + d16);
+ d16 = +(d12 + d16);
+ i13 = i2 + 8 | 0;
+ HEAPF32[i13 >> 2] = d15;
+ HEAPF32[i13 + 4 >> 2] = d16;
+ STACKTOP = i3;
+ return;
+}
+function __ZNK10__cxxabiv120__si_class_type_info16search_above_dstEPNS_19__dynamic_cast_infoEPKvS4_ib(i5, i1, i4, i6, i3, i7) {
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ i7 = i7 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((i5 | 0) != (HEAP32[i1 + 8 >> 2] | 0)) {
+ i5 = HEAP32[i5 + 8 >> 2] | 0;
+ FUNCTION_TABLE_viiiiii[HEAP32[(HEAP32[i5 >> 2] | 0) + 20 >> 2] & 3](i5, i1, i4, i6, i3, i7);
+ STACKTOP = i2;
+ return;
+ }
+ HEAP8[i1 + 53 | 0] = 1;
+ if ((HEAP32[i1 + 4 >> 2] | 0) != (i6 | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ HEAP8[i1 + 52 | 0] = 1;
+ i5 = i1 + 16 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) == 0) {
+ HEAP32[i5 >> 2] = i4;
+ HEAP32[i1 + 24 >> 2] = i3;
+ HEAP32[i1 + 36 >> 2] = 1;
+ if (!((HEAP32[i1 + 48 >> 2] | 0) == 1 & (i3 | 0) == 1)) {
+ STACKTOP = i2;
+ return;
+ }
+ HEAP8[i1 + 54 | 0] = 1;
+ STACKTOP = i2;
+ return;
+ }
+ if ((i6 | 0) != (i4 | 0)) {
+ i7 = i1 + 36 | 0;
+ HEAP32[i7 >> 2] = (HEAP32[i7 >> 2] | 0) + 1;
+ HEAP8[i1 + 54 | 0] = 1;
+ STACKTOP = i2;
+ return;
+ }
+ i4 = i1 + 24 | 0;
+ i5 = HEAP32[i4 >> 2] | 0;
+ if ((i5 | 0) == 2) {
+ HEAP32[i4 >> 2] = i3;
+ } else {
+ i3 = i5;
+ }
+ if (!((HEAP32[i1 + 48 >> 2] | 0) == 1 & (i3 | 0) == 1)) {
+ STACKTOP = i2;
+ return;
+ }
+ HEAP8[i1 + 54 | 0] = 1;
+ STACKTOP = i2;
+ return;
+}
+function __ZN6b2Body13CreateFixtureEPK12b2FixtureDef(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0;
+ i3 = STACKTOP;
+ i2 = i1 + 88 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ if ((HEAP32[i4 + 102868 >> 2] & 2 | 0) != 0) {
+ ___assert_fail(1776, 1520, 153, 1808);
+ }
+ i6 = __ZN16b2BlockAllocator8AllocateEi(i4, 44) | 0;
+ if ((i6 | 0) == 0) {
+ i6 = 0;
+ } else {
+ __ZN9b2FixtureC2Ev(i6);
+ }
+ __ZN9b2Fixture6CreateEP16b2BlockAllocatorP6b2BodyPK12b2FixtureDef(i6, i4, i1, i5);
+ if (!((HEAP16[i1 + 4 >> 1] & 32) == 0)) {
+ __ZN9b2Fixture13CreateProxiesEP12b2BroadPhaseRK11b2Transform(i6, (HEAP32[i2 >> 2] | 0) + 102872 | 0, i1 + 12 | 0);
+ }
+ i5 = i1 + 100 | 0;
+ HEAP32[i6 + 4 >> 2] = HEAP32[i5 >> 2];
+ HEAP32[i5 >> 2] = i6;
+ i5 = i1 + 104 | 0;
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + 1;
+ HEAP32[i6 + 8 >> 2] = i1;
+ if (!(+HEAPF32[i6 >> 2] > 0.0)) {
+ i5 = HEAP32[i2 >> 2] | 0;
+ i5 = i5 + 102868 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i4 = i4 | 1;
+ HEAP32[i5 >> 2] = i4;
+ STACKTOP = i3;
+ return i6 | 0;
+ }
+ __ZN6b2Body13ResetMassDataEv(i1);
+ i5 = HEAP32[i2 >> 2] | 0;
+ i5 = i5 + 102868 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i4 = i4 | 1;
+ HEAP32[i5 >> 2] = i4;
+ STACKTOP = i3;
+ return i6 | 0;
+}
+function __Z13b2TestOverlapPK7b2ShapeiS1_iRK11b2TransformS4_(i6, i5, i4, i3, i2, i1) {
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i8 = STACKTOP;
+ STACKTOP = STACKTOP + 128 | 0;
+ i9 = i8 + 36 | 0;
+ i10 = i8 + 24 | 0;
+ i7 = i8;
+ HEAP32[i9 + 16 >> 2] = 0;
+ HEAP32[i9 + 20 >> 2] = 0;
+ HEAPF32[i9 + 24 >> 2] = 0.0;
+ HEAP32[i9 + 44 >> 2] = 0;
+ HEAP32[i9 + 48 >> 2] = 0;
+ HEAPF32[i9 + 52 >> 2] = 0.0;
+ __ZN15b2DistanceProxy3SetEPK7b2Shapei(i9, i6, i5);
+ __ZN15b2DistanceProxy3SetEPK7b2Shapei(i9 + 28 | 0, i4, i3);
+ i6 = i9 + 56 | 0;
+ HEAP32[i6 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ HEAP32[i6 + 12 >> 2] = HEAP32[i2 + 12 >> 2];
+ i6 = i9 + 72 | 0;
+ HEAP32[i6 + 0 >> 2] = HEAP32[i1 + 0 >> 2];
+ HEAP32[i6 + 4 >> 2] = HEAP32[i1 + 4 >> 2];
+ HEAP32[i6 + 8 >> 2] = HEAP32[i1 + 8 >> 2];
+ HEAP32[i6 + 12 >> 2] = HEAP32[i1 + 12 >> 2];
+ HEAP8[i9 + 88 | 0] = 1;
+ HEAP16[i10 + 4 >> 1] = 0;
+ __Z10b2DistanceP16b2DistanceOutputP14b2SimplexCachePK15b2DistanceInput(i7, i10, i9);
+ STACKTOP = i8;
+ return +HEAPF32[i7 + 16 >> 2] < 11920928955078125.0e-22 | 0;
+}
+function __ZNK10__cxxabiv117__class_type_info16search_above_dstEPNS_19__dynamic_cast_infoEPKvS4_ib(i6, i1, i4, i5, i2, i3) {
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i3 = STACKTOP;
+ if ((HEAP32[i1 + 8 >> 2] | 0) != (i6 | 0)) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP8[i1 + 53 | 0] = 1;
+ if ((HEAP32[i1 + 4 >> 2] | 0) != (i5 | 0)) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP8[i1 + 52 | 0] = 1;
+ i5 = i1 + 16 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) == 0) {
+ HEAP32[i5 >> 2] = i4;
+ HEAP32[i1 + 24 >> 2] = i2;
+ HEAP32[i1 + 36 >> 2] = 1;
+ if (!((HEAP32[i1 + 48 >> 2] | 0) == 1 & (i2 | 0) == 1)) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP8[i1 + 54 | 0] = 1;
+ STACKTOP = i3;
+ return;
+ }
+ if ((i6 | 0) != (i4 | 0)) {
+ i6 = i1 + 36 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + 1;
+ HEAP8[i1 + 54 | 0] = 1;
+ STACKTOP = i3;
+ return;
+ }
+ i4 = i1 + 24 | 0;
+ i5 = HEAP32[i4 >> 2] | 0;
+ if ((i5 | 0) == 2) {
+ HEAP32[i4 >> 2] = i2;
+ } else {
+ i2 = i5;
+ }
+ if (!((HEAP32[i1 + 48 >> 2] | 0) == 1 & (i2 | 0) == 1)) {
+ STACKTOP = i3;
+ return;
+ }
+ HEAP8[i1 + 54 | 0] = 1;
+ STACKTOP = i3;
+ return;
+}
+function __ZNK11b2EdgeShape5CloneEP16b2BlockAllocator(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ i3 = __ZN16b2BlockAllocator8AllocateEi(i3, 48) | 0;
+ if ((i3 | 0) == 0) {
+ i3 = 0;
+ } else {
+ HEAP32[i3 >> 2] = 240;
+ HEAP32[i3 + 4 >> 2] = 1;
+ HEAPF32[i3 + 8 >> 2] = .009999999776482582;
+ i4 = i3 + 28 | 0;
+ HEAP32[i4 + 0 >> 2] = 0;
+ HEAP32[i4 + 4 >> 2] = 0;
+ HEAP32[i4 + 8 >> 2] = 0;
+ HEAP32[i4 + 12 >> 2] = 0;
+ HEAP16[i4 + 16 >> 1] = 0;
+ }
+ i6 = i1 + 4 | 0;
+ i5 = HEAP32[i6 + 4 >> 2] | 0;
+ i4 = i3 + 4 | 0;
+ HEAP32[i4 >> 2] = HEAP32[i6 >> 2];
+ HEAP32[i4 + 4 >> 2] = i5;
+ i4 = i3 + 12 | 0;
+ i1 = i1 + 12 | 0;
+ HEAP32[i4 + 0 >> 2] = HEAP32[i1 + 0 >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[i1 + 4 >> 2];
+ HEAP32[i4 + 8 >> 2] = HEAP32[i1 + 8 >> 2];
+ HEAP32[i4 + 12 >> 2] = HEAP32[i1 + 12 >> 2];
+ HEAP32[i4 + 16 >> 2] = HEAP32[i1 + 16 >> 2];
+ HEAP32[i4 + 20 >> 2] = HEAP32[i1 + 20 >> 2];
+ HEAP32[i4 + 24 >> 2] = HEAP32[i1 + 24 >> 2];
+ HEAP32[i4 + 28 >> 2] = HEAP32[i1 + 28 >> 2];
+ HEAP16[i4 + 32 >> 1] = HEAP16[i1 + 32 >> 1] | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function __ZN7b2WorldC2ERK6b2Vec2(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i3 = STACKTOP;
+ __ZN16b2BlockAllocatorC2Ev(i1);
+ __ZN16b2StackAllocatorC2Ev(i1 + 68 | 0);
+ __ZN16b2ContactManagerC2Ev(i1 + 102872 | 0);
+ i6 = i1 + 102968 | 0;
+ HEAP32[i1 + 102980 >> 2] = 0;
+ HEAP32[i1 + 102984 >> 2] = 0;
+ i4 = i1 + 102952 | 0;
+ i5 = i1 + 102992 | 0;
+ HEAP32[i4 + 0 >> 2] = 0;
+ HEAP32[i4 + 4 >> 2] = 0;
+ HEAP32[i4 + 8 >> 2] = 0;
+ HEAP32[i4 + 12 >> 2] = 0;
+ HEAP8[i5] = 1;
+ HEAP8[i1 + 102993 | 0] = 1;
+ HEAP8[i1 + 102994 | 0] = 0;
+ HEAP8[i1 + 102995 | 0] = 1;
+ HEAP8[i1 + 102976 | 0] = 1;
+ i5 = i2;
+ i4 = HEAP32[i5 + 4 >> 2] | 0;
+ i2 = i6;
+ HEAP32[i2 >> 2] = HEAP32[i5 >> 2];
+ HEAP32[i2 + 4 >> 2] = i4;
+ HEAP32[i1 + 102868 >> 2] = 4;
+ HEAPF32[i1 + 102988 >> 2] = 0.0;
+ HEAP32[i1 + 102948 >> 2] = i1;
+ i2 = i1 + 102996 | 0;
+ HEAP32[i2 + 0 >> 2] = 0;
+ HEAP32[i2 + 4 >> 2] = 0;
+ HEAP32[i2 + 8 >> 2] = 0;
+ HEAP32[i2 + 12 >> 2] = 0;
+ HEAP32[i2 + 16 >> 2] = 0;
+ HEAP32[i2 + 20 >> 2] = 0;
+ HEAP32[i2 + 24 >> 2] = 0;
+ HEAP32[i2 + 28 >> 2] = 0;
+ STACKTOP = i3;
+ return;
+}
+function __ZNK10__cxxabiv117__class_type_info16search_below_dstEPNS_19__dynamic_cast_infoEPKvib(i6, i3, i4, i1, i2) {
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i5 = 0;
+ i2 = STACKTOP;
+ if ((HEAP32[i3 + 8 >> 2] | 0) == (i6 | 0)) {
+ if ((HEAP32[i3 + 4 >> 2] | 0) != (i4 | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ i3 = i3 + 28 | 0;
+ if ((HEAP32[i3 >> 2] | 0) == 1) {
+ STACKTOP = i2;
+ return;
+ }
+ HEAP32[i3 >> 2] = i1;
+ STACKTOP = i2;
+ return;
+ }
+ if ((HEAP32[i3 >> 2] | 0) != (i6 | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ if ((HEAP32[i3 + 16 >> 2] | 0) != (i4 | 0) ? (i5 = i3 + 20 | 0, (HEAP32[i5 >> 2] | 0) != (i4 | 0)) : 0) {
+ HEAP32[i3 + 32 >> 2] = i1;
+ HEAP32[i5 >> 2] = i4;
+ i6 = i3 + 40 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + 1;
+ if ((HEAP32[i3 + 36 >> 2] | 0) == 1 ? (HEAP32[i3 + 24 >> 2] | 0) == 2 : 0) {
+ HEAP8[i3 + 54 | 0] = 1;
+ }
+ HEAP32[i3 + 44 >> 2] = 4;
+ STACKTOP = i2;
+ return;
+ }
+ if ((i1 | 0) != 1) {
+ STACKTOP = i2;
+ return;
+ }
+ HEAP32[i3 + 32 >> 2] = 1;
+ STACKTOP = i2;
+ return;
+}
+function __ZN9b2Contact7DestroyEPS_P16b2BlockAllocator(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i3 = STACKTOP;
+ if ((HEAP8[4200] | 0) == 0) {
+ ___assert_fail(4352, 4256, 103, 4376);
+ }
+ i4 = HEAP32[i1 + 48 >> 2] | 0;
+ if ((HEAP32[i1 + 124 >> 2] | 0) > 0) {
+ i7 = HEAP32[i4 + 8 >> 2] | 0;
+ i6 = i7 + 4 | 0;
+ i5 = HEAPU16[i6 >> 1] | 0;
+ if ((i5 & 2 | 0) == 0) {
+ HEAP16[i6 >> 1] = i5 | 2;
+ HEAPF32[i7 + 144 >> 2] = 0.0;
+ }
+ i7 = HEAP32[i1 + 52 >> 2] | 0;
+ i6 = HEAP32[i7 + 8 >> 2] | 0;
+ i5 = i6 + 4 | 0;
+ i8 = HEAPU16[i5 >> 1] | 0;
+ if ((i8 & 2 | 0) == 0) {
+ HEAP16[i5 >> 1] = i8 | 2;
+ HEAPF32[i6 + 144 >> 2] = 0.0;
+ }
+ } else {
+ i7 = HEAP32[i1 + 52 >> 2] | 0;
+ }
+ i4 = HEAP32[(HEAP32[i4 + 12 >> 2] | 0) + 4 >> 2] | 0;
+ i5 = HEAP32[(HEAP32[i7 + 12 >> 2] | 0) + 4 >> 2] | 0;
+ if ((i4 | 0) > -1 & (i5 | 0) < 4) {
+ FUNCTION_TABLE_vii[HEAP32[4008 + (i4 * 48 | 0) + (i5 * 12 | 0) + 4 >> 2] & 15](i1, i2);
+ STACKTOP = i3;
+ return;
+ } else {
+ ___assert_fail(4384, 4256, 114, 4376);
+ }
+}
+function __ZN9b2Fixture13CreateProxiesEP12b2BroadPhaseRK11b2Transform(i5, i4, i1) {
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0;
+ i2 = STACKTOP;
+ i3 = i5 + 28 | 0;
+ if ((HEAP32[i3 >> 2] | 0) != 0) {
+ ___assert_fail(2088, 2112, 124, 2144);
+ }
+ i6 = i5 + 12 | 0;
+ i8 = HEAP32[i6 >> 2] | 0;
+ i8 = FUNCTION_TABLE_ii[HEAP32[(HEAP32[i8 >> 2] | 0) + 12 >> 2] & 3](i8) | 0;
+ HEAP32[i3 >> 2] = i8;
+ if ((i8 | 0) <= 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i7 = i5 + 24 | 0;
+ i8 = 0;
+ do {
+ i9 = HEAP32[i7 >> 2] | 0;
+ i10 = i9 + (i8 * 28 | 0) | 0;
+ i11 = HEAP32[i6 >> 2] | 0;
+ FUNCTION_TABLE_viiii[HEAP32[(HEAP32[i11 >> 2] | 0) + 24 >> 2] & 15](i11, i10, i1, i8);
+ HEAP32[i9 + (i8 * 28 | 0) + 24 >> 2] = __ZN12b2BroadPhase11CreateProxyERK6b2AABBPv(i4, i10, i10) | 0;
+ HEAP32[i9 + (i8 * 28 | 0) + 16 >> 2] = i5;
+ HEAP32[i9 + (i8 * 28 | 0) + 20 >> 2] = i8;
+ i8 = i8 + 1 | 0;
+ } while ((i8 | 0) < (HEAP32[i3 >> 2] | 0));
+ STACKTOP = i2;
+ return;
+}
+function __ZNK10__cxxabiv117__class_type_info9can_catchEPKNS_16__shim_type_infoERPv(i1, i5, i4) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i3 = i2;
+ if ((i1 | 0) == (i5 | 0)) {
+ i7 = 1;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ if ((i5 | 0) == 0) {
+ i7 = 0;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ i5 = ___dynamic_cast(i5, 6952, 7008, 0) | 0;
+ if ((i5 | 0) == 0) {
+ i7 = 0;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ i7 = i3 + 0 | 0;
+ i6 = i7 + 56 | 0;
+ do {
+ HEAP32[i7 >> 2] = 0;
+ i7 = i7 + 4 | 0;
+ } while ((i7 | 0) < (i6 | 0));
+ HEAP32[i3 >> 2] = i5;
+ HEAP32[i3 + 8 >> 2] = i1;
+ HEAP32[i3 + 12 >> 2] = -1;
+ HEAP32[i3 + 48 >> 2] = 1;
+ FUNCTION_TABLE_viiii[HEAP32[(HEAP32[i5 >> 2] | 0) + 28 >> 2] & 15](i5, i3, HEAP32[i4 >> 2] | 0, 1);
+ if ((HEAP32[i3 + 24 >> 2] | 0) != 1) {
+ i7 = 0;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ HEAP32[i4 >> 2] = HEAP32[i3 + 16 >> 2];
+ i7 = 1;
+ STACKTOP = i2;
+ return i7 | 0;
+}
+function __ZN8b2IslandC2EiiiP16b2StackAllocatorP17b2ContactListener(i1, i4, i3, i2, i5, i6) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ var i7 = 0, i8 = 0;
+ i7 = STACKTOP;
+ i8 = i1 + 40 | 0;
+ HEAP32[i8 >> 2] = i4;
+ HEAP32[i1 + 44 >> 2] = i3;
+ HEAP32[i1 + 48 >> 2] = i2;
+ HEAP32[i1 + 28 >> 2] = 0;
+ HEAP32[i1 + 36 >> 2] = 0;
+ HEAP32[i1 + 32 >> 2] = 0;
+ HEAP32[i1 >> 2] = i5;
+ HEAP32[i1 + 4 >> 2] = i6;
+ HEAP32[i1 + 8 >> 2] = __ZN16b2StackAllocator8AllocateEi(i5, i4 << 2) | 0;
+ HEAP32[i1 + 12 >> 2] = __ZN16b2StackAllocator8AllocateEi(HEAP32[i1 >> 2] | 0, i3 << 2) | 0;
+ HEAP32[i1 + 16 >> 2] = __ZN16b2StackAllocator8AllocateEi(HEAP32[i1 >> 2] | 0, i2 << 2) | 0;
+ HEAP32[i1 + 24 >> 2] = __ZN16b2StackAllocator8AllocateEi(HEAP32[i1 >> 2] | 0, (HEAP32[i8 >> 2] | 0) * 12 | 0) | 0;
+ HEAP32[i1 + 20 >> 2] = __ZN16b2StackAllocator8AllocateEi(HEAP32[i1 >> 2] | 0, (HEAP32[i8 >> 2] | 0) * 12 | 0) | 0;
+ STACKTOP = i7;
+ return;
+}
+function __ZNK11b2EdgeShape11ComputeAABBEP6b2AABBRK11b2Transformi(i8, i1, i10, i2) {
+ i8 = i8 | 0;
+ i1 = i1 | 0;
+ i10 = i10 | 0;
+ i2 = i2 | 0;
+ var d3 = 0.0, d4 = 0.0, d5 = 0.0, d6 = 0.0, d7 = 0.0, d9 = 0.0, d11 = 0.0, d12 = 0.0;
+ i2 = STACKTOP;
+ d7 = +HEAPF32[i10 + 12 >> 2];
+ d9 = +HEAPF32[i8 + 12 >> 2];
+ d11 = +HEAPF32[i10 + 8 >> 2];
+ d3 = +HEAPF32[i8 + 16 >> 2];
+ d6 = +HEAPF32[i10 >> 2];
+ d5 = d6 + (d7 * d9 - d11 * d3);
+ d12 = +HEAPF32[i10 + 4 >> 2];
+ d3 = d9 * d11 + d7 * d3 + d12;
+ d9 = +HEAPF32[i8 + 20 >> 2];
+ d4 = +HEAPF32[i8 + 24 >> 2];
+ d6 = d6 + (d7 * d9 - d11 * d4);
+ d4 = d12 + (d11 * d9 + d7 * d4);
+ d7 = +HEAPF32[i8 + 8 >> 2];
+ d9 = +((d5 < d6 ? d5 : d6) - d7);
+ d12 = +((d3 < d4 ? d3 : d4) - d7);
+ i10 = i1;
+ HEAPF32[i10 >> 2] = d9;
+ HEAPF32[i10 + 4 >> 2] = d12;
+ d5 = +(d7 + (d5 > d6 ? d5 : d6));
+ d12 = +(d7 + (d3 > d4 ? d3 : d4));
+ i10 = i1 + 8 | 0;
+ HEAPF32[i10 >> 2] = d5;
+ HEAPF32[i10 + 4 >> 2] = d12;
+ STACKTOP = i2;
+ return;
+}
+function __ZNK14b2PolygonShape9TestPointERK11b2TransformRK6b2Vec2(i2, i3, i6) {
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, d4 = 0.0, d5 = 0.0, i7 = 0, d8 = 0.0, d9 = 0.0, d10 = 0.0;
+ i1 = STACKTOP;
+ d8 = +HEAPF32[i6 >> 2] - +HEAPF32[i3 >> 2];
+ d9 = +HEAPF32[i6 + 4 >> 2] - +HEAPF32[i3 + 4 >> 2];
+ d10 = +HEAPF32[i3 + 12 >> 2];
+ d5 = +HEAPF32[i3 + 8 >> 2];
+ d4 = d8 * d10 + d9 * d5;
+ d5 = d10 * d9 - d8 * d5;
+ i3 = HEAP32[i2 + 148 >> 2] | 0;
+ if ((i3 | 0) > 0) {
+ i6 = 0;
+ } else {
+ i7 = 1;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ while (1) {
+ i7 = i6 + 1 | 0;
+ if ((d4 - +HEAPF32[i2 + (i6 << 3) + 20 >> 2]) * +HEAPF32[i2 + (i6 << 3) + 84 >> 2] + (d5 - +HEAPF32[i2 + (i6 << 3) + 24 >> 2]) * +HEAPF32[i2 + (i6 << 3) + 88 >> 2] > 0.0) {
+ i3 = 0;
+ i2 = 4;
+ break;
+ }
+ if ((i7 | 0) < (i3 | 0)) {
+ i6 = i7;
+ } else {
+ i3 = 1;
+ i2 = 4;
+ break;
+ }
+ }
+ if ((i2 | 0) == 4) {
+ STACKTOP = i1;
+ return i3 | 0;
+ }
+ return 0;
+}
+function __ZN16b2StackAllocator8AllocateEi(i4, i5) {
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ i3 = i4 + 102796 | 0;
+ i6 = HEAP32[i3 >> 2] | 0;
+ if ((i6 | 0) >= 32) {
+ ___assert_fail(3896, 3808, 38, 3936);
+ }
+ i1 = i4 + (i6 * 12 | 0) + 102412 | 0;
+ HEAP32[i4 + (i6 * 12 | 0) + 102416 >> 2] = i5;
+ i7 = i4 + 102400 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if ((i8 + i5 | 0) > 102400) {
+ HEAP32[i1 >> 2] = __Z7b2Alloci(i5) | 0;
+ HEAP8[i4 + (i6 * 12 | 0) + 102420 | 0] = 1;
+ } else {
+ HEAP32[i1 >> 2] = i4 + i8;
+ HEAP8[i4 + (i6 * 12 | 0) + 102420 | 0] = 0;
+ HEAP32[i7 >> 2] = (HEAP32[i7 >> 2] | 0) + i5;
+ }
+ i6 = i4 + 102404 | 0;
+ i5 = (HEAP32[i6 >> 2] | 0) + i5 | 0;
+ HEAP32[i6 >> 2] = i5;
+ i4 = i4 + 102408 | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = (i6 | 0) > (i5 | 0) ? i6 : i5;
+ HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + 1;
+ STACKTOP = i2;
+ return HEAP32[i1 >> 2] | 0;
+}
+function __ZN12b2BroadPhase13QueryCallbackEi(i5, i1) {
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ i4 = i5 + 56 | 0;
+ i7 = HEAP32[i4 >> 2] | 0;
+ if ((i7 | 0) == (i1 | 0)) {
+ STACKTOP = i2;
+ return 1;
+ }
+ i3 = i5 + 52 | 0;
+ i6 = HEAP32[i3 >> 2] | 0;
+ i8 = i5 + 48 | 0;
+ i5 = i5 + 44 | 0;
+ if ((i6 | 0) == (HEAP32[i8 >> 2] | 0)) {
+ i7 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i8 >> 2] = i6 << 1;
+ i6 = __Z7b2Alloci(i6 * 24 | 0) | 0;
+ HEAP32[i5 >> 2] = i6;
+ _memcpy(i6 | 0, i7 | 0, (HEAP32[i3 >> 2] | 0) * 12 | 0) | 0;
+ __Z6b2FreePv(i7);
+ i7 = HEAP32[i4 >> 2] | 0;
+ i6 = HEAP32[i3 >> 2] | 0;
+ }
+ i5 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 + (i6 * 12 | 0) >> 2] = (i7 | 0) > (i1 | 0) ? i1 : i7;
+ i4 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i5 + ((HEAP32[i3 >> 2] | 0) * 12 | 0) + 4 >> 2] = (i4 | 0) < (i1 | 0) ? i1 : i4;
+ HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + 1;
+ STACKTOP = i2;
+ return 1;
+}
+function __ZNK10__cxxabiv120__si_class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi(i5, i4, i3, i1) {
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i6 = 0;
+ i2 = STACKTOP;
+ if ((i5 | 0) != (HEAP32[i4 + 8 >> 2] | 0)) {
+ i6 = HEAP32[i5 + 8 >> 2] | 0;
+ FUNCTION_TABLE_viiii[HEAP32[(HEAP32[i6 >> 2] | 0) + 28 >> 2] & 15](i6, i4, i3, i1);
+ STACKTOP = i2;
+ return;
+ }
+ i5 = i4 + 16 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) == 0) {
+ HEAP32[i5 >> 2] = i3;
+ HEAP32[i4 + 24 >> 2] = i1;
+ HEAP32[i4 + 36 >> 2] = 1;
+ STACKTOP = i2;
+ return;
+ }
+ if ((i6 | 0) != (i3 | 0)) {
+ i6 = i4 + 36 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + 1;
+ HEAP32[i4 + 24 >> 2] = 2;
+ HEAP8[i4 + 54 | 0] = 1;
+ STACKTOP = i2;
+ return;
+ }
+ i3 = i4 + 24 | 0;
+ if ((HEAP32[i3 >> 2] | 0) != 2) {
+ STACKTOP = i2;
+ return;
+ }
+ HEAP32[i3 >> 2] = i1;
+ STACKTOP = i2;
+ return;
+}
+function __ZN6b2Body19SynchronizeFixturesEv(i5) {
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, d6 = 0.0, d7 = 0.0, d8 = 0.0, d9 = 0.0, d10 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i1;
+ d8 = +HEAPF32[i5 + 52 >> 2];
+ d9 = +Math_sin(+d8);
+ HEAPF32[i3 + 8 >> 2] = d9;
+ d8 = +Math_cos(+d8);
+ HEAPF32[i3 + 12 >> 2] = d8;
+ d10 = +HEAPF32[i5 + 28 >> 2];
+ d6 = +HEAPF32[i5 + 32 >> 2];
+ d7 = +(+HEAPF32[i5 + 36 >> 2] - (d8 * d10 - d9 * d6));
+ d6 = +(+HEAPF32[i5 + 40 >> 2] - (d10 * d9 + d8 * d6));
+ i2 = i3;
+ HEAPF32[i2 >> 2] = d7;
+ HEAPF32[i2 + 4 >> 2] = d6;
+ i2 = (HEAP32[i5 + 88 >> 2] | 0) + 102872 | 0;
+ i4 = HEAP32[i5 + 100 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i5 = i5 + 12 | 0;
+ do {
+ __ZN9b2Fixture11SynchronizeEP12b2BroadPhaseRK11b2TransformS4_(i4, i2, i3, i5);
+ i4 = HEAP32[i4 + 4 >> 2] | 0;
+ } while ((i4 | 0) != 0);
+ STACKTOP = i1;
+ return;
+}
+function __ZN13b2DynamicTreeC2Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i4 = STACKTOP;
+ HEAP32[i1 >> 2] = -1;
+ i3 = i1 + 12 | 0;
+ HEAP32[i3 >> 2] = 16;
+ HEAP32[i1 + 8 >> 2] = 0;
+ i6 = __Z7b2Alloci(576) | 0;
+ i2 = i1 + 4 | 0;
+ HEAP32[i2 >> 2] = i6;
+ _memset(i6 | 0, 0, (HEAP32[i3 >> 2] | 0) * 36 | 0) | 0;
+ i6 = (HEAP32[i3 >> 2] | 0) + -1 | 0;
+ i2 = HEAP32[i2 >> 2] | 0;
+ if ((i6 | 0) > 0) {
+ i6 = 0;
+ while (1) {
+ i5 = i6 + 1 | 0;
+ HEAP32[i2 + (i6 * 36 | 0) + 20 >> 2] = i5;
+ HEAP32[i2 + (i6 * 36 | 0) + 32 >> 2] = -1;
+ i6 = (HEAP32[i3 >> 2] | 0) + -1 | 0;
+ if ((i5 | 0) < (i6 | 0)) {
+ i6 = i5;
+ } else {
+ break;
+ }
+ }
+ }
+ HEAP32[i2 + (i6 * 36 | 0) + 20 >> 2] = -1;
+ HEAP32[i2 + (((HEAP32[i3 >> 2] | 0) + -1 | 0) * 36 | 0) + 32 >> 2] = -1;
+ HEAP32[i1 + 16 >> 2] = 0;
+ HEAP32[i1 + 20 >> 2] = 0;
+ HEAP32[i1 + 24 >> 2] = 0;
+ STACKTOP = i4;
+ return;
+}
+function __Z7measurePl(i1, i9) {
+ i1 = i1 | 0;
+ i9 = i9 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, d5 = 0.0, d6 = 0.0, i7 = 0, d8 = 0.0, i10 = 0, d11 = 0.0;
+ i2 = STACKTOP;
+ i3 = HEAP32[4] | 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + ((4 * i3 | 0) + 15 & -16) | 0;
+ i7 = (i3 | 0) > 0;
+ if (i7) {
+ i10 = 0;
+ d6 = 0.0;
+ do {
+ d8 = +(HEAP32[i9 + (i10 << 2) >> 2] | 0) / 1.0e6 * 1.0e3;
+ HEAPF32[i4 + (i10 << 2) >> 2] = d8;
+ d6 = d6 + d8;
+ i10 = i10 + 1 | 0;
+ } while ((i10 | 0) < (i3 | 0));
+ d5 = +(i3 | 0);
+ d6 = d6 / d5;
+ HEAPF32[i1 >> 2] = d6;
+ if (i7) {
+ i7 = 0;
+ d8 = 0.0;
+ do {
+ d11 = +HEAPF32[i4 + (i7 << 2) >> 2] - d6;
+ d8 = d8 + d11 * d11;
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) < (i3 | 0));
+ } else {
+ d8 = 0.0;
+ }
+ } else {
+ d5 = +(i3 | 0);
+ HEAPF32[i1 >> 2] = 0.0 / d5;
+ d8 = 0.0;
+ }
+ HEAPF32[i1 + 4 >> 2] = +Math_sqrt(+(d8 / d5));
+ STACKTOP = i2;
+ return;
+}
+function __ZN13b2DynamicTree11CreateProxyERK6b2AABBPv(i1, i3, i2) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i4 = 0, i5 = 0, i6 = 0, d7 = 0.0, d8 = 0.0, i9 = 0;
+ i5 = STACKTOP;
+ i4 = __ZN13b2DynamicTree12AllocateNodeEv(i1) | 0;
+ i6 = i1 + 4 | 0;
+ d7 = +(+HEAPF32[i3 >> 2] + -.10000000149011612);
+ d8 = +(+HEAPF32[i3 + 4 >> 2] + -.10000000149011612);
+ i9 = (HEAP32[i6 >> 2] | 0) + (i4 * 36 | 0) | 0;
+ HEAPF32[i9 >> 2] = d7;
+ HEAPF32[i9 + 4 >> 2] = d8;
+ d8 = +(+HEAPF32[i3 + 8 >> 2] + .10000000149011612);
+ d7 = +(+HEAPF32[i3 + 12 >> 2] + .10000000149011612);
+ i3 = (HEAP32[i6 >> 2] | 0) + (i4 * 36 | 0) + 8 | 0;
+ HEAPF32[i3 >> 2] = d8;
+ HEAPF32[i3 + 4 >> 2] = d7;
+ HEAP32[(HEAP32[i6 >> 2] | 0) + (i4 * 36 | 0) + 16 >> 2] = i2;
+ HEAP32[(HEAP32[i6 >> 2] | 0) + (i4 * 36 | 0) + 32 >> 2] = 0;
+ __ZN13b2DynamicTree10InsertLeafEi(i1, i4);
+ STACKTOP = i5;
+ return i4 | 0;
+}
+function __ZN16b2BlockAllocatorC2Ev(i3) {
+ i3 = i3 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i4 = i3 + 8 | 0;
+ HEAP32[i4 >> 2] = 128;
+ HEAP32[i3 + 4 >> 2] = 0;
+ i5 = __Z7b2Alloci(1024) | 0;
+ HEAP32[i3 >> 2] = i5;
+ _memset(i5 | 0, 0, HEAP32[i4 >> 2] << 3 | 0) | 0;
+ i4 = i3 + 12 | 0;
+ i3 = i4 + 56 | 0;
+ do {
+ HEAP32[i4 >> 2] = 0;
+ i4 = i4 + 4 | 0;
+ } while ((i4 | 0) < (i3 | 0));
+ if ((HEAP8[1280] | 0) == 0) {
+ i3 = 1;
+ i4 = 0;
+ } else {
+ STACKTOP = i2;
+ return;
+ }
+ do {
+ if ((i4 | 0) >= 14) {
+ i1 = 3;
+ break;
+ }
+ if ((i3 | 0) > (HEAP32[576 + (i4 << 2) >> 2] | 0)) {
+ i4 = i4 + 1 | 0;
+ HEAP8[632 + i3 | 0] = i4;
+ } else {
+ HEAP8[632 + i3 | 0] = i4;
+ }
+ i3 = i3 + 1 | 0;
+ } while ((i3 | 0) < 641);
+ if ((i1 | 0) == 3) {
+ ___assert_fail(1288, 1312, 73, 1352);
+ }
+ HEAP8[1280] = 1;
+ STACKTOP = i2;
+ return;
+}
+function __ZN24b2ChainAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_(i2, i4, i3, i1) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i5 = STACKTOP;
+ STACKTOP = STACKTOP + 48 | 0;
+ i6 = i5;
+ i7 = HEAP32[(HEAP32[i2 + 48 >> 2] | 0) + 12 >> 2] | 0;
+ HEAP32[i6 >> 2] = 240;
+ HEAP32[i6 + 4 >> 2] = 1;
+ HEAPF32[i6 + 8 >> 2] = .009999999776482582;
+ i8 = i6 + 28 | 0;
+ HEAP32[i8 + 0 >> 2] = 0;
+ HEAP32[i8 + 4 >> 2] = 0;
+ HEAP32[i8 + 8 >> 2] = 0;
+ HEAP32[i8 + 12 >> 2] = 0;
+ HEAP16[i8 + 16 >> 1] = 0;
+ __ZNK12b2ChainShape12GetChildEdgeEP11b2EdgeShapei(i7, i6, HEAP32[i2 + 56 >> 2] | 0);
+ __Z23b2CollideEdgeAndPolygonP10b2ManifoldPK11b2EdgeShapeRK11b2TransformPK14b2PolygonShapeS6_(i4, i6, i3, HEAP32[(HEAP32[i2 + 52 >> 2] | 0) + 12 >> 2] | 0, i1);
+ STACKTOP = i5;
+ return;
+}
+function __ZN23b2ChainAndCircleContact8EvaluateEP10b2ManifoldRK11b2TransformS4_(i2, i4, i3, i1) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i5 = STACKTOP;
+ STACKTOP = STACKTOP + 48 | 0;
+ i6 = i5;
+ i7 = HEAP32[(HEAP32[i2 + 48 >> 2] | 0) + 12 >> 2] | 0;
+ HEAP32[i6 >> 2] = 240;
+ HEAP32[i6 + 4 >> 2] = 1;
+ HEAPF32[i6 + 8 >> 2] = .009999999776482582;
+ i8 = i6 + 28 | 0;
+ HEAP32[i8 + 0 >> 2] = 0;
+ HEAP32[i8 + 4 >> 2] = 0;
+ HEAP32[i8 + 8 >> 2] = 0;
+ HEAP32[i8 + 12 >> 2] = 0;
+ HEAP16[i8 + 16 >> 1] = 0;
+ __ZNK12b2ChainShape12GetChildEdgeEP11b2EdgeShapei(i7, i6, HEAP32[i2 + 56 >> 2] | 0);
+ __Z22b2CollideEdgeAndCircleP10b2ManifoldPK11b2EdgeShapeRK11b2TransformPK13b2CircleShapeS6_(i4, i6, i3, HEAP32[(HEAP32[i2 + 52 >> 2] | 0) + 12 >> 2] | 0, i1);
+ STACKTOP = i5;
+ return;
+}
+function __ZN15b2ContactSolver13StoreImpulsesEv(i4) {
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i1 = STACKTOP;
+ i2 = HEAP32[i4 + 48 >> 2] | 0;
+ if ((i2 | 0) <= 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i3 = HEAP32[i4 + 40 >> 2] | 0;
+ i4 = HEAP32[i4 + 44 >> 2] | 0;
+ i5 = 0;
+ do {
+ i6 = HEAP32[i4 + (HEAP32[i3 + (i5 * 152 | 0) + 148 >> 2] << 2) >> 2] | 0;
+ i7 = HEAP32[i3 + (i5 * 152 | 0) + 144 >> 2] | 0;
+ if ((i7 | 0) > 0) {
+ i8 = 0;
+ do {
+ HEAPF32[i6 + (i8 * 20 | 0) + 72 >> 2] = +HEAPF32[i3 + (i5 * 152 | 0) + (i8 * 36 | 0) + 16 >> 2];
+ HEAPF32[i6 + (i8 * 20 | 0) + 76 >> 2] = +HEAPF32[i3 + (i5 * 152 | 0) + (i8 * 36 | 0) + 20 >> 2];
+ i8 = i8 + 1 | 0;
+ } while ((i8 | 0) < (i7 | 0));
+ }
+ i5 = i5 + 1 | 0;
+ } while ((i5 | 0) < (i2 | 0));
+ STACKTOP = i1;
+ return;
+}
+function __ZN16b2StackAllocator4FreeEPv(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0;
+ i3 = STACKTOP;
+ i2 = i1 + 102796 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ if ((i4 | 0) <= 0) {
+ ___assert_fail(3952, 3808, 63, 3976);
+ }
+ i6 = i4 + -1 | 0;
+ if ((HEAP32[i1 + (i6 * 12 | 0) + 102412 >> 2] | 0) != (i5 | 0)) {
+ ___assert_fail(3984, 3808, 65, 3976);
+ }
+ if ((HEAP8[i1 + (i6 * 12 | 0) + 102420 | 0] | 0) == 0) {
+ i5 = i1 + (i6 * 12 | 0) + 102416 | 0;
+ i6 = i1 + 102400 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) - (HEAP32[i5 >> 2] | 0);
+ } else {
+ __Z6b2FreePv(i5);
+ i5 = i1 + (i6 * 12 | 0) + 102416 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ }
+ i6 = i1 + 102404 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) - (HEAP32[i5 >> 2] | 0);
+ HEAP32[i2 >> 2] = i4 + -1;
+ STACKTOP = i3;
+ return;
+}
+function __ZNK10__cxxabiv117__class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi(i5, i4, i3, i2) {
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i6 = 0;
+ i1 = STACKTOP;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != (i5 | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ i5 = i4 + 16 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) == 0) {
+ HEAP32[i5 >> 2] = i3;
+ HEAP32[i4 + 24 >> 2] = i2;
+ HEAP32[i4 + 36 >> 2] = 1;
+ STACKTOP = i1;
+ return;
+ }
+ if ((i6 | 0) != (i3 | 0)) {
+ i6 = i4 + 36 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + 1;
+ HEAP32[i4 + 24 >> 2] = 2;
+ HEAP8[i4 + 54 | 0] = 1;
+ STACKTOP = i1;
+ return;
+ }
+ i3 = i4 + 24 | 0;
+ if ((HEAP32[i3 >> 2] | 0) != 2) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[i3 >> 2] = i2;
+ STACKTOP = i1;
+ return;
+}
+function __ZN12b2BroadPhase11CreateProxyERK6b2AABBPv(i2, i4, i3) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i1 = STACKTOP;
+ i3 = __ZN13b2DynamicTree11CreateProxyERK6b2AABBPv(i2, i4, i3) | 0;
+ i4 = i2 + 28 | 0;
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + 1;
+ i4 = i2 + 40 | 0;
+ i5 = HEAP32[i4 >> 2] | 0;
+ i6 = i2 + 36 | 0;
+ i2 = i2 + 32 | 0;
+ if ((i5 | 0) == (HEAP32[i6 >> 2] | 0)) {
+ i7 = HEAP32[i2 >> 2] | 0;
+ HEAP32[i6 >> 2] = i5 << 1;
+ i5 = __Z7b2Alloci(i5 << 3) | 0;
+ HEAP32[i2 >> 2] = i5;
+ _memcpy(i5 | 0, i7 | 0, HEAP32[i4 >> 2] << 2 | 0) | 0;
+ __Z6b2FreePv(i7);
+ i5 = HEAP32[i4 >> 2] | 0;
+ }
+ HEAP32[(HEAP32[i2 >> 2] | 0) + (i5 << 2) >> 2] = i3;
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + 1;
+ STACKTOP = i1;
+ return i3 | 0;
+}
+function __ZN9b2ContactC2EP9b2FixtureiS1_i(i1, i4, i6, i3, i5) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i7 = 0, d8 = 0.0, d9 = 0.0;
+ i2 = STACKTOP;
+ HEAP32[i1 >> 2] = 4440;
+ HEAP32[i1 + 4 >> 2] = 4;
+ HEAP32[i1 + 48 >> 2] = i4;
+ HEAP32[i1 + 52 >> 2] = i3;
+ HEAP32[i1 + 56 >> 2] = i6;
+ HEAP32[i1 + 60 >> 2] = i5;
+ HEAP32[i1 + 124 >> 2] = 0;
+ HEAP32[i1 + 128 >> 2] = 0;
+ i5 = i4 + 16 | 0;
+ i6 = i1 + 8 | 0;
+ i7 = i6 + 40 | 0;
+ do {
+ HEAP32[i6 >> 2] = 0;
+ i6 = i6 + 4 | 0;
+ } while ((i6 | 0) < (i7 | 0));
+ HEAPF32[i1 + 136 >> 2] = +Math_sqrt(+(+HEAPF32[i5 >> 2] * +HEAPF32[i3 + 16 >> 2]));
+ d8 = +HEAPF32[i4 + 20 >> 2];
+ d9 = +HEAPF32[i3 + 20 >> 2];
+ HEAPF32[i1 + 140 >> 2] = d8 > d9 ? d8 : d9;
+ STACKTOP = i2;
+ return;
+}
+function __ZN12b2BroadPhase9MoveProxyEiRK6b2AABBRK6b2Vec2(i3, i1, i5, i4) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ if (!(__ZN13b2DynamicTree9MoveProxyEiRK6b2AABBRK6b2Vec2(i3, i1, i5, i4) | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ i4 = i3 + 40 | 0;
+ i5 = HEAP32[i4 >> 2] | 0;
+ i6 = i3 + 36 | 0;
+ i3 = i3 + 32 | 0;
+ if ((i5 | 0) == (HEAP32[i6 >> 2] | 0)) {
+ i7 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i6 >> 2] = i5 << 1;
+ i5 = __Z7b2Alloci(i5 << 3) | 0;
+ HEAP32[i3 >> 2] = i5;
+ _memcpy(i5 | 0, i7 | 0, HEAP32[i4 >> 2] << 2 | 0) | 0;
+ __Z6b2FreePv(i7);
+ i5 = HEAP32[i4 >> 2] | 0;
+ }
+ HEAP32[(HEAP32[i3 >> 2] | 0) + (i5 << 2) >> 2] = i1;
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + 1;
+ STACKTOP = i2;
+ return;
+}
+function __ZN24b2ChainAndPolygonContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator(i1, i3, i4, i5, i6) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i6 = __ZN16b2BlockAllocator8AllocateEi(i6, 144) | 0;
+ if ((i6 | 0) == 0) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ __ZN9b2ContactC2EP9b2FixtureiS1_i(i6, i1, i3, i4, i5);
+ HEAP32[i6 >> 2] = 6032;
+ if ((HEAP32[(HEAP32[(HEAP32[i6 + 48 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) != 3) {
+ ___assert_fail(6048, 6096, 43, 6152);
+ }
+ if ((HEAP32[(HEAP32[(HEAP32[i6 + 52 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) == 2) {
+ STACKTOP = i2;
+ return i6 | 0;
+ } else {
+ ___assert_fail(6184, 6096, 44, 6152);
+ }
+ return 0;
+}
+function __ZN23b2ChainAndCircleContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator(i1, i3, i4, i5, i6) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i6 = __ZN16b2BlockAllocator8AllocateEi(i6, 144) | 0;
+ if ((i6 | 0) == 0) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ __ZN9b2ContactC2EP9b2FixtureiS1_i(i6, i1, i3, i4, i5);
+ HEAP32[i6 >> 2] = 5784;
+ if ((HEAP32[(HEAP32[(HEAP32[i6 + 48 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) != 3) {
+ ___assert_fail(5800, 5848, 43, 5904);
+ }
+ if ((HEAP32[(HEAP32[(HEAP32[i6 + 52 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) == 0) {
+ STACKTOP = i2;
+ return i6 | 0;
+ } else {
+ ___assert_fail(5928, 5848, 44, 5904);
+ }
+ return 0;
+}
+function __ZN25b2PolygonAndCircleContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator(i1, i4, i2, i5, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ i4 = STACKTOP;
+ i3 = __ZN16b2BlockAllocator8AllocateEi(i3, 144) | 0;
+ if ((i3 | 0) == 0) {
+ i5 = 0;
+ STACKTOP = i4;
+ return i5 | 0;
+ }
+ __ZN9b2ContactC2EP9b2FixtureiS1_i(i3, i1, 0, i2, 0);
+ HEAP32[i3 >> 2] = 4984;
+ if ((HEAP32[(HEAP32[(HEAP32[i3 + 48 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) != 2) {
+ ___assert_fail(5e3, 5048, 41, 5104);
+ }
+ if ((HEAP32[(HEAP32[(HEAP32[i3 + 52 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) == 0) {
+ i5 = i3;
+ STACKTOP = i4;
+ return i5 | 0;
+ } else {
+ ___assert_fail(5136, 5048, 42, 5104);
+ }
+ return 0;
+}
+function __ZN23b2EdgeAndPolygonContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator(i1, i4, i2, i5, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ i4 = STACKTOP;
+ i3 = __ZN16b2BlockAllocator8AllocateEi(i3, 144) | 0;
+ if ((i3 | 0) == 0) {
+ i5 = 0;
+ STACKTOP = i4;
+ return i5 | 0;
+ }
+ __ZN9b2ContactC2EP9b2FixtureiS1_i(i3, i1, 0, i2, 0);
+ HEAP32[i3 >> 2] = 4736;
+ if ((HEAP32[(HEAP32[(HEAP32[i3 + 48 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) != 1) {
+ ___assert_fail(4752, 4800, 41, 4856);
+ }
+ if ((HEAP32[(HEAP32[(HEAP32[i3 + 52 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) == 2) {
+ i5 = i3;
+ STACKTOP = i4;
+ return i5 | 0;
+ } else {
+ ___assert_fail(4880, 4800, 42, 4856);
+ }
+ return 0;
+}
+function __ZN22b2EdgeAndCircleContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator(i1, i4, i2, i5, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ i4 = STACKTOP;
+ i3 = __ZN16b2BlockAllocator8AllocateEi(i3, 144) | 0;
+ if ((i3 | 0) == 0) {
+ i5 = 0;
+ STACKTOP = i4;
+ return i5 | 0;
+ }
+ __ZN9b2ContactC2EP9b2FixtureiS1_i(i3, i1, 0, i2, 0);
+ HEAP32[i3 >> 2] = 4488;
+ if ((HEAP32[(HEAP32[(HEAP32[i3 + 48 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) != 1) {
+ ___assert_fail(4504, 4552, 41, 4608);
+ }
+ if ((HEAP32[(HEAP32[(HEAP32[i3 + 52 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) == 0) {
+ i5 = i3;
+ STACKTOP = i4;
+ return i5 | 0;
+ } else {
+ ___assert_fail(4632, 4552, 42, 4608);
+ }
+ return 0;
+}
+function __ZN14b2PolygonShape8SetAsBoxEff(i1, d3, d2) {
+ i1 = i1 | 0;
+ d3 = +d3;
+ d2 = +d2;
+ var d4 = 0.0, d5 = 0.0;
+ HEAP32[i1 + 148 >> 2] = 4;
+ d4 = -d3;
+ d5 = -d2;
+ HEAPF32[i1 + 20 >> 2] = d4;
+ HEAPF32[i1 + 24 >> 2] = d5;
+ HEAPF32[i1 + 28 >> 2] = d3;
+ HEAPF32[i1 + 32 >> 2] = d5;
+ HEAPF32[i1 + 36 >> 2] = d3;
+ HEAPF32[i1 + 40 >> 2] = d2;
+ HEAPF32[i1 + 44 >> 2] = d4;
+ HEAPF32[i1 + 48 >> 2] = d2;
+ HEAPF32[i1 + 84 >> 2] = 0.0;
+ HEAPF32[i1 + 88 >> 2] = -1.0;
+ HEAPF32[i1 + 92 >> 2] = 1.0;
+ HEAPF32[i1 + 96 >> 2] = 0.0;
+ HEAPF32[i1 + 100 >> 2] = 0.0;
+ HEAPF32[i1 + 104 >> 2] = 1.0;
+ HEAPF32[i1 + 108 >> 2] = -1.0;
+ HEAPF32[i1 + 112 >> 2] = 0.0;
+ HEAPF32[i1 + 12 >> 2] = 0.0;
+ HEAPF32[i1 + 16 >> 2] = 0.0;
+ return;
+}
+function __ZN16b2PolygonContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator(i1, i4, i2, i5, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ i4 = STACKTOP;
+ i3 = __ZN16b2BlockAllocator8AllocateEi(i3, 144) | 0;
+ if ((i3 | 0) == 0) {
+ i5 = 0;
+ STACKTOP = i4;
+ return i5 | 0;
+ }
+ __ZN9b2ContactC2EP9b2FixtureiS1_i(i3, i1, 0, i2, 0);
+ HEAP32[i3 >> 2] = 5240;
+ if ((HEAP32[(HEAP32[(HEAP32[i3 + 48 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) != 2) {
+ ___assert_fail(5256, 5304, 44, 5352);
+ }
+ if ((HEAP32[(HEAP32[(HEAP32[i3 + 52 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) == 2) {
+ i5 = i3;
+ STACKTOP = i4;
+ return i5 | 0;
+ } else {
+ ___assert_fail(5376, 5304, 45, 5352);
+ }
+ return 0;
+}
+function __ZN15b2CircleContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator(i1, i4, i2, i5, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ i4 = STACKTOP;
+ i3 = __ZN16b2BlockAllocator8AllocateEi(i3, 144) | 0;
+ if ((i3 | 0) == 0) {
+ i5 = 0;
+ STACKTOP = i4;
+ return i5 | 0;
+ }
+ __ZN9b2ContactC2EP9b2FixtureiS1_i(i3, i1, 0, i2, 0);
+ HEAP32[i3 >> 2] = 6288;
+ if ((HEAP32[(HEAP32[(HEAP32[i3 + 48 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) != 0) {
+ ___assert_fail(6304, 6352, 44, 6400);
+ }
+ if ((HEAP32[(HEAP32[(HEAP32[i3 + 52 >> 2] | 0) + 12 >> 2] | 0) + 4 >> 2] | 0) == 0) {
+ i5 = i3;
+ STACKTOP = i4;
+ return i5 | 0;
+ } else {
+ ___assert_fail(6416, 6352, 45, 6400);
+ }
+ return 0;
+}
+function __ZN7b2World10CreateBodyEPK9b2BodyDef(i1, i4) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0, i5 = 0;
+ i2 = STACKTOP;
+ if ((HEAP32[i1 + 102868 >> 2] & 2 | 0) != 0) {
+ ___assert_fail(2160, 2184, 109, 2216);
+ }
+ i3 = __ZN16b2BlockAllocator8AllocateEi(i1, 152) | 0;
+ if ((i3 | 0) == 0) {
+ i3 = 0;
+ } else {
+ __ZN6b2BodyC2EPK9b2BodyDefP7b2World(i3, i4, i1);
+ }
+ HEAP32[i3 + 92 >> 2] = 0;
+ i4 = i1 + 102952 | 0;
+ HEAP32[i3 + 96 >> 2] = HEAP32[i4 >> 2];
+ i5 = HEAP32[i4 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ HEAP32[i5 + 92 >> 2] = i3;
+ }
+ HEAP32[i4 >> 2] = i3;
+ i5 = i1 + 102960 | 0;
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + 1;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function __ZNK6b2Body13ShouldCollideEPKS_(i4, i2) {
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0;
+ i1 = STACKTOP;
+ if ((HEAP32[i4 >> 2] | 0) != 2 ? (HEAP32[i2 >> 2] | 0) != 2 : 0) {
+ i2 = 0;
+ } else {
+ i3 = 3;
+ }
+ L3 : do {
+ if ((i3 | 0) == 3) {
+ i3 = HEAP32[i4 + 108 >> 2] | 0;
+ if ((i3 | 0) == 0) {
+ i2 = 1;
+ } else {
+ while (1) {
+ if ((HEAP32[i3 >> 2] | 0) == (i2 | 0) ? (HEAP8[(HEAP32[i3 + 4 >> 2] | 0) + 61 | 0] | 0) == 0 : 0) {
+ i2 = 0;
+ break L3;
+ }
+ i3 = HEAP32[i3 + 12 >> 2] | 0;
+ if ((i3 | 0) == 0) {
+ i2 = 1;
+ break;
+ }
+ }
+ }
+ }
+ } while (0);
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function __ZNK14b2PolygonShape5CloneEP16b2BlockAllocator(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ i3 = __ZN16b2BlockAllocator8AllocateEi(i3, 152) | 0;
+ if ((i3 | 0) == 0) {
+ i3 = 0;
+ } else {
+ HEAP32[i3 >> 2] = 504;
+ HEAP32[i3 + 4 >> 2] = 2;
+ HEAPF32[i3 + 8 >> 2] = .009999999776482582;
+ HEAP32[i3 + 148 >> 2] = 0;
+ HEAPF32[i3 + 12 >> 2] = 0.0;
+ HEAPF32[i3 + 16 >> 2] = 0.0;
+ }
+ i6 = i1 + 4 | 0;
+ i5 = HEAP32[i6 + 4 >> 2] | 0;
+ i4 = i3 + 4 | 0;
+ HEAP32[i4 >> 2] = HEAP32[i6 >> 2];
+ HEAP32[i4 + 4 >> 2] = i5;
+ _memcpy(i3 + 12 | 0, i1 + 12 | 0, 140) | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _memcpy(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ if ((i1 | 0) >= 4096) return _emscripten_memcpy_big(i3 | 0, i2 | 0, i1 | 0) | 0;
+ i4 = i3 | 0;
+ if ((i3 & 3) == (i2 & 3)) {
+ while (i3 & 3) {
+ if ((i1 | 0) == 0) return i4 | 0;
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ while ((i1 | 0) >= 4) {
+ HEAP32[i3 >> 2] = HEAP32[i2 >> 2];
+ i3 = i3 + 4 | 0;
+ i2 = i2 + 4 | 0;
+ i1 = i1 - 4 | 0;
+ }
+ }
+ while ((i1 | 0) > 0) {
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ return i4 | 0;
+}
+function __ZN7b2World16SetAllowSleepingEb(i2, i4) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i3 = 0;
+ i1 = STACKTOP;
+ i3 = i2 + 102976 | 0;
+ if ((i4 & 1 | 0) == (HEAPU8[i3] | 0 | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP8[i3] = i4 & 1;
+ if (i4) {
+ STACKTOP = i1;
+ return;
+ }
+ i2 = HEAP32[i2 + 102952 >> 2] | 0;
+ if ((i2 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ do {
+ i3 = i2 + 4 | 0;
+ i4 = HEAPU16[i3 >> 1] | 0;
+ if ((i4 & 2 | 0) == 0) {
+ HEAP16[i3 >> 1] = i4 | 2;
+ HEAPF32[i2 + 144 >> 2] = 0.0;
+ }
+ i2 = HEAP32[i2 + 96 >> 2] | 0;
+ } while ((i2 | 0) != 0);
+ STACKTOP = i1;
+ return;
+}
+function __ZN16b2BlockAllocator4FreeEPvi(i3, i1, i4) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((i4 | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ if ((i4 | 0) <= 0) {
+ ___assert_fail(1376, 1312, 164, 1488);
+ }
+ if ((i4 | 0) > 640) {
+ __Z6b2FreePv(i1);
+ STACKTOP = i2;
+ return;
+ }
+ i4 = HEAP8[632 + i4 | 0] | 0;
+ if (!((i4 & 255) < 14)) {
+ ___assert_fail(1408, 1312, 173, 1488);
+ }
+ i4 = i3 + ((i4 & 255) << 2) + 12 | 0;
+ HEAP32[i1 >> 2] = HEAP32[i4 >> 2];
+ HEAP32[i4 >> 2] = i1;
+ STACKTOP = i2;
+ return;
+}
+function __ZN15b2ContactFilter13ShouldCollideEP9b2FixtureS1_(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ i3 = STACKTOP;
+ i4 = HEAP16[i2 + 36 >> 1] | 0;
+ if (!(i4 << 16 >> 16 != (HEAP16[i1 + 36 >> 1] | 0) | i4 << 16 >> 16 == 0)) {
+ i4 = i4 << 16 >> 16 > 0;
+ STACKTOP = i3;
+ return i4 | 0;
+ }
+ if ((HEAP16[i1 + 32 >> 1] & HEAP16[i2 + 34 >> 1]) << 16 >> 16 == 0) {
+ i4 = 0;
+ STACKTOP = i3;
+ return i4 | 0;
+ }
+ i4 = (HEAP16[i1 + 34 >> 1] & HEAP16[i2 + 32 >> 1]) << 16 >> 16 != 0;
+ STACKTOP = i3;
+ return i4 | 0;
+}
+function _memset(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = i1 + i3 | 0;
+ if ((i3 | 0) >= 20) {
+ i4 = i4 & 255;
+ i7 = i1 & 3;
+ i6 = i4 | i4 << 8 | i4 << 16 | i4 << 24;
+ i5 = i2 & ~3;
+ if (i7) {
+ i7 = i1 + 4 - i7 | 0;
+ while ((i1 | 0) < (i7 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ }
+ while ((i1 | 0) < (i5 | 0)) {
+ HEAP32[i1 >> 2] = i6;
+ i1 = i1 + 4 | 0;
+ }
+ }
+ while ((i1 | 0) < (i2 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ return i1 - i3 | 0;
+}
+function __ZN6b2Body13CreateFixtureEPK7b2Shapef(i1, i3, d2) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ d2 = +d2;
+ var i4 = 0, i5 = 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i5 = i4;
+ HEAP16[i5 + 22 >> 1] = 1;
+ HEAP16[i5 + 24 >> 1] = -1;
+ HEAP16[i5 + 26 >> 1] = 0;
+ HEAP32[i5 + 4 >> 2] = 0;
+ HEAPF32[i5 + 8 >> 2] = .20000000298023224;
+ HEAPF32[i5 + 12 >> 2] = 0.0;
+ HEAP8[i5 + 20 | 0] = 0;
+ HEAP32[i5 >> 2] = i3;
+ HEAPF32[i5 + 16 >> 2] = d2;
+ i3 = __ZN6b2Body13CreateFixtureEPK12b2FixtureDef(i1, i5) | 0;
+ STACKTOP = i4;
+ return i3 | 0;
+}
+function __Znwj(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0;
+ i1 = STACKTOP;
+ i2 = (i2 | 0) == 0 ? 1 : i2;
+ while (1) {
+ i3 = _malloc(i2) | 0;
+ if ((i3 | 0) != 0) {
+ i2 = 6;
+ break;
+ }
+ i3 = HEAP32[1914] | 0;
+ HEAP32[1914] = i3 + 0;
+ if ((i3 | 0) == 0) {
+ i2 = 5;
+ break;
+ }
+ FUNCTION_TABLE_v[i3 & 3]();
+ }
+ if ((i2 | 0) == 5) {
+ i3 = ___cxa_allocate_exception(4) | 0;
+ HEAP32[i3 >> 2] = 7672;
+ ___cxa_throw(i3 | 0, 7720, 30);
+ } else if ((i2 | 0) == 6) {
+ STACKTOP = i1;
+ return i3 | 0;
+ }
+ return 0;
+}
+function __ZN8b2IslandD2Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZN16b2StackAllocator4FreeEPv(HEAP32[i1 >> 2] | 0, HEAP32[i1 + 20 >> 2] | 0);
+ __ZN16b2StackAllocator4FreeEPv(HEAP32[i1 >> 2] | 0, HEAP32[i1 + 24 >> 2] | 0);
+ __ZN16b2StackAllocator4FreeEPv(HEAP32[i1 >> 2] | 0, HEAP32[i1 + 16 >> 2] | 0);
+ __ZN16b2StackAllocator4FreeEPv(HEAP32[i1 >> 2] | 0, HEAP32[i1 + 12 >> 2] | 0);
+ __ZN16b2StackAllocator4FreeEPv(HEAP32[i1 >> 2] | 0, HEAP32[i1 + 8 >> 2] | 0);
+ STACKTOP = i2;
+ return;
+}
+function __ZN16b2BlockAllocatorD2Ev(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i1 = STACKTOP;
+ i3 = i2 + 4 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ if ((HEAP32[i3 >> 2] | 0) > 0) {
+ i5 = 0;
+ } else {
+ i5 = i4;
+ __Z6b2FreePv(i5);
+ STACKTOP = i1;
+ return;
+ }
+ do {
+ __Z6b2FreePv(HEAP32[i4 + (i5 << 3) + 4 >> 2] | 0);
+ i5 = i5 + 1 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ } while ((i5 | 0) < (HEAP32[i3 >> 2] | 0));
+ __Z6b2FreePv(i4);
+ STACKTOP = i1;
+ return;
+}
+function copyTempDouble(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+ HEAP8[tempDoublePtr + 4 | 0] = HEAP8[i1 + 4 | 0];
+ HEAP8[tempDoublePtr + 5 | 0] = HEAP8[i1 + 5 | 0];
+ HEAP8[tempDoublePtr + 6 | 0] = HEAP8[i1 + 6 | 0];
+ HEAP8[tempDoublePtr + 7 | 0] = HEAP8[i1 + 7 | 0];
+}
+function __ZNK11b2EdgeShape11ComputeMassEP10b2MassDataf(i2, i1, d3) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ d3 = +d3;
+ var i4 = 0, d5 = 0.0;
+ i4 = STACKTOP;
+ HEAPF32[i1 >> 2] = 0.0;
+ d5 = +((+HEAPF32[i2 + 12 >> 2] + +HEAPF32[i2 + 20 >> 2]) * .5);
+ d3 = +((+HEAPF32[i2 + 16 >> 2] + +HEAPF32[i2 + 24 >> 2]) * .5);
+ i2 = i1 + 4 | 0;
+ HEAPF32[i2 >> 2] = d5;
+ HEAPF32[i2 + 4 >> 2] = d3;
+ HEAPF32[i1 + 12 >> 2] = 0.0;
+ STACKTOP = i4;
+ return;
+}
+function __ZN11b2EdgeShape3SetERK6b2Vec2S2_(i1, i3, i2) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i4 = 0, i5 = 0;
+ i5 = i3;
+ i3 = HEAP32[i5 + 4 >> 2] | 0;
+ i4 = i1 + 12 | 0;
+ HEAP32[i4 >> 2] = HEAP32[i5 >> 2];
+ HEAP32[i4 + 4 >> 2] = i3;
+ i4 = i2;
+ i2 = HEAP32[i4 + 4 >> 2] | 0;
+ i3 = i1 + 20 | 0;
+ HEAP32[i3 >> 2] = HEAP32[i4 >> 2];
+ HEAP32[i3 + 4 >> 2] = i2;
+ HEAP8[i1 + 44 | 0] = 0;
+ HEAP8[i1 + 45 | 0] = 0;
+ return;
+}
+function __ZN25b2PolygonAndCircleContact8EvaluateEP10b2ManifoldRK11b2TransformS4_(i2, i4, i3, i1) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i5 = 0;
+ i5 = STACKTOP;
+ __Z25b2CollidePolygonAndCircleP10b2ManifoldPK14b2PolygonShapeRK11b2TransformPK13b2CircleShapeS6_(i4, HEAP32[(HEAP32[i2 + 48 >> 2] | 0) + 12 >> 2] | 0, i3, HEAP32[(HEAP32[i2 + 52 >> 2] | 0) + 12 >> 2] | 0, i1);
+ STACKTOP = i5;
+ return;
+}
+function __ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_(i2, i4, i3, i1) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i5 = 0;
+ i5 = STACKTOP;
+ __Z23b2CollideEdgeAndPolygonP10b2ManifoldPK11b2EdgeShapeRK11b2TransformPK14b2PolygonShapeS6_(i4, HEAP32[(HEAP32[i2 + 48 >> 2] | 0) + 12 >> 2] | 0, i3, HEAP32[(HEAP32[i2 + 52 >> 2] | 0) + 12 >> 2] | 0, i1);
+ STACKTOP = i5;
+ return;
+}
+function __ZN22b2EdgeAndCircleContact8EvaluateEP10b2ManifoldRK11b2TransformS4_(i2, i4, i3, i1) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i5 = 0;
+ i5 = STACKTOP;
+ __Z22b2CollideEdgeAndCircleP10b2ManifoldPK11b2EdgeShapeRK11b2TransformPK13b2CircleShapeS6_(i4, HEAP32[(HEAP32[i2 + 48 >> 2] | 0) + 12 >> 2] | 0, i3, HEAP32[(HEAP32[i2 + 52 >> 2] | 0) + 12 >> 2] | 0, i1);
+ STACKTOP = i5;
+ return;
+}
+function __Z23b2CollideEdgeAndPolygonP10b2ManifoldPK11b2EdgeShapeRK11b2TransformPK14b2PolygonShapeS6_(i5, i4, i3, i2, i1) {
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i6 = 0;
+ i6 = STACKTOP;
+ STACKTOP = STACKTOP + 256 | 0;
+ __ZN12b2EPCollider7CollideEP10b2ManifoldPK11b2EdgeShapeRK11b2TransformPK14b2PolygonShapeS7_(i6, i5, i4, i3, i2, i1);
+ STACKTOP = i6;
+ return;
+}
+function __ZN16b2PolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_(i2, i4, i3, i1) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i5 = 0;
+ i5 = STACKTOP;
+ __Z17b2CollidePolygonsP10b2ManifoldPK14b2PolygonShapeRK11b2TransformS3_S6_(i4, HEAP32[(HEAP32[i2 + 48 >> 2] | 0) + 12 >> 2] | 0, i3, HEAP32[(HEAP32[i2 + 52 >> 2] | 0) + 12 >> 2] | 0, i1);
+ STACKTOP = i5;
+ return;
+}
+function __ZN15b2CircleContact8EvaluateEP10b2ManifoldRK11b2TransformS4_(i2, i4, i3, i1) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i5 = 0;
+ i5 = STACKTOP;
+ __Z16b2CollideCirclesP10b2ManifoldPK13b2CircleShapeRK11b2TransformS3_S6_(i4, HEAP32[(HEAP32[i2 + 48 >> 2] | 0) + 12 >> 2] | 0, i3, HEAP32[(HEAP32[i2 + 52 >> 2] | 0) + 12 >> 2] | 0, i1);
+ STACKTOP = i5;
+ return;
+}
+function __Z14b2PairLessThanRK6b2PairS1_(i2, i5) {
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i3 = 0, i4 = 0;
+ i1 = STACKTOP;
+ i4 = HEAP32[i2 >> 2] | 0;
+ i3 = HEAP32[i5 >> 2] | 0;
+ if ((i4 | 0) >= (i3 | 0)) {
+ if ((i4 | 0) == (i3 | 0)) {
+ i2 = (HEAP32[i2 + 4 >> 2] | 0) < (HEAP32[i5 + 4 >> 2] | 0);
+ } else {
+ i2 = 0;
+ }
+ } else {
+ i2 = 1;
+ }
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function __ZN9b2FixtureC2Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ HEAP16[i1 + 32 >> 1] = 1;
+ HEAP16[i1 + 34 >> 1] = -1;
+ HEAP16[i1 + 36 >> 1] = 0;
+ HEAP32[i1 + 40 >> 2] = 0;
+ HEAP32[i1 + 24 >> 2] = 0;
+ HEAP32[i1 + 28 >> 2] = 0;
+ HEAP32[i1 + 0 >> 2] = 0;
+ HEAP32[i1 + 4 >> 2] = 0;
+ HEAP32[i1 + 8 >> 2] = 0;
+ HEAP32[i1 + 12 >> 2] = 0;
+ STACKTOP = i2;
+ return;
+}
+function __ZN12b2BroadPhaseC2Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZN13b2DynamicTreeC2Ev(i1);
+ HEAP32[i1 + 28 >> 2] = 0;
+ HEAP32[i1 + 48 >> 2] = 16;
+ HEAP32[i1 + 52 >> 2] = 0;
+ HEAP32[i1 + 44 >> 2] = __Z7b2Alloci(192) | 0;
+ HEAP32[i1 + 36 >> 2] = 16;
+ HEAP32[i1 + 40 >> 2] = 0;
+ HEAP32[i1 + 32 >> 2] = __Z7b2Alloci(64) | 0;
+ STACKTOP = i2;
+ return;
+}
+function __ZN16b2StackAllocatorD2Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((HEAP32[i1 + 102400 >> 2] | 0) != 0) {
+ ___assert_fail(3792, 3808, 32, 3848);
+ }
+ if ((HEAP32[i1 + 102796 >> 2] | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ } else {
+ ___assert_fail(3872, 3808, 33, 3848);
+ }
+}
+function __ZN15b2ContactSolverD2Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = i1 + 32 | 0;
+ __ZN16b2StackAllocator4FreeEPv(HEAP32[i3 >> 2] | 0, HEAP32[i1 + 40 >> 2] | 0);
+ __ZN16b2StackAllocator4FreeEPv(HEAP32[i3 >> 2] | 0, HEAP32[i1 + 36 >> 2] | 0);
+ STACKTOP = i2;
+ return;
+}
+function __ZN25b2PolygonAndCircleContact7DestroyEP9b2ContactP16b2BlockAllocator(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ FUNCTION_TABLE_vi[HEAP32[(HEAP32[i1 >> 2] | 0) + 4 >> 2] & 31](i1);
+ __ZN16b2BlockAllocator4FreeEPvi(i2, i1, 144);
+ STACKTOP = i3;
+ return;
+}
+function __ZN24b2ChainAndPolygonContact7DestroyEP9b2ContactP16b2BlockAllocator(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ FUNCTION_TABLE_vi[HEAP32[(HEAP32[i1 >> 2] | 0) + 4 >> 2] & 31](i1);
+ __ZN16b2BlockAllocator4FreeEPvi(i2, i1, 144);
+ STACKTOP = i3;
+ return;
+}
+function __ZN23b2EdgeAndPolygonContact7DestroyEP9b2ContactP16b2BlockAllocator(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ FUNCTION_TABLE_vi[HEAP32[(HEAP32[i1 >> 2] | 0) + 4 >> 2] & 31](i1);
+ __ZN16b2BlockAllocator4FreeEPvi(i2, i1, 144);
+ STACKTOP = i3;
+ return;
+}
+function __ZN23b2ChainAndCircleContact7DestroyEP9b2ContactP16b2BlockAllocator(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ FUNCTION_TABLE_vi[HEAP32[(HEAP32[i1 >> 2] | 0) + 4 >> 2] & 31](i1);
+ __ZN16b2BlockAllocator4FreeEPvi(i2, i1, 144);
+ STACKTOP = i3;
+ return;
+}
+function __ZN22b2EdgeAndCircleContact7DestroyEP9b2ContactP16b2BlockAllocator(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ FUNCTION_TABLE_vi[HEAP32[(HEAP32[i1 >> 2] | 0) + 4 >> 2] & 31](i1);
+ __ZN16b2BlockAllocator4FreeEPvi(i2, i1, 144);
+ STACKTOP = i3;
+ return;
+}
+function __ZN16b2ContactManagerC2Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZN12b2BroadPhaseC2Ev(i1);
+ HEAP32[i1 + 60 >> 2] = 0;
+ HEAP32[i1 + 64 >> 2] = 0;
+ HEAP32[i1 + 68 >> 2] = 1888;
+ HEAP32[i1 + 72 >> 2] = 1896;
+ HEAP32[i1 + 76 >> 2] = 0;
+ STACKTOP = i2;
+ return;
+}
+function __ZN16b2PolygonContact7DestroyEP9b2ContactP16b2BlockAllocator(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ FUNCTION_TABLE_vi[HEAP32[(HEAP32[i1 >> 2] | 0) + 4 >> 2] & 31](i1);
+ __ZN16b2BlockAllocator4FreeEPvi(i2, i1, 144);
+ STACKTOP = i3;
+ return;
+}
+function __ZN15b2CircleContact7DestroyEP9b2ContactP16b2BlockAllocator(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ FUNCTION_TABLE_vi[HEAP32[(HEAP32[i1 >> 2] | 0) + 4 >> 2] & 31](i1);
+ __ZN16b2BlockAllocator4FreeEPvi(i2, i1, 144);
+ STACKTOP = i3;
+ return;
+}
+function dynCall_viiiiii(i7, i6, i5, i4, i3, i2, i1) {
+ i7 = i7 | 0;
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ FUNCTION_TABLE_viiiiii[i7 & 3](i6 | 0, i5 | 0, i4 | 0, i3 | 0, i2 | 0, i1 | 0);
+}
+function copyTempFloat(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+}
+function dynCall_iiiiii(i6, i5, i4, i3, i2, i1) {
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ return FUNCTION_TABLE_iiiiii[i6 & 15](i5 | 0, i4 | 0, i3 | 0, i2 | 0, i1 | 0) | 0;
+}
+function dynCall_viiiii(i6, i5, i4, i3, i2, i1) {
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ FUNCTION_TABLE_viiiii[i6 & 3](i5 | 0, i4 | 0, i3 | 0, i2 | 0, i1 | 0);
+}
+function __ZN16b2ContactManager15FindNewContactsEv(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZN12b2BroadPhase11UpdatePairsI16b2ContactManagerEEvPT_(i1, i1);
+ STACKTOP = i2;
+ return;
+}
+function __ZN16b2StackAllocatorC2Ev(i1) {
+ i1 = i1 | 0;
+ HEAP32[i1 + 102400 >> 2] = 0;
+ HEAP32[i1 + 102404 >> 2] = 0;
+ HEAP32[i1 + 102408 >> 2] = 0;
+ HEAP32[i1 + 102796 >> 2] = 0;
+ return;
+}
+function dynCall_viiii(i5, i4, i3, i2, i1) {
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ FUNCTION_TABLE_viiii[i5 & 15](i4 | 0, i3 | 0, i2 | 0, i1 | 0);
+}
+function dynCall_iiii(i4, i3, i2, i1) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ return FUNCTION_TABLE_iiii[i4 & 7](i3 | 0, i2 | 0, i1 | 0) | 0;
+}
+function dynCall_viii(i4, i3, i2, i1) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ FUNCTION_TABLE_viii[i4 & 3](i3 | 0, i2 | 0, i1 | 0);
+}
+function __ZNSt9bad_allocD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZNSt9exceptionD2Ev(i1 | 0);
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function stackAlloc(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + i1 | 0;
+ STACKTOP = STACKTOP + 7 & -8;
+ return i2 | 0;
+}
+function __ZN13b2DynamicTreeD2Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __Z6b2FreePv(HEAP32[i1 + 4 >> 2] | 0);
+ STACKTOP = i2;
+ return;
+}
+function dynCall_viid(i4, i3, i2, d1) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ d1 = +d1;
+ FUNCTION_TABLE_viid[i4 & 3](i3 | 0, i2 | 0, +d1);
+}
+function __ZN17b2ContactListener9PostSolveEP9b2ContactPK16b2ContactImpulse(i1, i2, i3) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ return;
+}
+function __ZN10__cxxabiv120__si_class_type_infoD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function __ZN10__cxxabiv117__class_type_infoD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function __ZNSt9bad_allocD2Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZNSt9exceptionD2Ev(i1 | 0);
+ STACKTOP = i2;
+ return;
+}
+function dynCall_iii(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ return FUNCTION_TABLE_iii[i3 & 3](i2 | 0, i1 | 0) | 0;
+}
+function b8(i1, i2, i3, i4, i5, i6) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ abort(8);
+}
+function __ZN25b2PolygonAndCircleContactD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function __ZN17b2ContactListener8PreSolveEP9b2ContactPK10b2Manifold(i1, i2, i3) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ return;
+}
+function __ZN24b2ChainAndPolygonContactD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function __ZN23b2EdgeAndPolygonContactD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function __ZN23b2ChainAndCircleContactD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function __ZNK11b2EdgeShape9TestPointERK11b2TransformRK6b2Vec2(i1, i2, i3) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ return 0;
+}
+function __ZN22b2EdgeAndCircleContactD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function __ZdlPv(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((i1 | 0) != 0) {
+ _free(i1);
+ }
+ STACKTOP = i2;
+ return;
+}
+function b10(i1, i2, i3, i4, i5) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ abort(10);
+ return 0;
+}
+function _strlen(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = i1;
+ while (HEAP8[i2] | 0) {
+ i2 = i2 + 1 | 0;
+ }
+ return i2 - i1 | 0;
+}
+function __Z7b2Alloci(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i1 = _malloc(i1) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function setThrew(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ if ((__THREW__ | 0) == 0) {
+ __THREW__ = i1;
+ threwValue = i2;
+ }
+}
+function __ZN17b2ContactListenerD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function __ZN16b2PolygonContactD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function dynCall_vii(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ FUNCTION_TABLE_vii[i3 & 15](i2 | 0, i1 | 0);
+}
+function __ZN15b2ContactFilterD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function __ZN15b2CircleContactD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function __ZN14b2PolygonShapeD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function __Znaj(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i1 = __Znwj(i1) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function __ZN11b2EdgeShapeD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function __ZN9b2ContactD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function b1(i1, i2, i3, i4, i5) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ abort(1);
+}
+function __Z6b2FreePv(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _free(i1);
+ STACKTOP = i2;
+ return;
+}
+function ___clang_call_terminate(i1) {
+ i1 = i1 | 0;
+ ___cxa_begin_catch(i1 | 0) | 0;
+ __ZSt9terminatev();
+}
+function __ZN17b2ContactListener12BeginContactEP9b2Contact(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ return;
+}
+function dynCall_ii(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ return FUNCTION_TABLE_ii[i2 & 3](i1 | 0) | 0;
+}
+function __ZN17b2ContactListener10EndContactEP9b2Contact(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ return;
+}
+function b11(i1, i2, i3, i4) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ abort(11);
+}
+function dynCall_vi(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ FUNCTION_TABLE_vi[i2 & 31](i1 | 0);
+}
+function b0(i1, i2, i3) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ abort(0);
+ return 0;
+}
+function __ZNK10__cxxabiv116__shim_type_info5noop2Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function __ZNK10__cxxabiv116__shim_type_info5noop1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function b5(i1, i2, i3) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ abort(5);
+}
+function __ZNK14b2PolygonShape13GetChildCountEv(i1) {
+ i1 = i1 | 0;
+ return 1;
+}
+function __ZN10__cxxabiv116__shim_type_infoD2Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function b7(i1, i2, d3) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ d3 = +d3;
+ abort(7);
+}
+function __ZNK11b2EdgeShape13GetChildCountEv(i1) {
+ i1 = i1 | 0;
+ return 1;
+}
+function __ZNK7b2Timer15GetMillisecondsEv(i1) {
+ i1 = i1 | 0;
+ return 0.0;
+}
+function __ZN25b2PolygonAndCircleContactD1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function __ZN24b2ChainAndPolygonContactD1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function b9(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ abort(9);
+ return 0;
+}
+function __ZN23b2EdgeAndPolygonContactD1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function __ZN23b2ChainAndCircleContactD1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function __ZN22b2EdgeAndCircleContactD1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function dynCall_v(i1) {
+ i1 = i1 | 0;
+ FUNCTION_TABLE_v[i1 & 3]();
+}
+function __ZNKSt9bad_alloc4whatEv(i1) {
+ i1 = i1 | 0;
+ return 7688;
+}
+function ___cxa_pure_virtual__wrapper() {
+ ___cxa_pure_virtual();
+}
+function __ZN17b2ContactListenerD1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function __ZN16b2PolygonContactD1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function __ZN15b2ContactFilterD1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function __ZN15b2CircleContactD1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function __ZN14b2PolygonShapeD1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function b3(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ abort(3);
+}
+function runPostSets() {
+ HEAP32[1932] = __ZTISt9exception;
+}
+function __ZN11b2EdgeShapeD1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function __ZNSt9type_infoD2Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function __ZN7b2Timer5ResetEv(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function stackRestore(i1) {
+ i1 = i1 | 0;
+ STACKTOP = i1;
+}
+function setTempRet9(i1) {
+ i1 = i1 | 0;
+ tempRet9 = i1;
+}
+function setTempRet8(i1) {
+ i1 = i1 | 0;
+ tempRet8 = i1;
+}
+function setTempRet7(i1) {
+ i1 = i1 | 0;
+ tempRet7 = i1;
+}
+function setTempRet6(i1) {
+ i1 = i1 | 0;
+ tempRet6 = i1;
+}
+function setTempRet5(i1) {
+ i1 = i1 | 0;
+ tempRet5 = i1;
+}
+function setTempRet4(i1) {
+ i1 = i1 | 0;
+ tempRet4 = i1;
+}
+function setTempRet3(i1) {
+ i1 = i1 | 0;
+ tempRet3 = i1;
+}
+function setTempRet2(i1) {
+ i1 = i1 | 0;
+ tempRet2 = i1;
+}
+function setTempRet1(i1) {
+ i1 = i1 | 0;
+ tempRet1 = i1;
+}
+function setTempRet0(i1) {
+ i1 = i1 | 0;
+ tempRet0 = i1;
+}
+function __ZN9b2ContactD1Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function __ZN7b2TimerC2Ev(i1) {
+ i1 = i1 | 0;
+ return;
+}
+function b4(i1) {
+ i1 = i1 | 0;
+ abort(4);
+ return 0;
+}
+function stackSave() {
+ return STACKTOP | 0;
+}
+function b2(i1) {
+ i1 = i1 | 0;
+ abort(2);
+}
+function b6() {
+ abort(6);
+}
+
+// EMSCRIPTEN_END_FUNCS
+ var FUNCTION_TABLE_iiii = [b0,__ZNK11b2EdgeShape9TestPointERK11b2TransformRK6b2Vec2,__ZNK14b2PolygonShape9TestPointERK11b2TransformRK6b2Vec2,__ZN15b2ContactFilter13ShouldCollideEP9b2FixtureS1_,__ZNK10__cxxabiv117__class_type_info9can_catchEPKNS_16__shim_type_infoERPv,b0,b0,b0];
+ var FUNCTION_TABLE_viiiii = [b1,__ZNK10__cxxabiv117__class_type_info16search_below_dstEPNS_19__dynamic_cast_infoEPKvib,__ZNK10__cxxabiv120__si_class_type_info16search_below_dstEPNS_19__dynamic_cast_infoEPKvib,b1];
+ var FUNCTION_TABLE_vi = [b2,__ZN11b2EdgeShapeD1Ev,__ZN11b2EdgeShapeD0Ev,__ZN14b2PolygonShapeD1Ev,__ZN14b2PolygonShapeD0Ev,__ZN17b2ContactListenerD1Ev,__ZN17b2ContactListenerD0Ev,__ZN15b2ContactFilterD1Ev,__ZN15b2ContactFilterD0Ev,__ZN9b2ContactD1Ev,__ZN9b2ContactD0Ev,__ZN22b2EdgeAndCircleContactD1Ev,__ZN22b2EdgeAndCircleContactD0Ev,__ZN23b2EdgeAndPolygonContactD1Ev,__ZN23b2EdgeAndPolygonContactD0Ev,__ZN25b2PolygonAndCircleContactD1Ev,__ZN25b2PolygonAndCircleContactD0Ev,__ZN16b2PolygonContactD1Ev,__ZN16b2PolygonContactD0Ev,__ZN23b2ChainAndCircleContactD1Ev,__ZN23b2ChainAndCircleContactD0Ev,__ZN24b2ChainAndPolygonContactD1Ev,__ZN24b2ChainAndPolygonContactD0Ev,__ZN15b2CircleContactD1Ev,__ZN15b2CircleContactD0Ev,__ZN10__cxxabiv116__shim_type_infoD2Ev,__ZN10__cxxabiv117__class_type_infoD0Ev,__ZNK10__cxxabiv116__shim_type_info5noop1Ev,__ZNK10__cxxabiv116__shim_type_info5noop2Ev
+ ,__ZN10__cxxabiv120__si_class_type_infoD0Ev,__ZNSt9bad_allocD2Ev,__ZNSt9bad_allocD0Ev];
+ var FUNCTION_TABLE_vii = [b3,__ZN17b2ContactListener12BeginContactEP9b2Contact,__ZN17b2ContactListener10EndContactEP9b2Contact,__ZN15b2CircleContact7DestroyEP9b2ContactP16b2BlockAllocator,__ZN25b2PolygonAndCircleContact7DestroyEP9b2ContactP16b2BlockAllocator,__ZN16b2PolygonContact7DestroyEP9b2ContactP16b2BlockAllocator,__ZN22b2EdgeAndCircleContact7DestroyEP9b2ContactP16b2BlockAllocator,__ZN23b2EdgeAndPolygonContact7DestroyEP9b2ContactP16b2BlockAllocator,__ZN23b2ChainAndCircleContact7DestroyEP9b2ContactP16b2BlockAllocator,__ZN24b2ChainAndPolygonContact7DestroyEP9b2ContactP16b2BlockAllocator,b3,b3,b3,b3,b3,b3];
+ var FUNCTION_TABLE_ii = [b4,__ZNK11b2EdgeShape13GetChildCountEv,__ZNK14b2PolygonShape13GetChildCountEv,__ZNKSt9bad_alloc4whatEv];
+ var FUNCTION_TABLE_viii = [b5,__ZN17b2ContactListener8PreSolveEP9b2ContactPK10b2Manifold,__ZN17b2ContactListener9PostSolveEP9b2ContactPK16b2ContactImpulse,b5];
+ var FUNCTION_TABLE_v = [b6,___cxa_pure_virtual__wrapper,__Z4iterv,b6];
+ var FUNCTION_TABLE_viid = [b7,__ZNK11b2EdgeShape11ComputeMassEP10b2MassDataf,__ZNK14b2PolygonShape11ComputeMassEP10b2MassDataf,b7];
+ var FUNCTION_TABLE_viiiiii = [b8,__ZNK10__cxxabiv117__class_type_info16search_above_dstEPNS_19__dynamic_cast_infoEPKvS4_ib,__ZNK10__cxxabiv120__si_class_type_info16search_above_dstEPNS_19__dynamic_cast_infoEPKvS4_ib,b8];
+ var FUNCTION_TABLE_iii = [b9,__ZNK11b2EdgeShape5CloneEP16b2BlockAllocator,__ZNK14b2PolygonShape5CloneEP16b2BlockAllocator,__Z14b2PairLessThanRK6b2PairS1_];
+ var FUNCTION_TABLE_iiiiii = [b10,__ZNK11b2EdgeShape7RayCastEP15b2RayCastOutputRK14b2RayCastInputRK11b2Transformi,__ZNK14b2PolygonShape7RayCastEP15b2RayCastOutputRK14b2RayCastInputRK11b2Transformi,__ZN15b2CircleContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator,__ZN25b2PolygonAndCircleContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator,__ZN16b2PolygonContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator,__ZN22b2EdgeAndCircleContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator,__ZN23b2EdgeAndPolygonContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator,__ZN23b2ChainAndCircleContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator,__ZN24b2ChainAndPolygonContact6CreateEP9b2FixtureiS1_iP16b2BlockAllocator,b10,b10,b10,b10,b10,b10];
+ var FUNCTION_TABLE_viiii = [b11,__ZNK11b2EdgeShape11ComputeAABBEP6b2AABBRK11b2Transformi,__ZNK14b2PolygonShape11ComputeAABBEP6b2AABBRK11b2Transformi,__ZN22b2EdgeAndCircleContact8EvaluateEP10b2ManifoldRK11b2TransformS4_,__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_,__ZN25b2PolygonAndCircleContact8EvaluateEP10b2ManifoldRK11b2TransformS4_,__ZN16b2PolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_,__ZN23b2ChainAndCircleContact8EvaluateEP10b2ManifoldRK11b2TransformS4_,__ZN24b2ChainAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_,__ZN15b2CircleContact8EvaluateEP10b2ManifoldRK11b2TransformS4_,__ZNK10__cxxabiv117__class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi,__ZNK10__cxxabiv120__si_class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi,b11,b11,b11,b11];
+
+ return { _strlen: _strlen, _free: _free, _main: _main, _memset: _memset, _malloc: _malloc, _memcpy: _memcpy, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, setThrew: setThrew, setTempRet0: setTempRet0, setTempRet1: setTempRet1, setTempRet2: setTempRet2, setTempRet3: setTempRet3, setTempRet4: setTempRet4, setTempRet5: setTempRet5, setTempRet6: setTempRet6, setTempRet7: setTempRet7, setTempRet8: setTempRet8, setTempRet9: setTempRet9, dynCall_iiii: dynCall_iiii, dynCall_viiiii: dynCall_viiiii, dynCall_vi: dynCall_vi, dynCall_vii: dynCall_vii, dynCall_ii: dynCall_ii, dynCall_viii: dynCall_viii, dynCall_v: dynCall_v, dynCall_viid: dynCall_viid, dynCall_viiiiii: dynCall_viiiiii, dynCall_iii: dynCall_iii, dynCall_iiiiii: dynCall_iiiiii, dynCall_viiii: dynCall_viiii };
+})
+// EMSCRIPTEN_END_ASM
+({ "Math": Math, "Int8Array": Int8Array, "Int16Array": Int16Array, "Int32Array": Int32Array, "Uint8Array": Uint8Array, "Uint16Array": Uint16Array, "Uint32Array": Uint32Array, "Float32Array": Float32Array, "Float64Array": Float64Array }, { "abort": abort, "assert": assert, "asmPrintInt": asmPrintInt, "asmPrintFloat": asmPrintFloat, "min": Math_min, "invoke_iiii": invoke_iiii, "invoke_viiiii": invoke_viiiii, "invoke_vi": invoke_vi, "invoke_vii": invoke_vii, "invoke_ii": invoke_ii, "invoke_viii": invoke_viii, "invoke_v": invoke_v, "invoke_viid": invoke_viid, "invoke_viiiiii": invoke_viiiiii, "invoke_iii": invoke_iii, "invoke_iiiiii": invoke_iiiiii, "invoke_viiii": invoke_viiii, "___cxa_throw": ___cxa_throw, "_emscripten_run_script": _emscripten_run_script, "_cosf": _cosf, "_send": _send, "__ZSt9terminatev": __ZSt9terminatev, "__reallyNegative": __reallyNegative, "___cxa_is_number_type": ___cxa_is_number_type, "___assert_fail": ___assert_fail, "___cxa_allocate_exception": ___cxa_allocate_exception, "___cxa_find_matching_catch": ___cxa_find_matching_catch, "_fflush": _fflush, "_pwrite": _pwrite, "___setErrNo": ___setErrNo, "_sbrk": _sbrk, "___cxa_begin_catch": ___cxa_begin_catch, "_sinf": _sinf, "_fileno": _fileno, "___resumeException": ___resumeException, "__ZSt18uncaught_exceptionv": __ZSt18uncaught_exceptionv, "_sysconf": _sysconf, "_clock": _clock, "_emscripten_memcpy_big": _emscripten_memcpy_big, "_puts": _puts, "_mkport": _mkport, "_floorf": _floorf, "_sqrtf": _sqrtf, "_write": _write, "_emscripten_set_main_loop": _emscripten_set_main_loop, "___errno_location": ___errno_location, "__ZNSt9exceptionD2Ev": __ZNSt9exceptionD2Ev, "_printf": _printf, "___cxa_does_inherit": ___cxa_does_inherit, "__exit": __exit, "_fputc": _fputc, "_abort": _abort, "_fwrite": _fwrite, "_time": _time, "_fprintf": _fprintf, "_emscripten_cancel_main_loop": _emscripten_cancel_main_loop, "__formatString": __formatString, "_fputs": _fputs, "_exit": _exit, "___cxa_pure_virtual": ___cxa_pure_virtual, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX, "tempDoublePtr": tempDoublePtr, "ABORT": ABORT, "NaN": NaN, "Infinity": Infinity, "__ZTISt9exception": __ZTISt9exception }, buffer);
+var _strlen = Module["_strlen"] = asm["_strlen"];
+var _free = Module["_free"] = asm["_free"];
+var _main = Module["_main"] = asm["_main"];
+var _memset = Module["_memset"] = asm["_memset"];
+var _malloc = Module["_malloc"] = asm["_malloc"];
+var _memcpy = Module["_memcpy"] = asm["_memcpy"];
+var runPostSets = Module["runPostSets"] = asm["runPostSets"];
+var dynCall_iiii = Module["dynCall_iiii"] = asm["dynCall_iiii"];
+var dynCall_viiiii = Module["dynCall_viiiii"] = asm["dynCall_viiiii"];
+var dynCall_vi = Module["dynCall_vi"] = asm["dynCall_vi"];
+var dynCall_vii = Module["dynCall_vii"] = asm["dynCall_vii"];
+var dynCall_ii = Module["dynCall_ii"] = asm["dynCall_ii"];
+var dynCall_viii = Module["dynCall_viii"] = asm["dynCall_viii"];
+var dynCall_v = Module["dynCall_v"] = asm["dynCall_v"];
+var dynCall_viid = Module["dynCall_viid"] = asm["dynCall_viid"];
+var dynCall_viiiiii = Module["dynCall_viiiiii"] = asm["dynCall_viiiiii"];
+var dynCall_iii = Module["dynCall_iii"] = asm["dynCall_iii"];
+var dynCall_iiiiii = Module["dynCall_iiiiii"] = asm["dynCall_iiiiii"];
+var dynCall_viiii = Module["dynCall_viiii"] = asm["dynCall_viiii"];
+
+Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
+Runtime.stackSave = function() { return asm['stackSave']() };
+Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
+
+
+// Warning: printing of i64 values may be slightly rounded! No deep i64 math used, so precise i64 code not included
+var i64Math = null;
+
+// === Auto-generated postamble setup entry stuff ===
+
+if (memoryInitializer) {
+ if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
+ var data = Module['readBinary'](memoryInitializer);
+ HEAPU8.set(data, STATIC_BASE);
+ } else {
+ addRunDependency('memory initializer');
+ Browser.asyncLoad(memoryInitializer, function(data) {
+ HEAPU8.set(data, STATIC_BASE);
+ removeRunDependency('memory initializer');
+ }, function(data) {
+ throw 'could not load memory initializer ' + memoryInitializer;
+ });
+ }
+}
+
+function ExitStatus(status) {
+ this.name = "ExitStatus";
+ this.message = "Program terminated with exit(" + status + ")";
+ this.status = status;
+};
+ExitStatus.prototype = new Error();
+ExitStatus.prototype.constructor = ExitStatus;
+
+var initialStackTop;
+var preloadStartTime = null;
+var calledMain = false;
+
+dependenciesFulfilled = function runCaller() {
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
+ if (!Module['calledRun'] && shouldRunNow) run([].concat(Module["arguments"]));
+ if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
+}
+
+Module['callMain'] = Module.callMain = function callMain(args) {
+ assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');
+ assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
+
+ args = args || [];
+
+ ensureInitRuntime();
+
+ var argc = args.length+1;
+ function pad() {
+ for (var i = 0; i < 4-1; i++) {
+ argv.push(0);
+ }
+ }
+ var argv = [allocate(intArrayFromString("/bin/this.program"), 'i8', ALLOC_NORMAL) ];
+ pad();
+ for (var i = 0; i < argc-1; i = i + 1) {
+ argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL));
+ pad();
+ }
+ argv.push(0);
+ argv = allocate(argv, 'i32', ALLOC_NORMAL);
+
+ initialStackTop = STACKTOP;
+
+ try {
+
+ var ret = Module['_main'](argc, argv, 0);
+
+
+ // if we're not running an evented main loop, it's time to exit
+ if (!Module['noExitRuntime']) {
+ exit(ret);
+ }
+ }
+ catch(e) {
+ if (e instanceof ExitStatus) {
+ // exit() throws this once it's done to make sure execution
+ // has been stopped completely
+ return;
+ } else if (e == 'SimulateInfiniteLoop') {
+ // running an evented main loop, don't immediately exit
+ Module['noExitRuntime'] = true;
+ return;
+ } else {
+ if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
+ throw e;
+ }
+ } finally {
+ calledMain = true;
+ }
+}
+
+
+
+
+function run(args) {
+ args = args || Module['arguments'];
+
+ if (preloadStartTime === null) preloadStartTime = Date.now();
+
+ if (runDependencies > 0) {
+ Module.printErr('run() called, but dependencies remain, so not running');
+ return;
+ }
+
+ preRun();
+
+ if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
+ if (Module['calledRun']) return; // run may have just been called through dependencies being fulfilled just in this very frame
+
+ function doRun() {
+ if (Module['calledRun']) return; // run may have just been called while the async setStatus time below was happening
+ Module['calledRun'] = true;
+
+ ensureInitRuntime();
+
+ preMain();
+
+ if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) {
+ Module.printErr('pre-main prep time: ' + (Date.now() - preloadStartTime) + ' ms');
+ }
+
+ if (Module['_main'] && shouldRunNow) {
+ Module['callMain'](args);
+ }
+
+ postRun();
+ }
+
+ if (Module['setStatus']) {
+ Module['setStatus']('Running...');
+ setTimeout(function() {
+ setTimeout(function() {
+ Module['setStatus']('');
+ }, 1);
+ if (!ABORT) doRun();
+ }, 1);
+ } else {
+ doRun();
+ }
+}
+Module['run'] = Module.run = run;
+
+function exit(status) {
+ ABORT = true;
+ EXITSTATUS = status;
+ STACKTOP = initialStackTop;
+
+ // exit the runtime
+ exitRuntime();
+
+ // TODO We should handle this differently based on environment.
+ // In the browser, the best we can do is throw an exception
+ // to halt execution, but in node we could process.exit and
+ // I'd imagine SM shell would have something equivalent.
+ // This would let us set a proper exit status (which
+ // would be great for checking test exit statuses).
+ // https://github.com/kripken/emscripten/issues/1371
+
+ // throw an exception to halt the current execution
+ throw new ExitStatus(status);
+}
+Module['exit'] = Module.exit = exit;
+
+function abort(text) {
+ if (text) {
+ Module.print(text);
+ Module.printErr(text);
+ }
+
+ ABORT = true;
+ EXITSTATUS = 1;
+
+ var extra = '\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.';
+
+ throw 'abort() at ' + stackTrace() + extra;
+}
+Module['abort'] = Module.abort = abort;
+
+// {{PRE_RUN_ADDITIONS}}
+
+if (Module['preInit']) {
+ if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
+ while (Module['preInit'].length > 0) {
+ Module['preInit'].pop()();
+ }
+}
+
+// shouldRunNow refers to calling main(), not run().
+var shouldRunNow = true;
+if (Module['noInitialRun']) {
+ shouldRunNow = false;
+}
+
+
+run([].concat(Module["arguments"]));
diff --git a/test/mjsunit/asm/embenchen/copy.js b/test/mjsunit/asm/embenchen/copy.js
new file mode 100644
index 000000000..8cf63f50d
--- /dev/null
+++ b/test/mjsunit/asm/embenchen/copy.js
@@ -0,0 +1,5980 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var EXPECTED_OUTPUT = 'sum:8930\n';
+var Module = {
+ arguments: [1],
+ print: function(x) {Module.printBuffer += x + '\n';},
+ preRun: [function() {Module.printBuffer = ''}],
+ postRun: [function() {
+ assertEquals(EXPECTED_OUTPUT, Module.printBuffer);
+ }],
+};
+// The Module object: Our interface to the outside world. We import
+// and export values on it, and do the work to get that through
+// closure compiler if necessary. There are various ways Module can be used:
+// 1. Not defined. We create it here
+// 2. A function parameter, function(Module) { ..generated code.. }
+// 3. pre-run appended it, var Module = {}; ..generated code..
+// 4. External script tag defines var Module.
+// We need to do an eval in order to handle the closure compiler
+// case, where this code here is minified but Module was defined
+// elsewhere (e.g. case 4 above). We also need to check if Module
+// already exists (e.g. case 3 above).
+// Note that if you want to run closure, and also to use Module
+// after the generated code, you will need to define var Module = {};
+// before the code. Then that object will be used in the code, and you
+// can continue to use Module afterwards as well.
+var Module;
+if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {};
+
+// Sometimes an existing Module object exists with properties
+// meant to overwrite the default module functionality. Here
+// we collect those properties and reapply _after_ we configure
+// the current environment's defaults to avoid having to be so
+// defensive during initialization.
+var moduleOverrides = {};
+for (var key in Module) {
+ if (Module.hasOwnProperty(key)) {
+ moduleOverrides[key] = Module[key];
+ }
+}
+
+// The environment setup code below is customized to use Module.
+// *** Environment setup code ***
+var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
+var ENVIRONMENT_IS_WEB = typeof window === 'object';
+var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
+var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+
+if (ENVIRONMENT_IS_NODE) {
+ // Expose functionality in the same simple way that the shells work
+ // Note that we pollute the global namespace here, otherwise we break in node
+ if (!Module['print']) Module['print'] = function print(x) {
+ process['stdout'].write(x + '\n');
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ process['stderr'].write(x + '\n');
+ };
+
+ var nodeFS = require('fs');
+ var nodePath = require('path');
+
+ Module['read'] = function read(filename, binary) {
+ filename = nodePath['normalize'](filename);
+ var ret = nodeFS['readFileSync'](filename);
+ // The path is absolute if the normalized version is the same as the resolved.
+ if (!ret && filename != nodePath['resolve'](filename)) {
+ filename = path.join(__dirname, '..', 'src', filename);
+ ret = nodeFS['readFileSync'](filename);
+ }
+ if (ret && !binary) ret = ret.toString();
+ return ret;
+ };
+
+ Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
+
+ Module['load'] = function load(f) {
+ globalEval(read(f));
+ };
+
+ Module['arguments'] = process['argv'].slice(2);
+
+ module['exports'] = Module;
+}
+else if (ENVIRONMENT_IS_SHELL) {
+ if (!Module['print']) Module['print'] = print;
+ if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
+
+ if (typeof read != 'undefined') {
+ Module['read'] = read;
+ } else {
+ Module['read'] = function read() { throw 'no read() available (jsc?)' };
+ }
+
+ Module['readBinary'] = function readBinary(f) {
+ return read(f, 'binary');
+ };
+
+ if (typeof scriptArgs != 'undefined') {
+ Module['arguments'] = scriptArgs;
+ } else if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ this['Module'] = Module;
+
+ eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
+}
+else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
+ Module['read'] = function read(url) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ xhr.send(null);
+ return xhr.responseText;
+ };
+
+ if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ if (typeof console !== 'undefined') {
+ if (!Module['print']) Module['print'] = function print(x) {
+ console.log(x);
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ console.log(x);
+ };
+ } else {
+ // Probably a worker, and without console.log. We can do very little here...
+ var TRY_USE_DUMP = false;
+ if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
+ dump(x);
+ }) : (function(x) {
+ // self.postMessage(x); // enable this if you want stdout to be sent as messages
+ }));
+ }
+
+ if (ENVIRONMENT_IS_WEB) {
+ window['Module'] = Module;
+ } else {
+ Module['load'] = importScripts;
+ }
+}
+else {
+ // Unreachable because SHELL is dependant on the others
+ throw 'Unknown runtime environment. Where are we?';
+}
+
+function globalEval(x) {
+ eval.call(null, x);
+}
+if (!Module['load'] == 'undefined' && Module['read']) {
+ Module['load'] = function load(f) {
+ globalEval(Module['read'](f));
+ };
+}
+if (!Module['print']) {
+ Module['print'] = function(){};
+}
+if (!Module['printErr']) {
+ Module['printErr'] = Module['print'];
+}
+if (!Module['arguments']) {
+ Module['arguments'] = [];
+}
+// *** Environment setup code ***
+
+// Closure helpers
+Module.print = Module['print'];
+Module.printErr = Module['printErr'];
+
+// Callbacks
+Module['preRun'] = [];
+Module['postRun'] = [];
+
+// Merge back in the overrides
+for (var key in moduleOverrides) {
+ if (moduleOverrides.hasOwnProperty(key)) {
+ Module[key] = moduleOverrides[key];
+ }
+}
+
+
+
+// === Auto-generated preamble library stuff ===
+
+//========================================
+// Runtime code shared with compiler
+//========================================
+
+var Runtime = {
+ stackSave: function () {
+ return STACKTOP;
+ },
+ stackRestore: function (stackTop) {
+ STACKTOP = stackTop;
+ },
+ forceAlign: function (target, quantum) {
+ quantum = quantum || 4;
+ if (quantum == 1) return target;
+ if (isNumber(target) && isNumber(quantum)) {
+ return Math.ceil(target/quantum)*quantum;
+ } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
+ return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')';
+ }
+ return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
+ },
+ isNumberType: function (type) {
+ return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
+ },
+ isPointerType: function isPointerType(type) {
+ return type[type.length-1] == '*';
+},
+ isStructType: function isStructType(type) {
+ if (isPointerType(type)) return false;
+ if (isArrayType(type)) return true;
+ if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
+ // See comment in isStructPointerType()
+ return type[0] == '%';
+},
+ INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
+ FLOAT_TYPES: {"float":0,"double":0},
+ or64: function (x, y) {
+ var l = (x | 0) | (y | 0);
+ var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ and64: function (x, y) {
+ var l = (x | 0) & (y | 0);
+ var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ xor64: function (x, y) {
+ var l = (x | 0) ^ (y | 0);
+ var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ getNativeTypeSize: function (type) {
+ switch (type) {
+ case 'i1': case 'i8': return 1;
+ case 'i16': return 2;
+ case 'i32': return 4;
+ case 'i64': return 8;
+ case 'float': return 4;
+ case 'double': return 8;
+ default: {
+ if (type[type.length-1] === '*') {
+ return Runtime.QUANTUM_SIZE; // A pointer
+ } else if (type[0] === 'i') {
+ var bits = parseInt(type.substr(1));
+ assert(bits % 8 === 0);
+ return bits/8;
+ } else {
+ return 0;
+ }
+ }
+ }
+ },
+ getNativeFieldSize: function (type) {
+ return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
+ },
+ dedup: function dedup(items, ident) {
+ var seen = {};
+ if (ident) {
+ return items.filter(function(item) {
+ if (seen[item[ident]]) return false;
+ seen[item[ident]] = true;
+ return true;
+ });
+ } else {
+ return items.filter(function(item) {
+ if (seen[item]) return false;
+ seen[item] = true;
+ return true;
+ });
+ }
+},
+ set: function set() {
+ var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
+ var ret = {};
+ for (var i = 0; i < args.length; i++) {
+ ret[args[i]] = 0;
+ }
+ return ret;
+},
+ STACK_ALIGN: 8,
+ getAlignSize: function (type, size, vararg) {
+ // we align i64s and doubles on 64-bit boundaries, unlike x86
+ if (!vararg && (type == 'i64' || type == 'double')) return 8;
+ if (!type) return Math.min(size, 8); // align structures internally to 64 bits
+ return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
+ },
+ calculateStructAlignment: function calculateStructAlignment(type) {
+ type.flatSize = 0;
+ type.alignSize = 0;
+ var diffs = [];
+ var prev = -1;
+ var index = 0;
+ type.flatIndexes = type.fields.map(function(field) {
+ index++;
+ var size, alignSize;
+ if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
+ size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
+ alignSize = Runtime.getAlignSize(field, size);
+ } else if (Runtime.isStructType(field)) {
+ if (field[1] === '0') {
+ // this is [0 x something]. When inside another structure like here, it must be at the end,
+ // and it adds no size
+ // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');
+ size = 0;
+ if (Types.types[field]) {
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ } else {
+ alignSize = type.alignSize || QUANTUM_SIZE;
+ }
+ } else {
+ size = Types.types[field].flatSize;
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ }
+ } else if (field[0] == 'b') {
+ // bN, large number field, like a [N x i8]
+ size = field.substr(1)|0;
+ alignSize = 1;
+ } else if (field[0] === '<') {
+ // vector type
+ size = alignSize = Types.types[field].flatSize; // fully aligned
+ } else if (field[0] === 'i') {
+ // illegal integer field, that could not be legalized because it is an internal structure field
+ // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
+ size = alignSize = parseInt(field.substr(1))/8;
+ assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
+ } else {
+ assert(false, 'invalid type for calculateStructAlignment');
+ }
+ if (type.packed) alignSize = 1;
+ type.alignSize = Math.max(type.alignSize, alignSize);
+ var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
+ type.flatSize = curr + size;
+ if (prev >= 0) {
+ diffs.push(curr-prev);
+ }
+ prev = curr;
+ return curr;
+ });
+ if (type.name_ && type.name_[0] === '[') {
+ // arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
+ // allocating a potentially huge array for [999999 x i8] etc.
+ type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
+ }
+ type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
+ if (diffs.length == 0) {
+ type.flatFactor = type.flatSize;
+ } else if (Runtime.dedup(diffs).length == 1) {
+ type.flatFactor = diffs[0];
+ }
+ type.needsFlattening = (type.flatFactor != 1);
+ return type.flatIndexes;
+ },
+ generateStructInfo: function (struct, typeName, offset) {
+ var type, alignment;
+ if (typeName) {
+ offset = offset || 0;
+ type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
+ if (!type) return null;
+ if (type.fields.length != struct.length) {
+ printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');
+ return null;
+ }
+ alignment = type.flatIndexes;
+ } else {
+ var type = { fields: struct.map(function(item) { return item[0] }) };
+ alignment = Runtime.calculateStructAlignment(type);
+ }
+ var ret = {
+ __size__: type.flatSize
+ };
+ if (typeName) {
+ struct.forEach(function(item, i) {
+ if (typeof item === 'string') {
+ ret[item] = alignment[i] + offset;
+ } else {
+ // embedded struct
+ var key;
+ for (var k in item) key = k;
+ ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
+ }
+ });
+ } else {
+ struct.forEach(function(item, i) {
+ ret[item[1]] = alignment[i];
+ });
+ }
+ return ret;
+ },
+ dynCall: function (sig, ptr, args) {
+ if (args && args.length) {
+ if (!args.splice) args = Array.prototype.slice.call(args);
+ args.splice(0, 0, ptr);
+ return Module['dynCall_' + sig].apply(null, args);
+ } else {
+ return Module['dynCall_' + sig].call(null, ptr);
+ }
+ },
+ functionPointers: [],
+ addFunction: function (func) {
+ for (var i = 0; i < Runtime.functionPointers.length; i++) {
+ if (!Runtime.functionPointers[i]) {
+ Runtime.functionPointers[i] = func;
+ return 2*(1 + i);
+ }
+ }
+ throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
+ },
+ removeFunction: function (index) {
+ Runtime.functionPointers[(index-2)/2] = null;
+ },
+ getAsmConst: function (code, numArgs) {
+ // code is a constant string on the heap, so we can cache these
+ if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
+ var func = Runtime.asmConstCache[code];
+ if (func) return func;
+ var args = [];
+ for (var i = 0; i < numArgs; i++) {
+ args.push(String.fromCharCode(36) + i); // $0, $1 etc
+ }
+ var source = Pointer_stringify(code);
+ if (source[0] === '"') {
+ // tolerate EM_ASM("..code..") even though EM_ASM(..code..) is correct
+ if (source.indexOf('"', 1) === source.length-1) {
+ source = source.substr(1, source.length-2);
+ } else {
+ // something invalid happened, e.g. EM_ASM("..code($0)..", input)
+ abort('invalid EM_ASM input |' + source + '|. Please use EM_ASM(..code..) (no quotes) or EM_ASM({ ..code($0).. }, input) (to input values)');
+ }
+ }
+ try {
+ var evalled = eval('(function(' + args.join(',') + '){ ' + source + ' })'); // new Function does not allow upvars in node
+ } catch(e) {
+ Module.printErr('error in executing inline EM_ASM code: ' + e + ' on: \n\n' + source + '\n\nwith args |' + args + '| (make sure to use the right one out of EM_ASM, EM_ASM_ARGS, etc.)');
+ throw e;
+ }
+ return Runtime.asmConstCache[code] = evalled;
+ },
+ warnOnce: function (text) {
+ if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
+ if (!Runtime.warnOnce.shown[text]) {
+ Runtime.warnOnce.shown[text] = 1;
+ Module.printErr(text);
+ }
+ },
+ funcWrappers: {},
+ getFuncWrapper: function (func, sig) {
+ assert(sig);
+ if (!Runtime.funcWrappers[func]) {
+ Runtime.funcWrappers[func] = function dynCall_wrapper() {
+ return Runtime.dynCall(sig, func, arguments);
+ };
+ }
+ return Runtime.funcWrappers[func];
+ },
+ UTF8Processor: function () {
+ var buffer = [];
+ var needed = 0;
+ this.processCChar = function (code) {
+ code = code & 0xFF;
+
+ if (buffer.length == 0) {
+ if ((code & 0x80) == 0x00) { // 0xxxxxxx
+ return String.fromCharCode(code);
+ }
+ buffer.push(code);
+ if ((code & 0xE0) == 0xC0) { // 110xxxxx
+ needed = 1;
+ } else if ((code & 0xF0) == 0xE0) { // 1110xxxx
+ needed = 2;
+ } else { // 11110xxx
+ needed = 3;
+ }
+ return '';
+ }
+
+ if (needed) {
+ buffer.push(code);
+ needed--;
+ if (needed > 0) return '';
+ }
+
+ var c1 = buffer[0];
+ var c2 = buffer[1];
+ var c3 = buffer[2];
+ var c4 = buffer[3];
+ var ret;
+ if (buffer.length == 2) {
+ ret = String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ } else if (buffer.length == 3) {
+ ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ } else {
+ // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |
+ ((c3 & 0x3F) << 6) | (c4 & 0x3F);
+ ret = String.fromCharCode(
+ Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,
+ (codePoint - 0x10000) % 0x400 + 0xDC00);
+ }
+ buffer.length = 0;
+ return ret;
+ }
+ this.processJSString = function processJSString(string) {
+ /* TODO: use TextEncoder when present,
+ var encoder = new TextEncoder();
+ encoder['encoding'] = "utf-8";
+ var utf8Array = encoder['encode'](aMsg.data);
+ */
+ string = unescape(encodeURIComponent(string));
+ var ret = [];
+ for (var i = 0; i < string.length; i++) {
+ ret.push(string.charCodeAt(i));
+ }
+ return ret;
+ }
+ },
+ getCompilerSetting: function (name) {
+ throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
+ },
+ stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+7)&-8); return ret; },
+ staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = (((STATICTOP)+7)&-8); return ret; },
+ dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = (((DYNAMICTOP)+7)&-8); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
+ alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },
+ makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*(+4294967296))) : ((+((low>>>0)))+((+((high|0)))*(+4294967296)))); return ret; },
+ GLOBAL_BASE: 8,
+ QUANTUM_SIZE: 4,
+ __dummy__: 0
+}
+
+
+Module['Runtime'] = Runtime;
+
+
+
+
+
+
+
+
+
+//========================================
+// Runtime essentials
+//========================================
+
+var __THREW__ = 0; // Used in checking for thrown exceptions.
+
+var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()
+var EXITSTATUS = 0;
+
+var undef = 0;
+// tempInt is used for 32-bit signed values or smaller. tempBigInt is used
+// for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
+var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
+var tempI64, tempI64b;
+var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
+
+function assert(condition, text) {
+ if (!condition) {
+ abort('Assertion failed: ' + text);
+ }
+}
+
+var globalScope = this;
+
+// C calling interface. A convenient way to call C functions (in C files, or
+// defined with extern "C").
+//
+// Note: LLVM optimizations can inline and remove functions, after which you will not be
+// able to call them. Closure can also do so. To avoid that, add your function to
+// the exports using something like
+//
+// -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]'
+//
+// @param ident The name of the C function (note that C++ functions will be name-mangled - use extern "C")
+// @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and
+// 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).
+// @param argTypes An array of the types of arguments for the function (if there are no arguments, this can be ommitted). Types are as in returnType,
+// except that 'array' is not possible (there is no way for us to know the length of the array)
+// @param args An array of the arguments to the function, as native JS values (as in returnType)
+// Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).
+// @return The return value, as a native JS value (as in returnType)
+function ccall(ident, returnType, argTypes, args) {
+ return ccallFunc(getCFunc(ident), returnType, argTypes, args);
+}
+Module["ccall"] = ccall;
+
+// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
+function getCFunc(ident) {
+ try {
+ var func = Module['_' + ident]; // closure exported function
+ if (!func) func = eval('_' + ident); // explicit lookup
+ } catch(e) {
+ }
+ assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
+ return func;
+}
+
+// Internal function that does a C call using a function, not an identifier
+function ccallFunc(func, returnType, argTypes, args) {
+ var stack = 0;
+ function toC(value, type) {
+ if (type == 'string') {
+ if (value === null || value === undefined || value === 0) return 0; // null string
+ value = intArrayFromString(value);
+ type = 'array';
+ }
+ if (type == 'array') {
+ if (!stack) stack = Runtime.stackSave();
+ var ret = Runtime.stackAlloc(value.length);
+ writeArrayToMemory(value, ret);
+ return ret;
+ }
+ return value;
+ }
+ function fromC(value, type) {
+ if (type == 'string') {
+ return Pointer_stringify(value);
+ }
+ assert(type != 'array');
+ return value;
+ }
+ var i = 0;
+ var cArgs = args ? args.map(function(arg) {
+ return toC(arg, argTypes[i++]);
+ }) : [];
+ var ret = fromC(func.apply(null, cArgs), returnType);
+ if (stack) Runtime.stackRestore(stack);
+ return ret;
+}
+
+// Returns a native JS wrapper for a C function. This is similar to ccall, but
+// returns a function you can call repeatedly in a normal way. For example:
+//
+// var my_function = cwrap('my_c_function', 'number', ['number', 'number']);
+// alert(my_function(5, 22));
+// alert(my_function(99, 12));
+//
+function cwrap(ident, returnType, argTypes) {
+ var func = getCFunc(ident);
+ return function() {
+ return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));
+ }
+}
+Module["cwrap"] = cwrap;
+
+// Sets a value in memory in a dynamic way at run-time. Uses the
+// type data. This is the same as makeSetValue, except that
+// makeSetValue is done at compile-time and generates the needed
+// code then, whereas this function picks the right code at
+// run-time.
+// Note that setValue and getValue only do *aligned* writes and reads!
+// Note that ccall uses JS types as for defining types, while setValue and
+// getValue need LLVM types ('i8', 'i32') - this is a lower-level operation
+function setValue(ptr, value, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': HEAP8[(ptr)]=value; break;
+ case 'i8': HEAP8[(ptr)]=value; break;
+ case 'i16': HEAP16[((ptr)>>1)]=value; break;
+ case 'i32': HEAP32[((ptr)>>2)]=value; break;
+ case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= (+1) ? (tempDouble > (+0) ? ((Math_min((+(Math_floor((tempDouble)/(+4294967296)))), (+4294967295)))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+4294967296))))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
+ case 'float': HEAPF32[((ptr)>>2)]=value; break;
+ case 'double': HEAPF64[((ptr)>>3)]=value; break;
+ default: abort('invalid type for setValue: ' + type);
+ }
+}
+Module['setValue'] = setValue;
+
+// Parallel to setValue.
+function getValue(ptr, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': return HEAP8[(ptr)];
+ case 'i8': return HEAP8[(ptr)];
+ case 'i16': return HEAP16[((ptr)>>1)];
+ case 'i32': return HEAP32[((ptr)>>2)];
+ case 'i64': return HEAP32[((ptr)>>2)];
+ case 'float': return HEAPF32[((ptr)>>2)];
+ case 'double': return HEAPF64[((ptr)>>3)];
+ default: abort('invalid type for setValue: ' + type);
+ }
+ return null;
+}
+Module['getValue'] = getValue;
+
+var ALLOC_NORMAL = 0; // Tries to use _malloc()
+var ALLOC_STACK = 1; // Lives for the duration of the current function call
+var ALLOC_STATIC = 2; // Cannot be freed
+var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
+var ALLOC_NONE = 4; // Do not allocate
+Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
+Module['ALLOC_STACK'] = ALLOC_STACK;
+Module['ALLOC_STATIC'] = ALLOC_STATIC;
+Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;
+Module['ALLOC_NONE'] = ALLOC_NONE;
+
+// allocate(): This is for internal use. You can use it yourself as well, but the interface
+// is a little tricky (see docs right below). The reason is that it is optimized
+// for multiple syntaxes to save space in generated code. So you should
+// normally not use allocate(), and instead allocate memory using _malloc(),
+// initialize it with setValue(), and so forth.
+// @slab: An array of data, or a number. If a number, then the size of the block to allocate,
+// in *bytes* (note that this is sometimes confusing: the next parameter does not
+// affect this!)
+// @types: Either an array of types, one for each byte (or 0 if no type at that position),
+// or a single type which is used for the entire block. This only matters if there
+// is initial data - if @slab is a number, then this does not matter at all and is
+// ignored.
+// @allocator: How to allocate memory, see ALLOC_*
+function allocate(slab, types, allocator, ptr) {
+ var zeroinit, size;
+ if (typeof slab === 'number') {
+ zeroinit = true;
+ size = slab;
+ } else {
+ zeroinit = false;
+ size = slab.length;
+ }
+
+ var singleType = typeof types === 'string' ? types : null;
+
+ var ret;
+ if (allocator == ALLOC_NONE) {
+ ret = ptr;
+ } else {
+ ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
+ }
+
+ if (zeroinit) {
+ var ptr = ret, stop;
+ assert((ret & 3) == 0);
+ stop = ret + (size & ~3);
+ for (; ptr < stop; ptr += 4) {
+ HEAP32[((ptr)>>2)]=0;
+ }
+ stop = ret + size;
+ while (ptr < stop) {
+ HEAP8[((ptr++)|0)]=0;
+ }
+ return ret;
+ }
+
+ if (singleType === 'i8') {
+ if (slab.subarray || slab.slice) {
+ HEAPU8.set(slab, ret);
+ } else {
+ HEAPU8.set(new Uint8Array(slab), ret);
+ }
+ return ret;
+ }
+
+ var i = 0, type, typeSize, previousType;
+ while (i < size) {
+ var curr = slab[i];
+
+ if (typeof curr === 'function') {
+ curr = Runtime.getFunctionIndex(curr);
+ }
+
+ type = singleType || types[i];
+ if (type === 0) {
+ i++;
+ continue;
+ }
+
+ if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
+
+ setValue(ret+i, curr, type);
+
+ // no need to look up size unless type changes, so cache it
+ if (previousType !== type) {
+ typeSize = Runtime.getNativeTypeSize(type);
+ previousType = type;
+ }
+ i += typeSize;
+ }
+
+ return ret;
+}
+Module['allocate'] = allocate;
+
+function Pointer_stringify(ptr, /* optional */ length) {
+ // TODO: use TextDecoder
+ // Find the length, and check for UTF while doing so
+ var hasUtf = false;
+ var t;
+ var i = 0;
+ while (1) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ if (t >= 128) hasUtf = true;
+ else if (t == 0 && !length) break;
+ i++;
+ if (length && i == length) break;
+ }
+ if (!length) length = i;
+
+ var ret = '';
+
+ if (!hasUtf) {
+ var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
+ var curr;
+ while (length > 0) {
+ curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
+ ret = ret ? ret + curr : curr;
+ ptr += MAX_CHUNK;
+ length -= MAX_CHUNK;
+ }
+ return ret;
+ }
+
+ var utf8 = new Runtime.UTF8Processor();
+ for (i = 0; i < length; i++) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ ret += utf8.processCChar(t);
+ }
+ return ret;
+}
+Module['Pointer_stringify'] = Pointer_stringify;
+
+// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF16ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
+ if (codeUnit == 0)
+ return str;
+ ++i;
+ // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
+ str += String.fromCharCode(codeUnit);
+ }
+}
+Module['UTF16ToString'] = UTF16ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
+function stringToUTF16(str, outPtr) {
+ for(var i = 0; i < str.length; ++i) {
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
+ HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP16[(((outPtr)+(str.length*2))>>1)]=0;
+}
+Module['stringToUTF16'] = stringToUTF16;
+
+// Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF32ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
+ if (utf32 == 0)
+ return str;
+ ++i;
+ // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
+ if (utf32 >= 0x10000) {
+ var ch = utf32 - 0x10000;
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
+ } else {
+ str += String.fromCharCode(utf32);
+ }
+ }
+}
+Module['UTF32ToString'] = UTF32ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
+// but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.
+function stringToUTF32(str, outPtr) {
+ var iChar = 0;
+ for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
+ var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
+ var trailSurrogate = str.charCodeAt(++iCodeUnit);
+ codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
+ }
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit;
+ ++iChar;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=0;
+}
+Module['stringToUTF32'] = stringToUTF32;
+
+function demangle(func) {
+ var i = 3;
+ // params, etc.
+ var basicTypes = {
+ 'v': 'void',
+ 'b': 'bool',
+ 'c': 'char',
+ 's': 'short',
+ 'i': 'int',
+ 'l': 'long',
+ 'f': 'float',
+ 'd': 'double',
+ 'w': 'wchar_t',
+ 'a': 'signed char',
+ 'h': 'unsigned char',
+ 't': 'unsigned short',
+ 'j': 'unsigned int',
+ 'm': 'unsigned long',
+ 'x': 'long long',
+ 'y': 'unsigned long long',
+ 'z': '...'
+ };
+ var subs = [];
+ var first = true;
+ function dump(x) {
+ //return;
+ if (x) Module.print(x);
+ Module.print(func);
+ var pre = '';
+ for (var a = 0; a < i; a++) pre += ' ';
+ Module.print (pre + '^');
+ }
+ function parseNested() {
+ i++;
+ if (func[i] === 'K') i++; // ignore const
+ var parts = [];
+ while (func[i] !== 'E') {
+ if (func[i] === 'S') { // substitution
+ i++;
+ var next = func.indexOf('_', i);
+ var num = func.substring(i, next) || 0;
+ parts.push(subs[num] || '?');
+ i = next+1;
+ continue;
+ }
+ if (func[i] === 'C') { // constructor
+ parts.push(parts[parts.length-1]);
+ i += 2;
+ continue;
+ }
+ var size = parseInt(func.substr(i));
+ var pre = size.toString().length;
+ if (!size || !pre) { i--; break; } // counter i++ below us
+ var curr = func.substr(i + pre, size);
+ parts.push(curr);
+ subs.push(curr);
+ i += pre + size;
+ }
+ i++; // skip E
+ return parts;
+ }
+ function parse(rawList, limit, allowVoid) { // main parser
+ limit = limit || Infinity;
+ var ret = '', list = [];
+ function flushList() {
+ return '(' + list.join(', ') + ')';
+ }
+ var name;
+ if (func[i] === 'N') {
+ // namespaced N-E
+ name = parseNested().join('::');
+ limit--;
+ if (limit === 0) return rawList ? [name] : name;
+ } else {
+ // not namespaced
+ if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
+ var size = parseInt(func.substr(i));
+ if (size) {
+ var pre = size.toString().length;
+ name = func.substr(i + pre, size);
+ i += pre + size;
+ }
+ }
+ first = false;
+ if (func[i] === 'I') {
+ i++;
+ var iList = parse(true);
+ var iRet = parse(true, 1, true);
+ ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
+ } else {
+ ret = name;
+ }
+ paramLoop: while (i < func.length && limit-- > 0) {
+ //dump('paramLoop');
+ var c = func[i++];
+ if (c in basicTypes) {
+ list.push(basicTypes[c]);
+ } else {
+ switch (c) {
+ case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
+ case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
+ case 'L': { // literal
+ i++; // skip basic type
+ var end = func.indexOf('E', i);
+ var size = end - i;
+ list.push(func.substr(i, size));
+ i += size + 2; // size + 'EE'
+ break;
+ }
+ case 'A': { // array
+ var size = parseInt(func.substr(i));
+ i += size.toString().length;
+ if (func[i] !== '_') throw '?';
+ i++; // skip _
+ list.push(parse(true, 1, true)[0] + ' [' + size + ']');
+ break;
+ }
+ case 'E': break paramLoop;
+ default: ret += '?' + c; break paramLoop;
+ }
+ }
+ }
+ if (!allowVoid && list.length === 1 && list[0] === 'void') list = []; // avoid (void)
+ if (rawList) {
+ if (ret) {
+ list.push(ret + '?');
+ }
+ return list;
+ } else {
+ return ret + flushList();
+ }
+ }
+ try {
+ // Special-case the entry point, since its name differs from other name mangling.
+ if (func == 'Object._main' || func == '_main') {
+ return 'main()';
+ }
+ if (typeof func === 'number') func = Pointer_stringify(func);
+ if (func[0] !== '_') return func;
+ if (func[1] !== '_') return func; // C function
+ if (func[2] !== 'Z') return func;
+ switch (func[3]) {
+ case 'n': return 'operator new()';
+ case 'd': return 'operator delete()';
+ }
+ return parse();
+ } catch(e) {
+ return func;
+ }
+}
+
+function demangleAll(text) {
+ return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });
+}
+
+function stackTrace() {
+ var stack = new Error().stack;
+ return stack ? demangleAll(stack) : '(no stack trace available)'; // Stack trace is not available at least on IE10 and Safari 6.
+}
+
+// Memory management
+
+var PAGE_SIZE = 4096;
+function alignMemoryPage(x) {
+ return (x+4095)&-4096;
+}
+
+var HEAP;
+var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
+
+var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area
+var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area
+var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk
+
+function enlargeMemory() {
+ abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
+}
+
+var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
+var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 134217728;
+var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
+
+var totalMemory = 4096;
+while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
+ if (totalMemory < 16*1024*1024) {
+ totalMemory *= 2;
+ } else {
+ totalMemory += 16*1024*1024
+ }
+}
+if (totalMemory !== TOTAL_MEMORY) {
+ Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
+ TOTAL_MEMORY = totalMemory;
+}
+
+// Initialize the runtime's memory
+// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
+assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
+ 'JS engine does not provide full typed array support');
+
+var buffer = new ArrayBuffer(TOTAL_MEMORY);
+HEAP8 = new Int8Array(buffer);
+HEAP16 = new Int16Array(buffer);
+HEAP32 = new Int32Array(buffer);
+HEAPU8 = new Uint8Array(buffer);
+HEAPU16 = new Uint16Array(buffer);
+HEAPU32 = new Uint32Array(buffer);
+HEAPF32 = new Float32Array(buffer);
+HEAPF64 = new Float64Array(buffer);
+
+// Endianness check (note: assumes compiler arch was little-endian)
+HEAP32[0] = 255;
+assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
+
+Module['HEAP'] = HEAP;
+Module['HEAP8'] = HEAP8;
+Module['HEAP16'] = HEAP16;
+Module['HEAP32'] = HEAP32;
+Module['HEAPU8'] = HEAPU8;
+Module['HEAPU16'] = HEAPU16;
+Module['HEAPU32'] = HEAPU32;
+Module['HEAPF32'] = HEAPF32;
+Module['HEAPF64'] = HEAPF64;
+
+function callRuntimeCallbacks(callbacks) {
+ while(callbacks.length > 0) {
+ var callback = callbacks.shift();
+ if (typeof callback == 'function') {
+ callback();
+ continue;
+ }
+ var func = callback.func;
+ if (typeof func === 'number') {
+ if (callback.arg === undefined) {
+ Runtime.dynCall('v', func);
+ } else {
+ Runtime.dynCall('vi', func, [callback.arg]);
+ }
+ } else {
+ func(callback.arg === undefined ? null : callback.arg);
+ }
+ }
+}
+
+var __ATPRERUN__ = []; // functions called before the runtime is initialized
+var __ATINIT__ = []; // functions called during startup
+var __ATMAIN__ = []; // functions called when main() is to be run
+var __ATEXIT__ = []; // functions called during shutdown
+var __ATPOSTRUN__ = []; // functions called after the runtime has exited
+
+var runtimeInitialized = false;
+
+function preRun() {
+ // compatibility - merge in anything from Module['preRun'] at this time
+ if (Module['preRun']) {
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
+ while (Module['preRun'].length) {
+ addOnPreRun(Module['preRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPRERUN__);
+}
+
+function ensureInitRuntime() {
+ if (runtimeInitialized) return;
+ runtimeInitialized = true;
+ callRuntimeCallbacks(__ATINIT__);
+}
+
+function preMain() {
+ callRuntimeCallbacks(__ATMAIN__);
+}
+
+function exitRuntime() {
+ callRuntimeCallbacks(__ATEXIT__);
+}
+
+function postRun() {
+ // compatibility - merge in anything from Module['postRun'] at this time
+ if (Module['postRun']) {
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
+ while (Module['postRun'].length) {
+ addOnPostRun(Module['postRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPOSTRUN__);
+}
+
+function addOnPreRun(cb) {
+ __ATPRERUN__.unshift(cb);
+}
+Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;
+
+function addOnInit(cb) {
+ __ATINIT__.unshift(cb);
+}
+Module['addOnInit'] = Module.addOnInit = addOnInit;
+
+function addOnPreMain(cb) {
+ __ATMAIN__.unshift(cb);
+}
+Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;
+
+function addOnExit(cb) {
+ __ATEXIT__.unshift(cb);
+}
+Module['addOnExit'] = Module.addOnExit = addOnExit;
+
+function addOnPostRun(cb) {
+ __ATPOSTRUN__.unshift(cb);
+}
+Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;
+
+// Tools
+
+// This processes a JS string into a C-line array of numbers, 0-terminated.
+// For LLVM-originating strings, see parser.js:parseLLVMString function
+function intArrayFromString(stringy, dontAddNull, length /* optional */) {
+ var ret = (new Runtime.UTF8Processor()).processJSString(stringy);
+ if (length) {
+ ret.length = length;
+ }
+ if (!dontAddNull) {
+ ret.push(0);
+ }
+ return ret;
+}
+Module['intArrayFromString'] = intArrayFromString;
+
+function intArrayToString(array) {
+ var ret = [];
+ for (var i = 0; i < array.length; i++) {
+ var chr = array[i];
+ if (chr > 0xFF) {
+ chr &= 0xFF;
+ }
+ ret.push(String.fromCharCode(chr));
+ }
+ return ret.join('');
+}
+Module['intArrayToString'] = intArrayToString;
+
+// Write a Javascript array to somewhere in the heap
+function writeStringToMemory(string, buffer, dontAddNull) {
+ var array = intArrayFromString(string, dontAddNull);
+ var i = 0;
+ while (i < array.length) {
+ var chr = array[i];
+ HEAP8[(((buffer)+(i))|0)]=chr;
+ i = i + 1;
+ }
+}
+Module['writeStringToMemory'] = writeStringToMemory;
+
+function writeArrayToMemory(array, buffer) {
+ for (var i = 0; i < array.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=array[i];
+ }
+}
+Module['writeArrayToMemory'] = writeArrayToMemory;
+
+function writeAsciiToMemory(str, buffer, dontAddNull) {
+ for (var i = 0; i < str.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=str.charCodeAt(i);
+ }
+ if (!dontAddNull) HEAP8[(((buffer)+(str.length))|0)]=0;
+}
+Module['writeAsciiToMemory'] = writeAsciiToMemory;
+
+function unSign(value, bits, ignore) {
+ if (value >= 0) {
+ return value;
+ }
+ return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
+ : Math.pow(2, bits) + value;
+}
+function reSign(value, bits, ignore) {
+ if (value <= 0) {
+ return value;
+ }
+ var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
+ : Math.pow(2, bits-1);
+ if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
+ // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
+ // TODO: In i64 mode 1, resign the two parts separately and safely
+ value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
+ }
+ return value;
+}
+
+// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
+if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
+ var ah = a >>> 16;
+ var al = a & 0xffff;
+ var bh = b >>> 16;
+ var bl = b & 0xffff;
+ return (al*bl + ((ah*bl + al*bh) << 16))|0;
+};
+Math.imul = Math['imul'];
+
+
+var Math_abs = Math.abs;
+var Math_cos = Math.cos;
+var Math_sin = Math.sin;
+var Math_tan = Math.tan;
+var Math_acos = Math.acos;
+var Math_asin = Math.asin;
+var Math_atan = Math.atan;
+var Math_atan2 = Math.atan2;
+var Math_exp = Math.exp;
+var Math_log = Math.log;
+var Math_sqrt = Math.sqrt;
+var Math_ceil = Math.ceil;
+var Math_floor = Math.floor;
+var Math_pow = Math.pow;
+var Math_imul = Math.imul;
+var Math_fround = Math.fround;
+var Math_min = Math.min;
+
+// A counter of dependencies for calling run(). If we need to
+// do asynchronous work before running, increment this and
+// decrement it. Incrementing must happen in a place like
+// PRE_RUN_ADDITIONS (used by emcc to add file preloading).
+// Note that you can add dependencies in preRun, even though
+// it happens right before run - run will be postponed until
+// the dependencies are met.
+var runDependencies = 0;
+var runDependencyWatcher = null;
+var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
+
+function addRunDependency(id) {
+ runDependencies++;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+}
+Module['addRunDependency'] = addRunDependency;
+function removeRunDependency(id) {
+ runDependencies--;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+ if (runDependencies == 0) {
+ if (runDependencyWatcher !== null) {
+ clearInterval(runDependencyWatcher);
+ runDependencyWatcher = null;
+ }
+ if (dependenciesFulfilled) {
+ var callback = dependenciesFulfilled;
+ dependenciesFulfilled = null;
+ callback(); // can add another dependenciesFulfilled
+ }
+ }
+}
+Module['removeRunDependency'] = removeRunDependency;
+
+Module["preloadedImages"] = {}; // maps url to image data
+Module["preloadedAudios"] = {}; // maps url to audio data
+
+
+var memoryInitializer = null;
+
+// === Body ===
+
+
+
+
+
+STATIC_BASE = 8;
+
+STATICTOP = STATIC_BASE + Runtime.alignMemory(27);
+/* global initializers */ __ATINIT__.push();
+
+
+/* memory initializer */ allocate([101,114,114,111,114,58,32,37,100,92,110,0,0,0,0,0,115,117,109,58,37,100,10,0], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
+
+
+
+
+var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8);
+
+assert(tempDoublePtr % 8 == 0);
+
+function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+}
+
+function copyTempDouble(ptr) {
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+ HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
+
+ HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
+
+ HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
+
+ HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
+
+}
+
+
+ function _malloc(bytes) {
+ /* Over-allocate to make sure it is byte-aligned by 8.
+ * This will leak memory, but this is only the dummy
+ * implementation (replaced by dlmalloc normally) so
+ * not an issue.
+ */
+ var ptr = Runtime.dynamicAlloc(bytes + 8);
+ return (ptr+8) & 0xFFFFFFF8;
+ }
+ Module["_malloc"] = _malloc;
+
+
+
+
+ var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};
+
+ var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
+
+
+ var ___errno_state=0;function ___setErrNo(value) {
+ // For convenient setting and returning of errno.
+ HEAP32[((___errno_state)>>2)]=value;
+ return value;
+ }
+
+ var TTY={ttys:[],init:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // currently, FS.init does not distinguish if process.stdin is a file or TTY
+ // // device, it always assumes it's a TTY device. because of this, we're forcing
+ // // process.stdin to UTF8 encoding to at least make stdin reading compatible
+ // // with text files until FS.init can be refactored.
+ // process['stdin']['setEncoding']('utf8');
+ // }
+ },shutdown:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
+ // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
+ // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
+ // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
+ // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
+ // process['stdin']['pause']();
+ // }
+ },register:function (dev, ops) {
+ TTY.ttys[dev] = { input: [], output: [], ops: ops };
+ FS.registerDevice(dev, TTY.stream_ops);
+ },stream_ops:{open:function (stream) {
+ var tty = TTY.ttys[stream.node.rdev];
+ if (!tty) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ stream.tty = tty;
+ stream.seekable = false;
+ },close:function (stream) {
+ // flush any pending line data
+ if (stream.tty.output.length) {
+ stream.tty.ops.put_char(stream.tty, 10);
+ }
+ },read:function (stream, buffer, offset, length, pos /* ignored */) {
+ if (!stream.tty || !stream.tty.ops.get_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = stream.tty.ops.get_char(stream.tty);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, pos) {
+ if (!stream.tty || !stream.tty.ops.put_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ for (var i = 0; i < length; i++) {
+ try {
+ stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }},default_tty_ops:{get_char:function (tty) {
+ if (!tty.input.length) {
+ var result = null;
+ if (ENVIRONMENT_IS_NODE) {
+ result = process['stdin']['read']();
+ if (!result) {
+ if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
+ return null; // EOF
+ }
+ return undefined; // no data available
+ }
+ } else if (typeof window != 'undefined' &&
+ typeof window.prompt == 'function') {
+ // Browser.
+ result = window.prompt('Input: '); // returns null on cancel
+ if (result !== null) {
+ result += '\n';
+ }
+ } else if (typeof readline == 'function') {
+ // Command line.
+ result = readline();
+ if (result !== null) {
+ result += '\n';
+ }
+ }
+ if (!result) {
+ return null;
+ }
+ tty.input = intArrayFromString(result, true);
+ }
+ return tty.input.shift();
+ },put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['print'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }},default_tty1_ops:{put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['printErr'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }}};
+
+ var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
+ return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
+ // no supported
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (!MEMFS.ops_table) {
+ MEMFS.ops_table = {
+ dir: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ lookup: MEMFS.node_ops.lookup,
+ mknod: MEMFS.node_ops.mknod,
+ rename: MEMFS.node_ops.rename,
+ unlink: MEMFS.node_ops.unlink,
+ rmdir: MEMFS.node_ops.rmdir,
+ readdir: MEMFS.node_ops.readdir,
+ symlink: MEMFS.node_ops.symlink
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek
+ }
+ },
+ file: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek,
+ read: MEMFS.stream_ops.read,
+ write: MEMFS.stream_ops.write,
+ allocate: MEMFS.stream_ops.allocate,
+ mmap: MEMFS.stream_ops.mmap
+ }
+ },
+ link: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ readlink: MEMFS.node_ops.readlink
+ },
+ stream: {}
+ },
+ chrdev: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: FS.chrdev_stream_ops
+ },
+ };
+ }
+ var node = FS.createNode(parent, name, mode, dev);
+ if (FS.isDir(node.mode)) {
+ node.node_ops = MEMFS.ops_table.dir.node;
+ node.stream_ops = MEMFS.ops_table.dir.stream;
+ node.contents = {};
+ } else if (FS.isFile(node.mode)) {
+ node.node_ops = MEMFS.ops_table.file.node;
+ node.stream_ops = MEMFS.ops_table.file.stream;
+ node.contents = [];
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ } else if (FS.isLink(node.mode)) {
+ node.node_ops = MEMFS.ops_table.link.node;
+ node.stream_ops = MEMFS.ops_table.link.stream;
+ } else if (FS.isChrdev(node.mode)) {
+ node.node_ops = MEMFS.ops_table.chrdev.node;
+ node.stream_ops = MEMFS.ops_table.chrdev.stream;
+ }
+ node.timestamp = Date.now();
+ // add the new node to the parent
+ if (parent) {
+ parent.contents[name] = node;
+ }
+ return node;
+ },ensureFlexible:function (node) {
+ if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
+ var contents = node.contents;
+ node.contents = Array.prototype.slice.call(contents);
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ }
+ },node_ops:{getattr:function (node) {
+ var attr = {};
+ // device numbers reuse inode numbers.
+ attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
+ attr.ino = node.id;
+ attr.mode = node.mode;
+ attr.nlink = 1;
+ attr.uid = 0;
+ attr.gid = 0;
+ attr.rdev = node.rdev;
+ if (FS.isDir(node.mode)) {
+ attr.size = 4096;
+ } else if (FS.isFile(node.mode)) {
+ attr.size = node.contents.length;
+ } else if (FS.isLink(node.mode)) {
+ attr.size = node.link.length;
+ } else {
+ attr.size = 0;
+ }
+ attr.atime = new Date(node.timestamp);
+ attr.mtime = new Date(node.timestamp);
+ attr.ctime = new Date(node.timestamp);
+ // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
+ // but this is not required by the standard.
+ attr.blksize = 4096;
+ attr.blocks = Math.ceil(attr.size / attr.blksize);
+ return attr;
+ },setattr:function (node, attr) {
+ if (attr.mode !== undefined) {
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ node.timestamp = attr.timestamp;
+ }
+ if (attr.size !== undefined) {
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ if (attr.size < contents.length) contents.length = attr.size;
+ else while (attr.size > contents.length) contents.push(0);
+ }
+ },lookup:function (parent, name) {
+ throw FS.genericErrors[ERRNO_CODES.ENOENT];
+ },mknod:function (parent, name, mode, dev) {
+ return MEMFS.createNode(parent, name, mode, dev);
+ },rename:function (old_node, new_dir, new_name) {
+ // if we're overwriting a directory at new_name, make sure it's empty.
+ if (FS.isDir(old_node.mode)) {
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ }
+ if (new_node) {
+ for (var i in new_node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ }
+ }
+ // do the internal rewiring
+ delete old_node.parent.contents[old_node.name];
+ old_node.name = new_name;
+ new_dir.contents[new_name] = old_node;
+ old_node.parent = new_dir;
+ },unlink:function (parent, name) {
+ delete parent.contents[name];
+ },rmdir:function (parent, name) {
+ var node = FS.lookupNode(parent, name);
+ for (var i in node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ delete parent.contents[name];
+ },readdir:function (node) {
+ var entries = ['.', '..']
+ for (var key in node.contents) {
+ if (!node.contents.hasOwnProperty(key)) {
+ continue;
+ }
+ entries.push(key);
+ }
+ return entries;
+ },symlink:function (parent, newname, oldpath) {
+ var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
+ node.link = oldpath;
+ return node;
+ },readlink:function (node) {
+ if (!FS.isLink(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return node.link;
+ }},stream_ops:{read:function (stream, buffer, offset, length, position) {
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (size > 8 && contents.subarray) { // non-trivial, and typed array
+ buffer.set(contents.subarray(position, position + size), offset);
+ } else
+ {
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ }
+ return size;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ var node = stream.node;
+ node.timestamp = Date.now();
+ var contents = node.contents;
+ if (length && contents.length === 0 && position === 0 && buffer.subarray) {
+ // just replace it with the new data
+ if (canOwn && offset === 0) {
+ node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
+ node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
+ } else {
+ node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
+ node.contentMode = MEMFS.CONTENT_FIXED;
+ }
+ return length;
+ }
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ while (contents.length < position) contents.push(0);
+ for (var i = 0; i < length; i++) {
+ contents[position + i] = buffer[offset + i];
+ }
+ return length;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ position += stream.node.contents.length;
+ }
+ }
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ stream.ungotten = [];
+ stream.position = position;
+ return position;
+ },allocate:function (stream, offset, length) {
+ MEMFS.ensureFlexible(stream.node);
+ var contents = stream.node.contents;
+ var limit = offset + length;
+ while (limit > contents.length) contents.push(0);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ if (!FS.isFile(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ var ptr;
+ var allocated;
+ var contents = stream.node.contents;
+ // Only make a new copy when MAP_PRIVATE is specified.
+ if ( !(flags & 2) &&
+ (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
+ // We can't emulate MAP_SHARED when the file is not backed by the buffer
+ // we're mapping to (e.g. the HEAP buffer).
+ allocated = false;
+ ptr = contents.byteOffset;
+ } else {
+ // Try to avoid unnecessary slices.
+ if (position > 0 || position + length < contents.length) {
+ if (contents.subarray) {
+ contents = contents.subarray(position, position + length);
+ } else {
+ contents = Array.prototype.slice.call(contents, position, position + length);
+ }
+ }
+ allocated = true;
+ ptr = _malloc(length);
+ if (!ptr) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
+ }
+ buffer.set(contents, ptr);
+ }
+ return { ptr: ptr, allocated: allocated };
+ }}};
+
+ var IDBFS={dbs:{},indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
+ // reuse all of the core MEMFS functionality
+ return MEMFS.mount.apply(null, arguments);
+ },syncfs:function (mount, populate, callback) {
+ IDBFS.getLocalSet(mount, function(err, local) {
+ if (err) return callback(err);
+
+ IDBFS.getRemoteSet(mount, function(err, remote) {
+ if (err) return callback(err);
+
+ var src = populate ? remote : local;
+ var dst = populate ? local : remote;
+
+ IDBFS.reconcile(src, dst, callback);
+ });
+ });
+ },getDB:function (name, callback) {
+ // check the cache first
+ var db = IDBFS.dbs[name];
+ if (db) {
+ return callback(null, db);
+ }
+
+ var req;
+ try {
+ req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
+ } catch (e) {
+ return callback(e);
+ }
+ req.onupgradeneeded = function(e) {
+ var db = e.target.result;
+ var transaction = e.target.transaction;
+
+ var fileStore;
+
+ if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
+ fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ } else {
+ fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
+ }
+
+ fileStore.createIndex('timestamp', 'timestamp', { unique: false });
+ };
+ req.onsuccess = function() {
+ db = req.result;
+
+ // add to the cache
+ IDBFS.dbs[name] = db;
+ callback(null, db);
+ };
+ req.onerror = function() {
+ callback(this.error);
+ };
+ },getLocalSet:function (mount, callback) {
+ var entries = {};
+
+ function isRealDir(p) {
+ return p !== '.' && p !== '..';
+ };
+ function toAbsolute(root) {
+ return function(p) {
+ return PATH.join2(root, p);
+ }
+ };
+
+ var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
+
+ while (check.length) {
+ var path = check.pop();
+ var stat;
+
+ try {
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
+ }
+
+ entries[path] = { timestamp: stat.mtime };
+ }
+
+ return callback(null, { type: 'local', entries: entries });
+ },getRemoteSet:function (mount, callback) {
+ var entries = {};
+
+ IDBFS.getDB(mount.mountpoint, function(err, db) {
+ if (err) return callback(err);
+
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
+ transaction.onerror = function() { callback(this.error); };
+
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ var index = store.index('timestamp');
+
+ index.openKeyCursor().onsuccess = function(event) {
+ var cursor = event.target.result;
+
+ if (!cursor) {
+ return callback(null, { type: 'remote', db: db, entries: entries });
+ }
+
+ entries[cursor.primaryKey] = { timestamp: cursor.key };
+
+ cursor.continue();
+ };
+ });
+ },loadLocalEntry:function (path, callback) {
+ var stat, node;
+
+ try {
+ var lookup = FS.lookupPath(path);
+ node = lookup.node;
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode });
+ } else if (FS.isFile(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+ },storeLocalEntry:function (path, entry, callback) {
+ try {
+ if (FS.isDir(entry.mode)) {
+ FS.mkdir(path, entry.mode);
+ } else if (FS.isFile(entry.mode)) {
+ FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+
+ FS.utime(path, entry.timestamp, entry.timestamp);
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },removeLocalEntry:function (path, callback) {
+ try {
+ var lookup = FS.lookupPath(path);
+ var stat = FS.stat(path);
+
+ if (FS.isDir(stat.mode)) {
+ FS.rmdir(path);
+ } else if (FS.isFile(stat.mode)) {
+ FS.unlink(path);
+ }
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },loadRemoteEntry:function (store, path, callback) {
+ var req = store.get(path);
+ req.onsuccess = function(event) { callback(null, event.target.result); };
+ req.onerror = function() { callback(this.error); };
+ },storeRemoteEntry:function (store, path, entry, callback) {
+ var req = store.put(entry, path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },removeRemoteEntry:function (store, path, callback) {
+ var req = store.delete(path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },reconcile:function (src, dst, callback) {
+ var total = 0;
+
+ var create = [];
+ Object.keys(src.entries).forEach(function (key) {
+ var e = src.entries[key];
+ var e2 = dst.entries[key];
+ if (!e2 || e.timestamp > e2.timestamp) {
+ create.push(key);
+ total++;
+ }
+ });
+
+ var remove = [];
+ Object.keys(dst.entries).forEach(function (key) {
+ var e = dst.entries[key];
+ var e2 = src.entries[key];
+ if (!e2) {
+ remove.push(key);
+ total++;
+ }
+ });
+
+ if (!total) {
+ return callback(null);
+ }
+
+ var errored = false;
+ var completed = 0;
+ var db = src.type === 'remote' ? src.db : dst.db;
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= total) {
+ return callback(null);
+ }
+ };
+
+ transaction.onerror = function() { done(this.error); };
+
+ // sort paths in ascending order so directory entries are created
+ // before the files inside them
+ create.sort().forEach(function (path) {
+ if (dst.type === 'local') {
+ IDBFS.loadRemoteEntry(store, path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeLocalEntry(path, entry, done);
+ });
+ } else {
+ IDBFS.loadLocalEntry(path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeRemoteEntry(store, path, entry, done);
+ });
+ }
+ });
+
+ // sort paths in descending order so files are deleted before their
+ // parent directories
+ remove.sort().reverse().forEach(function(path) {
+ if (dst.type === 'local') {
+ IDBFS.removeLocalEntry(path, done);
+ } else {
+ IDBFS.removeRemoteEntry(store, path, done);
+ }
+ });
+ }};
+
+ var NODEFS={isWindows:false,staticInit:function () {
+ NODEFS.isWindows = !!process.platform.match(/^win/);
+ },mount:function (mount) {
+ assert(ENVIRONMENT_IS_NODE);
+ return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node = FS.createNode(parent, name, mode);
+ node.node_ops = NODEFS.node_ops;
+ node.stream_ops = NODEFS.stream_ops;
+ return node;
+ },getMode:function (path) {
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ if (NODEFS.isWindows) {
+ // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so
+ // propagate write bits to execute bits.
+ stat.mode = stat.mode | ((stat.mode & 146) >> 1);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return stat.mode;
+ },realPath:function (node) {
+ var parts = [];
+ while (node.parent !== node) {
+ parts.push(node.name);
+ node = node.parent;
+ }
+ parts.push(node.mount.opts.root);
+ parts.reverse();
+ return PATH.join.apply(null, parts);
+ },flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function (flags) {
+ if (flags in NODEFS.flagsToPermissionStringMap) {
+ return NODEFS.flagsToPermissionStringMap[flags];
+ } else {
+ return flags;
+ }
+ },node_ops:{getattr:function (node) {
+ var path = NODEFS.realPath(node);
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
+ // See http://support.microsoft.com/kb/140365
+ if (NODEFS.isWindows && !stat.blksize) {
+ stat.blksize = 4096;
+ }
+ if (NODEFS.isWindows && !stat.blocks) {
+ stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
+ }
+ return {
+ dev: stat.dev,
+ ino: stat.ino,
+ mode: stat.mode,
+ nlink: stat.nlink,
+ uid: stat.uid,
+ gid: stat.gid,
+ rdev: stat.rdev,
+ size: stat.size,
+ atime: stat.atime,
+ mtime: stat.mtime,
+ ctime: stat.ctime,
+ blksize: stat.blksize,
+ blocks: stat.blocks
+ };
+ },setattr:function (node, attr) {
+ var path = NODEFS.realPath(node);
+ try {
+ if (attr.mode !== undefined) {
+ fs.chmodSync(path, attr.mode);
+ // update the common node structure mode as well
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ var date = new Date(attr.timestamp);
+ fs.utimesSync(path, date, date);
+ }
+ if (attr.size !== undefined) {
+ fs.truncateSync(path, attr.size);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },lookup:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ var mode = NODEFS.getMode(path);
+ return NODEFS.createNode(parent, name, mode);
+ },mknod:function (parent, name, mode, dev) {
+ var node = NODEFS.createNode(parent, name, mode, dev);
+ // create the backing node for this in the fs root as well
+ var path = NODEFS.realPath(node);
+ try {
+ if (FS.isDir(node.mode)) {
+ fs.mkdirSync(path, node.mode);
+ } else {
+ fs.writeFileSync(path, '', { mode: node.mode });
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return node;
+ },rename:function (oldNode, newDir, newName) {
+ var oldPath = NODEFS.realPath(oldNode);
+ var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
+ try {
+ fs.renameSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },unlink:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.unlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },rmdir:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.rmdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readdir:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },symlink:function (parent, newName, oldPath) {
+ var newPath = PATH.join2(NODEFS.realPath(parent), newName);
+ try {
+ fs.symlinkSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readlink:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }},stream_ops:{open:function (stream) {
+ var path = NODEFS.realPath(stream.node);
+ try {
+ if (FS.isFile(stream.node.mode)) {
+ stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },close:function (stream) {
+ try {
+ if (FS.isFile(stream.node.mode) && stream.nfd) {
+ fs.closeSync(stream.nfd);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },read:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(length);
+ var res;
+ try {
+ res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ if (res > 0) {
+ for (var i = 0; i < res; i++) {
+ buffer[offset + i] = nbuffer[i];
+ }
+ }
+ return res;
+ },write:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
+ var res;
+ try {
+ res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return res;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ try {
+ var stat = fs.fstatSync(stream.nfd);
+ position += stat.size;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }
+ }
+
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ stream.position = position;
+ return position;
+ }}};
+
+ var _stdin=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stdout=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stderr=allocate(1, "i32*", ALLOC_STATIC);
+
+ function _fflush(stream) {
+ // int fflush(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html
+ // we don't currently perform any user-space buffering of data
+ }var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},handleFSError:function (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
+ return ___setErrNo(e.errno);
+ },lookupPath:function (path, opts) {
+ path = PATH.resolve(FS.cwd(), path);
+ opts = opts || {};
+
+ var defaults = {
+ follow_mount: true,
+ recurse_count: 0
+ };
+ for (var key in defaults) {
+ if (opts[key] === undefined) {
+ opts[key] = defaults[key];
+ }
+ }
+
+ if (opts.recurse_count > 8) { // max recursive lookup of 8
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+
+ // split the path
+ var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), false);
+
+ // start at the root
+ var current = FS.root;
+ var current_path = '/';
+
+ for (var i = 0; i < parts.length; i++) {
+ var islast = (i === parts.length-1);
+ if (islast && opts.parent) {
+ // stop resolving
+ break;
+ }
+
+ current = FS.lookupNode(current, parts[i]);
+ current_path = PATH.join2(current_path, parts[i]);
+
+ // jump to the mount's root node if this is a mountpoint
+ if (FS.isMountpoint(current)) {
+ if (!islast || (islast && opts.follow_mount)) {
+ current = current.mounted.root;
+ }
+ }
+
+ // by default, lookupPath will not follow a symlink if it is the final path component.
+ // setting opts.follow = true will override this behavior.
+ if (!islast || opts.follow) {
+ var count = 0;
+ while (FS.isLink(current.mode)) {
+ var link = FS.readlink(current_path);
+ current_path = PATH.resolve(PATH.dirname(current_path), link);
+
+ var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
+ current = lookup.node;
+
+ if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+ }
+ }
+ }
+
+ return { path: current_path, node: current };
+ },getPath:function (node) {
+ var path;
+ while (true) {
+ if (FS.isRoot(node)) {
+ var mount = node.mount.mountpoint;
+ if (!path) return mount;
+ return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
+ }
+ path = path ? node.name + '/' + path : node.name;
+ node = node.parent;
+ }
+ },hashName:function (parentid, name) {
+ var hash = 0;
+
+
+ for (var i = 0; i < name.length; i++) {
+ hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
+ }
+ return ((parentid + hash) >>> 0) % FS.nameTable.length;
+ },hashAddNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ node.name_next = FS.nameTable[hash];
+ FS.nameTable[hash] = node;
+ },hashRemoveNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ if (FS.nameTable[hash] === node) {
+ FS.nameTable[hash] = node.name_next;
+ } else {
+ var current = FS.nameTable[hash];
+ while (current) {
+ if (current.name_next === node) {
+ current.name_next = node.name_next;
+ break;
+ }
+ current = current.name_next;
+ }
+ }
+ },lookupNode:function (parent, name) {
+ var err = FS.mayLookup(parent);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ var hash = FS.hashName(parent.id, name);
+ for (var node = FS.nameTable[hash]; node; node = node.name_next) {
+ var nodeName = node.name;
+ if (node.parent.id === parent.id && nodeName === name) {
+ return node;
+ }
+ }
+ // if we failed to find it in the cache, call into the VFS
+ return FS.lookup(parent, name);
+ },createNode:function (parent, name, mode, rdev) {
+ if (!FS.FSNode) {
+ FS.FSNode = function(parent, name, mode, rdev) {
+ if (!parent) {
+ parent = this; // root node sets parent to itself
+ }
+ this.parent = parent;
+ this.mount = parent.mount;
+ this.mounted = null;
+ this.id = FS.nextInode++;
+ this.name = name;
+ this.mode = mode;
+ this.node_ops = {};
+ this.stream_ops = {};
+ this.rdev = rdev;
+ };
+
+ FS.FSNode.prototype = {};
+
+ // compatibility
+ var readMode = 292 | 73;
+ var writeMode = 146;
+
+ // NOTE we must use Object.defineProperties instead of individual calls to
+ // Object.defineProperty in order to make closure compiler happy
+ Object.defineProperties(FS.FSNode.prototype, {
+ read: {
+ get: function() { return (this.mode & readMode) === readMode; },
+ set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
+ },
+ write: {
+ get: function() { return (this.mode & writeMode) === writeMode; },
+ set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
+ },
+ isFolder: {
+ get: function() { return FS.isDir(this.mode); },
+ },
+ isDevice: {
+ get: function() { return FS.isChrdev(this.mode); },
+ },
+ });
+ }
+
+ var node = new FS.FSNode(parent, name, mode, rdev);
+
+ FS.hashAddNode(node);
+
+ return node;
+ },destroyNode:function (node) {
+ FS.hashRemoveNode(node);
+ },isRoot:function (node) {
+ return node === node.parent;
+ },isMountpoint:function (node) {
+ return !!node.mounted;
+ },isFile:function (mode) {
+ return (mode & 61440) === 32768;
+ },isDir:function (mode) {
+ return (mode & 61440) === 16384;
+ },isLink:function (mode) {
+ return (mode & 61440) === 40960;
+ },isChrdev:function (mode) {
+ return (mode & 61440) === 8192;
+ },isBlkdev:function (mode) {
+ return (mode & 61440) === 24576;
+ },isFIFO:function (mode) {
+ return (mode & 61440) === 4096;
+ },isSocket:function (mode) {
+ return (mode & 49152) === 49152;
+ },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
+ var flags = FS.flagModes[str];
+ if (typeof flags === 'undefined') {
+ throw new Error('Unknown file open mode: ' + str);
+ }
+ return flags;
+ },flagsToPermissionString:function (flag) {
+ var accmode = flag & 2097155;
+ var perms = ['r', 'w', 'rw'][accmode];
+ if ((flag & 512)) {
+ perms += 'w';
+ }
+ return perms;
+ },nodePermissions:function (node, perms) {
+ if (FS.ignorePermissions) {
+ return 0;
+ }
+ // return 0 if any user, group or owner bits are set.
+ if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
+ return ERRNO_CODES.EACCES;
+ }
+ return 0;
+ },mayLookup:function (dir) {
+ return FS.nodePermissions(dir, 'x');
+ },mayCreate:function (dir, name) {
+ try {
+ var node = FS.lookupNode(dir, name);
+ return ERRNO_CODES.EEXIST;
+ } catch (e) {
+ }
+ return FS.nodePermissions(dir, 'wx');
+ },mayDelete:function (dir, name, isdir) {
+ var node;
+ try {
+ node = FS.lookupNode(dir, name);
+ } catch (e) {
+ return e.errno;
+ }
+ var err = FS.nodePermissions(dir, 'wx');
+ if (err) {
+ return err;
+ }
+ if (isdir) {
+ if (!FS.isDir(node.mode)) {
+ return ERRNO_CODES.ENOTDIR;
+ }
+ if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
+ return ERRNO_CODES.EBUSY;
+ }
+ } else {
+ if (FS.isDir(node.mode)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return 0;
+ },mayOpen:function (node, flags) {
+ if (!node) {
+ return ERRNO_CODES.ENOENT;
+ }
+ if (FS.isLink(node.mode)) {
+ return ERRNO_CODES.ELOOP;
+ } else if (FS.isDir(node.mode)) {
+ if ((flags & 2097155) !== 0 || // opening for write
+ (flags & 512)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
+ },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
+ fd_start = fd_start || 0;
+ fd_end = fd_end || FS.MAX_OPEN_FDS;
+ for (var fd = fd_start; fd <= fd_end; fd++) {
+ if (!FS.streams[fd]) {
+ return fd;
+ }
+ }
+ throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
+ },getStream:function (fd) {
+ return FS.streams[fd];
+ },createStream:function (stream, fd_start, fd_end) {
+ if (!FS.FSStream) {
+ FS.FSStream = function(){};
+ FS.FSStream.prototype = {};
+ // compatibility
+ Object.defineProperties(FS.FSStream.prototype, {
+ object: {
+ get: function() { return this.node; },
+ set: function(val) { this.node = val; }
+ },
+ isRead: {
+ get: function() { return (this.flags & 2097155) !== 1; }
+ },
+ isWrite: {
+ get: function() { return (this.flags & 2097155) !== 0; }
+ },
+ isAppend: {
+ get: function() { return (this.flags & 1024); }
+ }
+ });
+ }
+ if (0) {
+ // reuse the object
+ stream.__proto__ = FS.FSStream.prototype;
+ } else {
+ var newStream = new FS.FSStream();
+ for (var p in stream) {
+ newStream[p] = stream[p];
+ }
+ stream = newStream;
+ }
+ var fd = FS.nextfd(fd_start, fd_end);
+ stream.fd = fd;
+ FS.streams[fd] = stream;
+ return stream;
+ },closeStream:function (fd) {
+ FS.streams[fd] = null;
+ },getStreamFromPtr:function (ptr) {
+ return FS.streams[ptr - 1];
+ },getPtrForStream:function (stream) {
+ return stream ? stream.fd + 1 : 0;
+ },chrdev_stream_ops:{open:function (stream) {
+ var device = FS.getDevice(stream.node.rdev);
+ // override node's stream ops with the device's
+ stream.stream_ops = device.stream_ops;
+ // forward the open call
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ },llseek:function () {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }},major:function (dev) {
+ return ((dev) >> 8);
+ },minor:function (dev) {
+ return ((dev) & 0xff);
+ },makedev:function (ma, mi) {
+ return ((ma) << 8 | (mi));
+ },registerDevice:function (dev, ops) {
+ FS.devices[dev] = { stream_ops: ops };
+ },getDevice:function (dev) {
+ return FS.devices[dev];
+ },getMounts:function (mount) {
+ var mounts = [];
+ var check = [mount];
+
+ while (check.length) {
+ var m = check.pop();
+
+ mounts.push(m);
+
+ check.push.apply(check, m.mounts);
+ }
+
+ return mounts;
+ },syncfs:function (populate, callback) {
+ if (typeof(populate) === 'function') {
+ callback = populate;
+ populate = false;
+ }
+
+ var mounts = FS.getMounts(FS.root.mount);
+ var completed = 0;
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= mounts.length) {
+ callback(null);
+ }
+ };
+
+ // sync all mounts
+ mounts.forEach(function (mount) {
+ if (!mount.type.syncfs) {
+ return done(null);
+ }
+ mount.type.syncfs(mount, populate, done);
+ });
+ },mount:function (type, opts, mountpoint) {
+ var root = mountpoint === '/';
+ var pseudo = !mountpoint;
+ var node;
+
+ if (root && FS.root) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ } else if (!root && !pseudo) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ mountpoint = lookup.path; // use the absolute path
+ node = lookup.node;
+
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+
+ if (!FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ }
+
+ var mount = {
+ type: type,
+ opts: opts,
+ mountpoint: mountpoint,
+ mounts: []
+ };
+
+ // create a root node for the fs
+ var mountRoot = type.mount(mount);
+ mountRoot.mount = mount;
+ mount.root = mountRoot;
+
+ if (root) {
+ FS.root = mountRoot;
+ } else if (node) {
+ // set as a mountpoint
+ node.mounted = mount;
+
+ // add the new mount to the current mount's children
+ if (node.mount) {
+ node.mount.mounts.push(mount);
+ }
+ }
+
+ return mountRoot;
+ },unmount:function (mountpoint) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ if (!FS.isMountpoint(lookup.node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ // destroy the nodes for this mount, and all its child mounts
+ var node = lookup.node;
+ var mount = node.mounted;
+ var mounts = FS.getMounts(mount);
+
+ Object.keys(FS.nameTable).forEach(function (hash) {
+ var current = FS.nameTable[hash];
+
+ while (current) {
+ var next = current.name_next;
+
+ if (mounts.indexOf(current.mount) !== -1) {
+ FS.destroyNode(current);
+ }
+
+ current = next;
+ }
+ });
+
+ // no longer a mountpoint
+ node.mounted = null;
+
+ // remove this mount from the child mounts
+ var idx = node.mount.mounts.indexOf(mount);
+ assert(idx !== -1);
+ node.mount.mounts.splice(idx, 1);
+ },lookup:function (parent, name) {
+ return parent.node_ops.lookup(parent, name);
+ },mknod:function (path, mode, dev) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var err = FS.mayCreate(parent, name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.mknod) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.mknod(parent, name, mode, dev);
+ },create:function (path, mode) {
+ mode = mode !== undefined ? mode : 438 /* 0666 */;
+ mode &= 4095;
+ mode |= 32768;
+ return FS.mknod(path, mode, 0);
+ },mkdir:function (path, mode) {
+ mode = mode !== undefined ? mode : 511 /* 0777 */;
+ mode &= 511 | 512;
+ mode |= 16384;
+ return FS.mknod(path, mode, 0);
+ },mkdev:function (path, mode, dev) {
+ if (typeof(dev) === 'undefined') {
+ dev = mode;
+ mode = 438 /* 0666 */;
+ }
+ mode |= 8192;
+ return FS.mknod(path, mode, dev);
+ },symlink:function (oldpath, newpath) {
+ var lookup = FS.lookupPath(newpath, { parent: true });
+ var parent = lookup.node;
+ var newname = PATH.basename(newpath);
+ var err = FS.mayCreate(parent, newname);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.symlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.symlink(parent, newname, oldpath);
+ },rename:function (old_path, new_path) {
+ var old_dirname = PATH.dirname(old_path);
+ var new_dirname = PATH.dirname(new_path);
+ var old_name = PATH.basename(old_path);
+ var new_name = PATH.basename(new_path);
+ // parents must exist
+ var lookup, old_dir, new_dir;
+ try {
+ lookup = FS.lookupPath(old_path, { parent: true });
+ old_dir = lookup.node;
+ lookup = FS.lookupPath(new_path, { parent: true });
+ new_dir = lookup.node;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // need to be part of the same mount
+ if (old_dir.mount !== new_dir.mount) {
+ throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
+ }
+ // source must exist
+ var old_node = FS.lookupNode(old_dir, old_name);
+ // old path should not be an ancestor of the new path
+ var relative = PATH.relative(old_path, new_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ // new path should not be an ancestor of the old path
+ relative = PATH.relative(new_path, old_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ // see if the new path already exists
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ // not fatal
+ }
+ // early out if nothing needs to change
+ if (old_node === new_node) {
+ return;
+ }
+ // we'll need to delete the old entry
+ var isdir = FS.isDir(old_node.mode);
+ var err = FS.mayDelete(old_dir, old_name, isdir);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // need delete permissions if we'll be overwriting.
+ // need create permissions if new doesn't already exist.
+ err = new_node ?
+ FS.mayDelete(new_dir, new_name, isdir) :
+ FS.mayCreate(new_dir, new_name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!old_dir.node_ops.rename) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // if we are going to change the parent, check write permissions
+ if (new_dir !== old_dir) {
+ err = FS.nodePermissions(old_dir, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ }
+ // remove the node from the lookup hash
+ FS.hashRemoveNode(old_node);
+ // do the underlying fs rename
+ try {
+ old_dir.node_ops.rename(old_node, new_dir, new_name);
+ } catch (e) {
+ throw e;
+ } finally {
+ // add the node back to the hash (in case node_ops.rename
+ // changed its name)
+ FS.hashAddNode(old_node);
+ }
+ },rmdir:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, true);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.rmdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.rmdir(parent, name);
+ FS.destroyNode(node);
+ },readdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ if (!node.node_ops.readdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ return node.node_ops.readdir(node);
+ },unlink:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, false);
+ if (err) {
+ // POSIX says unlink should set EPERM, not EISDIR
+ if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.unlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.unlink(parent, name);
+ FS.destroyNode(node);
+ },readlink:function (path) {
+ var lookup = FS.lookupPath(path);
+ var link = lookup.node;
+ if (!link.node_ops.readlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return link.node_ops.readlink(link);
+ },stat:function (path, dontFollow) {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ var node = lookup.node;
+ if (!node.node_ops.getattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return node.node_ops.getattr(node);
+ },lstat:function (path) {
+ return FS.stat(path, true);
+ },chmod:function (path, mode, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ mode: (mode & 4095) | (node.mode & ~4095),
+ timestamp: Date.now()
+ });
+ },lchmod:function (path, mode) {
+ FS.chmod(path, mode, true);
+ },fchmod:function (fd, mode) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chmod(stream.node, mode);
+ },chown:function (path, uid, gid, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ timestamp: Date.now()
+ // we ignore the uid / gid for now
+ });
+ },lchown:function (path, uid, gid) {
+ FS.chown(path, uid, gid, true);
+ },fchown:function (fd, uid, gid) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chown(stream.node, uid, gid);
+ },truncate:function (path, len) {
+ if (len < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: true });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!FS.isFile(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var err = FS.nodePermissions(node, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ node.node_ops.setattr(node, {
+ size: len,
+ timestamp: Date.now()
+ });
+ },ftruncate:function (fd, len) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ FS.truncate(stream.node, len);
+ },utime:function (path, atime, mtime) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ node.node_ops.setattr(node, {
+ timestamp: Math.max(atime, mtime)
+ });
+ },open:function (path, flags, mode, fd_start, fd_end) {
+ flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
+ mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
+ if ((flags & 64)) {
+ mode = (mode & 4095) | 32768;
+ } else {
+ mode = 0;
+ }
+ var node;
+ if (typeof path === 'object') {
+ node = path;
+ } else {
+ path = PATH.normalize(path);
+ try {
+ var lookup = FS.lookupPath(path, {
+ follow: !(flags & 131072)
+ });
+ node = lookup.node;
+ } catch (e) {
+ // ignore
+ }
+ }
+ // perhaps we need to create the node
+ if ((flags & 64)) {
+ if (node) {
+ // if O_CREAT and O_EXCL are set, error out if the node already exists
+ if ((flags & 128)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
+ }
+ } else {
+ // node doesn't exist, try to create it
+ node = FS.mknod(path, mode, 0);
+ }
+ }
+ if (!node) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
+ }
+ // can't truncate a device
+ if (FS.isChrdev(node.mode)) {
+ flags &= ~512;
+ }
+ // check permissions
+ var err = FS.mayOpen(node, flags);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // do truncation if necessary
+ if ((flags & 512)) {
+ FS.truncate(node, 0);
+ }
+ // we've already handled these, don't pass down to the underlying vfs
+ flags &= ~(128 | 512);
+
+ // register the stream with the filesystem
+ var stream = FS.createStream({
+ node: node,
+ path: FS.getPath(node), // we want the absolute path to the node
+ flags: flags,
+ seekable: true,
+ position: 0,
+ stream_ops: node.stream_ops,
+ // used by the file family libc calls (fopen, fwrite, ferror, etc.)
+ ungotten: [],
+ error: false
+ }, fd_start, fd_end);
+ // call the new stream's open function
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ if (Module['logReadFiles'] && !(flags & 1)) {
+ if (!FS.readFiles) FS.readFiles = {};
+ if (!(path in FS.readFiles)) {
+ FS.readFiles[path] = 1;
+ Module['printErr']('read file: ' + path);
+ }
+ }
+ return stream;
+ },close:function (stream) {
+ try {
+ if (stream.stream_ops.close) {
+ stream.stream_ops.close(stream);
+ }
+ } catch (e) {
+ throw e;
+ } finally {
+ FS.closeStream(stream.fd);
+ }
+ },llseek:function (stream, offset, whence) {
+ if (!stream.seekable || !stream.stream_ops.llseek) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ return stream.stream_ops.llseek(stream, offset, whence);
+ },read:function (stream, buffer, offset, length, position) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.read) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
+ if (!seeking) stream.position += bytesRead;
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.write) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ if (stream.flags & 1024) {
+ // seek to the end before writing in append mode
+ FS.llseek(stream, 0, 2);
+ }
+ var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
+ if (!seeking) stream.position += bytesWritten;
+ return bytesWritten;
+ },allocate:function (stream, offset, length) {
+ if (offset < 0 || length <= 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ if (!stream.stream_ops.allocate) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ stream.stream_ops.allocate(stream, offset, length);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ // TODO if PROT is PROT_WRITE, make sure we have write access
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EACCES);
+ }
+ if (!stream.stream_ops.mmap) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
+ },ioctl:function (stream, cmd, arg) {
+ if (!stream.stream_ops.ioctl) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
+ }
+ return stream.stream_ops.ioctl(stream, cmd, arg);
+ },readFile:function (path, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'r';
+ opts.encoding = opts.encoding || 'binary';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var ret;
+ var stream = FS.open(path, opts.flags);
+ var stat = FS.stat(path);
+ var length = stat.size;
+ var buf = new Uint8Array(length);
+ FS.read(stream, buf, 0, length, 0);
+ if (opts.encoding === 'utf8') {
+ ret = '';
+ var utf8 = new Runtime.UTF8Processor();
+ for (var i = 0; i < length; i++) {
+ ret += utf8.processCChar(buf[i]);
+ }
+ } else if (opts.encoding === 'binary') {
+ ret = buf;
+ }
+ FS.close(stream);
+ return ret;
+ },writeFile:function (path, data, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'w';
+ opts.encoding = opts.encoding || 'utf8';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var stream = FS.open(path, opts.flags, opts.mode);
+ if (opts.encoding === 'utf8') {
+ var utf8 = new Runtime.UTF8Processor();
+ var buf = new Uint8Array(utf8.processJSString(data));
+ FS.write(stream, buf, 0, buf.length, 0, opts.canOwn);
+ } else if (opts.encoding === 'binary') {
+ FS.write(stream, data, 0, data.length, 0, opts.canOwn);
+ }
+ FS.close(stream);
+ },cwd:function () {
+ return FS.currentPath;
+ },chdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ if (!FS.isDir(lookup.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ var err = FS.nodePermissions(lookup.node, 'x');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ FS.currentPath = lookup.path;
+ },createDefaultDirectories:function () {
+ FS.mkdir('/tmp');
+ },createDefaultDevices:function () {
+ // create /dev
+ FS.mkdir('/dev');
+ // setup /dev/null
+ FS.registerDevice(FS.makedev(1, 3), {
+ read: function() { return 0; },
+ write: function() { return 0; }
+ });
+ FS.mkdev('/dev/null', FS.makedev(1, 3));
+ // setup /dev/tty and /dev/tty1
+ // stderr needs to print output using Module['printErr']
+ // so we register a second tty just for it.
+ TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
+ TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
+ FS.mkdev('/dev/tty', FS.makedev(5, 0));
+ FS.mkdev('/dev/tty1', FS.makedev(6, 0));
+ // we're not going to emulate the actual shm device,
+ // just create the tmp dirs that reside in it commonly
+ FS.mkdir('/dev/shm');
+ FS.mkdir('/dev/shm/tmp');
+ },createStandardStreams:function () {
+ // TODO deprecate the old functionality of a single
+ // input / output callback and that utilizes FS.createDevice
+ // and instead require a unique set of stream ops
+
+ // by default, we symlink the standard streams to the
+ // default tty devices. however, if the standard streams
+ // have been overwritten we create a unique device for
+ // them instead.
+ if (Module['stdin']) {
+ FS.createDevice('/dev', 'stdin', Module['stdin']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdin');
+ }
+ if (Module['stdout']) {
+ FS.createDevice('/dev', 'stdout', null, Module['stdout']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdout');
+ }
+ if (Module['stderr']) {
+ FS.createDevice('/dev', 'stderr', null, Module['stderr']);
+ } else {
+ FS.symlink('/dev/tty1', '/dev/stderr');
+ }
+
+ // open default streams for the stdin, stdout and stderr devices
+ var stdin = FS.open('/dev/stdin', 'r');
+ HEAP32[((_stdin)>>2)]=FS.getPtrForStream(stdin);
+ assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
+
+ var stdout = FS.open('/dev/stdout', 'w');
+ HEAP32[((_stdout)>>2)]=FS.getPtrForStream(stdout);
+ assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
+
+ var stderr = FS.open('/dev/stderr', 'w');
+ HEAP32[((_stderr)>>2)]=FS.getPtrForStream(stderr);
+ assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
+ },ensureErrnoError:function () {
+ if (FS.ErrnoError) return;
+ FS.ErrnoError = function ErrnoError(errno) {
+ this.errno = errno;
+ for (var key in ERRNO_CODES) {
+ if (ERRNO_CODES[key] === errno) {
+ this.code = key;
+ break;
+ }
+ }
+ this.message = ERRNO_MESSAGES[errno];
+ };
+ FS.ErrnoError.prototype = new Error();
+ FS.ErrnoError.prototype.constructor = FS.ErrnoError;
+ // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
+ [ERRNO_CODES.ENOENT].forEach(function(code) {
+ FS.genericErrors[code] = new FS.ErrnoError(code);
+ FS.genericErrors[code].stack = '<generic error, no stack>';
+ });
+ },staticInit:function () {
+ FS.ensureErrnoError();
+
+ FS.nameTable = new Array(4096);
+
+ FS.mount(MEMFS, {}, '/');
+
+ FS.createDefaultDirectories();
+ FS.createDefaultDevices();
+ },init:function (input, output, error) {
+ assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
+ FS.init.initialized = true;
+
+ FS.ensureErrnoError();
+
+ // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
+ Module['stdin'] = input || Module['stdin'];
+ Module['stdout'] = output || Module['stdout'];
+ Module['stderr'] = error || Module['stderr'];
+
+ FS.createStandardStreams();
+ },quit:function () {
+ FS.init.initialized = false;
+ for (var i = 0; i < FS.streams.length; i++) {
+ var stream = FS.streams[i];
+ if (!stream) {
+ continue;
+ }
+ FS.close(stream);
+ }
+ },getMode:function (canRead, canWrite) {
+ var mode = 0;
+ if (canRead) mode |= 292 | 73;
+ if (canWrite) mode |= 146;
+ return mode;
+ },joinPath:function (parts, forceRelative) {
+ var path = PATH.join.apply(null, parts);
+ if (forceRelative && path[0] == '/') path = path.substr(1);
+ return path;
+ },absolutePath:function (relative, base) {
+ return PATH.resolve(base, relative);
+ },standardizePath:function (path) {
+ return PATH.normalize(path);
+ },findObject:function (path, dontResolveLastLink) {
+ var ret = FS.analyzePath(path, dontResolveLastLink);
+ if (ret.exists) {
+ return ret.object;
+ } else {
+ ___setErrNo(ret.error);
+ return null;
+ }
+ },analyzePath:function (path, dontResolveLastLink) {
+ // operate from within the context of the symlink's target
+ try {
+ var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ path = lookup.path;
+ } catch (e) {
+ }
+ var ret = {
+ isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
+ parentExists: false, parentPath: null, parentObject: null
+ };
+ try {
+ var lookup = FS.lookupPath(path, { parent: true });
+ ret.parentExists = true;
+ ret.parentPath = lookup.path;
+ ret.parentObject = lookup.node;
+ ret.name = PATH.basename(path);
+ lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ ret.exists = true;
+ ret.path = lookup.path;
+ ret.object = lookup.node;
+ ret.name = lookup.node.name;
+ ret.isRoot = lookup.path === '/';
+ } catch (e) {
+ ret.error = e.errno;
+ };
+ return ret;
+ },createFolder:function (parent, name, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.mkdir(path, mode);
+ },createPath:function (parent, path, canRead, canWrite) {
+ parent = typeof parent === 'string' ? parent : FS.getPath(parent);
+ var parts = path.split('/').reverse();
+ while (parts.length) {
+ var part = parts.pop();
+ if (!part) continue;
+ var current = PATH.join2(parent, part);
+ try {
+ FS.mkdir(current);
+ } catch (e) {
+ // ignore EEXIST
+ }
+ parent = current;
+ }
+ return current;
+ },createFile:function (parent, name, properties, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.create(path, mode);
+ },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
+ var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
+ var mode = FS.getMode(canRead, canWrite);
+ var node = FS.create(path, mode);
+ if (data) {
+ if (typeof data === 'string') {
+ var arr = new Array(data.length);
+ for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
+ data = arr;
+ }
+ // make sure we can write to the file
+ FS.chmod(node, mode | 146);
+ var stream = FS.open(node, 'w');
+ FS.write(stream, data, 0, data.length, 0, canOwn);
+ FS.close(stream);
+ FS.chmod(node, mode);
+ }
+ return node;
+ },createDevice:function (parent, name, input, output) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(!!input, !!output);
+ if (!FS.createDevice.major) FS.createDevice.major = 64;
+ var dev = FS.makedev(FS.createDevice.major++, 0);
+ // Create a fake device that a set of stream ops to emulate
+ // the old behavior.
+ FS.registerDevice(dev, {
+ open: function(stream) {
+ stream.seekable = false;
+ },
+ close: function(stream) {
+ // flush any pending line data
+ if (output && output.buffer && output.buffer.length) {
+ output(10);
+ }
+ },
+ read: function(stream, buffer, offset, length, pos /* ignored */) {
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = input();
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },
+ write: function(stream, buffer, offset, length, pos) {
+ for (var i = 0; i < length; i++) {
+ try {
+ output(buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }
+ });
+ return FS.mkdev(path, mode, dev);
+ },createLink:function (parent, name, target, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ return FS.symlink(target, path);
+ },forceLoadFile:function (obj) {
+ if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
+ var success = true;
+ if (typeof XMLHttpRequest !== 'undefined') {
+ throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
+ } else if (Module['read']) {
+ // Command-line.
+ try {
+ // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
+ // read() will try to parse UTF8.
+ obj.contents = intArrayFromString(Module['read'](obj.url), true);
+ } catch (e) {
+ success = false;
+ }
+ } else {
+ throw new Error('Cannot load without read() or XMLHttpRequest.');
+ }
+ if (!success) ___setErrNo(ERRNO_CODES.EIO);
+ return success;
+ },createLazyFile:function (parent, name, url, canRead, canWrite) {
+ // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
+ function LazyUint8Array() {
+ this.lengthKnown = false;
+ this.chunks = []; // Loaded chunks. Index is the chunk number
+ }
+ LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
+ if (idx > this.length-1 || idx < 0) {
+ return undefined;
+ }
+ var chunkOffset = idx % this.chunkSize;
+ var chunkNum = Math.floor(idx / this.chunkSize);
+ return this.getter(chunkNum)[chunkOffset];
+ }
+ LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
+ this.getter = getter;
+ }
+ LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
+ // Find length
+ var xhr = new XMLHttpRequest();
+ xhr.open('HEAD', url, false);
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ var datalength = Number(xhr.getResponseHeader("Content-length"));
+ var header;
+ var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
+ var chunkSize = 1024*1024; // Chunk size in bytes
+
+ if (!hasByteServing) chunkSize = datalength;
+
+ // Function to get a range from the remote URL.
+ var doXHR = (function(from, to) {
+ if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
+ if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
+
+ // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
+
+ // Some hints to the browser that we want binary data.
+ if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
+ if (xhr.overrideMimeType) {
+ xhr.overrideMimeType('text/plain; charset=x-user-defined');
+ }
+
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ if (xhr.response !== undefined) {
+ return new Uint8Array(xhr.response || []);
+ } else {
+ return intArrayFromString(xhr.responseText || '', true);
+ }
+ });
+ var lazyArray = this;
+ lazyArray.setDataGetter(function(chunkNum) {
+ var start = chunkNum * chunkSize;
+ var end = (chunkNum+1) * chunkSize - 1; // including this byte
+ end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
+ lazyArray.chunks[chunkNum] = doXHR(start, end);
+ }
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
+ return lazyArray.chunks[chunkNum];
+ });
+
+ this._length = datalength;
+ this._chunkSize = chunkSize;
+ this.lengthKnown = true;
+ }
+ if (typeof XMLHttpRequest !== 'undefined') {
+ if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
+ var lazyArray = new LazyUint8Array();
+ Object.defineProperty(lazyArray, "length", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._length;
+ }
+ });
+ Object.defineProperty(lazyArray, "chunkSize", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._chunkSize;
+ }
+ });
+
+ var properties = { isDevice: false, contents: lazyArray };
+ } else {
+ var properties = { isDevice: false, url: url };
+ }
+
+ var node = FS.createFile(parent, name, properties, canRead, canWrite);
+ // This is a total hack, but I want to get this lazy file code out of the
+ // core of MEMFS. If we want to keep this lazy file concept I feel it should
+ // be its own thin LAZYFS proxying calls to MEMFS.
+ if (properties.contents) {
+ node.contents = properties.contents;
+ } else if (properties.url) {
+ node.contents = null;
+ node.url = properties.url;
+ }
+ // override each stream op with one that tries to force load the lazy file first
+ var stream_ops = {};
+ var keys = Object.keys(node.stream_ops);
+ keys.forEach(function(key) {
+ var fn = node.stream_ops[key];
+ stream_ops[key] = function forceLoadLazyFile() {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ return fn.apply(null, arguments);
+ };
+ });
+ // use a custom read function
+ stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (contents.slice) { // normal array
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ } else {
+ for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
+ buffer[offset + i] = contents.get(position + i);
+ }
+ }
+ return size;
+ };
+ node.stream_ops = stream_ops;
+ return node;
+ },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {
+ Browser.init();
+ // TODO we should allow people to just pass in a complete filename instead
+ // of parent and name being that we just join them anyways
+ var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
+ function processData(byteArray) {
+ function finish(byteArray) {
+ if (!dontCreateFile) {
+ FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
+ }
+ if (onload) onload();
+ removeRunDependency('cp ' + fullname);
+ }
+ var handled = false;
+ Module['preloadPlugins'].forEach(function(plugin) {
+ if (handled) return;
+ if (plugin['canHandle'](fullname)) {
+ plugin['handle'](byteArray, fullname, finish, function() {
+ if (onerror) onerror();
+ removeRunDependency('cp ' + fullname);
+ });
+ handled = true;
+ }
+ });
+ if (!handled) finish(byteArray);
+ }
+ addRunDependency('cp ' + fullname);
+ if (typeof url == 'string') {
+ Browser.asyncLoad(url, function(byteArray) {
+ processData(byteArray);
+ }, onerror);
+ } else {
+ processData(url);
+ }
+ },indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_NAME:function () {
+ return 'EM_FS_' + window.location.pathname;
+ },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
+ console.log('creating db');
+ var db = openRequest.result;
+ db.createObjectStore(FS.DB_STORE_NAME);
+ };
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var putRequest = files.put(FS.analyzePath(path).object.contents, path);
+ putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
+ putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ },loadFilesFromDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = onerror; // no database to load from
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ try {
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
+ } catch(e) {
+ onerror(e);
+ return;
+ }
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var getRequest = files.get(path);
+ getRequest.onsuccess = function getRequest_onsuccess() {
+ if (FS.analyzePath(path).exists) {
+ FS.unlink(path);
+ }
+ FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
+ ok++;
+ if (ok + fail == total) finish();
+ };
+ getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ }};var PATH={splitPath:function (filename) {
+ var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
+ return splitPathRe.exec(filename).slice(1);
+ },normalizeArray:function (parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length - 1; i >= 0; i--) {
+ var last = parts[i];
+ if (last === '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+ return parts;
+ },normalize:function (path) {
+ var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.substr(-1) === '/';
+ // Normalize the path
+ path = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+ return (isAbsolute ? '/' : '') + path;
+ },dirname:function (path) {
+ var result = PATH.splitPath(path),
+ root = result[0],
+ dir = result[1];
+ if (!root && !dir) {
+ // No dirname whatsoever
+ return '.';
+ }
+ if (dir) {
+ // It has a dirname, strip trailing slash
+ dir = dir.substr(0, dir.length - 1);
+ }
+ return root + dir;
+ },basename:function (path) {
+ // EMSCRIPTEN return '/'' for '/', not an empty string
+ if (path === '/') return '/';
+ var lastSlash = path.lastIndexOf('/');
+ if (lastSlash === -1) return path;
+ return path.substr(lastSlash+1);
+ },extname:function (path) {
+ return PATH.splitPath(path)[3];
+ },join:function () {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return PATH.normalize(paths.join('/'));
+ },join2:function (l, r) {
+ return PATH.normalize(l + '/' + r);
+ },resolve:function () {
+ var resolvedPath = '',
+ resolvedAbsolute = false;
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0) ? arguments[i] : FS.cwd();
+ // Skip empty and invalid entries
+ if (typeof path !== 'string') {
+ throw new TypeError('Arguments to path.resolve must be strings');
+ } else if (!path) {
+ continue;
+ }
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+ }
+ // At this point the path should be resolved to a full absolute path, but
+ // handle relative paths to be safe (might happen when process.cwd() fails)
+ resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+ },relative:function (from, to) {
+ from = PATH.resolve(from).substr(1);
+ to = PATH.resolve(to).substr(1);
+ function trim(arr) {
+ var start = 0;
+ for (; start < arr.length; start++) {
+ if (arr[start] !== '') break;
+ }
+ var end = arr.length - 1;
+ for (; end >= 0; end--) {
+ if (arr[end] !== '') break;
+ }
+ if (start > end) return [];
+ return arr.slice(start, end - start + 1);
+ }
+ var fromParts = trim(from.split('/'));
+ var toParts = trim(to.split('/'));
+ var length = Math.min(fromParts.length, toParts.length);
+ var samePartsLength = length;
+ for (var i = 0; i < length; i++) {
+ if (fromParts[i] !== toParts[i]) {
+ samePartsLength = i;
+ break;
+ }
+ }
+ var outputParts = [];
+ for (var i = samePartsLength; i < fromParts.length; i++) {
+ outputParts.push('..');
+ }
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
+ return outputParts.join('/');
+ }};var Browser={mainLoop:{scheduler:null,method:"",shouldPause:false,paused:false,queue:[],pause:function () {
+ Browser.mainLoop.shouldPause = true;
+ },resume:function () {
+ if (Browser.mainLoop.paused) {
+ Browser.mainLoop.paused = false;
+ Browser.mainLoop.scheduler();
+ }
+ Browser.mainLoop.shouldPause = false;
+ },updateStatus:function () {
+ if (Module['setStatus']) {
+ var message = Module['statusMessage'] || 'Please wait...';
+ var remaining = Browser.mainLoop.remainingBlockers;
+ var expected = Browser.mainLoop.expectedBlockers;
+ if (remaining) {
+ if (remaining < expected) {
+ Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');
+ } else {
+ Module['setStatus'](message);
+ }
+ } else {
+ Module['setStatus']('');
+ }
+ }
+ }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {
+ if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers
+
+ if (Browser.initted || ENVIRONMENT_IS_WORKER) return;
+ Browser.initted = true;
+
+ try {
+ new Blob();
+ Browser.hasBlobConstructor = true;
+ } catch(e) {
+ Browser.hasBlobConstructor = false;
+ console.log("warning: no blob constructor, cannot create blobs with mimetypes");
+ }
+ Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null));
+ Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
+ if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {
+ console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
+ Module.noImageDecoding = true;
+ }
+
+ // Support for plugins that can process preloaded files. You can add more of these to
+ // your app by creating and appending to Module.preloadPlugins.
+ //
+ // Each plugin is asked if it can handle a file based on the file's name. If it can,
+ // it is given the file's raw data. When it is done, it calls a callback with the file's
+ // (possibly modified) data. For example, a plugin might decompress a file, or it
+ // might create some side data structure for use later (like an Image element, etc.).
+
+ var imagePlugin = {};
+ imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
+ return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
+ };
+ imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
+ var b = null;
+ if (Browser.hasBlobConstructor) {
+ try {
+ b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ if (b.size !== byteArray.length) { // Safari bug #118630
+ // Safari's Blob can only take an ArrayBuffer
+ b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
+ }
+ } catch(e) {
+ Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');
+ }
+ }
+ if (!b) {
+ var bb = new Browser.BlobBuilder();
+ bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range
+ b = bb.getBlob();
+ }
+ var url = Browser.URLObject.createObjectURL(b);
+ var img = new Image();
+ img.onload = function img_onload() {
+ assert(img.complete, 'Image ' + name + ' could not be decoded');
+ var canvas = document.createElement('canvas');
+ canvas.width = img.width;
+ canvas.height = img.height;
+ var ctx = canvas.getContext('2d');
+ ctx.drawImage(img, 0, 0);
+ Module["preloadedImages"][name] = canvas;
+ Browser.URLObject.revokeObjectURL(url);
+ if (onload) onload(byteArray);
+ };
+ img.onerror = function img_onerror(event) {
+ console.log('Image ' + url + ' could not be decoded');
+ if (onerror) onerror();
+ };
+ img.src = url;
+ };
+ Module['preloadPlugins'].push(imagePlugin);
+
+ var audioPlugin = {};
+ audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
+ return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
+ };
+ audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
+ var done = false;
+ function finish(audio) {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = audio;
+ if (onload) onload(byteArray);
+ }
+ function fail() {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = new Audio(); // empty shim
+ if (onerror) onerror();
+ }
+ if (Browser.hasBlobConstructor) {
+ try {
+ var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ } catch(e) {
+ return fail();
+ }
+ var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
+ var audio = new Audio();
+ audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
+ audio.onerror = function audio_onerror(event) {
+ if (done) return;
+ console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
+ function encode64(data) {
+ var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ var PAD = '=';
+ var ret = '';
+ var leftchar = 0;
+ var leftbits = 0;
+ for (var i = 0; i < data.length; i++) {
+ leftchar = (leftchar << 8) | data[i];
+ leftbits += 8;
+ while (leftbits >= 6) {
+ var curr = (leftchar >> (leftbits-6)) & 0x3f;
+ leftbits -= 6;
+ ret += BASE[curr];
+ }
+ }
+ if (leftbits == 2) {
+ ret += BASE[(leftchar&3) << 4];
+ ret += PAD + PAD;
+ } else if (leftbits == 4) {
+ ret += BASE[(leftchar&0xf) << 2];
+ ret += PAD;
+ }
+ return ret;
+ }
+ audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);
+ finish(audio); // we don't wait for confirmation this worked - but it's worth trying
+ };
+ audio.src = url;
+ // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror
+ Browser.safeSetTimeout(function() {
+ finish(audio); // try to use it even though it is not necessarily ready to play
+ }, 10000);
+ } else {
+ return fail();
+ }
+ };
+ Module['preloadPlugins'].push(audioPlugin);
+
+ // Canvas event setup
+
+ var canvas = Module['canvas'];
+
+ // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module
+ // Module['forcedAspectRatio'] = 4 / 3;
+
+ canvas.requestPointerLock = canvas['requestPointerLock'] ||
+ canvas['mozRequestPointerLock'] ||
+ canvas['webkitRequestPointerLock'] ||
+ canvas['msRequestPointerLock'] ||
+ function(){};
+ canvas.exitPointerLock = document['exitPointerLock'] ||
+ document['mozExitPointerLock'] ||
+ document['webkitExitPointerLock'] ||
+ document['msExitPointerLock'] ||
+ function(){}; // no-op if function does not exist
+ canvas.exitPointerLock = canvas.exitPointerLock.bind(document);
+
+ function pointerLockChange() {
+ Browser.pointerLock = document['pointerLockElement'] === canvas ||
+ document['mozPointerLockElement'] === canvas ||
+ document['webkitPointerLockElement'] === canvas ||
+ document['msPointerLockElement'] === canvas;
+ }
+
+ document.addEventListener('pointerlockchange', pointerLockChange, false);
+ document.addEventListener('mozpointerlockchange', pointerLockChange, false);
+ document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
+ document.addEventListener('mspointerlockchange', pointerLockChange, false);
+
+ if (Module['elementPointerLock']) {
+ canvas.addEventListener("click", function(ev) {
+ if (!Browser.pointerLock && canvas.requestPointerLock) {
+ canvas.requestPointerLock();
+ ev.preventDefault();
+ }
+ }, false);
+ }
+ },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) {
+ var ctx;
+ var errorInfo = '?';
+ function onContextCreationError(event) {
+ errorInfo = event.statusMessage || errorInfo;
+ }
+ try {
+ if (useWebGL) {
+ var contextAttributes = {
+ antialias: false,
+ alpha: false
+ };
+
+ if (webGLContextAttributes) {
+ for (var attribute in webGLContextAttributes) {
+ contextAttributes[attribute] = webGLContextAttributes[attribute];
+ }
+ }
+
+
+ canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
+ try {
+ ['experimental-webgl', 'webgl'].some(function(webglId) {
+ return ctx = canvas.getContext(webglId, contextAttributes);
+ });
+ } finally {
+ canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
+ }
+ } else {
+ ctx = canvas.getContext('2d');
+ }
+ if (!ctx) throw ':(';
+ } catch (e) {
+ Module.print('Could not create canvas: ' + [errorInfo, e]);
+ return null;
+ }
+ if (useWebGL) {
+ // Set the background of the WebGL canvas to black
+ canvas.style.backgroundColor = "black";
+
+ // Warn on context loss
+ canvas.addEventListener('webglcontextlost', function(event) {
+ alert('WebGL context lost. You will need to reload the page.');
+ }, false);
+ }
+ if (setInModule) {
+ GLctx = Module.ctx = ctx;
+ Module.useWebGL = useWebGL;
+ Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
+ Browser.init();
+ }
+ return ctx;
+ },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {
+ Browser.lockPointer = lockPointer;
+ Browser.resizeCanvas = resizeCanvas;
+ if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;
+ if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;
+
+ var canvas = Module['canvas'];
+ function fullScreenChange() {
+ Browser.isFullScreen = false;
+ var canvasContainer = canvas.parentNode;
+ if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvasContainer) {
+ canvas.cancelFullScreen = document['cancelFullScreen'] ||
+ document['mozCancelFullScreen'] ||
+ document['webkitCancelFullScreen'] ||
+ document['msExitFullscreen'] ||
+ document['exitFullscreen'] ||
+ function() {};
+ canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);
+ if (Browser.lockPointer) canvas.requestPointerLock();
+ Browser.isFullScreen = true;
+ if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();
+ } else {
+
+ // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen
+ canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
+ canvasContainer.parentNode.removeChild(canvasContainer);
+
+ if (Browser.resizeCanvas) Browser.setWindowedCanvasSize();
+ }
+ if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);
+ Browser.updateCanvasDimensions(canvas);
+ }
+
+ if (!Browser.fullScreenHandlersInstalled) {
+ Browser.fullScreenHandlersInstalled = true;
+ document.addEventListener('fullscreenchange', fullScreenChange, false);
+ document.addEventListener('mozfullscreenchange', fullScreenChange, false);
+ document.addEventListener('webkitfullscreenchange', fullScreenChange, false);
+ document.addEventListener('MSFullscreenChange', fullScreenChange, false);
+ }
+
+ // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root
+ var canvasContainer = document.createElement("div");
+ canvas.parentNode.insertBefore(canvasContainer, canvas);
+ canvasContainer.appendChild(canvas);
+
+ // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size)
+ canvasContainer.requestFullScreen = canvasContainer['requestFullScreen'] ||
+ canvasContainer['mozRequestFullScreen'] ||
+ canvasContainer['msRequestFullscreen'] ||
+ (canvasContainer['webkitRequestFullScreen'] ? function() { canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);
+ canvasContainer.requestFullScreen();
+ },requestAnimationFrame:function requestAnimationFrame(func) {
+ if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
+ setTimeout(func, 1000/60);
+ } else {
+ if (!window.requestAnimationFrame) {
+ window.requestAnimationFrame = window['requestAnimationFrame'] ||
+ window['mozRequestAnimationFrame'] ||
+ window['webkitRequestAnimationFrame'] ||
+ window['msRequestAnimationFrame'] ||
+ window['oRequestAnimationFrame'] ||
+ window['setTimeout'];
+ }
+ window.requestAnimationFrame(func);
+ }
+ },safeCallback:function (func) {
+ return function() {
+ if (!ABORT) return func.apply(null, arguments);
+ };
+ },safeRequestAnimationFrame:function (func) {
+ return Browser.requestAnimationFrame(function() {
+ if (!ABORT) func();
+ });
+ },safeSetTimeout:function (func, timeout) {
+ return setTimeout(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },safeSetInterval:function (func, timeout) {
+ return setInterval(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },getMimetype:function (name) {
+ return {
+ 'jpg': 'image/jpeg',
+ 'jpeg': 'image/jpeg',
+ 'png': 'image/png',
+ 'bmp': 'image/bmp',
+ 'ogg': 'audio/ogg',
+ 'wav': 'audio/wav',
+ 'mp3': 'audio/mpeg'
+ }[name.substr(name.lastIndexOf('.')+1)];
+ },getUserMedia:function (func) {
+ if(!window.getUserMedia) {
+ window.getUserMedia = navigator['getUserMedia'] ||
+ navigator['mozGetUserMedia'];
+ }
+ window.getUserMedia(func);
+ },getMovementX:function (event) {
+ return event['movementX'] ||
+ event['mozMovementX'] ||
+ event['webkitMovementX'] ||
+ 0;
+ },getMovementY:function (event) {
+ return event['movementY'] ||
+ event['mozMovementY'] ||
+ event['webkitMovementY'] ||
+ 0;
+ },getMouseWheelDelta:function (event) {
+ return Math.max(-1, Math.min(1, event.type === 'DOMMouseScroll' ? event.detail : -event.wheelDelta));
+ },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup
+ if (Browser.pointerLock) {
+ // When the pointer is locked, calculate the coordinates
+ // based on the movement of the mouse.
+ // Workaround for Firefox bug 764498
+ if (event.type != 'mousemove' &&
+ ('mozMovementX' in event)) {
+ Browser.mouseMovementX = Browser.mouseMovementY = 0;
+ } else {
+ Browser.mouseMovementX = Browser.getMovementX(event);
+ Browser.mouseMovementY = Browser.getMovementY(event);
+ }
+
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
+ Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
+ } else {
+ // just add the mouse delta to the current absolut mouse position
+ // FIXME: ideally this should be clamped against the canvas size and zero
+ Browser.mouseX += Browser.mouseMovementX;
+ Browser.mouseY += Browser.mouseMovementY;
+ }
+ } else {
+ // Otherwise, calculate the movement based on the changes
+ // in the coordinates.
+ var rect = Module["canvas"].getBoundingClientRect();
+ var x, y;
+
+ // Neither .scrollX or .pageXOffset are defined in a spec, but
+ // we prefer .scrollX because it is currently in a spec draft.
+ // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
+ var scrollX = ((typeof window.scrollX !== 'undefined') ? window.scrollX : window.pageXOffset);
+ var scrollY = ((typeof window.scrollY !== 'undefined') ? window.scrollY : window.pageYOffset);
+ if (event.type == 'touchstart' ||
+ event.type == 'touchend' ||
+ event.type == 'touchmove') {
+ var t = event.touches.item(0);
+ if (t) {
+ x = t.pageX - (scrollX + rect.left);
+ y = t.pageY - (scrollY + rect.top);
+ } else {
+ return;
+ }
+ } else {
+ x = event.pageX - (scrollX + rect.left);
+ y = event.pageY - (scrollY + rect.top);
+ }
+
+ // the canvas might be CSS-scaled compared to its backbuffer;
+ // SDL-using content will want mouse coordinates in terms
+ // of backbuffer units.
+ var cw = Module["canvas"].width;
+ var ch = Module["canvas"].height;
+ x = x * (cw / rect.width);
+ y = y * (ch / rect.height);
+
+ Browser.mouseMovementX = x - Browser.mouseX;
+ Browser.mouseMovementY = y - Browser.mouseY;
+ Browser.mouseX = x;
+ Browser.mouseY = y;
+ }
+ },xhrLoad:function (url, onload, onerror) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, true);
+ xhr.responseType = 'arraybuffer';
+ xhr.onload = function xhr_onload() {
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
+ onload(xhr.response);
+ } else {
+ onerror();
+ }
+ };
+ xhr.onerror = onerror;
+ xhr.send(null);
+ },asyncLoad:function (url, onload, onerror, noRunDep) {
+ Browser.xhrLoad(url, function(arrayBuffer) {
+ assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
+ onload(new Uint8Array(arrayBuffer));
+ if (!noRunDep) removeRunDependency('al ' + url);
+ }, function(event) {
+ if (onerror) {
+ onerror();
+ } else {
+ throw 'Loading data file "' + url + '" failed.';
+ }
+ });
+ if (!noRunDep) addRunDependency('al ' + url);
+ },resizeListeners:[],updateResizeListeners:function () {
+ var canvas = Module['canvas'];
+ Browser.resizeListeners.forEach(function(listener) {
+ listener(canvas.width, canvas.height);
+ });
+ },setCanvasSize:function (width, height, noUpdates) {
+ var canvas = Module['canvas'];
+ Browser.updateCanvasDimensions(canvas, width, height);
+ if (!noUpdates) Browser.updateResizeListeners();
+ },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },setWindowedCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },updateCanvasDimensions:function (canvas, wNative, hNative) {
+ if (wNative && hNative) {
+ canvas.widthNative = wNative;
+ canvas.heightNative = hNative;
+ } else {
+ wNative = canvas.widthNative;
+ hNative = canvas.heightNative;
+ }
+ var w = wNative;
+ var h = hNative;
+ if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) {
+ if (w/h < Module['forcedAspectRatio']) {
+ w = Math.round(h * Module['forcedAspectRatio']);
+ } else {
+ h = Math.round(w / Module['forcedAspectRatio']);
+ }
+ }
+ if (((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
+ var factor = Math.min(screen.width / w, screen.height / h);
+ w = Math.round(w * factor);
+ h = Math.round(h * factor);
+ }
+ if (Browser.resizeCanvas) {
+ if (canvas.width != w) canvas.width = w;
+ if (canvas.height != h) canvas.height = h;
+ if (typeof canvas.style != 'undefined') {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ } else {
+ if (canvas.width != wNative) canvas.width = wNative;
+ if (canvas.height != hNative) canvas.height = hNative;
+ if (typeof canvas.style != 'undefined') {
+ if (w != wNative || h != hNative) {
+ canvas.style.setProperty( "width", w + "px", "important");
+ canvas.style.setProperty("height", h + "px", "important");
+ } else {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ }
+ }
+ }};
+
+
+
+
+
+
+
+ function _mkport() { throw 'TODO' }var SOCKFS={mount:function (mount) {
+ return FS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createSocket:function (family, type, protocol) {
+ var streaming = type == 1;
+ if (protocol) {
+ assert(streaming == (protocol == 6)); // if SOCK_STREAM, must be tcp
+ }
+
+ // create our internal socket structure
+ var sock = {
+ family: family,
+ type: type,
+ protocol: protocol,
+ server: null,
+ peers: {},
+ pending: [],
+ recv_queue: [],
+ sock_ops: SOCKFS.websocket_sock_ops
+ };
+
+ // create the filesystem node to store the socket structure
+ var name = SOCKFS.nextname();
+ var node = FS.createNode(SOCKFS.root, name, 49152, 0);
+ node.sock = sock;
+
+ // and the wrapping stream that enables library functions such
+ // as read and write to indirectly interact with the socket
+ var stream = FS.createStream({
+ path: name,
+ node: node,
+ flags: FS.modeStringToFlags('r+'),
+ seekable: false,
+ stream_ops: SOCKFS.stream_ops
+ });
+
+ // map the new stream to the socket structure (sockets have a 1:1
+ // relationship with a stream)
+ sock.stream = stream;
+
+ return sock;
+ },getSocket:function (fd) {
+ var stream = FS.getStream(fd);
+ if (!stream || !FS.isSocket(stream.node.mode)) {
+ return null;
+ }
+ return stream.node.sock;
+ },stream_ops:{poll:function (stream) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.poll(sock);
+ },ioctl:function (stream, request, varargs) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.ioctl(sock, request, varargs);
+ },read:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ var msg = sock.sock_ops.recvmsg(sock, length);
+ if (!msg) {
+ // socket is closed
+ return 0;
+ }
+ buffer.set(msg.buffer, offset);
+ return msg.buffer.length;
+ },write:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.sendmsg(sock, buffer, offset, length);
+ },close:function (stream) {
+ var sock = stream.node.sock;
+ sock.sock_ops.close(sock);
+ }},nextname:function () {
+ if (!SOCKFS.nextname.current) {
+ SOCKFS.nextname.current = 0;
+ }
+ return 'socket[' + (SOCKFS.nextname.current++) + ']';
+ },websocket_sock_ops:{createPeer:function (sock, addr, port) {
+ var ws;
+
+ if (typeof addr === 'object') {
+ ws = addr;
+ addr = null;
+ port = null;
+ }
+
+ if (ws) {
+ // for sockets that've already connected (e.g. we're the server)
+ // we can inspect the _socket property for the address
+ if (ws._socket) {
+ addr = ws._socket.remoteAddress;
+ port = ws._socket.remotePort;
+ }
+ // if we're just now initializing a connection to the remote,
+ // inspect the url property
+ else {
+ var result = /ws[s]?:\/\/([^:]+):(\d+)/.exec(ws.url);
+ if (!result) {
+ throw new Error('WebSocket URL must be in the format ws(s)://address:port');
+ }
+ addr = result[1];
+ port = parseInt(result[2], 10);
+ }
+ } else {
+ // create the actual websocket object and connect
+ try {
+ // runtimeConfig gets set to true if WebSocket runtime configuration is available.
+ var runtimeConfig = (Module['websocket'] && ('object' === typeof Module['websocket']));
+
+ // The default value is 'ws://' the replace is needed because the compiler replaces "//" comments with '#'
+ // comments without checking context, so we'd end up with ws:#, the replace swaps the "#" for "//" again.
+ var url = 'ws:#'.replace('#', '//');
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['url']) {
+ url = Module['websocket']['url']; // Fetch runtime WebSocket URL config.
+ }
+ }
+
+ if (url === 'ws://' || url === 'wss://') { // Is the supplied URL config just a prefix, if so complete it.
+ url = url + addr + ':' + port;
+ }
+
+ // Make the WebSocket subprotocol (Sec-WebSocket-Protocol) default to binary if no configuration is set.
+ var subProtocols = 'binary'; // The default value is 'binary'
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['subprotocol']) {
+ subProtocols = Module['websocket']['subprotocol']; // Fetch runtime WebSocket subprotocol config.
+ }
+ }
+
+ // The regex trims the string (removes spaces at the beginning and end, then splits the string by
+ // <any space>,<any space> into an Array. Whitespace removal is important for Websockify and ws.
+ subProtocols = subProtocols.replace(/^ +| +$/g,"").split(/ *, */);
+
+ // The node ws library API for specifying optional subprotocol is slightly different than the browser's.
+ var opts = ENVIRONMENT_IS_NODE ? {'protocol': subProtocols.toString()} : subProtocols;
+
+ // If node we use the ws library.
+ var WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : window['WebSocket'];
+ ws = new WebSocket(url, opts);
+ ws.binaryType = 'arraybuffer';
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EHOSTUNREACH);
+ }
+ }
+
+
+ var peer = {
+ addr: addr,
+ port: port,
+ socket: ws,
+ dgram_send_queue: []
+ };
+
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);
+
+ // if this is a bound dgram socket, send the port number first to allow
+ // us to override the ephemeral port reported to us by remotePort on the
+ // remote end.
+ if (sock.type === 2 && typeof sock.sport !== 'undefined') {
+ peer.dgram_send_queue.push(new Uint8Array([
+ 255, 255, 255, 255,
+ 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),
+ ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)
+ ]));
+ }
+
+ return peer;
+ },getPeer:function (sock, addr, port) {
+ return sock.peers[addr + ':' + port];
+ },addPeer:function (sock, peer) {
+ sock.peers[peer.addr + ':' + peer.port] = peer;
+ },removePeer:function (sock, peer) {
+ delete sock.peers[peer.addr + ':' + peer.port];
+ },handlePeerEvents:function (sock, peer) {
+ var first = true;
+
+ var handleOpen = function () {
+ try {
+ var queued = peer.dgram_send_queue.shift();
+ while (queued) {
+ peer.socket.send(queued);
+ queued = peer.dgram_send_queue.shift();
+ }
+ } catch (e) {
+ // not much we can do here in the way of proper error handling as we've already
+ // lied and said this data was sent. shut it down.
+ peer.socket.close();
+ }
+ };
+
+ function handleMessage(data) {
+ assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer
+ data = new Uint8Array(data); // make a typed array view on the array buffer
+
+
+ // if this is the port message, override the peer's port with it
+ var wasfirst = first;
+ first = false;
+ if (wasfirst &&
+ data.length === 10 &&
+ data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&
+ data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {
+ // update the peer's port and it's key in the peer map
+ var newport = ((data[8] << 8) | data[9]);
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ peer.port = newport;
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ return;
+ }
+
+ sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });
+ };
+
+ if (ENVIRONMENT_IS_NODE) {
+ peer.socket.on('open', handleOpen);
+ peer.socket.on('message', function(data, flags) {
+ if (!flags.binary) {
+ return;
+ }
+ handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
+ });
+ peer.socket.on('error', function() {
+ // don't throw
+ });
+ } else {
+ peer.socket.onopen = handleOpen;
+ peer.socket.onmessage = function peer_socket_onmessage(event) {
+ handleMessage(event.data);
+ };
+ }
+ },poll:function (sock) {
+ if (sock.type === 1 && sock.server) {
+ // listen sockets should only say they're available for reading
+ // if there are pending clients.
+ return sock.pending.length ? (64 | 1) : 0;
+ }
+
+ var mask = 0;
+ var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets
+ SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :
+ null;
+
+ if (sock.recv_queue.length ||
+ !dest || // connection-less sockets are always ready to read
+ (dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed
+ mask |= (64 | 1);
+ }
+
+ if (!dest || // connection-less sockets are always ready to write
+ (dest && dest.socket.readyState === dest.socket.OPEN)) {
+ mask |= 4;
+ }
+
+ if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) {
+ mask |= 16;
+ }
+
+ return mask;
+ },ioctl:function (sock, request, arg) {
+ switch (request) {
+ case 21531:
+ var bytes = 0;
+ if (sock.recv_queue.length) {
+ bytes = sock.recv_queue[0].data.length;
+ }
+ HEAP32[((arg)>>2)]=bytes;
+ return 0;
+ default:
+ return ERRNO_CODES.EINVAL;
+ }
+ },close:function (sock) {
+ // if we've spawned a listen server, close it
+ if (sock.server) {
+ try {
+ sock.server.close();
+ } catch (e) {
+ }
+ sock.server = null;
+ }
+ // close any peer connections
+ var peers = Object.keys(sock.peers);
+ for (var i = 0; i < peers.length; i++) {
+ var peer = sock.peers[peers[i]];
+ try {
+ peer.socket.close();
+ } catch (e) {
+ }
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ }
+ return 0;
+ },bind:function (sock, addr, port) {
+ if (typeof sock.saddr !== 'undefined' || typeof sock.sport !== 'undefined') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already bound
+ }
+ sock.saddr = addr;
+ sock.sport = port || _mkport();
+ // in order to emulate dgram sockets, we need to launch a listen server when
+ // binding on a connection-less socket
+ // note: this is only required on the server side
+ if (sock.type === 2) {
+ // close the existing server if it exists
+ if (sock.server) {
+ sock.server.close();
+ sock.server = null;
+ }
+ // swallow error operation not supported error that occurs when binding in the
+ // browser where this isn't supported
+ try {
+ sock.sock_ops.listen(sock, 0);
+ } catch (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e;
+ if (e.errno !== ERRNO_CODES.EOPNOTSUPP) throw e;
+ }
+ }
+ },connect:function (sock, addr, port) {
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODS.EOPNOTSUPP);
+ }
+
+ // TODO autobind
+ // if (!sock.addr && sock.type == 2) {
+ // }
+
+ // early out if we're already connected / in the middle of connecting
+ if (typeof sock.daddr !== 'undefined' && typeof sock.dport !== 'undefined') {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+ if (dest) {
+ if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EALREADY);
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EISCONN);
+ }
+ }
+ }
+
+ // add the socket to our peer list and set our
+ // destination address / port to match
+ var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ sock.daddr = peer.addr;
+ sock.dport = peer.port;
+
+ // always "fail" in non-blocking mode
+ throw new FS.ErrnoError(ERRNO_CODES.EINPROGRESS);
+ },listen:function (sock, backlog) {
+ if (!ENVIRONMENT_IS_NODE) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already listening
+ }
+ var WebSocketServer = require('ws').Server;
+ var host = sock.saddr;
+ sock.server = new WebSocketServer({
+ host: host,
+ port: sock.sport
+ // TODO support backlog
+ });
+
+ sock.server.on('connection', function(ws) {
+ if (sock.type === 1) {
+ var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);
+
+ // create a peer on the new socket
+ var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);
+ newsock.daddr = peer.addr;
+ newsock.dport = peer.port;
+
+ // push to queue for accept to pick up
+ sock.pending.push(newsock);
+ } else {
+ // create a peer on the listen socket so calling sendto
+ // with the listen socket and an address will resolve
+ // to the correct client
+ SOCKFS.websocket_sock_ops.createPeer(sock, ws);
+ }
+ });
+ sock.server.on('closed', function() {
+ sock.server = null;
+ });
+ sock.server.on('error', function() {
+ // don't throw
+ });
+ },accept:function (listensock) {
+ if (!listensock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var newsock = listensock.pending.shift();
+ newsock.stream.flags = listensock.stream.flags;
+ return newsock;
+ },getname:function (sock, peer) {
+ var addr, port;
+ if (peer) {
+ if (sock.daddr === undefined || sock.dport === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ addr = sock.daddr;
+ port = sock.dport;
+ } else {
+ // TODO saddr and sport will be set for bind()'d UDP sockets, but what
+ // should we be returning for TCP sockets that've been connect()'d?
+ addr = sock.saddr || 0;
+ port = sock.sport || 0;
+ }
+ return { addr: addr, port: port };
+ },sendmsg:function (sock, buffer, offset, length, addr, port) {
+ if (sock.type === 2) {
+ // connection-less sockets will honor the message address,
+ // and otherwise fall back to the bound destination address
+ if (addr === undefined || port === undefined) {
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+ // if there was no address to fall back to, error out
+ if (addr === undefined || port === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.EDESTADDRREQ);
+ }
+ } else {
+ // connection-based sockets will only use the bound
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+
+ // find the peer for the destination address
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);
+
+ // early out if not connected with a connection-based socket
+ if (sock.type === 1) {
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ } else if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // create a copy of the incoming data to send, as the WebSocket API
+ // doesn't work entirely with an ArrayBufferView, it'll just send
+ // the entire underlying buffer
+ var data;
+ if (buffer instanceof Array || buffer instanceof ArrayBuffer) {
+ data = buffer.slice(offset, offset + length);
+ } else { // ArrayBufferView
+ data = buffer.buffer.slice(buffer.byteOffset + offset, buffer.byteOffset + offset + length);
+ }
+
+ // if we're emulating a connection-less dgram socket and don't have
+ // a cached connection, queue the buffer to send upon connect and
+ // lie, saying the data was sent now.
+ if (sock.type === 2) {
+ if (!dest || dest.socket.readyState !== dest.socket.OPEN) {
+ // if we're not connected, open a new connection
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ }
+ dest.dgram_send_queue.push(data);
+ return length;
+ }
+ }
+
+ try {
+ // send the actual data
+ dest.socket.send(data);
+ return length;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ },recvmsg:function (sock, length) {
+ // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html
+ if (sock.type === 1 && sock.server) {
+ // tcp servers should not be recv()'ing on the listen socket
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+
+ var queued = sock.recv_queue.shift();
+ if (!queued) {
+ if (sock.type === 1) {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+
+ if (!dest) {
+ // if we have a destination address but are not connected, error out
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ else if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ // return null if the socket has closed
+ return null;
+ }
+ else {
+ // else, our socket is in a valid state but truly has nothing available
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // queued.data will be an ArrayBuffer if it's unadulterated, but if it's
+ // requeued TCP data it'll be an ArrayBufferView
+ var queuedLength = queued.data.byteLength || queued.data.length;
+ var queuedOffset = queued.data.byteOffset || 0;
+ var queuedBuffer = queued.data.buffer || queued.data;
+ var bytesRead = Math.min(length, queuedLength);
+ var res = {
+ buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),
+ addr: queued.addr,
+ port: queued.port
+ };
+
+
+ // push back any unread data for TCP connections
+ if (sock.type === 1 && bytesRead < queuedLength) {
+ var bytesRemaining = queuedLength - bytesRead;
+ queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
+ sock.recv_queue.unshift(queued);
+ }
+
+ return res;
+ }}};function _send(fd, buf, len, flags) {
+ var sock = SOCKFS.getSocket(fd);
+ if (!sock) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ // TODO honor flags
+ return _write(fd, buf, len);
+ }
+
+ function _pwrite(fildes, buf, nbyte, offset) {
+ // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte, offset);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _write(fildes, buf, nbyte) {
+ // ssize_t write(int fildes, const void *buf, size_t nbyte);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+
+
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }
+
+ function _fileno(stream) {
+ // int fileno(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fileno.html
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) return -1;
+ return stream.fd;
+ }function _fwrite(ptr, size, nitems, stream) {
+ // size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html
+ var bytesToWrite = nitems * size;
+ if (bytesToWrite == 0) return 0;
+ var fd = _fileno(stream);
+ var bytesWritten = _write(fd, ptr, bytesToWrite);
+ if (bytesWritten == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return 0;
+ } else {
+ return Math.floor(bytesWritten / size);
+ }
+ }
+
+
+
+ Module["_strlen"] = _strlen;
+
+ function __reallyNegative(x) {
+ return x < 0 || (x === 0 && (1/x) === -Infinity);
+ }function __formatString(format, varargs) {
+ var textIndex = format;
+ var argIndex = 0;
+ function getNextArg(type) {
+ // NOTE: Explicitly ignoring type safety. Otherwise this fails:
+ // int x = 4; printf("%c\n", (char)x);
+ var ret;
+ if (type === 'double') {
+ ret = HEAPF64[(((varargs)+(argIndex))>>3)];
+ } else if (type == 'i64') {
+ ret = [HEAP32[(((varargs)+(argIndex))>>2)],
+ HEAP32[(((varargs)+(argIndex+4))>>2)]];
+
+ } else {
+ type = 'i32'; // varargs are always i32, i64, or double
+ ret = HEAP32[(((varargs)+(argIndex))>>2)];
+ }
+ argIndex += Runtime.getNativeFieldSize(type);
+ return ret;
+ }
+
+ var ret = [];
+ var curr, next, currArg;
+ while(1) {
+ var startTextIndex = textIndex;
+ curr = HEAP8[(textIndex)];
+ if (curr === 0) break;
+ next = HEAP8[((textIndex+1)|0)];
+ if (curr == 37) {
+ // Handle flags.
+ var flagAlwaysSigned = false;
+ var flagLeftAlign = false;
+ var flagAlternative = false;
+ var flagZeroPad = false;
+ var flagPadSign = false;
+ flagsLoop: while (1) {
+ switch (next) {
+ case 43:
+ flagAlwaysSigned = true;
+ break;
+ case 45:
+ flagLeftAlign = true;
+ break;
+ case 35:
+ flagAlternative = true;
+ break;
+ case 48:
+ if (flagZeroPad) {
+ break flagsLoop;
+ } else {
+ flagZeroPad = true;
+ break;
+ }
+ case 32:
+ flagPadSign = true;
+ break;
+ default:
+ break flagsLoop;
+ }
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+
+ // Handle width.
+ var width = 0;
+ if (next == 42) {
+ width = getNextArg('i32');
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ } else {
+ while (next >= 48 && next <= 57) {
+ width = width * 10 + (next - 48);
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ }
+
+ // Handle precision.
+ var precisionSet = false, precision = -1;
+ if (next == 46) {
+ precision = 0;
+ precisionSet = true;
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ if (next == 42) {
+ precision = getNextArg('i32');
+ textIndex++;
+ } else {
+ while(1) {
+ var precisionChr = HEAP8[((textIndex+1)|0)];
+ if (precisionChr < 48 ||
+ precisionChr > 57) break;
+ precision = precision * 10 + (precisionChr - 48);
+ textIndex++;
+ }
+ }
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ if (precision < 0) {
+ precision = 6; // Standard default.
+ precisionSet = false;
+ }
+
+ // Handle integer sizes. WARNING: These assume a 32-bit architecture!
+ var argSize;
+ switch (String.fromCharCode(next)) {
+ case 'h':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 104) {
+ textIndex++;
+ argSize = 1; // char (actually i32 in varargs)
+ } else {
+ argSize = 2; // short (actually i32 in varargs)
+ }
+ break;
+ case 'l':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 108) {
+ textIndex++;
+ argSize = 8; // long long
+ } else {
+ argSize = 4; // long
+ }
+ break;
+ case 'L': // long long
+ case 'q': // int64_t
+ case 'j': // intmax_t
+ argSize = 8;
+ break;
+ case 'z': // size_t
+ case 't': // ptrdiff_t
+ case 'I': // signed ptrdiff_t or unsigned size_t
+ argSize = 4;
+ break;
+ default:
+ argSize = null;
+ }
+ if (argSize) textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+
+ // Handle type specifier.
+ switch (String.fromCharCode(next)) {
+ case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {
+ // Integer.
+ var signed = next == 100 || next == 105;
+ argSize = argSize || 4;
+ var currArg = getNextArg('i' + (argSize * 8));
+ var argText;
+ // Flatten i64-1 [low, high] into a (slightly rounded) double
+ if (argSize == 8) {
+ currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);
+ }
+ // Truncate to requested size.
+ if (argSize <= 4) {
+ var limit = Math.pow(256, argSize) - 1;
+ currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);
+ }
+ // Format the number.
+ var currAbsArg = Math.abs(currArg);
+ var prefix = '';
+ if (next == 100 || next == 105) {
+ argText = reSign(currArg, 8 * argSize, 1).toString(10);
+ } else if (next == 117) {
+ argText = unSign(currArg, 8 * argSize, 1).toString(10);
+ currArg = Math.abs(currArg);
+ } else if (next == 111) {
+ argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
+ } else if (next == 120 || next == 88) {
+ prefix = (flagAlternative && currArg != 0) ? '0x' : '';
+ if (currArg < 0) {
+ // Represent negative numbers in hex as 2's complement.
+ currArg = -currArg;
+ argText = (currAbsArg - 1).toString(16);
+ var buffer = [];
+ for (var i = 0; i < argText.length; i++) {
+ buffer.push((0xF - parseInt(argText[i], 16)).toString(16));
+ }
+ argText = buffer.join('');
+ while (argText.length < argSize * 2) argText = 'f' + argText;
+ } else {
+ argText = currAbsArg.toString(16);
+ }
+ if (next == 88) {
+ prefix = prefix.toUpperCase();
+ argText = argText.toUpperCase();
+ }
+ } else if (next == 112) {
+ if (currAbsArg === 0) {
+ argText = '(nil)';
+ } else {
+ prefix = '0x';
+ argText = currAbsArg.toString(16);
+ }
+ }
+ if (precisionSet) {
+ while (argText.length < precision) {
+ argText = '0' + argText;
+ }
+ }
+
+ // Add sign if needed
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ prefix = '+' + prefix;
+ } else if (flagPadSign) {
+ prefix = ' ' + prefix;
+ }
+ }
+
+ // Move sign to prefix so we zero-pad after the sign
+ if (argText.charAt(0) == '-') {
+ prefix = '-' + prefix;
+ argText = argText.substr(1);
+ }
+
+ // Add padding.
+ while (prefix.length + argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad) {
+ argText = '0' + argText;
+ } else {
+ prefix = ' ' + prefix;
+ }
+ }
+ }
+
+ // Insert the result into the buffer.
+ argText = prefix + argText;
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {
+ // Float.
+ var currArg = getNextArg('double');
+ var argText;
+ if (isNaN(currArg)) {
+ argText = 'nan';
+ flagZeroPad = false;
+ } else if (!isFinite(currArg)) {
+ argText = (currArg < 0 ? '-' : '') + 'inf';
+ flagZeroPad = false;
+ } else {
+ var isGeneral = false;
+ var effectivePrecision = Math.min(precision, 20);
+
+ // Convert g/G to f/F or e/E, as per:
+ // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
+ if (next == 103 || next == 71) {
+ isGeneral = true;
+ precision = precision || 1;
+ var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);
+ if (precision > exponent && exponent >= -4) {
+ next = ((next == 103) ? 'f' : 'F').charCodeAt(0);
+ precision -= exponent + 1;
+ } else {
+ next = ((next == 103) ? 'e' : 'E').charCodeAt(0);
+ precision--;
+ }
+ effectivePrecision = Math.min(precision, 20);
+ }
+
+ if (next == 101 || next == 69) {
+ argText = currArg.toExponential(effectivePrecision);
+ // Make sure the exponent has at least 2 digits.
+ if (/[eE][-+]\d$/.test(argText)) {
+ argText = argText.slice(0, -1) + '0' + argText.slice(-1);
+ }
+ } else if (next == 102 || next == 70) {
+ argText = currArg.toFixed(effectivePrecision);
+ if (currArg === 0 && __reallyNegative(currArg)) {
+ argText = '-' + argText;
+ }
+ }
+
+ var parts = argText.split('e');
+ if (isGeneral && !flagAlternative) {
+ // Discard trailing zeros and periods.
+ while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&
+ (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {
+ parts[0] = parts[0].slice(0, -1);
+ }
+ } else {
+ // Make sure we have a period in alternative mode.
+ if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';
+ // Zero pad until required precision.
+ while (precision > effectivePrecision++) parts[0] += '0';
+ }
+ argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');
+
+ // Capitalize 'E' if needed.
+ if (next == 69) argText = argText.toUpperCase();
+
+ // Add sign.
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ argText = '+' + argText;
+ } else if (flagPadSign) {
+ argText = ' ' + argText;
+ }
+ }
+ }
+
+ // Add padding.
+ while (argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {
+ argText = argText[0] + '0' + argText.slice(1);
+ } else {
+ argText = (flagZeroPad ? '0' : ' ') + argText;
+ }
+ }
+ }
+
+ // Adjust case.
+ if (next < 97) argText = argText.toUpperCase();
+
+ // Insert the result into the buffer.
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 's': {
+ // String.
+ var arg = getNextArg('i8*');
+ var argLength = arg ? _strlen(arg) : '(null)'.length;
+ if (precisionSet) argLength = Math.min(argLength, precision);
+ if (!flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ if (arg) {
+ for (var i = 0; i < argLength; i++) {
+ ret.push(HEAPU8[((arg++)|0)]);
+ }
+ } else {
+ ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true));
+ }
+ if (flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ break;
+ }
+ case 'c': {
+ // Character.
+ if (flagLeftAlign) ret.push(getNextArg('i8'));
+ while (--width > 0) {
+ ret.push(32);
+ }
+ if (!flagLeftAlign) ret.push(getNextArg('i8'));
+ break;
+ }
+ case 'n': {
+ // Write the length written so far to the next parameter.
+ var ptr = getNextArg('i32*');
+ HEAP32[((ptr)>>2)]=ret.length;
+ break;
+ }
+ case '%': {
+ // Literal percent sign.
+ ret.push(curr);
+ break;
+ }
+ default: {
+ // Unknown specifiers remain untouched.
+ for (var i = startTextIndex; i < textIndex + 2; i++) {
+ ret.push(HEAP8[(i)]);
+ }
+ }
+ }
+ textIndex += 2;
+ // TODO: Support a/A (hex float) and m (last error) specifiers.
+ // TODO: Support %1${specifier} for arg selection.
+ } else {
+ ret.push(curr);
+ textIndex += 1;
+ }
+ }
+ return ret;
+ }function _fprintf(stream, format, varargs) {
+ // int fprintf(FILE *restrict stream, const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var result = __formatString(format, varargs);
+ var stack = Runtime.stackSave();
+ var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);
+ Runtime.stackRestore(stack);
+ return ret;
+ }function _printf(format, varargs) {
+ // int printf(const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var stdout = HEAP32[((_stdout)>>2)];
+ return _fprintf(stdout, format, varargs);
+ }
+
+
+ Module["_memset"] = _memset;
+
+
+
+ function _emscripten_memcpy_big(dest, src, num) {
+ HEAPU8.set(HEAPU8.subarray(src, src+num), dest);
+ return dest;
+ }
+ Module["_memcpy"] = _memcpy;
+
+ function _free() {
+ }
+ Module["_free"] = _free;
+Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };
+ Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };
+ Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };
+ Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };
+ Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };
+ Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }
+FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;
+___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;
+__ATINIT__.unshift({ func: function() { TTY.init() } });__ATEXIT__.push({ func: function() { TTY.shutdown() } });TTY.utf8 = new Runtime.UTF8Processor();
+if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); NODEFS.staticInit(); }
+__ATINIT__.push({ func: function() { SOCKFS.root = FS.mount(SOCKFS, {}, null); } });
+STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);
+
+staticSealed = true; // seal the static portion of memory
+
+STACK_MAX = STACK_BASE + 5242880;
+
+DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);
+
+assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");
+
+
+var Math_min = Math.min;
+function asmPrintInt(x, y) {
+ Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+function asmPrintFloat(x, y) {
+ Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+// EMSCRIPTEN_START_ASM
+var asm = (function(global, env, buffer) {
+ 'use asm';
+ var HEAP8 = new global.Int8Array(buffer);
+ var HEAP16 = new global.Int16Array(buffer);
+ var HEAP32 = new global.Int32Array(buffer);
+ var HEAPU8 = new global.Uint8Array(buffer);
+ var HEAPU16 = new global.Uint16Array(buffer);
+ var HEAPU32 = new global.Uint32Array(buffer);
+ var HEAPF32 = new global.Float32Array(buffer);
+ var HEAPF64 = new global.Float64Array(buffer);
+
+ var STACKTOP=env.STACKTOP|0;
+ var STACK_MAX=env.STACK_MAX|0;
+ var tempDoublePtr=env.tempDoublePtr|0;
+ var ABORT=env.ABORT|0;
+
+ var __THREW__ = 0;
+ var threwValue = 0;
+ var setjmpId = 0;
+ var undef = 0;
+ var nan = +env.NaN, inf = +env.Infinity;
+ var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0;
+
+ var tempRet0 = 0;
+ var tempRet1 = 0;
+ var tempRet2 = 0;
+ var tempRet3 = 0;
+ var tempRet4 = 0;
+ var tempRet5 = 0;
+ var tempRet6 = 0;
+ var tempRet7 = 0;
+ var tempRet8 = 0;
+ var tempRet9 = 0;
+ var Math_floor=global.Math.floor;
+ var Math_abs=global.Math.abs;
+ var Math_sqrt=global.Math.sqrt;
+ var Math_pow=global.Math.pow;
+ var Math_cos=global.Math.cos;
+ var Math_sin=global.Math.sin;
+ var Math_tan=global.Math.tan;
+ var Math_acos=global.Math.acos;
+ var Math_asin=global.Math.asin;
+ var Math_atan=global.Math.atan;
+ var Math_atan2=global.Math.atan2;
+ var Math_exp=global.Math.exp;
+ var Math_log=global.Math.log;
+ var Math_ceil=global.Math.ceil;
+ var Math_imul=global.Math.imul;
+ var abort=env.abort;
+ var assert=env.assert;
+ var asmPrintInt=env.asmPrintInt;
+ var asmPrintFloat=env.asmPrintFloat;
+ var Math_min=env.min;
+ var _free=env._free;
+ var _emscripten_memcpy_big=env._emscripten_memcpy_big;
+ var _printf=env._printf;
+ var _send=env._send;
+ var _pwrite=env._pwrite;
+ var __reallyNegative=env.__reallyNegative;
+ var _fwrite=env._fwrite;
+ var _malloc=env._malloc;
+ var _mkport=env._mkport;
+ var _fprintf=env._fprintf;
+ var ___setErrNo=env.___setErrNo;
+ var __formatString=env.__formatString;
+ var _fileno=env._fileno;
+ var _fflush=env._fflush;
+ var _write=env._write;
+ var tempFloat = 0.0;
+
+// EMSCRIPTEN_START_FUNCS
+function _main(i3, i5) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i1;
+ L1 : do {
+ if ((i3 | 0) > 1) {
+ i3 = HEAP8[HEAP32[i5 + 4 >> 2] | 0] | 0;
+ switch (i3 | 0) {
+ case 50:
+ {
+ i3 = 625;
+ break L1;
+ }
+ case 51:
+ {
+ i4 = 4;
+ break L1;
+ }
+ case 52:
+ {
+ i3 = 6250;
+ break L1;
+ }
+ case 53:
+ {
+ i3 = 12500;
+ break L1;
+ }
+ case 49:
+ {
+ i3 = 75;
+ break L1;
+ }
+ case 48:
+ {
+ i12 = 0;
+ STACKTOP = i1;
+ return i12 | 0;
+ }
+ default:
+ {
+ HEAP32[i2 >> 2] = i3 + -48;
+ _printf(8, i2 | 0) | 0;
+ i12 = -1;
+ STACKTOP = i1;
+ return i12 | 0;
+ }
+ }
+ } else {
+ i4 = 4;
+ }
+ } while (0);
+ if ((i4 | 0) == 4) {
+ i3 = 1250;
+ }
+ i4 = 0;
+ i12 = 0;
+ do {
+ i9 = (i4 | 0) % 10 | 0;
+ i5 = i9 + i4 | 0;
+ i6 = (i4 | 0) % 255 | 0;
+ i8 = (i4 | 0) % 15 | 0;
+ i10 = ((i4 | 0) % 120 | 0 | 0) % 1024 | 0;
+ i11 = ((i4 | 0) % 1024 | 0) + i4 | 0;
+ i5 = ((i5 | 0) % 1024 | 0) + i5 | 0;
+ i8 = ((i8 | 0) % 1024 | 0) + i8 | 0;
+ i6 = (((i6 | 0) % 1024 | 0) + i6 + i10 | 0) % 1024 | 0;
+ i7 = 0;
+ do {
+ i17 = i7 << 1;
+ i14 = (i7 | 0) % 120 | 0;
+ i18 = (i17 | 0) % 1024 | 0;
+ i19 = (i9 + i7 | 0) % 1024 | 0;
+ i16 = ((i7 | 0) % 255 | 0 | 0) % 1024 | 0;
+ i15 = (i7 | 0) % 1024 | 0;
+ i13 = ((i7 | 0) % 15 | 0 | 0) % 1024 | 0;
+ i12 = (((i19 + i18 + i16 + i10 + i15 + i13 + ((i11 + i19 | 0) % 1024 | 0) + ((i5 + i18 | 0) % 1024 | 0) + ((i18 + i17 + i16 | 0) % 1024 | 0) + i6 + ((i8 + i15 | 0) % 1024 | 0) + ((((i14 | 0) % 1024 | 0) + i14 + i13 | 0) % 1024 | 0) | 0) % 100 | 0) + i12 | 0) % 10240 | 0;
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) != 5e4);
+ i4 = i4 + 1 | 0;
+ } while ((i4 | 0) < (i3 | 0));
+ HEAP32[i2 >> 2] = i12;
+ _printf(24, i2 | 0) | 0;
+ i19 = 0;
+ STACKTOP = i1;
+ return i19 | 0;
+}
+function _memcpy(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ if ((i1 | 0) >= 4096) return _emscripten_memcpy_big(i3 | 0, i2 | 0, i1 | 0) | 0;
+ i4 = i3 | 0;
+ if ((i3 & 3) == (i2 & 3)) {
+ while (i3 & 3) {
+ if ((i1 | 0) == 0) return i4 | 0;
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ while ((i1 | 0) >= 4) {
+ HEAP32[i3 >> 2] = HEAP32[i2 >> 2];
+ i3 = i3 + 4 | 0;
+ i2 = i2 + 4 | 0;
+ i1 = i1 - 4 | 0;
+ }
+ }
+ while ((i1 | 0) > 0) {
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ return i4 | 0;
+}
+function _memset(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = i1 + i3 | 0;
+ if ((i3 | 0) >= 20) {
+ i4 = i4 & 255;
+ i7 = i1 & 3;
+ i6 = i4 | i4 << 8 | i4 << 16 | i4 << 24;
+ i5 = i2 & ~3;
+ if (i7) {
+ i7 = i1 + 4 - i7 | 0;
+ while ((i1 | 0) < (i7 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ }
+ while ((i1 | 0) < (i5 | 0)) {
+ HEAP32[i1 >> 2] = i6;
+ i1 = i1 + 4 | 0;
+ }
+ }
+ while ((i1 | 0) < (i2 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ return i1 - i3 | 0;
+}
+function copyTempDouble(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+ HEAP8[tempDoublePtr + 4 | 0] = HEAP8[i1 + 4 | 0];
+ HEAP8[tempDoublePtr + 5 | 0] = HEAP8[i1 + 5 | 0];
+ HEAP8[tempDoublePtr + 6 | 0] = HEAP8[i1 + 6 | 0];
+ HEAP8[tempDoublePtr + 7 | 0] = HEAP8[i1 + 7 | 0];
+}
+function copyTempFloat(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+}
+function runPostSets() {}
+function _strlen(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = i1;
+ while (HEAP8[i2] | 0) {
+ i2 = i2 + 1 | 0;
+ }
+ return i2 - i1 | 0;
+}
+function stackAlloc(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + i1 | 0;
+ STACKTOP = STACKTOP + 7 & -8;
+ return i2 | 0;
+}
+function setThrew(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ if ((__THREW__ | 0) == 0) {
+ __THREW__ = i1;
+ threwValue = i2;
+ }
+}
+function stackRestore(i1) {
+ i1 = i1 | 0;
+ STACKTOP = i1;
+}
+function setTempRet9(i1) {
+ i1 = i1 | 0;
+ tempRet9 = i1;
+}
+function setTempRet8(i1) {
+ i1 = i1 | 0;
+ tempRet8 = i1;
+}
+function setTempRet7(i1) {
+ i1 = i1 | 0;
+ tempRet7 = i1;
+}
+function setTempRet6(i1) {
+ i1 = i1 | 0;
+ tempRet6 = i1;
+}
+function setTempRet5(i1) {
+ i1 = i1 | 0;
+ tempRet5 = i1;
+}
+function setTempRet4(i1) {
+ i1 = i1 | 0;
+ tempRet4 = i1;
+}
+function setTempRet3(i1) {
+ i1 = i1 | 0;
+ tempRet3 = i1;
+}
+function setTempRet2(i1) {
+ i1 = i1 | 0;
+ tempRet2 = i1;
+}
+function setTempRet1(i1) {
+ i1 = i1 | 0;
+ tempRet1 = i1;
+}
+function setTempRet0(i1) {
+ i1 = i1 | 0;
+ tempRet0 = i1;
+}
+function stackSave() {
+ return STACKTOP | 0;
+}
+
+// EMSCRIPTEN_END_FUNCS
+
+
+ return { _strlen: _strlen, _memcpy: _memcpy, _main: _main, _memset: _memset, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, setThrew: setThrew, setTempRet0: setTempRet0, setTempRet1: setTempRet1, setTempRet2: setTempRet2, setTempRet3: setTempRet3, setTempRet4: setTempRet4, setTempRet5: setTempRet5, setTempRet6: setTempRet6, setTempRet7: setTempRet7, setTempRet8: setTempRet8, setTempRet9: setTempRet9 };
+})
+// EMSCRIPTEN_END_ASM
+({ "Math": Math, "Int8Array": Int8Array, "Int16Array": Int16Array, "Int32Array": Int32Array, "Uint8Array": Uint8Array, "Uint16Array": Uint16Array, "Uint32Array": Uint32Array, "Float32Array": Float32Array, "Float64Array": Float64Array }, { "abort": abort, "assert": assert, "asmPrintInt": asmPrintInt, "asmPrintFloat": asmPrintFloat, "min": Math_min, "_free": _free, "_emscripten_memcpy_big": _emscripten_memcpy_big, "_printf": _printf, "_send": _send, "_pwrite": _pwrite, "__reallyNegative": __reallyNegative, "_fwrite": _fwrite, "_malloc": _malloc, "_mkport": _mkport, "_fprintf": _fprintf, "___setErrNo": ___setErrNo, "__formatString": __formatString, "_fileno": _fileno, "_fflush": _fflush, "_write": _write, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX, "tempDoublePtr": tempDoublePtr, "ABORT": ABORT, "NaN": NaN, "Infinity": Infinity }, buffer);
+var _strlen = Module["_strlen"] = asm["_strlen"];
+var _memcpy = Module["_memcpy"] = asm["_memcpy"];
+var _main = Module["_main"] = asm["_main"];
+var _memset = Module["_memset"] = asm["_memset"];
+var runPostSets = Module["runPostSets"] = asm["runPostSets"];
+
+Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
+Runtime.stackSave = function() { return asm['stackSave']() };
+Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
+
+
+// Warning: printing of i64 values may be slightly rounded! No deep i64 math used, so precise i64 code not included
+var i64Math = null;
+
+// === Auto-generated postamble setup entry stuff ===
+
+if (memoryInitializer) {
+ if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
+ var data = Module['readBinary'](memoryInitializer);
+ HEAPU8.set(data, STATIC_BASE);
+ } else {
+ addRunDependency('memory initializer');
+ Browser.asyncLoad(memoryInitializer, function(data) {
+ HEAPU8.set(data, STATIC_BASE);
+ removeRunDependency('memory initializer');
+ }, function(data) {
+ throw 'could not load memory initializer ' + memoryInitializer;
+ });
+ }
+}
+
+function ExitStatus(status) {
+ this.name = "ExitStatus";
+ this.message = "Program terminated with exit(" + status + ")";
+ this.status = status;
+};
+ExitStatus.prototype = new Error();
+ExitStatus.prototype.constructor = ExitStatus;
+
+var initialStackTop;
+var preloadStartTime = null;
+var calledMain = false;
+
+dependenciesFulfilled = function runCaller() {
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
+ if (!Module['calledRun'] && shouldRunNow) run([].concat(Module["arguments"]));
+ if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
+}
+
+Module['callMain'] = Module.callMain = function callMain(args) {
+ assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');
+ assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
+
+ args = args || [];
+
+ ensureInitRuntime();
+
+ var argc = args.length+1;
+ function pad() {
+ for (var i = 0; i < 4-1; i++) {
+ argv.push(0);
+ }
+ }
+ var argv = [allocate(intArrayFromString("/bin/this.program"), 'i8', ALLOC_NORMAL) ];
+ pad();
+ for (var i = 0; i < argc-1; i = i + 1) {
+ argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL));
+ pad();
+ }
+ argv.push(0);
+ argv = allocate(argv, 'i32', ALLOC_NORMAL);
+
+ initialStackTop = STACKTOP;
+
+ try {
+
+ var ret = Module['_main'](argc, argv, 0);
+
+
+ // if we're not running an evented main loop, it's time to exit
+ if (!Module['noExitRuntime']) {
+ exit(ret);
+ }
+ }
+ catch(e) {
+ if (e instanceof ExitStatus) {
+ // exit() throws this once it's done to make sure execution
+ // has been stopped completely
+ return;
+ } else if (e == 'SimulateInfiniteLoop') {
+ // running an evented main loop, don't immediately exit
+ Module['noExitRuntime'] = true;
+ return;
+ } else {
+ if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
+ throw e;
+ }
+ } finally {
+ calledMain = true;
+ }
+}
+
+
+
+
+function run(args) {
+ args = args || Module['arguments'];
+
+ if (preloadStartTime === null) preloadStartTime = Date.now();
+
+ if (runDependencies > 0) {
+ Module.printErr('run() called, but dependencies remain, so not running');
+ return;
+ }
+
+ preRun();
+
+ if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
+ if (Module['calledRun']) return; // run may have just been called through dependencies being fulfilled just in this very frame
+
+ function doRun() {
+ if (Module['calledRun']) return; // run may have just been called while the async setStatus time below was happening
+ Module['calledRun'] = true;
+
+ ensureInitRuntime();
+
+ preMain();
+
+ if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) {
+ Module.printErr('pre-main prep time: ' + (Date.now() - preloadStartTime) + ' ms');
+ }
+
+ if (Module['_main'] && shouldRunNow) {
+ Module['callMain'](args);
+ }
+
+ postRun();
+ }
+
+ if (Module['setStatus']) {
+ Module['setStatus']('Running...');
+ setTimeout(function() {
+ setTimeout(function() {
+ Module['setStatus']('');
+ }, 1);
+ if (!ABORT) doRun();
+ }, 1);
+ } else {
+ doRun();
+ }
+}
+Module['run'] = Module.run = run;
+
+function exit(status) {
+ ABORT = true;
+ EXITSTATUS = status;
+ STACKTOP = initialStackTop;
+
+ // exit the runtime
+ exitRuntime();
+
+ // TODO We should handle this differently based on environment.
+ // In the browser, the best we can do is throw an exception
+ // to halt execution, but in node we could process.exit and
+ // I'd imagine SM shell would have something equivalent.
+ // This would let us set a proper exit status (which
+ // would be great for checking test exit statuses).
+ // https://github.com/kripken/emscripten/issues/1371
+
+ // throw an exception to halt the current execution
+ throw new ExitStatus(status);
+}
+Module['exit'] = Module.exit = exit;
+
+function abort(text) {
+ if (text) {
+ Module.print(text);
+ Module.printErr(text);
+ }
+
+ ABORT = true;
+ EXITSTATUS = 1;
+
+ var extra = '\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.';
+
+ throw 'abort() at ' + stackTrace() + extra;
+}
+Module['abort'] = Module.abort = abort;
+
+// {{PRE_RUN_ADDITIONS}}
+
+if (Module['preInit']) {
+ if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
+ while (Module['preInit'].length > 0) {
+ Module['preInit'].pop()();
+ }
+}
+
+// shouldRunNow refers to calling main(), not run().
+var shouldRunNow = true;
+if (Module['noInitialRun']) {
+ shouldRunNow = false;
+}
+
+
+run([].concat(Module["arguments"]));
diff --git a/test/mjsunit/asm/embenchen/corrections.js b/test/mjsunit/asm/embenchen/corrections.js
new file mode 100644
index 000000000..f4884ac8a
--- /dev/null
+++ b/test/mjsunit/asm/embenchen/corrections.js
@@ -0,0 +1,5987 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var EXPECTED_OUTPUT = 'final: 40006013:58243.\n';
+var Module = {
+ arguments: [1],
+ print: function(x) {Module.printBuffer += x + '\n';},
+ preRun: [function() {Module.printBuffer = ''}],
+ postRun: [function() {
+ assertEquals(EXPECTED_OUTPUT, Module.printBuffer);
+ }],
+};
+// The Module object: Our interface to the outside world. We import
+// and export values on it, and do the work to get that through
+// closure compiler if necessary. There are various ways Module can be used:
+// 1. Not defined. We create it here
+// 2. A function parameter, function(Module) { ..generated code.. }
+// 3. pre-run appended it, var Module = {}; ..generated code..
+// 4. External script tag defines var Module.
+// We need to do an eval in order to handle the closure compiler
+// case, where this code here is minified but Module was defined
+// elsewhere (e.g. case 4 above). We also need to check if Module
+// already exists (e.g. case 3 above).
+// Note that if you want to run closure, and also to use Module
+// after the generated code, you will need to define var Module = {};
+// before the code. Then that object will be used in the code, and you
+// can continue to use Module afterwards as well.
+var Module;
+if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {};
+
+// Sometimes an existing Module object exists with properties
+// meant to overwrite the default module functionality. Here
+// we collect those properties and reapply _after_ we configure
+// the current environment's defaults to avoid having to be so
+// defensive during initialization.
+var moduleOverrides = {};
+for (var key in Module) {
+ if (Module.hasOwnProperty(key)) {
+ moduleOverrides[key] = Module[key];
+ }
+}
+
+// The environment setup code below is customized to use Module.
+// *** Environment setup code ***
+var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
+var ENVIRONMENT_IS_WEB = typeof window === 'object';
+var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
+var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+
+if (ENVIRONMENT_IS_NODE) {
+ // Expose functionality in the same simple way that the shells work
+ // Note that we pollute the global namespace here, otherwise we break in node
+ if (!Module['print']) Module['print'] = function print(x) {
+ process['stdout'].write(x + '\n');
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ process['stderr'].write(x + '\n');
+ };
+
+ var nodeFS = require('fs');
+ var nodePath = require('path');
+
+ Module['read'] = function read(filename, binary) {
+ filename = nodePath['normalize'](filename);
+ var ret = nodeFS['readFileSync'](filename);
+ // The path is absolute if the normalized version is the same as the resolved.
+ if (!ret && filename != nodePath['resolve'](filename)) {
+ filename = path.join(__dirname, '..', 'src', filename);
+ ret = nodeFS['readFileSync'](filename);
+ }
+ if (ret && !binary) ret = ret.toString();
+ return ret;
+ };
+
+ Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
+
+ Module['load'] = function load(f) {
+ globalEval(read(f));
+ };
+
+ Module['arguments'] = process['argv'].slice(2);
+
+ module['exports'] = Module;
+}
+else if (ENVIRONMENT_IS_SHELL) {
+ if (!Module['print']) Module['print'] = print;
+ if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
+
+ if (typeof read != 'undefined') {
+ Module['read'] = read;
+ } else {
+ Module['read'] = function read() { throw 'no read() available (jsc?)' };
+ }
+
+ Module['readBinary'] = function readBinary(f) {
+ return read(f, 'binary');
+ };
+
+ if (typeof scriptArgs != 'undefined') {
+ Module['arguments'] = scriptArgs;
+ } else if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ this['Module'] = Module;
+
+ eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
+}
+else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
+ Module['read'] = function read(url) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ xhr.send(null);
+ return xhr.responseText;
+ };
+
+ if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ if (typeof console !== 'undefined') {
+ if (!Module['print']) Module['print'] = function print(x) {
+ console.log(x);
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ console.log(x);
+ };
+ } else {
+ // Probably a worker, and without console.log. We can do very little here...
+ var TRY_USE_DUMP = false;
+ if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
+ dump(x);
+ }) : (function(x) {
+ // self.postMessage(x); // enable this if you want stdout to be sent as messages
+ }));
+ }
+
+ if (ENVIRONMENT_IS_WEB) {
+ window['Module'] = Module;
+ } else {
+ Module['load'] = importScripts;
+ }
+}
+else {
+ // Unreachable because SHELL is dependant on the others
+ throw 'Unknown runtime environment. Where are we?';
+}
+
+function globalEval(x) {
+ eval.call(null, x);
+}
+if (!Module['load'] == 'undefined' && Module['read']) {
+ Module['load'] = function load(f) {
+ globalEval(Module['read'](f));
+ };
+}
+if (!Module['print']) {
+ Module['print'] = function(){};
+}
+if (!Module['printErr']) {
+ Module['printErr'] = Module['print'];
+}
+if (!Module['arguments']) {
+ Module['arguments'] = [];
+}
+// *** Environment setup code ***
+
+// Closure helpers
+Module.print = Module['print'];
+Module.printErr = Module['printErr'];
+
+// Callbacks
+Module['preRun'] = [];
+Module['postRun'] = [];
+
+// Merge back in the overrides
+for (var key in moduleOverrides) {
+ if (moduleOverrides.hasOwnProperty(key)) {
+ Module[key] = moduleOverrides[key];
+ }
+}
+
+
+
+// === Auto-generated preamble library stuff ===
+
+//========================================
+// Runtime code shared with compiler
+//========================================
+
+var Runtime = {
+ stackSave: function () {
+ return STACKTOP;
+ },
+ stackRestore: function (stackTop) {
+ STACKTOP = stackTop;
+ },
+ forceAlign: function (target, quantum) {
+ quantum = quantum || 4;
+ if (quantum == 1) return target;
+ if (isNumber(target) && isNumber(quantum)) {
+ return Math.ceil(target/quantum)*quantum;
+ } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
+ return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')';
+ }
+ return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
+ },
+ isNumberType: function (type) {
+ return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
+ },
+ isPointerType: function isPointerType(type) {
+ return type[type.length-1] == '*';
+},
+ isStructType: function isStructType(type) {
+ if (isPointerType(type)) return false;
+ if (isArrayType(type)) return true;
+ if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
+ // See comment in isStructPointerType()
+ return type[0] == '%';
+},
+ INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
+ FLOAT_TYPES: {"float":0,"double":0},
+ or64: function (x, y) {
+ var l = (x | 0) | (y | 0);
+ var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ and64: function (x, y) {
+ var l = (x | 0) & (y | 0);
+ var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ xor64: function (x, y) {
+ var l = (x | 0) ^ (y | 0);
+ var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ getNativeTypeSize: function (type) {
+ switch (type) {
+ case 'i1': case 'i8': return 1;
+ case 'i16': return 2;
+ case 'i32': return 4;
+ case 'i64': return 8;
+ case 'float': return 4;
+ case 'double': return 8;
+ default: {
+ if (type[type.length-1] === '*') {
+ return Runtime.QUANTUM_SIZE; // A pointer
+ } else if (type[0] === 'i') {
+ var bits = parseInt(type.substr(1));
+ assert(bits % 8 === 0);
+ return bits/8;
+ } else {
+ return 0;
+ }
+ }
+ }
+ },
+ getNativeFieldSize: function (type) {
+ return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
+ },
+ dedup: function dedup(items, ident) {
+ var seen = {};
+ if (ident) {
+ return items.filter(function(item) {
+ if (seen[item[ident]]) return false;
+ seen[item[ident]] = true;
+ return true;
+ });
+ } else {
+ return items.filter(function(item) {
+ if (seen[item]) return false;
+ seen[item] = true;
+ return true;
+ });
+ }
+},
+ set: function set() {
+ var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
+ var ret = {};
+ for (var i = 0; i < args.length; i++) {
+ ret[args[i]] = 0;
+ }
+ return ret;
+},
+ STACK_ALIGN: 8,
+ getAlignSize: function (type, size, vararg) {
+ // we align i64s and doubles on 64-bit boundaries, unlike x86
+ if (!vararg && (type == 'i64' || type == 'double')) return 8;
+ if (!type) return Math.min(size, 8); // align structures internally to 64 bits
+ return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
+ },
+ calculateStructAlignment: function calculateStructAlignment(type) {
+ type.flatSize = 0;
+ type.alignSize = 0;
+ var diffs = [];
+ var prev = -1;
+ var index = 0;
+ type.flatIndexes = type.fields.map(function(field) {
+ index++;
+ var size, alignSize;
+ if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
+ size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
+ alignSize = Runtime.getAlignSize(field, size);
+ } else if (Runtime.isStructType(field)) {
+ if (field[1] === '0') {
+ // this is [0 x something]. When inside another structure like here, it must be at the end,
+ // and it adds no size
+ // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');
+ size = 0;
+ if (Types.types[field]) {
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ } else {
+ alignSize = type.alignSize || QUANTUM_SIZE;
+ }
+ } else {
+ size = Types.types[field].flatSize;
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ }
+ } else if (field[0] == 'b') {
+ // bN, large number field, like a [N x i8]
+ size = field.substr(1)|0;
+ alignSize = 1;
+ } else if (field[0] === '<') {
+ // vector type
+ size = alignSize = Types.types[field].flatSize; // fully aligned
+ } else if (field[0] === 'i') {
+ // illegal integer field, that could not be legalized because it is an internal structure field
+ // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
+ size = alignSize = parseInt(field.substr(1))/8;
+ assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
+ } else {
+ assert(false, 'invalid type for calculateStructAlignment');
+ }
+ if (type.packed) alignSize = 1;
+ type.alignSize = Math.max(type.alignSize, alignSize);
+ var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
+ type.flatSize = curr + size;
+ if (prev >= 0) {
+ diffs.push(curr-prev);
+ }
+ prev = curr;
+ return curr;
+ });
+ if (type.name_ && type.name_[0] === '[') {
+ // arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
+ // allocating a potentially huge array for [999999 x i8] etc.
+ type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
+ }
+ type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
+ if (diffs.length == 0) {
+ type.flatFactor = type.flatSize;
+ } else if (Runtime.dedup(diffs).length == 1) {
+ type.flatFactor = diffs[0];
+ }
+ type.needsFlattening = (type.flatFactor != 1);
+ return type.flatIndexes;
+ },
+ generateStructInfo: function (struct, typeName, offset) {
+ var type, alignment;
+ if (typeName) {
+ offset = offset || 0;
+ type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
+ if (!type) return null;
+ if (type.fields.length != struct.length) {
+ printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');
+ return null;
+ }
+ alignment = type.flatIndexes;
+ } else {
+ var type = { fields: struct.map(function(item) { return item[0] }) };
+ alignment = Runtime.calculateStructAlignment(type);
+ }
+ var ret = {
+ __size__: type.flatSize
+ };
+ if (typeName) {
+ struct.forEach(function(item, i) {
+ if (typeof item === 'string') {
+ ret[item] = alignment[i] + offset;
+ } else {
+ // embedded struct
+ var key;
+ for (var k in item) key = k;
+ ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
+ }
+ });
+ } else {
+ struct.forEach(function(item, i) {
+ ret[item[1]] = alignment[i];
+ });
+ }
+ return ret;
+ },
+ dynCall: function (sig, ptr, args) {
+ if (args && args.length) {
+ if (!args.splice) args = Array.prototype.slice.call(args);
+ args.splice(0, 0, ptr);
+ return Module['dynCall_' + sig].apply(null, args);
+ } else {
+ return Module['dynCall_' + sig].call(null, ptr);
+ }
+ },
+ functionPointers: [],
+ addFunction: function (func) {
+ for (var i = 0; i < Runtime.functionPointers.length; i++) {
+ if (!Runtime.functionPointers[i]) {
+ Runtime.functionPointers[i] = func;
+ return 2*(1 + i);
+ }
+ }
+ throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
+ },
+ removeFunction: function (index) {
+ Runtime.functionPointers[(index-2)/2] = null;
+ },
+ getAsmConst: function (code, numArgs) {
+ // code is a constant string on the heap, so we can cache these
+ if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
+ var func = Runtime.asmConstCache[code];
+ if (func) return func;
+ var args = [];
+ for (var i = 0; i < numArgs; i++) {
+ args.push(String.fromCharCode(36) + i); // $0, $1 etc
+ }
+ var source = Pointer_stringify(code);
+ if (source[0] === '"') {
+ // tolerate EM_ASM("..code..") even though EM_ASM(..code..) is correct
+ if (source.indexOf('"', 1) === source.length-1) {
+ source = source.substr(1, source.length-2);
+ } else {
+ // something invalid happened, e.g. EM_ASM("..code($0)..", input)
+ abort('invalid EM_ASM input |' + source + '|. Please use EM_ASM(..code..) (no quotes) or EM_ASM({ ..code($0).. }, input) (to input values)');
+ }
+ }
+ try {
+ var evalled = eval('(function(' + args.join(',') + '){ ' + source + ' })'); // new Function does not allow upvars in node
+ } catch(e) {
+ Module.printErr('error in executing inline EM_ASM code: ' + e + ' on: \n\n' + source + '\n\nwith args |' + args + '| (make sure to use the right one out of EM_ASM, EM_ASM_ARGS, etc.)');
+ throw e;
+ }
+ return Runtime.asmConstCache[code] = evalled;
+ },
+ warnOnce: function (text) {
+ if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
+ if (!Runtime.warnOnce.shown[text]) {
+ Runtime.warnOnce.shown[text] = 1;
+ Module.printErr(text);
+ }
+ },
+ funcWrappers: {},
+ getFuncWrapper: function (func, sig) {
+ assert(sig);
+ if (!Runtime.funcWrappers[func]) {
+ Runtime.funcWrappers[func] = function dynCall_wrapper() {
+ return Runtime.dynCall(sig, func, arguments);
+ };
+ }
+ return Runtime.funcWrappers[func];
+ },
+ UTF8Processor: function () {
+ var buffer = [];
+ var needed = 0;
+ this.processCChar = function (code) {
+ code = code & 0xFF;
+
+ if (buffer.length == 0) {
+ if ((code & 0x80) == 0x00) { // 0xxxxxxx
+ return String.fromCharCode(code);
+ }
+ buffer.push(code);
+ if ((code & 0xE0) == 0xC0) { // 110xxxxx
+ needed = 1;
+ } else if ((code & 0xF0) == 0xE0) { // 1110xxxx
+ needed = 2;
+ } else { // 11110xxx
+ needed = 3;
+ }
+ return '';
+ }
+
+ if (needed) {
+ buffer.push(code);
+ needed--;
+ if (needed > 0) return '';
+ }
+
+ var c1 = buffer[0];
+ var c2 = buffer[1];
+ var c3 = buffer[2];
+ var c4 = buffer[3];
+ var ret;
+ if (buffer.length == 2) {
+ ret = String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ } else if (buffer.length == 3) {
+ ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ } else {
+ // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |
+ ((c3 & 0x3F) << 6) | (c4 & 0x3F);
+ ret = String.fromCharCode(
+ Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,
+ (codePoint - 0x10000) % 0x400 + 0xDC00);
+ }
+ buffer.length = 0;
+ return ret;
+ }
+ this.processJSString = function processJSString(string) {
+ /* TODO: use TextEncoder when present,
+ var encoder = new TextEncoder();
+ encoder['encoding'] = "utf-8";
+ var utf8Array = encoder['encode'](aMsg.data);
+ */
+ string = unescape(encodeURIComponent(string));
+ var ret = [];
+ for (var i = 0; i < string.length; i++) {
+ ret.push(string.charCodeAt(i));
+ }
+ return ret;
+ }
+ },
+ getCompilerSetting: function (name) {
+ throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
+ },
+ stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+7)&-8); return ret; },
+ staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = (((STATICTOP)+7)&-8); return ret; },
+ dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = (((DYNAMICTOP)+7)&-8); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
+ alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },
+ makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*(+4294967296))) : ((+((low>>>0)))+((+((high|0)))*(+4294967296)))); return ret; },
+ GLOBAL_BASE: 8,
+ QUANTUM_SIZE: 4,
+ __dummy__: 0
+}
+
+
+Module['Runtime'] = Runtime;
+
+
+
+
+
+
+
+
+
+//========================================
+// Runtime essentials
+//========================================
+
+var __THREW__ = 0; // Used in checking for thrown exceptions.
+
+var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()
+var EXITSTATUS = 0;
+
+var undef = 0;
+// tempInt is used for 32-bit signed values or smaller. tempBigInt is used
+// for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
+var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
+var tempI64, tempI64b;
+var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
+
+function assert(condition, text) {
+ if (!condition) {
+ abort('Assertion failed: ' + text);
+ }
+}
+
+var globalScope = this;
+
+// C calling interface. A convenient way to call C functions (in C files, or
+// defined with extern "C").
+//
+// Note: LLVM optimizations can inline and remove functions, after which you will not be
+// able to call them. Closure can also do so. To avoid that, add your function to
+// the exports using something like
+//
+// -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]'
+//
+// @param ident The name of the C function (note that C++ functions will be name-mangled - use extern "C")
+// @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and
+// 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).
+// @param argTypes An array of the types of arguments for the function (if there are no arguments, this can be ommitted). Types are as in returnType,
+// except that 'array' is not possible (there is no way for us to know the length of the array)
+// @param args An array of the arguments to the function, as native JS values (as in returnType)
+// Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).
+// @return The return value, as a native JS value (as in returnType)
+function ccall(ident, returnType, argTypes, args) {
+ return ccallFunc(getCFunc(ident), returnType, argTypes, args);
+}
+Module["ccall"] = ccall;
+
+// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
+function getCFunc(ident) {
+ try {
+ var func = Module['_' + ident]; // closure exported function
+ if (!func) func = eval('_' + ident); // explicit lookup
+ } catch(e) {
+ }
+ assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
+ return func;
+}
+
+// Internal function that does a C call using a function, not an identifier
+function ccallFunc(func, returnType, argTypes, args) {
+ var stack = 0;
+ function toC(value, type) {
+ if (type == 'string') {
+ if (value === null || value === undefined || value === 0) return 0; // null string
+ value = intArrayFromString(value);
+ type = 'array';
+ }
+ if (type == 'array') {
+ if (!stack) stack = Runtime.stackSave();
+ var ret = Runtime.stackAlloc(value.length);
+ writeArrayToMemory(value, ret);
+ return ret;
+ }
+ return value;
+ }
+ function fromC(value, type) {
+ if (type == 'string') {
+ return Pointer_stringify(value);
+ }
+ assert(type != 'array');
+ return value;
+ }
+ var i = 0;
+ var cArgs = args ? args.map(function(arg) {
+ return toC(arg, argTypes[i++]);
+ }) : [];
+ var ret = fromC(func.apply(null, cArgs), returnType);
+ if (stack) Runtime.stackRestore(stack);
+ return ret;
+}
+
+// Returns a native JS wrapper for a C function. This is similar to ccall, but
+// returns a function you can call repeatedly in a normal way. For example:
+//
+// var my_function = cwrap('my_c_function', 'number', ['number', 'number']);
+// alert(my_function(5, 22));
+// alert(my_function(99, 12));
+//
+function cwrap(ident, returnType, argTypes) {
+ var func = getCFunc(ident);
+ return function() {
+ return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));
+ }
+}
+Module["cwrap"] = cwrap;
+
+// Sets a value in memory in a dynamic way at run-time. Uses the
+// type data. This is the same as makeSetValue, except that
+// makeSetValue is done at compile-time and generates the needed
+// code then, whereas this function picks the right code at
+// run-time.
+// Note that setValue and getValue only do *aligned* writes and reads!
+// Note that ccall uses JS types as for defining types, while setValue and
+// getValue need LLVM types ('i8', 'i32') - this is a lower-level operation
+function setValue(ptr, value, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': HEAP8[(ptr)]=value; break;
+ case 'i8': HEAP8[(ptr)]=value; break;
+ case 'i16': HEAP16[((ptr)>>1)]=value; break;
+ case 'i32': HEAP32[((ptr)>>2)]=value; break;
+ case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= (+1) ? (tempDouble > (+0) ? ((Math_min((+(Math_floor((tempDouble)/(+4294967296)))), (+4294967295)))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+4294967296))))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
+ case 'float': HEAPF32[((ptr)>>2)]=value; break;
+ case 'double': HEAPF64[((ptr)>>3)]=value; break;
+ default: abort('invalid type for setValue: ' + type);
+ }
+}
+Module['setValue'] = setValue;
+
+// Parallel to setValue.
+function getValue(ptr, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': return HEAP8[(ptr)];
+ case 'i8': return HEAP8[(ptr)];
+ case 'i16': return HEAP16[((ptr)>>1)];
+ case 'i32': return HEAP32[((ptr)>>2)];
+ case 'i64': return HEAP32[((ptr)>>2)];
+ case 'float': return HEAPF32[((ptr)>>2)];
+ case 'double': return HEAPF64[((ptr)>>3)];
+ default: abort('invalid type for setValue: ' + type);
+ }
+ return null;
+}
+Module['getValue'] = getValue;
+
+var ALLOC_NORMAL = 0; // Tries to use _malloc()
+var ALLOC_STACK = 1; // Lives for the duration of the current function call
+var ALLOC_STATIC = 2; // Cannot be freed
+var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
+var ALLOC_NONE = 4; // Do not allocate
+Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
+Module['ALLOC_STACK'] = ALLOC_STACK;
+Module['ALLOC_STATIC'] = ALLOC_STATIC;
+Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;
+Module['ALLOC_NONE'] = ALLOC_NONE;
+
+// allocate(): This is for internal use. You can use it yourself as well, but the interface
+// is a little tricky (see docs right below). The reason is that it is optimized
+// for multiple syntaxes to save space in generated code. So you should
+// normally not use allocate(), and instead allocate memory using _malloc(),
+// initialize it with setValue(), and so forth.
+// @slab: An array of data, or a number. If a number, then the size of the block to allocate,
+// in *bytes* (note that this is sometimes confusing: the next parameter does not
+// affect this!)
+// @types: Either an array of types, one for each byte (or 0 if no type at that position),
+// or a single type which is used for the entire block. This only matters if there
+// is initial data - if @slab is a number, then this does not matter at all and is
+// ignored.
+// @allocator: How to allocate memory, see ALLOC_*
+function allocate(slab, types, allocator, ptr) {
+ var zeroinit, size;
+ if (typeof slab === 'number') {
+ zeroinit = true;
+ size = slab;
+ } else {
+ zeroinit = false;
+ size = slab.length;
+ }
+
+ var singleType = typeof types === 'string' ? types : null;
+
+ var ret;
+ if (allocator == ALLOC_NONE) {
+ ret = ptr;
+ } else {
+ ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
+ }
+
+ if (zeroinit) {
+ var ptr = ret, stop;
+ assert((ret & 3) == 0);
+ stop = ret + (size & ~3);
+ for (; ptr < stop; ptr += 4) {
+ HEAP32[((ptr)>>2)]=0;
+ }
+ stop = ret + size;
+ while (ptr < stop) {
+ HEAP8[((ptr++)|0)]=0;
+ }
+ return ret;
+ }
+
+ if (singleType === 'i8') {
+ if (slab.subarray || slab.slice) {
+ HEAPU8.set(slab, ret);
+ } else {
+ HEAPU8.set(new Uint8Array(slab), ret);
+ }
+ return ret;
+ }
+
+ var i = 0, type, typeSize, previousType;
+ while (i < size) {
+ var curr = slab[i];
+
+ if (typeof curr === 'function') {
+ curr = Runtime.getFunctionIndex(curr);
+ }
+
+ type = singleType || types[i];
+ if (type === 0) {
+ i++;
+ continue;
+ }
+
+ if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
+
+ setValue(ret+i, curr, type);
+
+ // no need to look up size unless type changes, so cache it
+ if (previousType !== type) {
+ typeSize = Runtime.getNativeTypeSize(type);
+ previousType = type;
+ }
+ i += typeSize;
+ }
+
+ return ret;
+}
+Module['allocate'] = allocate;
+
+function Pointer_stringify(ptr, /* optional */ length) {
+ // TODO: use TextDecoder
+ // Find the length, and check for UTF while doing so
+ var hasUtf = false;
+ var t;
+ var i = 0;
+ while (1) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ if (t >= 128) hasUtf = true;
+ else if (t == 0 && !length) break;
+ i++;
+ if (length && i == length) break;
+ }
+ if (!length) length = i;
+
+ var ret = '';
+
+ if (!hasUtf) {
+ var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
+ var curr;
+ while (length > 0) {
+ curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
+ ret = ret ? ret + curr : curr;
+ ptr += MAX_CHUNK;
+ length -= MAX_CHUNK;
+ }
+ return ret;
+ }
+
+ var utf8 = new Runtime.UTF8Processor();
+ for (i = 0; i < length; i++) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ ret += utf8.processCChar(t);
+ }
+ return ret;
+}
+Module['Pointer_stringify'] = Pointer_stringify;
+
+// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF16ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
+ if (codeUnit == 0)
+ return str;
+ ++i;
+ // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
+ str += String.fromCharCode(codeUnit);
+ }
+}
+Module['UTF16ToString'] = UTF16ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
+function stringToUTF16(str, outPtr) {
+ for(var i = 0; i < str.length; ++i) {
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
+ HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP16[(((outPtr)+(str.length*2))>>1)]=0;
+}
+Module['stringToUTF16'] = stringToUTF16;
+
+// Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF32ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
+ if (utf32 == 0)
+ return str;
+ ++i;
+ // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
+ if (utf32 >= 0x10000) {
+ var ch = utf32 - 0x10000;
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
+ } else {
+ str += String.fromCharCode(utf32);
+ }
+ }
+}
+Module['UTF32ToString'] = UTF32ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
+// but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.
+function stringToUTF32(str, outPtr) {
+ var iChar = 0;
+ for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
+ var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
+ var trailSurrogate = str.charCodeAt(++iCodeUnit);
+ codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
+ }
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit;
+ ++iChar;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=0;
+}
+Module['stringToUTF32'] = stringToUTF32;
+
+function demangle(func) {
+ var i = 3;
+ // params, etc.
+ var basicTypes = {
+ 'v': 'void',
+ 'b': 'bool',
+ 'c': 'char',
+ 's': 'short',
+ 'i': 'int',
+ 'l': 'long',
+ 'f': 'float',
+ 'd': 'double',
+ 'w': 'wchar_t',
+ 'a': 'signed char',
+ 'h': 'unsigned char',
+ 't': 'unsigned short',
+ 'j': 'unsigned int',
+ 'm': 'unsigned long',
+ 'x': 'long long',
+ 'y': 'unsigned long long',
+ 'z': '...'
+ };
+ var subs = [];
+ var first = true;
+ function dump(x) {
+ //return;
+ if (x) Module.print(x);
+ Module.print(func);
+ var pre = '';
+ for (var a = 0; a < i; a++) pre += ' ';
+ Module.print (pre + '^');
+ }
+ function parseNested() {
+ i++;
+ if (func[i] === 'K') i++; // ignore const
+ var parts = [];
+ while (func[i] !== 'E') {
+ if (func[i] === 'S') { // substitution
+ i++;
+ var next = func.indexOf('_', i);
+ var num = func.substring(i, next) || 0;
+ parts.push(subs[num] || '?');
+ i = next+1;
+ continue;
+ }
+ if (func[i] === 'C') { // constructor
+ parts.push(parts[parts.length-1]);
+ i += 2;
+ continue;
+ }
+ var size = parseInt(func.substr(i));
+ var pre = size.toString().length;
+ if (!size || !pre) { i--; break; } // counter i++ below us
+ var curr = func.substr(i + pre, size);
+ parts.push(curr);
+ subs.push(curr);
+ i += pre + size;
+ }
+ i++; // skip E
+ return parts;
+ }
+ function parse(rawList, limit, allowVoid) { // main parser
+ limit = limit || Infinity;
+ var ret = '', list = [];
+ function flushList() {
+ return '(' + list.join(', ') + ')';
+ }
+ var name;
+ if (func[i] === 'N') {
+ // namespaced N-E
+ name = parseNested().join('::');
+ limit--;
+ if (limit === 0) return rawList ? [name] : name;
+ } else {
+ // not namespaced
+ if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
+ var size = parseInt(func.substr(i));
+ if (size) {
+ var pre = size.toString().length;
+ name = func.substr(i + pre, size);
+ i += pre + size;
+ }
+ }
+ first = false;
+ if (func[i] === 'I') {
+ i++;
+ var iList = parse(true);
+ var iRet = parse(true, 1, true);
+ ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
+ } else {
+ ret = name;
+ }
+ paramLoop: while (i < func.length && limit-- > 0) {
+ //dump('paramLoop');
+ var c = func[i++];
+ if (c in basicTypes) {
+ list.push(basicTypes[c]);
+ } else {
+ switch (c) {
+ case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
+ case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
+ case 'L': { // literal
+ i++; // skip basic type
+ var end = func.indexOf('E', i);
+ var size = end - i;
+ list.push(func.substr(i, size));
+ i += size + 2; // size + 'EE'
+ break;
+ }
+ case 'A': { // array
+ var size = parseInt(func.substr(i));
+ i += size.toString().length;
+ if (func[i] !== '_') throw '?';
+ i++; // skip _
+ list.push(parse(true, 1, true)[0] + ' [' + size + ']');
+ break;
+ }
+ case 'E': break paramLoop;
+ default: ret += '?' + c; break paramLoop;
+ }
+ }
+ }
+ if (!allowVoid && list.length === 1 && list[0] === 'void') list = []; // avoid (void)
+ if (rawList) {
+ if (ret) {
+ list.push(ret + '?');
+ }
+ return list;
+ } else {
+ return ret + flushList();
+ }
+ }
+ try {
+ // Special-case the entry point, since its name differs from other name mangling.
+ if (func == 'Object._main' || func == '_main') {
+ return 'main()';
+ }
+ if (typeof func === 'number') func = Pointer_stringify(func);
+ if (func[0] !== '_') return func;
+ if (func[1] !== '_') return func; // C function
+ if (func[2] !== 'Z') return func;
+ switch (func[3]) {
+ case 'n': return 'operator new()';
+ case 'd': return 'operator delete()';
+ }
+ return parse();
+ } catch(e) {
+ return func;
+ }
+}
+
+function demangleAll(text) {
+ return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });
+}
+
+function stackTrace() {
+ var stack = new Error().stack;
+ return stack ? demangleAll(stack) : '(no stack trace available)'; // Stack trace is not available at least on IE10 and Safari 6.
+}
+
+// Memory management
+
+var PAGE_SIZE = 4096;
+function alignMemoryPage(x) {
+ return (x+4095)&-4096;
+}
+
+var HEAP;
+var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
+
+var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area
+var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area
+var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk
+
+function enlargeMemory() {
+ abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
+}
+
+var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
+var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 134217728;
+var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
+
+var totalMemory = 4096;
+while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
+ if (totalMemory < 16*1024*1024) {
+ totalMemory *= 2;
+ } else {
+ totalMemory += 16*1024*1024
+ }
+}
+if (totalMemory !== TOTAL_MEMORY) {
+ Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
+ TOTAL_MEMORY = totalMemory;
+}
+
+// Initialize the runtime's memory
+// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
+assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
+ 'JS engine does not provide full typed array support');
+
+var buffer = new ArrayBuffer(TOTAL_MEMORY);
+HEAP8 = new Int8Array(buffer);
+HEAP16 = new Int16Array(buffer);
+HEAP32 = new Int32Array(buffer);
+HEAPU8 = new Uint8Array(buffer);
+HEAPU16 = new Uint16Array(buffer);
+HEAPU32 = new Uint32Array(buffer);
+HEAPF32 = new Float32Array(buffer);
+HEAPF64 = new Float64Array(buffer);
+
+// Endianness check (note: assumes compiler arch was little-endian)
+HEAP32[0] = 255;
+assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
+
+Module['HEAP'] = HEAP;
+Module['HEAP8'] = HEAP8;
+Module['HEAP16'] = HEAP16;
+Module['HEAP32'] = HEAP32;
+Module['HEAPU8'] = HEAPU8;
+Module['HEAPU16'] = HEAPU16;
+Module['HEAPU32'] = HEAPU32;
+Module['HEAPF32'] = HEAPF32;
+Module['HEAPF64'] = HEAPF64;
+
+function callRuntimeCallbacks(callbacks) {
+ while(callbacks.length > 0) {
+ var callback = callbacks.shift();
+ if (typeof callback == 'function') {
+ callback();
+ continue;
+ }
+ var func = callback.func;
+ if (typeof func === 'number') {
+ if (callback.arg === undefined) {
+ Runtime.dynCall('v', func);
+ } else {
+ Runtime.dynCall('vi', func, [callback.arg]);
+ }
+ } else {
+ func(callback.arg === undefined ? null : callback.arg);
+ }
+ }
+}
+
+var __ATPRERUN__ = []; // functions called before the runtime is initialized
+var __ATINIT__ = []; // functions called during startup
+var __ATMAIN__ = []; // functions called when main() is to be run
+var __ATEXIT__ = []; // functions called during shutdown
+var __ATPOSTRUN__ = []; // functions called after the runtime has exited
+
+var runtimeInitialized = false;
+
+function preRun() {
+ // compatibility - merge in anything from Module['preRun'] at this time
+ if (Module['preRun']) {
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
+ while (Module['preRun'].length) {
+ addOnPreRun(Module['preRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPRERUN__);
+}
+
+function ensureInitRuntime() {
+ if (runtimeInitialized) return;
+ runtimeInitialized = true;
+ callRuntimeCallbacks(__ATINIT__);
+}
+
+function preMain() {
+ callRuntimeCallbacks(__ATMAIN__);
+}
+
+function exitRuntime() {
+ callRuntimeCallbacks(__ATEXIT__);
+}
+
+function postRun() {
+ // compatibility - merge in anything from Module['postRun'] at this time
+ if (Module['postRun']) {
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
+ while (Module['postRun'].length) {
+ addOnPostRun(Module['postRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPOSTRUN__);
+}
+
+function addOnPreRun(cb) {
+ __ATPRERUN__.unshift(cb);
+}
+Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;
+
+function addOnInit(cb) {
+ __ATINIT__.unshift(cb);
+}
+Module['addOnInit'] = Module.addOnInit = addOnInit;
+
+function addOnPreMain(cb) {
+ __ATMAIN__.unshift(cb);
+}
+Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;
+
+function addOnExit(cb) {
+ __ATEXIT__.unshift(cb);
+}
+Module['addOnExit'] = Module.addOnExit = addOnExit;
+
+function addOnPostRun(cb) {
+ __ATPOSTRUN__.unshift(cb);
+}
+Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;
+
+// Tools
+
+// This processes a JS string into a C-line array of numbers, 0-terminated.
+// For LLVM-originating strings, see parser.js:parseLLVMString function
+function intArrayFromString(stringy, dontAddNull, length /* optional */) {
+ var ret = (new Runtime.UTF8Processor()).processJSString(stringy);
+ if (length) {
+ ret.length = length;
+ }
+ if (!dontAddNull) {
+ ret.push(0);
+ }
+ return ret;
+}
+Module['intArrayFromString'] = intArrayFromString;
+
+function intArrayToString(array) {
+ var ret = [];
+ for (var i = 0; i < array.length; i++) {
+ var chr = array[i];
+ if (chr > 0xFF) {
+ chr &= 0xFF;
+ }
+ ret.push(String.fromCharCode(chr));
+ }
+ return ret.join('');
+}
+Module['intArrayToString'] = intArrayToString;
+
+// Write a Javascript array to somewhere in the heap
+function writeStringToMemory(string, buffer, dontAddNull) {
+ var array = intArrayFromString(string, dontAddNull);
+ var i = 0;
+ while (i < array.length) {
+ var chr = array[i];
+ HEAP8[(((buffer)+(i))|0)]=chr;
+ i = i + 1;
+ }
+}
+Module['writeStringToMemory'] = writeStringToMemory;
+
+function writeArrayToMemory(array, buffer) {
+ for (var i = 0; i < array.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=array[i];
+ }
+}
+Module['writeArrayToMemory'] = writeArrayToMemory;
+
+function writeAsciiToMemory(str, buffer, dontAddNull) {
+ for (var i = 0; i < str.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=str.charCodeAt(i);
+ }
+ if (!dontAddNull) HEAP8[(((buffer)+(str.length))|0)]=0;
+}
+Module['writeAsciiToMemory'] = writeAsciiToMemory;
+
+function unSign(value, bits, ignore) {
+ if (value >= 0) {
+ return value;
+ }
+ return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
+ : Math.pow(2, bits) + value;
+}
+function reSign(value, bits, ignore) {
+ if (value <= 0) {
+ return value;
+ }
+ var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
+ : Math.pow(2, bits-1);
+ if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
+ // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
+ // TODO: In i64 mode 1, resign the two parts separately and safely
+ value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
+ }
+ return value;
+}
+
+// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
+if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
+ var ah = a >>> 16;
+ var al = a & 0xffff;
+ var bh = b >>> 16;
+ var bl = b & 0xffff;
+ return (al*bl + ((ah*bl + al*bh) << 16))|0;
+};
+Math.imul = Math['imul'];
+
+
+var Math_abs = Math.abs;
+var Math_cos = Math.cos;
+var Math_sin = Math.sin;
+var Math_tan = Math.tan;
+var Math_acos = Math.acos;
+var Math_asin = Math.asin;
+var Math_atan = Math.atan;
+var Math_atan2 = Math.atan2;
+var Math_exp = Math.exp;
+var Math_log = Math.log;
+var Math_sqrt = Math.sqrt;
+var Math_ceil = Math.ceil;
+var Math_floor = Math.floor;
+var Math_pow = Math.pow;
+var Math_imul = Math.imul;
+var Math_fround = Math.fround;
+var Math_min = Math.min;
+
+// A counter of dependencies for calling run(). If we need to
+// do asynchronous work before running, increment this and
+// decrement it. Incrementing must happen in a place like
+// PRE_RUN_ADDITIONS (used by emcc to add file preloading).
+// Note that you can add dependencies in preRun, even though
+// it happens right before run - run will be postponed until
+// the dependencies are met.
+var runDependencies = 0;
+var runDependencyWatcher = null;
+var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
+
+function addRunDependency(id) {
+ runDependencies++;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+}
+Module['addRunDependency'] = addRunDependency;
+function removeRunDependency(id) {
+ runDependencies--;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+ if (runDependencies == 0) {
+ if (runDependencyWatcher !== null) {
+ clearInterval(runDependencyWatcher);
+ runDependencyWatcher = null;
+ }
+ if (dependenciesFulfilled) {
+ var callback = dependenciesFulfilled;
+ dependenciesFulfilled = null;
+ callback(); // can add another dependenciesFulfilled
+ }
+ }
+}
+Module['removeRunDependency'] = removeRunDependency;
+
+Module["preloadedImages"] = {}; // maps url to image data
+Module["preloadedAudios"] = {}; // maps url to audio data
+
+
+var memoryInitializer = null;
+
+// === Body ===
+
+
+
+
+
+STATIC_BASE = 8;
+
+STATICTOP = STATIC_BASE + Runtime.alignMemory(35);
+/* global initializers */ __ATINIT__.push();
+
+
+/* memory initializer */ allocate([101,114,114,111,114,58,32,37,100,92,110,0,0,0,0,0,102,105,110,97,108,58,32,37,100,58,37,100,46,10,0,0], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
+
+
+
+
+var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8);
+
+assert(tempDoublePtr % 8 == 0);
+
+function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+}
+
+function copyTempDouble(ptr) {
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+ HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
+
+ HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
+
+ HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
+
+ HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
+
+}
+
+
+ function _malloc(bytes) {
+ /* Over-allocate to make sure it is byte-aligned by 8.
+ * This will leak memory, but this is only the dummy
+ * implementation (replaced by dlmalloc normally) so
+ * not an issue.
+ */
+ var ptr = Runtime.dynamicAlloc(bytes + 8);
+ return (ptr+8) & 0xFFFFFFF8;
+ }
+ Module["_malloc"] = _malloc;
+
+
+
+
+ var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};
+
+ var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
+
+
+ var ___errno_state=0;function ___setErrNo(value) {
+ // For convenient setting and returning of errno.
+ HEAP32[((___errno_state)>>2)]=value;
+ return value;
+ }
+
+ var TTY={ttys:[],init:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // currently, FS.init does not distinguish if process.stdin is a file or TTY
+ // // device, it always assumes it's a TTY device. because of this, we're forcing
+ // // process.stdin to UTF8 encoding to at least make stdin reading compatible
+ // // with text files until FS.init can be refactored.
+ // process['stdin']['setEncoding']('utf8');
+ // }
+ },shutdown:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
+ // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
+ // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
+ // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
+ // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
+ // process['stdin']['pause']();
+ // }
+ },register:function (dev, ops) {
+ TTY.ttys[dev] = { input: [], output: [], ops: ops };
+ FS.registerDevice(dev, TTY.stream_ops);
+ },stream_ops:{open:function (stream) {
+ var tty = TTY.ttys[stream.node.rdev];
+ if (!tty) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ stream.tty = tty;
+ stream.seekable = false;
+ },close:function (stream) {
+ // flush any pending line data
+ if (stream.tty.output.length) {
+ stream.tty.ops.put_char(stream.tty, 10);
+ }
+ },read:function (stream, buffer, offset, length, pos /* ignored */) {
+ if (!stream.tty || !stream.tty.ops.get_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = stream.tty.ops.get_char(stream.tty);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, pos) {
+ if (!stream.tty || !stream.tty.ops.put_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ for (var i = 0; i < length; i++) {
+ try {
+ stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }},default_tty_ops:{get_char:function (tty) {
+ if (!tty.input.length) {
+ var result = null;
+ if (ENVIRONMENT_IS_NODE) {
+ result = process['stdin']['read']();
+ if (!result) {
+ if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
+ return null; // EOF
+ }
+ return undefined; // no data available
+ }
+ } else if (typeof window != 'undefined' &&
+ typeof window.prompt == 'function') {
+ // Browser.
+ result = window.prompt('Input: '); // returns null on cancel
+ if (result !== null) {
+ result += '\n';
+ }
+ } else if (typeof readline == 'function') {
+ // Command line.
+ result = readline();
+ if (result !== null) {
+ result += '\n';
+ }
+ }
+ if (!result) {
+ return null;
+ }
+ tty.input = intArrayFromString(result, true);
+ }
+ return tty.input.shift();
+ },put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['print'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }},default_tty1_ops:{put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['printErr'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }}};
+
+ var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
+ return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
+ // no supported
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (!MEMFS.ops_table) {
+ MEMFS.ops_table = {
+ dir: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ lookup: MEMFS.node_ops.lookup,
+ mknod: MEMFS.node_ops.mknod,
+ rename: MEMFS.node_ops.rename,
+ unlink: MEMFS.node_ops.unlink,
+ rmdir: MEMFS.node_ops.rmdir,
+ readdir: MEMFS.node_ops.readdir,
+ symlink: MEMFS.node_ops.symlink
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek
+ }
+ },
+ file: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek,
+ read: MEMFS.stream_ops.read,
+ write: MEMFS.stream_ops.write,
+ allocate: MEMFS.stream_ops.allocate,
+ mmap: MEMFS.stream_ops.mmap
+ }
+ },
+ link: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ readlink: MEMFS.node_ops.readlink
+ },
+ stream: {}
+ },
+ chrdev: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: FS.chrdev_stream_ops
+ },
+ };
+ }
+ var node = FS.createNode(parent, name, mode, dev);
+ if (FS.isDir(node.mode)) {
+ node.node_ops = MEMFS.ops_table.dir.node;
+ node.stream_ops = MEMFS.ops_table.dir.stream;
+ node.contents = {};
+ } else if (FS.isFile(node.mode)) {
+ node.node_ops = MEMFS.ops_table.file.node;
+ node.stream_ops = MEMFS.ops_table.file.stream;
+ node.contents = [];
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ } else if (FS.isLink(node.mode)) {
+ node.node_ops = MEMFS.ops_table.link.node;
+ node.stream_ops = MEMFS.ops_table.link.stream;
+ } else if (FS.isChrdev(node.mode)) {
+ node.node_ops = MEMFS.ops_table.chrdev.node;
+ node.stream_ops = MEMFS.ops_table.chrdev.stream;
+ }
+ node.timestamp = Date.now();
+ // add the new node to the parent
+ if (parent) {
+ parent.contents[name] = node;
+ }
+ return node;
+ },ensureFlexible:function (node) {
+ if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
+ var contents = node.contents;
+ node.contents = Array.prototype.slice.call(contents);
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ }
+ },node_ops:{getattr:function (node) {
+ var attr = {};
+ // device numbers reuse inode numbers.
+ attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
+ attr.ino = node.id;
+ attr.mode = node.mode;
+ attr.nlink = 1;
+ attr.uid = 0;
+ attr.gid = 0;
+ attr.rdev = node.rdev;
+ if (FS.isDir(node.mode)) {
+ attr.size = 4096;
+ } else if (FS.isFile(node.mode)) {
+ attr.size = node.contents.length;
+ } else if (FS.isLink(node.mode)) {
+ attr.size = node.link.length;
+ } else {
+ attr.size = 0;
+ }
+ attr.atime = new Date(node.timestamp);
+ attr.mtime = new Date(node.timestamp);
+ attr.ctime = new Date(node.timestamp);
+ // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
+ // but this is not required by the standard.
+ attr.blksize = 4096;
+ attr.blocks = Math.ceil(attr.size / attr.blksize);
+ return attr;
+ },setattr:function (node, attr) {
+ if (attr.mode !== undefined) {
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ node.timestamp = attr.timestamp;
+ }
+ if (attr.size !== undefined) {
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ if (attr.size < contents.length) contents.length = attr.size;
+ else while (attr.size > contents.length) contents.push(0);
+ }
+ },lookup:function (parent, name) {
+ throw FS.genericErrors[ERRNO_CODES.ENOENT];
+ },mknod:function (parent, name, mode, dev) {
+ return MEMFS.createNode(parent, name, mode, dev);
+ },rename:function (old_node, new_dir, new_name) {
+ // if we're overwriting a directory at new_name, make sure it's empty.
+ if (FS.isDir(old_node.mode)) {
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ }
+ if (new_node) {
+ for (var i in new_node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ }
+ }
+ // do the internal rewiring
+ delete old_node.parent.contents[old_node.name];
+ old_node.name = new_name;
+ new_dir.contents[new_name] = old_node;
+ old_node.parent = new_dir;
+ },unlink:function (parent, name) {
+ delete parent.contents[name];
+ },rmdir:function (parent, name) {
+ var node = FS.lookupNode(parent, name);
+ for (var i in node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ delete parent.contents[name];
+ },readdir:function (node) {
+ var entries = ['.', '..']
+ for (var key in node.contents) {
+ if (!node.contents.hasOwnProperty(key)) {
+ continue;
+ }
+ entries.push(key);
+ }
+ return entries;
+ },symlink:function (parent, newname, oldpath) {
+ var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
+ node.link = oldpath;
+ return node;
+ },readlink:function (node) {
+ if (!FS.isLink(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return node.link;
+ }},stream_ops:{read:function (stream, buffer, offset, length, position) {
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (size > 8 && contents.subarray) { // non-trivial, and typed array
+ buffer.set(contents.subarray(position, position + size), offset);
+ } else
+ {
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ }
+ return size;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ var node = stream.node;
+ node.timestamp = Date.now();
+ var contents = node.contents;
+ if (length && contents.length === 0 && position === 0 && buffer.subarray) {
+ // just replace it with the new data
+ if (canOwn && offset === 0) {
+ node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
+ node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
+ } else {
+ node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
+ node.contentMode = MEMFS.CONTENT_FIXED;
+ }
+ return length;
+ }
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ while (contents.length < position) contents.push(0);
+ for (var i = 0; i < length; i++) {
+ contents[position + i] = buffer[offset + i];
+ }
+ return length;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ position += stream.node.contents.length;
+ }
+ }
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ stream.ungotten = [];
+ stream.position = position;
+ return position;
+ },allocate:function (stream, offset, length) {
+ MEMFS.ensureFlexible(stream.node);
+ var contents = stream.node.contents;
+ var limit = offset + length;
+ while (limit > contents.length) contents.push(0);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ if (!FS.isFile(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ var ptr;
+ var allocated;
+ var contents = stream.node.contents;
+ // Only make a new copy when MAP_PRIVATE is specified.
+ if ( !(flags & 2) &&
+ (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
+ // We can't emulate MAP_SHARED when the file is not backed by the buffer
+ // we're mapping to (e.g. the HEAP buffer).
+ allocated = false;
+ ptr = contents.byteOffset;
+ } else {
+ // Try to avoid unnecessary slices.
+ if (position > 0 || position + length < contents.length) {
+ if (contents.subarray) {
+ contents = contents.subarray(position, position + length);
+ } else {
+ contents = Array.prototype.slice.call(contents, position, position + length);
+ }
+ }
+ allocated = true;
+ ptr = _malloc(length);
+ if (!ptr) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
+ }
+ buffer.set(contents, ptr);
+ }
+ return { ptr: ptr, allocated: allocated };
+ }}};
+
+ var IDBFS={dbs:{},indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
+ // reuse all of the core MEMFS functionality
+ return MEMFS.mount.apply(null, arguments);
+ },syncfs:function (mount, populate, callback) {
+ IDBFS.getLocalSet(mount, function(err, local) {
+ if (err) return callback(err);
+
+ IDBFS.getRemoteSet(mount, function(err, remote) {
+ if (err) return callback(err);
+
+ var src = populate ? remote : local;
+ var dst = populate ? local : remote;
+
+ IDBFS.reconcile(src, dst, callback);
+ });
+ });
+ },getDB:function (name, callback) {
+ // check the cache first
+ var db = IDBFS.dbs[name];
+ if (db) {
+ return callback(null, db);
+ }
+
+ var req;
+ try {
+ req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
+ } catch (e) {
+ return callback(e);
+ }
+ req.onupgradeneeded = function(e) {
+ var db = e.target.result;
+ var transaction = e.target.transaction;
+
+ var fileStore;
+
+ if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
+ fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ } else {
+ fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
+ }
+
+ fileStore.createIndex('timestamp', 'timestamp', { unique: false });
+ };
+ req.onsuccess = function() {
+ db = req.result;
+
+ // add to the cache
+ IDBFS.dbs[name] = db;
+ callback(null, db);
+ };
+ req.onerror = function() {
+ callback(this.error);
+ };
+ },getLocalSet:function (mount, callback) {
+ var entries = {};
+
+ function isRealDir(p) {
+ return p !== '.' && p !== '..';
+ };
+ function toAbsolute(root) {
+ return function(p) {
+ return PATH.join2(root, p);
+ }
+ };
+
+ var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
+
+ while (check.length) {
+ var path = check.pop();
+ var stat;
+
+ try {
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
+ }
+
+ entries[path] = { timestamp: stat.mtime };
+ }
+
+ return callback(null, { type: 'local', entries: entries });
+ },getRemoteSet:function (mount, callback) {
+ var entries = {};
+
+ IDBFS.getDB(mount.mountpoint, function(err, db) {
+ if (err) return callback(err);
+
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
+ transaction.onerror = function() { callback(this.error); };
+
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ var index = store.index('timestamp');
+
+ index.openKeyCursor().onsuccess = function(event) {
+ var cursor = event.target.result;
+
+ if (!cursor) {
+ return callback(null, { type: 'remote', db: db, entries: entries });
+ }
+
+ entries[cursor.primaryKey] = { timestamp: cursor.key };
+
+ cursor.continue();
+ };
+ });
+ },loadLocalEntry:function (path, callback) {
+ var stat, node;
+
+ try {
+ var lookup = FS.lookupPath(path);
+ node = lookup.node;
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode });
+ } else if (FS.isFile(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+ },storeLocalEntry:function (path, entry, callback) {
+ try {
+ if (FS.isDir(entry.mode)) {
+ FS.mkdir(path, entry.mode);
+ } else if (FS.isFile(entry.mode)) {
+ FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+
+ FS.utime(path, entry.timestamp, entry.timestamp);
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },removeLocalEntry:function (path, callback) {
+ try {
+ var lookup = FS.lookupPath(path);
+ var stat = FS.stat(path);
+
+ if (FS.isDir(stat.mode)) {
+ FS.rmdir(path);
+ } else if (FS.isFile(stat.mode)) {
+ FS.unlink(path);
+ }
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },loadRemoteEntry:function (store, path, callback) {
+ var req = store.get(path);
+ req.onsuccess = function(event) { callback(null, event.target.result); };
+ req.onerror = function() { callback(this.error); };
+ },storeRemoteEntry:function (store, path, entry, callback) {
+ var req = store.put(entry, path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },removeRemoteEntry:function (store, path, callback) {
+ var req = store.delete(path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },reconcile:function (src, dst, callback) {
+ var total = 0;
+
+ var create = [];
+ Object.keys(src.entries).forEach(function (key) {
+ var e = src.entries[key];
+ var e2 = dst.entries[key];
+ if (!e2 || e.timestamp > e2.timestamp) {
+ create.push(key);
+ total++;
+ }
+ });
+
+ var remove = [];
+ Object.keys(dst.entries).forEach(function (key) {
+ var e = dst.entries[key];
+ var e2 = src.entries[key];
+ if (!e2) {
+ remove.push(key);
+ total++;
+ }
+ });
+
+ if (!total) {
+ return callback(null);
+ }
+
+ var errored = false;
+ var completed = 0;
+ var db = src.type === 'remote' ? src.db : dst.db;
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= total) {
+ return callback(null);
+ }
+ };
+
+ transaction.onerror = function() { done(this.error); };
+
+ // sort paths in ascending order so directory entries are created
+ // before the files inside them
+ create.sort().forEach(function (path) {
+ if (dst.type === 'local') {
+ IDBFS.loadRemoteEntry(store, path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeLocalEntry(path, entry, done);
+ });
+ } else {
+ IDBFS.loadLocalEntry(path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeRemoteEntry(store, path, entry, done);
+ });
+ }
+ });
+
+ // sort paths in descending order so files are deleted before their
+ // parent directories
+ remove.sort().reverse().forEach(function(path) {
+ if (dst.type === 'local') {
+ IDBFS.removeLocalEntry(path, done);
+ } else {
+ IDBFS.removeRemoteEntry(store, path, done);
+ }
+ });
+ }};
+
+ var NODEFS={isWindows:false,staticInit:function () {
+ NODEFS.isWindows = !!process.platform.match(/^win/);
+ },mount:function (mount) {
+ assert(ENVIRONMENT_IS_NODE);
+ return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node = FS.createNode(parent, name, mode);
+ node.node_ops = NODEFS.node_ops;
+ node.stream_ops = NODEFS.stream_ops;
+ return node;
+ },getMode:function (path) {
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ if (NODEFS.isWindows) {
+ // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so
+ // propagate write bits to execute bits.
+ stat.mode = stat.mode | ((stat.mode & 146) >> 1);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return stat.mode;
+ },realPath:function (node) {
+ var parts = [];
+ while (node.parent !== node) {
+ parts.push(node.name);
+ node = node.parent;
+ }
+ parts.push(node.mount.opts.root);
+ parts.reverse();
+ return PATH.join.apply(null, parts);
+ },flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function (flags) {
+ if (flags in NODEFS.flagsToPermissionStringMap) {
+ return NODEFS.flagsToPermissionStringMap[flags];
+ } else {
+ return flags;
+ }
+ },node_ops:{getattr:function (node) {
+ var path = NODEFS.realPath(node);
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
+ // See http://support.microsoft.com/kb/140365
+ if (NODEFS.isWindows && !stat.blksize) {
+ stat.blksize = 4096;
+ }
+ if (NODEFS.isWindows && !stat.blocks) {
+ stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
+ }
+ return {
+ dev: stat.dev,
+ ino: stat.ino,
+ mode: stat.mode,
+ nlink: stat.nlink,
+ uid: stat.uid,
+ gid: stat.gid,
+ rdev: stat.rdev,
+ size: stat.size,
+ atime: stat.atime,
+ mtime: stat.mtime,
+ ctime: stat.ctime,
+ blksize: stat.blksize,
+ blocks: stat.blocks
+ };
+ },setattr:function (node, attr) {
+ var path = NODEFS.realPath(node);
+ try {
+ if (attr.mode !== undefined) {
+ fs.chmodSync(path, attr.mode);
+ // update the common node structure mode as well
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ var date = new Date(attr.timestamp);
+ fs.utimesSync(path, date, date);
+ }
+ if (attr.size !== undefined) {
+ fs.truncateSync(path, attr.size);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },lookup:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ var mode = NODEFS.getMode(path);
+ return NODEFS.createNode(parent, name, mode);
+ },mknod:function (parent, name, mode, dev) {
+ var node = NODEFS.createNode(parent, name, mode, dev);
+ // create the backing node for this in the fs root as well
+ var path = NODEFS.realPath(node);
+ try {
+ if (FS.isDir(node.mode)) {
+ fs.mkdirSync(path, node.mode);
+ } else {
+ fs.writeFileSync(path, '', { mode: node.mode });
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return node;
+ },rename:function (oldNode, newDir, newName) {
+ var oldPath = NODEFS.realPath(oldNode);
+ var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
+ try {
+ fs.renameSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },unlink:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.unlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },rmdir:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.rmdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readdir:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },symlink:function (parent, newName, oldPath) {
+ var newPath = PATH.join2(NODEFS.realPath(parent), newName);
+ try {
+ fs.symlinkSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readlink:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }},stream_ops:{open:function (stream) {
+ var path = NODEFS.realPath(stream.node);
+ try {
+ if (FS.isFile(stream.node.mode)) {
+ stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },close:function (stream) {
+ try {
+ if (FS.isFile(stream.node.mode) && stream.nfd) {
+ fs.closeSync(stream.nfd);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },read:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(length);
+ var res;
+ try {
+ res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ if (res > 0) {
+ for (var i = 0; i < res; i++) {
+ buffer[offset + i] = nbuffer[i];
+ }
+ }
+ return res;
+ },write:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
+ var res;
+ try {
+ res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return res;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ try {
+ var stat = fs.fstatSync(stream.nfd);
+ position += stat.size;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }
+ }
+
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ stream.position = position;
+ return position;
+ }}};
+
+ var _stdin=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stdout=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stderr=allocate(1, "i32*", ALLOC_STATIC);
+
+ function _fflush(stream) {
+ // int fflush(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html
+ // we don't currently perform any user-space buffering of data
+ }var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},handleFSError:function (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
+ return ___setErrNo(e.errno);
+ },lookupPath:function (path, opts) {
+ path = PATH.resolve(FS.cwd(), path);
+ opts = opts || {};
+
+ var defaults = {
+ follow_mount: true,
+ recurse_count: 0
+ };
+ for (var key in defaults) {
+ if (opts[key] === undefined) {
+ opts[key] = defaults[key];
+ }
+ }
+
+ if (opts.recurse_count > 8) { // max recursive lookup of 8
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+
+ // split the path
+ var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), false);
+
+ // start at the root
+ var current = FS.root;
+ var current_path = '/';
+
+ for (var i = 0; i < parts.length; i++) {
+ var islast = (i === parts.length-1);
+ if (islast && opts.parent) {
+ // stop resolving
+ break;
+ }
+
+ current = FS.lookupNode(current, parts[i]);
+ current_path = PATH.join2(current_path, parts[i]);
+
+ // jump to the mount's root node if this is a mountpoint
+ if (FS.isMountpoint(current)) {
+ if (!islast || (islast && opts.follow_mount)) {
+ current = current.mounted.root;
+ }
+ }
+
+ // by default, lookupPath will not follow a symlink if it is the final path component.
+ // setting opts.follow = true will override this behavior.
+ if (!islast || opts.follow) {
+ var count = 0;
+ while (FS.isLink(current.mode)) {
+ var link = FS.readlink(current_path);
+ current_path = PATH.resolve(PATH.dirname(current_path), link);
+
+ var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
+ current = lookup.node;
+
+ if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+ }
+ }
+ }
+
+ return { path: current_path, node: current };
+ },getPath:function (node) {
+ var path;
+ while (true) {
+ if (FS.isRoot(node)) {
+ var mount = node.mount.mountpoint;
+ if (!path) return mount;
+ return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
+ }
+ path = path ? node.name + '/' + path : node.name;
+ node = node.parent;
+ }
+ },hashName:function (parentid, name) {
+ var hash = 0;
+
+
+ for (var i = 0; i < name.length; i++) {
+ hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
+ }
+ return ((parentid + hash) >>> 0) % FS.nameTable.length;
+ },hashAddNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ node.name_next = FS.nameTable[hash];
+ FS.nameTable[hash] = node;
+ },hashRemoveNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ if (FS.nameTable[hash] === node) {
+ FS.nameTable[hash] = node.name_next;
+ } else {
+ var current = FS.nameTable[hash];
+ while (current) {
+ if (current.name_next === node) {
+ current.name_next = node.name_next;
+ break;
+ }
+ current = current.name_next;
+ }
+ }
+ },lookupNode:function (parent, name) {
+ var err = FS.mayLookup(parent);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ var hash = FS.hashName(parent.id, name);
+ for (var node = FS.nameTable[hash]; node; node = node.name_next) {
+ var nodeName = node.name;
+ if (node.parent.id === parent.id && nodeName === name) {
+ return node;
+ }
+ }
+ // if we failed to find it in the cache, call into the VFS
+ return FS.lookup(parent, name);
+ },createNode:function (parent, name, mode, rdev) {
+ if (!FS.FSNode) {
+ FS.FSNode = function(parent, name, mode, rdev) {
+ if (!parent) {
+ parent = this; // root node sets parent to itself
+ }
+ this.parent = parent;
+ this.mount = parent.mount;
+ this.mounted = null;
+ this.id = FS.nextInode++;
+ this.name = name;
+ this.mode = mode;
+ this.node_ops = {};
+ this.stream_ops = {};
+ this.rdev = rdev;
+ };
+
+ FS.FSNode.prototype = {};
+
+ // compatibility
+ var readMode = 292 | 73;
+ var writeMode = 146;
+
+ // NOTE we must use Object.defineProperties instead of individual calls to
+ // Object.defineProperty in order to make closure compiler happy
+ Object.defineProperties(FS.FSNode.prototype, {
+ read: {
+ get: function() { return (this.mode & readMode) === readMode; },
+ set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
+ },
+ write: {
+ get: function() { return (this.mode & writeMode) === writeMode; },
+ set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
+ },
+ isFolder: {
+ get: function() { return FS.isDir(this.mode); },
+ },
+ isDevice: {
+ get: function() { return FS.isChrdev(this.mode); },
+ },
+ });
+ }
+
+ var node = new FS.FSNode(parent, name, mode, rdev);
+
+ FS.hashAddNode(node);
+
+ return node;
+ },destroyNode:function (node) {
+ FS.hashRemoveNode(node);
+ },isRoot:function (node) {
+ return node === node.parent;
+ },isMountpoint:function (node) {
+ return !!node.mounted;
+ },isFile:function (mode) {
+ return (mode & 61440) === 32768;
+ },isDir:function (mode) {
+ return (mode & 61440) === 16384;
+ },isLink:function (mode) {
+ return (mode & 61440) === 40960;
+ },isChrdev:function (mode) {
+ return (mode & 61440) === 8192;
+ },isBlkdev:function (mode) {
+ return (mode & 61440) === 24576;
+ },isFIFO:function (mode) {
+ return (mode & 61440) === 4096;
+ },isSocket:function (mode) {
+ return (mode & 49152) === 49152;
+ },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
+ var flags = FS.flagModes[str];
+ if (typeof flags === 'undefined') {
+ throw new Error('Unknown file open mode: ' + str);
+ }
+ return flags;
+ },flagsToPermissionString:function (flag) {
+ var accmode = flag & 2097155;
+ var perms = ['r', 'w', 'rw'][accmode];
+ if ((flag & 512)) {
+ perms += 'w';
+ }
+ return perms;
+ },nodePermissions:function (node, perms) {
+ if (FS.ignorePermissions) {
+ return 0;
+ }
+ // return 0 if any user, group or owner bits are set.
+ if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
+ return ERRNO_CODES.EACCES;
+ }
+ return 0;
+ },mayLookup:function (dir) {
+ return FS.nodePermissions(dir, 'x');
+ },mayCreate:function (dir, name) {
+ try {
+ var node = FS.lookupNode(dir, name);
+ return ERRNO_CODES.EEXIST;
+ } catch (e) {
+ }
+ return FS.nodePermissions(dir, 'wx');
+ },mayDelete:function (dir, name, isdir) {
+ var node;
+ try {
+ node = FS.lookupNode(dir, name);
+ } catch (e) {
+ return e.errno;
+ }
+ var err = FS.nodePermissions(dir, 'wx');
+ if (err) {
+ return err;
+ }
+ if (isdir) {
+ if (!FS.isDir(node.mode)) {
+ return ERRNO_CODES.ENOTDIR;
+ }
+ if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
+ return ERRNO_CODES.EBUSY;
+ }
+ } else {
+ if (FS.isDir(node.mode)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return 0;
+ },mayOpen:function (node, flags) {
+ if (!node) {
+ return ERRNO_CODES.ENOENT;
+ }
+ if (FS.isLink(node.mode)) {
+ return ERRNO_CODES.ELOOP;
+ } else if (FS.isDir(node.mode)) {
+ if ((flags & 2097155) !== 0 || // opening for write
+ (flags & 512)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
+ },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
+ fd_start = fd_start || 0;
+ fd_end = fd_end || FS.MAX_OPEN_FDS;
+ for (var fd = fd_start; fd <= fd_end; fd++) {
+ if (!FS.streams[fd]) {
+ return fd;
+ }
+ }
+ throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
+ },getStream:function (fd) {
+ return FS.streams[fd];
+ },createStream:function (stream, fd_start, fd_end) {
+ if (!FS.FSStream) {
+ FS.FSStream = function(){};
+ FS.FSStream.prototype = {};
+ // compatibility
+ Object.defineProperties(FS.FSStream.prototype, {
+ object: {
+ get: function() { return this.node; },
+ set: function(val) { this.node = val; }
+ },
+ isRead: {
+ get: function() { return (this.flags & 2097155) !== 1; }
+ },
+ isWrite: {
+ get: function() { return (this.flags & 2097155) !== 0; }
+ },
+ isAppend: {
+ get: function() { return (this.flags & 1024); }
+ }
+ });
+ }
+ if (0) {
+ // reuse the object
+ stream.__proto__ = FS.FSStream.prototype;
+ } else {
+ var newStream = new FS.FSStream();
+ for (var p in stream) {
+ newStream[p] = stream[p];
+ }
+ stream = newStream;
+ }
+ var fd = FS.nextfd(fd_start, fd_end);
+ stream.fd = fd;
+ FS.streams[fd] = stream;
+ return stream;
+ },closeStream:function (fd) {
+ FS.streams[fd] = null;
+ },getStreamFromPtr:function (ptr) {
+ return FS.streams[ptr - 1];
+ },getPtrForStream:function (stream) {
+ return stream ? stream.fd + 1 : 0;
+ },chrdev_stream_ops:{open:function (stream) {
+ var device = FS.getDevice(stream.node.rdev);
+ // override node's stream ops with the device's
+ stream.stream_ops = device.stream_ops;
+ // forward the open call
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ },llseek:function () {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }},major:function (dev) {
+ return ((dev) >> 8);
+ },minor:function (dev) {
+ return ((dev) & 0xff);
+ },makedev:function (ma, mi) {
+ return ((ma) << 8 | (mi));
+ },registerDevice:function (dev, ops) {
+ FS.devices[dev] = { stream_ops: ops };
+ },getDevice:function (dev) {
+ return FS.devices[dev];
+ },getMounts:function (mount) {
+ var mounts = [];
+ var check = [mount];
+
+ while (check.length) {
+ var m = check.pop();
+
+ mounts.push(m);
+
+ check.push.apply(check, m.mounts);
+ }
+
+ return mounts;
+ },syncfs:function (populate, callback) {
+ if (typeof(populate) === 'function') {
+ callback = populate;
+ populate = false;
+ }
+
+ var mounts = FS.getMounts(FS.root.mount);
+ var completed = 0;
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= mounts.length) {
+ callback(null);
+ }
+ };
+
+ // sync all mounts
+ mounts.forEach(function (mount) {
+ if (!mount.type.syncfs) {
+ return done(null);
+ }
+ mount.type.syncfs(mount, populate, done);
+ });
+ },mount:function (type, opts, mountpoint) {
+ var root = mountpoint === '/';
+ var pseudo = !mountpoint;
+ var node;
+
+ if (root && FS.root) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ } else if (!root && !pseudo) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ mountpoint = lookup.path; // use the absolute path
+ node = lookup.node;
+
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+
+ if (!FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ }
+
+ var mount = {
+ type: type,
+ opts: opts,
+ mountpoint: mountpoint,
+ mounts: []
+ };
+
+ // create a root node for the fs
+ var mountRoot = type.mount(mount);
+ mountRoot.mount = mount;
+ mount.root = mountRoot;
+
+ if (root) {
+ FS.root = mountRoot;
+ } else if (node) {
+ // set as a mountpoint
+ node.mounted = mount;
+
+ // add the new mount to the current mount's children
+ if (node.mount) {
+ node.mount.mounts.push(mount);
+ }
+ }
+
+ return mountRoot;
+ },unmount:function (mountpoint) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ if (!FS.isMountpoint(lookup.node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ // destroy the nodes for this mount, and all its child mounts
+ var node = lookup.node;
+ var mount = node.mounted;
+ var mounts = FS.getMounts(mount);
+
+ Object.keys(FS.nameTable).forEach(function (hash) {
+ var current = FS.nameTable[hash];
+
+ while (current) {
+ var next = current.name_next;
+
+ if (mounts.indexOf(current.mount) !== -1) {
+ FS.destroyNode(current);
+ }
+
+ current = next;
+ }
+ });
+
+ // no longer a mountpoint
+ node.mounted = null;
+
+ // remove this mount from the child mounts
+ var idx = node.mount.mounts.indexOf(mount);
+ assert(idx !== -1);
+ node.mount.mounts.splice(idx, 1);
+ },lookup:function (parent, name) {
+ return parent.node_ops.lookup(parent, name);
+ },mknod:function (path, mode, dev) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var err = FS.mayCreate(parent, name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.mknod) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.mknod(parent, name, mode, dev);
+ },create:function (path, mode) {
+ mode = mode !== undefined ? mode : 438 /* 0666 */;
+ mode &= 4095;
+ mode |= 32768;
+ return FS.mknod(path, mode, 0);
+ },mkdir:function (path, mode) {
+ mode = mode !== undefined ? mode : 511 /* 0777 */;
+ mode &= 511 | 512;
+ mode |= 16384;
+ return FS.mknod(path, mode, 0);
+ },mkdev:function (path, mode, dev) {
+ if (typeof(dev) === 'undefined') {
+ dev = mode;
+ mode = 438 /* 0666 */;
+ }
+ mode |= 8192;
+ return FS.mknod(path, mode, dev);
+ },symlink:function (oldpath, newpath) {
+ var lookup = FS.lookupPath(newpath, { parent: true });
+ var parent = lookup.node;
+ var newname = PATH.basename(newpath);
+ var err = FS.mayCreate(parent, newname);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.symlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.symlink(parent, newname, oldpath);
+ },rename:function (old_path, new_path) {
+ var old_dirname = PATH.dirname(old_path);
+ var new_dirname = PATH.dirname(new_path);
+ var old_name = PATH.basename(old_path);
+ var new_name = PATH.basename(new_path);
+ // parents must exist
+ var lookup, old_dir, new_dir;
+ try {
+ lookup = FS.lookupPath(old_path, { parent: true });
+ old_dir = lookup.node;
+ lookup = FS.lookupPath(new_path, { parent: true });
+ new_dir = lookup.node;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // need to be part of the same mount
+ if (old_dir.mount !== new_dir.mount) {
+ throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
+ }
+ // source must exist
+ var old_node = FS.lookupNode(old_dir, old_name);
+ // old path should not be an ancestor of the new path
+ var relative = PATH.relative(old_path, new_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ // new path should not be an ancestor of the old path
+ relative = PATH.relative(new_path, old_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ // see if the new path already exists
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ // not fatal
+ }
+ // early out if nothing needs to change
+ if (old_node === new_node) {
+ return;
+ }
+ // we'll need to delete the old entry
+ var isdir = FS.isDir(old_node.mode);
+ var err = FS.mayDelete(old_dir, old_name, isdir);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // need delete permissions if we'll be overwriting.
+ // need create permissions if new doesn't already exist.
+ err = new_node ?
+ FS.mayDelete(new_dir, new_name, isdir) :
+ FS.mayCreate(new_dir, new_name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!old_dir.node_ops.rename) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // if we are going to change the parent, check write permissions
+ if (new_dir !== old_dir) {
+ err = FS.nodePermissions(old_dir, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ }
+ // remove the node from the lookup hash
+ FS.hashRemoveNode(old_node);
+ // do the underlying fs rename
+ try {
+ old_dir.node_ops.rename(old_node, new_dir, new_name);
+ } catch (e) {
+ throw e;
+ } finally {
+ // add the node back to the hash (in case node_ops.rename
+ // changed its name)
+ FS.hashAddNode(old_node);
+ }
+ },rmdir:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, true);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.rmdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.rmdir(parent, name);
+ FS.destroyNode(node);
+ },readdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ if (!node.node_ops.readdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ return node.node_ops.readdir(node);
+ },unlink:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, false);
+ if (err) {
+ // POSIX says unlink should set EPERM, not EISDIR
+ if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.unlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.unlink(parent, name);
+ FS.destroyNode(node);
+ },readlink:function (path) {
+ var lookup = FS.lookupPath(path);
+ var link = lookup.node;
+ if (!link.node_ops.readlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return link.node_ops.readlink(link);
+ },stat:function (path, dontFollow) {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ var node = lookup.node;
+ if (!node.node_ops.getattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return node.node_ops.getattr(node);
+ },lstat:function (path) {
+ return FS.stat(path, true);
+ },chmod:function (path, mode, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ mode: (mode & 4095) | (node.mode & ~4095),
+ timestamp: Date.now()
+ });
+ },lchmod:function (path, mode) {
+ FS.chmod(path, mode, true);
+ },fchmod:function (fd, mode) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chmod(stream.node, mode);
+ },chown:function (path, uid, gid, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ timestamp: Date.now()
+ // we ignore the uid / gid for now
+ });
+ },lchown:function (path, uid, gid) {
+ FS.chown(path, uid, gid, true);
+ },fchown:function (fd, uid, gid) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chown(stream.node, uid, gid);
+ },truncate:function (path, len) {
+ if (len < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: true });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!FS.isFile(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var err = FS.nodePermissions(node, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ node.node_ops.setattr(node, {
+ size: len,
+ timestamp: Date.now()
+ });
+ },ftruncate:function (fd, len) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ FS.truncate(stream.node, len);
+ },utime:function (path, atime, mtime) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ node.node_ops.setattr(node, {
+ timestamp: Math.max(atime, mtime)
+ });
+ },open:function (path, flags, mode, fd_start, fd_end) {
+ flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
+ mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
+ if ((flags & 64)) {
+ mode = (mode & 4095) | 32768;
+ } else {
+ mode = 0;
+ }
+ var node;
+ if (typeof path === 'object') {
+ node = path;
+ } else {
+ path = PATH.normalize(path);
+ try {
+ var lookup = FS.lookupPath(path, {
+ follow: !(flags & 131072)
+ });
+ node = lookup.node;
+ } catch (e) {
+ // ignore
+ }
+ }
+ // perhaps we need to create the node
+ if ((flags & 64)) {
+ if (node) {
+ // if O_CREAT and O_EXCL are set, error out if the node already exists
+ if ((flags & 128)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
+ }
+ } else {
+ // node doesn't exist, try to create it
+ node = FS.mknod(path, mode, 0);
+ }
+ }
+ if (!node) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
+ }
+ // can't truncate a device
+ if (FS.isChrdev(node.mode)) {
+ flags &= ~512;
+ }
+ // check permissions
+ var err = FS.mayOpen(node, flags);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // do truncation if necessary
+ if ((flags & 512)) {
+ FS.truncate(node, 0);
+ }
+ // we've already handled these, don't pass down to the underlying vfs
+ flags &= ~(128 | 512);
+
+ // register the stream with the filesystem
+ var stream = FS.createStream({
+ node: node,
+ path: FS.getPath(node), // we want the absolute path to the node
+ flags: flags,
+ seekable: true,
+ position: 0,
+ stream_ops: node.stream_ops,
+ // used by the file family libc calls (fopen, fwrite, ferror, etc.)
+ ungotten: [],
+ error: false
+ }, fd_start, fd_end);
+ // call the new stream's open function
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ if (Module['logReadFiles'] && !(flags & 1)) {
+ if (!FS.readFiles) FS.readFiles = {};
+ if (!(path in FS.readFiles)) {
+ FS.readFiles[path] = 1;
+ Module['printErr']('read file: ' + path);
+ }
+ }
+ return stream;
+ },close:function (stream) {
+ try {
+ if (stream.stream_ops.close) {
+ stream.stream_ops.close(stream);
+ }
+ } catch (e) {
+ throw e;
+ } finally {
+ FS.closeStream(stream.fd);
+ }
+ },llseek:function (stream, offset, whence) {
+ if (!stream.seekable || !stream.stream_ops.llseek) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ return stream.stream_ops.llseek(stream, offset, whence);
+ },read:function (stream, buffer, offset, length, position) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.read) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
+ if (!seeking) stream.position += bytesRead;
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.write) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ if (stream.flags & 1024) {
+ // seek to the end before writing in append mode
+ FS.llseek(stream, 0, 2);
+ }
+ var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
+ if (!seeking) stream.position += bytesWritten;
+ return bytesWritten;
+ },allocate:function (stream, offset, length) {
+ if (offset < 0 || length <= 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ if (!stream.stream_ops.allocate) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ stream.stream_ops.allocate(stream, offset, length);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ // TODO if PROT is PROT_WRITE, make sure we have write access
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EACCES);
+ }
+ if (!stream.stream_ops.mmap) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
+ },ioctl:function (stream, cmd, arg) {
+ if (!stream.stream_ops.ioctl) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
+ }
+ return stream.stream_ops.ioctl(stream, cmd, arg);
+ },readFile:function (path, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'r';
+ opts.encoding = opts.encoding || 'binary';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var ret;
+ var stream = FS.open(path, opts.flags);
+ var stat = FS.stat(path);
+ var length = stat.size;
+ var buf = new Uint8Array(length);
+ FS.read(stream, buf, 0, length, 0);
+ if (opts.encoding === 'utf8') {
+ ret = '';
+ var utf8 = new Runtime.UTF8Processor();
+ for (var i = 0; i < length; i++) {
+ ret += utf8.processCChar(buf[i]);
+ }
+ } else if (opts.encoding === 'binary') {
+ ret = buf;
+ }
+ FS.close(stream);
+ return ret;
+ },writeFile:function (path, data, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'w';
+ opts.encoding = opts.encoding || 'utf8';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var stream = FS.open(path, opts.flags, opts.mode);
+ if (opts.encoding === 'utf8') {
+ var utf8 = new Runtime.UTF8Processor();
+ var buf = new Uint8Array(utf8.processJSString(data));
+ FS.write(stream, buf, 0, buf.length, 0, opts.canOwn);
+ } else if (opts.encoding === 'binary') {
+ FS.write(stream, data, 0, data.length, 0, opts.canOwn);
+ }
+ FS.close(stream);
+ },cwd:function () {
+ return FS.currentPath;
+ },chdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ if (!FS.isDir(lookup.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ var err = FS.nodePermissions(lookup.node, 'x');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ FS.currentPath = lookup.path;
+ },createDefaultDirectories:function () {
+ FS.mkdir('/tmp');
+ },createDefaultDevices:function () {
+ // create /dev
+ FS.mkdir('/dev');
+ // setup /dev/null
+ FS.registerDevice(FS.makedev(1, 3), {
+ read: function() { return 0; },
+ write: function() { return 0; }
+ });
+ FS.mkdev('/dev/null', FS.makedev(1, 3));
+ // setup /dev/tty and /dev/tty1
+ // stderr needs to print output using Module['printErr']
+ // so we register a second tty just for it.
+ TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
+ TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
+ FS.mkdev('/dev/tty', FS.makedev(5, 0));
+ FS.mkdev('/dev/tty1', FS.makedev(6, 0));
+ // we're not going to emulate the actual shm device,
+ // just create the tmp dirs that reside in it commonly
+ FS.mkdir('/dev/shm');
+ FS.mkdir('/dev/shm/tmp');
+ },createStandardStreams:function () {
+ // TODO deprecate the old functionality of a single
+ // input / output callback and that utilizes FS.createDevice
+ // and instead require a unique set of stream ops
+
+ // by default, we symlink the standard streams to the
+ // default tty devices. however, if the standard streams
+ // have been overwritten we create a unique device for
+ // them instead.
+ if (Module['stdin']) {
+ FS.createDevice('/dev', 'stdin', Module['stdin']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdin');
+ }
+ if (Module['stdout']) {
+ FS.createDevice('/dev', 'stdout', null, Module['stdout']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdout');
+ }
+ if (Module['stderr']) {
+ FS.createDevice('/dev', 'stderr', null, Module['stderr']);
+ } else {
+ FS.symlink('/dev/tty1', '/dev/stderr');
+ }
+
+ // open default streams for the stdin, stdout and stderr devices
+ var stdin = FS.open('/dev/stdin', 'r');
+ HEAP32[((_stdin)>>2)]=FS.getPtrForStream(stdin);
+ assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
+
+ var stdout = FS.open('/dev/stdout', 'w');
+ HEAP32[((_stdout)>>2)]=FS.getPtrForStream(stdout);
+ assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
+
+ var stderr = FS.open('/dev/stderr', 'w');
+ HEAP32[((_stderr)>>2)]=FS.getPtrForStream(stderr);
+ assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
+ },ensureErrnoError:function () {
+ if (FS.ErrnoError) return;
+ FS.ErrnoError = function ErrnoError(errno) {
+ this.errno = errno;
+ for (var key in ERRNO_CODES) {
+ if (ERRNO_CODES[key] === errno) {
+ this.code = key;
+ break;
+ }
+ }
+ this.message = ERRNO_MESSAGES[errno];
+ };
+ FS.ErrnoError.prototype = new Error();
+ FS.ErrnoError.prototype.constructor = FS.ErrnoError;
+ // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
+ [ERRNO_CODES.ENOENT].forEach(function(code) {
+ FS.genericErrors[code] = new FS.ErrnoError(code);
+ FS.genericErrors[code].stack = '<generic error, no stack>';
+ });
+ },staticInit:function () {
+ FS.ensureErrnoError();
+
+ FS.nameTable = new Array(4096);
+
+ FS.mount(MEMFS, {}, '/');
+
+ FS.createDefaultDirectories();
+ FS.createDefaultDevices();
+ },init:function (input, output, error) {
+ assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
+ FS.init.initialized = true;
+
+ FS.ensureErrnoError();
+
+ // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
+ Module['stdin'] = input || Module['stdin'];
+ Module['stdout'] = output || Module['stdout'];
+ Module['stderr'] = error || Module['stderr'];
+
+ FS.createStandardStreams();
+ },quit:function () {
+ FS.init.initialized = false;
+ for (var i = 0; i < FS.streams.length; i++) {
+ var stream = FS.streams[i];
+ if (!stream) {
+ continue;
+ }
+ FS.close(stream);
+ }
+ },getMode:function (canRead, canWrite) {
+ var mode = 0;
+ if (canRead) mode |= 292 | 73;
+ if (canWrite) mode |= 146;
+ return mode;
+ },joinPath:function (parts, forceRelative) {
+ var path = PATH.join.apply(null, parts);
+ if (forceRelative && path[0] == '/') path = path.substr(1);
+ return path;
+ },absolutePath:function (relative, base) {
+ return PATH.resolve(base, relative);
+ },standardizePath:function (path) {
+ return PATH.normalize(path);
+ },findObject:function (path, dontResolveLastLink) {
+ var ret = FS.analyzePath(path, dontResolveLastLink);
+ if (ret.exists) {
+ return ret.object;
+ } else {
+ ___setErrNo(ret.error);
+ return null;
+ }
+ },analyzePath:function (path, dontResolveLastLink) {
+ // operate from within the context of the symlink's target
+ try {
+ var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ path = lookup.path;
+ } catch (e) {
+ }
+ var ret = {
+ isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
+ parentExists: false, parentPath: null, parentObject: null
+ };
+ try {
+ var lookup = FS.lookupPath(path, { parent: true });
+ ret.parentExists = true;
+ ret.parentPath = lookup.path;
+ ret.parentObject = lookup.node;
+ ret.name = PATH.basename(path);
+ lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ ret.exists = true;
+ ret.path = lookup.path;
+ ret.object = lookup.node;
+ ret.name = lookup.node.name;
+ ret.isRoot = lookup.path === '/';
+ } catch (e) {
+ ret.error = e.errno;
+ };
+ return ret;
+ },createFolder:function (parent, name, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.mkdir(path, mode);
+ },createPath:function (parent, path, canRead, canWrite) {
+ parent = typeof parent === 'string' ? parent : FS.getPath(parent);
+ var parts = path.split('/').reverse();
+ while (parts.length) {
+ var part = parts.pop();
+ if (!part) continue;
+ var current = PATH.join2(parent, part);
+ try {
+ FS.mkdir(current);
+ } catch (e) {
+ // ignore EEXIST
+ }
+ parent = current;
+ }
+ return current;
+ },createFile:function (parent, name, properties, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.create(path, mode);
+ },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
+ var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
+ var mode = FS.getMode(canRead, canWrite);
+ var node = FS.create(path, mode);
+ if (data) {
+ if (typeof data === 'string') {
+ var arr = new Array(data.length);
+ for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
+ data = arr;
+ }
+ // make sure we can write to the file
+ FS.chmod(node, mode | 146);
+ var stream = FS.open(node, 'w');
+ FS.write(stream, data, 0, data.length, 0, canOwn);
+ FS.close(stream);
+ FS.chmod(node, mode);
+ }
+ return node;
+ },createDevice:function (parent, name, input, output) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(!!input, !!output);
+ if (!FS.createDevice.major) FS.createDevice.major = 64;
+ var dev = FS.makedev(FS.createDevice.major++, 0);
+ // Create a fake device that a set of stream ops to emulate
+ // the old behavior.
+ FS.registerDevice(dev, {
+ open: function(stream) {
+ stream.seekable = false;
+ },
+ close: function(stream) {
+ // flush any pending line data
+ if (output && output.buffer && output.buffer.length) {
+ output(10);
+ }
+ },
+ read: function(stream, buffer, offset, length, pos /* ignored */) {
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = input();
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },
+ write: function(stream, buffer, offset, length, pos) {
+ for (var i = 0; i < length; i++) {
+ try {
+ output(buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }
+ });
+ return FS.mkdev(path, mode, dev);
+ },createLink:function (parent, name, target, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ return FS.symlink(target, path);
+ },forceLoadFile:function (obj) {
+ if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
+ var success = true;
+ if (typeof XMLHttpRequest !== 'undefined') {
+ throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
+ } else if (Module['read']) {
+ // Command-line.
+ try {
+ // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
+ // read() will try to parse UTF8.
+ obj.contents = intArrayFromString(Module['read'](obj.url), true);
+ } catch (e) {
+ success = false;
+ }
+ } else {
+ throw new Error('Cannot load without read() or XMLHttpRequest.');
+ }
+ if (!success) ___setErrNo(ERRNO_CODES.EIO);
+ return success;
+ },createLazyFile:function (parent, name, url, canRead, canWrite) {
+ // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
+ function LazyUint8Array() {
+ this.lengthKnown = false;
+ this.chunks = []; // Loaded chunks. Index is the chunk number
+ }
+ LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
+ if (idx > this.length-1 || idx < 0) {
+ return undefined;
+ }
+ var chunkOffset = idx % this.chunkSize;
+ var chunkNum = Math.floor(idx / this.chunkSize);
+ return this.getter(chunkNum)[chunkOffset];
+ }
+ LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
+ this.getter = getter;
+ }
+ LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
+ // Find length
+ var xhr = new XMLHttpRequest();
+ xhr.open('HEAD', url, false);
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ var datalength = Number(xhr.getResponseHeader("Content-length"));
+ var header;
+ var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
+ var chunkSize = 1024*1024; // Chunk size in bytes
+
+ if (!hasByteServing) chunkSize = datalength;
+
+ // Function to get a range from the remote URL.
+ var doXHR = (function(from, to) {
+ if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
+ if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
+
+ // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
+
+ // Some hints to the browser that we want binary data.
+ if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
+ if (xhr.overrideMimeType) {
+ xhr.overrideMimeType('text/plain; charset=x-user-defined');
+ }
+
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ if (xhr.response !== undefined) {
+ return new Uint8Array(xhr.response || []);
+ } else {
+ return intArrayFromString(xhr.responseText || '', true);
+ }
+ });
+ var lazyArray = this;
+ lazyArray.setDataGetter(function(chunkNum) {
+ var start = chunkNum * chunkSize;
+ var end = (chunkNum+1) * chunkSize - 1; // including this byte
+ end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
+ lazyArray.chunks[chunkNum] = doXHR(start, end);
+ }
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
+ return lazyArray.chunks[chunkNum];
+ });
+
+ this._length = datalength;
+ this._chunkSize = chunkSize;
+ this.lengthKnown = true;
+ }
+ if (typeof XMLHttpRequest !== 'undefined') {
+ if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
+ var lazyArray = new LazyUint8Array();
+ Object.defineProperty(lazyArray, "length", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._length;
+ }
+ });
+ Object.defineProperty(lazyArray, "chunkSize", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._chunkSize;
+ }
+ });
+
+ var properties = { isDevice: false, contents: lazyArray };
+ } else {
+ var properties = { isDevice: false, url: url };
+ }
+
+ var node = FS.createFile(parent, name, properties, canRead, canWrite);
+ // This is a total hack, but I want to get this lazy file code out of the
+ // core of MEMFS. If we want to keep this lazy file concept I feel it should
+ // be its own thin LAZYFS proxying calls to MEMFS.
+ if (properties.contents) {
+ node.contents = properties.contents;
+ } else if (properties.url) {
+ node.contents = null;
+ node.url = properties.url;
+ }
+ // override each stream op with one that tries to force load the lazy file first
+ var stream_ops = {};
+ var keys = Object.keys(node.stream_ops);
+ keys.forEach(function(key) {
+ var fn = node.stream_ops[key];
+ stream_ops[key] = function forceLoadLazyFile() {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ return fn.apply(null, arguments);
+ };
+ });
+ // use a custom read function
+ stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (contents.slice) { // normal array
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ } else {
+ for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
+ buffer[offset + i] = contents.get(position + i);
+ }
+ }
+ return size;
+ };
+ node.stream_ops = stream_ops;
+ return node;
+ },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {
+ Browser.init();
+ // TODO we should allow people to just pass in a complete filename instead
+ // of parent and name being that we just join them anyways
+ var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
+ function processData(byteArray) {
+ function finish(byteArray) {
+ if (!dontCreateFile) {
+ FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
+ }
+ if (onload) onload();
+ removeRunDependency('cp ' + fullname);
+ }
+ var handled = false;
+ Module['preloadPlugins'].forEach(function(plugin) {
+ if (handled) return;
+ if (plugin['canHandle'](fullname)) {
+ plugin['handle'](byteArray, fullname, finish, function() {
+ if (onerror) onerror();
+ removeRunDependency('cp ' + fullname);
+ });
+ handled = true;
+ }
+ });
+ if (!handled) finish(byteArray);
+ }
+ addRunDependency('cp ' + fullname);
+ if (typeof url == 'string') {
+ Browser.asyncLoad(url, function(byteArray) {
+ processData(byteArray);
+ }, onerror);
+ } else {
+ processData(url);
+ }
+ },indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_NAME:function () {
+ return 'EM_FS_' + window.location.pathname;
+ },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
+ console.log('creating db');
+ var db = openRequest.result;
+ db.createObjectStore(FS.DB_STORE_NAME);
+ };
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var putRequest = files.put(FS.analyzePath(path).object.contents, path);
+ putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
+ putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ },loadFilesFromDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = onerror; // no database to load from
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ try {
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
+ } catch(e) {
+ onerror(e);
+ return;
+ }
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var getRequest = files.get(path);
+ getRequest.onsuccess = function getRequest_onsuccess() {
+ if (FS.analyzePath(path).exists) {
+ FS.unlink(path);
+ }
+ FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
+ ok++;
+ if (ok + fail == total) finish();
+ };
+ getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ }};var PATH={splitPath:function (filename) {
+ var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
+ return splitPathRe.exec(filename).slice(1);
+ },normalizeArray:function (parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length - 1; i >= 0; i--) {
+ var last = parts[i];
+ if (last === '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+ return parts;
+ },normalize:function (path) {
+ var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.substr(-1) === '/';
+ // Normalize the path
+ path = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+ return (isAbsolute ? '/' : '') + path;
+ },dirname:function (path) {
+ var result = PATH.splitPath(path),
+ root = result[0],
+ dir = result[1];
+ if (!root && !dir) {
+ // No dirname whatsoever
+ return '.';
+ }
+ if (dir) {
+ // It has a dirname, strip trailing slash
+ dir = dir.substr(0, dir.length - 1);
+ }
+ return root + dir;
+ },basename:function (path) {
+ // EMSCRIPTEN return '/'' for '/', not an empty string
+ if (path === '/') return '/';
+ var lastSlash = path.lastIndexOf('/');
+ if (lastSlash === -1) return path;
+ return path.substr(lastSlash+1);
+ },extname:function (path) {
+ return PATH.splitPath(path)[3];
+ },join:function () {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return PATH.normalize(paths.join('/'));
+ },join2:function (l, r) {
+ return PATH.normalize(l + '/' + r);
+ },resolve:function () {
+ var resolvedPath = '',
+ resolvedAbsolute = false;
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0) ? arguments[i] : FS.cwd();
+ // Skip empty and invalid entries
+ if (typeof path !== 'string') {
+ throw new TypeError('Arguments to path.resolve must be strings');
+ } else if (!path) {
+ continue;
+ }
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+ }
+ // At this point the path should be resolved to a full absolute path, but
+ // handle relative paths to be safe (might happen when process.cwd() fails)
+ resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+ },relative:function (from, to) {
+ from = PATH.resolve(from).substr(1);
+ to = PATH.resolve(to).substr(1);
+ function trim(arr) {
+ var start = 0;
+ for (; start < arr.length; start++) {
+ if (arr[start] !== '') break;
+ }
+ var end = arr.length - 1;
+ for (; end >= 0; end--) {
+ if (arr[end] !== '') break;
+ }
+ if (start > end) return [];
+ return arr.slice(start, end - start + 1);
+ }
+ var fromParts = trim(from.split('/'));
+ var toParts = trim(to.split('/'));
+ var length = Math.min(fromParts.length, toParts.length);
+ var samePartsLength = length;
+ for (var i = 0; i < length; i++) {
+ if (fromParts[i] !== toParts[i]) {
+ samePartsLength = i;
+ break;
+ }
+ }
+ var outputParts = [];
+ for (var i = samePartsLength; i < fromParts.length; i++) {
+ outputParts.push('..');
+ }
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
+ return outputParts.join('/');
+ }};var Browser={mainLoop:{scheduler:null,method:"",shouldPause:false,paused:false,queue:[],pause:function () {
+ Browser.mainLoop.shouldPause = true;
+ },resume:function () {
+ if (Browser.mainLoop.paused) {
+ Browser.mainLoop.paused = false;
+ Browser.mainLoop.scheduler();
+ }
+ Browser.mainLoop.shouldPause = false;
+ },updateStatus:function () {
+ if (Module['setStatus']) {
+ var message = Module['statusMessage'] || 'Please wait...';
+ var remaining = Browser.mainLoop.remainingBlockers;
+ var expected = Browser.mainLoop.expectedBlockers;
+ if (remaining) {
+ if (remaining < expected) {
+ Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');
+ } else {
+ Module['setStatus'](message);
+ }
+ } else {
+ Module['setStatus']('');
+ }
+ }
+ }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {
+ if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers
+
+ if (Browser.initted || ENVIRONMENT_IS_WORKER) return;
+ Browser.initted = true;
+
+ try {
+ new Blob();
+ Browser.hasBlobConstructor = true;
+ } catch(e) {
+ Browser.hasBlobConstructor = false;
+ console.log("warning: no blob constructor, cannot create blobs with mimetypes");
+ }
+ Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null));
+ Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
+ if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {
+ console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
+ Module.noImageDecoding = true;
+ }
+
+ // Support for plugins that can process preloaded files. You can add more of these to
+ // your app by creating and appending to Module.preloadPlugins.
+ //
+ // Each plugin is asked if it can handle a file based on the file's name. If it can,
+ // it is given the file's raw data. When it is done, it calls a callback with the file's
+ // (possibly modified) data. For example, a plugin might decompress a file, or it
+ // might create some side data structure for use later (like an Image element, etc.).
+
+ var imagePlugin = {};
+ imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
+ return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
+ };
+ imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
+ var b = null;
+ if (Browser.hasBlobConstructor) {
+ try {
+ b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ if (b.size !== byteArray.length) { // Safari bug #118630
+ // Safari's Blob can only take an ArrayBuffer
+ b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
+ }
+ } catch(e) {
+ Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');
+ }
+ }
+ if (!b) {
+ var bb = new Browser.BlobBuilder();
+ bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range
+ b = bb.getBlob();
+ }
+ var url = Browser.URLObject.createObjectURL(b);
+ var img = new Image();
+ img.onload = function img_onload() {
+ assert(img.complete, 'Image ' + name + ' could not be decoded');
+ var canvas = document.createElement('canvas');
+ canvas.width = img.width;
+ canvas.height = img.height;
+ var ctx = canvas.getContext('2d');
+ ctx.drawImage(img, 0, 0);
+ Module["preloadedImages"][name] = canvas;
+ Browser.URLObject.revokeObjectURL(url);
+ if (onload) onload(byteArray);
+ };
+ img.onerror = function img_onerror(event) {
+ console.log('Image ' + url + ' could not be decoded');
+ if (onerror) onerror();
+ };
+ img.src = url;
+ };
+ Module['preloadPlugins'].push(imagePlugin);
+
+ var audioPlugin = {};
+ audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
+ return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
+ };
+ audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
+ var done = false;
+ function finish(audio) {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = audio;
+ if (onload) onload(byteArray);
+ }
+ function fail() {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = new Audio(); // empty shim
+ if (onerror) onerror();
+ }
+ if (Browser.hasBlobConstructor) {
+ try {
+ var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ } catch(e) {
+ return fail();
+ }
+ var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
+ var audio = new Audio();
+ audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
+ audio.onerror = function audio_onerror(event) {
+ if (done) return;
+ console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
+ function encode64(data) {
+ var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ var PAD = '=';
+ var ret = '';
+ var leftchar = 0;
+ var leftbits = 0;
+ for (var i = 0; i < data.length; i++) {
+ leftchar = (leftchar << 8) | data[i];
+ leftbits += 8;
+ while (leftbits >= 6) {
+ var curr = (leftchar >> (leftbits-6)) & 0x3f;
+ leftbits -= 6;
+ ret += BASE[curr];
+ }
+ }
+ if (leftbits == 2) {
+ ret += BASE[(leftchar&3) << 4];
+ ret += PAD + PAD;
+ } else if (leftbits == 4) {
+ ret += BASE[(leftchar&0xf) << 2];
+ ret += PAD;
+ }
+ return ret;
+ }
+ audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);
+ finish(audio); // we don't wait for confirmation this worked - but it's worth trying
+ };
+ audio.src = url;
+ // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror
+ Browser.safeSetTimeout(function() {
+ finish(audio); // try to use it even though it is not necessarily ready to play
+ }, 10000);
+ } else {
+ return fail();
+ }
+ };
+ Module['preloadPlugins'].push(audioPlugin);
+
+ // Canvas event setup
+
+ var canvas = Module['canvas'];
+
+ // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module
+ // Module['forcedAspectRatio'] = 4 / 3;
+
+ canvas.requestPointerLock = canvas['requestPointerLock'] ||
+ canvas['mozRequestPointerLock'] ||
+ canvas['webkitRequestPointerLock'] ||
+ canvas['msRequestPointerLock'] ||
+ function(){};
+ canvas.exitPointerLock = document['exitPointerLock'] ||
+ document['mozExitPointerLock'] ||
+ document['webkitExitPointerLock'] ||
+ document['msExitPointerLock'] ||
+ function(){}; // no-op if function does not exist
+ canvas.exitPointerLock = canvas.exitPointerLock.bind(document);
+
+ function pointerLockChange() {
+ Browser.pointerLock = document['pointerLockElement'] === canvas ||
+ document['mozPointerLockElement'] === canvas ||
+ document['webkitPointerLockElement'] === canvas ||
+ document['msPointerLockElement'] === canvas;
+ }
+
+ document.addEventListener('pointerlockchange', pointerLockChange, false);
+ document.addEventListener('mozpointerlockchange', pointerLockChange, false);
+ document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
+ document.addEventListener('mspointerlockchange', pointerLockChange, false);
+
+ if (Module['elementPointerLock']) {
+ canvas.addEventListener("click", function(ev) {
+ if (!Browser.pointerLock && canvas.requestPointerLock) {
+ canvas.requestPointerLock();
+ ev.preventDefault();
+ }
+ }, false);
+ }
+ },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) {
+ var ctx;
+ var errorInfo = '?';
+ function onContextCreationError(event) {
+ errorInfo = event.statusMessage || errorInfo;
+ }
+ try {
+ if (useWebGL) {
+ var contextAttributes = {
+ antialias: false,
+ alpha: false
+ };
+
+ if (webGLContextAttributes) {
+ for (var attribute in webGLContextAttributes) {
+ contextAttributes[attribute] = webGLContextAttributes[attribute];
+ }
+ }
+
+
+ canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
+ try {
+ ['experimental-webgl', 'webgl'].some(function(webglId) {
+ return ctx = canvas.getContext(webglId, contextAttributes);
+ });
+ } finally {
+ canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
+ }
+ } else {
+ ctx = canvas.getContext('2d');
+ }
+ if (!ctx) throw ':(';
+ } catch (e) {
+ Module.print('Could not create canvas: ' + [errorInfo, e]);
+ return null;
+ }
+ if (useWebGL) {
+ // Set the background of the WebGL canvas to black
+ canvas.style.backgroundColor = "black";
+
+ // Warn on context loss
+ canvas.addEventListener('webglcontextlost', function(event) {
+ alert('WebGL context lost. You will need to reload the page.');
+ }, false);
+ }
+ if (setInModule) {
+ GLctx = Module.ctx = ctx;
+ Module.useWebGL = useWebGL;
+ Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
+ Browser.init();
+ }
+ return ctx;
+ },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {
+ Browser.lockPointer = lockPointer;
+ Browser.resizeCanvas = resizeCanvas;
+ if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;
+ if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;
+
+ var canvas = Module['canvas'];
+ function fullScreenChange() {
+ Browser.isFullScreen = false;
+ var canvasContainer = canvas.parentNode;
+ if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvasContainer) {
+ canvas.cancelFullScreen = document['cancelFullScreen'] ||
+ document['mozCancelFullScreen'] ||
+ document['webkitCancelFullScreen'] ||
+ document['msExitFullscreen'] ||
+ document['exitFullscreen'] ||
+ function() {};
+ canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);
+ if (Browser.lockPointer) canvas.requestPointerLock();
+ Browser.isFullScreen = true;
+ if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();
+ } else {
+
+ // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen
+ canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
+ canvasContainer.parentNode.removeChild(canvasContainer);
+
+ if (Browser.resizeCanvas) Browser.setWindowedCanvasSize();
+ }
+ if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);
+ Browser.updateCanvasDimensions(canvas);
+ }
+
+ if (!Browser.fullScreenHandlersInstalled) {
+ Browser.fullScreenHandlersInstalled = true;
+ document.addEventListener('fullscreenchange', fullScreenChange, false);
+ document.addEventListener('mozfullscreenchange', fullScreenChange, false);
+ document.addEventListener('webkitfullscreenchange', fullScreenChange, false);
+ document.addEventListener('MSFullscreenChange', fullScreenChange, false);
+ }
+
+ // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root
+ var canvasContainer = document.createElement("div");
+ canvas.parentNode.insertBefore(canvasContainer, canvas);
+ canvasContainer.appendChild(canvas);
+
+ // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size)
+ canvasContainer.requestFullScreen = canvasContainer['requestFullScreen'] ||
+ canvasContainer['mozRequestFullScreen'] ||
+ canvasContainer['msRequestFullscreen'] ||
+ (canvasContainer['webkitRequestFullScreen'] ? function() { canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);
+ canvasContainer.requestFullScreen();
+ },requestAnimationFrame:function requestAnimationFrame(func) {
+ if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
+ setTimeout(func, 1000/60);
+ } else {
+ if (!window.requestAnimationFrame) {
+ window.requestAnimationFrame = window['requestAnimationFrame'] ||
+ window['mozRequestAnimationFrame'] ||
+ window['webkitRequestAnimationFrame'] ||
+ window['msRequestAnimationFrame'] ||
+ window['oRequestAnimationFrame'] ||
+ window['setTimeout'];
+ }
+ window.requestAnimationFrame(func);
+ }
+ },safeCallback:function (func) {
+ return function() {
+ if (!ABORT) return func.apply(null, arguments);
+ };
+ },safeRequestAnimationFrame:function (func) {
+ return Browser.requestAnimationFrame(function() {
+ if (!ABORT) func();
+ });
+ },safeSetTimeout:function (func, timeout) {
+ return setTimeout(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },safeSetInterval:function (func, timeout) {
+ return setInterval(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },getMimetype:function (name) {
+ return {
+ 'jpg': 'image/jpeg',
+ 'jpeg': 'image/jpeg',
+ 'png': 'image/png',
+ 'bmp': 'image/bmp',
+ 'ogg': 'audio/ogg',
+ 'wav': 'audio/wav',
+ 'mp3': 'audio/mpeg'
+ }[name.substr(name.lastIndexOf('.')+1)];
+ },getUserMedia:function (func) {
+ if(!window.getUserMedia) {
+ window.getUserMedia = navigator['getUserMedia'] ||
+ navigator['mozGetUserMedia'];
+ }
+ window.getUserMedia(func);
+ },getMovementX:function (event) {
+ return event['movementX'] ||
+ event['mozMovementX'] ||
+ event['webkitMovementX'] ||
+ 0;
+ },getMovementY:function (event) {
+ return event['movementY'] ||
+ event['mozMovementY'] ||
+ event['webkitMovementY'] ||
+ 0;
+ },getMouseWheelDelta:function (event) {
+ return Math.max(-1, Math.min(1, event.type === 'DOMMouseScroll' ? event.detail : -event.wheelDelta));
+ },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup
+ if (Browser.pointerLock) {
+ // When the pointer is locked, calculate the coordinates
+ // based on the movement of the mouse.
+ // Workaround for Firefox bug 764498
+ if (event.type != 'mousemove' &&
+ ('mozMovementX' in event)) {
+ Browser.mouseMovementX = Browser.mouseMovementY = 0;
+ } else {
+ Browser.mouseMovementX = Browser.getMovementX(event);
+ Browser.mouseMovementY = Browser.getMovementY(event);
+ }
+
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
+ Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
+ } else {
+ // just add the mouse delta to the current absolut mouse position
+ // FIXME: ideally this should be clamped against the canvas size and zero
+ Browser.mouseX += Browser.mouseMovementX;
+ Browser.mouseY += Browser.mouseMovementY;
+ }
+ } else {
+ // Otherwise, calculate the movement based on the changes
+ // in the coordinates.
+ var rect = Module["canvas"].getBoundingClientRect();
+ var x, y;
+
+ // Neither .scrollX or .pageXOffset are defined in a spec, but
+ // we prefer .scrollX because it is currently in a spec draft.
+ // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
+ var scrollX = ((typeof window.scrollX !== 'undefined') ? window.scrollX : window.pageXOffset);
+ var scrollY = ((typeof window.scrollY !== 'undefined') ? window.scrollY : window.pageYOffset);
+ if (event.type == 'touchstart' ||
+ event.type == 'touchend' ||
+ event.type == 'touchmove') {
+ var t = event.touches.item(0);
+ if (t) {
+ x = t.pageX - (scrollX + rect.left);
+ y = t.pageY - (scrollY + rect.top);
+ } else {
+ return;
+ }
+ } else {
+ x = event.pageX - (scrollX + rect.left);
+ y = event.pageY - (scrollY + rect.top);
+ }
+
+ // the canvas might be CSS-scaled compared to its backbuffer;
+ // SDL-using content will want mouse coordinates in terms
+ // of backbuffer units.
+ var cw = Module["canvas"].width;
+ var ch = Module["canvas"].height;
+ x = x * (cw / rect.width);
+ y = y * (ch / rect.height);
+
+ Browser.mouseMovementX = x - Browser.mouseX;
+ Browser.mouseMovementY = y - Browser.mouseY;
+ Browser.mouseX = x;
+ Browser.mouseY = y;
+ }
+ },xhrLoad:function (url, onload, onerror) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, true);
+ xhr.responseType = 'arraybuffer';
+ xhr.onload = function xhr_onload() {
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
+ onload(xhr.response);
+ } else {
+ onerror();
+ }
+ };
+ xhr.onerror = onerror;
+ xhr.send(null);
+ },asyncLoad:function (url, onload, onerror, noRunDep) {
+ Browser.xhrLoad(url, function(arrayBuffer) {
+ assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
+ onload(new Uint8Array(arrayBuffer));
+ if (!noRunDep) removeRunDependency('al ' + url);
+ }, function(event) {
+ if (onerror) {
+ onerror();
+ } else {
+ throw 'Loading data file "' + url + '" failed.';
+ }
+ });
+ if (!noRunDep) addRunDependency('al ' + url);
+ },resizeListeners:[],updateResizeListeners:function () {
+ var canvas = Module['canvas'];
+ Browser.resizeListeners.forEach(function(listener) {
+ listener(canvas.width, canvas.height);
+ });
+ },setCanvasSize:function (width, height, noUpdates) {
+ var canvas = Module['canvas'];
+ Browser.updateCanvasDimensions(canvas, width, height);
+ if (!noUpdates) Browser.updateResizeListeners();
+ },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },setWindowedCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },updateCanvasDimensions:function (canvas, wNative, hNative) {
+ if (wNative && hNative) {
+ canvas.widthNative = wNative;
+ canvas.heightNative = hNative;
+ } else {
+ wNative = canvas.widthNative;
+ hNative = canvas.heightNative;
+ }
+ var w = wNative;
+ var h = hNative;
+ if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) {
+ if (w/h < Module['forcedAspectRatio']) {
+ w = Math.round(h * Module['forcedAspectRatio']);
+ } else {
+ h = Math.round(w / Module['forcedAspectRatio']);
+ }
+ }
+ if (((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
+ var factor = Math.min(screen.width / w, screen.height / h);
+ w = Math.round(w * factor);
+ h = Math.round(h * factor);
+ }
+ if (Browser.resizeCanvas) {
+ if (canvas.width != w) canvas.width = w;
+ if (canvas.height != h) canvas.height = h;
+ if (typeof canvas.style != 'undefined') {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ } else {
+ if (canvas.width != wNative) canvas.width = wNative;
+ if (canvas.height != hNative) canvas.height = hNative;
+ if (typeof canvas.style != 'undefined') {
+ if (w != wNative || h != hNative) {
+ canvas.style.setProperty( "width", w + "px", "important");
+ canvas.style.setProperty("height", h + "px", "important");
+ } else {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ }
+ }
+ }};
+
+
+
+
+
+
+
+ function _mkport() { throw 'TODO' }var SOCKFS={mount:function (mount) {
+ return FS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createSocket:function (family, type, protocol) {
+ var streaming = type == 1;
+ if (protocol) {
+ assert(streaming == (protocol == 6)); // if SOCK_STREAM, must be tcp
+ }
+
+ // create our internal socket structure
+ var sock = {
+ family: family,
+ type: type,
+ protocol: protocol,
+ server: null,
+ peers: {},
+ pending: [],
+ recv_queue: [],
+ sock_ops: SOCKFS.websocket_sock_ops
+ };
+
+ // create the filesystem node to store the socket structure
+ var name = SOCKFS.nextname();
+ var node = FS.createNode(SOCKFS.root, name, 49152, 0);
+ node.sock = sock;
+
+ // and the wrapping stream that enables library functions such
+ // as read and write to indirectly interact with the socket
+ var stream = FS.createStream({
+ path: name,
+ node: node,
+ flags: FS.modeStringToFlags('r+'),
+ seekable: false,
+ stream_ops: SOCKFS.stream_ops
+ });
+
+ // map the new stream to the socket structure (sockets have a 1:1
+ // relationship with a stream)
+ sock.stream = stream;
+
+ return sock;
+ },getSocket:function (fd) {
+ var stream = FS.getStream(fd);
+ if (!stream || !FS.isSocket(stream.node.mode)) {
+ return null;
+ }
+ return stream.node.sock;
+ },stream_ops:{poll:function (stream) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.poll(sock);
+ },ioctl:function (stream, request, varargs) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.ioctl(sock, request, varargs);
+ },read:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ var msg = sock.sock_ops.recvmsg(sock, length);
+ if (!msg) {
+ // socket is closed
+ return 0;
+ }
+ buffer.set(msg.buffer, offset);
+ return msg.buffer.length;
+ },write:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.sendmsg(sock, buffer, offset, length);
+ },close:function (stream) {
+ var sock = stream.node.sock;
+ sock.sock_ops.close(sock);
+ }},nextname:function () {
+ if (!SOCKFS.nextname.current) {
+ SOCKFS.nextname.current = 0;
+ }
+ return 'socket[' + (SOCKFS.nextname.current++) + ']';
+ },websocket_sock_ops:{createPeer:function (sock, addr, port) {
+ var ws;
+
+ if (typeof addr === 'object') {
+ ws = addr;
+ addr = null;
+ port = null;
+ }
+
+ if (ws) {
+ // for sockets that've already connected (e.g. we're the server)
+ // we can inspect the _socket property for the address
+ if (ws._socket) {
+ addr = ws._socket.remoteAddress;
+ port = ws._socket.remotePort;
+ }
+ // if we're just now initializing a connection to the remote,
+ // inspect the url property
+ else {
+ var result = /ws[s]?:\/\/([^:]+):(\d+)/.exec(ws.url);
+ if (!result) {
+ throw new Error('WebSocket URL must be in the format ws(s)://address:port');
+ }
+ addr = result[1];
+ port = parseInt(result[2], 10);
+ }
+ } else {
+ // create the actual websocket object and connect
+ try {
+ // runtimeConfig gets set to true if WebSocket runtime configuration is available.
+ var runtimeConfig = (Module['websocket'] && ('object' === typeof Module['websocket']));
+
+ // The default value is 'ws://' the replace is needed because the compiler replaces "//" comments with '#'
+ // comments without checking context, so we'd end up with ws:#, the replace swaps the "#" for "//" again.
+ var url = 'ws:#'.replace('#', '//');
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['url']) {
+ url = Module['websocket']['url']; // Fetch runtime WebSocket URL config.
+ }
+ }
+
+ if (url === 'ws://' || url === 'wss://') { // Is the supplied URL config just a prefix, if so complete it.
+ url = url + addr + ':' + port;
+ }
+
+ // Make the WebSocket subprotocol (Sec-WebSocket-Protocol) default to binary if no configuration is set.
+ var subProtocols = 'binary'; // The default value is 'binary'
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['subprotocol']) {
+ subProtocols = Module['websocket']['subprotocol']; // Fetch runtime WebSocket subprotocol config.
+ }
+ }
+
+ // The regex trims the string (removes spaces at the beginning and end, then splits the string by
+ // <any space>,<any space> into an Array. Whitespace removal is important for Websockify and ws.
+ subProtocols = subProtocols.replace(/^ +| +$/g,"").split(/ *, */);
+
+ // The node ws library API for specifying optional subprotocol is slightly different than the browser's.
+ var opts = ENVIRONMENT_IS_NODE ? {'protocol': subProtocols.toString()} : subProtocols;
+
+ // If node we use the ws library.
+ var WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : window['WebSocket'];
+ ws = new WebSocket(url, opts);
+ ws.binaryType = 'arraybuffer';
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EHOSTUNREACH);
+ }
+ }
+
+
+ var peer = {
+ addr: addr,
+ port: port,
+ socket: ws,
+ dgram_send_queue: []
+ };
+
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);
+
+ // if this is a bound dgram socket, send the port number first to allow
+ // us to override the ephemeral port reported to us by remotePort on the
+ // remote end.
+ if (sock.type === 2 && typeof sock.sport !== 'undefined') {
+ peer.dgram_send_queue.push(new Uint8Array([
+ 255, 255, 255, 255,
+ 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),
+ ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)
+ ]));
+ }
+
+ return peer;
+ },getPeer:function (sock, addr, port) {
+ return sock.peers[addr + ':' + port];
+ },addPeer:function (sock, peer) {
+ sock.peers[peer.addr + ':' + peer.port] = peer;
+ },removePeer:function (sock, peer) {
+ delete sock.peers[peer.addr + ':' + peer.port];
+ },handlePeerEvents:function (sock, peer) {
+ var first = true;
+
+ var handleOpen = function () {
+ try {
+ var queued = peer.dgram_send_queue.shift();
+ while (queued) {
+ peer.socket.send(queued);
+ queued = peer.dgram_send_queue.shift();
+ }
+ } catch (e) {
+ // not much we can do here in the way of proper error handling as we've already
+ // lied and said this data was sent. shut it down.
+ peer.socket.close();
+ }
+ };
+
+ function handleMessage(data) {
+ assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer
+ data = new Uint8Array(data); // make a typed array view on the array buffer
+
+
+ // if this is the port message, override the peer's port with it
+ var wasfirst = first;
+ first = false;
+ if (wasfirst &&
+ data.length === 10 &&
+ data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&
+ data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {
+ // update the peer's port and it's key in the peer map
+ var newport = ((data[8] << 8) | data[9]);
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ peer.port = newport;
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ return;
+ }
+
+ sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });
+ };
+
+ if (ENVIRONMENT_IS_NODE) {
+ peer.socket.on('open', handleOpen);
+ peer.socket.on('message', function(data, flags) {
+ if (!flags.binary) {
+ return;
+ }
+ handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
+ });
+ peer.socket.on('error', function() {
+ // don't throw
+ });
+ } else {
+ peer.socket.onopen = handleOpen;
+ peer.socket.onmessage = function peer_socket_onmessage(event) {
+ handleMessage(event.data);
+ };
+ }
+ },poll:function (sock) {
+ if (sock.type === 1 && sock.server) {
+ // listen sockets should only say they're available for reading
+ // if there are pending clients.
+ return sock.pending.length ? (64 | 1) : 0;
+ }
+
+ var mask = 0;
+ var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets
+ SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :
+ null;
+
+ if (sock.recv_queue.length ||
+ !dest || // connection-less sockets are always ready to read
+ (dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed
+ mask |= (64 | 1);
+ }
+
+ if (!dest || // connection-less sockets are always ready to write
+ (dest && dest.socket.readyState === dest.socket.OPEN)) {
+ mask |= 4;
+ }
+
+ if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) {
+ mask |= 16;
+ }
+
+ return mask;
+ },ioctl:function (sock, request, arg) {
+ switch (request) {
+ case 21531:
+ var bytes = 0;
+ if (sock.recv_queue.length) {
+ bytes = sock.recv_queue[0].data.length;
+ }
+ HEAP32[((arg)>>2)]=bytes;
+ return 0;
+ default:
+ return ERRNO_CODES.EINVAL;
+ }
+ },close:function (sock) {
+ // if we've spawned a listen server, close it
+ if (sock.server) {
+ try {
+ sock.server.close();
+ } catch (e) {
+ }
+ sock.server = null;
+ }
+ // close any peer connections
+ var peers = Object.keys(sock.peers);
+ for (var i = 0; i < peers.length; i++) {
+ var peer = sock.peers[peers[i]];
+ try {
+ peer.socket.close();
+ } catch (e) {
+ }
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ }
+ return 0;
+ },bind:function (sock, addr, port) {
+ if (typeof sock.saddr !== 'undefined' || typeof sock.sport !== 'undefined') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already bound
+ }
+ sock.saddr = addr;
+ sock.sport = port || _mkport();
+ // in order to emulate dgram sockets, we need to launch a listen server when
+ // binding on a connection-less socket
+ // note: this is only required on the server side
+ if (sock.type === 2) {
+ // close the existing server if it exists
+ if (sock.server) {
+ sock.server.close();
+ sock.server = null;
+ }
+ // swallow error operation not supported error that occurs when binding in the
+ // browser where this isn't supported
+ try {
+ sock.sock_ops.listen(sock, 0);
+ } catch (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e;
+ if (e.errno !== ERRNO_CODES.EOPNOTSUPP) throw e;
+ }
+ }
+ },connect:function (sock, addr, port) {
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODS.EOPNOTSUPP);
+ }
+
+ // TODO autobind
+ // if (!sock.addr && sock.type == 2) {
+ // }
+
+ // early out if we're already connected / in the middle of connecting
+ if (typeof sock.daddr !== 'undefined' && typeof sock.dport !== 'undefined') {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+ if (dest) {
+ if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EALREADY);
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EISCONN);
+ }
+ }
+ }
+
+ // add the socket to our peer list and set our
+ // destination address / port to match
+ var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ sock.daddr = peer.addr;
+ sock.dport = peer.port;
+
+ // always "fail" in non-blocking mode
+ throw new FS.ErrnoError(ERRNO_CODES.EINPROGRESS);
+ },listen:function (sock, backlog) {
+ if (!ENVIRONMENT_IS_NODE) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already listening
+ }
+ var WebSocketServer = require('ws').Server;
+ var host = sock.saddr;
+ sock.server = new WebSocketServer({
+ host: host,
+ port: sock.sport
+ // TODO support backlog
+ });
+
+ sock.server.on('connection', function(ws) {
+ if (sock.type === 1) {
+ var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);
+
+ // create a peer on the new socket
+ var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);
+ newsock.daddr = peer.addr;
+ newsock.dport = peer.port;
+
+ // push to queue for accept to pick up
+ sock.pending.push(newsock);
+ } else {
+ // create a peer on the listen socket so calling sendto
+ // with the listen socket and an address will resolve
+ // to the correct client
+ SOCKFS.websocket_sock_ops.createPeer(sock, ws);
+ }
+ });
+ sock.server.on('closed', function() {
+ sock.server = null;
+ });
+ sock.server.on('error', function() {
+ // don't throw
+ });
+ },accept:function (listensock) {
+ if (!listensock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var newsock = listensock.pending.shift();
+ newsock.stream.flags = listensock.stream.flags;
+ return newsock;
+ },getname:function (sock, peer) {
+ var addr, port;
+ if (peer) {
+ if (sock.daddr === undefined || sock.dport === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ addr = sock.daddr;
+ port = sock.dport;
+ } else {
+ // TODO saddr and sport will be set for bind()'d UDP sockets, but what
+ // should we be returning for TCP sockets that've been connect()'d?
+ addr = sock.saddr || 0;
+ port = sock.sport || 0;
+ }
+ return { addr: addr, port: port };
+ },sendmsg:function (sock, buffer, offset, length, addr, port) {
+ if (sock.type === 2) {
+ // connection-less sockets will honor the message address,
+ // and otherwise fall back to the bound destination address
+ if (addr === undefined || port === undefined) {
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+ // if there was no address to fall back to, error out
+ if (addr === undefined || port === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.EDESTADDRREQ);
+ }
+ } else {
+ // connection-based sockets will only use the bound
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+
+ // find the peer for the destination address
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);
+
+ // early out if not connected with a connection-based socket
+ if (sock.type === 1) {
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ } else if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // create a copy of the incoming data to send, as the WebSocket API
+ // doesn't work entirely with an ArrayBufferView, it'll just send
+ // the entire underlying buffer
+ var data;
+ if (buffer instanceof Array || buffer instanceof ArrayBuffer) {
+ data = buffer.slice(offset, offset + length);
+ } else { // ArrayBufferView
+ data = buffer.buffer.slice(buffer.byteOffset + offset, buffer.byteOffset + offset + length);
+ }
+
+ // if we're emulating a connection-less dgram socket and don't have
+ // a cached connection, queue the buffer to send upon connect and
+ // lie, saying the data was sent now.
+ if (sock.type === 2) {
+ if (!dest || dest.socket.readyState !== dest.socket.OPEN) {
+ // if we're not connected, open a new connection
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ }
+ dest.dgram_send_queue.push(data);
+ return length;
+ }
+ }
+
+ try {
+ // send the actual data
+ dest.socket.send(data);
+ return length;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ },recvmsg:function (sock, length) {
+ // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html
+ if (sock.type === 1 && sock.server) {
+ // tcp servers should not be recv()'ing on the listen socket
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+
+ var queued = sock.recv_queue.shift();
+ if (!queued) {
+ if (sock.type === 1) {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+
+ if (!dest) {
+ // if we have a destination address but are not connected, error out
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ else if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ // return null if the socket has closed
+ return null;
+ }
+ else {
+ // else, our socket is in a valid state but truly has nothing available
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // queued.data will be an ArrayBuffer if it's unadulterated, but if it's
+ // requeued TCP data it'll be an ArrayBufferView
+ var queuedLength = queued.data.byteLength || queued.data.length;
+ var queuedOffset = queued.data.byteOffset || 0;
+ var queuedBuffer = queued.data.buffer || queued.data;
+ var bytesRead = Math.min(length, queuedLength);
+ var res = {
+ buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),
+ addr: queued.addr,
+ port: queued.port
+ };
+
+
+ // push back any unread data for TCP connections
+ if (sock.type === 1 && bytesRead < queuedLength) {
+ var bytesRemaining = queuedLength - bytesRead;
+ queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
+ sock.recv_queue.unshift(queued);
+ }
+
+ return res;
+ }}};function _send(fd, buf, len, flags) {
+ var sock = SOCKFS.getSocket(fd);
+ if (!sock) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ // TODO honor flags
+ return _write(fd, buf, len);
+ }
+
+ function _pwrite(fildes, buf, nbyte, offset) {
+ // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte, offset);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _write(fildes, buf, nbyte) {
+ // ssize_t write(int fildes, const void *buf, size_t nbyte);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+
+
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }
+
+ function _fileno(stream) {
+ // int fileno(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fileno.html
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) return -1;
+ return stream.fd;
+ }function _fwrite(ptr, size, nitems, stream) {
+ // size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html
+ var bytesToWrite = nitems * size;
+ if (bytesToWrite == 0) return 0;
+ var fd = _fileno(stream);
+ var bytesWritten = _write(fd, ptr, bytesToWrite);
+ if (bytesWritten == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return 0;
+ } else {
+ return Math.floor(bytesWritten / size);
+ }
+ }
+
+
+
+ Module["_strlen"] = _strlen;
+
+ function __reallyNegative(x) {
+ return x < 0 || (x === 0 && (1/x) === -Infinity);
+ }function __formatString(format, varargs) {
+ var textIndex = format;
+ var argIndex = 0;
+ function getNextArg(type) {
+ // NOTE: Explicitly ignoring type safety. Otherwise this fails:
+ // int x = 4; printf("%c\n", (char)x);
+ var ret;
+ if (type === 'double') {
+ ret = HEAPF64[(((varargs)+(argIndex))>>3)];
+ } else if (type == 'i64') {
+ ret = [HEAP32[(((varargs)+(argIndex))>>2)],
+ HEAP32[(((varargs)+(argIndex+4))>>2)]];
+
+ } else {
+ type = 'i32'; // varargs are always i32, i64, or double
+ ret = HEAP32[(((varargs)+(argIndex))>>2)];
+ }
+ argIndex += Runtime.getNativeFieldSize(type);
+ return ret;
+ }
+
+ var ret = [];
+ var curr, next, currArg;
+ while(1) {
+ var startTextIndex = textIndex;
+ curr = HEAP8[(textIndex)];
+ if (curr === 0) break;
+ next = HEAP8[((textIndex+1)|0)];
+ if (curr == 37) {
+ // Handle flags.
+ var flagAlwaysSigned = false;
+ var flagLeftAlign = false;
+ var flagAlternative = false;
+ var flagZeroPad = false;
+ var flagPadSign = false;
+ flagsLoop: while (1) {
+ switch (next) {
+ case 43:
+ flagAlwaysSigned = true;
+ break;
+ case 45:
+ flagLeftAlign = true;
+ break;
+ case 35:
+ flagAlternative = true;
+ break;
+ case 48:
+ if (flagZeroPad) {
+ break flagsLoop;
+ } else {
+ flagZeroPad = true;
+ break;
+ }
+ case 32:
+ flagPadSign = true;
+ break;
+ default:
+ break flagsLoop;
+ }
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+
+ // Handle width.
+ var width = 0;
+ if (next == 42) {
+ width = getNextArg('i32');
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ } else {
+ while (next >= 48 && next <= 57) {
+ width = width * 10 + (next - 48);
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ }
+
+ // Handle precision.
+ var precisionSet = false, precision = -1;
+ if (next == 46) {
+ precision = 0;
+ precisionSet = true;
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ if (next == 42) {
+ precision = getNextArg('i32');
+ textIndex++;
+ } else {
+ while(1) {
+ var precisionChr = HEAP8[((textIndex+1)|0)];
+ if (precisionChr < 48 ||
+ precisionChr > 57) break;
+ precision = precision * 10 + (precisionChr - 48);
+ textIndex++;
+ }
+ }
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ if (precision < 0) {
+ precision = 6; // Standard default.
+ precisionSet = false;
+ }
+
+ // Handle integer sizes. WARNING: These assume a 32-bit architecture!
+ var argSize;
+ switch (String.fromCharCode(next)) {
+ case 'h':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 104) {
+ textIndex++;
+ argSize = 1; // char (actually i32 in varargs)
+ } else {
+ argSize = 2; // short (actually i32 in varargs)
+ }
+ break;
+ case 'l':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 108) {
+ textIndex++;
+ argSize = 8; // long long
+ } else {
+ argSize = 4; // long
+ }
+ break;
+ case 'L': // long long
+ case 'q': // int64_t
+ case 'j': // intmax_t
+ argSize = 8;
+ break;
+ case 'z': // size_t
+ case 't': // ptrdiff_t
+ case 'I': // signed ptrdiff_t or unsigned size_t
+ argSize = 4;
+ break;
+ default:
+ argSize = null;
+ }
+ if (argSize) textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+
+ // Handle type specifier.
+ switch (String.fromCharCode(next)) {
+ case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {
+ // Integer.
+ var signed = next == 100 || next == 105;
+ argSize = argSize || 4;
+ var currArg = getNextArg('i' + (argSize * 8));
+ var argText;
+ // Flatten i64-1 [low, high] into a (slightly rounded) double
+ if (argSize == 8) {
+ currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);
+ }
+ // Truncate to requested size.
+ if (argSize <= 4) {
+ var limit = Math.pow(256, argSize) - 1;
+ currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);
+ }
+ // Format the number.
+ var currAbsArg = Math.abs(currArg);
+ var prefix = '';
+ if (next == 100 || next == 105) {
+ argText = reSign(currArg, 8 * argSize, 1).toString(10);
+ } else if (next == 117) {
+ argText = unSign(currArg, 8 * argSize, 1).toString(10);
+ currArg = Math.abs(currArg);
+ } else if (next == 111) {
+ argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
+ } else if (next == 120 || next == 88) {
+ prefix = (flagAlternative && currArg != 0) ? '0x' : '';
+ if (currArg < 0) {
+ // Represent negative numbers in hex as 2's complement.
+ currArg = -currArg;
+ argText = (currAbsArg - 1).toString(16);
+ var buffer = [];
+ for (var i = 0; i < argText.length; i++) {
+ buffer.push((0xF - parseInt(argText[i], 16)).toString(16));
+ }
+ argText = buffer.join('');
+ while (argText.length < argSize * 2) argText = 'f' + argText;
+ } else {
+ argText = currAbsArg.toString(16);
+ }
+ if (next == 88) {
+ prefix = prefix.toUpperCase();
+ argText = argText.toUpperCase();
+ }
+ } else if (next == 112) {
+ if (currAbsArg === 0) {
+ argText = '(nil)';
+ } else {
+ prefix = '0x';
+ argText = currAbsArg.toString(16);
+ }
+ }
+ if (precisionSet) {
+ while (argText.length < precision) {
+ argText = '0' + argText;
+ }
+ }
+
+ // Add sign if needed
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ prefix = '+' + prefix;
+ } else if (flagPadSign) {
+ prefix = ' ' + prefix;
+ }
+ }
+
+ // Move sign to prefix so we zero-pad after the sign
+ if (argText.charAt(0) == '-') {
+ prefix = '-' + prefix;
+ argText = argText.substr(1);
+ }
+
+ // Add padding.
+ while (prefix.length + argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad) {
+ argText = '0' + argText;
+ } else {
+ prefix = ' ' + prefix;
+ }
+ }
+ }
+
+ // Insert the result into the buffer.
+ argText = prefix + argText;
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {
+ // Float.
+ var currArg = getNextArg('double');
+ var argText;
+ if (isNaN(currArg)) {
+ argText = 'nan';
+ flagZeroPad = false;
+ } else if (!isFinite(currArg)) {
+ argText = (currArg < 0 ? '-' : '') + 'inf';
+ flagZeroPad = false;
+ } else {
+ var isGeneral = false;
+ var effectivePrecision = Math.min(precision, 20);
+
+ // Convert g/G to f/F or e/E, as per:
+ // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
+ if (next == 103 || next == 71) {
+ isGeneral = true;
+ precision = precision || 1;
+ var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);
+ if (precision > exponent && exponent >= -4) {
+ next = ((next == 103) ? 'f' : 'F').charCodeAt(0);
+ precision -= exponent + 1;
+ } else {
+ next = ((next == 103) ? 'e' : 'E').charCodeAt(0);
+ precision--;
+ }
+ effectivePrecision = Math.min(precision, 20);
+ }
+
+ if (next == 101 || next == 69) {
+ argText = currArg.toExponential(effectivePrecision);
+ // Make sure the exponent has at least 2 digits.
+ if (/[eE][-+]\d$/.test(argText)) {
+ argText = argText.slice(0, -1) + '0' + argText.slice(-1);
+ }
+ } else if (next == 102 || next == 70) {
+ argText = currArg.toFixed(effectivePrecision);
+ if (currArg === 0 && __reallyNegative(currArg)) {
+ argText = '-' + argText;
+ }
+ }
+
+ var parts = argText.split('e');
+ if (isGeneral && !flagAlternative) {
+ // Discard trailing zeros and periods.
+ while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&
+ (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {
+ parts[0] = parts[0].slice(0, -1);
+ }
+ } else {
+ // Make sure we have a period in alternative mode.
+ if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';
+ // Zero pad until required precision.
+ while (precision > effectivePrecision++) parts[0] += '0';
+ }
+ argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');
+
+ // Capitalize 'E' if needed.
+ if (next == 69) argText = argText.toUpperCase();
+
+ // Add sign.
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ argText = '+' + argText;
+ } else if (flagPadSign) {
+ argText = ' ' + argText;
+ }
+ }
+ }
+
+ // Add padding.
+ while (argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {
+ argText = argText[0] + '0' + argText.slice(1);
+ } else {
+ argText = (flagZeroPad ? '0' : ' ') + argText;
+ }
+ }
+ }
+
+ // Adjust case.
+ if (next < 97) argText = argText.toUpperCase();
+
+ // Insert the result into the buffer.
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 's': {
+ // String.
+ var arg = getNextArg('i8*');
+ var argLength = arg ? _strlen(arg) : '(null)'.length;
+ if (precisionSet) argLength = Math.min(argLength, precision);
+ if (!flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ if (arg) {
+ for (var i = 0; i < argLength; i++) {
+ ret.push(HEAPU8[((arg++)|0)]);
+ }
+ } else {
+ ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true));
+ }
+ if (flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ break;
+ }
+ case 'c': {
+ // Character.
+ if (flagLeftAlign) ret.push(getNextArg('i8'));
+ while (--width > 0) {
+ ret.push(32);
+ }
+ if (!flagLeftAlign) ret.push(getNextArg('i8'));
+ break;
+ }
+ case 'n': {
+ // Write the length written so far to the next parameter.
+ var ptr = getNextArg('i32*');
+ HEAP32[((ptr)>>2)]=ret.length;
+ break;
+ }
+ case '%': {
+ // Literal percent sign.
+ ret.push(curr);
+ break;
+ }
+ default: {
+ // Unknown specifiers remain untouched.
+ for (var i = startTextIndex; i < textIndex + 2; i++) {
+ ret.push(HEAP8[(i)]);
+ }
+ }
+ }
+ textIndex += 2;
+ // TODO: Support a/A (hex float) and m (last error) specifiers.
+ // TODO: Support %1${specifier} for arg selection.
+ } else {
+ ret.push(curr);
+ textIndex += 1;
+ }
+ }
+ return ret;
+ }function _fprintf(stream, format, varargs) {
+ // int fprintf(FILE *restrict stream, const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var result = __formatString(format, varargs);
+ var stack = Runtime.stackSave();
+ var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);
+ Runtime.stackRestore(stack);
+ return ret;
+ }function _printf(format, varargs) {
+ // int printf(const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var stdout = HEAP32[((_stdout)>>2)];
+ return _fprintf(stdout, format, varargs);
+ }
+
+
+ Module["_memset"] = _memset;
+
+
+
+ function _emscripten_memcpy_big(dest, src, num) {
+ HEAPU8.set(HEAPU8.subarray(src, src+num), dest);
+ return dest;
+ }
+ Module["_memcpy"] = _memcpy;
+
+ function _free() {
+ }
+ Module["_free"] = _free;
+Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };
+ Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };
+ Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };
+ Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };
+ Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };
+ Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }
+FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;
+___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;
+__ATINIT__.unshift({ func: function() { TTY.init() } });__ATEXIT__.push({ func: function() { TTY.shutdown() } });TTY.utf8 = new Runtime.UTF8Processor();
+if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); NODEFS.staticInit(); }
+__ATINIT__.push({ func: function() { SOCKFS.root = FS.mount(SOCKFS, {}, null); } });
+STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);
+
+staticSealed = true; // seal the static portion of memory
+
+STACK_MAX = STACK_BASE + 5242880;
+
+DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);
+
+assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");
+
+
+var Math_min = Math.min;
+function asmPrintInt(x, y) {
+ Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+function asmPrintFloat(x, y) {
+ Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+// EMSCRIPTEN_START_ASM
+var asm = (function(global, env, buffer) {
+ 'use asm';
+ var HEAP8 = new global.Int8Array(buffer);
+ var HEAP16 = new global.Int16Array(buffer);
+ var HEAP32 = new global.Int32Array(buffer);
+ var HEAPU8 = new global.Uint8Array(buffer);
+ var HEAPU16 = new global.Uint16Array(buffer);
+ var HEAPU32 = new global.Uint32Array(buffer);
+ var HEAPF32 = new global.Float32Array(buffer);
+ var HEAPF64 = new global.Float64Array(buffer);
+
+ var STACKTOP=env.STACKTOP|0;
+ var STACK_MAX=env.STACK_MAX|0;
+ var tempDoublePtr=env.tempDoublePtr|0;
+ var ABORT=env.ABORT|0;
+
+ var __THREW__ = 0;
+ var threwValue = 0;
+ var setjmpId = 0;
+ var undef = 0;
+ var nan = +env.NaN, inf = +env.Infinity;
+ var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0;
+
+ var tempRet0 = 0;
+ var tempRet1 = 0;
+ var tempRet2 = 0;
+ var tempRet3 = 0;
+ var tempRet4 = 0;
+ var tempRet5 = 0;
+ var tempRet6 = 0;
+ var tempRet7 = 0;
+ var tempRet8 = 0;
+ var tempRet9 = 0;
+ var Math_floor=global.Math.floor;
+ var Math_abs=global.Math.abs;
+ var Math_sqrt=global.Math.sqrt;
+ var Math_pow=global.Math.pow;
+ var Math_cos=global.Math.cos;
+ var Math_sin=global.Math.sin;
+ var Math_tan=global.Math.tan;
+ var Math_acos=global.Math.acos;
+ var Math_asin=global.Math.asin;
+ var Math_atan=global.Math.atan;
+ var Math_atan2=global.Math.atan2;
+ var Math_exp=global.Math.exp;
+ var Math_log=global.Math.log;
+ var Math_ceil=global.Math.ceil;
+ var Math_imul=global.Math.imul;
+ var abort=env.abort;
+ var assert=env.assert;
+ var asmPrintInt=env.asmPrintInt;
+ var asmPrintFloat=env.asmPrintFloat;
+ var Math_min=env.min;
+ var _free=env._free;
+ var _emscripten_memcpy_big=env._emscripten_memcpy_big;
+ var _printf=env._printf;
+ var _send=env._send;
+ var _pwrite=env._pwrite;
+ var __reallyNegative=env.__reallyNegative;
+ var _fwrite=env._fwrite;
+ var _malloc=env._malloc;
+ var _mkport=env._mkport;
+ var _fprintf=env._fprintf;
+ var ___setErrNo=env.___setErrNo;
+ var __formatString=env.__formatString;
+ var _fileno=env._fileno;
+ var _fflush=env._fflush;
+ var _write=env._write;
+ var tempFloat = 0.0;
+
+// EMSCRIPTEN_START_FUNCS
+function _main(i3, i5) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i1;
+ L1 : do {
+ if ((i3 | 0) > 1) {
+ i3 = HEAP8[HEAP32[i5 + 4 >> 2] | 0] | 0;
+ switch (i3 | 0) {
+ case 50:
+ {
+ i3 = 3500;
+ break L1;
+ }
+ case 51:
+ {
+ i4 = 4;
+ break L1;
+ }
+ case 52:
+ {
+ i3 = 35e3;
+ break L1;
+ }
+ case 53:
+ {
+ i3 = 7e4;
+ break L1;
+ }
+ case 49:
+ {
+ i3 = 550;
+ break L1;
+ }
+ case 48:
+ {
+ i11 = 0;
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ default:
+ {
+ HEAP32[i2 >> 2] = i3 + -48;
+ _printf(8, i2 | 0) | 0;
+ i11 = -1;
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ }
+ } else {
+ i4 = 4;
+ }
+ } while (0);
+ if ((i4 | 0) == 4) {
+ i3 = 7e3;
+ }
+ i11 = 0;
+ i8 = 0;
+ i5 = 0;
+ while (1) {
+ i6 = ((i5 | 0) % 5 | 0) + 1 | 0;
+ i4 = ((i5 | 0) % 3 | 0) + 1 | 0;
+ i7 = 0;
+ while (1) {
+ i11 = ((i7 | 0) / (i6 | 0) | 0) + i11 | 0;
+ if (i11 >>> 0 > 1e3) {
+ i11 = (i11 >>> 0) / (i4 >>> 0) | 0;
+ }
+ if ((i7 & 3 | 0) == 0) {
+ i11 = i11 + (Math_imul((i7 & 7 | 0) == 0 ? 1 : -1, i7) | 0) | 0;
+ }
+ i10 = i11 << 16 >> 16;
+ i10 = (Math_imul(i10, i10) | 0) & 255;
+ i9 = i10 + (i8 & 65535) | 0;
+ i7 = i7 + 1 | 0;
+ if ((i7 | 0) == 2e4) {
+ break;
+ } else {
+ i8 = i9;
+ }
+ }
+ i5 = i5 + 1 | 0;
+ if ((i5 | 0) < (i3 | 0)) {
+ i8 = i9;
+ } else {
+ break;
+ }
+ }
+ HEAP32[i2 >> 2] = i11;
+ HEAP32[i2 + 4 >> 2] = i8 + i10 & 65535;
+ _printf(24, i2 | 0) | 0;
+ i11 = 0;
+ STACKTOP = i1;
+ return i11 | 0;
+}
+function _memcpy(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ if ((i1 | 0) >= 4096) return _emscripten_memcpy_big(i3 | 0, i2 | 0, i1 | 0) | 0;
+ i4 = i3 | 0;
+ if ((i3 & 3) == (i2 & 3)) {
+ while (i3 & 3) {
+ if ((i1 | 0) == 0) return i4 | 0;
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ while ((i1 | 0) >= 4) {
+ HEAP32[i3 >> 2] = HEAP32[i2 >> 2];
+ i3 = i3 + 4 | 0;
+ i2 = i2 + 4 | 0;
+ i1 = i1 - 4 | 0;
+ }
+ }
+ while ((i1 | 0) > 0) {
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ return i4 | 0;
+}
+function _memset(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = i1 + i3 | 0;
+ if ((i3 | 0) >= 20) {
+ i4 = i4 & 255;
+ i7 = i1 & 3;
+ i6 = i4 | i4 << 8 | i4 << 16 | i4 << 24;
+ i5 = i2 & ~3;
+ if (i7) {
+ i7 = i1 + 4 - i7 | 0;
+ while ((i1 | 0) < (i7 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ }
+ while ((i1 | 0) < (i5 | 0)) {
+ HEAP32[i1 >> 2] = i6;
+ i1 = i1 + 4 | 0;
+ }
+ }
+ while ((i1 | 0) < (i2 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ return i1 - i3 | 0;
+}
+function copyTempDouble(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+ HEAP8[tempDoublePtr + 4 | 0] = HEAP8[i1 + 4 | 0];
+ HEAP8[tempDoublePtr + 5 | 0] = HEAP8[i1 + 5 | 0];
+ HEAP8[tempDoublePtr + 6 | 0] = HEAP8[i1 + 6 | 0];
+ HEAP8[tempDoublePtr + 7 | 0] = HEAP8[i1 + 7 | 0];
+}
+function copyTempFloat(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+}
+function runPostSets() {}
+function _strlen(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = i1;
+ while (HEAP8[i2] | 0) {
+ i2 = i2 + 1 | 0;
+ }
+ return i2 - i1 | 0;
+}
+function stackAlloc(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + i1 | 0;
+ STACKTOP = STACKTOP + 7 & -8;
+ return i2 | 0;
+}
+function setThrew(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ if ((__THREW__ | 0) == 0) {
+ __THREW__ = i1;
+ threwValue = i2;
+ }
+}
+function stackRestore(i1) {
+ i1 = i1 | 0;
+ STACKTOP = i1;
+}
+function setTempRet9(i1) {
+ i1 = i1 | 0;
+ tempRet9 = i1;
+}
+function setTempRet8(i1) {
+ i1 = i1 | 0;
+ tempRet8 = i1;
+}
+function setTempRet7(i1) {
+ i1 = i1 | 0;
+ tempRet7 = i1;
+}
+function setTempRet6(i1) {
+ i1 = i1 | 0;
+ tempRet6 = i1;
+}
+function setTempRet5(i1) {
+ i1 = i1 | 0;
+ tempRet5 = i1;
+}
+function setTempRet4(i1) {
+ i1 = i1 | 0;
+ tempRet4 = i1;
+}
+function setTempRet3(i1) {
+ i1 = i1 | 0;
+ tempRet3 = i1;
+}
+function setTempRet2(i1) {
+ i1 = i1 | 0;
+ tempRet2 = i1;
+}
+function setTempRet1(i1) {
+ i1 = i1 | 0;
+ tempRet1 = i1;
+}
+function setTempRet0(i1) {
+ i1 = i1 | 0;
+ tempRet0 = i1;
+}
+function stackSave() {
+ return STACKTOP | 0;
+}
+
+// EMSCRIPTEN_END_FUNCS
+
+
+ return { _strlen: _strlen, _memcpy: _memcpy, _main: _main, _memset: _memset, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, setThrew: setThrew, setTempRet0: setTempRet0, setTempRet1: setTempRet1, setTempRet2: setTempRet2, setTempRet3: setTempRet3, setTempRet4: setTempRet4, setTempRet5: setTempRet5, setTempRet6: setTempRet6, setTempRet7: setTempRet7, setTempRet8: setTempRet8, setTempRet9: setTempRet9 };
+})
+// EMSCRIPTEN_END_ASM
+({ "Math": Math, "Int8Array": Int8Array, "Int16Array": Int16Array, "Int32Array": Int32Array, "Uint8Array": Uint8Array, "Uint16Array": Uint16Array, "Uint32Array": Uint32Array, "Float32Array": Float32Array, "Float64Array": Float64Array }, { "abort": abort, "assert": assert, "asmPrintInt": asmPrintInt, "asmPrintFloat": asmPrintFloat, "min": Math_min, "_free": _free, "_emscripten_memcpy_big": _emscripten_memcpy_big, "_printf": _printf, "_send": _send, "_pwrite": _pwrite, "__reallyNegative": __reallyNegative, "_fwrite": _fwrite, "_malloc": _malloc, "_mkport": _mkport, "_fprintf": _fprintf, "___setErrNo": ___setErrNo, "__formatString": __formatString, "_fileno": _fileno, "_fflush": _fflush, "_write": _write, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX, "tempDoublePtr": tempDoublePtr, "ABORT": ABORT, "NaN": NaN, "Infinity": Infinity }, buffer);
+var _strlen = Module["_strlen"] = asm["_strlen"];
+var _memcpy = Module["_memcpy"] = asm["_memcpy"];
+var _main = Module["_main"] = asm["_main"];
+var _memset = Module["_memset"] = asm["_memset"];
+var runPostSets = Module["runPostSets"] = asm["runPostSets"];
+
+Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
+Runtime.stackSave = function() { return asm['stackSave']() };
+Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
+
+
+// Warning: printing of i64 values may be slightly rounded! No deep i64 math used, so precise i64 code not included
+var i64Math = null;
+
+// === Auto-generated postamble setup entry stuff ===
+
+if (memoryInitializer) {
+ if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
+ var data = Module['readBinary'](memoryInitializer);
+ HEAPU8.set(data, STATIC_BASE);
+ } else {
+ addRunDependency('memory initializer');
+ Browser.asyncLoad(memoryInitializer, function(data) {
+ HEAPU8.set(data, STATIC_BASE);
+ removeRunDependency('memory initializer');
+ }, function(data) {
+ throw 'could not load memory initializer ' + memoryInitializer;
+ });
+ }
+}
+
+function ExitStatus(status) {
+ this.name = "ExitStatus";
+ this.message = "Program terminated with exit(" + status + ")";
+ this.status = status;
+};
+ExitStatus.prototype = new Error();
+ExitStatus.prototype.constructor = ExitStatus;
+
+var initialStackTop;
+var preloadStartTime = null;
+var calledMain = false;
+
+dependenciesFulfilled = function runCaller() {
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
+ if (!Module['calledRun'] && shouldRunNow) run([].concat(Module["arguments"]));
+ if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
+}
+
+Module['callMain'] = Module.callMain = function callMain(args) {
+ assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');
+ assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
+
+ args = args || [];
+
+ ensureInitRuntime();
+
+ var argc = args.length+1;
+ function pad() {
+ for (var i = 0; i < 4-1; i++) {
+ argv.push(0);
+ }
+ }
+ var argv = [allocate(intArrayFromString("/bin/this.program"), 'i8', ALLOC_NORMAL) ];
+ pad();
+ for (var i = 0; i < argc-1; i = i + 1) {
+ argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL));
+ pad();
+ }
+ argv.push(0);
+ argv = allocate(argv, 'i32', ALLOC_NORMAL);
+
+ initialStackTop = STACKTOP;
+
+ try {
+
+ var ret = Module['_main'](argc, argv, 0);
+
+
+ // if we're not running an evented main loop, it's time to exit
+ if (!Module['noExitRuntime']) {
+ exit(ret);
+ }
+ }
+ catch(e) {
+ if (e instanceof ExitStatus) {
+ // exit() throws this once it's done to make sure execution
+ // has been stopped completely
+ return;
+ } else if (e == 'SimulateInfiniteLoop') {
+ // running an evented main loop, don't immediately exit
+ Module['noExitRuntime'] = true;
+ return;
+ } else {
+ if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
+ throw e;
+ }
+ } finally {
+ calledMain = true;
+ }
+}
+
+
+
+
+function run(args) {
+ args = args || Module['arguments'];
+
+ if (preloadStartTime === null) preloadStartTime = Date.now();
+
+ if (runDependencies > 0) {
+ Module.printErr('run() called, but dependencies remain, so not running');
+ return;
+ }
+
+ preRun();
+
+ if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
+ if (Module['calledRun']) return; // run may have just been called through dependencies being fulfilled just in this very frame
+
+ function doRun() {
+ if (Module['calledRun']) return; // run may have just been called while the async setStatus time below was happening
+ Module['calledRun'] = true;
+
+ ensureInitRuntime();
+
+ preMain();
+
+ if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) {
+ Module.printErr('pre-main prep time: ' + (Date.now() - preloadStartTime) + ' ms');
+ }
+
+ if (Module['_main'] && shouldRunNow) {
+ Module['callMain'](args);
+ }
+
+ postRun();
+ }
+
+ if (Module['setStatus']) {
+ Module['setStatus']('Running...');
+ setTimeout(function() {
+ setTimeout(function() {
+ Module['setStatus']('');
+ }, 1);
+ if (!ABORT) doRun();
+ }, 1);
+ } else {
+ doRun();
+ }
+}
+Module['run'] = Module.run = run;
+
+function exit(status) {
+ ABORT = true;
+ EXITSTATUS = status;
+ STACKTOP = initialStackTop;
+
+ // exit the runtime
+ exitRuntime();
+
+ // TODO We should handle this differently based on environment.
+ // In the browser, the best we can do is throw an exception
+ // to halt execution, but in node we could process.exit and
+ // I'd imagine SM shell would have something equivalent.
+ // This would let us set a proper exit status (which
+ // would be great for checking test exit statuses).
+ // https://github.com/kripken/emscripten/issues/1371
+
+ // throw an exception to halt the current execution
+ throw new ExitStatus(status);
+}
+Module['exit'] = Module.exit = exit;
+
+function abort(text) {
+ if (text) {
+ Module.print(text);
+ Module.printErr(text);
+ }
+
+ ABORT = true;
+ EXITSTATUS = 1;
+
+ var extra = '\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.';
+
+ throw 'abort() at ' + stackTrace() + extra;
+}
+Module['abort'] = Module.abort = abort;
+
+// {{PRE_RUN_ADDITIONS}}
+
+if (Module['preInit']) {
+ if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
+ while (Module['preInit'].length > 0) {
+ Module['preInit'].pop()();
+ }
+}
+
+// shouldRunNow refers to calling main(), not run().
+var shouldRunNow = true;
+if (Module['noInitialRun']) {
+ shouldRunNow = false;
+}
+
+
+run([].concat(Module["arguments"]));
diff --git a/test/mjsunit/asm/embenchen/fannkuch.js b/test/mjsunit/asm/embenchen/fannkuch.js
new file mode 100644
index 000000000..d4c1a3194
--- /dev/null
+++ b/test/mjsunit/asm/embenchen/fannkuch.js
@@ -0,0 +1,8439 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var EXPECTED_OUTPUT =
+ '123456789\n' +
+ '213456789\n' +
+ '231456789\n' +
+ '321456789\n' +
+ '312456789\n' +
+ '132456789\n' +
+ '234156789\n' +
+ '324156789\n' +
+ '342156789\n' +
+ '432156789\n' +
+ '423156789\n' +
+ '243156789\n' +
+ '341256789\n' +
+ '431256789\n' +
+ '413256789\n' +
+ '143256789\n' +
+ '134256789\n' +
+ '314256789\n' +
+ '412356789\n' +
+ '142356789\n' +
+ '124356789\n' +
+ '214356789\n' +
+ '241356789\n' +
+ '421356789\n' +
+ '234516789\n' +
+ '324516789\n' +
+ '342516789\n' +
+ '432516789\n' +
+ '423516789\n' +
+ '243516789\n' +
+ 'Pfannkuchen(9) = 30.\n';
+var Module = {
+ arguments: [1],
+ print: function(x) {Module.printBuffer += x + '\n';},
+ preRun: [function() {Module.printBuffer = ''}],
+ postRun: [function() {
+ assertEquals(EXPECTED_OUTPUT, Module.printBuffer);
+ }],
+};
+// The Module object: Our interface to the outside world. We import
+// and export values on it, and do the work to get that through
+// closure compiler if necessary. There are various ways Module can be used:
+// 1. Not defined. We create it here
+// 2. A function parameter, function(Module) { ..generated code.. }
+// 3. pre-run appended it, var Module = {}; ..generated code..
+// 4. External script tag defines var Module.
+// We need to do an eval in order to handle the closure compiler
+// case, where this code here is minified but Module was defined
+// elsewhere (e.g. case 4 above). We also need to check if Module
+// already exists (e.g. case 3 above).
+// Note that if you want to run closure, and also to use Module
+// after the generated code, you will need to define var Module = {};
+// before the code. Then that object will be used in the code, and you
+// can continue to use Module afterwards as well.
+var Module;
+if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {};
+
+// Sometimes an existing Module object exists with properties
+// meant to overwrite the default module functionality. Here
+// we collect those properties and reapply _after_ we configure
+// the current environment's defaults to avoid having to be so
+// defensive during initialization.
+var moduleOverrides = {};
+for (var key in Module) {
+ if (Module.hasOwnProperty(key)) {
+ moduleOverrides[key] = Module[key];
+ }
+}
+
+// The environment setup code below is customized to use Module.
+// *** Environment setup code ***
+var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
+var ENVIRONMENT_IS_WEB = typeof window === 'object';
+var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
+var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+
+if (ENVIRONMENT_IS_NODE) {
+ // Expose functionality in the same simple way that the shells work
+ // Note that we pollute the global namespace here, otherwise we break in node
+ if (!Module['print']) Module['print'] = function print(x) {
+ process['stdout'].write(x + '\n');
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ process['stderr'].write(x + '\n');
+ };
+
+ var nodeFS = require('fs');
+ var nodePath = require('path');
+
+ Module['read'] = function read(filename, binary) {
+ filename = nodePath['normalize'](filename);
+ var ret = nodeFS['readFileSync'](filename);
+ // The path is absolute if the normalized version is the same as the resolved.
+ if (!ret && filename != nodePath['resolve'](filename)) {
+ filename = path.join(__dirname, '..', 'src', filename);
+ ret = nodeFS['readFileSync'](filename);
+ }
+ if (ret && !binary) ret = ret.toString();
+ return ret;
+ };
+
+ Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
+
+ Module['load'] = function load(f) {
+ globalEval(read(f));
+ };
+
+ Module['arguments'] = process['argv'].slice(2);
+
+ module['exports'] = Module;
+}
+else if (ENVIRONMENT_IS_SHELL) {
+ if (!Module['print']) Module['print'] = print;
+ if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
+
+ if (typeof read != 'undefined') {
+ Module['read'] = read;
+ } else {
+ Module['read'] = function read() { throw 'no read() available (jsc?)' };
+ }
+
+ Module['readBinary'] = function readBinary(f) {
+ return read(f, 'binary');
+ };
+
+ if (typeof scriptArgs != 'undefined') {
+ Module['arguments'] = scriptArgs;
+ } else if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ this['Module'] = Module;
+
+ eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
+}
+else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
+ Module['read'] = function read(url) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ xhr.send(null);
+ return xhr.responseText;
+ };
+
+ if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ if (typeof console !== 'undefined') {
+ if (!Module['print']) Module['print'] = function print(x) {
+ console.log(x);
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ console.log(x);
+ };
+ } else {
+ // Probably a worker, and without console.log. We can do very little here...
+ var TRY_USE_DUMP = false;
+ if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
+ dump(x);
+ }) : (function(x) {
+ // self.postMessage(x); // enable this if you want stdout to be sent as messages
+ }));
+ }
+
+ if (ENVIRONMENT_IS_WEB) {
+ window['Module'] = Module;
+ } else {
+ Module['load'] = importScripts;
+ }
+}
+else {
+ // Unreachable because SHELL is dependant on the others
+ throw 'Unknown runtime environment. Where are we?';
+}
+
+function globalEval(x) {
+ eval.call(null, x);
+}
+if (!Module['load'] == 'undefined' && Module['read']) {
+ Module['load'] = function load(f) {
+ globalEval(Module['read'](f));
+ };
+}
+if (!Module['print']) {
+ Module['print'] = function(){};
+}
+if (!Module['printErr']) {
+ Module['printErr'] = Module['print'];
+}
+if (!Module['arguments']) {
+ Module['arguments'] = [];
+}
+// *** Environment setup code ***
+
+// Closure helpers
+Module.print = Module['print'];
+Module.printErr = Module['printErr'];
+
+// Callbacks
+Module['preRun'] = [];
+Module['postRun'] = [];
+
+// Merge back in the overrides
+for (var key in moduleOverrides) {
+ if (moduleOverrides.hasOwnProperty(key)) {
+ Module[key] = moduleOverrides[key];
+ }
+}
+
+
+
+// === Auto-generated preamble library stuff ===
+
+//========================================
+// Runtime code shared with compiler
+//========================================
+
+var Runtime = {
+ stackSave: function () {
+ return STACKTOP;
+ },
+ stackRestore: function (stackTop) {
+ STACKTOP = stackTop;
+ },
+ forceAlign: function (target, quantum) {
+ quantum = quantum || 4;
+ if (quantum == 1) return target;
+ if (isNumber(target) && isNumber(quantum)) {
+ return Math.ceil(target/quantum)*quantum;
+ } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
+ return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')';
+ }
+ return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
+ },
+ isNumberType: function (type) {
+ return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
+ },
+ isPointerType: function isPointerType(type) {
+ return type[type.length-1] == '*';
+},
+ isStructType: function isStructType(type) {
+ if (isPointerType(type)) return false;
+ if (isArrayType(type)) return true;
+ if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
+ // See comment in isStructPointerType()
+ return type[0] == '%';
+},
+ INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
+ FLOAT_TYPES: {"float":0,"double":0},
+ or64: function (x, y) {
+ var l = (x | 0) | (y | 0);
+ var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ and64: function (x, y) {
+ var l = (x | 0) & (y | 0);
+ var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ xor64: function (x, y) {
+ var l = (x | 0) ^ (y | 0);
+ var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ getNativeTypeSize: function (type) {
+ switch (type) {
+ case 'i1': case 'i8': return 1;
+ case 'i16': return 2;
+ case 'i32': return 4;
+ case 'i64': return 8;
+ case 'float': return 4;
+ case 'double': return 8;
+ default: {
+ if (type[type.length-1] === '*') {
+ return Runtime.QUANTUM_SIZE; // A pointer
+ } else if (type[0] === 'i') {
+ var bits = parseInt(type.substr(1));
+ assert(bits % 8 === 0);
+ return bits/8;
+ } else {
+ return 0;
+ }
+ }
+ }
+ },
+ getNativeFieldSize: function (type) {
+ return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
+ },
+ dedup: function dedup(items, ident) {
+ var seen = {};
+ if (ident) {
+ return items.filter(function(item) {
+ if (seen[item[ident]]) return false;
+ seen[item[ident]] = true;
+ return true;
+ });
+ } else {
+ return items.filter(function(item) {
+ if (seen[item]) return false;
+ seen[item] = true;
+ return true;
+ });
+ }
+},
+ set: function set() {
+ var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
+ var ret = {};
+ for (var i = 0; i < args.length; i++) {
+ ret[args[i]] = 0;
+ }
+ return ret;
+},
+ STACK_ALIGN: 8,
+ getAlignSize: function (type, size, vararg) {
+ // we align i64s and doubles on 64-bit boundaries, unlike x86
+ if (!vararg && (type == 'i64' || type == 'double')) return 8;
+ if (!type) return Math.min(size, 8); // align structures internally to 64 bits
+ return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
+ },
+ calculateStructAlignment: function calculateStructAlignment(type) {
+ type.flatSize = 0;
+ type.alignSize = 0;
+ var diffs = [];
+ var prev = -1;
+ var index = 0;
+ type.flatIndexes = type.fields.map(function(field) {
+ index++;
+ var size, alignSize;
+ if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
+ size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
+ alignSize = Runtime.getAlignSize(field, size);
+ } else if (Runtime.isStructType(field)) {
+ if (field[1] === '0') {
+ // this is [0 x something]. When inside another structure like here, it must be at the end,
+ // and it adds no size
+ // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');
+ size = 0;
+ if (Types.types[field]) {
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ } else {
+ alignSize = type.alignSize || QUANTUM_SIZE;
+ }
+ } else {
+ size = Types.types[field].flatSize;
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ }
+ } else if (field[0] == 'b') {
+ // bN, large number field, like a [N x i8]
+ size = field.substr(1)|0;
+ alignSize = 1;
+ } else if (field[0] === '<') {
+ // vector type
+ size = alignSize = Types.types[field].flatSize; // fully aligned
+ } else if (field[0] === 'i') {
+ // illegal integer field, that could not be legalized because it is an internal structure field
+ // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
+ size = alignSize = parseInt(field.substr(1))/8;
+ assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
+ } else {
+ assert(false, 'invalid type for calculateStructAlignment');
+ }
+ if (type.packed) alignSize = 1;
+ type.alignSize = Math.max(type.alignSize, alignSize);
+ var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
+ type.flatSize = curr + size;
+ if (prev >= 0) {
+ diffs.push(curr-prev);
+ }
+ prev = curr;
+ return curr;
+ });
+ if (type.name_ && type.name_[0] === '[') {
+ // arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
+ // allocating a potentially huge array for [999999 x i8] etc.
+ type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
+ }
+ type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
+ if (diffs.length == 0) {
+ type.flatFactor = type.flatSize;
+ } else if (Runtime.dedup(diffs).length == 1) {
+ type.flatFactor = diffs[0];
+ }
+ type.needsFlattening = (type.flatFactor != 1);
+ return type.flatIndexes;
+ },
+ generateStructInfo: function (struct, typeName, offset) {
+ var type, alignment;
+ if (typeName) {
+ offset = offset || 0;
+ type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
+ if (!type) return null;
+ if (type.fields.length != struct.length) {
+ printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');
+ return null;
+ }
+ alignment = type.flatIndexes;
+ } else {
+ var type = { fields: struct.map(function(item) { return item[0] }) };
+ alignment = Runtime.calculateStructAlignment(type);
+ }
+ var ret = {
+ __size__: type.flatSize
+ };
+ if (typeName) {
+ struct.forEach(function(item, i) {
+ if (typeof item === 'string') {
+ ret[item] = alignment[i] + offset;
+ } else {
+ // embedded struct
+ var key;
+ for (var k in item) key = k;
+ ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
+ }
+ });
+ } else {
+ struct.forEach(function(item, i) {
+ ret[item[1]] = alignment[i];
+ });
+ }
+ return ret;
+ },
+ dynCall: function (sig, ptr, args) {
+ if (args && args.length) {
+ if (!args.splice) args = Array.prototype.slice.call(args);
+ args.splice(0, 0, ptr);
+ return Module['dynCall_' + sig].apply(null, args);
+ } else {
+ return Module['dynCall_' + sig].call(null, ptr);
+ }
+ },
+ functionPointers: [],
+ addFunction: function (func) {
+ for (var i = 0; i < Runtime.functionPointers.length; i++) {
+ if (!Runtime.functionPointers[i]) {
+ Runtime.functionPointers[i] = func;
+ return 2*(1 + i);
+ }
+ }
+ throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
+ },
+ removeFunction: function (index) {
+ Runtime.functionPointers[(index-2)/2] = null;
+ },
+ getAsmConst: function (code, numArgs) {
+ // code is a constant string on the heap, so we can cache these
+ if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
+ var func = Runtime.asmConstCache[code];
+ if (func) return func;
+ var args = [];
+ for (var i = 0; i < numArgs; i++) {
+ args.push(String.fromCharCode(36) + i); // $0, $1 etc
+ }
+ var source = Pointer_stringify(code);
+ if (source[0] === '"') {
+ // tolerate EM_ASM("..code..") even though EM_ASM(..code..) is correct
+ if (source.indexOf('"', 1) === source.length-1) {
+ source = source.substr(1, source.length-2);
+ } else {
+ // something invalid happened, e.g. EM_ASM("..code($0)..", input)
+ abort('invalid EM_ASM input |' + source + '|. Please use EM_ASM(..code..) (no quotes) or EM_ASM({ ..code($0).. }, input) (to input values)');
+ }
+ }
+ try {
+ var evalled = eval('(function(' + args.join(',') + '){ ' + source + ' })'); // new Function does not allow upvars in node
+ } catch(e) {
+ Module.printErr('error in executing inline EM_ASM code: ' + e + ' on: \n\n' + source + '\n\nwith args |' + args + '| (make sure to use the right one out of EM_ASM, EM_ASM_ARGS, etc.)');
+ throw e;
+ }
+ return Runtime.asmConstCache[code] = evalled;
+ },
+ warnOnce: function (text) {
+ if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
+ if (!Runtime.warnOnce.shown[text]) {
+ Runtime.warnOnce.shown[text] = 1;
+ Module.printErr(text);
+ }
+ },
+ funcWrappers: {},
+ getFuncWrapper: function (func, sig) {
+ assert(sig);
+ if (!Runtime.funcWrappers[func]) {
+ Runtime.funcWrappers[func] = function dynCall_wrapper() {
+ return Runtime.dynCall(sig, func, arguments);
+ };
+ }
+ return Runtime.funcWrappers[func];
+ },
+ UTF8Processor: function () {
+ var buffer = [];
+ var needed = 0;
+ this.processCChar = function (code) {
+ code = code & 0xFF;
+
+ if (buffer.length == 0) {
+ if ((code & 0x80) == 0x00) { // 0xxxxxxx
+ return String.fromCharCode(code);
+ }
+ buffer.push(code);
+ if ((code & 0xE0) == 0xC0) { // 110xxxxx
+ needed = 1;
+ } else if ((code & 0xF0) == 0xE0) { // 1110xxxx
+ needed = 2;
+ } else { // 11110xxx
+ needed = 3;
+ }
+ return '';
+ }
+
+ if (needed) {
+ buffer.push(code);
+ needed--;
+ if (needed > 0) return '';
+ }
+
+ var c1 = buffer[0];
+ var c2 = buffer[1];
+ var c3 = buffer[2];
+ var c4 = buffer[3];
+ var ret;
+ if (buffer.length == 2) {
+ ret = String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ } else if (buffer.length == 3) {
+ ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ } else {
+ // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |
+ ((c3 & 0x3F) << 6) | (c4 & 0x3F);
+ ret = String.fromCharCode(
+ Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,
+ (codePoint - 0x10000) % 0x400 + 0xDC00);
+ }
+ buffer.length = 0;
+ return ret;
+ }
+ this.processJSString = function processJSString(string) {
+ /* TODO: use TextEncoder when present,
+ var encoder = new TextEncoder();
+ encoder['encoding'] = "utf-8";
+ var utf8Array = encoder['encode'](aMsg.data);
+ */
+ string = unescape(encodeURIComponent(string));
+ var ret = [];
+ for (var i = 0; i < string.length; i++) {
+ ret.push(string.charCodeAt(i));
+ }
+ return ret;
+ }
+ },
+ getCompilerSetting: function (name) {
+ throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
+ },
+ stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+7)&-8); return ret; },
+ staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = (((STATICTOP)+7)&-8); return ret; },
+ dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = (((DYNAMICTOP)+7)&-8); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
+ alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },
+ makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*(+4294967296))) : ((+((low>>>0)))+((+((high|0)))*(+4294967296)))); return ret; },
+ GLOBAL_BASE: 8,
+ QUANTUM_SIZE: 4,
+ __dummy__: 0
+}
+
+
+Module['Runtime'] = Runtime;
+
+
+
+
+
+
+
+
+
+//========================================
+// Runtime essentials
+//========================================
+
+var __THREW__ = 0; // Used in checking for thrown exceptions.
+
+var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()
+var EXITSTATUS = 0;
+
+var undef = 0;
+// tempInt is used for 32-bit signed values or smaller. tempBigInt is used
+// for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
+var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
+var tempI64, tempI64b;
+var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
+
+function assert(condition, text) {
+ if (!condition) {
+ abort('Assertion failed: ' + text);
+ }
+}
+
+var globalScope = this;
+
+// C calling interface. A convenient way to call C functions (in C files, or
+// defined with extern "C").
+//
+// Note: LLVM optimizations can inline and remove functions, after which you will not be
+// able to call them. Closure can also do so. To avoid that, add your function to
+// the exports using something like
+//
+// -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]'
+//
+// @param ident The name of the C function (note that C++ functions will be name-mangled - use extern "C")
+// @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and
+// 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).
+// @param argTypes An array of the types of arguments for the function (if there are no arguments, this can be ommitted). Types are as in returnType,
+// except that 'array' is not possible (there is no way for us to know the length of the array)
+// @param args An array of the arguments to the function, as native JS values (as in returnType)
+// Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).
+// @return The return value, as a native JS value (as in returnType)
+function ccall(ident, returnType, argTypes, args) {
+ return ccallFunc(getCFunc(ident), returnType, argTypes, args);
+}
+Module["ccall"] = ccall;
+
+// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
+function getCFunc(ident) {
+ try {
+ var func = Module['_' + ident]; // closure exported function
+ if (!func) func = eval('_' + ident); // explicit lookup
+ } catch(e) {
+ }
+ assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
+ return func;
+}
+
+// Internal function that does a C call using a function, not an identifier
+function ccallFunc(func, returnType, argTypes, args) {
+ var stack = 0;
+ function toC(value, type) {
+ if (type == 'string') {
+ if (value === null || value === undefined || value === 0) return 0; // null string
+ value = intArrayFromString(value);
+ type = 'array';
+ }
+ if (type == 'array') {
+ if (!stack) stack = Runtime.stackSave();
+ var ret = Runtime.stackAlloc(value.length);
+ writeArrayToMemory(value, ret);
+ return ret;
+ }
+ return value;
+ }
+ function fromC(value, type) {
+ if (type == 'string') {
+ return Pointer_stringify(value);
+ }
+ assert(type != 'array');
+ return value;
+ }
+ var i = 0;
+ var cArgs = args ? args.map(function(arg) {
+ return toC(arg, argTypes[i++]);
+ }) : [];
+ var ret = fromC(func.apply(null, cArgs), returnType);
+ if (stack) Runtime.stackRestore(stack);
+ return ret;
+}
+
+// Returns a native JS wrapper for a C function. This is similar to ccall, but
+// returns a function you can call repeatedly in a normal way. For example:
+//
+// var my_function = cwrap('my_c_function', 'number', ['number', 'number']);
+// alert(my_function(5, 22));
+// alert(my_function(99, 12));
+//
+function cwrap(ident, returnType, argTypes) {
+ var func = getCFunc(ident);
+ return function() {
+ return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));
+ }
+}
+Module["cwrap"] = cwrap;
+
+// Sets a value in memory in a dynamic way at run-time. Uses the
+// type data. This is the same as makeSetValue, except that
+// makeSetValue is done at compile-time and generates the needed
+// code then, whereas this function picks the right code at
+// run-time.
+// Note that setValue and getValue only do *aligned* writes and reads!
+// Note that ccall uses JS types as for defining types, while setValue and
+// getValue need LLVM types ('i8', 'i32') - this is a lower-level operation
+function setValue(ptr, value, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': HEAP8[(ptr)]=value; break;
+ case 'i8': HEAP8[(ptr)]=value; break;
+ case 'i16': HEAP16[((ptr)>>1)]=value; break;
+ case 'i32': HEAP32[((ptr)>>2)]=value; break;
+ case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= (+1) ? (tempDouble > (+0) ? ((Math_min((+(Math_floor((tempDouble)/(+4294967296)))), (+4294967295)))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+4294967296))))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
+ case 'float': HEAPF32[((ptr)>>2)]=value; break;
+ case 'double': HEAPF64[((ptr)>>3)]=value; break;
+ default: abort('invalid type for setValue: ' + type);
+ }
+}
+Module['setValue'] = setValue;
+
+// Parallel to setValue.
+function getValue(ptr, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': return HEAP8[(ptr)];
+ case 'i8': return HEAP8[(ptr)];
+ case 'i16': return HEAP16[((ptr)>>1)];
+ case 'i32': return HEAP32[((ptr)>>2)];
+ case 'i64': return HEAP32[((ptr)>>2)];
+ case 'float': return HEAPF32[((ptr)>>2)];
+ case 'double': return HEAPF64[((ptr)>>3)];
+ default: abort('invalid type for setValue: ' + type);
+ }
+ return null;
+}
+Module['getValue'] = getValue;
+
+var ALLOC_NORMAL = 0; // Tries to use _malloc()
+var ALLOC_STACK = 1; // Lives for the duration of the current function call
+var ALLOC_STATIC = 2; // Cannot be freed
+var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
+var ALLOC_NONE = 4; // Do not allocate
+Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
+Module['ALLOC_STACK'] = ALLOC_STACK;
+Module['ALLOC_STATIC'] = ALLOC_STATIC;
+Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;
+Module['ALLOC_NONE'] = ALLOC_NONE;
+
+// allocate(): This is for internal use. You can use it yourself as well, but the interface
+// is a little tricky (see docs right below). The reason is that it is optimized
+// for multiple syntaxes to save space in generated code. So you should
+// normally not use allocate(), and instead allocate memory using _malloc(),
+// initialize it with setValue(), and so forth.
+// @slab: An array of data, or a number. If a number, then the size of the block to allocate,
+// in *bytes* (note that this is sometimes confusing: the next parameter does not
+// affect this!)
+// @types: Either an array of types, one for each byte (or 0 if no type at that position),
+// or a single type which is used for the entire block. This only matters if there
+// is initial data - if @slab is a number, then this does not matter at all and is
+// ignored.
+// @allocator: How to allocate memory, see ALLOC_*
+function allocate(slab, types, allocator, ptr) {
+ var zeroinit, size;
+ if (typeof slab === 'number') {
+ zeroinit = true;
+ size = slab;
+ } else {
+ zeroinit = false;
+ size = slab.length;
+ }
+
+ var singleType = typeof types === 'string' ? types : null;
+
+ var ret;
+ if (allocator == ALLOC_NONE) {
+ ret = ptr;
+ } else {
+ ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
+ }
+
+ if (zeroinit) {
+ var ptr = ret, stop;
+ assert((ret & 3) == 0);
+ stop = ret + (size & ~3);
+ for (; ptr < stop; ptr += 4) {
+ HEAP32[((ptr)>>2)]=0;
+ }
+ stop = ret + size;
+ while (ptr < stop) {
+ HEAP8[((ptr++)|0)]=0;
+ }
+ return ret;
+ }
+
+ if (singleType === 'i8') {
+ if (slab.subarray || slab.slice) {
+ HEAPU8.set(slab, ret);
+ } else {
+ HEAPU8.set(new Uint8Array(slab), ret);
+ }
+ return ret;
+ }
+
+ var i = 0, type, typeSize, previousType;
+ while (i < size) {
+ var curr = slab[i];
+
+ if (typeof curr === 'function') {
+ curr = Runtime.getFunctionIndex(curr);
+ }
+
+ type = singleType || types[i];
+ if (type === 0) {
+ i++;
+ continue;
+ }
+
+ if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
+
+ setValue(ret+i, curr, type);
+
+ // no need to look up size unless type changes, so cache it
+ if (previousType !== type) {
+ typeSize = Runtime.getNativeTypeSize(type);
+ previousType = type;
+ }
+ i += typeSize;
+ }
+
+ return ret;
+}
+Module['allocate'] = allocate;
+
+function Pointer_stringify(ptr, /* optional */ length) {
+ // TODO: use TextDecoder
+ // Find the length, and check for UTF while doing so
+ var hasUtf = false;
+ var t;
+ var i = 0;
+ while (1) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ if (t >= 128) hasUtf = true;
+ else if (t == 0 && !length) break;
+ i++;
+ if (length && i == length) break;
+ }
+ if (!length) length = i;
+
+ var ret = '';
+
+ if (!hasUtf) {
+ var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
+ var curr;
+ while (length > 0) {
+ curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
+ ret = ret ? ret + curr : curr;
+ ptr += MAX_CHUNK;
+ length -= MAX_CHUNK;
+ }
+ return ret;
+ }
+
+ var utf8 = new Runtime.UTF8Processor();
+ for (i = 0; i < length; i++) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ ret += utf8.processCChar(t);
+ }
+ return ret;
+}
+Module['Pointer_stringify'] = Pointer_stringify;
+
+// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF16ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
+ if (codeUnit == 0)
+ return str;
+ ++i;
+ // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
+ str += String.fromCharCode(codeUnit);
+ }
+}
+Module['UTF16ToString'] = UTF16ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
+function stringToUTF16(str, outPtr) {
+ for(var i = 0; i < str.length; ++i) {
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
+ HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP16[(((outPtr)+(str.length*2))>>1)]=0;
+}
+Module['stringToUTF16'] = stringToUTF16;
+
+// Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF32ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
+ if (utf32 == 0)
+ return str;
+ ++i;
+ // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
+ if (utf32 >= 0x10000) {
+ var ch = utf32 - 0x10000;
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
+ } else {
+ str += String.fromCharCode(utf32);
+ }
+ }
+}
+Module['UTF32ToString'] = UTF32ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
+// but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.
+function stringToUTF32(str, outPtr) {
+ var iChar = 0;
+ for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
+ var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
+ var trailSurrogate = str.charCodeAt(++iCodeUnit);
+ codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
+ }
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit;
+ ++iChar;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=0;
+}
+Module['stringToUTF32'] = stringToUTF32;
+
+function demangle(func) {
+ var i = 3;
+ // params, etc.
+ var basicTypes = {
+ 'v': 'void',
+ 'b': 'bool',
+ 'c': 'char',
+ 's': 'short',
+ 'i': 'int',
+ 'l': 'long',
+ 'f': 'float',
+ 'd': 'double',
+ 'w': 'wchar_t',
+ 'a': 'signed char',
+ 'h': 'unsigned char',
+ 't': 'unsigned short',
+ 'j': 'unsigned int',
+ 'm': 'unsigned long',
+ 'x': 'long long',
+ 'y': 'unsigned long long',
+ 'z': '...'
+ };
+ var subs = [];
+ var first = true;
+ function dump(x) {
+ //return;
+ if (x) Module.print(x);
+ Module.print(func);
+ var pre = '';
+ for (var a = 0; a < i; a++) pre += ' ';
+ Module.print (pre + '^');
+ }
+ function parseNested() {
+ i++;
+ if (func[i] === 'K') i++; // ignore const
+ var parts = [];
+ while (func[i] !== 'E') {
+ if (func[i] === 'S') { // substitution
+ i++;
+ var next = func.indexOf('_', i);
+ var num = func.substring(i, next) || 0;
+ parts.push(subs[num] || '?');
+ i = next+1;
+ continue;
+ }
+ if (func[i] === 'C') { // constructor
+ parts.push(parts[parts.length-1]);
+ i += 2;
+ continue;
+ }
+ var size = parseInt(func.substr(i));
+ var pre = size.toString().length;
+ if (!size || !pre) { i--; break; } // counter i++ below us
+ var curr = func.substr(i + pre, size);
+ parts.push(curr);
+ subs.push(curr);
+ i += pre + size;
+ }
+ i++; // skip E
+ return parts;
+ }
+ function parse(rawList, limit, allowVoid) { // main parser
+ limit = limit || Infinity;
+ var ret = '', list = [];
+ function flushList() {
+ return '(' + list.join(', ') + ')';
+ }
+ var name;
+ if (func[i] === 'N') {
+ // namespaced N-E
+ name = parseNested().join('::');
+ limit--;
+ if (limit === 0) return rawList ? [name] : name;
+ } else {
+ // not namespaced
+ if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
+ var size = parseInt(func.substr(i));
+ if (size) {
+ var pre = size.toString().length;
+ name = func.substr(i + pre, size);
+ i += pre + size;
+ }
+ }
+ first = false;
+ if (func[i] === 'I') {
+ i++;
+ var iList = parse(true);
+ var iRet = parse(true, 1, true);
+ ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
+ } else {
+ ret = name;
+ }
+ paramLoop: while (i < func.length && limit-- > 0) {
+ //dump('paramLoop');
+ var c = func[i++];
+ if (c in basicTypes) {
+ list.push(basicTypes[c]);
+ } else {
+ switch (c) {
+ case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
+ case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
+ case 'L': { // literal
+ i++; // skip basic type
+ var end = func.indexOf('E', i);
+ var size = end - i;
+ list.push(func.substr(i, size));
+ i += size + 2; // size + 'EE'
+ break;
+ }
+ case 'A': { // array
+ var size = parseInt(func.substr(i));
+ i += size.toString().length;
+ if (func[i] !== '_') throw '?';
+ i++; // skip _
+ list.push(parse(true, 1, true)[0] + ' [' + size + ']');
+ break;
+ }
+ case 'E': break paramLoop;
+ default: ret += '?' + c; break paramLoop;
+ }
+ }
+ }
+ if (!allowVoid && list.length === 1 && list[0] === 'void') list = []; // avoid (void)
+ if (rawList) {
+ if (ret) {
+ list.push(ret + '?');
+ }
+ return list;
+ } else {
+ return ret + flushList();
+ }
+ }
+ try {
+ // Special-case the entry point, since its name differs from other name mangling.
+ if (func == 'Object._main' || func == '_main') {
+ return 'main()';
+ }
+ if (typeof func === 'number') func = Pointer_stringify(func);
+ if (func[0] !== '_') return func;
+ if (func[1] !== '_') return func; // C function
+ if (func[2] !== 'Z') return func;
+ switch (func[3]) {
+ case 'n': return 'operator new()';
+ case 'd': return 'operator delete()';
+ }
+ return parse();
+ } catch(e) {
+ return func;
+ }
+}
+
+function demangleAll(text) {
+ return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });
+}
+
+function stackTrace() {
+ var stack = new Error().stack;
+ return stack ? demangleAll(stack) : '(no stack trace available)'; // Stack trace is not available at least on IE10 and Safari 6.
+}
+
+// Memory management
+
+var PAGE_SIZE = 4096;
+function alignMemoryPage(x) {
+ return (x+4095)&-4096;
+}
+
+var HEAP;
+var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
+
+var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area
+var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area
+var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk
+
+function enlargeMemory() {
+ abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
+}
+
+var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
+var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 134217728;
+var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
+
+var totalMemory = 4096;
+while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
+ if (totalMemory < 16*1024*1024) {
+ totalMemory *= 2;
+ } else {
+ totalMemory += 16*1024*1024
+ }
+}
+if (totalMemory !== TOTAL_MEMORY) {
+ Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
+ TOTAL_MEMORY = totalMemory;
+}
+
+// Initialize the runtime's memory
+// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
+assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
+ 'JS engine does not provide full typed array support');
+
+var buffer = new ArrayBuffer(TOTAL_MEMORY);
+HEAP8 = new Int8Array(buffer);
+HEAP16 = new Int16Array(buffer);
+HEAP32 = new Int32Array(buffer);
+HEAPU8 = new Uint8Array(buffer);
+HEAPU16 = new Uint16Array(buffer);
+HEAPU32 = new Uint32Array(buffer);
+HEAPF32 = new Float32Array(buffer);
+HEAPF64 = new Float64Array(buffer);
+
+// Endianness check (note: assumes compiler arch was little-endian)
+HEAP32[0] = 255;
+assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
+
+Module['HEAP'] = HEAP;
+Module['HEAP8'] = HEAP8;
+Module['HEAP16'] = HEAP16;
+Module['HEAP32'] = HEAP32;
+Module['HEAPU8'] = HEAPU8;
+Module['HEAPU16'] = HEAPU16;
+Module['HEAPU32'] = HEAPU32;
+Module['HEAPF32'] = HEAPF32;
+Module['HEAPF64'] = HEAPF64;
+
+function callRuntimeCallbacks(callbacks) {
+ while(callbacks.length > 0) {
+ var callback = callbacks.shift();
+ if (typeof callback == 'function') {
+ callback();
+ continue;
+ }
+ var func = callback.func;
+ if (typeof func === 'number') {
+ if (callback.arg === undefined) {
+ Runtime.dynCall('v', func);
+ } else {
+ Runtime.dynCall('vi', func, [callback.arg]);
+ }
+ } else {
+ func(callback.arg === undefined ? null : callback.arg);
+ }
+ }
+}
+
+var __ATPRERUN__ = []; // functions called before the runtime is initialized
+var __ATINIT__ = []; // functions called during startup
+var __ATMAIN__ = []; // functions called when main() is to be run
+var __ATEXIT__ = []; // functions called during shutdown
+var __ATPOSTRUN__ = []; // functions called after the runtime has exited
+
+var runtimeInitialized = false;
+
+function preRun() {
+ // compatibility - merge in anything from Module['preRun'] at this time
+ if (Module['preRun']) {
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
+ while (Module['preRun'].length) {
+ addOnPreRun(Module['preRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPRERUN__);
+}
+
+function ensureInitRuntime() {
+ if (runtimeInitialized) return;
+ runtimeInitialized = true;
+ callRuntimeCallbacks(__ATINIT__);
+}
+
+function preMain() {
+ callRuntimeCallbacks(__ATMAIN__);
+}
+
+function exitRuntime() {
+ callRuntimeCallbacks(__ATEXIT__);
+}
+
+function postRun() {
+ // compatibility - merge in anything from Module['postRun'] at this time
+ if (Module['postRun']) {
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
+ while (Module['postRun'].length) {
+ addOnPostRun(Module['postRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPOSTRUN__);
+}
+
+function addOnPreRun(cb) {
+ __ATPRERUN__.unshift(cb);
+}
+Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;
+
+function addOnInit(cb) {
+ __ATINIT__.unshift(cb);
+}
+Module['addOnInit'] = Module.addOnInit = addOnInit;
+
+function addOnPreMain(cb) {
+ __ATMAIN__.unshift(cb);
+}
+Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;
+
+function addOnExit(cb) {
+ __ATEXIT__.unshift(cb);
+}
+Module['addOnExit'] = Module.addOnExit = addOnExit;
+
+function addOnPostRun(cb) {
+ __ATPOSTRUN__.unshift(cb);
+}
+Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;
+
+// Tools
+
+// This processes a JS string into a C-line array of numbers, 0-terminated.
+// For LLVM-originating strings, see parser.js:parseLLVMString function
+function intArrayFromString(stringy, dontAddNull, length /* optional */) {
+ var ret = (new Runtime.UTF8Processor()).processJSString(stringy);
+ if (length) {
+ ret.length = length;
+ }
+ if (!dontAddNull) {
+ ret.push(0);
+ }
+ return ret;
+}
+Module['intArrayFromString'] = intArrayFromString;
+
+function intArrayToString(array) {
+ var ret = [];
+ for (var i = 0; i < array.length; i++) {
+ var chr = array[i];
+ if (chr > 0xFF) {
+ chr &= 0xFF;
+ }
+ ret.push(String.fromCharCode(chr));
+ }
+ return ret.join('');
+}
+Module['intArrayToString'] = intArrayToString;
+
+// Write a Javascript array to somewhere in the heap
+function writeStringToMemory(string, buffer, dontAddNull) {
+ var array = intArrayFromString(string, dontAddNull);
+ var i = 0;
+ while (i < array.length) {
+ var chr = array[i];
+ HEAP8[(((buffer)+(i))|0)]=chr;
+ i = i + 1;
+ }
+}
+Module['writeStringToMemory'] = writeStringToMemory;
+
+function writeArrayToMemory(array, buffer) {
+ for (var i = 0; i < array.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=array[i];
+ }
+}
+Module['writeArrayToMemory'] = writeArrayToMemory;
+
+function writeAsciiToMemory(str, buffer, dontAddNull) {
+ for (var i = 0; i < str.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=str.charCodeAt(i);
+ }
+ if (!dontAddNull) HEAP8[(((buffer)+(str.length))|0)]=0;
+}
+Module['writeAsciiToMemory'] = writeAsciiToMemory;
+
+function unSign(value, bits, ignore) {
+ if (value >= 0) {
+ return value;
+ }
+ return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
+ : Math.pow(2, bits) + value;
+}
+function reSign(value, bits, ignore) {
+ if (value <= 0) {
+ return value;
+ }
+ var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
+ : Math.pow(2, bits-1);
+ if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
+ // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
+ // TODO: In i64 mode 1, resign the two parts separately and safely
+ value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
+ }
+ return value;
+}
+
+// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
+if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
+ var ah = a >>> 16;
+ var al = a & 0xffff;
+ var bh = b >>> 16;
+ var bl = b & 0xffff;
+ return (al*bl + ((ah*bl + al*bh) << 16))|0;
+};
+Math.imul = Math['imul'];
+
+
+var Math_abs = Math.abs;
+var Math_cos = Math.cos;
+var Math_sin = Math.sin;
+var Math_tan = Math.tan;
+var Math_acos = Math.acos;
+var Math_asin = Math.asin;
+var Math_atan = Math.atan;
+var Math_atan2 = Math.atan2;
+var Math_exp = Math.exp;
+var Math_log = Math.log;
+var Math_sqrt = Math.sqrt;
+var Math_ceil = Math.ceil;
+var Math_floor = Math.floor;
+var Math_pow = Math.pow;
+var Math_imul = Math.imul;
+var Math_fround = Math.fround;
+var Math_min = Math.min;
+
+// A counter of dependencies for calling run(). If we need to
+// do asynchronous work before running, increment this and
+// decrement it. Incrementing must happen in a place like
+// PRE_RUN_ADDITIONS (used by emcc to add file preloading).
+// Note that you can add dependencies in preRun, even though
+// it happens right before run - run will be postponed until
+// the dependencies are met.
+var runDependencies = 0;
+var runDependencyWatcher = null;
+var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
+
+function addRunDependency(id) {
+ runDependencies++;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+}
+Module['addRunDependency'] = addRunDependency;
+function removeRunDependency(id) {
+ runDependencies--;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+ if (runDependencies == 0) {
+ if (runDependencyWatcher !== null) {
+ clearInterval(runDependencyWatcher);
+ runDependencyWatcher = null;
+ }
+ if (dependenciesFulfilled) {
+ var callback = dependenciesFulfilled;
+ dependenciesFulfilled = null;
+ callback(); // can add another dependenciesFulfilled
+ }
+ }
+}
+Module['removeRunDependency'] = removeRunDependency;
+
+Module["preloadedImages"] = {}; // maps url to image data
+Module["preloadedAudios"] = {}; // maps url to audio data
+
+
+var memoryInitializer = null;
+
+// === Body ===
+
+
+
+
+
+STATIC_BASE = 8;
+
+STATICTOP = STATIC_BASE + Runtime.alignMemory(547);
+/* global initializers */ __ATINIT__.push();
+
+
+/* memory initializer */ allocate([101,114,114,111,114,58,32,37,100,10,0,0,0,0,0,0,80,102,97,110,110,107,117,99,104,101,110,40,37,100,41,32,61,32,37,100,46,10,0,0,37,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
+
+
+
+
+var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8);
+
+assert(tempDoublePtr % 8 == 0);
+
+function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+}
+
+function copyTempDouble(ptr) {
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+ HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
+
+ HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
+
+ HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
+
+ HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
+
+}
+
+
+
+
+
+
+ var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};
+
+ var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
+
+
+ var ___errno_state=0;function ___setErrNo(value) {
+ // For convenient setting and returning of errno.
+ HEAP32[((___errno_state)>>2)]=value;
+ return value;
+ }
+
+ var PATH={splitPath:function (filename) {
+ var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
+ return splitPathRe.exec(filename).slice(1);
+ },normalizeArray:function (parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length - 1; i >= 0; i--) {
+ var last = parts[i];
+ if (last === '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+ return parts;
+ },normalize:function (path) {
+ var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.substr(-1) === '/';
+ // Normalize the path
+ path = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+ return (isAbsolute ? '/' : '') + path;
+ },dirname:function (path) {
+ var result = PATH.splitPath(path),
+ root = result[0],
+ dir = result[1];
+ if (!root && !dir) {
+ // No dirname whatsoever
+ return '.';
+ }
+ if (dir) {
+ // It has a dirname, strip trailing slash
+ dir = dir.substr(0, dir.length - 1);
+ }
+ return root + dir;
+ },basename:function (path) {
+ // EMSCRIPTEN return '/'' for '/', not an empty string
+ if (path === '/') return '/';
+ var lastSlash = path.lastIndexOf('/');
+ if (lastSlash === -1) return path;
+ return path.substr(lastSlash+1);
+ },extname:function (path) {
+ return PATH.splitPath(path)[3];
+ },join:function () {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return PATH.normalize(paths.join('/'));
+ },join2:function (l, r) {
+ return PATH.normalize(l + '/' + r);
+ },resolve:function () {
+ var resolvedPath = '',
+ resolvedAbsolute = false;
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0) ? arguments[i] : FS.cwd();
+ // Skip empty and invalid entries
+ if (typeof path !== 'string') {
+ throw new TypeError('Arguments to path.resolve must be strings');
+ } else if (!path) {
+ continue;
+ }
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+ }
+ // At this point the path should be resolved to a full absolute path, but
+ // handle relative paths to be safe (might happen when process.cwd() fails)
+ resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+ },relative:function (from, to) {
+ from = PATH.resolve(from).substr(1);
+ to = PATH.resolve(to).substr(1);
+ function trim(arr) {
+ var start = 0;
+ for (; start < arr.length; start++) {
+ if (arr[start] !== '') break;
+ }
+ var end = arr.length - 1;
+ for (; end >= 0; end--) {
+ if (arr[end] !== '') break;
+ }
+ if (start > end) return [];
+ return arr.slice(start, end - start + 1);
+ }
+ var fromParts = trim(from.split('/'));
+ var toParts = trim(to.split('/'));
+ var length = Math.min(fromParts.length, toParts.length);
+ var samePartsLength = length;
+ for (var i = 0; i < length; i++) {
+ if (fromParts[i] !== toParts[i]) {
+ samePartsLength = i;
+ break;
+ }
+ }
+ var outputParts = [];
+ for (var i = samePartsLength; i < fromParts.length; i++) {
+ outputParts.push('..');
+ }
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
+ return outputParts.join('/');
+ }};
+
+ var TTY={ttys:[],init:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // currently, FS.init does not distinguish if process.stdin is a file or TTY
+ // // device, it always assumes it's a TTY device. because of this, we're forcing
+ // // process.stdin to UTF8 encoding to at least make stdin reading compatible
+ // // with text files until FS.init can be refactored.
+ // process['stdin']['setEncoding']('utf8');
+ // }
+ },shutdown:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
+ // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
+ // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
+ // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
+ // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
+ // process['stdin']['pause']();
+ // }
+ },register:function (dev, ops) {
+ TTY.ttys[dev] = { input: [], output: [], ops: ops };
+ FS.registerDevice(dev, TTY.stream_ops);
+ },stream_ops:{open:function (stream) {
+ var tty = TTY.ttys[stream.node.rdev];
+ if (!tty) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ stream.tty = tty;
+ stream.seekable = false;
+ },close:function (stream) {
+ // flush any pending line data
+ if (stream.tty.output.length) {
+ stream.tty.ops.put_char(stream.tty, 10);
+ }
+ },read:function (stream, buffer, offset, length, pos /* ignored */) {
+ if (!stream.tty || !stream.tty.ops.get_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = stream.tty.ops.get_char(stream.tty);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, pos) {
+ if (!stream.tty || !stream.tty.ops.put_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ for (var i = 0; i < length; i++) {
+ try {
+ stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }},default_tty_ops:{get_char:function (tty) {
+ if (!tty.input.length) {
+ var result = null;
+ if (ENVIRONMENT_IS_NODE) {
+ result = process['stdin']['read']();
+ if (!result) {
+ if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
+ return null; // EOF
+ }
+ return undefined; // no data available
+ }
+ } else if (typeof window != 'undefined' &&
+ typeof window.prompt == 'function') {
+ // Browser.
+ result = window.prompt('Input: '); // returns null on cancel
+ if (result !== null) {
+ result += '\n';
+ }
+ } else if (typeof readline == 'function') {
+ // Command line.
+ result = readline();
+ if (result !== null) {
+ result += '\n';
+ }
+ }
+ if (!result) {
+ return null;
+ }
+ tty.input = intArrayFromString(result, true);
+ }
+ return tty.input.shift();
+ },put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['print'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }},default_tty1_ops:{put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['printErr'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }}};
+
+ var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
+ return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
+ // no supported
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (!MEMFS.ops_table) {
+ MEMFS.ops_table = {
+ dir: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ lookup: MEMFS.node_ops.lookup,
+ mknod: MEMFS.node_ops.mknod,
+ rename: MEMFS.node_ops.rename,
+ unlink: MEMFS.node_ops.unlink,
+ rmdir: MEMFS.node_ops.rmdir,
+ readdir: MEMFS.node_ops.readdir,
+ symlink: MEMFS.node_ops.symlink
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek
+ }
+ },
+ file: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek,
+ read: MEMFS.stream_ops.read,
+ write: MEMFS.stream_ops.write,
+ allocate: MEMFS.stream_ops.allocate,
+ mmap: MEMFS.stream_ops.mmap
+ }
+ },
+ link: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ readlink: MEMFS.node_ops.readlink
+ },
+ stream: {}
+ },
+ chrdev: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: FS.chrdev_stream_ops
+ },
+ };
+ }
+ var node = FS.createNode(parent, name, mode, dev);
+ if (FS.isDir(node.mode)) {
+ node.node_ops = MEMFS.ops_table.dir.node;
+ node.stream_ops = MEMFS.ops_table.dir.stream;
+ node.contents = {};
+ } else if (FS.isFile(node.mode)) {
+ node.node_ops = MEMFS.ops_table.file.node;
+ node.stream_ops = MEMFS.ops_table.file.stream;
+ node.contents = [];
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ } else if (FS.isLink(node.mode)) {
+ node.node_ops = MEMFS.ops_table.link.node;
+ node.stream_ops = MEMFS.ops_table.link.stream;
+ } else if (FS.isChrdev(node.mode)) {
+ node.node_ops = MEMFS.ops_table.chrdev.node;
+ node.stream_ops = MEMFS.ops_table.chrdev.stream;
+ }
+ node.timestamp = Date.now();
+ // add the new node to the parent
+ if (parent) {
+ parent.contents[name] = node;
+ }
+ return node;
+ },ensureFlexible:function (node) {
+ if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
+ var contents = node.contents;
+ node.contents = Array.prototype.slice.call(contents);
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ }
+ },node_ops:{getattr:function (node) {
+ var attr = {};
+ // device numbers reuse inode numbers.
+ attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
+ attr.ino = node.id;
+ attr.mode = node.mode;
+ attr.nlink = 1;
+ attr.uid = 0;
+ attr.gid = 0;
+ attr.rdev = node.rdev;
+ if (FS.isDir(node.mode)) {
+ attr.size = 4096;
+ } else if (FS.isFile(node.mode)) {
+ attr.size = node.contents.length;
+ } else if (FS.isLink(node.mode)) {
+ attr.size = node.link.length;
+ } else {
+ attr.size = 0;
+ }
+ attr.atime = new Date(node.timestamp);
+ attr.mtime = new Date(node.timestamp);
+ attr.ctime = new Date(node.timestamp);
+ // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
+ // but this is not required by the standard.
+ attr.blksize = 4096;
+ attr.blocks = Math.ceil(attr.size / attr.blksize);
+ return attr;
+ },setattr:function (node, attr) {
+ if (attr.mode !== undefined) {
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ node.timestamp = attr.timestamp;
+ }
+ if (attr.size !== undefined) {
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ if (attr.size < contents.length) contents.length = attr.size;
+ else while (attr.size > contents.length) contents.push(0);
+ }
+ },lookup:function (parent, name) {
+ throw FS.genericErrors[ERRNO_CODES.ENOENT];
+ },mknod:function (parent, name, mode, dev) {
+ return MEMFS.createNode(parent, name, mode, dev);
+ },rename:function (old_node, new_dir, new_name) {
+ // if we're overwriting a directory at new_name, make sure it's empty.
+ if (FS.isDir(old_node.mode)) {
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ }
+ if (new_node) {
+ for (var i in new_node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ }
+ }
+ // do the internal rewiring
+ delete old_node.parent.contents[old_node.name];
+ old_node.name = new_name;
+ new_dir.contents[new_name] = old_node;
+ old_node.parent = new_dir;
+ },unlink:function (parent, name) {
+ delete parent.contents[name];
+ },rmdir:function (parent, name) {
+ var node = FS.lookupNode(parent, name);
+ for (var i in node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ delete parent.contents[name];
+ },readdir:function (node) {
+ var entries = ['.', '..']
+ for (var key in node.contents) {
+ if (!node.contents.hasOwnProperty(key)) {
+ continue;
+ }
+ entries.push(key);
+ }
+ return entries;
+ },symlink:function (parent, newname, oldpath) {
+ var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
+ node.link = oldpath;
+ return node;
+ },readlink:function (node) {
+ if (!FS.isLink(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return node.link;
+ }},stream_ops:{read:function (stream, buffer, offset, length, position) {
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (size > 8 && contents.subarray) { // non-trivial, and typed array
+ buffer.set(contents.subarray(position, position + size), offset);
+ } else
+ {
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ }
+ return size;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ var node = stream.node;
+ node.timestamp = Date.now();
+ var contents = node.contents;
+ if (length && contents.length === 0 && position === 0 && buffer.subarray) {
+ // just replace it with the new data
+ if (canOwn && offset === 0) {
+ node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
+ node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
+ } else {
+ node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
+ node.contentMode = MEMFS.CONTENT_FIXED;
+ }
+ return length;
+ }
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ while (contents.length < position) contents.push(0);
+ for (var i = 0; i < length; i++) {
+ contents[position + i] = buffer[offset + i];
+ }
+ return length;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ position += stream.node.contents.length;
+ }
+ }
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ stream.ungotten = [];
+ stream.position = position;
+ return position;
+ },allocate:function (stream, offset, length) {
+ MEMFS.ensureFlexible(stream.node);
+ var contents = stream.node.contents;
+ var limit = offset + length;
+ while (limit > contents.length) contents.push(0);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ if (!FS.isFile(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ var ptr;
+ var allocated;
+ var contents = stream.node.contents;
+ // Only make a new copy when MAP_PRIVATE is specified.
+ if ( !(flags & 2) &&
+ (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
+ // We can't emulate MAP_SHARED when the file is not backed by the buffer
+ // we're mapping to (e.g. the HEAP buffer).
+ allocated = false;
+ ptr = contents.byteOffset;
+ } else {
+ // Try to avoid unnecessary slices.
+ if (position > 0 || position + length < contents.length) {
+ if (contents.subarray) {
+ contents = contents.subarray(position, position + length);
+ } else {
+ contents = Array.prototype.slice.call(contents, position, position + length);
+ }
+ }
+ allocated = true;
+ ptr = _malloc(length);
+ if (!ptr) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
+ }
+ buffer.set(contents, ptr);
+ }
+ return { ptr: ptr, allocated: allocated };
+ }}};
+
+ var IDBFS={dbs:{},indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
+ // reuse all of the core MEMFS functionality
+ return MEMFS.mount.apply(null, arguments);
+ },syncfs:function (mount, populate, callback) {
+ IDBFS.getLocalSet(mount, function(err, local) {
+ if (err) return callback(err);
+
+ IDBFS.getRemoteSet(mount, function(err, remote) {
+ if (err) return callback(err);
+
+ var src = populate ? remote : local;
+ var dst = populate ? local : remote;
+
+ IDBFS.reconcile(src, dst, callback);
+ });
+ });
+ },getDB:function (name, callback) {
+ // check the cache first
+ var db = IDBFS.dbs[name];
+ if (db) {
+ return callback(null, db);
+ }
+
+ var req;
+ try {
+ req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
+ } catch (e) {
+ return callback(e);
+ }
+ req.onupgradeneeded = function(e) {
+ var db = e.target.result;
+ var transaction = e.target.transaction;
+
+ var fileStore;
+
+ if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
+ fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ } else {
+ fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
+ }
+
+ fileStore.createIndex('timestamp', 'timestamp', { unique: false });
+ };
+ req.onsuccess = function() {
+ db = req.result;
+
+ // add to the cache
+ IDBFS.dbs[name] = db;
+ callback(null, db);
+ };
+ req.onerror = function() {
+ callback(this.error);
+ };
+ },getLocalSet:function (mount, callback) {
+ var entries = {};
+
+ function isRealDir(p) {
+ return p !== '.' && p !== '..';
+ };
+ function toAbsolute(root) {
+ return function(p) {
+ return PATH.join2(root, p);
+ }
+ };
+
+ var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
+
+ while (check.length) {
+ var path = check.pop();
+ var stat;
+
+ try {
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
+ }
+
+ entries[path] = { timestamp: stat.mtime };
+ }
+
+ return callback(null, { type: 'local', entries: entries });
+ },getRemoteSet:function (mount, callback) {
+ var entries = {};
+
+ IDBFS.getDB(mount.mountpoint, function(err, db) {
+ if (err) return callback(err);
+
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
+ transaction.onerror = function() { callback(this.error); };
+
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ var index = store.index('timestamp');
+
+ index.openKeyCursor().onsuccess = function(event) {
+ var cursor = event.target.result;
+
+ if (!cursor) {
+ return callback(null, { type: 'remote', db: db, entries: entries });
+ }
+
+ entries[cursor.primaryKey] = { timestamp: cursor.key };
+
+ cursor.continue();
+ };
+ });
+ },loadLocalEntry:function (path, callback) {
+ var stat, node;
+
+ try {
+ var lookup = FS.lookupPath(path);
+ node = lookup.node;
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode });
+ } else if (FS.isFile(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+ },storeLocalEntry:function (path, entry, callback) {
+ try {
+ if (FS.isDir(entry.mode)) {
+ FS.mkdir(path, entry.mode);
+ } else if (FS.isFile(entry.mode)) {
+ FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+
+ FS.utime(path, entry.timestamp, entry.timestamp);
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },removeLocalEntry:function (path, callback) {
+ try {
+ var lookup = FS.lookupPath(path);
+ var stat = FS.stat(path);
+
+ if (FS.isDir(stat.mode)) {
+ FS.rmdir(path);
+ } else if (FS.isFile(stat.mode)) {
+ FS.unlink(path);
+ }
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },loadRemoteEntry:function (store, path, callback) {
+ var req = store.get(path);
+ req.onsuccess = function(event) { callback(null, event.target.result); };
+ req.onerror = function() { callback(this.error); };
+ },storeRemoteEntry:function (store, path, entry, callback) {
+ var req = store.put(entry, path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },removeRemoteEntry:function (store, path, callback) {
+ var req = store.delete(path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },reconcile:function (src, dst, callback) {
+ var total = 0;
+
+ var create = [];
+ Object.keys(src.entries).forEach(function (key) {
+ var e = src.entries[key];
+ var e2 = dst.entries[key];
+ if (!e2 || e.timestamp > e2.timestamp) {
+ create.push(key);
+ total++;
+ }
+ });
+
+ var remove = [];
+ Object.keys(dst.entries).forEach(function (key) {
+ var e = dst.entries[key];
+ var e2 = src.entries[key];
+ if (!e2) {
+ remove.push(key);
+ total++;
+ }
+ });
+
+ if (!total) {
+ return callback(null);
+ }
+
+ var errored = false;
+ var completed = 0;
+ var db = src.type === 'remote' ? src.db : dst.db;
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= total) {
+ return callback(null);
+ }
+ };
+
+ transaction.onerror = function() { done(this.error); };
+
+ // sort paths in ascending order so directory entries are created
+ // before the files inside them
+ create.sort().forEach(function (path) {
+ if (dst.type === 'local') {
+ IDBFS.loadRemoteEntry(store, path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeLocalEntry(path, entry, done);
+ });
+ } else {
+ IDBFS.loadLocalEntry(path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeRemoteEntry(store, path, entry, done);
+ });
+ }
+ });
+
+ // sort paths in descending order so files are deleted before their
+ // parent directories
+ remove.sort().reverse().forEach(function(path) {
+ if (dst.type === 'local') {
+ IDBFS.removeLocalEntry(path, done);
+ } else {
+ IDBFS.removeRemoteEntry(store, path, done);
+ }
+ });
+ }};
+
+ var NODEFS={isWindows:false,staticInit:function () {
+ NODEFS.isWindows = !!process.platform.match(/^win/);
+ },mount:function (mount) {
+ assert(ENVIRONMENT_IS_NODE);
+ return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node = FS.createNode(parent, name, mode);
+ node.node_ops = NODEFS.node_ops;
+ node.stream_ops = NODEFS.stream_ops;
+ return node;
+ },getMode:function (path) {
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ if (NODEFS.isWindows) {
+ // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so
+ // propagate write bits to execute bits.
+ stat.mode = stat.mode | ((stat.mode & 146) >> 1);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return stat.mode;
+ },realPath:function (node) {
+ var parts = [];
+ while (node.parent !== node) {
+ parts.push(node.name);
+ node = node.parent;
+ }
+ parts.push(node.mount.opts.root);
+ parts.reverse();
+ return PATH.join.apply(null, parts);
+ },flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function (flags) {
+ if (flags in NODEFS.flagsToPermissionStringMap) {
+ return NODEFS.flagsToPermissionStringMap[flags];
+ } else {
+ return flags;
+ }
+ },node_ops:{getattr:function (node) {
+ var path = NODEFS.realPath(node);
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
+ // See http://support.microsoft.com/kb/140365
+ if (NODEFS.isWindows && !stat.blksize) {
+ stat.blksize = 4096;
+ }
+ if (NODEFS.isWindows && !stat.blocks) {
+ stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
+ }
+ return {
+ dev: stat.dev,
+ ino: stat.ino,
+ mode: stat.mode,
+ nlink: stat.nlink,
+ uid: stat.uid,
+ gid: stat.gid,
+ rdev: stat.rdev,
+ size: stat.size,
+ atime: stat.atime,
+ mtime: stat.mtime,
+ ctime: stat.ctime,
+ blksize: stat.blksize,
+ blocks: stat.blocks
+ };
+ },setattr:function (node, attr) {
+ var path = NODEFS.realPath(node);
+ try {
+ if (attr.mode !== undefined) {
+ fs.chmodSync(path, attr.mode);
+ // update the common node structure mode as well
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ var date = new Date(attr.timestamp);
+ fs.utimesSync(path, date, date);
+ }
+ if (attr.size !== undefined) {
+ fs.truncateSync(path, attr.size);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },lookup:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ var mode = NODEFS.getMode(path);
+ return NODEFS.createNode(parent, name, mode);
+ },mknod:function (parent, name, mode, dev) {
+ var node = NODEFS.createNode(parent, name, mode, dev);
+ // create the backing node for this in the fs root as well
+ var path = NODEFS.realPath(node);
+ try {
+ if (FS.isDir(node.mode)) {
+ fs.mkdirSync(path, node.mode);
+ } else {
+ fs.writeFileSync(path, '', { mode: node.mode });
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return node;
+ },rename:function (oldNode, newDir, newName) {
+ var oldPath = NODEFS.realPath(oldNode);
+ var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
+ try {
+ fs.renameSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },unlink:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.unlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },rmdir:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.rmdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readdir:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },symlink:function (parent, newName, oldPath) {
+ var newPath = PATH.join2(NODEFS.realPath(parent), newName);
+ try {
+ fs.symlinkSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readlink:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }},stream_ops:{open:function (stream) {
+ var path = NODEFS.realPath(stream.node);
+ try {
+ if (FS.isFile(stream.node.mode)) {
+ stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },close:function (stream) {
+ try {
+ if (FS.isFile(stream.node.mode) && stream.nfd) {
+ fs.closeSync(stream.nfd);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },read:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(length);
+ var res;
+ try {
+ res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ if (res > 0) {
+ for (var i = 0; i < res; i++) {
+ buffer[offset + i] = nbuffer[i];
+ }
+ }
+ return res;
+ },write:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
+ var res;
+ try {
+ res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return res;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ try {
+ var stat = fs.fstatSync(stream.nfd);
+ position += stat.size;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }
+ }
+
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ stream.position = position;
+ return position;
+ }}};
+
+ var _stdin=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stdout=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stderr=allocate(1, "i32*", ALLOC_STATIC);
+
+ function _fflush(stream) {
+ // int fflush(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html
+ // we don't currently perform any user-space buffering of data
+ }var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},handleFSError:function (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
+ return ___setErrNo(e.errno);
+ },lookupPath:function (path, opts) {
+ path = PATH.resolve(FS.cwd(), path);
+ opts = opts || {};
+
+ var defaults = {
+ follow_mount: true,
+ recurse_count: 0
+ };
+ for (var key in defaults) {
+ if (opts[key] === undefined) {
+ opts[key] = defaults[key];
+ }
+ }
+
+ if (opts.recurse_count > 8) { // max recursive lookup of 8
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+
+ // split the path
+ var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), false);
+
+ // start at the root
+ var current = FS.root;
+ var current_path = '/';
+
+ for (var i = 0; i < parts.length; i++) {
+ var islast = (i === parts.length-1);
+ if (islast && opts.parent) {
+ // stop resolving
+ break;
+ }
+
+ current = FS.lookupNode(current, parts[i]);
+ current_path = PATH.join2(current_path, parts[i]);
+
+ // jump to the mount's root node if this is a mountpoint
+ if (FS.isMountpoint(current)) {
+ if (!islast || (islast && opts.follow_mount)) {
+ current = current.mounted.root;
+ }
+ }
+
+ // by default, lookupPath will not follow a symlink if it is the final path component.
+ // setting opts.follow = true will override this behavior.
+ if (!islast || opts.follow) {
+ var count = 0;
+ while (FS.isLink(current.mode)) {
+ var link = FS.readlink(current_path);
+ current_path = PATH.resolve(PATH.dirname(current_path), link);
+
+ var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
+ current = lookup.node;
+
+ if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+ }
+ }
+ }
+
+ return { path: current_path, node: current };
+ },getPath:function (node) {
+ var path;
+ while (true) {
+ if (FS.isRoot(node)) {
+ var mount = node.mount.mountpoint;
+ if (!path) return mount;
+ return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
+ }
+ path = path ? node.name + '/' + path : node.name;
+ node = node.parent;
+ }
+ },hashName:function (parentid, name) {
+ var hash = 0;
+
+
+ for (var i = 0; i < name.length; i++) {
+ hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
+ }
+ return ((parentid + hash) >>> 0) % FS.nameTable.length;
+ },hashAddNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ node.name_next = FS.nameTable[hash];
+ FS.nameTable[hash] = node;
+ },hashRemoveNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ if (FS.nameTable[hash] === node) {
+ FS.nameTable[hash] = node.name_next;
+ } else {
+ var current = FS.nameTable[hash];
+ while (current) {
+ if (current.name_next === node) {
+ current.name_next = node.name_next;
+ break;
+ }
+ current = current.name_next;
+ }
+ }
+ },lookupNode:function (parent, name) {
+ var err = FS.mayLookup(parent);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ var hash = FS.hashName(parent.id, name);
+ for (var node = FS.nameTable[hash]; node; node = node.name_next) {
+ var nodeName = node.name;
+ if (node.parent.id === parent.id && nodeName === name) {
+ return node;
+ }
+ }
+ // if we failed to find it in the cache, call into the VFS
+ return FS.lookup(parent, name);
+ },createNode:function (parent, name, mode, rdev) {
+ if (!FS.FSNode) {
+ FS.FSNode = function(parent, name, mode, rdev) {
+ if (!parent) {
+ parent = this; // root node sets parent to itself
+ }
+ this.parent = parent;
+ this.mount = parent.mount;
+ this.mounted = null;
+ this.id = FS.nextInode++;
+ this.name = name;
+ this.mode = mode;
+ this.node_ops = {};
+ this.stream_ops = {};
+ this.rdev = rdev;
+ };
+
+ FS.FSNode.prototype = {};
+
+ // compatibility
+ var readMode = 292 | 73;
+ var writeMode = 146;
+
+ // NOTE we must use Object.defineProperties instead of individual calls to
+ // Object.defineProperty in order to make closure compiler happy
+ Object.defineProperties(FS.FSNode.prototype, {
+ read: {
+ get: function() { return (this.mode & readMode) === readMode; },
+ set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
+ },
+ write: {
+ get: function() { return (this.mode & writeMode) === writeMode; },
+ set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
+ },
+ isFolder: {
+ get: function() { return FS.isDir(this.mode); },
+ },
+ isDevice: {
+ get: function() { return FS.isChrdev(this.mode); },
+ },
+ });
+ }
+
+ var node = new FS.FSNode(parent, name, mode, rdev);
+
+ FS.hashAddNode(node);
+
+ return node;
+ },destroyNode:function (node) {
+ FS.hashRemoveNode(node);
+ },isRoot:function (node) {
+ return node === node.parent;
+ },isMountpoint:function (node) {
+ return !!node.mounted;
+ },isFile:function (mode) {
+ return (mode & 61440) === 32768;
+ },isDir:function (mode) {
+ return (mode & 61440) === 16384;
+ },isLink:function (mode) {
+ return (mode & 61440) === 40960;
+ },isChrdev:function (mode) {
+ return (mode & 61440) === 8192;
+ },isBlkdev:function (mode) {
+ return (mode & 61440) === 24576;
+ },isFIFO:function (mode) {
+ return (mode & 61440) === 4096;
+ },isSocket:function (mode) {
+ return (mode & 49152) === 49152;
+ },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
+ var flags = FS.flagModes[str];
+ if (typeof flags === 'undefined') {
+ throw new Error('Unknown file open mode: ' + str);
+ }
+ return flags;
+ },flagsToPermissionString:function (flag) {
+ var accmode = flag & 2097155;
+ var perms = ['r', 'w', 'rw'][accmode];
+ if ((flag & 512)) {
+ perms += 'w';
+ }
+ return perms;
+ },nodePermissions:function (node, perms) {
+ if (FS.ignorePermissions) {
+ return 0;
+ }
+ // return 0 if any user, group or owner bits are set.
+ if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
+ return ERRNO_CODES.EACCES;
+ }
+ return 0;
+ },mayLookup:function (dir) {
+ return FS.nodePermissions(dir, 'x');
+ },mayCreate:function (dir, name) {
+ try {
+ var node = FS.lookupNode(dir, name);
+ return ERRNO_CODES.EEXIST;
+ } catch (e) {
+ }
+ return FS.nodePermissions(dir, 'wx');
+ },mayDelete:function (dir, name, isdir) {
+ var node;
+ try {
+ node = FS.lookupNode(dir, name);
+ } catch (e) {
+ return e.errno;
+ }
+ var err = FS.nodePermissions(dir, 'wx');
+ if (err) {
+ return err;
+ }
+ if (isdir) {
+ if (!FS.isDir(node.mode)) {
+ return ERRNO_CODES.ENOTDIR;
+ }
+ if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
+ return ERRNO_CODES.EBUSY;
+ }
+ } else {
+ if (FS.isDir(node.mode)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return 0;
+ },mayOpen:function (node, flags) {
+ if (!node) {
+ return ERRNO_CODES.ENOENT;
+ }
+ if (FS.isLink(node.mode)) {
+ return ERRNO_CODES.ELOOP;
+ } else if (FS.isDir(node.mode)) {
+ if ((flags & 2097155) !== 0 || // opening for write
+ (flags & 512)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
+ },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
+ fd_start = fd_start || 0;
+ fd_end = fd_end || FS.MAX_OPEN_FDS;
+ for (var fd = fd_start; fd <= fd_end; fd++) {
+ if (!FS.streams[fd]) {
+ return fd;
+ }
+ }
+ throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
+ },getStream:function (fd) {
+ return FS.streams[fd];
+ },createStream:function (stream, fd_start, fd_end) {
+ if (!FS.FSStream) {
+ FS.FSStream = function(){};
+ FS.FSStream.prototype = {};
+ // compatibility
+ Object.defineProperties(FS.FSStream.prototype, {
+ object: {
+ get: function() { return this.node; },
+ set: function(val) { this.node = val; }
+ },
+ isRead: {
+ get: function() { return (this.flags & 2097155) !== 1; }
+ },
+ isWrite: {
+ get: function() { return (this.flags & 2097155) !== 0; }
+ },
+ isAppend: {
+ get: function() { return (this.flags & 1024); }
+ }
+ });
+ }
+ if (0) {
+ // reuse the object
+ stream.__proto__ = FS.FSStream.prototype;
+ } else {
+ var newStream = new FS.FSStream();
+ for (var p in stream) {
+ newStream[p] = stream[p];
+ }
+ stream = newStream;
+ }
+ var fd = FS.nextfd(fd_start, fd_end);
+ stream.fd = fd;
+ FS.streams[fd] = stream;
+ return stream;
+ },closeStream:function (fd) {
+ FS.streams[fd] = null;
+ },getStreamFromPtr:function (ptr) {
+ return FS.streams[ptr - 1];
+ },getPtrForStream:function (stream) {
+ return stream ? stream.fd + 1 : 0;
+ },chrdev_stream_ops:{open:function (stream) {
+ var device = FS.getDevice(stream.node.rdev);
+ // override node's stream ops with the device's
+ stream.stream_ops = device.stream_ops;
+ // forward the open call
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ },llseek:function () {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }},major:function (dev) {
+ return ((dev) >> 8);
+ },minor:function (dev) {
+ return ((dev) & 0xff);
+ },makedev:function (ma, mi) {
+ return ((ma) << 8 | (mi));
+ },registerDevice:function (dev, ops) {
+ FS.devices[dev] = { stream_ops: ops };
+ },getDevice:function (dev) {
+ return FS.devices[dev];
+ },getMounts:function (mount) {
+ var mounts = [];
+ var check = [mount];
+
+ while (check.length) {
+ var m = check.pop();
+
+ mounts.push(m);
+
+ check.push.apply(check, m.mounts);
+ }
+
+ return mounts;
+ },syncfs:function (populate, callback) {
+ if (typeof(populate) === 'function') {
+ callback = populate;
+ populate = false;
+ }
+
+ var mounts = FS.getMounts(FS.root.mount);
+ var completed = 0;
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= mounts.length) {
+ callback(null);
+ }
+ };
+
+ // sync all mounts
+ mounts.forEach(function (mount) {
+ if (!mount.type.syncfs) {
+ return done(null);
+ }
+ mount.type.syncfs(mount, populate, done);
+ });
+ },mount:function (type, opts, mountpoint) {
+ var root = mountpoint === '/';
+ var pseudo = !mountpoint;
+ var node;
+
+ if (root && FS.root) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ } else if (!root && !pseudo) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ mountpoint = lookup.path; // use the absolute path
+ node = lookup.node;
+
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+
+ if (!FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ }
+
+ var mount = {
+ type: type,
+ opts: opts,
+ mountpoint: mountpoint,
+ mounts: []
+ };
+
+ // create a root node for the fs
+ var mountRoot = type.mount(mount);
+ mountRoot.mount = mount;
+ mount.root = mountRoot;
+
+ if (root) {
+ FS.root = mountRoot;
+ } else if (node) {
+ // set as a mountpoint
+ node.mounted = mount;
+
+ // add the new mount to the current mount's children
+ if (node.mount) {
+ node.mount.mounts.push(mount);
+ }
+ }
+
+ return mountRoot;
+ },unmount:function (mountpoint) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ if (!FS.isMountpoint(lookup.node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ // destroy the nodes for this mount, and all its child mounts
+ var node = lookup.node;
+ var mount = node.mounted;
+ var mounts = FS.getMounts(mount);
+
+ Object.keys(FS.nameTable).forEach(function (hash) {
+ var current = FS.nameTable[hash];
+
+ while (current) {
+ var next = current.name_next;
+
+ if (mounts.indexOf(current.mount) !== -1) {
+ FS.destroyNode(current);
+ }
+
+ current = next;
+ }
+ });
+
+ // no longer a mountpoint
+ node.mounted = null;
+
+ // remove this mount from the child mounts
+ var idx = node.mount.mounts.indexOf(mount);
+ assert(idx !== -1);
+ node.mount.mounts.splice(idx, 1);
+ },lookup:function (parent, name) {
+ return parent.node_ops.lookup(parent, name);
+ },mknod:function (path, mode, dev) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var err = FS.mayCreate(parent, name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.mknod) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.mknod(parent, name, mode, dev);
+ },create:function (path, mode) {
+ mode = mode !== undefined ? mode : 438 /* 0666 */;
+ mode &= 4095;
+ mode |= 32768;
+ return FS.mknod(path, mode, 0);
+ },mkdir:function (path, mode) {
+ mode = mode !== undefined ? mode : 511 /* 0777 */;
+ mode &= 511 | 512;
+ mode |= 16384;
+ return FS.mknod(path, mode, 0);
+ },mkdev:function (path, mode, dev) {
+ if (typeof(dev) === 'undefined') {
+ dev = mode;
+ mode = 438 /* 0666 */;
+ }
+ mode |= 8192;
+ return FS.mknod(path, mode, dev);
+ },symlink:function (oldpath, newpath) {
+ var lookup = FS.lookupPath(newpath, { parent: true });
+ var parent = lookup.node;
+ var newname = PATH.basename(newpath);
+ var err = FS.mayCreate(parent, newname);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.symlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.symlink(parent, newname, oldpath);
+ },rename:function (old_path, new_path) {
+ var old_dirname = PATH.dirname(old_path);
+ var new_dirname = PATH.dirname(new_path);
+ var old_name = PATH.basename(old_path);
+ var new_name = PATH.basename(new_path);
+ // parents must exist
+ var lookup, old_dir, new_dir;
+ try {
+ lookup = FS.lookupPath(old_path, { parent: true });
+ old_dir = lookup.node;
+ lookup = FS.lookupPath(new_path, { parent: true });
+ new_dir = lookup.node;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // need to be part of the same mount
+ if (old_dir.mount !== new_dir.mount) {
+ throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
+ }
+ // source must exist
+ var old_node = FS.lookupNode(old_dir, old_name);
+ // old path should not be an ancestor of the new path
+ var relative = PATH.relative(old_path, new_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ // new path should not be an ancestor of the old path
+ relative = PATH.relative(new_path, old_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ // see if the new path already exists
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ // not fatal
+ }
+ // early out if nothing needs to change
+ if (old_node === new_node) {
+ return;
+ }
+ // we'll need to delete the old entry
+ var isdir = FS.isDir(old_node.mode);
+ var err = FS.mayDelete(old_dir, old_name, isdir);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // need delete permissions if we'll be overwriting.
+ // need create permissions if new doesn't already exist.
+ err = new_node ?
+ FS.mayDelete(new_dir, new_name, isdir) :
+ FS.mayCreate(new_dir, new_name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!old_dir.node_ops.rename) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // if we are going to change the parent, check write permissions
+ if (new_dir !== old_dir) {
+ err = FS.nodePermissions(old_dir, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ }
+ // remove the node from the lookup hash
+ FS.hashRemoveNode(old_node);
+ // do the underlying fs rename
+ try {
+ old_dir.node_ops.rename(old_node, new_dir, new_name);
+ } catch (e) {
+ throw e;
+ } finally {
+ // add the node back to the hash (in case node_ops.rename
+ // changed its name)
+ FS.hashAddNode(old_node);
+ }
+ },rmdir:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, true);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.rmdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.rmdir(parent, name);
+ FS.destroyNode(node);
+ },readdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ if (!node.node_ops.readdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ return node.node_ops.readdir(node);
+ },unlink:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, false);
+ if (err) {
+ // POSIX says unlink should set EPERM, not EISDIR
+ if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.unlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.unlink(parent, name);
+ FS.destroyNode(node);
+ },readlink:function (path) {
+ var lookup = FS.lookupPath(path);
+ var link = lookup.node;
+ if (!link.node_ops.readlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return link.node_ops.readlink(link);
+ },stat:function (path, dontFollow) {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ var node = lookup.node;
+ if (!node.node_ops.getattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return node.node_ops.getattr(node);
+ },lstat:function (path) {
+ return FS.stat(path, true);
+ },chmod:function (path, mode, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ mode: (mode & 4095) | (node.mode & ~4095),
+ timestamp: Date.now()
+ });
+ },lchmod:function (path, mode) {
+ FS.chmod(path, mode, true);
+ },fchmod:function (fd, mode) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chmod(stream.node, mode);
+ },chown:function (path, uid, gid, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ timestamp: Date.now()
+ // we ignore the uid / gid for now
+ });
+ },lchown:function (path, uid, gid) {
+ FS.chown(path, uid, gid, true);
+ },fchown:function (fd, uid, gid) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chown(stream.node, uid, gid);
+ },truncate:function (path, len) {
+ if (len < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: true });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!FS.isFile(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var err = FS.nodePermissions(node, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ node.node_ops.setattr(node, {
+ size: len,
+ timestamp: Date.now()
+ });
+ },ftruncate:function (fd, len) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ FS.truncate(stream.node, len);
+ },utime:function (path, atime, mtime) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ node.node_ops.setattr(node, {
+ timestamp: Math.max(atime, mtime)
+ });
+ },open:function (path, flags, mode, fd_start, fd_end) {
+ flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
+ mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
+ if ((flags & 64)) {
+ mode = (mode & 4095) | 32768;
+ } else {
+ mode = 0;
+ }
+ var node;
+ if (typeof path === 'object') {
+ node = path;
+ } else {
+ path = PATH.normalize(path);
+ try {
+ var lookup = FS.lookupPath(path, {
+ follow: !(flags & 131072)
+ });
+ node = lookup.node;
+ } catch (e) {
+ // ignore
+ }
+ }
+ // perhaps we need to create the node
+ if ((flags & 64)) {
+ if (node) {
+ // if O_CREAT and O_EXCL are set, error out if the node already exists
+ if ((flags & 128)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
+ }
+ } else {
+ // node doesn't exist, try to create it
+ node = FS.mknod(path, mode, 0);
+ }
+ }
+ if (!node) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
+ }
+ // can't truncate a device
+ if (FS.isChrdev(node.mode)) {
+ flags &= ~512;
+ }
+ // check permissions
+ var err = FS.mayOpen(node, flags);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // do truncation if necessary
+ if ((flags & 512)) {
+ FS.truncate(node, 0);
+ }
+ // we've already handled these, don't pass down to the underlying vfs
+ flags &= ~(128 | 512);
+
+ // register the stream with the filesystem
+ var stream = FS.createStream({
+ node: node,
+ path: FS.getPath(node), // we want the absolute path to the node
+ flags: flags,
+ seekable: true,
+ position: 0,
+ stream_ops: node.stream_ops,
+ // used by the file family libc calls (fopen, fwrite, ferror, etc.)
+ ungotten: [],
+ error: false
+ }, fd_start, fd_end);
+ // call the new stream's open function
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ if (Module['logReadFiles'] && !(flags & 1)) {
+ if (!FS.readFiles) FS.readFiles = {};
+ if (!(path in FS.readFiles)) {
+ FS.readFiles[path] = 1;
+ Module['printErr']('read file: ' + path);
+ }
+ }
+ return stream;
+ },close:function (stream) {
+ try {
+ if (stream.stream_ops.close) {
+ stream.stream_ops.close(stream);
+ }
+ } catch (e) {
+ throw e;
+ } finally {
+ FS.closeStream(stream.fd);
+ }
+ },llseek:function (stream, offset, whence) {
+ if (!stream.seekable || !stream.stream_ops.llseek) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ return stream.stream_ops.llseek(stream, offset, whence);
+ },read:function (stream, buffer, offset, length, position) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.read) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
+ if (!seeking) stream.position += bytesRead;
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.write) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ if (stream.flags & 1024) {
+ // seek to the end before writing in append mode
+ FS.llseek(stream, 0, 2);
+ }
+ var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
+ if (!seeking) stream.position += bytesWritten;
+ return bytesWritten;
+ },allocate:function (stream, offset, length) {
+ if (offset < 0 || length <= 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ if (!stream.stream_ops.allocate) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ stream.stream_ops.allocate(stream, offset, length);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ // TODO if PROT is PROT_WRITE, make sure we have write access
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EACCES);
+ }
+ if (!stream.stream_ops.mmap) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
+ },ioctl:function (stream, cmd, arg) {
+ if (!stream.stream_ops.ioctl) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
+ }
+ return stream.stream_ops.ioctl(stream, cmd, arg);
+ },readFile:function (path, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'r';
+ opts.encoding = opts.encoding || 'binary';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var ret;
+ var stream = FS.open(path, opts.flags);
+ var stat = FS.stat(path);
+ var length = stat.size;
+ var buf = new Uint8Array(length);
+ FS.read(stream, buf, 0, length, 0);
+ if (opts.encoding === 'utf8') {
+ ret = '';
+ var utf8 = new Runtime.UTF8Processor();
+ for (var i = 0; i < length; i++) {
+ ret += utf8.processCChar(buf[i]);
+ }
+ } else if (opts.encoding === 'binary') {
+ ret = buf;
+ }
+ FS.close(stream);
+ return ret;
+ },writeFile:function (path, data, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'w';
+ opts.encoding = opts.encoding || 'utf8';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var stream = FS.open(path, opts.flags, opts.mode);
+ if (opts.encoding === 'utf8') {
+ var utf8 = new Runtime.UTF8Processor();
+ var buf = new Uint8Array(utf8.processJSString(data));
+ FS.write(stream, buf, 0, buf.length, 0, opts.canOwn);
+ } else if (opts.encoding === 'binary') {
+ FS.write(stream, data, 0, data.length, 0, opts.canOwn);
+ }
+ FS.close(stream);
+ },cwd:function () {
+ return FS.currentPath;
+ },chdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ if (!FS.isDir(lookup.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ var err = FS.nodePermissions(lookup.node, 'x');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ FS.currentPath = lookup.path;
+ },createDefaultDirectories:function () {
+ FS.mkdir('/tmp');
+ },createDefaultDevices:function () {
+ // create /dev
+ FS.mkdir('/dev');
+ // setup /dev/null
+ FS.registerDevice(FS.makedev(1, 3), {
+ read: function() { return 0; },
+ write: function() { return 0; }
+ });
+ FS.mkdev('/dev/null', FS.makedev(1, 3));
+ // setup /dev/tty and /dev/tty1
+ // stderr needs to print output using Module['printErr']
+ // so we register a second tty just for it.
+ TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
+ TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
+ FS.mkdev('/dev/tty', FS.makedev(5, 0));
+ FS.mkdev('/dev/tty1', FS.makedev(6, 0));
+ // we're not going to emulate the actual shm device,
+ // just create the tmp dirs that reside in it commonly
+ FS.mkdir('/dev/shm');
+ FS.mkdir('/dev/shm/tmp');
+ },createStandardStreams:function () {
+ // TODO deprecate the old functionality of a single
+ // input / output callback and that utilizes FS.createDevice
+ // and instead require a unique set of stream ops
+
+ // by default, we symlink the standard streams to the
+ // default tty devices. however, if the standard streams
+ // have been overwritten we create a unique device for
+ // them instead.
+ if (Module['stdin']) {
+ FS.createDevice('/dev', 'stdin', Module['stdin']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdin');
+ }
+ if (Module['stdout']) {
+ FS.createDevice('/dev', 'stdout', null, Module['stdout']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdout');
+ }
+ if (Module['stderr']) {
+ FS.createDevice('/dev', 'stderr', null, Module['stderr']);
+ } else {
+ FS.symlink('/dev/tty1', '/dev/stderr');
+ }
+
+ // open default streams for the stdin, stdout and stderr devices
+ var stdin = FS.open('/dev/stdin', 'r');
+ HEAP32[((_stdin)>>2)]=FS.getPtrForStream(stdin);
+ assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
+
+ var stdout = FS.open('/dev/stdout', 'w');
+ HEAP32[((_stdout)>>2)]=FS.getPtrForStream(stdout);
+ assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
+
+ var stderr = FS.open('/dev/stderr', 'w');
+ HEAP32[((_stderr)>>2)]=FS.getPtrForStream(stderr);
+ assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
+ },ensureErrnoError:function () {
+ if (FS.ErrnoError) return;
+ FS.ErrnoError = function ErrnoError(errno) {
+ this.errno = errno;
+ for (var key in ERRNO_CODES) {
+ if (ERRNO_CODES[key] === errno) {
+ this.code = key;
+ break;
+ }
+ }
+ this.message = ERRNO_MESSAGES[errno];
+ };
+ FS.ErrnoError.prototype = new Error();
+ FS.ErrnoError.prototype.constructor = FS.ErrnoError;
+ // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
+ [ERRNO_CODES.ENOENT].forEach(function(code) {
+ FS.genericErrors[code] = new FS.ErrnoError(code);
+ FS.genericErrors[code].stack = '<generic error, no stack>';
+ });
+ },staticInit:function () {
+ FS.ensureErrnoError();
+
+ FS.nameTable = new Array(4096);
+
+ FS.mount(MEMFS, {}, '/');
+
+ FS.createDefaultDirectories();
+ FS.createDefaultDevices();
+ },init:function (input, output, error) {
+ assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
+ FS.init.initialized = true;
+
+ FS.ensureErrnoError();
+
+ // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
+ Module['stdin'] = input || Module['stdin'];
+ Module['stdout'] = output || Module['stdout'];
+ Module['stderr'] = error || Module['stderr'];
+
+ FS.createStandardStreams();
+ },quit:function () {
+ FS.init.initialized = false;
+ for (var i = 0; i < FS.streams.length; i++) {
+ var stream = FS.streams[i];
+ if (!stream) {
+ continue;
+ }
+ FS.close(stream);
+ }
+ },getMode:function (canRead, canWrite) {
+ var mode = 0;
+ if (canRead) mode |= 292 | 73;
+ if (canWrite) mode |= 146;
+ return mode;
+ },joinPath:function (parts, forceRelative) {
+ var path = PATH.join.apply(null, parts);
+ if (forceRelative && path[0] == '/') path = path.substr(1);
+ return path;
+ },absolutePath:function (relative, base) {
+ return PATH.resolve(base, relative);
+ },standardizePath:function (path) {
+ return PATH.normalize(path);
+ },findObject:function (path, dontResolveLastLink) {
+ var ret = FS.analyzePath(path, dontResolveLastLink);
+ if (ret.exists) {
+ return ret.object;
+ } else {
+ ___setErrNo(ret.error);
+ return null;
+ }
+ },analyzePath:function (path, dontResolveLastLink) {
+ // operate from within the context of the symlink's target
+ try {
+ var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ path = lookup.path;
+ } catch (e) {
+ }
+ var ret = {
+ isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
+ parentExists: false, parentPath: null, parentObject: null
+ };
+ try {
+ var lookup = FS.lookupPath(path, { parent: true });
+ ret.parentExists = true;
+ ret.parentPath = lookup.path;
+ ret.parentObject = lookup.node;
+ ret.name = PATH.basename(path);
+ lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ ret.exists = true;
+ ret.path = lookup.path;
+ ret.object = lookup.node;
+ ret.name = lookup.node.name;
+ ret.isRoot = lookup.path === '/';
+ } catch (e) {
+ ret.error = e.errno;
+ };
+ return ret;
+ },createFolder:function (parent, name, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.mkdir(path, mode);
+ },createPath:function (parent, path, canRead, canWrite) {
+ parent = typeof parent === 'string' ? parent : FS.getPath(parent);
+ var parts = path.split('/').reverse();
+ while (parts.length) {
+ var part = parts.pop();
+ if (!part) continue;
+ var current = PATH.join2(parent, part);
+ try {
+ FS.mkdir(current);
+ } catch (e) {
+ // ignore EEXIST
+ }
+ parent = current;
+ }
+ return current;
+ },createFile:function (parent, name, properties, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.create(path, mode);
+ },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
+ var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
+ var mode = FS.getMode(canRead, canWrite);
+ var node = FS.create(path, mode);
+ if (data) {
+ if (typeof data === 'string') {
+ var arr = new Array(data.length);
+ for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
+ data = arr;
+ }
+ // make sure we can write to the file
+ FS.chmod(node, mode | 146);
+ var stream = FS.open(node, 'w');
+ FS.write(stream, data, 0, data.length, 0, canOwn);
+ FS.close(stream);
+ FS.chmod(node, mode);
+ }
+ return node;
+ },createDevice:function (parent, name, input, output) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(!!input, !!output);
+ if (!FS.createDevice.major) FS.createDevice.major = 64;
+ var dev = FS.makedev(FS.createDevice.major++, 0);
+ // Create a fake device that a set of stream ops to emulate
+ // the old behavior.
+ FS.registerDevice(dev, {
+ open: function(stream) {
+ stream.seekable = false;
+ },
+ close: function(stream) {
+ // flush any pending line data
+ if (output && output.buffer && output.buffer.length) {
+ output(10);
+ }
+ },
+ read: function(stream, buffer, offset, length, pos /* ignored */) {
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = input();
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },
+ write: function(stream, buffer, offset, length, pos) {
+ for (var i = 0; i < length; i++) {
+ try {
+ output(buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }
+ });
+ return FS.mkdev(path, mode, dev);
+ },createLink:function (parent, name, target, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ return FS.symlink(target, path);
+ },forceLoadFile:function (obj) {
+ if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
+ var success = true;
+ if (typeof XMLHttpRequest !== 'undefined') {
+ throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
+ } else if (Module['read']) {
+ // Command-line.
+ try {
+ // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
+ // read() will try to parse UTF8.
+ obj.contents = intArrayFromString(Module['read'](obj.url), true);
+ } catch (e) {
+ success = false;
+ }
+ } else {
+ throw new Error('Cannot load without read() or XMLHttpRequest.');
+ }
+ if (!success) ___setErrNo(ERRNO_CODES.EIO);
+ return success;
+ },createLazyFile:function (parent, name, url, canRead, canWrite) {
+ // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
+ function LazyUint8Array() {
+ this.lengthKnown = false;
+ this.chunks = []; // Loaded chunks. Index is the chunk number
+ }
+ LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
+ if (idx > this.length-1 || idx < 0) {
+ return undefined;
+ }
+ var chunkOffset = idx % this.chunkSize;
+ var chunkNum = Math.floor(idx / this.chunkSize);
+ return this.getter(chunkNum)[chunkOffset];
+ }
+ LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
+ this.getter = getter;
+ }
+ LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
+ // Find length
+ var xhr = new XMLHttpRequest();
+ xhr.open('HEAD', url, false);
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ var datalength = Number(xhr.getResponseHeader("Content-length"));
+ var header;
+ var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
+ var chunkSize = 1024*1024; // Chunk size in bytes
+
+ if (!hasByteServing) chunkSize = datalength;
+
+ // Function to get a range from the remote URL.
+ var doXHR = (function(from, to) {
+ if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
+ if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
+
+ // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
+
+ // Some hints to the browser that we want binary data.
+ if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
+ if (xhr.overrideMimeType) {
+ xhr.overrideMimeType('text/plain; charset=x-user-defined');
+ }
+
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ if (xhr.response !== undefined) {
+ return new Uint8Array(xhr.response || []);
+ } else {
+ return intArrayFromString(xhr.responseText || '', true);
+ }
+ });
+ var lazyArray = this;
+ lazyArray.setDataGetter(function(chunkNum) {
+ var start = chunkNum * chunkSize;
+ var end = (chunkNum+1) * chunkSize - 1; // including this byte
+ end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
+ lazyArray.chunks[chunkNum] = doXHR(start, end);
+ }
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
+ return lazyArray.chunks[chunkNum];
+ });
+
+ this._length = datalength;
+ this._chunkSize = chunkSize;
+ this.lengthKnown = true;
+ }
+ if (typeof XMLHttpRequest !== 'undefined') {
+ if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
+ var lazyArray = new LazyUint8Array();
+ Object.defineProperty(lazyArray, "length", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._length;
+ }
+ });
+ Object.defineProperty(lazyArray, "chunkSize", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._chunkSize;
+ }
+ });
+
+ var properties = { isDevice: false, contents: lazyArray };
+ } else {
+ var properties = { isDevice: false, url: url };
+ }
+
+ var node = FS.createFile(parent, name, properties, canRead, canWrite);
+ // This is a total hack, but I want to get this lazy file code out of the
+ // core of MEMFS. If we want to keep this lazy file concept I feel it should
+ // be its own thin LAZYFS proxying calls to MEMFS.
+ if (properties.contents) {
+ node.contents = properties.contents;
+ } else if (properties.url) {
+ node.contents = null;
+ node.url = properties.url;
+ }
+ // override each stream op with one that tries to force load the lazy file first
+ var stream_ops = {};
+ var keys = Object.keys(node.stream_ops);
+ keys.forEach(function(key) {
+ var fn = node.stream_ops[key];
+ stream_ops[key] = function forceLoadLazyFile() {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ return fn.apply(null, arguments);
+ };
+ });
+ // use a custom read function
+ stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (contents.slice) { // normal array
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ } else {
+ for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
+ buffer[offset + i] = contents.get(position + i);
+ }
+ }
+ return size;
+ };
+ node.stream_ops = stream_ops;
+ return node;
+ },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {
+ Browser.init();
+ // TODO we should allow people to just pass in a complete filename instead
+ // of parent and name being that we just join them anyways
+ var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
+ function processData(byteArray) {
+ function finish(byteArray) {
+ if (!dontCreateFile) {
+ FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
+ }
+ if (onload) onload();
+ removeRunDependency('cp ' + fullname);
+ }
+ var handled = false;
+ Module['preloadPlugins'].forEach(function(plugin) {
+ if (handled) return;
+ if (plugin['canHandle'](fullname)) {
+ plugin['handle'](byteArray, fullname, finish, function() {
+ if (onerror) onerror();
+ removeRunDependency('cp ' + fullname);
+ });
+ handled = true;
+ }
+ });
+ if (!handled) finish(byteArray);
+ }
+ addRunDependency('cp ' + fullname);
+ if (typeof url == 'string') {
+ Browser.asyncLoad(url, function(byteArray) {
+ processData(byteArray);
+ }, onerror);
+ } else {
+ processData(url);
+ }
+ },indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_NAME:function () {
+ return 'EM_FS_' + window.location.pathname;
+ },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
+ console.log('creating db');
+ var db = openRequest.result;
+ db.createObjectStore(FS.DB_STORE_NAME);
+ };
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var putRequest = files.put(FS.analyzePath(path).object.contents, path);
+ putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
+ putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ },loadFilesFromDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = onerror; // no database to load from
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ try {
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
+ } catch(e) {
+ onerror(e);
+ return;
+ }
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var getRequest = files.get(path);
+ getRequest.onsuccess = function getRequest_onsuccess() {
+ if (FS.analyzePath(path).exists) {
+ FS.unlink(path);
+ }
+ FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
+ ok++;
+ if (ok + fail == total) finish();
+ };
+ getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ }};
+
+
+
+
+ function _mkport() { throw 'TODO' }var SOCKFS={mount:function (mount) {
+ return FS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createSocket:function (family, type, protocol) {
+ var streaming = type == 1;
+ if (protocol) {
+ assert(streaming == (protocol == 6)); // if SOCK_STREAM, must be tcp
+ }
+
+ // create our internal socket structure
+ var sock = {
+ family: family,
+ type: type,
+ protocol: protocol,
+ server: null,
+ peers: {},
+ pending: [],
+ recv_queue: [],
+ sock_ops: SOCKFS.websocket_sock_ops
+ };
+
+ // create the filesystem node to store the socket structure
+ var name = SOCKFS.nextname();
+ var node = FS.createNode(SOCKFS.root, name, 49152, 0);
+ node.sock = sock;
+
+ // and the wrapping stream that enables library functions such
+ // as read and write to indirectly interact with the socket
+ var stream = FS.createStream({
+ path: name,
+ node: node,
+ flags: FS.modeStringToFlags('r+'),
+ seekable: false,
+ stream_ops: SOCKFS.stream_ops
+ });
+
+ // map the new stream to the socket structure (sockets have a 1:1
+ // relationship with a stream)
+ sock.stream = stream;
+
+ return sock;
+ },getSocket:function (fd) {
+ var stream = FS.getStream(fd);
+ if (!stream || !FS.isSocket(stream.node.mode)) {
+ return null;
+ }
+ return stream.node.sock;
+ },stream_ops:{poll:function (stream) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.poll(sock);
+ },ioctl:function (stream, request, varargs) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.ioctl(sock, request, varargs);
+ },read:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ var msg = sock.sock_ops.recvmsg(sock, length);
+ if (!msg) {
+ // socket is closed
+ return 0;
+ }
+ buffer.set(msg.buffer, offset);
+ return msg.buffer.length;
+ },write:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.sendmsg(sock, buffer, offset, length);
+ },close:function (stream) {
+ var sock = stream.node.sock;
+ sock.sock_ops.close(sock);
+ }},nextname:function () {
+ if (!SOCKFS.nextname.current) {
+ SOCKFS.nextname.current = 0;
+ }
+ return 'socket[' + (SOCKFS.nextname.current++) + ']';
+ },websocket_sock_ops:{createPeer:function (sock, addr, port) {
+ var ws;
+
+ if (typeof addr === 'object') {
+ ws = addr;
+ addr = null;
+ port = null;
+ }
+
+ if (ws) {
+ // for sockets that've already connected (e.g. we're the server)
+ // we can inspect the _socket property for the address
+ if (ws._socket) {
+ addr = ws._socket.remoteAddress;
+ port = ws._socket.remotePort;
+ }
+ // if we're just now initializing a connection to the remote,
+ // inspect the url property
+ else {
+ var result = /ws[s]?:\/\/([^:]+):(\d+)/.exec(ws.url);
+ if (!result) {
+ throw new Error('WebSocket URL must be in the format ws(s)://address:port');
+ }
+ addr = result[1];
+ port = parseInt(result[2], 10);
+ }
+ } else {
+ // create the actual websocket object and connect
+ try {
+ // runtimeConfig gets set to true if WebSocket runtime configuration is available.
+ var runtimeConfig = (Module['websocket'] && ('object' === typeof Module['websocket']));
+
+ // The default value is 'ws://' the replace is needed because the compiler replaces "//" comments with '#'
+ // comments without checking context, so we'd end up with ws:#, the replace swaps the "#" for "//" again.
+ var url = 'ws:#'.replace('#', '//');
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['url']) {
+ url = Module['websocket']['url']; // Fetch runtime WebSocket URL config.
+ }
+ }
+
+ if (url === 'ws://' || url === 'wss://') { // Is the supplied URL config just a prefix, if so complete it.
+ url = url + addr + ':' + port;
+ }
+
+ // Make the WebSocket subprotocol (Sec-WebSocket-Protocol) default to binary if no configuration is set.
+ var subProtocols = 'binary'; // The default value is 'binary'
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['subprotocol']) {
+ subProtocols = Module['websocket']['subprotocol']; // Fetch runtime WebSocket subprotocol config.
+ }
+ }
+
+ // The regex trims the string (removes spaces at the beginning and end, then splits the string by
+ // <any space>,<any space> into an Array. Whitespace removal is important for Websockify and ws.
+ subProtocols = subProtocols.replace(/^ +| +$/g,"").split(/ *, */);
+
+ // The node ws library API for specifying optional subprotocol is slightly different than the browser's.
+ var opts = ENVIRONMENT_IS_NODE ? {'protocol': subProtocols.toString()} : subProtocols;
+
+ // If node we use the ws library.
+ var WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : window['WebSocket'];
+ ws = new WebSocket(url, opts);
+ ws.binaryType = 'arraybuffer';
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EHOSTUNREACH);
+ }
+ }
+
+
+ var peer = {
+ addr: addr,
+ port: port,
+ socket: ws,
+ dgram_send_queue: []
+ };
+
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);
+
+ // if this is a bound dgram socket, send the port number first to allow
+ // us to override the ephemeral port reported to us by remotePort on the
+ // remote end.
+ if (sock.type === 2 && typeof sock.sport !== 'undefined') {
+ peer.dgram_send_queue.push(new Uint8Array([
+ 255, 255, 255, 255,
+ 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),
+ ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)
+ ]));
+ }
+
+ return peer;
+ },getPeer:function (sock, addr, port) {
+ return sock.peers[addr + ':' + port];
+ },addPeer:function (sock, peer) {
+ sock.peers[peer.addr + ':' + peer.port] = peer;
+ },removePeer:function (sock, peer) {
+ delete sock.peers[peer.addr + ':' + peer.port];
+ },handlePeerEvents:function (sock, peer) {
+ var first = true;
+
+ var handleOpen = function () {
+ try {
+ var queued = peer.dgram_send_queue.shift();
+ while (queued) {
+ peer.socket.send(queued);
+ queued = peer.dgram_send_queue.shift();
+ }
+ } catch (e) {
+ // not much we can do here in the way of proper error handling as we've already
+ // lied and said this data was sent. shut it down.
+ peer.socket.close();
+ }
+ };
+
+ function handleMessage(data) {
+ assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer
+ data = new Uint8Array(data); // make a typed array view on the array buffer
+
+
+ // if this is the port message, override the peer's port with it
+ var wasfirst = first;
+ first = false;
+ if (wasfirst &&
+ data.length === 10 &&
+ data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&
+ data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {
+ // update the peer's port and it's key in the peer map
+ var newport = ((data[8] << 8) | data[9]);
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ peer.port = newport;
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ return;
+ }
+
+ sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });
+ };
+
+ if (ENVIRONMENT_IS_NODE) {
+ peer.socket.on('open', handleOpen);
+ peer.socket.on('message', function(data, flags) {
+ if (!flags.binary) {
+ return;
+ }
+ handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
+ });
+ peer.socket.on('error', function() {
+ // don't throw
+ });
+ } else {
+ peer.socket.onopen = handleOpen;
+ peer.socket.onmessage = function peer_socket_onmessage(event) {
+ handleMessage(event.data);
+ };
+ }
+ },poll:function (sock) {
+ if (sock.type === 1 && sock.server) {
+ // listen sockets should only say they're available for reading
+ // if there are pending clients.
+ return sock.pending.length ? (64 | 1) : 0;
+ }
+
+ var mask = 0;
+ var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets
+ SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :
+ null;
+
+ if (sock.recv_queue.length ||
+ !dest || // connection-less sockets are always ready to read
+ (dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed
+ mask |= (64 | 1);
+ }
+
+ if (!dest || // connection-less sockets are always ready to write
+ (dest && dest.socket.readyState === dest.socket.OPEN)) {
+ mask |= 4;
+ }
+
+ if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) {
+ mask |= 16;
+ }
+
+ return mask;
+ },ioctl:function (sock, request, arg) {
+ switch (request) {
+ case 21531:
+ var bytes = 0;
+ if (sock.recv_queue.length) {
+ bytes = sock.recv_queue[0].data.length;
+ }
+ HEAP32[((arg)>>2)]=bytes;
+ return 0;
+ default:
+ return ERRNO_CODES.EINVAL;
+ }
+ },close:function (sock) {
+ // if we've spawned a listen server, close it
+ if (sock.server) {
+ try {
+ sock.server.close();
+ } catch (e) {
+ }
+ sock.server = null;
+ }
+ // close any peer connections
+ var peers = Object.keys(sock.peers);
+ for (var i = 0; i < peers.length; i++) {
+ var peer = sock.peers[peers[i]];
+ try {
+ peer.socket.close();
+ } catch (e) {
+ }
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ }
+ return 0;
+ },bind:function (sock, addr, port) {
+ if (typeof sock.saddr !== 'undefined' || typeof sock.sport !== 'undefined') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already bound
+ }
+ sock.saddr = addr;
+ sock.sport = port || _mkport();
+ // in order to emulate dgram sockets, we need to launch a listen server when
+ // binding on a connection-less socket
+ // note: this is only required on the server side
+ if (sock.type === 2) {
+ // close the existing server if it exists
+ if (sock.server) {
+ sock.server.close();
+ sock.server = null;
+ }
+ // swallow error operation not supported error that occurs when binding in the
+ // browser where this isn't supported
+ try {
+ sock.sock_ops.listen(sock, 0);
+ } catch (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e;
+ if (e.errno !== ERRNO_CODES.EOPNOTSUPP) throw e;
+ }
+ }
+ },connect:function (sock, addr, port) {
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODS.EOPNOTSUPP);
+ }
+
+ // TODO autobind
+ // if (!sock.addr && sock.type == 2) {
+ // }
+
+ // early out if we're already connected / in the middle of connecting
+ if (typeof sock.daddr !== 'undefined' && typeof sock.dport !== 'undefined') {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+ if (dest) {
+ if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EALREADY);
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EISCONN);
+ }
+ }
+ }
+
+ // add the socket to our peer list and set our
+ // destination address / port to match
+ var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ sock.daddr = peer.addr;
+ sock.dport = peer.port;
+
+ // always "fail" in non-blocking mode
+ throw new FS.ErrnoError(ERRNO_CODES.EINPROGRESS);
+ },listen:function (sock, backlog) {
+ if (!ENVIRONMENT_IS_NODE) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already listening
+ }
+ var WebSocketServer = require('ws').Server;
+ var host = sock.saddr;
+ sock.server = new WebSocketServer({
+ host: host,
+ port: sock.sport
+ // TODO support backlog
+ });
+
+ sock.server.on('connection', function(ws) {
+ if (sock.type === 1) {
+ var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);
+
+ // create a peer on the new socket
+ var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);
+ newsock.daddr = peer.addr;
+ newsock.dport = peer.port;
+
+ // push to queue for accept to pick up
+ sock.pending.push(newsock);
+ } else {
+ // create a peer on the listen socket so calling sendto
+ // with the listen socket and an address will resolve
+ // to the correct client
+ SOCKFS.websocket_sock_ops.createPeer(sock, ws);
+ }
+ });
+ sock.server.on('closed', function() {
+ sock.server = null;
+ });
+ sock.server.on('error', function() {
+ // don't throw
+ });
+ },accept:function (listensock) {
+ if (!listensock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var newsock = listensock.pending.shift();
+ newsock.stream.flags = listensock.stream.flags;
+ return newsock;
+ },getname:function (sock, peer) {
+ var addr, port;
+ if (peer) {
+ if (sock.daddr === undefined || sock.dport === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ addr = sock.daddr;
+ port = sock.dport;
+ } else {
+ // TODO saddr and sport will be set for bind()'d UDP sockets, but what
+ // should we be returning for TCP sockets that've been connect()'d?
+ addr = sock.saddr || 0;
+ port = sock.sport || 0;
+ }
+ return { addr: addr, port: port };
+ },sendmsg:function (sock, buffer, offset, length, addr, port) {
+ if (sock.type === 2) {
+ // connection-less sockets will honor the message address,
+ // and otherwise fall back to the bound destination address
+ if (addr === undefined || port === undefined) {
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+ // if there was no address to fall back to, error out
+ if (addr === undefined || port === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.EDESTADDRREQ);
+ }
+ } else {
+ // connection-based sockets will only use the bound
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+
+ // find the peer for the destination address
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);
+
+ // early out if not connected with a connection-based socket
+ if (sock.type === 1) {
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ } else if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // create a copy of the incoming data to send, as the WebSocket API
+ // doesn't work entirely with an ArrayBufferView, it'll just send
+ // the entire underlying buffer
+ var data;
+ if (buffer instanceof Array || buffer instanceof ArrayBuffer) {
+ data = buffer.slice(offset, offset + length);
+ } else { // ArrayBufferView
+ data = buffer.buffer.slice(buffer.byteOffset + offset, buffer.byteOffset + offset + length);
+ }
+
+ // if we're emulating a connection-less dgram socket and don't have
+ // a cached connection, queue the buffer to send upon connect and
+ // lie, saying the data was sent now.
+ if (sock.type === 2) {
+ if (!dest || dest.socket.readyState !== dest.socket.OPEN) {
+ // if we're not connected, open a new connection
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ }
+ dest.dgram_send_queue.push(data);
+ return length;
+ }
+ }
+
+ try {
+ // send the actual data
+ dest.socket.send(data);
+ return length;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ },recvmsg:function (sock, length) {
+ // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html
+ if (sock.type === 1 && sock.server) {
+ // tcp servers should not be recv()'ing on the listen socket
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+
+ var queued = sock.recv_queue.shift();
+ if (!queued) {
+ if (sock.type === 1) {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+
+ if (!dest) {
+ // if we have a destination address but are not connected, error out
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ else if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ // return null if the socket has closed
+ return null;
+ }
+ else {
+ // else, our socket is in a valid state but truly has nothing available
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // queued.data will be an ArrayBuffer if it's unadulterated, but if it's
+ // requeued TCP data it'll be an ArrayBufferView
+ var queuedLength = queued.data.byteLength || queued.data.length;
+ var queuedOffset = queued.data.byteOffset || 0;
+ var queuedBuffer = queued.data.buffer || queued.data;
+ var bytesRead = Math.min(length, queuedLength);
+ var res = {
+ buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),
+ addr: queued.addr,
+ port: queued.port
+ };
+
+
+ // push back any unread data for TCP connections
+ if (sock.type === 1 && bytesRead < queuedLength) {
+ var bytesRemaining = queuedLength - bytesRead;
+ queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
+ sock.recv_queue.unshift(queued);
+ }
+
+ return res;
+ }}};function _send(fd, buf, len, flags) {
+ var sock = SOCKFS.getSocket(fd);
+ if (!sock) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ // TODO honor flags
+ return _write(fd, buf, len);
+ }
+
+ function _pwrite(fildes, buf, nbyte, offset) {
+ // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte, offset);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _write(fildes, buf, nbyte) {
+ // ssize_t write(int fildes, const void *buf, size_t nbyte);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+
+
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }
+
+ function _fileno(stream) {
+ // int fileno(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fileno.html
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) return -1;
+ return stream.fd;
+ }function _fwrite(ptr, size, nitems, stream) {
+ // size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html
+ var bytesToWrite = nitems * size;
+ if (bytesToWrite == 0) return 0;
+ var fd = _fileno(stream);
+ var bytesWritten = _write(fd, ptr, bytesToWrite);
+ if (bytesWritten == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return 0;
+ } else {
+ return Math.floor(bytesWritten / size);
+ }
+ }
+
+
+
+ Module["_strlen"] = _strlen;
+
+ function __reallyNegative(x) {
+ return x < 0 || (x === 0 && (1/x) === -Infinity);
+ }function __formatString(format, varargs) {
+ var textIndex = format;
+ var argIndex = 0;
+ function getNextArg(type) {
+ // NOTE: Explicitly ignoring type safety. Otherwise this fails:
+ // int x = 4; printf("%c\n", (char)x);
+ var ret;
+ if (type === 'double') {
+ ret = HEAPF64[(((varargs)+(argIndex))>>3)];
+ } else if (type == 'i64') {
+ ret = [HEAP32[(((varargs)+(argIndex))>>2)],
+ HEAP32[(((varargs)+(argIndex+4))>>2)]];
+
+ } else {
+ type = 'i32'; // varargs are always i32, i64, or double
+ ret = HEAP32[(((varargs)+(argIndex))>>2)];
+ }
+ argIndex += Runtime.getNativeFieldSize(type);
+ return ret;
+ }
+
+ var ret = [];
+ var curr, next, currArg;
+ while(1) {
+ var startTextIndex = textIndex;
+ curr = HEAP8[(textIndex)];
+ if (curr === 0) break;
+ next = HEAP8[((textIndex+1)|0)];
+ if (curr == 37) {
+ // Handle flags.
+ var flagAlwaysSigned = false;
+ var flagLeftAlign = false;
+ var flagAlternative = false;
+ var flagZeroPad = false;
+ var flagPadSign = false;
+ flagsLoop: while (1) {
+ switch (next) {
+ case 43:
+ flagAlwaysSigned = true;
+ break;
+ case 45:
+ flagLeftAlign = true;
+ break;
+ case 35:
+ flagAlternative = true;
+ break;
+ case 48:
+ if (flagZeroPad) {
+ break flagsLoop;
+ } else {
+ flagZeroPad = true;
+ break;
+ }
+ case 32:
+ flagPadSign = true;
+ break;
+ default:
+ break flagsLoop;
+ }
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+
+ // Handle width.
+ var width = 0;
+ if (next == 42) {
+ width = getNextArg('i32');
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ } else {
+ while (next >= 48 && next <= 57) {
+ width = width * 10 + (next - 48);
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ }
+
+ // Handle precision.
+ var precisionSet = false, precision = -1;
+ if (next == 46) {
+ precision = 0;
+ precisionSet = true;
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ if (next == 42) {
+ precision = getNextArg('i32');
+ textIndex++;
+ } else {
+ while(1) {
+ var precisionChr = HEAP8[((textIndex+1)|0)];
+ if (precisionChr < 48 ||
+ precisionChr > 57) break;
+ precision = precision * 10 + (precisionChr - 48);
+ textIndex++;
+ }
+ }
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ if (precision < 0) {
+ precision = 6; // Standard default.
+ precisionSet = false;
+ }
+
+ // Handle integer sizes. WARNING: These assume a 32-bit architecture!
+ var argSize;
+ switch (String.fromCharCode(next)) {
+ case 'h':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 104) {
+ textIndex++;
+ argSize = 1; // char (actually i32 in varargs)
+ } else {
+ argSize = 2; // short (actually i32 in varargs)
+ }
+ break;
+ case 'l':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 108) {
+ textIndex++;
+ argSize = 8; // long long
+ } else {
+ argSize = 4; // long
+ }
+ break;
+ case 'L': // long long
+ case 'q': // int64_t
+ case 'j': // intmax_t
+ argSize = 8;
+ break;
+ case 'z': // size_t
+ case 't': // ptrdiff_t
+ case 'I': // signed ptrdiff_t or unsigned size_t
+ argSize = 4;
+ break;
+ default:
+ argSize = null;
+ }
+ if (argSize) textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+
+ // Handle type specifier.
+ switch (String.fromCharCode(next)) {
+ case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {
+ // Integer.
+ var signed = next == 100 || next == 105;
+ argSize = argSize || 4;
+ var currArg = getNextArg('i' + (argSize * 8));
+ var argText;
+ // Flatten i64-1 [low, high] into a (slightly rounded) double
+ if (argSize == 8) {
+ currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);
+ }
+ // Truncate to requested size.
+ if (argSize <= 4) {
+ var limit = Math.pow(256, argSize) - 1;
+ currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);
+ }
+ // Format the number.
+ var currAbsArg = Math.abs(currArg);
+ var prefix = '';
+ if (next == 100 || next == 105) {
+ argText = reSign(currArg, 8 * argSize, 1).toString(10);
+ } else if (next == 117) {
+ argText = unSign(currArg, 8 * argSize, 1).toString(10);
+ currArg = Math.abs(currArg);
+ } else if (next == 111) {
+ argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
+ } else if (next == 120 || next == 88) {
+ prefix = (flagAlternative && currArg != 0) ? '0x' : '';
+ if (currArg < 0) {
+ // Represent negative numbers in hex as 2's complement.
+ currArg = -currArg;
+ argText = (currAbsArg - 1).toString(16);
+ var buffer = [];
+ for (var i = 0; i < argText.length; i++) {
+ buffer.push((0xF - parseInt(argText[i], 16)).toString(16));
+ }
+ argText = buffer.join('');
+ while (argText.length < argSize * 2) argText = 'f' + argText;
+ } else {
+ argText = currAbsArg.toString(16);
+ }
+ if (next == 88) {
+ prefix = prefix.toUpperCase();
+ argText = argText.toUpperCase();
+ }
+ } else if (next == 112) {
+ if (currAbsArg === 0) {
+ argText = '(nil)';
+ } else {
+ prefix = '0x';
+ argText = currAbsArg.toString(16);
+ }
+ }
+ if (precisionSet) {
+ while (argText.length < precision) {
+ argText = '0' + argText;
+ }
+ }
+
+ // Add sign if needed
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ prefix = '+' + prefix;
+ } else if (flagPadSign) {
+ prefix = ' ' + prefix;
+ }
+ }
+
+ // Move sign to prefix so we zero-pad after the sign
+ if (argText.charAt(0) == '-') {
+ prefix = '-' + prefix;
+ argText = argText.substr(1);
+ }
+
+ // Add padding.
+ while (prefix.length + argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad) {
+ argText = '0' + argText;
+ } else {
+ prefix = ' ' + prefix;
+ }
+ }
+ }
+
+ // Insert the result into the buffer.
+ argText = prefix + argText;
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {
+ // Float.
+ var currArg = getNextArg('double');
+ var argText;
+ if (isNaN(currArg)) {
+ argText = 'nan';
+ flagZeroPad = false;
+ } else if (!isFinite(currArg)) {
+ argText = (currArg < 0 ? '-' : '') + 'inf';
+ flagZeroPad = false;
+ } else {
+ var isGeneral = false;
+ var effectivePrecision = Math.min(precision, 20);
+
+ // Convert g/G to f/F or e/E, as per:
+ // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
+ if (next == 103 || next == 71) {
+ isGeneral = true;
+ precision = precision || 1;
+ var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);
+ if (precision > exponent && exponent >= -4) {
+ next = ((next == 103) ? 'f' : 'F').charCodeAt(0);
+ precision -= exponent + 1;
+ } else {
+ next = ((next == 103) ? 'e' : 'E').charCodeAt(0);
+ precision--;
+ }
+ effectivePrecision = Math.min(precision, 20);
+ }
+
+ if (next == 101 || next == 69) {
+ argText = currArg.toExponential(effectivePrecision);
+ // Make sure the exponent has at least 2 digits.
+ if (/[eE][-+]\d$/.test(argText)) {
+ argText = argText.slice(0, -1) + '0' + argText.slice(-1);
+ }
+ } else if (next == 102 || next == 70) {
+ argText = currArg.toFixed(effectivePrecision);
+ if (currArg === 0 && __reallyNegative(currArg)) {
+ argText = '-' + argText;
+ }
+ }
+
+ var parts = argText.split('e');
+ if (isGeneral && !flagAlternative) {
+ // Discard trailing zeros and periods.
+ while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&
+ (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {
+ parts[0] = parts[0].slice(0, -1);
+ }
+ } else {
+ // Make sure we have a period in alternative mode.
+ if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';
+ // Zero pad until required precision.
+ while (precision > effectivePrecision++) parts[0] += '0';
+ }
+ argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');
+
+ // Capitalize 'E' if needed.
+ if (next == 69) argText = argText.toUpperCase();
+
+ // Add sign.
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ argText = '+' + argText;
+ } else if (flagPadSign) {
+ argText = ' ' + argText;
+ }
+ }
+ }
+
+ // Add padding.
+ while (argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {
+ argText = argText[0] + '0' + argText.slice(1);
+ } else {
+ argText = (flagZeroPad ? '0' : ' ') + argText;
+ }
+ }
+ }
+
+ // Adjust case.
+ if (next < 97) argText = argText.toUpperCase();
+
+ // Insert the result into the buffer.
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 's': {
+ // String.
+ var arg = getNextArg('i8*');
+ var argLength = arg ? _strlen(arg) : '(null)'.length;
+ if (precisionSet) argLength = Math.min(argLength, precision);
+ if (!flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ if (arg) {
+ for (var i = 0; i < argLength; i++) {
+ ret.push(HEAPU8[((arg++)|0)]);
+ }
+ } else {
+ ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true));
+ }
+ if (flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ break;
+ }
+ case 'c': {
+ // Character.
+ if (flagLeftAlign) ret.push(getNextArg('i8'));
+ while (--width > 0) {
+ ret.push(32);
+ }
+ if (!flagLeftAlign) ret.push(getNextArg('i8'));
+ break;
+ }
+ case 'n': {
+ // Write the length written so far to the next parameter.
+ var ptr = getNextArg('i32*');
+ HEAP32[((ptr)>>2)]=ret.length;
+ break;
+ }
+ case '%': {
+ // Literal percent sign.
+ ret.push(curr);
+ break;
+ }
+ default: {
+ // Unknown specifiers remain untouched.
+ for (var i = startTextIndex; i < textIndex + 2; i++) {
+ ret.push(HEAP8[(i)]);
+ }
+ }
+ }
+ textIndex += 2;
+ // TODO: Support a/A (hex float) and m (last error) specifiers.
+ // TODO: Support %1${specifier} for arg selection.
+ } else {
+ ret.push(curr);
+ textIndex += 1;
+ }
+ }
+ return ret;
+ }function _fprintf(stream, format, varargs) {
+ // int fprintf(FILE *restrict stream, const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var result = __formatString(format, varargs);
+ var stack = Runtime.stackSave();
+ var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);
+ Runtime.stackRestore(stack);
+ return ret;
+ }function _printf(format, varargs) {
+ // int printf(const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var stdout = HEAP32[((_stdout)>>2)];
+ return _fprintf(stdout, format, varargs);
+ }
+
+
+ function _fputc(c, stream) {
+ // int fputc(int c, FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputc.html
+ var chr = unSign(c & 0xFF);
+ HEAP8[((_fputc.ret)|0)]=chr;
+ var fd = _fileno(stream);
+ var ret = _write(fd, _fputc.ret, 1);
+ if (ret == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return -1;
+ } else {
+ return chr;
+ }
+ }function _putchar(c) {
+ // int putchar(int c);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/putchar.html
+ return _fputc(c, HEAP32[((_stdout)>>2)]);
+ }
+
+ function _sbrk(bytes) {
+ // Implement a Linux-like 'memory area' for our 'process'.
+ // Changes the size of the memory area by |bytes|; returns the
+ // address of the previous top ('break') of the memory area
+ // We control the "dynamic" memory - DYNAMIC_BASE to DYNAMICTOP
+ var self = _sbrk;
+ if (!self.called) {
+ DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned
+ self.called = true;
+ assert(Runtime.dynamicAlloc);
+ self.alloc = Runtime.dynamicAlloc;
+ Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') };
+ }
+ var ret = DYNAMICTOP;
+ if (bytes != 0) self.alloc(bytes);
+ return ret; // Previous break location.
+ }
+
+ function _sysconf(name) {
+ // long sysconf(int name);
+ // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html
+ switch(name) {
+ case 30: return PAGE_SIZE;
+ case 132:
+ case 133:
+ case 12:
+ case 137:
+ case 138:
+ case 15:
+ case 235:
+ case 16:
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ case 149:
+ case 13:
+ case 10:
+ case 236:
+ case 153:
+ case 9:
+ case 21:
+ case 22:
+ case 159:
+ case 154:
+ case 14:
+ case 77:
+ case 78:
+ case 139:
+ case 80:
+ case 81:
+ case 79:
+ case 82:
+ case 68:
+ case 67:
+ case 164:
+ case 11:
+ case 29:
+ case 47:
+ case 48:
+ case 95:
+ case 52:
+ case 51:
+ case 46:
+ return 200809;
+ case 27:
+ case 246:
+ case 127:
+ case 128:
+ case 23:
+ case 24:
+ case 160:
+ case 161:
+ case 181:
+ case 182:
+ case 242:
+ case 183:
+ case 184:
+ case 243:
+ case 244:
+ case 245:
+ case 165:
+ case 178:
+ case 179:
+ case 49:
+ case 50:
+ case 168:
+ case 169:
+ case 175:
+ case 170:
+ case 171:
+ case 172:
+ case 97:
+ case 76:
+ case 32:
+ case 173:
+ case 35:
+ return -1;
+ case 176:
+ case 177:
+ case 7:
+ case 155:
+ case 8:
+ case 157:
+ case 125:
+ case 126:
+ case 92:
+ case 93:
+ case 129:
+ case 130:
+ case 131:
+ case 94:
+ case 91:
+ return 1;
+ case 74:
+ case 60:
+ case 69:
+ case 70:
+ case 4:
+ return 1024;
+ case 31:
+ case 42:
+ case 72:
+ return 32;
+ case 87:
+ case 26:
+ case 33:
+ return 2147483647;
+ case 34:
+ case 1:
+ return 47839;
+ case 38:
+ case 36:
+ return 99;
+ case 43:
+ case 37:
+ return 2048;
+ case 0: return 2097152;
+ case 3: return 65536;
+ case 28: return 32768;
+ case 44: return 32767;
+ case 75: return 16384;
+ case 39: return 1000;
+ case 89: return 700;
+ case 71: return 256;
+ case 40: return 255;
+ case 2: return 100;
+ case 180: return 64;
+ case 25: return 20;
+ case 5: return 16;
+ case 6: return 6;
+ case 73: return 4;
+ case 84: return 1;
+ }
+ ___setErrNo(ERRNO_CODES.EINVAL);
+ return -1;
+ }
+
+
+ Module["_memset"] = _memset;
+
+ function ___errno_location() {
+ return ___errno_state;
+ }
+
+ function _abort() {
+ Module['abort']();
+ }
+
+ var Browser={mainLoop:{scheduler:null,method:"",shouldPause:false,paused:false,queue:[],pause:function () {
+ Browser.mainLoop.shouldPause = true;
+ },resume:function () {
+ if (Browser.mainLoop.paused) {
+ Browser.mainLoop.paused = false;
+ Browser.mainLoop.scheduler();
+ }
+ Browser.mainLoop.shouldPause = false;
+ },updateStatus:function () {
+ if (Module['setStatus']) {
+ var message = Module['statusMessage'] || 'Please wait...';
+ var remaining = Browser.mainLoop.remainingBlockers;
+ var expected = Browser.mainLoop.expectedBlockers;
+ if (remaining) {
+ if (remaining < expected) {
+ Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');
+ } else {
+ Module['setStatus'](message);
+ }
+ } else {
+ Module['setStatus']('');
+ }
+ }
+ }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {
+ if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers
+
+ if (Browser.initted || ENVIRONMENT_IS_WORKER) return;
+ Browser.initted = true;
+
+ try {
+ new Blob();
+ Browser.hasBlobConstructor = true;
+ } catch(e) {
+ Browser.hasBlobConstructor = false;
+ console.log("warning: no blob constructor, cannot create blobs with mimetypes");
+ }
+ Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null));
+ Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
+ if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {
+ console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
+ Module.noImageDecoding = true;
+ }
+
+ // Support for plugins that can process preloaded files. You can add more of these to
+ // your app by creating and appending to Module.preloadPlugins.
+ //
+ // Each plugin is asked if it can handle a file based on the file's name. If it can,
+ // it is given the file's raw data. When it is done, it calls a callback with the file's
+ // (possibly modified) data. For example, a plugin might decompress a file, or it
+ // might create some side data structure for use later (like an Image element, etc.).
+
+ var imagePlugin = {};
+ imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
+ return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
+ };
+ imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
+ var b = null;
+ if (Browser.hasBlobConstructor) {
+ try {
+ b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ if (b.size !== byteArray.length) { // Safari bug #118630
+ // Safari's Blob can only take an ArrayBuffer
+ b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
+ }
+ } catch(e) {
+ Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');
+ }
+ }
+ if (!b) {
+ var bb = new Browser.BlobBuilder();
+ bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range
+ b = bb.getBlob();
+ }
+ var url = Browser.URLObject.createObjectURL(b);
+ var img = new Image();
+ img.onload = function img_onload() {
+ assert(img.complete, 'Image ' + name + ' could not be decoded');
+ var canvas = document.createElement('canvas');
+ canvas.width = img.width;
+ canvas.height = img.height;
+ var ctx = canvas.getContext('2d');
+ ctx.drawImage(img, 0, 0);
+ Module["preloadedImages"][name] = canvas;
+ Browser.URLObject.revokeObjectURL(url);
+ if (onload) onload(byteArray);
+ };
+ img.onerror = function img_onerror(event) {
+ console.log('Image ' + url + ' could not be decoded');
+ if (onerror) onerror();
+ };
+ img.src = url;
+ };
+ Module['preloadPlugins'].push(imagePlugin);
+
+ var audioPlugin = {};
+ audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
+ return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
+ };
+ audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
+ var done = false;
+ function finish(audio) {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = audio;
+ if (onload) onload(byteArray);
+ }
+ function fail() {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = new Audio(); // empty shim
+ if (onerror) onerror();
+ }
+ if (Browser.hasBlobConstructor) {
+ try {
+ var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ } catch(e) {
+ return fail();
+ }
+ var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
+ var audio = new Audio();
+ audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
+ audio.onerror = function audio_onerror(event) {
+ if (done) return;
+ console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
+ function encode64(data) {
+ var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ var PAD = '=';
+ var ret = '';
+ var leftchar = 0;
+ var leftbits = 0;
+ for (var i = 0; i < data.length; i++) {
+ leftchar = (leftchar << 8) | data[i];
+ leftbits += 8;
+ while (leftbits >= 6) {
+ var curr = (leftchar >> (leftbits-6)) & 0x3f;
+ leftbits -= 6;
+ ret += BASE[curr];
+ }
+ }
+ if (leftbits == 2) {
+ ret += BASE[(leftchar&3) << 4];
+ ret += PAD + PAD;
+ } else if (leftbits == 4) {
+ ret += BASE[(leftchar&0xf) << 2];
+ ret += PAD;
+ }
+ return ret;
+ }
+ audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);
+ finish(audio); // we don't wait for confirmation this worked - but it's worth trying
+ };
+ audio.src = url;
+ // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror
+ Browser.safeSetTimeout(function() {
+ finish(audio); // try to use it even though it is not necessarily ready to play
+ }, 10000);
+ } else {
+ return fail();
+ }
+ };
+ Module['preloadPlugins'].push(audioPlugin);
+
+ // Canvas event setup
+
+ var canvas = Module['canvas'];
+
+ // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module
+ // Module['forcedAspectRatio'] = 4 / 3;
+
+ canvas.requestPointerLock = canvas['requestPointerLock'] ||
+ canvas['mozRequestPointerLock'] ||
+ canvas['webkitRequestPointerLock'] ||
+ canvas['msRequestPointerLock'] ||
+ function(){};
+ canvas.exitPointerLock = document['exitPointerLock'] ||
+ document['mozExitPointerLock'] ||
+ document['webkitExitPointerLock'] ||
+ document['msExitPointerLock'] ||
+ function(){}; // no-op if function does not exist
+ canvas.exitPointerLock = canvas.exitPointerLock.bind(document);
+
+ function pointerLockChange() {
+ Browser.pointerLock = document['pointerLockElement'] === canvas ||
+ document['mozPointerLockElement'] === canvas ||
+ document['webkitPointerLockElement'] === canvas ||
+ document['msPointerLockElement'] === canvas;
+ }
+
+ document.addEventListener('pointerlockchange', pointerLockChange, false);
+ document.addEventListener('mozpointerlockchange', pointerLockChange, false);
+ document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
+ document.addEventListener('mspointerlockchange', pointerLockChange, false);
+
+ if (Module['elementPointerLock']) {
+ canvas.addEventListener("click", function(ev) {
+ if (!Browser.pointerLock && canvas.requestPointerLock) {
+ canvas.requestPointerLock();
+ ev.preventDefault();
+ }
+ }, false);
+ }
+ },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) {
+ var ctx;
+ var errorInfo = '?';
+ function onContextCreationError(event) {
+ errorInfo = event.statusMessage || errorInfo;
+ }
+ try {
+ if (useWebGL) {
+ var contextAttributes = {
+ antialias: false,
+ alpha: false
+ };
+
+ if (webGLContextAttributes) {
+ for (var attribute in webGLContextAttributes) {
+ contextAttributes[attribute] = webGLContextAttributes[attribute];
+ }
+ }
+
+
+ canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
+ try {
+ ['experimental-webgl', 'webgl'].some(function(webglId) {
+ return ctx = canvas.getContext(webglId, contextAttributes);
+ });
+ } finally {
+ canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
+ }
+ } else {
+ ctx = canvas.getContext('2d');
+ }
+ if (!ctx) throw ':(';
+ } catch (e) {
+ Module.print('Could not create canvas: ' + [errorInfo, e]);
+ return null;
+ }
+ if (useWebGL) {
+ // Set the background of the WebGL canvas to black
+ canvas.style.backgroundColor = "black";
+
+ // Warn on context loss
+ canvas.addEventListener('webglcontextlost', function(event) {
+ alert('WebGL context lost. You will need to reload the page.');
+ }, false);
+ }
+ if (setInModule) {
+ GLctx = Module.ctx = ctx;
+ Module.useWebGL = useWebGL;
+ Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
+ Browser.init();
+ }
+ return ctx;
+ },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {
+ Browser.lockPointer = lockPointer;
+ Browser.resizeCanvas = resizeCanvas;
+ if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;
+ if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;
+
+ var canvas = Module['canvas'];
+ function fullScreenChange() {
+ Browser.isFullScreen = false;
+ var canvasContainer = canvas.parentNode;
+ if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvasContainer) {
+ canvas.cancelFullScreen = document['cancelFullScreen'] ||
+ document['mozCancelFullScreen'] ||
+ document['webkitCancelFullScreen'] ||
+ document['msExitFullscreen'] ||
+ document['exitFullscreen'] ||
+ function() {};
+ canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);
+ if (Browser.lockPointer) canvas.requestPointerLock();
+ Browser.isFullScreen = true;
+ if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();
+ } else {
+
+ // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen
+ canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
+ canvasContainer.parentNode.removeChild(canvasContainer);
+
+ if (Browser.resizeCanvas) Browser.setWindowedCanvasSize();
+ }
+ if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);
+ Browser.updateCanvasDimensions(canvas);
+ }
+
+ if (!Browser.fullScreenHandlersInstalled) {
+ Browser.fullScreenHandlersInstalled = true;
+ document.addEventListener('fullscreenchange', fullScreenChange, false);
+ document.addEventListener('mozfullscreenchange', fullScreenChange, false);
+ document.addEventListener('webkitfullscreenchange', fullScreenChange, false);
+ document.addEventListener('MSFullscreenChange', fullScreenChange, false);
+ }
+
+ // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root
+ var canvasContainer = document.createElement("div");
+ canvas.parentNode.insertBefore(canvasContainer, canvas);
+ canvasContainer.appendChild(canvas);
+
+ // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size)
+ canvasContainer.requestFullScreen = canvasContainer['requestFullScreen'] ||
+ canvasContainer['mozRequestFullScreen'] ||
+ canvasContainer['msRequestFullscreen'] ||
+ (canvasContainer['webkitRequestFullScreen'] ? function() { canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);
+ canvasContainer.requestFullScreen();
+ },requestAnimationFrame:function requestAnimationFrame(func) {
+ if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
+ setTimeout(func, 1000/60);
+ } else {
+ if (!window.requestAnimationFrame) {
+ window.requestAnimationFrame = window['requestAnimationFrame'] ||
+ window['mozRequestAnimationFrame'] ||
+ window['webkitRequestAnimationFrame'] ||
+ window['msRequestAnimationFrame'] ||
+ window['oRequestAnimationFrame'] ||
+ window['setTimeout'];
+ }
+ window.requestAnimationFrame(func);
+ }
+ },safeCallback:function (func) {
+ return function() {
+ if (!ABORT) return func.apply(null, arguments);
+ };
+ },safeRequestAnimationFrame:function (func) {
+ return Browser.requestAnimationFrame(function() {
+ if (!ABORT) func();
+ });
+ },safeSetTimeout:function (func, timeout) {
+ return setTimeout(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },safeSetInterval:function (func, timeout) {
+ return setInterval(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },getMimetype:function (name) {
+ return {
+ 'jpg': 'image/jpeg',
+ 'jpeg': 'image/jpeg',
+ 'png': 'image/png',
+ 'bmp': 'image/bmp',
+ 'ogg': 'audio/ogg',
+ 'wav': 'audio/wav',
+ 'mp3': 'audio/mpeg'
+ }[name.substr(name.lastIndexOf('.')+1)];
+ },getUserMedia:function (func) {
+ if(!window.getUserMedia) {
+ window.getUserMedia = navigator['getUserMedia'] ||
+ navigator['mozGetUserMedia'];
+ }
+ window.getUserMedia(func);
+ },getMovementX:function (event) {
+ return event['movementX'] ||
+ event['mozMovementX'] ||
+ event['webkitMovementX'] ||
+ 0;
+ },getMovementY:function (event) {
+ return event['movementY'] ||
+ event['mozMovementY'] ||
+ event['webkitMovementY'] ||
+ 0;
+ },getMouseWheelDelta:function (event) {
+ return Math.max(-1, Math.min(1, event.type === 'DOMMouseScroll' ? event.detail : -event.wheelDelta));
+ },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup
+ if (Browser.pointerLock) {
+ // When the pointer is locked, calculate the coordinates
+ // based on the movement of the mouse.
+ // Workaround for Firefox bug 764498
+ if (event.type != 'mousemove' &&
+ ('mozMovementX' in event)) {
+ Browser.mouseMovementX = Browser.mouseMovementY = 0;
+ } else {
+ Browser.mouseMovementX = Browser.getMovementX(event);
+ Browser.mouseMovementY = Browser.getMovementY(event);
+ }
+
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
+ Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
+ } else {
+ // just add the mouse delta to the current absolut mouse position
+ // FIXME: ideally this should be clamped against the canvas size and zero
+ Browser.mouseX += Browser.mouseMovementX;
+ Browser.mouseY += Browser.mouseMovementY;
+ }
+ } else {
+ // Otherwise, calculate the movement based on the changes
+ // in the coordinates.
+ var rect = Module["canvas"].getBoundingClientRect();
+ var x, y;
+
+ // Neither .scrollX or .pageXOffset are defined in a spec, but
+ // we prefer .scrollX because it is currently in a spec draft.
+ // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
+ var scrollX = ((typeof window.scrollX !== 'undefined') ? window.scrollX : window.pageXOffset);
+ var scrollY = ((typeof window.scrollY !== 'undefined') ? window.scrollY : window.pageYOffset);
+ if (event.type == 'touchstart' ||
+ event.type == 'touchend' ||
+ event.type == 'touchmove') {
+ var t = event.touches.item(0);
+ if (t) {
+ x = t.pageX - (scrollX + rect.left);
+ y = t.pageY - (scrollY + rect.top);
+ } else {
+ return;
+ }
+ } else {
+ x = event.pageX - (scrollX + rect.left);
+ y = event.pageY - (scrollY + rect.top);
+ }
+
+ // the canvas might be CSS-scaled compared to its backbuffer;
+ // SDL-using content will want mouse coordinates in terms
+ // of backbuffer units.
+ var cw = Module["canvas"].width;
+ var ch = Module["canvas"].height;
+ x = x * (cw / rect.width);
+ y = y * (ch / rect.height);
+
+ Browser.mouseMovementX = x - Browser.mouseX;
+ Browser.mouseMovementY = y - Browser.mouseY;
+ Browser.mouseX = x;
+ Browser.mouseY = y;
+ }
+ },xhrLoad:function (url, onload, onerror) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, true);
+ xhr.responseType = 'arraybuffer';
+ xhr.onload = function xhr_onload() {
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
+ onload(xhr.response);
+ } else {
+ onerror();
+ }
+ };
+ xhr.onerror = onerror;
+ xhr.send(null);
+ },asyncLoad:function (url, onload, onerror, noRunDep) {
+ Browser.xhrLoad(url, function(arrayBuffer) {
+ assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
+ onload(new Uint8Array(arrayBuffer));
+ if (!noRunDep) removeRunDependency('al ' + url);
+ }, function(event) {
+ if (onerror) {
+ onerror();
+ } else {
+ throw 'Loading data file "' + url + '" failed.';
+ }
+ });
+ if (!noRunDep) addRunDependency('al ' + url);
+ },resizeListeners:[],updateResizeListeners:function () {
+ var canvas = Module['canvas'];
+ Browser.resizeListeners.forEach(function(listener) {
+ listener(canvas.width, canvas.height);
+ });
+ },setCanvasSize:function (width, height, noUpdates) {
+ var canvas = Module['canvas'];
+ Browser.updateCanvasDimensions(canvas, width, height);
+ if (!noUpdates) Browser.updateResizeListeners();
+ },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },setWindowedCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },updateCanvasDimensions:function (canvas, wNative, hNative) {
+ if (wNative && hNative) {
+ canvas.widthNative = wNative;
+ canvas.heightNative = hNative;
+ } else {
+ wNative = canvas.widthNative;
+ hNative = canvas.heightNative;
+ }
+ var w = wNative;
+ var h = hNative;
+ if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) {
+ if (w/h < Module['forcedAspectRatio']) {
+ w = Math.round(h * Module['forcedAspectRatio']);
+ } else {
+ h = Math.round(w / Module['forcedAspectRatio']);
+ }
+ }
+ if (((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
+ var factor = Math.min(screen.width / w, screen.height / h);
+ w = Math.round(w * factor);
+ h = Math.round(h * factor);
+ }
+ if (Browser.resizeCanvas) {
+ if (canvas.width != w) canvas.width = w;
+ if (canvas.height != h) canvas.height = h;
+ if (typeof canvas.style != 'undefined') {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ } else {
+ if (canvas.width != wNative) canvas.width = wNative;
+ if (canvas.height != hNative) canvas.height = hNative;
+ if (typeof canvas.style != 'undefined') {
+ if (w != wNative || h != hNative) {
+ canvas.style.setProperty( "width", w + "px", "important");
+ canvas.style.setProperty("height", h + "px", "important");
+ } else {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ }
+ }
+ }};
+
+ function _time(ptr) {
+ var ret = Math.floor(Date.now()/1000);
+ if (ptr) {
+ HEAP32[((ptr)>>2)]=ret;
+ }
+ return ret;
+ }
+
+
+
+ function _emscripten_memcpy_big(dest, src, num) {
+ HEAPU8.set(HEAPU8.subarray(src, src+num), dest);
+ return dest;
+ }
+ Module["_memcpy"] = _memcpy;
+FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;
+___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;
+__ATINIT__.unshift({ func: function() { TTY.init() } });__ATEXIT__.push({ func: function() { TTY.shutdown() } });TTY.utf8 = new Runtime.UTF8Processor();
+if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); NODEFS.staticInit(); }
+__ATINIT__.push({ func: function() { SOCKFS.root = FS.mount(SOCKFS, {}, null); } });
+_fputc.ret = allocate([0], "i8", ALLOC_STATIC);
+Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };
+ Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };
+ Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };
+ Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };
+ Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };
+ Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }
+STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);
+
+staticSealed = true; // seal the static portion of memory
+
+STACK_MAX = STACK_BASE + 5242880;
+
+DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);
+
+assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");
+
+
+var Math_min = Math.min;
+function asmPrintInt(x, y) {
+ Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+function asmPrintFloat(x, y) {
+ Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+// EMSCRIPTEN_START_ASM
+var asm = (function(global, env, buffer) {
+ 'use asm';
+ var HEAP8 = new global.Int8Array(buffer);
+ var HEAP16 = new global.Int16Array(buffer);
+ var HEAP32 = new global.Int32Array(buffer);
+ var HEAPU8 = new global.Uint8Array(buffer);
+ var HEAPU16 = new global.Uint16Array(buffer);
+ var HEAPU32 = new global.Uint32Array(buffer);
+ var HEAPF32 = new global.Float32Array(buffer);
+ var HEAPF64 = new global.Float64Array(buffer);
+
+ var STACKTOP=env.STACKTOP|0;
+ var STACK_MAX=env.STACK_MAX|0;
+ var tempDoublePtr=env.tempDoublePtr|0;
+ var ABORT=env.ABORT|0;
+
+ var __THREW__ = 0;
+ var threwValue = 0;
+ var setjmpId = 0;
+ var undef = 0;
+ var nan = +env.NaN, inf = +env.Infinity;
+ var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0;
+
+ var tempRet0 = 0;
+ var tempRet1 = 0;
+ var tempRet2 = 0;
+ var tempRet3 = 0;
+ var tempRet4 = 0;
+ var tempRet5 = 0;
+ var tempRet6 = 0;
+ var tempRet7 = 0;
+ var tempRet8 = 0;
+ var tempRet9 = 0;
+ var Math_floor=global.Math.floor;
+ var Math_abs=global.Math.abs;
+ var Math_sqrt=global.Math.sqrt;
+ var Math_pow=global.Math.pow;
+ var Math_cos=global.Math.cos;
+ var Math_sin=global.Math.sin;
+ var Math_tan=global.Math.tan;
+ var Math_acos=global.Math.acos;
+ var Math_asin=global.Math.asin;
+ var Math_atan=global.Math.atan;
+ var Math_atan2=global.Math.atan2;
+ var Math_exp=global.Math.exp;
+ var Math_log=global.Math.log;
+ var Math_ceil=global.Math.ceil;
+ var Math_imul=global.Math.imul;
+ var abort=env.abort;
+ var assert=env.assert;
+ var asmPrintInt=env.asmPrintInt;
+ var asmPrintFloat=env.asmPrintFloat;
+ var Math_min=env.min;
+ var _fflush=env._fflush;
+ var _emscripten_memcpy_big=env._emscripten_memcpy_big;
+ var _putchar=env._putchar;
+ var _fputc=env._fputc;
+ var _send=env._send;
+ var _pwrite=env._pwrite;
+ var _abort=env._abort;
+ var __reallyNegative=env.__reallyNegative;
+ var _fwrite=env._fwrite;
+ var _sbrk=env._sbrk;
+ var _mkport=env._mkport;
+ var _fprintf=env._fprintf;
+ var ___setErrNo=env.___setErrNo;
+ var __formatString=env.__formatString;
+ var _fileno=env._fileno;
+ var _printf=env._printf;
+ var _time=env._time;
+ var _sysconf=env._sysconf;
+ var _write=env._write;
+ var ___errno_location=env.___errno_location;
+ var tempFloat = 0.0;
+
+// EMSCRIPTEN_START_FUNCS
+function _malloc(i12) {
+ i12 = i12 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0;
+ i1 = STACKTOP;
+ do {
+ if (i12 >>> 0 < 245) {
+ if (i12 >>> 0 < 11) {
+ i12 = 16;
+ } else {
+ i12 = i12 + 11 & -8;
+ }
+ i20 = i12 >>> 3;
+ i18 = HEAP32[14] | 0;
+ i21 = i18 >>> i20;
+ if ((i21 & 3 | 0) != 0) {
+ i6 = (i21 & 1 ^ 1) + i20 | 0;
+ i5 = i6 << 1;
+ i3 = 96 + (i5 << 2) | 0;
+ i5 = 96 + (i5 + 2 << 2) | 0;
+ i7 = HEAP32[i5 >> 2] | 0;
+ i2 = i7 + 8 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ do {
+ if ((i3 | 0) != (i4 | 0)) {
+ if (i4 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i4 + 12 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i7 | 0)) {
+ HEAP32[i8 >> 2] = i3;
+ HEAP32[i5 >> 2] = i4;
+ break;
+ } else {
+ _abort();
+ }
+ } else {
+ HEAP32[14] = i18 & ~(1 << i6);
+ }
+ } while (0);
+ i32 = i6 << 3;
+ HEAP32[i7 + 4 >> 2] = i32 | 3;
+ i32 = i7 + (i32 | 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ i32 = i2;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ if (i12 >>> 0 > (HEAP32[64 >> 2] | 0) >>> 0) {
+ if ((i21 | 0) != 0) {
+ i7 = 2 << i20;
+ i7 = i21 << i20 & (i7 | 0 - i7);
+ i7 = (i7 & 0 - i7) + -1 | 0;
+ i2 = i7 >>> 12 & 16;
+ i7 = i7 >>> i2;
+ i6 = i7 >>> 5 & 8;
+ i7 = i7 >>> i6;
+ i5 = i7 >>> 2 & 4;
+ i7 = i7 >>> i5;
+ i4 = i7 >>> 1 & 2;
+ i7 = i7 >>> i4;
+ i3 = i7 >>> 1 & 1;
+ i3 = (i6 | i2 | i5 | i4 | i3) + (i7 >>> i3) | 0;
+ i7 = i3 << 1;
+ i4 = 96 + (i7 << 2) | 0;
+ i7 = 96 + (i7 + 2 << 2) | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ i2 = i5 + 8 | 0;
+ i6 = HEAP32[i2 >> 2] | 0;
+ do {
+ if ((i4 | 0) != (i6 | 0)) {
+ if (i6 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i6 + 12 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i5 | 0)) {
+ HEAP32[i8 >> 2] = i4;
+ HEAP32[i7 >> 2] = i6;
+ break;
+ } else {
+ _abort();
+ }
+ } else {
+ HEAP32[14] = i18 & ~(1 << i3);
+ }
+ } while (0);
+ i6 = i3 << 3;
+ i4 = i6 - i12 | 0;
+ HEAP32[i5 + 4 >> 2] = i12 | 3;
+ i3 = i5 + i12 | 0;
+ HEAP32[i5 + (i12 | 4) >> 2] = i4 | 1;
+ HEAP32[i5 + i6 >> 2] = i4;
+ i6 = HEAP32[64 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i5 = HEAP32[76 >> 2] | 0;
+ i8 = i6 >>> 3;
+ i9 = i8 << 1;
+ i6 = 96 + (i9 << 2) | 0;
+ i7 = HEAP32[14] | 0;
+ i8 = 1 << i8;
+ if ((i7 & i8 | 0) != 0) {
+ i7 = 96 + (i9 + 2 << 2) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i28 = i7;
+ i27 = i8;
+ }
+ } else {
+ HEAP32[14] = i7 | i8;
+ i28 = 96 + (i9 + 2 << 2) | 0;
+ i27 = i6;
+ }
+ HEAP32[i28 >> 2] = i5;
+ HEAP32[i27 + 12 >> 2] = i5;
+ HEAP32[i5 + 8 >> 2] = i27;
+ HEAP32[i5 + 12 >> 2] = i6;
+ }
+ HEAP32[64 >> 2] = i4;
+ HEAP32[76 >> 2] = i3;
+ i32 = i2;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i18 = HEAP32[60 >> 2] | 0;
+ if ((i18 | 0) != 0) {
+ i2 = (i18 & 0 - i18) + -1 | 0;
+ i31 = i2 >>> 12 & 16;
+ i2 = i2 >>> i31;
+ i30 = i2 >>> 5 & 8;
+ i2 = i2 >>> i30;
+ i32 = i2 >>> 2 & 4;
+ i2 = i2 >>> i32;
+ i6 = i2 >>> 1 & 2;
+ i2 = i2 >>> i6;
+ i3 = i2 >>> 1 & 1;
+ i3 = HEAP32[360 + ((i30 | i31 | i32 | i6 | i3) + (i2 >>> i3) << 2) >> 2] | 0;
+ i2 = (HEAP32[i3 + 4 >> 2] & -8) - i12 | 0;
+ i6 = i3;
+ while (1) {
+ i5 = HEAP32[i6 + 16 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i5 = HEAP32[i6 + 20 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ }
+ i6 = (HEAP32[i5 + 4 >> 2] & -8) - i12 | 0;
+ i4 = i6 >>> 0 < i2 >>> 0;
+ i2 = i4 ? i6 : i2;
+ i6 = i5;
+ i3 = i4 ? i5 : i3;
+ }
+ i6 = HEAP32[72 >> 2] | 0;
+ if (i3 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ i4 = i3 + i12 | 0;
+ if (!(i3 >>> 0 < i4 >>> 0)) {
+ _abort();
+ }
+ i5 = HEAP32[i3 + 24 >> 2] | 0;
+ i7 = HEAP32[i3 + 12 >> 2] | 0;
+ do {
+ if ((i7 | 0) == (i3 | 0)) {
+ i8 = i3 + 20 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i8 = i3 + 16 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i26 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i10 = i7 + 20 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ i7 = i9;
+ i8 = i10;
+ continue;
+ }
+ i10 = i7 + 16 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ } else {
+ i7 = i9;
+ i8 = i10;
+ }
+ }
+ if (i8 >>> 0 < i6 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i8 >> 2] = 0;
+ i26 = i7;
+ break;
+ }
+ } else {
+ i8 = HEAP32[i3 + 8 >> 2] | 0;
+ if (i8 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ i6 = i8 + 12 | 0;
+ if ((HEAP32[i6 >> 2] | 0) != (i3 | 0)) {
+ _abort();
+ }
+ i9 = i7 + 8 | 0;
+ if ((HEAP32[i9 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i6 >> 2] = i7;
+ HEAP32[i9 >> 2] = i8;
+ i26 = i7;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ do {
+ if ((i5 | 0) != 0) {
+ i7 = HEAP32[i3 + 28 >> 2] | 0;
+ i6 = 360 + (i7 << 2) | 0;
+ if ((i3 | 0) == (HEAP32[i6 >> 2] | 0)) {
+ HEAP32[i6 >> 2] = i26;
+ if ((i26 | 0) == 0) {
+ HEAP32[60 >> 2] = HEAP32[60 >> 2] & ~(1 << i7);
+ break;
+ }
+ } else {
+ if (i5 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i6 = i5 + 16 | 0;
+ if ((HEAP32[i6 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i6 >> 2] = i26;
+ } else {
+ HEAP32[i5 + 20 >> 2] = i26;
+ }
+ if ((i26 | 0) == 0) {
+ break;
+ }
+ }
+ if (i26 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i26 + 24 >> 2] = i5;
+ i5 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i26 + 16 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i26;
+ break;
+ }
+ }
+ } while (0);
+ i5 = HEAP32[i3 + 20 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i26 + 20 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i26;
+ break;
+ }
+ }
+ }
+ } while (0);
+ if (i2 >>> 0 < 16) {
+ i32 = i2 + i12 | 0;
+ HEAP32[i3 + 4 >> 2] = i32 | 3;
+ i32 = i3 + (i32 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ } else {
+ HEAP32[i3 + 4 >> 2] = i12 | 3;
+ HEAP32[i3 + (i12 | 4) >> 2] = i2 | 1;
+ HEAP32[i3 + (i2 + i12) >> 2] = i2;
+ i6 = HEAP32[64 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i5 = HEAP32[76 >> 2] | 0;
+ i8 = i6 >>> 3;
+ i9 = i8 << 1;
+ i6 = 96 + (i9 << 2) | 0;
+ i7 = HEAP32[14] | 0;
+ i8 = 1 << i8;
+ if ((i7 & i8 | 0) != 0) {
+ i7 = 96 + (i9 + 2 << 2) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i25 = i7;
+ i24 = i8;
+ }
+ } else {
+ HEAP32[14] = i7 | i8;
+ i25 = 96 + (i9 + 2 << 2) | 0;
+ i24 = i6;
+ }
+ HEAP32[i25 >> 2] = i5;
+ HEAP32[i24 + 12 >> 2] = i5;
+ HEAP32[i5 + 8 >> 2] = i24;
+ HEAP32[i5 + 12 >> 2] = i6;
+ }
+ HEAP32[64 >> 2] = i2;
+ HEAP32[76 >> 2] = i4;
+ }
+ i32 = i3 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ } else {
+ if (!(i12 >>> 0 > 4294967231)) {
+ i24 = i12 + 11 | 0;
+ i12 = i24 & -8;
+ i26 = HEAP32[60 >> 2] | 0;
+ if ((i26 | 0) != 0) {
+ i25 = 0 - i12 | 0;
+ i24 = i24 >>> 8;
+ if ((i24 | 0) != 0) {
+ if (i12 >>> 0 > 16777215) {
+ i27 = 31;
+ } else {
+ i31 = (i24 + 1048320 | 0) >>> 16 & 8;
+ i32 = i24 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i27 = (i32 + 245760 | 0) >>> 16 & 2;
+ i27 = 14 - (i30 | i31 | i27) + (i32 << i27 >>> 15) | 0;
+ i27 = i12 >>> (i27 + 7 | 0) & 1 | i27 << 1;
+ }
+ } else {
+ i27 = 0;
+ }
+ i30 = HEAP32[360 + (i27 << 2) >> 2] | 0;
+ L126 : do {
+ if ((i30 | 0) == 0) {
+ i29 = 0;
+ i24 = 0;
+ } else {
+ if ((i27 | 0) == 31) {
+ i24 = 0;
+ } else {
+ i24 = 25 - (i27 >>> 1) | 0;
+ }
+ i29 = 0;
+ i28 = i12 << i24;
+ i24 = 0;
+ while (1) {
+ i32 = HEAP32[i30 + 4 >> 2] & -8;
+ i31 = i32 - i12 | 0;
+ if (i31 >>> 0 < i25 >>> 0) {
+ if ((i32 | 0) == (i12 | 0)) {
+ i25 = i31;
+ i29 = i30;
+ i24 = i30;
+ break L126;
+ } else {
+ i25 = i31;
+ i24 = i30;
+ }
+ }
+ i31 = HEAP32[i30 + 20 >> 2] | 0;
+ i30 = HEAP32[i30 + (i28 >>> 31 << 2) + 16 >> 2] | 0;
+ i29 = (i31 | 0) == 0 | (i31 | 0) == (i30 | 0) ? i29 : i31;
+ if ((i30 | 0) == 0) {
+ break;
+ } else {
+ i28 = i28 << 1;
+ }
+ }
+ }
+ } while (0);
+ if ((i29 | 0) == 0 & (i24 | 0) == 0) {
+ i32 = 2 << i27;
+ i26 = i26 & (i32 | 0 - i32);
+ if ((i26 | 0) == 0) {
+ break;
+ }
+ i32 = (i26 & 0 - i26) + -1 | 0;
+ i28 = i32 >>> 12 & 16;
+ i32 = i32 >>> i28;
+ i27 = i32 >>> 5 & 8;
+ i32 = i32 >>> i27;
+ i30 = i32 >>> 2 & 4;
+ i32 = i32 >>> i30;
+ i31 = i32 >>> 1 & 2;
+ i32 = i32 >>> i31;
+ i29 = i32 >>> 1 & 1;
+ i29 = HEAP32[360 + ((i27 | i28 | i30 | i31 | i29) + (i32 >>> i29) << 2) >> 2] | 0;
+ }
+ if ((i29 | 0) != 0) {
+ while (1) {
+ i27 = (HEAP32[i29 + 4 >> 2] & -8) - i12 | 0;
+ i26 = i27 >>> 0 < i25 >>> 0;
+ i25 = i26 ? i27 : i25;
+ i24 = i26 ? i29 : i24;
+ i26 = HEAP32[i29 + 16 >> 2] | 0;
+ if ((i26 | 0) != 0) {
+ i29 = i26;
+ continue;
+ }
+ i29 = HEAP32[i29 + 20 >> 2] | 0;
+ if ((i29 | 0) == 0) {
+ break;
+ }
+ }
+ }
+ if ((i24 | 0) != 0 ? i25 >>> 0 < ((HEAP32[64 >> 2] | 0) - i12 | 0) >>> 0 : 0) {
+ i4 = HEAP32[72 >> 2] | 0;
+ if (i24 >>> 0 < i4 >>> 0) {
+ _abort();
+ }
+ i2 = i24 + i12 | 0;
+ if (!(i24 >>> 0 < i2 >>> 0)) {
+ _abort();
+ }
+ i3 = HEAP32[i24 + 24 >> 2] | 0;
+ i6 = HEAP32[i24 + 12 >> 2] | 0;
+ do {
+ if ((i6 | 0) == (i24 | 0)) {
+ i6 = i24 + 20 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i6 = i24 + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i22 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i8 = i5 + 20 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) != 0) {
+ i5 = i7;
+ i6 = i8;
+ continue;
+ }
+ i7 = i5 + 16 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if ((i8 | 0) == 0) {
+ break;
+ } else {
+ i5 = i8;
+ i6 = i7;
+ }
+ }
+ if (i6 >>> 0 < i4 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = 0;
+ i22 = i5;
+ break;
+ }
+ } else {
+ i5 = HEAP32[i24 + 8 >> 2] | 0;
+ if (i5 >>> 0 < i4 >>> 0) {
+ _abort();
+ }
+ i7 = i5 + 12 | 0;
+ if ((HEAP32[i7 >> 2] | 0) != (i24 | 0)) {
+ _abort();
+ }
+ i4 = i6 + 8 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
+ HEAP32[i7 >> 2] = i6;
+ HEAP32[i4 >> 2] = i5;
+ i22 = i6;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ do {
+ if ((i3 | 0) != 0) {
+ i4 = HEAP32[i24 + 28 >> 2] | 0;
+ i5 = 360 + (i4 << 2) | 0;
+ if ((i24 | 0) == (HEAP32[i5 >> 2] | 0)) {
+ HEAP32[i5 >> 2] = i22;
+ if ((i22 | 0) == 0) {
+ HEAP32[60 >> 2] = HEAP32[60 >> 2] & ~(1 << i4);
+ break;
+ }
+ } else {
+ if (i3 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i4 = i3 + 16 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
+ HEAP32[i4 >> 2] = i22;
+ } else {
+ HEAP32[i3 + 20 >> 2] = i22;
+ }
+ if ((i22 | 0) == 0) {
+ break;
+ }
+ }
+ if (i22 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i22 + 24 >> 2] = i3;
+ i3 = HEAP32[i24 + 16 >> 2] | 0;
+ do {
+ if ((i3 | 0) != 0) {
+ if (i3 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i22 + 16 >> 2] = i3;
+ HEAP32[i3 + 24 >> 2] = i22;
+ break;
+ }
+ }
+ } while (0);
+ i3 = HEAP32[i24 + 20 >> 2] | 0;
+ if ((i3 | 0) != 0) {
+ if (i3 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i22 + 20 >> 2] = i3;
+ HEAP32[i3 + 24 >> 2] = i22;
+ break;
+ }
+ }
+ }
+ } while (0);
+ L204 : do {
+ if (!(i25 >>> 0 < 16)) {
+ HEAP32[i24 + 4 >> 2] = i12 | 3;
+ HEAP32[i24 + (i12 | 4) >> 2] = i25 | 1;
+ HEAP32[i24 + (i25 + i12) >> 2] = i25;
+ i4 = i25 >>> 3;
+ if (i25 >>> 0 < 256) {
+ i6 = i4 << 1;
+ i3 = 96 + (i6 << 2) | 0;
+ i5 = HEAP32[14] | 0;
+ i4 = 1 << i4;
+ if ((i5 & i4 | 0) != 0) {
+ i5 = 96 + (i6 + 2 << 2) | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ if (i4 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i21 = i5;
+ i20 = i4;
+ }
+ } else {
+ HEAP32[14] = i5 | i4;
+ i21 = 96 + (i6 + 2 << 2) | 0;
+ i20 = i3;
+ }
+ HEAP32[i21 >> 2] = i2;
+ HEAP32[i20 + 12 >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i20;
+ HEAP32[i24 + (i12 + 12) >> 2] = i3;
+ break;
+ }
+ i3 = i25 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i25 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i25 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i6 = 360 + (i3 << 2) | 0;
+ HEAP32[i24 + (i12 + 28) >> 2] = i3;
+ HEAP32[i24 + (i12 + 20) >> 2] = 0;
+ HEAP32[i24 + (i12 + 16) >> 2] = 0;
+ i4 = HEAP32[60 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i4 & i5 | 0) == 0) {
+ HEAP32[60 >> 2] = i4 | i5;
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i24 + (i12 + 24) >> 2] = i6;
+ HEAP32[i24 + (i12 + 12) >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i2;
+ break;
+ }
+ i4 = HEAP32[i6 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L225 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i25 | 0)) {
+ i3 = i25 << i3;
+ while (1) {
+ i6 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i25 | 0)) {
+ i18 = i5;
+ break L225;
+ } else {
+ i3 = i3 << 1;
+ i4 = i5;
+ }
+ }
+ if (i6 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i24 + (i12 + 24) >> 2] = i4;
+ HEAP32[i24 + (i12 + 12) >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i2;
+ break L204;
+ }
+ } else {
+ i18 = i4;
+ }
+ } while (0);
+ i4 = i18 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[72 >> 2] | 0;
+ if (i18 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i2;
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i3;
+ HEAP32[i24 + (i12 + 12) >> 2] = i18;
+ HEAP32[i24 + (i12 + 24) >> 2] = 0;
+ break;
+ }
+ } else {
+ i32 = i25 + i12 | 0;
+ HEAP32[i24 + 4 >> 2] = i32 | 3;
+ i32 = i24 + (i32 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ }
+ } while (0);
+ i32 = i24 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ } else {
+ i12 = -1;
+ }
+ }
+ } while (0);
+ i18 = HEAP32[64 >> 2] | 0;
+ if (!(i12 >>> 0 > i18 >>> 0)) {
+ i3 = i18 - i12 | 0;
+ i2 = HEAP32[76 >> 2] | 0;
+ if (i3 >>> 0 > 15) {
+ HEAP32[76 >> 2] = i2 + i12;
+ HEAP32[64 >> 2] = i3;
+ HEAP32[i2 + (i12 + 4) >> 2] = i3 | 1;
+ HEAP32[i2 + i18 >> 2] = i3;
+ HEAP32[i2 + 4 >> 2] = i12 | 3;
+ } else {
+ HEAP32[64 >> 2] = 0;
+ HEAP32[76 >> 2] = 0;
+ HEAP32[i2 + 4 >> 2] = i18 | 3;
+ i32 = i2 + (i18 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ }
+ i32 = i2 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i18 = HEAP32[68 >> 2] | 0;
+ if (i12 >>> 0 < i18 >>> 0) {
+ i31 = i18 - i12 | 0;
+ HEAP32[68 >> 2] = i31;
+ i32 = HEAP32[80 >> 2] | 0;
+ HEAP32[80 >> 2] = i32 + i12;
+ HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
+ HEAP32[i32 + 4 >> 2] = i12 | 3;
+ i32 = i32 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ do {
+ if ((HEAP32[132] | 0) == 0) {
+ i18 = _sysconf(30) | 0;
+ if ((i18 + -1 & i18 | 0) == 0) {
+ HEAP32[536 >> 2] = i18;
+ HEAP32[532 >> 2] = i18;
+ HEAP32[540 >> 2] = -1;
+ HEAP32[544 >> 2] = -1;
+ HEAP32[548 >> 2] = 0;
+ HEAP32[500 >> 2] = 0;
+ HEAP32[132] = (_time(0) | 0) & -16 ^ 1431655768;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ i20 = i12 + 48 | 0;
+ i25 = HEAP32[536 >> 2] | 0;
+ i21 = i12 + 47 | 0;
+ i22 = i25 + i21 | 0;
+ i25 = 0 - i25 | 0;
+ i18 = i22 & i25;
+ if (!(i18 >>> 0 > i12 >>> 0)) {
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i24 = HEAP32[496 >> 2] | 0;
+ if ((i24 | 0) != 0 ? (i31 = HEAP32[488 >> 2] | 0, i32 = i31 + i18 | 0, i32 >>> 0 <= i31 >>> 0 | i32 >>> 0 > i24 >>> 0) : 0) {
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ L269 : do {
+ if ((HEAP32[500 >> 2] & 4 | 0) == 0) {
+ i26 = HEAP32[80 >> 2] | 0;
+ L271 : do {
+ if ((i26 | 0) != 0) {
+ i24 = 504 | 0;
+ while (1) {
+ i27 = HEAP32[i24 >> 2] | 0;
+ if (!(i27 >>> 0 > i26 >>> 0) ? (i23 = i24 + 4 | 0, (i27 + (HEAP32[i23 >> 2] | 0) | 0) >>> 0 > i26 >>> 0) : 0) {
+ break;
+ }
+ i24 = HEAP32[i24 + 8 >> 2] | 0;
+ if ((i24 | 0) == 0) {
+ i13 = 182;
+ break L271;
+ }
+ }
+ if ((i24 | 0) != 0) {
+ i25 = i22 - (HEAP32[68 >> 2] | 0) & i25;
+ if (i25 >>> 0 < 2147483647) {
+ i13 = _sbrk(i25 | 0) | 0;
+ i26 = (i13 | 0) == ((HEAP32[i24 >> 2] | 0) + (HEAP32[i23 >> 2] | 0) | 0);
+ i22 = i13;
+ i24 = i25;
+ i23 = i26 ? i13 : -1;
+ i25 = i26 ? i25 : 0;
+ i13 = 191;
+ } else {
+ i25 = 0;
+ }
+ } else {
+ i13 = 182;
+ }
+ } else {
+ i13 = 182;
+ }
+ } while (0);
+ do {
+ if ((i13 | 0) == 182) {
+ i23 = _sbrk(0) | 0;
+ if ((i23 | 0) != (-1 | 0)) {
+ i24 = i23;
+ i22 = HEAP32[532 >> 2] | 0;
+ i25 = i22 + -1 | 0;
+ if ((i25 & i24 | 0) == 0) {
+ i25 = i18;
+ } else {
+ i25 = i18 - i24 + (i25 + i24 & 0 - i22) | 0;
+ }
+ i24 = HEAP32[488 >> 2] | 0;
+ i26 = i24 + i25 | 0;
+ if (i25 >>> 0 > i12 >>> 0 & i25 >>> 0 < 2147483647) {
+ i22 = HEAP32[496 >> 2] | 0;
+ if ((i22 | 0) != 0 ? i26 >>> 0 <= i24 >>> 0 | i26 >>> 0 > i22 >>> 0 : 0) {
+ i25 = 0;
+ break;
+ }
+ i22 = _sbrk(i25 | 0) | 0;
+ i13 = (i22 | 0) == (i23 | 0);
+ i24 = i25;
+ i23 = i13 ? i23 : -1;
+ i25 = i13 ? i25 : 0;
+ i13 = 191;
+ } else {
+ i25 = 0;
+ }
+ } else {
+ i25 = 0;
+ }
+ }
+ } while (0);
+ L291 : do {
+ if ((i13 | 0) == 191) {
+ i13 = 0 - i24 | 0;
+ if ((i23 | 0) != (-1 | 0)) {
+ i17 = i23;
+ i14 = i25;
+ i13 = 202;
+ break L269;
+ }
+ do {
+ if ((i22 | 0) != (-1 | 0) & i24 >>> 0 < 2147483647 & i24 >>> 0 < i20 >>> 0 ? (i19 = HEAP32[536 >> 2] | 0, i19 = i21 - i24 + i19 & 0 - i19, i19 >>> 0 < 2147483647) : 0) {
+ if ((_sbrk(i19 | 0) | 0) == (-1 | 0)) {
+ _sbrk(i13 | 0) | 0;
+ break L291;
+ } else {
+ i24 = i19 + i24 | 0;
+ break;
+ }
+ }
+ } while (0);
+ if ((i22 | 0) != (-1 | 0)) {
+ i17 = i22;
+ i14 = i24;
+ i13 = 202;
+ break L269;
+ }
+ }
+ } while (0);
+ HEAP32[500 >> 2] = HEAP32[500 >> 2] | 4;
+ i13 = 199;
+ } else {
+ i25 = 0;
+ i13 = 199;
+ }
+ } while (0);
+ if ((((i13 | 0) == 199 ? i18 >>> 0 < 2147483647 : 0) ? (i17 = _sbrk(i18 | 0) | 0, i16 = _sbrk(0) | 0, (i16 | 0) != (-1 | 0) & (i17 | 0) != (-1 | 0) & i17 >>> 0 < i16 >>> 0) : 0) ? (i15 = i16 - i17 | 0, i14 = i15 >>> 0 > (i12 + 40 | 0) >>> 0, i14) : 0) {
+ i14 = i14 ? i15 : i25;
+ i13 = 202;
+ }
+ if ((i13 | 0) == 202) {
+ i15 = (HEAP32[488 >> 2] | 0) + i14 | 0;
+ HEAP32[488 >> 2] = i15;
+ if (i15 >>> 0 > (HEAP32[492 >> 2] | 0) >>> 0) {
+ HEAP32[492 >> 2] = i15;
+ }
+ i15 = HEAP32[80 >> 2] | 0;
+ L311 : do {
+ if ((i15 | 0) != 0) {
+ i21 = 504 | 0;
+ while (1) {
+ i16 = HEAP32[i21 >> 2] | 0;
+ i19 = i21 + 4 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i17 | 0) == (i16 + i20 | 0)) {
+ i13 = 214;
+ break;
+ }
+ i18 = HEAP32[i21 + 8 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ break;
+ } else {
+ i21 = i18;
+ }
+ }
+ if (((i13 | 0) == 214 ? (HEAP32[i21 + 12 >> 2] & 8 | 0) == 0 : 0) ? i15 >>> 0 >= i16 >>> 0 & i15 >>> 0 < i17 >>> 0 : 0) {
+ HEAP32[i19 >> 2] = i20 + i14;
+ i2 = (HEAP32[68 >> 2] | 0) + i14 | 0;
+ i3 = i15 + 8 | 0;
+ if ((i3 & 7 | 0) == 0) {
+ i3 = 0;
+ } else {
+ i3 = 0 - i3 & 7;
+ }
+ i32 = i2 - i3 | 0;
+ HEAP32[80 >> 2] = i15 + i3;
+ HEAP32[68 >> 2] = i32;
+ HEAP32[i15 + (i3 + 4) >> 2] = i32 | 1;
+ HEAP32[i15 + (i2 + 4) >> 2] = 40;
+ HEAP32[84 >> 2] = HEAP32[544 >> 2];
+ break;
+ }
+ if (i17 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ HEAP32[72 >> 2] = i17;
+ }
+ i19 = i17 + i14 | 0;
+ i16 = 504 | 0;
+ while (1) {
+ if ((HEAP32[i16 >> 2] | 0) == (i19 | 0)) {
+ i13 = 224;
+ break;
+ }
+ i18 = HEAP32[i16 + 8 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ break;
+ } else {
+ i16 = i18;
+ }
+ }
+ if ((i13 | 0) == 224 ? (HEAP32[i16 + 12 >> 2] & 8 | 0) == 0 : 0) {
+ HEAP32[i16 >> 2] = i17;
+ i6 = i16 + 4 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + i14;
+ i6 = i17 + 8 | 0;
+ if ((i6 & 7 | 0) == 0) {
+ i6 = 0;
+ } else {
+ i6 = 0 - i6 & 7;
+ }
+ i7 = i17 + (i14 + 8) | 0;
+ if ((i7 & 7 | 0) == 0) {
+ i13 = 0;
+ } else {
+ i13 = 0 - i7 & 7;
+ }
+ i15 = i17 + (i13 + i14) | 0;
+ i8 = i6 + i12 | 0;
+ i7 = i17 + i8 | 0;
+ i10 = i15 - (i17 + i6) - i12 | 0;
+ HEAP32[i17 + (i6 + 4) >> 2] = i12 | 3;
+ L348 : do {
+ if ((i15 | 0) != (HEAP32[80 >> 2] | 0)) {
+ if ((i15 | 0) == (HEAP32[76 >> 2] | 0)) {
+ i32 = (HEAP32[64 >> 2] | 0) + i10 | 0;
+ HEAP32[64 >> 2] = i32;
+ HEAP32[76 >> 2] = i7;
+ HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i32 + i8) >> 2] = i32;
+ break;
+ }
+ i12 = i14 + 4 | 0;
+ i18 = HEAP32[i17 + (i12 + i13) >> 2] | 0;
+ if ((i18 & 3 | 0) == 1) {
+ i11 = i18 & -8;
+ i16 = i18 >>> 3;
+ do {
+ if (!(i18 >>> 0 < 256)) {
+ i9 = HEAP32[i17 + ((i13 | 24) + i14) >> 2] | 0;
+ i19 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
+ do {
+ if ((i19 | 0) == (i15 | 0)) {
+ i19 = i13 | 16;
+ i18 = i17 + (i12 + i19) | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ if ((i16 | 0) == 0) {
+ i18 = i17 + (i19 + i14) | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ if ((i16 | 0) == 0) {
+ i5 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i20 = i16 + 20 | 0;
+ i19 = HEAP32[i20 >> 2] | 0;
+ if ((i19 | 0) != 0) {
+ i16 = i19;
+ i18 = i20;
+ continue;
+ }
+ i19 = i16 + 16 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i20 | 0) == 0) {
+ break;
+ } else {
+ i16 = i20;
+ i18 = i19;
+ }
+ }
+ if (i18 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i18 >> 2] = 0;
+ i5 = i16;
+ break;
+ }
+ } else {
+ i18 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
+ if (i18 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i18 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != (i15 | 0)) {
+ _abort();
+ }
+ i20 = i19 + 8 | 0;
+ if ((HEAP32[i20 >> 2] | 0) == (i15 | 0)) {
+ HEAP32[i16 >> 2] = i19;
+ HEAP32[i20 >> 2] = i18;
+ i5 = i19;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i9 | 0) != 0) {
+ i16 = HEAP32[i17 + (i14 + 28 + i13) >> 2] | 0;
+ i18 = 360 + (i16 << 2) | 0;
+ if ((i15 | 0) == (HEAP32[i18 >> 2] | 0)) {
+ HEAP32[i18 >> 2] = i5;
+ if ((i5 | 0) == 0) {
+ HEAP32[60 >> 2] = HEAP32[60 >> 2] & ~(1 << i16);
+ break;
+ }
+ } else {
+ if (i9 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i9 + 16 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
+ HEAP32[i16 >> 2] = i5;
+ } else {
+ HEAP32[i9 + 20 >> 2] = i5;
+ }
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i5 + 24 >> 2] = i9;
+ i15 = i13 | 16;
+ i9 = HEAP32[i17 + (i15 + i14) >> 2] | 0;
+ do {
+ if ((i9 | 0) != 0) {
+ if (i9 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 + 16 >> 2] = i9;
+ HEAP32[i9 + 24 >> 2] = i5;
+ break;
+ }
+ }
+ } while (0);
+ i9 = HEAP32[i17 + (i12 + i15) >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ if (i9 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 + 20 >> 2] = i9;
+ HEAP32[i9 + 24 >> 2] = i5;
+ break;
+ }
+ }
+ }
+ } else {
+ i5 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
+ i12 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
+ i18 = 96 + (i16 << 1 << 2) | 0;
+ if ((i5 | 0) != (i18 | 0)) {
+ if (i5 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i5 + 12 >> 2] | 0) != (i15 | 0)) {
+ _abort();
+ }
+ }
+ if ((i12 | 0) == (i5 | 0)) {
+ HEAP32[14] = HEAP32[14] & ~(1 << i16);
+ break;
+ }
+ if ((i12 | 0) != (i18 | 0)) {
+ if (i12 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i12 + 8 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
+ i9 = i16;
+ } else {
+ _abort();
+ }
+ } else {
+ i9 = i12 + 8 | 0;
+ }
+ HEAP32[i5 + 12 >> 2] = i12;
+ HEAP32[i9 >> 2] = i5;
+ }
+ } while (0);
+ i15 = i17 + ((i11 | i13) + i14) | 0;
+ i10 = i11 + i10 | 0;
+ }
+ i5 = i15 + 4 | 0;
+ HEAP32[i5 >> 2] = HEAP32[i5 >> 2] & -2;
+ HEAP32[i17 + (i8 + 4) >> 2] = i10 | 1;
+ HEAP32[i17 + (i10 + i8) >> 2] = i10;
+ i5 = i10 >>> 3;
+ if (i10 >>> 0 < 256) {
+ i10 = i5 << 1;
+ i2 = 96 + (i10 << 2) | 0;
+ i9 = HEAP32[14] | 0;
+ i5 = 1 << i5;
+ if ((i9 & i5 | 0) != 0) {
+ i9 = 96 + (i10 + 2 << 2) | 0;
+ i5 = HEAP32[i9 >> 2] | 0;
+ if (i5 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i3 = i9;
+ i4 = i5;
+ }
+ } else {
+ HEAP32[14] = i9 | i5;
+ i3 = 96 + (i10 + 2 << 2) | 0;
+ i4 = i2;
+ }
+ HEAP32[i3 >> 2] = i7;
+ HEAP32[i4 + 12 >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i2;
+ break;
+ }
+ i3 = i10 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i10 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i10 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i4 = 360 + (i3 << 2) | 0;
+ HEAP32[i17 + (i8 + 28) >> 2] = i3;
+ HEAP32[i17 + (i8 + 20) >> 2] = 0;
+ HEAP32[i17 + (i8 + 16) >> 2] = 0;
+ i9 = HEAP32[60 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i9 & i5 | 0) == 0) {
+ HEAP32[60 >> 2] = i9 | i5;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i17 + (i8 + 24) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i7;
+ break;
+ }
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L444 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i10 | 0)) {
+ i3 = i10 << i3;
+ while (1) {
+ i5 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i9 = HEAP32[i5 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i9 + 4 >> 2] & -8 | 0) == (i10 | 0)) {
+ i2 = i9;
+ break L444;
+ } else {
+ i3 = i3 << 1;
+ i4 = i9;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 >> 2] = i7;
+ HEAP32[i17 + (i8 + 24) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i7;
+ break L348;
+ }
+ } else {
+ i2 = i4;
+ }
+ } while (0);
+ i4 = i2 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[72 >> 2] | 0;
+ if (i2 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i7;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i3;
+ HEAP32[i17 + (i8 + 12) >> 2] = i2;
+ HEAP32[i17 + (i8 + 24) >> 2] = 0;
+ break;
+ }
+ } else {
+ i32 = (HEAP32[68 >> 2] | 0) + i10 | 0;
+ HEAP32[68 >> 2] = i32;
+ HEAP32[80 >> 2] = i7;
+ HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
+ }
+ } while (0);
+ i32 = i17 + (i6 | 8) | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i3 = 504 | 0;
+ while (1) {
+ i2 = HEAP32[i3 >> 2] | 0;
+ if (!(i2 >>> 0 > i15 >>> 0) ? (i11 = HEAP32[i3 + 4 >> 2] | 0, i10 = i2 + i11 | 0, i10 >>> 0 > i15 >>> 0) : 0) {
+ break;
+ }
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ }
+ i3 = i2 + (i11 + -39) | 0;
+ if ((i3 & 7 | 0) == 0) {
+ i3 = 0;
+ } else {
+ i3 = 0 - i3 & 7;
+ }
+ i2 = i2 + (i11 + -47 + i3) | 0;
+ i2 = i2 >>> 0 < (i15 + 16 | 0) >>> 0 ? i15 : i2;
+ i3 = i2 + 8 | 0;
+ i4 = i17 + 8 | 0;
+ if ((i4 & 7 | 0) == 0) {
+ i4 = 0;
+ } else {
+ i4 = 0 - i4 & 7;
+ }
+ i32 = i14 + -40 - i4 | 0;
+ HEAP32[80 >> 2] = i17 + i4;
+ HEAP32[68 >> 2] = i32;
+ HEAP32[i17 + (i4 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i14 + -36) >> 2] = 40;
+ HEAP32[84 >> 2] = HEAP32[544 >> 2];
+ HEAP32[i2 + 4 >> 2] = 27;
+ HEAP32[i3 + 0 >> 2] = HEAP32[504 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[508 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[512 >> 2];
+ HEAP32[i3 + 12 >> 2] = HEAP32[516 >> 2];
+ HEAP32[504 >> 2] = i17;
+ HEAP32[508 >> 2] = i14;
+ HEAP32[516 >> 2] = 0;
+ HEAP32[512 >> 2] = i3;
+ i4 = i2 + 28 | 0;
+ HEAP32[i4 >> 2] = 7;
+ if ((i2 + 32 | 0) >>> 0 < i10 >>> 0) {
+ while (1) {
+ i3 = i4 + 4 | 0;
+ HEAP32[i3 >> 2] = 7;
+ if ((i4 + 8 | 0) >>> 0 < i10 >>> 0) {
+ i4 = i3;
+ } else {
+ break;
+ }
+ }
+ }
+ if ((i2 | 0) != (i15 | 0)) {
+ i2 = i2 - i15 | 0;
+ i3 = i15 + (i2 + 4) | 0;
+ HEAP32[i3 >> 2] = HEAP32[i3 >> 2] & -2;
+ HEAP32[i15 + 4 >> 2] = i2 | 1;
+ HEAP32[i15 + i2 >> 2] = i2;
+ i3 = i2 >>> 3;
+ if (i2 >>> 0 < 256) {
+ i4 = i3 << 1;
+ i2 = 96 + (i4 << 2) | 0;
+ i5 = HEAP32[14] | 0;
+ i3 = 1 << i3;
+ if ((i5 & i3 | 0) != 0) {
+ i4 = 96 + (i4 + 2 << 2) | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ if (i3 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i7 = i4;
+ i8 = i3;
+ }
+ } else {
+ HEAP32[14] = i5 | i3;
+ i7 = 96 + (i4 + 2 << 2) | 0;
+ i8 = i2;
+ }
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i8 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i8;
+ HEAP32[i15 + 12 >> 2] = i2;
+ break;
+ }
+ i3 = i2 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i2 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i2 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i7 = 360 + (i3 << 2) | 0;
+ HEAP32[i15 + 28 >> 2] = i3;
+ HEAP32[i15 + 20 >> 2] = 0;
+ HEAP32[i15 + 16 >> 2] = 0;
+ i4 = HEAP32[60 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i4 & i5 | 0) == 0) {
+ HEAP32[60 >> 2] = i4 | i5;
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i7;
+ HEAP32[i15 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i15;
+ break;
+ }
+ i4 = HEAP32[i7 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L499 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i2 | 0)) {
+ i3 = i2 << i3;
+ while (1) {
+ i7 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i2 | 0)) {
+ i6 = i5;
+ break L499;
+ } else {
+ i3 = i3 << 1;
+ i4 = i5;
+ }
+ }
+ if (i7 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i4;
+ HEAP32[i15 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i15;
+ break L311;
+ }
+ } else {
+ i6 = i4;
+ }
+ } while (0);
+ i4 = i6 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i2 = HEAP32[72 >> 2] | 0;
+ if (i6 >>> 0 < i2 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i2 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i15;
+ HEAP32[i4 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i3;
+ HEAP32[i15 + 12 >> 2] = i6;
+ HEAP32[i15 + 24 >> 2] = 0;
+ break;
+ }
+ }
+ } else {
+ i32 = HEAP32[72 >> 2] | 0;
+ if ((i32 | 0) == 0 | i17 >>> 0 < i32 >>> 0) {
+ HEAP32[72 >> 2] = i17;
+ }
+ HEAP32[504 >> 2] = i17;
+ HEAP32[508 >> 2] = i14;
+ HEAP32[516 >> 2] = 0;
+ HEAP32[92 >> 2] = HEAP32[132];
+ HEAP32[88 >> 2] = -1;
+ i2 = 0;
+ do {
+ i32 = i2 << 1;
+ i31 = 96 + (i32 << 2) | 0;
+ HEAP32[96 + (i32 + 3 << 2) >> 2] = i31;
+ HEAP32[96 + (i32 + 2 << 2) >> 2] = i31;
+ i2 = i2 + 1 | 0;
+ } while ((i2 | 0) != 32);
+ i2 = i17 + 8 | 0;
+ if ((i2 & 7 | 0) == 0) {
+ i2 = 0;
+ } else {
+ i2 = 0 - i2 & 7;
+ }
+ i32 = i14 + -40 - i2 | 0;
+ HEAP32[80 >> 2] = i17 + i2;
+ HEAP32[68 >> 2] = i32;
+ HEAP32[i17 + (i2 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i14 + -36) >> 2] = 40;
+ HEAP32[84 >> 2] = HEAP32[544 >> 2];
+ }
+ } while (0);
+ i2 = HEAP32[68 >> 2] | 0;
+ if (i2 >>> 0 > i12 >>> 0) {
+ i31 = i2 - i12 | 0;
+ HEAP32[68 >> 2] = i31;
+ i32 = HEAP32[80 >> 2] | 0;
+ HEAP32[80 >> 2] = i32 + i12;
+ HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
+ HEAP32[i32 + 4 >> 2] = i12 | 3;
+ i32 = i32 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ HEAP32[(___errno_location() | 0) >> 2] = 12;
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+}
+function _free(i7) {
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0;
+ i1 = STACKTOP;
+ if ((i7 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i15 = i7 + -8 | 0;
+ i16 = HEAP32[72 >> 2] | 0;
+ if (i15 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i13 = HEAP32[i7 + -4 >> 2] | 0;
+ i12 = i13 & 3;
+ if ((i12 | 0) == 1) {
+ _abort();
+ }
+ i8 = i13 & -8;
+ i6 = i7 + (i8 + -8) | 0;
+ do {
+ if ((i13 & 1 | 0) == 0) {
+ i19 = HEAP32[i15 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i15 = -8 - i19 | 0;
+ i13 = i7 + i15 | 0;
+ i12 = i19 + i8 | 0;
+ if (i13 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ if ((i13 | 0) == (HEAP32[76 >> 2] | 0)) {
+ i2 = i7 + (i8 + -4) | 0;
+ if ((HEAP32[i2 >> 2] & 3 | 0) != 3) {
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ HEAP32[64 >> 2] = i12;
+ HEAP32[i2 >> 2] = HEAP32[i2 >> 2] & -2;
+ HEAP32[i7 + (i15 + 4) >> 2] = i12 | 1;
+ HEAP32[i6 >> 2] = i12;
+ STACKTOP = i1;
+ return;
+ }
+ i18 = i19 >>> 3;
+ if (i19 >>> 0 < 256) {
+ i2 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
+ i11 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
+ i14 = 96 + (i18 << 1 << 2) | 0;
+ if ((i2 | 0) != (i14 | 0)) {
+ if (i2 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i2 + 12 >> 2] | 0) != (i13 | 0)) {
+ _abort();
+ }
+ }
+ if ((i11 | 0) == (i2 | 0)) {
+ HEAP32[14] = HEAP32[14] & ~(1 << i18);
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ if ((i11 | 0) != (i14 | 0)) {
+ if (i11 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i14 = i11 + 8 | 0;
+ if ((HEAP32[i14 >> 2] | 0) == (i13 | 0)) {
+ i17 = i14;
+ } else {
+ _abort();
+ }
+ } else {
+ i17 = i11 + 8 | 0;
+ }
+ HEAP32[i2 + 12 >> 2] = i11;
+ HEAP32[i17 >> 2] = i2;
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ i17 = HEAP32[i7 + (i15 + 24) >> 2] | 0;
+ i18 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
+ do {
+ if ((i18 | 0) == (i13 | 0)) {
+ i19 = i7 + (i15 + 20) | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ i19 = i7 + (i15 + 16) | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ i14 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i21 = i18 + 20 | 0;
+ i20 = HEAP32[i21 >> 2] | 0;
+ if ((i20 | 0) != 0) {
+ i18 = i20;
+ i19 = i21;
+ continue;
+ }
+ i20 = i18 + 16 | 0;
+ i21 = HEAP32[i20 >> 2] | 0;
+ if ((i21 | 0) == 0) {
+ break;
+ } else {
+ i18 = i21;
+ i19 = i20;
+ }
+ }
+ if (i19 >>> 0 < i16 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i19 >> 2] = 0;
+ i14 = i18;
+ break;
+ }
+ } else {
+ i19 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
+ if (i19 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i16 = i19 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != (i13 | 0)) {
+ _abort();
+ }
+ i20 = i18 + 8 | 0;
+ if ((HEAP32[i20 >> 2] | 0) == (i13 | 0)) {
+ HEAP32[i16 >> 2] = i18;
+ HEAP32[i20 >> 2] = i19;
+ i14 = i18;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i17 | 0) != 0) {
+ i18 = HEAP32[i7 + (i15 + 28) >> 2] | 0;
+ i16 = 360 + (i18 << 2) | 0;
+ if ((i13 | 0) == (HEAP32[i16 >> 2] | 0)) {
+ HEAP32[i16 >> 2] = i14;
+ if ((i14 | 0) == 0) {
+ HEAP32[60 >> 2] = HEAP32[60 >> 2] & ~(1 << i18);
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ } else {
+ if (i17 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i17 + 16 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i13 | 0)) {
+ HEAP32[i16 >> 2] = i14;
+ } else {
+ HEAP32[i17 + 20 >> 2] = i14;
+ }
+ if ((i14 | 0) == 0) {
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ }
+ if (i14 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i14 + 24 >> 2] = i17;
+ i16 = HEAP32[i7 + (i15 + 16) >> 2] | 0;
+ do {
+ if ((i16 | 0) != 0) {
+ if (i16 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i14 + 16 >> 2] = i16;
+ HEAP32[i16 + 24 >> 2] = i14;
+ break;
+ }
+ }
+ } while (0);
+ i15 = HEAP32[i7 + (i15 + 20) >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ if (i15 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i14 + 20 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i14;
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ } else {
+ i2 = i13;
+ i11 = i12;
+ }
+ } else {
+ i2 = i13;
+ i11 = i12;
+ }
+ } else {
+ i2 = i15;
+ i11 = i8;
+ }
+ } while (0);
+ if (!(i2 >>> 0 < i6 >>> 0)) {
+ _abort();
+ }
+ i12 = i7 + (i8 + -4) | 0;
+ i13 = HEAP32[i12 >> 2] | 0;
+ if ((i13 & 1 | 0) == 0) {
+ _abort();
+ }
+ if ((i13 & 2 | 0) == 0) {
+ if ((i6 | 0) == (HEAP32[80 >> 2] | 0)) {
+ i21 = (HEAP32[68 >> 2] | 0) + i11 | 0;
+ HEAP32[68 >> 2] = i21;
+ HEAP32[80 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i21 | 1;
+ if ((i2 | 0) != (HEAP32[76 >> 2] | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[76 >> 2] = 0;
+ HEAP32[64 >> 2] = 0;
+ STACKTOP = i1;
+ return;
+ }
+ if ((i6 | 0) == (HEAP32[76 >> 2] | 0)) {
+ i21 = (HEAP32[64 >> 2] | 0) + i11 | 0;
+ HEAP32[64 >> 2] = i21;
+ HEAP32[76 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i21 | 1;
+ HEAP32[i2 + i21 >> 2] = i21;
+ STACKTOP = i1;
+ return;
+ }
+ i11 = (i13 & -8) + i11 | 0;
+ i12 = i13 >>> 3;
+ do {
+ if (!(i13 >>> 0 < 256)) {
+ i10 = HEAP32[i7 + (i8 + 16) >> 2] | 0;
+ i15 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
+ do {
+ if ((i15 | 0) == (i6 | 0)) {
+ i13 = i7 + (i8 + 12) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i13 = i7 + (i8 + 8) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i9 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i14 = i12 + 20 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ i12 = i15;
+ i13 = i14;
+ continue;
+ }
+ i14 = i12 + 16 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) == 0) {
+ break;
+ } else {
+ i12 = i15;
+ i13 = i14;
+ }
+ }
+ if (i13 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i13 >> 2] = 0;
+ i9 = i12;
+ break;
+ }
+ } else {
+ i13 = HEAP32[i7 + i8 >> 2] | 0;
+ if (i13 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i14 = i13 + 12 | 0;
+ if ((HEAP32[i14 >> 2] | 0) != (i6 | 0)) {
+ _abort();
+ }
+ i12 = i15 + 8 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i14 >> 2] = i15;
+ HEAP32[i12 >> 2] = i13;
+ i9 = i15;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i10 | 0) != 0) {
+ i12 = HEAP32[i7 + (i8 + 20) >> 2] | 0;
+ i13 = 360 + (i12 << 2) | 0;
+ if ((i6 | 0) == (HEAP32[i13 >> 2] | 0)) {
+ HEAP32[i13 >> 2] = i9;
+ if ((i9 | 0) == 0) {
+ HEAP32[60 >> 2] = HEAP32[60 >> 2] & ~(1 << i12);
+ break;
+ }
+ } else {
+ if (i10 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i12 = i10 + 16 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i12 >> 2] = i9;
+ } else {
+ HEAP32[i10 + 20 >> 2] = i9;
+ }
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ }
+ if (i9 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i9 + 24 >> 2] = i10;
+ i6 = HEAP32[i7 + (i8 + 8) >> 2] | 0;
+ do {
+ if ((i6 | 0) != 0) {
+ if (i6 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 16 >> 2] = i6;
+ HEAP32[i6 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ } while (0);
+ i6 = HEAP32[i7 + (i8 + 12) >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ if (i6 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 20 >> 2] = i6;
+ HEAP32[i6 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ }
+ } else {
+ i9 = HEAP32[i7 + i8 >> 2] | 0;
+ i7 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
+ i8 = 96 + (i12 << 1 << 2) | 0;
+ if ((i9 | 0) != (i8 | 0)) {
+ if (i9 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i9 + 12 >> 2] | 0) != (i6 | 0)) {
+ _abort();
+ }
+ }
+ if ((i7 | 0) == (i9 | 0)) {
+ HEAP32[14] = HEAP32[14] & ~(1 << i12);
+ break;
+ }
+ if ((i7 | 0) != (i8 | 0)) {
+ if (i7 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i7 + 8 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i6 | 0)) {
+ i10 = i8;
+ } else {
+ _abort();
+ }
+ } else {
+ i10 = i7 + 8 | 0;
+ }
+ HEAP32[i9 + 12 >> 2] = i7;
+ HEAP32[i10 >> 2] = i9;
+ }
+ } while (0);
+ HEAP32[i2 + 4 >> 2] = i11 | 1;
+ HEAP32[i2 + i11 >> 2] = i11;
+ if ((i2 | 0) == (HEAP32[76 >> 2] | 0)) {
+ HEAP32[64 >> 2] = i11;
+ STACKTOP = i1;
+ return;
+ }
+ } else {
+ HEAP32[i12 >> 2] = i13 & -2;
+ HEAP32[i2 + 4 >> 2] = i11 | 1;
+ HEAP32[i2 + i11 >> 2] = i11;
+ }
+ i6 = i11 >>> 3;
+ if (i11 >>> 0 < 256) {
+ i7 = i6 << 1;
+ i3 = 96 + (i7 << 2) | 0;
+ i8 = HEAP32[14] | 0;
+ i6 = 1 << i6;
+ if ((i8 & i6 | 0) != 0) {
+ i6 = 96 + (i7 + 2 << 2) | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ if (i7 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i4 = i6;
+ i5 = i7;
+ }
+ } else {
+ HEAP32[14] = i8 | i6;
+ i4 = 96 + (i7 + 2 << 2) | 0;
+ i5 = i3;
+ }
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i5 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i5;
+ HEAP32[i2 + 12 >> 2] = i3;
+ STACKTOP = i1;
+ return;
+ }
+ i4 = i11 >>> 8;
+ if ((i4 | 0) != 0) {
+ if (i11 >>> 0 > 16777215) {
+ i4 = 31;
+ } else {
+ i20 = (i4 + 1048320 | 0) >>> 16 & 8;
+ i21 = i4 << i20;
+ i19 = (i21 + 520192 | 0) >>> 16 & 4;
+ i21 = i21 << i19;
+ i4 = (i21 + 245760 | 0) >>> 16 & 2;
+ i4 = 14 - (i19 | i20 | i4) + (i21 << i4 >>> 15) | 0;
+ i4 = i11 >>> (i4 + 7 | 0) & 1 | i4 << 1;
+ }
+ } else {
+ i4 = 0;
+ }
+ i5 = 360 + (i4 << 2) | 0;
+ HEAP32[i2 + 28 >> 2] = i4;
+ HEAP32[i2 + 20 >> 2] = 0;
+ HEAP32[i2 + 16 >> 2] = 0;
+ i7 = HEAP32[60 >> 2] | 0;
+ i6 = 1 << i4;
+ L199 : do {
+ if ((i7 & i6 | 0) != 0) {
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((i4 | 0) == 31) {
+ i4 = 0;
+ } else {
+ i4 = 25 - (i4 >>> 1) | 0;
+ }
+ L205 : do {
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) != (i11 | 0)) {
+ i4 = i11 << i4;
+ i7 = i5;
+ while (1) {
+ i6 = i7 + (i4 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i11 | 0)) {
+ i3 = i5;
+ break L205;
+ } else {
+ i4 = i4 << 1;
+ i7 = i5;
+ }
+ }
+ if (i6 >>> 0 < (HEAP32[72 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i7;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ break L199;
+ }
+ } else {
+ i3 = i5;
+ }
+ } while (0);
+ i5 = i3 + 8 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i6 = HEAP32[72 >> 2] | 0;
+ if (i3 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ if (i4 >>> 0 < i6 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i4 + 12 >> 2] = i2;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i4;
+ HEAP32[i2 + 12 >> 2] = i3;
+ HEAP32[i2 + 24 >> 2] = 0;
+ break;
+ }
+ } else {
+ HEAP32[60 >> 2] = i7 | i6;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i5;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ }
+ } while (0);
+ i21 = (HEAP32[88 >> 2] | 0) + -1 | 0;
+ HEAP32[88 >> 2] = i21;
+ if ((i21 | 0) == 0) {
+ i2 = 512 | 0;
+ } else {
+ STACKTOP = i1;
+ return;
+ }
+ while (1) {
+ i2 = HEAP32[i2 >> 2] | 0;
+ if ((i2 | 0) == 0) {
+ break;
+ } else {
+ i2 = i2 + 8 | 0;
+ }
+ }
+ HEAP32[88 >> 2] = -1;
+ STACKTOP = i1;
+ return;
+}
+function __Z15fannkuch_workerPv(i9) {
+ i9 = i9 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0;
+ i3 = STACKTOP;
+ i7 = HEAP32[i9 + 4 >> 2] | 0;
+ i6 = i7 << 2;
+ i5 = _malloc(i6) | 0;
+ i2 = _malloc(i6) | 0;
+ i6 = _malloc(i6) | 0;
+ i10 = (i7 | 0) > 0;
+ if (i10) {
+ i8 = 0;
+ do {
+ HEAP32[i5 + (i8 << 2) >> 2] = i8;
+ i8 = i8 + 1 | 0;
+ } while ((i8 | 0) != (i7 | 0));
+ i8 = i7 + -1 | 0;
+ i17 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i5 + (i17 << 2) >> 2] = i8;
+ i9 = i5 + (i8 << 2) | 0;
+ HEAP32[i9 >> 2] = i17;
+ if (i10) {
+ i10 = i7 << 2;
+ i11 = 0;
+ i12 = i7;
+ L7 : while (1) {
+ if ((i12 | 0) > 1) {
+ while (1) {
+ i13 = i12 + -1 | 0;
+ HEAP32[i6 + (i13 << 2) >> 2] = i12;
+ if ((i13 | 0) > 1) {
+ i12 = i13;
+ } else {
+ i12 = 1;
+ break;
+ }
+ }
+ }
+ i13 = HEAP32[i5 >> 2] | 0;
+ if ((i13 | 0) != 0 ? (HEAP32[i9 >> 2] | 0) != (i8 | 0) : 0) {
+ _memcpy(i2 | 0, i5 | 0, i10 | 0) | 0;
+ i15 = 0;
+ i14 = HEAP32[i2 >> 2] | 0;
+ while (1) {
+ i17 = i14 + -1 | 0;
+ if ((i17 | 0) > 1) {
+ i16 = 1;
+ do {
+ i20 = i2 + (i16 << 2) | 0;
+ i19 = HEAP32[i20 >> 2] | 0;
+ i18 = i2 + (i17 << 2) | 0;
+ HEAP32[i20 >> 2] = HEAP32[i18 >> 2];
+ HEAP32[i18 >> 2] = i19;
+ i16 = i16 + 1 | 0;
+ i17 = i17 + -1 | 0;
+ } while ((i16 | 0) < (i17 | 0));
+ }
+ i15 = i15 + 1 | 0;
+ i20 = i2 + (i14 << 2) | 0;
+ i16 = HEAP32[i20 >> 2] | 0;
+ HEAP32[i20 >> 2] = i14;
+ if ((i16 | 0) == 0) {
+ break;
+ } else {
+ i14 = i16;
+ }
+ }
+ i11 = (i11 | 0) < (i15 | 0) ? i15 : i11;
+ }
+ if ((i12 | 0) >= (i8 | 0)) {
+ i8 = 34;
+ break;
+ }
+ while (1) {
+ if ((i12 | 0) > 0) {
+ i14 = 0;
+ while (1) {
+ i15 = i14 + 1 | 0;
+ HEAP32[i5 + (i14 << 2) >> 2] = HEAP32[i5 + (i15 << 2) >> 2];
+ if ((i15 | 0) == (i12 | 0)) {
+ i14 = i12;
+ break;
+ } else {
+ i14 = i15;
+ }
+ }
+ } else {
+ i14 = 0;
+ }
+ HEAP32[i5 + (i14 << 2) >> 2] = i13;
+ i14 = i6 + (i12 << 2) | 0;
+ i20 = (HEAP32[i14 >> 2] | 0) + -1 | 0;
+ HEAP32[i14 >> 2] = i20;
+ i14 = i12 + 1 | 0;
+ if ((i20 | 0) > 0) {
+ continue L7;
+ }
+ if ((i14 | 0) >= (i8 | 0)) {
+ i8 = 34;
+ break L7;
+ }
+ i13 = HEAP32[i5 >> 2] | 0;
+ i12 = i14;
+ }
+ }
+ if ((i8 | 0) == 34) {
+ _free(i5);
+ _free(i2);
+ _free(i6);
+ STACKTOP = i3;
+ return i11 | 0;
+ }
+ } else {
+ i1 = i9;
+ i4 = i8;
+ }
+ } else {
+ i4 = i7 + -1 | 0;
+ i20 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i5 + (i20 << 2) >> 2] = i4;
+ i1 = i5 + (i4 << 2) | 0;
+ HEAP32[i1 >> 2] = i20;
+ }
+ i11 = 0;
+ L36 : while (1) {
+ if ((i7 | 0) > 1) {
+ while (1) {
+ i8 = i7 + -1 | 0;
+ HEAP32[i6 + (i8 << 2) >> 2] = i7;
+ if ((i8 | 0) > 1) {
+ i7 = i8;
+ } else {
+ i7 = 1;
+ break;
+ }
+ }
+ }
+ i8 = HEAP32[i5 >> 2] | 0;
+ if ((i8 | 0) != 0 ? (HEAP32[i1 >> 2] | 0) != (i4 | 0) : 0) {
+ i10 = 0;
+ i9 = HEAP32[i2 >> 2] | 0;
+ while (1) {
+ i13 = i9 + -1 | 0;
+ if ((i13 | 0) > 1) {
+ i12 = 1;
+ do {
+ i18 = i2 + (i12 << 2) | 0;
+ i19 = HEAP32[i18 >> 2] | 0;
+ i20 = i2 + (i13 << 2) | 0;
+ HEAP32[i18 >> 2] = HEAP32[i20 >> 2];
+ HEAP32[i20 >> 2] = i19;
+ i12 = i12 + 1 | 0;
+ i13 = i13 + -1 | 0;
+ } while ((i12 | 0) < (i13 | 0));
+ }
+ i10 = i10 + 1 | 0;
+ i20 = i2 + (i9 << 2) | 0;
+ i12 = HEAP32[i20 >> 2] | 0;
+ HEAP32[i20 >> 2] = i9;
+ if ((i12 | 0) == 0) {
+ break;
+ } else {
+ i9 = i12;
+ }
+ }
+ i11 = (i11 | 0) < (i10 | 0) ? i10 : i11;
+ }
+ if ((i7 | 0) >= (i4 | 0)) {
+ i8 = 34;
+ break;
+ }
+ while (1) {
+ if ((i7 | 0) > 0) {
+ i9 = 0;
+ while (1) {
+ i10 = i9 + 1 | 0;
+ HEAP32[i5 + (i9 << 2) >> 2] = HEAP32[i5 + (i10 << 2) >> 2];
+ if ((i10 | 0) == (i7 | 0)) {
+ i9 = i7;
+ break;
+ } else {
+ i9 = i10;
+ }
+ }
+ } else {
+ i9 = 0;
+ }
+ HEAP32[i5 + (i9 << 2) >> 2] = i8;
+ i9 = i6 + (i7 << 2) | 0;
+ i20 = (HEAP32[i9 >> 2] | 0) + -1 | 0;
+ HEAP32[i9 >> 2] = i20;
+ i9 = i7 + 1 | 0;
+ if ((i20 | 0) > 0) {
+ continue L36;
+ }
+ if ((i9 | 0) >= (i4 | 0)) {
+ i8 = 34;
+ break L36;
+ }
+ i8 = HEAP32[i5 >> 2] | 0;
+ i7 = i9;
+ }
+ }
+ if ((i8 | 0) == 34) {
+ _free(i5);
+ _free(i2);
+ _free(i6);
+ STACKTOP = i3;
+ return i11 | 0;
+ }
+ return 0;
+}
+function _main(i3, i5) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i1 = i2;
+ L1 : do {
+ if ((i3 | 0) > 1) {
+ i3 = HEAP8[HEAP32[i5 + 4 >> 2] | 0] | 0;
+ switch (i3 | 0) {
+ case 50:
+ {
+ i3 = 10;
+ break L1;
+ }
+ case 51:
+ {
+ i4 = 4;
+ break L1;
+ }
+ case 52:
+ {
+ i3 = 11;
+ break L1;
+ }
+ case 53:
+ {
+ i3 = 12;
+ break L1;
+ }
+ case 49:
+ {
+ i3 = 9;
+ break L1;
+ }
+ case 48:
+ {
+ i11 = 0;
+ STACKTOP = i2;
+ return i11 | 0;
+ }
+ default:
+ {
+ HEAP32[i1 >> 2] = i3 + -48;
+ _printf(8, i1 | 0) | 0;
+ i11 = -1;
+ STACKTOP = i2;
+ return i11 | 0;
+ }
+ }
+ } else {
+ i4 = 4;
+ }
+ } while (0);
+ if ((i4 | 0) == 4) {
+ i3 = 11;
+ }
+ i5 = i3 + -1 | 0;
+ i6 = 0;
+ i7 = 0;
+ while (1) {
+ i4 = _malloc(12) | 0;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i4 + 4 >> 2] = i3;
+ HEAP32[i4 + 8 >> 2] = i6;
+ i7 = i7 + 1 | 0;
+ if ((i7 | 0) == (i5 | 0)) {
+ break;
+ } else {
+ i6 = i4;
+ }
+ }
+ i5 = i3 << 2;
+ i6 = _malloc(i5) | 0;
+ i5 = _malloc(i5) | 0;
+ i7 = 0;
+ do {
+ HEAP32[i6 + (i7 << 2) >> 2] = i7;
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) != (i3 | 0));
+ i8 = i3;
+ i7 = 30;
+ L19 : do {
+ i9 = 0;
+ do {
+ HEAP32[i1 >> 2] = (HEAP32[i6 + (i9 << 2) >> 2] | 0) + 1;
+ _printf(48, i1 | 0) | 0;
+ i9 = i9 + 1 | 0;
+ } while ((i9 | 0) != (i3 | 0));
+ _putchar(10) | 0;
+ i7 = i7 + -1 | 0;
+ if ((i8 | 0) <= 1) {
+ if ((i8 | 0) == (i3 | 0)) {
+ break;
+ }
+ } else {
+ while (1) {
+ i9 = i8 + -1 | 0;
+ HEAP32[i5 + (i9 << 2) >> 2] = i8;
+ if ((i9 | 0) > 1) {
+ i8 = i9;
+ } else {
+ i8 = 1;
+ break;
+ }
+ }
+ }
+ while (1) {
+ i9 = HEAP32[i6 >> 2] | 0;
+ if ((i8 | 0) > 0) {
+ i11 = 0;
+ while (1) {
+ i10 = i11 + 1 | 0;
+ HEAP32[i6 + (i11 << 2) >> 2] = HEAP32[i6 + (i10 << 2) >> 2];
+ if ((i10 | 0) == (i8 | 0)) {
+ i10 = i8;
+ break;
+ } else {
+ i11 = i10;
+ }
+ }
+ } else {
+ i10 = 0;
+ }
+ HEAP32[i6 + (i10 << 2) >> 2] = i9;
+ i9 = i5 + (i8 << 2) | 0;
+ i11 = (HEAP32[i9 >> 2] | 0) + -1 | 0;
+ HEAP32[i9 >> 2] = i11;
+ i9 = i8 + 1 | 0;
+ if ((i11 | 0) > 0) {
+ break;
+ }
+ if ((i9 | 0) == (i3 | 0)) {
+ break L19;
+ } else {
+ i8 = i9;
+ }
+ }
+ } while ((i7 | 0) != 0);
+ _free(i6);
+ _free(i5);
+ if ((i4 | 0) == 0) {
+ i5 = 0;
+ } else {
+ i5 = 0;
+ while (1) {
+ i6 = __Z15fannkuch_workerPv(i4) | 0;
+ i5 = (i5 | 0) < (i6 | 0) ? i6 : i5;
+ i6 = HEAP32[i4 + 8 >> 2] | 0;
+ _free(i4);
+ if ((i6 | 0) == 0) {
+ break;
+ } else {
+ i4 = i6;
+ }
+ }
+ }
+ HEAP32[i1 >> 2] = i3;
+ HEAP32[i1 + 4 >> 2] = i5;
+ _printf(24, i1 | 0) | 0;
+ i11 = 0;
+ STACKTOP = i2;
+ return i11 | 0;
+}
+function _memcpy(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ if ((i1 | 0) >= 4096) return _emscripten_memcpy_big(i3 | 0, i2 | 0, i1 | 0) | 0;
+ i4 = i3 | 0;
+ if ((i3 & 3) == (i2 & 3)) {
+ while (i3 & 3) {
+ if ((i1 | 0) == 0) return i4 | 0;
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ while ((i1 | 0) >= 4) {
+ HEAP32[i3 >> 2] = HEAP32[i2 >> 2];
+ i3 = i3 + 4 | 0;
+ i2 = i2 + 4 | 0;
+ i1 = i1 - 4 | 0;
+ }
+ }
+ while ((i1 | 0) > 0) {
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ return i4 | 0;
+}
+function _memset(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = i1 + i3 | 0;
+ if ((i3 | 0) >= 20) {
+ i4 = i4 & 255;
+ i7 = i1 & 3;
+ i6 = i4 | i4 << 8 | i4 << 16 | i4 << 24;
+ i5 = i2 & ~3;
+ if (i7) {
+ i7 = i1 + 4 - i7 | 0;
+ while ((i1 | 0) < (i7 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ }
+ while ((i1 | 0) < (i5 | 0)) {
+ HEAP32[i1 >> 2] = i6;
+ i1 = i1 + 4 | 0;
+ }
+ }
+ while ((i1 | 0) < (i2 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ return i1 - i3 | 0;
+}
+function copyTempDouble(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+ HEAP8[tempDoublePtr + 4 | 0] = HEAP8[i1 + 4 | 0];
+ HEAP8[tempDoublePtr + 5 | 0] = HEAP8[i1 + 5 | 0];
+ HEAP8[tempDoublePtr + 6 | 0] = HEAP8[i1 + 6 | 0];
+ HEAP8[tempDoublePtr + 7 | 0] = HEAP8[i1 + 7 | 0];
+}
+function copyTempFloat(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+}
+function runPostSets() {}
+function _strlen(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = i1;
+ while (HEAP8[i2] | 0) {
+ i2 = i2 + 1 | 0;
+ }
+ return i2 - i1 | 0;
+}
+function stackAlloc(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + i1 | 0;
+ STACKTOP = STACKTOP + 7 & -8;
+ return i2 | 0;
+}
+function setThrew(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ if ((__THREW__ | 0) == 0) {
+ __THREW__ = i1;
+ threwValue = i2;
+ }
+}
+function stackRestore(i1) {
+ i1 = i1 | 0;
+ STACKTOP = i1;
+}
+function setTempRet9(i1) {
+ i1 = i1 | 0;
+ tempRet9 = i1;
+}
+function setTempRet8(i1) {
+ i1 = i1 | 0;
+ tempRet8 = i1;
+}
+function setTempRet7(i1) {
+ i1 = i1 | 0;
+ tempRet7 = i1;
+}
+function setTempRet6(i1) {
+ i1 = i1 | 0;
+ tempRet6 = i1;
+}
+function setTempRet5(i1) {
+ i1 = i1 | 0;
+ tempRet5 = i1;
+}
+function setTempRet4(i1) {
+ i1 = i1 | 0;
+ tempRet4 = i1;
+}
+function setTempRet3(i1) {
+ i1 = i1 | 0;
+ tempRet3 = i1;
+}
+function setTempRet2(i1) {
+ i1 = i1 | 0;
+ tempRet2 = i1;
+}
+function setTempRet1(i1) {
+ i1 = i1 | 0;
+ tempRet1 = i1;
+}
+function setTempRet0(i1) {
+ i1 = i1 | 0;
+ tempRet0 = i1;
+}
+function stackSave() {
+ return STACKTOP | 0;
+}
+
+// EMSCRIPTEN_END_FUNCS
+
+
+ return { _strlen: _strlen, _free: _free, _main: _main, _memset: _memset, _malloc: _malloc, _memcpy: _memcpy, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, setThrew: setThrew, setTempRet0: setTempRet0, setTempRet1: setTempRet1, setTempRet2: setTempRet2, setTempRet3: setTempRet3, setTempRet4: setTempRet4, setTempRet5: setTempRet5, setTempRet6: setTempRet6, setTempRet7: setTempRet7, setTempRet8: setTempRet8, setTempRet9: setTempRet9 };
+})
+// EMSCRIPTEN_END_ASM
+({ "Math": Math, "Int8Array": Int8Array, "Int16Array": Int16Array, "Int32Array": Int32Array, "Uint8Array": Uint8Array, "Uint16Array": Uint16Array, "Uint32Array": Uint32Array, "Float32Array": Float32Array, "Float64Array": Float64Array }, { "abort": abort, "assert": assert, "asmPrintInt": asmPrintInt, "asmPrintFloat": asmPrintFloat, "min": Math_min, "_fflush": _fflush, "_emscripten_memcpy_big": _emscripten_memcpy_big, "_putchar": _putchar, "_fputc": _fputc, "_send": _send, "_pwrite": _pwrite, "_abort": _abort, "__reallyNegative": __reallyNegative, "_fwrite": _fwrite, "_sbrk": _sbrk, "_mkport": _mkport, "_fprintf": _fprintf, "___setErrNo": ___setErrNo, "__formatString": __formatString, "_fileno": _fileno, "_printf": _printf, "_time": _time, "_sysconf": _sysconf, "_write": _write, "___errno_location": ___errno_location, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX, "tempDoublePtr": tempDoublePtr, "ABORT": ABORT, "NaN": NaN, "Infinity": Infinity }, buffer);
+var _strlen = Module["_strlen"] = asm["_strlen"];
+var _free = Module["_free"] = asm["_free"];
+var _main = Module["_main"] = asm["_main"];
+var _memset = Module["_memset"] = asm["_memset"];
+var _malloc = Module["_malloc"] = asm["_malloc"];
+var _memcpy = Module["_memcpy"] = asm["_memcpy"];
+var runPostSets = Module["runPostSets"] = asm["runPostSets"];
+
+Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
+Runtime.stackSave = function() { return asm['stackSave']() };
+Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
+
+
+// Warning: printing of i64 values may be slightly rounded! No deep i64 math used, so precise i64 code not included
+var i64Math = null;
+
+// === Auto-generated postamble setup entry stuff ===
+
+if (memoryInitializer) {
+ if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
+ var data = Module['readBinary'](memoryInitializer);
+ HEAPU8.set(data, STATIC_BASE);
+ } else {
+ addRunDependency('memory initializer');
+ Browser.asyncLoad(memoryInitializer, function(data) {
+ HEAPU8.set(data, STATIC_BASE);
+ removeRunDependency('memory initializer');
+ }, function(data) {
+ throw 'could not load memory initializer ' + memoryInitializer;
+ });
+ }
+}
+
+function ExitStatus(status) {
+ this.name = "ExitStatus";
+ this.message = "Program terminated with exit(" + status + ")";
+ this.status = status;
+};
+ExitStatus.prototype = new Error();
+ExitStatus.prototype.constructor = ExitStatus;
+
+var initialStackTop;
+var preloadStartTime = null;
+var calledMain = false;
+
+dependenciesFulfilled = function runCaller() {
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
+ if (!Module['calledRun'] && shouldRunNow) run([].concat(Module["arguments"]));
+ if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
+}
+
+Module['callMain'] = Module.callMain = function callMain(args) {
+ assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');
+ assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
+
+ args = args || [];
+
+ ensureInitRuntime();
+
+ var argc = args.length+1;
+ function pad() {
+ for (var i = 0; i < 4-1; i++) {
+ argv.push(0);
+ }
+ }
+ var argv = [allocate(intArrayFromString("/bin/this.program"), 'i8', ALLOC_NORMAL) ];
+ pad();
+ for (var i = 0; i < argc-1; i = i + 1) {
+ argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL));
+ pad();
+ }
+ argv.push(0);
+ argv = allocate(argv, 'i32', ALLOC_NORMAL);
+
+ initialStackTop = STACKTOP;
+
+ try {
+
+ var ret = Module['_main'](argc, argv, 0);
+
+
+ // if we're not running an evented main loop, it's time to exit
+ if (!Module['noExitRuntime']) {
+ exit(ret);
+ }
+ }
+ catch(e) {
+ if (e instanceof ExitStatus) {
+ // exit() throws this once it's done to make sure execution
+ // has been stopped completely
+ return;
+ } else if (e == 'SimulateInfiniteLoop') {
+ // running an evented main loop, don't immediately exit
+ Module['noExitRuntime'] = true;
+ return;
+ } else {
+ if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
+ throw e;
+ }
+ } finally {
+ calledMain = true;
+ }
+}
+
+
+
+
+function run(args) {
+ args = args || Module['arguments'];
+
+ if (preloadStartTime === null) preloadStartTime = Date.now();
+
+ if (runDependencies > 0) {
+ Module.printErr('run() called, but dependencies remain, so not running');
+ return;
+ }
+
+ preRun();
+
+ if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
+ if (Module['calledRun']) return; // run may have just been called through dependencies being fulfilled just in this very frame
+
+ function doRun() {
+ if (Module['calledRun']) return; // run may have just been called while the async setStatus time below was happening
+ Module['calledRun'] = true;
+
+ ensureInitRuntime();
+
+ preMain();
+
+ if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) {
+ Module.printErr('pre-main prep time: ' + (Date.now() - preloadStartTime) + ' ms');
+ }
+
+ if (Module['_main'] && shouldRunNow) {
+ Module['callMain'](args);
+ }
+
+ postRun();
+ }
+
+ if (Module['setStatus']) {
+ Module['setStatus']('Running...');
+ setTimeout(function() {
+ setTimeout(function() {
+ Module['setStatus']('');
+ }, 1);
+ if (!ABORT) doRun();
+ }, 1);
+ } else {
+ doRun();
+ }
+}
+Module['run'] = Module.run = run;
+
+function exit(status) {
+ ABORT = true;
+ EXITSTATUS = status;
+ STACKTOP = initialStackTop;
+
+ // exit the runtime
+ exitRuntime();
+
+ // TODO We should handle this differently based on environment.
+ // In the browser, the best we can do is throw an exception
+ // to halt execution, but in node we could process.exit and
+ // I'd imagine SM shell would have something equivalent.
+ // This would let us set a proper exit status (which
+ // would be great for checking test exit statuses).
+ // https://github.com/kripken/emscripten/issues/1371
+
+ // throw an exception to halt the current execution
+ throw new ExitStatus(status);
+}
+Module['exit'] = Module.exit = exit;
+
+function abort(text) {
+ if (text) {
+ Module.print(text);
+ Module.printErr(text);
+ }
+
+ ABORT = true;
+ EXITSTATUS = 1;
+
+ var extra = '\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.';
+
+ throw 'abort() at ' + stackTrace() + extra;
+}
+Module['abort'] = Module.abort = abort;
+
+// {{PRE_RUN_ADDITIONS}}
+
+if (Module['preInit']) {
+ if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
+ while (Module['preInit'].length > 0) {
+ Module['preInit'].pop()();
+ }
+}
+
+// shouldRunNow refers to calling main(), not run().
+var shouldRunNow = true;
+if (Module['noInitialRun']) {
+ shouldRunNow = false;
+}
+
+
+run([].concat(Module["arguments"]));
diff --git a/test/mjsunit/asm/embenchen/fasta.js b/test/mjsunit/asm/embenchen/fasta.js
new file mode 100644
index 000000000..a7aab3d81
--- /dev/null
+++ b/test/mjsunit/asm/embenchen/fasta.js
@@ -0,0 +1,8609 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var EXPECTED_OUTPUT =
+ 'GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA\n' +
+ 'TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT\n' +
+ 'AAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG\n' +
+ 'GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG\n' +
+ 'CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT\n' +
+ 'GGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA\n' +
+ 'GGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA\n' +
+ 'TTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG\n' +
+ 'AATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA\n' +
+ 'GCCTGGGCGA\n';
+var Module = {
+ arguments: [1],
+ print: function(x) {Module.printBuffer += x + '\n';},
+ preRun: [function() {Module.printBuffer = ''}],
+ postRun: [function() {
+ assertEquals(EXPECTED_OUTPUT, Module.printBuffer);
+ }],
+};
+// The Module object: Our interface to the outside world. We import
+// and export values on it, and do the work to get that through
+// closure compiler if necessary. There are various ways Module can be used:
+// 1. Not defined. We create it here
+// 2. A function parameter, function(Module) { ..generated code.. }
+// 3. pre-run appended it, var Module = {}; ..generated code..
+// 4. External script tag defines var Module.
+// We need to do an eval in order to handle the closure compiler
+// case, where this code here is minified but Module was defined
+// elsewhere (e.g. case 4 above). We also need to check if Module
+// already exists (e.g. case 3 above).
+// Note that if you want to run closure, and also to use Module
+// after the generated code, you will need to define var Module = {};
+// before the code. Then that object will be used in the code, and you
+// can continue to use Module afterwards as well.
+var Module;
+if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {};
+
+// Sometimes an existing Module object exists with properties
+// meant to overwrite the default module functionality. Here
+// we collect those properties and reapply _after_ we configure
+// the current environment's defaults to avoid having to be so
+// defensive during initialization.
+var moduleOverrides = {};
+for (var key in Module) {
+ if (Module.hasOwnProperty(key)) {
+ moduleOverrides[key] = Module[key];
+ }
+}
+
+// The environment setup code below is customized to use Module.
+// *** Environment setup code ***
+var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
+var ENVIRONMENT_IS_WEB = typeof window === 'object';
+var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
+var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+
+if (ENVIRONMENT_IS_NODE) {
+ // Expose functionality in the same simple way that the shells work
+ // Note that we pollute the global namespace here, otherwise we break in node
+ if (!Module['print']) Module['print'] = function print(x) {
+ process['stdout'].write(x + '\n');
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ process['stderr'].write(x + '\n');
+ };
+
+ var nodeFS = require('fs');
+ var nodePath = require('path');
+
+ Module['read'] = function read(filename, binary) {
+ filename = nodePath['normalize'](filename);
+ var ret = nodeFS['readFileSync'](filename);
+ // The path is absolute if the normalized version is the same as the resolved.
+ if (!ret && filename != nodePath['resolve'](filename)) {
+ filename = path.join(__dirname, '..', 'src', filename);
+ ret = nodeFS['readFileSync'](filename);
+ }
+ if (ret && !binary) ret = ret.toString();
+ return ret;
+ };
+
+ Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
+
+ Module['load'] = function load(f) {
+ globalEval(read(f));
+ };
+
+ Module['arguments'] = process['argv'].slice(2);
+
+ module['exports'] = Module;
+}
+else if (ENVIRONMENT_IS_SHELL) {
+ if (!Module['print']) Module['print'] = print;
+ if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
+
+ if (typeof read != 'undefined') {
+ Module['read'] = read;
+ } else {
+ Module['read'] = function read() { throw 'no read() available (jsc?)' };
+ }
+
+ Module['readBinary'] = function readBinary(f) {
+ return read(f, 'binary');
+ };
+
+ if (typeof scriptArgs != 'undefined') {
+ Module['arguments'] = scriptArgs;
+ } else if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ this['Module'] = Module;
+
+ eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
+}
+else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
+ Module['read'] = function read(url) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ xhr.send(null);
+ return xhr.responseText;
+ };
+
+ if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ if (typeof console !== 'undefined') {
+ if (!Module['print']) Module['print'] = function print(x) {
+ console.log(x);
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ console.log(x);
+ };
+ } else {
+ // Probably a worker, and without console.log. We can do very little here...
+ var TRY_USE_DUMP = false;
+ if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
+ dump(x);
+ }) : (function(x) {
+ // self.postMessage(x); // enable this if you want stdout to be sent as messages
+ }));
+ }
+
+ if (ENVIRONMENT_IS_WEB) {
+ window['Module'] = Module;
+ } else {
+ Module['load'] = importScripts;
+ }
+}
+else {
+ // Unreachable because SHELL is dependant on the others
+ throw 'Unknown runtime environment. Where are we?';
+}
+
+function globalEval(x) {
+ eval.call(null, x);
+}
+if (!Module['load'] == 'undefined' && Module['read']) {
+ Module['load'] = function load(f) {
+ globalEval(Module['read'](f));
+ };
+}
+if (!Module['print']) {
+ Module['print'] = function(){};
+}
+if (!Module['printErr']) {
+ Module['printErr'] = Module['print'];
+}
+if (!Module['arguments']) {
+ Module['arguments'] = [];
+}
+// *** Environment setup code ***
+
+// Closure helpers
+Module.print = Module['print'];
+Module.printErr = Module['printErr'];
+
+// Callbacks
+Module['preRun'] = [];
+Module['postRun'] = [];
+
+// Merge back in the overrides
+for (var key in moduleOverrides) {
+ if (moduleOverrides.hasOwnProperty(key)) {
+ Module[key] = moduleOverrides[key];
+ }
+}
+
+
+
+// === Auto-generated preamble library stuff ===
+
+//========================================
+// Runtime code shared with compiler
+//========================================
+
+var Runtime = {
+ stackSave: function () {
+ return STACKTOP;
+ },
+ stackRestore: function (stackTop) {
+ STACKTOP = stackTop;
+ },
+ forceAlign: function (target, quantum) {
+ quantum = quantum || 4;
+ if (quantum == 1) return target;
+ if (isNumber(target) && isNumber(quantum)) {
+ return Math.ceil(target/quantum)*quantum;
+ } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
+ return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')';
+ }
+ return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
+ },
+ isNumberType: function (type) {
+ return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
+ },
+ isPointerType: function isPointerType(type) {
+ return type[type.length-1] == '*';
+},
+ isStructType: function isStructType(type) {
+ if (isPointerType(type)) return false;
+ if (isArrayType(type)) return true;
+ if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
+ // See comment in isStructPointerType()
+ return type[0] == '%';
+},
+ INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
+ FLOAT_TYPES: {"float":0,"double":0},
+ or64: function (x, y) {
+ var l = (x | 0) | (y | 0);
+ var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ and64: function (x, y) {
+ var l = (x | 0) & (y | 0);
+ var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ xor64: function (x, y) {
+ var l = (x | 0) ^ (y | 0);
+ var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ getNativeTypeSize: function (type) {
+ switch (type) {
+ case 'i1': case 'i8': return 1;
+ case 'i16': return 2;
+ case 'i32': return 4;
+ case 'i64': return 8;
+ case 'float': return 4;
+ case 'double': return 8;
+ default: {
+ if (type[type.length-1] === '*') {
+ return Runtime.QUANTUM_SIZE; // A pointer
+ } else if (type[0] === 'i') {
+ var bits = parseInt(type.substr(1));
+ assert(bits % 8 === 0);
+ return bits/8;
+ } else {
+ return 0;
+ }
+ }
+ }
+ },
+ getNativeFieldSize: function (type) {
+ return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
+ },
+ dedup: function dedup(items, ident) {
+ var seen = {};
+ if (ident) {
+ return items.filter(function(item) {
+ if (seen[item[ident]]) return false;
+ seen[item[ident]] = true;
+ return true;
+ });
+ } else {
+ return items.filter(function(item) {
+ if (seen[item]) return false;
+ seen[item] = true;
+ return true;
+ });
+ }
+},
+ set: function set() {
+ var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
+ var ret = {};
+ for (var i = 0; i < args.length; i++) {
+ ret[args[i]] = 0;
+ }
+ return ret;
+},
+ STACK_ALIGN: 8,
+ getAlignSize: function (type, size, vararg) {
+ // we align i64s and doubles on 64-bit boundaries, unlike x86
+ if (!vararg && (type == 'i64' || type == 'double')) return 8;
+ if (!type) return Math.min(size, 8); // align structures internally to 64 bits
+ return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
+ },
+ calculateStructAlignment: function calculateStructAlignment(type) {
+ type.flatSize = 0;
+ type.alignSize = 0;
+ var diffs = [];
+ var prev = -1;
+ var index = 0;
+ type.flatIndexes = type.fields.map(function(field) {
+ index++;
+ var size, alignSize;
+ if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
+ size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
+ alignSize = Runtime.getAlignSize(field, size);
+ } else if (Runtime.isStructType(field)) {
+ if (field[1] === '0') {
+ // this is [0 x something]. When inside another structure like here, it must be at the end,
+ // and it adds no size
+ // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');
+ size = 0;
+ if (Types.types[field]) {
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ } else {
+ alignSize = type.alignSize || QUANTUM_SIZE;
+ }
+ } else {
+ size = Types.types[field].flatSize;
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ }
+ } else if (field[0] == 'b') {
+ // bN, large number field, like a [N x i8]
+ size = field.substr(1)|0;
+ alignSize = 1;
+ } else if (field[0] === '<') {
+ // vector type
+ size = alignSize = Types.types[field].flatSize; // fully aligned
+ } else if (field[0] === 'i') {
+ // illegal integer field, that could not be legalized because it is an internal structure field
+ // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
+ size = alignSize = parseInt(field.substr(1))/8;
+ assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
+ } else {
+ assert(false, 'invalid type for calculateStructAlignment');
+ }
+ if (type.packed) alignSize = 1;
+ type.alignSize = Math.max(type.alignSize, alignSize);
+ var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
+ type.flatSize = curr + size;
+ if (prev >= 0) {
+ diffs.push(curr-prev);
+ }
+ prev = curr;
+ return curr;
+ });
+ if (type.name_ && type.name_[0] === '[') {
+ // arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
+ // allocating a potentially huge array for [999999 x i8] etc.
+ type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
+ }
+ type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
+ if (diffs.length == 0) {
+ type.flatFactor = type.flatSize;
+ } else if (Runtime.dedup(diffs).length == 1) {
+ type.flatFactor = diffs[0];
+ }
+ type.needsFlattening = (type.flatFactor != 1);
+ return type.flatIndexes;
+ },
+ generateStructInfo: function (struct, typeName, offset) {
+ var type, alignment;
+ if (typeName) {
+ offset = offset || 0;
+ type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
+ if (!type) return null;
+ if (type.fields.length != struct.length) {
+ printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');
+ return null;
+ }
+ alignment = type.flatIndexes;
+ } else {
+ var type = { fields: struct.map(function(item) { return item[0] }) };
+ alignment = Runtime.calculateStructAlignment(type);
+ }
+ var ret = {
+ __size__: type.flatSize
+ };
+ if (typeName) {
+ struct.forEach(function(item, i) {
+ if (typeof item === 'string') {
+ ret[item] = alignment[i] + offset;
+ } else {
+ // embedded struct
+ var key;
+ for (var k in item) key = k;
+ ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
+ }
+ });
+ } else {
+ struct.forEach(function(item, i) {
+ ret[item[1]] = alignment[i];
+ });
+ }
+ return ret;
+ },
+ dynCall: function (sig, ptr, args) {
+ if (args && args.length) {
+ if (!args.splice) args = Array.prototype.slice.call(args);
+ args.splice(0, 0, ptr);
+ return Module['dynCall_' + sig].apply(null, args);
+ } else {
+ return Module['dynCall_' + sig].call(null, ptr);
+ }
+ },
+ functionPointers: [],
+ addFunction: function (func) {
+ for (var i = 0; i < Runtime.functionPointers.length; i++) {
+ if (!Runtime.functionPointers[i]) {
+ Runtime.functionPointers[i] = func;
+ return 2*(1 + i);
+ }
+ }
+ throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
+ },
+ removeFunction: function (index) {
+ Runtime.functionPointers[(index-2)/2] = null;
+ },
+ getAsmConst: function (code, numArgs) {
+ // code is a constant string on the heap, so we can cache these
+ if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
+ var func = Runtime.asmConstCache[code];
+ if (func) return func;
+ var args = [];
+ for (var i = 0; i < numArgs; i++) {
+ args.push(String.fromCharCode(36) + i); // $0, $1 etc
+ }
+ var source = Pointer_stringify(code);
+ if (source[0] === '"') {
+ // tolerate EM_ASM("..code..") even though EM_ASM(..code..) is correct
+ if (source.indexOf('"', 1) === source.length-1) {
+ source = source.substr(1, source.length-2);
+ } else {
+ // something invalid happened, e.g. EM_ASM("..code($0)..", input)
+ abort('invalid EM_ASM input |' + source + '|. Please use EM_ASM(..code..) (no quotes) or EM_ASM({ ..code($0).. }, input) (to input values)');
+ }
+ }
+ try {
+ var evalled = eval('(function(' + args.join(',') + '){ ' + source + ' })'); // new Function does not allow upvars in node
+ } catch(e) {
+ Module.printErr('error in executing inline EM_ASM code: ' + e + ' on: \n\n' + source + '\n\nwith args |' + args + '| (make sure to use the right one out of EM_ASM, EM_ASM_ARGS, etc.)');
+ throw e;
+ }
+ return Runtime.asmConstCache[code] = evalled;
+ },
+ warnOnce: function (text) {
+ if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
+ if (!Runtime.warnOnce.shown[text]) {
+ Runtime.warnOnce.shown[text] = 1;
+ Module.printErr(text);
+ }
+ },
+ funcWrappers: {},
+ getFuncWrapper: function (func, sig) {
+ assert(sig);
+ if (!Runtime.funcWrappers[func]) {
+ Runtime.funcWrappers[func] = function dynCall_wrapper() {
+ return Runtime.dynCall(sig, func, arguments);
+ };
+ }
+ return Runtime.funcWrappers[func];
+ },
+ UTF8Processor: function () {
+ var buffer = [];
+ var needed = 0;
+ this.processCChar = function (code) {
+ code = code & 0xFF;
+
+ if (buffer.length == 0) {
+ if ((code & 0x80) == 0x00) { // 0xxxxxxx
+ return String.fromCharCode(code);
+ }
+ buffer.push(code);
+ if ((code & 0xE0) == 0xC0) { // 110xxxxx
+ needed = 1;
+ } else if ((code & 0xF0) == 0xE0) { // 1110xxxx
+ needed = 2;
+ } else { // 11110xxx
+ needed = 3;
+ }
+ return '';
+ }
+
+ if (needed) {
+ buffer.push(code);
+ needed--;
+ if (needed > 0) return '';
+ }
+
+ var c1 = buffer[0];
+ var c2 = buffer[1];
+ var c3 = buffer[2];
+ var c4 = buffer[3];
+ var ret;
+ if (buffer.length == 2) {
+ ret = String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ } else if (buffer.length == 3) {
+ ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ } else {
+ // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |
+ ((c3 & 0x3F) << 6) | (c4 & 0x3F);
+ ret = String.fromCharCode(
+ Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,
+ (codePoint - 0x10000) % 0x400 + 0xDC00);
+ }
+ buffer.length = 0;
+ return ret;
+ }
+ this.processJSString = function processJSString(string) {
+ /* TODO: use TextEncoder when present,
+ var encoder = new TextEncoder();
+ encoder['encoding'] = "utf-8";
+ var utf8Array = encoder['encode'](aMsg.data);
+ */
+ string = unescape(encodeURIComponent(string));
+ var ret = [];
+ for (var i = 0; i < string.length; i++) {
+ ret.push(string.charCodeAt(i));
+ }
+ return ret;
+ }
+ },
+ getCompilerSetting: function (name) {
+ throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
+ },
+ stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+7)&-8); return ret; },
+ staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = (((STATICTOP)+7)&-8); return ret; },
+ dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = (((DYNAMICTOP)+7)&-8); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
+ alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },
+ makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*(+4294967296))) : ((+((low>>>0)))+((+((high|0)))*(+4294967296)))); return ret; },
+ GLOBAL_BASE: 8,
+ QUANTUM_SIZE: 4,
+ __dummy__: 0
+}
+
+
+Module['Runtime'] = Runtime;
+
+
+
+
+
+
+
+
+
+//========================================
+// Runtime essentials
+//========================================
+
+var __THREW__ = 0; // Used in checking for thrown exceptions.
+
+var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()
+var EXITSTATUS = 0;
+
+var undef = 0;
+// tempInt is used for 32-bit signed values or smaller. tempBigInt is used
+// for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
+var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
+var tempI64, tempI64b;
+var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
+
+function assert(condition, text) {
+ if (!condition) {
+ abort('Assertion failed: ' + text);
+ }
+}
+
+var globalScope = this;
+
+// C calling interface. A convenient way to call C functions (in C files, or
+// defined with extern "C").
+//
+// Note: LLVM optimizations can inline and remove functions, after which you will not be
+// able to call them. Closure can also do so. To avoid that, add your function to
+// the exports using something like
+//
+// -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]'
+//
+// @param ident The name of the C function (note that C++ functions will be name-mangled - use extern "C")
+// @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and
+// 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).
+// @param argTypes An array of the types of arguments for the function (if there are no arguments, this can be ommitted). Types are as in returnType,
+// except that 'array' is not possible (there is no way for us to know the length of the array)
+// @param args An array of the arguments to the function, as native JS values (as in returnType)
+// Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).
+// @return The return value, as a native JS value (as in returnType)
+function ccall(ident, returnType, argTypes, args) {
+ return ccallFunc(getCFunc(ident), returnType, argTypes, args);
+}
+Module["ccall"] = ccall;
+
+// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
+function getCFunc(ident) {
+ try {
+ var func = Module['_' + ident]; // closure exported function
+ if (!func) func = eval('_' + ident); // explicit lookup
+ } catch(e) {
+ }
+ assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
+ return func;
+}
+
+// Internal function that does a C call using a function, not an identifier
+function ccallFunc(func, returnType, argTypes, args) {
+ var stack = 0;
+ function toC(value, type) {
+ if (type == 'string') {
+ if (value === null || value === undefined || value === 0) return 0; // null string
+ value = intArrayFromString(value);
+ type = 'array';
+ }
+ if (type == 'array') {
+ if (!stack) stack = Runtime.stackSave();
+ var ret = Runtime.stackAlloc(value.length);
+ writeArrayToMemory(value, ret);
+ return ret;
+ }
+ return value;
+ }
+ function fromC(value, type) {
+ if (type == 'string') {
+ return Pointer_stringify(value);
+ }
+ assert(type != 'array');
+ return value;
+ }
+ var i = 0;
+ var cArgs = args ? args.map(function(arg) {
+ return toC(arg, argTypes[i++]);
+ }) : [];
+ var ret = fromC(func.apply(null, cArgs), returnType);
+ if (stack) Runtime.stackRestore(stack);
+ return ret;
+}
+
+// Returns a native JS wrapper for a C function. This is similar to ccall, but
+// returns a function you can call repeatedly in a normal way. For example:
+//
+// var my_function = cwrap('my_c_function', 'number', ['number', 'number']);
+// alert(my_function(5, 22));
+// alert(my_function(99, 12));
+//
+function cwrap(ident, returnType, argTypes) {
+ var func = getCFunc(ident);
+ return function() {
+ return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));
+ }
+}
+Module["cwrap"] = cwrap;
+
+// Sets a value in memory in a dynamic way at run-time. Uses the
+// type data. This is the same as makeSetValue, except that
+// makeSetValue is done at compile-time and generates the needed
+// code then, whereas this function picks the right code at
+// run-time.
+// Note that setValue and getValue only do *aligned* writes and reads!
+// Note that ccall uses JS types as for defining types, while setValue and
+// getValue need LLVM types ('i8', 'i32') - this is a lower-level operation
+function setValue(ptr, value, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': HEAP8[(ptr)]=value; break;
+ case 'i8': HEAP8[(ptr)]=value; break;
+ case 'i16': HEAP16[((ptr)>>1)]=value; break;
+ case 'i32': HEAP32[((ptr)>>2)]=value; break;
+ case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= (+1) ? (tempDouble > (+0) ? ((Math_min((+(Math_floor((tempDouble)/(+4294967296)))), (+4294967295)))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+4294967296))))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
+ case 'float': HEAPF32[((ptr)>>2)]=value; break;
+ case 'double': HEAPF64[((ptr)>>3)]=value; break;
+ default: abort('invalid type for setValue: ' + type);
+ }
+}
+Module['setValue'] = setValue;
+
+// Parallel to setValue.
+function getValue(ptr, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': return HEAP8[(ptr)];
+ case 'i8': return HEAP8[(ptr)];
+ case 'i16': return HEAP16[((ptr)>>1)];
+ case 'i32': return HEAP32[((ptr)>>2)];
+ case 'i64': return HEAP32[((ptr)>>2)];
+ case 'float': return HEAPF32[((ptr)>>2)];
+ case 'double': return HEAPF64[((ptr)>>3)];
+ default: abort('invalid type for setValue: ' + type);
+ }
+ return null;
+}
+Module['getValue'] = getValue;
+
+var ALLOC_NORMAL = 0; // Tries to use _malloc()
+var ALLOC_STACK = 1; // Lives for the duration of the current function call
+var ALLOC_STATIC = 2; // Cannot be freed
+var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
+var ALLOC_NONE = 4; // Do not allocate
+Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
+Module['ALLOC_STACK'] = ALLOC_STACK;
+Module['ALLOC_STATIC'] = ALLOC_STATIC;
+Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;
+Module['ALLOC_NONE'] = ALLOC_NONE;
+
+// allocate(): This is for internal use. You can use it yourself as well, but the interface
+// is a little tricky (see docs right below). The reason is that it is optimized
+// for multiple syntaxes to save space in generated code. So you should
+// normally not use allocate(), and instead allocate memory using _malloc(),
+// initialize it with setValue(), and so forth.
+// @slab: An array of data, or a number. If a number, then the size of the block to allocate,
+// in *bytes* (note that this is sometimes confusing: the next parameter does not
+// affect this!)
+// @types: Either an array of types, one for each byte (or 0 if no type at that position),
+// or a single type which is used for the entire block. This only matters if there
+// is initial data - if @slab is a number, then this does not matter at all and is
+// ignored.
+// @allocator: How to allocate memory, see ALLOC_*
+function allocate(slab, types, allocator, ptr) {
+ var zeroinit, size;
+ if (typeof slab === 'number') {
+ zeroinit = true;
+ size = slab;
+ } else {
+ zeroinit = false;
+ size = slab.length;
+ }
+
+ var singleType = typeof types === 'string' ? types : null;
+
+ var ret;
+ if (allocator == ALLOC_NONE) {
+ ret = ptr;
+ } else {
+ ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
+ }
+
+ if (zeroinit) {
+ var ptr = ret, stop;
+ assert((ret & 3) == 0);
+ stop = ret + (size & ~3);
+ for (; ptr < stop; ptr += 4) {
+ HEAP32[((ptr)>>2)]=0;
+ }
+ stop = ret + size;
+ while (ptr < stop) {
+ HEAP8[((ptr++)|0)]=0;
+ }
+ return ret;
+ }
+
+ if (singleType === 'i8') {
+ if (slab.subarray || slab.slice) {
+ HEAPU8.set(slab, ret);
+ } else {
+ HEAPU8.set(new Uint8Array(slab), ret);
+ }
+ return ret;
+ }
+
+ var i = 0, type, typeSize, previousType;
+ while (i < size) {
+ var curr = slab[i];
+
+ if (typeof curr === 'function') {
+ curr = Runtime.getFunctionIndex(curr);
+ }
+
+ type = singleType || types[i];
+ if (type === 0) {
+ i++;
+ continue;
+ }
+
+ if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
+
+ setValue(ret+i, curr, type);
+
+ // no need to look up size unless type changes, so cache it
+ if (previousType !== type) {
+ typeSize = Runtime.getNativeTypeSize(type);
+ previousType = type;
+ }
+ i += typeSize;
+ }
+
+ return ret;
+}
+Module['allocate'] = allocate;
+
+function Pointer_stringify(ptr, /* optional */ length) {
+ // TODO: use TextDecoder
+ // Find the length, and check for UTF while doing so
+ var hasUtf = false;
+ var t;
+ var i = 0;
+ while (1) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ if (t >= 128) hasUtf = true;
+ else if (t == 0 && !length) break;
+ i++;
+ if (length && i == length) break;
+ }
+ if (!length) length = i;
+
+ var ret = '';
+
+ if (!hasUtf) {
+ var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
+ var curr;
+ while (length > 0) {
+ curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
+ ret = ret ? ret + curr : curr;
+ ptr += MAX_CHUNK;
+ length -= MAX_CHUNK;
+ }
+ return ret;
+ }
+
+ var utf8 = new Runtime.UTF8Processor();
+ for (i = 0; i < length; i++) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ ret += utf8.processCChar(t);
+ }
+ return ret;
+}
+Module['Pointer_stringify'] = Pointer_stringify;
+
+// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF16ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
+ if (codeUnit == 0)
+ return str;
+ ++i;
+ // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
+ str += String.fromCharCode(codeUnit);
+ }
+}
+Module['UTF16ToString'] = UTF16ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
+function stringToUTF16(str, outPtr) {
+ for(var i = 0; i < str.length; ++i) {
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
+ HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP16[(((outPtr)+(str.length*2))>>1)]=0;
+}
+Module['stringToUTF16'] = stringToUTF16;
+
+// Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF32ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
+ if (utf32 == 0)
+ return str;
+ ++i;
+ // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
+ if (utf32 >= 0x10000) {
+ var ch = utf32 - 0x10000;
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
+ } else {
+ str += String.fromCharCode(utf32);
+ }
+ }
+}
+Module['UTF32ToString'] = UTF32ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
+// but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.
+function stringToUTF32(str, outPtr) {
+ var iChar = 0;
+ for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
+ var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
+ var trailSurrogate = str.charCodeAt(++iCodeUnit);
+ codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
+ }
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit;
+ ++iChar;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=0;
+}
+Module['stringToUTF32'] = stringToUTF32;
+
+function demangle(func) {
+ var i = 3;
+ // params, etc.
+ var basicTypes = {
+ 'v': 'void',
+ 'b': 'bool',
+ 'c': 'char',
+ 's': 'short',
+ 'i': 'int',
+ 'l': 'long',
+ 'f': 'float',
+ 'd': 'double',
+ 'w': 'wchar_t',
+ 'a': 'signed char',
+ 'h': 'unsigned char',
+ 't': 'unsigned short',
+ 'j': 'unsigned int',
+ 'm': 'unsigned long',
+ 'x': 'long long',
+ 'y': 'unsigned long long',
+ 'z': '...'
+ };
+ var subs = [];
+ var first = true;
+ function dump(x) {
+ //return;
+ if (x) Module.print(x);
+ Module.print(func);
+ var pre = '';
+ for (var a = 0; a < i; a++) pre += ' ';
+ Module.print (pre + '^');
+ }
+ function parseNested() {
+ i++;
+ if (func[i] === 'K') i++; // ignore const
+ var parts = [];
+ while (func[i] !== 'E') {
+ if (func[i] === 'S') { // substitution
+ i++;
+ var next = func.indexOf('_', i);
+ var num = func.substring(i, next) || 0;
+ parts.push(subs[num] || '?');
+ i = next+1;
+ continue;
+ }
+ if (func[i] === 'C') { // constructor
+ parts.push(parts[parts.length-1]);
+ i += 2;
+ continue;
+ }
+ var size = parseInt(func.substr(i));
+ var pre = size.toString().length;
+ if (!size || !pre) { i--; break; } // counter i++ below us
+ var curr = func.substr(i + pre, size);
+ parts.push(curr);
+ subs.push(curr);
+ i += pre + size;
+ }
+ i++; // skip E
+ return parts;
+ }
+ function parse(rawList, limit, allowVoid) { // main parser
+ limit = limit || Infinity;
+ var ret = '', list = [];
+ function flushList() {
+ return '(' + list.join(', ') + ')';
+ }
+ var name;
+ if (func[i] === 'N') {
+ // namespaced N-E
+ name = parseNested().join('::');
+ limit--;
+ if (limit === 0) return rawList ? [name] : name;
+ } else {
+ // not namespaced
+ if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
+ var size = parseInt(func.substr(i));
+ if (size) {
+ var pre = size.toString().length;
+ name = func.substr(i + pre, size);
+ i += pre + size;
+ }
+ }
+ first = false;
+ if (func[i] === 'I') {
+ i++;
+ var iList = parse(true);
+ var iRet = parse(true, 1, true);
+ ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
+ } else {
+ ret = name;
+ }
+ paramLoop: while (i < func.length && limit-- > 0) {
+ //dump('paramLoop');
+ var c = func[i++];
+ if (c in basicTypes) {
+ list.push(basicTypes[c]);
+ } else {
+ switch (c) {
+ case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
+ case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
+ case 'L': { // literal
+ i++; // skip basic type
+ var end = func.indexOf('E', i);
+ var size = end - i;
+ list.push(func.substr(i, size));
+ i += size + 2; // size + 'EE'
+ break;
+ }
+ case 'A': { // array
+ var size = parseInt(func.substr(i));
+ i += size.toString().length;
+ if (func[i] !== '_') throw '?';
+ i++; // skip _
+ list.push(parse(true, 1, true)[0] + ' [' + size + ']');
+ break;
+ }
+ case 'E': break paramLoop;
+ default: ret += '?' + c; break paramLoop;
+ }
+ }
+ }
+ if (!allowVoid && list.length === 1 && list[0] === 'void') list = []; // avoid (void)
+ if (rawList) {
+ if (ret) {
+ list.push(ret + '?');
+ }
+ return list;
+ } else {
+ return ret + flushList();
+ }
+ }
+ try {
+ // Special-case the entry point, since its name differs from other name mangling.
+ if (func == 'Object._main' || func == '_main') {
+ return 'main()';
+ }
+ if (typeof func === 'number') func = Pointer_stringify(func);
+ if (func[0] !== '_') return func;
+ if (func[1] !== '_') return func; // C function
+ if (func[2] !== 'Z') return func;
+ switch (func[3]) {
+ case 'n': return 'operator new()';
+ case 'd': return 'operator delete()';
+ }
+ return parse();
+ } catch(e) {
+ return func;
+ }
+}
+
+function demangleAll(text) {
+ return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });
+}
+
+function stackTrace() {
+ var stack = new Error().stack;
+ return stack ? demangleAll(stack) : '(no stack trace available)'; // Stack trace is not available at least on IE10 and Safari 6.
+}
+
+// Memory management
+
+var PAGE_SIZE = 4096;
+function alignMemoryPage(x) {
+ return (x+4095)&-4096;
+}
+
+var HEAP;
+var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
+
+var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area
+var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area
+var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk
+
+function enlargeMemory() {
+ abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
+}
+
+var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
+var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 134217728;
+var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
+
+var totalMemory = 4096;
+while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
+ if (totalMemory < 16*1024*1024) {
+ totalMemory *= 2;
+ } else {
+ totalMemory += 16*1024*1024
+ }
+}
+if (totalMemory !== TOTAL_MEMORY) {
+ Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
+ TOTAL_MEMORY = totalMemory;
+}
+
+// Initialize the runtime's memory
+// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
+assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
+ 'JS engine does not provide full typed array support');
+
+var buffer = new ArrayBuffer(TOTAL_MEMORY);
+HEAP8 = new Int8Array(buffer);
+HEAP16 = new Int16Array(buffer);
+HEAP32 = new Int32Array(buffer);
+HEAPU8 = new Uint8Array(buffer);
+HEAPU16 = new Uint16Array(buffer);
+HEAPU32 = new Uint32Array(buffer);
+HEAPF32 = new Float32Array(buffer);
+HEAPF64 = new Float64Array(buffer);
+
+// Endianness check (note: assumes compiler arch was little-endian)
+HEAP32[0] = 255;
+assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
+
+Module['HEAP'] = HEAP;
+Module['HEAP8'] = HEAP8;
+Module['HEAP16'] = HEAP16;
+Module['HEAP32'] = HEAP32;
+Module['HEAPU8'] = HEAPU8;
+Module['HEAPU16'] = HEAPU16;
+Module['HEAPU32'] = HEAPU32;
+Module['HEAPF32'] = HEAPF32;
+Module['HEAPF64'] = HEAPF64;
+
+function callRuntimeCallbacks(callbacks) {
+ while(callbacks.length > 0) {
+ var callback = callbacks.shift();
+ if (typeof callback == 'function') {
+ callback();
+ continue;
+ }
+ var func = callback.func;
+ if (typeof func === 'number') {
+ if (callback.arg === undefined) {
+ Runtime.dynCall('v', func);
+ } else {
+ Runtime.dynCall('vi', func, [callback.arg]);
+ }
+ } else {
+ func(callback.arg === undefined ? null : callback.arg);
+ }
+ }
+}
+
+var __ATPRERUN__ = []; // functions called before the runtime is initialized
+var __ATINIT__ = []; // functions called during startup
+var __ATMAIN__ = []; // functions called when main() is to be run
+var __ATEXIT__ = []; // functions called during shutdown
+var __ATPOSTRUN__ = []; // functions called after the runtime has exited
+
+var runtimeInitialized = false;
+
+function preRun() {
+ // compatibility - merge in anything from Module['preRun'] at this time
+ if (Module['preRun']) {
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
+ while (Module['preRun'].length) {
+ addOnPreRun(Module['preRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPRERUN__);
+}
+
+function ensureInitRuntime() {
+ if (runtimeInitialized) return;
+ runtimeInitialized = true;
+ callRuntimeCallbacks(__ATINIT__);
+}
+
+function preMain() {
+ callRuntimeCallbacks(__ATMAIN__);
+}
+
+function exitRuntime() {
+ callRuntimeCallbacks(__ATEXIT__);
+}
+
+function postRun() {
+ // compatibility - merge in anything from Module['postRun'] at this time
+ if (Module['postRun']) {
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
+ while (Module['postRun'].length) {
+ addOnPostRun(Module['postRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPOSTRUN__);
+}
+
+function addOnPreRun(cb) {
+ __ATPRERUN__.unshift(cb);
+}
+Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;
+
+function addOnInit(cb) {
+ __ATINIT__.unshift(cb);
+}
+Module['addOnInit'] = Module.addOnInit = addOnInit;
+
+function addOnPreMain(cb) {
+ __ATMAIN__.unshift(cb);
+}
+Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;
+
+function addOnExit(cb) {
+ __ATEXIT__.unshift(cb);
+}
+Module['addOnExit'] = Module.addOnExit = addOnExit;
+
+function addOnPostRun(cb) {
+ __ATPOSTRUN__.unshift(cb);
+}
+Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;
+
+// Tools
+
+// This processes a JS string into a C-line array of numbers, 0-terminated.
+// For LLVM-originating strings, see parser.js:parseLLVMString function
+function intArrayFromString(stringy, dontAddNull, length /* optional */) {
+ var ret = (new Runtime.UTF8Processor()).processJSString(stringy);
+ if (length) {
+ ret.length = length;
+ }
+ if (!dontAddNull) {
+ ret.push(0);
+ }
+ return ret;
+}
+Module['intArrayFromString'] = intArrayFromString;
+
+function intArrayToString(array) {
+ var ret = [];
+ for (var i = 0; i < array.length; i++) {
+ var chr = array[i];
+ if (chr > 0xFF) {
+ chr &= 0xFF;
+ }
+ ret.push(String.fromCharCode(chr));
+ }
+ return ret.join('');
+}
+Module['intArrayToString'] = intArrayToString;
+
+// Write a Javascript array to somewhere in the heap
+function writeStringToMemory(string, buffer, dontAddNull) {
+ var array = intArrayFromString(string, dontAddNull);
+ var i = 0;
+ while (i < array.length) {
+ var chr = array[i];
+ HEAP8[(((buffer)+(i))|0)]=chr;
+ i = i + 1;
+ }
+}
+Module['writeStringToMemory'] = writeStringToMemory;
+
+function writeArrayToMemory(array, buffer) {
+ for (var i = 0; i < array.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=array[i];
+ }
+}
+Module['writeArrayToMemory'] = writeArrayToMemory;
+
+function writeAsciiToMemory(str, buffer, dontAddNull) {
+ for (var i = 0; i < str.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=str.charCodeAt(i);
+ }
+ if (!dontAddNull) HEAP8[(((buffer)+(str.length))|0)]=0;
+}
+Module['writeAsciiToMemory'] = writeAsciiToMemory;
+
+function unSign(value, bits, ignore) {
+ if (value >= 0) {
+ return value;
+ }
+ return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
+ : Math.pow(2, bits) + value;
+}
+function reSign(value, bits, ignore) {
+ if (value <= 0) {
+ return value;
+ }
+ var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
+ : Math.pow(2, bits-1);
+ if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
+ // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
+ // TODO: In i64 mode 1, resign the two parts separately and safely
+ value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
+ }
+ return value;
+}
+
+// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
+if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
+ var ah = a >>> 16;
+ var al = a & 0xffff;
+ var bh = b >>> 16;
+ var bl = b & 0xffff;
+ return (al*bl + ((ah*bl + al*bh) << 16))|0;
+};
+Math.imul = Math['imul'];
+
+
+var Math_abs = Math.abs;
+var Math_cos = Math.cos;
+var Math_sin = Math.sin;
+var Math_tan = Math.tan;
+var Math_acos = Math.acos;
+var Math_asin = Math.asin;
+var Math_atan = Math.atan;
+var Math_atan2 = Math.atan2;
+var Math_exp = Math.exp;
+var Math_log = Math.log;
+var Math_sqrt = Math.sqrt;
+var Math_ceil = Math.ceil;
+var Math_floor = Math.floor;
+var Math_pow = Math.pow;
+var Math_imul = Math.imul;
+var Math_fround = Math.fround;
+var Math_min = Math.min;
+
+// A counter of dependencies for calling run(). If we need to
+// do asynchronous work before running, increment this and
+// decrement it. Incrementing must happen in a place like
+// PRE_RUN_ADDITIONS (used by emcc to add file preloading).
+// Note that you can add dependencies in preRun, even though
+// it happens right before run - run will be postponed until
+// the dependencies are met.
+var runDependencies = 0;
+var runDependencyWatcher = null;
+var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
+
+function addRunDependency(id) {
+ runDependencies++;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+}
+Module['addRunDependency'] = addRunDependency;
+function removeRunDependency(id) {
+ runDependencies--;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+ if (runDependencies == 0) {
+ if (runDependencyWatcher !== null) {
+ clearInterval(runDependencyWatcher);
+ runDependencyWatcher = null;
+ }
+ if (dependenciesFulfilled) {
+ var callback = dependenciesFulfilled;
+ dependenciesFulfilled = null;
+ callback(); // can add another dependenciesFulfilled
+ }
+ }
+}
+Module['removeRunDependency'] = removeRunDependency;
+
+Module["preloadedImages"] = {}; // maps url to image data
+Module["preloadedAudios"] = {}; // maps url to audio data
+
+
+var memoryInitializer = null;
+
+// === Body ===
+
+
+
+
+
+STATIC_BASE = 8;
+
+STATICTOP = STATIC_BASE + Runtime.alignMemory(1155);
+/* global initializers */ __ATINIT__.push();
+
+
+/* memory initializer */ allocate([38,2,0,0,0,0,0,0,42,0,0,0,0,0,0,0,97,0,0,0,113,61,138,62,0,0,0,0,99,0,0,0,143,194,245,61,0,0,0,0,103,0,0,0,143,194,245,61,0,0,0,0,116,0,0,0,113,61,138,62,0,0,0,0,66,0,0,0,10,215,163,60,0,0,0,0,68,0,0,0,10,215,163,60,0,0,0,0,72,0,0,0,10,215,163,60,0,0,0,0,75,0,0,0,10,215,163,60,0,0,0,0,77,0,0,0,10,215,163,60,0,0,0,0,78,0,0,0,10,215,163,60,0,0,0,0,82,0,0,0,10,215,163,60,0,0,0,0,83,0,0,0,10,215,163,60,0,0,0,0,86,0,0,0,10,215,163,60,0,0,0,0,87,0,0,0,10,215,163,60,0,0,0,0,89,0,0,0,10,215,163,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,97,0,0,0,233,28,155,62,0,0,0,0,99,0,0,0,114,189,74,62,0,0,0,0,103,0,0,0,215,73,74,62,0,0,0,0,116,0,0,0,114,95,154,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,114,114,111,114,58,32,37,100,10,0,0,0,0,0,0,71,71,67,67,71,71,71,67,71,67,71,71,84,71,71,67,84,67,65,67,71,67,67,84,71,84,65,65,84,67,67,67,65,71,67,65,67,84,84,84,71,71,71,65,71,71,67,67,71,65,71,71,67,71,71,71,67,71,71,65,84,67,65,67,67,84,71,65,71,71,84,67,65,71,71,65,71,84,84,67,71,65,71,65,67,67,65,71,67,67,84,71,71,67,67,65,65,67,65,84,71,71,84,71,65,65,65,67,67,67,67,71,84,67,84,67,84,65,67,84,65,65,65,65,65,84,65,67,65,65,65,65,65,84,84,65,71,67,67,71,71,71,67,71,84,71,71,84,71,71,67,71,67,71,67,71,67,67,84,71,84,65,65,84,67,67,67,65,71,67,84,65,67,84,67,71,71,71,65,71,71,67,84,71,65,71,71,67,65,71,71,65,71,65,65,84,67,71,67,84,84,71,65,65,67,67,67,71,71,71,65,71,71,67,71,71,65,71,71,84,84,71,67,65,71,84,71,65,71,67,67,71,65,71,65,84,67,71,67,71,67,67,65,67,84,71,67,65,67,84,67,67,65,71,67,67,84,71,71,71,67,71,65,67,65,71,65,71,67,71,65,71,65,67,84,67,67,71,84,67,84,67,65,65,65,65,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,120,4,0,0,1,0,0,0,2,0,0,0,1,0,0,0,0,0,0,0,115,116,100,58,58,98,97,100,95,97,108,108,111,99,0,0,83,116,57,98,97,100,95,97,108,108,111,99,0,0,0,0,8,0,0,0,104,4,0,0,0,0,0,0,0,0,0,0], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
+
+
+
+
+var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8);
+
+assert(tempDoublePtr % 8 == 0);
+
+function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+}
+
+function copyTempDouble(ptr) {
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+ HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
+
+ HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
+
+ HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
+
+ HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
+
+}
+
+
+
+
+ var ___errno_state=0;function ___setErrNo(value) {
+ // For convenient setting and returning of errno.
+ HEAP32[((___errno_state)>>2)]=value;
+ return value;
+ }
+
+ var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};function _sysconf(name) {
+ // long sysconf(int name);
+ // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html
+ switch(name) {
+ case 30: return PAGE_SIZE;
+ case 132:
+ case 133:
+ case 12:
+ case 137:
+ case 138:
+ case 15:
+ case 235:
+ case 16:
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ case 149:
+ case 13:
+ case 10:
+ case 236:
+ case 153:
+ case 9:
+ case 21:
+ case 22:
+ case 159:
+ case 154:
+ case 14:
+ case 77:
+ case 78:
+ case 139:
+ case 80:
+ case 81:
+ case 79:
+ case 82:
+ case 68:
+ case 67:
+ case 164:
+ case 11:
+ case 29:
+ case 47:
+ case 48:
+ case 95:
+ case 52:
+ case 51:
+ case 46:
+ return 200809;
+ case 27:
+ case 246:
+ case 127:
+ case 128:
+ case 23:
+ case 24:
+ case 160:
+ case 161:
+ case 181:
+ case 182:
+ case 242:
+ case 183:
+ case 184:
+ case 243:
+ case 244:
+ case 245:
+ case 165:
+ case 178:
+ case 179:
+ case 49:
+ case 50:
+ case 168:
+ case 169:
+ case 175:
+ case 170:
+ case 171:
+ case 172:
+ case 97:
+ case 76:
+ case 32:
+ case 173:
+ case 35:
+ return -1;
+ case 176:
+ case 177:
+ case 7:
+ case 155:
+ case 8:
+ case 157:
+ case 125:
+ case 126:
+ case 92:
+ case 93:
+ case 129:
+ case 130:
+ case 131:
+ case 94:
+ case 91:
+ return 1;
+ case 74:
+ case 60:
+ case 69:
+ case 70:
+ case 4:
+ return 1024;
+ case 31:
+ case 42:
+ case 72:
+ return 32;
+ case 87:
+ case 26:
+ case 33:
+ return 2147483647;
+ case 34:
+ case 1:
+ return 47839;
+ case 38:
+ case 36:
+ return 99;
+ case 43:
+ case 37:
+ return 2048;
+ case 0: return 2097152;
+ case 3: return 65536;
+ case 28: return 32768;
+ case 44: return 32767;
+ case 75: return 16384;
+ case 39: return 1000;
+ case 89: return 700;
+ case 71: return 256;
+ case 40: return 255;
+ case 2: return 100;
+ case 180: return 64;
+ case 25: return 20;
+ case 5: return 16;
+ case 6: return 6;
+ case 73: return 4;
+ case 84: return 1;
+ }
+ ___setErrNo(ERRNO_CODES.EINVAL);
+ return -1;
+ }
+
+
+ function __ZSt18uncaught_exceptionv() { // std::uncaught_exception()
+ return !!__ZSt18uncaught_exceptionv.uncaught_exception;
+ }
+
+
+
+ function ___cxa_is_number_type(type) {
+ var isNumber = false;
+ try { if (type == __ZTIi) isNumber = true } catch(e){}
+ try { if (type == __ZTIj) isNumber = true } catch(e){}
+ try { if (type == __ZTIl) isNumber = true } catch(e){}
+ try { if (type == __ZTIm) isNumber = true } catch(e){}
+ try { if (type == __ZTIx) isNumber = true } catch(e){}
+ try { if (type == __ZTIy) isNumber = true } catch(e){}
+ try { if (type == __ZTIf) isNumber = true } catch(e){}
+ try { if (type == __ZTId) isNumber = true } catch(e){}
+ try { if (type == __ZTIe) isNumber = true } catch(e){}
+ try { if (type == __ZTIc) isNumber = true } catch(e){}
+ try { if (type == __ZTIa) isNumber = true } catch(e){}
+ try { if (type == __ZTIh) isNumber = true } catch(e){}
+ try { if (type == __ZTIs) isNumber = true } catch(e){}
+ try { if (type == __ZTIt) isNumber = true } catch(e){}
+ return isNumber;
+ }function ___cxa_does_inherit(definiteType, possibilityType, possibility) {
+ if (possibility == 0) return false;
+ if (possibilityType == 0 || possibilityType == definiteType)
+ return true;
+ var possibility_type_info;
+ if (___cxa_is_number_type(possibilityType)) {
+ possibility_type_info = possibilityType;
+ } else {
+ var possibility_type_infoAddr = HEAP32[((possibilityType)>>2)] - 8;
+ possibility_type_info = HEAP32[((possibility_type_infoAddr)>>2)];
+ }
+ switch (possibility_type_info) {
+ case 0: // possibility is a pointer
+ // See if definite type is a pointer
+ var definite_type_infoAddr = HEAP32[((definiteType)>>2)] - 8;
+ var definite_type_info = HEAP32[((definite_type_infoAddr)>>2)];
+ if (definite_type_info == 0) {
+ // Also a pointer; compare base types of pointers
+ var defPointerBaseAddr = definiteType+8;
+ var defPointerBaseType = HEAP32[((defPointerBaseAddr)>>2)];
+ var possPointerBaseAddr = possibilityType+8;
+ var possPointerBaseType = HEAP32[((possPointerBaseAddr)>>2)];
+ return ___cxa_does_inherit(defPointerBaseType, possPointerBaseType, possibility);
+ } else
+ return false; // one pointer and one non-pointer
+ case 1: // class with no base class
+ return false;
+ case 2: // class with base class
+ var parentTypeAddr = possibilityType + 8;
+ var parentType = HEAP32[((parentTypeAddr)>>2)];
+ return ___cxa_does_inherit(definiteType, parentType, possibility);
+ default:
+ return false; // some unencountered type
+ }
+ }
+
+
+
+ var ___cxa_last_thrown_exception=0;function ___resumeException(ptr) {
+ if (!___cxa_last_thrown_exception) { ___cxa_last_thrown_exception = ptr; }
+ throw ptr + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";
+ }
+
+ var ___cxa_exception_header_size=8;function ___cxa_find_matching_catch(thrown, throwntype) {
+ if (thrown == -1) thrown = ___cxa_last_thrown_exception;
+ header = thrown - ___cxa_exception_header_size;
+ if (throwntype == -1) throwntype = HEAP32[((header)>>2)];
+ var typeArray = Array.prototype.slice.call(arguments, 2);
+
+ // If throwntype is a pointer, this means a pointer has been
+ // thrown. When a pointer is thrown, actually what's thrown
+ // is a pointer to the pointer. We'll dereference it.
+ if (throwntype != 0 && !___cxa_is_number_type(throwntype)) {
+ var throwntypeInfoAddr= HEAP32[((throwntype)>>2)] - 8;
+ var throwntypeInfo= HEAP32[((throwntypeInfoAddr)>>2)];
+ if (throwntypeInfo == 0)
+ thrown = HEAP32[((thrown)>>2)];
+ }
+ // The different catch blocks are denoted by different types.
+ // Due to inheritance, those types may not precisely match the
+ // type of the thrown object. Find one which matches, and
+ // return the type of the catch block which should be called.
+ for (var i = 0; i < typeArray.length; i++) {
+ if (___cxa_does_inherit(typeArray[i], throwntype, thrown))
+ return ((asm["setTempRet0"](typeArray[i]),thrown)|0);
+ }
+ // Shouldn't happen unless we have bogus data in typeArray
+ // or encounter a type for which emscripten doesn't have suitable
+ // typeinfo defined. Best-efforts match just in case.
+ return ((asm["setTempRet0"](throwntype),thrown)|0);
+ }function ___cxa_throw(ptr, type, destructor) {
+ if (!___cxa_throw.initialized) {
+ try {
+ HEAP32[((__ZTVN10__cxxabiv119__pointer_type_infoE)>>2)]=0; // Workaround for libcxxabi integration bug
+ } catch(e){}
+ try {
+ HEAP32[((__ZTVN10__cxxabiv117__class_type_infoE)>>2)]=1; // Workaround for libcxxabi integration bug
+ } catch(e){}
+ try {
+ HEAP32[((__ZTVN10__cxxabiv120__si_class_type_infoE)>>2)]=2; // Workaround for libcxxabi integration bug
+ } catch(e){}
+ ___cxa_throw.initialized = true;
+ }
+ var header = ptr - ___cxa_exception_header_size;
+ HEAP32[((header)>>2)]=type;
+ HEAP32[(((header)+(4))>>2)]=destructor;
+ ___cxa_last_thrown_exception = ptr;
+ if (!("uncaught_exception" in __ZSt18uncaught_exceptionv)) {
+ __ZSt18uncaught_exceptionv.uncaught_exception = 1;
+ } else {
+ __ZSt18uncaught_exceptionv.uncaught_exception++;
+ }
+ throw ptr + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";
+ }
+
+
+ Module["_memset"] = _memset;
+
+ function _abort() {
+ Module['abort']();
+ }
+
+
+
+
+
+ var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
+
+ var PATH={splitPath:function (filename) {
+ var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
+ return splitPathRe.exec(filename).slice(1);
+ },normalizeArray:function (parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length - 1; i >= 0; i--) {
+ var last = parts[i];
+ if (last === '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+ return parts;
+ },normalize:function (path) {
+ var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.substr(-1) === '/';
+ // Normalize the path
+ path = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+ return (isAbsolute ? '/' : '') + path;
+ },dirname:function (path) {
+ var result = PATH.splitPath(path),
+ root = result[0],
+ dir = result[1];
+ if (!root && !dir) {
+ // No dirname whatsoever
+ return '.';
+ }
+ if (dir) {
+ // It has a dirname, strip trailing slash
+ dir = dir.substr(0, dir.length - 1);
+ }
+ return root + dir;
+ },basename:function (path) {
+ // EMSCRIPTEN return '/'' for '/', not an empty string
+ if (path === '/') return '/';
+ var lastSlash = path.lastIndexOf('/');
+ if (lastSlash === -1) return path;
+ return path.substr(lastSlash+1);
+ },extname:function (path) {
+ return PATH.splitPath(path)[3];
+ },join:function () {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return PATH.normalize(paths.join('/'));
+ },join2:function (l, r) {
+ return PATH.normalize(l + '/' + r);
+ },resolve:function () {
+ var resolvedPath = '',
+ resolvedAbsolute = false;
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0) ? arguments[i] : FS.cwd();
+ // Skip empty and invalid entries
+ if (typeof path !== 'string') {
+ throw new TypeError('Arguments to path.resolve must be strings');
+ } else if (!path) {
+ continue;
+ }
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+ }
+ // At this point the path should be resolved to a full absolute path, but
+ // handle relative paths to be safe (might happen when process.cwd() fails)
+ resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+ },relative:function (from, to) {
+ from = PATH.resolve(from).substr(1);
+ to = PATH.resolve(to).substr(1);
+ function trim(arr) {
+ var start = 0;
+ for (; start < arr.length; start++) {
+ if (arr[start] !== '') break;
+ }
+ var end = arr.length - 1;
+ for (; end >= 0; end--) {
+ if (arr[end] !== '') break;
+ }
+ if (start > end) return [];
+ return arr.slice(start, end - start + 1);
+ }
+ var fromParts = trim(from.split('/'));
+ var toParts = trim(to.split('/'));
+ var length = Math.min(fromParts.length, toParts.length);
+ var samePartsLength = length;
+ for (var i = 0; i < length; i++) {
+ if (fromParts[i] !== toParts[i]) {
+ samePartsLength = i;
+ break;
+ }
+ }
+ var outputParts = [];
+ for (var i = samePartsLength; i < fromParts.length; i++) {
+ outputParts.push('..');
+ }
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
+ return outputParts.join('/');
+ }};
+
+ var TTY={ttys:[],init:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // currently, FS.init does not distinguish if process.stdin is a file or TTY
+ // // device, it always assumes it's a TTY device. because of this, we're forcing
+ // // process.stdin to UTF8 encoding to at least make stdin reading compatible
+ // // with text files until FS.init can be refactored.
+ // process['stdin']['setEncoding']('utf8');
+ // }
+ },shutdown:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
+ // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
+ // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
+ // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
+ // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
+ // process['stdin']['pause']();
+ // }
+ },register:function (dev, ops) {
+ TTY.ttys[dev] = { input: [], output: [], ops: ops };
+ FS.registerDevice(dev, TTY.stream_ops);
+ },stream_ops:{open:function (stream) {
+ var tty = TTY.ttys[stream.node.rdev];
+ if (!tty) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ stream.tty = tty;
+ stream.seekable = false;
+ },close:function (stream) {
+ // flush any pending line data
+ if (stream.tty.output.length) {
+ stream.tty.ops.put_char(stream.tty, 10);
+ }
+ },read:function (stream, buffer, offset, length, pos /* ignored */) {
+ if (!stream.tty || !stream.tty.ops.get_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = stream.tty.ops.get_char(stream.tty);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, pos) {
+ if (!stream.tty || !stream.tty.ops.put_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ for (var i = 0; i < length; i++) {
+ try {
+ stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }},default_tty_ops:{get_char:function (tty) {
+ if (!tty.input.length) {
+ var result = null;
+ if (ENVIRONMENT_IS_NODE) {
+ result = process['stdin']['read']();
+ if (!result) {
+ if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
+ return null; // EOF
+ }
+ return undefined; // no data available
+ }
+ } else if (typeof window != 'undefined' &&
+ typeof window.prompt == 'function') {
+ // Browser.
+ result = window.prompt('Input: '); // returns null on cancel
+ if (result !== null) {
+ result += '\n';
+ }
+ } else if (typeof readline == 'function') {
+ // Command line.
+ result = readline();
+ if (result !== null) {
+ result += '\n';
+ }
+ }
+ if (!result) {
+ return null;
+ }
+ tty.input = intArrayFromString(result, true);
+ }
+ return tty.input.shift();
+ },put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['print'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }},default_tty1_ops:{put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['printErr'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }}};
+
+ var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
+ return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
+ // no supported
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (!MEMFS.ops_table) {
+ MEMFS.ops_table = {
+ dir: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ lookup: MEMFS.node_ops.lookup,
+ mknod: MEMFS.node_ops.mknod,
+ rename: MEMFS.node_ops.rename,
+ unlink: MEMFS.node_ops.unlink,
+ rmdir: MEMFS.node_ops.rmdir,
+ readdir: MEMFS.node_ops.readdir,
+ symlink: MEMFS.node_ops.symlink
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek
+ }
+ },
+ file: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek,
+ read: MEMFS.stream_ops.read,
+ write: MEMFS.stream_ops.write,
+ allocate: MEMFS.stream_ops.allocate,
+ mmap: MEMFS.stream_ops.mmap
+ }
+ },
+ link: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ readlink: MEMFS.node_ops.readlink
+ },
+ stream: {}
+ },
+ chrdev: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: FS.chrdev_stream_ops
+ },
+ };
+ }
+ var node = FS.createNode(parent, name, mode, dev);
+ if (FS.isDir(node.mode)) {
+ node.node_ops = MEMFS.ops_table.dir.node;
+ node.stream_ops = MEMFS.ops_table.dir.stream;
+ node.contents = {};
+ } else if (FS.isFile(node.mode)) {
+ node.node_ops = MEMFS.ops_table.file.node;
+ node.stream_ops = MEMFS.ops_table.file.stream;
+ node.contents = [];
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ } else if (FS.isLink(node.mode)) {
+ node.node_ops = MEMFS.ops_table.link.node;
+ node.stream_ops = MEMFS.ops_table.link.stream;
+ } else if (FS.isChrdev(node.mode)) {
+ node.node_ops = MEMFS.ops_table.chrdev.node;
+ node.stream_ops = MEMFS.ops_table.chrdev.stream;
+ }
+ node.timestamp = Date.now();
+ // add the new node to the parent
+ if (parent) {
+ parent.contents[name] = node;
+ }
+ return node;
+ },ensureFlexible:function (node) {
+ if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
+ var contents = node.contents;
+ node.contents = Array.prototype.slice.call(contents);
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ }
+ },node_ops:{getattr:function (node) {
+ var attr = {};
+ // device numbers reuse inode numbers.
+ attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
+ attr.ino = node.id;
+ attr.mode = node.mode;
+ attr.nlink = 1;
+ attr.uid = 0;
+ attr.gid = 0;
+ attr.rdev = node.rdev;
+ if (FS.isDir(node.mode)) {
+ attr.size = 4096;
+ } else if (FS.isFile(node.mode)) {
+ attr.size = node.contents.length;
+ } else if (FS.isLink(node.mode)) {
+ attr.size = node.link.length;
+ } else {
+ attr.size = 0;
+ }
+ attr.atime = new Date(node.timestamp);
+ attr.mtime = new Date(node.timestamp);
+ attr.ctime = new Date(node.timestamp);
+ // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
+ // but this is not required by the standard.
+ attr.blksize = 4096;
+ attr.blocks = Math.ceil(attr.size / attr.blksize);
+ return attr;
+ },setattr:function (node, attr) {
+ if (attr.mode !== undefined) {
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ node.timestamp = attr.timestamp;
+ }
+ if (attr.size !== undefined) {
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ if (attr.size < contents.length) contents.length = attr.size;
+ else while (attr.size > contents.length) contents.push(0);
+ }
+ },lookup:function (parent, name) {
+ throw FS.genericErrors[ERRNO_CODES.ENOENT];
+ },mknod:function (parent, name, mode, dev) {
+ return MEMFS.createNode(parent, name, mode, dev);
+ },rename:function (old_node, new_dir, new_name) {
+ // if we're overwriting a directory at new_name, make sure it's empty.
+ if (FS.isDir(old_node.mode)) {
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ }
+ if (new_node) {
+ for (var i in new_node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ }
+ }
+ // do the internal rewiring
+ delete old_node.parent.contents[old_node.name];
+ old_node.name = new_name;
+ new_dir.contents[new_name] = old_node;
+ old_node.parent = new_dir;
+ },unlink:function (parent, name) {
+ delete parent.contents[name];
+ },rmdir:function (parent, name) {
+ var node = FS.lookupNode(parent, name);
+ for (var i in node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ delete parent.contents[name];
+ },readdir:function (node) {
+ var entries = ['.', '..']
+ for (var key in node.contents) {
+ if (!node.contents.hasOwnProperty(key)) {
+ continue;
+ }
+ entries.push(key);
+ }
+ return entries;
+ },symlink:function (parent, newname, oldpath) {
+ var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
+ node.link = oldpath;
+ return node;
+ },readlink:function (node) {
+ if (!FS.isLink(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return node.link;
+ }},stream_ops:{read:function (stream, buffer, offset, length, position) {
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (size > 8 && contents.subarray) { // non-trivial, and typed array
+ buffer.set(contents.subarray(position, position + size), offset);
+ } else
+ {
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ }
+ return size;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ var node = stream.node;
+ node.timestamp = Date.now();
+ var contents = node.contents;
+ if (length && contents.length === 0 && position === 0 && buffer.subarray) {
+ // just replace it with the new data
+ if (canOwn && offset === 0) {
+ node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
+ node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
+ } else {
+ node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
+ node.contentMode = MEMFS.CONTENT_FIXED;
+ }
+ return length;
+ }
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ while (contents.length < position) contents.push(0);
+ for (var i = 0; i < length; i++) {
+ contents[position + i] = buffer[offset + i];
+ }
+ return length;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ position += stream.node.contents.length;
+ }
+ }
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ stream.ungotten = [];
+ stream.position = position;
+ return position;
+ },allocate:function (stream, offset, length) {
+ MEMFS.ensureFlexible(stream.node);
+ var contents = stream.node.contents;
+ var limit = offset + length;
+ while (limit > contents.length) contents.push(0);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ if (!FS.isFile(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ var ptr;
+ var allocated;
+ var contents = stream.node.contents;
+ // Only make a new copy when MAP_PRIVATE is specified.
+ if ( !(flags & 2) &&
+ (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
+ // We can't emulate MAP_SHARED when the file is not backed by the buffer
+ // we're mapping to (e.g. the HEAP buffer).
+ allocated = false;
+ ptr = contents.byteOffset;
+ } else {
+ // Try to avoid unnecessary slices.
+ if (position > 0 || position + length < contents.length) {
+ if (contents.subarray) {
+ contents = contents.subarray(position, position + length);
+ } else {
+ contents = Array.prototype.slice.call(contents, position, position + length);
+ }
+ }
+ allocated = true;
+ ptr = _malloc(length);
+ if (!ptr) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
+ }
+ buffer.set(contents, ptr);
+ }
+ return { ptr: ptr, allocated: allocated };
+ }}};
+
+ var IDBFS={dbs:{},indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
+ // reuse all of the core MEMFS functionality
+ return MEMFS.mount.apply(null, arguments);
+ },syncfs:function (mount, populate, callback) {
+ IDBFS.getLocalSet(mount, function(err, local) {
+ if (err) return callback(err);
+
+ IDBFS.getRemoteSet(mount, function(err, remote) {
+ if (err) return callback(err);
+
+ var src = populate ? remote : local;
+ var dst = populate ? local : remote;
+
+ IDBFS.reconcile(src, dst, callback);
+ });
+ });
+ },getDB:function (name, callback) {
+ // check the cache first
+ var db = IDBFS.dbs[name];
+ if (db) {
+ return callback(null, db);
+ }
+
+ var req;
+ try {
+ req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
+ } catch (e) {
+ return callback(e);
+ }
+ req.onupgradeneeded = function(e) {
+ var db = e.target.result;
+ var transaction = e.target.transaction;
+
+ var fileStore;
+
+ if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
+ fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ } else {
+ fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
+ }
+
+ fileStore.createIndex('timestamp', 'timestamp', { unique: false });
+ };
+ req.onsuccess = function() {
+ db = req.result;
+
+ // add to the cache
+ IDBFS.dbs[name] = db;
+ callback(null, db);
+ };
+ req.onerror = function() {
+ callback(this.error);
+ };
+ },getLocalSet:function (mount, callback) {
+ var entries = {};
+
+ function isRealDir(p) {
+ return p !== '.' && p !== '..';
+ };
+ function toAbsolute(root) {
+ return function(p) {
+ return PATH.join2(root, p);
+ }
+ };
+
+ var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
+
+ while (check.length) {
+ var path = check.pop();
+ var stat;
+
+ try {
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
+ }
+
+ entries[path] = { timestamp: stat.mtime };
+ }
+
+ return callback(null, { type: 'local', entries: entries });
+ },getRemoteSet:function (mount, callback) {
+ var entries = {};
+
+ IDBFS.getDB(mount.mountpoint, function(err, db) {
+ if (err) return callback(err);
+
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
+ transaction.onerror = function() { callback(this.error); };
+
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ var index = store.index('timestamp');
+
+ index.openKeyCursor().onsuccess = function(event) {
+ var cursor = event.target.result;
+
+ if (!cursor) {
+ return callback(null, { type: 'remote', db: db, entries: entries });
+ }
+
+ entries[cursor.primaryKey] = { timestamp: cursor.key };
+
+ cursor.continue();
+ };
+ });
+ },loadLocalEntry:function (path, callback) {
+ var stat, node;
+
+ try {
+ var lookup = FS.lookupPath(path);
+ node = lookup.node;
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode });
+ } else if (FS.isFile(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+ },storeLocalEntry:function (path, entry, callback) {
+ try {
+ if (FS.isDir(entry.mode)) {
+ FS.mkdir(path, entry.mode);
+ } else if (FS.isFile(entry.mode)) {
+ FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+
+ FS.utime(path, entry.timestamp, entry.timestamp);
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },removeLocalEntry:function (path, callback) {
+ try {
+ var lookup = FS.lookupPath(path);
+ var stat = FS.stat(path);
+
+ if (FS.isDir(stat.mode)) {
+ FS.rmdir(path);
+ } else if (FS.isFile(stat.mode)) {
+ FS.unlink(path);
+ }
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },loadRemoteEntry:function (store, path, callback) {
+ var req = store.get(path);
+ req.onsuccess = function(event) { callback(null, event.target.result); };
+ req.onerror = function() { callback(this.error); };
+ },storeRemoteEntry:function (store, path, entry, callback) {
+ var req = store.put(entry, path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },removeRemoteEntry:function (store, path, callback) {
+ var req = store.delete(path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },reconcile:function (src, dst, callback) {
+ var total = 0;
+
+ var create = [];
+ Object.keys(src.entries).forEach(function (key) {
+ var e = src.entries[key];
+ var e2 = dst.entries[key];
+ if (!e2 || e.timestamp > e2.timestamp) {
+ create.push(key);
+ total++;
+ }
+ });
+
+ var remove = [];
+ Object.keys(dst.entries).forEach(function (key) {
+ var e = dst.entries[key];
+ var e2 = src.entries[key];
+ if (!e2) {
+ remove.push(key);
+ total++;
+ }
+ });
+
+ if (!total) {
+ return callback(null);
+ }
+
+ var errored = false;
+ var completed = 0;
+ var db = src.type === 'remote' ? src.db : dst.db;
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= total) {
+ return callback(null);
+ }
+ };
+
+ transaction.onerror = function() { done(this.error); };
+
+ // sort paths in ascending order so directory entries are created
+ // before the files inside them
+ create.sort().forEach(function (path) {
+ if (dst.type === 'local') {
+ IDBFS.loadRemoteEntry(store, path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeLocalEntry(path, entry, done);
+ });
+ } else {
+ IDBFS.loadLocalEntry(path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeRemoteEntry(store, path, entry, done);
+ });
+ }
+ });
+
+ // sort paths in descending order so files are deleted before their
+ // parent directories
+ remove.sort().reverse().forEach(function(path) {
+ if (dst.type === 'local') {
+ IDBFS.removeLocalEntry(path, done);
+ } else {
+ IDBFS.removeRemoteEntry(store, path, done);
+ }
+ });
+ }};
+
+ var NODEFS={isWindows:false,staticInit:function () {
+ NODEFS.isWindows = !!process.platform.match(/^win/);
+ },mount:function (mount) {
+ assert(ENVIRONMENT_IS_NODE);
+ return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node = FS.createNode(parent, name, mode);
+ node.node_ops = NODEFS.node_ops;
+ node.stream_ops = NODEFS.stream_ops;
+ return node;
+ },getMode:function (path) {
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ if (NODEFS.isWindows) {
+ // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so
+ // propagate write bits to execute bits.
+ stat.mode = stat.mode | ((stat.mode & 146) >> 1);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return stat.mode;
+ },realPath:function (node) {
+ var parts = [];
+ while (node.parent !== node) {
+ parts.push(node.name);
+ node = node.parent;
+ }
+ parts.push(node.mount.opts.root);
+ parts.reverse();
+ return PATH.join.apply(null, parts);
+ },flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function (flags) {
+ if (flags in NODEFS.flagsToPermissionStringMap) {
+ return NODEFS.flagsToPermissionStringMap[flags];
+ } else {
+ return flags;
+ }
+ },node_ops:{getattr:function (node) {
+ var path = NODEFS.realPath(node);
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
+ // See http://support.microsoft.com/kb/140365
+ if (NODEFS.isWindows && !stat.blksize) {
+ stat.blksize = 4096;
+ }
+ if (NODEFS.isWindows && !stat.blocks) {
+ stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
+ }
+ return {
+ dev: stat.dev,
+ ino: stat.ino,
+ mode: stat.mode,
+ nlink: stat.nlink,
+ uid: stat.uid,
+ gid: stat.gid,
+ rdev: stat.rdev,
+ size: stat.size,
+ atime: stat.atime,
+ mtime: stat.mtime,
+ ctime: stat.ctime,
+ blksize: stat.blksize,
+ blocks: stat.blocks
+ };
+ },setattr:function (node, attr) {
+ var path = NODEFS.realPath(node);
+ try {
+ if (attr.mode !== undefined) {
+ fs.chmodSync(path, attr.mode);
+ // update the common node structure mode as well
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ var date = new Date(attr.timestamp);
+ fs.utimesSync(path, date, date);
+ }
+ if (attr.size !== undefined) {
+ fs.truncateSync(path, attr.size);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },lookup:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ var mode = NODEFS.getMode(path);
+ return NODEFS.createNode(parent, name, mode);
+ },mknod:function (parent, name, mode, dev) {
+ var node = NODEFS.createNode(parent, name, mode, dev);
+ // create the backing node for this in the fs root as well
+ var path = NODEFS.realPath(node);
+ try {
+ if (FS.isDir(node.mode)) {
+ fs.mkdirSync(path, node.mode);
+ } else {
+ fs.writeFileSync(path, '', { mode: node.mode });
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return node;
+ },rename:function (oldNode, newDir, newName) {
+ var oldPath = NODEFS.realPath(oldNode);
+ var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
+ try {
+ fs.renameSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },unlink:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.unlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },rmdir:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.rmdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readdir:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },symlink:function (parent, newName, oldPath) {
+ var newPath = PATH.join2(NODEFS.realPath(parent), newName);
+ try {
+ fs.symlinkSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readlink:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }},stream_ops:{open:function (stream) {
+ var path = NODEFS.realPath(stream.node);
+ try {
+ if (FS.isFile(stream.node.mode)) {
+ stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },close:function (stream) {
+ try {
+ if (FS.isFile(stream.node.mode) && stream.nfd) {
+ fs.closeSync(stream.nfd);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },read:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(length);
+ var res;
+ try {
+ res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ if (res > 0) {
+ for (var i = 0; i < res; i++) {
+ buffer[offset + i] = nbuffer[i];
+ }
+ }
+ return res;
+ },write:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
+ var res;
+ try {
+ res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return res;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ try {
+ var stat = fs.fstatSync(stream.nfd);
+ position += stat.size;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }
+ }
+
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ stream.position = position;
+ return position;
+ }}};
+
+ var _stdin=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stdout=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stderr=allocate(1, "i32*", ALLOC_STATIC);
+
+ function _fflush(stream) {
+ // int fflush(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html
+ // we don't currently perform any user-space buffering of data
+ }var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},handleFSError:function (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
+ return ___setErrNo(e.errno);
+ },lookupPath:function (path, opts) {
+ path = PATH.resolve(FS.cwd(), path);
+ opts = opts || {};
+
+ var defaults = {
+ follow_mount: true,
+ recurse_count: 0
+ };
+ for (var key in defaults) {
+ if (opts[key] === undefined) {
+ opts[key] = defaults[key];
+ }
+ }
+
+ if (opts.recurse_count > 8) { // max recursive lookup of 8
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+
+ // split the path
+ var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), false);
+
+ // start at the root
+ var current = FS.root;
+ var current_path = '/';
+
+ for (var i = 0; i < parts.length; i++) {
+ var islast = (i === parts.length-1);
+ if (islast && opts.parent) {
+ // stop resolving
+ break;
+ }
+
+ current = FS.lookupNode(current, parts[i]);
+ current_path = PATH.join2(current_path, parts[i]);
+
+ // jump to the mount's root node if this is a mountpoint
+ if (FS.isMountpoint(current)) {
+ if (!islast || (islast && opts.follow_mount)) {
+ current = current.mounted.root;
+ }
+ }
+
+ // by default, lookupPath will not follow a symlink if it is the final path component.
+ // setting opts.follow = true will override this behavior.
+ if (!islast || opts.follow) {
+ var count = 0;
+ while (FS.isLink(current.mode)) {
+ var link = FS.readlink(current_path);
+ current_path = PATH.resolve(PATH.dirname(current_path), link);
+
+ var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
+ current = lookup.node;
+
+ if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+ }
+ }
+ }
+
+ return { path: current_path, node: current };
+ },getPath:function (node) {
+ var path;
+ while (true) {
+ if (FS.isRoot(node)) {
+ var mount = node.mount.mountpoint;
+ if (!path) return mount;
+ return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
+ }
+ path = path ? node.name + '/' + path : node.name;
+ node = node.parent;
+ }
+ },hashName:function (parentid, name) {
+ var hash = 0;
+
+
+ for (var i = 0; i < name.length; i++) {
+ hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
+ }
+ return ((parentid + hash) >>> 0) % FS.nameTable.length;
+ },hashAddNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ node.name_next = FS.nameTable[hash];
+ FS.nameTable[hash] = node;
+ },hashRemoveNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ if (FS.nameTable[hash] === node) {
+ FS.nameTable[hash] = node.name_next;
+ } else {
+ var current = FS.nameTable[hash];
+ while (current) {
+ if (current.name_next === node) {
+ current.name_next = node.name_next;
+ break;
+ }
+ current = current.name_next;
+ }
+ }
+ },lookupNode:function (parent, name) {
+ var err = FS.mayLookup(parent);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ var hash = FS.hashName(parent.id, name);
+ for (var node = FS.nameTable[hash]; node; node = node.name_next) {
+ var nodeName = node.name;
+ if (node.parent.id === parent.id && nodeName === name) {
+ return node;
+ }
+ }
+ // if we failed to find it in the cache, call into the VFS
+ return FS.lookup(parent, name);
+ },createNode:function (parent, name, mode, rdev) {
+ if (!FS.FSNode) {
+ FS.FSNode = function(parent, name, mode, rdev) {
+ if (!parent) {
+ parent = this; // root node sets parent to itself
+ }
+ this.parent = parent;
+ this.mount = parent.mount;
+ this.mounted = null;
+ this.id = FS.nextInode++;
+ this.name = name;
+ this.mode = mode;
+ this.node_ops = {};
+ this.stream_ops = {};
+ this.rdev = rdev;
+ };
+
+ FS.FSNode.prototype = {};
+
+ // compatibility
+ var readMode = 292 | 73;
+ var writeMode = 146;
+
+ // NOTE we must use Object.defineProperties instead of individual calls to
+ // Object.defineProperty in order to make closure compiler happy
+ Object.defineProperties(FS.FSNode.prototype, {
+ read: {
+ get: function() { return (this.mode & readMode) === readMode; },
+ set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
+ },
+ write: {
+ get: function() { return (this.mode & writeMode) === writeMode; },
+ set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
+ },
+ isFolder: {
+ get: function() { return FS.isDir(this.mode); },
+ },
+ isDevice: {
+ get: function() { return FS.isChrdev(this.mode); },
+ },
+ });
+ }
+
+ var node = new FS.FSNode(parent, name, mode, rdev);
+
+ FS.hashAddNode(node);
+
+ return node;
+ },destroyNode:function (node) {
+ FS.hashRemoveNode(node);
+ },isRoot:function (node) {
+ return node === node.parent;
+ },isMountpoint:function (node) {
+ return !!node.mounted;
+ },isFile:function (mode) {
+ return (mode & 61440) === 32768;
+ },isDir:function (mode) {
+ return (mode & 61440) === 16384;
+ },isLink:function (mode) {
+ return (mode & 61440) === 40960;
+ },isChrdev:function (mode) {
+ return (mode & 61440) === 8192;
+ },isBlkdev:function (mode) {
+ return (mode & 61440) === 24576;
+ },isFIFO:function (mode) {
+ return (mode & 61440) === 4096;
+ },isSocket:function (mode) {
+ return (mode & 49152) === 49152;
+ },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
+ var flags = FS.flagModes[str];
+ if (typeof flags === 'undefined') {
+ throw new Error('Unknown file open mode: ' + str);
+ }
+ return flags;
+ },flagsToPermissionString:function (flag) {
+ var accmode = flag & 2097155;
+ var perms = ['r', 'w', 'rw'][accmode];
+ if ((flag & 512)) {
+ perms += 'w';
+ }
+ return perms;
+ },nodePermissions:function (node, perms) {
+ if (FS.ignorePermissions) {
+ return 0;
+ }
+ // return 0 if any user, group or owner bits are set.
+ if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
+ return ERRNO_CODES.EACCES;
+ }
+ return 0;
+ },mayLookup:function (dir) {
+ return FS.nodePermissions(dir, 'x');
+ },mayCreate:function (dir, name) {
+ try {
+ var node = FS.lookupNode(dir, name);
+ return ERRNO_CODES.EEXIST;
+ } catch (e) {
+ }
+ return FS.nodePermissions(dir, 'wx');
+ },mayDelete:function (dir, name, isdir) {
+ var node;
+ try {
+ node = FS.lookupNode(dir, name);
+ } catch (e) {
+ return e.errno;
+ }
+ var err = FS.nodePermissions(dir, 'wx');
+ if (err) {
+ return err;
+ }
+ if (isdir) {
+ if (!FS.isDir(node.mode)) {
+ return ERRNO_CODES.ENOTDIR;
+ }
+ if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
+ return ERRNO_CODES.EBUSY;
+ }
+ } else {
+ if (FS.isDir(node.mode)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return 0;
+ },mayOpen:function (node, flags) {
+ if (!node) {
+ return ERRNO_CODES.ENOENT;
+ }
+ if (FS.isLink(node.mode)) {
+ return ERRNO_CODES.ELOOP;
+ } else if (FS.isDir(node.mode)) {
+ if ((flags & 2097155) !== 0 || // opening for write
+ (flags & 512)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
+ },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
+ fd_start = fd_start || 0;
+ fd_end = fd_end || FS.MAX_OPEN_FDS;
+ for (var fd = fd_start; fd <= fd_end; fd++) {
+ if (!FS.streams[fd]) {
+ return fd;
+ }
+ }
+ throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
+ },getStream:function (fd) {
+ return FS.streams[fd];
+ },createStream:function (stream, fd_start, fd_end) {
+ if (!FS.FSStream) {
+ FS.FSStream = function(){};
+ FS.FSStream.prototype = {};
+ // compatibility
+ Object.defineProperties(FS.FSStream.prototype, {
+ object: {
+ get: function() { return this.node; },
+ set: function(val) { this.node = val; }
+ },
+ isRead: {
+ get: function() { return (this.flags & 2097155) !== 1; }
+ },
+ isWrite: {
+ get: function() { return (this.flags & 2097155) !== 0; }
+ },
+ isAppend: {
+ get: function() { return (this.flags & 1024); }
+ }
+ });
+ }
+ if (0) {
+ // reuse the object
+ stream.__proto__ = FS.FSStream.prototype;
+ } else {
+ var newStream = new FS.FSStream();
+ for (var p in stream) {
+ newStream[p] = stream[p];
+ }
+ stream = newStream;
+ }
+ var fd = FS.nextfd(fd_start, fd_end);
+ stream.fd = fd;
+ FS.streams[fd] = stream;
+ return stream;
+ },closeStream:function (fd) {
+ FS.streams[fd] = null;
+ },getStreamFromPtr:function (ptr) {
+ return FS.streams[ptr - 1];
+ },getPtrForStream:function (stream) {
+ return stream ? stream.fd + 1 : 0;
+ },chrdev_stream_ops:{open:function (stream) {
+ var device = FS.getDevice(stream.node.rdev);
+ // override node's stream ops with the device's
+ stream.stream_ops = device.stream_ops;
+ // forward the open call
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ },llseek:function () {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }},major:function (dev) {
+ return ((dev) >> 8);
+ },minor:function (dev) {
+ return ((dev) & 0xff);
+ },makedev:function (ma, mi) {
+ return ((ma) << 8 | (mi));
+ },registerDevice:function (dev, ops) {
+ FS.devices[dev] = { stream_ops: ops };
+ },getDevice:function (dev) {
+ return FS.devices[dev];
+ },getMounts:function (mount) {
+ var mounts = [];
+ var check = [mount];
+
+ while (check.length) {
+ var m = check.pop();
+
+ mounts.push(m);
+
+ check.push.apply(check, m.mounts);
+ }
+
+ return mounts;
+ },syncfs:function (populate, callback) {
+ if (typeof(populate) === 'function') {
+ callback = populate;
+ populate = false;
+ }
+
+ var mounts = FS.getMounts(FS.root.mount);
+ var completed = 0;
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= mounts.length) {
+ callback(null);
+ }
+ };
+
+ // sync all mounts
+ mounts.forEach(function (mount) {
+ if (!mount.type.syncfs) {
+ return done(null);
+ }
+ mount.type.syncfs(mount, populate, done);
+ });
+ },mount:function (type, opts, mountpoint) {
+ var root = mountpoint === '/';
+ var pseudo = !mountpoint;
+ var node;
+
+ if (root && FS.root) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ } else if (!root && !pseudo) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ mountpoint = lookup.path; // use the absolute path
+ node = lookup.node;
+
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+
+ if (!FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ }
+
+ var mount = {
+ type: type,
+ opts: opts,
+ mountpoint: mountpoint,
+ mounts: []
+ };
+
+ // create a root node for the fs
+ var mountRoot = type.mount(mount);
+ mountRoot.mount = mount;
+ mount.root = mountRoot;
+
+ if (root) {
+ FS.root = mountRoot;
+ } else if (node) {
+ // set as a mountpoint
+ node.mounted = mount;
+
+ // add the new mount to the current mount's children
+ if (node.mount) {
+ node.mount.mounts.push(mount);
+ }
+ }
+
+ return mountRoot;
+ },unmount:function (mountpoint) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ if (!FS.isMountpoint(lookup.node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ // destroy the nodes for this mount, and all its child mounts
+ var node = lookup.node;
+ var mount = node.mounted;
+ var mounts = FS.getMounts(mount);
+
+ Object.keys(FS.nameTable).forEach(function (hash) {
+ var current = FS.nameTable[hash];
+
+ while (current) {
+ var next = current.name_next;
+
+ if (mounts.indexOf(current.mount) !== -1) {
+ FS.destroyNode(current);
+ }
+
+ current = next;
+ }
+ });
+
+ // no longer a mountpoint
+ node.mounted = null;
+
+ // remove this mount from the child mounts
+ var idx = node.mount.mounts.indexOf(mount);
+ assert(idx !== -1);
+ node.mount.mounts.splice(idx, 1);
+ },lookup:function (parent, name) {
+ return parent.node_ops.lookup(parent, name);
+ },mknod:function (path, mode, dev) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var err = FS.mayCreate(parent, name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.mknod) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.mknod(parent, name, mode, dev);
+ },create:function (path, mode) {
+ mode = mode !== undefined ? mode : 438 /* 0666 */;
+ mode &= 4095;
+ mode |= 32768;
+ return FS.mknod(path, mode, 0);
+ },mkdir:function (path, mode) {
+ mode = mode !== undefined ? mode : 511 /* 0777 */;
+ mode &= 511 | 512;
+ mode |= 16384;
+ return FS.mknod(path, mode, 0);
+ },mkdev:function (path, mode, dev) {
+ if (typeof(dev) === 'undefined') {
+ dev = mode;
+ mode = 438 /* 0666 */;
+ }
+ mode |= 8192;
+ return FS.mknod(path, mode, dev);
+ },symlink:function (oldpath, newpath) {
+ var lookup = FS.lookupPath(newpath, { parent: true });
+ var parent = lookup.node;
+ var newname = PATH.basename(newpath);
+ var err = FS.mayCreate(parent, newname);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.symlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.symlink(parent, newname, oldpath);
+ },rename:function (old_path, new_path) {
+ var old_dirname = PATH.dirname(old_path);
+ var new_dirname = PATH.dirname(new_path);
+ var old_name = PATH.basename(old_path);
+ var new_name = PATH.basename(new_path);
+ // parents must exist
+ var lookup, old_dir, new_dir;
+ try {
+ lookup = FS.lookupPath(old_path, { parent: true });
+ old_dir = lookup.node;
+ lookup = FS.lookupPath(new_path, { parent: true });
+ new_dir = lookup.node;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // need to be part of the same mount
+ if (old_dir.mount !== new_dir.mount) {
+ throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
+ }
+ // source must exist
+ var old_node = FS.lookupNode(old_dir, old_name);
+ // old path should not be an ancestor of the new path
+ var relative = PATH.relative(old_path, new_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ // new path should not be an ancestor of the old path
+ relative = PATH.relative(new_path, old_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ // see if the new path already exists
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ // not fatal
+ }
+ // early out if nothing needs to change
+ if (old_node === new_node) {
+ return;
+ }
+ // we'll need to delete the old entry
+ var isdir = FS.isDir(old_node.mode);
+ var err = FS.mayDelete(old_dir, old_name, isdir);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // need delete permissions if we'll be overwriting.
+ // need create permissions if new doesn't already exist.
+ err = new_node ?
+ FS.mayDelete(new_dir, new_name, isdir) :
+ FS.mayCreate(new_dir, new_name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!old_dir.node_ops.rename) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // if we are going to change the parent, check write permissions
+ if (new_dir !== old_dir) {
+ err = FS.nodePermissions(old_dir, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ }
+ // remove the node from the lookup hash
+ FS.hashRemoveNode(old_node);
+ // do the underlying fs rename
+ try {
+ old_dir.node_ops.rename(old_node, new_dir, new_name);
+ } catch (e) {
+ throw e;
+ } finally {
+ // add the node back to the hash (in case node_ops.rename
+ // changed its name)
+ FS.hashAddNode(old_node);
+ }
+ },rmdir:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, true);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.rmdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.rmdir(parent, name);
+ FS.destroyNode(node);
+ },readdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ if (!node.node_ops.readdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ return node.node_ops.readdir(node);
+ },unlink:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, false);
+ if (err) {
+ // POSIX says unlink should set EPERM, not EISDIR
+ if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.unlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.unlink(parent, name);
+ FS.destroyNode(node);
+ },readlink:function (path) {
+ var lookup = FS.lookupPath(path);
+ var link = lookup.node;
+ if (!link.node_ops.readlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return link.node_ops.readlink(link);
+ },stat:function (path, dontFollow) {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ var node = lookup.node;
+ if (!node.node_ops.getattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return node.node_ops.getattr(node);
+ },lstat:function (path) {
+ return FS.stat(path, true);
+ },chmod:function (path, mode, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ mode: (mode & 4095) | (node.mode & ~4095),
+ timestamp: Date.now()
+ });
+ },lchmod:function (path, mode) {
+ FS.chmod(path, mode, true);
+ },fchmod:function (fd, mode) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chmod(stream.node, mode);
+ },chown:function (path, uid, gid, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ timestamp: Date.now()
+ // we ignore the uid / gid for now
+ });
+ },lchown:function (path, uid, gid) {
+ FS.chown(path, uid, gid, true);
+ },fchown:function (fd, uid, gid) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chown(stream.node, uid, gid);
+ },truncate:function (path, len) {
+ if (len < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: true });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!FS.isFile(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var err = FS.nodePermissions(node, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ node.node_ops.setattr(node, {
+ size: len,
+ timestamp: Date.now()
+ });
+ },ftruncate:function (fd, len) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ FS.truncate(stream.node, len);
+ },utime:function (path, atime, mtime) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ node.node_ops.setattr(node, {
+ timestamp: Math.max(atime, mtime)
+ });
+ },open:function (path, flags, mode, fd_start, fd_end) {
+ flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
+ mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
+ if ((flags & 64)) {
+ mode = (mode & 4095) | 32768;
+ } else {
+ mode = 0;
+ }
+ var node;
+ if (typeof path === 'object') {
+ node = path;
+ } else {
+ path = PATH.normalize(path);
+ try {
+ var lookup = FS.lookupPath(path, {
+ follow: !(flags & 131072)
+ });
+ node = lookup.node;
+ } catch (e) {
+ // ignore
+ }
+ }
+ // perhaps we need to create the node
+ if ((flags & 64)) {
+ if (node) {
+ // if O_CREAT and O_EXCL are set, error out if the node already exists
+ if ((flags & 128)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
+ }
+ } else {
+ // node doesn't exist, try to create it
+ node = FS.mknod(path, mode, 0);
+ }
+ }
+ if (!node) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
+ }
+ // can't truncate a device
+ if (FS.isChrdev(node.mode)) {
+ flags &= ~512;
+ }
+ // check permissions
+ var err = FS.mayOpen(node, flags);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // do truncation if necessary
+ if ((flags & 512)) {
+ FS.truncate(node, 0);
+ }
+ // we've already handled these, don't pass down to the underlying vfs
+ flags &= ~(128 | 512);
+
+ // register the stream with the filesystem
+ var stream = FS.createStream({
+ node: node,
+ path: FS.getPath(node), // we want the absolute path to the node
+ flags: flags,
+ seekable: true,
+ position: 0,
+ stream_ops: node.stream_ops,
+ // used by the file family libc calls (fopen, fwrite, ferror, etc.)
+ ungotten: [],
+ error: false
+ }, fd_start, fd_end);
+ // call the new stream's open function
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ if (Module['logReadFiles'] && !(flags & 1)) {
+ if (!FS.readFiles) FS.readFiles = {};
+ if (!(path in FS.readFiles)) {
+ FS.readFiles[path] = 1;
+ Module['printErr']('read file: ' + path);
+ }
+ }
+ return stream;
+ },close:function (stream) {
+ try {
+ if (stream.stream_ops.close) {
+ stream.stream_ops.close(stream);
+ }
+ } catch (e) {
+ throw e;
+ } finally {
+ FS.closeStream(stream.fd);
+ }
+ },llseek:function (stream, offset, whence) {
+ if (!stream.seekable || !stream.stream_ops.llseek) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ return stream.stream_ops.llseek(stream, offset, whence);
+ },read:function (stream, buffer, offset, length, position) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.read) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
+ if (!seeking) stream.position += bytesRead;
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.write) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ if (stream.flags & 1024) {
+ // seek to the end before writing in append mode
+ FS.llseek(stream, 0, 2);
+ }
+ var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
+ if (!seeking) stream.position += bytesWritten;
+ return bytesWritten;
+ },allocate:function (stream, offset, length) {
+ if (offset < 0 || length <= 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ if (!stream.stream_ops.allocate) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ stream.stream_ops.allocate(stream, offset, length);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ // TODO if PROT is PROT_WRITE, make sure we have write access
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EACCES);
+ }
+ if (!stream.stream_ops.mmap) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
+ },ioctl:function (stream, cmd, arg) {
+ if (!stream.stream_ops.ioctl) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
+ }
+ return stream.stream_ops.ioctl(stream, cmd, arg);
+ },readFile:function (path, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'r';
+ opts.encoding = opts.encoding || 'binary';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var ret;
+ var stream = FS.open(path, opts.flags);
+ var stat = FS.stat(path);
+ var length = stat.size;
+ var buf = new Uint8Array(length);
+ FS.read(stream, buf, 0, length, 0);
+ if (opts.encoding === 'utf8') {
+ ret = '';
+ var utf8 = new Runtime.UTF8Processor();
+ for (var i = 0; i < length; i++) {
+ ret += utf8.processCChar(buf[i]);
+ }
+ } else if (opts.encoding === 'binary') {
+ ret = buf;
+ }
+ FS.close(stream);
+ return ret;
+ },writeFile:function (path, data, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'w';
+ opts.encoding = opts.encoding || 'utf8';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var stream = FS.open(path, opts.flags, opts.mode);
+ if (opts.encoding === 'utf8') {
+ var utf8 = new Runtime.UTF8Processor();
+ var buf = new Uint8Array(utf8.processJSString(data));
+ FS.write(stream, buf, 0, buf.length, 0, opts.canOwn);
+ } else if (opts.encoding === 'binary') {
+ FS.write(stream, data, 0, data.length, 0, opts.canOwn);
+ }
+ FS.close(stream);
+ },cwd:function () {
+ return FS.currentPath;
+ },chdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ if (!FS.isDir(lookup.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ var err = FS.nodePermissions(lookup.node, 'x');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ FS.currentPath = lookup.path;
+ },createDefaultDirectories:function () {
+ FS.mkdir('/tmp');
+ },createDefaultDevices:function () {
+ // create /dev
+ FS.mkdir('/dev');
+ // setup /dev/null
+ FS.registerDevice(FS.makedev(1, 3), {
+ read: function() { return 0; },
+ write: function() { return 0; }
+ });
+ FS.mkdev('/dev/null', FS.makedev(1, 3));
+ // setup /dev/tty and /dev/tty1
+ // stderr needs to print output using Module['printErr']
+ // so we register a second tty just for it.
+ TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
+ TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
+ FS.mkdev('/dev/tty', FS.makedev(5, 0));
+ FS.mkdev('/dev/tty1', FS.makedev(6, 0));
+ // we're not going to emulate the actual shm device,
+ // just create the tmp dirs that reside in it commonly
+ FS.mkdir('/dev/shm');
+ FS.mkdir('/dev/shm/tmp');
+ },createStandardStreams:function () {
+ // TODO deprecate the old functionality of a single
+ // input / output callback and that utilizes FS.createDevice
+ // and instead require a unique set of stream ops
+
+ // by default, we symlink the standard streams to the
+ // default tty devices. however, if the standard streams
+ // have been overwritten we create a unique device for
+ // them instead.
+ if (Module['stdin']) {
+ FS.createDevice('/dev', 'stdin', Module['stdin']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdin');
+ }
+ if (Module['stdout']) {
+ FS.createDevice('/dev', 'stdout', null, Module['stdout']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdout');
+ }
+ if (Module['stderr']) {
+ FS.createDevice('/dev', 'stderr', null, Module['stderr']);
+ } else {
+ FS.symlink('/dev/tty1', '/dev/stderr');
+ }
+
+ // open default streams for the stdin, stdout and stderr devices
+ var stdin = FS.open('/dev/stdin', 'r');
+ HEAP32[((_stdin)>>2)]=FS.getPtrForStream(stdin);
+ assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
+
+ var stdout = FS.open('/dev/stdout', 'w');
+ HEAP32[((_stdout)>>2)]=FS.getPtrForStream(stdout);
+ assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
+
+ var stderr = FS.open('/dev/stderr', 'w');
+ HEAP32[((_stderr)>>2)]=FS.getPtrForStream(stderr);
+ assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
+ },ensureErrnoError:function () {
+ if (FS.ErrnoError) return;
+ FS.ErrnoError = function ErrnoError(errno) {
+ this.errno = errno;
+ for (var key in ERRNO_CODES) {
+ if (ERRNO_CODES[key] === errno) {
+ this.code = key;
+ break;
+ }
+ }
+ this.message = ERRNO_MESSAGES[errno];
+ };
+ FS.ErrnoError.prototype = new Error();
+ FS.ErrnoError.prototype.constructor = FS.ErrnoError;
+ // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
+ [ERRNO_CODES.ENOENT].forEach(function(code) {
+ FS.genericErrors[code] = new FS.ErrnoError(code);
+ FS.genericErrors[code].stack = '<generic error, no stack>';
+ });
+ },staticInit:function () {
+ FS.ensureErrnoError();
+
+ FS.nameTable = new Array(4096);
+
+ FS.mount(MEMFS, {}, '/');
+
+ FS.createDefaultDirectories();
+ FS.createDefaultDevices();
+ },init:function (input, output, error) {
+ assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
+ FS.init.initialized = true;
+
+ FS.ensureErrnoError();
+
+ // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
+ Module['stdin'] = input || Module['stdin'];
+ Module['stdout'] = output || Module['stdout'];
+ Module['stderr'] = error || Module['stderr'];
+
+ FS.createStandardStreams();
+ },quit:function () {
+ FS.init.initialized = false;
+ for (var i = 0; i < FS.streams.length; i++) {
+ var stream = FS.streams[i];
+ if (!stream) {
+ continue;
+ }
+ FS.close(stream);
+ }
+ },getMode:function (canRead, canWrite) {
+ var mode = 0;
+ if (canRead) mode |= 292 | 73;
+ if (canWrite) mode |= 146;
+ return mode;
+ },joinPath:function (parts, forceRelative) {
+ var path = PATH.join.apply(null, parts);
+ if (forceRelative && path[0] == '/') path = path.substr(1);
+ return path;
+ },absolutePath:function (relative, base) {
+ return PATH.resolve(base, relative);
+ },standardizePath:function (path) {
+ return PATH.normalize(path);
+ },findObject:function (path, dontResolveLastLink) {
+ var ret = FS.analyzePath(path, dontResolveLastLink);
+ if (ret.exists) {
+ return ret.object;
+ } else {
+ ___setErrNo(ret.error);
+ return null;
+ }
+ },analyzePath:function (path, dontResolveLastLink) {
+ // operate from within the context of the symlink's target
+ try {
+ var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ path = lookup.path;
+ } catch (e) {
+ }
+ var ret = {
+ isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
+ parentExists: false, parentPath: null, parentObject: null
+ };
+ try {
+ var lookup = FS.lookupPath(path, { parent: true });
+ ret.parentExists = true;
+ ret.parentPath = lookup.path;
+ ret.parentObject = lookup.node;
+ ret.name = PATH.basename(path);
+ lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ ret.exists = true;
+ ret.path = lookup.path;
+ ret.object = lookup.node;
+ ret.name = lookup.node.name;
+ ret.isRoot = lookup.path === '/';
+ } catch (e) {
+ ret.error = e.errno;
+ };
+ return ret;
+ },createFolder:function (parent, name, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.mkdir(path, mode);
+ },createPath:function (parent, path, canRead, canWrite) {
+ parent = typeof parent === 'string' ? parent : FS.getPath(parent);
+ var parts = path.split('/').reverse();
+ while (parts.length) {
+ var part = parts.pop();
+ if (!part) continue;
+ var current = PATH.join2(parent, part);
+ try {
+ FS.mkdir(current);
+ } catch (e) {
+ // ignore EEXIST
+ }
+ parent = current;
+ }
+ return current;
+ },createFile:function (parent, name, properties, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.create(path, mode);
+ },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
+ var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
+ var mode = FS.getMode(canRead, canWrite);
+ var node = FS.create(path, mode);
+ if (data) {
+ if (typeof data === 'string') {
+ var arr = new Array(data.length);
+ for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
+ data = arr;
+ }
+ // make sure we can write to the file
+ FS.chmod(node, mode | 146);
+ var stream = FS.open(node, 'w');
+ FS.write(stream, data, 0, data.length, 0, canOwn);
+ FS.close(stream);
+ FS.chmod(node, mode);
+ }
+ return node;
+ },createDevice:function (parent, name, input, output) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(!!input, !!output);
+ if (!FS.createDevice.major) FS.createDevice.major = 64;
+ var dev = FS.makedev(FS.createDevice.major++, 0);
+ // Create a fake device that a set of stream ops to emulate
+ // the old behavior.
+ FS.registerDevice(dev, {
+ open: function(stream) {
+ stream.seekable = false;
+ },
+ close: function(stream) {
+ // flush any pending line data
+ if (output && output.buffer && output.buffer.length) {
+ output(10);
+ }
+ },
+ read: function(stream, buffer, offset, length, pos /* ignored */) {
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = input();
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },
+ write: function(stream, buffer, offset, length, pos) {
+ for (var i = 0; i < length; i++) {
+ try {
+ output(buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }
+ });
+ return FS.mkdev(path, mode, dev);
+ },createLink:function (parent, name, target, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ return FS.symlink(target, path);
+ },forceLoadFile:function (obj) {
+ if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
+ var success = true;
+ if (typeof XMLHttpRequest !== 'undefined') {
+ throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
+ } else if (Module['read']) {
+ // Command-line.
+ try {
+ // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
+ // read() will try to parse UTF8.
+ obj.contents = intArrayFromString(Module['read'](obj.url), true);
+ } catch (e) {
+ success = false;
+ }
+ } else {
+ throw new Error('Cannot load without read() or XMLHttpRequest.');
+ }
+ if (!success) ___setErrNo(ERRNO_CODES.EIO);
+ return success;
+ },createLazyFile:function (parent, name, url, canRead, canWrite) {
+ // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
+ function LazyUint8Array() {
+ this.lengthKnown = false;
+ this.chunks = []; // Loaded chunks. Index is the chunk number
+ }
+ LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
+ if (idx > this.length-1 || idx < 0) {
+ return undefined;
+ }
+ var chunkOffset = idx % this.chunkSize;
+ var chunkNum = Math.floor(idx / this.chunkSize);
+ return this.getter(chunkNum)[chunkOffset];
+ }
+ LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
+ this.getter = getter;
+ }
+ LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
+ // Find length
+ var xhr = new XMLHttpRequest();
+ xhr.open('HEAD', url, false);
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ var datalength = Number(xhr.getResponseHeader("Content-length"));
+ var header;
+ var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
+ var chunkSize = 1024*1024; // Chunk size in bytes
+
+ if (!hasByteServing) chunkSize = datalength;
+
+ // Function to get a range from the remote URL.
+ var doXHR = (function(from, to) {
+ if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
+ if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
+
+ // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
+
+ // Some hints to the browser that we want binary data.
+ if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
+ if (xhr.overrideMimeType) {
+ xhr.overrideMimeType('text/plain; charset=x-user-defined');
+ }
+
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ if (xhr.response !== undefined) {
+ return new Uint8Array(xhr.response || []);
+ } else {
+ return intArrayFromString(xhr.responseText || '', true);
+ }
+ });
+ var lazyArray = this;
+ lazyArray.setDataGetter(function(chunkNum) {
+ var start = chunkNum * chunkSize;
+ var end = (chunkNum+1) * chunkSize - 1; // including this byte
+ end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
+ lazyArray.chunks[chunkNum] = doXHR(start, end);
+ }
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
+ return lazyArray.chunks[chunkNum];
+ });
+
+ this._length = datalength;
+ this._chunkSize = chunkSize;
+ this.lengthKnown = true;
+ }
+ if (typeof XMLHttpRequest !== 'undefined') {
+ if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
+ var lazyArray = new LazyUint8Array();
+ Object.defineProperty(lazyArray, "length", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._length;
+ }
+ });
+ Object.defineProperty(lazyArray, "chunkSize", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._chunkSize;
+ }
+ });
+
+ var properties = { isDevice: false, contents: lazyArray };
+ } else {
+ var properties = { isDevice: false, url: url };
+ }
+
+ var node = FS.createFile(parent, name, properties, canRead, canWrite);
+ // This is a total hack, but I want to get this lazy file code out of the
+ // core of MEMFS. If we want to keep this lazy file concept I feel it should
+ // be its own thin LAZYFS proxying calls to MEMFS.
+ if (properties.contents) {
+ node.contents = properties.contents;
+ } else if (properties.url) {
+ node.contents = null;
+ node.url = properties.url;
+ }
+ // override each stream op with one that tries to force load the lazy file first
+ var stream_ops = {};
+ var keys = Object.keys(node.stream_ops);
+ keys.forEach(function(key) {
+ var fn = node.stream_ops[key];
+ stream_ops[key] = function forceLoadLazyFile() {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ return fn.apply(null, arguments);
+ };
+ });
+ // use a custom read function
+ stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (contents.slice) { // normal array
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ } else {
+ for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
+ buffer[offset + i] = contents.get(position + i);
+ }
+ }
+ return size;
+ };
+ node.stream_ops = stream_ops;
+ return node;
+ },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {
+ Browser.init();
+ // TODO we should allow people to just pass in a complete filename instead
+ // of parent and name being that we just join them anyways
+ var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
+ function processData(byteArray) {
+ function finish(byteArray) {
+ if (!dontCreateFile) {
+ FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
+ }
+ if (onload) onload();
+ removeRunDependency('cp ' + fullname);
+ }
+ var handled = false;
+ Module['preloadPlugins'].forEach(function(plugin) {
+ if (handled) return;
+ if (plugin['canHandle'](fullname)) {
+ plugin['handle'](byteArray, fullname, finish, function() {
+ if (onerror) onerror();
+ removeRunDependency('cp ' + fullname);
+ });
+ handled = true;
+ }
+ });
+ if (!handled) finish(byteArray);
+ }
+ addRunDependency('cp ' + fullname);
+ if (typeof url == 'string') {
+ Browser.asyncLoad(url, function(byteArray) {
+ processData(byteArray);
+ }, onerror);
+ } else {
+ processData(url);
+ }
+ },indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_NAME:function () {
+ return 'EM_FS_' + window.location.pathname;
+ },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
+ console.log('creating db');
+ var db = openRequest.result;
+ db.createObjectStore(FS.DB_STORE_NAME);
+ };
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var putRequest = files.put(FS.analyzePath(path).object.contents, path);
+ putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
+ putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ },loadFilesFromDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = onerror; // no database to load from
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ try {
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
+ } catch(e) {
+ onerror(e);
+ return;
+ }
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var getRequest = files.get(path);
+ getRequest.onsuccess = function getRequest_onsuccess() {
+ if (FS.analyzePath(path).exists) {
+ FS.unlink(path);
+ }
+ FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
+ ok++;
+ if (ok + fail == total) finish();
+ };
+ getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ }};
+
+
+
+
+ function _mkport() { throw 'TODO' }var SOCKFS={mount:function (mount) {
+ return FS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createSocket:function (family, type, protocol) {
+ var streaming = type == 1;
+ if (protocol) {
+ assert(streaming == (protocol == 6)); // if SOCK_STREAM, must be tcp
+ }
+
+ // create our internal socket structure
+ var sock = {
+ family: family,
+ type: type,
+ protocol: protocol,
+ server: null,
+ peers: {},
+ pending: [],
+ recv_queue: [],
+ sock_ops: SOCKFS.websocket_sock_ops
+ };
+
+ // create the filesystem node to store the socket structure
+ var name = SOCKFS.nextname();
+ var node = FS.createNode(SOCKFS.root, name, 49152, 0);
+ node.sock = sock;
+
+ // and the wrapping stream that enables library functions such
+ // as read and write to indirectly interact with the socket
+ var stream = FS.createStream({
+ path: name,
+ node: node,
+ flags: FS.modeStringToFlags('r+'),
+ seekable: false,
+ stream_ops: SOCKFS.stream_ops
+ });
+
+ // map the new stream to the socket structure (sockets have a 1:1
+ // relationship with a stream)
+ sock.stream = stream;
+
+ return sock;
+ },getSocket:function (fd) {
+ var stream = FS.getStream(fd);
+ if (!stream || !FS.isSocket(stream.node.mode)) {
+ return null;
+ }
+ return stream.node.sock;
+ },stream_ops:{poll:function (stream) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.poll(sock);
+ },ioctl:function (stream, request, varargs) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.ioctl(sock, request, varargs);
+ },read:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ var msg = sock.sock_ops.recvmsg(sock, length);
+ if (!msg) {
+ // socket is closed
+ return 0;
+ }
+ buffer.set(msg.buffer, offset);
+ return msg.buffer.length;
+ },write:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.sendmsg(sock, buffer, offset, length);
+ },close:function (stream) {
+ var sock = stream.node.sock;
+ sock.sock_ops.close(sock);
+ }},nextname:function () {
+ if (!SOCKFS.nextname.current) {
+ SOCKFS.nextname.current = 0;
+ }
+ return 'socket[' + (SOCKFS.nextname.current++) + ']';
+ },websocket_sock_ops:{createPeer:function (sock, addr, port) {
+ var ws;
+
+ if (typeof addr === 'object') {
+ ws = addr;
+ addr = null;
+ port = null;
+ }
+
+ if (ws) {
+ // for sockets that've already connected (e.g. we're the server)
+ // we can inspect the _socket property for the address
+ if (ws._socket) {
+ addr = ws._socket.remoteAddress;
+ port = ws._socket.remotePort;
+ }
+ // if we're just now initializing a connection to the remote,
+ // inspect the url property
+ else {
+ var result = /ws[s]?:\/\/([^:]+):(\d+)/.exec(ws.url);
+ if (!result) {
+ throw new Error('WebSocket URL must be in the format ws(s)://address:port');
+ }
+ addr = result[1];
+ port = parseInt(result[2], 10);
+ }
+ } else {
+ // create the actual websocket object and connect
+ try {
+ // runtimeConfig gets set to true if WebSocket runtime configuration is available.
+ var runtimeConfig = (Module['websocket'] && ('object' === typeof Module['websocket']));
+
+ // The default value is 'ws://' the replace is needed because the compiler replaces "//" comments with '#'
+ // comments without checking context, so we'd end up with ws:#, the replace swaps the "#" for "//" again.
+ var url = 'ws:#'.replace('#', '//');
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['url']) {
+ url = Module['websocket']['url']; // Fetch runtime WebSocket URL config.
+ }
+ }
+
+ if (url === 'ws://' || url === 'wss://') { // Is the supplied URL config just a prefix, if so complete it.
+ url = url + addr + ':' + port;
+ }
+
+ // Make the WebSocket subprotocol (Sec-WebSocket-Protocol) default to binary if no configuration is set.
+ var subProtocols = 'binary'; // The default value is 'binary'
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['subprotocol']) {
+ subProtocols = Module['websocket']['subprotocol']; // Fetch runtime WebSocket subprotocol config.
+ }
+ }
+
+ // The regex trims the string (removes spaces at the beginning and end, then splits the string by
+ // <any space>,<any space> into an Array. Whitespace removal is important for Websockify and ws.
+ subProtocols = subProtocols.replace(/^ +| +$/g,"").split(/ *, */);
+
+ // The node ws library API for specifying optional subprotocol is slightly different than the browser's.
+ var opts = ENVIRONMENT_IS_NODE ? {'protocol': subProtocols.toString()} : subProtocols;
+
+ // If node we use the ws library.
+ var WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : window['WebSocket'];
+ ws = new WebSocket(url, opts);
+ ws.binaryType = 'arraybuffer';
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EHOSTUNREACH);
+ }
+ }
+
+
+ var peer = {
+ addr: addr,
+ port: port,
+ socket: ws,
+ dgram_send_queue: []
+ };
+
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);
+
+ // if this is a bound dgram socket, send the port number first to allow
+ // us to override the ephemeral port reported to us by remotePort on the
+ // remote end.
+ if (sock.type === 2 && typeof sock.sport !== 'undefined') {
+ peer.dgram_send_queue.push(new Uint8Array([
+ 255, 255, 255, 255,
+ 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),
+ ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)
+ ]));
+ }
+
+ return peer;
+ },getPeer:function (sock, addr, port) {
+ return sock.peers[addr + ':' + port];
+ },addPeer:function (sock, peer) {
+ sock.peers[peer.addr + ':' + peer.port] = peer;
+ },removePeer:function (sock, peer) {
+ delete sock.peers[peer.addr + ':' + peer.port];
+ },handlePeerEvents:function (sock, peer) {
+ var first = true;
+
+ var handleOpen = function () {
+ try {
+ var queued = peer.dgram_send_queue.shift();
+ while (queued) {
+ peer.socket.send(queued);
+ queued = peer.dgram_send_queue.shift();
+ }
+ } catch (e) {
+ // not much we can do here in the way of proper error handling as we've already
+ // lied and said this data was sent. shut it down.
+ peer.socket.close();
+ }
+ };
+
+ function handleMessage(data) {
+ assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer
+ data = new Uint8Array(data); // make a typed array view on the array buffer
+
+
+ // if this is the port message, override the peer's port with it
+ var wasfirst = first;
+ first = false;
+ if (wasfirst &&
+ data.length === 10 &&
+ data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&
+ data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {
+ // update the peer's port and it's key in the peer map
+ var newport = ((data[8] << 8) | data[9]);
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ peer.port = newport;
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ return;
+ }
+
+ sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });
+ };
+
+ if (ENVIRONMENT_IS_NODE) {
+ peer.socket.on('open', handleOpen);
+ peer.socket.on('message', function(data, flags) {
+ if (!flags.binary) {
+ return;
+ }
+ handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
+ });
+ peer.socket.on('error', function() {
+ // don't throw
+ });
+ } else {
+ peer.socket.onopen = handleOpen;
+ peer.socket.onmessage = function peer_socket_onmessage(event) {
+ handleMessage(event.data);
+ };
+ }
+ },poll:function (sock) {
+ if (sock.type === 1 && sock.server) {
+ // listen sockets should only say they're available for reading
+ // if there are pending clients.
+ return sock.pending.length ? (64 | 1) : 0;
+ }
+
+ var mask = 0;
+ var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets
+ SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :
+ null;
+
+ if (sock.recv_queue.length ||
+ !dest || // connection-less sockets are always ready to read
+ (dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed
+ mask |= (64 | 1);
+ }
+
+ if (!dest || // connection-less sockets are always ready to write
+ (dest && dest.socket.readyState === dest.socket.OPEN)) {
+ mask |= 4;
+ }
+
+ if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) {
+ mask |= 16;
+ }
+
+ return mask;
+ },ioctl:function (sock, request, arg) {
+ switch (request) {
+ case 21531:
+ var bytes = 0;
+ if (sock.recv_queue.length) {
+ bytes = sock.recv_queue[0].data.length;
+ }
+ HEAP32[((arg)>>2)]=bytes;
+ return 0;
+ default:
+ return ERRNO_CODES.EINVAL;
+ }
+ },close:function (sock) {
+ // if we've spawned a listen server, close it
+ if (sock.server) {
+ try {
+ sock.server.close();
+ } catch (e) {
+ }
+ sock.server = null;
+ }
+ // close any peer connections
+ var peers = Object.keys(sock.peers);
+ for (var i = 0; i < peers.length; i++) {
+ var peer = sock.peers[peers[i]];
+ try {
+ peer.socket.close();
+ } catch (e) {
+ }
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ }
+ return 0;
+ },bind:function (sock, addr, port) {
+ if (typeof sock.saddr !== 'undefined' || typeof sock.sport !== 'undefined') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already bound
+ }
+ sock.saddr = addr;
+ sock.sport = port || _mkport();
+ // in order to emulate dgram sockets, we need to launch a listen server when
+ // binding on a connection-less socket
+ // note: this is only required on the server side
+ if (sock.type === 2) {
+ // close the existing server if it exists
+ if (sock.server) {
+ sock.server.close();
+ sock.server = null;
+ }
+ // swallow error operation not supported error that occurs when binding in the
+ // browser where this isn't supported
+ try {
+ sock.sock_ops.listen(sock, 0);
+ } catch (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e;
+ if (e.errno !== ERRNO_CODES.EOPNOTSUPP) throw e;
+ }
+ }
+ },connect:function (sock, addr, port) {
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODS.EOPNOTSUPP);
+ }
+
+ // TODO autobind
+ // if (!sock.addr && sock.type == 2) {
+ // }
+
+ // early out if we're already connected / in the middle of connecting
+ if (typeof sock.daddr !== 'undefined' && typeof sock.dport !== 'undefined') {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+ if (dest) {
+ if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EALREADY);
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EISCONN);
+ }
+ }
+ }
+
+ // add the socket to our peer list and set our
+ // destination address / port to match
+ var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ sock.daddr = peer.addr;
+ sock.dport = peer.port;
+
+ // always "fail" in non-blocking mode
+ throw new FS.ErrnoError(ERRNO_CODES.EINPROGRESS);
+ },listen:function (sock, backlog) {
+ if (!ENVIRONMENT_IS_NODE) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already listening
+ }
+ var WebSocketServer = require('ws').Server;
+ var host = sock.saddr;
+ sock.server = new WebSocketServer({
+ host: host,
+ port: sock.sport
+ // TODO support backlog
+ });
+
+ sock.server.on('connection', function(ws) {
+ if (sock.type === 1) {
+ var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);
+
+ // create a peer on the new socket
+ var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);
+ newsock.daddr = peer.addr;
+ newsock.dport = peer.port;
+
+ // push to queue for accept to pick up
+ sock.pending.push(newsock);
+ } else {
+ // create a peer on the listen socket so calling sendto
+ // with the listen socket and an address will resolve
+ // to the correct client
+ SOCKFS.websocket_sock_ops.createPeer(sock, ws);
+ }
+ });
+ sock.server.on('closed', function() {
+ sock.server = null;
+ });
+ sock.server.on('error', function() {
+ // don't throw
+ });
+ },accept:function (listensock) {
+ if (!listensock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var newsock = listensock.pending.shift();
+ newsock.stream.flags = listensock.stream.flags;
+ return newsock;
+ },getname:function (sock, peer) {
+ var addr, port;
+ if (peer) {
+ if (sock.daddr === undefined || sock.dport === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ addr = sock.daddr;
+ port = sock.dport;
+ } else {
+ // TODO saddr and sport will be set for bind()'d UDP sockets, but what
+ // should we be returning for TCP sockets that've been connect()'d?
+ addr = sock.saddr || 0;
+ port = sock.sport || 0;
+ }
+ return { addr: addr, port: port };
+ },sendmsg:function (sock, buffer, offset, length, addr, port) {
+ if (sock.type === 2) {
+ // connection-less sockets will honor the message address,
+ // and otherwise fall back to the bound destination address
+ if (addr === undefined || port === undefined) {
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+ // if there was no address to fall back to, error out
+ if (addr === undefined || port === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.EDESTADDRREQ);
+ }
+ } else {
+ // connection-based sockets will only use the bound
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+
+ // find the peer for the destination address
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);
+
+ // early out if not connected with a connection-based socket
+ if (sock.type === 1) {
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ } else if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // create a copy of the incoming data to send, as the WebSocket API
+ // doesn't work entirely with an ArrayBufferView, it'll just send
+ // the entire underlying buffer
+ var data;
+ if (buffer instanceof Array || buffer instanceof ArrayBuffer) {
+ data = buffer.slice(offset, offset + length);
+ } else { // ArrayBufferView
+ data = buffer.buffer.slice(buffer.byteOffset + offset, buffer.byteOffset + offset + length);
+ }
+
+ // if we're emulating a connection-less dgram socket and don't have
+ // a cached connection, queue the buffer to send upon connect and
+ // lie, saying the data was sent now.
+ if (sock.type === 2) {
+ if (!dest || dest.socket.readyState !== dest.socket.OPEN) {
+ // if we're not connected, open a new connection
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ }
+ dest.dgram_send_queue.push(data);
+ return length;
+ }
+ }
+
+ try {
+ // send the actual data
+ dest.socket.send(data);
+ return length;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ },recvmsg:function (sock, length) {
+ // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html
+ if (sock.type === 1 && sock.server) {
+ // tcp servers should not be recv()'ing on the listen socket
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+
+ var queued = sock.recv_queue.shift();
+ if (!queued) {
+ if (sock.type === 1) {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+
+ if (!dest) {
+ // if we have a destination address but are not connected, error out
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ else if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ // return null if the socket has closed
+ return null;
+ }
+ else {
+ // else, our socket is in a valid state but truly has nothing available
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // queued.data will be an ArrayBuffer if it's unadulterated, but if it's
+ // requeued TCP data it'll be an ArrayBufferView
+ var queuedLength = queued.data.byteLength || queued.data.length;
+ var queuedOffset = queued.data.byteOffset || 0;
+ var queuedBuffer = queued.data.buffer || queued.data;
+ var bytesRead = Math.min(length, queuedLength);
+ var res = {
+ buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),
+ addr: queued.addr,
+ port: queued.port
+ };
+
+
+ // push back any unread data for TCP connections
+ if (sock.type === 1 && bytesRead < queuedLength) {
+ var bytesRemaining = queuedLength - bytesRead;
+ queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
+ sock.recv_queue.unshift(queued);
+ }
+
+ return res;
+ }}};function _send(fd, buf, len, flags) {
+ var sock = SOCKFS.getSocket(fd);
+ if (!sock) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ // TODO honor flags
+ return _write(fd, buf, len);
+ }
+
+ function _pwrite(fildes, buf, nbyte, offset) {
+ // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte, offset);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _write(fildes, buf, nbyte) {
+ // ssize_t write(int fildes, const void *buf, size_t nbyte);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+
+
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }
+
+ function _fileno(stream) {
+ // int fileno(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fileno.html
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) return -1;
+ return stream.fd;
+ }function _fwrite(ptr, size, nitems, stream) {
+ // size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html
+ var bytesToWrite = nitems * size;
+ if (bytesToWrite == 0) return 0;
+ var fd = _fileno(stream);
+ var bytesWritten = _write(fd, ptr, bytesToWrite);
+ if (bytesWritten == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return 0;
+ } else {
+ return Math.floor(bytesWritten / size);
+ }
+ }
+
+
+
+ Module["_strlen"] = _strlen;
+
+ function __reallyNegative(x) {
+ return x < 0 || (x === 0 && (1/x) === -Infinity);
+ }function __formatString(format, varargs) {
+ var textIndex = format;
+ var argIndex = 0;
+ function getNextArg(type) {
+ // NOTE: Explicitly ignoring type safety. Otherwise this fails:
+ // int x = 4; printf("%c\n", (char)x);
+ var ret;
+ if (type === 'double') {
+ ret = HEAPF64[(((varargs)+(argIndex))>>3)];
+ } else if (type == 'i64') {
+ ret = [HEAP32[(((varargs)+(argIndex))>>2)],
+ HEAP32[(((varargs)+(argIndex+4))>>2)]];
+
+ } else {
+ type = 'i32'; // varargs are always i32, i64, or double
+ ret = HEAP32[(((varargs)+(argIndex))>>2)];
+ }
+ argIndex += Runtime.getNativeFieldSize(type);
+ return ret;
+ }
+
+ var ret = [];
+ var curr, next, currArg;
+ while(1) {
+ var startTextIndex = textIndex;
+ curr = HEAP8[(textIndex)];
+ if (curr === 0) break;
+ next = HEAP8[((textIndex+1)|0)];
+ if (curr == 37) {
+ // Handle flags.
+ var flagAlwaysSigned = false;
+ var flagLeftAlign = false;
+ var flagAlternative = false;
+ var flagZeroPad = false;
+ var flagPadSign = false;
+ flagsLoop: while (1) {
+ switch (next) {
+ case 43:
+ flagAlwaysSigned = true;
+ break;
+ case 45:
+ flagLeftAlign = true;
+ break;
+ case 35:
+ flagAlternative = true;
+ break;
+ case 48:
+ if (flagZeroPad) {
+ break flagsLoop;
+ } else {
+ flagZeroPad = true;
+ break;
+ }
+ case 32:
+ flagPadSign = true;
+ break;
+ default:
+ break flagsLoop;
+ }
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+
+ // Handle width.
+ var width = 0;
+ if (next == 42) {
+ width = getNextArg('i32');
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ } else {
+ while (next >= 48 && next <= 57) {
+ width = width * 10 + (next - 48);
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ }
+
+ // Handle precision.
+ var precisionSet = false, precision = -1;
+ if (next == 46) {
+ precision = 0;
+ precisionSet = true;
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ if (next == 42) {
+ precision = getNextArg('i32');
+ textIndex++;
+ } else {
+ while(1) {
+ var precisionChr = HEAP8[((textIndex+1)|0)];
+ if (precisionChr < 48 ||
+ precisionChr > 57) break;
+ precision = precision * 10 + (precisionChr - 48);
+ textIndex++;
+ }
+ }
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ if (precision < 0) {
+ precision = 6; // Standard default.
+ precisionSet = false;
+ }
+
+ // Handle integer sizes. WARNING: These assume a 32-bit architecture!
+ var argSize;
+ switch (String.fromCharCode(next)) {
+ case 'h':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 104) {
+ textIndex++;
+ argSize = 1; // char (actually i32 in varargs)
+ } else {
+ argSize = 2; // short (actually i32 in varargs)
+ }
+ break;
+ case 'l':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 108) {
+ textIndex++;
+ argSize = 8; // long long
+ } else {
+ argSize = 4; // long
+ }
+ break;
+ case 'L': // long long
+ case 'q': // int64_t
+ case 'j': // intmax_t
+ argSize = 8;
+ break;
+ case 'z': // size_t
+ case 't': // ptrdiff_t
+ case 'I': // signed ptrdiff_t or unsigned size_t
+ argSize = 4;
+ break;
+ default:
+ argSize = null;
+ }
+ if (argSize) textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+
+ // Handle type specifier.
+ switch (String.fromCharCode(next)) {
+ case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {
+ // Integer.
+ var signed = next == 100 || next == 105;
+ argSize = argSize || 4;
+ var currArg = getNextArg('i' + (argSize * 8));
+ var argText;
+ // Flatten i64-1 [low, high] into a (slightly rounded) double
+ if (argSize == 8) {
+ currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);
+ }
+ // Truncate to requested size.
+ if (argSize <= 4) {
+ var limit = Math.pow(256, argSize) - 1;
+ currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);
+ }
+ // Format the number.
+ var currAbsArg = Math.abs(currArg);
+ var prefix = '';
+ if (next == 100 || next == 105) {
+ argText = reSign(currArg, 8 * argSize, 1).toString(10);
+ } else if (next == 117) {
+ argText = unSign(currArg, 8 * argSize, 1).toString(10);
+ currArg = Math.abs(currArg);
+ } else if (next == 111) {
+ argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
+ } else if (next == 120 || next == 88) {
+ prefix = (flagAlternative && currArg != 0) ? '0x' : '';
+ if (currArg < 0) {
+ // Represent negative numbers in hex as 2's complement.
+ currArg = -currArg;
+ argText = (currAbsArg - 1).toString(16);
+ var buffer = [];
+ for (var i = 0; i < argText.length; i++) {
+ buffer.push((0xF - parseInt(argText[i], 16)).toString(16));
+ }
+ argText = buffer.join('');
+ while (argText.length < argSize * 2) argText = 'f' + argText;
+ } else {
+ argText = currAbsArg.toString(16);
+ }
+ if (next == 88) {
+ prefix = prefix.toUpperCase();
+ argText = argText.toUpperCase();
+ }
+ } else if (next == 112) {
+ if (currAbsArg === 0) {
+ argText = '(nil)';
+ } else {
+ prefix = '0x';
+ argText = currAbsArg.toString(16);
+ }
+ }
+ if (precisionSet) {
+ while (argText.length < precision) {
+ argText = '0' + argText;
+ }
+ }
+
+ // Add sign if needed
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ prefix = '+' + prefix;
+ } else if (flagPadSign) {
+ prefix = ' ' + prefix;
+ }
+ }
+
+ // Move sign to prefix so we zero-pad after the sign
+ if (argText.charAt(0) == '-') {
+ prefix = '-' + prefix;
+ argText = argText.substr(1);
+ }
+
+ // Add padding.
+ while (prefix.length + argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad) {
+ argText = '0' + argText;
+ } else {
+ prefix = ' ' + prefix;
+ }
+ }
+ }
+
+ // Insert the result into the buffer.
+ argText = prefix + argText;
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {
+ // Float.
+ var currArg = getNextArg('double');
+ var argText;
+ if (isNaN(currArg)) {
+ argText = 'nan';
+ flagZeroPad = false;
+ } else if (!isFinite(currArg)) {
+ argText = (currArg < 0 ? '-' : '') + 'inf';
+ flagZeroPad = false;
+ } else {
+ var isGeneral = false;
+ var effectivePrecision = Math.min(precision, 20);
+
+ // Convert g/G to f/F or e/E, as per:
+ // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
+ if (next == 103 || next == 71) {
+ isGeneral = true;
+ precision = precision || 1;
+ var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);
+ if (precision > exponent && exponent >= -4) {
+ next = ((next == 103) ? 'f' : 'F').charCodeAt(0);
+ precision -= exponent + 1;
+ } else {
+ next = ((next == 103) ? 'e' : 'E').charCodeAt(0);
+ precision--;
+ }
+ effectivePrecision = Math.min(precision, 20);
+ }
+
+ if (next == 101 || next == 69) {
+ argText = currArg.toExponential(effectivePrecision);
+ // Make sure the exponent has at least 2 digits.
+ if (/[eE][-+]\d$/.test(argText)) {
+ argText = argText.slice(0, -1) + '0' + argText.slice(-1);
+ }
+ } else if (next == 102 || next == 70) {
+ argText = currArg.toFixed(effectivePrecision);
+ if (currArg === 0 && __reallyNegative(currArg)) {
+ argText = '-' + argText;
+ }
+ }
+
+ var parts = argText.split('e');
+ if (isGeneral && !flagAlternative) {
+ // Discard trailing zeros and periods.
+ while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&
+ (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {
+ parts[0] = parts[0].slice(0, -1);
+ }
+ } else {
+ // Make sure we have a period in alternative mode.
+ if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';
+ // Zero pad until required precision.
+ while (precision > effectivePrecision++) parts[0] += '0';
+ }
+ argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');
+
+ // Capitalize 'E' if needed.
+ if (next == 69) argText = argText.toUpperCase();
+
+ // Add sign.
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ argText = '+' + argText;
+ } else if (flagPadSign) {
+ argText = ' ' + argText;
+ }
+ }
+ }
+
+ // Add padding.
+ while (argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {
+ argText = argText[0] + '0' + argText.slice(1);
+ } else {
+ argText = (flagZeroPad ? '0' : ' ') + argText;
+ }
+ }
+ }
+
+ // Adjust case.
+ if (next < 97) argText = argText.toUpperCase();
+
+ // Insert the result into the buffer.
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 's': {
+ // String.
+ var arg = getNextArg('i8*');
+ var argLength = arg ? _strlen(arg) : '(null)'.length;
+ if (precisionSet) argLength = Math.min(argLength, precision);
+ if (!flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ if (arg) {
+ for (var i = 0; i < argLength; i++) {
+ ret.push(HEAPU8[((arg++)|0)]);
+ }
+ } else {
+ ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true));
+ }
+ if (flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ break;
+ }
+ case 'c': {
+ // Character.
+ if (flagLeftAlign) ret.push(getNextArg('i8'));
+ while (--width > 0) {
+ ret.push(32);
+ }
+ if (!flagLeftAlign) ret.push(getNextArg('i8'));
+ break;
+ }
+ case 'n': {
+ // Write the length written so far to the next parameter.
+ var ptr = getNextArg('i32*');
+ HEAP32[((ptr)>>2)]=ret.length;
+ break;
+ }
+ case '%': {
+ // Literal percent sign.
+ ret.push(curr);
+ break;
+ }
+ default: {
+ // Unknown specifiers remain untouched.
+ for (var i = startTextIndex; i < textIndex + 2; i++) {
+ ret.push(HEAP8[(i)]);
+ }
+ }
+ }
+ textIndex += 2;
+ // TODO: Support a/A (hex float) and m (last error) specifiers.
+ // TODO: Support %1${specifier} for arg selection.
+ } else {
+ ret.push(curr);
+ textIndex += 1;
+ }
+ }
+ return ret;
+ }function _fprintf(stream, format, varargs) {
+ // int fprintf(FILE *restrict stream, const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var result = __formatString(format, varargs);
+ var stack = Runtime.stackSave();
+ var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);
+ Runtime.stackRestore(stack);
+ return ret;
+ }function _printf(format, varargs) {
+ // int printf(const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var stdout = HEAP32[((_stdout)>>2)];
+ return _fprintf(stdout, format, varargs);
+ }
+
+
+
+ function _emscripten_memcpy_big(dest, src, num) {
+ HEAPU8.set(HEAPU8.subarray(src, src+num), dest);
+ return dest;
+ }
+ Module["_memcpy"] = _memcpy;
+
+
+ function _fputs(s, stream) {
+ // int fputs(const char *restrict s, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputs.html
+ var fd = _fileno(stream);
+ return _write(fd, s, _strlen(s));
+ }
+
+ function _fputc(c, stream) {
+ // int fputc(int c, FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputc.html
+ var chr = unSign(c & 0xFF);
+ HEAP8[((_fputc.ret)|0)]=chr;
+ var fd = _fileno(stream);
+ var ret = _write(fd, _fputc.ret, 1);
+ if (ret == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return -1;
+ } else {
+ return chr;
+ }
+ }function _puts(s) {
+ // int puts(const char *s);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/puts.html
+ // NOTE: puts() always writes an extra newline.
+ var stdout = HEAP32[((_stdout)>>2)];
+ var ret = _fputs(s, stdout);
+ if (ret < 0) {
+ return ret;
+ } else {
+ var newlineRet = _fputc(10, stdout);
+ return (newlineRet < 0) ? -1 : ret + 1;
+ }
+ }
+
+ function _sbrk(bytes) {
+ // Implement a Linux-like 'memory area' for our 'process'.
+ // Changes the size of the memory area by |bytes|; returns the
+ // address of the previous top ('break') of the memory area
+ // We control the "dynamic" memory - DYNAMIC_BASE to DYNAMICTOP
+ var self = _sbrk;
+ if (!self.called) {
+ DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned
+ self.called = true;
+ assert(Runtime.dynamicAlloc);
+ self.alloc = Runtime.dynamicAlloc;
+ Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') };
+ }
+ var ret = DYNAMICTOP;
+ if (bytes != 0) self.alloc(bytes);
+ return ret; // Previous break location.
+ }
+
+ function ___errno_location() {
+ return ___errno_state;
+ }
+
+ function __ZNSt9exceptionD2Ev() {}
+
+ var Browser={mainLoop:{scheduler:null,method:"",shouldPause:false,paused:false,queue:[],pause:function () {
+ Browser.mainLoop.shouldPause = true;
+ },resume:function () {
+ if (Browser.mainLoop.paused) {
+ Browser.mainLoop.paused = false;
+ Browser.mainLoop.scheduler();
+ }
+ Browser.mainLoop.shouldPause = false;
+ },updateStatus:function () {
+ if (Module['setStatus']) {
+ var message = Module['statusMessage'] || 'Please wait...';
+ var remaining = Browser.mainLoop.remainingBlockers;
+ var expected = Browser.mainLoop.expectedBlockers;
+ if (remaining) {
+ if (remaining < expected) {
+ Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');
+ } else {
+ Module['setStatus'](message);
+ }
+ } else {
+ Module['setStatus']('');
+ }
+ }
+ }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {
+ if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers
+
+ if (Browser.initted || ENVIRONMENT_IS_WORKER) return;
+ Browser.initted = true;
+
+ try {
+ new Blob();
+ Browser.hasBlobConstructor = true;
+ } catch(e) {
+ Browser.hasBlobConstructor = false;
+ console.log("warning: no blob constructor, cannot create blobs with mimetypes");
+ }
+ Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null));
+ Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
+ if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {
+ console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
+ Module.noImageDecoding = true;
+ }
+
+ // Support for plugins that can process preloaded files. You can add more of these to
+ // your app by creating and appending to Module.preloadPlugins.
+ //
+ // Each plugin is asked if it can handle a file based on the file's name. If it can,
+ // it is given the file's raw data. When it is done, it calls a callback with the file's
+ // (possibly modified) data. For example, a plugin might decompress a file, or it
+ // might create some side data structure for use later (like an Image element, etc.).
+
+ var imagePlugin = {};
+ imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
+ return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
+ };
+ imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
+ var b = null;
+ if (Browser.hasBlobConstructor) {
+ try {
+ b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ if (b.size !== byteArray.length) { // Safari bug #118630
+ // Safari's Blob can only take an ArrayBuffer
+ b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
+ }
+ } catch(e) {
+ Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');
+ }
+ }
+ if (!b) {
+ var bb = new Browser.BlobBuilder();
+ bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range
+ b = bb.getBlob();
+ }
+ var url = Browser.URLObject.createObjectURL(b);
+ var img = new Image();
+ img.onload = function img_onload() {
+ assert(img.complete, 'Image ' + name + ' could not be decoded');
+ var canvas = document.createElement('canvas');
+ canvas.width = img.width;
+ canvas.height = img.height;
+ var ctx = canvas.getContext('2d');
+ ctx.drawImage(img, 0, 0);
+ Module["preloadedImages"][name] = canvas;
+ Browser.URLObject.revokeObjectURL(url);
+ if (onload) onload(byteArray);
+ };
+ img.onerror = function img_onerror(event) {
+ console.log('Image ' + url + ' could not be decoded');
+ if (onerror) onerror();
+ };
+ img.src = url;
+ };
+ Module['preloadPlugins'].push(imagePlugin);
+
+ var audioPlugin = {};
+ audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
+ return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
+ };
+ audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
+ var done = false;
+ function finish(audio) {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = audio;
+ if (onload) onload(byteArray);
+ }
+ function fail() {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = new Audio(); // empty shim
+ if (onerror) onerror();
+ }
+ if (Browser.hasBlobConstructor) {
+ try {
+ var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ } catch(e) {
+ return fail();
+ }
+ var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
+ var audio = new Audio();
+ audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
+ audio.onerror = function audio_onerror(event) {
+ if (done) return;
+ console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
+ function encode64(data) {
+ var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ var PAD = '=';
+ var ret = '';
+ var leftchar = 0;
+ var leftbits = 0;
+ for (var i = 0; i < data.length; i++) {
+ leftchar = (leftchar << 8) | data[i];
+ leftbits += 8;
+ while (leftbits >= 6) {
+ var curr = (leftchar >> (leftbits-6)) & 0x3f;
+ leftbits -= 6;
+ ret += BASE[curr];
+ }
+ }
+ if (leftbits == 2) {
+ ret += BASE[(leftchar&3) << 4];
+ ret += PAD + PAD;
+ } else if (leftbits == 4) {
+ ret += BASE[(leftchar&0xf) << 2];
+ ret += PAD;
+ }
+ return ret;
+ }
+ audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);
+ finish(audio); // we don't wait for confirmation this worked - but it's worth trying
+ };
+ audio.src = url;
+ // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror
+ Browser.safeSetTimeout(function() {
+ finish(audio); // try to use it even though it is not necessarily ready to play
+ }, 10000);
+ } else {
+ return fail();
+ }
+ };
+ Module['preloadPlugins'].push(audioPlugin);
+
+ // Canvas event setup
+
+ var canvas = Module['canvas'];
+
+ // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module
+ // Module['forcedAspectRatio'] = 4 / 3;
+
+ canvas.requestPointerLock = canvas['requestPointerLock'] ||
+ canvas['mozRequestPointerLock'] ||
+ canvas['webkitRequestPointerLock'] ||
+ canvas['msRequestPointerLock'] ||
+ function(){};
+ canvas.exitPointerLock = document['exitPointerLock'] ||
+ document['mozExitPointerLock'] ||
+ document['webkitExitPointerLock'] ||
+ document['msExitPointerLock'] ||
+ function(){}; // no-op if function does not exist
+ canvas.exitPointerLock = canvas.exitPointerLock.bind(document);
+
+ function pointerLockChange() {
+ Browser.pointerLock = document['pointerLockElement'] === canvas ||
+ document['mozPointerLockElement'] === canvas ||
+ document['webkitPointerLockElement'] === canvas ||
+ document['msPointerLockElement'] === canvas;
+ }
+
+ document.addEventListener('pointerlockchange', pointerLockChange, false);
+ document.addEventListener('mozpointerlockchange', pointerLockChange, false);
+ document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
+ document.addEventListener('mspointerlockchange', pointerLockChange, false);
+
+ if (Module['elementPointerLock']) {
+ canvas.addEventListener("click", function(ev) {
+ if (!Browser.pointerLock && canvas.requestPointerLock) {
+ canvas.requestPointerLock();
+ ev.preventDefault();
+ }
+ }, false);
+ }
+ },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) {
+ var ctx;
+ var errorInfo = '?';
+ function onContextCreationError(event) {
+ errorInfo = event.statusMessage || errorInfo;
+ }
+ try {
+ if (useWebGL) {
+ var contextAttributes = {
+ antialias: false,
+ alpha: false
+ };
+
+ if (webGLContextAttributes) {
+ for (var attribute in webGLContextAttributes) {
+ contextAttributes[attribute] = webGLContextAttributes[attribute];
+ }
+ }
+
+
+ canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
+ try {
+ ['experimental-webgl', 'webgl'].some(function(webglId) {
+ return ctx = canvas.getContext(webglId, contextAttributes);
+ });
+ } finally {
+ canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
+ }
+ } else {
+ ctx = canvas.getContext('2d');
+ }
+ if (!ctx) throw ':(';
+ } catch (e) {
+ Module.print('Could not create canvas: ' + [errorInfo, e]);
+ return null;
+ }
+ if (useWebGL) {
+ // Set the background of the WebGL canvas to black
+ canvas.style.backgroundColor = "black";
+
+ // Warn on context loss
+ canvas.addEventListener('webglcontextlost', function(event) {
+ alert('WebGL context lost. You will need to reload the page.');
+ }, false);
+ }
+ if (setInModule) {
+ GLctx = Module.ctx = ctx;
+ Module.useWebGL = useWebGL;
+ Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
+ Browser.init();
+ }
+ return ctx;
+ },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {
+ Browser.lockPointer = lockPointer;
+ Browser.resizeCanvas = resizeCanvas;
+ if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;
+ if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;
+
+ var canvas = Module['canvas'];
+ function fullScreenChange() {
+ Browser.isFullScreen = false;
+ var canvasContainer = canvas.parentNode;
+ if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvasContainer) {
+ canvas.cancelFullScreen = document['cancelFullScreen'] ||
+ document['mozCancelFullScreen'] ||
+ document['webkitCancelFullScreen'] ||
+ document['msExitFullscreen'] ||
+ document['exitFullscreen'] ||
+ function() {};
+ canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);
+ if (Browser.lockPointer) canvas.requestPointerLock();
+ Browser.isFullScreen = true;
+ if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();
+ } else {
+
+ // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen
+ canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
+ canvasContainer.parentNode.removeChild(canvasContainer);
+
+ if (Browser.resizeCanvas) Browser.setWindowedCanvasSize();
+ }
+ if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);
+ Browser.updateCanvasDimensions(canvas);
+ }
+
+ if (!Browser.fullScreenHandlersInstalled) {
+ Browser.fullScreenHandlersInstalled = true;
+ document.addEventListener('fullscreenchange', fullScreenChange, false);
+ document.addEventListener('mozfullscreenchange', fullScreenChange, false);
+ document.addEventListener('webkitfullscreenchange', fullScreenChange, false);
+ document.addEventListener('MSFullscreenChange', fullScreenChange, false);
+ }
+
+ // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root
+ var canvasContainer = document.createElement("div");
+ canvas.parentNode.insertBefore(canvasContainer, canvas);
+ canvasContainer.appendChild(canvas);
+
+ // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size)
+ canvasContainer.requestFullScreen = canvasContainer['requestFullScreen'] ||
+ canvasContainer['mozRequestFullScreen'] ||
+ canvasContainer['msRequestFullscreen'] ||
+ (canvasContainer['webkitRequestFullScreen'] ? function() { canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);
+ canvasContainer.requestFullScreen();
+ },requestAnimationFrame:function requestAnimationFrame(func) {
+ if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
+ setTimeout(func, 1000/60);
+ } else {
+ if (!window.requestAnimationFrame) {
+ window.requestAnimationFrame = window['requestAnimationFrame'] ||
+ window['mozRequestAnimationFrame'] ||
+ window['webkitRequestAnimationFrame'] ||
+ window['msRequestAnimationFrame'] ||
+ window['oRequestAnimationFrame'] ||
+ window['setTimeout'];
+ }
+ window.requestAnimationFrame(func);
+ }
+ },safeCallback:function (func) {
+ return function() {
+ if (!ABORT) return func.apply(null, arguments);
+ };
+ },safeRequestAnimationFrame:function (func) {
+ return Browser.requestAnimationFrame(function() {
+ if (!ABORT) func();
+ });
+ },safeSetTimeout:function (func, timeout) {
+ return setTimeout(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },safeSetInterval:function (func, timeout) {
+ return setInterval(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },getMimetype:function (name) {
+ return {
+ 'jpg': 'image/jpeg',
+ 'jpeg': 'image/jpeg',
+ 'png': 'image/png',
+ 'bmp': 'image/bmp',
+ 'ogg': 'audio/ogg',
+ 'wav': 'audio/wav',
+ 'mp3': 'audio/mpeg'
+ }[name.substr(name.lastIndexOf('.')+1)];
+ },getUserMedia:function (func) {
+ if(!window.getUserMedia) {
+ window.getUserMedia = navigator['getUserMedia'] ||
+ navigator['mozGetUserMedia'];
+ }
+ window.getUserMedia(func);
+ },getMovementX:function (event) {
+ return event['movementX'] ||
+ event['mozMovementX'] ||
+ event['webkitMovementX'] ||
+ 0;
+ },getMovementY:function (event) {
+ return event['movementY'] ||
+ event['mozMovementY'] ||
+ event['webkitMovementY'] ||
+ 0;
+ },getMouseWheelDelta:function (event) {
+ return Math.max(-1, Math.min(1, event.type === 'DOMMouseScroll' ? event.detail : -event.wheelDelta));
+ },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup
+ if (Browser.pointerLock) {
+ // When the pointer is locked, calculate the coordinates
+ // based on the movement of the mouse.
+ // Workaround for Firefox bug 764498
+ if (event.type != 'mousemove' &&
+ ('mozMovementX' in event)) {
+ Browser.mouseMovementX = Browser.mouseMovementY = 0;
+ } else {
+ Browser.mouseMovementX = Browser.getMovementX(event);
+ Browser.mouseMovementY = Browser.getMovementY(event);
+ }
+
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
+ Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
+ } else {
+ // just add the mouse delta to the current absolut mouse position
+ // FIXME: ideally this should be clamped against the canvas size and zero
+ Browser.mouseX += Browser.mouseMovementX;
+ Browser.mouseY += Browser.mouseMovementY;
+ }
+ } else {
+ // Otherwise, calculate the movement based on the changes
+ // in the coordinates.
+ var rect = Module["canvas"].getBoundingClientRect();
+ var x, y;
+
+ // Neither .scrollX or .pageXOffset are defined in a spec, but
+ // we prefer .scrollX because it is currently in a spec draft.
+ // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
+ var scrollX = ((typeof window.scrollX !== 'undefined') ? window.scrollX : window.pageXOffset);
+ var scrollY = ((typeof window.scrollY !== 'undefined') ? window.scrollY : window.pageYOffset);
+ if (event.type == 'touchstart' ||
+ event.type == 'touchend' ||
+ event.type == 'touchmove') {
+ var t = event.touches.item(0);
+ if (t) {
+ x = t.pageX - (scrollX + rect.left);
+ y = t.pageY - (scrollY + rect.top);
+ } else {
+ return;
+ }
+ } else {
+ x = event.pageX - (scrollX + rect.left);
+ y = event.pageY - (scrollY + rect.top);
+ }
+
+ // the canvas might be CSS-scaled compared to its backbuffer;
+ // SDL-using content will want mouse coordinates in terms
+ // of backbuffer units.
+ var cw = Module["canvas"].width;
+ var ch = Module["canvas"].height;
+ x = x * (cw / rect.width);
+ y = y * (ch / rect.height);
+
+ Browser.mouseMovementX = x - Browser.mouseX;
+ Browser.mouseMovementY = y - Browser.mouseY;
+ Browser.mouseX = x;
+ Browser.mouseY = y;
+ }
+ },xhrLoad:function (url, onload, onerror) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, true);
+ xhr.responseType = 'arraybuffer';
+ xhr.onload = function xhr_onload() {
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
+ onload(xhr.response);
+ } else {
+ onerror();
+ }
+ };
+ xhr.onerror = onerror;
+ xhr.send(null);
+ },asyncLoad:function (url, onload, onerror, noRunDep) {
+ Browser.xhrLoad(url, function(arrayBuffer) {
+ assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
+ onload(new Uint8Array(arrayBuffer));
+ if (!noRunDep) removeRunDependency('al ' + url);
+ }, function(event) {
+ if (onerror) {
+ onerror();
+ } else {
+ throw 'Loading data file "' + url + '" failed.';
+ }
+ });
+ if (!noRunDep) addRunDependency('al ' + url);
+ },resizeListeners:[],updateResizeListeners:function () {
+ var canvas = Module['canvas'];
+ Browser.resizeListeners.forEach(function(listener) {
+ listener(canvas.width, canvas.height);
+ });
+ },setCanvasSize:function (width, height, noUpdates) {
+ var canvas = Module['canvas'];
+ Browser.updateCanvasDimensions(canvas, width, height);
+ if (!noUpdates) Browser.updateResizeListeners();
+ },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },setWindowedCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },updateCanvasDimensions:function (canvas, wNative, hNative) {
+ if (wNative && hNative) {
+ canvas.widthNative = wNative;
+ canvas.heightNative = hNative;
+ } else {
+ wNative = canvas.widthNative;
+ hNative = canvas.heightNative;
+ }
+ var w = wNative;
+ var h = hNative;
+ if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) {
+ if (w/h < Module['forcedAspectRatio']) {
+ w = Math.round(h * Module['forcedAspectRatio']);
+ } else {
+ h = Math.round(w / Module['forcedAspectRatio']);
+ }
+ }
+ if (((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
+ var factor = Math.min(screen.width / w, screen.height / h);
+ w = Math.round(w * factor);
+ h = Math.round(h * factor);
+ }
+ if (Browser.resizeCanvas) {
+ if (canvas.width != w) canvas.width = w;
+ if (canvas.height != h) canvas.height = h;
+ if (typeof canvas.style != 'undefined') {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ } else {
+ if (canvas.width != wNative) canvas.width = wNative;
+ if (canvas.height != hNative) canvas.height = hNative;
+ if (typeof canvas.style != 'undefined') {
+ if (w != wNative || h != hNative) {
+ canvas.style.setProperty( "width", w + "px", "important");
+ canvas.style.setProperty("height", h + "px", "important");
+ } else {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ }
+ }
+ }};
+
+ function _time(ptr) {
+ var ret = Math.floor(Date.now()/1000);
+ if (ptr) {
+ HEAP32[((ptr)>>2)]=ret;
+ }
+ return ret;
+ }
+
+
+ function _malloc(bytes) {
+ /* Over-allocate to make sure it is byte-aligned by 8.
+ * This will leak memory, but this is only the dummy
+ * implementation (replaced by dlmalloc normally) so
+ * not an issue.
+ */
+ var ptr = Runtime.dynamicAlloc(bytes + 8);
+ return (ptr+8) & 0xFFFFFFF8;
+ }
+ Module["_malloc"] = _malloc;function ___cxa_allocate_exception(size) {
+ var ptr = _malloc(size + ___cxa_exception_header_size);
+ return ptr + ___cxa_exception_header_size;
+ }
+
+ var __ZTISt9exception=allocate([allocate([1,0,0,0,0,0,0], "i8", ALLOC_STATIC)+8, 0], "i32", ALLOC_STATIC);
+
+ function __ZTVN10__cxxabiv120__si_class_type_infoE() {
+ Module['printErr']('missing function: _ZTVN10__cxxabiv120__si_class_type_infoE'); abort(-1);
+ }
+___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;
+FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;
+__ATINIT__.unshift({ func: function() { TTY.init() } });__ATEXIT__.push({ func: function() { TTY.shutdown() } });TTY.utf8 = new Runtime.UTF8Processor();
+if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); NODEFS.staticInit(); }
+__ATINIT__.push({ func: function() { SOCKFS.root = FS.mount(SOCKFS, {}, null); } });
+_fputc.ret = allocate([0], "i8", ALLOC_STATIC);
+Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };
+ Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };
+ Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };
+ Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };
+ Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };
+ Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }
+STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);
+
+staticSealed = true; // seal the static portion of memory
+
+STACK_MAX = STACK_BASE + 5242880;
+
+DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);
+
+assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");
+
+
+var Math_min = Math.min;
+function invoke_ii(index,a1) {
+ try {
+ return Module["dynCall_ii"](index,a1);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_vi(index,a1) {
+ try {
+ Module["dynCall_vi"](index,a1);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_v(index) {
+ try {
+ Module["dynCall_v"](index);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function asmPrintInt(x, y) {
+ Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+function asmPrintFloat(x, y) {
+ Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+// EMSCRIPTEN_START_ASM
+var asm = (function(global, env, buffer) {
+ 'use asm';
+ var HEAP8 = new global.Int8Array(buffer);
+ var HEAP16 = new global.Int16Array(buffer);
+ var HEAP32 = new global.Int32Array(buffer);
+ var HEAPU8 = new global.Uint8Array(buffer);
+ var HEAPU16 = new global.Uint16Array(buffer);
+ var HEAPU32 = new global.Uint32Array(buffer);
+ var HEAPF32 = new global.Float32Array(buffer);
+ var HEAPF64 = new global.Float64Array(buffer);
+
+ var STACKTOP=env.STACKTOP|0;
+ var STACK_MAX=env.STACK_MAX|0;
+ var tempDoublePtr=env.tempDoublePtr|0;
+ var ABORT=env.ABORT|0;
+ var __ZTISt9exception=env.__ZTISt9exception|0;
+ var __ZTVN10__cxxabiv120__si_class_type_infoE=env.__ZTVN10__cxxabiv120__si_class_type_infoE|0;
+
+ var __THREW__ = 0;
+ var threwValue = 0;
+ var setjmpId = 0;
+ var undef = 0;
+ var nan = +env.NaN, inf = +env.Infinity;
+ var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0;
+
+ var tempRet0 = 0;
+ var tempRet1 = 0;
+ var tempRet2 = 0;
+ var tempRet3 = 0;
+ var tempRet4 = 0;
+ var tempRet5 = 0;
+ var tempRet6 = 0;
+ var tempRet7 = 0;
+ var tempRet8 = 0;
+ var tempRet9 = 0;
+ var Math_floor=global.Math.floor;
+ var Math_abs=global.Math.abs;
+ var Math_sqrt=global.Math.sqrt;
+ var Math_pow=global.Math.pow;
+ var Math_cos=global.Math.cos;
+ var Math_sin=global.Math.sin;
+ var Math_tan=global.Math.tan;
+ var Math_acos=global.Math.acos;
+ var Math_asin=global.Math.asin;
+ var Math_atan=global.Math.atan;
+ var Math_atan2=global.Math.atan2;
+ var Math_exp=global.Math.exp;
+ var Math_log=global.Math.log;
+ var Math_ceil=global.Math.ceil;
+ var Math_imul=global.Math.imul;
+ var abort=env.abort;
+ var assert=env.assert;
+ var asmPrintInt=env.asmPrintInt;
+ var asmPrintFloat=env.asmPrintFloat;
+ var Math_min=env.min;
+ var invoke_ii=env.invoke_ii;
+ var invoke_vi=env.invoke_vi;
+ var invoke_v=env.invoke_v;
+ var _send=env._send;
+ var ___setErrNo=env.___setErrNo;
+ var ___cxa_is_number_type=env.___cxa_is_number_type;
+ var ___cxa_allocate_exception=env.___cxa_allocate_exception;
+ var ___cxa_find_matching_catch=env.___cxa_find_matching_catch;
+ var _fflush=env._fflush;
+ var _time=env._time;
+ var _pwrite=env._pwrite;
+ var __reallyNegative=env.__reallyNegative;
+ var _sbrk=env._sbrk;
+ var _emscripten_memcpy_big=env._emscripten_memcpy_big;
+ var _fileno=env._fileno;
+ var ___resumeException=env.___resumeException;
+ var __ZSt18uncaught_exceptionv=env.__ZSt18uncaught_exceptionv;
+ var _sysconf=env._sysconf;
+ var _puts=env._puts;
+ var _mkport=env._mkport;
+ var _write=env._write;
+ var ___errno_location=env.___errno_location;
+ var __ZNSt9exceptionD2Ev=env.__ZNSt9exceptionD2Ev;
+ var _fputc=env._fputc;
+ var ___cxa_throw=env.___cxa_throw;
+ var _abort=env._abort;
+ var _fwrite=env._fwrite;
+ var ___cxa_does_inherit=env.___cxa_does_inherit;
+ var _fprintf=env._fprintf;
+ var __formatString=env.__formatString;
+ var _fputs=env._fputs;
+ var _printf=env._printf;
+ var tempFloat = 0.0;
+
+// EMSCRIPTEN_START_FUNCS
+function _malloc(i12) {
+ i12 = i12 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0;
+ i1 = STACKTOP;
+ do {
+ if (i12 >>> 0 < 245) {
+ if (i12 >>> 0 < 11) {
+ i12 = 16;
+ } else {
+ i12 = i12 + 11 & -8;
+ }
+ i20 = i12 >>> 3;
+ i18 = HEAP32[146] | 0;
+ i21 = i18 >>> i20;
+ if ((i21 & 3 | 0) != 0) {
+ i6 = (i21 & 1 ^ 1) + i20 | 0;
+ i5 = i6 << 1;
+ i3 = 624 + (i5 << 2) | 0;
+ i5 = 624 + (i5 + 2 << 2) | 0;
+ i7 = HEAP32[i5 >> 2] | 0;
+ i2 = i7 + 8 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ do {
+ if ((i3 | 0) != (i4 | 0)) {
+ if (i4 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i4 + 12 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i7 | 0)) {
+ HEAP32[i8 >> 2] = i3;
+ HEAP32[i5 >> 2] = i4;
+ break;
+ } else {
+ _abort();
+ }
+ } else {
+ HEAP32[146] = i18 & ~(1 << i6);
+ }
+ } while (0);
+ i32 = i6 << 3;
+ HEAP32[i7 + 4 >> 2] = i32 | 3;
+ i32 = i7 + (i32 | 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ i32 = i2;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ if (i12 >>> 0 > (HEAP32[592 >> 2] | 0) >>> 0) {
+ if ((i21 | 0) != 0) {
+ i7 = 2 << i20;
+ i7 = i21 << i20 & (i7 | 0 - i7);
+ i7 = (i7 & 0 - i7) + -1 | 0;
+ i2 = i7 >>> 12 & 16;
+ i7 = i7 >>> i2;
+ i6 = i7 >>> 5 & 8;
+ i7 = i7 >>> i6;
+ i5 = i7 >>> 2 & 4;
+ i7 = i7 >>> i5;
+ i4 = i7 >>> 1 & 2;
+ i7 = i7 >>> i4;
+ i3 = i7 >>> 1 & 1;
+ i3 = (i6 | i2 | i5 | i4 | i3) + (i7 >>> i3) | 0;
+ i7 = i3 << 1;
+ i4 = 624 + (i7 << 2) | 0;
+ i7 = 624 + (i7 + 2 << 2) | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ i2 = i5 + 8 | 0;
+ i6 = HEAP32[i2 >> 2] | 0;
+ do {
+ if ((i4 | 0) != (i6 | 0)) {
+ if (i6 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i6 + 12 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i5 | 0)) {
+ HEAP32[i8 >> 2] = i4;
+ HEAP32[i7 >> 2] = i6;
+ break;
+ } else {
+ _abort();
+ }
+ } else {
+ HEAP32[146] = i18 & ~(1 << i3);
+ }
+ } while (0);
+ i6 = i3 << 3;
+ i4 = i6 - i12 | 0;
+ HEAP32[i5 + 4 >> 2] = i12 | 3;
+ i3 = i5 + i12 | 0;
+ HEAP32[i5 + (i12 | 4) >> 2] = i4 | 1;
+ HEAP32[i5 + i6 >> 2] = i4;
+ i6 = HEAP32[592 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i5 = HEAP32[604 >> 2] | 0;
+ i8 = i6 >>> 3;
+ i9 = i8 << 1;
+ i6 = 624 + (i9 << 2) | 0;
+ i7 = HEAP32[146] | 0;
+ i8 = 1 << i8;
+ if ((i7 & i8 | 0) != 0) {
+ i7 = 624 + (i9 + 2 << 2) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i28 = i7;
+ i27 = i8;
+ }
+ } else {
+ HEAP32[146] = i7 | i8;
+ i28 = 624 + (i9 + 2 << 2) | 0;
+ i27 = i6;
+ }
+ HEAP32[i28 >> 2] = i5;
+ HEAP32[i27 + 12 >> 2] = i5;
+ HEAP32[i5 + 8 >> 2] = i27;
+ HEAP32[i5 + 12 >> 2] = i6;
+ }
+ HEAP32[592 >> 2] = i4;
+ HEAP32[604 >> 2] = i3;
+ i32 = i2;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i18 = HEAP32[588 >> 2] | 0;
+ if ((i18 | 0) != 0) {
+ i2 = (i18 & 0 - i18) + -1 | 0;
+ i31 = i2 >>> 12 & 16;
+ i2 = i2 >>> i31;
+ i30 = i2 >>> 5 & 8;
+ i2 = i2 >>> i30;
+ i32 = i2 >>> 2 & 4;
+ i2 = i2 >>> i32;
+ i6 = i2 >>> 1 & 2;
+ i2 = i2 >>> i6;
+ i3 = i2 >>> 1 & 1;
+ i3 = HEAP32[888 + ((i30 | i31 | i32 | i6 | i3) + (i2 >>> i3) << 2) >> 2] | 0;
+ i2 = (HEAP32[i3 + 4 >> 2] & -8) - i12 | 0;
+ i6 = i3;
+ while (1) {
+ i5 = HEAP32[i6 + 16 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i5 = HEAP32[i6 + 20 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ }
+ i6 = (HEAP32[i5 + 4 >> 2] & -8) - i12 | 0;
+ i4 = i6 >>> 0 < i2 >>> 0;
+ i2 = i4 ? i6 : i2;
+ i6 = i5;
+ i3 = i4 ? i5 : i3;
+ }
+ i6 = HEAP32[600 >> 2] | 0;
+ if (i3 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ i4 = i3 + i12 | 0;
+ if (!(i3 >>> 0 < i4 >>> 0)) {
+ _abort();
+ }
+ i5 = HEAP32[i3 + 24 >> 2] | 0;
+ i7 = HEAP32[i3 + 12 >> 2] | 0;
+ do {
+ if ((i7 | 0) == (i3 | 0)) {
+ i8 = i3 + 20 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i8 = i3 + 16 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i26 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i10 = i7 + 20 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ i7 = i9;
+ i8 = i10;
+ continue;
+ }
+ i10 = i7 + 16 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ } else {
+ i7 = i9;
+ i8 = i10;
+ }
+ }
+ if (i8 >>> 0 < i6 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i8 >> 2] = 0;
+ i26 = i7;
+ break;
+ }
+ } else {
+ i8 = HEAP32[i3 + 8 >> 2] | 0;
+ if (i8 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ i6 = i8 + 12 | 0;
+ if ((HEAP32[i6 >> 2] | 0) != (i3 | 0)) {
+ _abort();
+ }
+ i9 = i7 + 8 | 0;
+ if ((HEAP32[i9 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i6 >> 2] = i7;
+ HEAP32[i9 >> 2] = i8;
+ i26 = i7;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ do {
+ if ((i5 | 0) != 0) {
+ i7 = HEAP32[i3 + 28 >> 2] | 0;
+ i6 = 888 + (i7 << 2) | 0;
+ if ((i3 | 0) == (HEAP32[i6 >> 2] | 0)) {
+ HEAP32[i6 >> 2] = i26;
+ if ((i26 | 0) == 0) {
+ HEAP32[588 >> 2] = HEAP32[588 >> 2] & ~(1 << i7);
+ break;
+ }
+ } else {
+ if (i5 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i6 = i5 + 16 | 0;
+ if ((HEAP32[i6 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i6 >> 2] = i26;
+ } else {
+ HEAP32[i5 + 20 >> 2] = i26;
+ }
+ if ((i26 | 0) == 0) {
+ break;
+ }
+ }
+ if (i26 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i26 + 24 >> 2] = i5;
+ i5 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i26 + 16 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i26;
+ break;
+ }
+ }
+ } while (0);
+ i5 = HEAP32[i3 + 20 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i26 + 20 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i26;
+ break;
+ }
+ }
+ }
+ } while (0);
+ if (i2 >>> 0 < 16) {
+ i32 = i2 + i12 | 0;
+ HEAP32[i3 + 4 >> 2] = i32 | 3;
+ i32 = i3 + (i32 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ } else {
+ HEAP32[i3 + 4 >> 2] = i12 | 3;
+ HEAP32[i3 + (i12 | 4) >> 2] = i2 | 1;
+ HEAP32[i3 + (i2 + i12) >> 2] = i2;
+ i6 = HEAP32[592 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i5 = HEAP32[604 >> 2] | 0;
+ i8 = i6 >>> 3;
+ i9 = i8 << 1;
+ i6 = 624 + (i9 << 2) | 0;
+ i7 = HEAP32[146] | 0;
+ i8 = 1 << i8;
+ if ((i7 & i8 | 0) != 0) {
+ i7 = 624 + (i9 + 2 << 2) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i25 = i7;
+ i24 = i8;
+ }
+ } else {
+ HEAP32[146] = i7 | i8;
+ i25 = 624 + (i9 + 2 << 2) | 0;
+ i24 = i6;
+ }
+ HEAP32[i25 >> 2] = i5;
+ HEAP32[i24 + 12 >> 2] = i5;
+ HEAP32[i5 + 8 >> 2] = i24;
+ HEAP32[i5 + 12 >> 2] = i6;
+ }
+ HEAP32[592 >> 2] = i2;
+ HEAP32[604 >> 2] = i4;
+ }
+ i32 = i3 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ } else {
+ if (!(i12 >>> 0 > 4294967231)) {
+ i24 = i12 + 11 | 0;
+ i12 = i24 & -8;
+ i26 = HEAP32[588 >> 2] | 0;
+ if ((i26 | 0) != 0) {
+ i25 = 0 - i12 | 0;
+ i24 = i24 >>> 8;
+ if ((i24 | 0) != 0) {
+ if (i12 >>> 0 > 16777215) {
+ i27 = 31;
+ } else {
+ i31 = (i24 + 1048320 | 0) >>> 16 & 8;
+ i32 = i24 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i27 = (i32 + 245760 | 0) >>> 16 & 2;
+ i27 = 14 - (i30 | i31 | i27) + (i32 << i27 >>> 15) | 0;
+ i27 = i12 >>> (i27 + 7 | 0) & 1 | i27 << 1;
+ }
+ } else {
+ i27 = 0;
+ }
+ i30 = HEAP32[888 + (i27 << 2) >> 2] | 0;
+ L126 : do {
+ if ((i30 | 0) == 0) {
+ i29 = 0;
+ i24 = 0;
+ } else {
+ if ((i27 | 0) == 31) {
+ i24 = 0;
+ } else {
+ i24 = 25 - (i27 >>> 1) | 0;
+ }
+ i29 = 0;
+ i28 = i12 << i24;
+ i24 = 0;
+ while (1) {
+ i32 = HEAP32[i30 + 4 >> 2] & -8;
+ i31 = i32 - i12 | 0;
+ if (i31 >>> 0 < i25 >>> 0) {
+ if ((i32 | 0) == (i12 | 0)) {
+ i25 = i31;
+ i29 = i30;
+ i24 = i30;
+ break L126;
+ } else {
+ i25 = i31;
+ i24 = i30;
+ }
+ }
+ i31 = HEAP32[i30 + 20 >> 2] | 0;
+ i30 = HEAP32[i30 + (i28 >>> 31 << 2) + 16 >> 2] | 0;
+ i29 = (i31 | 0) == 0 | (i31 | 0) == (i30 | 0) ? i29 : i31;
+ if ((i30 | 0) == 0) {
+ break;
+ } else {
+ i28 = i28 << 1;
+ }
+ }
+ }
+ } while (0);
+ if ((i29 | 0) == 0 & (i24 | 0) == 0) {
+ i32 = 2 << i27;
+ i26 = i26 & (i32 | 0 - i32);
+ if ((i26 | 0) == 0) {
+ break;
+ }
+ i32 = (i26 & 0 - i26) + -1 | 0;
+ i28 = i32 >>> 12 & 16;
+ i32 = i32 >>> i28;
+ i27 = i32 >>> 5 & 8;
+ i32 = i32 >>> i27;
+ i30 = i32 >>> 2 & 4;
+ i32 = i32 >>> i30;
+ i31 = i32 >>> 1 & 2;
+ i32 = i32 >>> i31;
+ i29 = i32 >>> 1 & 1;
+ i29 = HEAP32[888 + ((i27 | i28 | i30 | i31 | i29) + (i32 >>> i29) << 2) >> 2] | 0;
+ }
+ if ((i29 | 0) != 0) {
+ while (1) {
+ i27 = (HEAP32[i29 + 4 >> 2] & -8) - i12 | 0;
+ i26 = i27 >>> 0 < i25 >>> 0;
+ i25 = i26 ? i27 : i25;
+ i24 = i26 ? i29 : i24;
+ i26 = HEAP32[i29 + 16 >> 2] | 0;
+ if ((i26 | 0) != 0) {
+ i29 = i26;
+ continue;
+ }
+ i29 = HEAP32[i29 + 20 >> 2] | 0;
+ if ((i29 | 0) == 0) {
+ break;
+ }
+ }
+ }
+ if ((i24 | 0) != 0 ? i25 >>> 0 < ((HEAP32[592 >> 2] | 0) - i12 | 0) >>> 0 : 0) {
+ i4 = HEAP32[600 >> 2] | 0;
+ if (i24 >>> 0 < i4 >>> 0) {
+ _abort();
+ }
+ i2 = i24 + i12 | 0;
+ if (!(i24 >>> 0 < i2 >>> 0)) {
+ _abort();
+ }
+ i3 = HEAP32[i24 + 24 >> 2] | 0;
+ i6 = HEAP32[i24 + 12 >> 2] | 0;
+ do {
+ if ((i6 | 0) == (i24 | 0)) {
+ i6 = i24 + 20 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i6 = i24 + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i22 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i8 = i5 + 20 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) != 0) {
+ i5 = i7;
+ i6 = i8;
+ continue;
+ }
+ i7 = i5 + 16 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if ((i8 | 0) == 0) {
+ break;
+ } else {
+ i5 = i8;
+ i6 = i7;
+ }
+ }
+ if (i6 >>> 0 < i4 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = 0;
+ i22 = i5;
+ break;
+ }
+ } else {
+ i5 = HEAP32[i24 + 8 >> 2] | 0;
+ if (i5 >>> 0 < i4 >>> 0) {
+ _abort();
+ }
+ i7 = i5 + 12 | 0;
+ if ((HEAP32[i7 >> 2] | 0) != (i24 | 0)) {
+ _abort();
+ }
+ i4 = i6 + 8 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
+ HEAP32[i7 >> 2] = i6;
+ HEAP32[i4 >> 2] = i5;
+ i22 = i6;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ do {
+ if ((i3 | 0) != 0) {
+ i4 = HEAP32[i24 + 28 >> 2] | 0;
+ i5 = 888 + (i4 << 2) | 0;
+ if ((i24 | 0) == (HEAP32[i5 >> 2] | 0)) {
+ HEAP32[i5 >> 2] = i22;
+ if ((i22 | 0) == 0) {
+ HEAP32[588 >> 2] = HEAP32[588 >> 2] & ~(1 << i4);
+ break;
+ }
+ } else {
+ if (i3 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i4 = i3 + 16 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
+ HEAP32[i4 >> 2] = i22;
+ } else {
+ HEAP32[i3 + 20 >> 2] = i22;
+ }
+ if ((i22 | 0) == 0) {
+ break;
+ }
+ }
+ if (i22 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i22 + 24 >> 2] = i3;
+ i3 = HEAP32[i24 + 16 >> 2] | 0;
+ do {
+ if ((i3 | 0) != 0) {
+ if (i3 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i22 + 16 >> 2] = i3;
+ HEAP32[i3 + 24 >> 2] = i22;
+ break;
+ }
+ }
+ } while (0);
+ i3 = HEAP32[i24 + 20 >> 2] | 0;
+ if ((i3 | 0) != 0) {
+ if (i3 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i22 + 20 >> 2] = i3;
+ HEAP32[i3 + 24 >> 2] = i22;
+ break;
+ }
+ }
+ }
+ } while (0);
+ L204 : do {
+ if (!(i25 >>> 0 < 16)) {
+ HEAP32[i24 + 4 >> 2] = i12 | 3;
+ HEAP32[i24 + (i12 | 4) >> 2] = i25 | 1;
+ HEAP32[i24 + (i25 + i12) >> 2] = i25;
+ i4 = i25 >>> 3;
+ if (i25 >>> 0 < 256) {
+ i6 = i4 << 1;
+ i3 = 624 + (i6 << 2) | 0;
+ i5 = HEAP32[146] | 0;
+ i4 = 1 << i4;
+ if ((i5 & i4 | 0) != 0) {
+ i5 = 624 + (i6 + 2 << 2) | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ if (i4 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i21 = i5;
+ i20 = i4;
+ }
+ } else {
+ HEAP32[146] = i5 | i4;
+ i21 = 624 + (i6 + 2 << 2) | 0;
+ i20 = i3;
+ }
+ HEAP32[i21 >> 2] = i2;
+ HEAP32[i20 + 12 >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i20;
+ HEAP32[i24 + (i12 + 12) >> 2] = i3;
+ break;
+ }
+ i3 = i25 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i25 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i25 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i6 = 888 + (i3 << 2) | 0;
+ HEAP32[i24 + (i12 + 28) >> 2] = i3;
+ HEAP32[i24 + (i12 + 20) >> 2] = 0;
+ HEAP32[i24 + (i12 + 16) >> 2] = 0;
+ i4 = HEAP32[588 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i4 & i5 | 0) == 0) {
+ HEAP32[588 >> 2] = i4 | i5;
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i24 + (i12 + 24) >> 2] = i6;
+ HEAP32[i24 + (i12 + 12) >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i2;
+ break;
+ }
+ i4 = HEAP32[i6 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L225 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i25 | 0)) {
+ i3 = i25 << i3;
+ while (1) {
+ i6 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i25 | 0)) {
+ i18 = i5;
+ break L225;
+ } else {
+ i3 = i3 << 1;
+ i4 = i5;
+ }
+ }
+ if (i6 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i24 + (i12 + 24) >> 2] = i4;
+ HEAP32[i24 + (i12 + 12) >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i2;
+ break L204;
+ }
+ } else {
+ i18 = i4;
+ }
+ } while (0);
+ i4 = i18 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[600 >> 2] | 0;
+ if (i18 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i2;
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i3;
+ HEAP32[i24 + (i12 + 12) >> 2] = i18;
+ HEAP32[i24 + (i12 + 24) >> 2] = 0;
+ break;
+ }
+ } else {
+ i32 = i25 + i12 | 0;
+ HEAP32[i24 + 4 >> 2] = i32 | 3;
+ i32 = i24 + (i32 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ }
+ } while (0);
+ i32 = i24 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ } else {
+ i12 = -1;
+ }
+ }
+ } while (0);
+ i18 = HEAP32[592 >> 2] | 0;
+ if (!(i12 >>> 0 > i18 >>> 0)) {
+ i3 = i18 - i12 | 0;
+ i2 = HEAP32[604 >> 2] | 0;
+ if (i3 >>> 0 > 15) {
+ HEAP32[604 >> 2] = i2 + i12;
+ HEAP32[592 >> 2] = i3;
+ HEAP32[i2 + (i12 + 4) >> 2] = i3 | 1;
+ HEAP32[i2 + i18 >> 2] = i3;
+ HEAP32[i2 + 4 >> 2] = i12 | 3;
+ } else {
+ HEAP32[592 >> 2] = 0;
+ HEAP32[604 >> 2] = 0;
+ HEAP32[i2 + 4 >> 2] = i18 | 3;
+ i32 = i2 + (i18 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ }
+ i32 = i2 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i18 = HEAP32[596 >> 2] | 0;
+ if (i12 >>> 0 < i18 >>> 0) {
+ i31 = i18 - i12 | 0;
+ HEAP32[596 >> 2] = i31;
+ i32 = HEAP32[608 >> 2] | 0;
+ HEAP32[608 >> 2] = i32 + i12;
+ HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
+ HEAP32[i32 + 4 >> 2] = i12 | 3;
+ i32 = i32 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ do {
+ if ((HEAP32[264] | 0) == 0) {
+ i18 = _sysconf(30) | 0;
+ if ((i18 + -1 & i18 | 0) == 0) {
+ HEAP32[1064 >> 2] = i18;
+ HEAP32[1060 >> 2] = i18;
+ HEAP32[1068 >> 2] = -1;
+ HEAP32[1072 >> 2] = -1;
+ HEAP32[1076 >> 2] = 0;
+ HEAP32[1028 >> 2] = 0;
+ HEAP32[264] = (_time(0) | 0) & -16 ^ 1431655768;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ i20 = i12 + 48 | 0;
+ i25 = HEAP32[1064 >> 2] | 0;
+ i21 = i12 + 47 | 0;
+ i22 = i25 + i21 | 0;
+ i25 = 0 - i25 | 0;
+ i18 = i22 & i25;
+ if (!(i18 >>> 0 > i12 >>> 0)) {
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i24 = HEAP32[1024 >> 2] | 0;
+ if ((i24 | 0) != 0 ? (i31 = HEAP32[1016 >> 2] | 0, i32 = i31 + i18 | 0, i32 >>> 0 <= i31 >>> 0 | i32 >>> 0 > i24 >>> 0) : 0) {
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ L269 : do {
+ if ((HEAP32[1028 >> 2] & 4 | 0) == 0) {
+ i26 = HEAP32[608 >> 2] | 0;
+ L271 : do {
+ if ((i26 | 0) != 0) {
+ i24 = 1032 | 0;
+ while (1) {
+ i27 = HEAP32[i24 >> 2] | 0;
+ if (!(i27 >>> 0 > i26 >>> 0) ? (i23 = i24 + 4 | 0, (i27 + (HEAP32[i23 >> 2] | 0) | 0) >>> 0 > i26 >>> 0) : 0) {
+ break;
+ }
+ i24 = HEAP32[i24 + 8 >> 2] | 0;
+ if ((i24 | 0) == 0) {
+ i13 = 182;
+ break L271;
+ }
+ }
+ if ((i24 | 0) != 0) {
+ i25 = i22 - (HEAP32[596 >> 2] | 0) & i25;
+ if (i25 >>> 0 < 2147483647) {
+ i13 = _sbrk(i25 | 0) | 0;
+ i26 = (i13 | 0) == ((HEAP32[i24 >> 2] | 0) + (HEAP32[i23 >> 2] | 0) | 0);
+ i22 = i13;
+ i24 = i25;
+ i23 = i26 ? i13 : -1;
+ i25 = i26 ? i25 : 0;
+ i13 = 191;
+ } else {
+ i25 = 0;
+ }
+ } else {
+ i13 = 182;
+ }
+ } else {
+ i13 = 182;
+ }
+ } while (0);
+ do {
+ if ((i13 | 0) == 182) {
+ i23 = _sbrk(0) | 0;
+ if ((i23 | 0) != (-1 | 0)) {
+ i24 = i23;
+ i22 = HEAP32[1060 >> 2] | 0;
+ i25 = i22 + -1 | 0;
+ if ((i25 & i24 | 0) == 0) {
+ i25 = i18;
+ } else {
+ i25 = i18 - i24 + (i25 + i24 & 0 - i22) | 0;
+ }
+ i24 = HEAP32[1016 >> 2] | 0;
+ i26 = i24 + i25 | 0;
+ if (i25 >>> 0 > i12 >>> 0 & i25 >>> 0 < 2147483647) {
+ i22 = HEAP32[1024 >> 2] | 0;
+ if ((i22 | 0) != 0 ? i26 >>> 0 <= i24 >>> 0 | i26 >>> 0 > i22 >>> 0 : 0) {
+ i25 = 0;
+ break;
+ }
+ i22 = _sbrk(i25 | 0) | 0;
+ i13 = (i22 | 0) == (i23 | 0);
+ i24 = i25;
+ i23 = i13 ? i23 : -1;
+ i25 = i13 ? i25 : 0;
+ i13 = 191;
+ } else {
+ i25 = 0;
+ }
+ } else {
+ i25 = 0;
+ }
+ }
+ } while (0);
+ L291 : do {
+ if ((i13 | 0) == 191) {
+ i13 = 0 - i24 | 0;
+ if ((i23 | 0) != (-1 | 0)) {
+ i17 = i23;
+ i14 = i25;
+ i13 = 202;
+ break L269;
+ }
+ do {
+ if ((i22 | 0) != (-1 | 0) & i24 >>> 0 < 2147483647 & i24 >>> 0 < i20 >>> 0 ? (i19 = HEAP32[1064 >> 2] | 0, i19 = i21 - i24 + i19 & 0 - i19, i19 >>> 0 < 2147483647) : 0) {
+ if ((_sbrk(i19 | 0) | 0) == (-1 | 0)) {
+ _sbrk(i13 | 0) | 0;
+ break L291;
+ } else {
+ i24 = i19 + i24 | 0;
+ break;
+ }
+ }
+ } while (0);
+ if ((i22 | 0) != (-1 | 0)) {
+ i17 = i22;
+ i14 = i24;
+ i13 = 202;
+ break L269;
+ }
+ }
+ } while (0);
+ HEAP32[1028 >> 2] = HEAP32[1028 >> 2] | 4;
+ i13 = 199;
+ } else {
+ i25 = 0;
+ i13 = 199;
+ }
+ } while (0);
+ if ((((i13 | 0) == 199 ? i18 >>> 0 < 2147483647 : 0) ? (i17 = _sbrk(i18 | 0) | 0, i16 = _sbrk(0) | 0, (i16 | 0) != (-1 | 0) & (i17 | 0) != (-1 | 0) & i17 >>> 0 < i16 >>> 0) : 0) ? (i15 = i16 - i17 | 0, i14 = i15 >>> 0 > (i12 + 40 | 0) >>> 0, i14) : 0) {
+ i14 = i14 ? i15 : i25;
+ i13 = 202;
+ }
+ if ((i13 | 0) == 202) {
+ i15 = (HEAP32[1016 >> 2] | 0) + i14 | 0;
+ HEAP32[1016 >> 2] = i15;
+ if (i15 >>> 0 > (HEAP32[1020 >> 2] | 0) >>> 0) {
+ HEAP32[1020 >> 2] = i15;
+ }
+ i15 = HEAP32[608 >> 2] | 0;
+ L311 : do {
+ if ((i15 | 0) != 0) {
+ i21 = 1032 | 0;
+ while (1) {
+ i16 = HEAP32[i21 >> 2] | 0;
+ i19 = i21 + 4 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i17 | 0) == (i16 + i20 | 0)) {
+ i13 = 214;
+ break;
+ }
+ i18 = HEAP32[i21 + 8 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ break;
+ } else {
+ i21 = i18;
+ }
+ }
+ if (((i13 | 0) == 214 ? (HEAP32[i21 + 12 >> 2] & 8 | 0) == 0 : 0) ? i15 >>> 0 >= i16 >>> 0 & i15 >>> 0 < i17 >>> 0 : 0) {
+ HEAP32[i19 >> 2] = i20 + i14;
+ i2 = (HEAP32[596 >> 2] | 0) + i14 | 0;
+ i3 = i15 + 8 | 0;
+ if ((i3 & 7 | 0) == 0) {
+ i3 = 0;
+ } else {
+ i3 = 0 - i3 & 7;
+ }
+ i32 = i2 - i3 | 0;
+ HEAP32[608 >> 2] = i15 + i3;
+ HEAP32[596 >> 2] = i32;
+ HEAP32[i15 + (i3 + 4) >> 2] = i32 | 1;
+ HEAP32[i15 + (i2 + 4) >> 2] = 40;
+ HEAP32[612 >> 2] = HEAP32[1072 >> 2];
+ break;
+ }
+ if (i17 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ HEAP32[600 >> 2] = i17;
+ }
+ i19 = i17 + i14 | 0;
+ i16 = 1032 | 0;
+ while (1) {
+ if ((HEAP32[i16 >> 2] | 0) == (i19 | 0)) {
+ i13 = 224;
+ break;
+ }
+ i18 = HEAP32[i16 + 8 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ break;
+ } else {
+ i16 = i18;
+ }
+ }
+ if ((i13 | 0) == 224 ? (HEAP32[i16 + 12 >> 2] & 8 | 0) == 0 : 0) {
+ HEAP32[i16 >> 2] = i17;
+ i6 = i16 + 4 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + i14;
+ i6 = i17 + 8 | 0;
+ if ((i6 & 7 | 0) == 0) {
+ i6 = 0;
+ } else {
+ i6 = 0 - i6 & 7;
+ }
+ i7 = i17 + (i14 + 8) | 0;
+ if ((i7 & 7 | 0) == 0) {
+ i13 = 0;
+ } else {
+ i13 = 0 - i7 & 7;
+ }
+ i15 = i17 + (i13 + i14) | 0;
+ i8 = i6 + i12 | 0;
+ i7 = i17 + i8 | 0;
+ i10 = i15 - (i17 + i6) - i12 | 0;
+ HEAP32[i17 + (i6 + 4) >> 2] = i12 | 3;
+ L348 : do {
+ if ((i15 | 0) != (HEAP32[608 >> 2] | 0)) {
+ if ((i15 | 0) == (HEAP32[604 >> 2] | 0)) {
+ i32 = (HEAP32[592 >> 2] | 0) + i10 | 0;
+ HEAP32[592 >> 2] = i32;
+ HEAP32[604 >> 2] = i7;
+ HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i32 + i8) >> 2] = i32;
+ break;
+ }
+ i12 = i14 + 4 | 0;
+ i18 = HEAP32[i17 + (i12 + i13) >> 2] | 0;
+ if ((i18 & 3 | 0) == 1) {
+ i11 = i18 & -8;
+ i16 = i18 >>> 3;
+ do {
+ if (!(i18 >>> 0 < 256)) {
+ i9 = HEAP32[i17 + ((i13 | 24) + i14) >> 2] | 0;
+ i19 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
+ do {
+ if ((i19 | 0) == (i15 | 0)) {
+ i19 = i13 | 16;
+ i18 = i17 + (i12 + i19) | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ if ((i16 | 0) == 0) {
+ i18 = i17 + (i19 + i14) | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ if ((i16 | 0) == 0) {
+ i5 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i20 = i16 + 20 | 0;
+ i19 = HEAP32[i20 >> 2] | 0;
+ if ((i19 | 0) != 0) {
+ i16 = i19;
+ i18 = i20;
+ continue;
+ }
+ i19 = i16 + 16 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i20 | 0) == 0) {
+ break;
+ } else {
+ i16 = i20;
+ i18 = i19;
+ }
+ }
+ if (i18 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i18 >> 2] = 0;
+ i5 = i16;
+ break;
+ }
+ } else {
+ i18 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
+ if (i18 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i18 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != (i15 | 0)) {
+ _abort();
+ }
+ i20 = i19 + 8 | 0;
+ if ((HEAP32[i20 >> 2] | 0) == (i15 | 0)) {
+ HEAP32[i16 >> 2] = i19;
+ HEAP32[i20 >> 2] = i18;
+ i5 = i19;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i9 | 0) != 0) {
+ i16 = HEAP32[i17 + (i14 + 28 + i13) >> 2] | 0;
+ i18 = 888 + (i16 << 2) | 0;
+ if ((i15 | 0) == (HEAP32[i18 >> 2] | 0)) {
+ HEAP32[i18 >> 2] = i5;
+ if ((i5 | 0) == 0) {
+ HEAP32[588 >> 2] = HEAP32[588 >> 2] & ~(1 << i16);
+ break;
+ }
+ } else {
+ if (i9 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i9 + 16 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
+ HEAP32[i16 >> 2] = i5;
+ } else {
+ HEAP32[i9 + 20 >> 2] = i5;
+ }
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i5 + 24 >> 2] = i9;
+ i15 = i13 | 16;
+ i9 = HEAP32[i17 + (i15 + i14) >> 2] | 0;
+ do {
+ if ((i9 | 0) != 0) {
+ if (i9 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 + 16 >> 2] = i9;
+ HEAP32[i9 + 24 >> 2] = i5;
+ break;
+ }
+ }
+ } while (0);
+ i9 = HEAP32[i17 + (i12 + i15) >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ if (i9 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 + 20 >> 2] = i9;
+ HEAP32[i9 + 24 >> 2] = i5;
+ break;
+ }
+ }
+ }
+ } else {
+ i5 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
+ i12 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
+ i18 = 624 + (i16 << 1 << 2) | 0;
+ if ((i5 | 0) != (i18 | 0)) {
+ if (i5 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i5 + 12 >> 2] | 0) != (i15 | 0)) {
+ _abort();
+ }
+ }
+ if ((i12 | 0) == (i5 | 0)) {
+ HEAP32[146] = HEAP32[146] & ~(1 << i16);
+ break;
+ }
+ if ((i12 | 0) != (i18 | 0)) {
+ if (i12 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i12 + 8 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
+ i9 = i16;
+ } else {
+ _abort();
+ }
+ } else {
+ i9 = i12 + 8 | 0;
+ }
+ HEAP32[i5 + 12 >> 2] = i12;
+ HEAP32[i9 >> 2] = i5;
+ }
+ } while (0);
+ i15 = i17 + ((i11 | i13) + i14) | 0;
+ i10 = i11 + i10 | 0;
+ }
+ i5 = i15 + 4 | 0;
+ HEAP32[i5 >> 2] = HEAP32[i5 >> 2] & -2;
+ HEAP32[i17 + (i8 + 4) >> 2] = i10 | 1;
+ HEAP32[i17 + (i10 + i8) >> 2] = i10;
+ i5 = i10 >>> 3;
+ if (i10 >>> 0 < 256) {
+ i10 = i5 << 1;
+ i2 = 624 + (i10 << 2) | 0;
+ i9 = HEAP32[146] | 0;
+ i5 = 1 << i5;
+ if ((i9 & i5 | 0) != 0) {
+ i9 = 624 + (i10 + 2 << 2) | 0;
+ i5 = HEAP32[i9 >> 2] | 0;
+ if (i5 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i3 = i9;
+ i4 = i5;
+ }
+ } else {
+ HEAP32[146] = i9 | i5;
+ i3 = 624 + (i10 + 2 << 2) | 0;
+ i4 = i2;
+ }
+ HEAP32[i3 >> 2] = i7;
+ HEAP32[i4 + 12 >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i2;
+ break;
+ }
+ i3 = i10 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i10 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i10 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i4 = 888 + (i3 << 2) | 0;
+ HEAP32[i17 + (i8 + 28) >> 2] = i3;
+ HEAP32[i17 + (i8 + 20) >> 2] = 0;
+ HEAP32[i17 + (i8 + 16) >> 2] = 0;
+ i9 = HEAP32[588 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i9 & i5 | 0) == 0) {
+ HEAP32[588 >> 2] = i9 | i5;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i17 + (i8 + 24) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i7;
+ break;
+ }
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L444 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i10 | 0)) {
+ i3 = i10 << i3;
+ while (1) {
+ i5 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i9 = HEAP32[i5 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i9 + 4 >> 2] & -8 | 0) == (i10 | 0)) {
+ i2 = i9;
+ break L444;
+ } else {
+ i3 = i3 << 1;
+ i4 = i9;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 >> 2] = i7;
+ HEAP32[i17 + (i8 + 24) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i7;
+ break L348;
+ }
+ } else {
+ i2 = i4;
+ }
+ } while (0);
+ i4 = i2 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[600 >> 2] | 0;
+ if (i2 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i7;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i3;
+ HEAP32[i17 + (i8 + 12) >> 2] = i2;
+ HEAP32[i17 + (i8 + 24) >> 2] = 0;
+ break;
+ }
+ } else {
+ i32 = (HEAP32[596 >> 2] | 0) + i10 | 0;
+ HEAP32[596 >> 2] = i32;
+ HEAP32[608 >> 2] = i7;
+ HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
+ }
+ } while (0);
+ i32 = i17 + (i6 | 8) | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i3 = 1032 | 0;
+ while (1) {
+ i2 = HEAP32[i3 >> 2] | 0;
+ if (!(i2 >>> 0 > i15 >>> 0) ? (i11 = HEAP32[i3 + 4 >> 2] | 0, i10 = i2 + i11 | 0, i10 >>> 0 > i15 >>> 0) : 0) {
+ break;
+ }
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ }
+ i3 = i2 + (i11 + -39) | 0;
+ if ((i3 & 7 | 0) == 0) {
+ i3 = 0;
+ } else {
+ i3 = 0 - i3 & 7;
+ }
+ i2 = i2 + (i11 + -47 + i3) | 0;
+ i2 = i2 >>> 0 < (i15 + 16 | 0) >>> 0 ? i15 : i2;
+ i3 = i2 + 8 | 0;
+ i4 = i17 + 8 | 0;
+ if ((i4 & 7 | 0) == 0) {
+ i4 = 0;
+ } else {
+ i4 = 0 - i4 & 7;
+ }
+ i32 = i14 + -40 - i4 | 0;
+ HEAP32[608 >> 2] = i17 + i4;
+ HEAP32[596 >> 2] = i32;
+ HEAP32[i17 + (i4 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i14 + -36) >> 2] = 40;
+ HEAP32[612 >> 2] = HEAP32[1072 >> 2];
+ HEAP32[i2 + 4 >> 2] = 27;
+ HEAP32[i3 + 0 >> 2] = HEAP32[1032 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[1036 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[1040 >> 2];
+ HEAP32[i3 + 12 >> 2] = HEAP32[1044 >> 2];
+ HEAP32[1032 >> 2] = i17;
+ HEAP32[1036 >> 2] = i14;
+ HEAP32[1044 >> 2] = 0;
+ HEAP32[1040 >> 2] = i3;
+ i4 = i2 + 28 | 0;
+ HEAP32[i4 >> 2] = 7;
+ if ((i2 + 32 | 0) >>> 0 < i10 >>> 0) {
+ while (1) {
+ i3 = i4 + 4 | 0;
+ HEAP32[i3 >> 2] = 7;
+ if ((i4 + 8 | 0) >>> 0 < i10 >>> 0) {
+ i4 = i3;
+ } else {
+ break;
+ }
+ }
+ }
+ if ((i2 | 0) != (i15 | 0)) {
+ i2 = i2 - i15 | 0;
+ i3 = i15 + (i2 + 4) | 0;
+ HEAP32[i3 >> 2] = HEAP32[i3 >> 2] & -2;
+ HEAP32[i15 + 4 >> 2] = i2 | 1;
+ HEAP32[i15 + i2 >> 2] = i2;
+ i3 = i2 >>> 3;
+ if (i2 >>> 0 < 256) {
+ i4 = i3 << 1;
+ i2 = 624 + (i4 << 2) | 0;
+ i5 = HEAP32[146] | 0;
+ i3 = 1 << i3;
+ if ((i5 & i3 | 0) != 0) {
+ i4 = 624 + (i4 + 2 << 2) | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ if (i3 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i7 = i4;
+ i8 = i3;
+ }
+ } else {
+ HEAP32[146] = i5 | i3;
+ i7 = 624 + (i4 + 2 << 2) | 0;
+ i8 = i2;
+ }
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i8 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i8;
+ HEAP32[i15 + 12 >> 2] = i2;
+ break;
+ }
+ i3 = i2 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i2 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i2 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i7 = 888 + (i3 << 2) | 0;
+ HEAP32[i15 + 28 >> 2] = i3;
+ HEAP32[i15 + 20 >> 2] = 0;
+ HEAP32[i15 + 16 >> 2] = 0;
+ i4 = HEAP32[588 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i4 & i5 | 0) == 0) {
+ HEAP32[588 >> 2] = i4 | i5;
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i7;
+ HEAP32[i15 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i15;
+ break;
+ }
+ i4 = HEAP32[i7 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L499 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i2 | 0)) {
+ i3 = i2 << i3;
+ while (1) {
+ i7 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i2 | 0)) {
+ i6 = i5;
+ break L499;
+ } else {
+ i3 = i3 << 1;
+ i4 = i5;
+ }
+ }
+ if (i7 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i4;
+ HEAP32[i15 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i15;
+ break L311;
+ }
+ } else {
+ i6 = i4;
+ }
+ } while (0);
+ i4 = i6 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i2 = HEAP32[600 >> 2] | 0;
+ if (i6 >>> 0 < i2 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i2 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i15;
+ HEAP32[i4 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i3;
+ HEAP32[i15 + 12 >> 2] = i6;
+ HEAP32[i15 + 24 >> 2] = 0;
+ break;
+ }
+ }
+ } else {
+ i32 = HEAP32[600 >> 2] | 0;
+ if ((i32 | 0) == 0 | i17 >>> 0 < i32 >>> 0) {
+ HEAP32[600 >> 2] = i17;
+ }
+ HEAP32[1032 >> 2] = i17;
+ HEAP32[1036 >> 2] = i14;
+ HEAP32[1044 >> 2] = 0;
+ HEAP32[620 >> 2] = HEAP32[264];
+ HEAP32[616 >> 2] = -1;
+ i2 = 0;
+ do {
+ i32 = i2 << 1;
+ i31 = 624 + (i32 << 2) | 0;
+ HEAP32[624 + (i32 + 3 << 2) >> 2] = i31;
+ HEAP32[624 + (i32 + 2 << 2) >> 2] = i31;
+ i2 = i2 + 1 | 0;
+ } while ((i2 | 0) != 32);
+ i2 = i17 + 8 | 0;
+ if ((i2 & 7 | 0) == 0) {
+ i2 = 0;
+ } else {
+ i2 = 0 - i2 & 7;
+ }
+ i32 = i14 + -40 - i2 | 0;
+ HEAP32[608 >> 2] = i17 + i2;
+ HEAP32[596 >> 2] = i32;
+ HEAP32[i17 + (i2 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i14 + -36) >> 2] = 40;
+ HEAP32[612 >> 2] = HEAP32[1072 >> 2];
+ }
+ } while (0);
+ i2 = HEAP32[596 >> 2] | 0;
+ if (i2 >>> 0 > i12 >>> 0) {
+ i31 = i2 - i12 | 0;
+ HEAP32[596 >> 2] = i31;
+ i32 = HEAP32[608 >> 2] | 0;
+ HEAP32[608 >> 2] = i32 + i12;
+ HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
+ HEAP32[i32 + 4 >> 2] = i12 | 3;
+ i32 = i32 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ HEAP32[(___errno_location() | 0) >> 2] = 12;
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+}
+function _free(i7) {
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0;
+ i1 = STACKTOP;
+ if ((i7 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i15 = i7 + -8 | 0;
+ i16 = HEAP32[600 >> 2] | 0;
+ if (i15 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i13 = HEAP32[i7 + -4 >> 2] | 0;
+ i12 = i13 & 3;
+ if ((i12 | 0) == 1) {
+ _abort();
+ }
+ i8 = i13 & -8;
+ i6 = i7 + (i8 + -8) | 0;
+ do {
+ if ((i13 & 1 | 0) == 0) {
+ i19 = HEAP32[i15 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i15 = -8 - i19 | 0;
+ i13 = i7 + i15 | 0;
+ i12 = i19 + i8 | 0;
+ if (i13 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ if ((i13 | 0) == (HEAP32[604 >> 2] | 0)) {
+ i2 = i7 + (i8 + -4) | 0;
+ if ((HEAP32[i2 >> 2] & 3 | 0) != 3) {
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ HEAP32[592 >> 2] = i12;
+ HEAP32[i2 >> 2] = HEAP32[i2 >> 2] & -2;
+ HEAP32[i7 + (i15 + 4) >> 2] = i12 | 1;
+ HEAP32[i6 >> 2] = i12;
+ STACKTOP = i1;
+ return;
+ }
+ i18 = i19 >>> 3;
+ if (i19 >>> 0 < 256) {
+ i2 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
+ i11 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
+ i14 = 624 + (i18 << 1 << 2) | 0;
+ if ((i2 | 0) != (i14 | 0)) {
+ if (i2 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i2 + 12 >> 2] | 0) != (i13 | 0)) {
+ _abort();
+ }
+ }
+ if ((i11 | 0) == (i2 | 0)) {
+ HEAP32[146] = HEAP32[146] & ~(1 << i18);
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ if ((i11 | 0) != (i14 | 0)) {
+ if (i11 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i14 = i11 + 8 | 0;
+ if ((HEAP32[i14 >> 2] | 0) == (i13 | 0)) {
+ i17 = i14;
+ } else {
+ _abort();
+ }
+ } else {
+ i17 = i11 + 8 | 0;
+ }
+ HEAP32[i2 + 12 >> 2] = i11;
+ HEAP32[i17 >> 2] = i2;
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ i17 = HEAP32[i7 + (i15 + 24) >> 2] | 0;
+ i18 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
+ do {
+ if ((i18 | 0) == (i13 | 0)) {
+ i19 = i7 + (i15 + 20) | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ i19 = i7 + (i15 + 16) | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ i14 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i21 = i18 + 20 | 0;
+ i20 = HEAP32[i21 >> 2] | 0;
+ if ((i20 | 0) != 0) {
+ i18 = i20;
+ i19 = i21;
+ continue;
+ }
+ i20 = i18 + 16 | 0;
+ i21 = HEAP32[i20 >> 2] | 0;
+ if ((i21 | 0) == 0) {
+ break;
+ } else {
+ i18 = i21;
+ i19 = i20;
+ }
+ }
+ if (i19 >>> 0 < i16 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i19 >> 2] = 0;
+ i14 = i18;
+ break;
+ }
+ } else {
+ i19 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
+ if (i19 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i16 = i19 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != (i13 | 0)) {
+ _abort();
+ }
+ i20 = i18 + 8 | 0;
+ if ((HEAP32[i20 >> 2] | 0) == (i13 | 0)) {
+ HEAP32[i16 >> 2] = i18;
+ HEAP32[i20 >> 2] = i19;
+ i14 = i18;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i17 | 0) != 0) {
+ i18 = HEAP32[i7 + (i15 + 28) >> 2] | 0;
+ i16 = 888 + (i18 << 2) | 0;
+ if ((i13 | 0) == (HEAP32[i16 >> 2] | 0)) {
+ HEAP32[i16 >> 2] = i14;
+ if ((i14 | 0) == 0) {
+ HEAP32[588 >> 2] = HEAP32[588 >> 2] & ~(1 << i18);
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ } else {
+ if (i17 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i17 + 16 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i13 | 0)) {
+ HEAP32[i16 >> 2] = i14;
+ } else {
+ HEAP32[i17 + 20 >> 2] = i14;
+ }
+ if ((i14 | 0) == 0) {
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ }
+ if (i14 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i14 + 24 >> 2] = i17;
+ i16 = HEAP32[i7 + (i15 + 16) >> 2] | 0;
+ do {
+ if ((i16 | 0) != 0) {
+ if (i16 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i14 + 16 >> 2] = i16;
+ HEAP32[i16 + 24 >> 2] = i14;
+ break;
+ }
+ }
+ } while (0);
+ i15 = HEAP32[i7 + (i15 + 20) >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ if (i15 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i14 + 20 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i14;
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ } else {
+ i2 = i13;
+ i11 = i12;
+ }
+ } else {
+ i2 = i13;
+ i11 = i12;
+ }
+ } else {
+ i2 = i15;
+ i11 = i8;
+ }
+ } while (0);
+ if (!(i2 >>> 0 < i6 >>> 0)) {
+ _abort();
+ }
+ i12 = i7 + (i8 + -4) | 0;
+ i13 = HEAP32[i12 >> 2] | 0;
+ if ((i13 & 1 | 0) == 0) {
+ _abort();
+ }
+ if ((i13 & 2 | 0) == 0) {
+ if ((i6 | 0) == (HEAP32[608 >> 2] | 0)) {
+ i21 = (HEAP32[596 >> 2] | 0) + i11 | 0;
+ HEAP32[596 >> 2] = i21;
+ HEAP32[608 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i21 | 1;
+ if ((i2 | 0) != (HEAP32[604 >> 2] | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[604 >> 2] = 0;
+ HEAP32[592 >> 2] = 0;
+ STACKTOP = i1;
+ return;
+ }
+ if ((i6 | 0) == (HEAP32[604 >> 2] | 0)) {
+ i21 = (HEAP32[592 >> 2] | 0) + i11 | 0;
+ HEAP32[592 >> 2] = i21;
+ HEAP32[604 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i21 | 1;
+ HEAP32[i2 + i21 >> 2] = i21;
+ STACKTOP = i1;
+ return;
+ }
+ i11 = (i13 & -8) + i11 | 0;
+ i12 = i13 >>> 3;
+ do {
+ if (!(i13 >>> 0 < 256)) {
+ i10 = HEAP32[i7 + (i8 + 16) >> 2] | 0;
+ i15 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
+ do {
+ if ((i15 | 0) == (i6 | 0)) {
+ i13 = i7 + (i8 + 12) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i13 = i7 + (i8 + 8) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i9 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i14 = i12 + 20 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ i12 = i15;
+ i13 = i14;
+ continue;
+ }
+ i14 = i12 + 16 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) == 0) {
+ break;
+ } else {
+ i12 = i15;
+ i13 = i14;
+ }
+ }
+ if (i13 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i13 >> 2] = 0;
+ i9 = i12;
+ break;
+ }
+ } else {
+ i13 = HEAP32[i7 + i8 >> 2] | 0;
+ if (i13 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i14 = i13 + 12 | 0;
+ if ((HEAP32[i14 >> 2] | 0) != (i6 | 0)) {
+ _abort();
+ }
+ i12 = i15 + 8 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i14 >> 2] = i15;
+ HEAP32[i12 >> 2] = i13;
+ i9 = i15;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i10 | 0) != 0) {
+ i12 = HEAP32[i7 + (i8 + 20) >> 2] | 0;
+ i13 = 888 + (i12 << 2) | 0;
+ if ((i6 | 0) == (HEAP32[i13 >> 2] | 0)) {
+ HEAP32[i13 >> 2] = i9;
+ if ((i9 | 0) == 0) {
+ HEAP32[588 >> 2] = HEAP32[588 >> 2] & ~(1 << i12);
+ break;
+ }
+ } else {
+ if (i10 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i12 = i10 + 16 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i12 >> 2] = i9;
+ } else {
+ HEAP32[i10 + 20 >> 2] = i9;
+ }
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ }
+ if (i9 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i9 + 24 >> 2] = i10;
+ i6 = HEAP32[i7 + (i8 + 8) >> 2] | 0;
+ do {
+ if ((i6 | 0) != 0) {
+ if (i6 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 16 >> 2] = i6;
+ HEAP32[i6 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ } while (0);
+ i6 = HEAP32[i7 + (i8 + 12) >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ if (i6 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 20 >> 2] = i6;
+ HEAP32[i6 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ }
+ } else {
+ i9 = HEAP32[i7 + i8 >> 2] | 0;
+ i7 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
+ i8 = 624 + (i12 << 1 << 2) | 0;
+ if ((i9 | 0) != (i8 | 0)) {
+ if (i9 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i9 + 12 >> 2] | 0) != (i6 | 0)) {
+ _abort();
+ }
+ }
+ if ((i7 | 0) == (i9 | 0)) {
+ HEAP32[146] = HEAP32[146] & ~(1 << i12);
+ break;
+ }
+ if ((i7 | 0) != (i8 | 0)) {
+ if (i7 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i7 + 8 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i6 | 0)) {
+ i10 = i8;
+ } else {
+ _abort();
+ }
+ } else {
+ i10 = i7 + 8 | 0;
+ }
+ HEAP32[i9 + 12 >> 2] = i7;
+ HEAP32[i10 >> 2] = i9;
+ }
+ } while (0);
+ HEAP32[i2 + 4 >> 2] = i11 | 1;
+ HEAP32[i2 + i11 >> 2] = i11;
+ if ((i2 | 0) == (HEAP32[604 >> 2] | 0)) {
+ HEAP32[592 >> 2] = i11;
+ STACKTOP = i1;
+ return;
+ }
+ } else {
+ HEAP32[i12 >> 2] = i13 & -2;
+ HEAP32[i2 + 4 >> 2] = i11 | 1;
+ HEAP32[i2 + i11 >> 2] = i11;
+ }
+ i6 = i11 >>> 3;
+ if (i11 >>> 0 < 256) {
+ i7 = i6 << 1;
+ i3 = 624 + (i7 << 2) | 0;
+ i8 = HEAP32[146] | 0;
+ i6 = 1 << i6;
+ if ((i8 & i6 | 0) != 0) {
+ i6 = 624 + (i7 + 2 << 2) | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ if (i7 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i4 = i6;
+ i5 = i7;
+ }
+ } else {
+ HEAP32[146] = i8 | i6;
+ i4 = 624 + (i7 + 2 << 2) | 0;
+ i5 = i3;
+ }
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i5 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i5;
+ HEAP32[i2 + 12 >> 2] = i3;
+ STACKTOP = i1;
+ return;
+ }
+ i4 = i11 >>> 8;
+ if ((i4 | 0) != 0) {
+ if (i11 >>> 0 > 16777215) {
+ i4 = 31;
+ } else {
+ i20 = (i4 + 1048320 | 0) >>> 16 & 8;
+ i21 = i4 << i20;
+ i19 = (i21 + 520192 | 0) >>> 16 & 4;
+ i21 = i21 << i19;
+ i4 = (i21 + 245760 | 0) >>> 16 & 2;
+ i4 = 14 - (i19 | i20 | i4) + (i21 << i4 >>> 15) | 0;
+ i4 = i11 >>> (i4 + 7 | 0) & 1 | i4 << 1;
+ }
+ } else {
+ i4 = 0;
+ }
+ i5 = 888 + (i4 << 2) | 0;
+ HEAP32[i2 + 28 >> 2] = i4;
+ HEAP32[i2 + 20 >> 2] = 0;
+ HEAP32[i2 + 16 >> 2] = 0;
+ i7 = HEAP32[588 >> 2] | 0;
+ i6 = 1 << i4;
+ L199 : do {
+ if ((i7 & i6 | 0) != 0) {
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((i4 | 0) == 31) {
+ i4 = 0;
+ } else {
+ i4 = 25 - (i4 >>> 1) | 0;
+ }
+ L204 : do {
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) != (i11 | 0)) {
+ i4 = i11 << i4;
+ i7 = i5;
+ while (1) {
+ i6 = i7 + (i4 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i11 | 0)) {
+ i3 = i5;
+ break L204;
+ } else {
+ i4 = i4 << 1;
+ i7 = i5;
+ }
+ }
+ if (i6 >>> 0 < (HEAP32[600 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i7;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ break L199;
+ }
+ } else {
+ i3 = i5;
+ }
+ } while (0);
+ i5 = i3 + 8 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i6 = HEAP32[600 >> 2] | 0;
+ if (i3 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ if (i4 >>> 0 < i6 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i4 + 12 >> 2] = i2;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i4;
+ HEAP32[i2 + 12 >> 2] = i3;
+ HEAP32[i2 + 24 >> 2] = 0;
+ break;
+ }
+ } else {
+ HEAP32[588 >> 2] = i7 | i6;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i5;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ }
+ } while (0);
+ i21 = (HEAP32[616 >> 2] | 0) + -1 | 0;
+ HEAP32[616 >> 2] = i21;
+ if ((i21 | 0) == 0) {
+ i2 = 1040 | 0;
+ } else {
+ STACKTOP = i1;
+ return;
+ }
+ while (1) {
+ i2 = HEAP32[i2 >> 2] | 0;
+ if ((i2 | 0) == 0) {
+ break;
+ } else {
+ i2 = i2 + 8 | 0;
+ }
+ }
+ HEAP32[616 >> 2] = -1;
+ STACKTOP = i1;
+ return;
+}
+function _main(i7, i8) {
+ i7 = i7 | 0;
+ i8 = i8 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, d9 = 0.0, d10 = 0.0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 4272 | 0;
+ i3 = i2;
+ i5 = i2 + 4248 | 0;
+ i4 = i2 + 2128 | 0;
+ i1 = i2 + 8 | 0;
+ L1 : do {
+ if ((i7 | 0) > 1) {
+ i7 = HEAP8[HEAP32[i8 + 4 >> 2] | 0] | 0;
+ switch (i7 | 0) {
+ case 50:
+ {
+ i3 = 95e5;
+ break L1;
+ }
+ case 51:
+ {
+ i6 = 4;
+ break L1;
+ }
+ case 52:
+ {
+ i3 = 95e6;
+ break L1;
+ }
+ case 53:
+ {
+ i3 = 19e7;
+ break L1;
+ }
+ case 49:
+ {
+ i3 = 95e4;
+ break L1;
+ }
+ case 48:
+ {
+ i8 = 0;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ default:
+ {
+ HEAP32[i3 >> 2] = i7 + -48;
+ _printf(280, i3 | 0) | 0;
+ i8 = -1;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ }
+ } else {
+ i6 = 4;
+ }
+ } while (0);
+ if ((i6 | 0) == 4) {
+ i3 = 19e6;
+ }
+ HEAP32[i5 + 8 >> 2] = 0;
+ HEAP32[i5 + 4 >> 2] = 287;
+ i8 = __Znaj(347) | 0;
+ HEAP32[i5 >> 2] = i8;
+ _memcpy(i8 | 0, 296, 287) | 0;
+ i8 = i8 + 287 | 0;
+ i7 = 296 | 0;
+ i6 = i8 + 60 | 0;
+ do {
+ HEAP8[i8] = HEAP8[i7] | 0;
+ i8 = i8 + 1 | 0;
+ i7 = i7 + 1 | 0;
+ } while ((i8 | 0) < (i6 | 0));
+ i7 = i3 << 1;
+ while (1) {
+ i6 = i7 >>> 0 < 60 ? i7 : 60;
+ __ZN14RotatingString5writeEj(i5, i6);
+ if ((i7 | 0) == (i6 | 0)) {
+ break;
+ } else {
+ i7 = i7 - i6 | 0;
+ }
+ }
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ __ZdaPv(i5);
+ }
+ if ((HEAP32[6] | 0) == 0) {
+ i6 = 24;
+ i5 = 0;
+ } else {
+ i5 = 24;
+ d9 = 0.0;
+ while (1) {
+ i6 = i5 + 4 | 0;
+ d9 = d9 + +HEAPF32[i6 >> 2];
+ d10 = d9 < 1.0 ? d9 : 1.0;
+ HEAPF32[i6 >> 2] = d10;
+ HEAP32[i5 + 8 >> 2] = ~~(d10 * 512.0) >>> 0;
+ i5 = i5 + 12 | 0;
+ if ((HEAP32[i5 >> 2] | 0) == 0) {
+ i6 = 24;
+ i5 = 0;
+ break;
+ }
+ }
+ }
+ do {
+ while (1) {
+ i8 = HEAP32[i6 + 8 >> 2] | 0;
+ if (i5 >>> 0 > i8 >>> 0 & (i8 | 0) != 0) {
+ i6 = i6 + 12 | 0;
+ } else {
+ break;
+ }
+ }
+ HEAP32[i4 + (i5 << 2) >> 2] = i6;
+ i5 = i5 + 1 | 0;
+ } while ((i5 | 0) != 513);
+ HEAP32[i4 + 2116 >> 2] = 0;
+ __Z9makeFastaI10RandomizedEvPKcS2_jRT_(0, 0, i3 * 3 | 0, i4);
+ if ((HEAP32[54] | 0) == 0) {
+ i5 = 216;
+ i4 = 0;
+ } else {
+ i5 = 216;
+ d9 = 0.0;
+ while (1) {
+ i4 = i5 + 4 | 0;
+ d9 = d9 + +HEAPF32[i4 >> 2];
+ d10 = d9 < 1.0 ? d9 : 1.0;
+ HEAPF32[i4 >> 2] = d10;
+ HEAP32[i5 + 8 >> 2] = ~~(d10 * 512.0) >>> 0;
+ i5 = i5 + 12 | 0;
+ if ((HEAP32[i5 >> 2] | 0) == 0) {
+ i5 = 216;
+ i4 = 0;
+ break;
+ }
+ }
+ }
+ do {
+ while (1) {
+ i8 = HEAP32[i5 + 8 >> 2] | 0;
+ if (i4 >>> 0 > i8 >>> 0 & (i8 | 0) != 0) {
+ i5 = i5 + 12 | 0;
+ } else {
+ break;
+ }
+ }
+ HEAP32[i1 + (i4 << 2) >> 2] = i5;
+ i4 = i4 + 1 | 0;
+ } while ((i4 | 0) != 513);
+ HEAP32[i1 + 2116 >> 2] = 0;
+ __Z9makeFastaI10RandomizedEvPKcS2_jRT_(0, 0, i3 * 5 | 0, i1);
+ i8 = 0;
+ STACKTOP = i2;
+ return i8 | 0;
+}
+function __Z9makeFastaI10RandomizedEvPKcS2_jRT_(i3, i2, i6, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ var i4 = 0, i5 = 0, i7 = 0, d8 = 0.0, i9 = 0;
+ i2 = STACKTOP;
+ if ((i6 | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i4 = i1 + 2116 | 0;
+ i3 = i1 + 2052 | 0;
+ while (1) {
+ i5 = i6 >>> 0 < 60 ? i6 : 60;
+ if ((i5 | 0) != 0) {
+ i7 = 0;
+ do {
+ i9 = ((((HEAP32[4] | 0) * 3877 | 0) + 29573 | 0) >>> 0) % 139968 | 0;
+ HEAP32[4] = i9;
+ d8 = +(i9 >>> 0) / 139968.0;
+ i9 = HEAP32[i1 + (~~(d8 * 512.0) >>> 0 << 2) >> 2] | 0;
+ while (1) {
+ if (+HEAPF32[i9 + 4 >> 2] < d8) {
+ i9 = i9 + 12 | 0;
+ } else {
+ break;
+ }
+ }
+ HEAP8[i1 + i7 + 2052 | 0] = HEAP32[i9 >> 2];
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) != (i5 | 0));
+ }
+ HEAP8[i1 + i5 + 2052 | 0] = 10;
+ i9 = i5 + 1 | 0;
+ HEAP8[i1 + i9 + 2052 | 0] = 0;
+ HEAP32[i4 >> 2] = i9;
+ i9 = _strlen(i3 | 0) | 0;
+ i7 = HEAP32[2] | 0;
+ if ((i9 | 0) > (i7 | 0)) {
+ if ((i7 | 0) > 0) {
+ HEAP8[i1 + i7 + 2052 | 0] = 0;
+ _puts(i3 | 0) | 0;
+ HEAP8[i1 + (HEAP32[2] | 0) + 2052 | 0] = 122;
+ HEAP32[2] = 0;
+ }
+ } else {
+ _puts(i3 | 0) | 0;
+ HEAP32[2] = (HEAP32[2] | 0) - i9;
+ }
+ if ((i6 | 0) == (i5 | 0)) {
+ break;
+ } else {
+ i6 = i6 - i5 | 0;
+ }
+ }
+ STACKTOP = i2;
+ return;
+}
+function __ZN14RotatingString5writeEj(i3, i4) {
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i1 = STACKTOP;
+ i5 = __Znaj(i4 + 2 | 0) | 0;
+ i2 = i3 + 8 | 0;
+ _memcpy(i5 | 0, (HEAP32[i3 >> 2] | 0) + (HEAP32[i2 >> 2] | 0) | 0, i4 | 0) | 0;
+ HEAP8[i5 + i4 | 0] = 0;
+ i7 = _strlen(i5 | 0) | 0;
+ i6 = HEAP32[2] | 0;
+ if ((i7 | 0) > (i6 | 0)) {
+ if ((i6 | 0) > 0) {
+ HEAP8[i5 + i6 | 0] = 0;
+ _puts(i5 | 0) | 0;
+ HEAP32[2] = 0;
+ i6 = 6;
+ } else {
+ i6 = 5;
+ }
+ } else {
+ _puts(i5 | 0) | 0;
+ HEAP32[2] = (HEAP32[2] | 0) - i7;
+ i6 = 5;
+ }
+ if ((i6 | 0) == 5 ? (i5 | 0) != 0 : 0) {
+ i6 = 6;
+ }
+ if ((i6 | 0) == 6) {
+ __ZdlPv(i5);
+ }
+ i4 = (HEAP32[i2 >> 2] | 0) + i4 | 0;
+ HEAP32[i2 >> 2] = i4;
+ i3 = HEAP32[i3 + 4 >> 2] | 0;
+ if (!(i4 >>> 0 > i3 >>> 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[i2 >> 2] = i4 - i3;
+ STACKTOP = i1;
+ return;
+}
+function _memcpy(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ if ((i1 | 0) >= 4096) return _emscripten_memcpy_big(i3 | 0, i2 | 0, i1 | 0) | 0;
+ i4 = i3 | 0;
+ if ((i3 & 3) == (i2 & 3)) {
+ while (i3 & 3) {
+ if ((i1 | 0) == 0) return i4 | 0;
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ while ((i1 | 0) >= 4) {
+ HEAP32[i3 >> 2] = HEAP32[i2 >> 2];
+ i3 = i3 + 4 | 0;
+ i2 = i2 + 4 | 0;
+ i1 = i1 - 4 | 0;
+ }
+ }
+ while ((i1 | 0) > 0) {
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ return i4 | 0;
+}
+function _memset(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = i1 + i3 | 0;
+ if ((i3 | 0) >= 20) {
+ i4 = i4 & 255;
+ i7 = i1 & 3;
+ i6 = i4 | i4 << 8 | i4 << 16 | i4 << 24;
+ i5 = i2 & ~3;
+ if (i7) {
+ i7 = i1 + 4 - i7 | 0;
+ while ((i1 | 0) < (i7 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ }
+ while ((i1 | 0) < (i5 | 0)) {
+ HEAP32[i1 >> 2] = i6;
+ i1 = i1 + 4 | 0;
+ }
+ }
+ while ((i1 | 0) < (i2 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ return i1 - i3 | 0;
+}
+function __Znwj(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0;
+ i1 = STACKTOP;
+ i2 = (i2 | 0) == 0 ? 1 : i2;
+ while (1) {
+ i3 = _malloc(i2) | 0;
+ if ((i3 | 0) != 0) {
+ i2 = 6;
+ break;
+ }
+ i3 = HEAP32[270] | 0;
+ HEAP32[270] = i3 + 0;
+ if ((i3 | 0) == 0) {
+ i2 = 5;
+ break;
+ }
+ FUNCTION_TABLE_v[i3 & 0]();
+ }
+ if ((i2 | 0) == 5) {
+ i3 = ___cxa_allocate_exception(4) | 0;
+ HEAP32[i3 >> 2] = 1096;
+ ___cxa_throw(i3 | 0, 1144, 1);
+ } else if ((i2 | 0) == 6) {
+ STACKTOP = i1;
+ return i3 | 0;
+ }
+ return 0;
+}
+function copyTempDouble(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+ HEAP8[tempDoublePtr + 4 | 0] = HEAP8[i1 + 4 | 0];
+ HEAP8[tempDoublePtr + 5 | 0] = HEAP8[i1 + 5 | 0];
+ HEAP8[tempDoublePtr + 6 | 0] = HEAP8[i1 + 6 | 0];
+ HEAP8[tempDoublePtr + 7 | 0] = HEAP8[i1 + 7 | 0];
+}
+function copyTempFloat(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+}
+function __ZNSt9bad_allocD0Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZNSt9exceptionD2Ev(i1 | 0);
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function stackAlloc(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + i1 | 0;
+ STACKTOP = STACKTOP + 7 & -8;
+ return i2 | 0;
+}
+function __ZNSt9bad_allocD2Ev(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZNSt9exceptionD2Ev(i1 | 0);
+ STACKTOP = i2;
+ return;
+}
+function __ZdlPv(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((i1 | 0) != 0) {
+ _free(i1);
+ }
+ STACKTOP = i2;
+ return;
+}
+function _strlen(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = i1;
+ while (HEAP8[i2] | 0) {
+ i2 = i2 + 1 | 0;
+ }
+ return i2 - i1 | 0;
+}
+function setThrew(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ if ((__THREW__ | 0) == 0) {
+ __THREW__ = i1;
+ threwValue = i2;
+ }
+}
+function __Znaj(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i1 = __Znwj(i1) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function runPostSets() {
+ HEAP32[286] = __ZTVN10__cxxabiv120__si_class_type_infoE;
+ HEAP32[288] = __ZTISt9exception;
+}
+function dynCall_ii(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ return FUNCTION_TABLE_ii[i2 & 1](i1 | 0) | 0;
+}
+function __ZdaPv(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ __ZdlPv(i1);
+ STACKTOP = i2;
+ return;
+}
+function dynCall_vi(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ FUNCTION_TABLE_vi[i2 & 3](i1 | 0);
+}
+function dynCall_v(i1) {
+ i1 = i1 | 0;
+ FUNCTION_TABLE_v[i1 & 0]();
+}
+function __ZNKSt9bad_alloc4whatEv(i1) {
+ i1 = i1 | 0;
+ return 1112;
+}
+function stackRestore(i1) {
+ i1 = i1 | 0;
+ STACKTOP = i1;
+}
+function setTempRet9(i1) {
+ i1 = i1 | 0;
+ tempRet9 = i1;
+}
+function setTempRet8(i1) {
+ i1 = i1 | 0;
+ tempRet8 = i1;
+}
+function setTempRet7(i1) {
+ i1 = i1 | 0;
+ tempRet7 = i1;
+}
+function setTempRet6(i1) {
+ i1 = i1 | 0;
+ tempRet6 = i1;
+}
+function setTempRet5(i1) {
+ i1 = i1 | 0;
+ tempRet5 = i1;
+}
+function setTempRet4(i1) {
+ i1 = i1 | 0;
+ tempRet4 = i1;
+}
+function setTempRet3(i1) {
+ i1 = i1 | 0;
+ tempRet3 = i1;
+}
+function setTempRet2(i1) {
+ i1 = i1 | 0;
+ tempRet2 = i1;
+}
+function setTempRet1(i1) {
+ i1 = i1 | 0;
+ tempRet1 = i1;
+}
+function setTempRet0(i1) {
+ i1 = i1 | 0;
+ tempRet0 = i1;
+}
+function b0(i1) {
+ i1 = i1 | 0;
+ abort(0);
+ return 0;
+}
+function stackSave() {
+ return STACKTOP | 0;
+}
+function b1(i1) {
+ i1 = i1 | 0;
+ abort(1);
+}
+function b2() {
+ abort(2);
+}
+
+// EMSCRIPTEN_END_FUNCS
+ var FUNCTION_TABLE_ii = [b0,__ZNKSt9bad_alloc4whatEv];
+ var FUNCTION_TABLE_vi = [b1,__ZNSt9bad_allocD2Ev,__ZNSt9bad_allocD0Ev,b1];
+ var FUNCTION_TABLE_v = [b2];
+
+ return { _strlen: _strlen, _free: _free, _main: _main, _memset: _memset, _malloc: _malloc, _memcpy: _memcpy, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, setThrew: setThrew, setTempRet0: setTempRet0, setTempRet1: setTempRet1, setTempRet2: setTempRet2, setTempRet3: setTempRet3, setTempRet4: setTempRet4, setTempRet5: setTempRet5, setTempRet6: setTempRet6, setTempRet7: setTempRet7, setTempRet8: setTempRet8, setTempRet9: setTempRet9, dynCall_ii: dynCall_ii, dynCall_vi: dynCall_vi, dynCall_v: dynCall_v };
+})
+// EMSCRIPTEN_END_ASM
+({ "Math": Math, "Int8Array": Int8Array, "Int16Array": Int16Array, "Int32Array": Int32Array, "Uint8Array": Uint8Array, "Uint16Array": Uint16Array, "Uint32Array": Uint32Array, "Float32Array": Float32Array, "Float64Array": Float64Array }, { "abort": abort, "assert": assert, "asmPrintInt": asmPrintInt, "asmPrintFloat": asmPrintFloat, "min": Math_min, "invoke_ii": invoke_ii, "invoke_vi": invoke_vi, "invoke_v": invoke_v, "_send": _send, "___setErrNo": ___setErrNo, "___cxa_is_number_type": ___cxa_is_number_type, "___cxa_allocate_exception": ___cxa_allocate_exception, "___cxa_find_matching_catch": ___cxa_find_matching_catch, "_fflush": _fflush, "_time": _time, "_pwrite": _pwrite, "__reallyNegative": __reallyNegative, "_sbrk": _sbrk, "_emscripten_memcpy_big": _emscripten_memcpy_big, "_fileno": _fileno, "___resumeException": ___resumeException, "__ZSt18uncaught_exceptionv": __ZSt18uncaught_exceptionv, "_sysconf": _sysconf, "_puts": _puts, "_mkport": _mkport, "_write": _write, "___errno_location": ___errno_location, "__ZNSt9exceptionD2Ev": __ZNSt9exceptionD2Ev, "_fputc": _fputc, "___cxa_throw": ___cxa_throw, "_abort": _abort, "_fwrite": _fwrite, "___cxa_does_inherit": ___cxa_does_inherit, "_fprintf": _fprintf, "__formatString": __formatString, "_fputs": _fputs, "_printf": _printf, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX, "tempDoublePtr": tempDoublePtr, "ABORT": ABORT, "NaN": NaN, "Infinity": Infinity, "__ZTISt9exception": __ZTISt9exception, "__ZTVN10__cxxabiv120__si_class_type_infoE": __ZTVN10__cxxabiv120__si_class_type_infoE }, buffer);
+var _strlen = Module["_strlen"] = asm["_strlen"];
+var _free = Module["_free"] = asm["_free"];
+var _main = Module["_main"] = asm["_main"];
+var _memset = Module["_memset"] = asm["_memset"];
+var _malloc = Module["_malloc"] = asm["_malloc"];
+var _memcpy = Module["_memcpy"] = asm["_memcpy"];
+var runPostSets = Module["runPostSets"] = asm["runPostSets"];
+var dynCall_ii = Module["dynCall_ii"] = asm["dynCall_ii"];
+var dynCall_vi = Module["dynCall_vi"] = asm["dynCall_vi"];
+var dynCall_v = Module["dynCall_v"] = asm["dynCall_v"];
+
+Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
+Runtime.stackSave = function() { return asm['stackSave']() };
+Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
+
+
+// Warning: printing of i64 values may be slightly rounded! No deep i64 math used, so precise i64 code not included
+var i64Math = null;
+
+// === Auto-generated postamble setup entry stuff ===
+
+if (memoryInitializer) {
+ if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
+ var data = Module['readBinary'](memoryInitializer);
+ HEAPU8.set(data, STATIC_BASE);
+ } else {
+ addRunDependency('memory initializer');
+ Browser.asyncLoad(memoryInitializer, function(data) {
+ HEAPU8.set(data, STATIC_BASE);
+ removeRunDependency('memory initializer');
+ }, function(data) {
+ throw 'could not load memory initializer ' + memoryInitializer;
+ });
+ }
+}
+
+function ExitStatus(status) {
+ this.name = "ExitStatus";
+ this.message = "Program terminated with exit(" + status + ")";
+ this.status = status;
+};
+ExitStatus.prototype = new Error();
+ExitStatus.prototype.constructor = ExitStatus;
+
+var initialStackTop;
+var preloadStartTime = null;
+var calledMain = false;
+
+dependenciesFulfilled = function runCaller() {
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
+ if (!Module['calledRun'] && shouldRunNow) run([].concat(Module["arguments"]));
+ if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
+}
+
+Module['callMain'] = Module.callMain = function callMain(args) {
+ assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');
+ assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
+
+ args = args || [];
+
+ ensureInitRuntime();
+
+ var argc = args.length+1;
+ function pad() {
+ for (var i = 0; i < 4-1; i++) {
+ argv.push(0);
+ }
+ }
+ var argv = [allocate(intArrayFromString("/bin/this.program"), 'i8', ALLOC_NORMAL) ];
+ pad();
+ for (var i = 0; i < argc-1; i = i + 1) {
+ argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL));
+ pad();
+ }
+ argv.push(0);
+ argv = allocate(argv, 'i32', ALLOC_NORMAL);
+
+ initialStackTop = STACKTOP;
+
+ try {
+
+ var ret = Module['_main'](argc, argv, 0);
+
+
+ // if we're not running an evented main loop, it's time to exit
+ if (!Module['noExitRuntime']) {
+ exit(ret);
+ }
+ }
+ catch(e) {
+ if (e instanceof ExitStatus) {
+ // exit() throws this once it's done to make sure execution
+ // has been stopped completely
+ return;
+ } else if (e == 'SimulateInfiniteLoop') {
+ // running an evented main loop, don't immediately exit
+ Module['noExitRuntime'] = true;
+ return;
+ } else {
+ if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
+ throw e;
+ }
+ } finally {
+ calledMain = true;
+ }
+}
+
+
+
+
+function run(args) {
+ args = args || Module['arguments'];
+
+ if (preloadStartTime === null) preloadStartTime = Date.now();
+
+ if (runDependencies > 0) {
+ Module.printErr('run() called, but dependencies remain, so not running');
+ return;
+ }
+
+ preRun();
+
+ if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
+ if (Module['calledRun']) return; // run may have just been called through dependencies being fulfilled just in this very frame
+
+ function doRun() {
+ if (Module['calledRun']) return; // run may have just been called while the async setStatus time below was happening
+ Module['calledRun'] = true;
+
+ ensureInitRuntime();
+
+ preMain();
+
+ if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) {
+ Module.printErr('pre-main prep time: ' + (Date.now() - preloadStartTime) + ' ms');
+ }
+
+ if (Module['_main'] && shouldRunNow) {
+ Module['callMain'](args);
+ }
+
+ postRun();
+ }
+
+ if (Module['setStatus']) {
+ Module['setStatus']('Running...');
+ setTimeout(function() {
+ setTimeout(function() {
+ Module['setStatus']('');
+ }, 1);
+ if (!ABORT) doRun();
+ }, 1);
+ } else {
+ doRun();
+ }
+}
+Module['run'] = Module.run = run;
+
+function exit(status) {
+ ABORT = true;
+ EXITSTATUS = status;
+ STACKTOP = initialStackTop;
+
+ // exit the runtime
+ exitRuntime();
+
+ // TODO We should handle this differently based on environment.
+ // In the browser, the best we can do is throw an exception
+ // to halt execution, but in node we could process.exit and
+ // I'd imagine SM shell would have something equivalent.
+ // This would let us set a proper exit status (which
+ // would be great for checking test exit statuses).
+ // https://github.com/kripken/emscripten/issues/1371
+
+ // throw an exception to halt the current execution
+ throw new ExitStatus(status);
+}
+Module['exit'] = Module.exit = exit;
+
+function abort(text) {
+ if (text) {
+ Module.print(text);
+ Module.printErr(text);
+ }
+
+ ABORT = true;
+ EXITSTATUS = 1;
+
+ var extra = '\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.';
+
+ throw 'abort() at ' + stackTrace() + extra;
+}
+Module['abort'] = Module.abort = abort;
+
+// {{PRE_RUN_ADDITIONS}}
+
+if (Module['preInit']) {
+ if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
+ while (Module['preInit'].length > 0) {
+ Module['preInit'].pop()();
+ }
+}
+
+// shouldRunNow refers to calling main(), not run().
+var shouldRunNow = true;
+if (Module['noInitialRun']) {
+ shouldRunNow = false;
+}
+
+
+run([].concat(Module["arguments"]));
diff --git a/test/mjsunit/asm/embenchen/lua_binarytrees.js b/test/mjsunit/asm/embenchen/lua_binarytrees.js
new file mode 100644
index 000000000..ca71bdc9a
--- /dev/null
+++ b/test/mjsunit/asm/embenchen/lua_binarytrees.js
@@ -0,0 +1,42714 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var EXPECTED_OUTPUT =
+ 'stretch tree of depth 10\t check: -1\n' +
+ '1448\t trees of depth 4\t check: -1448\n' +
+ '362\t trees of depth 6\t check: -362\n' +
+ '90\t trees of depth 8\t check: -90\n' +
+ 'long lived tree of depth 9\t check: -1\n';
+var Module = {
+ arguments: [1],
+ print: function(x) {Module.printBuffer += x + '\n';},
+ preRun: [function() {Module.printBuffer = ''}],
+ postRun: [function() {
+ assertEquals(EXPECTED_OUTPUT, Module.printBuffer);
+ }],
+};
+
+var Module;
+if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
+if (!Module.expectedDataFileDownloads) {
+ Module.expectedDataFileDownloads = 0;
+ Module.finishedDataFileDownloads = 0;
+}
+Module.expectedDataFileDownloads++;
+(function() {
+
+ function runWithFS() {
+
+function assert(check, msg) {
+ if (!check) throw msg + new Error().stack;
+}
+Module['FS_createDataFile']('/', 'binarytrees.lua', [45, 45, 32, 84, 104, 101, 32, 67, 111, 109, 112, 117, 116, 101, 114, 32, 76, 97, 110, 103, 117, 97, 103, 101, 32, 66, 101, 110, 99, 104, 109, 97, 114, 107, 115, 32, 71, 97, 109, 101, 10, 45, 45, 32, 104, 116, 116, 112, 58, 47, 47, 98, 101, 110, 99, 104, 109, 97, 114, 107, 115, 103, 97, 109, 101, 46, 97, 108, 105, 111, 116, 104, 46, 100, 101, 98, 105, 97, 110, 46, 111, 114, 103, 47, 10, 45, 45, 32, 99, 111, 110, 116, 114, 105, 98, 117, 116, 101, 100, 32, 98, 121, 32, 77, 105, 107, 101, 32, 80, 97, 108, 108, 10, 10, 108, 111, 99, 97, 108, 32, 102, 117, 110, 99, 116, 105, 111, 110, 32, 66, 111, 116, 116, 111, 109, 85, 112, 84, 114, 101, 101, 40, 105, 116, 101, 109, 44, 32, 100, 101, 112, 116, 104, 41, 10, 32, 32, 105, 102, 32, 100, 101, 112, 116, 104, 32, 62, 32, 48, 32, 116, 104, 101, 110, 10, 32, 32, 32, 32, 108, 111, 99, 97, 108, 32, 105, 32, 61, 32, 105, 116, 101, 109, 32, 43, 32, 105, 116, 101, 109, 10, 32, 32, 32, 32, 100, 101, 112, 116, 104, 32, 61, 32, 100, 101, 112, 116, 104, 32, 45, 32, 49, 10, 32, 32, 32, 32, 108, 111, 99, 97, 108, 32, 108, 101, 102, 116, 44, 32, 114, 105, 103, 104, 116, 32, 61, 32, 66, 111, 116, 116, 111, 109, 85, 112, 84, 114, 101, 101, 40, 105, 45, 49, 44, 32, 100, 101, 112, 116, 104, 41, 44, 32, 66, 111, 116, 116, 111, 109, 85, 112, 84, 114, 101, 101, 40, 105, 44, 32, 100, 101, 112, 116, 104, 41, 10, 32, 32, 32, 32, 114, 101, 116, 117, 114, 110, 32, 123, 32, 105, 116, 101, 109, 44, 32, 108, 101, 102, 116, 44, 32, 114, 105, 103, 104, 116, 32, 125, 10, 32, 32, 101, 108, 115, 101, 10, 32, 32, 32, 32, 114, 101, 116, 117, 114, 110, 32, 123, 32, 105, 116, 101, 109, 32, 125, 10, 32, 32, 101, 110, 100, 10, 101, 110, 100, 10, 10, 108, 111, 99, 97, 108, 32, 102, 117, 110, 99, 116, 105, 111, 110, 32, 73, 116, 101, 109, 67, 104, 101, 99, 107, 40, 116, 114, 101, 101, 41, 10, 32, 32, 105, 102, 32, 116, 114, 101, 101, 91, 50, 93, 32, 116, 104, 101, 110, 10, 32, 32, 32, 32, 114, 101, 116, 117, 114, 110, 32, 116, 114, 101, 101, 91, 49, 93, 32, 43, 32, 73, 116, 101, 109, 67, 104, 101, 99, 107, 40, 116, 114, 101, 101, 91, 50, 93, 41, 32, 45, 32, 73, 116, 101, 109, 67, 104, 101, 99, 107, 40, 116, 114, 101, 101, 91, 51, 93, 41, 10, 32, 32, 101, 108, 115, 101, 10, 32, 32, 32, 32, 114, 101, 116, 117, 114, 110, 32, 116, 114, 101, 101, 91, 49, 93, 10, 32, 32, 101, 110, 100, 10, 101, 110, 100, 10, 10, 108, 111, 99, 97, 108, 32, 78, 32, 61, 32, 116, 111, 110, 117, 109, 98, 101, 114, 40, 97, 114, 103, 32, 97, 110, 100, 32, 97, 114, 103, 91, 49, 93, 41, 32, 111, 114, 32, 52, 10, 10, 105, 102, 32, 78, 32, 61, 61, 32, 48, 32, 116, 104, 101, 110, 10, 32, 32, 78, 32, 61, 32, 48, 10, 101, 108, 115, 101, 105, 102, 32, 78, 32, 61, 61, 32, 49, 32, 116, 104, 101, 110, 10, 32, 32, 78, 32, 61, 32, 57, 46, 53, 10, 101, 108, 115, 101, 105, 102, 32, 78, 32, 61, 61, 32, 50, 32, 116, 104, 101, 110, 10, 32, 32, 78, 32, 61, 32, 49, 49, 46, 57, 57, 10, 101, 108, 115, 101, 105, 102, 32, 78, 32, 61, 61, 32, 51, 32, 116, 104, 101, 110, 10, 32, 32, 78, 32, 61, 32, 49, 50, 46, 56, 53, 10, 101, 108, 115, 101, 105, 102, 32, 78, 32, 61, 61, 32, 52, 32, 116, 104, 101, 110, 10, 32, 32, 78, 32, 61, 32, 49, 52, 46, 55, 50, 10, 101, 108, 115, 101, 105, 102, 32, 78, 32, 61, 61, 32, 53, 32, 116, 104, 101, 110, 10, 32, 32, 78, 32, 61, 32, 49, 53, 46, 56, 50, 10, 101, 110, 100, 10, 10, 108, 111, 99, 97, 108, 32, 109, 105, 110, 100, 101, 112, 116, 104, 32, 61, 32, 52, 10, 108, 111, 99, 97, 108, 32, 109, 97, 120, 100, 101, 112, 116, 104, 32, 61, 32, 109, 105, 110, 100, 101, 112, 116, 104, 32, 43, 32, 50, 10, 105, 102, 32, 109, 97, 120, 100, 101, 112, 116, 104, 32, 60, 32, 78, 32, 116, 104, 101, 110, 32, 109, 97, 120, 100, 101, 112, 116, 104, 32, 61, 32, 78, 32, 101, 110, 100, 10, 10, 100, 111, 10, 32, 32, 108, 111, 99, 97, 108, 32, 115, 116, 114, 101, 116, 99, 104, 100, 101, 112, 116, 104, 32, 61, 32, 109, 97, 120, 100, 101, 112, 116, 104, 32, 43, 32, 49, 10, 32, 32, 108, 111, 99, 97, 108, 32, 115, 116, 114, 101, 116, 99, 104, 116, 114, 101, 101, 32, 61, 32, 66, 111, 116, 116, 111, 109, 85, 112, 84, 114, 101, 101, 40, 48, 44, 32, 115, 116, 114, 101, 116, 99, 104, 100, 101, 112, 116, 104, 41, 10, 32, 32, 105, 111, 46, 119, 114, 105, 116, 101, 40, 115, 116, 114, 105, 110, 103, 46, 102, 111, 114, 109, 97, 116, 40, 34, 115, 116, 114, 101, 116, 99, 104, 32, 116, 114, 101, 101, 32, 111, 102, 32, 100, 101, 112, 116, 104, 32, 37, 100, 92, 116, 32, 99, 104, 101, 99, 107, 58, 32, 37, 100, 92, 110, 34, 44, 10, 32, 32, 32, 32, 115, 116, 114, 101, 116, 99, 104, 100, 101, 112, 116, 104, 44, 32, 73, 116, 101, 109, 67, 104, 101, 99, 107, 40, 115, 116, 114, 101, 116, 99, 104, 116, 114, 101, 101, 41, 41, 41, 10, 101, 110, 100, 10, 10, 108, 111, 99, 97, 108, 32, 108, 111, 110, 103, 108, 105, 118, 101, 100, 116, 114, 101, 101, 32, 61, 32, 66, 111, 116, 116, 111, 109, 85, 112, 84, 114, 101, 101, 40, 48, 44, 32, 109, 97, 120, 100, 101, 112, 116, 104, 41, 10, 10, 102, 111, 114, 32, 100, 101, 112, 116, 104, 61, 109, 105, 110, 100, 101, 112, 116, 104, 44, 109, 97, 120, 100, 101, 112, 116, 104, 44, 50, 32, 100, 111, 10, 32, 32, 108, 111, 99, 97, 108, 32, 105, 116, 101, 114, 97, 116, 105, 111, 110, 115, 32, 61, 32, 50, 32, 94, 32, 40, 109, 97, 120, 100, 101, 112, 116, 104, 32, 45, 32, 100, 101, 112, 116, 104, 32, 43, 32, 109, 105, 110, 100, 101, 112, 116, 104, 41, 10, 32, 32, 108, 111, 99, 97, 108, 32, 99, 104, 101, 99, 107, 32, 61, 32, 48, 10, 32, 32, 102, 111, 114, 32, 105, 61, 49, 44, 105, 116, 101, 114, 97, 116, 105, 111, 110, 115, 32, 100, 111, 10, 32, 32, 32, 32, 99, 104, 101, 99, 107, 32, 61, 32, 99, 104, 101, 99, 107, 32, 43, 32, 73, 116, 101, 109, 67, 104, 101, 99, 107, 40, 66, 111, 116, 116, 111, 109, 85, 112, 84, 114, 101, 101, 40, 49, 44, 32, 100, 101, 112, 116, 104, 41, 41, 32, 43, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 73, 116, 101, 109, 67, 104, 101, 99, 107, 40, 66, 111, 116, 116, 111, 109, 85, 112, 84, 114, 101, 101, 40, 45, 49, 44, 32, 100, 101, 112, 116, 104, 41, 41, 10, 32, 32, 101, 110, 100, 10, 32, 32, 105, 111, 46, 119, 114, 105, 116, 101, 40, 115, 116, 114, 105, 110, 103, 46, 102, 111, 114, 109, 97, 116, 40, 34, 37, 100, 92, 116, 32, 116, 114, 101, 101, 115, 32, 111, 102, 32, 100, 101, 112, 116, 104, 32, 37, 100, 92, 116, 32, 99, 104, 101, 99, 107, 58, 32, 37, 100, 92, 110, 34, 44, 10, 32, 32, 32, 32, 105, 116, 101, 114, 97, 116, 105, 111, 110, 115, 42, 50, 44, 32, 100, 101, 112, 116, 104, 44, 32, 99, 104, 101, 99, 107, 41, 41, 10, 101, 110, 100, 10, 10, 105, 111, 46, 119, 114, 105, 116, 101, 40, 115, 116, 114, 105, 110, 103, 46, 102, 111, 114, 109, 97, 116, 40, 34, 108, 111, 110, 103, 32, 108, 105, 118, 101, 100, 32, 116, 114, 101, 101, 32, 111, 102, 32, 100, 101, 112, 116, 104, 32, 37, 100, 92, 116, 32, 99, 104, 101, 99, 107, 58, 32, 37, 100, 92, 110, 34, 44, 10, 32, 32, 109, 97, 120, 100, 101, 112, 116, 104, 44, 32, 73, 116, 101, 109, 67, 104, 101, 99, 107, 40, 108, 111, 110, 103, 108, 105, 118, 101, 100, 116, 114, 101, 101, 41, 41, 41, 10], true, true);
+
+ }
+ if (Module['calledRun']) {
+ runWithFS();
+ } else {
+ if (!Module['preRun']) Module['preRun'] = [];
+ Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
+ }
+
+})();
+
+// The Module object: Our interface to the outside world. We import
+// and export values on it, and do the work to get that through
+// closure compiler if necessary. There are various ways Module can be used:
+// 1. Not defined. We create it here
+// 2. A function parameter, function(Module) { ..generated code.. }
+// 3. pre-run appended it, var Module = {}; ..generated code..
+// 4. External script tag defines var Module.
+// We need to do an eval in order to handle the closure compiler
+// case, where this code here is minified but Module was defined
+// elsewhere (e.g. case 4 above). We also need to check if Module
+// already exists (e.g. case 3 above).
+// Note that if you want to run closure, and also to use Module
+// after the generated code, you will need to define var Module = {};
+// before the code. Then that object will be used in the code, and you
+// can continue to use Module afterwards as well.
+var Module;
+if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {};
+
+// Sometimes an existing Module object exists with properties
+// meant to overwrite the default module functionality. Here
+// we collect those properties and reapply _after_ we configure
+// the current environment's defaults to avoid having to be so
+// defensive during initialization.
+var moduleOverrides = {};
+for (var key in Module) {
+ if (Module.hasOwnProperty(key)) {
+ moduleOverrides[key] = Module[key];
+ }
+}
+
+// The environment setup code below is customized to use Module.
+// *** Environment setup code ***
+var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
+var ENVIRONMENT_IS_WEB = typeof window === 'object';
+var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
+var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+
+if (ENVIRONMENT_IS_NODE) {
+ // Expose functionality in the same simple way that the shells work
+ // Note that we pollute the global namespace here, otherwise we break in node
+ if (!Module['print']) Module['print'] = function print(x) {
+ process['stdout'].write(x + '\n');
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ process['stderr'].write(x + '\n');
+ };
+
+ var nodeFS = require('fs');
+ var nodePath = require('path');
+
+ Module['read'] = function read(filename, binary) {
+ filename = nodePath['normalize'](filename);
+ var ret = nodeFS['readFileSync'](filename);
+ // The path is absolute if the normalized version is the same as the resolved.
+ if (!ret && filename != nodePath['resolve'](filename)) {
+ filename = path.join(__dirname, '..', 'src', filename);
+ ret = nodeFS['readFileSync'](filename);
+ }
+ if (ret && !binary) ret = ret.toString();
+ return ret;
+ };
+
+ Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
+
+ Module['load'] = function load(f) {
+ globalEval(read(f));
+ };
+
+ Module['arguments'] = process['argv'].slice(2);
+
+ module['exports'] = Module;
+}
+else if (ENVIRONMENT_IS_SHELL) {
+ if (!Module['print']) Module['print'] = print;
+ if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
+
+ if (typeof read != 'undefined') {
+ Module['read'] = read;
+ } else {
+ Module['read'] = function read() { throw 'no read() available (jsc?)' };
+ }
+
+ Module['readBinary'] = function readBinary(f) {
+ return read(f, 'binary');
+ };
+
+ if (typeof scriptArgs != 'undefined') {
+ Module['arguments'] = scriptArgs;
+ } else if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ this['Module'] = Module;
+
+ eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
+}
+else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
+ Module['read'] = function read(url) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ xhr.send(null);
+ return xhr.responseText;
+ };
+
+ if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ if (typeof console !== 'undefined') {
+ if (!Module['print']) Module['print'] = function print(x) {
+ console.log(x);
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ console.log(x);
+ };
+ } else {
+ // Probably a worker, and without console.log. We can do very little here...
+ var TRY_USE_DUMP = false;
+ if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
+ dump(x);
+ }) : (function(x) {
+ // self.postMessage(x); // enable this if you want stdout to be sent as messages
+ }));
+ }
+
+ if (ENVIRONMENT_IS_WEB) {
+ window['Module'] = Module;
+ } else {
+ Module['load'] = importScripts;
+ }
+}
+else {
+ // Unreachable because SHELL is dependant on the others
+ throw 'Unknown runtime environment. Where are we?';
+}
+
+function globalEval(x) {
+ eval.call(null, x);
+}
+if (!Module['load'] == 'undefined' && Module['read']) {
+ Module['load'] = function load(f) {
+ globalEval(Module['read'](f));
+ };
+}
+if (!Module['print']) {
+ Module['print'] = function(){};
+}
+if (!Module['printErr']) {
+ Module['printErr'] = Module['print'];
+}
+if (!Module['arguments']) {
+ Module['arguments'] = [];
+}
+// *** Environment setup code ***
+
+// Closure helpers
+Module.print = Module['print'];
+Module.printErr = Module['printErr'];
+
+// Callbacks
+Module['preRun'] = [];
+Module['postRun'] = [];
+
+// Merge back in the overrides
+for (var key in moduleOverrides) {
+ if (moduleOverrides.hasOwnProperty(key)) {
+ Module[key] = moduleOverrides[key];
+ }
+}
+
+
+
+// === Auto-generated preamble library stuff ===
+
+//========================================
+// Runtime code shared with compiler
+//========================================
+
+var Runtime = {
+ stackSave: function () {
+ return STACKTOP;
+ },
+ stackRestore: function (stackTop) {
+ STACKTOP = stackTop;
+ },
+ forceAlign: function (target, quantum) {
+ quantum = quantum || 4;
+ if (quantum == 1) return target;
+ if (isNumber(target) && isNumber(quantum)) {
+ return Math.ceil(target/quantum)*quantum;
+ } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
+ return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')';
+ }
+ return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
+ },
+ isNumberType: function (type) {
+ return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
+ },
+ isPointerType: function isPointerType(type) {
+ return type[type.length-1] == '*';
+},
+ isStructType: function isStructType(type) {
+ if (isPointerType(type)) return false;
+ if (isArrayType(type)) return true;
+ if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
+ // See comment in isStructPointerType()
+ return type[0] == '%';
+},
+ INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
+ FLOAT_TYPES: {"float":0,"double":0},
+ or64: function (x, y) {
+ var l = (x | 0) | (y | 0);
+ var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ and64: function (x, y) {
+ var l = (x | 0) & (y | 0);
+ var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ xor64: function (x, y) {
+ var l = (x | 0) ^ (y | 0);
+ var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ getNativeTypeSize: function (type) {
+ switch (type) {
+ case 'i1': case 'i8': return 1;
+ case 'i16': return 2;
+ case 'i32': return 4;
+ case 'i64': return 8;
+ case 'float': return 4;
+ case 'double': return 8;
+ default: {
+ if (type[type.length-1] === '*') {
+ return Runtime.QUANTUM_SIZE; // A pointer
+ } else if (type[0] === 'i') {
+ var bits = parseInt(type.substr(1));
+ assert(bits % 8 === 0);
+ return bits/8;
+ } else {
+ return 0;
+ }
+ }
+ }
+ },
+ getNativeFieldSize: function (type) {
+ return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
+ },
+ dedup: function dedup(items, ident) {
+ var seen = {};
+ if (ident) {
+ return items.filter(function(item) {
+ if (seen[item[ident]]) return false;
+ seen[item[ident]] = true;
+ return true;
+ });
+ } else {
+ return items.filter(function(item) {
+ if (seen[item]) return false;
+ seen[item] = true;
+ return true;
+ });
+ }
+},
+ set: function set() {
+ var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
+ var ret = {};
+ for (var i = 0; i < args.length; i++) {
+ ret[args[i]] = 0;
+ }
+ return ret;
+},
+ STACK_ALIGN: 8,
+ getAlignSize: function (type, size, vararg) {
+ // we align i64s and doubles on 64-bit boundaries, unlike x86
+ if (!vararg && (type == 'i64' || type == 'double')) return 8;
+ if (!type) return Math.min(size, 8); // align structures internally to 64 bits
+ return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
+ },
+ calculateStructAlignment: function calculateStructAlignment(type) {
+ type.flatSize = 0;
+ type.alignSize = 0;
+ var diffs = [];
+ var prev = -1;
+ var index = 0;
+ type.flatIndexes = type.fields.map(function(field) {
+ index++;
+ var size, alignSize;
+ if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
+ size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
+ alignSize = Runtime.getAlignSize(field, size);
+ } else if (Runtime.isStructType(field)) {
+ if (field[1] === '0') {
+ // this is [0 x something]. When inside another structure like here, it must be at the end,
+ // and it adds no size
+ // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');
+ size = 0;
+ if (Types.types[field]) {
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ } else {
+ alignSize = type.alignSize || QUANTUM_SIZE;
+ }
+ } else {
+ size = Types.types[field].flatSize;
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ }
+ } else if (field[0] == 'b') {
+ // bN, large number field, like a [N x i8]
+ size = field.substr(1)|0;
+ alignSize = 1;
+ } else if (field[0] === '<') {
+ // vector type
+ size = alignSize = Types.types[field].flatSize; // fully aligned
+ } else if (field[0] === 'i') {
+ // illegal integer field, that could not be legalized because it is an internal structure field
+ // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
+ size = alignSize = parseInt(field.substr(1))/8;
+ assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
+ } else {
+ assert(false, 'invalid type for calculateStructAlignment');
+ }
+ if (type.packed) alignSize = 1;
+ type.alignSize = Math.max(type.alignSize, alignSize);
+ var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
+ type.flatSize = curr + size;
+ if (prev >= 0) {
+ diffs.push(curr-prev);
+ }
+ prev = curr;
+ return curr;
+ });
+ if (type.name_ && type.name_[0] === '[') {
+ // arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
+ // allocating a potentially huge array for [999999 x i8] etc.
+ type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
+ }
+ type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
+ if (diffs.length == 0) {
+ type.flatFactor = type.flatSize;
+ } else if (Runtime.dedup(diffs).length == 1) {
+ type.flatFactor = diffs[0];
+ }
+ type.needsFlattening = (type.flatFactor != 1);
+ return type.flatIndexes;
+ },
+ generateStructInfo: function (struct, typeName, offset) {
+ var type, alignment;
+ if (typeName) {
+ offset = offset || 0;
+ type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
+ if (!type) return null;
+ if (type.fields.length != struct.length) {
+ printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');
+ return null;
+ }
+ alignment = type.flatIndexes;
+ } else {
+ var type = { fields: struct.map(function(item) { return item[0] }) };
+ alignment = Runtime.calculateStructAlignment(type);
+ }
+ var ret = {
+ __size__: type.flatSize
+ };
+ if (typeName) {
+ struct.forEach(function(item, i) {
+ if (typeof item === 'string') {
+ ret[item] = alignment[i] + offset;
+ } else {
+ // embedded struct
+ var key;
+ for (var k in item) key = k;
+ ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
+ }
+ });
+ } else {
+ struct.forEach(function(item, i) {
+ ret[item[1]] = alignment[i];
+ });
+ }
+ return ret;
+ },
+ dynCall: function (sig, ptr, args) {
+ if (args && args.length) {
+ if (!args.splice) args = Array.prototype.slice.call(args);
+ args.splice(0, 0, ptr);
+ return Module['dynCall_' + sig].apply(null, args);
+ } else {
+ return Module['dynCall_' + sig].call(null, ptr);
+ }
+ },
+ functionPointers: [],
+ addFunction: function (func) {
+ for (var i = 0; i < Runtime.functionPointers.length; i++) {
+ if (!Runtime.functionPointers[i]) {
+ Runtime.functionPointers[i] = func;
+ return 2*(1 + i);
+ }
+ }
+ throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
+ },
+ removeFunction: function (index) {
+ Runtime.functionPointers[(index-2)/2] = null;
+ },
+ getAsmConst: function (code, numArgs) {
+ // code is a constant string on the heap, so we can cache these
+ if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
+ var func = Runtime.asmConstCache[code];
+ if (func) return func;
+ var args = [];
+ for (var i = 0; i < numArgs; i++) {
+ args.push(String.fromCharCode(36) + i); // $0, $1 etc
+ }
+ var source = Pointer_stringify(code);
+ if (source[0] === '"') {
+ // tolerate EM_ASM("..code..") even though EM_ASM(..code..) is correct
+ if (source.indexOf('"', 1) === source.length-1) {
+ source = source.substr(1, source.length-2);
+ } else {
+ // something invalid happened, e.g. EM_ASM("..code($0)..", input)
+ abort('invalid EM_ASM input |' + source + '|. Please use EM_ASM(..code..) (no quotes) or EM_ASM({ ..code($0).. }, input) (to input values)');
+ }
+ }
+ try {
+ var evalled = eval('(function(' + args.join(',') + '){ ' + source + ' })'); // new Function does not allow upvars in node
+ } catch(e) {
+ Module.printErr('error in executing inline EM_ASM code: ' + e + ' on: \n\n' + source + '\n\nwith args |' + args + '| (make sure to use the right one out of EM_ASM, EM_ASM_ARGS, etc.)');
+ throw e;
+ }
+ return Runtime.asmConstCache[code] = evalled;
+ },
+ warnOnce: function (text) {
+ if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
+ if (!Runtime.warnOnce.shown[text]) {
+ Runtime.warnOnce.shown[text] = 1;
+ Module.printErr(text);
+ }
+ },
+ funcWrappers: {},
+ getFuncWrapper: function (func, sig) {
+ assert(sig);
+ if (!Runtime.funcWrappers[func]) {
+ Runtime.funcWrappers[func] = function dynCall_wrapper() {
+ return Runtime.dynCall(sig, func, arguments);
+ };
+ }
+ return Runtime.funcWrappers[func];
+ },
+ UTF8Processor: function () {
+ var buffer = [];
+ var needed = 0;
+ this.processCChar = function (code) {
+ code = code & 0xFF;
+
+ if (buffer.length == 0) {
+ if ((code & 0x80) == 0x00) { // 0xxxxxxx
+ return String.fromCharCode(code);
+ }
+ buffer.push(code);
+ if ((code & 0xE0) == 0xC0) { // 110xxxxx
+ needed = 1;
+ } else if ((code & 0xF0) == 0xE0) { // 1110xxxx
+ needed = 2;
+ } else { // 11110xxx
+ needed = 3;
+ }
+ return '';
+ }
+
+ if (needed) {
+ buffer.push(code);
+ needed--;
+ if (needed > 0) return '';
+ }
+
+ var c1 = buffer[0];
+ var c2 = buffer[1];
+ var c3 = buffer[2];
+ var c4 = buffer[3];
+ var ret;
+ if (buffer.length == 2) {
+ ret = String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ } else if (buffer.length == 3) {
+ ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ } else {
+ // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |
+ ((c3 & 0x3F) << 6) | (c4 & 0x3F);
+ ret = String.fromCharCode(
+ Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,
+ (codePoint - 0x10000) % 0x400 + 0xDC00);
+ }
+ buffer.length = 0;
+ return ret;
+ }
+ this.processJSString = function processJSString(string) {
+ /* TODO: use TextEncoder when present,
+ var encoder = new TextEncoder();
+ encoder['encoding'] = "utf-8";
+ var utf8Array = encoder['encode'](aMsg.data);
+ */
+ string = unescape(encodeURIComponent(string));
+ var ret = [];
+ for (var i = 0; i < string.length; i++) {
+ ret.push(string.charCodeAt(i));
+ }
+ return ret;
+ }
+ },
+ getCompilerSetting: function (name) {
+ throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
+ },
+ stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+7)&-8); return ret; },
+ staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = (((STATICTOP)+7)&-8); return ret; },
+ dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = (((DYNAMICTOP)+7)&-8); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
+ alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },
+ makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*(+4294967296))) : ((+((low>>>0)))+((+((high|0)))*(+4294967296)))); return ret; },
+ GLOBAL_BASE: 8,
+ QUANTUM_SIZE: 4,
+ __dummy__: 0
+}
+
+
+Module['Runtime'] = Runtime;
+
+
+
+
+
+
+
+
+
+//========================================
+// Runtime essentials
+//========================================
+
+var __THREW__ = 0; // Used in checking for thrown exceptions.
+
+var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()
+var EXITSTATUS = 0;
+
+var undef = 0;
+// tempInt is used for 32-bit signed values or smaller. tempBigInt is used
+// for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
+var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
+var tempI64, tempI64b;
+var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
+
+function assert(condition, text) {
+ if (!condition) {
+ abort('Assertion failed: ' + text);
+ }
+}
+
+var globalScope = this;
+
+// C calling interface. A convenient way to call C functions (in C files, or
+// defined with extern "C").
+//
+// Note: LLVM optimizations can inline and remove functions, after which you will not be
+// able to call them. Closure can also do so. To avoid that, add your function to
+// the exports using something like
+//
+// -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]'
+//
+// @param ident The name of the C function (note that C++ functions will be name-mangled - use extern "C")
+// @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and
+// 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).
+// @param argTypes An array of the types of arguments for the function (if there are no arguments, this can be ommitted). Types are as in returnType,
+// except that 'array' is not possible (there is no way for us to know the length of the array)
+// @param args An array of the arguments to the function, as native JS values (as in returnType)
+// Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).
+// @return The return value, as a native JS value (as in returnType)
+function ccall(ident, returnType, argTypes, args) {
+ return ccallFunc(getCFunc(ident), returnType, argTypes, args);
+}
+Module["ccall"] = ccall;
+
+// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
+function getCFunc(ident) {
+ try {
+ var func = Module['_' + ident]; // closure exported function
+ if (!func) func = eval('_' + ident); // explicit lookup
+ } catch(e) {
+ }
+ assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
+ return func;
+}
+
+// Internal function that does a C call using a function, not an identifier
+function ccallFunc(func, returnType, argTypes, args) {
+ var stack = 0;
+ function toC(value, type) {
+ if (type == 'string') {
+ if (value === null || value === undefined || value === 0) return 0; // null string
+ value = intArrayFromString(value);
+ type = 'array';
+ }
+ if (type == 'array') {
+ if (!stack) stack = Runtime.stackSave();
+ var ret = Runtime.stackAlloc(value.length);
+ writeArrayToMemory(value, ret);
+ return ret;
+ }
+ return value;
+ }
+ function fromC(value, type) {
+ if (type == 'string') {
+ return Pointer_stringify(value);
+ }
+ assert(type != 'array');
+ return value;
+ }
+ var i = 0;
+ var cArgs = args ? args.map(function(arg) {
+ return toC(arg, argTypes[i++]);
+ }) : [];
+ var ret = fromC(func.apply(null, cArgs), returnType);
+ if (stack) Runtime.stackRestore(stack);
+ return ret;
+}
+
+// Returns a native JS wrapper for a C function. This is similar to ccall, but
+// returns a function you can call repeatedly in a normal way. For example:
+//
+// var my_function = cwrap('my_c_function', 'number', ['number', 'number']);
+// alert(my_function(5, 22));
+// alert(my_function(99, 12));
+//
+function cwrap(ident, returnType, argTypes) {
+ var func = getCFunc(ident);
+ return function() {
+ return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));
+ }
+}
+Module["cwrap"] = cwrap;
+
+// Sets a value in memory in a dynamic way at run-time. Uses the
+// type data. This is the same as makeSetValue, except that
+// makeSetValue is done at compile-time and generates the needed
+// code then, whereas this function picks the right code at
+// run-time.
+// Note that setValue and getValue only do *aligned* writes and reads!
+// Note that ccall uses JS types as for defining types, while setValue and
+// getValue need LLVM types ('i8', 'i32') - this is a lower-level operation
+function setValue(ptr, value, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': HEAP8[(ptr)]=value; break;
+ case 'i8': HEAP8[(ptr)]=value; break;
+ case 'i16': HEAP16[((ptr)>>1)]=value; break;
+ case 'i32': HEAP32[((ptr)>>2)]=value; break;
+ case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= (+1) ? (tempDouble > (+0) ? ((Math_min((+(Math_floor((tempDouble)/(+4294967296)))), (+4294967295)))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+4294967296))))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
+ case 'float': HEAPF32[((ptr)>>2)]=value; break;
+ case 'double': HEAPF64[((ptr)>>3)]=value; break;
+ default: abort('invalid type for setValue: ' + type);
+ }
+}
+Module['setValue'] = setValue;
+
+// Parallel to setValue.
+function getValue(ptr, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': return HEAP8[(ptr)];
+ case 'i8': return HEAP8[(ptr)];
+ case 'i16': return HEAP16[((ptr)>>1)];
+ case 'i32': return HEAP32[((ptr)>>2)];
+ case 'i64': return HEAP32[((ptr)>>2)];
+ case 'float': return HEAPF32[((ptr)>>2)];
+ case 'double': return HEAPF64[((ptr)>>3)];
+ default: abort('invalid type for setValue: ' + type);
+ }
+ return null;
+}
+Module['getValue'] = getValue;
+
+var ALLOC_NORMAL = 0; // Tries to use _malloc()
+var ALLOC_STACK = 1; // Lives for the duration of the current function call
+var ALLOC_STATIC = 2; // Cannot be freed
+var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
+var ALLOC_NONE = 4; // Do not allocate
+Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
+Module['ALLOC_STACK'] = ALLOC_STACK;
+Module['ALLOC_STATIC'] = ALLOC_STATIC;
+Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;
+Module['ALLOC_NONE'] = ALLOC_NONE;
+
+// allocate(): This is for internal use. You can use it yourself as well, but the interface
+// is a little tricky (see docs right below). The reason is that it is optimized
+// for multiple syntaxes to save space in generated code. So you should
+// normally not use allocate(), and instead allocate memory using _malloc(),
+// initialize it with setValue(), and so forth.
+// @slab: An array of data, or a number. If a number, then the size of the block to allocate,
+// in *bytes* (note that this is sometimes confusing: the next parameter does not
+// affect this!)
+// @types: Either an array of types, one for each byte (or 0 if no type at that position),
+// or a single type which is used for the entire block. This only matters if there
+// is initial data - if @slab is a number, then this does not matter at all and is
+// ignored.
+// @allocator: How to allocate memory, see ALLOC_*
+function allocate(slab, types, allocator, ptr) {
+ var zeroinit, size;
+ if (typeof slab === 'number') {
+ zeroinit = true;
+ size = slab;
+ } else {
+ zeroinit = false;
+ size = slab.length;
+ }
+
+ var singleType = typeof types === 'string' ? types : null;
+
+ var ret;
+ if (allocator == ALLOC_NONE) {
+ ret = ptr;
+ } else {
+ ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
+ }
+
+ if (zeroinit) {
+ var ptr = ret, stop;
+ assert((ret & 3) == 0);
+ stop = ret + (size & ~3);
+ for (; ptr < stop; ptr += 4) {
+ HEAP32[((ptr)>>2)]=0;
+ }
+ stop = ret + size;
+ while (ptr < stop) {
+ HEAP8[((ptr++)|0)]=0;
+ }
+ return ret;
+ }
+
+ if (singleType === 'i8') {
+ if (slab.subarray || slab.slice) {
+ HEAPU8.set(slab, ret);
+ } else {
+ HEAPU8.set(new Uint8Array(slab), ret);
+ }
+ return ret;
+ }
+
+ var i = 0, type, typeSize, previousType;
+ while (i < size) {
+ var curr = slab[i];
+
+ if (typeof curr === 'function') {
+ curr = Runtime.getFunctionIndex(curr);
+ }
+
+ type = singleType || types[i];
+ if (type === 0) {
+ i++;
+ continue;
+ }
+
+ if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
+
+ setValue(ret+i, curr, type);
+
+ // no need to look up size unless type changes, so cache it
+ if (previousType !== type) {
+ typeSize = Runtime.getNativeTypeSize(type);
+ previousType = type;
+ }
+ i += typeSize;
+ }
+
+ return ret;
+}
+Module['allocate'] = allocate;
+
+function Pointer_stringify(ptr, /* optional */ length) {
+ // TODO: use TextDecoder
+ // Find the length, and check for UTF while doing so
+ var hasUtf = false;
+ var t;
+ var i = 0;
+ while (1) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ if (t >= 128) hasUtf = true;
+ else if (t == 0 && !length) break;
+ i++;
+ if (length && i == length) break;
+ }
+ if (!length) length = i;
+
+ var ret = '';
+
+ if (!hasUtf) {
+ var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
+ var curr;
+ while (length > 0) {
+ curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
+ ret = ret ? ret + curr : curr;
+ ptr += MAX_CHUNK;
+ length -= MAX_CHUNK;
+ }
+ return ret;
+ }
+
+ var utf8 = new Runtime.UTF8Processor();
+ for (i = 0; i < length; i++) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ ret += utf8.processCChar(t);
+ }
+ return ret;
+}
+Module['Pointer_stringify'] = Pointer_stringify;
+
+// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF16ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
+ if (codeUnit == 0)
+ return str;
+ ++i;
+ // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
+ str += String.fromCharCode(codeUnit);
+ }
+}
+Module['UTF16ToString'] = UTF16ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
+function stringToUTF16(str, outPtr) {
+ for(var i = 0; i < str.length; ++i) {
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
+ HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP16[(((outPtr)+(str.length*2))>>1)]=0;
+}
+Module['stringToUTF16'] = stringToUTF16;
+
+// Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF32ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
+ if (utf32 == 0)
+ return str;
+ ++i;
+ // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
+ if (utf32 >= 0x10000) {
+ var ch = utf32 - 0x10000;
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
+ } else {
+ str += String.fromCharCode(utf32);
+ }
+ }
+}
+Module['UTF32ToString'] = UTF32ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
+// but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.
+function stringToUTF32(str, outPtr) {
+ var iChar = 0;
+ for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
+ var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
+ var trailSurrogate = str.charCodeAt(++iCodeUnit);
+ codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
+ }
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit;
+ ++iChar;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=0;
+}
+Module['stringToUTF32'] = stringToUTF32;
+
+function demangle(func) {
+ var i = 3;
+ // params, etc.
+ var basicTypes = {
+ 'v': 'void',
+ 'b': 'bool',
+ 'c': 'char',
+ 's': 'short',
+ 'i': 'int',
+ 'l': 'long',
+ 'f': 'float',
+ 'd': 'double',
+ 'w': 'wchar_t',
+ 'a': 'signed char',
+ 'h': 'unsigned char',
+ 't': 'unsigned short',
+ 'j': 'unsigned int',
+ 'm': 'unsigned long',
+ 'x': 'long long',
+ 'y': 'unsigned long long',
+ 'z': '...'
+ };
+ var subs = [];
+ var first = true;
+ function dump(x) {
+ //return;
+ if (x) Module.print(x);
+ Module.print(func);
+ var pre = '';
+ for (var a = 0; a < i; a++) pre += ' ';
+ Module.print (pre + '^');
+ }
+ function parseNested() {
+ i++;
+ if (func[i] === 'K') i++; // ignore const
+ var parts = [];
+ while (func[i] !== 'E') {
+ if (func[i] === 'S') { // substitution
+ i++;
+ var next = func.indexOf('_', i);
+ var num = func.substring(i, next) || 0;
+ parts.push(subs[num] || '?');
+ i = next+1;
+ continue;
+ }
+ if (func[i] === 'C') { // constructor
+ parts.push(parts[parts.length-1]);
+ i += 2;
+ continue;
+ }
+ var size = parseInt(func.substr(i));
+ var pre = size.toString().length;
+ if (!size || !pre) { i--; break; } // counter i++ below us
+ var curr = func.substr(i + pre, size);
+ parts.push(curr);
+ subs.push(curr);
+ i += pre + size;
+ }
+ i++; // skip E
+ return parts;
+ }
+ function parse(rawList, limit, allowVoid) { // main parser
+ limit = limit || Infinity;
+ var ret = '', list = [];
+ function flushList() {
+ return '(' + list.join(', ') + ')';
+ }
+ var name;
+ if (func[i] === 'N') {
+ // namespaced N-E
+ name = parseNested().join('::');
+ limit--;
+ if (limit === 0) return rawList ? [name] : name;
+ } else {
+ // not namespaced
+ if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
+ var size = parseInt(func.substr(i));
+ if (size) {
+ var pre = size.toString().length;
+ name = func.substr(i + pre, size);
+ i += pre + size;
+ }
+ }
+ first = false;
+ if (func[i] === 'I') {
+ i++;
+ var iList = parse(true);
+ var iRet = parse(true, 1, true);
+ ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
+ } else {
+ ret = name;
+ }
+ paramLoop: while (i < func.length && limit-- > 0) {
+ //dump('paramLoop');
+ var c = func[i++];
+ if (c in basicTypes) {
+ list.push(basicTypes[c]);
+ } else {
+ switch (c) {
+ case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
+ case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
+ case 'L': { // literal
+ i++; // skip basic type
+ var end = func.indexOf('E', i);
+ var size = end - i;
+ list.push(func.substr(i, size));
+ i += size + 2; // size + 'EE'
+ break;
+ }
+ case 'A': { // array
+ var size = parseInt(func.substr(i));
+ i += size.toString().length;
+ if (func[i] !== '_') throw '?';
+ i++; // skip _
+ list.push(parse(true, 1, true)[0] + ' [' + size + ']');
+ break;
+ }
+ case 'E': break paramLoop;
+ default: ret += '?' + c; break paramLoop;
+ }
+ }
+ }
+ if (!allowVoid && list.length === 1 && list[0] === 'void') list = []; // avoid (void)
+ if (rawList) {
+ if (ret) {
+ list.push(ret + '?');
+ }
+ return list;
+ } else {
+ return ret + flushList();
+ }
+ }
+ try {
+ // Special-case the entry point, since its name differs from other name mangling.
+ if (func == 'Object._main' || func == '_main') {
+ return 'main()';
+ }
+ if (typeof func === 'number') func = Pointer_stringify(func);
+ if (func[0] !== '_') return func;
+ if (func[1] !== '_') return func; // C function
+ if (func[2] !== 'Z') return func;
+ switch (func[3]) {
+ case 'n': return 'operator new()';
+ case 'd': return 'operator delete()';
+ }
+ return parse();
+ } catch(e) {
+ return func;
+ }
+}
+
+function demangleAll(text) {
+ return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });
+}
+
+function stackTrace() {
+ var stack = new Error().stack;
+ return stack ? demangleAll(stack) : '(no stack trace available)'; // Stack trace is not available at least on IE10 and Safari 6.
+}
+
+// Memory management
+
+var PAGE_SIZE = 4096;
+function alignMemoryPage(x) {
+ return (x+4095)&-4096;
+}
+
+var HEAP;
+var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
+
+var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area
+var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area
+var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk
+
+function enlargeMemory() {
+ abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
+}
+
+var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
+var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 134217728;
+var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
+
+var totalMemory = 4096;
+while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
+ if (totalMemory < 16*1024*1024) {
+ totalMemory *= 2;
+ } else {
+ totalMemory += 16*1024*1024
+ }
+}
+if (totalMemory !== TOTAL_MEMORY) {
+ Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
+ TOTAL_MEMORY = totalMemory;
+}
+
+// Initialize the runtime's memory
+// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
+assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
+ 'JS engine does not provide full typed array support');
+
+var buffer = new ArrayBuffer(TOTAL_MEMORY);
+HEAP8 = new Int8Array(buffer);
+HEAP16 = new Int16Array(buffer);
+HEAP32 = new Int32Array(buffer);
+HEAPU8 = new Uint8Array(buffer);
+HEAPU16 = new Uint16Array(buffer);
+HEAPU32 = new Uint32Array(buffer);
+HEAPF32 = new Float32Array(buffer);
+HEAPF64 = new Float64Array(buffer);
+
+// Endianness check (note: assumes compiler arch was little-endian)
+HEAP32[0] = 255;
+assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
+
+Module['HEAP'] = HEAP;
+Module['HEAP8'] = HEAP8;
+Module['HEAP16'] = HEAP16;
+Module['HEAP32'] = HEAP32;
+Module['HEAPU8'] = HEAPU8;
+Module['HEAPU16'] = HEAPU16;
+Module['HEAPU32'] = HEAPU32;
+Module['HEAPF32'] = HEAPF32;
+Module['HEAPF64'] = HEAPF64;
+
+function callRuntimeCallbacks(callbacks) {
+ while(callbacks.length > 0) {
+ var callback = callbacks.shift();
+ if (typeof callback == 'function') {
+ callback();
+ continue;
+ }
+ var func = callback.func;
+ if (typeof func === 'number') {
+ if (callback.arg === undefined) {
+ Runtime.dynCall('v', func);
+ } else {
+ Runtime.dynCall('vi', func, [callback.arg]);
+ }
+ } else {
+ func(callback.arg === undefined ? null : callback.arg);
+ }
+ }
+}
+
+var __ATPRERUN__ = []; // functions called before the runtime is initialized
+var __ATINIT__ = []; // functions called during startup
+var __ATMAIN__ = []; // functions called when main() is to be run
+var __ATEXIT__ = []; // functions called during shutdown
+var __ATPOSTRUN__ = []; // functions called after the runtime has exited
+
+var runtimeInitialized = false;
+
+function preRun() {
+ // compatibility - merge in anything from Module['preRun'] at this time
+ if (Module['preRun']) {
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
+ while (Module['preRun'].length) {
+ addOnPreRun(Module['preRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPRERUN__);
+}
+
+function ensureInitRuntime() {
+ if (runtimeInitialized) return;
+ runtimeInitialized = true;
+ callRuntimeCallbacks(__ATINIT__);
+}
+
+function preMain() {
+ callRuntimeCallbacks(__ATMAIN__);
+}
+
+function exitRuntime() {
+ callRuntimeCallbacks(__ATEXIT__);
+}
+
+function postRun() {
+ // compatibility - merge in anything from Module['postRun'] at this time
+ if (Module['postRun']) {
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
+ while (Module['postRun'].length) {
+ addOnPostRun(Module['postRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPOSTRUN__);
+}
+
+function addOnPreRun(cb) {
+ __ATPRERUN__.unshift(cb);
+}
+Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;
+
+function addOnInit(cb) {
+ __ATINIT__.unshift(cb);
+}
+Module['addOnInit'] = Module.addOnInit = addOnInit;
+
+function addOnPreMain(cb) {
+ __ATMAIN__.unshift(cb);
+}
+Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;
+
+function addOnExit(cb) {
+ __ATEXIT__.unshift(cb);
+}
+Module['addOnExit'] = Module.addOnExit = addOnExit;
+
+function addOnPostRun(cb) {
+ __ATPOSTRUN__.unshift(cb);
+}
+Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;
+
+// Tools
+
+// This processes a JS string into a C-line array of numbers, 0-terminated.
+// For LLVM-originating strings, see parser.js:parseLLVMString function
+function intArrayFromString(stringy, dontAddNull, length /* optional */) {
+ var ret = (new Runtime.UTF8Processor()).processJSString(stringy);
+ if (length) {
+ ret.length = length;
+ }
+ if (!dontAddNull) {
+ ret.push(0);
+ }
+ return ret;
+}
+Module['intArrayFromString'] = intArrayFromString;
+
+function intArrayToString(array) {
+ var ret = [];
+ for (var i = 0; i < array.length; i++) {
+ var chr = array[i];
+ if (chr > 0xFF) {
+ chr &= 0xFF;
+ }
+ ret.push(String.fromCharCode(chr));
+ }
+ return ret.join('');
+}
+Module['intArrayToString'] = intArrayToString;
+
+// Write a Javascript array to somewhere in the heap
+function writeStringToMemory(string, buffer, dontAddNull) {
+ var array = intArrayFromString(string, dontAddNull);
+ var i = 0;
+ while (i < array.length) {
+ var chr = array[i];
+ HEAP8[(((buffer)+(i))|0)]=chr;
+ i = i + 1;
+ }
+}
+Module['writeStringToMemory'] = writeStringToMemory;
+
+function writeArrayToMemory(array, buffer) {
+ for (var i = 0; i < array.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=array[i];
+ }
+}
+Module['writeArrayToMemory'] = writeArrayToMemory;
+
+function writeAsciiToMemory(str, buffer, dontAddNull) {
+ for (var i = 0; i < str.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=str.charCodeAt(i);
+ }
+ if (!dontAddNull) HEAP8[(((buffer)+(str.length))|0)]=0;
+}
+Module['writeAsciiToMemory'] = writeAsciiToMemory;
+
+function unSign(value, bits, ignore) {
+ if (value >= 0) {
+ return value;
+ }
+ return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
+ : Math.pow(2, bits) + value;
+}
+function reSign(value, bits, ignore) {
+ if (value <= 0) {
+ return value;
+ }
+ var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
+ : Math.pow(2, bits-1);
+ if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
+ // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
+ // TODO: In i64 mode 1, resign the two parts separately and safely
+ value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
+ }
+ return value;
+}
+
+// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
+if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
+ var ah = a >>> 16;
+ var al = a & 0xffff;
+ var bh = b >>> 16;
+ var bl = b & 0xffff;
+ return (al*bl + ((ah*bl + al*bh) << 16))|0;
+};
+Math.imul = Math['imul'];
+
+
+var Math_abs = Math.abs;
+var Math_cos = Math.cos;
+var Math_sin = Math.sin;
+var Math_tan = Math.tan;
+var Math_acos = Math.acos;
+var Math_asin = Math.asin;
+var Math_atan = Math.atan;
+var Math_atan2 = Math.atan2;
+var Math_exp = Math.exp;
+var Math_log = Math.log;
+var Math_sqrt = Math.sqrt;
+var Math_ceil = Math.ceil;
+var Math_floor = Math.floor;
+var Math_pow = Math.pow;
+var Math_imul = Math.imul;
+var Math_fround = Math.fround;
+var Math_min = Math.min;
+
+// A counter of dependencies for calling run(). If we need to
+// do asynchronous work before running, increment this and
+// decrement it. Incrementing must happen in a place like
+// PRE_RUN_ADDITIONS (used by emcc to add file preloading).
+// Note that you can add dependencies in preRun, even though
+// it happens right before run - run will be postponed until
+// the dependencies are met.
+var runDependencies = 0;
+var runDependencyWatcher = null;
+var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
+
+function addRunDependency(id) {
+ runDependencies++;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+}
+Module['addRunDependency'] = addRunDependency;
+function removeRunDependency(id) {
+ runDependencies--;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+ if (runDependencies == 0) {
+ if (runDependencyWatcher !== null) {
+ clearInterval(runDependencyWatcher);
+ runDependencyWatcher = null;
+ }
+ if (dependenciesFulfilled) {
+ var callback = dependenciesFulfilled;
+ dependenciesFulfilled = null;
+ callback(); // can add another dependenciesFulfilled
+ }
+ }
+}
+Module['removeRunDependency'] = removeRunDependency;
+
+Module["preloadedImages"] = {}; // maps url to image data
+Module["preloadedAudios"] = {}; // maps url to audio data
+
+
+var memoryInitializer = null;
+
+// === Body ===
+
+
+
+
+
+STATIC_BASE = 8;
+
+STATICTOP = STATIC_BASE + Runtime.alignMemory(13467);
+/* global initializers */ __ATINIT__.push();
+
+
+/* memory initializer */ allocate([99,97,110,110,111,116,32,99,114,101,97,116,101,32,115,116,97,116,101,58,32,110,111,116,32,101,110,111,117,103,104,32,109,101,109,111,114,121,0,0,40,101,114,114,111,114,32,111,98,106,101,99,116,32,105,115,32,110,111,116,32,97,32,115,116,114,105,110,103,41,0,0,88,0,0,0,0,0,0,0,108,117,97,0,0,0,0,0,76,85,65,95,78,79,69,78,86,0,0,0,0,0,0,0,116,111,111,32,109,97,110,121,32,114,101,115,117,108,116,115,32,116,111,32,112,114,105,110,116,0,0,0,0,0,0,0,112,114,105,110,116,0,0,0,101,114,114,111,114,32,99,97,108,108,105,110,103,32,39,112,114,105,110,116,39,32,40,37,115,41,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,105,110,116,101,114,114,117,112,116,101,100,33,0,0,0,0,95,95,116,111,115,116,114,105,110,103,0,0,0,0,0,0,40,110,111,32,101,114,114,111,114,32,109,101,115,115,97,103,101,41,0,0,0,0,0,0,61,115,116,100,105,110,0,0,60,101,111,102,62,0,0,0,114,101,116,117,114,110,32,37,115,0,0,0,0,0,0,0,95,80,82,79,77,80,84,0,95,80,82,79,77,80,84,50,0,0,0,0,0,0,0,0,62,32,0,0,0,0,0,0,62,62,32,0,0,0,0,0,97,114,103,0,0,0,0,0,45,0,0,0,0,0,0,0,45,45,0,0,0,0,0,0,116,111,111,32,109,97,110,121,32,97,114,103,117,109,101,110,116,115,32,116,111,32,115,99,114,105,112,116,0,0,0,0,61,40,99,111,109,109,97,110,100,32,108,105,110,101,41,0,114,101,113,117,105,114,101,0,61,76,85,65,95,73,78,73,84,95,53,95,50,0,0,0,61,76,85,65,95,73,78,73,84,0,0,0,0,0,0,0,76,117,97,32,53,46,50,46,50,32,32,67,111,112,121,114,105,103,104,116,32,40,67,41,32,49,57,57,52,45,50,48,49,51,32,76,117,97,46,111,114,103,44,32,80,85,67,45,82,105,111,0,0,0,0,0,37,115,58,32,0,0,0,0,39,37,115,39,32,110,101,101,100,115,32,97,114,103,117,109,101,110,116,10,0,0,0,0,117,110,114,101,99,111,103,110,105,122,101,100,32,111,112,116,105,111,110,32,39,37,115,39,10,0,0,0,0,0,0,0,117,115,97,103,101,58,32,37,115,32,91,111,112,116,105,111,110,115,93,32,91,115,99,114,105,112,116,32,91,97,114,103,115,93,93,10,65,118,97,105,108,97,98,108,101,32,111,112,116,105,111,110,115,32,97,114,101,58,10,32,32,45,101,32,115,116,97,116,32,32,101,120,101,99,117,116,101,32,115,116,114,105,110,103,32,39,115,116,97,116,39,10,32,32,45,105,32,32,32,32,32,32,32,101,110,116,101,114,32,105,110,116,101,114,97,99,116,105,118,101,32,109,111,100,101,32,97,102,116,101,114,32,101,120,101,99,117,116,105,110,103,32,39,115,99,114,105,112,116,39,10,32,32,45,108,32,110,97,109,101,32,32,114,101,113,117,105,114,101,32,108,105,98,114,97,114,121,32,39,110,97,109,101,39,10,32,32,45,118,32,32,32,32,32,32,32,115,104,111,119,32,118,101,114,115,105,111,110,32,105,110,102,111,114,109,97,116,105,111,110,10,32,32,45,69,32,32,32,32,32,32,32,105,103,110,111,114,101,32,101,110,118,105,114,111,110,109,101,110,116,32,118,97,114,105,97,98,108,101,115,10,32,32,45,45,32,32,32,32,32,32,32,115,116,111,112,32,104,97,110,100,108,105,110,103,32,111,112,116,105,111,110,115,10,32,32,45,32,32,32,32,32,32,32,32,115,116,111,112,32,104,97,110,100,108,105,110,103,32,111,112,116,105,111,110,115,32,97,110,100,32,101,120,101,99,117,116,101,32,115,116,100,105,110,10,0,0,0,0,0,0,0,37,115,10,0,0,0,0,0,0,0,0,0,0,96,127,64,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,115,10,0,0,0,0,0,115,116,97,99,107,32,116,114,97,99,101,98,97,99,107,58,0,0,0,0,0,0,0,0,10,9,46,46,46,0,0,0,83,108,110,116,0,0,0,0,10,9,37,115,58,0,0,0,37,100,58,0,0,0,0,0,32,105,110,32,0,0,0,0,10,9,40,46,46,46,116,97,105,108,32,99,97,108,108,115,46,46,46,41,0,0,0,0,98,97,100,32,97,114,103,117,109,101,110,116,32,35,37,100,32,40,37,115,41,0,0,0,110,0,0,0,0,0,0,0,109,101,116,104,111,100,0,0,99,97,108,108,105,110,103,32,39,37,115,39,32,111,110,32,98,97,100,32,115,101,108,102,32,40,37,115,41,0,0,0,63,0,0,0,0,0,0,0,98,97,100,32,97,114,103,117,109,101,110,116,32,35,37,100,32,116,111,32,39,37,115,39,32,40,37,115,41,0,0,0,83,108,0,0,0,0,0,0,37,115,58,37,100,58,32,0,0,0,0,0,0,0,0,0,37,115,58,32,37,115,0,0,101,120,105,116,0,0,0,0,105,110,118,97,108,105,100,32,111,112,116,105,111,110,32,39,37,115,39,0,0,0,0,0,115,116,97,99,107,32,111,118,101,114,102,108,111,119,32,40,37,115,41,0,0,0,0,0,115,116,97,99,107,32,111,118,101,114,102,108,111,119,0,0,118,97,108,117,101,32,101,120,112,101,99,116,101,100,0,0,98,117,102,102,101,114,32,116,111,111,32,108,97,114,103,101,0,0,0,0,0,0,0,0,61,115,116,100,105,110,0,0,64,37,115,0,0,0,0,0,114,0,0,0,0,0,0,0,111,112,101,110,0,0,0,0,114,98,0,0,0,0,0,0,114,101,111,112,101,110,0,0,114,101,97,100,0,0,0,0,111,98,106,101,99,116,32,108,101,110,103,116,104,32,105,115,32,110,111,116,32,97,32,110,117,109,98,101,114,0,0,0,95,95,116,111,115,116,114,105,110,103,0,0,0,0,0,0,116,114,117,101,0,0,0,0,102,97,108,115,101,0,0,0,110,105,108,0,0,0,0,0,37,115,58,32,37,112,0,0,95,76,79,65,68,69,68,0,110,97,109,101,32,99,111,110,102,108,105,99,116,32,102,111,114,32,109,111,100,117,108,101,32,39,37,115,39,0,0,0,116,111,111,32,109,97,110,121,32,117,112,118,97,108,117,101,115,0,0,0,0,0,0,0,109,117,108,116,105,112,108,101,32,76,117,97,32,86,77,115,32,100,101,116,101,99,116,101,100,0,0,0,0,0,0,0,118,101,114,115,105,111,110,32,109,105,115,109,97,116,99,104,58,32,97,112,112,46,32,110,101,101,100,115,32,37,102,44,32,76,117,97,32,99,111,114,101,32,112,114,111,118,105,100,101,115,32,37,102,0,0,0,98,97,100,32,99,111,110,118,101,114,115,105,111,110,32,110,117,109,98,101,114,45,62,105,110,116,59,32,109,117,115,116,32,114,101,99,111,109,112,105,108,101,32,76,117,97,32,119,105,116,104,32,112,114,111,112,101,114,32,115,101,116,116,105,110,103,115,0,0,0,0,0,80,65,78,73,67,58,32,117,110,112,114,111,116,101,99,116,101,100,32,101,114,114,111,114,32,105,110,32,99,97,108,108,32,116,111,32,76,117,97,32,65,80,73,32,40,37,115,41,10,0,0,0,0,0,0,0,239,187,191,0,0,0,0,0,99,97,110,110,111,116,32,37,115,32,37,115,58,32,37,115,0,0,0,0,0,0,0,0,37,115,32,101,120,112,101,99,116,101,100,44,32,103,111,116,32,37,115,0,0,0,0,0,102,0,0,0,0,0,0,0,46,0,0,0,0,0,0,0,102,117,110,99,116,105,111,110,32,39,37,115,39,0,0,0,109,97,105,110,32,99,104,117,110,107,0,0,0,0,0,0,102,117,110,99,116,105,111,110,32,60,37,115,58,37,100,62,0,0,0,0,0,0,0,0,97,116,116,101,109,112,116,32,116,111,32,37,115,32,37,115,32,39,37,115,39,32,40,97,32,37,115,32,118,97,108,117,101,41,0,0,0,0,0,0,97,116,116,101,109,112,116,32,116,111,32,37,115,32,97,32,37,115,32,118,97,108,117,101,0,0,0,0,0,0,0,0,99,111,110,99,97,116,101,110,97,116,101,0,0,0,0,0,112,101,114,102,111,114,109,32,97,114,105,116,104,109,101,116,105,99,32,111,110,0,0,0,97,116,116,101,109,112,116,32,116,111,32,99,111,109,112,97,114,101,32,116,119,111,32,37,115,32,118,97,108,117,101,115,0,0,0,0,0,0,0,0,97,116,116,101,109,112,116,32,116,111,32,99,111,109,112,97,114,101,32,37,115,32,119,105,116,104,32,37,115,0,0,0,37,115,58,37,100,58,32,37,115,0,0,0,0,0,0,0,108,111,99,97,108,0,0,0,95,69,78,86,0,0,0,0,103,108,111,98,97,108,0,0,102,105,101,108,100,0,0,0,117,112,118,97,108,117,101,0,99,111,110,115,116,97,110,116,0,0,0,0,0,0,0,0,109,101,116,104,111,100,0,0,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,102,111,114,32,105,116,101,114,97,116,111,114,0,0,0,0,109,101,116,97,109,101,116,104,111,100,0,0,0,0,0,0,61,91,67,93,0,0,0,0,67,0,0,0,0,0,0,0,61,63,0,0,0,0,0,0,109,97,105,110,0,0,0,0,76,117,97,0,0,0,0,0,40,42,116,101,109,112,111,114,97,114,121,41,0,0,0,0,40,42,118,97,114,97,114,103,41,0,0,0,0,0,0,0,115,116,97,99,107,32,111,118,101,114,102,108,111,119,0,0,67,32,115,116,97,99,107,32,111,118,101,114,102,108,111,119,0,0,0,0,0,0,0,0,97,116,116,101,109,112,116,32,116,111,32,121,105,101,108,100,32,97,99,114,111,115,115,32,97,32,67,45,99,97,108,108,32,98,111,117,110,100,97,114,121,0,0,0,0,0,0,0,97,116,116,101,109,112,116,32,116,111,32,121,105,101,108,100,32,102,114,111,109,32,111,117,116,115,105,100,101,32,97,32,99,111,114,111,117,116,105,110,101,0,0,0,0,0,0,0,98,105,110,97,114,121,0,0,116,101,120,116,0,0,0,0,97,116,116,101,109,112,116,32,116,111,32,108,111,97,100,32,97,32,37,115,32,99,104,117,110,107,32,40,109,111,100,101,32,105,115,32,39,37,115,39,41,0,0,0,0,0,0,0,101,114,114,111,114,32,105,110,32,101,114,114,111,114,32,104,97,110,100,108,105,110,103,0,99,97,110,110,111,116,32,114,101,115,117,109,101,32,110,111,110,45,115,117,115,112,101,110,100,101,100,32,99,111,114,111,117,116,105,110,101,0,0,0,99,97,110,110,111,116,32,114,101,115,117,109,101,32,100,101,97,100,32,99,111,114,111,117,116,105,110,101,0,0,0,0,99,97,108,108,0,0,0,0,110,111,32,109,101,115,115,97,103,101,0,0,0,0,0,0,101,114,114,111,114,32,105,110,32,95,95,103,99,32,109,101,116,97,109,101,116,104,111,100,32,40,37,115,41,0,0,0,95,80,82,69,76,79,65,68,0,0,0,0,0,0,0,0,95,71,0,0,0,0,0,0,112,97,99,107,97,103,101,0,99,111,114,111,117,116,105,110,101,0,0,0,0,0,0,0,116,97,98,108,101,0,0,0,105,111,0,0,0,0,0,0,111,115,0,0,0,0,0,0,115,116,114,105,110,103,0,0,98,105,116,51,50,0,0,0,109,97,116,104,0,0,0,0,100,101,98,117,103,0,0,0,144,11,0,0,1,0,0,0,152,11,0,0,2,0,0,0,48,13,0,0,3,0,0,0,160,11,0,0,4,0,0,0,56,13,0,0,5,0,0,0,64,13,0,0,6,0,0,0,72,13,0,0,7,0,0,0,168,11,0,0,8,0,0,0,80,13,0,0,9,0,0,0,88,13,0,0,10,0,0,0,192,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,95,73,79,95,105,110,112,117,116,0,0,0,0,0,0,0,115,116,100,105,110,0,0,0,95,73,79,95,111,117,116,112,117,116,0,0,0,0,0,0,115,116,100,111,117,116,0,0,115,116,100,101,114,114,0,0,70,73,76,69,42,0,0,0,99,97,110,110,111,116,32,99,108,111,115,101,32,115,116,97,110,100,97,114,100,32,102,105,108,101,0,0,0,0,0,0,95,95,105,110,100,101,120,0,144,11,0,0,1,0,0,0,152,11,0,0,12,0,0,0,160,11,0,0,13,0,0,0,168,11,0,0,14,0,0,0,176,11,0,0,15,0,0,0,184,11,0,0,16,0,0,0,192,11,0,0,17,0,0,0,200,11,0,0,18,0,0,0,208,11,0,0,19,0,0,0,0,0,0,0,0,0,0,0,99,108,111,115,101,0,0,0,102,108,117,115,104,0,0,0,108,105,110,101,115,0,0,0,114,101,97,100,0,0,0,0,115,101,101,107,0,0,0,0,115,101,116,118,98,117,102,0,119,114,105,116,101,0,0,0,95,95,103,99,0,0,0,0,95,95,116,111,115,116,114,105,110,103,0,0,0,0,0,0,102,105,108,101,32,40,99,108,111,115,101,100,41,0,0,0,102,105,108,101,32,40,37,112,41,0,0,0,0,0,0,0,37,46,49,52,103,0,0,0,97,116,116,101,109,112,116,32,116,111,32,117,115,101,32,97,32,99,108,111,115,101,100,32,102,105,108,101,0,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,72,12,0,0,80,12,0,0,88,12,0,0,0,0,0,0,110,111,0,0,0,0,0,0,102,117,108,108,0,0,0,0,108,105,110,101,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,0,0,0,0,128,12,0,0,136,12,0,0,144,12,0,0,0,0,0,0,115,101,116,0,0,0,0,0,99,117,114,0,0,0,0,0,101,110,100,0,0,0,0,0,110,111,116,32,97,110,32,105,110,116,101,103,101,114,32,105,110,32,112,114,111,112,101,114,32,114,97,110,103,101,0,0,116,111,111,32,109,97,110,121,32,97,114,103,117,109,101,110,116,115,0,0,0,0,0,0,105,110,118,97,108,105,100,32,111,112,116,105,111,110,0,0,105,110,118,97,108,105,100,32,102,111,114,109,97,116,0,0,37,108,102,0,0,0,0,0,116,111,111,32,109,97,110,121,32,111,112,116,105,111,110,115,0,0,0,0,0,0,0,0,102,105,108,101,32,105,115,32,97,108,114,101,97,100,121,32,99,108,111,115,101,100,0,0,37,115,0,0,0,0,0,0,105,110,112,117,116,0,0,0,111,112,101,110,0,0,0,0,111,117,116,112,117,116,0,0,112,111,112,101,110,0,0,0,116,109,112,102,105,108,101,0,116,121,112,101,0,0,0,0,115,116,97,110,100,97,114,100,32,37,115,32,102,105,108,101,32,105,115,32,99,108,111,115,101,100,0,0,0,0,0,0,99,108,111,115,101,100,32,102,105,108,101,0,0,0,0,0,102,105,108,101,0,0,0,0,114,0,0,0,0,0,0,0,39,112,111,112,101,110,39,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,0,0,119,0,0,0,0,0,0,0,99,97,110,110,111,116,32,111,112,101,110,32,102,105,108,101,32,39,37,115,39,32,40,37,115,41,0,0,0,0,0,0,114,119,97,0,0,0,0,0,105,110,118,97,108,105,100,32,109,111,100,101,0,0,0,0,240,14,0,0,20,0,0,0,248,14,0,0,21,0,0,0,0,15,0,0,22,0,0,0,8,15,0,0,23,0,0,0,16,15,0,0,24,0,0,0,24,15,0,0,25,0,0,0,32,15,0,0,26,0,0,0,40,15,0,0,27,0,0,0,48,15,0,0,28,0,0,0,56,15,0,0,29,0,0,0,64,15,0,0,30,0,0,0,72,15,0,0,31,0,0,0,80,15,0,0,32,0,0,0,88,15,0,0,33,0,0,0,96,15,0,0,34,0,0,0,104,15,0,0,35,0,0,0,112,15,0,0,36,0,0,0,120,15,0,0,37,0,0,0,128,15,0,0,38,0,0,0,136,15,0,0,39,0,0,0,144,15,0,0,40,0,0,0,152,15,0,0,41,0,0,0,160,15,0,0,42,0,0,0,176,15,0,0,43,0,0,0,184,15,0,0,44,0,0,0,192,15,0,0,45,0,0,0,200,15,0,0,46,0,0,0,208,15,0,0,47,0,0,0,0,0,0,0,0,0,0,0,112,105,0,0,0,0,0,0,104,117,103,101,0,0,0,0,97,98,115,0,0,0,0,0,97,99,111,115,0,0,0,0,97,115,105,110,0,0,0,0,97,116,97,110,50,0,0,0,97,116,97,110,0,0,0,0,99,101,105,108,0,0,0,0,99,111,115,104,0,0,0,0,99,111,115,0,0,0,0,0,100,101,103,0,0,0,0,0,101,120,112,0,0,0,0,0,102,108,111,111,114,0,0,0,102,109,111,100,0,0,0,0,102,114,101,120,112,0,0,0,108,100,101,120,112,0,0,0,108,111,103,49,48,0,0,0,108,111,103,0,0,0,0,0,109,97,120,0,0,0,0,0,109,105,110,0,0,0,0,0,109,111,100,102,0,0,0,0,112,111,119,0,0,0,0,0,114,97,100,0,0,0,0,0,114,97,110,100,111,109,0,0,114,97,110,100,111,109,115,101,101,100,0,0,0,0,0,0,115,105,110,104,0,0,0,0,115,105,110,0,0,0,0,0,115,113,114,116,0,0,0,0,116,97,110,104,0,0,0,0,116,97,110,0,0,0,0,0,105,110,116,101,114,118,97,108,32,105,115,32,101,109,112,116,121,0,0,0,0,0,0,0,119,114,111,110,103,32,110,117,109,98,101,114,32,111,102,32,97,114,103,117,109,101,110,116,115,0,0,0,0,0,0,0,116,111,111,32,109,97,110,121,32,37,115,32,40,108,105,109,105,116,32,105,115,32,37,100,41,0,0,0,0,0,0,0,109,101,109,111,114,121,32,97,108,108,111,99,97,116,105,111,110,32,101,114,114,111,114,58,32,98,108,111,99,107,32,116,111,111,32,98,105,103,0,0,95,67,76,73,66,83,0,0,95,95,103,99,0,0,0,0,16,20,0,0,48,0,0,0,24,20,0,0,49,0,0,0,40,20,0,0,50,0,0,0,0,0,0,0,0,0,0,0,108,111,97,100,101,114,115,0,115,101,97,114,99,104,101,114,115,0,0,0,0,0,0,0,112,97,116,104,0,0,0,0,76,85,65,95,80,65,84,72,95,53,95,50,0,0,0,0,76,85,65,95,80,65,84,72,0,0,0,0,0,0,0,0,47,117,115,114,47,108,111,99,97,108,47,115,104,97,114,101,47,108,117,97,47,53,46,50,47,63,46,108,117,97,59,47,117,115,114,47,108,111,99,97,108,47,115,104,97,114,101,47,108,117,97,47,53,46,50,47,63,47,105,110,105,116,46,108,117,97,59,47,117,115,114,47,108,111,99,97,108,47,108,105,98,47,108,117,97,47,53,46,50,47,63,46,108,117,97,59,47,117,115,114,47,108,111,99,97,108,47,108,105,98,47,108,117,97,47,53,46,50,47,63,47,105,110,105,116,46,108,117,97,59,46,47,63,46,108,117,97,0,0,0,0,0,0,0,99,112,97,116,104,0,0,0,76,85,65,95,67,80,65,84,72,95,53,95,50,0,0,0,76,85,65,95,67,80,65,84,72,0,0,0,0,0,0,0,47,117,115,114,47,108,111,99,97,108,47,108,105,98,47,108,117,97,47,53,46,50,47,63,46,115,111,59,47,117,115,114,47,108,111,99,97,108,47,108,105,98,47,108,117,97,47,53,46,50,47,108,111,97,100,97,108,108,46,115,111,59,46,47,63,46,115,111,0,0,0,0,47,10,59,10,63,10,33,10,45,10,0,0,0,0,0,0,99,111,110,102,105,103,0,0,95,76,79,65,68,69,68,0,108,111,97,100,101,100,0,0,95,80,82,69,76,79,65,68,0,0,0,0,0,0,0,0,112,114,101,108,111,97,100,0,32,18,0,0,51,0,0,0,40,18,0,0,52,0,0,0,0,0,0,0,0,0,0,0,109,111,100,117,108,101,0,0,114,101,113,117,105,114,101,0,39,112,97,99,107,97,103,101,46,115,101,97,114,99,104,101,114,115,39,32,109,117,115,116,32,98,101,32,97,32,116,97,98,108,101,0,0,0,0,0,109,111,100,117,108,101,32,39,37,115,39,32,110,111,116,32,102,111,117,110,100,58,37,115,0,0,0,0,0,0,0,0,95,78,65,77,69,0,0,0,102,0,0,0,0,0,0,0,39,109,111,100,117,108,101,39,32,110,111,116,32,99,97,108,108,101,100,32,102,114,111,109,32,97,32,76,117,97,32,102,117,110,99,116,105,111,110,0,95,77,0,0,0,0,0,0,95,80,65,67,75,65,71,69,0,0,0,0,0,0,0,0,59,59,0,0,0,0,0,0,59,1,59,0,0,0,0,0,1,0,0,0,0,0,0,0,76,85,65,95,78,79,69,78,86,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,10,9,110,111,32,109,111,100,117,108,101,32,39,37,115,39,32,105,110,32,102,105,108,101,32,39,37,115,39,0,0,0,101,114,114,111,114,32,108,111,97,100,105,110,103,32,109,111,100,117,108,101,32,39,37,115,39,32,102,114,111,109,32,102,105,108,101,32,39,37,115,39,58,10,9,37,115,0,0,0,46,0,0,0,0,0,0,0,95,0,0,0,0,0,0,0,108,117,97,111,112,101,110,95,37,115,0,0,0,0,0,0,100,121,110,97,109,105,99,32,108,105,98,114,97,114,105,101,115,32,110,111,116,32,101,110,97,98,108,101,100,59,32,99,104,101,99,107,32,121,111,117,114,32,76,117,97,32,105,110,115,116,97,108,108,97,116,105,111,110,0,0,0,0,0,0,39,112,97,99,107,97,103,101,46,37,115,39,32,109,117,115,116,32,98,101,32,97,32,115,116,114,105,110,103,0,0,0,63,0,0,0,0,0,0,0,10,9,110,111,32,102,105,108,101,32,39,37,115,39,0,0,114,0,0,0,0,0,0,0,10,9,110,111,32,102,105,101,108,100,32,112,97,99,107,97,103,101,46,112,114,101,108,111,97,100,91,39,37,115,39,93,0,0,0,0,0,0,0,0,108,111,97,100,108,105,98,0,115,101,97,114,99,104,112,97,116,104,0,0,0,0,0,0,115,101,101,97,108,108,0,0,95,95,105,110,100,101,120,0,97,98,115,101,110,116,0,0,105,110,105,116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,110,78,0,0,0,0,0,0,120,88,0,0,0,0,0,0,40,110,117,108,108,41,0,0,37,112,0,0,0,0,0,0,37,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,111,112,116,105,111,110,32,39,37,37,37,99,39,32,116,111,32,39,108,117,97,95,112,117,115,104,102,115,116,114,105,110,103,39,0,0,0,0,0,0,46,46,46,0,0,0,0,0,91,115,116,114,105,110,103,32,34,0,0,0,0,0,0,0,34,93,0,0,0,0,0,0,96,113,65,84,80,80,92,108,60,16,60,84,108,124,124,124,124,124,124,96,96,96,104,34,188,188,188,132,228,84,84,16,98,98,4,98,20,81,80,23,88,22,0,0,53,0,0,0,96,22,0,0,54,0,0,0,104,22,0,0,55,0,0,0,120,22,0,0,56,0,0,0,128,22,0,0,57,0,0,0,136,22,0,0,58,0,0,0,144,22,0,0,59,0,0,0,152,22,0,0,60,0,0,0,160,22,0,0,61,0,0,0,176,22,0,0,62,0,0,0,184,22,0,0,63,0,0,0,0,0,0,0,0,0,0,0,99,108,111,99,107,0,0,0,100,97,116,101,0,0,0,0,100,105,102,102,116,105,109,101,0,0,0,0,0,0,0,0,101,120,101,99,117,116,101,0,101,120,105,116,0,0,0,0,103,101,116,101,110,118,0,0,114,101,109,111,118,101,0,0,114,101,110,97,109,101,0,0,115,101,116,108,111,99,97,108,101,0,0,0,0,0,0,0,116,105,109,101,0,0,0,0,116,109,112,110,97,109,101,0,117,110,97,98,108,101,32,116,111,32,103,101,110,101,114,97,116,101,32,97,32,117,110,105,113,117,101,32,102,105,108,101,110,97,109,101,0,0,0,0,115,101,99,0,0,0,0,0,109,105,110,0,0,0,0,0,104,111,117,114,0,0,0,0,100,97,121,0,0,0,0,0,109,111,110,116,104,0,0,0,121,101,97,114,0,0,0,0,105,115,100,115,116,0,0,0,102,105,101,108,100,32,39,37,115,39,32,109,105,115,115,105,110,103,32,105,110,32,100,97,116,101,32,116,97,98,108,101,0,0,0,0,0,0,0,0,6,0,0,0,3,0,0,0,0,0,0,0,4,0,0,0,1,0,0,0,2,0,0,0,128,23,0,0,136,23,0,0,144,23,0,0,152,23,0,0,168,23,0,0,176,22,0,0,0,0,0,0,0,0,0,0,97,108,108,0,0,0,0,0,99,111,108,108,97,116,101,0,99,116,121,112,101,0,0,0,109,111,110,101,116,97,114,121,0,0,0,0,0,0,0,0,110,117,109,101,114,105,99,0,37,99,0,0,0,0,0,0,42,116,0,0,0,0,0,0,119,100,97,121,0,0,0,0,121,100,97,121,0,0,0,0,97,65,98,66,99,100,72,73,106,109,77,112,83,85,119,87,120,88,121,89,122,37,0,0,105,110,118,97,108,105,100,32,99,111,110,118,101,114,115,105,111,110,32,115,112,101,99,105,102,105,101,114,32,39,37,37,37,115,39,0,0,0,0,0,60,37,115,62,32,97,116,32,108,105,110,101,32,37,100,32,110,111,116,32,105,110,115,105,100,101,32,97,32,108,111,111,112,0,0,0,0,0,0,0,110,111,32,118,105,115,105,98,108,101,32,108,97,98,101,108,32,39,37,115,39,32,102,111,114,32,60,103,111,116,111,62,32,97,116,32,108,105,110,101,32,37,100,0,0,0,0,0,60,103,111,116,111,32,37,115,62,32,97,116,32,108,105,110,101,32,37,100,32,106,117,109,112,115,32,105,110,116,111,32,116,104,101,32,115,99,111,112,101,32,111,102,32,108,111,99,97,108,32,39,37,115,39,0,98,114,101,97,107,0,0,0,108,97,98,101,108,115,47,103,111,116,111,115,0,0,0,0,37,115,32,101,120,112,101,99,116,101,100,0,0,0,0,0,115,121,110,116,97,120,32,101,114,114,111,114,0,0,0,0,67,32,108,101,118,101,108,115,0,0,0,0,0,0,0,0,6,6,6,6,7,7,7,7,7,7,10,9,5,4,3,3,3,3,3,3,3,3,3,3,3,3,2,2,1,1,0,0,99,97,110,110,111,116,32,117,115,101,32,39,46,46,46,39,32,111,117,116,115,105,100,101,32,97,32,118,97,114,97,114,103,32,102,117,110,99,116,105,111,110,0,0,0,0,0,0,115,101,108,102,0,0,0,0,60,110,97,109,101,62,32,111,114,32,39,46,46,46,39,32,101,120,112,101,99,116,101,100,0,0,0,0,0,0,0,0,108,111,99,97,108,32,118,97,114,105,97,98,108,101,115,0,102,117,110,99,116,105,111,110,115,0,0,0,0,0,0,0,105,116,101,109,115,32,105,110,32,97,32,99,111,110,115,116,114,117,99,116,111,114,0,0,109,97,105,110,32,102,117,110,99,116,105,111,110,0,0,0,102,117,110,99,116,105,111,110,32,97,116,32,108,105,110,101,32,37,100,0,0,0,0,0,116,111,111,32,109,97,110,121,32,37,115,32,40,108,105,109,105,116,32,105,115,32,37,100,41,32,105,110,32,37,115,0,102,117,110,99,116,105,111,110,32,97,114,103,117,109,101,110,116,115,32,101,120,112,101,99,116,101,100,0,0,0,0,0,117,110,101,120,112,101,99,116,101,100,32,115,121,109,98,111,108,0,0,0,0,0,0,0,108,97,98,101,108,32,39,37,115,39,32,97,108,114,101,97,100,121,32,100,101,102,105,110,101,100,32,111,110,32,108,105,110,101,32,37,100,0,0,0,39,61,39,32,111,114,32,39,105,110,39,32,101,120,112,101,99,116,101,100,0,0,0,0,40,102,111,114,32,103,101,110,101,114,97,116,111,114,41,0,40,102,111,114,32,115,116,97,116,101,41,0,0,0,0,0,40,102,111,114,32,99,111,110,116,114,111,108,41,0,0,0,40,102,111,114,32,105,110,100,101,120,41,0,0,0,0,0,40,102,111,114,32,108,105,109,105,116,41,0,0,0,0,0,40,102,111,114,32,115,116,101,112,41,0,0,0,0,0,0,37,115,32,101,120,112,101,99,116,101,100,32,40,116,111,32,99,108,111,115,101,32,37,115,32,97,116,32,108,105,110,101,32,37,100,41,0,0,0,0,117,112,118,97,108,117,101,115,0,0,0,0,0,0,0,0,110,111,116,32,101,110,111,117,103,104,32,109,101,109,111,114,121,0,0,0,0,0,0,0,144,27,0,0,64,0,0,0,152,27,0,0,65,0,0,0,160,27,0,0,66,0,0,0,168,27,0,0,67,0,0,0,176,27,0,0,68,0,0,0,184,27,0,0,69,0,0,0,192,27,0,0,70,0,0,0,200,27,0,0,71,0,0,0,208,27,0,0,72,0,0,0,216,27,0,0,73,0,0,0,224,27,0,0,74,0,0,0,232,27,0,0,75,0,0,0,240,27,0,0,76,0,0,0,248,27,0,0,77,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,95,95,105,110,100,101,120,0,98,121,116,101,0,0,0,0,99,104,97,114,0,0,0,0,100,117,109,112,0,0,0,0,102,105,110,100,0,0,0,0,102,111,114,109,97,116,0,0,103,109,97,116,99,104,0,0,103,115,117,98,0,0,0,0,108,101,110,0,0,0,0,0,108,111,119,101,114,0,0,0,109,97,116,99,104,0,0,0,114,101,112,0,0,0,0,0,114,101,118,101,114,115,101,0,115,117,98,0,0,0,0,0,117,112,112,101,114,0,0,0,114,101,115,117,108,116,105,110,103,32,115,116,114,105,110,103,32,116,111,111,32,108,97,114,103,101,0,0,0,0,0,0,116,111,111,32,109,97,110,121,32,99,97,112,116,117,114,101,115,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,99,97,112,116,117,114,101,32,105,110,100,101,120,0,0,0,117,110,102,105,110,105,115,104,101,100,32,99,97,112,116,117,114,101,0,0,0,0,0,0,112,97,116,116,101,114,110,32,116,111,111,32,99,111,109,112,108,101,120,0,0,0,0,0,109,105,115,115,105,110,103,32,39,91,39,32,97,102,116,101,114,32,39,37,37,102,39,32,105,110,32,112,97,116,116,101,114,110,0,0,0,0,0,0,105,110,118,97,108,105,100,32,99,97,112,116,117,114,101,32,105,110,100,101,120,32,37,37,37,100,0,0,0,0,0,0,109,97,108,102,111,114,109,101,100,32,112,97,116,116,101,114,110,32,40,101,110,100,115,32,119,105,116,104,32,39,37,37,39,41,0,0,0,0,0,0,109,97,108,102,111,114,109,101,100,32,112,97,116,116,101,114,110,32,40,109,105,115,115,105,110,103,32,39,93,39,41,0,109,97,108,102,111,114,109,101,100,32,112,97,116,116,101,114,110,32,40,109,105,115,115,105,110,103,32,97,114,103,117,109,101,110,116,115,32,116,111,32,39,37,37,98,39,41,0,0,105,110,118,97,108,105,100,32,112,97,116,116,101,114,110,32,99,97,112,116,117,114,101,0,94,36,42,43,63,46,40,91,37,45,0,0,0,0,0,0,115,116,114,105,110,103,47,102,117,110,99,116,105,111,110,47,116,97,98,108,101,32,101,120,112,101,99,116,101,100,0,0,105,110,118,97,108,105,100,32,114,101,112,108,97,99,101,109,101,110,116,32,118,97,108,117,101,32,40,97,32,37,115,41,0,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,117,115,101,32,111,102,32,39,37,99,39,32,105,110,32,114,101,112,108,97,99,101,109,101,110,116,32,115,116,114,105,110,103,0,0,0,0,0,0,0,110,111,32,118,97,108,117,101,0,0,0,0,0,0,0,0,110,111,116,32,97,32,110,117,109,98,101,114,32,105,110,32,112,114,111,112,101,114,32,114,97,110,103,101,0,0,0,0,110,111,116,32,97,32,110,111,110,45,110,101,103,97,116,105,118,101,32,110,117,109,98,101,114,32,105,110,32,112,114,111,112,101,114,32,114,97,110,103,101,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,111,112,116,105,111,110,32,39,37,37,37,99,39,32,116,111,32,39,102,111,114,109,97,116,39,0,0,0,0,0,0,0,92,37,100,0,0,0,0,0,92,37,48,51,100,0,0,0,45,43,32,35,48,0,0,0,105,110,118,97,108,105,100,32,102,111,114,109,97,116,32,40,114,101,112,101,97,116,101,100,32,102,108,97,103,115,41,0,105,110,118,97,108,105,100,32,102,111,114,109,97,116,32,40,119,105,100,116,104,32,111,114,32,112,114,101,99,105,115,105,111,110,32,116,111,111,32,108,111,110,103,41,0,0,0,0,117,110,97,98,108,101,32,116,111,32,100,117,109,112,32,103,105,118,101,110,32,102,117,110,99,116,105,111,110,0,0,0,118,97,108,117,101,32,111,117,116,32,111,102,32,114,97,110,103,101,0,0,0,0,0,0,115,116,114,105,110,103,32,115,108,105,99,101,32,116,111,111,32,108,111,110,103,0,0,0,116,97,98,108,101,32,105,110,100,101,120,32,105,115,32,110,105,108,0,0,0,0,0,0,116,97,98,108,101,32,105,110,100,101,120,32,105,115,32,78,97,78,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,97,98,108,101,32,111,118,101,114,102,108,111,119,0,0,105,110,118,97,108,105,100,32,107,101,121,32,116,111,32,39,110,101,120,116,39,0,0,0,224,31,0,0,78,0,0,0,232,31,0,0,79,0,0,0,240,31,0,0,80,0,0,0,248,31,0,0,81,0,0,0,216,31,0,0,82,0,0,0,0,32,0,0,83,0,0,0,8,32,0,0,84,0,0,0,0,0,0,0,0,0,0,0,117,110,112,97,99,107,0,0,99,111,110,99,97,116,0,0,109,97,120,110,0,0,0,0,105,110,115,101,114,116,0,0,112,97,99,107,0,0,0,0,114,101,109,111,118,101,0,0,115,111,114,116,0,0,0,0,0,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,111,114,100,101,114,32,102,117,110,99,116,105,111,110,32,102,111,114,32,115,111,114,116,105,110,103,0,0,0,0,0,0,112,111,115,105,116,105,111,110,32,111,117,116,32,111,102,32,98,111,117,110,100,115,0,0,116,111,111,32,109,97,110,121,32,114,101,115,117,108,116,115,32,116,111,32,117,110,112,97,99,107,0,0,0,0,0,0,110,0,0,0,0,0,0,0,119,114,111,110,103,32,110,117,109,98,101,114,32,111,102,32,97,114,103,117,109,101,110,116,115,32,116,111,32,39,105,110,115,101,114,116,39,0,0,0,105,110,118,97,108,105,100,32,118,97,108,117,101,32,40,37,115,41,32,97,116,32,105,110,100,101,120,32,37,100,32,105,110,32,116,97,98,108,101,32,102,111,114,32,39,99,111,110,99,97,116,39,0,0,0,0,110,111,32,118,97,108,117,101,0,0,0,0,0,0,0,0,110,105,108,0,0,0,0,0,98,111,111,108,101,97,110,0,117,115,101,114,100,97,116,97,0,0,0,0,0,0,0,0,110,117,109,98,101,114,0,0,115,116,114,105,110,103,0,0,116,97,98,108,101,0,0,0,102,117,110,99,116,105,111,110,0,0,0,0,0,0,0,0,116,104,114,101,97,100,0,0,112,114,111,116,111,0,0,0,117,112,118,97,108,0,0,0,224,32,0,0,240,32,0,0,248,32,0,0,0,33,0,0,16,33,0,0,24,33,0,0,32,33,0,0,40,33,0,0,0,33,0,0,56,33,0,0,64,33,0,0,72,33,0,0,200,33,0,0,208,33,0,0,224,33,0,0,232,33,0,0,240,33,0,0,248,33,0,0,0,34,0,0,8,34,0,0,16,34,0,0,24,34,0,0,32,34,0,0,40,34,0,0,48,34,0,0,56,34,0,0,64,34,0,0,72,34,0,0,88,34,0,0,0,0,0,0,95,95,105,110,100,101,120,0,95,95,110,101,119,105,110,100,101,120,0,0,0,0,0,0,95,95,103,99,0,0,0,0,95,95,109,111,100,101,0,0,95,95,108,101,110,0,0,0,95,95,101,113,0,0,0,0,95,95,97,100,100,0,0,0,95,95,115,117,98,0,0,0,95,95,109,117,108,0,0,0,95,95,100,105,118,0,0,0,95,95,109,111,100,0,0,0,95,95,112,111,119,0,0,0,95,95,117,110,109,0,0,0,95,95,108,116,0,0,0,0,95,95,108,101,0,0,0,0,95,95,99,111,110,99,97,116,0,0,0,0,0,0,0,0,95,95,99,97,108,108,0,0,98,105,110,97,114,121,32,115,116,114,105,110,103,0,0,0,25,147,13,10,26,10,0,0,116,114,117,110,99,97,116,101,100,0,0,0,0,0,0,0,37,115,58,32,37,115,32,112,114,101,99,111,109,112,105,108,101,100,32,99,104,117,110,107,0,0,0,0,0,0,0,0,99,111,114,114,117,112,116,101,100,0,0,0,0,0,0,0,110,111,116,32,97,0,0,0,118,101,114,115,105,111,110,32,109,105,115,109,97,116,99,104,32,105,110,0,0,0,0,0,105,110,99,111,109,112,97,116,105,98,108,101,0,0,0,0,37,46,49,52,103,0,0,0,105,110,100,101,120,0,0,0,108,111,111,112,32,105,110,32,103,101,116,116,97,98,108,101,0,0,0,0,0,0,0,0,108,111,111,112,32,105,110,32,115,101,116,116,97,98,108,101,0,0,0,0,0,0,0,0,115,116,114,105,110,103,32,108,101,110,103,116,104,32,111,118,101,114,102,108,111,119,0,0,103,101,116,32,108,101,110,103,116,104,32,111,102,0,0,0,39,102,111,114,39,32,105,110,105,116,105,97,108,32,118,97,108,117,101,32,109,117,115,116,32,98,101,32,97,32,110,117,109,98,101,114,0,0,0,0,39,102,111,114,39,32,108,105,109,105,116,32,109,117,115,116,32,98,101,32,97,32,110,117,109,98,101,114,0,0,0,0,39,102,111,114,39,32,115,116,101,112,32,109,117,115,116,32,98,101,32,97,32,110,117,109,98,101,114,0,0,0,0,0,95,71,0,0,0,0,0,0,152,36,0,0,85,0,0,0,160,36,0,0,86,0,0,0,176,36,0,0,87,0,0,0,184,36,0,0,88,0,0,0,192,36,0,0,89,0,0,0,208,36,0,0,90,0,0,0,216,36,0,0,91,0,0,0,232,36,0,0,92,0,0,0,240,36,0,0,92,0,0,0,0,37,0,0,93,0,0,0,8,37,0,0,94,0,0,0,16,37,0,0,95,0,0,0,24,37,0,0,96,0,0,0,32,37,0,0,97,0,0,0,48,37,0,0,98,0,0,0,56,37,0,0,99,0,0,0,64,37,0,0,100,0,0,0,72,37,0,0,101,0,0,0,80,37,0,0,102,0,0,0,96,37,0,0,103,0,0,0,112,37,0,0,104,0,0,0,128,37,0,0,105,0,0,0,136,37,0,0,106,0,0,0,0,0,0,0,0,0,0,0,76,117,97,32,53,46,50,0,95,86,69,82,83,73,79,78,0,0,0,0,0,0,0,0,97,115,115,101,114,116,0,0,99,111,108,108,101,99,116,103,97,114,98,97,103,101,0,0,100,111,102,105,108,101,0,0,101,114,114,111,114,0,0,0,103,101,116,109,101,116,97,116,97,98,108,101,0,0,0,0,105,112,97,105,114,115,0,0,108,111,97,100,102,105,108,101,0,0,0,0,0,0,0,0,108,111,97,100,0,0,0,0,108,111,97,100,115,116,114,105,110,103,0,0,0,0,0,0,110,101,120,116,0,0,0,0,112,97,105,114,115,0,0,0,112,99,97,108,108,0,0,0,112,114,105,110,116,0,0,0,114,97,119,101,113,117,97,108,0,0,0,0,0,0,0,0,114,97,119,108,101,110,0,0,114,97,119,103,101,116,0,0,114,97,119,115,101,116,0,0,115,101,108,101,99,116,0,0,115,101,116,109,101,116,97,116,97,98,108,101,0,0,0,0,116,111,110,117,109,98,101,114,0,0,0,0,0,0,0,0,116,111,115,116,114,105,110,103,0,0,0,0,0,0,0,0,116,121,112,101,0,0,0,0,120,112,99,97,108,108,0,0,118,97,108,117,101,32,101,120,112,101,99,116,101,100,0,0,115,116,97,99,107,32,111,118,101,114,102,108,111,119,0,0,98,97,115,101,32,111,117,116,32,111,102,32,114,97,110,103,101,0,0,0,0,0,0,0,32,12,10,13,9,11,0,0,110,105,108,32,111,114,32,116,97,98,108,101,32,101,120,112,101,99,116,101,100,0,0,0,95,95,109,101,116,97,116,97,98,108,101,0,0,0,0,0,99,97,110,110,111,116,32,99,104,97,110,103,101,32,97,32,112,114,111,116,101,99,116,101,100,32,109,101,116,97,116,97,98,108,101,0,0,0,0,0,105,110,100,101,120,32,111,117,116,32,111,102,32,114,97,110,103,101,0,0,0,0,0,0,116,97,98,108,101,32,111,114,32,115,116,114,105,110,103,32,101,120,112,101,99,116,101,100,0,0,0,0,0,0,0,0,39,116,111,115,116,114,105,110,103,39,32,109,117,115,116,32,114,101,116,117,114,110,32,97,32,115,116,114,105,110,103,32,116,111,32,39,112,114,105,110,116,39,0,0,0,0,0,0,95,95,112,97,105,114,115,0,98,116,0,0,0,0,0,0,61,40,108,111,97,100,41,0,116,111,111,32,109,97,110,121,32,110,101,115,116,101,100,32,102,117,110,99,116,105,111,110,115,0,0,0,0,0,0,0,114,101,97,100,101,114,32,102,117,110,99,116,105,111,110,32,109,117,115,116,32,114,101,116,117,114,110,32,97,32,115,116,114,105,110,103,0,0,0,0,95,95,105,112,97,105,114,115,0,0,0,0,0,0,0,0,40,39,0,0,48,39,0,0,56,39,0,0,64,39,0,0,72,39,0,0,80,39,0,0,96,39,0,0,112,39,0,0,128,39,0,0,144,39,0,0,160,39,0,0,0,0,0,0,115,116,111,112,0,0,0,0,114,101,115,116,97,114,116,0,99,111,108,108,101,99,116,0,99,111,117,110,116,0,0,0,115,116,101,112,0,0,0,0,115,101,116,112,97,117,115,101,0,0,0,0,0,0,0,0,115,101,116,115,116,101,112,109,117,108,0,0,0,0,0,0,115,101,116,109,97,106,111,114,105,110,99,0,0,0,0,0,105,115,114,117,110,110,105,110,103,0,0,0,0,0,0,0,103,101,110,101,114,97,116,105,111,110,97,108,0,0,0,0,105,110,99,114,101,109,101,110,116,97,108,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,5,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,11,0,0,0,0,0,0,0,37,115,0,0,0,0,0,0,97,115,115,101,114,116,105,111,110,32,102,97,105,108,101,100,33,0,0,0,0,0,0,0,104,40,0,0,107], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
+/* memory initializer */ allocate([112,40,0,0,108,0,0,0,120,40,0,0,109,0,0,0,128,40,0,0,110,0,0,0,136,40,0,0,111,0,0,0,144,40,0,0,112,0,0,0,152,40,0,0,113,0,0,0,160,40,0,0,114,0,0,0,168,40,0,0,115,0,0,0,176,40,0,0,116,0,0,0,184,40,0,0,117,0,0,0,192,40,0,0,118,0,0,0,0,0,0,0,0,0,0,0,97,114,115,104,105,102,116,0,98,97,110,100,0,0,0,0,98,110,111,116,0,0,0,0,98,111,114,0,0,0,0,0,98,120,111,114,0,0,0,0,98,116,101,115,116,0,0,0,101,120,116,114,97,99,116,0,108,114,111,116,97,116,101,0,108,115,104,105,102,116,0,0,114,101,112,108,97,99,101,0,114,114,111,116,97,116,101,0,114,115,104,105,102,116,0,0,102,105,101,108,100,32,99,97,110,110,111,116,32,98,101,32,110,101,103,97,116,105,118,101,0,0,0,0,0,0,0,0,119,105,100,116,104,32,109,117,115,116,32,98,101,32,112,111,115,105,116,105,118,101,0,0,116,114,121,105,110,103,32,116,111,32,97,99,99,101,115,115,32,110,111,110,45,101,120,105,115,116,101,110,116,32,98,105,116,115,0,0,0,0,0,0,102,117,110,99,116,105,111,110,32,111,114,32,101,120,112,114,101,115,115,105,111,110,32,116,111,111,32,99,111,109,112,108,101,120,0,0,0,0,0,0,99,111,110,115,116,114,117,99,116,111,114,32,116,111,111,32,108,111,110,103,0,0,0,0,99,111,110,115,116,97,110,116,115,0,0,0,0,0,0,0,111,112,99,111,100,101,115,0,99,111,110,116,114,111,108,32,115,116,114,117,99,116,117,114,101,32,116,111,111,32,108,111,110,103,0,0,0,0,0,0,216,41,0,0,119,0,0,0,224,41,0,0,120,0,0,0,232,41,0,0,121,0,0,0,240,41,0,0,122,0,0,0,248,41,0,0,123,0,0,0,0,42,0,0,124,0,0,0,0,0,0,0,0,0,0,0,99,114,101,97,116,101,0,0,114,101,115,117,109,101,0,0,114,117,110,110,105,110,103,0,115,116,97,116,117,115,0,0,119,114,97,112,0,0,0,0,121,105,101,108,100,0,0,0,116,111,111,32,109,97,110,121,32,97,114,103,117,109,101,110,116,115,32,116,111,32,114,101,115,117,109,101,0,0,0,0,99,97,110,110,111,116,32,114,101,115,117,109,101,32,100,101,97,100,32,99,111,114,111,117,116,105,110,101,0,0,0,0,116,111,111,32,109,97,110,121,32,114,101,115,117,108,116,115,32,116,111,32,114,101,115,117,109,101,0,0,0,0,0,0,99,111,114,111,117,116,105,110,101,32,101,120,112,101,99,116,101,100,0,0,0,0,0,0,115,117,115,112,101,110,100,101,100,0,0,0,0,0,0,0,110,111,114,109,97,108,0,0,100,101,97,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,8,8,8,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,22,22,22,22,22,22,22,22,22,22,4,4,4,4,4,4,4,21,21,21,21,21,21,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,5,4,21,21,21,21,21,21,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,44,0,0,125,0,0,0,56,44,0,0,126,0,0,0,72,44,0,0,127,0,0,0,80,44,0,0,128,0,0,0,88,44,0,0,129,0,0,0,104,44,0,0,130,0,0,0,120,44,0,0,131,0,0,0,136,44,0,0,132,0,0,0,152,44,0,0,133,0,0,0,168,44,0,0,134,0,0,0,184,44,0,0,135,0,0,0,200,44,0,0,136,0,0,0,208,44,0,0,137,0,0,0,224,44,0,0,138,0,0,0,240,44,0,0,139,0,0,0,0,45,0,0,140,0,0,0,0,0,0,0,0,0,0,0,100,101,98,117,103,0,0,0,103,101,116,117,115,101,114,118,97,108,117,101,0,0,0,0,103,101,116,104,111,111,107,0,103,101,116,105,110,102,111,0,103,101,116,108,111,99,97,108,0,0,0,0,0,0,0,0,103,101,116,114,101,103,105,115,116,114,121,0,0,0,0,0,103,101,116,109,101,116,97,116,97,98,108,101,0,0,0,0,103,101,116,117,112,118,97,108,117,101,0,0,0,0,0,0,117,112,118,97,108,117,101,106,111,105,110,0,0,0,0,0,117,112,118,97,108,117,101,105,100,0,0,0,0,0,0,0,115,101,116,117,115,101,114,118,97,108,117,101,0,0,0,0,115,101,116,104,111,111,107,0,115,101,116,108,111,99,97,108,0,0,0,0,0,0,0,0,115,101,116,109,101,116,97,116,97,98,108,101,0,0,0,0,115,101,116,117,112,118,97,108,117,101,0,0,0,0,0,0,116,114,97,99,101,98,97,99,107,0,0,0,0,0,0,0,110,105,108,32,111,114,32,116,97,98,108,101,32,101,120,112,101,99,116,101,100,0,0,0,108,101,118,101,108,32,111,117,116,32,111,102,32,114,97,110,103,101,0,0,0,0,0,0,95,72,75,69,89,0,0,0,107,0,0,0,0,0,0,0,95,95,109,111,100,101,0,0,112,45,0,0,120,45,0,0,128,45,0,0,136,45,0,0,144,45,0,0,0,0,0,0,99,97,108,108,0,0,0,0,114,101,116,117,114,110,0,0,108,105,110,101,0,0,0,0,99,111,117,110,116,0,0,0,116,97,105,108,32,99,97,108,108,0,0,0,0,0,0,0,102,117,108,108,32,117,115,101,114,100,97,116,97,32,101,120,112,101,99,116,101,100,44,32,103,111,116,32,108,105,103,104,116,32,117,115,101,114,100,97,116,97,0,0,0,0,0,0,62,117,0,0,0,0,0,0,105,110,118,97,108,105,100,32,117,112,118,97,108,117,101,32,105,110,100,101,120,0,0,0,76,117,97,32,102,117,110,99,116,105,111,110,32,101,120,112,101,99,116,101,100,0,0,0,102,108,110,83,116,117,0,0,62,37,115,0,0,0,0,0,102,117,110,99,116,105,111,110,32,111,114,32,108,101,118,101,108,32,101,120,112,101,99,116,101,100,0,0,0,0,0,0,105,110,118,97,108,105,100,32,111,112,116,105,111,110,0,0,115,111,117,114,99,101,0,0,115,104,111,114,116,95,115,114,99,0,0,0,0,0,0,0,108,105,110,101,100,101,102,105,110,101,100,0,0,0,0,0,108,97,115,116,108,105,110,101,100,101,102,105,110,101,100,0,119,104,97,116,0,0,0,0,99,117,114,114,101,110,116,108,105,110,101,0,0,0,0,0,110,117,112,115,0,0,0,0,110,112,97,114,97,109,115,0,105,115,118,97,114,97,114,103,0,0,0,0,0,0,0,0,110,97,109,101,0,0,0,0,110,97,109,101,119,104,97,116,0,0,0,0,0,0,0,0,105,115,116,97,105,108,99,97,108,108,0,0,0,0,0,0,97,99,116,105,118,101,108,105,110,101,115,0,0,0,0,0,102,117,110,99,0,0,0,0,101,120,116,101,114,110,97,108,32,104,111,111,107,0,0,0,108,117,97,95,100,101,98,117,103,62,32,0,0,0,0,0,99,111,110,116,10,0,0,0,61,40,100,101,98,117,103,32,99,111,109,109,97,110,100,41,0,0,0,0,0,0,0,0,37,115,10,0,0,0,0,0,80,49,0,0,88,49,0,0,96,49,0,0,104,49,0,0,112,49,0,0,120,49,0,0,128,49,0,0,136,49,0,0,144,49,0,0,160,49,0,0,168,49,0,0,176,49,0,0,184,49,0,0,192,49,0,0,200,49,0,0,208,49,0,0,216,49,0,0,224,49,0,0,232,49,0,0,240,49,0,0,248,49,0,0,0,50,0,0,8,50,0,0,16,50,0,0,24,50,0,0,32,50,0,0,40,50,0,0,48,50,0,0,56,50,0,0,64,50,0,0,72,50,0,0,88,50,0,0,96,50,0,0,0,0,0,0,39,37,99,39,0,0,0,0,99,104,97,114,40,37,100,41,0,0,0,0,0,0,0,0,39,37,115,39,0,0,0,0,95,69,78,86,0,0,0,0,105,110,118,97,108,105,100,32,108,111,110,103,32,115,116,114,105,110,103,32,100,101,108,105,109,105,116,101,114,0,0,0,46,0,0,0,0,0,0,0,69,101,0,0,0,0,0,0,88,120,0,0,0,0,0,0,80,112,0,0,0,0,0,0,43,45,0,0,0,0,0,0,109,97,108,102,111,114,109,101,100,32,110,117,109,98,101,114,0,0,0,0,0,0,0,0,108,101,120,105,99,97,108,32,101,108,101,109,101,110,116,32,116,111,111,32,108,111,110,103,0,0,0,0,0,0,0,0,117,110,102,105,110,105,115,104,101,100,32,115,116,114,105,110,103,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,101,115,99,97,112,101,32,115,101,113,117,101,110,99,101,0,100,101,99,105,109,97,108,32,101,115,99,97,112,101,32,116,111,111,32,108,97,114,103,101,0,0,0,0,0,0,0,0,104,101,120,97,100,101,99,105,109,97,108,32,100,105,103,105,116,32,101,120,112,101,99,116,101,100,0,0,0,0,0,0,117,110,102,105,110,105,115,104,101,100,32,108,111,110,103,32,115,116,114,105,110,103,0,0,117,110,102,105,110,105,115,104,101,100,32,108,111,110,103,32,99,111,109,109,101,110,116,0,99,104,117,110,107,32,104,97,115,32,116,111,111,32,109,97,110,121,32,108,105,110,101,115,0,0,0,0,0,0,0,0,37,115,58,37,100,58,32,37,115,0,0,0,0,0,0,0,37,115,32,110,101,97,114,32,37,115,0,0,0,0,0,0,97,110,100,0,0,0,0,0,98,114,101,97,107,0,0,0,100,111,0,0,0,0,0,0,101,108,115,101,0,0,0,0,101,108,115,101,105,102,0,0,101,110,100,0,0,0,0,0,102,97,108,115,101,0,0,0,102,111,114,0,0,0,0,0,102,117,110,99,116,105,111,110,0,0,0,0,0,0,0,0,103,111,116,111,0,0,0,0,105,102,0,0,0,0,0,0,105,110,0,0,0,0,0,0,108,111,99,97,108,0,0,0,110,105,108,0,0,0,0,0,110,111,116,0,0,0,0,0,111,114,0,0,0,0,0,0,114,101,112,101,97,116,0,0,114,101,116,117,114,110,0,0,116,104,101,110,0,0,0,0,116,114,117,101,0,0,0,0,117,110,116,105,108,0,0,0,119,104,105,108,101,0,0,0,46,46,0,0,0,0,0,0,46,46,46,0,0,0,0,0,61,61,0,0,0,0,0,0,62,61,0,0,0,0,0,0,60,61,0,0,0,0,0,0,126,61,0,0,0,0,0,0,58,58,0,0,0,0,0,0,60,101,111,102,62,0,0,0,60,110,117,109,98,101,114,62,0,0,0,0,0,0,0,0,60,110,97,109,101,62,0,0,60,115,116,114,105,110,103,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,105,110,102,105,110,105,116,121,0,0,0,0,0,0,0,0,110,97,110,0,0,0,0,0,95,112,137,0,255,9,47,15,10,0,0,0,100,0,0,0,232,3,0,0,16,39,0,0,160,134,1,0,64,66,15,0,128,150,152,0,0,225,245,5], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE+10240);
+
+
+
+
+var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8);
+
+assert(tempDoublePtr % 8 == 0);
+
+function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+}
+
+function copyTempDouble(ptr) {
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+ HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
+
+ HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
+
+ HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
+
+ HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
+
+}
+
+
+
+
+ Module["_rand_r"] = _rand_r;
+
+ var ___rand_seed=allocate([0x0273459b, 0, 0, 0], "i32", ALLOC_STATIC);
+ Module["_rand"] = _rand;
+
+
+
+ var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};
+
+ var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
+
+
+ var ___errno_state=0;function ___setErrNo(value) {
+ // For convenient setting and returning of errno.
+ HEAP32[((___errno_state)>>2)]=value;
+ return value;
+ }
+
+ var PATH={splitPath:function (filename) {
+ var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
+ return splitPathRe.exec(filename).slice(1);
+ },normalizeArray:function (parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length - 1; i >= 0; i--) {
+ var last = parts[i];
+ if (last === '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+ return parts;
+ },normalize:function (path) {
+ var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.substr(-1) === '/';
+ // Normalize the path
+ path = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+ return (isAbsolute ? '/' : '') + path;
+ },dirname:function (path) {
+ var result = PATH.splitPath(path),
+ root = result[0],
+ dir = result[1];
+ if (!root && !dir) {
+ // No dirname whatsoever
+ return '.';
+ }
+ if (dir) {
+ // It has a dirname, strip trailing slash
+ dir = dir.substr(0, dir.length - 1);
+ }
+ return root + dir;
+ },basename:function (path) {
+ // EMSCRIPTEN return '/'' for '/', not an empty string
+ if (path === '/') return '/';
+ var lastSlash = path.lastIndexOf('/');
+ if (lastSlash === -1) return path;
+ return path.substr(lastSlash+1);
+ },extname:function (path) {
+ return PATH.splitPath(path)[3];
+ },join:function () {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return PATH.normalize(paths.join('/'));
+ },join2:function (l, r) {
+ return PATH.normalize(l + '/' + r);
+ },resolve:function () {
+ var resolvedPath = '',
+ resolvedAbsolute = false;
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0) ? arguments[i] : FS.cwd();
+ // Skip empty and invalid entries
+ if (typeof path !== 'string') {
+ throw new TypeError('Arguments to path.resolve must be strings');
+ } else if (!path) {
+ continue;
+ }
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+ }
+ // At this point the path should be resolved to a full absolute path, but
+ // handle relative paths to be safe (might happen when process.cwd() fails)
+ resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+ },relative:function (from, to) {
+ from = PATH.resolve(from).substr(1);
+ to = PATH.resolve(to).substr(1);
+ function trim(arr) {
+ var start = 0;
+ for (; start < arr.length; start++) {
+ if (arr[start] !== '') break;
+ }
+ var end = arr.length - 1;
+ for (; end >= 0; end--) {
+ if (arr[end] !== '') break;
+ }
+ if (start > end) return [];
+ return arr.slice(start, end - start + 1);
+ }
+ var fromParts = trim(from.split('/'));
+ var toParts = trim(to.split('/'));
+ var length = Math.min(fromParts.length, toParts.length);
+ var samePartsLength = length;
+ for (var i = 0; i < length; i++) {
+ if (fromParts[i] !== toParts[i]) {
+ samePartsLength = i;
+ break;
+ }
+ }
+ var outputParts = [];
+ for (var i = samePartsLength; i < fromParts.length; i++) {
+ outputParts.push('..');
+ }
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
+ return outputParts.join('/');
+ }};
+
+ var TTY={ttys:[],init:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // currently, FS.init does not distinguish if process.stdin is a file or TTY
+ // // device, it always assumes it's a TTY device. because of this, we're forcing
+ // // process.stdin to UTF8 encoding to at least make stdin reading compatible
+ // // with text files until FS.init can be refactored.
+ // process['stdin']['setEncoding']('utf8');
+ // }
+ },shutdown:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
+ // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
+ // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
+ // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
+ // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
+ // process['stdin']['pause']();
+ // }
+ },register:function (dev, ops) {
+ TTY.ttys[dev] = { input: [], output: [], ops: ops };
+ FS.registerDevice(dev, TTY.stream_ops);
+ },stream_ops:{open:function (stream) {
+ var tty = TTY.ttys[stream.node.rdev];
+ if (!tty) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ stream.tty = tty;
+ stream.seekable = false;
+ },close:function (stream) {
+ // flush any pending line data
+ if (stream.tty.output.length) {
+ stream.tty.ops.put_char(stream.tty, 10);
+ }
+ },read:function (stream, buffer, offset, length, pos /* ignored */) {
+ if (!stream.tty || !stream.tty.ops.get_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = stream.tty.ops.get_char(stream.tty);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, pos) {
+ if (!stream.tty || !stream.tty.ops.put_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ for (var i = 0; i < length; i++) {
+ try {
+ stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }},default_tty_ops:{get_char:function (tty) {
+ if (!tty.input.length) {
+ var result = null;
+ if (ENVIRONMENT_IS_NODE) {
+ result = process['stdin']['read']();
+ if (!result) {
+ if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
+ return null; // EOF
+ }
+ return undefined; // no data available
+ }
+ } else if (typeof window != 'undefined' &&
+ typeof window.prompt == 'function') {
+ // Browser.
+ result = window.prompt('Input: '); // returns null on cancel
+ if (result !== null) {
+ result += '\n';
+ }
+ } else if (typeof readline == 'function') {
+ // Command line.
+ result = readline();
+ if (result !== null) {
+ result += '\n';
+ }
+ }
+ if (!result) {
+ return null;
+ }
+ tty.input = intArrayFromString(result, true);
+ }
+ return tty.input.shift();
+ },put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['print'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }},default_tty1_ops:{put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['printErr'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }}};
+
+ var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
+ return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
+ // no supported
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (!MEMFS.ops_table) {
+ MEMFS.ops_table = {
+ dir: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ lookup: MEMFS.node_ops.lookup,
+ mknod: MEMFS.node_ops.mknod,
+ rename: MEMFS.node_ops.rename,
+ unlink: MEMFS.node_ops.unlink,
+ rmdir: MEMFS.node_ops.rmdir,
+ readdir: MEMFS.node_ops.readdir,
+ symlink: MEMFS.node_ops.symlink
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek
+ }
+ },
+ file: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek,
+ read: MEMFS.stream_ops.read,
+ write: MEMFS.stream_ops.write,
+ allocate: MEMFS.stream_ops.allocate,
+ mmap: MEMFS.stream_ops.mmap
+ }
+ },
+ link: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ readlink: MEMFS.node_ops.readlink
+ },
+ stream: {}
+ },
+ chrdev: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: FS.chrdev_stream_ops
+ },
+ };
+ }
+ var node = FS.createNode(parent, name, mode, dev);
+ if (FS.isDir(node.mode)) {
+ node.node_ops = MEMFS.ops_table.dir.node;
+ node.stream_ops = MEMFS.ops_table.dir.stream;
+ node.contents = {};
+ } else if (FS.isFile(node.mode)) {
+ node.node_ops = MEMFS.ops_table.file.node;
+ node.stream_ops = MEMFS.ops_table.file.stream;
+ node.contents = [];
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ } else if (FS.isLink(node.mode)) {
+ node.node_ops = MEMFS.ops_table.link.node;
+ node.stream_ops = MEMFS.ops_table.link.stream;
+ } else if (FS.isChrdev(node.mode)) {
+ node.node_ops = MEMFS.ops_table.chrdev.node;
+ node.stream_ops = MEMFS.ops_table.chrdev.stream;
+ }
+ node.timestamp = Date.now();
+ // add the new node to the parent
+ if (parent) {
+ parent.contents[name] = node;
+ }
+ return node;
+ },ensureFlexible:function (node) {
+ if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
+ var contents = node.contents;
+ node.contents = Array.prototype.slice.call(contents);
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ }
+ },node_ops:{getattr:function (node) {
+ var attr = {};
+ // device numbers reuse inode numbers.
+ attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
+ attr.ino = node.id;
+ attr.mode = node.mode;
+ attr.nlink = 1;
+ attr.uid = 0;
+ attr.gid = 0;
+ attr.rdev = node.rdev;
+ if (FS.isDir(node.mode)) {
+ attr.size = 4096;
+ } else if (FS.isFile(node.mode)) {
+ attr.size = node.contents.length;
+ } else if (FS.isLink(node.mode)) {
+ attr.size = node.link.length;
+ } else {
+ attr.size = 0;
+ }
+ attr.atime = new Date(node.timestamp);
+ attr.mtime = new Date(node.timestamp);
+ attr.ctime = new Date(node.timestamp);
+ // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
+ // but this is not required by the standard.
+ attr.blksize = 4096;
+ attr.blocks = Math.ceil(attr.size / attr.blksize);
+ return attr;
+ },setattr:function (node, attr) {
+ if (attr.mode !== undefined) {
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ node.timestamp = attr.timestamp;
+ }
+ if (attr.size !== undefined) {
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ if (attr.size < contents.length) contents.length = attr.size;
+ else while (attr.size > contents.length) contents.push(0);
+ }
+ },lookup:function (parent, name) {
+ throw FS.genericErrors[ERRNO_CODES.ENOENT];
+ },mknod:function (parent, name, mode, dev) {
+ return MEMFS.createNode(parent, name, mode, dev);
+ },rename:function (old_node, new_dir, new_name) {
+ // if we're overwriting a directory at new_name, make sure it's empty.
+ if (FS.isDir(old_node.mode)) {
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ }
+ if (new_node) {
+ for (var i in new_node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ }
+ }
+ // do the internal rewiring
+ delete old_node.parent.contents[old_node.name];
+ old_node.name = new_name;
+ new_dir.contents[new_name] = old_node;
+ old_node.parent = new_dir;
+ },unlink:function (parent, name) {
+ delete parent.contents[name];
+ },rmdir:function (parent, name) {
+ var node = FS.lookupNode(parent, name);
+ for (var i in node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ delete parent.contents[name];
+ },readdir:function (node) {
+ var entries = ['.', '..']
+ for (var key in node.contents) {
+ if (!node.contents.hasOwnProperty(key)) {
+ continue;
+ }
+ entries.push(key);
+ }
+ return entries;
+ },symlink:function (parent, newname, oldpath) {
+ var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
+ node.link = oldpath;
+ return node;
+ },readlink:function (node) {
+ if (!FS.isLink(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return node.link;
+ }},stream_ops:{read:function (stream, buffer, offset, length, position) {
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (size > 8 && contents.subarray) { // non-trivial, and typed array
+ buffer.set(contents.subarray(position, position + size), offset);
+ } else
+ {
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ }
+ return size;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ var node = stream.node;
+ node.timestamp = Date.now();
+ var contents = node.contents;
+ if (length && contents.length === 0 && position === 0 && buffer.subarray) {
+ // just replace it with the new data
+ if (canOwn && offset === 0) {
+ node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
+ node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
+ } else {
+ node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
+ node.contentMode = MEMFS.CONTENT_FIXED;
+ }
+ return length;
+ }
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ while (contents.length < position) contents.push(0);
+ for (var i = 0; i < length; i++) {
+ contents[position + i] = buffer[offset + i];
+ }
+ return length;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ position += stream.node.contents.length;
+ }
+ }
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ stream.ungotten = [];
+ stream.position = position;
+ return position;
+ },allocate:function (stream, offset, length) {
+ MEMFS.ensureFlexible(stream.node);
+ var contents = stream.node.contents;
+ var limit = offset + length;
+ while (limit > contents.length) contents.push(0);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ if (!FS.isFile(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ var ptr;
+ var allocated;
+ var contents = stream.node.contents;
+ // Only make a new copy when MAP_PRIVATE is specified.
+ if ( !(flags & 2) &&
+ (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
+ // We can't emulate MAP_SHARED when the file is not backed by the buffer
+ // we're mapping to (e.g. the HEAP buffer).
+ allocated = false;
+ ptr = contents.byteOffset;
+ } else {
+ // Try to avoid unnecessary slices.
+ if (position > 0 || position + length < contents.length) {
+ if (contents.subarray) {
+ contents = contents.subarray(position, position + length);
+ } else {
+ contents = Array.prototype.slice.call(contents, position, position + length);
+ }
+ }
+ allocated = true;
+ ptr = _malloc(length);
+ if (!ptr) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
+ }
+ buffer.set(contents, ptr);
+ }
+ return { ptr: ptr, allocated: allocated };
+ }}};
+
+ var IDBFS={dbs:{},indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
+ // reuse all of the core MEMFS functionality
+ return MEMFS.mount.apply(null, arguments);
+ },syncfs:function (mount, populate, callback) {
+ IDBFS.getLocalSet(mount, function(err, local) {
+ if (err) return callback(err);
+
+ IDBFS.getRemoteSet(mount, function(err, remote) {
+ if (err) return callback(err);
+
+ var src = populate ? remote : local;
+ var dst = populate ? local : remote;
+
+ IDBFS.reconcile(src, dst, callback);
+ });
+ });
+ },getDB:function (name, callback) {
+ // check the cache first
+ var db = IDBFS.dbs[name];
+ if (db) {
+ return callback(null, db);
+ }
+
+ var req;
+ try {
+ req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
+ } catch (e) {
+ return callback(e);
+ }
+ req.onupgradeneeded = function(e) {
+ var db = e.target.result;
+ var transaction = e.target.transaction;
+
+ var fileStore;
+
+ if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
+ fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ } else {
+ fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
+ }
+
+ fileStore.createIndex('timestamp', 'timestamp', { unique: false });
+ };
+ req.onsuccess = function() {
+ db = req.result;
+
+ // add to the cache
+ IDBFS.dbs[name] = db;
+ callback(null, db);
+ };
+ req.onerror = function() {
+ callback(this.error);
+ };
+ },getLocalSet:function (mount, callback) {
+ var entries = {};
+
+ function isRealDir(p) {
+ return p !== '.' && p !== '..';
+ };
+ function toAbsolute(root) {
+ return function(p) {
+ return PATH.join2(root, p);
+ }
+ };
+
+ var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
+
+ while (check.length) {
+ var path = check.pop();
+ var stat;
+
+ try {
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
+ }
+
+ entries[path] = { timestamp: stat.mtime };
+ }
+
+ return callback(null, { type: 'local', entries: entries });
+ },getRemoteSet:function (mount, callback) {
+ var entries = {};
+
+ IDBFS.getDB(mount.mountpoint, function(err, db) {
+ if (err) return callback(err);
+
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
+ transaction.onerror = function() { callback(this.error); };
+
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ var index = store.index('timestamp');
+
+ index.openKeyCursor().onsuccess = function(event) {
+ var cursor = event.target.result;
+
+ if (!cursor) {
+ return callback(null, { type: 'remote', db: db, entries: entries });
+ }
+
+ entries[cursor.primaryKey] = { timestamp: cursor.key };
+
+ cursor.continue();
+ };
+ });
+ },loadLocalEntry:function (path, callback) {
+ var stat, node;
+
+ try {
+ var lookup = FS.lookupPath(path);
+ node = lookup.node;
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode });
+ } else if (FS.isFile(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+ },storeLocalEntry:function (path, entry, callback) {
+ try {
+ if (FS.isDir(entry.mode)) {
+ FS.mkdir(path, entry.mode);
+ } else if (FS.isFile(entry.mode)) {
+ FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+
+ FS.utime(path, entry.timestamp, entry.timestamp);
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },removeLocalEntry:function (path, callback) {
+ try {
+ var lookup = FS.lookupPath(path);
+ var stat = FS.stat(path);
+
+ if (FS.isDir(stat.mode)) {
+ FS.rmdir(path);
+ } else if (FS.isFile(stat.mode)) {
+ FS.unlink(path);
+ }
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },loadRemoteEntry:function (store, path, callback) {
+ var req = store.get(path);
+ req.onsuccess = function(event) { callback(null, event.target.result); };
+ req.onerror = function() { callback(this.error); };
+ },storeRemoteEntry:function (store, path, entry, callback) {
+ var req = store.put(entry, path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },removeRemoteEntry:function (store, path, callback) {
+ var req = store.delete(path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },reconcile:function (src, dst, callback) {
+ var total = 0;
+
+ var create = [];
+ Object.keys(src.entries).forEach(function (key) {
+ var e = src.entries[key];
+ var e2 = dst.entries[key];
+ if (!e2 || e.timestamp > e2.timestamp) {
+ create.push(key);
+ total++;
+ }
+ });
+
+ var remove = [];
+ Object.keys(dst.entries).forEach(function (key) {
+ var e = dst.entries[key];
+ var e2 = src.entries[key];
+ if (!e2) {
+ remove.push(key);
+ total++;
+ }
+ });
+
+ if (!total) {
+ return callback(null);
+ }
+
+ var errored = false;
+ var completed = 0;
+ var db = src.type === 'remote' ? src.db : dst.db;
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= total) {
+ return callback(null);
+ }
+ };
+
+ transaction.onerror = function() { done(this.error); };
+
+ // sort paths in ascending order so directory entries are created
+ // before the files inside them
+ create.sort().forEach(function (path) {
+ if (dst.type === 'local') {
+ IDBFS.loadRemoteEntry(store, path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeLocalEntry(path, entry, done);
+ });
+ } else {
+ IDBFS.loadLocalEntry(path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeRemoteEntry(store, path, entry, done);
+ });
+ }
+ });
+
+ // sort paths in descending order so files are deleted before their
+ // parent directories
+ remove.sort().reverse().forEach(function(path) {
+ if (dst.type === 'local') {
+ IDBFS.removeLocalEntry(path, done);
+ } else {
+ IDBFS.removeRemoteEntry(store, path, done);
+ }
+ });
+ }};
+
+ var NODEFS={isWindows:false,staticInit:function () {
+ NODEFS.isWindows = !!process.platform.match(/^win/);
+ },mount:function (mount) {
+ assert(ENVIRONMENT_IS_NODE);
+ return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node = FS.createNode(parent, name, mode);
+ node.node_ops = NODEFS.node_ops;
+ node.stream_ops = NODEFS.stream_ops;
+ return node;
+ },getMode:function (path) {
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ if (NODEFS.isWindows) {
+ // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so
+ // propagate write bits to execute bits.
+ stat.mode = stat.mode | ((stat.mode & 146) >> 1);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return stat.mode;
+ },realPath:function (node) {
+ var parts = [];
+ while (node.parent !== node) {
+ parts.push(node.name);
+ node = node.parent;
+ }
+ parts.push(node.mount.opts.root);
+ parts.reverse();
+ return PATH.join.apply(null, parts);
+ },flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function (flags) {
+ if (flags in NODEFS.flagsToPermissionStringMap) {
+ return NODEFS.flagsToPermissionStringMap[flags];
+ } else {
+ return flags;
+ }
+ },node_ops:{getattr:function (node) {
+ var path = NODEFS.realPath(node);
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
+ // See http://support.microsoft.com/kb/140365
+ if (NODEFS.isWindows && !stat.blksize) {
+ stat.blksize = 4096;
+ }
+ if (NODEFS.isWindows && !stat.blocks) {
+ stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
+ }
+ return {
+ dev: stat.dev,
+ ino: stat.ino,
+ mode: stat.mode,
+ nlink: stat.nlink,
+ uid: stat.uid,
+ gid: stat.gid,
+ rdev: stat.rdev,
+ size: stat.size,
+ atime: stat.atime,
+ mtime: stat.mtime,
+ ctime: stat.ctime,
+ blksize: stat.blksize,
+ blocks: stat.blocks
+ };
+ },setattr:function (node, attr) {
+ var path = NODEFS.realPath(node);
+ try {
+ if (attr.mode !== undefined) {
+ fs.chmodSync(path, attr.mode);
+ // update the common node structure mode as well
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ var date = new Date(attr.timestamp);
+ fs.utimesSync(path, date, date);
+ }
+ if (attr.size !== undefined) {
+ fs.truncateSync(path, attr.size);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },lookup:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ var mode = NODEFS.getMode(path);
+ return NODEFS.createNode(parent, name, mode);
+ },mknod:function (parent, name, mode, dev) {
+ var node = NODEFS.createNode(parent, name, mode, dev);
+ // create the backing node for this in the fs root as well
+ var path = NODEFS.realPath(node);
+ try {
+ if (FS.isDir(node.mode)) {
+ fs.mkdirSync(path, node.mode);
+ } else {
+ fs.writeFileSync(path, '', { mode: node.mode });
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return node;
+ },rename:function (oldNode, newDir, newName) {
+ var oldPath = NODEFS.realPath(oldNode);
+ var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
+ try {
+ fs.renameSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },unlink:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.unlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },rmdir:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.rmdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readdir:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },symlink:function (parent, newName, oldPath) {
+ var newPath = PATH.join2(NODEFS.realPath(parent), newName);
+ try {
+ fs.symlinkSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readlink:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }},stream_ops:{open:function (stream) {
+ var path = NODEFS.realPath(stream.node);
+ try {
+ if (FS.isFile(stream.node.mode)) {
+ stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },close:function (stream) {
+ try {
+ if (FS.isFile(stream.node.mode) && stream.nfd) {
+ fs.closeSync(stream.nfd);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },read:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(length);
+ var res;
+ try {
+ res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ if (res > 0) {
+ for (var i = 0; i < res; i++) {
+ buffer[offset + i] = nbuffer[i];
+ }
+ }
+ return res;
+ },write:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
+ var res;
+ try {
+ res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return res;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ try {
+ var stat = fs.fstatSync(stream.nfd);
+ position += stat.size;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }
+ }
+
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ stream.position = position;
+ return position;
+ }}};
+
+ var _stdin=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stdout=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stderr=allocate(1, "i32*", ALLOC_STATIC);
+
+ function _fflush(stream) {
+ // int fflush(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html
+ // we don't currently perform any user-space buffering of data
+ }var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},handleFSError:function (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
+ return ___setErrNo(e.errno);
+ },lookupPath:function (path, opts) {
+ path = PATH.resolve(FS.cwd(), path);
+ opts = opts || {};
+
+ var defaults = {
+ follow_mount: true,
+ recurse_count: 0
+ };
+ for (var key in defaults) {
+ if (opts[key] === undefined) {
+ opts[key] = defaults[key];
+ }
+ }
+
+ if (opts.recurse_count > 8) { // max recursive lookup of 8
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+
+ // split the path
+ var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), false);
+
+ // start at the root
+ var current = FS.root;
+ var current_path = '/';
+
+ for (var i = 0; i < parts.length; i++) {
+ var islast = (i === parts.length-1);
+ if (islast && opts.parent) {
+ // stop resolving
+ break;
+ }
+
+ current = FS.lookupNode(current, parts[i]);
+ current_path = PATH.join2(current_path, parts[i]);
+
+ // jump to the mount's root node if this is a mountpoint
+ if (FS.isMountpoint(current)) {
+ if (!islast || (islast && opts.follow_mount)) {
+ current = current.mounted.root;
+ }
+ }
+
+ // by default, lookupPath will not follow a symlink if it is the final path component.
+ // setting opts.follow = true will override this behavior.
+ if (!islast || opts.follow) {
+ var count = 0;
+ while (FS.isLink(current.mode)) {
+ var link = FS.readlink(current_path);
+ current_path = PATH.resolve(PATH.dirname(current_path), link);
+
+ var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
+ current = lookup.node;
+
+ if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+ }
+ }
+ }
+
+ return { path: current_path, node: current };
+ },getPath:function (node) {
+ var path;
+ while (true) {
+ if (FS.isRoot(node)) {
+ var mount = node.mount.mountpoint;
+ if (!path) return mount;
+ return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
+ }
+ path = path ? node.name + '/' + path : node.name;
+ node = node.parent;
+ }
+ },hashName:function (parentid, name) {
+ var hash = 0;
+
+
+ for (var i = 0; i < name.length; i++) {
+ hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
+ }
+ return ((parentid + hash) >>> 0) % FS.nameTable.length;
+ },hashAddNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ node.name_next = FS.nameTable[hash];
+ FS.nameTable[hash] = node;
+ },hashRemoveNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ if (FS.nameTable[hash] === node) {
+ FS.nameTable[hash] = node.name_next;
+ } else {
+ var current = FS.nameTable[hash];
+ while (current) {
+ if (current.name_next === node) {
+ current.name_next = node.name_next;
+ break;
+ }
+ current = current.name_next;
+ }
+ }
+ },lookupNode:function (parent, name) {
+ var err = FS.mayLookup(parent);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ var hash = FS.hashName(parent.id, name);
+ for (var node = FS.nameTable[hash]; node; node = node.name_next) {
+ var nodeName = node.name;
+ if (node.parent.id === parent.id && nodeName === name) {
+ return node;
+ }
+ }
+ // if we failed to find it in the cache, call into the VFS
+ return FS.lookup(parent, name);
+ },createNode:function (parent, name, mode, rdev) {
+ if (!FS.FSNode) {
+ FS.FSNode = function(parent, name, mode, rdev) {
+ if (!parent) {
+ parent = this; // root node sets parent to itself
+ }
+ this.parent = parent;
+ this.mount = parent.mount;
+ this.mounted = null;
+ this.id = FS.nextInode++;
+ this.name = name;
+ this.mode = mode;
+ this.node_ops = {};
+ this.stream_ops = {};
+ this.rdev = rdev;
+ };
+
+ FS.FSNode.prototype = {};
+
+ // compatibility
+ var readMode = 292 | 73;
+ var writeMode = 146;
+
+ // NOTE we must use Object.defineProperties instead of individual calls to
+ // Object.defineProperty in order to make closure compiler happy
+ Object.defineProperties(FS.FSNode.prototype, {
+ read: {
+ get: function() { return (this.mode & readMode) === readMode; },
+ set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
+ },
+ write: {
+ get: function() { return (this.mode & writeMode) === writeMode; },
+ set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
+ },
+ isFolder: {
+ get: function() { return FS.isDir(this.mode); },
+ },
+ isDevice: {
+ get: function() { return FS.isChrdev(this.mode); },
+ },
+ });
+ }
+
+ var node = new FS.FSNode(parent, name, mode, rdev);
+
+ FS.hashAddNode(node);
+
+ return node;
+ },destroyNode:function (node) {
+ FS.hashRemoveNode(node);
+ },isRoot:function (node) {
+ return node === node.parent;
+ },isMountpoint:function (node) {
+ return !!node.mounted;
+ },isFile:function (mode) {
+ return (mode & 61440) === 32768;
+ },isDir:function (mode) {
+ return (mode & 61440) === 16384;
+ },isLink:function (mode) {
+ return (mode & 61440) === 40960;
+ },isChrdev:function (mode) {
+ return (mode & 61440) === 8192;
+ },isBlkdev:function (mode) {
+ return (mode & 61440) === 24576;
+ },isFIFO:function (mode) {
+ return (mode & 61440) === 4096;
+ },isSocket:function (mode) {
+ return (mode & 49152) === 49152;
+ },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
+ var flags = FS.flagModes[str];
+ if (typeof flags === 'undefined') {
+ throw new Error('Unknown file open mode: ' + str);
+ }
+ return flags;
+ },flagsToPermissionString:function (flag) {
+ var accmode = flag & 2097155;
+ var perms = ['r', 'w', 'rw'][accmode];
+ if ((flag & 512)) {
+ perms += 'w';
+ }
+ return perms;
+ },nodePermissions:function (node, perms) {
+ if (FS.ignorePermissions) {
+ return 0;
+ }
+ // return 0 if any user, group or owner bits are set.
+ if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
+ return ERRNO_CODES.EACCES;
+ }
+ return 0;
+ },mayLookup:function (dir) {
+ return FS.nodePermissions(dir, 'x');
+ },mayCreate:function (dir, name) {
+ try {
+ var node = FS.lookupNode(dir, name);
+ return ERRNO_CODES.EEXIST;
+ } catch (e) {
+ }
+ return FS.nodePermissions(dir, 'wx');
+ },mayDelete:function (dir, name, isdir) {
+ var node;
+ try {
+ node = FS.lookupNode(dir, name);
+ } catch (e) {
+ return e.errno;
+ }
+ var err = FS.nodePermissions(dir, 'wx');
+ if (err) {
+ return err;
+ }
+ if (isdir) {
+ if (!FS.isDir(node.mode)) {
+ return ERRNO_CODES.ENOTDIR;
+ }
+ if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
+ return ERRNO_CODES.EBUSY;
+ }
+ } else {
+ if (FS.isDir(node.mode)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return 0;
+ },mayOpen:function (node, flags) {
+ if (!node) {
+ return ERRNO_CODES.ENOENT;
+ }
+ if (FS.isLink(node.mode)) {
+ return ERRNO_CODES.ELOOP;
+ } else if (FS.isDir(node.mode)) {
+ if ((flags & 2097155) !== 0 || // opening for write
+ (flags & 512)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
+ },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
+ fd_start = fd_start || 0;
+ fd_end = fd_end || FS.MAX_OPEN_FDS;
+ for (var fd = fd_start; fd <= fd_end; fd++) {
+ if (!FS.streams[fd]) {
+ return fd;
+ }
+ }
+ throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
+ },getStream:function (fd) {
+ return FS.streams[fd];
+ },createStream:function (stream, fd_start, fd_end) {
+ if (!FS.FSStream) {
+ FS.FSStream = function(){};
+ FS.FSStream.prototype = {};
+ // compatibility
+ Object.defineProperties(FS.FSStream.prototype, {
+ object: {
+ get: function() { return this.node; },
+ set: function(val) { this.node = val; }
+ },
+ isRead: {
+ get: function() { return (this.flags & 2097155) !== 1; }
+ },
+ isWrite: {
+ get: function() { return (this.flags & 2097155) !== 0; }
+ },
+ isAppend: {
+ get: function() { return (this.flags & 1024); }
+ }
+ });
+ }
+ if (0) {
+ // reuse the object
+ stream.__proto__ = FS.FSStream.prototype;
+ } else {
+ var newStream = new FS.FSStream();
+ for (var p in stream) {
+ newStream[p] = stream[p];
+ }
+ stream = newStream;
+ }
+ var fd = FS.nextfd(fd_start, fd_end);
+ stream.fd = fd;
+ FS.streams[fd] = stream;
+ return stream;
+ },closeStream:function (fd) {
+ FS.streams[fd] = null;
+ },getStreamFromPtr:function (ptr) {
+ return FS.streams[ptr - 1];
+ },getPtrForStream:function (stream) {
+ return stream ? stream.fd + 1 : 0;
+ },chrdev_stream_ops:{open:function (stream) {
+ var device = FS.getDevice(stream.node.rdev);
+ // override node's stream ops with the device's
+ stream.stream_ops = device.stream_ops;
+ // forward the open call
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ },llseek:function () {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }},major:function (dev) {
+ return ((dev) >> 8);
+ },minor:function (dev) {
+ return ((dev) & 0xff);
+ },makedev:function (ma, mi) {
+ return ((ma) << 8 | (mi));
+ },registerDevice:function (dev, ops) {
+ FS.devices[dev] = { stream_ops: ops };
+ },getDevice:function (dev) {
+ return FS.devices[dev];
+ },getMounts:function (mount) {
+ var mounts = [];
+ var check = [mount];
+
+ while (check.length) {
+ var m = check.pop();
+
+ mounts.push(m);
+
+ check.push.apply(check, m.mounts);
+ }
+
+ return mounts;
+ },syncfs:function (populate, callback) {
+ if (typeof(populate) === 'function') {
+ callback = populate;
+ populate = false;
+ }
+
+ var mounts = FS.getMounts(FS.root.mount);
+ var completed = 0;
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= mounts.length) {
+ callback(null);
+ }
+ };
+
+ // sync all mounts
+ mounts.forEach(function (mount) {
+ if (!mount.type.syncfs) {
+ return done(null);
+ }
+ mount.type.syncfs(mount, populate, done);
+ });
+ },mount:function (type, opts, mountpoint) {
+ var root = mountpoint === '/';
+ var pseudo = !mountpoint;
+ var node;
+
+ if (root && FS.root) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ } else if (!root && !pseudo) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ mountpoint = lookup.path; // use the absolute path
+ node = lookup.node;
+
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+
+ if (!FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ }
+
+ var mount = {
+ type: type,
+ opts: opts,
+ mountpoint: mountpoint,
+ mounts: []
+ };
+
+ // create a root node for the fs
+ var mountRoot = type.mount(mount);
+ mountRoot.mount = mount;
+ mount.root = mountRoot;
+
+ if (root) {
+ FS.root = mountRoot;
+ } else if (node) {
+ // set as a mountpoint
+ node.mounted = mount;
+
+ // add the new mount to the current mount's children
+ if (node.mount) {
+ node.mount.mounts.push(mount);
+ }
+ }
+
+ return mountRoot;
+ },unmount:function (mountpoint) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ if (!FS.isMountpoint(lookup.node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ // destroy the nodes for this mount, and all its child mounts
+ var node = lookup.node;
+ var mount = node.mounted;
+ var mounts = FS.getMounts(mount);
+
+ Object.keys(FS.nameTable).forEach(function (hash) {
+ var current = FS.nameTable[hash];
+
+ while (current) {
+ var next = current.name_next;
+
+ if (mounts.indexOf(current.mount) !== -1) {
+ FS.destroyNode(current);
+ }
+
+ current = next;
+ }
+ });
+
+ // no longer a mountpoint
+ node.mounted = null;
+
+ // remove this mount from the child mounts
+ var idx = node.mount.mounts.indexOf(mount);
+ assert(idx !== -1);
+ node.mount.mounts.splice(idx, 1);
+ },lookup:function (parent, name) {
+ return parent.node_ops.lookup(parent, name);
+ },mknod:function (path, mode, dev) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var err = FS.mayCreate(parent, name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.mknod) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.mknod(parent, name, mode, dev);
+ },create:function (path, mode) {
+ mode = mode !== undefined ? mode : 438 /* 0666 */;
+ mode &= 4095;
+ mode |= 32768;
+ return FS.mknod(path, mode, 0);
+ },mkdir:function (path, mode) {
+ mode = mode !== undefined ? mode : 511 /* 0777 */;
+ mode &= 511 | 512;
+ mode |= 16384;
+ return FS.mknod(path, mode, 0);
+ },mkdev:function (path, mode, dev) {
+ if (typeof(dev) === 'undefined') {
+ dev = mode;
+ mode = 438 /* 0666 */;
+ }
+ mode |= 8192;
+ return FS.mknod(path, mode, dev);
+ },symlink:function (oldpath, newpath) {
+ var lookup = FS.lookupPath(newpath, { parent: true });
+ var parent = lookup.node;
+ var newname = PATH.basename(newpath);
+ var err = FS.mayCreate(parent, newname);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.symlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.symlink(parent, newname, oldpath);
+ },rename:function (old_path, new_path) {
+ var old_dirname = PATH.dirname(old_path);
+ var new_dirname = PATH.dirname(new_path);
+ var old_name = PATH.basename(old_path);
+ var new_name = PATH.basename(new_path);
+ // parents must exist
+ var lookup, old_dir, new_dir;
+ try {
+ lookup = FS.lookupPath(old_path, { parent: true });
+ old_dir = lookup.node;
+ lookup = FS.lookupPath(new_path, { parent: true });
+ new_dir = lookup.node;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // need to be part of the same mount
+ if (old_dir.mount !== new_dir.mount) {
+ throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
+ }
+ // source must exist
+ var old_node = FS.lookupNode(old_dir, old_name);
+ // old path should not be an ancestor of the new path
+ var relative = PATH.relative(old_path, new_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ // new path should not be an ancestor of the old path
+ relative = PATH.relative(new_path, old_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ // see if the new path already exists
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ // not fatal
+ }
+ // early out if nothing needs to change
+ if (old_node === new_node) {
+ return;
+ }
+ // we'll need to delete the old entry
+ var isdir = FS.isDir(old_node.mode);
+ var err = FS.mayDelete(old_dir, old_name, isdir);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // need delete permissions if we'll be overwriting.
+ // need create permissions if new doesn't already exist.
+ err = new_node ?
+ FS.mayDelete(new_dir, new_name, isdir) :
+ FS.mayCreate(new_dir, new_name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!old_dir.node_ops.rename) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // if we are going to change the parent, check write permissions
+ if (new_dir !== old_dir) {
+ err = FS.nodePermissions(old_dir, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ }
+ // remove the node from the lookup hash
+ FS.hashRemoveNode(old_node);
+ // do the underlying fs rename
+ try {
+ old_dir.node_ops.rename(old_node, new_dir, new_name);
+ } catch (e) {
+ throw e;
+ } finally {
+ // add the node back to the hash (in case node_ops.rename
+ // changed its name)
+ FS.hashAddNode(old_node);
+ }
+ },rmdir:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, true);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.rmdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.rmdir(parent, name);
+ FS.destroyNode(node);
+ },readdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ if (!node.node_ops.readdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ return node.node_ops.readdir(node);
+ },unlink:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, false);
+ if (err) {
+ // POSIX says unlink should set EPERM, not EISDIR
+ if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.unlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.unlink(parent, name);
+ FS.destroyNode(node);
+ },readlink:function (path) {
+ var lookup = FS.lookupPath(path);
+ var link = lookup.node;
+ if (!link.node_ops.readlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return link.node_ops.readlink(link);
+ },stat:function (path, dontFollow) {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ var node = lookup.node;
+ if (!node.node_ops.getattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return node.node_ops.getattr(node);
+ },lstat:function (path) {
+ return FS.stat(path, true);
+ },chmod:function (path, mode, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ mode: (mode & 4095) | (node.mode & ~4095),
+ timestamp: Date.now()
+ });
+ },lchmod:function (path, mode) {
+ FS.chmod(path, mode, true);
+ },fchmod:function (fd, mode) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chmod(stream.node, mode);
+ },chown:function (path, uid, gid, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ timestamp: Date.now()
+ // we ignore the uid / gid for now
+ });
+ },lchown:function (path, uid, gid) {
+ FS.chown(path, uid, gid, true);
+ },fchown:function (fd, uid, gid) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chown(stream.node, uid, gid);
+ },truncate:function (path, len) {
+ if (len < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: true });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!FS.isFile(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var err = FS.nodePermissions(node, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ node.node_ops.setattr(node, {
+ size: len,
+ timestamp: Date.now()
+ });
+ },ftruncate:function (fd, len) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ FS.truncate(stream.node, len);
+ },utime:function (path, atime, mtime) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ node.node_ops.setattr(node, {
+ timestamp: Math.max(atime, mtime)
+ });
+ },open:function (path, flags, mode, fd_start, fd_end) {
+ flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
+ mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
+ if ((flags & 64)) {
+ mode = (mode & 4095) | 32768;
+ } else {
+ mode = 0;
+ }
+ var node;
+ if (typeof path === 'object') {
+ node = path;
+ } else {
+ path = PATH.normalize(path);
+ try {
+ var lookup = FS.lookupPath(path, {
+ follow: !(flags & 131072)
+ });
+ node = lookup.node;
+ } catch (e) {
+ // ignore
+ }
+ }
+ // perhaps we need to create the node
+ if ((flags & 64)) {
+ if (node) {
+ // if O_CREAT and O_EXCL are set, error out if the node already exists
+ if ((flags & 128)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
+ }
+ } else {
+ // node doesn't exist, try to create it
+ node = FS.mknod(path, mode, 0);
+ }
+ }
+ if (!node) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
+ }
+ // can't truncate a device
+ if (FS.isChrdev(node.mode)) {
+ flags &= ~512;
+ }
+ // check permissions
+ var err = FS.mayOpen(node, flags);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // do truncation if necessary
+ if ((flags & 512)) {
+ FS.truncate(node, 0);
+ }
+ // we've already handled these, don't pass down to the underlying vfs
+ flags &= ~(128 | 512);
+
+ // register the stream with the filesystem
+ var stream = FS.createStream({
+ node: node,
+ path: FS.getPath(node), // we want the absolute path to the node
+ flags: flags,
+ seekable: true,
+ position: 0,
+ stream_ops: node.stream_ops,
+ // used by the file family libc calls (fopen, fwrite, ferror, etc.)
+ ungotten: [],
+ error: false
+ }, fd_start, fd_end);
+ // call the new stream's open function
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ if (Module['logReadFiles'] && !(flags & 1)) {
+ if (!FS.readFiles) FS.readFiles = {};
+ if (!(path in FS.readFiles)) {
+ FS.readFiles[path] = 1;
+ Module['printErr']('read file: ' + path);
+ }
+ }
+ return stream;
+ },close:function (stream) {
+ try {
+ if (stream.stream_ops.close) {
+ stream.stream_ops.close(stream);
+ }
+ } catch (e) {
+ throw e;
+ } finally {
+ FS.closeStream(stream.fd);
+ }
+ },llseek:function (stream, offset, whence) {
+ if (!stream.seekable || !stream.stream_ops.llseek) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ return stream.stream_ops.llseek(stream, offset, whence);
+ },read:function (stream, buffer, offset, length, position) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.read) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
+ if (!seeking) stream.position += bytesRead;
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.write) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ if (stream.flags & 1024) {
+ // seek to the end before writing in append mode
+ FS.llseek(stream, 0, 2);
+ }
+ var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
+ if (!seeking) stream.position += bytesWritten;
+ return bytesWritten;
+ },allocate:function (stream, offset, length) {
+ if (offset < 0 || length <= 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ if (!stream.stream_ops.allocate) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ stream.stream_ops.allocate(stream, offset, length);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ // TODO if PROT is PROT_WRITE, make sure we have write access
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EACCES);
+ }
+ if (!stream.stream_ops.mmap) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
+ },ioctl:function (stream, cmd, arg) {
+ if (!stream.stream_ops.ioctl) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
+ }
+ return stream.stream_ops.ioctl(stream, cmd, arg);
+ },readFile:function (path, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'r';
+ opts.encoding = opts.encoding || 'binary';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var ret;
+ var stream = FS.open(path, opts.flags);
+ var stat = FS.stat(path);
+ var length = stat.size;
+ var buf = new Uint8Array(length);
+ FS.read(stream, buf, 0, length, 0);
+ if (opts.encoding === 'utf8') {
+ ret = '';
+ var utf8 = new Runtime.UTF8Processor();
+ for (var i = 0; i < length; i++) {
+ ret += utf8.processCChar(buf[i]);
+ }
+ } else if (opts.encoding === 'binary') {
+ ret = buf;
+ }
+ FS.close(stream);
+ return ret;
+ },writeFile:function (path, data, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'w';
+ opts.encoding = opts.encoding || 'utf8';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var stream = FS.open(path, opts.flags, opts.mode);
+ if (opts.encoding === 'utf8') {
+ var utf8 = new Runtime.UTF8Processor();
+ var buf = new Uint8Array(utf8.processJSString(data));
+ FS.write(stream, buf, 0, buf.length, 0, opts.canOwn);
+ } else if (opts.encoding === 'binary') {
+ FS.write(stream, data, 0, data.length, 0, opts.canOwn);
+ }
+ FS.close(stream);
+ },cwd:function () {
+ return FS.currentPath;
+ },chdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ if (!FS.isDir(lookup.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ var err = FS.nodePermissions(lookup.node, 'x');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ FS.currentPath = lookup.path;
+ },createDefaultDirectories:function () {
+ FS.mkdir('/tmp');
+ },createDefaultDevices:function () {
+ // create /dev
+ FS.mkdir('/dev');
+ // setup /dev/null
+ FS.registerDevice(FS.makedev(1, 3), {
+ read: function() { return 0; },
+ write: function() { return 0; }
+ });
+ FS.mkdev('/dev/null', FS.makedev(1, 3));
+ // setup /dev/tty and /dev/tty1
+ // stderr needs to print output using Module['printErr']
+ // so we register a second tty just for it.
+ TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
+ TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
+ FS.mkdev('/dev/tty', FS.makedev(5, 0));
+ FS.mkdev('/dev/tty1', FS.makedev(6, 0));
+ // we're not going to emulate the actual shm device,
+ // just create the tmp dirs that reside in it commonly
+ FS.mkdir('/dev/shm');
+ FS.mkdir('/dev/shm/tmp');
+ },createStandardStreams:function () {
+ // TODO deprecate the old functionality of a single
+ // input / output callback and that utilizes FS.createDevice
+ // and instead require a unique set of stream ops
+
+ // by default, we symlink the standard streams to the
+ // default tty devices. however, if the standard streams
+ // have been overwritten we create a unique device for
+ // them instead.
+ if (Module['stdin']) {
+ FS.createDevice('/dev', 'stdin', Module['stdin']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdin');
+ }
+ if (Module['stdout']) {
+ FS.createDevice('/dev', 'stdout', null, Module['stdout']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdout');
+ }
+ if (Module['stderr']) {
+ FS.createDevice('/dev', 'stderr', null, Module['stderr']);
+ } else {
+ FS.symlink('/dev/tty1', '/dev/stderr');
+ }
+
+ // open default streams for the stdin, stdout and stderr devices
+ var stdin = FS.open('/dev/stdin', 'r');
+ HEAP32[((_stdin)>>2)]=FS.getPtrForStream(stdin);
+ assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
+
+ var stdout = FS.open('/dev/stdout', 'w');
+ HEAP32[((_stdout)>>2)]=FS.getPtrForStream(stdout);
+ assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
+
+ var stderr = FS.open('/dev/stderr', 'w');
+ HEAP32[((_stderr)>>2)]=FS.getPtrForStream(stderr);
+ assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
+ },ensureErrnoError:function () {
+ if (FS.ErrnoError) return;
+ FS.ErrnoError = function ErrnoError(errno) {
+ this.errno = errno;
+ for (var key in ERRNO_CODES) {
+ if (ERRNO_CODES[key] === errno) {
+ this.code = key;
+ break;
+ }
+ }
+ this.message = ERRNO_MESSAGES[errno];
+ };
+ FS.ErrnoError.prototype = new Error();
+ FS.ErrnoError.prototype.constructor = FS.ErrnoError;
+ // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
+ [ERRNO_CODES.ENOENT].forEach(function(code) {
+ FS.genericErrors[code] = new FS.ErrnoError(code);
+ FS.genericErrors[code].stack = '<generic error, no stack>';
+ });
+ },staticInit:function () {
+ FS.ensureErrnoError();
+
+ FS.nameTable = new Array(4096);
+
+ FS.mount(MEMFS, {}, '/');
+
+ FS.createDefaultDirectories();
+ FS.createDefaultDevices();
+ },init:function (input, output, error) {
+ assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
+ FS.init.initialized = true;
+
+ FS.ensureErrnoError();
+
+ // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
+ Module['stdin'] = input || Module['stdin'];
+ Module['stdout'] = output || Module['stdout'];
+ Module['stderr'] = error || Module['stderr'];
+
+ FS.createStandardStreams();
+ },quit:function () {
+ FS.init.initialized = false;
+ for (var i = 0; i < FS.streams.length; i++) {
+ var stream = FS.streams[i];
+ if (!stream) {
+ continue;
+ }
+ FS.close(stream);
+ }
+ },getMode:function (canRead, canWrite) {
+ var mode = 0;
+ if (canRead) mode |= 292 | 73;
+ if (canWrite) mode |= 146;
+ return mode;
+ },joinPath:function (parts, forceRelative) {
+ var path = PATH.join.apply(null, parts);
+ if (forceRelative && path[0] == '/') path = path.substr(1);
+ return path;
+ },absolutePath:function (relative, base) {
+ return PATH.resolve(base, relative);
+ },standardizePath:function (path) {
+ return PATH.normalize(path);
+ },findObject:function (path, dontResolveLastLink) {
+ var ret = FS.analyzePath(path, dontResolveLastLink);
+ if (ret.exists) {
+ return ret.object;
+ } else {
+ ___setErrNo(ret.error);
+ return null;
+ }
+ },analyzePath:function (path, dontResolveLastLink) {
+ // operate from within the context of the symlink's target
+ try {
+ var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ path = lookup.path;
+ } catch (e) {
+ }
+ var ret = {
+ isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
+ parentExists: false, parentPath: null, parentObject: null
+ };
+ try {
+ var lookup = FS.lookupPath(path, { parent: true });
+ ret.parentExists = true;
+ ret.parentPath = lookup.path;
+ ret.parentObject = lookup.node;
+ ret.name = PATH.basename(path);
+ lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ ret.exists = true;
+ ret.path = lookup.path;
+ ret.object = lookup.node;
+ ret.name = lookup.node.name;
+ ret.isRoot = lookup.path === '/';
+ } catch (e) {
+ ret.error = e.errno;
+ };
+ return ret;
+ },createFolder:function (parent, name, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.mkdir(path, mode);
+ },createPath:function (parent, path, canRead, canWrite) {
+ parent = typeof parent === 'string' ? parent : FS.getPath(parent);
+ var parts = path.split('/').reverse();
+ while (parts.length) {
+ var part = parts.pop();
+ if (!part) continue;
+ var current = PATH.join2(parent, part);
+ try {
+ FS.mkdir(current);
+ } catch (e) {
+ // ignore EEXIST
+ }
+ parent = current;
+ }
+ return current;
+ },createFile:function (parent, name, properties, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.create(path, mode);
+ },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
+ var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
+ var mode = FS.getMode(canRead, canWrite);
+ var node = FS.create(path, mode);
+ if (data) {
+ if (typeof data === 'string') {
+ var arr = new Array(data.length);
+ for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
+ data = arr;
+ }
+ // make sure we can write to the file
+ FS.chmod(node, mode | 146);
+ var stream = FS.open(node, 'w');
+ FS.write(stream, data, 0, data.length, 0, canOwn);
+ FS.close(stream);
+ FS.chmod(node, mode);
+ }
+ return node;
+ },createDevice:function (parent, name, input, output) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(!!input, !!output);
+ if (!FS.createDevice.major) FS.createDevice.major = 64;
+ var dev = FS.makedev(FS.createDevice.major++, 0);
+ // Create a fake device that a set of stream ops to emulate
+ // the old behavior.
+ FS.registerDevice(dev, {
+ open: function(stream) {
+ stream.seekable = false;
+ },
+ close: function(stream) {
+ // flush any pending line data
+ if (output && output.buffer && output.buffer.length) {
+ output(10);
+ }
+ },
+ read: function(stream, buffer, offset, length, pos /* ignored */) {
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = input();
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },
+ write: function(stream, buffer, offset, length, pos) {
+ for (var i = 0; i < length; i++) {
+ try {
+ output(buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }
+ });
+ return FS.mkdev(path, mode, dev);
+ },createLink:function (parent, name, target, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ return FS.symlink(target, path);
+ },forceLoadFile:function (obj) {
+ if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
+ var success = true;
+ if (typeof XMLHttpRequest !== 'undefined') {
+ throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
+ } else if (Module['read']) {
+ // Command-line.
+ try {
+ // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
+ // read() will try to parse UTF8.
+ obj.contents = intArrayFromString(Module['read'](obj.url), true);
+ } catch (e) {
+ success = false;
+ }
+ } else {
+ throw new Error('Cannot load without read() or XMLHttpRequest.');
+ }
+ if (!success) ___setErrNo(ERRNO_CODES.EIO);
+ return success;
+ },createLazyFile:function (parent, name, url, canRead, canWrite) {
+ // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
+ function LazyUint8Array() {
+ this.lengthKnown = false;
+ this.chunks = []; // Loaded chunks. Index is the chunk number
+ }
+ LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
+ if (idx > this.length-1 || idx < 0) {
+ return undefined;
+ }
+ var chunkOffset = idx % this.chunkSize;
+ var chunkNum = Math.floor(idx / this.chunkSize);
+ return this.getter(chunkNum)[chunkOffset];
+ }
+ LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
+ this.getter = getter;
+ }
+ LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
+ // Find length
+ var xhr = new XMLHttpRequest();
+ xhr.open('HEAD', url, false);
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ var datalength = Number(xhr.getResponseHeader("Content-length"));
+ var header;
+ var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
+ var chunkSize = 1024*1024; // Chunk size in bytes
+
+ if (!hasByteServing) chunkSize = datalength;
+
+ // Function to get a range from the remote URL.
+ var doXHR = (function(from, to) {
+ if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
+ if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
+
+ // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
+
+ // Some hints to the browser that we want binary data.
+ if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
+ if (xhr.overrideMimeType) {
+ xhr.overrideMimeType('text/plain; charset=x-user-defined');
+ }
+
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ if (xhr.response !== undefined) {
+ return new Uint8Array(xhr.response || []);
+ } else {
+ return intArrayFromString(xhr.responseText || '', true);
+ }
+ });
+ var lazyArray = this;
+ lazyArray.setDataGetter(function(chunkNum) {
+ var start = chunkNum * chunkSize;
+ var end = (chunkNum+1) * chunkSize - 1; // including this byte
+ end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
+ lazyArray.chunks[chunkNum] = doXHR(start, end);
+ }
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
+ return lazyArray.chunks[chunkNum];
+ });
+
+ this._length = datalength;
+ this._chunkSize = chunkSize;
+ this.lengthKnown = true;
+ }
+ if (typeof XMLHttpRequest !== 'undefined') {
+ if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
+ var lazyArray = new LazyUint8Array();
+ Object.defineProperty(lazyArray, "length", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._length;
+ }
+ });
+ Object.defineProperty(lazyArray, "chunkSize", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._chunkSize;
+ }
+ });
+
+ var properties = { isDevice: false, contents: lazyArray };
+ } else {
+ var properties = { isDevice: false, url: url };
+ }
+
+ var node = FS.createFile(parent, name, properties, canRead, canWrite);
+ // This is a total hack, but I want to get this lazy file code out of the
+ // core of MEMFS. If we want to keep this lazy file concept I feel it should
+ // be its own thin LAZYFS proxying calls to MEMFS.
+ if (properties.contents) {
+ node.contents = properties.contents;
+ } else if (properties.url) {
+ node.contents = null;
+ node.url = properties.url;
+ }
+ // override each stream op with one that tries to force load the lazy file first
+ var stream_ops = {};
+ var keys = Object.keys(node.stream_ops);
+ keys.forEach(function(key) {
+ var fn = node.stream_ops[key];
+ stream_ops[key] = function forceLoadLazyFile() {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ return fn.apply(null, arguments);
+ };
+ });
+ // use a custom read function
+ stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (contents.slice) { // normal array
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ } else {
+ for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
+ buffer[offset + i] = contents.get(position + i);
+ }
+ }
+ return size;
+ };
+ node.stream_ops = stream_ops;
+ return node;
+ },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {
+ Browser.init();
+ // TODO we should allow people to just pass in a complete filename instead
+ // of parent and name being that we just join them anyways
+ var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
+ function processData(byteArray) {
+ function finish(byteArray) {
+ if (!dontCreateFile) {
+ FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
+ }
+ if (onload) onload();
+ removeRunDependency('cp ' + fullname);
+ }
+ var handled = false;
+ Module['preloadPlugins'].forEach(function(plugin) {
+ if (handled) return;
+ if (plugin['canHandle'](fullname)) {
+ plugin['handle'](byteArray, fullname, finish, function() {
+ if (onerror) onerror();
+ removeRunDependency('cp ' + fullname);
+ });
+ handled = true;
+ }
+ });
+ if (!handled) finish(byteArray);
+ }
+ addRunDependency('cp ' + fullname);
+ if (typeof url == 'string') {
+ Browser.asyncLoad(url, function(byteArray) {
+ processData(byteArray);
+ }, onerror);
+ } else {
+ processData(url);
+ }
+ },indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_NAME:function () {
+ return 'EM_FS_' + window.location.pathname;
+ },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
+ console.log('creating db');
+ var db = openRequest.result;
+ db.createObjectStore(FS.DB_STORE_NAME);
+ };
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var putRequest = files.put(FS.analyzePath(path).object.contents, path);
+ putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
+ putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ },loadFilesFromDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = onerror; // no database to load from
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ try {
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
+ } catch(e) {
+ onerror(e);
+ return;
+ }
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var getRequest = files.get(path);
+ getRequest.onsuccess = function getRequest_onsuccess() {
+ if (FS.analyzePath(path).exists) {
+ FS.unlink(path);
+ }
+ FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
+ ok++;
+ if (ok + fail == total) finish();
+ };
+ getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ }};
+
+ function _lseek(fildes, offset, whence) {
+ // off_t lseek(int fildes, off_t offset, int whence);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/lseek.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ try {
+ return FS.llseek(stream, offset, whence);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }
+
+ function _fileno(stream) {
+ // int fileno(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fileno.html
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) return -1;
+ return stream.fd;
+ }function _fseek(stream, offset, whence) {
+ // int fseek(FILE *stream, long offset, int whence);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fseek.html
+ var fd = _fileno(stream);
+ var ret = _lseek(fd, offset, whence);
+ if (ret == -1) {
+ return -1;
+ }
+ stream = FS.getStreamFromPtr(stream);
+ stream.eof = false;
+ return 0;
+ }
+
+
+ Module["_i64Subtract"] = _i64Subtract;
+
+
+ Module["_i64Add"] = _i64Add;
+
+ function _setlocale(category, locale) {
+ if (!_setlocale.ret) _setlocale.ret = allocate([0], 'i8', ALLOC_NORMAL);
+ return _setlocale.ret;
+ }
+
+
+ function _close(fildes) {
+ // int close(int fildes);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/close.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ try {
+ FS.close(stream);
+ return 0;
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }
+
+ function _fsync(fildes) {
+ // int fsync(int fildes);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fsync.html
+ var stream = FS.getStream(fildes);
+ if (stream) {
+ // We write directly to the file system, so there's nothing to do here.
+ return 0;
+ } else {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ }function _fclose(stream) {
+ // int fclose(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fclose.html
+ var fd = _fileno(stream);
+ _fsync(fd);
+ return _close(fd);
+ }
+
+
+
+
+
+ function _mkport() { throw 'TODO' }var SOCKFS={mount:function (mount) {
+ return FS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createSocket:function (family, type, protocol) {
+ var streaming = type == 1;
+ if (protocol) {
+ assert(streaming == (protocol == 6)); // if SOCK_STREAM, must be tcp
+ }
+
+ // create our internal socket structure
+ var sock = {
+ family: family,
+ type: type,
+ protocol: protocol,
+ server: null,
+ peers: {},
+ pending: [],
+ recv_queue: [],
+ sock_ops: SOCKFS.websocket_sock_ops
+ };
+
+ // create the filesystem node to store the socket structure
+ var name = SOCKFS.nextname();
+ var node = FS.createNode(SOCKFS.root, name, 49152, 0);
+ node.sock = sock;
+
+ // and the wrapping stream that enables library functions such
+ // as read and write to indirectly interact with the socket
+ var stream = FS.createStream({
+ path: name,
+ node: node,
+ flags: FS.modeStringToFlags('r+'),
+ seekable: false,
+ stream_ops: SOCKFS.stream_ops
+ });
+
+ // map the new stream to the socket structure (sockets have a 1:1
+ // relationship with a stream)
+ sock.stream = stream;
+
+ return sock;
+ },getSocket:function (fd) {
+ var stream = FS.getStream(fd);
+ if (!stream || !FS.isSocket(stream.node.mode)) {
+ return null;
+ }
+ return stream.node.sock;
+ },stream_ops:{poll:function (stream) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.poll(sock);
+ },ioctl:function (stream, request, varargs) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.ioctl(sock, request, varargs);
+ },read:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ var msg = sock.sock_ops.recvmsg(sock, length);
+ if (!msg) {
+ // socket is closed
+ return 0;
+ }
+ buffer.set(msg.buffer, offset);
+ return msg.buffer.length;
+ },write:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.sendmsg(sock, buffer, offset, length);
+ },close:function (stream) {
+ var sock = stream.node.sock;
+ sock.sock_ops.close(sock);
+ }},nextname:function () {
+ if (!SOCKFS.nextname.current) {
+ SOCKFS.nextname.current = 0;
+ }
+ return 'socket[' + (SOCKFS.nextname.current++) + ']';
+ },websocket_sock_ops:{createPeer:function (sock, addr, port) {
+ var ws;
+
+ if (typeof addr === 'object') {
+ ws = addr;
+ addr = null;
+ port = null;
+ }
+
+ if (ws) {
+ // for sockets that've already connected (e.g. we're the server)
+ // we can inspect the _socket property for the address
+ if (ws._socket) {
+ addr = ws._socket.remoteAddress;
+ port = ws._socket.remotePort;
+ }
+ // if we're just now initializing a connection to the remote,
+ // inspect the url property
+ else {
+ var result = /ws[s]?:\/\/([^:]+):(\d+)/.exec(ws.url);
+ if (!result) {
+ throw new Error('WebSocket URL must be in the format ws(s)://address:port');
+ }
+ addr = result[1];
+ port = parseInt(result[2], 10);
+ }
+ } else {
+ // create the actual websocket object and connect
+ try {
+ // runtimeConfig gets set to true if WebSocket runtime configuration is available.
+ var runtimeConfig = (Module['websocket'] && ('object' === typeof Module['websocket']));
+
+ // The default value is 'ws://' the replace is needed because the compiler replaces "//" comments with '#'
+ // comments without checking context, so we'd end up with ws:#, the replace swaps the "#" for "//" again.
+ var url = 'ws:#'.replace('#', '//');
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['url']) {
+ url = Module['websocket']['url']; // Fetch runtime WebSocket URL config.
+ }
+ }
+
+ if (url === 'ws://' || url === 'wss://') { // Is the supplied URL config just a prefix, if so complete it.
+ url = url + addr + ':' + port;
+ }
+
+ // Make the WebSocket subprotocol (Sec-WebSocket-Protocol) default to binary if no configuration is set.
+ var subProtocols = 'binary'; // The default value is 'binary'
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['subprotocol']) {
+ subProtocols = Module['websocket']['subprotocol']; // Fetch runtime WebSocket subprotocol config.
+ }
+ }
+
+ // The regex trims the string (removes spaces at the beginning and end, then splits the string by
+ // <any space>,<any space> into an Array. Whitespace removal is important for Websockify and ws.
+ subProtocols = subProtocols.replace(/^ +| +$/g,"").split(/ *, */);
+
+ // The node ws library API for specifying optional subprotocol is slightly different than the browser's.
+ var opts = ENVIRONMENT_IS_NODE ? {'protocol': subProtocols.toString()} : subProtocols;
+
+ // If node we use the ws library.
+ var WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : window['WebSocket'];
+ ws = new WebSocket(url, opts);
+ ws.binaryType = 'arraybuffer';
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EHOSTUNREACH);
+ }
+ }
+
+
+ var peer = {
+ addr: addr,
+ port: port,
+ socket: ws,
+ dgram_send_queue: []
+ };
+
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);
+
+ // if this is a bound dgram socket, send the port number first to allow
+ // us to override the ephemeral port reported to us by remotePort on the
+ // remote end.
+ if (sock.type === 2 && typeof sock.sport !== 'undefined') {
+ peer.dgram_send_queue.push(new Uint8Array([
+ 255, 255, 255, 255,
+ 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),
+ ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)
+ ]));
+ }
+
+ return peer;
+ },getPeer:function (sock, addr, port) {
+ return sock.peers[addr + ':' + port];
+ },addPeer:function (sock, peer) {
+ sock.peers[peer.addr + ':' + peer.port] = peer;
+ },removePeer:function (sock, peer) {
+ delete sock.peers[peer.addr + ':' + peer.port];
+ },handlePeerEvents:function (sock, peer) {
+ var first = true;
+
+ var handleOpen = function () {
+ try {
+ var queued = peer.dgram_send_queue.shift();
+ while (queued) {
+ peer.socket.send(queued);
+ queued = peer.dgram_send_queue.shift();
+ }
+ } catch (e) {
+ // not much we can do here in the way of proper error handling as we've already
+ // lied and said this data was sent. shut it down.
+ peer.socket.close();
+ }
+ };
+
+ function handleMessage(data) {
+ assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer
+ data = new Uint8Array(data); // make a typed array view on the array buffer
+
+
+ // if this is the port message, override the peer's port with it
+ var wasfirst = first;
+ first = false;
+ if (wasfirst &&
+ data.length === 10 &&
+ data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&
+ data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {
+ // update the peer's port and it's key in the peer map
+ var newport = ((data[8] << 8) | data[9]);
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ peer.port = newport;
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ return;
+ }
+
+ sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });
+ };
+
+ if (ENVIRONMENT_IS_NODE) {
+ peer.socket.on('open', handleOpen);
+ peer.socket.on('message', function(data, flags) {
+ if (!flags.binary) {
+ return;
+ }
+ handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
+ });
+ peer.socket.on('error', function() {
+ // don't throw
+ });
+ } else {
+ peer.socket.onopen = handleOpen;
+ peer.socket.onmessage = function peer_socket_onmessage(event) {
+ handleMessage(event.data);
+ };
+ }
+ },poll:function (sock) {
+ if (sock.type === 1 && sock.server) {
+ // listen sockets should only say they're available for reading
+ // if there are pending clients.
+ return sock.pending.length ? (64 | 1) : 0;
+ }
+
+ var mask = 0;
+ var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets
+ SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :
+ null;
+
+ if (sock.recv_queue.length ||
+ !dest || // connection-less sockets are always ready to read
+ (dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed
+ mask |= (64 | 1);
+ }
+
+ if (!dest || // connection-less sockets are always ready to write
+ (dest && dest.socket.readyState === dest.socket.OPEN)) {
+ mask |= 4;
+ }
+
+ if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) {
+ mask |= 16;
+ }
+
+ return mask;
+ },ioctl:function (sock, request, arg) {
+ switch (request) {
+ case 21531:
+ var bytes = 0;
+ if (sock.recv_queue.length) {
+ bytes = sock.recv_queue[0].data.length;
+ }
+ HEAP32[((arg)>>2)]=bytes;
+ return 0;
+ default:
+ return ERRNO_CODES.EINVAL;
+ }
+ },close:function (sock) {
+ // if we've spawned a listen server, close it
+ if (sock.server) {
+ try {
+ sock.server.close();
+ } catch (e) {
+ }
+ sock.server = null;
+ }
+ // close any peer connections
+ var peers = Object.keys(sock.peers);
+ for (var i = 0; i < peers.length; i++) {
+ var peer = sock.peers[peers[i]];
+ try {
+ peer.socket.close();
+ } catch (e) {
+ }
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ }
+ return 0;
+ },bind:function (sock, addr, port) {
+ if (typeof sock.saddr !== 'undefined' || typeof sock.sport !== 'undefined') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already bound
+ }
+ sock.saddr = addr;
+ sock.sport = port || _mkport();
+ // in order to emulate dgram sockets, we need to launch a listen server when
+ // binding on a connection-less socket
+ // note: this is only required on the server side
+ if (sock.type === 2) {
+ // close the existing server if it exists
+ if (sock.server) {
+ sock.server.close();
+ sock.server = null;
+ }
+ // swallow error operation not supported error that occurs when binding in the
+ // browser where this isn't supported
+ try {
+ sock.sock_ops.listen(sock, 0);
+ } catch (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e;
+ if (e.errno !== ERRNO_CODES.EOPNOTSUPP) throw e;
+ }
+ }
+ },connect:function (sock, addr, port) {
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODS.EOPNOTSUPP);
+ }
+
+ // TODO autobind
+ // if (!sock.addr && sock.type == 2) {
+ // }
+
+ // early out if we're already connected / in the middle of connecting
+ if (typeof sock.daddr !== 'undefined' && typeof sock.dport !== 'undefined') {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+ if (dest) {
+ if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EALREADY);
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EISCONN);
+ }
+ }
+ }
+
+ // add the socket to our peer list and set our
+ // destination address / port to match
+ var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ sock.daddr = peer.addr;
+ sock.dport = peer.port;
+
+ // always "fail" in non-blocking mode
+ throw new FS.ErrnoError(ERRNO_CODES.EINPROGRESS);
+ },listen:function (sock, backlog) {
+ if (!ENVIRONMENT_IS_NODE) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already listening
+ }
+ var WebSocketServer = require('ws').Server;
+ var host = sock.saddr;
+ sock.server = new WebSocketServer({
+ host: host,
+ port: sock.sport
+ // TODO support backlog
+ });
+
+ sock.server.on('connection', function(ws) {
+ if (sock.type === 1) {
+ var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);
+
+ // create a peer on the new socket
+ var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);
+ newsock.daddr = peer.addr;
+ newsock.dport = peer.port;
+
+ // push to queue for accept to pick up
+ sock.pending.push(newsock);
+ } else {
+ // create a peer on the listen socket so calling sendto
+ // with the listen socket and an address will resolve
+ // to the correct client
+ SOCKFS.websocket_sock_ops.createPeer(sock, ws);
+ }
+ });
+ sock.server.on('closed', function() {
+ sock.server = null;
+ });
+ sock.server.on('error', function() {
+ // don't throw
+ });
+ },accept:function (listensock) {
+ if (!listensock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var newsock = listensock.pending.shift();
+ newsock.stream.flags = listensock.stream.flags;
+ return newsock;
+ },getname:function (sock, peer) {
+ var addr, port;
+ if (peer) {
+ if (sock.daddr === undefined || sock.dport === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ addr = sock.daddr;
+ port = sock.dport;
+ } else {
+ // TODO saddr and sport will be set for bind()'d UDP sockets, but what
+ // should we be returning for TCP sockets that've been connect()'d?
+ addr = sock.saddr || 0;
+ port = sock.sport || 0;
+ }
+ return { addr: addr, port: port };
+ },sendmsg:function (sock, buffer, offset, length, addr, port) {
+ if (sock.type === 2) {
+ // connection-less sockets will honor the message address,
+ // and otherwise fall back to the bound destination address
+ if (addr === undefined || port === undefined) {
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+ // if there was no address to fall back to, error out
+ if (addr === undefined || port === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.EDESTADDRREQ);
+ }
+ } else {
+ // connection-based sockets will only use the bound
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+
+ // find the peer for the destination address
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);
+
+ // early out if not connected with a connection-based socket
+ if (sock.type === 1) {
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ } else if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // create a copy of the incoming data to send, as the WebSocket API
+ // doesn't work entirely with an ArrayBufferView, it'll just send
+ // the entire underlying buffer
+ var data;
+ if (buffer instanceof Array || buffer instanceof ArrayBuffer) {
+ data = buffer.slice(offset, offset + length);
+ } else { // ArrayBufferView
+ data = buffer.buffer.slice(buffer.byteOffset + offset, buffer.byteOffset + offset + length);
+ }
+
+ // if we're emulating a connection-less dgram socket and don't have
+ // a cached connection, queue the buffer to send upon connect and
+ // lie, saying the data was sent now.
+ if (sock.type === 2) {
+ if (!dest || dest.socket.readyState !== dest.socket.OPEN) {
+ // if we're not connected, open a new connection
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ }
+ dest.dgram_send_queue.push(data);
+ return length;
+ }
+ }
+
+ try {
+ // send the actual data
+ dest.socket.send(data);
+ return length;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ },recvmsg:function (sock, length) {
+ // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html
+ if (sock.type === 1 && sock.server) {
+ // tcp servers should not be recv()'ing on the listen socket
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+
+ var queued = sock.recv_queue.shift();
+ if (!queued) {
+ if (sock.type === 1) {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+
+ if (!dest) {
+ // if we have a destination address but are not connected, error out
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ else if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ // return null if the socket has closed
+ return null;
+ }
+ else {
+ // else, our socket is in a valid state but truly has nothing available
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // queued.data will be an ArrayBuffer if it's unadulterated, but if it's
+ // requeued TCP data it'll be an ArrayBufferView
+ var queuedLength = queued.data.byteLength || queued.data.length;
+ var queuedOffset = queued.data.byteOffset || 0;
+ var queuedBuffer = queued.data.buffer || queued.data;
+ var bytesRead = Math.min(length, queuedLength);
+ var res = {
+ buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),
+ addr: queued.addr,
+ port: queued.port
+ };
+
+
+ // push back any unread data for TCP connections
+ if (sock.type === 1 && bytesRead < queuedLength) {
+ var bytesRemaining = queuedLength - bytesRead;
+ queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
+ sock.recv_queue.unshift(queued);
+ }
+
+ return res;
+ }}};function _recv(fd, buf, len, flags) {
+ var sock = SOCKFS.getSocket(fd);
+ if (!sock) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ // TODO honor flags
+ return _read(fd, buf, len);
+ }
+
+ function _pread(fildes, buf, nbyte, offset) {
+ // ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/read.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ try {
+ var slab = HEAP8;
+ return FS.read(stream, slab, buf, nbyte, offset);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _read(fildes, buf, nbyte) {
+ // ssize_t read(int fildes, void *buf, size_t nbyte);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/read.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+
+
+ try {
+ var slab = HEAP8;
+ return FS.read(stream, slab, buf, nbyte);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _fread(ptr, size, nitems, stream) {
+ // size_t fread(void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fread.html
+ var bytesToRead = nitems * size;
+ if (bytesToRead == 0) {
+ return 0;
+ }
+ var bytesRead = 0;
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (!streamObj) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return 0;
+ }
+ while (streamObj.ungotten.length && bytesToRead > 0) {
+ HEAP8[((ptr++)|0)]=streamObj.ungotten.pop();
+ bytesToRead--;
+ bytesRead++;
+ }
+ var err = _read(streamObj.fd, ptr, bytesToRead);
+ if (err == -1) {
+ if (streamObj) streamObj.error = true;
+ return 0;
+ }
+ bytesRead += err;
+ if (bytesRead < bytesToRead) streamObj.eof = true;
+ return Math.floor(bytesRead / size);
+ }
+
+ function _toupper(chr) {
+ if (chr >= 97 && chr <= 122) {
+ return chr - 97 + 65;
+ } else {
+ return chr;
+ }
+ }
+
+
+
+ function _open(path, oflag, varargs) {
+ // int open(const char *path, int oflag, ...);
+ // http://pubs.opengroup.org/onlinepubs/009695399/functions/open.html
+ var mode = HEAP32[((varargs)>>2)];
+ path = Pointer_stringify(path);
+ try {
+ var stream = FS.open(path, oflag, mode);
+ return stream.fd;
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _fopen(filename, mode) {
+ // FILE *fopen(const char *restrict filename, const char *restrict mode);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fopen.html
+ var flags;
+ mode = Pointer_stringify(mode);
+ if (mode[0] == 'r') {
+ if (mode.indexOf('+') != -1) {
+ flags = 2;
+ } else {
+ flags = 0;
+ }
+ } else if (mode[0] == 'w') {
+ if (mode.indexOf('+') != -1) {
+ flags = 2;
+ } else {
+ flags = 1;
+ }
+ flags |= 64;
+ flags |= 512;
+ } else if (mode[0] == 'a') {
+ if (mode.indexOf('+') != -1) {
+ flags = 2;
+ } else {
+ flags = 1;
+ }
+ flags |= 64;
+ flags |= 1024;
+ } else {
+ ___setErrNo(ERRNO_CODES.EINVAL);
+ return 0;
+ }
+ var fd = _open(filename, flags, allocate([0x1FF, 0, 0, 0], 'i32', ALLOC_STACK)); // All creation permissions.
+ return fd === -1 ? 0 : FS.getPtrForStream(FS.getStream(fd));
+ }
+
+ var _emscripten_check_longjmp=true;
+
+
+
+ function _send(fd, buf, len, flags) {
+ var sock = SOCKFS.getSocket(fd);
+ if (!sock) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ // TODO honor flags
+ return _write(fd, buf, len);
+ }
+
+ function _pwrite(fildes, buf, nbyte, offset) {
+ // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte, offset);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _write(fildes, buf, nbyte) {
+ // ssize_t write(int fildes, const void *buf, size_t nbyte);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+
+
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _fputc(c, stream) {
+ // int fputc(int c, FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputc.html
+ var chr = unSign(c & 0xFF);
+ HEAP8[((_fputc.ret)|0)]=chr;
+ var fd = _fileno(stream);
+ var ret = _write(fd, _fputc.ret, 1);
+ if (ret == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return -1;
+ } else {
+ return chr;
+ }
+ }
+
+ var _log=Math_log;
+
+ var _emscripten_postinvoke=true;
+
+
+ function _putchar(c) {
+ // int putchar(int c);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/putchar.html
+ return _fputc(c, HEAP32[((_stdout)>>2)]);
+ }
+ Module["_saveSetjmp"] = _saveSetjmp;
+
+ function _fwrite(ptr, size, nitems, stream) {
+ // size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html
+ var bytesToWrite = nitems * size;
+ if (bytesToWrite == 0) return 0;
+ var fd = _fileno(stream);
+ var bytesWritten = _write(fd, ptr, bytesToWrite);
+ if (bytesWritten == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return 0;
+ } else {
+ return Math.floor(bytesWritten / size);
+ }
+ }
+
+ function _system(command) {
+ // int system(const char *command);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/system.html
+ // Can't call external programs.
+ ___setErrNo(ERRNO_CODES.EAGAIN);
+ return -1;
+ }
+
+ function _frexp(x, exp_addr) {
+ var sig = 0, exp_ = 0;
+ if (x !== 0) {
+ var sign = 1;
+ if (x < 0) {
+ x = -x;
+ sign = -1;
+ }
+ var raw_exp = Math.log(x)/Math.log(2);
+ exp_ = Math.ceil(raw_exp);
+ if (exp_ === raw_exp) exp_ += 1;
+ sig = sign*x/Math.pow(2, exp_);
+ }
+ HEAP32[((exp_addr)>>2)]=exp_;
+ return sig;
+ }
+
+
+
+ var _tzname=allocate(8, "i32*", ALLOC_STATIC);
+
+ var _daylight=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _timezone=allocate(1, "i32*", ALLOC_STATIC);function _tzset() {
+ // TODO: Use (malleable) environment variables instead of system settings.
+ if (_tzset.called) return;
+ _tzset.called = true;
+
+ HEAP32[((_timezone)>>2)]=-(new Date()).getTimezoneOffset() * 60;
+
+ var winter = new Date(2000, 0, 1);
+ var summer = new Date(2000, 6, 1);
+ HEAP32[((_daylight)>>2)]=Number(winter.getTimezoneOffset() != summer.getTimezoneOffset());
+
+ var winterName = 'GMT'; // XXX do not rely on browser timezone info, it is very unpredictable | winter.toString().match(/\(([A-Z]+)\)/)[1];
+ var summerName = 'GMT'; // XXX do not rely on browser timezone info, it is very unpredictable | summer.toString().match(/\(([A-Z]+)\)/)[1];
+ var winterNamePtr = allocate(intArrayFromString(winterName), 'i8', ALLOC_NORMAL);
+ var summerNamePtr = allocate(intArrayFromString(summerName), 'i8', ALLOC_NORMAL);
+ HEAP32[((_tzname)>>2)]=winterNamePtr;
+ HEAP32[(((_tzname)+(4))>>2)]=summerNamePtr;
+ }function _mktime(tmPtr) {
+ _tzset();
+ var year = HEAP32[(((tmPtr)+(20))>>2)];
+ var timestamp = new Date(year >= 1900 ? year : year + 1900,
+ HEAP32[(((tmPtr)+(16))>>2)],
+ HEAP32[(((tmPtr)+(12))>>2)],
+ HEAP32[(((tmPtr)+(8))>>2)],
+ HEAP32[(((tmPtr)+(4))>>2)],
+ HEAP32[((tmPtr)>>2)],
+ 0).getTime() / 1000;
+ HEAP32[(((tmPtr)+(24))>>2)]=new Date(timestamp).getDay();
+ var yday = Math.round((timestamp - (new Date(year, 0, 1)).getTime()) / (1000 * 60 * 60 * 24));
+ HEAP32[(((tmPtr)+(28))>>2)]=yday;
+ return timestamp;
+ }
+
+ function _isalpha(chr) {
+ return (chr >= 97 && chr <= 122) ||
+ (chr >= 65 && chr <= 90);
+ }
+
+
+ function _malloc(bytes) {
+ /* Over-allocate to make sure it is byte-aligned by 8.
+ * This will leak memory, but this is only the dummy
+ * implementation (replaced by dlmalloc normally) so
+ * not an issue.
+ */
+ var ptr = Runtime.dynamicAlloc(bytes + 8);
+ return (ptr+8) & 0xFFFFFFF8;
+ }
+ Module["_malloc"] = _malloc;function _tmpnam(s, dir, prefix) {
+ // char *tmpnam(char *s);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/tmpnam.html
+ // NOTE: The dir and prefix arguments are for internal use only.
+ var folder = FS.findObject(dir || '/tmp');
+ if (!folder || !folder.isFolder) {
+ dir = '/tmp';
+ folder = FS.findObject(dir);
+ if (!folder || !folder.isFolder) return 0;
+ }
+ var name = prefix || 'file';
+ do {
+ name += String.fromCharCode(65 + Math.floor(Math.random() * 25));
+ } while (name in folder.contents);
+ var result = dir + '/' + name;
+ if (!_tmpnam.buffer) _tmpnam.buffer = _malloc(256);
+ if (!s) s = _tmpnam.buffer;
+ writeAsciiToMemory(result, s);
+ return s;
+ }
+
+ var Browser={mainLoop:{scheduler:null,method:"",shouldPause:false,paused:false,queue:[],pause:function () {
+ Browser.mainLoop.shouldPause = true;
+ },resume:function () {
+ if (Browser.mainLoop.paused) {
+ Browser.mainLoop.paused = false;
+ Browser.mainLoop.scheduler();
+ }
+ Browser.mainLoop.shouldPause = false;
+ },updateStatus:function () {
+ if (Module['setStatus']) {
+ var message = Module['statusMessage'] || 'Please wait...';
+ var remaining = Browser.mainLoop.remainingBlockers;
+ var expected = Browser.mainLoop.expectedBlockers;
+ if (remaining) {
+ if (remaining < expected) {
+ Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');
+ } else {
+ Module['setStatus'](message);
+ }
+ } else {
+ Module['setStatus']('');
+ }
+ }
+ }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {
+ if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers
+
+ if (Browser.initted || ENVIRONMENT_IS_WORKER) return;
+ Browser.initted = true;
+
+ try {
+ new Blob();
+ Browser.hasBlobConstructor = true;
+ } catch(e) {
+ Browser.hasBlobConstructor = false;
+ console.log("warning: no blob constructor, cannot create blobs with mimetypes");
+ }
+ Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null));
+ Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
+ if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {
+ console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
+ Module.noImageDecoding = true;
+ }
+
+ // Support for plugins that can process preloaded files. You can add more of these to
+ // your app by creating and appending to Module.preloadPlugins.
+ //
+ // Each plugin is asked if it can handle a file based on the file's name. If it can,
+ // it is given the file's raw data. When it is done, it calls a callback with the file's
+ // (possibly modified) data. For example, a plugin might decompress a file, or it
+ // might create some side data structure for use later (like an Image element, etc.).
+
+ var imagePlugin = {};
+ imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
+ return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
+ };
+ imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
+ var b = null;
+ if (Browser.hasBlobConstructor) {
+ try {
+ b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ if (b.size !== byteArray.length) { // Safari bug #118630
+ // Safari's Blob can only take an ArrayBuffer
+ b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
+ }
+ } catch(e) {
+ Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');
+ }
+ }
+ if (!b) {
+ var bb = new Browser.BlobBuilder();
+ bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range
+ b = bb.getBlob();
+ }
+ var url = Browser.URLObject.createObjectURL(b);
+ var img = new Image();
+ img.onload = function img_onload() {
+ assert(img.complete, 'Image ' + name + ' could not be decoded');
+ var canvas = document.createElement('canvas');
+ canvas.width = img.width;
+ canvas.height = img.height;
+ var ctx = canvas.getContext('2d');
+ ctx.drawImage(img, 0, 0);
+ Module["preloadedImages"][name] = canvas;
+ Browser.URLObject.revokeObjectURL(url);
+ if (onload) onload(byteArray);
+ };
+ img.onerror = function img_onerror(event) {
+ console.log('Image ' + url + ' could not be decoded');
+ if (onerror) onerror();
+ };
+ img.src = url;
+ };
+ Module['preloadPlugins'].push(imagePlugin);
+
+ var audioPlugin = {};
+ audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
+ return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
+ };
+ audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
+ var done = false;
+ function finish(audio) {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = audio;
+ if (onload) onload(byteArray);
+ }
+ function fail() {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = new Audio(); // empty shim
+ if (onerror) onerror();
+ }
+ if (Browser.hasBlobConstructor) {
+ try {
+ var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ } catch(e) {
+ return fail();
+ }
+ var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
+ var audio = new Audio();
+ audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
+ audio.onerror = function audio_onerror(event) {
+ if (done) return;
+ console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
+ function encode64(data) {
+ var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ var PAD = '=';
+ var ret = '';
+ var leftchar = 0;
+ var leftbits = 0;
+ for (var i = 0; i < data.length; i++) {
+ leftchar = (leftchar << 8) | data[i];
+ leftbits += 8;
+ while (leftbits >= 6) {
+ var curr = (leftchar >> (leftbits-6)) & 0x3f;
+ leftbits -= 6;
+ ret += BASE[curr];
+ }
+ }
+ if (leftbits == 2) {
+ ret += BASE[(leftchar&3) << 4];
+ ret += PAD + PAD;
+ } else if (leftbits == 4) {
+ ret += BASE[(leftchar&0xf) << 2];
+ ret += PAD;
+ }
+ return ret;
+ }
+ audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);
+ finish(audio); // we don't wait for confirmation this worked - but it's worth trying
+ };
+ audio.src = url;
+ // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror
+ Browser.safeSetTimeout(function() {
+ finish(audio); // try to use it even though it is not necessarily ready to play
+ }, 10000);
+ } else {
+ return fail();
+ }
+ };
+ Module['preloadPlugins'].push(audioPlugin);
+
+ // Canvas event setup
+
+ var canvas = Module['canvas'];
+
+ // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module
+ // Module['forcedAspectRatio'] = 4 / 3;
+
+ canvas.requestPointerLock = canvas['requestPointerLock'] ||
+ canvas['mozRequestPointerLock'] ||
+ canvas['webkitRequestPointerLock'] ||
+ canvas['msRequestPointerLock'] ||
+ function(){};
+ canvas.exitPointerLock = document['exitPointerLock'] ||
+ document['mozExitPointerLock'] ||
+ document['webkitExitPointerLock'] ||
+ document['msExitPointerLock'] ||
+ function(){}; // no-op if function does not exist
+ canvas.exitPointerLock = canvas.exitPointerLock.bind(document);
+
+ function pointerLockChange() {
+ Browser.pointerLock = document['pointerLockElement'] === canvas ||
+ document['mozPointerLockElement'] === canvas ||
+ document['webkitPointerLockElement'] === canvas ||
+ document['msPointerLockElement'] === canvas;
+ }
+
+ document.addEventListener('pointerlockchange', pointerLockChange, false);
+ document.addEventListener('mozpointerlockchange', pointerLockChange, false);
+ document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
+ document.addEventListener('mspointerlockchange', pointerLockChange, false);
+
+ if (Module['elementPointerLock']) {
+ canvas.addEventListener("click", function(ev) {
+ if (!Browser.pointerLock && canvas.requestPointerLock) {
+ canvas.requestPointerLock();
+ ev.preventDefault();
+ }
+ }, false);
+ }
+ },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) {
+ var ctx;
+ var errorInfo = '?';
+ function onContextCreationError(event) {
+ errorInfo = event.statusMessage || errorInfo;
+ }
+ try {
+ if (useWebGL) {
+ var contextAttributes = {
+ antialias: false,
+ alpha: false
+ };
+
+ if (webGLContextAttributes) {
+ for (var attribute in webGLContextAttributes) {
+ contextAttributes[attribute] = webGLContextAttributes[attribute];
+ }
+ }
+
+
+ canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
+ try {
+ ['experimental-webgl', 'webgl'].some(function(webglId) {
+ return ctx = canvas.getContext(webglId, contextAttributes);
+ });
+ } finally {
+ canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
+ }
+ } else {
+ ctx = canvas.getContext('2d');
+ }
+ if (!ctx) throw ':(';
+ } catch (e) {
+ Module.print('Could not create canvas: ' + [errorInfo, e]);
+ return null;
+ }
+ if (useWebGL) {
+ // Set the background of the WebGL canvas to black
+ canvas.style.backgroundColor = "black";
+
+ // Warn on context loss
+ canvas.addEventListener('webglcontextlost', function(event) {
+ alert('WebGL context lost. You will need to reload the page.');
+ }, false);
+ }
+ if (setInModule) {
+ GLctx = Module.ctx = ctx;
+ Module.useWebGL = useWebGL;
+ Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
+ Browser.init();
+ }
+ return ctx;
+ },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {
+ Browser.lockPointer = lockPointer;
+ Browser.resizeCanvas = resizeCanvas;
+ if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;
+ if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;
+
+ var canvas = Module['canvas'];
+ function fullScreenChange() {
+ Browser.isFullScreen = false;
+ var canvasContainer = canvas.parentNode;
+ if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvasContainer) {
+ canvas.cancelFullScreen = document['cancelFullScreen'] ||
+ document['mozCancelFullScreen'] ||
+ document['webkitCancelFullScreen'] ||
+ document['msExitFullscreen'] ||
+ document['exitFullscreen'] ||
+ function() {};
+ canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);
+ if (Browser.lockPointer) canvas.requestPointerLock();
+ Browser.isFullScreen = true;
+ if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();
+ } else {
+
+ // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen
+ canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
+ canvasContainer.parentNode.removeChild(canvasContainer);
+
+ if (Browser.resizeCanvas) Browser.setWindowedCanvasSize();
+ }
+ if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);
+ Browser.updateCanvasDimensions(canvas);
+ }
+
+ if (!Browser.fullScreenHandlersInstalled) {
+ Browser.fullScreenHandlersInstalled = true;
+ document.addEventListener('fullscreenchange', fullScreenChange, false);
+ document.addEventListener('mozfullscreenchange', fullScreenChange, false);
+ document.addEventListener('webkitfullscreenchange', fullScreenChange, false);
+ document.addEventListener('MSFullscreenChange', fullScreenChange, false);
+ }
+
+ // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root
+ var canvasContainer = document.createElement("div");
+ canvas.parentNode.insertBefore(canvasContainer, canvas);
+ canvasContainer.appendChild(canvas);
+
+ // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size)
+ canvasContainer.requestFullScreen = canvasContainer['requestFullScreen'] ||
+ canvasContainer['mozRequestFullScreen'] ||
+ canvasContainer['msRequestFullscreen'] ||
+ (canvasContainer['webkitRequestFullScreen'] ? function() { canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);
+ canvasContainer.requestFullScreen();
+ },requestAnimationFrame:function requestAnimationFrame(func) {
+ if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
+ setTimeout(func, 1000/60);
+ } else {
+ if (!window.requestAnimationFrame) {
+ window.requestAnimationFrame = window['requestAnimationFrame'] ||
+ window['mozRequestAnimationFrame'] ||
+ window['webkitRequestAnimationFrame'] ||
+ window['msRequestAnimationFrame'] ||
+ window['oRequestAnimationFrame'] ||
+ window['setTimeout'];
+ }
+ window.requestAnimationFrame(func);
+ }
+ },safeCallback:function (func) {
+ return function() {
+ if (!ABORT) return func.apply(null, arguments);
+ };
+ },safeRequestAnimationFrame:function (func) {
+ return Browser.requestAnimationFrame(function() {
+ if (!ABORT) func();
+ });
+ },safeSetTimeout:function (func, timeout) {
+ return setTimeout(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },safeSetInterval:function (func, timeout) {
+ return setInterval(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },getMimetype:function (name) {
+ return {
+ 'jpg': 'image/jpeg',
+ 'jpeg': 'image/jpeg',
+ 'png': 'image/png',
+ 'bmp': 'image/bmp',
+ 'ogg': 'audio/ogg',
+ 'wav': 'audio/wav',
+ 'mp3': 'audio/mpeg'
+ }[name.substr(name.lastIndexOf('.')+1)];
+ },getUserMedia:function (func) {
+ if(!window.getUserMedia) {
+ window.getUserMedia = navigator['getUserMedia'] ||
+ navigator['mozGetUserMedia'];
+ }
+ window.getUserMedia(func);
+ },getMovementX:function (event) {
+ return event['movementX'] ||
+ event['mozMovementX'] ||
+ event['webkitMovementX'] ||
+ 0;
+ },getMovementY:function (event) {
+ return event['movementY'] ||
+ event['mozMovementY'] ||
+ event['webkitMovementY'] ||
+ 0;
+ },getMouseWheelDelta:function (event) {
+ return Math.max(-1, Math.min(1, event.type === 'DOMMouseScroll' ? event.detail : -event.wheelDelta));
+ },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup
+ if (Browser.pointerLock) {
+ // When the pointer is locked, calculate the coordinates
+ // based on the movement of the mouse.
+ // Workaround for Firefox bug 764498
+ if (event.type != 'mousemove' &&
+ ('mozMovementX' in event)) {
+ Browser.mouseMovementX = Browser.mouseMovementY = 0;
+ } else {
+ Browser.mouseMovementX = Browser.getMovementX(event);
+ Browser.mouseMovementY = Browser.getMovementY(event);
+ }
+
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
+ Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
+ } else {
+ // just add the mouse delta to the current absolut mouse position
+ // FIXME: ideally this should be clamped against the canvas size and zero
+ Browser.mouseX += Browser.mouseMovementX;
+ Browser.mouseY += Browser.mouseMovementY;
+ }
+ } else {
+ // Otherwise, calculate the movement based on the changes
+ // in the coordinates.
+ var rect = Module["canvas"].getBoundingClientRect();
+ var x, y;
+
+ // Neither .scrollX or .pageXOffset are defined in a spec, but
+ // we prefer .scrollX because it is currently in a spec draft.
+ // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
+ var scrollX = ((typeof window.scrollX !== 'undefined') ? window.scrollX : window.pageXOffset);
+ var scrollY = ((typeof window.scrollY !== 'undefined') ? window.scrollY : window.pageYOffset);
+ if (event.type == 'touchstart' ||
+ event.type == 'touchend' ||
+ event.type == 'touchmove') {
+ var t = event.touches.item(0);
+ if (t) {
+ x = t.pageX - (scrollX + rect.left);
+ y = t.pageY - (scrollY + rect.top);
+ } else {
+ return;
+ }
+ } else {
+ x = event.pageX - (scrollX + rect.left);
+ y = event.pageY - (scrollY + rect.top);
+ }
+
+ // the canvas might be CSS-scaled compared to its backbuffer;
+ // SDL-using content will want mouse coordinates in terms
+ // of backbuffer units.
+ var cw = Module["canvas"].width;
+ var ch = Module["canvas"].height;
+ x = x * (cw / rect.width);
+ y = y * (ch / rect.height);
+
+ Browser.mouseMovementX = x - Browser.mouseX;
+ Browser.mouseMovementY = y - Browser.mouseY;
+ Browser.mouseX = x;
+ Browser.mouseY = y;
+ }
+ },xhrLoad:function (url, onload, onerror) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, true);
+ xhr.responseType = 'arraybuffer';
+ xhr.onload = function xhr_onload() {
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
+ onload(xhr.response);
+ } else {
+ onerror();
+ }
+ };
+ xhr.onerror = onerror;
+ xhr.send(null);
+ },asyncLoad:function (url, onload, onerror, noRunDep) {
+ Browser.xhrLoad(url, function(arrayBuffer) {
+ assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
+ onload(new Uint8Array(arrayBuffer));
+ if (!noRunDep) removeRunDependency('al ' + url);
+ }, function(event) {
+ if (onerror) {
+ onerror();
+ } else {
+ throw 'Loading data file "' + url + '" failed.';
+ }
+ });
+ if (!noRunDep) addRunDependency('al ' + url);
+ },resizeListeners:[],updateResizeListeners:function () {
+ var canvas = Module['canvas'];
+ Browser.resizeListeners.forEach(function(listener) {
+ listener(canvas.width, canvas.height);
+ });
+ },setCanvasSize:function (width, height, noUpdates) {
+ var canvas = Module['canvas'];
+ Browser.updateCanvasDimensions(canvas, width, height);
+ if (!noUpdates) Browser.updateResizeListeners();
+ },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },setWindowedCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },updateCanvasDimensions:function (canvas, wNative, hNative) {
+ if (wNative && hNative) {
+ canvas.widthNative = wNative;
+ canvas.heightNative = hNative;
+ } else {
+ wNative = canvas.widthNative;
+ hNative = canvas.heightNative;
+ }
+ var w = wNative;
+ var h = hNative;
+ if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) {
+ if (w/h < Module['forcedAspectRatio']) {
+ w = Math.round(h * Module['forcedAspectRatio']);
+ } else {
+ h = Math.round(w / Module['forcedAspectRatio']);
+ }
+ }
+ if (((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
+ var factor = Math.min(screen.width / w, screen.height / h);
+ w = Math.round(w * factor);
+ h = Math.round(h * factor);
+ }
+ if (Browser.resizeCanvas) {
+ if (canvas.width != w) canvas.width = w;
+ if (canvas.height != h) canvas.height = h;
+ if (typeof canvas.style != 'undefined') {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ } else {
+ if (canvas.width != wNative) canvas.width = wNative;
+ if (canvas.height != hNative) canvas.height = hNative;
+ if (typeof canvas.style != 'undefined') {
+ if (w != wNative || h != hNative) {
+ canvas.style.setProperty( "width", w + "px", "important");
+ canvas.style.setProperty("height", h + "px", "important");
+ } else {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ }
+ }
+ }};
+
+ function _log10(x) {
+ return Math.log(x) / Math.LN10;
+ }
+
+ function _isspace(chr) {
+ return (chr == 32) || (chr >= 9 && chr <= 13);
+ }
+
+
+ var ___tm_current=allocate(44, "i8", ALLOC_STATIC);
+
+
+ var ___tm_timezone=allocate(intArrayFromString("GMT"), "i8", ALLOC_STATIC);function _localtime_r(time, tmPtr) {
+ _tzset();
+ var date = new Date(HEAP32[((time)>>2)]*1000);
+ HEAP32[((tmPtr)>>2)]=date.getSeconds();
+ HEAP32[(((tmPtr)+(4))>>2)]=date.getMinutes();
+ HEAP32[(((tmPtr)+(8))>>2)]=date.getHours();
+ HEAP32[(((tmPtr)+(12))>>2)]=date.getDate();
+ HEAP32[(((tmPtr)+(16))>>2)]=date.getMonth();
+ HEAP32[(((tmPtr)+(20))>>2)]=date.getFullYear()-1900;
+ HEAP32[(((tmPtr)+(24))>>2)]=date.getDay();
+
+ var start = new Date(date.getFullYear(), 0, 1);
+ var yday = Math.floor((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));
+ HEAP32[(((tmPtr)+(28))>>2)]=yday;
+ HEAP32[(((tmPtr)+(36))>>2)]=start.getTimezoneOffset() * 60;
+
+ var dst = Number(start.getTimezoneOffset() != date.getTimezoneOffset());
+ HEAP32[(((tmPtr)+(32))>>2)]=dst;
+
+ HEAP32[(((tmPtr)+(40))>>2)]=___tm_timezone;
+
+ return tmPtr;
+ }function _localtime(time) {
+ return _localtime_r(time, ___tm_current);
+ }
+
+ function _srand(seed) {
+ HEAP32[((___rand_seed)>>2)]=seed
+ }
+
+ var _emscripten_prep_setjmp=true;
+
+
+
+
+ Module["_testSetjmp"] = _testSetjmp;function _longjmp(env, value) {
+ asm['setThrew'](env, value || 1);
+ throw 'longjmp';
+ }function _emscripten_longjmp(env, value) {
+ _longjmp(env, value);
+ }
+
+ var _ceil=Math_ceil;
+
+
+ function _emscripten_memcpy_big(dest, src, num) {
+ HEAPU8.set(HEAPU8.subarray(src, src+num), dest);
+ return dest;
+ }
+ Module["_memcpy"] = _memcpy;
+
+ var _llvm_pow_f64=Math_pow;
+
+
+
+ Module["_strlen"] = _strlen;function _fputs(s, stream) {
+ // int fputs(const char *restrict s, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputs.html
+ var fd = _fileno(stream);
+ return _write(fd, s, _strlen(s));
+ }
+
+ function _sbrk(bytes) {
+ // Implement a Linux-like 'memory area' for our 'process'.
+ // Changes the size of the memory area by |bytes|; returns the
+ // address of the previous top ('break') of the memory area
+ // We control the "dynamic" memory - DYNAMIC_BASE to DYNAMICTOP
+ var self = _sbrk;
+ if (!self.called) {
+ DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned
+ self.called = true;
+ assert(Runtime.dynamicAlloc);
+ self.alloc = Runtime.dynamicAlloc;
+ Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') };
+ }
+ var ret = DYNAMICTOP;
+ if (bytes != 0) self.alloc(bytes);
+ return ret; // Previous break location.
+ }
+
+
+ function _sinh(x) {
+ var p = Math.pow(Math.E, x);
+ return (p - (1 / p)) / 2;
+ }
+
+ function _cosh(x) {
+ var p = Math.pow(Math.E, x);
+ return (p + (1 / p)) / 2;
+ }function _tanh(x) {
+ return _sinh(x) / _cosh(x);
+ }
+
+ function _signal(sig, func) {
+ // TODO
+ return 0;
+ }
+
+
+
+ function __getFloat(text) {
+ return /^[+-]?[0-9]*\.?[0-9]+([eE][+-]?[0-9]+)?/.exec(text);
+ }function __scanString(format, get, unget, varargs) {
+ if (!__scanString.whiteSpace) {
+ __scanString.whiteSpace = {};
+ __scanString.whiteSpace[32] = 1;
+ __scanString.whiteSpace[9] = 1;
+ __scanString.whiteSpace[10] = 1;
+ __scanString.whiteSpace[11] = 1;
+ __scanString.whiteSpace[12] = 1;
+ __scanString.whiteSpace[13] = 1;
+ }
+ // Supports %x, %4x, %d.%d, %lld, %s, %f, %lf.
+ // TODO: Support all format specifiers.
+ format = Pointer_stringify(format);
+ var soFar = 0;
+ if (format.indexOf('%n') >= 0) {
+ // need to track soFar
+ var _get = get;
+ get = function get() {
+ soFar++;
+ return _get();
+ }
+ var _unget = unget;
+ unget = function unget() {
+ soFar--;
+ return _unget();
+ }
+ }
+ var formatIndex = 0;
+ var argsi = 0;
+ var fields = 0;
+ var argIndex = 0;
+ var next;
+
+ mainLoop:
+ for (var formatIndex = 0; formatIndex < format.length;) {
+ if (format[formatIndex] === '%' && format[formatIndex+1] == 'n') {
+ var argPtr = HEAP32[(((varargs)+(argIndex))>>2)];
+ argIndex += Runtime.getAlignSize('void*', null, true);
+ HEAP32[((argPtr)>>2)]=soFar;
+ formatIndex += 2;
+ continue;
+ }
+
+ if (format[formatIndex] === '%') {
+ var nextC = format.indexOf('c', formatIndex+1);
+ if (nextC > 0) {
+ var maxx = 1;
+ if (nextC > formatIndex+1) {
+ var sub = format.substring(formatIndex+1, nextC);
+ maxx = parseInt(sub);
+ if (maxx != sub) maxx = 0;
+ }
+ if (maxx) {
+ var argPtr = HEAP32[(((varargs)+(argIndex))>>2)];
+ argIndex += Runtime.getAlignSize('void*', null, true);
+ fields++;
+ for (var i = 0; i < maxx; i++) {
+ next = get();
+ HEAP8[((argPtr++)|0)]=next;
+ if (next === 0) return i > 0 ? fields : fields-1; // we failed to read the full length of this field
+ }
+ formatIndex += nextC - formatIndex + 1;
+ continue;
+ }
+ }
+ }
+
+ // handle %[...]
+ if (format[formatIndex] === '%' && format.indexOf('[', formatIndex+1) > 0) {
+ var match = /\%([0-9]*)\[(\^)?(\]?[^\]]*)\]/.exec(format.substring(formatIndex));
+ if (match) {
+ var maxNumCharacters = parseInt(match[1]) || Infinity;
+ var negateScanList = (match[2] === '^');
+ var scanList = match[3];
+
+ // expand "middle" dashs into character sets
+ var middleDashMatch;
+ while ((middleDashMatch = /([^\-])\-([^\-])/.exec(scanList))) {
+ var rangeStartCharCode = middleDashMatch[1].charCodeAt(0);
+ var rangeEndCharCode = middleDashMatch[2].charCodeAt(0);
+ for (var expanded = ''; rangeStartCharCode <= rangeEndCharCode; expanded += String.fromCharCode(rangeStartCharCode++));
+ scanList = scanList.replace(middleDashMatch[1] + '-' + middleDashMatch[2], expanded);
+ }
+
+ var argPtr = HEAP32[(((varargs)+(argIndex))>>2)];
+ argIndex += Runtime.getAlignSize('void*', null, true);
+ fields++;
+
+ for (var i = 0; i < maxNumCharacters; i++) {
+ next = get();
+ if (negateScanList) {
+ if (scanList.indexOf(String.fromCharCode(next)) < 0) {
+ HEAP8[((argPtr++)|0)]=next;
+ } else {
+ unget();
+ break;
+ }
+ } else {
+ if (scanList.indexOf(String.fromCharCode(next)) >= 0) {
+ HEAP8[((argPtr++)|0)]=next;
+ } else {
+ unget();
+ break;
+ }
+ }
+ }
+
+ // write out null-terminating character
+ HEAP8[((argPtr++)|0)]=0;
+ formatIndex += match[0].length;
+
+ continue;
+ }
+ }
+ // remove whitespace
+ while (1) {
+ next = get();
+ if (next == 0) return fields;
+ if (!(next in __scanString.whiteSpace)) break;
+ }
+ unget();
+
+ if (format[formatIndex] === '%') {
+ formatIndex++;
+ var suppressAssignment = false;
+ if (format[formatIndex] == '*') {
+ suppressAssignment = true;
+ formatIndex++;
+ }
+ var maxSpecifierStart = formatIndex;
+ while (format[formatIndex].charCodeAt(0) >= 48 &&
+ format[formatIndex].charCodeAt(0) <= 57) {
+ formatIndex++;
+ }
+ var max_;
+ if (formatIndex != maxSpecifierStart) {
+ max_ = parseInt(format.slice(maxSpecifierStart, formatIndex), 10);
+ }
+ var long_ = false;
+ var half = false;
+ var longLong = false;
+ if (format[formatIndex] == 'l') {
+ long_ = true;
+ formatIndex++;
+ if (format[formatIndex] == 'l') {
+ longLong = true;
+ formatIndex++;
+ }
+ } else if (format[formatIndex] == 'h') {
+ half = true;
+ formatIndex++;
+ }
+ var type = format[formatIndex];
+ formatIndex++;
+ var curr = 0;
+ var buffer = [];
+ // Read characters according to the format. floats are trickier, they may be in an unfloat state in the middle, then be a valid float later
+ if (type == 'f' || type == 'e' || type == 'g' ||
+ type == 'F' || type == 'E' || type == 'G') {
+ next = get();
+ while (next > 0 && (!(next in __scanString.whiteSpace))) {
+ buffer.push(String.fromCharCode(next));
+ next = get();
+ }
+ var m = __getFloat(buffer.join(''));
+ var last = m ? m[0].length : 0;
+ for (var i = 0; i < buffer.length - last + 1; i++) {
+ unget();
+ }
+ buffer.length = last;
+ } else {
+ next = get();
+ var first = true;
+
+ // Strip the optional 0x prefix for %x.
+ if ((type == 'x' || type == 'X') && (next == 48)) {
+ var peek = get();
+ if (peek == 120 || peek == 88) {
+ next = get();
+ } else {
+ unget();
+ }
+ }
+
+ while ((curr < max_ || isNaN(max_)) && next > 0) {
+ if (!(next in __scanString.whiteSpace) && // stop on whitespace
+ (type == 's' ||
+ ((type === 'd' || type == 'u' || type == 'i') && ((next >= 48 && next <= 57) ||
+ (first && next == 45))) ||
+ ((type === 'x' || type === 'X') && (next >= 48 && next <= 57 ||
+ next >= 97 && next <= 102 ||
+ next >= 65 && next <= 70))) &&
+ (formatIndex >= format.length || next !== format[formatIndex].charCodeAt(0))) { // Stop when we read something that is coming up
+ buffer.push(String.fromCharCode(next));
+ next = get();
+ curr++;
+ first = false;
+ } else {
+ break;
+ }
+ }
+ unget();
+ }
+ if (buffer.length === 0) return 0; // Failure.
+ if (suppressAssignment) continue;
+
+ var text = buffer.join('');
+ var argPtr = HEAP32[(((varargs)+(argIndex))>>2)];
+ argIndex += Runtime.getAlignSize('void*', null, true);
+ switch (type) {
+ case 'd': case 'u': case 'i':
+ if (half) {
+ HEAP16[((argPtr)>>1)]=parseInt(text, 10);
+ } else if (longLong) {
+ (tempI64 = [parseInt(text, 10)>>>0,(tempDouble=parseInt(text, 10),(+(Math_abs(tempDouble))) >= (+1) ? (tempDouble > (+0) ? ((Math_min((+(Math_floor((tempDouble)/(+4294967296)))), (+4294967295)))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+4294967296))))))>>>0) : 0)],HEAP32[((argPtr)>>2)]=tempI64[0],HEAP32[(((argPtr)+(4))>>2)]=tempI64[1]);
+ } else {
+ HEAP32[((argPtr)>>2)]=parseInt(text, 10);
+ }
+ break;
+ case 'X':
+ case 'x':
+ HEAP32[((argPtr)>>2)]=parseInt(text, 16);
+ break;
+ case 'F':
+ case 'f':
+ case 'E':
+ case 'e':
+ case 'G':
+ case 'g':
+ case 'E':
+ // fallthrough intended
+ if (long_) {
+ HEAPF64[((argPtr)>>3)]=parseFloat(text);
+ } else {
+ HEAPF32[((argPtr)>>2)]=parseFloat(text);
+ }
+ break;
+ case 's':
+ var array = intArrayFromString(text);
+ for (var j = 0; j < array.length; j++) {
+ HEAP8[(((argPtr)+(j))|0)]=array[j];
+ }
+ break;
+ }
+ fields++;
+ } else if (format[formatIndex].charCodeAt(0) in __scanString.whiteSpace) {
+ next = get();
+ while (next in __scanString.whiteSpace) {
+ if (next <= 0) break mainLoop; // End of input.
+ next = get();
+ }
+ unget(next);
+ formatIndex++;
+ } else {
+ // Not a specifier.
+ next = get();
+ if (format[formatIndex].charCodeAt(0) !== next) {
+ unget(next);
+ break mainLoop;
+ }
+ formatIndex++;
+ }
+ }
+ return fields;
+ }
+
+ function _fgetc(stream) {
+ // int fgetc(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fgetc.html
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (!streamObj) return -1;
+ if (streamObj.eof || streamObj.error) return -1;
+ var ret = _fread(_fgetc.ret, 1, 1, stream);
+ if (ret == 0) {
+ return -1;
+ } else if (ret == -1) {
+ streamObj.error = true;
+ return -1;
+ } else {
+ return HEAPU8[((_fgetc.ret)|0)];
+ }
+ }
+
+ function _ungetc(c, stream) {
+ // int ungetc(int c, FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/ungetc.html
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) {
+ return -1;
+ }
+ if (c === -1) {
+ // do nothing for EOF character
+ return c;
+ }
+ c = unSign(c & 0xFF);
+ stream.ungotten.push(c);
+ stream.eof = false;
+ return c;
+ }function _fscanf(stream, format, varargs) {
+ // int fscanf(FILE *restrict stream, const char *restrict format, ... );
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/scanf.html
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (!streamObj) {
+ return -1;
+ }
+ var buffer = [];
+ function get() {
+ var c = _fgetc(stream);
+ buffer.push(c);
+ return c;
+ };
+ function unget() {
+ _ungetc(buffer.pop(), stream);
+ };
+ return __scanString(format, get, unget, varargs);
+ }
+
+ var _emscripten_preinvoke=true;
+
+ function _localeconv() {
+ // %struct.timeval = type { char* decimal point, other stuff... }
+ // var indexes = Runtime.calculateStructAlignment({ fields: ['i32', 'i32'] });
+ var me = _localeconv;
+ if (!me.ret) {
+ // These are defaults from the "C" locale
+ me.ret = allocate([
+ allocate(intArrayFromString('.'), 'i8', ALLOC_NORMAL),0,0,0, // decimal_point
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // thousands_sep
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // grouping
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // int_curr_symbol
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // currency_symbol
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // mon_decimal_point
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // mon_thousands_sep
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // mon_grouping
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0, // positive_sign
+ allocate(intArrayFromString(''), 'i8', ALLOC_NORMAL),0,0,0 // negative_sign
+ ], 'i8*', ALLOC_NORMAL); // Allocate strings in lconv, still don't allocate chars
+ }
+ return me.ret;
+ }
+
+
+ function _unlink(path) {
+ // int unlink(const char *path);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/unlink.html
+ path = Pointer_stringify(path);
+ try {
+ FS.unlink(path);
+ return 0;
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }
+
+ function _rmdir(path) {
+ // int rmdir(const char *path);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/rmdir.html
+ path = Pointer_stringify(path);
+ try {
+ FS.rmdir(path);
+ return 0;
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _remove(path) {
+ // int remove(const char *path);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/remove.html
+ var ret = _unlink(path);
+ if (ret == -1) ret = _rmdir(path);
+ return ret;
+ }
+
+ function _freopen(filename, mode, stream) {
+ // FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/freopen.html
+ if (!filename) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (!streamObj) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return 0;
+ }
+ if (_freopen.buffer) _free(_freopen.buffer);
+ filename = intArrayFromString(streamObj.path);
+ filename = allocate(filename, 'i8', ALLOC_NORMAL);
+ }
+ _fclose(stream);
+ return _fopen(filename, mode);
+ }
+
+
+ function _rename(old_path, new_path) {
+ // int rename(const char *old, const char *new);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/rename.html
+ old_path = Pointer_stringify(old_path);
+ new_path = Pointer_stringify(new_path);
+ try {
+ FS.rename(old_path, new_path);
+ return 0;
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }
+
+ function _tmpfile() {
+ // FILE *tmpfile(void);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/tmpfile.html
+ // TODO: Delete the created file on closing.
+ if (_tmpfile.mode) {
+ _tmpfile.mode = allocate(intArrayFromString('w+'), 'i8', ALLOC_NORMAL);
+ }
+ return _fopen(_tmpnam(0), _tmpfile.mode);
+ }
+
+ function _sysconf(name) {
+ // long sysconf(int name);
+ // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html
+ switch(name) {
+ case 30: return PAGE_SIZE;
+ case 132:
+ case 133:
+ case 12:
+ case 137:
+ case 138:
+ case 15:
+ case 235:
+ case 16:
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ case 149:
+ case 13:
+ case 10:
+ case 236:
+ case 153:
+ case 9:
+ case 21:
+ case 22:
+ case 159:
+ case 154:
+ case 14:
+ case 77:
+ case 78:
+ case 139:
+ case 80:
+ case 81:
+ case 79:
+ case 82:
+ case 68:
+ case 67:
+ case 164:
+ case 11:
+ case 29:
+ case 47:
+ case 48:
+ case 95:
+ case 52:
+ case 51:
+ case 46:
+ return 200809;
+ case 27:
+ case 246:
+ case 127:
+ case 128:
+ case 23:
+ case 24:
+ case 160:
+ case 161:
+ case 181:
+ case 182:
+ case 242:
+ case 183:
+ case 184:
+ case 243:
+ case 244:
+ case 245:
+ case 165:
+ case 178:
+ case 179:
+ case 49:
+ case 50:
+ case 168:
+ case 169:
+ case 175:
+ case 170:
+ case 171:
+ case 172:
+ case 97:
+ case 76:
+ case 32:
+ case 173:
+ case 35:
+ return -1;
+ case 176:
+ case 177:
+ case 7:
+ case 155:
+ case 8:
+ case 157:
+ case 125:
+ case 126:
+ case 92:
+ case 93:
+ case 129:
+ case 130:
+ case 131:
+ case 94:
+ case 91:
+ return 1;
+ case 74:
+ case 60:
+ case 69:
+ case 70:
+ case 4:
+ return 1024;
+ case 31:
+ case 42:
+ case 72:
+ return 32;
+ case 87:
+ case 26:
+ case 33:
+ return 2147483647;
+ case 34:
+ case 1:
+ return 47839;
+ case 38:
+ case 36:
+ return 99;
+ case 43:
+ case 37:
+ return 2048;
+ case 0: return 2097152;
+ case 3: return 65536;
+ case 28: return 32768;
+ case 44: return 32767;
+ case 75: return 16384;
+ case 39: return 1000;
+ case 89: return 700;
+ case 71: return 256;
+ case 40: return 255;
+ case 2: return 100;
+ case 180: return 64;
+ case 25: return 20;
+ case 5: return 16;
+ case 6: return 6;
+ case 73: return 4;
+ case 84: return 1;
+ }
+ ___setErrNo(ERRNO_CODES.EINVAL);
+ return -1;
+ }
+
+
+ function ___errno_location() {
+ return ___errno_state;
+ }
+
+
+ Module["_memset"] = _memset;
+
+
+
+ Module["_bitshift64Shl"] = _bitshift64Shl;
+
+ function _abort() {
+ Module['abort']();
+ }
+
+
+
+ function __reallyNegative(x) {
+ return x < 0 || (x === 0 && (1/x) === -Infinity);
+ }function __formatString(format, varargs) {
+ var textIndex = format;
+ var argIndex = 0;
+ function getNextArg(type) {
+ // NOTE: Explicitly ignoring type safety. Otherwise this fails:
+ // int x = 4; printf("%c\n", (char)x);
+ var ret;
+ if (type === 'double') {
+ ret = HEAPF64[(((varargs)+(argIndex))>>3)];
+ } else if (type == 'i64') {
+ ret = [HEAP32[(((varargs)+(argIndex))>>2)],
+ HEAP32[(((varargs)+(argIndex+4))>>2)]];
+
+ } else {
+ type = 'i32'; // varargs are always i32, i64, or double
+ ret = HEAP32[(((varargs)+(argIndex))>>2)];
+ }
+ argIndex += Runtime.getNativeFieldSize(type);
+ return ret;
+ }
+
+ var ret = [];
+ var curr, next, currArg;
+ while(1) {
+ var startTextIndex = textIndex;
+ curr = HEAP8[(textIndex)];
+ if (curr === 0) break;
+ next = HEAP8[((textIndex+1)|0)];
+ if (curr == 37) {
+ // Handle flags.
+ var flagAlwaysSigned = false;
+ var flagLeftAlign = false;
+ var flagAlternative = false;
+ var flagZeroPad = false;
+ var flagPadSign = false;
+ flagsLoop: while (1) {
+ switch (next) {
+ case 43:
+ flagAlwaysSigned = true;
+ break;
+ case 45:
+ flagLeftAlign = true;
+ break;
+ case 35:
+ flagAlternative = true;
+ break;
+ case 48:
+ if (flagZeroPad) {
+ break flagsLoop;
+ } else {
+ flagZeroPad = true;
+ break;
+ }
+ case 32:
+ flagPadSign = true;
+ break;
+ default:
+ break flagsLoop;
+ }
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+
+ // Handle width.
+ var width = 0;
+ if (next == 42) {
+ width = getNextArg('i32');
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ } else {
+ while (next >= 48 && next <= 57) {
+ width = width * 10 + (next - 48);
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ }
+
+ // Handle precision.
+ var precisionSet = false, precision = -1;
+ if (next == 46) {
+ precision = 0;
+ precisionSet = true;
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ if (next == 42) {
+ precision = getNextArg('i32');
+ textIndex++;
+ } else {
+ while(1) {
+ var precisionChr = HEAP8[((textIndex+1)|0)];
+ if (precisionChr < 48 ||
+ precisionChr > 57) break;
+ precision = precision * 10 + (precisionChr - 48);
+ textIndex++;
+ }
+ }
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ if (precision < 0) {
+ precision = 6; // Standard default.
+ precisionSet = false;
+ }
+
+ // Handle integer sizes. WARNING: These assume a 32-bit architecture!
+ var argSize;
+ switch (String.fromCharCode(next)) {
+ case 'h':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 104) {
+ textIndex++;
+ argSize = 1; // char (actually i32 in varargs)
+ } else {
+ argSize = 2; // short (actually i32 in varargs)
+ }
+ break;
+ case 'l':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 108) {
+ textIndex++;
+ argSize = 8; // long long
+ } else {
+ argSize = 4; // long
+ }
+ break;
+ case 'L': // long long
+ case 'q': // int64_t
+ case 'j': // intmax_t
+ argSize = 8;
+ break;
+ case 'z': // size_t
+ case 't': // ptrdiff_t
+ case 'I': // signed ptrdiff_t or unsigned size_t
+ argSize = 4;
+ break;
+ default:
+ argSize = null;
+ }
+ if (argSize) textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+
+ // Handle type specifier.
+ switch (String.fromCharCode(next)) {
+ case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {
+ // Integer.
+ var signed = next == 100 || next == 105;
+ argSize = argSize || 4;
+ var currArg = getNextArg('i' + (argSize * 8));
+ var origArg = currArg;
+ var argText;
+ // Flatten i64-1 [low, high] into a (slightly rounded) double
+ if (argSize == 8) {
+ currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);
+ }
+ // Truncate to requested size.
+ if (argSize <= 4) {
+ var limit = Math.pow(256, argSize) - 1;
+ currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);
+ }
+ // Format the number.
+ var currAbsArg = Math.abs(currArg);
+ var prefix = '';
+ if (next == 100 || next == 105) {
+ if (argSize == 8 && i64Math) argText = i64Math.stringify(origArg[0], origArg[1], null); else
+ argText = reSign(currArg, 8 * argSize, 1).toString(10);
+ } else if (next == 117) {
+ if (argSize == 8 && i64Math) argText = i64Math.stringify(origArg[0], origArg[1], true); else
+ argText = unSign(currArg, 8 * argSize, 1).toString(10);
+ currArg = Math.abs(currArg);
+ } else if (next == 111) {
+ argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
+ } else if (next == 120 || next == 88) {
+ prefix = (flagAlternative && currArg != 0) ? '0x' : '';
+ if (argSize == 8 && i64Math) {
+ if (origArg[1]) {
+ argText = (origArg[1]>>>0).toString(16);
+ var lower = (origArg[0]>>>0).toString(16);
+ while (lower.length < 8) lower = '0' + lower;
+ argText += lower;
+ } else {
+ argText = (origArg[0]>>>0).toString(16);
+ }
+ } else
+ if (currArg < 0) {
+ // Represent negative numbers in hex as 2's complement.
+ currArg = -currArg;
+ argText = (currAbsArg - 1).toString(16);
+ var buffer = [];
+ for (var i = 0; i < argText.length; i++) {
+ buffer.push((0xF - parseInt(argText[i], 16)).toString(16));
+ }
+ argText = buffer.join('');
+ while (argText.length < argSize * 2) argText = 'f' + argText;
+ } else {
+ argText = currAbsArg.toString(16);
+ }
+ if (next == 88) {
+ prefix = prefix.toUpperCase();
+ argText = argText.toUpperCase();
+ }
+ } else if (next == 112) {
+ if (currAbsArg === 0) {
+ argText = '(nil)';
+ } else {
+ prefix = '0x';
+ argText = currAbsArg.toString(16);
+ }
+ }
+ if (precisionSet) {
+ while (argText.length < precision) {
+ argText = '0' + argText;
+ }
+ }
+
+ // Add sign if needed
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ prefix = '+' + prefix;
+ } else if (flagPadSign) {
+ prefix = ' ' + prefix;
+ }
+ }
+
+ // Move sign to prefix so we zero-pad after the sign
+ if (argText.charAt(0) == '-') {
+ prefix = '-' + prefix;
+ argText = argText.substr(1);
+ }
+
+ // Add padding.
+ while (prefix.length + argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad) {
+ argText = '0' + argText;
+ } else {
+ prefix = ' ' + prefix;
+ }
+ }
+ }
+
+ // Insert the result into the buffer.
+ argText = prefix + argText;
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {
+ // Float.
+ var currArg = getNextArg('double');
+ var argText;
+ if (isNaN(currArg)) {
+ argText = 'nan';
+ flagZeroPad = false;
+ } else if (!isFinite(currArg)) {
+ argText = (currArg < 0 ? '-' : '') + 'inf';
+ flagZeroPad = false;
+ } else {
+ var isGeneral = false;
+ var effectivePrecision = Math.min(precision, 20);
+
+ // Convert g/G to f/F or e/E, as per:
+ // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
+ if (next == 103 || next == 71) {
+ isGeneral = true;
+ precision = precision || 1;
+ var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);
+ if (precision > exponent && exponent >= -4) {
+ next = ((next == 103) ? 'f' : 'F').charCodeAt(0);
+ precision -= exponent + 1;
+ } else {
+ next = ((next == 103) ? 'e' : 'E').charCodeAt(0);
+ precision--;
+ }
+ effectivePrecision = Math.min(precision, 20);
+ }
+
+ if (next == 101 || next == 69) {
+ argText = currArg.toExponential(effectivePrecision);
+ // Make sure the exponent has at least 2 digits.
+ if (/[eE][-+]\d$/.test(argText)) {
+ argText = argText.slice(0, -1) + '0' + argText.slice(-1);
+ }
+ } else if (next == 102 || next == 70) {
+ argText = currArg.toFixed(effectivePrecision);
+ if (currArg === 0 && __reallyNegative(currArg)) {
+ argText = '-' + argText;
+ }
+ }
+
+ var parts = argText.split('e');
+ if (isGeneral && !flagAlternative) {
+ // Discard trailing zeros and periods.
+ while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&
+ (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {
+ parts[0] = parts[0].slice(0, -1);
+ }
+ } else {
+ // Make sure we have a period in alternative mode.
+ if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';
+ // Zero pad until required precision.
+ while (precision > effectivePrecision++) parts[0] += '0';
+ }
+ argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');
+
+ // Capitalize 'E' if needed.
+ if (next == 69) argText = argText.toUpperCase();
+
+ // Add sign.
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ argText = '+' + argText;
+ } else if (flagPadSign) {
+ argText = ' ' + argText;
+ }
+ }
+ }
+
+ // Add padding.
+ while (argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {
+ argText = argText[0] + '0' + argText.slice(1);
+ } else {
+ argText = (flagZeroPad ? '0' : ' ') + argText;
+ }
+ }
+ }
+
+ // Adjust case.
+ if (next < 97) argText = argText.toUpperCase();
+
+ // Insert the result into the buffer.
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 's': {
+ // String.
+ var arg = getNextArg('i8*');
+ var argLength = arg ? _strlen(arg) : '(null)'.length;
+ if (precisionSet) argLength = Math.min(argLength, precision);
+ if (!flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ if (arg) {
+ for (var i = 0; i < argLength; i++) {
+ ret.push(HEAPU8[((arg++)|0)]);
+ }
+ } else {
+ ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true));
+ }
+ if (flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ break;
+ }
+ case 'c': {
+ // Character.
+ if (flagLeftAlign) ret.push(getNextArg('i8'));
+ while (--width > 0) {
+ ret.push(32);
+ }
+ if (!flagLeftAlign) ret.push(getNextArg('i8'));
+ break;
+ }
+ case 'n': {
+ // Write the length written so far to the next parameter.
+ var ptr = getNextArg('i32*');
+ HEAP32[((ptr)>>2)]=ret.length;
+ break;
+ }
+ case '%': {
+ // Literal percent sign.
+ ret.push(curr);
+ break;
+ }
+ default: {
+ // Unknown specifiers remain untouched.
+ for (var i = startTextIndex; i < textIndex + 2; i++) {
+ ret.push(HEAP8[(i)]);
+ }
+ }
+ }
+ textIndex += 2;
+ // TODO: Support a/A (hex float) and m (last error) specifiers.
+ // TODO: Support %1${specifier} for arg selection.
+ } else {
+ ret.push(curr);
+ textIndex += 1;
+ }
+ }
+ return ret;
+ }function _fprintf(stream, format, varargs) {
+ // int fprintf(FILE *restrict stream, const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var result = __formatString(format, varargs);
+ var stack = Runtime.stackSave();
+ var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);
+ Runtime.stackRestore(stack);
+ return ret;
+ }
+
+ function _fgets(s, n, stream) {
+ // char *fgets(char *restrict s, int n, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fgets.html
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (!streamObj) return 0;
+ if (streamObj.error || streamObj.eof) return 0;
+ var byte_;
+ for (var i = 0; i < n - 1 && byte_ != 10; i++) {
+ byte_ = _fgetc(stream);
+ if (byte_ == -1) {
+ if (streamObj.error || (streamObj.eof && i == 0)) return 0;
+ else if (streamObj.eof) break;
+ }
+ HEAP8[(((s)+(i))|0)]=byte_;
+ }
+ HEAP8[(((s)+(i))|0)]=0;
+ return s;
+ }
+
+ var _tan=Math_tan;
+
+ function _ispunct(chr) {
+ return (chr >= 33 && chr <= 47) ||
+ (chr >= 58 && chr <= 64) ||
+ (chr >= 91 && chr <= 96) ||
+ (chr >= 123 && chr <= 126);
+ }
+
+ function _feof(stream) {
+ // int feof(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/feof.html
+ stream = FS.getStreamFromPtr(stream);
+ return Number(stream && stream.eof);
+ }
+
+
+ Module["_tolower"] = _tolower;
+
+ var _asin=Math_asin;
+
+ function _clearerr(stream) {
+ // void clearerr(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/clearerr.html
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) {
+ return;
+ }
+ stream.eof = false;
+ stream.error = false;
+ }
+
+ var _fabs=Math_abs;
+
+ function _clock() {
+ if (_clock.start === undefined) _clock.start = Date.now();
+ return Math.floor((Date.now() - _clock.start) * (1000000/1000));
+ }
+
+
+ var _getc=_fgetc;
+
+ function _modf(x, intpart) {
+ HEAPF64[((intpart)>>3)]=Math.floor(x);
+ return x - HEAPF64[((intpart)>>3)];
+ }
+
+ var _sqrt=Math_sqrt;
+
+ function _isxdigit(chr) {
+ return (chr >= 48 && chr <= 57) ||
+ (chr >= 97 && chr <= 102) ||
+ (chr >= 65 && chr <= 70);
+ }
+
+ function _ftell(stream) {
+ // long ftell(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/ftell.html
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ if (FS.isChrdev(stream.node.mode)) {
+ ___setErrNo(ERRNO_CODES.ESPIPE);
+ return -1;
+ } else {
+ return stream.position;
+ }
+ }
+
+
+ function __exit(status) {
+ // void _exit(int status);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html
+ Module['exit'](status);
+ }function _exit(status) {
+ __exit(status);
+ }
+
+
+ function _snprintf(s, n, format, varargs) {
+ // int snprintf(char *restrict s, size_t n, const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var result = __formatString(format, varargs);
+ var limit = (n === undefined) ? result.length
+ : Math.min(result.length, Math.max(n - 1, 0));
+ if (s < 0) {
+ s = -s;
+ var buf = _malloc(limit+1);
+ HEAP32[((s)>>2)]=buf;
+ s = buf;
+ }
+ for (var i = 0; i < limit; i++) {
+ HEAP8[(((s)+(i))|0)]=result[i];
+ }
+ if (limit < n || (n === undefined)) HEAP8[(((s)+(i))|0)]=0;
+ return result.length;
+ }function _sprintf(s, format, varargs) {
+ // int sprintf(char *restrict s, const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ return _snprintf(s, undefined, format, varargs);
+ }
+
+ var _emscripten_get_longjmp_result=true;
+
+ var _sin=Math_sin;
+
+
+ function _fmod(x, y) {
+ return x % y;
+ }var _fmodl=_fmod;
+
+
+
+ var _atan=Math_atan;
+
+ function _ferror(stream) {
+ // int ferror(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/ferror.html
+ stream = FS.getStreamFromPtr(stream);
+ return Number(stream && stream.error);
+ }
+
+ function _time(ptr) {
+ var ret = Math.floor(Date.now()/1000);
+ if (ptr) {
+ HEAP32[((ptr)>>2)]=ret;
+ }
+ return ret;
+ }
+
+ function _copysign(a, b) {
+ return __reallyNegative(a) === __reallyNegative(b) ? a : -a;
+ }
+
+
+ function _gmtime_r(time, tmPtr) {
+ var date = new Date(HEAP32[((time)>>2)]*1000);
+ HEAP32[((tmPtr)>>2)]=date.getUTCSeconds();
+ HEAP32[(((tmPtr)+(4))>>2)]=date.getUTCMinutes();
+ HEAP32[(((tmPtr)+(8))>>2)]=date.getUTCHours();
+ HEAP32[(((tmPtr)+(12))>>2)]=date.getUTCDate();
+ HEAP32[(((tmPtr)+(16))>>2)]=date.getUTCMonth();
+ HEAP32[(((tmPtr)+(20))>>2)]=date.getUTCFullYear()-1900;
+ HEAP32[(((tmPtr)+(24))>>2)]=date.getUTCDay();
+ HEAP32[(((tmPtr)+(36))>>2)]=0;
+ HEAP32[(((tmPtr)+(32))>>2)]=0;
+ var start = new Date(date); // define date using UTC, start from Jan 01 00:00:00 UTC
+ start.setUTCDate(1);
+ start.setUTCMonth(0);
+ start.setUTCHours(0);
+ start.setUTCMinutes(0);
+ start.setUTCSeconds(0);
+ start.setUTCMilliseconds(0);
+ var yday = Math.floor((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));
+ HEAP32[(((tmPtr)+(28))>>2)]=yday;
+ HEAP32[(((tmPtr)+(40))>>2)]=___tm_timezone;
+
+ return tmPtr;
+ }function _gmtime(time) {
+ return _gmtime_r(time, ___tm_current);
+ }
+
+ function _isgraph(chr) {
+ return 0x20 < chr && chr < 0x7F;
+ }
+
+
+
+ function _strerror_r(errnum, strerrbuf, buflen) {
+ if (errnum in ERRNO_MESSAGES) {
+ if (ERRNO_MESSAGES[errnum].length > buflen - 1) {
+ return ___setErrNo(ERRNO_CODES.ERANGE);
+ } else {
+ var msg = ERRNO_MESSAGES[errnum];
+ writeAsciiToMemory(msg, strerrbuf);
+ return 0;
+ }
+ } else {
+ return ___setErrNo(ERRNO_CODES.EINVAL);
+ }
+ }function _strerror(errnum) {
+ if (!_strerror.buffer) _strerror.buffer = _malloc(256);
+ _strerror_r(errnum, _strerror.buffer, 256);
+ return _strerror.buffer;
+ }
+
+
+
+
+
+ var _environ=allocate(1, "i32*", ALLOC_STATIC);var ___environ=_environ;function ___buildEnvironment(env) {
+ // WARNING: Arbitrary limit!
+ var MAX_ENV_VALUES = 64;
+ var TOTAL_ENV_SIZE = 1024;
+
+ // Statically allocate memory for the environment.
+ var poolPtr;
+ var envPtr;
+ if (!___buildEnvironment.called) {
+ ___buildEnvironment.called = true;
+ // Set default values. Use string keys for Closure Compiler compatibility.
+ ENV['USER'] = 'root';
+ ENV['PATH'] = '/';
+ ENV['PWD'] = '/';
+ ENV['HOME'] = '/home/emscripten';
+ ENV['LANG'] = 'en_US.UTF-8';
+ ENV['_'] = './this.program';
+ // Allocate memory.
+ poolPtr = allocate(TOTAL_ENV_SIZE, 'i8', ALLOC_STATIC);
+ envPtr = allocate(MAX_ENV_VALUES * 4,
+ 'i8*', ALLOC_STATIC);
+ HEAP32[((envPtr)>>2)]=poolPtr;
+ HEAP32[((_environ)>>2)]=envPtr;
+ } else {
+ envPtr = HEAP32[((_environ)>>2)];
+ poolPtr = HEAP32[((envPtr)>>2)];
+ }
+
+ // Collect key=value lines.
+ var strings = [];
+ var totalSize = 0;
+ for (var key in env) {
+ if (typeof env[key] === 'string') {
+ var line = key + '=' + env[key];
+ strings.push(line);
+ totalSize += line.length;
+ }
+ }
+ if (totalSize > TOTAL_ENV_SIZE) {
+ throw new Error('Environment size exceeded TOTAL_ENV_SIZE!');
+ }
+
+ // Make new.
+ var ptrSize = 4;
+ for (var i = 0; i < strings.length; i++) {
+ var line = strings[i];
+ writeAsciiToMemory(line, poolPtr);
+ HEAP32[(((envPtr)+(i * ptrSize))>>2)]=poolPtr;
+ poolPtr += line.length + 1;
+ }
+ HEAP32[(((envPtr)+(strings.length * ptrSize))>>2)]=0;
+ }var ENV={};function _getenv(name) {
+ // char *getenv(const char *name);
+ // http://pubs.opengroup.org/onlinepubs/009695399/functions/getenv.html
+ if (name === 0) return 0;
+ name = Pointer_stringify(name);
+ if (!ENV.hasOwnProperty(name)) return 0;
+
+ if (_getenv.ret) _free(_getenv.ret);
+ _getenv.ret = allocate(intArrayFromString(ENV[name]), 'i8', ALLOC_NORMAL);
+ return _getenv.ret;
+ }
+
+ var _emscripten_setjmp=true;
+
+ var _cos=Math_cos;
+
+ function _isalnum(chr) {
+ return (chr >= 48 && chr <= 57) ||
+ (chr >= 97 && chr <= 122) ||
+ (chr >= 65 && chr <= 90);
+ }
+
+ var _BItoD=true;
+
+ function _difftime(time1, time0) {
+ return time1 - time0;
+ }
+
+ var _floor=Math_floor;
+
+ function _iscntrl(chr) {
+ return (0 <= chr && chr <= 0x1F) || chr === 0x7F;
+ }
+
+ var _atan2=Math_atan2;
+
+ function _setvbuf(stream, buf, type, size) {
+ // int setvbuf(FILE *restrict stream, char *restrict buf, int type, size_t size);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/setvbuf.html
+ // TODO: Implement custom buffering.
+ return 0;
+ }
+
+ var _exp=Math_exp;
+
+ var _copysignl=_copysign;
+
+ function _islower(chr) {
+ return chr >= 97 && chr <= 122;
+ }
+
+ var _acos=Math_acos;
+
+ function _isupper(chr) {
+ return chr >= 65 && chr <= 90;
+ }
+
+
+ function __isLeapYear(year) {
+ return year%4 === 0 && (year%100 !== 0 || year%400 === 0);
+ }
+
+ function __arraySum(array, index) {
+ var sum = 0;
+ for (var i = 0; i <= index; sum += array[i++]);
+ return sum;
+ }
+
+
+ var __MONTH_DAYS_LEAP=[31,29,31,30,31,30,31,31,30,31,30,31];
+
+ var __MONTH_DAYS_REGULAR=[31,28,31,30,31,30,31,31,30,31,30,31];function __addDays(date, days) {
+ var newDate = new Date(date.getTime());
+ while(days > 0) {
+ var leap = __isLeapYear(newDate.getFullYear());
+ var currentMonth = newDate.getMonth();
+ var daysInCurrentMonth = (leap ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR)[currentMonth];
+
+ if (days > daysInCurrentMonth-newDate.getDate()) {
+ // we spill over to next month
+ days -= (daysInCurrentMonth-newDate.getDate()+1);
+ newDate.setDate(1);
+ if (currentMonth < 11) {
+ newDate.setMonth(currentMonth+1)
+ } else {
+ newDate.setMonth(0);
+ newDate.setFullYear(newDate.getFullYear()+1);
+ }
+ } else {
+ // we stay in current month
+ newDate.setDate(newDate.getDate()+days);
+ return newDate;
+ }
+ }
+
+ return newDate;
+ }function _strftime(s, maxsize, format, tm) {
+ // size_t strftime(char *restrict s, size_t maxsize, const char *restrict format, const struct tm *restrict timeptr);
+ // http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html
+
+ var date = {
+ tm_sec: HEAP32[((tm)>>2)],
+ tm_min: HEAP32[(((tm)+(4))>>2)],
+ tm_hour: HEAP32[(((tm)+(8))>>2)],
+ tm_mday: HEAP32[(((tm)+(12))>>2)],
+ tm_mon: HEAP32[(((tm)+(16))>>2)],
+ tm_year: HEAP32[(((tm)+(20))>>2)],
+ tm_wday: HEAP32[(((tm)+(24))>>2)],
+ tm_yday: HEAP32[(((tm)+(28))>>2)],
+ tm_isdst: HEAP32[(((tm)+(32))>>2)]
+ };
+
+ var pattern = Pointer_stringify(format);
+
+ // expand format
+ var EXPANSION_RULES_1 = {
+ '%c': '%a %b %d %H:%M:%S %Y', // Replaced by the locale's appropriate date and time representation - e.g., Mon Aug 3 14:02:01 2013
+ '%D': '%m/%d/%y', // Equivalent to %m / %d / %y
+ '%F': '%Y-%m-%d', // Equivalent to %Y - %m - %d
+ '%h': '%b', // Equivalent to %b
+ '%r': '%I:%M:%S %p', // Replaced by the time in a.m. and p.m. notation
+ '%R': '%H:%M', // Replaced by the time in 24-hour notation
+ '%T': '%H:%M:%S', // Replaced by the time
+ '%x': '%m/%d/%y', // Replaced by the locale's appropriate date representation
+ '%X': '%H:%M:%S', // Replaced by the locale's appropriate date representation
+ };
+ for (var rule in EXPANSION_RULES_1) {
+ pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_1[rule]);
+ }
+
+ var WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
+ var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
+
+ function leadingSomething(value, digits, character) {
+ var str = typeof value === 'number' ? value.toString() : (value || '');
+ while (str.length < digits) {
+ str = character[0]+str;
+ }
+ return str;
+ };
+
+ function leadingNulls(value, digits) {
+ return leadingSomething(value, digits, '0');
+ };
+
+ function compareByDay(date1, date2) {
+ function sgn(value) {
+ return value < 0 ? -1 : (value > 0 ? 1 : 0);
+ };
+
+ var compare;
+ if ((compare = sgn(date1.getFullYear()-date2.getFullYear())) === 0) {
+ if ((compare = sgn(date1.getMonth()-date2.getMonth())) === 0) {
+ compare = sgn(date1.getDate()-date2.getDate());
+ }
+ }
+ return compare;
+ };
+
+ function getFirstWeekStartDate(janFourth) {
+ switch (janFourth.getDay()) {
+ case 0: // Sunday
+ return new Date(janFourth.getFullYear()-1, 11, 29);
+ case 1: // Monday
+ return janFourth;
+ case 2: // Tuesday
+ return new Date(janFourth.getFullYear(), 0, 3);
+ case 3: // Wednesday
+ return new Date(janFourth.getFullYear(), 0, 2);
+ case 4: // Thursday
+ return new Date(janFourth.getFullYear(), 0, 1);
+ case 5: // Friday
+ return new Date(janFourth.getFullYear()-1, 11, 31);
+ case 6: // Saturday
+ return new Date(janFourth.getFullYear()-1, 11, 30);
+ }
+ };
+
+ function getWeekBasedYear(date) {
+ var thisDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday);
+
+ var janFourthThisYear = new Date(thisDate.getFullYear(), 0, 4);
+ var janFourthNextYear = new Date(thisDate.getFullYear()+1, 0, 4);
+
+ var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);
+ var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);
+
+ if (compareByDay(firstWeekStartThisYear, thisDate) <= 0) {
+ // this date is after the start of the first week of this year
+ if (compareByDay(firstWeekStartNextYear, thisDate) <= 0) {
+ return thisDate.getFullYear()+1;
+ } else {
+ return thisDate.getFullYear();
+ }
+ } else {
+ return thisDate.getFullYear()-1;
+ }
+ };
+
+ var EXPANSION_RULES_2 = {
+ '%a': function(date) {
+ return WEEKDAYS[date.tm_wday].substring(0,3);
+ },
+ '%A': function(date) {
+ return WEEKDAYS[date.tm_wday];
+ },
+ '%b': function(date) {
+ return MONTHS[date.tm_mon].substring(0,3);
+ },
+ '%B': function(date) {
+ return MONTHS[date.tm_mon];
+ },
+ '%C': function(date) {
+ var year = date.tm_year+1900;
+ return leadingNulls(Math.floor(year/100),2);
+ },
+ '%d': function(date) {
+ return leadingNulls(date.tm_mday, 2);
+ },
+ '%e': function(date) {
+ return leadingSomething(date.tm_mday, 2, ' ');
+ },
+ '%g': function(date) {
+ // %g, %G, and %V give values according to the ISO 8601:2000 standard week-based year.
+ // In this system, weeks begin on a Monday and week 1 of the year is the week that includes
+ // January 4th, which is also the week that includes the first Thursday of the year, and
+ // is also the first week that contains at least four days in the year.
+ // If the first Monday of January is the 2nd, 3rd, or 4th, the preceding days are part of
+ // the last week of the preceding year; thus, for Saturday 2nd January 1999,
+ // %G is replaced by 1998 and %V is replaced by 53. If December 29th, 30th,
+ // or 31st is a Monday, it and any following days are part of week 1 of the following year.
+ // Thus, for Tuesday 30th December 1997, %G is replaced by 1998 and %V is replaced by 01.
+
+ return getWeekBasedYear(date).toString().substring(2);
+ },
+ '%G': function(date) {
+ return getWeekBasedYear(date);
+ },
+ '%H': function(date) {
+ return leadingNulls(date.tm_hour, 2);
+ },
+ '%I': function(date) {
+ return leadingNulls(date.tm_hour < 13 ? date.tm_hour : date.tm_hour-12, 2);
+ },
+ '%j': function(date) {
+ // Day of the year (001-366)
+ return leadingNulls(date.tm_mday+__arraySum(__isLeapYear(date.tm_year+1900) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, date.tm_mon-1), 3);
+ },
+ '%m': function(date) {
+ return leadingNulls(date.tm_mon+1, 2);
+ },
+ '%M': function(date) {
+ return leadingNulls(date.tm_min, 2);
+ },
+ '%n': function() {
+ return '\n';
+ },
+ '%p': function(date) {
+ if (date.tm_hour > 0 && date.tm_hour < 13) {
+ return 'AM';
+ } else {
+ return 'PM';
+ }
+ },
+ '%S': function(date) {
+ return leadingNulls(date.tm_sec, 2);
+ },
+ '%t': function() {
+ return '\t';
+ },
+ '%u': function(date) {
+ var day = new Date(date.tm_year+1900, date.tm_mon+1, date.tm_mday, 0, 0, 0, 0);
+ return day.getDay() || 7;
+ },
+ '%U': function(date) {
+ // Replaced by the week number of the year as a decimal number [00,53].
+ // The first Sunday of January is the first day of week 1;
+ // days in the new year before this are in week 0. [ tm_year, tm_wday, tm_yday]
+ var janFirst = new Date(date.tm_year+1900, 0, 1);
+ var firstSunday = janFirst.getDay() === 0 ? janFirst : __addDays(janFirst, 7-janFirst.getDay());
+ var endDate = new Date(date.tm_year+1900, date.tm_mon, date.tm_mday);
+
+ // is target date after the first Sunday?
+ if (compareByDay(firstSunday, endDate) < 0) {
+ // calculate difference in days between first Sunday and endDate
+ var februaryFirstUntilEndMonth = __arraySum(__isLeapYear(endDate.getFullYear()) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, endDate.getMonth()-1)-31;
+ var firstSundayUntilEndJanuary = 31-firstSunday.getDate();
+ var days = firstSundayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();
+ return leadingNulls(Math.ceil(days/7), 2);
+ }
+
+ return compareByDay(firstSunday, janFirst) === 0 ? '01': '00';
+ },
+ '%V': function(date) {
+ // Replaced by the week number of the year (Monday as the first day of the week)
+ // as a decimal number [01,53]. If the week containing 1 January has four
+ // or more days in the new year, then it is considered week 1.
+ // Otherwise, it is the last week of the previous year, and the next week is week 1.
+ // Both January 4th and the first Thursday of January are always in week 1. [ tm_year, tm_wday, tm_yday]
+ var janFourthThisYear = new Date(date.tm_year+1900, 0, 4);
+ var janFourthNextYear = new Date(date.tm_year+1901, 0, 4);
+
+ var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);
+ var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);
+
+ var endDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday);
+
+ if (compareByDay(endDate, firstWeekStartThisYear) < 0) {
+ // if given date is before this years first week, then it belongs to the 53rd week of last year
+ return '53';
+ }
+
+ if (compareByDay(firstWeekStartNextYear, endDate) <= 0) {
+ // if given date is after next years first week, then it belongs to the 01th week of next year
+ return '01';
+ }
+
+ // given date is in between CW 01..53 of this calendar year
+ var daysDifference;
+ if (firstWeekStartThisYear.getFullYear() < date.tm_year+1900) {
+ // first CW of this year starts last year
+ daysDifference = date.tm_yday+32-firstWeekStartThisYear.getDate()
+ } else {
+ // first CW of this year starts this year
+ daysDifference = date.tm_yday+1-firstWeekStartThisYear.getDate();
+ }
+ return leadingNulls(Math.ceil(daysDifference/7), 2);
+ },
+ '%w': function(date) {
+ var day = new Date(date.tm_year+1900, date.tm_mon+1, date.tm_mday, 0, 0, 0, 0);
+ return day.getDay();
+ },
+ '%W': function(date) {
+ // Replaced by the week number of the year as a decimal number [00,53].
+ // The first Monday of January is the first day of week 1;
+ // days in the new year before this are in week 0. [ tm_year, tm_wday, tm_yday]
+ var janFirst = new Date(date.tm_year, 0, 1);
+ var firstMonday = janFirst.getDay() === 1 ? janFirst : __addDays(janFirst, janFirst.getDay() === 0 ? 1 : 7-janFirst.getDay()+1);
+ var endDate = new Date(date.tm_year+1900, date.tm_mon, date.tm_mday);
+
+ // is target date after the first Monday?
+ if (compareByDay(firstMonday, endDate) < 0) {
+ var februaryFirstUntilEndMonth = __arraySum(__isLeapYear(endDate.getFullYear()) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, endDate.getMonth()-1)-31;
+ var firstMondayUntilEndJanuary = 31-firstMonday.getDate();
+ var days = firstMondayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();
+ return leadingNulls(Math.ceil(days/7), 2);
+ }
+ return compareByDay(firstMonday, janFirst) === 0 ? '01': '00';
+ },
+ '%y': function(date) {
+ // Replaced by the last two digits of the year as a decimal number [00,99]. [ tm_year]
+ return (date.tm_year+1900).toString().substring(2);
+ },
+ '%Y': function(date) {
+ // Replaced by the year as a decimal number (for example, 1997). [ tm_year]
+ return date.tm_year+1900;
+ },
+ '%z': function(date) {
+ // Replaced by the offset from UTC in the ISO 8601:2000 standard format ( +hhmm or -hhmm ),
+ // or by no characters if no timezone is determinable.
+ // For example, "-0430" means 4 hours 30 minutes behind UTC (west of Greenwich).
+ // If tm_isdst is zero, the standard time offset is used.
+ // If tm_isdst is greater than zero, the daylight savings time offset is used.
+ // If tm_isdst is negative, no characters are returned.
+ // FIXME: we cannot determine time zone (or can we?)
+ return '';
+ },
+ '%Z': function(date) {
+ // Replaced by the timezone name or abbreviation, or by no bytes if no timezone information exists. [ tm_isdst]
+ // FIXME: we cannot determine time zone (or can we?)
+ return '';
+ },
+ '%%': function() {
+ return '%';
+ }
+ };
+ for (var rule in EXPANSION_RULES_2) {
+ if (pattern.indexOf(rule) >= 0) {
+ pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_2[rule](date));
+ }
+ }
+
+ var bytes = intArrayFromString(pattern, false);
+ if (bytes.length > maxsize) {
+ return 0;
+ }
+
+ writeArrayToMemory(bytes, s);
+ return bytes.length-1;
+ }
+
+
+
+FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;
+___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;
+__ATINIT__.unshift({ func: function() { TTY.init() } });__ATEXIT__.push({ func: function() { TTY.shutdown() } });TTY.utf8 = new Runtime.UTF8Processor();
+if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); NODEFS.staticInit(); }
+__ATINIT__.push({ func: function() { SOCKFS.root = FS.mount(SOCKFS, {}, null); } });
+_fputc.ret = allocate([0], "i8", ALLOC_STATIC);
+Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };
+ Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };
+ Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };
+ Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };
+ Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };
+ Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }
+_fgetc.ret = allocate([0], "i8", ALLOC_STATIC);
+___buildEnvironment(ENV);
+STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);
+
+staticSealed = true; // seal the static portion of memory
+
+STACK_MAX = STACK_BASE + 5242880;
+
+DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);
+
+assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");
+
+ var ctlz_i8 = allocate([8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], "i8", ALLOC_DYNAMIC);
+ var cttz_i8 = allocate([8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0], "i8", ALLOC_DYNAMIC);
+
+var Math_min = Math.min;
+function invoke_iiii(index,a1,a2,a3) {
+ try {
+ return Module["dynCall_iiii"](index,a1,a2,a3);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_vi(index,a1) {
+ try {
+ Module["dynCall_vi"](index,a1);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_vii(index,a1,a2) {
+ try {
+ Module["dynCall_vii"](index,a1,a2);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_ii(index,a1) {
+ try {
+ return Module["dynCall_ii"](index,a1);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_iiiii(index,a1,a2,a3,a4) {
+ try {
+ return Module["dynCall_iiiii"](index,a1,a2,a3,a4);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_iii(index,a1,a2) {
+ try {
+ return Module["dynCall_iii"](index,a1,a2);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function asmPrintInt(x, y) {
+ Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+function asmPrintFloat(x, y) {
+ Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+// EMSCRIPTEN_START_ASM
+var asm = (function(global, env, buffer) {
+ 'use asm';
+ var HEAP8 = new global.Int8Array(buffer);
+ var HEAP16 = new global.Int16Array(buffer);
+ var HEAP32 = new global.Int32Array(buffer);
+ var HEAPU8 = new global.Uint8Array(buffer);
+ var HEAPU16 = new global.Uint16Array(buffer);
+ var HEAPU32 = new global.Uint32Array(buffer);
+ var HEAPF32 = new global.Float32Array(buffer);
+ var HEAPF64 = new global.Float64Array(buffer);
+
+ var STACKTOP=env.STACKTOP|0;
+ var STACK_MAX=env.STACK_MAX|0;
+ var tempDoublePtr=env.tempDoublePtr|0;
+ var ABORT=env.ABORT|0;
+ var cttz_i8=env.cttz_i8|0;
+ var ctlz_i8=env.ctlz_i8|0;
+ var ___rand_seed=env.___rand_seed|0;
+ var _stderr=env._stderr|0;
+ var _stdin=env._stdin|0;
+ var _stdout=env._stdout|0;
+
+ var __THREW__ = 0;
+ var threwValue = 0;
+ var setjmpId = 0;
+ var undef = 0;
+ var nan = +env.NaN, inf = +env.Infinity;
+ var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0;
+
+ var tempRet0 = 0;
+ var tempRet1 = 0;
+ var tempRet2 = 0;
+ var tempRet3 = 0;
+ var tempRet4 = 0;
+ var tempRet5 = 0;
+ var tempRet6 = 0;
+ var tempRet7 = 0;
+ var tempRet8 = 0;
+ var tempRet9 = 0;
+ var Math_floor=global.Math.floor;
+ var Math_abs=global.Math.abs;
+ var Math_sqrt=global.Math.sqrt;
+ var Math_pow=global.Math.pow;
+ var Math_cos=global.Math.cos;
+ var Math_sin=global.Math.sin;
+ var Math_tan=global.Math.tan;
+ var Math_acos=global.Math.acos;
+ var Math_asin=global.Math.asin;
+ var Math_atan=global.Math.atan;
+ var Math_atan2=global.Math.atan2;
+ var Math_exp=global.Math.exp;
+ var Math_log=global.Math.log;
+ var Math_ceil=global.Math.ceil;
+ var Math_imul=global.Math.imul;
+ var abort=env.abort;
+ var assert=env.assert;
+ var asmPrintInt=env.asmPrintInt;
+ var asmPrintFloat=env.asmPrintFloat;
+ var Math_min=env.min;
+ var invoke_iiii=env.invoke_iiii;
+ var invoke_vi=env.invoke_vi;
+ var invoke_vii=env.invoke_vii;
+ var invoke_ii=env.invoke_ii;
+ var invoke_iiiii=env.invoke_iiiii;
+ var invoke_iii=env.invoke_iii;
+ var _isalnum=env._isalnum;
+ var _fabs=env._fabs;
+ var _frexp=env._frexp;
+ var _exp=env._exp;
+ var _fread=env._fread;
+ var __reallyNegative=env.__reallyNegative;
+ var _longjmp=env._longjmp;
+ var __addDays=env.__addDays;
+ var _fsync=env._fsync;
+ var _signal=env._signal;
+ var _rename=env._rename;
+ var _sbrk=env._sbrk;
+ var _emscripten_memcpy_big=env._emscripten_memcpy_big;
+ var _sinh=env._sinh;
+ var _sysconf=env._sysconf;
+ var _close=env._close;
+ var _ferror=env._ferror;
+ var _clock=env._clock;
+ var _cos=env._cos;
+ var _tanh=env._tanh;
+ var _unlink=env._unlink;
+ var _write=env._write;
+ var __isLeapYear=env.__isLeapYear;
+ var _ftell=env._ftell;
+ var _isupper=env._isupper;
+ var _gmtime_r=env._gmtime_r;
+ var _islower=env._islower;
+ var _tmpnam=env._tmpnam;
+ var _tmpfile=env._tmpfile;
+ var _send=env._send;
+ var _abort=env._abort;
+ var _setvbuf=env._setvbuf;
+ var _atan2=env._atan2;
+ var _setlocale=env._setlocale;
+ var _isgraph=env._isgraph;
+ var _modf=env._modf;
+ var _strerror_r=env._strerror_r;
+ var _fscanf=env._fscanf;
+ var ___setErrNo=env.___setErrNo;
+ var _isalpha=env._isalpha;
+ var _srand=env._srand;
+ var _mktime=env._mktime;
+ var _putchar=env._putchar;
+ var _gmtime=env._gmtime;
+ var _localeconv=env._localeconv;
+ var _sprintf=env._sprintf;
+ var _localtime=env._localtime;
+ var _read=env._read;
+ var _fwrite=env._fwrite;
+ var _time=env._time;
+ var _fprintf=env._fprintf;
+ var _exit=env._exit;
+ var _freopen=env._freopen;
+ var _llvm_pow_f64=env._llvm_pow_f64;
+ var _fgetc=env._fgetc;
+ var _fmod=env._fmod;
+ var _lseek=env._lseek;
+ var _rmdir=env._rmdir;
+ var _asin=env._asin;
+ var _floor=env._floor;
+ var _pwrite=env._pwrite;
+ var _localtime_r=env._localtime_r;
+ var _tzset=env._tzset;
+ var _open=env._open;
+ var _remove=env._remove;
+ var _snprintf=env._snprintf;
+ var __scanString=env.__scanString;
+ var _strftime=env._strftime;
+ var _fseek=env._fseek;
+ var _iscntrl=env._iscntrl;
+ var _isxdigit=env._isxdigit;
+ var _fclose=env._fclose;
+ var _log=env._log;
+ var _recv=env._recv;
+ var _tan=env._tan;
+ var _copysign=env._copysign;
+ var __getFloat=env.__getFloat;
+ var _fputc=env._fputc;
+ var _ispunct=env._ispunct;
+ var _ceil=env._ceil;
+ var _isspace=env._isspace;
+ var _fopen=env._fopen;
+ var _sin=env._sin;
+ var _acos=env._acos;
+ var _cosh=env._cosh;
+ var ___buildEnvironment=env.___buildEnvironment;
+ var _difftime=env._difftime;
+ var _ungetc=env._ungetc;
+ var _system=env._system;
+ var _fflush=env._fflush;
+ var _log10=env._log10;
+ var _fileno=env._fileno;
+ var __exit=env.__exit;
+ var __arraySum=env.__arraySum;
+ var _fgets=env._fgets;
+ var _atan=env._atan;
+ var _pread=env._pread;
+ var _mkport=env._mkport;
+ var _toupper=env._toupper;
+ var _feof=env._feof;
+ var ___errno_location=env.___errno_location;
+ var _clearerr=env._clearerr;
+ var _getenv=env._getenv;
+ var _strerror=env._strerror;
+ var _emscripten_longjmp=env._emscripten_longjmp;
+ var __formatString=env.__formatString;
+ var _fputs=env._fputs;
+ var _sqrt=env._sqrt;
+ var tempFloat = 0.0;
+
+// EMSCRIPTEN_START_FUNCS
+function _malloc(i12) {
+ i12 = i12 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0;
+ i1 = STACKTOP;
+ do {
+ if (i12 >>> 0 < 245) {
+ if (i12 >>> 0 < 11) {
+ i12 = 16;
+ } else {
+ i12 = i12 + 11 & -8;
+ }
+ i20 = i12 >>> 3;
+ i18 = HEAP32[3228] | 0;
+ i21 = i18 >>> i20;
+ if ((i21 & 3 | 0) != 0) {
+ i6 = (i21 & 1 ^ 1) + i20 | 0;
+ i5 = i6 << 1;
+ i3 = 12952 + (i5 << 2) | 0;
+ i5 = 12952 + (i5 + 2 << 2) | 0;
+ i7 = HEAP32[i5 >> 2] | 0;
+ i2 = i7 + 8 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ do {
+ if ((i3 | 0) != (i4 | 0)) {
+ if (i4 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i4 + 12 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i7 | 0)) {
+ HEAP32[i8 >> 2] = i3;
+ HEAP32[i5 >> 2] = i4;
+ break;
+ } else {
+ _abort();
+ }
+ } else {
+ HEAP32[3228] = i18 & ~(1 << i6);
+ }
+ } while (0);
+ i32 = i6 << 3;
+ HEAP32[i7 + 4 >> 2] = i32 | 3;
+ i32 = i7 + (i32 | 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ i32 = i2;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ if (i12 >>> 0 > (HEAP32[12920 >> 2] | 0) >>> 0) {
+ if ((i21 | 0) != 0) {
+ i7 = 2 << i20;
+ i7 = i21 << i20 & (i7 | 0 - i7);
+ i7 = (i7 & 0 - i7) + -1 | 0;
+ i2 = i7 >>> 12 & 16;
+ i7 = i7 >>> i2;
+ i6 = i7 >>> 5 & 8;
+ i7 = i7 >>> i6;
+ i5 = i7 >>> 2 & 4;
+ i7 = i7 >>> i5;
+ i4 = i7 >>> 1 & 2;
+ i7 = i7 >>> i4;
+ i3 = i7 >>> 1 & 1;
+ i3 = (i6 | i2 | i5 | i4 | i3) + (i7 >>> i3) | 0;
+ i7 = i3 << 1;
+ i4 = 12952 + (i7 << 2) | 0;
+ i7 = 12952 + (i7 + 2 << 2) | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ i2 = i5 + 8 | 0;
+ i6 = HEAP32[i2 >> 2] | 0;
+ do {
+ if ((i4 | 0) != (i6 | 0)) {
+ if (i6 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i6 + 12 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i5 | 0)) {
+ HEAP32[i8 >> 2] = i4;
+ HEAP32[i7 >> 2] = i6;
+ break;
+ } else {
+ _abort();
+ }
+ } else {
+ HEAP32[3228] = i18 & ~(1 << i3);
+ }
+ } while (0);
+ i6 = i3 << 3;
+ i4 = i6 - i12 | 0;
+ HEAP32[i5 + 4 >> 2] = i12 | 3;
+ i3 = i5 + i12 | 0;
+ HEAP32[i5 + (i12 | 4) >> 2] = i4 | 1;
+ HEAP32[i5 + i6 >> 2] = i4;
+ i6 = HEAP32[12920 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i5 = HEAP32[12932 >> 2] | 0;
+ i8 = i6 >>> 3;
+ i9 = i8 << 1;
+ i6 = 12952 + (i9 << 2) | 0;
+ i7 = HEAP32[3228] | 0;
+ i8 = 1 << i8;
+ if ((i7 & i8 | 0) != 0) {
+ i7 = 12952 + (i9 + 2 << 2) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i28 = i7;
+ i27 = i8;
+ }
+ } else {
+ HEAP32[3228] = i7 | i8;
+ i28 = 12952 + (i9 + 2 << 2) | 0;
+ i27 = i6;
+ }
+ HEAP32[i28 >> 2] = i5;
+ HEAP32[i27 + 12 >> 2] = i5;
+ HEAP32[i5 + 8 >> 2] = i27;
+ HEAP32[i5 + 12 >> 2] = i6;
+ }
+ HEAP32[12920 >> 2] = i4;
+ HEAP32[12932 >> 2] = i3;
+ i32 = i2;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i18 = HEAP32[12916 >> 2] | 0;
+ if ((i18 | 0) != 0) {
+ i2 = (i18 & 0 - i18) + -1 | 0;
+ i31 = i2 >>> 12 & 16;
+ i2 = i2 >>> i31;
+ i30 = i2 >>> 5 & 8;
+ i2 = i2 >>> i30;
+ i32 = i2 >>> 2 & 4;
+ i2 = i2 >>> i32;
+ i6 = i2 >>> 1 & 2;
+ i2 = i2 >>> i6;
+ i3 = i2 >>> 1 & 1;
+ i3 = HEAP32[13216 + ((i30 | i31 | i32 | i6 | i3) + (i2 >>> i3) << 2) >> 2] | 0;
+ i2 = (HEAP32[i3 + 4 >> 2] & -8) - i12 | 0;
+ i6 = i3;
+ while (1) {
+ i5 = HEAP32[i6 + 16 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i5 = HEAP32[i6 + 20 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ }
+ i6 = (HEAP32[i5 + 4 >> 2] & -8) - i12 | 0;
+ i4 = i6 >>> 0 < i2 >>> 0;
+ i2 = i4 ? i6 : i2;
+ i6 = i5;
+ i3 = i4 ? i5 : i3;
+ }
+ i6 = HEAP32[12928 >> 2] | 0;
+ if (i3 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ i4 = i3 + i12 | 0;
+ if (!(i3 >>> 0 < i4 >>> 0)) {
+ _abort();
+ }
+ i5 = HEAP32[i3 + 24 >> 2] | 0;
+ i7 = HEAP32[i3 + 12 >> 2] | 0;
+ do {
+ if ((i7 | 0) == (i3 | 0)) {
+ i8 = i3 + 20 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i8 = i3 + 16 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i26 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i10 = i7 + 20 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ i7 = i9;
+ i8 = i10;
+ continue;
+ }
+ i10 = i7 + 16 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ } else {
+ i7 = i9;
+ i8 = i10;
+ }
+ }
+ if (i8 >>> 0 < i6 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i8 >> 2] = 0;
+ i26 = i7;
+ break;
+ }
+ } else {
+ i8 = HEAP32[i3 + 8 >> 2] | 0;
+ if (i8 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ i6 = i8 + 12 | 0;
+ if ((HEAP32[i6 >> 2] | 0) != (i3 | 0)) {
+ _abort();
+ }
+ i9 = i7 + 8 | 0;
+ if ((HEAP32[i9 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i6 >> 2] = i7;
+ HEAP32[i9 >> 2] = i8;
+ i26 = i7;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ do {
+ if ((i5 | 0) != 0) {
+ i7 = HEAP32[i3 + 28 >> 2] | 0;
+ i6 = 13216 + (i7 << 2) | 0;
+ if ((i3 | 0) == (HEAP32[i6 >> 2] | 0)) {
+ HEAP32[i6 >> 2] = i26;
+ if ((i26 | 0) == 0) {
+ HEAP32[12916 >> 2] = HEAP32[12916 >> 2] & ~(1 << i7);
+ break;
+ }
+ } else {
+ if (i5 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i6 = i5 + 16 | 0;
+ if ((HEAP32[i6 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i6 >> 2] = i26;
+ } else {
+ HEAP32[i5 + 20 >> 2] = i26;
+ }
+ if ((i26 | 0) == 0) {
+ break;
+ }
+ }
+ if (i26 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i26 + 24 >> 2] = i5;
+ i5 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i26 + 16 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i26;
+ break;
+ }
+ }
+ } while (0);
+ i5 = HEAP32[i3 + 20 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i26 + 20 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i26;
+ break;
+ }
+ }
+ }
+ } while (0);
+ if (i2 >>> 0 < 16) {
+ i32 = i2 + i12 | 0;
+ HEAP32[i3 + 4 >> 2] = i32 | 3;
+ i32 = i3 + (i32 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ } else {
+ HEAP32[i3 + 4 >> 2] = i12 | 3;
+ HEAP32[i3 + (i12 | 4) >> 2] = i2 | 1;
+ HEAP32[i3 + (i2 + i12) >> 2] = i2;
+ i6 = HEAP32[12920 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i5 = HEAP32[12932 >> 2] | 0;
+ i8 = i6 >>> 3;
+ i9 = i8 << 1;
+ i6 = 12952 + (i9 << 2) | 0;
+ i7 = HEAP32[3228] | 0;
+ i8 = 1 << i8;
+ if ((i7 & i8 | 0) != 0) {
+ i7 = 12952 + (i9 + 2 << 2) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i25 = i7;
+ i24 = i8;
+ }
+ } else {
+ HEAP32[3228] = i7 | i8;
+ i25 = 12952 + (i9 + 2 << 2) | 0;
+ i24 = i6;
+ }
+ HEAP32[i25 >> 2] = i5;
+ HEAP32[i24 + 12 >> 2] = i5;
+ HEAP32[i5 + 8 >> 2] = i24;
+ HEAP32[i5 + 12 >> 2] = i6;
+ }
+ HEAP32[12920 >> 2] = i2;
+ HEAP32[12932 >> 2] = i4;
+ }
+ i32 = i3 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ } else {
+ if (!(i12 >>> 0 > 4294967231)) {
+ i24 = i12 + 11 | 0;
+ i12 = i24 & -8;
+ i26 = HEAP32[12916 >> 2] | 0;
+ if ((i26 | 0) != 0) {
+ i25 = 0 - i12 | 0;
+ i24 = i24 >>> 8;
+ if ((i24 | 0) != 0) {
+ if (i12 >>> 0 > 16777215) {
+ i27 = 31;
+ } else {
+ i31 = (i24 + 1048320 | 0) >>> 16 & 8;
+ i32 = i24 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i27 = (i32 + 245760 | 0) >>> 16 & 2;
+ i27 = 14 - (i30 | i31 | i27) + (i32 << i27 >>> 15) | 0;
+ i27 = i12 >>> (i27 + 7 | 0) & 1 | i27 << 1;
+ }
+ } else {
+ i27 = 0;
+ }
+ i30 = HEAP32[13216 + (i27 << 2) >> 2] | 0;
+ L126 : do {
+ if ((i30 | 0) == 0) {
+ i29 = 0;
+ i24 = 0;
+ } else {
+ if ((i27 | 0) == 31) {
+ i24 = 0;
+ } else {
+ i24 = 25 - (i27 >>> 1) | 0;
+ }
+ i29 = 0;
+ i28 = i12 << i24;
+ i24 = 0;
+ while (1) {
+ i32 = HEAP32[i30 + 4 >> 2] & -8;
+ i31 = i32 - i12 | 0;
+ if (i31 >>> 0 < i25 >>> 0) {
+ if ((i32 | 0) == (i12 | 0)) {
+ i25 = i31;
+ i29 = i30;
+ i24 = i30;
+ break L126;
+ } else {
+ i25 = i31;
+ i24 = i30;
+ }
+ }
+ i31 = HEAP32[i30 + 20 >> 2] | 0;
+ i30 = HEAP32[i30 + (i28 >>> 31 << 2) + 16 >> 2] | 0;
+ i29 = (i31 | 0) == 0 | (i31 | 0) == (i30 | 0) ? i29 : i31;
+ if ((i30 | 0) == 0) {
+ break;
+ } else {
+ i28 = i28 << 1;
+ }
+ }
+ }
+ } while (0);
+ if ((i29 | 0) == 0 & (i24 | 0) == 0) {
+ i32 = 2 << i27;
+ i26 = i26 & (i32 | 0 - i32);
+ if ((i26 | 0) == 0) {
+ break;
+ }
+ i32 = (i26 & 0 - i26) + -1 | 0;
+ i28 = i32 >>> 12 & 16;
+ i32 = i32 >>> i28;
+ i27 = i32 >>> 5 & 8;
+ i32 = i32 >>> i27;
+ i30 = i32 >>> 2 & 4;
+ i32 = i32 >>> i30;
+ i31 = i32 >>> 1 & 2;
+ i32 = i32 >>> i31;
+ i29 = i32 >>> 1 & 1;
+ i29 = HEAP32[13216 + ((i27 | i28 | i30 | i31 | i29) + (i32 >>> i29) << 2) >> 2] | 0;
+ }
+ if ((i29 | 0) != 0) {
+ while (1) {
+ i27 = (HEAP32[i29 + 4 >> 2] & -8) - i12 | 0;
+ i26 = i27 >>> 0 < i25 >>> 0;
+ i25 = i26 ? i27 : i25;
+ i24 = i26 ? i29 : i24;
+ i26 = HEAP32[i29 + 16 >> 2] | 0;
+ if ((i26 | 0) != 0) {
+ i29 = i26;
+ continue;
+ }
+ i29 = HEAP32[i29 + 20 >> 2] | 0;
+ if ((i29 | 0) == 0) {
+ break;
+ }
+ }
+ }
+ if ((i24 | 0) != 0 ? i25 >>> 0 < ((HEAP32[12920 >> 2] | 0) - i12 | 0) >>> 0 : 0) {
+ i4 = HEAP32[12928 >> 2] | 0;
+ if (i24 >>> 0 < i4 >>> 0) {
+ _abort();
+ }
+ i2 = i24 + i12 | 0;
+ if (!(i24 >>> 0 < i2 >>> 0)) {
+ _abort();
+ }
+ i3 = HEAP32[i24 + 24 >> 2] | 0;
+ i6 = HEAP32[i24 + 12 >> 2] | 0;
+ do {
+ if ((i6 | 0) == (i24 | 0)) {
+ i6 = i24 + 20 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i6 = i24 + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i22 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i8 = i5 + 20 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) != 0) {
+ i5 = i7;
+ i6 = i8;
+ continue;
+ }
+ i7 = i5 + 16 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if ((i8 | 0) == 0) {
+ break;
+ } else {
+ i5 = i8;
+ i6 = i7;
+ }
+ }
+ if (i6 >>> 0 < i4 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = 0;
+ i22 = i5;
+ break;
+ }
+ } else {
+ i5 = HEAP32[i24 + 8 >> 2] | 0;
+ if (i5 >>> 0 < i4 >>> 0) {
+ _abort();
+ }
+ i7 = i5 + 12 | 0;
+ if ((HEAP32[i7 >> 2] | 0) != (i24 | 0)) {
+ _abort();
+ }
+ i4 = i6 + 8 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
+ HEAP32[i7 >> 2] = i6;
+ HEAP32[i4 >> 2] = i5;
+ i22 = i6;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ do {
+ if ((i3 | 0) != 0) {
+ i4 = HEAP32[i24 + 28 >> 2] | 0;
+ i5 = 13216 + (i4 << 2) | 0;
+ if ((i24 | 0) == (HEAP32[i5 >> 2] | 0)) {
+ HEAP32[i5 >> 2] = i22;
+ if ((i22 | 0) == 0) {
+ HEAP32[12916 >> 2] = HEAP32[12916 >> 2] & ~(1 << i4);
+ break;
+ }
+ } else {
+ if (i3 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i4 = i3 + 16 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
+ HEAP32[i4 >> 2] = i22;
+ } else {
+ HEAP32[i3 + 20 >> 2] = i22;
+ }
+ if ((i22 | 0) == 0) {
+ break;
+ }
+ }
+ if (i22 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i22 + 24 >> 2] = i3;
+ i3 = HEAP32[i24 + 16 >> 2] | 0;
+ do {
+ if ((i3 | 0) != 0) {
+ if (i3 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i22 + 16 >> 2] = i3;
+ HEAP32[i3 + 24 >> 2] = i22;
+ break;
+ }
+ }
+ } while (0);
+ i3 = HEAP32[i24 + 20 >> 2] | 0;
+ if ((i3 | 0) != 0) {
+ if (i3 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i22 + 20 >> 2] = i3;
+ HEAP32[i3 + 24 >> 2] = i22;
+ break;
+ }
+ }
+ }
+ } while (0);
+ L204 : do {
+ if (!(i25 >>> 0 < 16)) {
+ HEAP32[i24 + 4 >> 2] = i12 | 3;
+ HEAP32[i24 + (i12 | 4) >> 2] = i25 | 1;
+ HEAP32[i24 + (i25 + i12) >> 2] = i25;
+ i4 = i25 >>> 3;
+ if (i25 >>> 0 < 256) {
+ i6 = i4 << 1;
+ i3 = 12952 + (i6 << 2) | 0;
+ i5 = HEAP32[3228] | 0;
+ i4 = 1 << i4;
+ if ((i5 & i4 | 0) != 0) {
+ i5 = 12952 + (i6 + 2 << 2) | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ if (i4 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i21 = i5;
+ i20 = i4;
+ }
+ } else {
+ HEAP32[3228] = i5 | i4;
+ i21 = 12952 + (i6 + 2 << 2) | 0;
+ i20 = i3;
+ }
+ HEAP32[i21 >> 2] = i2;
+ HEAP32[i20 + 12 >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i20;
+ HEAP32[i24 + (i12 + 12) >> 2] = i3;
+ break;
+ }
+ i3 = i25 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i25 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i25 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i6 = 13216 + (i3 << 2) | 0;
+ HEAP32[i24 + (i12 + 28) >> 2] = i3;
+ HEAP32[i24 + (i12 + 20) >> 2] = 0;
+ HEAP32[i24 + (i12 + 16) >> 2] = 0;
+ i4 = HEAP32[12916 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i4 & i5 | 0) == 0) {
+ HEAP32[12916 >> 2] = i4 | i5;
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i24 + (i12 + 24) >> 2] = i6;
+ HEAP32[i24 + (i12 + 12) >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i2;
+ break;
+ }
+ i4 = HEAP32[i6 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L225 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i25 | 0)) {
+ i3 = i25 << i3;
+ while (1) {
+ i6 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i25 | 0)) {
+ i18 = i5;
+ break L225;
+ } else {
+ i3 = i3 << 1;
+ i4 = i5;
+ }
+ }
+ if (i6 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i24 + (i12 + 24) >> 2] = i4;
+ HEAP32[i24 + (i12 + 12) >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i2;
+ break L204;
+ }
+ } else {
+ i18 = i4;
+ }
+ } while (0);
+ i4 = i18 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[12928 >> 2] | 0;
+ if (i18 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i2;
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i3;
+ HEAP32[i24 + (i12 + 12) >> 2] = i18;
+ HEAP32[i24 + (i12 + 24) >> 2] = 0;
+ break;
+ }
+ } else {
+ i32 = i25 + i12 | 0;
+ HEAP32[i24 + 4 >> 2] = i32 | 3;
+ i32 = i24 + (i32 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ }
+ } while (0);
+ i32 = i24 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ } else {
+ i12 = -1;
+ }
+ }
+ } while (0);
+ i18 = HEAP32[12920 >> 2] | 0;
+ if (!(i12 >>> 0 > i18 >>> 0)) {
+ i3 = i18 - i12 | 0;
+ i2 = HEAP32[12932 >> 2] | 0;
+ if (i3 >>> 0 > 15) {
+ HEAP32[12932 >> 2] = i2 + i12;
+ HEAP32[12920 >> 2] = i3;
+ HEAP32[i2 + (i12 + 4) >> 2] = i3 | 1;
+ HEAP32[i2 + i18 >> 2] = i3;
+ HEAP32[i2 + 4 >> 2] = i12 | 3;
+ } else {
+ HEAP32[12920 >> 2] = 0;
+ HEAP32[12932 >> 2] = 0;
+ HEAP32[i2 + 4 >> 2] = i18 | 3;
+ i32 = i2 + (i18 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ }
+ i32 = i2 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i18 = HEAP32[12924 >> 2] | 0;
+ if (i12 >>> 0 < i18 >>> 0) {
+ i31 = i18 - i12 | 0;
+ HEAP32[12924 >> 2] = i31;
+ i32 = HEAP32[12936 >> 2] | 0;
+ HEAP32[12936 >> 2] = i32 + i12;
+ HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
+ HEAP32[i32 + 4 >> 2] = i12 | 3;
+ i32 = i32 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ do {
+ if ((HEAP32[3346] | 0) == 0) {
+ i18 = _sysconf(30) | 0;
+ if ((i18 + -1 & i18 | 0) == 0) {
+ HEAP32[13392 >> 2] = i18;
+ HEAP32[13388 >> 2] = i18;
+ HEAP32[13396 >> 2] = -1;
+ HEAP32[13400 >> 2] = -1;
+ HEAP32[13404 >> 2] = 0;
+ HEAP32[13356 >> 2] = 0;
+ HEAP32[3346] = (_time(0) | 0) & -16 ^ 1431655768;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ i20 = i12 + 48 | 0;
+ i25 = HEAP32[13392 >> 2] | 0;
+ i21 = i12 + 47 | 0;
+ i22 = i25 + i21 | 0;
+ i25 = 0 - i25 | 0;
+ i18 = i22 & i25;
+ if (!(i18 >>> 0 > i12 >>> 0)) {
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i24 = HEAP32[13352 >> 2] | 0;
+ if ((i24 | 0) != 0 ? (i31 = HEAP32[13344 >> 2] | 0, i32 = i31 + i18 | 0, i32 >>> 0 <= i31 >>> 0 | i32 >>> 0 > i24 >>> 0) : 0) {
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ L269 : do {
+ if ((HEAP32[13356 >> 2] & 4 | 0) == 0) {
+ i26 = HEAP32[12936 >> 2] | 0;
+ L271 : do {
+ if ((i26 | 0) != 0) {
+ i24 = 13360 | 0;
+ while (1) {
+ i27 = HEAP32[i24 >> 2] | 0;
+ if (!(i27 >>> 0 > i26 >>> 0) ? (i23 = i24 + 4 | 0, (i27 + (HEAP32[i23 >> 2] | 0) | 0) >>> 0 > i26 >>> 0) : 0) {
+ break;
+ }
+ i24 = HEAP32[i24 + 8 >> 2] | 0;
+ if ((i24 | 0) == 0) {
+ i13 = 182;
+ break L271;
+ }
+ }
+ if ((i24 | 0) != 0) {
+ i25 = i22 - (HEAP32[12924 >> 2] | 0) & i25;
+ if (i25 >>> 0 < 2147483647) {
+ i13 = _sbrk(i25 | 0) | 0;
+ i26 = (i13 | 0) == ((HEAP32[i24 >> 2] | 0) + (HEAP32[i23 >> 2] | 0) | 0);
+ i22 = i13;
+ i24 = i25;
+ i23 = i26 ? i13 : -1;
+ i25 = i26 ? i25 : 0;
+ i13 = 191;
+ } else {
+ i25 = 0;
+ }
+ } else {
+ i13 = 182;
+ }
+ } else {
+ i13 = 182;
+ }
+ } while (0);
+ do {
+ if ((i13 | 0) == 182) {
+ i23 = _sbrk(0) | 0;
+ if ((i23 | 0) != (-1 | 0)) {
+ i24 = i23;
+ i22 = HEAP32[13388 >> 2] | 0;
+ i25 = i22 + -1 | 0;
+ if ((i25 & i24 | 0) == 0) {
+ i25 = i18;
+ } else {
+ i25 = i18 - i24 + (i25 + i24 & 0 - i22) | 0;
+ }
+ i24 = HEAP32[13344 >> 2] | 0;
+ i26 = i24 + i25 | 0;
+ if (i25 >>> 0 > i12 >>> 0 & i25 >>> 0 < 2147483647) {
+ i22 = HEAP32[13352 >> 2] | 0;
+ if ((i22 | 0) != 0 ? i26 >>> 0 <= i24 >>> 0 | i26 >>> 0 > i22 >>> 0 : 0) {
+ i25 = 0;
+ break;
+ }
+ i22 = _sbrk(i25 | 0) | 0;
+ i13 = (i22 | 0) == (i23 | 0);
+ i24 = i25;
+ i23 = i13 ? i23 : -1;
+ i25 = i13 ? i25 : 0;
+ i13 = 191;
+ } else {
+ i25 = 0;
+ }
+ } else {
+ i25 = 0;
+ }
+ }
+ } while (0);
+ L291 : do {
+ if ((i13 | 0) == 191) {
+ i13 = 0 - i24 | 0;
+ if ((i23 | 0) != (-1 | 0)) {
+ i17 = i23;
+ i14 = i25;
+ i13 = 202;
+ break L269;
+ }
+ do {
+ if ((i22 | 0) != (-1 | 0) & i24 >>> 0 < 2147483647 & i24 >>> 0 < i20 >>> 0 ? (i19 = HEAP32[13392 >> 2] | 0, i19 = i21 - i24 + i19 & 0 - i19, i19 >>> 0 < 2147483647) : 0) {
+ if ((_sbrk(i19 | 0) | 0) == (-1 | 0)) {
+ _sbrk(i13 | 0) | 0;
+ break L291;
+ } else {
+ i24 = i19 + i24 | 0;
+ break;
+ }
+ }
+ } while (0);
+ if ((i22 | 0) != (-1 | 0)) {
+ i17 = i22;
+ i14 = i24;
+ i13 = 202;
+ break L269;
+ }
+ }
+ } while (0);
+ HEAP32[13356 >> 2] = HEAP32[13356 >> 2] | 4;
+ i13 = 199;
+ } else {
+ i25 = 0;
+ i13 = 199;
+ }
+ } while (0);
+ if ((((i13 | 0) == 199 ? i18 >>> 0 < 2147483647 : 0) ? (i17 = _sbrk(i18 | 0) | 0, i16 = _sbrk(0) | 0, (i16 | 0) != (-1 | 0) & (i17 | 0) != (-1 | 0) & i17 >>> 0 < i16 >>> 0) : 0) ? (i15 = i16 - i17 | 0, i14 = i15 >>> 0 > (i12 + 40 | 0) >>> 0, i14) : 0) {
+ i14 = i14 ? i15 : i25;
+ i13 = 202;
+ }
+ if ((i13 | 0) == 202) {
+ i15 = (HEAP32[13344 >> 2] | 0) + i14 | 0;
+ HEAP32[13344 >> 2] = i15;
+ if (i15 >>> 0 > (HEAP32[13348 >> 2] | 0) >>> 0) {
+ HEAP32[13348 >> 2] = i15;
+ }
+ i15 = HEAP32[12936 >> 2] | 0;
+ L311 : do {
+ if ((i15 | 0) != 0) {
+ i21 = 13360 | 0;
+ while (1) {
+ i16 = HEAP32[i21 >> 2] | 0;
+ i19 = i21 + 4 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i17 | 0) == (i16 + i20 | 0)) {
+ i13 = 214;
+ break;
+ }
+ i18 = HEAP32[i21 + 8 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ break;
+ } else {
+ i21 = i18;
+ }
+ }
+ if (((i13 | 0) == 214 ? (HEAP32[i21 + 12 >> 2] & 8 | 0) == 0 : 0) ? i15 >>> 0 >= i16 >>> 0 & i15 >>> 0 < i17 >>> 0 : 0) {
+ HEAP32[i19 >> 2] = i20 + i14;
+ i2 = (HEAP32[12924 >> 2] | 0) + i14 | 0;
+ i3 = i15 + 8 | 0;
+ if ((i3 & 7 | 0) == 0) {
+ i3 = 0;
+ } else {
+ i3 = 0 - i3 & 7;
+ }
+ i32 = i2 - i3 | 0;
+ HEAP32[12936 >> 2] = i15 + i3;
+ HEAP32[12924 >> 2] = i32;
+ HEAP32[i15 + (i3 + 4) >> 2] = i32 | 1;
+ HEAP32[i15 + (i2 + 4) >> 2] = 40;
+ HEAP32[12940 >> 2] = HEAP32[13400 >> 2];
+ break;
+ }
+ if (i17 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ HEAP32[12928 >> 2] = i17;
+ }
+ i19 = i17 + i14 | 0;
+ i16 = 13360 | 0;
+ while (1) {
+ if ((HEAP32[i16 >> 2] | 0) == (i19 | 0)) {
+ i13 = 224;
+ break;
+ }
+ i18 = HEAP32[i16 + 8 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ break;
+ } else {
+ i16 = i18;
+ }
+ }
+ if ((i13 | 0) == 224 ? (HEAP32[i16 + 12 >> 2] & 8 | 0) == 0 : 0) {
+ HEAP32[i16 >> 2] = i17;
+ i6 = i16 + 4 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + i14;
+ i6 = i17 + 8 | 0;
+ if ((i6 & 7 | 0) == 0) {
+ i6 = 0;
+ } else {
+ i6 = 0 - i6 & 7;
+ }
+ i7 = i17 + (i14 + 8) | 0;
+ if ((i7 & 7 | 0) == 0) {
+ i13 = 0;
+ } else {
+ i13 = 0 - i7 & 7;
+ }
+ i15 = i17 + (i13 + i14) | 0;
+ i8 = i6 + i12 | 0;
+ i7 = i17 + i8 | 0;
+ i10 = i15 - (i17 + i6) - i12 | 0;
+ HEAP32[i17 + (i6 + 4) >> 2] = i12 | 3;
+ L348 : do {
+ if ((i15 | 0) != (HEAP32[12936 >> 2] | 0)) {
+ if ((i15 | 0) == (HEAP32[12932 >> 2] | 0)) {
+ i32 = (HEAP32[12920 >> 2] | 0) + i10 | 0;
+ HEAP32[12920 >> 2] = i32;
+ HEAP32[12932 >> 2] = i7;
+ HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i32 + i8) >> 2] = i32;
+ break;
+ }
+ i12 = i14 + 4 | 0;
+ i18 = HEAP32[i17 + (i12 + i13) >> 2] | 0;
+ if ((i18 & 3 | 0) == 1) {
+ i11 = i18 & -8;
+ i16 = i18 >>> 3;
+ do {
+ if (!(i18 >>> 0 < 256)) {
+ i9 = HEAP32[i17 + ((i13 | 24) + i14) >> 2] | 0;
+ i19 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
+ do {
+ if ((i19 | 0) == (i15 | 0)) {
+ i19 = i13 | 16;
+ i18 = i17 + (i12 + i19) | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ if ((i16 | 0) == 0) {
+ i18 = i17 + (i19 + i14) | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ if ((i16 | 0) == 0) {
+ i5 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i20 = i16 + 20 | 0;
+ i19 = HEAP32[i20 >> 2] | 0;
+ if ((i19 | 0) != 0) {
+ i16 = i19;
+ i18 = i20;
+ continue;
+ }
+ i19 = i16 + 16 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i20 | 0) == 0) {
+ break;
+ } else {
+ i16 = i20;
+ i18 = i19;
+ }
+ }
+ if (i18 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i18 >> 2] = 0;
+ i5 = i16;
+ break;
+ }
+ } else {
+ i18 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
+ if (i18 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i18 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != (i15 | 0)) {
+ _abort();
+ }
+ i20 = i19 + 8 | 0;
+ if ((HEAP32[i20 >> 2] | 0) == (i15 | 0)) {
+ HEAP32[i16 >> 2] = i19;
+ HEAP32[i20 >> 2] = i18;
+ i5 = i19;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i9 | 0) != 0) {
+ i16 = HEAP32[i17 + (i14 + 28 + i13) >> 2] | 0;
+ i18 = 13216 + (i16 << 2) | 0;
+ if ((i15 | 0) == (HEAP32[i18 >> 2] | 0)) {
+ HEAP32[i18 >> 2] = i5;
+ if ((i5 | 0) == 0) {
+ HEAP32[12916 >> 2] = HEAP32[12916 >> 2] & ~(1 << i16);
+ break;
+ }
+ } else {
+ if (i9 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i9 + 16 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
+ HEAP32[i16 >> 2] = i5;
+ } else {
+ HEAP32[i9 + 20 >> 2] = i5;
+ }
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i5 + 24 >> 2] = i9;
+ i15 = i13 | 16;
+ i9 = HEAP32[i17 + (i15 + i14) >> 2] | 0;
+ do {
+ if ((i9 | 0) != 0) {
+ if (i9 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 + 16 >> 2] = i9;
+ HEAP32[i9 + 24 >> 2] = i5;
+ break;
+ }
+ }
+ } while (0);
+ i9 = HEAP32[i17 + (i12 + i15) >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ if (i9 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 + 20 >> 2] = i9;
+ HEAP32[i9 + 24 >> 2] = i5;
+ break;
+ }
+ }
+ }
+ } else {
+ i5 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
+ i12 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
+ i18 = 12952 + (i16 << 1 << 2) | 0;
+ if ((i5 | 0) != (i18 | 0)) {
+ if (i5 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i5 + 12 >> 2] | 0) != (i15 | 0)) {
+ _abort();
+ }
+ }
+ if ((i12 | 0) == (i5 | 0)) {
+ HEAP32[3228] = HEAP32[3228] & ~(1 << i16);
+ break;
+ }
+ if ((i12 | 0) != (i18 | 0)) {
+ if (i12 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i12 + 8 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
+ i9 = i16;
+ } else {
+ _abort();
+ }
+ } else {
+ i9 = i12 + 8 | 0;
+ }
+ HEAP32[i5 + 12 >> 2] = i12;
+ HEAP32[i9 >> 2] = i5;
+ }
+ } while (0);
+ i15 = i17 + ((i11 | i13) + i14) | 0;
+ i10 = i11 + i10 | 0;
+ }
+ i5 = i15 + 4 | 0;
+ HEAP32[i5 >> 2] = HEAP32[i5 >> 2] & -2;
+ HEAP32[i17 + (i8 + 4) >> 2] = i10 | 1;
+ HEAP32[i17 + (i10 + i8) >> 2] = i10;
+ i5 = i10 >>> 3;
+ if (i10 >>> 0 < 256) {
+ i10 = i5 << 1;
+ i2 = 12952 + (i10 << 2) | 0;
+ i9 = HEAP32[3228] | 0;
+ i5 = 1 << i5;
+ if ((i9 & i5 | 0) != 0) {
+ i9 = 12952 + (i10 + 2 << 2) | 0;
+ i5 = HEAP32[i9 >> 2] | 0;
+ if (i5 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i3 = i9;
+ i4 = i5;
+ }
+ } else {
+ HEAP32[3228] = i9 | i5;
+ i3 = 12952 + (i10 + 2 << 2) | 0;
+ i4 = i2;
+ }
+ HEAP32[i3 >> 2] = i7;
+ HEAP32[i4 + 12 >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i2;
+ break;
+ }
+ i3 = i10 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i10 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i10 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i4 = 13216 + (i3 << 2) | 0;
+ HEAP32[i17 + (i8 + 28) >> 2] = i3;
+ HEAP32[i17 + (i8 + 20) >> 2] = 0;
+ HEAP32[i17 + (i8 + 16) >> 2] = 0;
+ i9 = HEAP32[12916 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i9 & i5 | 0) == 0) {
+ HEAP32[12916 >> 2] = i9 | i5;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i17 + (i8 + 24) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i7;
+ break;
+ }
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L445 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i10 | 0)) {
+ i3 = i10 << i3;
+ while (1) {
+ i5 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i9 = HEAP32[i5 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i9 + 4 >> 2] & -8 | 0) == (i10 | 0)) {
+ i2 = i9;
+ break L445;
+ } else {
+ i3 = i3 << 1;
+ i4 = i9;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 >> 2] = i7;
+ HEAP32[i17 + (i8 + 24) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i7;
+ break L348;
+ }
+ } else {
+ i2 = i4;
+ }
+ } while (0);
+ i4 = i2 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[12928 >> 2] | 0;
+ if (i2 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i7;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i3;
+ HEAP32[i17 + (i8 + 12) >> 2] = i2;
+ HEAP32[i17 + (i8 + 24) >> 2] = 0;
+ break;
+ }
+ } else {
+ i32 = (HEAP32[12924 >> 2] | 0) + i10 | 0;
+ HEAP32[12924 >> 2] = i32;
+ HEAP32[12936 >> 2] = i7;
+ HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
+ }
+ } while (0);
+ i32 = i17 + (i6 | 8) | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i3 = 13360 | 0;
+ while (1) {
+ i2 = HEAP32[i3 >> 2] | 0;
+ if (!(i2 >>> 0 > i15 >>> 0) ? (i11 = HEAP32[i3 + 4 >> 2] | 0, i10 = i2 + i11 | 0, i10 >>> 0 > i15 >>> 0) : 0) {
+ break;
+ }
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ }
+ i3 = i2 + (i11 + -39) | 0;
+ if ((i3 & 7 | 0) == 0) {
+ i3 = 0;
+ } else {
+ i3 = 0 - i3 & 7;
+ }
+ i2 = i2 + (i11 + -47 + i3) | 0;
+ i2 = i2 >>> 0 < (i15 + 16 | 0) >>> 0 ? i15 : i2;
+ i3 = i2 + 8 | 0;
+ i4 = i17 + 8 | 0;
+ if ((i4 & 7 | 0) == 0) {
+ i4 = 0;
+ } else {
+ i4 = 0 - i4 & 7;
+ }
+ i32 = i14 + -40 - i4 | 0;
+ HEAP32[12936 >> 2] = i17 + i4;
+ HEAP32[12924 >> 2] = i32;
+ HEAP32[i17 + (i4 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i14 + -36) >> 2] = 40;
+ HEAP32[12940 >> 2] = HEAP32[13400 >> 2];
+ HEAP32[i2 + 4 >> 2] = 27;
+ HEAP32[i3 + 0 >> 2] = HEAP32[13360 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[13364 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[13368 >> 2];
+ HEAP32[i3 + 12 >> 2] = HEAP32[13372 >> 2];
+ HEAP32[13360 >> 2] = i17;
+ HEAP32[13364 >> 2] = i14;
+ HEAP32[13372 >> 2] = 0;
+ HEAP32[13368 >> 2] = i3;
+ i4 = i2 + 28 | 0;
+ HEAP32[i4 >> 2] = 7;
+ if ((i2 + 32 | 0) >>> 0 < i10 >>> 0) {
+ while (1) {
+ i3 = i4 + 4 | 0;
+ HEAP32[i3 >> 2] = 7;
+ if ((i4 + 8 | 0) >>> 0 < i10 >>> 0) {
+ i4 = i3;
+ } else {
+ break;
+ }
+ }
+ }
+ if ((i2 | 0) != (i15 | 0)) {
+ i2 = i2 - i15 | 0;
+ i3 = i15 + (i2 + 4) | 0;
+ HEAP32[i3 >> 2] = HEAP32[i3 >> 2] & -2;
+ HEAP32[i15 + 4 >> 2] = i2 | 1;
+ HEAP32[i15 + i2 >> 2] = i2;
+ i3 = i2 >>> 3;
+ if (i2 >>> 0 < 256) {
+ i4 = i3 << 1;
+ i2 = 12952 + (i4 << 2) | 0;
+ i5 = HEAP32[3228] | 0;
+ i3 = 1 << i3;
+ if ((i5 & i3 | 0) != 0) {
+ i4 = 12952 + (i4 + 2 << 2) | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ if (i3 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i7 = i4;
+ i8 = i3;
+ }
+ } else {
+ HEAP32[3228] = i5 | i3;
+ i7 = 12952 + (i4 + 2 << 2) | 0;
+ i8 = i2;
+ }
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i8 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i8;
+ HEAP32[i15 + 12 >> 2] = i2;
+ break;
+ }
+ i3 = i2 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i2 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i2 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i7 = 13216 + (i3 << 2) | 0;
+ HEAP32[i15 + 28 >> 2] = i3;
+ HEAP32[i15 + 20 >> 2] = 0;
+ HEAP32[i15 + 16 >> 2] = 0;
+ i4 = HEAP32[12916 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i4 & i5 | 0) == 0) {
+ HEAP32[12916 >> 2] = i4 | i5;
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i7;
+ HEAP32[i15 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i15;
+ break;
+ }
+ i4 = HEAP32[i7 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L499 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i2 | 0)) {
+ i3 = i2 << i3;
+ while (1) {
+ i7 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i2 | 0)) {
+ i6 = i5;
+ break L499;
+ } else {
+ i3 = i3 << 1;
+ i4 = i5;
+ }
+ }
+ if (i7 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i4;
+ HEAP32[i15 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i15;
+ break L311;
+ }
+ } else {
+ i6 = i4;
+ }
+ } while (0);
+ i4 = i6 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i2 = HEAP32[12928 >> 2] | 0;
+ if (i6 >>> 0 < i2 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i2 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i15;
+ HEAP32[i4 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i3;
+ HEAP32[i15 + 12 >> 2] = i6;
+ HEAP32[i15 + 24 >> 2] = 0;
+ break;
+ }
+ }
+ } else {
+ i32 = HEAP32[12928 >> 2] | 0;
+ if ((i32 | 0) == 0 | i17 >>> 0 < i32 >>> 0) {
+ HEAP32[12928 >> 2] = i17;
+ }
+ HEAP32[13360 >> 2] = i17;
+ HEAP32[13364 >> 2] = i14;
+ HEAP32[13372 >> 2] = 0;
+ HEAP32[12948 >> 2] = HEAP32[3346];
+ HEAP32[12944 >> 2] = -1;
+ i2 = 0;
+ do {
+ i32 = i2 << 1;
+ i31 = 12952 + (i32 << 2) | 0;
+ HEAP32[12952 + (i32 + 3 << 2) >> 2] = i31;
+ HEAP32[12952 + (i32 + 2 << 2) >> 2] = i31;
+ i2 = i2 + 1 | 0;
+ } while ((i2 | 0) != 32);
+ i2 = i17 + 8 | 0;
+ if ((i2 & 7 | 0) == 0) {
+ i2 = 0;
+ } else {
+ i2 = 0 - i2 & 7;
+ }
+ i32 = i14 + -40 - i2 | 0;
+ HEAP32[12936 >> 2] = i17 + i2;
+ HEAP32[12924 >> 2] = i32;
+ HEAP32[i17 + (i2 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i14 + -36) >> 2] = 40;
+ HEAP32[12940 >> 2] = HEAP32[13400 >> 2];
+ }
+ } while (0);
+ i2 = HEAP32[12924 >> 2] | 0;
+ if (i2 >>> 0 > i12 >>> 0) {
+ i31 = i2 - i12 | 0;
+ HEAP32[12924 >> 2] = i31;
+ i32 = HEAP32[12936 >> 2] | 0;
+ HEAP32[12936 >> 2] = i32 + i12;
+ HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
+ HEAP32[i32 + 4 >> 2] = i12 | 3;
+ i32 = i32 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ HEAP32[(___errno_location() | 0) >> 2] = 12;
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+}
+function _llex(i2, i3) {
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i12 = i1;
+ i4 = i2 + 60 | 0;
+ HEAP32[(HEAP32[i4 >> 2] | 0) + 4 >> 2] = 0;
+ i5 = i2 + 56 | 0;
+ L1 : while (1) {
+ i13 = HEAP32[i2 >> 2] | 0;
+ L3 : while (1) {
+ switch (i13 | 0) {
+ case 11:
+ case 9:
+ case 12:
+ case 32:
+ {
+ break;
+ }
+ case 91:
+ {
+ i9 = 25;
+ break L1;
+ }
+ case 62:
+ {
+ i9 = 45;
+ break L1;
+ }
+ case 46:
+ {
+ i9 = 161;
+ break L1;
+ }
+ case 13:
+ case 10:
+ {
+ i9 = 4;
+ break L3;
+ }
+ case 45:
+ {
+ break L3;
+ }
+ case 61:
+ {
+ i9 = 29;
+ break L1;
+ }
+ case 39:
+ case 34:
+ {
+ i9 = 69;
+ break L1;
+ }
+ case 126:
+ {
+ i9 = 53;
+ break L1;
+ }
+ case 60:
+ {
+ i9 = 37;
+ break L1;
+ }
+ case 58:
+ {
+ i9 = 61;
+ break L1;
+ }
+ case 57:
+ case 56:
+ case 55:
+ case 54:
+ case 53:
+ case 52:
+ case 51:
+ case 50:
+ case 49:
+ case 48:
+ {
+ i20 = i13;
+ break L1;
+ }
+ case -1:
+ {
+ i2 = 286;
+ i9 = 306;
+ break L1;
+ }
+ default:
+ {
+ i9 = 283;
+ break L1;
+ }
+ }
+ i13 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i13 = _luaZ_fill(i13) | 0;
+ } else {
+ i27 = i13 + 4 | 0;
+ i13 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i13 + 1;
+ i13 = HEAPU8[i13] | 0;
+ }
+ HEAP32[i2 >> 2] = i13;
+ }
+ if ((i9 | 0) == 4) {
+ i9 = 0;
+ _inclinenumber(i2);
+ continue;
+ }
+ i13 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i13 = _luaZ_fill(i13) | 0;
+ } else {
+ i27 = i13 + 4 | 0;
+ i13 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i13 + 1;
+ i13 = HEAPU8[i13] | 0;
+ }
+ HEAP32[i2 >> 2] = i13;
+ if ((i13 | 0) != 45) {
+ i2 = 45;
+ i9 = 306;
+ break;
+ }
+ i13 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i13 = _luaZ_fill(i13) | 0;
+ } else {
+ i27 = i13 + 4 | 0;
+ i13 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i13 + 1;
+ i13 = HEAPU8[i13] | 0;
+ }
+ HEAP32[i2 >> 2] = i13;
+ do {
+ if ((i13 | 0) == 91) {
+ i13 = _skip_sep(i2) | 0;
+ HEAP32[(HEAP32[i4 >> 2] | 0) + 4 >> 2] = 0;
+ if ((i13 | 0) > -1) {
+ _read_long_string(i2, 0, i13);
+ HEAP32[(HEAP32[i4 >> 2] | 0) + 4 >> 2] = 0;
+ continue L1;
+ } else {
+ i13 = HEAP32[i2 >> 2] | 0;
+ break;
+ }
+ }
+ } while (0);
+ while (1) {
+ if ((i13 | 0) == -1 | (i13 | 0) == 13 | (i13 | 0) == 10) {
+ continue L1;
+ }
+ i13 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i13 = _luaZ_fill(i13) | 0;
+ } else {
+ i27 = i13 + 4 | 0;
+ i13 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i13 + 1;
+ i13 = HEAPU8[i13] | 0;
+ }
+ HEAP32[i2 >> 2] = i13;
+ }
+ }
+ if ((i9 | 0) == 25) {
+ i9 = _skip_sep(i2) | 0;
+ if ((i9 | 0) > -1) {
+ _read_long_string(i2, i3, i9);
+ i27 = 289;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ if ((i9 | 0) == -1) {
+ i27 = 91;
+ STACKTOP = i1;
+ return i27 | 0;
+ } else {
+ _lexerror(i2, 12272, 289);
+ }
+ } else if ((i9 | 0) == 29) {
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ if ((i3 | 0) != 61) {
+ i27 = 61;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ i27 = 281;
+ STACKTOP = i1;
+ return i27 | 0;
+ } else if ((i9 | 0) == 37) {
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ if ((i3 | 0) != 61) {
+ i27 = 60;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ i27 = 283;
+ STACKTOP = i1;
+ return i27 | 0;
+ } else if ((i9 | 0) == 45) {
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ if ((i3 | 0) != 61) {
+ i27 = 62;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ i27 = 282;
+ STACKTOP = i1;
+ return i27 | 0;
+ } else if ((i9 | 0) == 53) {
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ if ((i3 | 0) != 61) {
+ i27 = 126;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ i27 = 284;
+ STACKTOP = i1;
+ return i27 | 0;
+ } else if ((i9 | 0) == 61) {
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ if ((i3 | 0) != 58) {
+ i27 = 58;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ i27 = 285;
+ STACKTOP = i1;
+ return i27 | 0;
+ } else if ((i9 | 0) == 69) {
+ i14 = HEAP32[i4 >> 2] | 0;
+ i7 = i14 + 4 | 0;
+ i15 = HEAP32[i7 >> 2] | 0;
+ i8 = i14 + 8 | 0;
+ i6 = HEAP32[i8 >> 2] | 0;
+ do {
+ if ((i15 + 1 | 0) >>> 0 > i6 >>> 0) {
+ if (i6 >>> 0 > 2147483645) {
+ _lexerror(i2, 12368, 0);
+ }
+ i16 = i6 << 1;
+ i15 = HEAP32[i2 + 52 >> 2] | 0;
+ if ((i16 | 0) == -2) {
+ _luaM_toobig(i15);
+ } else {
+ i24 = _luaM_realloc_(i15, HEAP32[i14 >> 2] | 0, i6, i16) | 0;
+ HEAP32[i14 >> 2] = i24;
+ HEAP32[i8 >> 2] = i16;
+ i23 = HEAP32[i7 >> 2] | 0;
+ break;
+ }
+ } else {
+ i23 = i15;
+ i24 = HEAP32[i14 >> 2] | 0;
+ }
+ } while (0);
+ i6 = i13 & 255;
+ HEAP32[i7 >> 2] = i23 + 1;
+ HEAP8[i24 + i23 | 0] = i6;
+ i7 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i14 = _luaZ_fill(i7) | 0;
+ } else {
+ i27 = i7 + 4 | 0;
+ i14 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i14 + 1;
+ i14 = HEAPU8[i14] | 0;
+ }
+ HEAP32[i2 >> 2] = i14;
+ L139 : do {
+ if ((i14 | 0) != (i13 | 0)) {
+ i7 = i2 + 52 | 0;
+ L141 : while (1) {
+ L143 : do {
+ if ((i14 | 0) == 92) {
+ i8 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i8 = _luaZ_fill(i8) | 0;
+ } else {
+ i27 = i8 + 4 | 0;
+ i8 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i8 + 1;
+ i8 = HEAPU8[i8] | 0;
+ }
+ HEAP32[i2 >> 2] = i8;
+ switch (i8 | 0) {
+ case 13:
+ case 10:
+ {
+ _inclinenumber(i2);
+ i8 = 10;
+ break;
+ }
+ case 39:
+ case 34:
+ case 92:
+ {
+ i9 = 124;
+ break;
+ }
+ case 122:
+ {
+ i8 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i14 = _luaZ_fill(i8) | 0;
+ } else {
+ i27 = i8 + 4 | 0;
+ i14 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i14 + 1;
+ i14 = HEAPU8[i14] | 0;
+ }
+ HEAP32[i2 >> 2] = i14;
+ if ((HEAP8[i14 + 10913 | 0] & 8) == 0) {
+ break L143;
+ }
+ while (1) {
+ if ((i14 | 0) == 13 | (i14 | 0) == 10) {
+ _inclinenumber(i2);
+ i14 = HEAP32[i2 >> 2] | 0;
+ } else {
+ i8 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i14 = _luaZ_fill(i8) | 0;
+ } else {
+ i27 = i8 + 4 | 0;
+ i14 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i14 + 1;
+ i14 = HEAPU8[i14] | 0;
+ }
+ HEAP32[i2 >> 2] = i14;
+ }
+ if ((HEAP8[i14 + 10913 | 0] & 8) == 0) {
+ break L143;
+ }
+ }
+ }
+ case 118:
+ {
+ i8 = 11;
+ i9 = 124;
+ break;
+ }
+ case 120:
+ {
+ HEAP32[i12 >> 2] = 120;
+ i14 = 1;
+ i8 = 0;
+ while (1) {
+ i9 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i9 = _luaZ_fill(i9) | 0;
+ } else {
+ i27 = i9 + 4 | 0;
+ i9 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i9 + 1;
+ i9 = HEAPU8[i9] | 0;
+ }
+ HEAP32[i2 >> 2] = i9;
+ HEAP32[i12 + (i14 << 2) >> 2] = i9;
+ if ((HEAP8[i9 + 10913 | 0] & 16) == 0) {
+ i9 = 100;
+ break L141;
+ }
+ i8 = (_luaO_hexavalue(i9) | 0) + (i8 << 4) | 0;
+ i14 = i14 + 1 | 0;
+ if ((i14 | 0) >= 3) {
+ i9 = 124;
+ break;
+ }
+ }
+ break;
+ }
+ case -1:
+ {
+ i14 = -1;
+ break L143;
+ }
+ case 98:
+ {
+ i8 = 8;
+ i9 = 124;
+ break;
+ }
+ case 102:
+ {
+ i8 = 12;
+ i9 = 124;
+ break;
+ }
+ case 110:
+ {
+ i8 = 10;
+ i9 = 124;
+ break;
+ }
+ case 114:
+ {
+ i8 = 13;
+ i9 = 124;
+ break;
+ }
+ case 116:
+ {
+ i8 = 9;
+ i9 = 124;
+ break;
+ }
+ case 97:
+ {
+ i8 = 7;
+ i9 = 124;
+ break;
+ }
+ default:
+ {
+ if ((HEAP8[i8 + 10913 | 0] & 2) == 0) {
+ i9 = 116;
+ break L141;
+ } else {
+ i15 = i8;
+ i14 = 0;
+ i8 = 0;
+ }
+ do {
+ if ((HEAP8[i15 + 10913 | 0] & 2) == 0) {
+ break;
+ }
+ HEAP32[i12 + (i14 << 2) >> 2] = i15;
+ i8 = i15 + -48 + (i8 * 10 | 0) | 0;
+ i15 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i15 >> 2] | 0;
+ HEAP32[i15 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i15 = _luaZ_fill(i15) | 0;
+ } else {
+ i27 = i15 + 4 | 0;
+ i15 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i15 + 1;
+ i15 = HEAPU8[i15] | 0;
+ }
+ HEAP32[i2 >> 2] = i15;
+ i14 = i14 + 1 | 0;
+ } while ((i14 | 0) < 3);
+ if ((i8 | 0) > 255) {
+ i9 = 123;
+ break L141;
+ }
+ }
+ }
+ if ((i9 | 0) == 124) {
+ i9 = 0;
+ i14 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i14 = _luaZ_fill(i14) | 0;
+ } else {
+ i27 = i14 + 4 | 0;
+ i14 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i14 + 1;
+ i14 = HEAPU8[i14] | 0;
+ }
+ HEAP32[i2 >> 2] = i14;
+ }
+ i15 = HEAP32[i4 >> 2] | 0;
+ i14 = i15 + 4 | 0;
+ i18 = HEAP32[i14 >> 2] | 0;
+ i16 = i15 + 8 | 0;
+ i17 = HEAP32[i16 >> 2] | 0;
+ if ((i18 + 1 | 0) >>> 0 > i17 >>> 0) {
+ if (i17 >>> 0 > 2147483645) {
+ i9 = 131;
+ break L141;
+ }
+ i18 = i17 << 1;
+ i19 = HEAP32[i7 >> 2] | 0;
+ if ((i18 | 0) == -2) {
+ i9 = 133;
+ break L141;
+ }
+ i27 = _luaM_realloc_(i19, HEAP32[i15 >> 2] | 0, i17, i18) | 0;
+ HEAP32[i15 >> 2] = i27;
+ HEAP32[i16 >> 2] = i18;
+ i18 = HEAP32[i14 >> 2] | 0;
+ i15 = i27;
+ } else {
+ i15 = HEAP32[i15 >> 2] | 0;
+ }
+ HEAP32[i14 >> 2] = i18 + 1;
+ HEAP8[i15 + i18 | 0] = i8;
+ i14 = HEAP32[i2 >> 2] | 0;
+ } else if ((i14 | 0) == -1) {
+ i9 = 82;
+ break L141;
+ } else if ((i14 | 0) == 13 | (i14 | 0) == 10) {
+ i9 = 83;
+ break L141;
+ } else {
+ i15 = HEAP32[i4 >> 2] | 0;
+ i8 = i15 + 4 | 0;
+ i18 = HEAP32[i8 >> 2] | 0;
+ i17 = i15 + 8 | 0;
+ i16 = HEAP32[i17 >> 2] | 0;
+ if ((i18 + 1 | 0) >>> 0 > i16 >>> 0) {
+ if (i16 >>> 0 > 2147483645) {
+ i9 = 139;
+ break L141;
+ }
+ i19 = i16 << 1;
+ i18 = HEAP32[i7 >> 2] | 0;
+ if ((i19 | 0) == -2) {
+ i9 = 141;
+ break L141;
+ }
+ i27 = _luaM_realloc_(i18, HEAP32[i15 >> 2] | 0, i16, i19) | 0;
+ HEAP32[i15 >> 2] = i27;
+ HEAP32[i17 >> 2] = i19;
+ i18 = HEAP32[i8 >> 2] | 0;
+ i15 = i27;
+ } else {
+ i15 = HEAP32[i15 >> 2] | 0;
+ }
+ HEAP32[i8 >> 2] = i18 + 1;
+ HEAP8[i15 + i18 | 0] = i14;
+ i8 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i14 = _luaZ_fill(i8) | 0;
+ } else {
+ i27 = i8 + 4 | 0;
+ i14 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i14 + 1;
+ i14 = HEAPU8[i14] | 0;
+ }
+ HEAP32[i2 >> 2] = i14;
+ }
+ } while (0);
+ if ((i14 | 0) == (i13 | 0)) {
+ break L139;
+ }
+ }
+ if ((i9 | 0) == 82) {
+ _lexerror(i2, 12400, 286);
+ } else if ((i9 | 0) == 83) {
+ _lexerror(i2, 12400, 289);
+ } else if ((i9 | 0) == 100) {
+ _escerror(i2, i12, i14 + 1 | 0, 12480);
+ } else if ((i9 | 0) == 116) {
+ _escerror(i2, i2, 1, 12424);
+ } else if ((i9 | 0) == 123) {
+ _escerror(i2, i12, i14, 12448);
+ } else if ((i9 | 0) == 131) {
+ _lexerror(i2, 12368, 0);
+ } else if ((i9 | 0) == 133) {
+ _luaM_toobig(i19);
+ } else if ((i9 | 0) == 139) {
+ _lexerror(i2, 12368, 0);
+ } else if ((i9 | 0) == 141) {
+ _luaM_toobig(i18);
+ }
+ }
+ } while (0);
+ i7 = HEAP32[i4 >> 2] | 0;
+ i8 = i7 + 4 | 0;
+ i13 = HEAP32[i8 >> 2] | 0;
+ i12 = i7 + 8 | 0;
+ i9 = HEAP32[i12 >> 2] | 0;
+ do {
+ if ((i13 + 1 | 0) >>> 0 > i9 >>> 0) {
+ if (i9 >>> 0 > 2147483645) {
+ _lexerror(i2, 12368, 0);
+ }
+ i14 = i9 << 1;
+ i13 = HEAP32[i2 + 52 >> 2] | 0;
+ if ((i14 | 0) == -2) {
+ _luaM_toobig(i13);
+ } else {
+ i11 = _luaM_realloc_(i13, HEAP32[i7 >> 2] | 0, i9, i14) | 0;
+ HEAP32[i7 >> 2] = i11;
+ HEAP32[i12 >> 2] = i14;
+ i10 = HEAP32[i8 >> 2] | 0;
+ break;
+ }
+ } else {
+ i10 = i13;
+ i11 = HEAP32[i7 >> 2] | 0;
+ }
+ } while (0);
+ HEAP32[i8 >> 2] = i10 + 1;
+ HEAP8[i11 + i10 | 0] = i6;
+ i5 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i5 = _luaZ_fill(i5) | 0;
+ } else {
+ i27 = i5 + 4 | 0;
+ i5 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i5 + 1;
+ i5 = HEAPU8[i5] | 0;
+ }
+ HEAP32[i2 >> 2] = i5;
+ i5 = HEAP32[i4 >> 2] | 0;
+ i4 = HEAP32[i2 + 52 >> 2] | 0;
+ i5 = _luaS_newlstr(i4, (HEAP32[i5 >> 2] | 0) + 1 | 0, (HEAP32[i5 + 4 >> 2] | 0) + -2 | 0) | 0;
+ i6 = i4 + 8 | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i7 + 16;
+ HEAP32[i7 >> 2] = i5;
+ HEAP32[i7 + 8 >> 2] = HEAPU8[i5 + 4 | 0] | 64;
+ i7 = _luaH_set(i4, HEAP32[(HEAP32[i2 + 48 >> 2] | 0) + 4 >> 2] | 0, (HEAP32[i6 >> 2] | 0) + -16 | 0) | 0;
+ i2 = i7 + 8 | 0;
+ if ((HEAP32[i2 >> 2] | 0) == 0 ? (HEAP32[i7 >> 2] = 1, HEAP32[i2 >> 2] = 1, (HEAP32[(HEAP32[i4 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) : 0) {
+ _luaC_step(i4);
+ }
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + -16;
+ HEAP32[i3 >> 2] = i5;
+ i27 = 289;
+ STACKTOP = i1;
+ return i27 | 0;
+ } else if ((i9 | 0) == 161) {
+ i10 = HEAP32[i4 >> 2] | 0;
+ i9 = i10 + 4 | 0;
+ i13 = HEAP32[i9 >> 2] | 0;
+ i12 = i10 + 8 | 0;
+ i11 = HEAP32[i12 >> 2] | 0;
+ do {
+ if ((i13 + 1 | 0) >>> 0 > i11 >>> 0) {
+ if (i11 >>> 0 > 2147483645) {
+ _lexerror(i2, 12368, 0);
+ }
+ i13 = i11 << 1;
+ i20 = HEAP32[i2 + 52 >> 2] | 0;
+ if ((i13 | 0) == -2) {
+ _luaM_toobig(i20);
+ } else {
+ i25 = _luaM_realloc_(i20, HEAP32[i10 >> 2] | 0, i11, i13) | 0;
+ HEAP32[i10 >> 2] = i25;
+ HEAP32[i12 >> 2] = i13;
+ i26 = HEAP32[i9 >> 2] | 0;
+ break;
+ }
+ } else {
+ i26 = i13;
+ i25 = HEAP32[i10 >> 2] | 0;
+ }
+ } while (0);
+ HEAP32[i9 >> 2] = i26 + 1;
+ HEAP8[i25 + i26 | 0] = 46;
+ i9 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i20 = _luaZ_fill(i9) | 0;
+ } else {
+ i27 = i9 + 4 | 0;
+ i20 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i20 + 1;
+ i20 = HEAPU8[i20] | 0;
+ }
+ HEAP32[i2 >> 2] = i20;
+ if ((i20 | 0) != 0 ? (_memchr(12304, i20, 2) | 0) != 0 : 0) {
+ i6 = HEAP32[i4 >> 2] | 0;
+ i3 = i6 + 4 | 0;
+ i9 = HEAP32[i3 >> 2] | 0;
+ i8 = i6 + 8 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ do {
+ if ((i9 + 1 | 0) >>> 0 > i7 >>> 0) {
+ if (i7 >>> 0 > 2147483645) {
+ _lexerror(i2, 12368, 0);
+ }
+ i9 = i7 << 1;
+ i10 = HEAP32[i2 + 52 >> 2] | 0;
+ if ((i9 | 0) == -2) {
+ _luaM_toobig(i10);
+ } else {
+ i21 = _luaM_realloc_(i10, HEAP32[i6 >> 2] | 0, i7, i9) | 0;
+ HEAP32[i6 >> 2] = i21;
+ HEAP32[i8 >> 2] = i9;
+ i22 = HEAP32[i3 >> 2] | 0;
+ break;
+ }
+ } else {
+ i22 = i9;
+ i21 = HEAP32[i6 >> 2] | 0;
+ }
+ } while (0);
+ HEAP32[i3 >> 2] = i22 + 1;
+ HEAP8[i21 + i22 | 0] = i20;
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ if ((i3 | 0) == 0) {
+ i27 = 279;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ if ((_memchr(12304, i3, 2) | 0) == 0) {
+ i27 = 279;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ i6 = HEAP32[i4 >> 2] | 0;
+ i7 = i6 + 4 | 0;
+ i9 = HEAP32[i7 >> 2] | 0;
+ i8 = i6 + 8 | 0;
+ i4 = HEAP32[i8 >> 2] | 0;
+ do {
+ if ((i9 + 1 | 0) >>> 0 > i4 >>> 0) {
+ if (i4 >>> 0 > 2147483645) {
+ _lexerror(i2, 12368, 0);
+ }
+ i10 = i4 << 1;
+ i9 = HEAP32[i2 + 52 >> 2] | 0;
+ if ((i10 | 0) == -2) {
+ _luaM_toobig(i9);
+ } else {
+ i18 = _luaM_realloc_(i9, HEAP32[i6 >> 2] | 0, i4, i10) | 0;
+ HEAP32[i6 >> 2] = i18;
+ HEAP32[i8 >> 2] = i10;
+ i19 = HEAP32[i7 >> 2] | 0;
+ break;
+ }
+ } else {
+ i19 = i9;
+ i18 = HEAP32[i6 >> 2] | 0;
+ }
+ } while (0);
+ HEAP32[i7 >> 2] = i19 + 1;
+ HEAP8[i18 + i19 | 0] = i3;
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ i27 = 280;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ if ((HEAP8[i20 + 10913 | 0] & 2) == 0) {
+ i27 = 46;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ } else if ((i9 | 0) == 283) {
+ if ((HEAP8[i13 + 10913 | 0] & 1) == 0) {
+ i3 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i27 = i3 + 4 | 0;
+ i3 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ i27 = i13;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ i10 = i2 + 52 | 0;
+ while (1) {
+ i11 = HEAP32[i4 >> 2] | 0;
+ i9 = i11 + 4 | 0;
+ i12 = HEAP32[i9 >> 2] | 0;
+ i19 = i11 + 8 | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i12 + 1 | 0) >>> 0 > i18 >>> 0) {
+ if (i18 >>> 0 > 2147483645) {
+ i9 = 288;
+ break;
+ }
+ i21 = i18 << 1;
+ i12 = HEAP32[i10 >> 2] | 0;
+ if ((i21 | 0) == -2) {
+ i9 = 290;
+ break;
+ }
+ i27 = _luaM_realloc_(i12, HEAP32[i11 >> 2] | 0, i18, i21) | 0;
+ HEAP32[i11 >> 2] = i27;
+ HEAP32[i19 >> 2] = i21;
+ i12 = HEAP32[i9 >> 2] | 0;
+ i11 = i27;
+ } else {
+ i11 = HEAP32[i11 >> 2] | 0;
+ }
+ HEAP32[i9 >> 2] = i12 + 1;
+ HEAP8[i11 + i12 | 0] = i13;
+ i9 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i13 = _luaZ_fill(i9) | 0;
+ } else {
+ i27 = i9 + 4 | 0;
+ i13 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i13 + 1;
+ i13 = HEAPU8[i13] | 0;
+ }
+ HEAP32[i2 >> 2] = i13;
+ if ((HEAP8[i13 + 10913 | 0] & 3) == 0) {
+ i9 = 296;
+ break;
+ }
+ }
+ if ((i9 | 0) == 288) {
+ _lexerror(i2, 12368, 0);
+ } else if ((i9 | 0) == 290) {
+ _luaM_toobig(i12);
+ } else if ((i9 | 0) == 296) {
+ i6 = HEAP32[i4 >> 2] | 0;
+ i4 = HEAP32[i10 >> 2] | 0;
+ i6 = _luaS_newlstr(i4, HEAP32[i6 >> 2] | 0, HEAP32[i6 + 4 >> 2] | 0) | 0;
+ i7 = i4 + 8 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i8 + 16;
+ HEAP32[i8 >> 2] = i6;
+ i5 = i6 + 4 | 0;
+ HEAP32[i8 + 8 >> 2] = HEAPU8[i5] | 64;
+ i8 = _luaH_set(i4, HEAP32[(HEAP32[i2 + 48 >> 2] | 0) + 4 >> 2] | 0, (HEAP32[i7 >> 2] | 0) + -16 | 0) | 0;
+ i2 = i8 + 8 | 0;
+ if ((HEAP32[i2 >> 2] | 0) == 0 ? (HEAP32[i8 >> 2] = 1, HEAP32[i2 >> 2] = 1, (HEAP32[(HEAP32[i4 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) : 0) {
+ _luaC_step(i4);
+ }
+ HEAP32[i7 >> 2] = (HEAP32[i7 >> 2] | 0) + -16;
+ HEAP32[i3 >> 2] = i6;
+ if ((HEAP8[i5] | 0) != 4) {
+ i27 = 288;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ i2 = HEAP8[i6 + 6 | 0] | 0;
+ if (i2 << 24 >> 24 == 0) {
+ i27 = 288;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ i27 = i2 & 255 | 256;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ } else if ((i9 | 0) == 306) {
+ STACKTOP = i1;
+ return i2 | 0;
+ }
+ i9 = HEAP32[i4 >> 2] | 0;
+ i12 = i9 + 4 | 0;
+ i13 = HEAP32[i12 >> 2] | 0;
+ i11 = i9 + 8 | 0;
+ i10 = HEAP32[i11 >> 2] | 0;
+ do {
+ if ((i13 + 1 | 0) >>> 0 > i10 >>> 0) {
+ if (i10 >>> 0 > 2147483645) {
+ _lexerror(i2, 12368, 0);
+ }
+ i18 = i10 << 1;
+ i13 = HEAP32[i2 + 52 >> 2] | 0;
+ if ((i18 | 0) == -2) {
+ _luaM_toobig(i13);
+ } else {
+ i16 = _luaM_realloc_(i13, HEAP32[i9 >> 2] | 0, i10, i18) | 0;
+ HEAP32[i9 >> 2] = i16;
+ HEAP32[i11 >> 2] = i18;
+ i17 = HEAP32[i12 >> 2] | 0;
+ break;
+ }
+ } else {
+ i17 = i13;
+ i16 = HEAP32[i9 >> 2] | 0;
+ }
+ } while (0);
+ HEAP32[i12 >> 2] = i17 + 1;
+ HEAP8[i16 + i17 | 0] = i20;
+ i9 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i9 = _luaZ_fill(i9) | 0;
+ } else {
+ i27 = i9 + 4 | 0;
+ i9 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i9 + 1;
+ i9 = HEAPU8[i9] | 0;
+ }
+ HEAP32[i2 >> 2] = i9;
+ if ((i20 | 0) == 48) {
+ if ((i9 | 0) != 0) {
+ if ((_memchr(12320, i9, 3) | 0) == 0) {
+ i15 = i9;
+ i9 = 12312;
+ } else {
+ i10 = HEAP32[i4 >> 2] | 0;
+ i13 = i10 + 4 | 0;
+ i16 = HEAP32[i13 >> 2] | 0;
+ i11 = i10 + 8 | 0;
+ i12 = HEAP32[i11 >> 2] | 0;
+ do {
+ if ((i16 + 1 | 0) >>> 0 > i12 >>> 0) {
+ if (i12 >>> 0 > 2147483645) {
+ _lexerror(i2, 12368, 0);
+ }
+ i17 = i12 << 1;
+ i16 = HEAP32[i2 + 52 >> 2] | 0;
+ if ((i17 | 0) == -2) {
+ _luaM_toobig(i16);
+ } else {
+ i15 = _luaM_realloc_(i16, HEAP32[i10 >> 2] | 0, i12, i17) | 0;
+ HEAP32[i10 >> 2] = i15;
+ HEAP32[i11 >> 2] = i17;
+ i14 = HEAP32[i13 >> 2] | 0;
+ break;
+ }
+ } else {
+ i14 = i16;
+ i15 = HEAP32[i10 >> 2] | 0;
+ }
+ } while (0);
+ HEAP32[i13 >> 2] = i14 + 1;
+ HEAP8[i15 + i14 | 0] = i9;
+ i9 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i15 = _luaZ_fill(i9) | 0;
+ } else {
+ i27 = i9 + 4 | 0;
+ i15 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i15 + 1;
+ i15 = HEAPU8[i15] | 0;
+ }
+ HEAP32[i2 >> 2] = i15;
+ i9 = 12328;
+ }
+ } else {
+ i15 = 0;
+ i9 = 12312;
+ }
+ } else {
+ i15 = i9;
+ i9 = 12312;
+ }
+ i10 = i2 + 52 | 0;
+ while (1) {
+ if ((i15 | 0) != 0) {
+ if ((_memchr(i9, i15, 3) | 0) != 0) {
+ i12 = HEAP32[i4 >> 2] | 0;
+ i11 = i12 + 4 | 0;
+ i16 = HEAP32[i11 >> 2] | 0;
+ i14 = i12 + 8 | 0;
+ i13 = HEAP32[i14 >> 2] | 0;
+ if ((i16 + 1 | 0) >>> 0 > i13 >>> 0) {
+ if (i13 >>> 0 > 2147483645) {
+ i9 = 227;
+ break;
+ }
+ i17 = i13 << 1;
+ i16 = HEAP32[i10 >> 2] | 0;
+ if ((i17 | 0) == -2) {
+ i9 = 229;
+ break;
+ }
+ i27 = _luaM_realloc_(i16, HEAP32[i12 >> 2] | 0, i13, i17) | 0;
+ HEAP32[i12 >> 2] = i27;
+ HEAP32[i14 >> 2] = i17;
+ i16 = HEAP32[i11 >> 2] | 0;
+ i12 = i27;
+ } else {
+ i12 = HEAP32[i12 >> 2] | 0;
+ }
+ HEAP32[i11 >> 2] = i16 + 1;
+ HEAP8[i12 + i16 | 0] = i15;
+ i11 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i11 >> 2] | 0;
+ HEAP32[i11 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i15 = _luaZ_fill(i11) | 0;
+ } else {
+ i27 = i11 + 4 | 0;
+ i15 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i15 + 1;
+ i15 = HEAPU8[i15] | 0;
+ }
+ HEAP32[i2 >> 2] = i15;
+ if ((i15 | 0) != 0) {
+ if ((_memchr(12336, i15, 3) | 0) != 0) {
+ i12 = HEAP32[i4 >> 2] | 0;
+ i11 = i12 + 4 | 0;
+ i16 = HEAP32[i11 >> 2] | 0;
+ i14 = i12 + 8 | 0;
+ i13 = HEAP32[i14 >> 2] | 0;
+ if ((i16 + 1 | 0) >>> 0 > i13 >>> 0) {
+ if (i13 >>> 0 > 2147483645) {
+ i9 = 239;
+ break;
+ }
+ i17 = i13 << 1;
+ i16 = HEAP32[i10 >> 2] | 0;
+ if ((i17 | 0) == -2) {
+ i9 = 241;
+ break;
+ }
+ i27 = _luaM_realloc_(i16, HEAP32[i12 >> 2] | 0, i13, i17) | 0;
+ HEAP32[i12 >> 2] = i27;
+ HEAP32[i14 >> 2] = i17;
+ i16 = HEAP32[i11 >> 2] | 0;
+ i12 = i27;
+ } else {
+ i12 = HEAP32[i12 >> 2] | 0;
+ }
+ HEAP32[i11 >> 2] = i16 + 1;
+ HEAP8[i12 + i16 | 0] = i15;
+ i11 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i11 >> 2] | 0;
+ HEAP32[i11 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i15 = _luaZ_fill(i11) | 0;
+ } else {
+ i27 = i11 + 4 | 0;
+ i15 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i15 + 1;
+ i15 = HEAPU8[i15] | 0;
+ }
+ HEAP32[i2 >> 2] = i15;
+ }
+ } else {
+ i15 = 0;
+ }
+ }
+ } else {
+ i15 = 0;
+ }
+ i12 = HEAP32[i4 >> 2] | 0;
+ i11 = i12 + 4 | 0;
+ i17 = HEAP32[i11 >> 2] | 0;
+ i14 = i12 + 8 | 0;
+ i13 = HEAP32[i14 >> 2] | 0;
+ i16 = (i17 + 1 | 0) >>> 0 > i13 >>> 0;
+ if (!((HEAP8[i15 + 10913 | 0] & 16) != 0 | (i15 | 0) == 46)) {
+ i9 = 259;
+ break;
+ }
+ if (i16) {
+ if (i13 >>> 0 > 2147483645) {
+ i9 = 251;
+ break;
+ }
+ i17 = i13 << 1;
+ i16 = HEAP32[i10 >> 2] | 0;
+ if ((i17 | 0) == -2) {
+ i9 = 253;
+ break;
+ }
+ i27 = _luaM_realloc_(i16, HEAP32[i12 >> 2] | 0, i13, i17) | 0;
+ HEAP32[i12 >> 2] = i27;
+ HEAP32[i14 >> 2] = i17;
+ i17 = HEAP32[i11 >> 2] | 0;
+ i12 = i27;
+ } else {
+ i12 = HEAP32[i12 >> 2] | 0;
+ }
+ HEAP32[i11 >> 2] = i17 + 1;
+ HEAP8[i12 + i17 | 0] = i15;
+ i11 = HEAP32[i5 >> 2] | 0;
+ i27 = HEAP32[i11 >> 2] | 0;
+ HEAP32[i11 >> 2] = i27 + -1;
+ if ((i27 | 0) == 0) {
+ i15 = _luaZ_fill(i11) | 0;
+ } else {
+ i27 = i11 + 4 | 0;
+ i15 = HEAP32[i27 >> 2] | 0;
+ HEAP32[i27 >> 2] = i15 + 1;
+ i15 = HEAPU8[i15] | 0;
+ }
+ HEAP32[i2 >> 2] = i15;
+ }
+ if ((i9 | 0) == 227) {
+ _lexerror(i2, 12368, 0);
+ } else if ((i9 | 0) == 229) {
+ _luaM_toobig(i16);
+ } else if ((i9 | 0) == 239) {
+ _lexerror(i2, 12368, 0);
+ } else if ((i9 | 0) == 241) {
+ _luaM_toobig(i16);
+ } else if ((i9 | 0) == 251) {
+ _lexerror(i2, 12368, 0);
+ } else if ((i9 | 0) == 253) {
+ _luaM_toobig(i16);
+ } else if ((i9 | 0) == 259) {
+ do {
+ if (i16) {
+ if (i13 >>> 0 > 2147483645) {
+ _lexerror(i2, 12368, 0);
+ }
+ i5 = i13 << 1;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i5 | 0) == -2) {
+ _luaM_toobig(i9);
+ } else {
+ i7 = _luaM_realloc_(i9, HEAP32[i12 >> 2] | 0, i13, i5) | 0;
+ HEAP32[i12 >> 2] = i7;
+ HEAP32[i14 >> 2] = i5;
+ i8 = HEAP32[i11 >> 2] | 0;
+ break;
+ }
+ } else {
+ i8 = i17;
+ i7 = HEAP32[i12 >> 2] | 0;
+ }
+ } while (0);
+ HEAP32[i11 >> 2] = i8 + 1;
+ HEAP8[i7 + i8 | 0] = 0;
+ i5 = i2 + 76 | 0;
+ i7 = HEAP8[i5] | 0;
+ i10 = HEAP32[i4 >> 2] | 0;
+ i8 = HEAP32[i10 >> 2] | 0;
+ i10 = HEAP32[i10 + 4 >> 2] | 0;
+ if ((i10 | 0) == 0) {
+ i7 = -1;
+ } else {
+ do {
+ i10 = i10 + -1 | 0;
+ i9 = i8 + i10 | 0;
+ if ((HEAP8[i9] | 0) == 46) {
+ HEAP8[i9] = i7;
+ }
+ } while ((i10 | 0) != 0);
+ i7 = HEAP32[i4 >> 2] | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ i7 = (HEAP32[i7 + 4 >> 2] | 0) + -1 | 0;
+ }
+ if ((_luaO_str2d(i8, i7, i3) | 0) != 0) {
+ i27 = 287;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ i9 = HEAP8[i5] | 0;
+ i8 = HEAP8[HEAP32[(_localeconv() | 0) >> 2] | 0] | 0;
+ HEAP8[i5] = i8;
+ i10 = HEAP32[i4 >> 2] | 0;
+ i7 = HEAP32[i10 >> 2] | 0;
+ i10 = HEAP32[i10 + 4 >> 2] | 0;
+ if ((i10 | 0) == 0) {
+ i8 = -1;
+ } else {
+ do {
+ i10 = i10 + -1 | 0;
+ i11 = i7 + i10 | 0;
+ if ((HEAP8[i11] | 0) == i9 << 24 >> 24) {
+ HEAP8[i11] = i8;
+ }
+ } while ((i10 | 0) != 0);
+ i8 = HEAP32[i4 >> 2] | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ i8 = (HEAP32[i8 + 4 >> 2] | 0) + -1 | 0;
+ }
+ if ((_luaO_str2d(i7, i8, i3) | 0) != 0) {
+ i27 = 287;
+ STACKTOP = i1;
+ return i27 | 0;
+ }
+ i1 = HEAP8[i5] | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i4 = HEAP32[i4 + 4 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ _lexerror(i2, 12344, 287);
+ } else {
+ i6 = i4;
+ }
+ do {
+ i6 = i6 + -1 | 0;
+ i4 = i3 + i6 | 0;
+ if ((HEAP8[i4] | 0) == i1 << 24 >> 24) {
+ HEAP8[i4] = 46;
+ }
+ } while ((i6 | 0) != 0);
+ _lexerror(i2, 12344, 287);
+ }
+ return 0;
+}
+function _luaV_execute(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0, d37 = 0.0, d38 = 0.0, d39 = 0.0;
+ i12 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i13 = i12 + 24 | 0;
+ i10 = i12 + 16 | 0;
+ i9 = i12 + 8 | 0;
+ i8 = i12;
+ i3 = i1 + 16 | 0;
+ i4 = i1 + 40 | 0;
+ i6 = i1 + 12 | 0;
+ i5 = i1 + 8 | 0;
+ i11 = i1 + 24 | 0;
+ i17 = i1 + 48 | 0;
+ i2 = i1 + 20 | 0;
+ i16 = i1 + 6 | 0;
+ i7 = i1 + 44 | 0;
+ i19 = HEAP32[i3 >> 2] | 0;
+ L1 : while (1) {
+ i22 = HEAP32[HEAP32[i19 >> 2] >> 2] | 0;
+ i18 = i22 + 12 | 0;
+ i23 = HEAP32[(HEAP32[i18 >> 2] | 0) + 8 >> 2] | 0;
+ i20 = i19 + 24 | 0;
+ i21 = i19 + 28 | 0;
+ i22 = i22 + 16 | 0;
+ i24 = i19 + 4 | 0;
+ i25 = HEAP32[i20 >> 2] | 0;
+ L3 : while (1) {
+ i28 = HEAP32[i21 >> 2] | 0;
+ HEAP32[i21 >> 2] = i28 + 4;
+ i28 = HEAP32[i28 >> 2] | 0;
+ i27 = HEAP8[i4] | 0;
+ do {
+ if (!((i27 & 12) == 0)) {
+ i26 = (HEAP32[i17 >> 2] | 0) + -1 | 0;
+ HEAP32[i17 >> 2] = i26;
+ i26 = (i26 | 0) == 0;
+ if (!i26 ? (i27 & 4) == 0 : 0) {
+ break;
+ }
+ i25 = HEAP32[i3 >> 2] | 0;
+ i29 = i27 & 255;
+ if ((i29 & 8 | 0) == 0 | i26 ^ 1) {
+ i27 = 0;
+ } else {
+ HEAP32[i17 >> 2] = HEAP32[i7 >> 2];
+ i27 = 1;
+ }
+ i26 = i25 + 18 | 0;
+ i30 = HEAPU8[i26] | 0;
+ if ((i30 & 128 | 0) == 0) {
+ if (i27) {
+ _luaD_hook(i1, 3, -1);
+ }
+ do {
+ if ((i29 & 4 | 0) == 0) {
+ i29 = i25 + 28 | 0;
+ } else {
+ i34 = HEAP32[(HEAP32[HEAP32[i25 >> 2] >> 2] | 0) + 12 >> 2] | 0;
+ i29 = i25 + 28 | 0;
+ i32 = HEAP32[i29 >> 2] | 0;
+ i35 = HEAP32[i34 + 12 >> 2] | 0;
+ i33 = (i32 - i35 >> 2) + -1 | 0;
+ i34 = HEAP32[i34 + 20 >> 2] | 0;
+ i31 = (i34 | 0) == 0;
+ if (i31) {
+ i30 = 0;
+ } else {
+ i30 = HEAP32[i34 + (i33 << 2) >> 2] | 0;
+ }
+ if ((i33 | 0) != 0 ? (i14 = HEAP32[i2 >> 2] | 0, i32 >>> 0 > i14 >>> 0) : 0) {
+ if (i31) {
+ i31 = 0;
+ } else {
+ i31 = HEAP32[i34 + ((i14 - i35 >> 2) + -1 << 2) >> 2] | 0;
+ }
+ if ((i30 | 0) == (i31 | 0)) {
+ break;
+ }
+ }
+ _luaD_hook(i1, 2, i30);
+ }
+ } while (0);
+ HEAP32[i2 >> 2] = HEAP32[i29 >> 2];
+ if ((HEAP8[i16] | 0) == 1) {
+ i15 = 23;
+ break L1;
+ }
+ } else {
+ HEAP8[i26] = i30 & 127;
+ }
+ i25 = HEAP32[i20 >> 2] | 0;
+ }
+ } while (0);
+ i26 = i28 >>> 6 & 255;
+ i27 = i25 + (i26 << 4) | 0;
+ switch (i28 & 63 | 0) {
+ case 9:
+ {
+ i28 = HEAP32[i22 + (i28 >>> 23 << 2) >> 2] | 0;
+ i35 = HEAP32[i28 + 8 >> 2] | 0;
+ i33 = i27;
+ i34 = HEAP32[i33 + 4 >> 2] | 0;
+ i36 = i35;
+ HEAP32[i36 >> 2] = HEAP32[i33 >> 2];
+ HEAP32[i36 + 4 >> 2] = i34;
+ i36 = i25 + (i26 << 4) + 8 | 0;
+ HEAP32[i35 + 8 >> 2] = HEAP32[i36 >> 2];
+ if ((HEAP32[i36 >> 2] & 64 | 0) == 0) {
+ continue L3;
+ }
+ i26 = HEAP32[i27 >> 2] | 0;
+ if ((HEAP8[i26 + 5 | 0] & 3) == 0) {
+ continue L3;
+ }
+ if ((HEAP8[i28 + 5 | 0] & 4) == 0) {
+ continue L3;
+ }
+ _luaC_barrier_(i1, i28, i26);
+ continue L3;
+ }
+ case 10:
+ {
+ i26 = i28 >>> 23;
+ if ((i26 & 256 | 0) == 0) {
+ i26 = i25 + (i26 << 4) | 0;
+ } else {
+ i26 = i23 + ((i26 & 255) << 4) | 0;
+ }
+ i28 = i28 >>> 14;
+ if ((i28 & 256 | 0) == 0) {
+ i25 = i25 + ((i28 & 511) << 4) | 0;
+ } else {
+ i25 = i23 + ((i28 & 255) << 4) | 0;
+ }
+ _luaV_settable(i1, i27, i26, i25);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 17:
+ {
+ i29 = i28 >>> 23;
+ if ((i29 & 256 | 0) == 0) {
+ i29 = i25 + (i29 << 4) | 0;
+ } else {
+ i29 = i23 + ((i29 & 255) << 4) | 0;
+ }
+ i28 = i28 >>> 14;
+ if ((i28 & 256 | 0) == 0) {
+ i28 = i25 + ((i28 & 511) << 4) | 0;
+ } else {
+ i28 = i23 + ((i28 & 255) << 4) | 0;
+ }
+ if ((HEAP32[i29 + 8 >> 2] | 0) == 3 ? (HEAP32[i28 + 8 >> 2] | 0) == 3 : 0) {
+ d37 = +HEAPF64[i29 >> 3];
+ d38 = +HEAPF64[i28 >> 3];
+ HEAPF64[i27 >> 3] = d37 - d38 * +Math_floor(+(d37 / d38));
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 3;
+ continue L3;
+ }
+ _luaV_arith(i1, i27, i29, i28, 10);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 23:
+ {
+ if ((i26 | 0) != 0) {
+ _luaF_close(i1, (HEAP32[i20 >> 2] | 0) + (i26 + -1 << 4) | 0);
+ }
+ HEAP32[i21 >> 2] = (HEAP32[i21 >> 2] | 0) + ((i28 >>> 14) + -131071 << 2);
+ continue L3;
+ }
+ case 24:
+ {
+ i27 = i28 >>> 23;
+ if ((i27 & 256 | 0) == 0) {
+ i27 = i25 + (i27 << 4) | 0;
+ } else {
+ i27 = i23 + ((i27 & 255) << 4) | 0;
+ }
+ i28 = i28 >>> 14;
+ if ((i28 & 256 | 0) == 0) {
+ i25 = i25 + ((i28 & 511) << 4) | 0;
+ } else {
+ i25 = i23 + ((i28 & 255) << 4) | 0;
+ }
+ if ((HEAP32[i27 + 8 >> 2] | 0) == (HEAP32[i25 + 8 >> 2] | 0)) {
+ i27 = (_luaV_equalobj_(i1, i27, i25) | 0) != 0;
+ } else {
+ i27 = 0;
+ }
+ i25 = HEAP32[i21 >> 2] | 0;
+ if ((i27 & 1 | 0) == (i26 | 0)) {
+ i26 = HEAP32[i25 >> 2] | 0;
+ i27 = i26 >>> 6 & 255;
+ if ((i27 | 0) != 0) {
+ _luaF_close(i1, (HEAP32[i20 >> 2] | 0) + (i27 + -1 << 4) | 0);
+ i25 = HEAP32[i21 >> 2] | 0;
+ }
+ i25 = i25 + ((i26 >>> 14) + -131070 << 2) | 0;
+ } else {
+ i25 = i25 + 4 | 0;
+ }
+ HEAP32[i21 >> 2] = i25;
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 18:
+ {
+ i29 = i28 >>> 23;
+ if ((i29 & 256 | 0) == 0) {
+ i29 = i25 + (i29 << 4) | 0;
+ } else {
+ i29 = i23 + ((i29 & 255) << 4) | 0;
+ }
+ i28 = i28 >>> 14;
+ if ((i28 & 256 | 0) == 0) {
+ i28 = i25 + ((i28 & 511) << 4) | 0;
+ } else {
+ i28 = i23 + ((i28 & 255) << 4) | 0;
+ }
+ if ((HEAP32[i29 + 8 >> 2] | 0) == 3 ? (HEAP32[i28 + 8 >> 2] | 0) == 3 : 0) {
+ HEAPF64[i27 >> 3] = +Math_pow(+(+HEAPF64[i29 >> 3]), +(+HEAPF64[i28 >> 3]));
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 3;
+ continue L3;
+ }
+ _luaV_arith(i1, i27, i29, i28, 11);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 1:
+ {
+ i36 = i28 >>> 14;
+ i33 = i23 + (i36 << 4) | 0;
+ i34 = HEAP32[i33 + 4 >> 2] | 0;
+ i35 = i27;
+ HEAP32[i35 >> 2] = HEAP32[i33 >> 2];
+ HEAP32[i35 + 4 >> 2] = i34;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = HEAP32[i23 + (i36 << 4) + 8 >> 2];
+ continue L3;
+ }
+ case 0:
+ {
+ i36 = i28 >>> 23;
+ i33 = i25 + (i36 << 4) | 0;
+ i34 = HEAP32[i33 + 4 >> 2] | 0;
+ i35 = i27;
+ HEAP32[i35 >> 2] = HEAP32[i33 >> 2];
+ HEAP32[i35 + 4 >> 2] = i34;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = HEAP32[i25 + (i36 << 4) + 8 >> 2];
+ continue L3;
+ }
+ case 2:
+ {
+ i36 = HEAP32[i21 >> 2] | 0;
+ HEAP32[i21 >> 2] = i36 + 4;
+ i36 = (HEAP32[i36 >> 2] | 0) >>> 6;
+ i33 = i23 + (i36 << 4) | 0;
+ i34 = HEAP32[i33 + 4 >> 2] | 0;
+ i35 = i27;
+ HEAP32[i35 >> 2] = HEAP32[i33 >> 2];
+ HEAP32[i35 + 4 >> 2] = i34;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = HEAP32[i23 + (i36 << 4) + 8 >> 2];
+ continue L3;
+ }
+ case 5:
+ {
+ i36 = HEAP32[(HEAP32[i22 + (i28 >>> 23 << 2) >> 2] | 0) + 8 >> 2] | 0;
+ i33 = i36;
+ i34 = HEAP32[i33 + 4 >> 2] | 0;
+ i35 = i27;
+ HEAP32[i35 >> 2] = HEAP32[i33 >> 2];
+ HEAP32[i35 + 4 >> 2] = i34;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = HEAP32[i36 + 8 >> 2];
+ continue L3;
+ }
+ case 3:
+ {
+ HEAP32[i27 >> 2] = i28 >>> 23;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 1;
+ if ((i28 & 8372224 | 0) == 0) {
+ continue L3;
+ }
+ HEAP32[i21 >> 2] = (HEAP32[i21 >> 2] | 0) + 4;
+ continue L3;
+ }
+ case 7:
+ {
+ i26 = i28 >>> 14;
+ if ((i26 & 256 | 0) == 0) {
+ i26 = i25 + ((i26 & 511) << 4) | 0;
+ } else {
+ i26 = i23 + ((i26 & 255) << 4) | 0;
+ }
+ _luaV_gettable(i1, i25 + (i28 >>> 23 << 4) | 0, i26, i27);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 12:
+ {
+ i36 = i28 >>> 23;
+ i29 = i25 + (i36 << 4) | 0;
+ i26 = i26 + 1 | 0;
+ i33 = i29;
+ i34 = HEAP32[i33 + 4 >> 2] | 0;
+ i35 = i25 + (i26 << 4) | 0;
+ HEAP32[i35 >> 2] = HEAP32[i33 >> 2];
+ HEAP32[i35 + 4 >> 2] = i34;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = HEAP32[i25 + (i36 << 4) + 8 >> 2];
+ i26 = i28 >>> 14;
+ if ((i26 & 256 | 0) == 0) {
+ i25 = i25 + ((i26 & 511) << 4) | 0;
+ } else {
+ i25 = i23 + ((i26 & 255) << 4) | 0;
+ }
+ _luaV_gettable(i1, i29, i25, i27);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 13:
+ {
+ i29 = i28 >>> 23;
+ if ((i29 & 256 | 0) == 0) {
+ i29 = i25 + (i29 << 4) | 0;
+ } else {
+ i29 = i23 + ((i29 & 255) << 4) | 0;
+ }
+ i28 = i28 >>> 14;
+ if ((i28 & 256 | 0) == 0) {
+ i28 = i25 + ((i28 & 511) << 4) | 0;
+ } else {
+ i28 = i23 + ((i28 & 255) << 4) | 0;
+ }
+ if ((HEAP32[i29 + 8 >> 2] | 0) == 3 ? (HEAP32[i28 + 8 >> 2] | 0) == 3 : 0) {
+ HEAPF64[i27 >> 3] = +HEAPF64[i29 >> 3] + +HEAPF64[i28 >> 3];
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 3;
+ continue L3;
+ }
+ _luaV_arith(i1, i27, i29, i28, 6);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 14:
+ {
+ i29 = i28 >>> 23;
+ if ((i29 & 256 | 0) == 0) {
+ i29 = i25 + (i29 << 4) | 0;
+ } else {
+ i29 = i23 + ((i29 & 255) << 4) | 0;
+ }
+ i28 = i28 >>> 14;
+ if ((i28 & 256 | 0) == 0) {
+ i28 = i25 + ((i28 & 511) << 4) | 0;
+ } else {
+ i28 = i23 + ((i28 & 255) << 4) | 0;
+ }
+ if ((HEAP32[i29 + 8 >> 2] | 0) == 3 ? (HEAP32[i28 + 8 >> 2] | 0) == 3 : 0) {
+ HEAPF64[i27 >> 3] = +HEAPF64[i29 >> 3] - +HEAPF64[i28 >> 3];
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 3;
+ continue L3;
+ }
+ _luaV_arith(i1, i27, i29, i28, 7);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 6:
+ {
+ i26 = i28 >>> 14;
+ if ((i26 & 256 | 0) == 0) {
+ i25 = i25 + ((i26 & 511) << 4) | 0;
+ } else {
+ i25 = i23 + ((i26 & 255) << 4) | 0;
+ }
+ _luaV_gettable(i1, HEAP32[(HEAP32[i22 + (i28 >>> 23 << 2) >> 2] | 0) + 8 >> 2] | 0, i25, i27);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 4:
+ {
+ i26 = i28 >>> 23;
+ while (1) {
+ HEAP32[i27 + 8 >> 2] = 0;
+ if ((i26 | 0) == 0) {
+ continue L3;
+ } else {
+ i26 = i26 + -1 | 0;
+ i27 = i27 + 16 | 0;
+ }
+ }
+ }
+ case 8:
+ {
+ i27 = i28 >>> 23;
+ if ((i27 & 256 | 0) == 0) {
+ i27 = i25 + (i27 << 4) | 0;
+ } else {
+ i27 = i23 + ((i27 & 255) << 4) | 0;
+ }
+ i28 = i28 >>> 14;
+ if ((i28 & 256 | 0) == 0) {
+ i25 = i25 + ((i28 & 511) << 4) | 0;
+ } else {
+ i25 = i23 + ((i28 & 255) << 4) | 0;
+ }
+ _luaV_settable(i1, HEAP32[(HEAP32[i22 + (i26 << 2) >> 2] | 0) + 8 >> 2] | 0, i27, i25);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 11:
+ {
+ i29 = i28 >>> 23;
+ i28 = i28 >>> 14 & 511;
+ i30 = _luaH_new(i1) | 0;
+ HEAP32[i27 >> 2] = i30;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 69;
+ if ((i28 | i29 | 0) != 0) {
+ i36 = _luaO_fb2int(i29) | 0;
+ _luaH_resize(i1, i30, i36, _luaO_fb2int(i28) | 0);
+ }
+ if ((HEAP32[(HEAP32[i6 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ HEAP32[i5 >> 2] = i25 + (i26 + 1 << 4);
+ _luaC_step(i1);
+ HEAP32[i5 >> 2] = HEAP32[i24 >> 2];
+ }
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 19:
+ {
+ i36 = i28 >>> 23;
+ i28 = i25 + (i36 << 4) | 0;
+ if ((HEAP32[i25 + (i36 << 4) + 8 >> 2] | 0) == 3) {
+ HEAPF64[i27 >> 3] = -+HEAPF64[i28 >> 3];
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 3;
+ continue L3;
+ } else {
+ _luaV_arith(i1, i27, i28, i28, 12);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ }
+ case 15:
+ {
+ i29 = i28 >>> 23;
+ if ((i29 & 256 | 0) == 0) {
+ i29 = i25 + (i29 << 4) | 0;
+ } else {
+ i29 = i23 + ((i29 & 255) << 4) | 0;
+ }
+ i28 = i28 >>> 14;
+ if ((i28 & 256 | 0) == 0) {
+ i28 = i25 + ((i28 & 511) << 4) | 0;
+ } else {
+ i28 = i23 + ((i28 & 255) << 4) | 0;
+ }
+ if ((HEAP32[i29 + 8 >> 2] | 0) == 3 ? (HEAP32[i28 + 8 >> 2] | 0) == 3 : 0) {
+ HEAPF64[i27 >> 3] = +HEAPF64[i29 >> 3] * +HEAPF64[i28 >> 3];
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 3;
+ continue L3;
+ }
+ _luaV_arith(i1, i27, i29, i28, 8);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 16:
+ {
+ i29 = i28 >>> 23;
+ if ((i29 & 256 | 0) == 0) {
+ i29 = i25 + (i29 << 4) | 0;
+ } else {
+ i29 = i23 + ((i29 & 255) << 4) | 0;
+ }
+ i28 = i28 >>> 14;
+ if ((i28 & 256 | 0) == 0) {
+ i28 = i25 + ((i28 & 511) << 4) | 0;
+ } else {
+ i28 = i23 + ((i28 & 255) << 4) | 0;
+ }
+ if ((HEAP32[i29 + 8 >> 2] | 0) == 3 ? (HEAP32[i28 + 8 >> 2] | 0) == 3 : 0) {
+ HEAPF64[i27 >> 3] = +HEAPF64[i29 >> 3] / +HEAPF64[i28 >> 3];
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 3;
+ continue L3;
+ }
+ _luaV_arith(i1, i27, i29, i28, 9);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 20:
+ {
+ i29 = i28 >>> 23;
+ i28 = HEAP32[i25 + (i29 << 4) + 8 >> 2] | 0;
+ if ((i28 | 0) != 0) {
+ if ((i28 | 0) == 1) {
+ i28 = (HEAP32[i25 + (i29 << 4) >> 2] | 0) == 0;
+ } else {
+ i28 = 0;
+ }
+ } else {
+ i28 = 1;
+ }
+ HEAP32[i27 >> 2] = i28 & 1;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 1;
+ continue L3;
+ }
+ case 21:
+ {
+ _luaV_objlen(i1, i27, i25 + (i28 >>> 23 << 4) | 0);
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 22:
+ {
+ i27 = i28 >>> 23;
+ i28 = i28 >>> 14 & 511;
+ HEAP32[i5 >> 2] = i25 + (i28 + 1 << 4);
+ _luaV_concat(i1, 1 - i27 + i28 | 0);
+ i25 = HEAP32[i20 >> 2] | 0;
+ i28 = i25 + (i27 << 4) | 0;
+ i34 = i28;
+ i35 = HEAP32[i34 + 4 >> 2] | 0;
+ i36 = i25 + (i26 << 4) | 0;
+ HEAP32[i36 >> 2] = HEAP32[i34 >> 2];
+ HEAP32[i36 + 4 >> 2] = i35;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = HEAP32[i25 + (i27 << 4) + 8 >> 2];
+ if ((HEAP32[(HEAP32[i6 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ if (!(i26 >>> 0 < i27 >>> 0)) {
+ i28 = i25 + (i26 + 1 << 4) | 0;
+ }
+ HEAP32[i5 >> 2] = i28;
+ _luaC_step(i1);
+ HEAP32[i5 >> 2] = HEAP32[i24 >> 2];
+ }
+ i25 = HEAP32[i20 >> 2] | 0;
+ HEAP32[i5 >> 2] = HEAP32[i24 >> 2];
+ continue L3;
+ }
+ case 25:
+ {
+ i27 = i28 >>> 23;
+ if ((i27 & 256 | 0) == 0) {
+ i27 = i25 + (i27 << 4) | 0;
+ } else {
+ i27 = i23 + ((i27 & 255) << 4) | 0;
+ }
+ i28 = i28 >>> 14;
+ if ((i28 & 256 | 0) == 0) {
+ i25 = i25 + ((i28 & 511) << 4) | 0;
+ } else {
+ i25 = i23 + ((i28 & 255) << 4) | 0;
+ }
+ i36 = (_luaV_lessthan(i1, i27, i25) | 0) == (i26 | 0);
+ i26 = HEAP32[i21 >> 2] | 0;
+ if (i36) {
+ i25 = HEAP32[i26 >> 2] | 0;
+ i27 = i25 >>> 6 & 255;
+ if ((i27 | 0) != 0) {
+ _luaF_close(i1, (HEAP32[i20 >> 2] | 0) + (i27 + -1 << 4) | 0);
+ i26 = HEAP32[i21 >> 2] | 0;
+ }
+ i25 = i26 + ((i25 >>> 14) + -131070 << 2) | 0;
+ } else {
+ i25 = i26 + 4 | 0;
+ }
+ HEAP32[i21 >> 2] = i25;
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 27:
+ {
+ i29 = HEAP32[i25 + (i26 << 4) + 8 >> 2] | 0;
+ i26 = (i29 | 0) == 0;
+ if ((i28 & 8372224 | 0) == 0) {
+ if (!i26) {
+ if (!((i29 | 0) == 1 ? (HEAP32[i27 >> 2] | 0) == 0 : 0)) {
+ i15 = 192;
+ }
+ }
+ } else {
+ if (!i26) {
+ if ((i29 | 0) == 1 ? (HEAP32[i27 >> 2] | 0) == 0 : 0) {
+ i15 = 192;
+ }
+ } else {
+ i15 = 192;
+ }
+ }
+ if ((i15 | 0) == 192) {
+ i15 = 0;
+ HEAP32[i21 >> 2] = (HEAP32[i21 >> 2] | 0) + 4;
+ continue L3;
+ }
+ i27 = HEAP32[i21 >> 2] | 0;
+ i26 = HEAP32[i27 >> 2] | 0;
+ i28 = i26 >>> 6 & 255;
+ if ((i28 | 0) != 0) {
+ _luaF_close(i1, (HEAP32[i20 >> 2] | 0) + (i28 + -1 << 4) | 0);
+ i27 = HEAP32[i21 >> 2] | 0;
+ }
+ HEAP32[i21 >> 2] = i27 + ((i26 >>> 14) + -131070 << 2);
+ continue L3;
+ }
+ case 26:
+ {
+ i27 = i28 >>> 23;
+ if ((i27 & 256 | 0) == 0) {
+ i27 = i25 + (i27 << 4) | 0;
+ } else {
+ i27 = i23 + ((i27 & 255) << 4) | 0;
+ }
+ i28 = i28 >>> 14;
+ if ((i28 & 256 | 0) == 0) {
+ i25 = i25 + ((i28 & 511) << 4) | 0;
+ } else {
+ i25 = i23 + ((i28 & 255) << 4) | 0;
+ }
+ i36 = (_luaV_lessequal(i1, i27, i25) | 0) == (i26 | 0);
+ i26 = HEAP32[i21 >> 2] | 0;
+ if (i36) {
+ i25 = HEAP32[i26 >> 2] | 0;
+ i27 = i25 >>> 6 & 255;
+ if ((i27 | 0) != 0) {
+ _luaF_close(i1, (HEAP32[i20 >> 2] | 0) + (i27 + -1 << 4) | 0);
+ i26 = HEAP32[i21 >> 2] | 0;
+ }
+ i25 = i26 + ((i25 >>> 14) + -131070 << 2) | 0;
+ } else {
+ i25 = i26 + 4 | 0;
+ }
+ HEAP32[i21 >> 2] = i25;
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 28:
+ {
+ i30 = i28 >>> 23;
+ i29 = i25 + (i30 << 4) | 0;
+ i30 = HEAP32[i25 + (i30 << 4) + 8 >> 2] | 0;
+ i31 = (i30 | 0) == 0;
+ if ((i28 & 8372224 | 0) == 0) {
+ if (!i31) {
+ if (!((i30 | 0) == 1 ? (HEAP32[i29 >> 2] | 0) == 0 : 0)) {
+ i15 = 203;
+ }
+ }
+ } else {
+ if (!i31) {
+ if ((i30 | 0) == 1 ? (HEAP32[i29 >> 2] | 0) == 0 : 0) {
+ i15 = 203;
+ }
+ } else {
+ i15 = 203;
+ }
+ }
+ if ((i15 | 0) == 203) {
+ i15 = 0;
+ HEAP32[i21 >> 2] = (HEAP32[i21 >> 2] | 0) + 4;
+ continue L3;
+ }
+ i36 = i29;
+ i28 = HEAP32[i36 + 4 >> 2] | 0;
+ HEAP32[i27 >> 2] = HEAP32[i36 >> 2];
+ HEAP32[i27 + 4 >> 2] = i28;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = i30;
+ i27 = HEAP32[i21 >> 2] | 0;
+ i26 = HEAP32[i27 >> 2] | 0;
+ i28 = i26 >>> 6 & 255;
+ if ((i28 | 0) != 0) {
+ _luaF_close(i1, (HEAP32[i20 >> 2] | 0) + (i28 + -1 << 4) | 0);
+ i27 = HEAP32[i21 >> 2] | 0;
+ }
+ HEAP32[i21 >> 2] = i27 + ((i26 >>> 14) + -131070 << 2);
+ continue L3;
+ }
+ case 30:
+ {
+ i28 = i28 >>> 23;
+ if ((i28 | 0) != 0) {
+ HEAP32[i5 >> 2] = i25 + (i26 + i28 << 4);
+ }
+ if ((_luaD_precall(i1, i27, -1) | 0) == 0) {
+ i15 = 218;
+ break L3;
+ }
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 29:
+ {
+ i29 = i28 >>> 23;
+ i28 = i28 >>> 14 & 511;
+ if ((i29 | 0) != 0) {
+ HEAP32[i5 >> 2] = i25 + (i26 + i29 << 4);
+ }
+ if ((_luaD_precall(i1, i27, i28 + -1 | 0) | 0) == 0) {
+ i15 = 213;
+ break L3;
+ }
+ if ((i28 | 0) != 0) {
+ HEAP32[i5 >> 2] = HEAP32[i24 >> 2];
+ }
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 32:
+ {
+ d39 = +HEAPF64[i25 + (i26 + 2 << 4) >> 3];
+ d38 = d39 + +HEAPF64[i27 >> 3];
+ d37 = +HEAPF64[i25 + (i26 + 1 << 4) >> 3];
+ if (d39 > 0.0) {
+ if (!(d38 <= d37)) {
+ continue L3;
+ }
+ } else {
+ if (!(d37 <= d38)) {
+ continue L3;
+ }
+ }
+ HEAP32[i21 >> 2] = (HEAP32[i21 >> 2] | 0) + ((i28 >>> 14) + -131071 << 2);
+ HEAPF64[i27 >> 3] = d38;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 3;
+ i36 = i26 + 3 | 0;
+ HEAPF64[i25 + (i36 << 4) >> 3] = d38;
+ HEAP32[i25 + (i36 << 4) + 8 >> 2] = 3;
+ continue L3;
+ }
+ case 33:
+ {
+ i32 = i26 + 1 | 0;
+ i30 = i25 + (i32 << 4) | 0;
+ i31 = i26 + 2 | 0;
+ i29 = i25 + (i31 << 4) | 0;
+ i26 = i25 + (i26 << 4) + 8 | 0;
+ i33 = HEAP32[i26 >> 2] | 0;
+ if ((i33 | 0) != 3) {
+ if ((i33 & 15 | 0) != 4) {
+ i15 = 239;
+ break L1;
+ }
+ i36 = HEAP32[i27 >> 2] | 0;
+ if ((_luaO_str2d(i36 + 16 | 0, HEAP32[i36 + 12 >> 2] | 0, i8) | 0) == 0) {
+ i15 = 239;
+ break L1;
+ }
+ HEAPF64[i27 >> 3] = +HEAPF64[i8 >> 3];
+ HEAP32[i26 >> 2] = 3;
+ if ((i27 | 0) == 0) {
+ i15 = 239;
+ break L1;
+ }
+ }
+ i33 = i25 + (i32 << 4) + 8 | 0;
+ i32 = HEAP32[i33 >> 2] | 0;
+ if ((i32 | 0) != 3) {
+ if ((i32 & 15 | 0) != 4) {
+ i15 = 244;
+ break L1;
+ }
+ i36 = HEAP32[i30 >> 2] | 0;
+ if ((_luaO_str2d(i36 + 16 | 0, HEAP32[i36 + 12 >> 2] | 0, i9) | 0) == 0) {
+ i15 = 244;
+ break L1;
+ }
+ HEAPF64[i30 >> 3] = +HEAPF64[i9 >> 3];
+ HEAP32[i33 >> 2] = 3;
+ }
+ i31 = i25 + (i31 << 4) + 8 | 0;
+ i30 = HEAP32[i31 >> 2] | 0;
+ if ((i30 | 0) != 3) {
+ if ((i30 & 15 | 0) != 4) {
+ i15 = 249;
+ break L1;
+ }
+ i36 = HEAP32[i29 >> 2] | 0;
+ if ((_luaO_str2d(i36 + 16 | 0, HEAP32[i36 + 12 >> 2] | 0, i10) | 0) == 0) {
+ i15 = 249;
+ break L1;
+ }
+ HEAPF64[i29 >> 3] = +HEAPF64[i10 >> 3];
+ HEAP32[i31 >> 2] = 3;
+ }
+ HEAPF64[i27 >> 3] = +HEAPF64[i27 >> 3] - +HEAPF64[i29 >> 3];
+ HEAP32[i26 >> 2] = 3;
+ HEAP32[i21 >> 2] = (HEAP32[i21 >> 2] | 0) + ((i28 >>> 14) + -131071 << 2);
+ continue L3;
+ }
+ case 31:
+ {
+ i15 = 223;
+ break L3;
+ }
+ case 34:
+ {
+ i35 = i26 + 3 | 0;
+ i36 = i25 + (i35 << 4) | 0;
+ i33 = i26 + 2 | 0;
+ i34 = i26 + 5 | 0;
+ i32 = i25 + (i33 << 4) | 0;
+ i31 = HEAP32[i32 + 4 >> 2] | 0;
+ i30 = i25 + (i34 << 4) | 0;
+ HEAP32[i30 >> 2] = HEAP32[i32 >> 2];
+ HEAP32[i30 + 4 >> 2] = i31;
+ HEAP32[i25 + (i34 << 4) + 8 >> 2] = HEAP32[i25 + (i33 << 4) + 8 >> 2];
+ i34 = i26 + 1 | 0;
+ i33 = i26 + 4 | 0;
+ i30 = i25 + (i34 << 4) | 0;
+ i31 = HEAP32[i30 + 4 >> 2] | 0;
+ i32 = i25 + (i33 << 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i30 >> 2];
+ HEAP32[i32 + 4 >> 2] = i31;
+ HEAP32[i25 + (i33 << 4) + 8 >> 2] = HEAP32[i25 + (i34 << 4) + 8 >> 2];
+ i33 = i27;
+ i34 = HEAP32[i33 + 4 >> 2] | 0;
+ i27 = i36;
+ HEAP32[i27 >> 2] = HEAP32[i33 >> 2];
+ HEAP32[i27 + 4 >> 2] = i34;
+ HEAP32[i25 + (i35 << 4) + 8 >> 2] = HEAP32[i25 + (i26 << 4) + 8 >> 2];
+ HEAP32[i5 >> 2] = i25 + (i26 + 6 << 4);
+ _luaD_call(i1, i36, i28 >>> 14 & 511, 1);
+ i36 = HEAP32[i20 >> 2] | 0;
+ HEAP32[i5 >> 2] = HEAP32[i24 >> 2];
+ i27 = HEAP32[i21 >> 2] | 0;
+ HEAP32[i21 >> 2] = i27 + 4;
+ i27 = HEAP32[i27 >> 2] | 0;
+ i25 = i36;
+ i28 = i27;
+ i27 = i36 + ((i27 >>> 6 & 255) << 4) | 0;
+ break;
+ }
+ case 35:
+ {
+ break;
+ }
+ case 36:
+ {
+ i29 = i28 >>> 23;
+ i28 = i28 >>> 14 & 511;
+ if ((i29 | 0) == 0) {
+ i29 = ((HEAP32[i5 >> 2] | 0) - i27 >> 4) + -1 | 0;
+ }
+ if ((i28 | 0) == 0) {
+ i28 = HEAP32[i21 >> 2] | 0;
+ HEAP32[i21 >> 2] = i28 + 4;
+ i28 = (HEAP32[i28 >> 2] | 0) >>> 6;
+ }
+ i27 = HEAP32[i27 >> 2] | 0;
+ i30 = i29 + -50 + (i28 * 50 | 0) | 0;
+ if ((i30 | 0) > (HEAP32[i27 + 28 >> 2] | 0)) {
+ _luaH_resizearray(i1, i27, i30);
+ }
+ if ((i29 | 0) > 0) {
+ i28 = i27 + 5 | 0;
+ while (1) {
+ i36 = i29 + i26 | 0;
+ i32 = i25 + (i36 << 4) | 0;
+ i31 = i30 + -1 | 0;
+ _luaH_setint(i1, i27, i30, i32);
+ if (((HEAP32[i25 + (i36 << 4) + 8 >> 2] & 64 | 0) != 0 ? !((HEAP8[(HEAP32[i32 >> 2] | 0) + 5 | 0] & 3) == 0) : 0) ? !((HEAP8[i28] & 4) == 0) : 0) {
+ _luaC_barrierback_(i1, i27);
+ }
+ i29 = i29 + -1 | 0;
+ if ((i29 | 0) > 0) {
+ i30 = i31;
+ } else {
+ break;
+ }
+ }
+ }
+ HEAP32[i5 >> 2] = HEAP32[i24 >> 2];
+ continue L3;
+ }
+ case 37:
+ {
+ i29 = HEAP32[(HEAP32[(HEAP32[i18 >> 2] | 0) + 16 >> 2] | 0) + (i28 >>> 14 << 2) >> 2] | 0;
+ i28 = i29 + 32 | 0;
+ i33 = HEAP32[i28 >> 2] | 0;
+ i30 = HEAP32[i29 + 40 >> 2] | 0;
+ i31 = HEAP32[i29 + 28 >> 2] | 0;
+ L323 : do {
+ if ((i33 | 0) == 0) {
+ i15 = 276;
+ } else {
+ if ((i30 | 0) > 0) {
+ i34 = i33 + 16 | 0;
+ i32 = 0;
+ while (1) {
+ i35 = HEAPU8[i31 + (i32 << 3) + 5 | 0] | 0;
+ if ((HEAP8[i31 + (i32 << 3) + 4 | 0] | 0) == 0) {
+ i36 = HEAP32[(HEAP32[i22 + (i35 << 2) >> 2] | 0) + 8 >> 2] | 0;
+ } else {
+ i36 = i25 + (i35 << 4) | 0;
+ }
+ i35 = i32 + 1 | 0;
+ if ((HEAP32[(HEAP32[i34 + (i32 << 2) >> 2] | 0) + 8 >> 2] | 0) != (i36 | 0)) {
+ i15 = 276;
+ break L323;
+ }
+ if ((i35 | 0) < (i30 | 0)) {
+ i32 = i35;
+ } else {
+ break;
+ }
+ }
+ }
+ HEAP32[i27 >> 2] = i33;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 70;
+ }
+ } while (0);
+ if ((i15 | 0) == 276) {
+ i15 = 0;
+ i32 = _luaF_newLclosure(i1, i30) | 0;
+ HEAP32[i32 + 12 >> 2] = i29;
+ HEAP32[i27 >> 2] = i32;
+ HEAP32[i25 + (i26 << 4) + 8 >> 2] = 70;
+ if ((i30 | 0) > 0) {
+ i27 = i32 + 16 | 0;
+ i34 = 0;
+ do {
+ i33 = HEAPU8[i31 + (i34 << 3) + 5 | 0] | 0;
+ if ((HEAP8[i31 + (i34 << 3) + 4 | 0] | 0) == 0) {
+ HEAP32[i27 + (i34 << 2) >> 2] = HEAP32[i22 + (i33 << 2) >> 2];
+ } else {
+ HEAP32[i27 + (i34 << 2) >> 2] = _luaF_findupval(i1, i25 + (i33 << 4) | 0) | 0;
+ }
+ i34 = i34 + 1 | 0;
+ } while ((i34 | 0) != (i30 | 0));
+ }
+ if (!((HEAP8[i29 + 5 | 0] & 4) == 0)) {
+ _luaC_barrierproto_(i1, i29, i32);
+ }
+ HEAP32[i28 >> 2] = i32;
+ }
+ if ((HEAP32[(HEAP32[i6 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ HEAP32[i5 >> 2] = i25 + (i26 + 1 << 4);
+ _luaC_step(i1);
+ HEAP32[i5 >> 2] = HEAP32[i24 >> 2];
+ }
+ i25 = HEAP32[i20 >> 2] | 0;
+ continue L3;
+ }
+ case 38:
+ {
+ i36 = i28 >>> 23;
+ i29 = i36 + -1 | 0;
+ i30 = (i25 - (HEAP32[i19 >> 2] | 0) >> 4) - (HEAPU8[(HEAP32[i18 >> 2] | 0) + 76 | 0] | 0) | 0;
+ i28 = i30 + -1 | 0;
+ if ((i36 | 0) == 0) {
+ if (((HEAP32[i11 >> 2] | 0) - (HEAP32[i5 >> 2] | 0) >> 4 | 0) <= (i28 | 0)) {
+ _luaD_growstack(i1, i28);
+ }
+ i27 = HEAP32[i20 >> 2] | 0;
+ HEAP32[i5 >> 2] = i27 + (i28 + i26 << 4);
+ i29 = i28;
+ i25 = i27;
+ i27 = i27 + (i26 << 4) | 0;
+ }
+ if ((i29 | 0) <= 0) {
+ continue L3;
+ }
+ i26 = 1 - i30 | 0;
+ i30 = 0;
+ while (1) {
+ if ((i30 | 0) < (i28 | 0)) {
+ i36 = i30 + i26 | 0;
+ i33 = i25 + (i36 << 4) | 0;
+ i34 = HEAP32[i33 + 4 >> 2] | 0;
+ i35 = i27 + (i30 << 4) | 0;
+ HEAP32[i35 >> 2] = HEAP32[i33 >> 2];
+ HEAP32[i35 + 4 >> 2] = i34;
+ HEAP32[i27 + (i30 << 4) + 8 >> 2] = HEAP32[i25 + (i36 << 4) + 8 >> 2];
+ } else {
+ HEAP32[i27 + (i30 << 4) + 8 >> 2] = 0;
+ }
+ i30 = i30 + 1 | 0;
+ if ((i30 | 0) == (i29 | 0)) {
+ continue L3;
+ }
+ }
+ }
+ default:
+ {
+ continue L3;
+ }
+ }
+ i26 = HEAP32[i27 + 24 >> 2] | 0;
+ if ((i26 | 0) == 0) {
+ continue;
+ }
+ i34 = i27 + 16 | 0;
+ i35 = HEAP32[i34 + 4 >> 2] | 0;
+ i36 = i27;
+ HEAP32[i36 >> 2] = HEAP32[i34 >> 2];
+ HEAP32[i36 + 4 >> 2] = i35;
+ HEAP32[i27 + 8 >> 2] = i26;
+ HEAP32[i21 >> 2] = (HEAP32[i21 >> 2] | 0) + ((i28 >>> 14) + -131071 << 2);
+ }
+ if ((i15 | 0) == 213) {
+ i15 = 0;
+ i19 = HEAP32[i3 >> 2] | 0;
+ i36 = i19 + 18 | 0;
+ HEAP8[i36] = HEAPU8[i36] | 4;
+ continue;
+ } else if ((i15 | 0) == 218) {
+ i15 = 0;
+ i22 = HEAP32[i3 >> 2] | 0;
+ i19 = HEAP32[i22 + 8 >> 2] | 0;
+ i23 = HEAP32[i22 >> 2] | 0;
+ i24 = HEAP32[i19 >> 2] | 0;
+ i20 = i22 + 24 | 0;
+ i21 = (HEAP32[i20 >> 2] | 0) + (HEAPU8[(HEAP32[(HEAP32[i23 >> 2] | 0) + 12 >> 2] | 0) + 76 | 0] << 4) | 0;
+ if ((HEAP32[(HEAP32[i18 >> 2] | 0) + 56 >> 2] | 0) > 0) {
+ _luaF_close(i1, HEAP32[i19 + 24 >> 2] | 0);
+ }
+ if (i23 >>> 0 < i21 >>> 0) {
+ i25 = i23;
+ i18 = 0;
+ do {
+ i34 = i25;
+ i35 = HEAP32[i34 + 4 >> 2] | 0;
+ i36 = i24 + (i18 << 4) | 0;
+ HEAP32[i36 >> 2] = HEAP32[i34 >> 2];
+ HEAP32[i36 + 4 >> 2] = i35;
+ HEAP32[i24 + (i18 << 4) + 8 >> 2] = HEAP32[i23 + (i18 << 4) + 8 >> 2];
+ i18 = i18 + 1 | 0;
+ i25 = i23 + (i18 << 4) | 0;
+ } while (i25 >>> 0 < i21 >>> 0);
+ }
+ i36 = i23;
+ HEAP32[i19 + 24 >> 2] = i24 + ((HEAP32[i20 >> 2] | 0) - i36 >> 4 << 4);
+ i36 = i24 + ((HEAP32[i5 >> 2] | 0) - i36 >> 4 << 4) | 0;
+ HEAP32[i5 >> 2] = i36;
+ HEAP32[i19 + 4 >> 2] = i36;
+ HEAP32[i19 + 28 >> 2] = HEAP32[i22 + 28 >> 2];
+ i36 = i19 + 18 | 0;
+ HEAP8[i36] = HEAPU8[i36] | 64;
+ HEAP32[i3 >> 2] = i19;
+ continue;
+ } else if ((i15 | 0) == 223) {
+ i15 = 0;
+ i20 = i28 >>> 23;
+ if ((i20 | 0) != 0) {
+ HEAP32[i5 >> 2] = i25 + (i20 + -1 + i26 << 4);
+ }
+ if ((HEAP32[(HEAP32[i18 >> 2] | 0) + 56 >> 2] | 0) > 0) {
+ _luaF_close(i1, i25);
+ }
+ i18 = _luaD_poscall(i1, i27) | 0;
+ if ((HEAP8[i19 + 18 | 0] & 4) == 0) {
+ i15 = 228;
+ break;
+ }
+ i19 = HEAP32[i3 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ continue;
+ }
+ HEAP32[i5 >> 2] = HEAP32[i19 + 4 >> 2];
+ continue;
+ }
+ }
+ if ((i15 | 0) == 23) {
+ if (!i27) {
+ i36 = HEAP32[i29 >> 2] | 0;
+ i36 = i36 + -4 | 0;
+ HEAP32[i29 >> 2] = i36;
+ i36 = HEAP8[i26] | 0;
+ i36 = i36 & 255;
+ i36 = i36 | 128;
+ i36 = i36 & 255;
+ HEAP8[i26] = i36;
+ i36 = HEAP32[i5 >> 2] | 0;
+ i36 = i36 + -16 | 0;
+ HEAP32[i25 >> 2] = i36;
+ _luaD_throw(i1, 1);
+ }
+ HEAP32[i17 >> 2] = 1;
+ i36 = HEAP32[i29 >> 2] | 0;
+ i36 = i36 + -4 | 0;
+ HEAP32[i29 >> 2] = i36;
+ i36 = HEAP8[i26] | 0;
+ i36 = i36 & 255;
+ i36 = i36 | 128;
+ i36 = i36 & 255;
+ HEAP8[i26] = i36;
+ i36 = HEAP32[i5 >> 2] | 0;
+ i36 = i36 + -16 | 0;
+ HEAP32[i25 >> 2] = i36;
+ _luaD_throw(i1, 1);
+ } else if ((i15 | 0) == 228) {
+ STACKTOP = i12;
+ return;
+ } else if ((i15 | 0) == 239) {
+ _luaG_runerror(i1, 9040, i13);
+ } else if ((i15 | 0) == 244) {
+ _luaG_runerror(i1, 9080, i13);
+ } else if ((i15 | 0) == 249) {
+ _luaG_runerror(i1, 9112, i13);
+ }
+}
+function ___floatscan(i8, i2, i11) {
+ i8 = i8 | 0;
+ i2 = i2 | 0;
+ i11 = i11 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i9 = 0, i10 = 0, i12 = 0, i13 = 0, d14 = 0.0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, d28 = 0.0, i29 = 0, d30 = 0.0, d31 = 0.0, d32 = 0.0, d33 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 512 | 0;
+ i5 = i1;
+ if ((i2 | 0) == 1) {
+ i2 = 53;
+ i3 = -1074;
+ } else if ((i2 | 0) == 2) {
+ i2 = 53;
+ i3 = -1074;
+ } else if ((i2 | 0) == 0) {
+ i2 = 24;
+ i3 = -149;
+ } else {
+ d31 = 0.0;
+ STACKTOP = i1;
+ return +d31;
+ }
+ i9 = i8 + 4 | 0;
+ i10 = i8 + 100 | 0;
+ do {
+ i4 = HEAP32[i9 >> 2] | 0;
+ if (i4 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i4 + 1;
+ i21 = HEAPU8[i4] | 0;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ }
+ } while ((_isspace(i21 | 0) | 0) != 0);
+ do {
+ if ((i21 | 0) == 43 | (i21 | 0) == 45) {
+ i4 = 1 - (((i21 | 0) == 45) << 1) | 0;
+ i7 = HEAP32[i9 >> 2] | 0;
+ if (i7 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i7 + 1;
+ i21 = HEAPU8[i7] | 0;
+ break;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ break;
+ }
+ } else {
+ i4 = 1;
+ }
+ } while (0);
+ i7 = 0;
+ do {
+ if ((i21 | 32 | 0) != (HEAP8[13408 + i7 | 0] | 0)) {
+ break;
+ }
+ do {
+ if (i7 >>> 0 < 7) {
+ i12 = HEAP32[i9 >> 2] | 0;
+ if (i12 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i12 + 1;
+ i21 = HEAPU8[i12] | 0;
+ break;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ break;
+ }
+ }
+ } while (0);
+ i7 = i7 + 1 | 0;
+ } while (i7 >>> 0 < 8);
+ do {
+ if ((i7 | 0) == 3) {
+ i13 = 23;
+ } else if ((i7 | 0) != 8) {
+ i12 = (i11 | 0) == 0;
+ if (!(i7 >>> 0 < 4 | i12)) {
+ if ((i7 | 0) == 8) {
+ break;
+ } else {
+ i13 = 23;
+ break;
+ }
+ }
+ L34 : do {
+ if ((i7 | 0) == 0) {
+ i7 = 0;
+ do {
+ if ((i21 | 32 | 0) != (HEAP8[13424 + i7 | 0] | 0)) {
+ break L34;
+ }
+ do {
+ if (i7 >>> 0 < 2) {
+ i15 = HEAP32[i9 >> 2] | 0;
+ if (i15 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i15 + 1;
+ i21 = HEAPU8[i15] | 0;
+ break;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ break;
+ }
+ }
+ } while (0);
+ i7 = i7 + 1 | 0;
+ } while (i7 >>> 0 < 3);
+ }
+ } while (0);
+ if ((i7 | 0) == 0) {
+ do {
+ if ((i21 | 0) == 48) {
+ i7 = HEAP32[i9 >> 2] | 0;
+ if (i7 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i7 + 1;
+ i7 = HEAPU8[i7] | 0;
+ } else {
+ i7 = ___shgetc(i8) | 0;
+ }
+ if ((i7 | 32 | 0) != 120) {
+ if ((HEAP32[i10 >> 2] | 0) == 0) {
+ i21 = 48;
+ break;
+ }
+ HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + -1;
+ i21 = 48;
+ break;
+ }
+ i5 = HEAP32[i9 >> 2] | 0;
+ if (i5 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i5 + 1;
+ i21 = HEAPU8[i5] | 0;
+ i19 = 0;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ i19 = 0;
+ }
+ while (1) {
+ if ((i21 | 0) == 46) {
+ i13 = 70;
+ break;
+ } else if ((i21 | 0) != 48) {
+ i5 = 0;
+ i7 = 0;
+ i15 = 0;
+ i16 = 0;
+ i18 = 0;
+ i20 = 0;
+ d28 = 1.0;
+ i17 = 0;
+ d14 = 0.0;
+ break;
+ }
+ i5 = HEAP32[i9 >> 2] | 0;
+ if (i5 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i5 + 1;
+ i21 = HEAPU8[i5] | 0;
+ i19 = 1;
+ continue;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ i19 = 1;
+ continue;
+ }
+ }
+ L66 : do {
+ if ((i13 | 0) == 70) {
+ i5 = HEAP32[i9 >> 2] | 0;
+ if (i5 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i5 + 1;
+ i21 = HEAPU8[i5] | 0;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ }
+ if ((i21 | 0) == 48) {
+ i15 = -1;
+ i16 = -1;
+ while (1) {
+ i5 = HEAP32[i9 >> 2] | 0;
+ if (i5 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i5 + 1;
+ i21 = HEAPU8[i5] | 0;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ }
+ if ((i21 | 0) != 48) {
+ i5 = 0;
+ i7 = 0;
+ i19 = 1;
+ i18 = 1;
+ i20 = 0;
+ d28 = 1.0;
+ i17 = 0;
+ d14 = 0.0;
+ break L66;
+ }
+ i29 = _i64Add(i15 | 0, i16 | 0, -1, -1) | 0;
+ i15 = i29;
+ i16 = tempRet0;
+ }
+ } else {
+ i5 = 0;
+ i7 = 0;
+ i15 = 0;
+ i16 = 0;
+ i18 = 1;
+ i20 = 0;
+ d28 = 1.0;
+ i17 = 0;
+ d14 = 0.0;
+ }
+ }
+ } while (0);
+ L79 : while (1) {
+ i24 = i21 + -48 | 0;
+ do {
+ if (!(i24 >>> 0 < 10)) {
+ i23 = i21 | 32;
+ i22 = (i21 | 0) == 46;
+ if (!((i23 + -97 | 0) >>> 0 < 6 | i22)) {
+ break L79;
+ }
+ if (i22) {
+ if ((i18 | 0) == 0) {
+ i15 = i7;
+ i16 = i5;
+ i18 = 1;
+ break;
+ } else {
+ i21 = 46;
+ break L79;
+ }
+ } else {
+ i24 = (i21 | 0) > 57 ? i23 + -87 | 0 : i24;
+ i13 = 84;
+ break;
+ }
+ } else {
+ i13 = 84;
+ }
+ } while (0);
+ if ((i13 | 0) == 84) {
+ i13 = 0;
+ do {
+ if (!((i5 | 0) < 0 | (i5 | 0) == 0 & i7 >>> 0 < 8)) {
+ if ((i5 | 0) < 0 | (i5 | 0) == 0 & i7 >>> 0 < 14) {
+ d31 = d28 * .0625;
+ d30 = d31;
+ d14 = d14 + d31 * +(i24 | 0);
+ break;
+ }
+ if ((i24 | 0) != 0 & (i20 | 0) == 0) {
+ i20 = 1;
+ d30 = d28;
+ d14 = d14 + d28 * .5;
+ } else {
+ d30 = d28;
+ }
+ } else {
+ d30 = d28;
+ i17 = i24 + (i17 << 4) | 0;
+ }
+ } while (0);
+ i7 = _i64Add(i7 | 0, i5 | 0, 1, 0) | 0;
+ i5 = tempRet0;
+ i19 = 1;
+ d28 = d30;
+ }
+ i21 = HEAP32[i9 >> 2] | 0;
+ if (i21 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i21 + 1;
+ i21 = HEAPU8[i21] | 0;
+ continue;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ continue;
+ }
+ }
+ if ((i19 | 0) == 0) {
+ i2 = (HEAP32[i10 >> 2] | 0) == 0;
+ if (!i2) {
+ HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + -1;
+ }
+ if (!i12) {
+ if (!i2 ? (i6 = HEAP32[i9 >> 2] | 0, HEAP32[i9 >> 2] = i6 + -1, (i18 | 0) != 0) : 0) {
+ HEAP32[i9 >> 2] = i6 + -2;
+ }
+ } else {
+ ___shlim(i8, 0);
+ }
+ d31 = +(i4 | 0) * 0.0;
+ STACKTOP = i1;
+ return +d31;
+ }
+ i13 = (i18 | 0) == 0;
+ i6 = i13 ? i7 : i15;
+ i13 = i13 ? i5 : i16;
+ if ((i5 | 0) < 0 | (i5 | 0) == 0 & i7 >>> 0 < 8) {
+ do {
+ i17 = i17 << 4;
+ i7 = _i64Add(i7 | 0, i5 | 0, 1, 0) | 0;
+ i5 = tempRet0;
+ } while ((i5 | 0) < 0 | (i5 | 0) == 0 & i7 >>> 0 < 8);
+ }
+ do {
+ if ((i21 | 32 | 0) == 112) {
+ i7 = _scanexp(i8, i11) | 0;
+ i5 = tempRet0;
+ if ((i7 | 0) == 0 & (i5 | 0) == -2147483648) {
+ if (i12) {
+ ___shlim(i8, 0);
+ d31 = 0.0;
+ STACKTOP = i1;
+ return +d31;
+ } else {
+ if ((HEAP32[i10 >> 2] | 0) == 0) {
+ i7 = 0;
+ i5 = 0;
+ break;
+ }
+ HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + -1;
+ i7 = 0;
+ i5 = 0;
+ break;
+ }
+ }
+ } else {
+ if ((HEAP32[i10 >> 2] | 0) == 0) {
+ i7 = 0;
+ i5 = 0;
+ } else {
+ HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + -1;
+ i7 = 0;
+ i5 = 0;
+ }
+ }
+ } while (0);
+ i6 = _bitshift64Shl(i6 | 0, i13 | 0, 2) | 0;
+ i6 = _i64Add(i6 | 0, tempRet0 | 0, -32, -1) | 0;
+ i5 = _i64Add(i6 | 0, tempRet0 | 0, i7 | 0, i5 | 0) | 0;
+ i6 = tempRet0;
+ if ((i17 | 0) == 0) {
+ d31 = +(i4 | 0) * 0.0;
+ STACKTOP = i1;
+ return +d31;
+ }
+ if ((i6 | 0) > 0 | (i6 | 0) == 0 & i5 >>> 0 > (0 - i3 | 0) >>> 0) {
+ HEAP32[(___errno_location() | 0) >> 2] = 34;
+ d31 = +(i4 | 0) * 1.7976931348623157e+308 * 1.7976931348623157e+308;
+ STACKTOP = i1;
+ return +d31;
+ }
+ i29 = i3 + -106 | 0;
+ i27 = ((i29 | 0) < 0) << 31 >> 31;
+ if ((i6 | 0) < (i27 | 0) | (i6 | 0) == (i27 | 0) & i5 >>> 0 < i29 >>> 0) {
+ HEAP32[(___errno_location() | 0) >> 2] = 34;
+ d31 = +(i4 | 0) * 2.2250738585072014e-308 * 2.2250738585072014e-308;
+ STACKTOP = i1;
+ return +d31;
+ }
+ if ((i17 | 0) > -1) {
+ do {
+ i17 = i17 << 1;
+ if (!(d14 >= .5)) {
+ d28 = d14;
+ } else {
+ d28 = d14 + -1.0;
+ i17 = i17 | 1;
+ }
+ d14 = d14 + d28;
+ i5 = _i64Add(i5 | 0, i6 | 0, -1, -1) | 0;
+ i6 = tempRet0;
+ } while ((i17 | 0) > -1);
+ }
+ i3 = _i64Subtract(32, 0, i3 | 0, ((i3 | 0) < 0) << 31 >> 31 | 0) | 0;
+ i3 = _i64Add(i5 | 0, i6 | 0, i3 | 0, tempRet0 | 0) | 0;
+ i29 = tempRet0;
+ if (0 > (i29 | 0) | 0 == (i29 | 0) & i2 >>> 0 > i3 >>> 0) {
+ i2 = (i3 | 0) < 0 ? 0 : i3;
+ }
+ if ((i2 | 0) < 53) {
+ d28 = +(i4 | 0);
+ d30 = +_copysign(+(+_scalbn(1.0, 84 - i2 | 0)), +d28);
+ if ((i2 | 0) < 32 & d14 != 0.0) {
+ i29 = i17 & 1;
+ i17 = (i29 ^ 1) + i17 | 0;
+ d14 = (i29 | 0) == 0 ? 0.0 : d14;
+ }
+ } else {
+ d28 = +(i4 | 0);
+ d30 = 0.0;
+ }
+ d14 = d28 * d14 + (d30 + d28 * +(i17 >>> 0)) - d30;
+ if (!(d14 != 0.0)) {
+ HEAP32[(___errno_location() | 0) >> 2] = 34;
+ }
+ d31 = +_scalbnl(d14, i5);
+ STACKTOP = i1;
+ return +d31;
+ }
+ } while (0);
+ i7 = i3 + i2 | 0;
+ i6 = 0 - i7 | 0;
+ i20 = 0;
+ while (1) {
+ if ((i21 | 0) == 46) {
+ i13 = 139;
+ break;
+ } else if ((i21 | 0) != 48) {
+ i25 = 0;
+ i22 = 0;
+ i19 = 0;
+ break;
+ }
+ i15 = HEAP32[i9 >> 2] | 0;
+ if (i15 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i15 + 1;
+ i21 = HEAPU8[i15] | 0;
+ i20 = 1;
+ continue;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ i20 = 1;
+ continue;
+ }
+ }
+ L168 : do {
+ if ((i13 | 0) == 139) {
+ i15 = HEAP32[i9 >> 2] | 0;
+ if (i15 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i15 + 1;
+ i21 = HEAPU8[i15] | 0;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ }
+ if ((i21 | 0) == 48) {
+ i25 = -1;
+ i22 = -1;
+ while (1) {
+ i15 = HEAP32[i9 >> 2] | 0;
+ if (i15 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i15 + 1;
+ i21 = HEAPU8[i15] | 0;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ }
+ if ((i21 | 0) != 48) {
+ i20 = 1;
+ i19 = 1;
+ break L168;
+ }
+ i29 = _i64Add(i25 | 0, i22 | 0, -1, -1) | 0;
+ i25 = i29;
+ i22 = tempRet0;
+ }
+ } else {
+ i25 = 0;
+ i22 = 0;
+ i19 = 1;
+ }
+ }
+ } while (0);
+ HEAP32[i5 >> 2] = 0;
+ i26 = i21 + -48 | 0;
+ i27 = (i21 | 0) == 46;
+ L182 : do {
+ if (i26 >>> 0 < 10 | i27) {
+ i15 = i5 + 496 | 0;
+ i24 = 0;
+ i23 = 0;
+ i18 = 0;
+ i17 = 0;
+ i16 = 0;
+ while (1) {
+ do {
+ if (i27) {
+ if ((i19 | 0) == 0) {
+ i25 = i24;
+ i22 = i23;
+ i19 = 1;
+ } else {
+ break L182;
+ }
+ } else {
+ i27 = _i64Add(i24 | 0, i23 | 0, 1, 0) | 0;
+ i23 = tempRet0;
+ i29 = (i21 | 0) != 48;
+ if ((i17 | 0) >= 125) {
+ if (!i29) {
+ i24 = i27;
+ break;
+ }
+ HEAP32[i15 >> 2] = HEAP32[i15 >> 2] | 1;
+ i24 = i27;
+ break;
+ }
+ i20 = i5 + (i17 << 2) | 0;
+ if ((i18 | 0) != 0) {
+ i26 = i21 + -48 + ((HEAP32[i20 >> 2] | 0) * 10 | 0) | 0;
+ }
+ HEAP32[i20 >> 2] = i26;
+ i18 = i18 + 1 | 0;
+ i21 = (i18 | 0) == 9;
+ i24 = i27;
+ i20 = 1;
+ i18 = i21 ? 0 : i18;
+ i17 = (i21 & 1) + i17 | 0;
+ i16 = i29 ? i27 : i16;
+ }
+ } while (0);
+ i21 = HEAP32[i9 >> 2] | 0;
+ if (i21 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i21 + 1;
+ i21 = HEAPU8[i21] | 0;
+ } else {
+ i21 = ___shgetc(i8) | 0;
+ }
+ i26 = i21 + -48 | 0;
+ i27 = (i21 | 0) == 46;
+ if (!(i26 >>> 0 < 10 | i27)) {
+ i13 = 162;
+ break;
+ }
+ }
+ } else {
+ i24 = 0;
+ i23 = 0;
+ i18 = 0;
+ i17 = 0;
+ i16 = 0;
+ i13 = 162;
+ }
+ } while (0);
+ if ((i13 | 0) == 162) {
+ i13 = (i19 | 0) == 0;
+ i25 = i13 ? i24 : i25;
+ i22 = i13 ? i23 : i22;
+ }
+ i13 = (i20 | 0) != 0;
+ if (i13 ? (i21 | 32 | 0) == 101 : 0) {
+ i15 = _scanexp(i8, i11) | 0;
+ i11 = tempRet0;
+ do {
+ if ((i15 | 0) == 0 & (i11 | 0) == -2147483648) {
+ if (i12) {
+ ___shlim(i8, 0);
+ d31 = 0.0;
+ STACKTOP = i1;
+ return +d31;
+ } else {
+ if ((HEAP32[i10 >> 2] | 0) == 0) {
+ i15 = 0;
+ i11 = 0;
+ break;
+ }
+ HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + -1;
+ i15 = 0;
+ i11 = 0;
+ break;
+ }
+ }
+ } while (0);
+ i9 = _i64Add(i15 | 0, i11 | 0, i25 | 0, i22 | 0) | 0;
+ i22 = tempRet0;
+ } else {
+ if ((i21 | 0) > -1 ? (HEAP32[i10 >> 2] | 0) != 0 : 0) {
+ HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + -1;
+ i9 = i25;
+ } else {
+ i9 = i25;
+ }
+ }
+ if (!i13) {
+ HEAP32[(___errno_location() | 0) >> 2] = 22;
+ ___shlim(i8, 0);
+ d31 = 0.0;
+ STACKTOP = i1;
+ return +d31;
+ }
+ i8 = HEAP32[i5 >> 2] | 0;
+ if ((i8 | 0) == 0) {
+ d31 = +(i4 | 0) * 0.0;
+ STACKTOP = i1;
+ return +d31;
+ }
+ do {
+ if ((i9 | 0) == (i24 | 0) & (i22 | 0) == (i23 | 0) & ((i23 | 0) < 0 | (i23 | 0) == 0 & i24 >>> 0 < 10)) {
+ if (!(i2 >>> 0 > 30) ? (i8 >>> i2 | 0) != 0 : 0) {
+ break;
+ }
+ d31 = +(i4 | 0) * +(i8 >>> 0);
+ STACKTOP = i1;
+ return +d31;
+ }
+ } while (0);
+ i29 = (i3 | 0) / -2 | 0;
+ i27 = ((i29 | 0) < 0) << 31 >> 31;
+ if ((i22 | 0) > (i27 | 0) | (i22 | 0) == (i27 | 0) & i9 >>> 0 > i29 >>> 0) {
+ HEAP32[(___errno_location() | 0) >> 2] = 34;
+ d31 = +(i4 | 0) * 1.7976931348623157e+308 * 1.7976931348623157e+308;
+ STACKTOP = i1;
+ return +d31;
+ }
+ i29 = i3 + -106 | 0;
+ i27 = ((i29 | 0) < 0) << 31 >> 31;
+ if ((i22 | 0) < (i27 | 0) | (i22 | 0) == (i27 | 0) & i9 >>> 0 < i29 >>> 0) {
+ HEAP32[(___errno_location() | 0) >> 2] = 34;
+ d31 = +(i4 | 0) * 2.2250738585072014e-308 * 2.2250738585072014e-308;
+ STACKTOP = i1;
+ return +d31;
+ }
+ if ((i18 | 0) != 0) {
+ if ((i18 | 0) < 9) {
+ i8 = i5 + (i17 << 2) | 0;
+ i10 = HEAP32[i8 >> 2] | 0;
+ do {
+ i10 = i10 * 10 | 0;
+ i18 = i18 + 1 | 0;
+ } while ((i18 | 0) != 9);
+ HEAP32[i8 >> 2] = i10;
+ }
+ i17 = i17 + 1 | 0;
+ }
+ do {
+ if ((i16 | 0) < 9 ? (i16 | 0) <= (i9 | 0) & (i9 | 0) < 18 : 0) {
+ if ((i9 | 0) == 9) {
+ d31 = +(i4 | 0) * +((HEAP32[i5 >> 2] | 0) >>> 0);
+ STACKTOP = i1;
+ return +d31;
+ }
+ if ((i9 | 0) < 9) {
+ d31 = +(i4 | 0) * +((HEAP32[i5 >> 2] | 0) >>> 0) / +(HEAP32[13440 + (8 - i9 << 2) >> 2] | 0);
+ STACKTOP = i1;
+ return +d31;
+ }
+ i10 = i2 + 27 + (Math_imul(i9, -3) | 0) | 0;
+ i8 = HEAP32[i5 >> 2] | 0;
+ if ((i10 | 0) <= 30 ? (i8 >>> i10 | 0) != 0 : 0) {
+ break;
+ }
+ d31 = +(i4 | 0) * +(i8 >>> 0) * +(HEAP32[13440 + (i9 + -10 << 2) >> 2] | 0);
+ STACKTOP = i1;
+ return +d31;
+ }
+ } while (0);
+ i8 = (i9 | 0) % 9 | 0;
+ if ((i8 | 0) == 0) {
+ i8 = 0;
+ i10 = 0;
+ } else {
+ i11 = (i9 | 0) > -1 ? i8 : i8 + 9 | 0;
+ i12 = HEAP32[13440 + (8 - i11 << 2) >> 2] | 0;
+ if ((i17 | 0) != 0) {
+ i10 = 1e9 / (i12 | 0) | 0;
+ i8 = 0;
+ i16 = 0;
+ i15 = 0;
+ while (1) {
+ i27 = i5 + (i15 << 2) | 0;
+ i13 = HEAP32[i27 >> 2] | 0;
+ i29 = ((i13 >>> 0) / (i12 >>> 0) | 0) + i16 | 0;
+ HEAP32[i27 >> 2] = i29;
+ i16 = Math_imul((i13 >>> 0) % (i12 >>> 0) | 0, i10) | 0;
+ i13 = i15 + 1 | 0;
+ if ((i15 | 0) == (i8 | 0) & (i29 | 0) == 0) {
+ i8 = i13 & 127;
+ i9 = i9 + -9 | 0;
+ }
+ if ((i13 | 0) == (i17 | 0)) {
+ break;
+ } else {
+ i15 = i13;
+ }
+ }
+ if ((i16 | 0) != 0) {
+ HEAP32[i5 + (i17 << 2) >> 2] = i16;
+ i17 = i17 + 1 | 0;
+ }
+ } else {
+ i8 = 0;
+ i17 = 0;
+ }
+ i10 = 0;
+ i9 = 9 - i11 + i9 | 0;
+ }
+ L280 : while (1) {
+ i11 = i5 + (i8 << 2) | 0;
+ if ((i9 | 0) < 18) {
+ do {
+ i13 = 0;
+ i11 = i17 + 127 | 0;
+ while (1) {
+ i11 = i11 & 127;
+ i12 = i5 + (i11 << 2) | 0;
+ i15 = _bitshift64Shl(HEAP32[i12 >> 2] | 0, 0, 29) | 0;
+ i15 = _i64Add(i15 | 0, tempRet0 | 0, i13 | 0, 0) | 0;
+ i13 = tempRet0;
+ if (i13 >>> 0 > 0 | (i13 | 0) == 0 & i15 >>> 0 > 1e9) {
+ i29 = ___udivdi3(i15 | 0, i13 | 0, 1e9, 0) | 0;
+ i15 = ___uremdi3(i15 | 0, i13 | 0, 1e9, 0) | 0;
+ i13 = i29;
+ } else {
+ i13 = 0;
+ }
+ HEAP32[i12 >> 2] = i15;
+ i12 = (i11 | 0) == (i8 | 0);
+ if (!((i11 | 0) != (i17 + 127 & 127 | 0) | i12)) {
+ i17 = (i15 | 0) == 0 ? i11 : i17;
+ }
+ if (i12) {
+ break;
+ } else {
+ i11 = i11 + -1 | 0;
+ }
+ }
+ i10 = i10 + -29 | 0;
+ } while ((i13 | 0) == 0);
+ } else {
+ if ((i9 | 0) != 18) {
+ break;
+ }
+ do {
+ if (!((HEAP32[i11 >> 2] | 0) >>> 0 < 9007199)) {
+ i9 = 18;
+ break L280;
+ }
+ i13 = 0;
+ i12 = i17 + 127 | 0;
+ while (1) {
+ i12 = i12 & 127;
+ i15 = i5 + (i12 << 2) | 0;
+ i16 = _bitshift64Shl(HEAP32[i15 >> 2] | 0, 0, 29) | 0;
+ i16 = _i64Add(i16 | 0, tempRet0 | 0, i13 | 0, 0) | 0;
+ i13 = tempRet0;
+ if (i13 >>> 0 > 0 | (i13 | 0) == 0 & i16 >>> 0 > 1e9) {
+ i29 = ___udivdi3(i16 | 0, i13 | 0, 1e9, 0) | 0;
+ i16 = ___uremdi3(i16 | 0, i13 | 0, 1e9, 0) | 0;
+ i13 = i29;
+ } else {
+ i13 = 0;
+ }
+ HEAP32[i15 >> 2] = i16;
+ i15 = (i12 | 0) == (i8 | 0);
+ if (!((i12 | 0) != (i17 + 127 & 127 | 0) | i15)) {
+ i17 = (i16 | 0) == 0 ? i12 : i17;
+ }
+ if (i15) {
+ break;
+ } else {
+ i12 = i12 + -1 | 0;
+ }
+ }
+ i10 = i10 + -29 | 0;
+ } while ((i13 | 0) == 0);
+ }
+ i8 = i8 + 127 & 127;
+ if ((i8 | 0) == (i17 | 0)) {
+ i29 = i17 + 127 & 127;
+ i17 = i5 + ((i17 + 126 & 127) << 2) | 0;
+ HEAP32[i17 >> 2] = HEAP32[i17 >> 2] | HEAP32[i5 + (i29 << 2) >> 2];
+ i17 = i29;
+ }
+ HEAP32[i5 + (i8 << 2) >> 2] = i13;
+ i9 = i9 + 9 | 0;
+ }
+ L311 : while (1) {
+ i11 = i17 + 1 & 127;
+ i12 = i5 + ((i17 + 127 & 127) << 2) | 0;
+ while (1) {
+ i15 = (i9 | 0) == 18;
+ i13 = (i9 | 0) > 27 ? 9 : 1;
+ while (1) {
+ i16 = 0;
+ while (1) {
+ i18 = i16 + i8 & 127;
+ if ((i18 | 0) == (i17 | 0)) {
+ i16 = 2;
+ break;
+ }
+ i18 = HEAP32[i5 + (i18 << 2) >> 2] | 0;
+ i19 = HEAP32[13432 + (i16 << 2) >> 2] | 0;
+ if (i18 >>> 0 < i19 >>> 0) {
+ i16 = 2;
+ break;
+ }
+ i20 = i16 + 1 | 0;
+ if (i18 >>> 0 > i19 >>> 0) {
+ break;
+ }
+ if ((i20 | 0) < 2) {
+ i16 = i20;
+ } else {
+ i16 = i20;
+ break;
+ }
+ }
+ if ((i16 | 0) == 2 & i15) {
+ break L311;
+ }
+ i10 = i13 + i10 | 0;
+ if ((i8 | 0) == (i17 | 0)) {
+ i8 = i17;
+ } else {
+ break;
+ }
+ }
+ i15 = (1 << i13) + -1 | 0;
+ i19 = 1e9 >>> i13;
+ i18 = i8;
+ i16 = 0;
+ do {
+ i27 = i5 + (i8 << 2) | 0;
+ i29 = HEAP32[i27 >> 2] | 0;
+ i20 = (i29 >>> i13) + i16 | 0;
+ HEAP32[i27 >> 2] = i20;
+ i16 = Math_imul(i29 & i15, i19) | 0;
+ i20 = (i8 | 0) == (i18 | 0) & (i20 | 0) == 0;
+ i8 = i8 + 1 & 127;
+ i9 = i20 ? i9 + -9 | 0 : i9;
+ i18 = i20 ? i8 : i18;
+ } while ((i8 | 0) != (i17 | 0));
+ if ((i16 | 0) == 0) {
+ i8 = i18;
+ continue;
+ }
+ if ((i11 | 0) != (i18 | 0)) {
+ break;
+ }
+ HEAP32[i12 >> 2] = HEAP32[i12 >> 2] | 1;
+ i8 = i18;
+ }
+ HEAP32[i5 + (i17 << 2) >> 2] = i16;
+ i8 = i18;
+ i17 = i11;
+ }
+ i9 = i8 & 127;
+ if ((i9 | 0) == (i17 | 0)) {
+ HEAP32[i5 + (i11 + -1 << 2) >> 2] = 0;
+ i17 = i11;
+ }
+ d28 = +((HEAP32[i5 + (i9 << 2) >> 2] | 0) >>> 0);
+ i9 = i8 + 1 & 127;
+ if ((i9 | 0) == (i17 | 0)) {
+ i17 = i17 + 1 & 127;
+ HEAP32[i5 + (i17 + -1 << 2) >> 2] = 0;
+ }
+ d14 = +(i4 | 0);
+ d30 = d14 * (d28 * 1.0e9 + +((HEAP32[i5 + (i9 << 2) >> 2] | 0) >>> 0));
+ i4 = i10 + 53 | 0;
+ i3 = i4 - i3 | 0;
+ if ((i3 | 0) < (i2 | 0)) {
+ i2 = (i3 | 0) < 0 ? 0 : i3;
+ i9 = 1;
+ } else {
+ i9 = 0;
+ }
+ if ((i2 | 0) < 53) {
+ d33 = +_copysign(+(+_scalbn(1.0, 105 - i2 | 0)), +d30);
+ d32 = +_fmod(+d30, +(+_scalbn(1.0, 53 - i2 | 0)));
+ d28 = d33;
+ d31 = d32;
+ d30 = d33 + (d30 - d32);
+ } else {
+ d28 = 0.0;
+ d31 = 0.0;
+ }
+ i11 = i8 + 2 & 127;
+ if ((i11 | 0) != (i17 | 0)) {
+ i5 = HEAP32[i5 + (i11 << 2) >> 2] | 0;
+ do {
+ if (!(i5 >>> 0 < 5e8)) {
+ if (i5 >>> 0 > 5e8) {
+ d31 = d14 * .75 + d31;
+ break;
+ }
+ if ((i8 + 3 & 127 | 0) == (i17 | 0)) {
+ d31 = d14 * .5 + d31;
+ break;
+ } else {
+ d31 = d14 * .75 + d31;
+ break;
+ }
+ } else {
+ if ((i5 | 0) == 0 ? (i8 + 3 & 127 | 0) == (i17 | 0) : 0) {
+ break;
+ }
+ d31 = d14 * .25 + d31;
+ }
+ } while (0);
+ if ((53 - i2 | 0) > 1 ? !(+_fmod(+d31, 1.0) != 0.0) : 0) {
+ d31 = d31 + 1.0;
+ }
+ }
+ d14 = d30 + d31 - d28;
+ do {
+ if ((i4 & 2147483647 | 0) > (-2 - i7 | 0)) {
+ if (+Math_abs(+d14) >= 9007199254740992.0) {
+ i9 = (i9 | 0) != 0 & (i2 | 0) == (i3 | 0) ? 0 : i9;
+ i10 = i10 + 1 | 0;
+ d14 = d14 * .5;
+ }
+ if ((i10 + 50 | 0) <= (i6 | 0) ? !((i9 | 0) != 0 & d31 != 0.0) : 0) {
+ break;
+ }
+ HEAP32[(___errno_location() | 0) >> 2] = 34;
+ }
+ } while (0);
+ d33 = +_scalbnl(d14, i10);
+ STACKTOP = i1;
+ return +d33;
+ } else if ((i7 | 0) == 3) {
+ i2 = HEAP32[i9 >> 2] | 0;
+ if (i2 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i2 + 1;
+ i2 = HEAPU8[i2] | 0;
+ } else {
+ i2 = ___shgetc(i8) | 0;
+ }
+ if ((i2 | 0) == 40) {
+ i2 = 1;
+ } else {
+ if ((HEAP32[i10 >> 2] | 0) == 0) {
+ d33 = nan;
+ STACKTOP = i1;
+ return +d33;
+ }
+ HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + -1;
+ d33 = nan;
+ STACKTOP = i1;
+ return +d33;
+ }
+ while (1) {
+ i3 = HEAP32[i9 >> 2] | 0;
+ if (i3 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0) {
+ HEAP32[i9 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ } else {
+ i3 = ___shgetc(i8) | 0;
+ }
+ if (!((i3 + -48 | 0) >>> 0 < 10 | (i3 + -65 | 0) >>> 0 < 26) ? !((i3 + -97 | 0) >>> 0 < 26 | (i3 | 0) == 95) : 0) {
+ break;
+ }
+ i2 = i2 + 1 | 0;
+ }
+ if ((i3 | 0) == 41) {
+ d33 = nan;
+ STACKTOP = i1;
+ return +d33;
+ }
+ i3 = (HEAP32[i10 >> 2] | 0) == 0;
+ if (!i3) {
+ HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + -1;
+ }
+ if (i12) {
+ HEAP32[(___errno_location() | 0) >> 2] = 22;
+ ___shlim(i8, 0);
+ d33 = 0.0;
+ STACKTOP = i1;
+ return +d33;
+ }
+ if ((i2 | 0) == 0 | i3) {
+ d33 = nan;
+ STACKTOP = i1;
+ return +d33;
+ }
+ while (1) {
+ i2 = i2 + -1 | 0;
+ HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + -1;
+ if ((i2 | 0) == 0) {
+ d14 = nan;
+ break;
+ }
+ }
+ STACKTOP = i1;
+ return +d14;
+ } else {
+ if ((HEAP32[i10 >> 2] | 0) != 0) {
+ HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + -1;
+ }
+ HEAP32[(___errno_location() | 0) >> 2] = 22;
+ ___shlim(i8, 0);
+ d33 = 0.0;
+ STACKTOP = i1;
+ return +d33;
+ }
+ }
+ } while (0);
+ if ((i13 | 0) == 23) {
+ i2 = (HEAP32[i10 >> 2] | 0) == 0;
+ if (!i2) {
+ HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + -1;
+ }
+ if (!(i7 >>> 0 < 4 | (i11 | 0) == 0 | i2)) {
+ do {
+ HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + -1;
+ i7 = i7 + -1 | 0;
+ } while (i7 >>> 0 > 3);
+ }
+ }
+ d33 = +(i4 | 0) * inf;
+ STACKTOP = i1;
+ return +d33;
+}
+function _statement(i4) {
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 160 | 0;
+ i8 = i2 + 120 | 0;
+ i24 = i2 + 96 | 0;
+ i15 = i2 + 72 | 0;
+ i25 = i2 + 48 | 0;
+ i20 = i2 + 24 | 0;
+ i21 = i2;
+ i19 = i4 + 4 | 0;
+ i6 = HEAP32[i19 >> 2] | 0;
+ i3 = i4 + 48 | 0;
+ i9 = HEAP32[i3 >> 2] | 0;
+ i1 = i4 + 52 | 0;
+ i26 = (HEAP32[i1 >> 2] | 0) + 38 | 0;
+ i27 = (HEAP16[i26 >> 1] | 0) + 1 << 16 >> 16;
+ HEAP16[i26 >> 1] = i27;
+ if ((i27 & 65535) > 200) {
+ i27 = i9 + 12 | 0;
+ i26 = HEAP32[(HEAP32[i27 >> 2] | 0) + 52 >> 2] | 0;
+ i5 = HEAP32[(HEAP32[i9 >> 2] | 0) + 64 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i29 = 6552;
+ HEAP32[i8 >> 2] = 6360;
+ i28 = i8 + 4 | 0;
+ HEAP32[i28 >> 2] = 200;
+ i28 = i8 + 8 | 0;
+ HEAP32[i28 >> 2] = i29;
+ i28 = _luaO_pushfstring(i26, 6592, i8) | 0;
+ i29 = HEAP32[i27 >> 2] | 0;
+ _luaX_syntaxerror(i29, i28);
+ }
+ HEAP32[i8 >> 2] = i5;
+ i28 = _luaO_pushfstring(i26, 6568, i8) | 0;
+ HEAP32[i8 >> 2] = 6360;
+ i29 = i8 + 4 | 0;
+ HEAP32[i29 >> 2] = 200;
+ i29 = i8 + 8 | 0;
+ HEAP32[i29 >> 2] = i28;
+ i29 = _luaO_pushfstring(i26, 6592, i8) | 0;
+ i28 = HEAP32[i27 >> 2] | 0;
+ _luaX_syntaxerror(i28, i29);
+ }
+ i5 = i4 + 16 | 0;
+ L8 : do {
+ switch (HEAP32[i5 >> 2] | 0) {
+ case 59:
+ {
+ _luaX_next(i4);
+ break;
+ }
+ case 267:
+ {
+ HEAP32[i21 >> 2] = -1;
+ _test_then_block(i4, i21);
+ while (1) {
+ i8 = HEAP32[i5 >> 2] | 0;
+ if ((i8 | 0) == 260) {
+ i7 = 10;
+ break;
+ } else if ((i8 | 0) != 261) {
+ break;
+ }
+ _test_then_block(i4, i21);
+ }
+ if ((i7 | 0) == 10) {
+ _luaX_next(i4);
+ i7 = HEAP32[i3 >> 2] | 0;
+ HEAP8[i20 + 10 | 0] = 0;
+ HEAP8[i20 + 8 | 0] = HEAP8[i7 + 46 | 0] | 0;
+ i29 = HEAP32[(HEAP32[i7 + 12 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i20 + 4 >> 1] = HEAP32[i29 + 28 >> 2];
+ HEAP16[i20 + 6 >> 1] = HEAP32[i29 + 16 >> 2];
+ HEAP8[i20 + 9 | 0] = 0;
+ i29 = i7 + 16 | 0;
+ HEAP32[i20 >> 2] = HEAP32[i29 >> 2];
+ HEAP32[i29 >> 2] = i20;
+ L16 : do {
+ i8 = HEAP32[i5 >> 2] | 0;
+ switch (i8 | 0) {
+ case 277:
+ case 286:
+ case 262:
+ case 261:
+ case 260:
+ {
+ break L16;
+ }
+ default:
+ {}
+ }
+ _statement(i4);
+ } while ((i8 | 0) != 274);
+ _leaveblock(i7);
+ }
+ _check_match(i4, 262, 267, i6);
+ _luaK_patchtohere(i9, HEAP32[i21 >> 2] | 0);
+ break;
+ }
+ case 259:
+ {
+ _luaX_next(i4);
+ i7 = HEAP32[i3 >> 2] | 0;
+ HEAP8[i20 + 10 | 0] = 0;
+ HEAP8[i20 + 8 | 0] = HEAP8[i7 + 46 | 0] | 0;
+ i29 = HEAP32[(HEAP32[i7 + 12 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i20 + 4 >> 1] = HEAP32[i29 + 28 >> 2];
+ HEAP16[i20 + 6 >> 1] = HEAP32[i29 + 16 >> 2];
+ HEAP8[i20 + 9 | 0] = 0;
+ i29 = i7 + 16 | 0;
+ HEAP32[i20 >> 2] = HEAP32[i29 >> 2];
+ HEAP32[i29 >> 2] = i20;
+ L22 : do {
+ i8 = HEAP32[i5 >> 2] | 0;
+ switch (i8 | 0) {
+ case 277:
+ case 286:
+ case 262:
+ case 261:
+ case 260:
+ {
+ break L22;
+ }
+ default:
+ {}
+ }
+ _statement(i4);
+ } while ((i8 | 0) != 274);
+ _leaveblock(i7);
+ _check_match(i4, 262, 259, i6);
+ break;
+ }
+ case 269:
+ {
+ _luaX_next(i4);
+ i6 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) == 265) {
+ _luaX_next(i4);
+ i7 = HEAP32[i3 >> 2] | 0;
+ if ((HEAP32[i5 >> 2] | 0) == 288) {
+ i29 = HEAP32[i4 + 24 >> 2] | 0;
+ _luaX_next(i4);
+ _new_localvar(i4, i29);
+ i29 = HEAP32[i3 >> 2] | 0;
+ i27 = i29 + 46 | 0;
+ i28 = (HEAPU8[i27] | 0) + 1 | 0;
+ HEAP8[i27] = i28;
+ HEAP32[(HEAP32[(HEAP32[i29 >> 2] | 0) + 24 >> 2] | 0) + ((HEAP16[(HEAP32[HEAP32[(HEAP32[i29 + 12 >> 2] | 0) + 64 >> 2] >> 2] | 0) + ((i28 & 255) + -1 + (HEAP32[i29 + 40 >> 2] | 0) << 1) >> 1] | 0) * 12 | 0) + 4 >> 2] = HEAP32[i29 + 20 >> 2];
+ _body(i4, i25, 0, HEAP32[i19 >> 2] | 0);
+ HEAP32[(HEAP32[(HEAP32[i7 >> 2] | 0) + 24 >> 2] | 0) + ((HEAP16[(HEAP32[HEAP32[(HEAP32[i7 + 12 >> 2] | 0) + 64 >> 2] >> 2] | 0) + ((HEAP32[i7 + 40 >> 2] | 0) + (HEAP32[i25 + 8 >> 2] | 0) << 1) >> 1] | 0) * 12 | 0) + 4 >> 2] = HEAP32[i7 + 20 >> 2];
+ break L8;
+ } else {
+ _error_expected(i4, 288);
+ }
+ }
+ if ((i6 | 0) != 288) {
+ _error_expected(i4, 288);
+ }
+ i7 = i4 + 24 | 0;
+ i6 = 1;
+ while (1) {
+ i8 = HEAP32[i7 >> 2] | 0;
+ _luaX_next(i4);
+ _new_localvar(i4, i8);
+ i8 = HEAP32[i5 >> 2] | 0;
+ if ((i8 | 0) == 61) {
+ i7 = 81;
+ break;
+ } else if ((i8 | 0) != 44) {
+ i7 = 83;
+ break;
+ }
+ _luaX_next(i4);
+ if ((HEAP32[i5 >> 2] | 0) == 288) {
+ i6 = i6 + 1 | 0;
+ } else {
+ i7 = 78;
+ break;
+ }
+ }
+ do {
+ if ((i7 | 0) == 78) {
+ _error_expected(i4, 288);
+ } else if ((i7 | 0) == 81) {
+ _luaX_next(i4);
+ _subexpr(i4, i15, 0) | 0;
+ if ((HEAP32[i5 >> 2] | 0) == 44) {
+ i8 = 1;
+ do {
+ _luaX_next(i4);
+ _luaK_exp2nextreg(HEAP32[i3 >> 2] | 0, i15);
+ _subexpr(i4, i15, 0) | 0;
+ i8 = i8 + 1 | 0;
+ } while ((HEAP32[i5 >> 2] | 0) == 44);
+ } else {
+ i8 = 1;
+ }
+ i5 = HEAP32[i15 >> 2] | 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ i8 = i6 - i8 | 0;
+ if ((i5 | 0) == 0) {
+ i17 = i8;
+ i18 = i4;
+ i7 = 88;
+ break;
+ } else if (!((i5 | 0) == 13 | (i5 | 0) == 12)) {
+ _luaK_exp2nextreg(i4, i15);
+ i17 = i8;
+ i18 = i4;
+ i7 = 88;
+ break;
+ }
+ i5 = i8 + 1 | 0;
+ i5 = (i5 | 0) < 0 ? 0 : i5;
+ _luaK_setreturns(i4, i15, i5);
+ if ((i5 | 0) > 1) {
+ _luaK_reserveregs(i4, i5 + -1 | 0);
+ }
+ } else if ((i7 | 0) == 83) {
+ HEAP32[i15 >> 2] = 0;
+ i17 = i6;
+ i18 = HEAP32[i3 >> 2] | 0;
+ i7 = 88;
+ }
+ } while (0);
+ if ((i7 | 0) == 88 ? (i17 | 0) > 0 : 0) {
+ i29 = HEAPU8[i18 + 48 | 0] | 0;
+ _luaK_reserveregs(i18, i17);
+ _luaK_nil(i18, i29, i17);
+ }
+ i5 = HEAP32[i3 >> 2] | 0;
+ i4 = i5 + 46 | 0;
+ i7 = (HEAPU8[i4] | 0) + i6 | 0;
+ HEAP8[i4] = i7;
+ if ((i6 | 0) != 0 ? (i11 = i5 + 20 | 0, i14 = i5 + 40 | 0, i12 = HEAP32[(HEAP32[i5 >> 2] | 0) + 24 >> 2] | 0, i13 = HEAP32[HEAP32[(HEAP32[i5 + 12 >> 2] | 0) + 64 >> 2] >> 2] | 0, HEAP32[i12 + ((HEAP16[i13 + ((i7 & 255) - i6 + (HEAP32[i14 >> 2] | 0) << 1) >> 1] | 0) * 12 | 0) + 4 >> 2] = HEAP32[i11 >> 2], i16 = i6 + -1 | 0, (i16 | 0) != 0) : 0) {
+ do {
+ HEAP32[i12 + ((HEAP16[i13 + ((HEAPU8[i4] | 0) - i16 + (HEAP32[i14 >> 2] | 0) << 1) >> 1] | 0) * 12 | 0) + 4 >> 2] = HEAP32[i11 >> 2];
+ i16 = i16 + -1 | 0;
+ } while ((i16 | 0) != 0);
+ }
+ break;
+ }
+ case 264:
+ {
+ HEAP8[i24 + 10 | 0] = 1;
+ HEAP8[i24 + 8 | 0] = HEAP8[i9 + 46 | 0] | 0;
+ i29 = HEAP32[(HEAP32[i9 + 12 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i24 + 4 >> 1] = HEAP32[i29 + 28 >> 2];
+ HEAP16[i24 + 6 >> 1] = HEAP32[i29 + 16 >> 2];
+ HEAP8[i24 + 9 | 0] = 0;
+ i29 = i9 + 16 | 0;
+ HEAP32[i24 >> 2] = HEAP32[i29 >> 2];
+ HEAP32[i29 >> 2] = i24;
+ _luaX_next(i4);
+ if ((HEAP32[i5 >> 2] | 0) != 288) {
+ _error_expected(i4, 288);
+ }
+ i14 = i4 + 24 | 0;
+ i13 = HEAP32[i14 >> 2] | 0;
+ _luaX_next(i4);
+ i11 = HEAP32[i5 >> 2] | 0;
+ if ((i11 | 0) == 268 | (i11 | 0) == 44) {
+ i12 = HEAP32[i3 >> 2] | 0;
+ i11 = HEAPU8[i12 + 48 | 0] | 0;
+ _new_localvar(i4, _luaX_newstring(i4, 6744, 15) | 0);
+ _new_localvar(i4, _luaX_newstring(i4, 6760, 11) | 0);
+ _new_localvar(i4, _luaX_newstring(i4, 6776, 13) | 0);
+ _new_localvar(i4, i13);
+ i13 = HEAP32[i5 >> 2] | 0;
+ do {
+ if ((i13 | 0) == 44) {
+ i15 = 4;
+ while (1) {
+ _luaX_next(i4);
+ if ((HEAP32[i5 >> 2] | 0) != 288) {
+ i7 = 40;
+ break;
+ }
+ i13 = HEAP32[i14 >> 2] | 0;
+ _luaX_next(i4);
+ _new_localvar(i4, i13);
+ i13 = HEAP32[i5 >> 2] | 0;
+ if ((i13 | 0) == 44) {
+ i15 = i15 + 1 | 0;
+ } else {
+ i7 = 42;
+ break;
+ }
+ }
+ if ((i7 | 0) == 40) {
+ _error_expected(i4, 288);
+ } else if ((i7 | 0) == 42) {
+ i22 = i13;
+ i10 = i15 + -2 | 0;
+ break;
+ }
+ } else {
+ i22 = i13;
+ i10 = 1;
+ }
+ } while (0);
+ if ((i22 | 0) != 268) {
+ _error_expected(i4, 268);
+ }
+ _luaX_next(i4);
+ i13 = HEAP32[i19 >> 2] | 0;
+ _subexpr(i4, i8, 0) | 0;
+ if ((HEAP32[i5 >> 2] | 0) == 44) {
+ i14 = 1;
+ do {
+ _luaX_next(i4);
+ _luaK_exp2nextreg(HEAP32[i3 >> 2] | 0, i8);
+ _subexpr(i4, i8, 0) | 0;
+ i14 = i14 + 1 | 0;
+ } while ((HEAP32[i5 >> 2] | 0) == 44);
+ } else {
+ i14 = 1;
+ }
+ i5 = HEAP32[i3 >> 2] | 0;
+ i14 = 3 - i14 | 0;
+ i15 = HEAP32[i8 >> 2] | 0;
+ if ((i15 | 0) == 0) {
+ i7 = 51;
+ } else if ((i15 | 0) == 13 | (i15 | 0) == 12) {
+ i15 = i14 + 1 | 0;
+ i15 = (i15 | 0) < 0 ? 0 : i15;
+ _luaK_setreturns(i5, i8, i15);
+ if ((i15 | 0) > 1) {
+ _luaK_reserveregs(i5, i15 + -1 | 0);
+ }
+ } else {
+ _luaK_exp2nextreg(i5, i8);
+ i7 = 51;
+ }
+ if ((i7 | 0) == 51 ? (i14 | 0) > 0 : 0) {
+ i29 = HEAPU8[i5 + 48 | 0] | 0;
+ _luaK_reserveregs(i5, i14);
+ _luaK_nil(i5, i29, i14);
+ }
+ _luaK_checkstack(i12, 3);
+ _forbody(i4, i11, i13, i10, 0);
+ } else if ((i11 | 0) == 61) {
+ i11 = HEAP32[i3 >> 2] | 0;
+ i7 = i11 + 48 | 0;
+ i10 = HEAPU8[i7] | 0;
+ _new_localvar(i4, _luaX_newstring(i4, 6792, 11) | 0);
+ _new_localvar(i4, _luaX_newstring(i4, 6808, 11) | 0);
+ _new_localvar(i4, _luaX_newstring(i4, 6824, 10) | 0);
+ _new_localvar(i4, i13);
+ if ((HEAP32[i5 >> 2] | 0) != 61) {
+ _error_expected(i4, 61);
+ }
+ _luaX_next(i4);
+ _subexpr(i4, i8, 0) | 0;
+ _luaK_exp2nextreg(HEAP32[i3 >> 2] | 0, i8);
+ if ((HEAP32[i5 >> 2] | 0) != 44) {
+ _error_expected(i4, 44);
+ }
+ _luaX_next(i4);
+ _subexpr(i4, i8, 0) | 0;
+ _luaK_exp2nextreg(HEAP32[i3 >> 2] | 0, i8);
+ if ((HEAP32[i5 >> 2] | 0) == 44) {
+ _luaX_next(i4);
+ _subexpr(i4, i8, 0) | 0;
+ _luaK_exp2nextreg(HEAP32[i3 >> 2] | 0, i8);
+ } else {
+ i29 = HEAPU8[i7] | 0;
+ _luaK_codek(i11, i29, _luaK_numberK(i11, 1.0) | 0) | 0;
+ _luaK_reserveregs(i11, 1);
+ }
+ _forbody(i4, i10, i6, 1, 1);
+ } else {
+ _luaX_syntaxerror(i4, 6720);
+ }
+ _check_match(i4, 262, 264, i6);
+ _leaveblock(i9);
+ break;
+ }
+ case 265:
+ {
+ _luaX_next(i4);
+ if ((HEAP32[i5 >> 2] | 0) != 288) {
+ _error_expected(i4, 288);
+ }
+ i8 = HEAP32[i4 + 24 >> 2] | 0;
+ _luaX_next(i4);
+ i9 = HEAP32[i3 >> 2] | 0;
+ if ((_singlevaraux(i9, i8, i20, 1) | 0) == 0) {
+ _singlevaraux(i9, HEAP32[i4 + 72 >> 2] | 0, i20, 1) | 0;
+ i29 = _luaK_stringK(HEAP32[i3 >> 2] | 0, i8) | 0;
+ HEAP32[i25 + 16 >> 2] = -1;
+ HEAP32[i25 + 20 >> 2] = -1;
+ HEAP32[i25 >> 2] = 4;
+ HEAP32[i25 + 8 >> 2] = i29;
+ _luaK_indexed(i9, i20, i25);
+ }
+ while (1) {
+ i8 = HEAP32[i5 >> 2] | 0;
+ if ((i8 | 0) == 58) {
+ i7 = 70;
+ break;
+ } else if ((i8 | 0) != 46) {
+ i5 = 0;
+ break;
+ }
+ _fieldsel(i4, i20);
+ }
+ if ((i7 | 0) == 70) {
+ _fieldsel(i4, i20);
+ i5 = 1;
+ }
+ _body(i4, i21, i5, i6);
+ _luaK_storevar(HEAP32[i3 >> 2] | 0, i20, i21);
+ _luaK_fixline(HEAP32[i3 >> 2] | 0, i6);
+ break;
+ }
+ case 278:
+ {
+ _luaX_next(i4);
+ i7 = _luaK_getlabel(i9) | 0;
+ _subexpr(i4, i20, 0) | 0;
+ if ((HEAP32[i20 >> 2] | 0) == 1) {
+ HEAP32[i20 >> 2] = 3;
+ }
+ _luaK_goiftrue(HEAP32[i3 >> 2] | 0, i20);
+ i8 = HEAP32[i20 + 20 >> 2] | 0;
+ HEAP8[i21 + 10 | 0] = 1;
+ HEAP8[i21 + 8 | 0] = HEAP8[i9 + 46 | 0] | 0;
+ i29 = HEAP32[(HEAP32[i9 + 12 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i21 + 4 >> 1] = HEAP32[i29 + 28 >> 2];
+ HEAP16[i21 + 6 >> 1] = HEAP32[i29 + 16 >> 2];
+ HEAP8[i21 + 9 | 0] = 0;
+ i29 = i9 + 16 | 0;
+ HEAP32[i21 >> 2] = HEAP32[i29 >> 2];
+ HEAP32[i29 >> 2] = i21;
+ if ((HEAP32[i5 >> 2] | 0) != 259) {
+ _error_expected(i4, 259);
+ }
+ _luaX_next(i4);
+ i10 = HEAP32[i3 >> 2] | 0;
+ HEAP8[i20 + 10 | 0] = 0;
+ HEAP8[i20 + 8 | 0] = HEAP8[i10 + 46 | 0] | 0;
+ i29 = HEAP32[(HEAP32[i10 + 12 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i20 + 4 >> 1] = HEAP32[i29 + 28 >> 2];
+ HEAP16[i20 + 6 >> 1] = HEAP32[i29 + 16 >> 2];
+ HEAP8[i20 + 9 | 0] = 0;
+ i29 = i10 + 16 | 0;
+ HEAP32[i20 >> 2] = HEAP32[i29 >> 2];
+ HEAP32[i29 >> 2] = i20;
+ L119 : do {
+ i11 = HEAP32[i5 >> 2] | 0;
+ switch (i11 | 0) {
+ case 277:
+ case 286:
+ case 262:
+ case 261:
+ case 260:
+ {
+ break L119;
+ }
+ default:
+ {}
+ }
+ _statement(i4);
+ } while ((i11 | 0) != 274);
+ _leaveblock(i10);
+ _luaK_patchlist(i9, _luaK_jump(i9) | 0, i7);
+ _check_match(i4, 262, 278, i6);
+ _leaveblock(i9);
+ _luaK_patchtohere(i9, i8);
+ break;
+ }
+ case 273:
+ {
+ i7 = _luaK_getlabel(i9) | 0;
+ HEAP8[i24 + 10 | 0] = 1;
+ i28 = i9 + 46 | 0;
+ HEAP8[i24 + 8 | 0] = HEAP8[i28] | 0;
+ i11 = i9 + 12 | 0;
+ i29 = HEAP32[(HEAP32[i11 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i24 + 4 >> 1] = HEAP32[i29 + 28 >> 2];
+ HEAP16[i24 + 6 >> 1] = HEAP32[i29 + 16 >> 2];
+ HEAP8[i24 + 9 | 0] = 0;
+ i29 = i9 + 16 | 0;
+ HEAP32[i24 >> 2] = HEAP32[i29 >> 2];
+ HEAP32[i29 >> 2] = i24;
+ HEAP8[i15 + 10 | 0] = 0;
+ i10 = i15 + 8 | 0;
+ HEAP8[i10] = HEAP8[i28] | 0;
+ i11 = HEAP32[(HEAP32[i11 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i15 + 4 >> 1] = HEAP32[i11 + 28 >> 2];
+ HEAP16[i15 + 6 >> 1] = HEAP32[i11 + 16 >> 2];
+ i11 = i15 + 9 | 0;
+ HEAP8[i11] = 0;
+ HEAP32[i15 >> 2] = HEAP32[i29 >> 2];
+ HEAP32[i29 >> 2] = i15;
+ _luaX_next(i4);
+ L124 : do {
+ i12 = HEAP32[i5 >> 2] | 0;
+ switch (i12 | 0) {
+ case 277:
+ case 286:
+ case 262:
+ case 261:
+ case 260:
+ {
+ break L124;
+ }
+ default:
+ {}
+ }
+ _statement(i4);
+ } while ((i12 | 0) != 274);
+ _check_match(i4, 277, 273, i6);
+ _subexpr(i4, i8, 0) | 0;
+ if ((HEAP32[i8 >> 2] | 0) == 1) {
+ HEAP32[i8 >> 2] = 3;
+ }
+ _luaK_goiftrue(HEAP32[i3 >> 2] | 0, i8);
+ i4 = HEAP32[i8 + 20 >> 2] | 0;
+ if ((HEAP8[i11] | 0) != 0) {
+ _luaK_patchclose(i9, i4, HEAPU8[i10] | 0);
+ }
+ _leaveblock(i9);
+ _luaK_patchlist(i9, i4, i7);
+ _leaveblock(i9);
+ break;
+ }
+ case 285:
+ {
+ _luaX_next(i4);
+ if ((HEAP32[i5 >> 2] | 0) != 288) {
+ _error_expected(i4, 288);
+ }
+ i10 = HEAP32[i4 + 24 >> 2] | 0;
+ _luaX_next(i4);
+ i15 = HEAP32[i3 >> 2] | 0;
+ i9 = i4 + 64 | 0;
+ i14 = HEAP32[i9 >> 2] | 0;
+ i12 = i14 + 24 | 0;
+ i11 = i15 + 16 | 0;
+ i16 = HEAP16[(HEAP32[i11 >> 2] | 0) + 4 >> 1] | 0;
+ i13 = i14 + 28 | 0;
+ L138 : do {
+ if ((i16 | 0) < (HEAP32[i13 >> 2] | 0)) {
+ while (1) {
+ i17 = i16 + 1 | 0;
+ if ((_luaS_eqstr(i10, HEAP32[(HEAP32[i12 >> 2] | 0) + (i16 << 4) >> 2] | 0) | 0) != 0) {
+ break;
+ }
+ if ((i17 | 0) < (HEAP32[i13 >> 2] | 0)) {
+ i16 = i17;
+ } else {
+ break L138;
+ }
+ }
+ i28 = i15 + 12 | 0;
+ i29 = HEAP32[(HEAP32[i28 >> 2] | 0) + 52 >> 2] | 0;
+ i27 = HEAP32[(HEAP32[i12 >> 2] | 0) + (i16 << 4) + 8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i10 + 16;
+ HEAP32[i8 + 4 >> 2] = i27;
+ i29 = _luaO_pushfstring(i29, 6680, i8) | 0;
+ _semerror(HEAP32[i28 >> 2] | 0, i29);
+ }
+ } while (0);
+ if ((HEAP32[i5 >> 2] | 0) != 285) {
+ _error_expected(i4, 285);
+ }
+ _luaX_next(i4);
+ i8 = HEAP32[i15 + 20 >> 2] | 0;
+ i15 = HEAP32[i13 >> 2] | 0;
+ i14 = i14 + 32 | 0;
+ if ((i15 | 0) < (HEAP32[i14 >> 2] | 0)) {
+ i14 = HEAP32[i12 >> 2] | 0;
+ } else {
+ i14 = _luaM_growaux_(HEAP32[i1 >> 2] | 0, HEAP32[i12 >> 2] | 0, i14, 16, 32767, 6312) | 0;
+ HEAP32[i12 >> 2] = i14;
+ }
+ HEAP32[i14 + (i15 << 4) >> 2] = i10;
+ i29 = HEAP32[i12 >> 2] | 0;
+ HEAP32[i29 + (i15 << 4) + 8 >> 2] = i6;
+ HEAP8[i29 + (i15 << 4) + 12 | 0] = HEAP8[(HEAP32[i3 >> 2] | 0) + 46 | 0] | 0;
+ HEAP32[(HEAP32[i12 >> 2] | 0) + (i15 << 4) + 4 >> 2] = i8;
+ HEAP32[i13 >> 2] = (HEAP32[i13 >> 2] | 0) + 1;
+ L152 : while (1) {
+ switch (HEAP32[i5 >> 2] | 0) {
+ case 285:
+ case 59:
+ {
+ break;
+ }
+ case 286:
+ case 262:
+ case 261:
+ case 260:
+ {
+ i7 = 108;
+ break L152;
+ }
+ default:
+ {
+ break L152;
+ }
+ }
+ _statement(i4);
+ }
+ if ((i7 | 0) == 108) {
+ HEAP8[(HEAP32[i12 >> 2] | 0) + (i15 << 4) + 12 | 0] = HEAP8[(HEAP32[i11 >> 2] | 0) + 8 | 0] | 0;
+ }
+ i5 = (HEAP32[i12 >> 2] | 0) + (i15 << 4) | 0;
+ i8 = HEAP32[i9 >> 2] | 0;
+ i7 = HEAP16[(HEAP32[(HEAP32[i3 >> 2] | 0) + 16 >> 2] | 0) + 6 >> 1] | 0;
+ i6 = i8 + 16 | 0;
+ if ((i7 | 0) < (HEAP32[i6 >> 2] | 0)) {
+ i8 = i8 + 12 | 0;
+ do {
+ while (1) {
+ if ((_luaS_eqstr(HEAP32[(HEAP32[i8 >> 2] | 0) + (i7 << 4) >> 2] | 0, HEAP32[i5 >> 2] | 0) | 0) == 0) {
+ break;
+ }
+ _closegoto(i4, i7, i5);
+ if ((i7 | 0) >= (HEAP32[i6 >> 2] | 0)) {
+ break L8;
+ }
+ }
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) < (HEAP32[i6 >> 2] | 0));
+ }
+ break;
+ }
+ case 274:
+ {
+ _luaX_next(i4);
+ i6 = HEAP32[i3 >> 2] | 0;
+ L166 : do {
+ switch (HEAP32[i5 >> 2] | 0) {
+ case 59:
+ case 277:
+ case 286:
+ case 262:
+ case 261:
+ case 260:
+ {
+ i8 = 0;
+ i7 = 0;
+ break;
+ }
+ default:
+ {
+ _subexpr(i4, i24, 0) | 0;
+ if ((HEAP32[i5 >> 2] | 0) == 44) {
+ i7 = 1;
+ do {
+ _luaX_next(i4);
+ _luaK_exp2nextreg(HEAP32[i3 >> 2] | 0, i24);
+ _subexpr(i4, i24, 0) | 0;
+ i7 = i7 + 1 | 0;
+ } while ((HEAP32[i5 >> 2] | 0) == 44);
+ } else {
+ i7 = 1;
+ }
+ if (!(((HEAP32[i24 >> 2] | 0) + -12 | 0) >>> 0 < 2)) {
+ if ((i7 | 0) == 1) {
+ i8 = _luaK_exp2anyreg(i6, i24) | 0;
+ i7 = 1;
+ break L166;
+ } else {
+ _luaK_exp2nextreg(i6, i24);
+ i8 = HEAPU8[i6 + 46 | 0] | 0;
+ break L166;
+ }
+ } else {
+ _luaK_setreturns(i6, i24, -1);
+ if ((HEAP32[i24 >> 2] | 0) == 12 & (i7 | 0) == 1) {
+ i29 = (HEAP32[(HEAP32[i6 >> 2] | 0) + 12 >> 2] | 0) + (HEAP32[i24 + 8 >> 2] << 2) | 0;
+ HEAP32[i29 >> 2] = HEAP32[i29 >> 2] & -64 | 30;
+ }
+ i8 = HEAPU8[i6 + 46 | 0] | 0;
+ i7 = -1;
+ break L166;
+ }
+ }
+ }
+ } while (0);
+ _luaK_ret(i6, i8, i7);
+ if ((HEAP32[i5 >> 2] | 0) == 59) {
+ _luaX_next(i4);
+ }
+ break;
+ }
+ case 266:
+ case 258:
+ {
+ i6 = _luaK_jump(i9) | 0;
+ i7 = HEAP32[i19 >> 2] | 0;
+ i29 = (HEAP32[i5 >> 2] | 0) == 266;
+ _luaX_next(i4);
+ do {
+ if (i29) {
+ if ((HEAP32[i5 >> 2] | 0) == 288) {
+ i23 = HEAP32[i4 + 24 >> 2] | 0;
+ _luaX_next(i4);
+ break;
+ } else {
+ _error_expected(i4, 288);
+ }
+ } else {
+ i23 = _luaS_new(HEAP32[i1 >> 2] | 0, 6304) | 0;
+ }
+ } while (0);
+ i10 = HEAP32[i4 + 64 >> 2] | 0;
+ i9 = i10 + 12 | 0;
+ i5 = i10 + 16 | 0;
+ i8 = HEAP32[i5 >> 2] | 0;
+ i10 = i10 + 20 | 0;
+ if ((i8 | 0) < (HEAP32[i10 >> 2] | 0)) {
+ i10 = HEAP32[i9 >> 2] | 0;
+ } else {
+ i10 = _luaM_growaux_(HEAP32[i1 >> 2] | 0, HEAP32[i9 >> 2] | 0, i10, 16, 32767, 6312) | 0;
+ HEAP32[i9 >> 2] = i10;
+ }
+ HEAP32[i10 + (i8 << 4) >> 2] = i23;
+ i29 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i29 + (i8 << 4) + 8 >> 2] = i7;
+ HEAP8[i29 + (i8 << 4) + 12 | 0] = HEAP8[(HEAP32[i3 >> 2] | 0) + 46 | 0] | 0;
+ HEAP32[(HEAP32[i9 >> 2] | 0) + (i8 << 4) + 4 >> 2] = i6;
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + 1;
+ _findlabel(i4, i8) | 0;
+ break;
+ }
+ default:
+ {
+ i6 = i8 + 8 | 0;
+ _suffixedexp(i4, i6);
+ i29 = HEAP32[i5 >> 2] | 0;
+ if ((i29 | 0) == 44 | (i29 | 0) == 61) {
+ HEAP32[i8 >> 2] = 0;
+ _assignment(i4, i8, 1);
+ break L8;
+ }
+ if ((HEAP32[i6 >> 2] | 0) == 12) {
+ i29 = (HEAP32[(HEAP32[i9 >> 2] | 0) + 12 >> 2] | 0) + (HEAP32[i8 + 16 >> 2] << 2) | 0;
+ HEAP32[i29 >> 2] = HEAP32[i29 >> 2] & -8372225 | 16384;
+ break L8;
+ } else {
+ _luaX_syntaxerror(i4, 6344);
+ }
+ }
+ }
+ } while (0);
+ i29 = HEAP32[i3 >> 2] | 0;
+ HEAP8[i29 + 48 | 0] = HEAP8[i29 + 46 | 0] | 0;
+ i29 = (HEAP32[i1 >> 2] | 0) + 38 | 0;
+ HEAP16[i29 >> 1] = (HEAP16[i29 >> 1] | 0) + -1 << 16 >> 16;
+ STACKTOP = i2;
+ return;
+}
+function _match(i1, i12, i11) {
+ i1 = i1 | 0;
+ i12 = i12 | 0;
+ i11 = i11 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i8 = i2;
+ i32 = HEAP32[i1 >> 2] | 0;
+ HEAP32[i1 >> 2] = i32 + -1;
+ if ((i32 | 0) == 0) {
+ _luaL_error(HEAP32[i1 + 16 >> 2] | 0, 7272, i8) | 0;
+ }
+ i14 = i1 + 12 | 0;
+ i22 = HEAP32[i14 >> 2] | 0;
+ L4 : do {
+ if ((i22 | 0) != (i11 | 0)) {
+ i3 = i1 + 8 | 0;
+ i9 = i1 + 16 | 0;
+ i16 = i1 + 4 | 0;
+ i10 = i1 + 20 | 0;
+ L6 : while (1) {
+ i19 = i12 + 1 | 0;
+ i20 = i12 + -1 | 0;
+ L8 : while (1) {
+ i23 = HEAP8[i11] | 0;
+ i21 = i23 << 24 >> 24;
+ L10 : do {
+ if ((i21 | 0) == 36) {
+ i7 = i11 + 1 | 0;
+ if ((i7 | 0) == (i22 | 0)) {
+ i7 = 23;
+ break L6;
+ } else {
+ i22 = i7;
+ i21 = i7;
+ i7 = 89;
+ }
+ } else if ((i21 | 0) == 37) {
+ i21 = i11 + 1 | 0;
+ i23 = HEAP8[i21] | 0;
+ switch (i23 << 24 >> 24 | 0) {
+ case 57:
+ case 56:
+ case 55:
+ case 54:
+ case 53:
+ case 52:
+ case 51:
+ case 50:
+ case 49:
+ case 48:
+ {
+ i7 = 69;
+ break L8;
+ }
+ case 98:
+ {
+ i7 = 25;
+ break L8;
+ }
+ case 102:
+ {
+ break;
+ }
+ default:
+ {
+ if ((i21 | 0) == (i22 | 0)) {
+ _luaL_error(HEAP32[i9 >> 2] | 0, 7368, i8) | 0;
+ }
+ i22 = i11 + 2 | 0;
+ i7 = 89;
+ break L10;
+ }
+ }
+ i22 = i11 + 2 | 0;
+ if ((HEAP8[i22] | 0) == 91) {
+ i21 = 91;
+ } else {
+ _luaL_error(HEAP32[i9 >> 2] | 0, 7296, i8) | 0;
+ i21 = HEAP8[i22] | 0;
+ }
+ i23 = i11 + 3 | 0;
+ i21 = i21 << 24 >> 24;
+ if ((i21 | 0) == 91) {
+ i21 = (HEAP8[i23] | 0) == 94 ? i11 + 4 | 0 : i23;
+ while (1) {
+ if ((i21 | 0) == (HEAP32[i14 >> 2] | 0)) {
+ _luaL_error(HEAP32[i9 >> 2] | 0, 7408, i8) | 0;
+ }
+ i11 = i21 + 1 | 0;
+ if ((HEAP8[i21] | 0) == 37) {
+ i11 = i11 >>> 0 < (HEAP32[i14 >> 2] | 0) >>> 0 ? i21 + 2 | 0 : i11;
+ }
+ if ((HEAP8[i11] | 0) == 93) {
+ break;
+ } else {
+ i21 = i11;
+ }
+ }
+ i11 = i11 + 1 | 0;
+ } else if ((i21 | 0) == 37) {
+ if ((i23 | 0) == (HEAP32[i14 >> 2] | 0)) {
+ _luaL_error(HEAP32[i9 >> 2] | 0, 7368, i8) | 0;
+ }
+ i11 = i11 + 4 | 0;
+ } else {
+ i11 = i23;
+ }
+ if ((i12 | 0) == (HEAP32[i16 >> 2] | 0)) {
+ i25 = 0;
+ } else {
+ i25 = HEAP8[i20] | 0;
+ }
+ i24 = i25 & 255;
+ i21 = i11 + -1 | 0;
+ i26 = (HEAP8[i23] | 0) == 94;
+ i28 = i26 ? i23 : i22;
+ i27 = i26 & 1;
+ i26 = i27 ^ 1;
+ i30 = i28 + 1 | 0;
+ L41 : do {
+ if (i30 >>> 0 < i21 >>> 0) {
+ while (1) {
+ i32 = HEAP8[i30] | 0;
+ i29 = i28 + 2 | 0;
+ i31 = HEAP8[i29] | 0;
+ do {
+ if (i32 << 24 >> 24 == 37) {
+ if ((_match_class(i24, i31 & 255) | 0) == 0) {
+ i28 = i29;
+ } else {
+ break L41;
+ }
+ } else {
+ if (i31 << 24 >> 24 == 45 ? (i18 = i28 + 3 | 0, i18 >>> 0 < i21 >>> 0) : 0) {
+ if ((i32 & 255) > (i25 & 255)) {
+ i28 = i18;
+ break;
+ }
+ if ((HEAPU8[i18] | 0) < (i25 & 255)) {
+ i28 = i18;
+ break;
+ } else {
+ break L41;
+ }
+ }
+ if (i32 << 24 >> 24 == i25 << 24 >> 24) {
+ break L41;
+ } else {
+ i28 = i30;
+ }
+ }
+ } while (0);
+ i30 = i28 + 1 | 0;
+ if (!(i30 >>> 0 < i21 >>> 0)) {
+ i26 = i27;
+ break;
+ }
+ }
+ } else {
+ i26 = i27;
+ }
+ } while (0);
+ if ((i26 | 0) != 0) {
+ i12 = 0;
+ break L4;
+ }
+ i24 = HEAP8[i12] | 0;
+ i25 = i24 & 255;
+ i27 = (HEAP8[i23] | 0) == 94;
+ i26 = i27 ? i23 : i22;
+ i22 = i27 & 1;
+ i23 = i22 ^ 1;
+ i30 = i26 + 1 | 0;
+ L55 : do {
+ if (i30 >>> 0 < i21 >>> 0) {
+ do {
+ i29 = HEAP8[i30] | 0;
+ i28 = i26 + 2 | 0;
+ i27 = HEAP8[i28] | 0;
+ do {
+ if (i29 << 24 >> 24 == 37) {
+ if ((_match_class(i25, i27 & 255) | 0) == 0) {
+ i26 = i28;
+ } else {
+ i22 = i23;
+ break L55;
+ }
+ } else {
+ if (i27 << 24 >> 24 == 45 ? (i17 = i26 + 3 | 0, i17 >>> 0 < i21 >>> 0) : 0) {
+ if ((i29 & 255) > (i24 & 255)) {
+ i26 = i17;
+ break;
+ }
+ if ((HEAPU8[i17] | 0) < (i24 & 255)) {
+ i26 = i17;
+ break;
+ } else {
+ i22 = i23;
+ break L55;
+ }
+ }
+ if (i29 << 24 >> 24 == i24 << 24 >> 24) {
+ i22 = i23;
+ break L55;
+ } else {
+ i26 = i30;
+ }
+ }
+ } while (0);
+ i30 = i26 + 1 | 0;
+ } while (i30 >>> 0 < i21 >>> 0);
+ }
+ } while (0);
+ if ((i22 | 0) == 0) {
+ i12 = 0;
+ break L4;
+ }
+ } else if ((i21 | 0) == 40) {
+ i7 = 7;
+ break L6;
+ } else if ((i21 | 0) != 41) {
+ i21 = i11 + 1 | 0;
+ if (i23 << 24 >> 24 == 91) {
+ i7 = (HEAP8[i21] | 0) == 94 ? i11 + 2 | 0 : i21;
+ while (1) {
+ if ((i7 | 0) == (i22 | 0)) {
+ _luaL_error(HEAP32[i9 >> 2] | 0, 7408, i8) | 0;
+ }
+ i22 = i7 + 1 | 0;
+ if ((HEAP8[i7] | 0) == 37) {
+ i7 = i22 >>> 0 < (HEAP32[i14 >> 2] | 0) >>> 0 ? i7 + 2 | 0 : i22;
+ } else {
+ i7 = i22;
+ }
+ if ((HEAP8[i7] | 0) == 93) {
+ break;
+ }
+ i22 = HEAP32[i14 >> 2] | 0;
+ }
+ i22 = i7 + 1 | 0;
+ i7 = 89;
+ } else {
+ i22 = i21;
+ i7 = 89;
+ }
+ } else {
+ i7 = 16;
+ break L6;
+ }
+ } while (0);
+ L80 : do {
+ if ((i7 | 0) == 89) {
+ i7 = 0;
+ do {
+ if ((HEAP32[i3 >> 2] | 0) >>> 0 > i12 >>> 0) {
+ i23 = HEAP8[i12] | 0;
+ i24 = i23 & 255;
+ i26 = HEAP8[i11] | 0;
+ i25 = i26 << 24 >> 24;
+ L85 : do {
+ if ((i25 | 0) == 46) {
+ i23 = HEAP8[i22] | 0;
+ } else if ((i25 | 0) == 37) {
+ i25 = _match_class(i24, HEAPU8[i21] | 0) | 0;
+ i7 = 104;
+ } else if ((i25 | 0) == 91) {
+ i7 = i22 + -1 | 0;
+ i25 = (HEAP8[i21] | 0) == 94;
+ i27 = i25 ? i21 : i11;
+ i26 = i25 & 1;
+ i25 = i26 ^ 1;
+ i30 = i27 + 1 | 0;
+ if (i30 >>> 0 < i7 >>> 0) {
+ while (1) {
+ i31 = HEAP8[i30] | 0;
+ i29 = i27 + 2 | 0;
+ i28 = HEAP8[i29] | 0;
+ do {
+ if (i31 << 24 >> 24 == 37) {
+ if ((_match_class(i24, i28 & 255) | 0) == 0) {
+ i27 = i29;
+ } else {
+ i7 = 104;
+ break L85;
+ }
+ } else {
+ if (i28 << 24 >> 24 == 45 ? (i13 = i27 + 3 | 0, i13 >>> 0 < i7 >>> 0) : 0) {
+ if ((i31 & 255) > (i23 & 255)) {
+ i27 = i13;
+ break;
+ }
+ if ((HEAPU8[i13] | 0) < (i23 & 255)) {
+ i27 = i13;
+ break;
+ } else {
+ i7 = 104;
+ break L85;
+ }
+ }
+ if (i31 << 24 >> 24 == i23 << 24 >> 24) {
+ i7 = 104;
+ break L85;
+ } else {
+ i27 = i30;
+ }
+ }
+ } while (0);
+ i30 = i27 + 1 | 0;
+ if (!(i30 >>> 0 < i7 >>> 0)) {
+ i25 = i26;
+ i7 = 104;
+ break;
+ }
+ }
+ } else {
+ i25 = i26;
+ i7 = 104;
+ }
+ } else {
+ i25 = i26 << 24 >> 24 == i23 << 24 >> 24 | 0;
+ i7 = 104;
+ }
+ } while (0);
+ if ((i7 | 0) == 104) {
+ i7 = 0;
+ i23 = HEAP8[i22] | 0;
+ if ((i25 | 0) == 0) {
+ break;
+ }
+ }
+ i23 = i23 << 24 >> 24;
+ if ((i23 | 0) == 45) {
+ i7 = 109;
+ break L6;
+ } else if ((i23 | 0) == 42) {
+ i7 = 112;
+ break L6;
+ } else if ((i23 | 0) == 43) {
+ break L6;
+ } else if ((i23 | 0) != 63) {
+ i12 = i19;
+ i11 = i22;
+ break L8;
+ }
+ i11 = i22 + 1 | 0;
+ i21 = _match(i1, i19, i11) | 0;
+ if ((i21 | 0) == 0) {
+ break L80;
+ } else {
+ i12 = i21;
+ break L4;
+ }
+ } else {
+ i23 = HEAP8[i22] | 0;
+ }
+ } while (0);
+ if (!(i23 << 24 >> 24 == 45 | i23 << 24 >> 24 == 63 | i23 << 24 >> 24 == 42)) {
+ i12 = 0;
+ break L4;
+ }
+ i11 = i22 + 1 | 0;
+ }
+ } while (0);
+ i22 = HEAP32[i14 >> 2] | 0;
+ if ((i11 | 0) == (i22 | 0)) {
+ break L4;
+ }
+ }
+ if ((i7 | 0) == 25) {
+ i7 = 0;
+ i21 = i11 + 2 | 0;
+ if (!((i22 + -1 | 0) >>> 0 > i21 >>> 0)) {
+ _luaL_error(HEAP32[i9 >> 2] | 0, 7440, i8) | 0;
+ }
+ i20 = HEAP8[i12] | 0;
+ if (!(i20 << 24 >> 24 == (HEAP8[i21] | 0))) {
+ i12 = 0;
+ break L4;
+ }
+ i21 = HEAP8[i11 + 3 | 0] | 0;
+ i22 = HEAP32[i3 >> 2] | 0;
+ if (i19 >>> 0 < i22 >>> 0) {
+ i24 = 1;
+ } else {
+ i12 = 0;
+ break L4;
+ }
+ while (1) {
+ i23 = HEAP8[i19] | 0;
+ if (i23 << 24 >> 24 == i21 << 24 >> 24) {
+ i24 = i24 + -1 | 0;
+ if ((i24 | 0) == 0) {
+ break;
+ }
+ } else {
+ i24 = (i23 << 24 >> 24 == i20 << 24 >> 24) + i24 | 0;
+ }
+ i12 = i19 + 1 | 0;
+ if (i12 >>> 0 < i22 >>> 0) {
+ i32 = i19;
+ i19 = i12;
+ i12 = i32;
+ } else {
+ i12 = 0;
+ break L4;
+ }
+ }
+ i12 = i12 + 2 | 0;
+ i11 = i11 + 4 | 0;
+ } else if ((i7 | 0) == 69) {
+ i7 = 0;
+ i20 = i23 & 255;
+ i19 = i20 + -49 | 0;
+ if (((i19 | 0) >= 0 ? (i19 | 0) < (HEAP32[i10 >> 2] | 0) : 0) ? (i15 = HEAP32[i1 + (i19 << 3) + 28 >> 2] | 0, !((i15 | 0) == -1)) : 0) {
+ i20 = i15;
+ } else {
+ i19 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i8 >> 2] = i20 + -48;
+ i20 = _luaL_error(i19, 7336, i8) | 0;
+ i19 = i20;
+ i20 = HEAP32[i1 + (i20 << 3) + 28 >> 2] | 0;
+ }
+ if (((HEAP32[i3 >> 2] | 0) - i12 | 0) >>> 0 < i20 >>> 0) {
+ i12 = 0;
+ break L4;
+ }
+ if ((_memcmp(HEAP32[i1 + (i19 << 3) + 24 >> 2] | 0, i12, i20) | 0) != 0) {
+ i12 = 0;
+ break L4;
+ }
+ i12 = i12 + i20 | 0;
+ if ((i12 | 0) == 0) {
+ i12 = 0;
+ break L4;
+ }
+ i11 = i11 + 2 | 0;
+ }
+ i22 = HEAP32[i14 >> 2] | 0;
+ if ((i11 | 0) == (i22 | 0)) {
+ break L4;
+ }
+ }
+ if ((i7 | 0) == 7) {
+ i3 = i11 + 1 | 0;
+ if ((HEAP8[i3] | 0) == 41) {
+ i3 = HEAP32[i10 >> 2] | 0;
+ if ((i3 | 0) > 31) {
+ _luaL_error(HEAP32[i9 >> 2] | 0, 7200, i8) | 0;
+ }
+ HEAP32[i1 + (i3 << 3) + 24 >> 2] = i12;
+ HEAP32[i1 + (i3 << 3) + 28 >> 2] = -2;
+ HEAP32[i10 >> 2] = i3 + 1;
+ i12 = _match(i1, i12, i11 + 2 | 0) | 0;
+ if ((i12 | 0) != 0) {
+ break;
+ }
+ HEAP32[i10 >> 2] = (HEAP32[i10 >> 2] | 0) + -1;
+ i12 = 0;
+ break;
+ } else {
+ i4 = HEAP32[i10 >> 2] | 0;
+ if ((i4 | 0) > 31) {
+ _luaL_error(HEAP32[i9 >> 2] | 0, 7200, i8) | 0;
+ }
+ HEAP32[i1 + (i4 << 3) + 24 >> 2] = i12;
+ HEAP32[i1 + (i4 << 3) + 28 >> 2] = -1;
+ HEAP32[i10 >> 2] = i4 + 1;
+ i12 = _match(i1, i12, i3) | 0;
+ if ((i12 | 0) != 0) {
+ break;
+ }
+ HEAP32[i10 >> 2] = (HEAP32[i10 >> 2] | 0) + -1;
+ i12 = 0;
+ break;
+ }
+ } else if ((i7 | 0) == 16) {
+ i3 = i11 + 1 | 0;
+ i5 = HEAP32[i10 >> 2] | 0;
+ while (1) {
+ i4 = i5 + -1 | 0;
+ if ((i5 | 0) <= 0) {
+ i7 = 19;
+ break;
+ }
+ if ((HEAP32[i1 + (i4 << 3) + 28 >> 2] | 0) == -1) {
+ break;
+ } else {
+ i5 = i4;
+ }
+ }
+ if ((i7 | 0) == 19) {
+ i4 = _luaL_error(HEAP32[i9 >> 2] | 0, 7488, i8) | 0;
+ }
+ i5 = i1 + (i4 << 3) + 28 | 0;
+ HEAP32[i5 >> 2] = i12 - (HEAP32[i1 + (i4 << 3) + 24 >> 2] | 0);
+ i12 = _match(i1, i12, i3) | 0;
+ if ((i12 | 0) != 0) {
+ break;
+ }
+ HEAP32[i5 >> 2] = -1;
+ i12 = 0;
+ break;
+ } else if ((i7 | 0) == 23) {
+ i12 = (i12 | 0) == (HEAP32[i3 >> 2] | 0) ? i12 : 0;
+ break;
+ } else if ((i7 | 0) == 109) {
+ i4 = i22 + 1 | 0;
+ i8 = _match(i1, i12, i4) | 0;
+ if ((i8 | 0) != 0) {
+ i12 = i8;
+ break;
+ }
+ i8 = i22 + -1 | 0;
+ while (1) {
+ if (!((HEAP32[i3 >> 2] | 0) >>> 0 > i12 >>> 0)) {
+ i12 = 0;
+ break L4;
+ }
+ i9 = HEAP8[i12] | 0;
+ i10 = i9 & 255;
+ i14 = HEAP8[i11] | 0;
+ i13 = i14 << 24 >> 24;
+ L139 : do {
+ if ((i13 | 0) == 91) {
+ i6 = (HEAP8[i21] | 0) == 94;
+ i13 = i6 ? i21 : i11;
+ i6 = i6 & 1;
+ i7 = i6 ^ 1;
+ i14 = i13 + 1 | 0;
+ if (i14 >>> 0 < i8 >>> 0) {
+ while (1) {
+ i17 = HEAP8[i14] | 0;
+ i15 = i13 + 2 | 0;
+ i16 = HEAP8[i15] | 0;
+ do {
+ if (i17 << 24 >> 24 == 37) {
+ if ((_match_class(i10, i16 & 255) | 0) == 0) {
+ i13 = i15;
+ } else {
+ i6 = i7;
+ i7 = 147;
+ break L139;
+ }
+ } else {
+ if (i16 << 24 >> 24 == 45 ? (i5 = i13 + 3 | 0, i5 >>> 0 < i8 >>> 0) : 0) {
+ if ((i17 & 255) > (i9 & 255)) {
+ i13 = i5;
+ break;
+ }
+ if ((HEAPU8[i5] | 0) < (i9 & 255)) {
+ i13 = i5;
+ break;
+ } else {
+ i6 = i7;
+ i7 = 147;
+ break L139;
+ }
+ }
+ if (i17 << 24 >> 24 == i9 << 24 >> 24) {
+ i6 = i7;
+ i7 = 147;
+ break L139;
+ } else {
+ i13 = i14;
+ }
+ }
+ } while (0);
+ i14 = i13 + 1 | 0;
+ if (!(i14 >>> 0 < i8 >>> 0)) {
+ i7 = 147;
+ break;
+ }
+ }
+ } else {
+ i7 = 147;
+ }
+ } else if ((i13 | 0) == 37) {
+ i6 = _match_class(i10, HEAPU8[i21] | 0) | 0;
+ i7 = 147;
+ } else if ((i13 | 0) != 46) {
+ i6 = i14 << 24 >> 24 == i9 << 24 >> 24 | 0;
+ i7 = 147;
+ }
+ } while (0);
+ if ((i7 | 0) == 147 ? (i7 = 0, (i6 | 0) == 0) : 0) {
+ i12 = 0;
+ break L4;
+ }
+ i9 = i12 + 1 | 0;
+ i12 = _match(i1, i9, i4) | 0;
+ if ((i12 | 0) == 0) {
+ i12 = i9;
+ } else {
+ break L4;
+ }
+ }
+ } else if ((i7 | 0) == 112) {
+ i19 = i12;
+ }
+ i10 = HEAP32[i3 >> 2] | 0;
+ if (i10 >>> 0 > i19 >>> 0) {
+ i5 = i22 + -1 | 0;
+ i8 = i19;
+ i6 = 0;
+ do {
+ i8 = HEAP8[i8] | 0;
+ i9 = i8 & 255;
+ i13 = HEAP8[i11] | 0;
+ i12 = i13 << 24 >> 24;
+ L183 : do {
+ if ((i12 | 0) == 37) {
+ i10 = _match_class(i9, HEAPU8[i21] | 0) | 0;
+ i7 = 129;
+ } else if ((i12 | 0) == 91) {
+ i7 = (HEAP8[i21] | 0) == 94;
+ i12 = i7 ? i21 : i11;
+ i10 = i7 & 1;
+ i7 = i10 ^ 1;
+ i13 = i12 + 1 | 0;
+ if (i13 >>> 0 < i5 >>> 0) {
+ while (1) {
+ i14 = HEAP8[i13] | 0;
+ i16 = i12 + 2 | 0;
+ i15 = HEAP8[i16] | 0;
+ do {
+ if (i14 << 24 >> 24 == 37) {
+ if ((_match_class(i9, i15 & 255) | 0) == 0) {
+ i12 = i16;
+ } else {
+ i10 = i7;
+ i7 = 129;
+ break L183;
+ }
+ } else {
+ if (i15 << 24 >> 24 == 45 ? (i4 = i12 + 3 | 0, i4 >>> 0 < i5 >>> 0) : 0) {
+ if ((i14 & 255) > (i8 & 255)) {
+ i12 = i4;
+ break;
+ }
+ if ((HEAPU8[i4] | 0) < (i8 & 255)) {
+ i12 = i4;
+ break;
+ } else {
+ i10 = i7;
+ i7 = 129;
+ break L183;
+ }
+ }
+ if (i14 << 24 >> 24 == i8 << 24 >> 24) {
+ i10 = i7;
+ i7 = 129;
+ break L183;
+ } else {
+ i12 = i13;
+ }
+ }
+ } while (0);
+ i13 = i12 + 1 | 0;
+ if (!(i13 >>> 0 < i5 >>> 0)) {
+ i7 = 129;
+ break;
+ }
+ }
+ } else {
+ i7 = 129;
+ }
+ } else if ((i12 | 0) != 46) {
+ i10 = i13 << 24 >> 24 == i8 << 24 >> 24 | 0;
+ i7 = 129;
+ }
+ } while (0);
+ if ((i7 | 0) == 129) {
+ i7 = 0;
+ if ((i10 | 0) == 0) {
+ break;
+ }
+ i10 = HEAP32[i3 >> 2] | 0;
+ }
+ i6 = i6 + 1 | 0;
+ i8 = i19 + i6 | 0;
+ } while (i10 >>> 0 > i8 >>> 0);
+ if (!((i6 | 0) > -1)) {
+ i12 = 0;
+ break;
+ }
+ } else {
+ i6 = 0;
+ }
+ i3 = i22 + 1 | 0;
+ while (1) {
+ i12 = _match(i1, i19 + i6 | 0, i3) | 0;
+ if ((i12 | 0) != 0) {
+ break L4;
+ }
+ if ((i6 | 0) > 0) {
+ i6 = i6 + -1 | 0;
+ } else {
+ i12 = 0;
+ break;
+ }
+ }
+ }
+ } while (0);
+ HEAP32[i1 >> 2] = (HEAP32[i1 >> 2] | 0) + 1;
+ STACKTOP = i2;
+ return i12 | 0;
+}
+function _free(i7) {
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0;
+ i1 = STACKTOP;
+ if ((i7 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i15 = i7 + -8 | 0;
+ i16 = HEAP32[12928 >> 2] | 0;
+ if (i15 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i13 = HEAP32[i7 + -4 >> 2] | 0;
+ i12 = i13 & 3;
+ if ((i12 | 0) == 1) {
+ _abort();
+ }
+ i8 = i13 & -8;
+ i6 = i7 + (i8 + -8) | 0;
+ do {
+ if ((i13 & 1 | 0) == 0) {
+ i19 = HEAP32[i15 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i15 = -8 - i19 | 0;
+ i13 = i7 + i15 | 0;
+ i12 = i19 + i8 | 0;
+ if (i13 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ if ((i13 | 0) == (HEAP32[12932 >> 2] | 0)) {
+ i2 = i7 + (i8 + -4) | 0;
+ if ((HEAP32[i2 >> 2] & 3 | 0) != 3) {
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ HEAP32[12920 >> 2] = i12;
+ HEAP32[i2 >> 2] = HEAP32[i2 >> 2] & -2;
+ HEAP32[i7 + (i15 + 4) >> 2] = i12 | 1;
+ HEAP32[i6 >> 2] = i12;
+ STACKTOP = i1;
+ return;
+ }
+ i18 = i19 >>> 3;
+ if (i19 >>> 0 < 256) {
+ i2 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
+ i11 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
+ i14 = 12952 + (i18 << 1 << 2) | 0;
+ if ((i2 | 0) != (i14 | 0)) {
+ if (i2 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i2 + 12 >> 2] | 0) != (i13 | 0)) {
+ _abort();
+ }
+ }
+ if ((i11 | 0) == (i2 | 0)) {
+ HEAP32[3228] = HEAP32[3228] & ~(1 << i18);
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ if ((i11 | 0) != (i14 | 0)) {
+ if (i11 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i14 = i11 + 8 | 0;
+ if ((HEAP32[i14 >> 2] | 0) == (i13 | 0)) {
+ i17 = i14;
+ } else {
+ _abort();
+ }
+ } else {
+ i17 = i11 + 8 | 0;
+ }
+ HEAP32[i2 + 12 >> 2] = i11;
+ HEAP32[i17 >> 2] = i2;
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ i17 = HEAP32[i7 + (i15 + 24) >> 2] | 0;
+ i18 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
+ do {
+ if ((i18 | 0) == (i13 | 0)) {
+ i19 = i7 + (i15 + 20) | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ i19 = i7 + (i15 + 16) | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ i14 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i21 = i18 + 20 | 0;
+ i20 = HEAP32[i21 >> 2] | 0;
+ if ((i20 | 0) != 0) {
+ i18 = i20;
+ i19 = i21;
+ continue;
+ }
+ i20 = i18 + 16 | 0;
+ i21 = HEAP32[i20 >> 2] | 0;
+ if ((i21 | 0) == 0) {
+ break;
+ } else {
+ i18 = i21;
+ i19 = i20;
+ }
+ }
+ if (i19 >>> 0 < i16 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i19 >> 2] = 0;
+ i14 = i18;
+ break;
+ }
+ } else {
+ i19 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
+ if (i19 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i16 = i19 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != (i13 | 0)) {
+ _abort();
+ }
+ i20 = i18 + 8 | 0;
+ if ((HEAP32[i20 >> 2] | 0) == (i13 | 0)) {
+ HEAP32[i16 >> 2] = i18;
+ HEAP32[i20 >> 2] = i19;
+ i14 = i18;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i17 | 0) != 0) {
+ i18 = HEAP32[i7 + (i15 + 28) >> 2] | 0;
+ i16 = 13216 + (i18 << 2) | 0;
+ if ((i13 | 0) == (HEAP32[i16 >> 2] | 0)) {
+ HEAP32[i16 >> 2] = i14;
+ if ((i14 | 0) == 0) {
+ HEAP32[12916 >> 2] = HEAP32[12916 >> 2] & ~(1 << i18);
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ } else {
+ if (i17 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i17 + 16 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i13 | 0)) {
+ HEAP32[i16 >> 2] = i14;
+ } else {
+ HEAP32[i17 + 20 >> 2] = i14;
+ }
+ if ((i14 | 0) == 0) {
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ }
+ if (i14 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i14 + 24 >> 2] = i17;
+ i16 = HEAP32[i7 + (i15 + 16) >> 2] | 0;
+ do {
+ if ((i16 | 0) != 0) {
+ if (i16 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i14 + 16 >> 2] = i16;
+ HEAP32[i16 + 24 >> 2] = i14;
+ break;
+ }
+ }
+ } while (0);
+ i15 = HEAP32[i7 + (i15 + 20) >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ if (i15 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i14 + 20 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i14;
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ } else {
+ i2 = i13;
+ i11 = i12;
+ }
+ } else {
+ i2 = i13;
+ i11 = i12;
+ }
+ } else {
+ i2 = i15;
+ i11 = i8;
+ }
+ } while (0);
+ if (!(i2 >>> 0 < i6 >>> 0)) {
+ _abort();
+ }
+ i12 = i7 + (i8 + -4) | 0;
+ i13 = HEAP32[i12 >> 2] | 0;
+ if ((i13 & 1 | 0) == 0) {
+ _abort();
+ }
+ if ((i13 & 2 | 0) == 0) {
+ if ((i6 | 0) == (HEAP32[12936 >> 2] | 0)) {
+ i21 = (HEAP32[12924 >> 2] | 0) + i11 | 0;
+ HEAP32[12924 >> 2] = i21;
+ HEAP32[12936 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i21 | 1;
+ if ((i2 | 0) != (HEAP32[12932 >> 2] | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[12932 >> 2] = 0;
+ HEAP32[12920 >> 2] = 0;
+ STACKTOP = i1;
+ return;
+ }
+ if ((i6 | 0) == (HEAP32[12932 >> 2] | 0)) {
+ i21 = (HEAP32[12920 >> 2] | 0) + i11 | 0;
+ HEAP32[12920 >> 2] = i21;
+ HEAP32[12932 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i21 | 1;
+ HEAP32[i2 + i21 >> 2] = i21;
+ STACKTOP = i1;
+ return;
+ }
+ i11 = (i13 & -8) + i11 | 0;
+ i12 = i13 >>> 3;
+ do {
+ if (!(i13 >>> 0 < 256)) {
+ i10 = HEAP32[i7 + (i8 + 16) >> 2] | 0;
+ i15 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
+ do {
+ if ((i15 | 0) == (i6 | 0)) {
+ i13 = i7 + (i8 + 12) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i13 = i7 + (i8 + 8) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i9 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i14 = i12 + 20 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ i12 = i15;
+ i13 = i14;
+ continue;
+ }
+ i14 = i12 + 16 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) == 0) {
+ break;
+ } else {
+ i12 = i15;
+ i13 = i14;
+ }
+ }
+ if (i13 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i13 >> 2] = 0;
+ i9 = i12;
+ break;
+ }
+ } else {
+ i13 = HEAP32[i7 + i8 >> 2] | 0;
+ if (i13 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i14 = i13 + 12 | 0;
+ if ((HEAP32[i14 >> 2] | 0) != (i6 | 0)) {
+ _abort();
+ }
+ i12 = i15 + 8 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i14 >> 2] = i15;
+ HEAP32[i12 >> 2] = i13;
+ i9 = i15;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i10 | 0) != 0) {
+ i12 = HEAP32[i7 + (i8 + 20) >> 2] | 0;
+ i13 = 13216 + (i12 << 2) | 0;
+ if ((i6 | 0) == (HEAP32[i13 >> 2] | 0)) {
+ HEAP32[i13 >> 2] = i9;
+ if ((i9 | 0) == 0) {
+ HEAP32[12916 >> 2] = HEAP32[12916 >> 2] & ~(1 << i12);
+ break;
+ }
+ } else {
+ if (i10 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i12 = i10 + 16 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i12 >> 2] = i9;
+ } else {
+ HEAP32[i10 + 20 >> 2] = i9;
+ }
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ }
+ if (i9 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i9 + 24 >> 2] = i10;
+ i6 = HEAP32[i7 + (i8 + 8) >> 2] | 0;
+ do {
+ if ((i6 | 0) != 0) {
+ if (i6 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 16 >> 2] = i6;
+ HEAP32[i6 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ } while (0);
+ i6 = HEAP32[i7 + (i8 + 12) >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ if (i6 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 20 >> 2] = i6;
+ HEAP32[i6 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ }
+ } else {
+ i9 = HEAP32[i7 + i8 >> 2] | 0;
+ i7 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
+ i8 = 12952 + (i12 << 1 << 2) | 0;
+ if ((i9 | 0) != (i8 | 0)) {
+ if (i9 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i9 + 12 >> 2] | 0) != (i6 | 0)) {
+ _abort();
+ }
+ }
+ if ((i7 | 0) == (i9 | 0)) {
+ HEAP32[3228] = HEAP32[3228] & ~(1 << i12);
+ break;
+ }
+ if ((i7 | 0) != (i8 | 0)) {
+ if (i7 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i7 + 8 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i6 | 0)) {
+ i10 = i8;
+ } else {
+ _abort();
+ }
+ } else {
+ i10 = i7 + 8 | 0;
+ }
+ HEAP32[i9 + 12 >> 2] = i7;
+ HEAP32[i10 >> 2] = i9;
+ }
+ } while (0);
+ HEAP32[i2 + 4 >> 2] = i11 | 1;
+ HEAP32[i2 + i11 >> 2] = i11;
+ if ((i2 | 0) == (HEAP32[12932 >> 2] | 0)) {
+ HEAP32[12920 >> 2] = i11;
+ STACKTOP = i1;
+ return;
+ }
+ } else {
+ HEAP32[i12 >> 2] = i13 & -2;
+ HEAP32[i2 + 4 >> 2] = i11 | 1;
+ HEAP32[i2 + i11 >> 2] = i11;
+ }
+ i6 = i11 >>> 3;
+ if (i11 >>> 0 < 256) {
+ i7 = i6 << 1;
+ i3 = 12952 + (i7 << 2) | 0;
+ i8 = HEAP32[3228] | 0;
+ i6 = 1 << i6;
+ if ((i8 & i6 | 0) != 0) {
+ i6 = 12952 + (i7 + 2 << 2) | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ if (i7 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i4 = i6;
+ i5 = i7;
+ }
+ } else {
+ HEAP32[3228] = i8 | i6;
+ i4 = 12952 + (i7 + 2 << 2) | 0;
+ i5 = i3;
+ }
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i5 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i5;
+ HEAP32[i2 + 12 >> 2] = i3;
+ STACKTOP = i1;
+ return;
+ }
+ i4 = i11 >>> 8;
+ if ((i4 | 0) != 0) {
+ if (i11 >>> 0 > 16777215) {
+ i4 = 31;
+ } else {
+ i20 = (i4 + 1048320 | 0) >>> 16 & 8;
+ i21 = i4 << i20;
+ i19 = (i21 + 520192 | 0) >>> 16 & 4;
+ i21 = i21 << i19;
+ i4 = (i21 + 245760 | 0) >>> 16 & 2;
+ i4 = 14 - (i19 | i20 | i4) + (i21 << i4 >>> 15) | 0;
+ i4 = i11 >>> (i4 + 7 | 0) & 1 | i4 << 1;
+ }
+ } else {
+ i4 = 0;
+ }
+ i5 = 13216 + (i4 << 2) | 0;
+ HEAP32[i2 + 28 >> 2] = i4;
+ HEAP32[i2 + 20 >> 2] = 0;
+ HEAP32[i2 + 16 >> 2] = 0;
+ i7 = HEAP32[12916 >> 2] | 0;
+ i6 = 1 << i4;
+ L199 : do {
+ if ((i7 & i6 | 0) != 0) {
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((i4 | 0) == 31) {
+ i4 = 0;
+ } else {
+ i4 = 25 - (i4 >>> 1) | 0;
+ }
+ L204 : do {
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) != (i11 | 0)) {
+ i4 = i11 << i4;
+ i7 = i5;
+ while (1) {
+ i6 = i7 + (i4 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i11 | 0)) {
+ i3 = i5;
+ break L204;
+ } else {
+ i4 = i4 << 1;
+ i7 = i5;
+ }
+ }
+ if (i6 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i7;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ break L199;
+ }
+ } else {
+ i3 = i5;
+ }
+ } while (0);
+ i5 = i3 + 8 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i6 = HEAP32[12928 >> 2] | 0;
+ if (i3 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ if (i4 >>> 0 < i6 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i4 + 12 >> 2] = i2;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i4;
+ HEAP32[i2 + 12 >> 2] = i3;
+ HEAP32[i2 + 24 >> 2] = 0;
+ break;
+ }
+ } else {
+ HEAP32[12916 >> 2] = i7 | i6;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i5;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ }
+ } while (0);
+ i21 = (HEAP32[12944 >> 2] | 0) + -1 | 0;
+ HEAP32[12944 >> 2] = i21;
+ if ((i21 | 0) == 0) {
+ i2 = 13368 | 0;
+ } else {
+ STACKTOP = i1;
+ return;
+ }
+ while (1) {
+ i2 = HEAP32[i2 >> 2] | 0;
+ if ((i2 | 0) == 0) {
+ break;
+ } else {
+ i2 = i2 + 8 | 0;
+ }
+ }
+ HEAP32[12944 >> 2] = -1;
+ STACKTOP = i1;
+ return;
+}
+function _dispose_chunk(i6, i7) {
+ i6 = i6 | 0;
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0;
+ i1 = STACKTOP;
+ i5 = i6 + i7 | 0;
+ i10 = HEAP32[i6 + 4 >> 2] | 0;
+ do {
+ if ((i10 & 1 | 0) == 0) {
+ i14 = HEAP32[i6 >> 2] | 0;
+ if ((i10 & 3 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i10 = i6 + (0 - i14) | 0;
+ i11 = i14 + i7 | 0;
+ i15 = HEAP32[12928 >> 2] | 0;
+ if (i10 >>> 0 < i15 >>> 0) {
+ _abort();
+ }
+ if ((i10 | 0) == (HEAP32[12932 >> 2] | 0)) {
+ i2 = i6 + (i7 + 4) | 0;
+ if ((HEAP32[i2 >> 2] & 3 | 0) != 3) {
+ i2 = i10;
+ i12 = i11;
+ break;
+ }
+ HEAP32[12920 >> 2] = i11;
+ HEAP32[i2 >> 2] = HEAP32[i2 >> 2] & -2;
+ HEAP32[i6 + (4 - i14) >> 2] = i11 | 1;
+ HEAP32[i5 >> 2] = i11;
+ STACKTOP = i1;
+ return;
+ }
+ i17 = i14 >>> 3;
+ if (i14 >>> 0 < 256) {
+ i2 = HEAP32[i6 + (8 - i14) >> 2] | 0;
+ i12 = HEAP32[i6 + (12 - i14) >> 2] | 0;
+ i13 = 12952 + (i17 << 1 << 2) | 0;
+ if ((i2 | 0) != (i13 | 0)) {
+ if (i2 >>> 0 < i15 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i2 + 12 >> 2] | 0) != (i10 | 0)) {
+ _abort();
+ }
+ }
+ if ((i12 | 0) == (i2 | 0)) {
+ HEAP32[3228] = HEAP32[3228] & ~(1 << i17);
+ i2 = i10;
+ i12 = i11;
+ break;
+ }
+ if ((i12 | 0) != (i13 | 0)) {
+ if (i12 >>> 0 < i15 >>> 0) {
+ _abort();
+ }
+ i13 = i12 + 8 | 0;
+ if ((HEAP32[i13 >> 2] | 0) == (i10 | 0)) {
+ i16 = i13;
+ } else {
+ _abort();
+ }
+ } else {
+ i16 = i12 + 8 | 0;
+ }
+ HEAP32[i2 + 12 >> 2] = i12;
+ HEAP32[i16 >> 2] = i2;
+ i2 = i10;
+ i12 = i11;
+ break;
+ }
+ i16 = HEAP32[i6 + (24 - i14) >> 2] | 0;
+ i18 = HEAP32[i6 + (12 - i14) >> 2] | 0;
+ do {
+ if ((i18 | 0) == (i10 | 0)) {
+ i19 = 16 - i14 | 0;
+ i18 = i6 + (i19 + 4) | 0;
+ i17 = HEAP32[i18 >> 2] | 0;
+ if ((i17 | 0) == 0) {
+ i18 = i6 + i19 | 0;
+ i17 = HEAP32[i18 >> 2] | 0;
+ if ((i17 | 0) == 0) {
+ i13 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i19 = i17 + 20 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i20 | 0) != 0) {
+ i17 = i20;
+ i18 = i19;
+ continue;
+ }
+ i20 = i17 + 16 | 0;
+ i19 = HEAP32[i20 >> 2] | 0;
+ if ((i19 | 0) == 0) {
+ break;
+ } else {
+ i17 = i19;
+ i18 = i20;
+ }
+ }
+ if (i18 >>> 0 < i15 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i18 >> 2] = 0;
+ i13 = i17;
+ break;
+ }
+ } else {
+ i17 = HEAP32[i6 + (8 - i14) >> 2] | 0;
+ if (i17 >>> 0 < i15 >>> 0) {
+ _abort();
+ }
+ i19 = i17 + 12 | 0;
+ if ((HEAP32[i19 >> 2] | 0) != (i10 | 0)) {
+ _abort();
+ }
+ i15 = i18 + 8 | 0;
+ if ((HEAP32[i15 >> 2] | 0) == (i10 | 0)) {
+ HEAP32[i19 >> 2] = i18;
+ HEAP32[i15 >> 2] = i17;
+ i13 = i18;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i16 | 0) != 0) {
+ i15 = HEAP32[i6 + (28 - i14) >> 2] | 0;
+ i17 = 13216 + (i15 << 2) | 0;
+ if ((i10 | 0) == (HEAP32[i17 >> 2] | 0)) {
+ HEAP32[i17 >> 2] = i13;
+ if ((i13 | 0) == 0) {
+ HEAP32[12916 >> 2] = HEAP32[12916 >> 2] & ~(1 << i15);
+ i2 = i10;
+ i12 = i11;
+ break;
+ }
+ } else {
+ if (i16 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i15 = i16 + 16 | 0;
+ if ((HEAP32[i15 >> 2] | 0) == (i10 | 0)) {
+ HEAP32[i15 >> 2] = i13;
+ } else {
+ HEAP32[i16 + 20 >> 2] = i13;
+ }
+ if ((i13 | 0) == 0) {
+ i2 = i10;
+ i12 = i11;
+ break;
+ }
+ }
+ if (i13 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i13 + 24 >> 2] = i16;
+ i14 = 16 - i14 | 0;
+ i15 = HEAP32[i6 + i14 >> 2] | 0;
+ do {
+ if ((i15 | 0) != 0) {
+ if (i15 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i13 + 16 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i13;
+ break;
+ }
+ }
+ } while (0);
+ i14 = HEAP32[i6 + (i14 + 4) >> 2] | 0;
+ if ((i14 | 0) != 0) {
+ if (i14 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i13 + 20 >> 2] = i14;
+ HEAP32[i14 + 24 >> 2] = i13;
+ i2 = i10;
+ i12 = i11;
+ break;
+ }
+ } else {
+ i2 = i10;
+ i12 = i11;
+ }
+ } else {
+ i2 = i10;
+ i12 = i11;
+ }
+ } else {
+ i2 = i6;
+ i12 = i7;
+ }
+ } while (0);
+ i10 = HEAP32[12928 >> 2] | 0;
+ if (i5 >>> 0 < i10 >>> 0) {
+ _abort();
+ }
+ i11 = i6 + (i7 + 4) | 0;
+ i13 = HEAP32[i11 >> 2] | 0;
+ if ((i13 & 2 | 0) == 0) {
+ if ((i5 | 0) == (HEAP32[12936 >> 2] | 0)) {
+ i20 = (HEAP32[12924 >> 2] | 0) + i12 | 0;
+ HEAP32[12924 >> 2] = i20;
+ HEAP32[12936 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i20 | 1;
+ if ((i2 | 0) != (HEAP32[12932 >> 2] | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[12932 >> 2] = 0;
+ HEAP32[12920 >> 2] = 0;
+ STACKTOP = i1;
+ return;
+ }
+ if ((i5 | 0) == (HEAP32[12932 >> 2] | 0)) {
+ i20 = (HEAP32[12920 >> 2] | 0) + i12 | 0;
+ HEAP32[12920 >> 2] = i20;
+ HEAP32[12932 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i20 | 1;
+ HEAP32[i2 + i20 >> 2] = i20;
+ STACKTOP = i1;
+ return;
+ }
+ i12 = (i13 & -8) + i12 | 0;
+ i11 = i13 >>> 3;
+ do {
+ if (!(i13 >>> 0 < 256)) {
+ i9 = HEAP32[i6 + (i7 + 24) >> 2] | 0;
+ i11 = HEAP32[i6 + (i7 + 12) >> 2] | 0;
+ do {
+ if ((i11 | 0) == (i5 | 0)) {
+ i13 = i6 + (i7 + 20) | 0;
+ i11 = HEAP32[i13 >> 2] | 0;
+ if ((i11 | 0) == 0) {
+ i13 = i6 + (i7 + 16) | 0;
+ i11 = HEAP32[i13 >> 2] | 0;
+ if ((i11 | 0) == 0) {
+ i8 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i15 = i11 + 20 | 0;
+ i14 = HEAP32[i15 >> 2] | 0;
+ if ((i14 | 0) != 0) {
+ i11 = i14;
+ i13 = i15;
+ continue;
+ }
+ i14 = i11 + 16 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) == 0) {
+ break;
+ } else {
+ i11 = i15;
+ i13 = i14;
+ }
+ }
+ if (i13 >>> 0 < i10 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i13 >> 2] = 0;
+ i8 = i11;
+ break;
+ }
+ } else {
+ i13 = HEAP32[i6 + (i7 + 8) >> 2] | 0;
+ if (i13 >>> 0 < i10 >>> 0) {
+ _abort();
+ }
+ i10 = i13 + 12 | 0;
+ if ((HEAP32[i10 >> 2] | 0) != (i5 | 0)) {
+ _abort();
+ }
+ i14 = i11 + 8 | 0;
+ if ((HEAP32[i14 >> 2] | 0) == (i5 | 0)) {
+ HEAP32[i10 >> 2] = i11;
+ HEAP32[i14 >> 2] = i13;
+ i8 = i11;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i9 | 0) != 0) {
+ i10 = HEAP32[i6 + (i7 + 28) >> 2] | 0;
+ i11 = 13216 + (i10 << 2) | 0;
+ if ((i5 | 0) == (HEAP32[i11 >> 2] | 0)) {
+ HEAP32[i11 >> 2] = i8;
+ if ((i8 | 0) == 0) {
+ HEAP32[12916 >> 2] = HEAP32[12916 >> 2] & ~(1 << i10);
+ break;
+ }
+ } else {
+ if (i9 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i10 = i9 + 16 | 0;
+ if ((HEAP32[i10 >> 2] | 0) == (i5 | 0)) {
+ HEAP32[i10 >> 2] = i8;
+ } else {
+ HEAP32[i9 + 20 >> 2] = i8;
+ }
+ if ((i8 | 0) == 0) {
+ break;
+ }
+ }
+ if (i8 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i8 + 24 >> 2] = i9;
+ i5 = HEAP32[i6 + (i7 + 16) >> 2] | 0;
+ do {
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i8 + 16 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i8;
+ break;
+ }
+ }
+ } while (0);
+ i5 = HEAP32[i6 + (i7 + 20) >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i8 + 20 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i8;
+ break;
+ }
+ }
+ }
+ } else {
+ i8 = HEAP32[i6 + (i7 + 8) >> 2] | 0;
+ i6 = HEAP32[i6 + (i7 + 12) >> 2] | 0;
+ i7 = 12952 + (i11 << 1 << 2) | 0;
+ if ((i8 | 0) != (i7 | 0)) {
+ if (i8 >>> 0 < i10 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i8 + 12 >> 2] | 0) != (i5 | 0)) {
+ _abort();
+ }
+ }
+ if ((i6 | 0) == (i8 | 0)) {
+ HEAP32[3228] = HEAP32[3228] & ~(1 << i11);
+ break;
+ }
+ if ((i6 | 0) != (i7 | 0)) {
+ if (i6 >>> 0 < i10 >>> 0) {
+ _abort();
+ }
+ i7 = i6 + 8 | 0;
+ if ((HEAP32[i7 >> 2] | 0) == (i5 | 0)) {
+ i9 = i7;
+ } else {
+ _abort();
+ }
+ } else {
+ i9 = i6 + 8 | 0;
+ }
+ HEAP32[i8 + 12 >> 2] = i6;
+ HEAP32[i9 >> 2] = i8;
+ }
+ } while (0);
+ HEAP32[i2 + 4 >> 2] = i12 | 1;
+ HEAP32[i2 + i12 >> 2] = i12;
+ if ((i2 | 0) == (HEAP32[12932 >> 2] | 0)) {
+ HEAP32[12920 >> 2] = i12;
+ STACKTOP = i1;
+ return;
+ }
+ } else {
+ HEAP32[i11 >> 2] = i13 & -2;
+ HEAP32[i2 + 4 >> 2] = i12 | 1;
+ HEAP32[i2 + i12 >> 2] = i12;
+ }
+ i6 = i12 >>> 3;
+ if (i12 >>> 0 < 256) {
+ i7 = i6 << 1;
+ i5 = 12952 + (i7 << 2) | 0;
+ i8 = HEAP32[3228] | 0;
+ i6 = 1 << i6;
+ if ((i8 & i6 | 0) != 0) {
+ i7 = 12952 + (i7 + 2 << 2) | 0;
+ i6 = HEAP32[i7 >> 2] | 0;
+ if (i6 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i4 = i7;
+ i3 = i6;
+ }
+ } else {
+ HEAP32[3228] = i8 | i6;
+ i4 = 12952 + (i7 + 2 << 2) | 0;
+ i3 = i5;
+ }
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i3 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i3;
+ HEAP32[i2 + 12 >> 2] = i5;
+ STACKTOP = i1;
+ return;
+ }
+ i3 = i12 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i12 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i19 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i20 = i3 << i19;
+ i18 = (i20 + 520192 | 0) >>> 16 & 4;
+ i20 = i20 << i18;
+ i3 = (i20 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i18 | i19 | i3) + (i20 << i3 >>> 15) | 0;
+ i3 = i12 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i6 = 13216 + (i3 << 2) | 0;
+ HEAP32[i2 + 28 >> 2] = i3;
+ HEAP32[i2 + 20 >> 2] = 0;
+ HEAP32[i2 + 16 >> 2] = 0;
+ i5 = HEAP32[12916 >> 2] | 0;
+ i4 = 1 << i3;
+ if ((i5 & i4 | 0) == 0) {
+ HEAP32[12916 >> 2] = i5 | i4;
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i6;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ STACKTOP = i1;
+ return;
+ }
+ i4 = HEAP32[i6 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L194 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i12 | 0)) {
+ i3 = i12 << i3;
+ i6 = i4;
+ while (1) {
+ i5 = i6 + (i3 >>> 31 << 2) + 16 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) == (i12 | 0)) {
+ break L194;
+ } else {
+ i3 = i3 << 1;
+ i6 = i4;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i6;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ STACKTOP = i1;
+ return;
+ }
+ } while (0);
+ i3 = i4 + 8 | 0;
+ i6 = HEAP32[i3 >> 2] | 0;
+ i5 = HEAP32[12928 >> 2] | 0;
+ if (i4 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i6 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ HEAP32[i6 + 12 >> 2] = i2;
+ HEAP32[i3 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i6;
+ HEAP32[i2 + 12 >> 2] = i4;
+ HEAP32[i2 + 24 >> 2] = 0;
+ STACKTOP = i1;
+ return;
+}
+function _singlestep(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i14 = i1;
+ i3 = i2 + 12 | 0;
+ i8 = HEAP32[i3 >> 2] | 0;
+ i6 = i8 + 61 | 0;
+ switch (HEAPU8[i6] | 0) {
+ case 0:
+ {
+ if ((HEAP32[i8 + 84 >> 2] | 0) != 0) {
+ i21 = i8 + 16 | 0;
+ i22 = HEAP32[i21 >> 2] | 0;
+ _propagatemark(i8);
+ i22 = (HEAP32[i21 >> 2] | 0) - i22 | 0;
+ STACKTOP = i1;
+ return i22 | 0;
+ }
+ HEAP8[i6] = 1;
+ i6 = i8 + 20 | 0;
+ HEAP32[i6 >> 2] = HEAP32[i8 + 16 >> 2];
+ i8 = HEAP32[i3 >> 2] | 0;
+ i7 = i8 + 16 | 0;
+ i14 = HEAP32[i7 >> 2] | 0;
+ if ((i2 | 0) != 0 ? !((HEAP8[i2 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i8, i2);
+ }
+ if ((HEAP32[i8 + 48 >> 2] & 64 | 0) != 0 ? (i13 = HEAP32[i8 + 40 >> 2] | 0, !((HEAP8[i13 + 5 | 0] & 3) == 0)) : 0) {
+ _reallymarkobject(i8, i13);
+ }
+ _markmt(i8);
+ i13 = i8 + 112 | 0;
+ i15 = HEAP32[i8 + 132 >> 2] | 0;
+ if ((i15 | 0) != (i13 | 0)) {
+ do {
+ if (((HEAP8[i15 + 5 | 0] & 7) == 0 ? (i12 = HEAP32[i15 + 8 >> 2] | 0, (HEAP32[i12 + 8 >> 2] & 64 | 0) != 0) : 0) ? (i11 = HEAP32[i12 >> 2] | 0, !((HEAP8[i11 + 5 | 0] & 3) == 0)) : 0) {
+ _reallymarkobject(i8, i11);
+ }
+ i15 = HEAP32[i15 + 20 >> 2] | 0;
+ } while ((i15 | 0) != (i13 | 0));
+ }
+ i16 = i8 + 84 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != 0) {
+ do {
+ _propagatemark(i8);
+ } while ((HEAP32[i16 >> 2] | 0) != 0);
+ }
+ i17 = (HEAP32[i7 >> 2] | 0) - i14 | 0;
+ i11 = i8 + 92 | 0;
+ i12 = HEAP32[i11 >> 2] | 0;
+ i21 = i8 + 88 | 0;
+ i22 = HEAP32[i21 >> 2] | 0;
+ i15 = i8 + 96 | 0;
+ i13 = HEAP32[i15 >> 2] | 0;
+ HEAP32[i15 >> 2] = 0;
+ HEAP32[i21 >> 2] = 0;
+ HEAP32[i11 >> 2] = 0;
+ HEAP32[i16 >> 2] = i22;
+ if ((i22 | 0) != 0) {
+ do {
+ _propagatemark(i8);
+ } while ((HEAP32[i16 >> 2] | 0) != 0);
+ }
+ HEAP32[i16 >> 2] = i12;
+ if ((i12 | 0) != 0) {
+ do {
+ _propagatemark(i8);
+ } while ((HEAP32[i16 >> 2] | 0) != 0);
+ }
+ HEAP32[i16 >> 2] = i13;
+ if ((i13 | 0) != 0) {
+ do {
+ _propagatemark(i8);
+ } while ((HEAP32[i16 >> 2] | 0) != 0);
+ }
+ i18 = HEAP32[i7 >> 2] | 0;
+ while (1) {
+ i13 = HEAP32[i15 >> 2] | 0;
+ HEAP32[i15 >> 2] = 0;
+ i12 = 0;
+ L42 : while (1) {
+ i14 = i13;
+ while (1) {
+ if ((i14 | 0) == 0) {
+ break L42;
+ }
+ i13 = HEAP32[i14 + 24 >> 2] | 0;
+ if ((_traverseephemeron(i8, i14) | 0) == 0) {
+ i14 = i13;
+ } else {
+ break;
+ }
+ }
+ if ((HEAP32[i16 >> 2] | 0) == 0) {
+ i12 = 1;
+ continue;
+ }
+ while (1) {
+ _propagatemark(i8);
+ if ((HEAP32[i16 >> 2] | 0) == 0) {
+ i12 = 1;
+ continue L42;
+ }
+ }
+ }
+ if ((i12 | 0) == 0) {
+ break;
+ }
+ }
+ _clearvalues(i8, HEAP32[i11 >> 2] | 0, 0);
+ i14 = i8 + 100 | 0;
+ _clearvalues(i8, HEAP32[i14 >> 2] | 0, 0);
+ i13 = HEAP32[i11 >> 2] | 0;
+ i12 = HEAP32[i14 >> 2] | 0;
+ i21 = HEAP32[i7 >> 2] | 0;
+ i20 = HEAP32[i3 >> 2] | 0;
+ i19 = i20 + 104 | 0;
+ while (1) {
+ i22 = HEAP32[i19 >> 2] | 0;
+ if ((i22 | 0) == 0) {
+ break;
+ } else {
+ i19 = i22;
+ }
+ }
+ i17 = i17 - i18 + i21 | 0;
+ i20 = i20 + 72 | 0;
+ i21 = HEAP32[i20 >> 2] | 0;
+ L55 : do {
+ if ((i21 | 0) != 0) {
+ while (1) {
+ i18 = i21;
+ while (1) {
+ i22 = i18 + 5 | 0;
+ i21 = HEAP8[i22] | 0;
+ if ((i21 & 3) == 0) {
+ break;
+ }
+ HEAP8[i22] = i21 & 255 | 8;
+ HEAP32[i20 >> 2] = HEAP32[i18 >> 2];
+ HEAP32[i18 >> 2] = HEAP32[i19 >> 2];
+ HEAP32[i19 >> 2] = i18;
+ i19 = HEAP32[i20 >> 2] | 0;
+ if ((i19 | 0) == 0) {
+ break L55;
+ } else {
+ i22 = i18;
+ i18 = i19;
+ i19 = i22;
+ }
+ }
+ i21 = HEAP32[i18 >> 2] | 0;
+ if ((i21 | 0) == 0) {
+ break;
+ } else {
+ i20 = i18;
+ }
+ }
+ }
+ } while (0);
+ i19 = HEAP32[i8 + 104 >> 2] | 0;
+ if ((i19 | 0) != 0) {
+ i18 = i8 + 60 | 0;
+ do {
+ i22 = i19 + 5 | 0;
+ HEAP8[i22] = HEAP8[i18] & 3 | HEAP8[i22] & 184;
+ _reallymarkobject(i8, i19);
+ i19 = HEAP32[i19 >> 2] | 0;
+ } while ((i19 | 0) != 0);
+ }
+ if ((HEAP32[i16 >> 2] | 0) != 0) {
+ do {
+ _propagatemark(i8);
+ } while ((HEAP32[i16 >> 2] | 0) != 0);
+ }
+ i18 = HEAP32[i7 >> 2] | 0;
+ while (1) {
+ i20 = HEAP32[i15 >> 2] | 0;
+ HEAP32[i15 >> 2] = 0;
+ i19 = 0;
+ L74 : while (1) {
+ i21 = i20;
+ while (1) {
+ if ((i21 | 0) == 0) {
+ break L74;
+ }
+ i20 = HEAP32[i21 + 24 >> 2] | 0;
+ if ((_traverseephemeron(i8, i21) | 0) == 0) {
+ i21 = i20;
+ } else {
+ break;
+ }
+ }
+ if ((HEAP32[i16 >> 2] | 0) == 0) {
+ i19 = 1;
+ continue;
+ }
+ while (1) {
+ _propagatemark(i8);
+ if ((HEAP32[i16 >> 2] | 0) == 0) {
+ i19 = 1;
+ continue L74;
+ }
+ }
+ }
+ if ((i19 | 0) == 0) {
+ break;
+ }
+ }
+ i16 = i17 - i18 | 0;
+ i15 = HEAP32[i15 >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ do {
+ i22 = 1 << HEAPU8[i15 + 7 | 0];
+ i19 = HEAP32[i15 + 16 >> 2] | 0;
+ i17 = i19 + (i22 << 5) | 0;
+ if ((i22 | 0) > 0) {
+ do {
+ i18 = i19 + 8 | 0;
+ do {
+ if ((HEAP32[i18 >> 2] | 0) != 0 ? (i9 = i19 + 24 | 0, i10 = HEAP32[i9 >> 2] | 0, (i10 & 64 | 0) != 0) : 0) {
+ i20 = HEAP32[i19 + 16 >> 2] | 0;
+ if ((i10 & 15 | 0) == 4) {
+ if ((i20 | 0) == 0) {
+ break;
+ }
+ if ((HEAP8[i20 + 5 | 0] & 3) == 0) {
+ break;
+ }
+ _reallymarkobject(i8, i20);
+ break;
+ } else {
+ i20 = i20 + 5 | 0;
+ if ((HEAP8[i20] & 3) == 0) {
+ break;
+ }
+ HEAP32[i18 >> 2] = 0;
+ if ((HEAP8[i20] & 3) == 0) {
+ break;
+ }
+ HEAP32[i9 >> 2] = 11;
+ break;
+ }
+ }
+ } while (0);
+ i19 = i19 + 32 | 0;
+ } while (i19 >>> 0 < i17 >>> 0);
+ }
+ i15 = HEAP32[i15 + 24 >> 2] | 0;
+ } while ((i15 | 0) != 0);
+ }
+ i10 = HEAP32[i14 >> 2] | 0;
+ if ((i10 | 0) != 0) {
+ do {
+ i22 = 1 << HEAPU8[i10 + 7 | 0];
+ i17 = HEAP32[i10 + 16 >> 2] | 0;
+ i9 = i17 + (i22 << 5) | 0;
+ if ((i22 | 0) > 0) {
+ do {
+ i15 = i17 + 8 | 0;
+ do {
+ if ((HEAP32[i15 >> 2] | 0) != 0 ? (i5 = i17 + 24 | 0, i4 = HEAP32[i5 >> 2] | 0, (i4 & 64 | 0) != 0) : 0) {
+ i18 = HEAP32[i17 + 16 >> 2] | 0;
+ if ((i4 & 15 | 0) == 4) {
+ if ((i18 | 0) == 0) {
+ break;
+ }
+ if ((HEAP8[i18 + 5 | 0] & 3) == 0) {
+ break;
+ }
+ _reallymarkobject(i8, i18);
+ break;
+ } else {
+ i18 = i18 + 5 | 0;
+ if ((HEAP8[i18] & 3) == 0) {
+ break;
+ }
+ HEAP32[i15 >> 2] = 0;
+ if ((HEAP8[i18] & 3) == 0) {
+ break;
+ }
+ HEAP32[i5 >> 2] = 11;
+ break;
+ }
+ }
+ } while (0);
+ i17 = i17 + 32 | 0;
+ } while (i17 >>> 0 < i9 >>> 0);
+ }
+ i10 = HEAP32[i10 + 24 >> 2] | 0;
+ } while ((i10 | 0) != 0);
+ }
+ _clearvalues(i8, HEAP32[i11 >> 2] | 0, i13);
+ _clearvalues(i8, HEAP32[i14 >> 2] | 0, i12);
+ i4 = i8 + 60 | 0;
+ HEAP8[i4] = HEAPU8[i4] ^ 3;
+ i4 = i16 + (HEAP32[i7 >> 2] | 0) | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + i4;
+ i3 = HEAP32[i3 >> 2] | 0;
+ HEAP8[i3 + 61 | 0] = 2;
+ HEAP32[i3 + 64 >> 2] = 0;
+ i7 = i3 + 72 | 0;
+ i5 = 0;
+ do {
+ i5 = i5 + 1 | 0;
+ i6 = _sweeplist(i2, i7, 1) | 0;
+ } while ((i6 | 0) == (i7 | 0));
+ HEAP32[i3 + 80 >> 2] = i6;
+ i6 = i3 + 68 | 0;
+ i7 = 0;
+ do {
+ i7 = i7 + 1 | 0;
+ i8 = _sweeplist(i2, i6, 1) | 0;
+ } while ((i8 | 0) == (i6 | 0));
+ HEAP32[i3 + 76 >> 2] = i8;
+ i22 = ((i7 + i5 | 0) * 5 | 0) + i4 | 0;
+ STACKTOP = i1;
+ return i22 | 0;
+ }
+ case 2:
+ {
+ i3 = i8 + 64 | 0;
+ i4 = i8 + 32 | 0;
+ i8 = i8 + 24 | 0;
+ i5 = 0;
+ while (1) {
+ i10 = HEAP32[i3 >> 2] | 0;
+ i11 = i10 + i5 | 0;
+ i9 = HEAP32[i4 >> 2] | 0;
+ if ((i11 | 0) >= (i9 | 0)) {
+ i2 = i10;
+ break;
+ }
+ _sweeplist(i2, (HEAP32[i8 >> 2] | 0) + (i11 << 2) | 0, -3) | 0;
+ i5 = i5 + 1 | 0;
+ if ((i5 | 0) >= 80) {
+ i7 = 96;
+ break;
+ }
+ }
+ if ((i7 | 0) == 96) {
+ i2 = HEAP32[i3 >> 2] | 0;
+ i9 = HEAP32[i4 >> 2] | 0;
+ }
+ i22 = i2 + i5 | 0;
+ HEAP32[i3 >> 2] = i22;
+ if ((i22 | 0) >= (i9 | 0)) {
+ HEAP8[i6] = 3;
+ }
+ i22 = i5 * 5 | 0;
+ STACKTOP = i1;
+ return i22 | 0;
+ }
+ case 5:
+ {
+ i2 = i8 + 16 | 0;
+ HEAP32[i2 >> 2] = HEAP32[i8 + 32 >> 2] << 2;
+ i22 = i8 + 84 | 0;
+ i3 = i8 + 172 | 0;
+ HEAP32[i22 + 0 >> 2] = 0;
+ HEAP32[i22 + 4 >> 2] = 0;
+ HEAP32[i22 + 8 >> 2] = 0;
+ HEAP32[i22 + 12 >> 2] = 0;
+ HEAP32[i22 + 16 >> 2] = 0;
+ i3 = HEAP32[i3 >> 2] | 0;
+ if ((i3 | 0) != 0 ? !((HEAP8[i3 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i8, i3);
+ }
+ if ((HEAP32[i8 + 48 >> 2] & 64 | 0) != 0 ? (i15 = HEAP32[i8 + 40 >> 2] | 0, !((HEAP8[i15 + 5 | 0] & 3) == 0)) : 0) {
+ _reallymarkobject(i8, i15);
+ }
+ _markmt(i8);
+ i4 = HEAP32[i8 + 104 >> 2] | 0;
+ if ((i4 | 0) != 0) {
+ i3 = i8 + 60 | 0;
+ do {
+ i22 = i4 + 5 | 0;
+ HEAP8[i22] = HEAP8[i3] & 3 | HEAP8[i22] & 184;
+ _reallymarkobject(i8, i4);
+ i4 = HEAP32[i4 >> 2] | 0;
+ } while ((i4 | 0) != 0);
+ }
+ HEAP8[i6] = 0;
+ i22 = HEAP32[i2 >> 2] | 0;
+ STACKTOP = i1;
+ return i22 | 0;
+ }
+ case 3:
+ {
+ i3 = i8 + 80 | 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ HEAP8[i6] = 4;
+ i22 = 0;
+ STACKTOP = i1;
+ return i22 | 0;
+ } else {
+ HEAP32[i3 >> 2] = _sweeplist(i2, i4, 80) | 0;
+ i22 = 400;
+ STACKTOP = i1;
+ return i22 | 0;
+ }
+ }
+ case 4:
+ {
+ i4 = i8 + 76 | 0;
+ i5 = HEAP32[i4 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ HEAP32[i4 >> 2] = _sweeplist(i2, i5, 80) | 0;
+ i22 = 400;
+ STACKTOP = i1;
+ return i22 | 0;
+ }
+ HEAP32[i14 >> 2] = HEAP32[i8 + 172 >> 2];
+ _sweeplist(i2, i14, 1) | 0;
+ i3 = HEAP32[i3 >> 2] | 0;
+ if ((HEAP8[i3 + 62 | 0] | 0) != 1) {
+ i4 = (HEAP32[i3 + 32 >> 2] | 0) / 2 | 0;
+ if ((HEAP32[i3 + 28 >> 2] | 0) >>> 0 < i4 >>> 0) {
+ _luaS_resize(i2, i4);
+ }
+ i21 = i3 + 144 | 0;
+ i22 = i3 + 152 | 0;
+ HEAP32[i21 >> 2] = _luaM_realloc_(i2, HEAP32[i21 >> 2] | 0, HEAP32[i22 >> 2] | 0, 0) | 0;
+ HEAP32[i22 >> 2] = 0;
+ }
+ HEAP8[i6] = 5;
+ i22 = 5;
+ STACKTOP = i1;
+ return i22 | 0;
+ }
+ default:
+ {
+ i22 = 0;
+ STACKTOP = i1;
+ return i22 | 0;
+ }
+ }
+ return 0;
+}
+function _pmain(i3) {
+ i3 = i3 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i1;
+ i7 = _lua_tointegerx(i3, 1, 0) | 0;
+ i4 = _lua_touserdata(i3, 2) | 0;
+ i5 = HEAP32[i4 >> 2] | 0;
+ if ((i5 | 0) != 0 ? (HEAP8[i5] | 0) != 0 : 0) {
+ HEAP32[20] = i5;
+ }
+ i12 = HEAP32[i4 + 4 >> 2] | 0;
+ do {
+ if ((i12 | 0) == 0) {
+ i5 = 0;
+ i6 = 0;
+ i8 = 0;
+ i9 = 1;
+ i10 = 1;
+ } else {
+ i9 = 0;
+ i8 = 0;
+ i11 = 0;
+ i6 = 0;
+ i5 = 1;
+ L6 : while (1) {
+ if ((HEAP8[i12] | 0) != 45) {
+ i10 = 18;
+ break;
+ }
+ switch (HEAP8[i12 + 1 | 0] | 0) {
+ case 108:
+ {
+ i10 = 12;
+ break;
+ }
+ case 69:
+ {
+ i9 = 1;
+ break;
+ }
+ case 45:
+ {
+ i10 = 7;
+ break L6;
+ }
+ case 105:
+ {
+ if ((HEAP8[i12 + 2 | 0] | 0) == 0) {
+ i11 = 1;
+ i6 = 1;
+ } else {
+ i5 = -1;
+ break L6;
+ }
+ break;
+ }
+ case 101:
+ {
+ i8 = 1;
+ i10 = 12;
+ break;
+ }
+ case 118:
+ {
+ if ((HEAP8[i12 + 2 | 0] | 0) == 0) {
+ i11 = 1;
+ } else {
+ i5 = -1;
+ break L6;
+ }
+ break;
+ }
+ case 0:
+ {
+ i10 = 18;
+ break L6;
+ }
+ default:
+ {
+ i10 = 16;
+ break L6;
+ }
+ }
+ if ((i10 | 0) == 12) {
+ i10 = 0;
+ if ((HEAP8[i12 + 2 | 0] | 0) == 0) {
+ i12 = i5 + 1 | 0;
+ i13 = HEAP32[i4 + (i12 << 2) >> 2] | 0;
+ if ((i13 | 0) == 0) {
+ i10 = 15;
+ break;
+ }
+ if ((HEAP8[i13] | 0) == 45) {
+ i10 = 15;
+ break;
+ } else {
+ i5 = i12;
+ }
+ }
+ }
+ i5 = i5 + 1 | 0;
+ i12 = HEAP32[i4 + (i5 << 2) >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i5 = 0;
+ i12 = i9;
+ i10 = 23;
+ break;
+ }
+ }
+ if ((i10 | 0) == 7) {
+ if ((HEAP8[i12 + 2 | 0] | 0) == 0) {
+ i5 = i5 + 1 | 0;
+ i5 = (HEAP32[i4 + (i5 << 2) >> 2] | 0) == 0 ? 0 : i5;
+ i10 = 18;
+ } else {
+ i5 = -1;
+ }
+ } else if ((i10 | 0) == 15) {
+ i5 = 0 - i5 | 0;
+ i10 = 18;
+ } else if ((i10 | 0) == 16) {
+ i5 = 0 - i5 | 0;
+ i10 = 18;
+ }
+ if ((i10 | 0) == 18) {
+ if ((i5 | 0) >= 0) {
+ i12 = i9;
+ i10 = 23;
+ }
+ }
+ if ((i10 | 0) == 23) {
+ if ((i11 | 0) == 0) {
+ i9 = 1;
+ } else {
+ i9 = HEAP32[_stdout >> 2] | 0;
+ _fwrite(440, 1, 51, i9 | 0) | 0;
+ _fputc(10, i9 | 0) | 0;
+ _fflush(i9 | 0) | 0;
+ i9 = 0;
+ }
+ if ((i12 | 0) == 0) {
+ i10 = 1;
+ break;
+ }
+ _lua_pushboolean(i3, 1);
+ _lua_setfield(i3, -1001e3, 96);
+ i10 = 0;
+ break;
+ }
+ i3 = HEAP32[i4 + (0 - i5 << 2) >> 2] | 0;
+ i4 = HEAP32[_stderr >> 2] | 0;
+ HEAP32[i2 >> 2] = HEAP32[20];
+ _fprintf(i4 | 0, 496, i2 | 0) | 0;
+ _fflush(i4 | 0) | 0;
+ i13 = HEAP8[i3 + 1 | 0] | 0;
+ if (i13 << 24 >> 24 == 108 | i13 << 24 >> 24 == 101) {
+ HEAP32[i2 >> 2] = i3;
+ _fprintf(i4 | 0, 504, i2 | 0) | 0;
+ _fflush(i4 | 0) | 0;
+ } else {
+ HEAP32[i2 >> 2] = i3;
+ _fprintf(i4 | 0, 528, i2 | 0) | 0;
+ _fflush(i4 | 0) | 0;
+ }
+ HEAP32[i2 >> 2] = HEAP32[20];
+ _fprintf(i4 | 0, 560, i2 | 0) | 0;
+ _fflush(i4 | 0) | 0;
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ } while (0);
+ _luaL_checkversion_(i3, 502.0);
+ _lua_gc(i3, 0, 0) | 0;
+ _luaL_openlibs(i3);
+ _lua_gc(i3, 1, 0) | 0;
+ do {
+ if (i10) {
+ i10 = _getenv(409 | 0) | 0;
+ if ((i10 | 0) == 0) {
+ i10 = _getenv(425 | 0) | 0;
+ if ((i10 | 0) == 0) {
+ break;
+ } else {
+ i11 = 424;
+ }
+ } else {
+ i11 = 408;
+ }
+ if ((HEAP8[i10] | 0) == 64) {
+ i13 = _luaL_loadfilex(i3, i10 + 1 | 0, 0) | 0;
+ if ((i13 | 0) == 0) {
+ i12 = _lua_gettop(i3) | 0;
+ _lua_pushcclosure(i3, 142, 0);
+ _lua_insert(i3, i12);
+ HEAP32[48] = i3;
+ _signal(2, 1) | 0;
+ i13 = _lua_pcallk(i3, 0, 0, i12, 0, 0) | 0;
+ _signal(2, 0) | 0;
+ _lua_remove(i3, i12);
+ if ((i13 | 0) == 0) {
+ break;
+ }
+ }
+ if ((_lua_type(i3, -1) | 0) == 0) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ i11 = _lua_tolstring(i3, -1, 0) | 0;
+ i12 = HEAP32[20] | 0;
+ i10 = HEAP32[_stderr >> 2] | 0;
+ if ((i12 | 0) != 0) {
+ HEAP32[i2 >> 2] = i12;
+ _fprintf(i10 | 0, 496, i2 | 0) | 0;
+ _fflush(i10 | 0) | 0;
+ }
+ HEAP32[i2 >> 2] = (i11 | 0) == 0 ? 48 : i11;
+ _fprintf(i10 | 0, 912, i2 | 0) | 0;
+ _fflush(i10 | 0) | 0;
+ _lua_settop(i3, -2);
+ _lua_gc(i3, 2, 0) | 0;
+ } else {
+ i13 = _luaL_loadbufferx(i3, i10, _strlen(i10 | 0) | 0, i11, 0) | 0;
+ if ((i13 | 0) == 0) {
+ i12 = _lua_gettop(i3) | 0;
+ _lua_pushcclosure(i3, 142, 0);
+ _lua_insert(i3, i12);
+ HEAP32[48] = i3;
+ _signal(2, 1) | 0;
+ i13 = _lua_pcallk(i3, 0, 0, i12, 0, 0) | 0;
+ _signal(2, 0) | 0;
+ _lua_remove(i3, i12);
+ if ((i13 | 0) == 0) {
+ break;
+ }
+ }
+ if ((_lua_type(i3, -1) | 0) == 0) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ i11 = _lua_tolstring(i3, -1, 0) | 0;
+ i10 = HEAP32[20] | 0;
+ i12 = HEAP32[_stderr >> 2] | 0;
+ if ((i10 | 0) != 0) {
+ HEAP32[i2 >> 2] = i10;
+ _fprintf(i12 | 0, 496, i2 | 0) | 0;
+ _fflush(i12 | 0) | 0;
+ }
+ HEAP32[i2 >> 2] = (i11 | 0) == 0 ? 48 : i11;
+ _fprintf(i12 | 0, 912, i2 | 0) | 0;
+ _fflush(i12 | 0) | 0;
+ _lua_settop(i3, -2);
+ _lua_gc(i3, 2, 0) | 0;
+ }
+ if ((i13 | 0) != 0) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ }
+ } while (0);
+ i7 = (i5 | 0) > 0 ? i5 : i7;
+ L67 : do {
+ if ((i7 | 0) > 1) {
+ i10 = 1;
+ while (1) {
+ i11 = HEAP32[i4 + (i10 << 2) >> 2] | 0;
+ i12 = HEAP8[i11 + 1 | 0] | 0;
+ if ((i12 | 0) == 108) {
+ i11 = i11 + 2 | 0;
+ if ((HEAP8[i11] | 0) == 0) {
+ i10 = i10 + 1 | 0;
+ i11 = HEAP32[i4 + (i10 << 2) >> 2] | 0;
+ }
+ _lua_getglobal(i3, 400);
+ _lua_pushstring(i3, i11) | 0;
+ i12 = (_lua_gettop(i3) | 0) + -1 | 0;
+ _lua_pushcclosure(i3, 142, 0);
+ _lua_insert(i3, i12);
+ HEAP32[48] = i3;
+ _signal(2, 1) | 0;
+ i13 = _lua_pcallk(i3, 1, 1, i12, 0, 0) | 0;
+ _signal(2, 0) | 0;
+ _lua_remove(i3, i12);
+ if ((i13 | 0) != 0) {
+ i10 = 58;
+ break;
+ }
+ _lua_setglobal(i3, i11);
+ } else if ((i12 | 0) == 101) {
+ i11 = i11 + 2 | 0;
+ if ((HEAP8[i11] | 0) == 0) {
+ i10 = i10 + 1 | 0;
+ i11 = HEAP32[i4 + (i10 << 2) >> 2] | 0;
+ }
+ if ((_luaL_loadbufferx(i3, i11, _strlen(i11 | 0) | 0, 384, 0) | 0) != 0) {
+ i10 = 50;
+ break;
+ }
+ i12 = _lua_gettop(i3) | 0;
+ _lua_pushcclosure(i3, 142, 0);
+ _lua_insert(i3, i12);
+ HEAP32[48] = i3;
+ _signal(2, 1) | 0;
+ i13 = _lua_pcallk(i3, 0, 0, i12, 0, 0) | 0;
+ _signal(2, 0) | 0;
+ _lua_remove(i3, i12);
+ if ((i13 | 0) != 0) {
+ i10 = 50;
+ break;
+ }
+ }
+ i10 = i10 + 1 | 0;
+ if ((i10 | 0) >= (i7 | 0)) {
+ break L67;
+ }
+ }
+ if ((i10 | 0) == 50) {
+ if ((_lua_type(i3, -1) | 0) == 0) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ i5 = _lua_tolstring(i3, -1, 0) | 0;
+ i6 = HEAP32[20] | 0;
+ i4 = HEAP32[_stderr >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ HEAP32[i2 >> 2] = i6;
+ _fprintf(i4 | 0, 496, i2 | 0) | 0;
+ _fflush(i4 | 0) | 0;
+ }
+ HEAP32[i2 >> 2] = (i5 | 0) == 0 ? 48 : i5;
+ _fprintf(i4 | 0, 912, i2 | 0) | 0;
+ _fflush(i4 | 0) | 0;
+ _lua_settop(i3, -2);
+ _lua_gc(i3, 2, 0) | 0;
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ } else if ((i10 | 0) == 58) {
+ if ((_lua_type(i3, -1) | 0) == 0) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ i5 = _lua_tolstring(i3, -1, 0) | 0;
+ i6 = HEAP32[20] | 0;
+ i4 = HEAP32[_stderr >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ HEAP32[i2 >> 2] = i6;
+ _fprintf(i4 | 0, 496, i2 | 0) | 0;
+ _fflush(i4 | 0) | 0;
+ }
+ HEAP32[i2 >> 2] = (i5 | 0) == 0 ? 48 : i5;
+ _fprintf(i4 | 0, 912, i2 | 0) | 0;
+ _fflush(i4 | 0) | 0;
+ _lua_settop(i3, -2);
+ _lua_gc(i3, 2, 0) | 0;
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ }
+ } while (0);
+ do {
+ if ((i5 | 0) != 0) {
+ i10 = 0;
+ while (1) {
+ if ((HEAP32[i4 + (i10 << 2) >> 2] | 0) == 0) {
+ break;
+ } else {
+ i10 = i10 + 1 | 0;
+ }
+ }
+ i11 = i5 + 1 | 0;
+ i7 = i10 - i11 | 0;
+ _luaL_checkstack(i3, i7 + 3 | 0, 352);
+ if ((i11 | 0) < (i10 | 0)) {
+ i12 = i11;
+ do {
+ _lua_pushstring(i3, HEAP32[i4 + (i12 << 2) >> 2] | 0) | 0;
+ i12 = i12 + 1 | 0;
+ } while ((i12 | 0) != (i10 | 0));
+ }
+ _lua_createtable(i3, i7, i11);
+ if ((i10 | 0) > 0) {
+ i11 = 0;
+ do {
+ _lua_pushstring(i3, HEAP32[i4 + (i11 << 2) >> 2] | 0) | 0;
+ _lua_rawseti(i3, -2, i11 - i5 | 0);
+ i11 = i11 + 1 | 0;
+ } while ((i11 | 0) != (i10 | 0));
+ }
+ _lua_setglobal(i3, 328);
+ i10 = HEAP32[i4 + (i5 << 2) >> 2] | 0;
+ if ((_strcmp(i10, 336) | 0) == 0) {
+ i13 = (_strcmp(HEAP32[i4 + (i5 + -1 << 2) >> 2] | 0, 344) | 0) == 0;
+ i10 = i13 ? i10 : 0;
+ }
+ i10 = _luaL_loadfilex(i3, i10, 0) | 0;
+ i4 = ~i7;
+ _lua_insert(i3, i4);
+ if ((i10 | 0) == 0) {
+ i13 = (_lua_gettop(i3) | 0) - i7 | 0;
+ _lua_pushcclosure(i3, 142, 0);
+ _lua_insert(i3, i13);
+ HEAP32[48] = i3;
+ _signal(2, 1) | 0;
+ i10 = _lua_pcallk(i3, i7, -1, i13, 0, 0) | 0;
+ _signal(2, 0) | 0;
+ _lua_remove(i3, i13);
+ if ((i10 | 0) == 0) {
+ break;
+ }
+ } else {
+ _lua_settop(i3, i4);
+ }
+ if ((_lua_type(i3, -1) | 0) != 0) {
+ i7 = _lua_tolstring(i3, -1, 0) | 0;
+ i11 = HEAP32[20] | 0;
+ i4 = HEAP32[_stderr >> 2] | 0;
+ if ((i11 | 0) != 0) {
+ HEAP32[i2 >> 2] = i11;
+ _fprintf(i4 | 0, 496, i2 | 0) | 0;
+ _fflush(i4 | 0) | 0;
+ }
+ HEAP32[i2 >> 2] = (i7 | 0) == 0 ? 48 : i7;
+ _fprintf(i4 | 0, 912, i2 | 0) | 0;
+ _fflush(i4 | 0) | 0;
+ _lua_settop(i3, -2);
+ _lua_gc(i3, 2, 0) | 0;
+ }
+ if ((i10 | 0) != 0) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ }
+ } while (0);
+ if ((i6 | 0) == 0) {
+ if (!((i8 | i5 | 0) != 0 | i9 ^ 1)) {
+ i13 = HEAP32[_stdout >> 2] | 0;
+ _fwrite(440, 1, 51, i13 | 0) | 0;
+ _fputc(10, i13 | 0) | 0;
+ _fflush(i13 | 0) | 0;
+ _dotty(i3);
+ }
+ } else {
+ _dotty(i3);
+ }
+ _lua_pushboolean(i3, 1);
+ i13 = 1;
+ STACKTOP = i1;
+ return i13 | 0;
+}
+function _DumpFunction(i6, i2) {
+ i6 = i6 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0;
+ i5 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i17 = i5 + 56 | 0;
+ i19 = i5 + 52 | 0;
+ i20 = i5 + 48 | 0;
+ i18 = i5;
+ i21 = i5 + 60 | 0;
+ i22 = i5 + 44 | 0;
+ i1 = i5 + 40 | 0;
+ i16 = i5 + 36 | 0;
+ i23 = i5 + 32 | 0;
+ i3 = i5 + 28 | 0;
+ i7 = i5 + 24 | 0;
+ i8 = i5 + 20 | 0;
+ i9 = i5 + 16 | 0;
+ i10 = i5 + 12 | 0;
+ i12 = i5 + 8 | 0;
+ HEAP32[i17 >> 2] = HEAP32[i6 + 64 >> 2];
+ i4 = i2 + 16 | 0;
+ i28 = HEAP32[i4 >> 2] | 0;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i2 + 4 >> 2] & 3](HEAP32[i2 >> 2] | 0, i17, 4, HEAP32[i2 + 8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ }
+ HEAP32[i17 >> 2] = HEAP32[i6 + 68 >> 2];
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i2 + 4 >> 2] & 3](HEAP32[i2 >> 2] | 0, i17, 4, HEAP32[i2 + 8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ }
+ HEAP8[i17] = HEAP8[i6 + 76 | 0] | 0;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i2 + 4 >> 2] & 3](HEAP32[i2 >> 2] | 0, i17, 1, HEAP32[i2 + 8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ }
+ HEAP8[i17] = HEAP8[i6 + 77 | 0] | 0;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i2 + 4 >> 2] & 3](HEAP32[i2 >> 2] | 0, i17, 1, HEAP32[i2 + 8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ }
+ HEAP8[i17] = HEAP8[i6 + 78 | 0] | 0;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i2 + 4 >> 2] & 3](HEAP32[i2 >> 2] | 0, i17, 1, HEAP32[i2 + 8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ }
+ i25 = HEAP32[i6 + 12 >> 2] | 0;
+ i24 = HEAP32[i6 + 48 >> 2] | 0;
+ HEAP32[i23 >> 2] = i24;
+ if ((i28 | 0) == 0) {
+ i26 = i2 + 4 | 0;
+ i27 = i2 + 8 | 0;
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i26 >> 2] & 3](HEAP32[i2 >> 2] | 0, i23, 4, HEAP32[i27 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i26 >> 2] & 3](HEAP32[i2 >> 2] | 0, i25, i24 << 2, HEAP32[i27 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ i25 = HEAP32[i6 + 44 >> 2] | 0;
+ HEAP32[i22 >> 2] = i25;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i2 + 4 >> 2] & 3](HEAP32[i2 >> 2] | 0, i22, 4, HEAP32[i2 + 8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ }
+ } else {
+ i11 = 13;
+ }
+ } else {
+ i11 = 13;
+ }
+ if ((i11 | 0) == 13) {
+ i25 = HEAP32[i6 + 44 >> 2] | 0;
+ HEAP32[i22 >> 2] = i25;
+ }
+ if ((i25 | 0) > 0) {
+ i24 = i6 + 8 | 0;
+ i23 = i2 + 4 | 0;
+ i22 = i2 + 8 | 0;
+ i26 = 0;
+ do {
+ i30 = HEAP32[i24 >> 2] | 0;
+ i27 = i30 + (i26 << 4) | 0;
+ i30 = i30 + (i26 << 4) + 8 | 0;
+ i29 = HEAP32[i30 >> 2] | 0;
+ HEAP8[i17] = i29 & 15;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i23 >> 2] & 3](HEAP32[i2 >> 2] | 0, i17, 1, HEAP32[i22 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ i29 = HEAP32[i30 >> 2] | 0;
+ }
+ i29 = i29 & 15;
+ do {
+ if ((i29 | 0) == 3) {
+ HEAPF64[i18 >> 3] = +HEAPF64[i27 >> 3];
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i23 >> 2] & 3](HEAP32[i2 >> 2] | 0, i18, 8, HEAP32[i22 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ }
+ } else if ((i29 | 0) == 1) {
+ HEAP8[i21] = HEAP32[i27 >> 2];
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i23 >> 2] & 3](HEAP32[i2 >> 2] | 0, i21, 1, HEAP32[i22 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ }
+ } else if ((i29 | 0) == 4) {
+ i27 = HEAP32[i27 >> 2] | 0;
+ if ((i27 | 0) == 0) {
+ HEAP32[i19 >> 2] = 0;
+ if ((i28 | 0) != 0) {
+ break;
+ }
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i23 >> 2] & 3](HEAP32[i2 >> 2] | 0, i19, 4, HEAP32[i22 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ break;
+ }
+ HEAP32[i20 >> 2] = (HEAP32[i27 + 12 >> 2] | 0) + 1;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i23 >> 2] & 3](HEAP32[i2 >> 2] | 0, i20, 4, HEAP32[i22 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i23 >> 2] & 3](HEAP32[i2 >> 2] | 0, i27 + 16 | 0, HEAP32[i20 >> 2] | 0, HEAP32[i22 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ }
+ }
+ }
+ } while (0);
+ i26 = i26 + 1 | 0;
+ } while ((i26 | 0) != (i25 | 0));
+ }
+ i18 = HEAP32[i6 + 56 >> 2] | 0;
+ HEAP32[i17 >> 2] = i18;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i2 + 4 >> 2] & 3](HEAP32[i2 >> 2] | 0, i17, 4, HEAP32[i2 + 8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ }
+ if ((i18 | 0) > 0) {
+ i17 = i6 + 16 | 0;
+ i19 = 0;
+ do {
+ _DumpFunction(HEAP32[(HEAP32[i17 >> 2] | 0) + (i19 << 2) >> 2] | 0, i2);
+ i19 = i19 + 1 | 0;
+ } while ((i19 | 0) != (i18 | 0));
+ i28 = HEAP32[i4 >> 2] | 0;
+ }
+ i17 = i6 + 40 | 0;
+ i18 = HEAP32[i17 >> 2] | 0;
+ HEAP32[i16 >> 2] = i18;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i2 + 4 >> 2] & 3](HEAP32[i2 >> 2] | 0, i16, 4, HEAP32[i2 + 8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ }
+ if ((i18 | 0) > 0) {
+ i19 = i6 + 28 | 0;
+ i16 = i2 + 4 | 0;
+ i20 = i2 + 8 | 0;
+ i21 = 0;
+ do {
+ i22 = HEAP32[i19 >> 2] | 0;
+ HEAP8[i1] = HEAP8[i22 + (i21 << 3) + 4 | 0] | 0;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i16 >> 2] & 3](HEAP32[i2 >> 2] | 0, i1, 1, HEAP32[i20 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ i22 = HEAP32[i19 >> 2] | 0;
+ }
+ HEAP8[i1] = HEAP8[i22 + (i21 << 3) + 5 | 0] | 0;
+ if ((i28 | 0) == 0) {
+ i28 = FUNCTION_TABLE_iiiii[HEAP32[i16 >> 2] & 3](HEAP32[i2 >> 2] | 0, i1, 1, HEAP32[i20 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i28;
+ }
+ i21 = i21 + 1 | 0;
+ } while ((i21 | 0) != (i18 | 0));
+ }
+ i16 = i2 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == 0 ? (i13 = HEAP32[i6 + 36 >> 2] | 0, (i13 | 0) != 0) : 0) {
+ HEAP32[i12 >> 2] = (HEAP32[i13 + 12 >> 2] | 0) + 1;
+ if ((i28 | 0) == 0 ? (i14 = i2 + 4 | 0, i15 = i2 + 8 | 0, i30 = FUNCTION_TABLE_iiiii[HEAP32[i14 >> 2] & 3](HEAP32[i2 >> 2] | 0, i12, 4, HEAP32[i15 >> 2] | 0) | 0, HEAP32[i4 >> 2] = i30, (i30 | 0) == 0) : 0) {
+ HEAP32[i4 >> 2] = FUNCTION_TABLE_iiiii[HEAP32[i14 >> 2] & 3](HEAP32[i2 >> 2] | 0, i13 + 16 | 0, HEAP32[i12 >> 2] | 0, HEAP32[i15 >> 2] | 0) | 0;
+ }
+ } else {
+ i12 = i10;
+ i11 = 50;
+ }
+ if ((i11 | 0) == 50) {
+ HEAP32[i10 >> 2] = 0;
+ if ((i28 | 0) == 0) {
+ HEAP32[i4 >> 2] = FUNCTION_TABLE_iiiii[HEAP32[i2 + 4 >> 2] & 3](HEAP32[i2 >> 2] | 0, i12, 4, HEAP32[i2 + 8 >> 2] | 0) | 0;
+ }
+ }
+ if ((HEAP32[i16 >> 2] | 0) == 0) {
+ i11 = HEAP32[i6 + 52 >> 2] | 0;
+ } else {
+ i11 = 0;
+ }
+ i10 = HEAP32[i6 + 20 >> 2] | 0;
+ HEAP32[i9 >> 2] = i11;
+ i14 = HEAP32[i4 >> 2] | 0;
+ if ((i14 | 0) == 0) {
+ i12 = i2 + 4 | 0;
+ i13 = i2 + 8 | 0;
+ i14 = FUNCTION_TABLE_iiiii[HEAP32[i12 >> 2] & 3](HEAP32[i2 >> 2] | 0, i9, 4, HEAP32[i13 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i14;
+ if ((i14 | 0) == 0) {
+ i14 = FUNCTION_TABLE_iiiii[HEAP32[i12 >> 2] & 3](HEAP32[i2 >> 2] | 0, i10, i11 << 2, HEAP32[i13 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i14;
+ }
+ }
+ if ((HEAP32[i16 >> 2] | 0) == 0) {
+ i9 = HEAP32[i6 + 60 >> 2] | 0;
+ } else {
+ i9 = 0;
+ }
+ HEAP32[i8 >> 2] = i9;
+ if ((i14 | 0) == 0) {
+ i14 = FUNCTION_TABLE_iiiii[HEAP32[i2 + 4 >> 2] & 3](HEAP32[i2 >> 2] | 0, i8, 4, HEAP32[i2 + 8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i14;
+ }
+ if ((i9 | 0) > 0) {
+ i10 = i6 + 24 | 0;
+ i11 = i2 + 4 | 0;
+ i8 = i2 + 8 | 0;
+ i12 = 0;
+ do {
+ i13 = HEAP32[(HEAP32[i10 >> 2] | 0) + (i12 * 12 | 0) >> 2] | 0;
+ if ((i13 | 0) == 0) {
+ HEAP32[i1 >> 2] = 0;
+ if ((i14 | 0) == 0) {
+ i14 = FUNCTION_TABLE_iiiii[HEAP32[i11 >> 2] & 3](HEAP32[i2 >> 2] | 0, i1, 4, HEAP32[i8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i14;
+ }
+ } else {
+ HEAP32[i3 >> 2] = (HEAP32[i13 + 12 >> 2] | 0) + 1;
+ if ((i14 | 0) == 0) {
+ i14 = FUNCTION_TABLE_iiiii[HEAP32[i11 >> 2] & 3](HEAP32[i2 >> 2] | 0, i3, 4, HEAP32[i8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i14;
+ if ((i14 | 0) == 0) {
+ i14 = FUNCTION_TABLE_iiiii[HEAP32[i11 >> 2] & 3](HEAP32[i2 >> 2] | 0, i13 + 16 | 0, HEAP32[i3 >> 2] | 0, HEAP32[i8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i14;
+ }
+ }
+ }
+ i13 = HEAP32[i10 >> 2] | 0;
+ HEAP32[i1 >> 2] = HEAP32[i13 + (i12 * 12 | 0) + 4 >> 2];
+ if ((i14 | 0) == 0) {
+ i14 = FUNCTION_TABLE_iiiii[HEAP32[i11 >> 2] & 3](HEAP32[i2 >> 2] | 0, i1, 4, HEAP32[i8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i14;
+ i13 = HEAP32[i10 >> 2] | 0;
+ }
+ HEAP32[i1 >> 2] = HEAP32[i13 + (i12 * 12 | 0) + 8 >> 2];
+ if ((i14 | 0) == 0) {
+ i14 = FUNCTION_TABLE_iiiii[HEAP32[i11 >> 2] & 3](HEAP32[i2 >> 2] | 0, i1, 4, HEAP32[i8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i14;
+ }
+ i12 = i12 + 1 | 0;
+ } while ((i12 | 0) != (i9 | 0));
+ }
+ if ((HEAP32[i16 >> 2] | 0) == 0) {
+ i8 = HEAP32[i17 >> 2] | 0;
+ } else {
+ i8 = 0;
+ }
+ HEAP32[i7 >> 2] = i8;
+ if ((i14 | 0) == 0) {
+ i14 = FUNCTION_TABLE_iiiii[HEAP32[i2 + 4 >> 2] & 3](HEAP32[i2 >> 2] | 0, i7, 4, HEAP32[i2 + 8 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i14;
+ }
+ if ((i8 | 0) <= 0) {
+ STACKTOP = i5;
+ return;
+ }
+ i7 = i6 + 28 | 0;
+ i6 = i2 + 4 | 0;
+ i9 = i2 + 8 | 0;
+ i10 = 0;
+ do {
+ i11 = HEAP32[(HEAP32[i7 >> 2] | 0) + (i10 << 3) >> 2] | 0;
+ if ((i11 | 0) == 0) {
+ HEAP32[i1 >> 2] = 0;
+ if ((i14 | 0) == 0) {
+ i14 = FUNCTION_TABLE_iiiii[HEAP32[i6 >> 2] & 3](HEAP32[i2 >> 2] | 0, i1, 4, HEAP32[i9 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i14;
+ }
+ } else {
+ HEAP32[i3 >> 2] = (HEAP32[i11 + 12 >> 2] | 0) + 1;
+ if ((i14 | 0) == 0) {
+ i14 = FUNCTION_TABLE_iiiii[HEAP32[i6 >> 2] & 3](HEAP32[i2 >> 2] | 0, i3, 4, HEAP32[i9 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i14;
+ if ((i14 | 0) == 0) {
+ i14 = FUNCTION_TABLE_iiiii[HEAP32[i6 >> 2] & 3](HEAP32[i2 >> 2] | 0, i11 + 16 | 0, HEAP32[i3 >> 2] | 0, HEAP32[i9 >> 2] | 0) | 0;
+ HEAP32[i4 >> 2] = i14;
+ }
+ }
+ }
+ i10 = i10 + 1 | 0;
+ } while ((i10 | 0) != (i8 | 0));
+ STACKTOP = i5;
+ return;
+}
+function _LoadFunction(i2, i6) {
+ i2 = i2 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i1;
+ i5 = i1 + 8 | 0;
+ i4 = i2 + 4 | 0;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ i8 = HEAP32[i3 >> 2] | 0;
+ if ((i8 | 0) < 0) {
+ _error(i2, 8872);
+ }
+ HEAP32[i6 + 64 >> 2] = i8;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ i8 = HEAP32[i3 >> 2] | 0;
+ if ((i8 | 0) < 0) {
+ _error(i2, 8872);
+ }
+ HEAP32[i6 + 68 >> 2] = i8;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 1) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ HEAP8[i6 + 76 | 0] = HEAP8[i3] | 0;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 1) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ HEAP8[i6 + 77 | 0] = HEAP8[i3] | 0;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 1) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ HEAP8[i6 + 78 | 0] = HEAP8[i3] | 0;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ i9 = HEAP32[i3 >> 2] | 0;
+ if ((i9 | 0) < 0) {
+ _error(i2, 8872);
+ }
+ i8 = HEAP32[i2 >> 2] | 0;
+ if ((i9 + 1 | 0) >>> 0 > 1073741823) {
+ _luaM_toobig(i8);
+ }
+ i14 = i9 << 2;
+ i13 = _luaM_realloc_(i8, 0, 0, i14) | 0;
+ HEAP32[i6 + 12 >> 2] = i13;
+ HEAP32[i6 + 48 >> 2] = i9;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i13, i14) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ i8 = HEAP32[i3 >> 2] | 0;
+ if ((i8 | 0) < 0) {
+ _error(i2, 8872);
+ }
+ i9 = HEAP32[i2 >> 2] | 0;
+ if ((i8 + 1 | 0) >>> 0 > 268435455) {
+ _luaM_toobig(i9);
+ }
+ i11 = _luaM_realloc_(i9, 0, 0, i8 << 4) | 0;
+ i9 = i6 + 8 | 0;
+ HEAP32[i9 >> 2] = i11;
+ HEAP32[i6 + 44 >> 2] = i8;
+ i12 = (i8 | 0) > 0;
+ L43 : do {
+ if (i12) {
+ i10 = 0;
+ do {
+ HEAP32[i11 + (i10 << 4) + 8 >> 2] = 0;
+ i10 = i10 + 1 | 0;
+ } while ((i10 | 0) != (i8 | 0));
+ if (i12) {
+ i10 = i2 + 8 | 0;
+ i13 = 0;
+ while (1) {
+ i12 = i11 + (i13 << 4) | 0;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 1) | 0) != 0) {
+ i9 = 34;
+ break;
+ }
+ i14 = HEAP8[i3] | 0;
+ if ((i14 | 0) == 4) {
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ i9 = 44;
+ break;
+ }
+ i14 = HEAP32[i3 >> 2] | 0;
+ if ((i14 | 0) == 0) {
+ i14 = 0;
+ } else {
+ i14 = _luaZ_openspace(HEAP32[i2 >> 2] | 0, HEAP32[i10 >> 2] | 0, i14) | 0;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i14, HEAP32[i3 >> 2] | 0) | 0) != 0) {
+ i9 = 47;
+ break;
+ }
+ i14 = _luaS_newlstr(HEAP32[i2 >> 2] | 0, i14, (HEAP32[i3 >> 2] | 0) + -1 | 0) | 0;
+ }
+ HEAP32[i12 >> 2] = i14;
+ HEAP32[i11 + (i13 << 4) + 8 >> 2] = HEAPU8[i14 + 4 | 0] | 64;
+ } else if ((i14 | 0) == 1) {
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 1) | 0) != 0) {
+ i9 = 38;
+ break;
+ }
+ HEAP32[i12 >> 2] = HEAP8[i3] | 0;
+ HEAP32[i11 + (i13 << 4) + 8 >> 2] = 1;
+ } else if ((i14 | 0) == 3) {
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 8) | 0) != 0) {
+ i9 = 41;
+ break;
+ }
+ HEAPF64[i12 >> 3] = +HEAPF64[i3 >> 3];
+ HEAP32[i11 + (i13 << 4) + 8 >> 2] = 3;
+ } else if ((i14 | 0) == 0) {
+ HEAP32[i11 + (i13 << 4) + 8 >> 2] = 0;
+ }
+ i13 = i13 + 1 | 0;
+ if ((i13 | 0) >= (i8 | 0)) {
+ break L43;
+ }
+ i11 = HEAP32[i9 >> 2] | 0;
+ }
+ if ((i9 | 0) == 34) {
+ _error(i2, 8824);
+ } else if ((i9 | 0) == 38) {
+ _error(i2, 8824);
+ } else if ((i9 | 0) == 41) {
+ _error(i2, 8824);
+ } else if ((i9 | 0) == 44) {
+ _error(i2, 8824);
+ } else if ((i9 | 0) == 47) {
+ _error(i2, 8824);
+ }
+ }
+ }
+ } while (0);
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ i8 = HEAP32[i3 >> 2] | 0;
+ if ((i8 | 0) < 0) {
+ _error(i2, 8872);
+ }
+ i9 = HEAP32[i2 >> 2] | 0;
+ if ((i8 + 1 | 0) >>> 0 > 1073741823) {
+ _luaM_toobig(i9);
+ }
+ i11 = _luaM_realloc_(i9, 0, 0, i8 << 2) | 0;
+ i9 = i6 + 16 | 0;
+ HEAP32[i9 >> 2] = i11;
+ HEAP32[i6 + 56 >> 2] = i8;
+ i10 = (i8 | 0) > 0;
+ if (i10) {
+ i12 = 0;
+ while (1) {
+ HEAP32[i11 + (i12 << 2) >> 2] = 0;
+ i12 = i12 + 1 | 0;
+ if ((i12 | 0) == (i8 | 0)) {
+ break;
+ }
+ i11 = HEAP32[i9 >> 2] | 0;
+ }
+ if (i10) {
+ i10 = 0;
+ do {
+ i14 = _luaF_newproto(HEAP32[i2 >> 2] | 0) | 0;
+ HEAP32[(HEAP32[i9 >> 2] | 0) + (i10 << 2) >> 2] = i14;
+ _LoadFunction(i2, HEAP32[(HEAP32[i9 >> 2] | 0) + (i10 << 2) >> 2] | 0);
+ i10 = i10 + 1 | 0;
+ } while ((i10 | 0) != (i8 | 0));
+ }
+ }
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ i9 = HEAP32[i3 >> 2] | 0;
+ if ((i9 | 0) < 0) {
+ _error(i2, 8872);
+ }
+ i8 = HEAP32[i2 >> 2] | 0;
+ if ((i9 + 1 | 0) >>> 0 > 536870911) {
+ _luaM_toobig(i8);
+ }
+ i10 = _luaM_realloc_(i8, 0, 0, i9 << 3) | 0;
+ i8 = i6 + 28 | 0;
+ HEAP32[i8 >> 2] = i10;
+ HEAP32[i6 + 40 >> 2] = i9;
+ L98 : do {
+ if ((i9 | 0) > 0) {
+ HEAP32[i10 >> 2] = 0;
+ if ((i9 | 0) == 1) {
+ i10 = 0;
+ } else {
+ i10 = 1;
+ while (1) {
+ HEAP32[(HEAP32[i8 >> 2] | 0) + (i10 << 3) >> 2] = 0;
+ i10 = i10 + 1 | 0;
+ if ((i10 | 0) == (i9 | 0)) {
+ i10 = 0;
+ break;
+ }
+ }
+ }
+ while (1) {
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 1) | 0) != 0) {
+ i9 = 73;
+ break;
+ }
+ HEAP8[(HEAP32[i8 >> 2] | 0) + (i10 << 3) + 4 | 0] = HEAP8[i3] | 0;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 1) | 0) != 0) {
+ i9 = 75;
+ break;
+ }
+ HEAP8[(HEAP32[i8 >> 2] | 0) + (i10 << 3) + 5 | 0] = HEAP8[i3] | 0;
+ i10 = i10 + 1 | 0;
+ if ((i10 | 0) >= (i9 | 0)) {
+ break L98;
+ }
+ }
+ if ((i9 | 0) == 73) {
+ _error(i2, 8824);
+ } else if ((i9 | 0) == 75) {
+ _error(i2, 8824);
+ }
+ }
+ } while (0);
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ i9 = HEAP32[i3 >> 2] | 0;
+ do {
+ if ((i9 | 0) != 0) {
+ i9 = _luaZ_openspace(HEAP32[i2 >> 2] | 0, HEAP32[i2 + 8 >> 2] | 0, i9) | 0;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i9, HEAP32[i3 >> 2] | 0) | 0) == 0) {
+ i7 = _luaS_newlstr(HEAP32[i2 >> 2] | 0, i9, (HEAP32[i3 >> 2] | 0) + -1 | 0) | 0;
+ break;
+ } else {
+ _error(i2, 8824);
+ }
+ } else {
+ i7 = 0;
+ }
+ } while (0);
+ HEAP32[i6 + 36 >> 2] = i7;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ i7 = HEAP32[i3 >> 2] | 0;
+ if ((i7 | 0) < 0) {
+ _error(i2, 8872);
+ }
+ i9 = HEAP32[i2 >> 2] | 0;
+ if ((i7 + 1 | 0) >>> 0 > 1073741823) {
+ _luaM_toobig(i9);
+ }
+ i14 = i7 << 2;
+ i13 = _luaM_realloc_(i9, 0, 0, i14) | 0;
+ HEAP32[i6 + 20 >> 2] = i13;
+ HEAP32[i6 + 52 >> 2] = i7;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i13, i14) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ i7 = HEAP32[i3 >> 2] | 0;
+ if ((i7 | 0) < 0) {
+ _error(i2, 8872);
+ }
+ i9 = HEAP32[i2 >> 2] | 0;
+ if ((i7 + 1 | 0) >>> 0 > 357913941) {
+ _luaM_toobig(i9);
+ }
+ i10 = _luaM_realloc_(i9, 0, 0, i7 * 12 | 0) | 0;
+ i9 = i6 + 24 | 0;
+ HEAP32[i9 >> 2] = i10;
+ HEAP32[i6 + 60 >> 2] = i7;
+ L141 : do {
+ if ((i7 | 0) > 0) {
+ HEAP32[i10 >> 2] = 0;
+ if ((i7 | 0) != 1) {
+ i6 = 1;
+ do {
+ HEAP32[(HEAP32[i9 >> 2] | 0) + (i6 * 12 | 0) >> 2] = 0;
+ i6 = i6 + 1 | 0;
+ } while ((i6 | 0) != (i7 | 0));
+ }
+ i6 = i2 + 8 | 0;
+ i10 = 0;
+ while (1) {
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ i9 = 102;
+ break;
+ }
+ i11 = HEAP32[i3 >> 2] | 0;
+ if ((i11 | 0) == 0) {
+ i11 = 0;
+ } else {
+ i11 = _luaZ_openspace(HEAP32[i2 >> 2] | 0, HEAP32[i6 >> 2] | 0, i11) | 0;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i11, HEAP32[i3 >> 2] | 0) | 0) != 0) {
+ i9 = 105;
+ break;
+ }
+ i11 = _luaS_newlstr(HEAP32[i2 >> 2] | 0, i11, (HEAP32[i3 >> 2] | 0) + -1 | 0) | 0;
+ }
+ HEAP32[(HEAP32[i9 >> 2] | 0) + (i10 * 12 | 0) >> 2] = i11;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ i9 = 108;
+ break;
+ }
+ i11 = HEAP32[i3 >> 2] | 0;
+ if ((i11 | 0) < 0) {
+ i9 = 110;
+ break;
+ }
+ HEAP32[(HEAP32[i9 >> 2] | 0) + (i10 * 12 | 0) + 4 >> 2] = i11;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ i9 = 112;
+ break;
+ }
+ i11 = HEAP32[i3 >> 2] | 0;
+ if ((i11 | 0) < 0) {
+ i9 = 114;
+ break;
+ }
+ HEAP32[(HEAP32[i9 >> 2] | 0) + (i10 * 12 | 0) + 8 >> 2] = i11;
+ i10 = i10 + 1 | 0;
+ if ((i10 | 0) >= (i7 | 0)) {
+ break L141;
+ }
+ }
+ if ((i9 | 0) == 102) {
+ _error(i2, 8824);
+ } else if ((i9 | 0) == 105) {
+ _error(i2, 8824);
+ } else if ((i9 | 0) == 108) {
+ _error(i2, 8824);
+ } else if ((i9 | 0) == 110) {
+ _error(i2, 8872);
+ } else if ((i9 | 0) == 112) {
+ _error(i2, 8824);
+ } else if ((i9 | 0) == 114) {
+ _error(i2, 8872);
+ }
+ }
+ } while (0);
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i5, 4) | 0) != 0) {
+ _error(i2, 8824);
+ }
+ i6 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) < 0) {
+ _error(i2, 8872);
+ }
+ if ((i6 | 0) <= 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i5 = i2 + 8 | 0;
+ i7 = 0;
+ while (1) {
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i3, 4) | 0) != 0) {
+ i9 = 123;
+ break;
+ }
+ i9 = HEAP32[i3 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ i9 = 0;
+ } else {
+ i9 = _luaZ_openspace(HEAP32[i2 >> 2] | 0, HEAP32[i5 >> 2] | 0, i9) | 0;
+ if ((_luaZ_read(HEAP32[i4 >> 2] | 0, i9, HEAP32[i3 >> 2] | 0) | 0) != 0) {
+ i9 = 126;
+ break;
+ }
+ i9 = _luaS_newlstr(HEAP32[i2 >> 2] | 0, i9, (HEAP32[i3 >> 2] | 0) + -1 | 0) | 0;
+ }
+ HEAP32[(HEAP32[i8 >> 2] | 0) + (i7 << 3) >> 2] = i9;
+ i7 = i7 + 1 | 0;
+ if ((i7 | 0) >= (i6 | 0)) {
+ i9 = 129;
+ break;
+ }
+ }
+ if ((i9 | 0) == 123) {
+ _error(i2, 8824);
+ } else if ((i9 | 0) == 126) {
+ _error(i2, 8824);
+ } else if ((i9 | 0) == 129) {
+ STACKTOP = i1;
+ return;
+ }
+}
+function _exp2reg(i4, i1, i7) {
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ i7 = i7 | 0;
+ var i2 = 0, i3 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0;
+ i5 = STACKTOP;
+ _discharge2reg(i4, i1, i7);
+ i6 = i1 + 16 | 0;
+ do {
+ if ((HEAP32[i1 >> 2] | 0) == 10 ? (i10 = HEAP32[i1 + 8 >> 2] | 0, !((i10 | 0) == -1)) : 0) {
+ i22 = HEAP32[i6 >> 2] | 0;
+ if ((i22 | 0) == -1) {
+ HEAP32[i6 >> 2] = i10;
+ break;
+ }
+ i20 = HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i19 = i20 + (i22 << 2) | 0;
+ i21 = HEAP32[i19 >> 2] | 0;
+ i23 = (i21 >>> 14) + -131071 | 0;
+ if ((i23 | 0) == -1) {
+ break;
+ }
+ i23 = i22 + 1 + i23 | 0;
+ if ((i23 | 0) == -1) {
+ break;
+ } else {
+ i22 = i23;
+ }
+ }
+ i10 = i10 + ~i22 | 0;
+ if ((((i10 | 0) > -1 ? i10 : 0 - i10 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i4 + 12 >> 2] | 0, 10624);
+ } else {
+ HEAP32[i19 >> 2] = (i10 << 14) + 2147467264 | i21 & 16383;
+ break;
+ }
+ }
+ } while (0);
+ i21 = HEAP32[i6 >> 2] | 0;
+ i10 = i1 + 20 | 0;
+ i19 = HEAP32[i10 >> 2] | 0;
+ if ((i21 | 0) == (i19 | 0)) {
+ HEAP32[i6 >> 2] = -1;
+ HEAP32[i10 >> 2] = -1;
+ i25 = i1 + 8 | 0;
+ HEAP32[i25 >> 2] = i7;
+ HEAP32[i1 >> 2] = 6;
+ STACKTOP = i5;
+ return;
+ }
+ L18 : do {
+ if ((i21 | 0) == -1) {
+ i18 = 20;
+ } else {
+ i20 = HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i23 = i20 + (i21 << 2) | 0;
+ if ((i21 | 0) > 0 ? (i18 = HEAP32[i20 + (i21 + -1 << 2) >> 2] | 0, (HEAP8[5584 + (i18 & 63) | 0] | 0) < 0) : 0) {
+ i22 = i18;
+ } else {
+ i22 = HEAP32[i23 >> 2] | 0;
+ }
+ if ((i22 & 63 | 0) != 28) {
+ i18 = 28;
+ break L18;
+ }
+ i22 = ((HEAP32[i23 >> 2] | 0) >>> 14) + -131071 | 0;
+ if ((i22 | 0) == -1) {
+ i18 = 20;
+ break L18;
+ }
+ i21 = i21 + 1 + i22 | 0;
+ if ((i21 | 0) == -1) {
+ i18 = 20;
+ break;
+ }
+ }
+ }
+ } while (0);
+ L29 : do {
+ if ((i18 | 0) == 20) {
+ if ((i19 | 0) == -1) {
+ i15 = -1;
+ i8 = -1;
+ } else {
+ i20 = HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i21 = i20 + (i19 << 2) | 0;
+ if ((i19 | 0) > 0 ? (i17 = HEAP32[i20 + (i19 + -1 << 2) >> 2] | 0, (HEAP8[5584 + (i17 & 63) | 0] | 0) < 0) : 0) {
+ i22 = i17;
+ } else {
+ i22 = HEAP32[i21 >> 2] | 0;
+ }
+ if ((i22 & 63 | 0) != 28) {
+ i18 = 28;
+ break L29;
+ }
+ i21 = ((HEAP32[i21 >> 2] | 0) >>> 14) + -131071 | 0;
+ if ((i21 | 0) == -1) {
+ i15 = -1;
+ i8 = -1;
+ break L29;
+ }
+ i19 = i19 + 1 + i21 | 0;
+ if ((i19 | 0) == -1) {
+ i15 = -1;
+ i8 = -1;
+ break;
+ }
+ }
+ }
+ }
+ } while (0);
+ do {
+ if ((i18 | 0) == 28) {
+ i17 = i4 + 28 | 0;
+ do {
+ if ((HEAP32[i1 >> 2] | 0) != 10) {
+ i21 = HEAP32[i17 >> 2] | 0;
+ HEAP32[i17 >> 2] = -1;
+ i18 = _luaK_code(i4, 2147450903) | 0;
+ if (!((i21 | 0) == -1)) {
+ if (!((i18 | 0) == -1)) {
+ i23 = HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] | 0;
+ i22 = i18;
+ while (1) {
+ i20 = i23 + (i22 << 2) | 0;
+ i19 = HEAP32[i20 >> 2] | 0;
+ i24 = (i19 >>> 14) + -131071 | 0;
+ if ((i24 | 0) == -1) {
+ break;
+ }
+ i24 = i22 + 1 + i24 | 0;
+ if ((i24 | 0) == -1) {
+ break;
+ } else {
+ i22 = i24;
+ }
+ }
+ i21 = i21 + ~i22 | 0;
+ if ((((i21 | 0) > -1 ? i21 : 0 - i21 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i4 + 12 >> 2] | 0, 10624);
+ } else {
+ HEAP32[i20 >> 2] = (i21 << 14) + 2147467264 | i19 & 16383;
+ i16 = i18;
+ break;
+ }
+ } else {
+ i16 = i21;
+ }
+ } else {
+ i16 = i18;
+ }
+ } else {
+ i16 = -1;
+ }
+ } while (0);
+ i24 = i4 + 20 | 0;
+ i25 = i4 + 24 | 0;
+ HEAP32[i25 >> 2] = HEAP32[i24 >> 2];
+ i19 = i7 << 6;
+ i18 = _luaK_code(i4, i19 | 16387) | 0;
+ HEAP32[i25 >> 2] = HEAP32[i24 >> 2];
+ i19 = _luaK_code(i4, i19 | 8388611) | 0;
+ HEAP32[i25 >> 2] = HEAP32[i24 >> 2];
+ if (!((i16 | 0) == -1)) {
+ i22 = HEAP32[i17 >> 2] | 0;
+ if ((i22 | 0) == -1) {
+ HEAP32[i17 >> 2] = i16;
+ i15 = i18;
+ i8 = i19;
+ break;
+ }
+ i17 = HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i21 = i17 + (i22 << 2) | 0;
+ i20 = HEAP32[i21 >> 2] | 0;
+ i23 = (i20 >>> 14) + -131071 | 0;
+ if ((i23 | 0) == -1) {
+ break;
+ }
+ i23 = i22 + 1 + i23 | 0;
+ if ((i23 | 0) == -1) {
+ break;
+ } else {
+ i22 = i23;
+ }
+ }
+ i16 = i16 + ~i22 | 0;
+ if ((((i16 | 0) > -1 ? i16 : 0 - i16 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i4 + 12 >> 2] | 0, 10624);
+ } else {
+ HEAP32[i21 >> 2] = (i16 << 14) + 2147467264 | i20 & 16383;
+ i15 = i18;
+ i8 = i19;
+ break;
+ }
+ } else {
+ i15 = i18;
+ i8 = i19;
+ }
+ }
+ } while (0);
+ i16 = HEAP32[i4 + 20 >> 2] | 0;
+ HEAP32[i4 + 24 >> 2] = i16;
+ i22 = HEAP32[i10 >> 2] | 0;
+ L67 : do {
+ if (!((i22 | 0) == -1)) {
+ i19 = (i7 | 0) == 255;
+ i17 = i7 << 6 & 16320;
+ i18 = HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i20 = i18 + (i22 << 2) | 0;
+ i23 = HEAP32[i20 >> 2] | 0;
+ i21 = (i23 >>> 14) + -131071 | 0;
+ if ((i21 | 0) == -1) {
+ i21 = -1;
+ } else {
+ i21 = i22 + 1 + i21 | 0;
+ }
+ if ((i22 | 0) > 0 ? (i14 = i18 + (i22 + -1 << 2) | 0, i13 = HEAP32[i14 >> 2] | 0, (HEAP8[5584 + (i13 & 63) | 0] | 0) < 0) : 0) {
+ i24 = i14;
+ i25 = i13;
+ } else {
+ i24 = i20;
+ i25 = i23;
+ }
+ if ((i25 & 63 | 0) == 28) {
+ i23 = i25 >>> 23;
+ if (i19 | (i23 | 0) == (i7 | 0)) {
+ i23 = i25 & 8372224 | i23 << 6 | 27;
+ } else {
+ i23 = i25 & -16321 | i17;
+ }
+ HEAP32[i24 >> 2] = i23;
+ i22 = i16 + ~i22 | 0;
+ if ((((i22 | 0) > -1 ? i22 : 0 - i22 | 0) | 0) > 131071) {
+ i18 = 58;
+ break;
+ }
+ i22 = HEAP32[i20 >> 2] & 16383 | (i22 << 14) + 2147467264;
+ } else {
+ i22 = i15 + ~i22 | 0;
+ if ((((i22 | 0) > -1 ? i22 : 0 - i22 | 0) | 0) > 131071) {
+ i18 = 61;
+ break;
+ }
+ i22 = i23 & 16383 | (i22 << 14) + 2147467264;
+ }
+ HEAP32[i20 >> 2] = i22;
+ if ((i21 | 0) == -1) {
+ break L67;
+ } else {
+ i22 = i21;
+ }
+ }
+ if ((i18 | 0) == 58) {
+ _luaX_syntaxerror(HEAP32[i4 + 12 >> 2] | 0, 10624);
+ } else if ((i18 | 0) == 61) {
+ _luaX_syntaxerror(HEAP32[i4 + 12 >> 2] | 0, 10624);
+ }
+ }
+ } while (0);
+ i20 = HEAP32[i6 >> 2] | 0;
+ if ((i20 | 0) == -1) {
+ HEAP32[i6 >> 2] = -1;
+ HEAP32[i10 >> 2] = -1;
+ i25 = i1 + 8 | 0;
+ HEAP32[i25 >> 2] = i7;
+ HEAP32[i1 >> 2] = 6;
+ STACKTOP = i5;
+ return;
+ }
+ i13 = i7 << 6;
+ i15 = i13 & 16320;
+ i14 = HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] | 0;
+ if ((i7 | 0) == 255) {
+ while (1) {
+ i17 = i14 + (i20 << 2) | 0;
+ i19 = HEAP32[i17 >> 2] | 0;
+ i18 = (i19 >>> 14) + -131071 | 0;
+ if ((i18 | 0) == -1) {
+ i18 = -1;
+ } else {
+ i18 = i20 + 1 + i18 | 0;
+ }
+ if ((i20 | 0) > 0 ? (i12 = i14 + (i20 + -1 << 2) | 0, i11 = HEAP32[i12 >> 2] | 0, (HEAP8[5584 + (i11 & 63) | 0] | 0) < 0) : 0) {
+ i22 = i12;
+ i21 = i11;
+ } else {
+ i22 = i17;
+ i21 = i19;
+ }
+ if ((i21 & 63 | 0) == 28) {
+ HEAP32[i22 >> 2] = i21 & 8372224 | i21 >>> 23 << 6 | 27;
+ i19 = i16 + ~i20 | 0;
+ if ((((i19 | 0) > -1 ? i19 : 0 - i19 | 0) | 0) > 131071) {
+ i18 = 87;
+ break;
+ }
+ i19 = HEAP32[i17 >> 2] & 16383 | (i19 << 14) + 2147467264;
+ } else {
+ i20 = i8 + ~i20 | 0;
+ if ((((i20 | 0) > -1 ? i20 : 0 - i20 | 0) | 0) > 131071) {
+ i18 = 90;
+ break;
+ }
+ i19 = i19 & 16383 | (i20 << 14) + 2147467264;
+ }
+ HEAP32[i17 >> 2] = i19;
+ if ((i18 | 0) == -1) {
+ i18 = 93;
+ break;
+ } else {
+ i20 = i18;
+ }
+ }
+ if ((i18 | 0) == 87) {
+ i25 = i4 + 12 | 0;
+ i25 = HEAP32[i25 >> 2] | 0;
+ _luaX_syntaxerror(i25, 10624);
+ } else if ((i18 | 0) == 90) {
+ i25 = i4 + 12 | 0;
+ i25 = HEAP32[i25 >> 2] | 0;
+ _luaX_syntaxerror(i25, 10624);
+ } else if ((i18 | 0) == 93) {
+ HEAP32[i6 >> 2] = -1;
+ HEAP32[i10 >> 2] = -1;
+ i25 = i1 + 8 | 0;
+ HEAP32[i25 >> 2] = i7;
+ HEAP32[i1 >> 2] = 6;
+ STACKTOP = i5;
+ return;
+ }
+ } else {
+ i9 = i20;
+ }
+ while (1) {
+ i11 = i14 + (i9 << 2) | 0;
+ i17 = HEAP32[i11 >> 2] | 0;
+ i12 = (i17 >>> 14) + -131071 | 0;
+ if ((i12 | 0) == -1) {
+ i12 = -1;
+ } else {
+ i12 = i9 + 1 + i12 | 0;
+ }
+ if ((i9 | 0) > 0 ? (i3 = i14 + (i9 + -1 << 2) | 0, i2 = HEAP32[i3 >> 2] | 0, (HEAP8[5584 + (i2 & 63) | 0] | 0) < 0) : 0) {
+ i18 = i3;
+ i19 = i2;
+ } else {
+ i18 = i11;
+ i19 = i17;
+ }
+ if ((i19 & 63 | 0) == 28) {
+ if ((i19 >>> 23 | 0) == (i7 | 0)) {
+ i17 = i19 & 8372224 | i13 | 27;
+ } else {
+ i17 = i19 & -16321 | i15;
+ }
+ HEAP32[i18 >> 2] = i17;
+ i9 = i16 + ~i9 | 0;
+ if ((((i9 | 0) > -1 ? i9 : 0 - i9 | 0) | 0) > 131071) {
+ i18 = 87;
+ break;
+ }
+ i9 = HEAP32[i11 >> 2] & 16383 | (i9 << 14) + 2147467264;
+ } else {
+ i9 = i8 + ~i9 | 0;
+ if ((((i9 | 0) > -1 ? i9 : 0 - i9 | 0) | 0) > 131071) {
+ i18 = 90;
+ break;
+ }
+ i9 = i17 & 16383 | (i9 << 14) + 2147467264;
+ }
+ HEAP32[i11 >> 2] = i9;
+ if ((i12 | 0) == -1) {
+ i18 = 93;
+ break;
+ } else {
+ i9 = i12;
+ }
+ }
+ if ((i18 | 0) == 87) {
+ i25 = i4 + 12 | 0;
+ i25 = HEAP32[i25 >> 2] | 0;
+ _luaX_syntaxerror(i25, 10624);
+ } else if ((i18 | 0) == 90) {
+ i25 = i4 + 12 | 0;
+ i25 = HEAP32[i25 >> 2] | 0;
+ _luaX_syntaxerror(i25, 10624);
+ } else if ((i18 | 0) == 93) {
+ HEAP32[i6 >> 2] = -1;
+ HEAP32[i10 >> 2] = -1;
+ i25 = i1 + 8 | 0;
+ HEAP32[i25 >> 2] = i7;
+ HEAP32[i1 >> 2] = 6;
+ STACKTOP = i5;
+ return;
+ }
+}
+function _propagatemark(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0;
+ i1 = STACKTOP;
+ i15 = i2 + 84 | 0;
+ i3 = HEAP32[i15 >> 2] | 0;
+ i10 = i3 + 5 | 0;
+ HEAP8[i10] = HEAPU8[i10] | 4;
+ switch (HEAPU8[i3 + 4 | 0] | 0) {
+ case 5:
+ {
+ i9 = i3 + 24 | 0;
+ HEAP32[i15 >> 2] = HEAP32[i9 >> 2];
+ i15 = i3 + 8 | 0;
+ i14 = HEAP32[i15 >> 2] | 0;
+ do {
+ if ((i14 | 0) != 0) {
+ if ((HEAP8[i14 + 6 | 0] & 8) == 0) {
+ i11 = _luaT_gettm(i14, 3, HEAP32[i2 + 196 >> 2] | 0) | 0;
+ i14 = HEAP32[i15 >> 2] | 0;
+ if ((i14 | 0) != 0) {
+ i6 = 5;
+ }
+ } else {
+ i11 = 0;
+ i6 = 5;
+ }
+ if ((i6 | 0) == 5) {
+ if (!((HEAP8[i14 + 5 | 0] & 3) == 0)) {
+ _reallymarkobject(i2, i14);
+ }
+ }
+ if (((i11 | 0) != 0 ? (HEAP32[i11 + 8 >> 2] & 15 | 0) == 4 : 0) ? (i13 = (HEAP32[i11 >> 2] | 0) + 16 | 0, i12 = _strchr(i13, 107) | 0, i12 = (i12 | 0) != 0, i13 = (_strchr(i13, 118) | 0) == 0, !(i13 & (i12 ^ 1))) : 0) {
+ HEAP8[i10] = HEAP8[i10] & 251;
+ if (i12) {
+ if (i13) {
+ _traverseephemeron(i2, i3) | 0;
+ break;
+ } else {
+ i15 = i2 + 100 | 0;
+ HEAP32[i9 >> 2] = HEAP32[i15 >> 2];
+ HEAP32[i15 >> 2] = i3;
+ break;
+ }
+ }
+ i15 = 1 << HEAPU8[i3 + 7 | 0];
+ i5 = HEAP32[i3 + 16 >> 2] | 0;
+ i4 = i5 + (i15 << 5) | 0;
+ i8 = (HEAP32[i3 + 28 >> 2] | 0) > 0 | 0;
+ if ((i15 | 0) > 0) {
+ do {
+ i12 = i5 + 8 | 0;
+ i10 = i5 + 24 | 0;
+ i11 = (HEAP32[i10 >> 2] & 64 | 0) == 0;
+ do {
+ if ((HEAP32[i12 >> 2] | 0) == 0) {
+ if (!i11 ? !((HEAP8[(HEAP32[i5 + 16 >> 2] | 0) + 5 | 0] & 3) == 0) : 0) {
+ HEAP32[i10 >> 2] = 11;
+ }
+ } else {
+ if (!i11 ? (i7 = HEAP32[i5 + 16 >> 2] | 0, !((HEAP8[i7 + 5 | 0] & 3) == 0)) : 0) {
+ _reallymarkobject(i2, i7);
+ }
+ if ((i8 | 0) == 0) {
+ i10 = HEAP32[i12 >> 2] | 0;
+ if ((i10 & 64 | 0) != 0) {
+ i8 = HEAP32[i5 >> 2] | 0;
+ if ((i10 & 15 | 0) != 4) {
+ i8 = (HEAP8[i8 + 5 | 0] & 3) != 0 | 0;
+ break;
+ }
+ if ((i8 | 0) != 0 ? !((HEAP8[i8 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i2, i8);
+ i8 = 0;
+ } else {
+ i8 = 0;
+ }
+ } else {
+ i8 = 0;
+ }
+ }
+ }
+ } while (0);
+ i5 = i5 + 32 | 0;
+ } while (i5 >>> 0 < i4 >>> 0);
+ }
+ if ((i8 | 0) == 0) {
+ i15 = i2 + 88 | 0;
+ HEAP32[i9 >> 2] = HEAP32[i15 >> 2];
+ HEAP32[i15 >> 2] = i3;
+ break;
+ } else {
+ i15 = i2 + 92 | 0;
+ HEAP32[i9 >> 2] = HEAP32[i15 >> 2];
+ HEAP32[i15 >> 2] = i3;
+ break;
+ }
+ } else {
+ i6 = 33;
+ }
+ } else {
+ i6 = 33;
+ }
+ } while (0);
+ if ((i6 | 0) == 33) {
+ i7 = i3 + 16 | 0;
+ i10 = HEAP32[i7 >> 2] | 0;
+ i6 = i10 + (1 << HEAPU8[i3 + 7 | 0] << 5) | 0;
+ i9 = i3 + 28 | 0;
+ i13 = HEAP32[i9 >> 2] | 0;
+ if ((i13 | 0) > 0) {
+ i10 = i3 + 12 | 0;
+ i11 = 0;
+ do {
+ i12 = HEAP32[i10 >> 2] | 0;
+ if ((HEAP32[i12 + (i11 << 4) + 8 >> 2] & 64 | 0) != 0 ? (i8 = HEAP32[i12 + (i11 << 4) >> 2] | 0, !((HEAP8[i8 + 5 | 0] & 3) == 0)) : 0) {
+ _reallymarkobject(i2, i8);
+ i13 = HEAP32[i9 >> 2] | 0;
+ }
+ i11 = i11 + 1 | 0;
+ } while ((i11 | 0) < (i13 | 0));
+ i7 = HEAP32[i7 >> 2] | 0;
+ } else {
+ i7 = i10;
+ }
+ if (i7 >>> 0 < i6 >>> 0) {
+ do {
+ i10 = i7 + 8 | 0;
+ i11 = HEAP32[i10 >> 2] | 0;
+ i9 = i7 + 24 | 0;
+ i8 = (HEAP32[i9 >> 2] & 64 | 0) == 0;
+ if ((i11 | 0) == 0) {
+ if (!i8 ? !((HEAP8[(HEAP32[i7 + 16 >> 2] | 0) + 5 | 0] & 3) == 0) : 0) {
+ HEAP32[i9 >> 2] = 11;
+ }
+ } else {
+ if (!i8 ? (i5 = HEAP32[i7 + 16 >> 2] | 0, !((HEAP8[i5 + 5 | 0] & 3) == 0)) : 0) {
+ _reallymarkobject(i2, i5);
+ i11 = HEAP32[i10 >> 2] | 0;
+ }
+ if ((i11 & 64 | 0) != 0 ? (i4 = HEAP32[i7 >> 2] | 0, !((HEAP8[i4 + 5 | 0] & 3) == 0)) : 0) {
+ _reallymarkobject(i2, i4);
+ }
+ }
+ i7 = i7 + 32 | 0;
+ } while (i7 >>> 0 < i6 >>> 0);
+ }
+ }
+ i3 = (HEAP32[i3 + 28 >> 2] << 4) + 32 + (32 << HEAPU8[i3 + 7 | 0]) | 0;
+ break;
+ }
+ case 8:
+ {
+ i7 = i3 + 60 | 0;
+ HEAP32[i15 >> 2] = HEAP32[i7 >> 2];
+ i4 = i2 + 88 | 0;
+ HEAP32[i7 >> 2] = HEAP32[i4 >> 2];
+ HEAP32[i4 >> 2] = i3;
+ HEAP8[i10] = HEAP8[i10] & 251;
+ i4 = i3 + 28 | 0;
+ i7 = HEAP32[i4 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i3 = 1;
+ } else {
+ i5 = i3 + 8 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ if (i7 >>> 0 < i6 >>> 0) {
+ do {
+ if ((HEAP32[i7 + 8 >> 2] & 64 | 0) != 0 ? (i11 = HEAP32[i7 >> 2] | 0, !((HEAP8[i11 + 5 | 0] & 3) == 0)) : 0) {
+ _reallymarkobject(i2, i11);
+ i6 = HEAP32[i5 >> 2] | 0;
+ }
+ i7 = i7 + 16 | 0;
+ } while (i7 >>> 0 < i6 >>> 0);
+ }
+ if ((HEAP8[i2 + 61 | 0] | 0) == 1) {
+ i3 = i3 + 32 | 0;
+ i4 = (HEAP32[i4 >> 2] | 0) + (HEAP32[i3 >> 2] << 4) | 0;
+ if (i7 >>> 0 < i4 >>> 0) {
+ do {
+ HEAP32[i7 + 8 >> 2] = 0;
+ i7 = i7 + 16 | 0;
+ } while (i7 >>> 0 < i4 >>> 0);
+ }
+ } else {
+ i3 = i3 + 32 | 0;
+ }
+ i3 = (HEAP32[i3 >> 2] << 4) + 112 | 0;
+ }
+ break;
+ }
+ case 9:
+ {
+ HEAP32[i15 >> 2] = HEAP32[i3 + 72 >> 2];
+ i5 = i3 + 32 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ if ((i4 | 0) != 0 ? !((HEAP8[i4 + 5 | 0] & 3) == 0) : 0) {
+ HEAP32[i5 >> 2] = 0;
+ }
+ i4 = HEAP32[i3 + 36 >> 2] | 0;
+ if ((i4 | 0) != 0 ? !((HEAP8[i4 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i2, i4);
+ }
+ i4 = i3 + 44 | 0;
+ i8 = HEAP32[i4 >> 2] | 0;
+ if ((i8 | 0) > 0) {
+ i5 = i3 + 8 | 0;
+ i6 = 0;
+ do {
+ i7 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i7 + (i6 << 4) + 8 >> 2] & 64 | 0) != 0 ? (i9 = HEAP32[i7 + (i6 << 4) >> 2] | 0, !((HEAP8[i9 + 5 | 0] & 3) == 0)) : 0) {
+ _reallymarkobject(i2, i9);
+ i8 = HEAP32[i4 >> 2] | 0;
+ }
+ i6 = i6 + 1 | 0;
+ } while ((i6 | 0) < (i8 | 0));
+ }
+ i5 = i3 + 40 | 0;
+ i8 = HEAP32[i5 >> 2] | 0;
+ if ((i8 | 0) > 0) {
+ i6 = i3 + 28 | 0;
+ i7 = 0;
+ do {
+ i9 = HEAP32[(HEAP32[i6 >> 2] | 0) + (i7 << 3) >> 2] | 0;
+ if ((i9 | 0) != 0 ? !((HEAP8[i9 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i2, i9);
+ i8 = HEAP32[i5 >> 2] | 0;
+ }
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) < (i8 | 0));
+ }
+ i6 = i3 + 56 | 0;
+ i8 = HEAP32[i6 >> 2] | 0;
+ if ((i8 | 0) > 0) {
+ i7 = i3 + 16 | 0;
+ i9 = 0;
+ do {
+ i10 = HEAP32[(HEAP32[i7 >> 2] | 0) + (i9 << 2) >> 2] | 0;
+ if ((i10 | 0) != 0 ? !((HEAP8[i10 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i2, i10);
+ i8 = HEAP32[i6 >> 2] | 0;
+ }
+ i9 = i9 + 1 | 0;
+ } while ((i9 | 0) < (i8 | 0));
+ }
+ i7 = i3 + 60 | 0;
+ i11 = HEAP32[i7 >> 2] | 0;
+ if ((i11 | 0) > 0) {
+ i8 = i3 + 24 | 0;
+ i9 = 0;
+ do {
+ i10 = HEAP32[(HEAP32[i8 >> 2] | 0) + (i9 * 12 | 0) >> 2] | 0;
+ if ((i10 | 0) != 0 ? !((HEAP8[i10 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i2, i10);
+ i11 = HEAP32[i7 >> 2] | 0;
+ }
+ i9 = i9 + 1 | 0;
+ } while ((i9 | 0) < (i11 | 0));
+ i8 = HEAP32[i6 >> 2] | 0;
+ }
+ i3 = (i11 * 12 | 0) + 80 + (HEAP32[i4 >> 2] << 4) + (HEAP32[i5 >> 2] << 3) + ((HEAP32[i3 + 48 >> 2] | 0) + i8 + (HEAP32[i3 + 52 >> 2] | 0) << 2) | 0;
+ break;
+ }
+ case 38:
+ {
+ HEAP32[i15 >> 2] = HEAP32[i3 + 8 >> 2];
+ i4 = i3 + 6 | 0;
+ i5 = HEAP8[i4] | 0;
+ if (i5 << 24 >> 24 == 0) {
+ i7 = i5 & 255;
+ } else {
+ i6 = 0;
+ do {
+ if ((HEAP32[i3 + (i6 << 4) + 24 >> 2] & 64 | 0) != 0 ? (i14 = HEAP32[i3 + (i6 << 4) + 16 >> 2] | 0, !((HEAP8[i14 + 5 | 0] & 3) == 0)) : 0) {
+ _reallymarkobject(i2, i14);
+ i5 = HEAP8[i4] | 0;
+ }
+ i6 = i6 + 1 | 0;
+ i7 = i5 & 255;
+ } while ((i6 | 0) < (i7 | 0));
+ }
+ i3 = (i7 << 4) + 16 | 0;
+ break;
+ }
+ case 6:
+ {
+ HEAP32[i15 >> 2] = HEAP32[i3 + 8 >> 2];
+ i4 = HEAP32[i3 + 12 >> 2] | 0;
+ if ((i4 | 0) != 0 ? !((HEAP8[i4 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i2, i4);
+ }
+ i4 = i3 + 6 | 0;
+ i6 = HEAP8[i4] | 0;
+ if (i6 << 24 >> 24 == 0) {
+ i7 = i6 & 255;
+ } else {
+ i5 = 0;
+ do {
+ i7 = HEAP32[i3 + (i5 << 2) + 16 >> 2] | 0;
+ if ((i7 | 0) != 0 ? !((HEAP8[i7 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i2, i7);
+ i6 = HEAP8[i4] | 0;
+ }
+ i5 = i5 + 1 | 0;
+ i7 = i6 & 255;
+ } while ((i5 | 0) < (i7 | 0));
+ }
+ i3 = (i7 << 2) + 16 | 0;
+ break;
+ }
+ default:
+ {
+ STACKTOP = i1;
+ return;
+ }
+ }
+ i15 = i2 + 16 | 0;
+ HEAP32[i15 >> 2] = (HEAP32[i15 >> 2] | 0) + i3;
+ STACKTOP = i1;
+ return;
+}
+function _strstr(i8, i4) {
+ i8 = i8 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 1056 | 0;
+ i6 = i1 + 1024 | 0;
+ i2 = i1;
+ i10 = HEAP8[i4] | 0;
+ if (i10 << 24 >> 24 == 0) {
+ i20 = i8;
+ STACKTOP = i1;
+ return i20 | 0;
+ }
+ i8 = _strchr(i8, i10 << 24 >> 24) | 0;
+ if ((i8 | 0) == 0) {
+ i20 = 0;
+ STACKTOP = i1;
+ return i20 | 0;
+ }
+ i13 = HEAP8[i4 + 1 | 0] | 0;
+ if (i13 << 24 >> 24 == 0) {
+ i20 = i8;
+ STACKTOP = i1;
+ return i20 | 0;
+ }
+ i11 = i8 + 1 | 0;
+ i9 = HEAP8[i11] | 0;
+ if (i9 << 24 >> 24 == 0) {
+ i20 = 0;
+ STACKTOP = i1;
+ return i20 | 0;
+ }
+ i15 = HEAP8[i4 + 2 | 0] | 0;
+ if (i15 << 24 >> 24 == 0) {
+ i2 = i13 & 255 | (i10 & 255) << 8;
+ i3 = i9;
+ i4 = HEAPU8[i8] << 8 | i9 & 255;
+ while (1) {
+ i5 = i4 & 65535;
+ if ((i5 | 0) == (i2 | 0)) {
+ break;
+ }
+ i11 = i11 + 1 | 0;
+ i4 = HEAP8[i11] | 0;
+ if (i4 << 24 >> 24 == 0) {
+ i3 = 0;
+ break;
+ } else {
+ i3 = i4;
+ i4 = i4 & 255 | i5 << 8;
+ }
+ }
+ i20 = i3 << 24 >> 24 == 0 ? 0 : i11 + -1 | 0;
+ STACKTOP = i1;
+ return i20 | 0;
+ }
+ i16 = i8 + 2 | 0;
+ i11 = HEAP8[i16] | 0;
+ if (i11 << 24 >> 24 == 0) {
+ i20 = 0;
+ STACKTOP = i1;
+ return i20 | 0;
+ }
+ i18 = HEAP8[i4 + 3 | 0] | 0;
+ if (i18 << 24 >> 24 == 0) {
+ i2 = (i13 & 255) << 16 | (i10 & 255) << 24 | (i15 & 255) << 8;
+ i4 = (i11 & 255) << 8 | (i9 & 255) << 16 | HEAPU8[i8] << 24;
+ if ((i4 | 0) == (i2 | 0)) {
+ i3 = 0;
+ } else {
+ do {
+ i16 = i16 + 1 | 0;
+ i3 = HEAP8[i16] | 0;
+ i4 = (i3 & 255 | i4) << 8;
+ i3 = i3 << 24 >> 24 == 0;
+ } while (!(i3 | (i4 | 0) == (i2 | 0)));
+ }
+ i20 = i3 ? 0 : i16 + -2 | 0;
+ STACKTOP = i1;
+ return i20 | 0;
+ }
+ i16 = i8 + 3 | 0;
+ i17 = HEAP8[i16] | 0;
+ if (i17 << 24 >> 24 == 0) {
+ i20 = 0;
+ STACKTOP = i1;
+ return i20 | 0;
+ }
+ if ((HEAP8[i4 + 4 | 0] | 0) == 0) {
+ i2 = (i13 & 255) << 16 | (i10 & 255) << 24 | (i15 & 255) << 8 | i18 & 255;
+ i3 = (i11 & 255) << 8 | (i9 & 255) << 16 | i17 & 255 | HEAPU8[i8] << 24;
+ if ((i3 | 0) == (i2 | 0)) {
+ i4 = 0;
+ } else {
+ do {
+ i16 = i16 + 1 | 0;
+ i4 = HEAP8[i16] | 0;
+ i3 = i4 & 255 | i3 << 8;
+ i4 = i4 << 24 >> 24 == 0;
+ } while (!(i4 | (i3 | 0) == (i2 | 0)));
+ }
+ i20 = i4 ? 0 : i16 + -3 | 0;
+ STACKTOP = i1;
+ return i20 | 0;
+ }
+ HEAP32[i6 + 0 >> 2] = 0;
+ HEAP32[i6 + 4 >> 2] = 0;
+ HEAP32[i6 + 8 >> 2] = 0;
+ HEAP32[i6 + 12 >> 2] = 0;
+ HEAP32[i6 + 16 >> 2] = 0;
+ HEAP32[i6 + 20 >> 2] = 0;
+ HEAP32[i6 + 24 >> 2] = 0;
+ HEAP32[i6 + 28 >> 2] = 0;
+ i9 = 0;
+ while (1) {
+ if ((HEAP8[i8 + i9 | 0] | 0) == 0) {
+ i14 = 0;
+ i12 = 80;
+ break;
+ }
+ i20 = i10 & 255;
+ i3 = i6 + (i20 >>> 5 << 2) | 0;
+ HEAP32[i3 >> 2] = HEAP32[i3 >> 2] | 1 << (i20 & 31);
+ i3 = i9 + 1 | 0;
+ HEAP32[i2 + (i20 << 2) >> 2] = i3;
+ i10 = HEAP8[i4 + i3 | 0] | 0;
+ if (i10 << 24 >> 24 == 0) {
+ break;
+ } else {
+ i9 = i3;
+ }
+ }
+ if ((i12 | 0) == 80) {
+ STACKTOP = i1;
+ return i14 | 0;
+ }
+ L49 : do {
+ if (i3 >>> 0 > 1) {
+ i14 = 1;
+ i11 = -1;
+ i12 = 0;
+ L50 : while (1) {
+ i10 = 1;
+ while (1) {
+ i13 = i14;
+ L54 : while (1) {
+ i14 = 1;
+ while (1) {
+ i15 = HEAP8[i4 + (i14 + i11) | 0] | 0;
+ i16 = HEAP8[i4 + i13 | 0] | 0;
+ if (!(i15 << 24 >> 24 == i16 << 24 >> 24)) {
+ break L54;
+ }
+ i15 = i14 + 1 | 0;
+ if ((i14 | 0) == (i10 | 0)) {
+ break;
+ }
+ i13 = i15 + i12 | 0;
+ if (i13 >>> 0 < i3 >>> 0) {
+ i14 = i15;
+ } else {
+ break L50;
+ }
+ }
+ i12 = i12 + i10 | 0;
+ i13 = i12 + 1 | 0;
+ if (!(i13 >>> 0 < i3 >>> 0)) {
+ break L50;
+ }
+ }
+ i10 = i13 - i11 | 0;
+ if (!((i15 & 255) > (i16 & 255))) {
+ break;
+ }
+ i14 = i13 + 1 | 0;
+ if (i14 >>> 0 < i3 >>> 0) {
+ i12 = i13;
+ } else {
+ break L50;
+ }
+ }
+ i14 = i12 + 2 | 0;
+ if (i14 >>> 0 < i3 >>> 0) {
+ i11 = i12;
+ i12 = i12 + 1 | 0;
+ } else {
+ i11 = i12;
+ i10 = 1;
+ break;
+ }
+ }
+ i16 = 1;
+ i12 = -1;
+ i14 = 0;
+ while (1) {
+ i13 = 1;
+ while (1) {
+ i15 = i16;
+ L69 : while (1) {
+ i18 = 1;
+ while (1) {
+ i17 = HEAP8[i4 + (i18 + i12) | 0] | 0;
+ i16 = HEAP8[i4 + i15 | 0] | 0;
+ if (!(i17 << 24 >> 24 == i16 << 24 >> 24)) {
+ break L69;
+ }
+ i16 = i18 + 1 | 0;
+ if ((i18 | 0) == (i13 | 0)) {
+ break;
+ }
+ i15 = i16 + i14 | 0;
+ if (i15 >>> 0 < i3 >>> 0) {
+ i18 = i16;
+ } else {
+ i14 = i12;
+ break L49;
+ }
+ }
+ i14 = i14 + i13 | 0;
+ i15 = i14 + 1 | 0;
+ if (!(i15 >>> 0 < i3 >>> 0)) {
+ i14 = i12;
+ break L49;
+ }
+ }
+ i13 = i15 - i12 | 0;
+ if (!((i17 & 255) < (i16 & 255))) {
+ break;
+ }
+ i16 = i15 + 1 | 0;
+ if (i16 >>> 0 < i3 >>> 0) {
+ i14 = i15;
+ } else {
+ i14 = i12;
+ break L49;
+ }
+ }
+ i16 = i14 + 2 | 0;
+ if (i16 >>> 0 < i3 >>> 0) {
+ i12 = i14;
+ i14 = i14 + 1 | 0;
+ } else {
+ i13 = 1;
+ break;
+ }
+ }
+ } else {
+ i11 = -1;
+ i14 = -1;
+ i10 = 1;
+ i13 = 1;
+ }
+ } while (0);
+ i15 = (i14 + 1 | 0) >>> 0 > (i11 + 1 | 0) >>> 0;
+ i12 = i15 ? i13 : i10;
+ i11 = i15 ? i14 : i11;
+ i10 = i11 + 1 | 0;
+ if ((_memcmp(i4, i4 + i12 | 0, i10) | 0) == 0) {
+ i15 = i3 - i12 | 0;
+ i16 = i3 | 63;
+ if ((i3 | 0) != (i12 | 0)) {
+ i14 = i8;
+ i13 = 0;
+ i17 = i8;
+ L82 : while (1) {
+ i18 = i14;
+ do {
+ if ((i17 - i18 | 0) >>> 0 < i3 >>> 0) {
+ i19 = _memchr(i17, 0, i16) | 0;
+ if ((i19 | 0) != 0) {
+ if ((i19 - i18 | 0) >>> 0 < i3 >>> 0) {
+ i14 = 0;
+ i12 = 80;
+ break L82;
+ } else {
+ i17 = i19;
+ break;
+ }
+ } else {
+ i17 = i17 + i16 | 0;
+ break;
+ }
+ }
+ } while (0);
+ i18 = HEAPU8[i14 + i9 | 0] | 0;
+ if ((1 << (i18 & 31) & HEAP32[i6 + (i18 >>> 5 << 2) >> 2] | 0) == 0) {
+ i14 = i14 + i3 | 0;
+ i13 = 0;
+ continue;
+ }
+ i20 = HEAP32[i2 + (i18 << 2) >> 2] | 0;
+ i18 = i3 - i20 | 0;
+ if ((i3 | 0) != (i20 | 0)) {
+ i14 = i14 + ((i13 | 0) != 0 & i18 >>> 0 < i12 >>> 0 ? i15 : i18) | 0;
+ i13 = 0;
+ continue;
+ }
+ i20 = i10 >>> 0 > i13 >>> 0 ? i10 : i13;
+ i18 = HEAP8[i4 + i20 | 0] | 0;
+ L96 : do {
+ if (i18 << 24 >> 24 == 0) {
+ i19 = i10;
+ } else {
+ while (1) {
+ i19 = i20 + 1 | 0;
+ if (!(i18 << 24 >> 24 == (HEAP8[i14 + i20 | 0] | 0))) {
+ break;
+ }
+ i18 = HEAP8[i4 + i19 | 0] | 0;
+ if (i18 << 24 >> 24 == 0) {
+ i19 = i10;
+ break L96;
+ } else {
+ i20 = i19;
+ }
+ }
+ i14 = i14 + (i20 - i11) | 0;
+ i13 = 0;
+ continue L82;
+ }
+ } while (0);
+ while (1) {
+ if (!(i19 >>> 0 > i13 >>> 0)) {
+ break;
+ }
+ i18 = i19 + -1 | 0;
+ if ((HEAP8[i4 + i18 | 0] | 0) == (HEAP8[i14 + i18 | 0] | 0)) {
+ i19 = i18;
+ } else {
+ break;
+ }
+ }
+ if ((i19 | 0) == (i13 | 0)) {
+ i12 = 80;
+ break;
+ }
+ i14 = i14 + i12 | 0;
+ i13 = i15;
+ }
+ if ((i12 | 0) == 80) {
+ STACKTOP = i1;
+ return i14 | 0;
+ }
+ } else {
+ i5 = i16;
+ i7 = i3;
+ }
+ } else {
+ i7 = i3 - i11 + -1 | 0;
+ i5 = i3 | 63;
+ i7 = (i11 >>> 0 > i7 >>> 0 ? i11 : i7) + 1 | 0;
+ }
+ i12 = i4 + i10 | 0;
+ i14 = i8;
+ L111 : while (1) {
+ i13 = i14;
+ do {
+ if ((i8 - i13 | 0) >>> 0 < i3 >>> 0) {
+ i15 = _memchr(i8, 0, i5) | 0;
+ if ((i15 | 0) != 0) {
+ if ((i15 - i13 | 0) >>> 0 < i3 >>> 0) {
+ i14 = 0;
+ i12 = 80;
+ break L111;
+ } else {
+ i8 = i15;
+ break;
+ }
+ } else {
+ i8 = i8 + i5 | 0;
+ break;
+ }
+ }
+ } while (0);
+ i13 = HEAPU8[i14 + i9 | 0] | 0;
+ if ((1 << (i13 & 31) & HEAP32[i6 + (i13 >>> 5 << 2) >> 2] | 0) == 0) {
+ i14 = i14 + i3 | 0;
+ continue;
+ }
+ i13 = HEAP32[i2 + (i13 << 2) >> 2] | 0;
+ if ((i3 | 0) != (i13 | 0)) {
+ i14 = i14 + (i3 - i13) | 0;
+ continue;
+ }
+ i15 = HEAP8[i12] | 0;
+ L125 : do {
+ if (i15 << 24 >> 24 == 0) {
+ i13 = i10;
+ } else {
+ i16 = i10;
+ while (1) {
+ i13 = i16 + 1 | 0;
+ if (!(i15 << 24 >> 24 == (HEAP8[i14 + i16 | 0] | 0))) {
+ break;
+ }
+ i15 = HEAP8[i4 + i13 | 0] | 0;
+ if (i15 << 24 >> 24 == 0) {
+ i13 = i10;
+ break L125;
+ } else {
+ i16 = i13;
+ }
+ }
+ i14 = i14 + (i16 - i11) | 0;
+ continue L111;
+ }
+ } while (0);
+ do {
+ if ((i13 | 0) == 0) {
+ i12 = 80;
+ break L111;
+ }
+ i13 = i13 + -1 | 0;
+ } while ((HEAP8[i4 + i13 | 0] | 0) == (HEAP8[i14 + i13 | 0] | 0));
+ i14 = i14 + i7 | 0;
+ }
+ if ((i12 | 0) == 80) {
+ STACKTOP = i1;
+ return i14 | 0;
+ }
+ return 0;
+}
+function _str_format(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, d21 = 0.0, i22 = 0;
+ i12 = STACKTOP;
+ STACKTOP = STACKTOP + 1104 | 0;
+ i4 = i12;
+ i7 = i12 + 1060 | 0;
+ i9 = i12 + 1082 | 0;
+ i20 = i12 + 1056 | 0;
+ i10 = i12 + 16 | 0;
+ i5 = i12 + 1064 | 0;
+ i6 = i12 + 8 | 0;
+ i8 = _lua_gettop(i2) | 0;
+ i16 = _luaL_checklstring(i2, 1, i20) | 0;
+ i20 = HEAP32[i20 >> 2] | 0;
+ i3 = i16 + i20 | 0;
+ _luaL_buffinit(i2, i10);
+ L1 : do {
+ if ((i20 | 0) > 0) {
+ i1 = i10 + 8 | 0;
+ i13 = i10 + 4 | 0;
+ i14 = i5 + 1 | 0;
+ i19 = 1;
+ L3 : while (1) {
+ while (1) {
+ i15 = HEAP8[i16] | 0;
+ if (i15 << 24 >> 24 == 37) {
+ i18 = i16 + 1 | 0;
+ if ((HEAP8[i18] | 0) != 37) {
+ break;
+ }
+ i15 = HEAP32[i1 >> 2] | 0;
+ if (i15 >>> 0 < (HEAP32[i13 >> 2] | 0) >>> 0) {
+ i17 = 37;
+ } else {
+ _luaL_prepbuffsize(i10, 1) | 0;
+ i15 = HEAP32[i1 >> 2] | 0;
+ i17 = HEAP8[i18] | 0;
+ }
+ HEAP32[i1 >> 2] = i15 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i15 | 0] = i17;
+ i16 = i16 + 2 | 0;
+ } else {
+ i17 = HEAP32[i1 >> 2] | 0;
+ if (!(i17 >>> 0 < (HEAP32[i13 >> 2] | 0) >>> 0)) {
+ _luaL_prepbuffsize(i10, 1) | 0;
+ i17 = HEAP32[i1 >> 2] | 0;
+ i15 = HEAP8[i16] | 0;
+ }
+ HEAP32[i1 >> 2] = i17 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i17 | 0] = i15;
+ i16 = i16 + 1 | 0;
+ }
+ if (!(i16 >>> 0 < i3 >>> 0)) {
+ break L1;
+ }
+ }
+ i17 = _luaL_prepbuffsize(i10, 512) | 0;
+ i15 = i19 + 1 | 0;
+ if ((i19 | 0) >= (i8 | 0)) {
+ _luaL_argerror(i2, i15, 7648) | 0;
+ }
+ i19 = HEAP8[i18] | 0;
+ L22 : do {
+ if (i19 << 24 >> 24 == 0) {
+ i19 = 0;
+ i20 = i18;
+ } else {
+ i20 = i18;
+ while (1) {
+ i16 = i20 + 1 | 0;
+ if ((_memchr(7800, i19 << 24 >> 24, 6) | 0) == 0) {
+ break L22;
+ }
+ i19 = HEAP8[i16] | 0;
+ if (i19 << 24 >> 24 == 0) {
+ i19 = 0;
+ i20 = i16;
+ break;
+ } else {
+ i20 = i16;
+ }
+ }
+ }
+ } while (0);
+ i16 = i18;
+ if ((i20 - i16 | 0) >>> 0 > 5) {
+ _luaL_error(i2, 7808, i4) | 0;
+ i19 = HEAP8[i20] | 0;
+ }
+ i19 = ((i19 & 255) + -48 | 0) >>> 0 < 10 ? i20 + 1 | 0 : i20;
+ i19 = ((HEAPU8[i19] | 0) + -48 | 0) >>> 0 < 10 ? i19 + 1 | 0 : i19;
+ i20 = HEAP8[i19] | 0;
+ if (i20 << 24 >> 24 == 46) {
+ i20 = i19 + 1 | 0;
+ i19 = ((HEAPU8[i20] | 0) + -48 | 0) >>> 0 < 10 ? i19 + 2 | 0 : i20;
+ i19 = ((HEAPU8[i19] | 0) + -48 | 0) >>> 0 < 10 ? i19 + 1 | 0 : i19;
+ i20 = HEAP8[i19] | 0;
+ }
+ if (((i20 & 255) + -48 | 0) >>> 0 < 10) {
+ _luaL_error(i2, 7840, i4) | 0;
+ }
+ HEAP8[i5] = 37;
+ i16 = i19 - i16 | 0;
+ _memcpy(i14 | 0, i18 | 0, i16 + 1 | 0) | 0;
+ HEAP8[i5 + (i16 + 2) | 0] = 0;
+ i16 = i19 + 1 | 0;
+ i18 = HEAP8[i19] | 0;
+ L36 : do {
+ switch (i18 | 0) {
+ case 115:
+ {
+ i18 = _luaL_tolstring(i2, i15, i6) | 0;
+ if ((_strchr(i5, 46) | 0) == 0 ? (HEAP32[i6 >> 2] | 0) >>> 0 > 99 : 0) {
+ _luaL_addvalue(i10);
+ i17 = 0;
+ break L36;
+ }
+ HEAP32[i4 >> 2] = i18;
+ i17 = _sprintf(i17 | 0, i5 | 0, i4 | 0) | 0;
+ _lua_settop(i2, -2);
+ break;
+ }
+ case 88:
+ case 120:
+ case 117:
+ case 111:
+ {
+ d21 = +_luaL_checknumber(i2, i15);
+ i18 = ~~d21 >>> 0;
+ d21 = d21 - +(i18 >>> 0);
+ if (!(d21 > -1.0 & d21 < 1.0)) {
+ _luaL_argerror(i2, i15, 7696) | 0;
+ }
+ i20 = _strlen(i5 | 0) | 0;
+ i22 = i5 + (i20 + -1) | 0;
+ i19 = HEAP8[i22] | 0;
+ HEAP8[i22] = 108;
+ HEAP8[i22 + 1 | 0] = 0;
+ HEAP8[i5 + i20 | 0] = i19;
+ HEAP8[i5 + (i20 + 1) | 0] = 0;
+ HEAP32[i4 >> 2] = i18;
+ i17 = _sprintf(i17 | 0, i5 | 0, i4 | 0) | 0;
+ break;
+ }
+ case 99:
+ {
+ HEAP32[i4 >> 2] = _luaL_checkinteger(i2, i15) | 0;
+ i17 = _sprintf(i17 | 0, i5 | 0, i4 | 0) | 0;
+ break;
+ }
+ case 113:
+ {
+ i17 = _luaL_checklstring(i2, i15, i7) | 0;
+ i18 = HEAP32[i1 >> 2] | 0;
+ if (!(i18 >>> 0 < (HEAP32[i13 >> 2] | 0) >>> 0)) {
+ _luaL_prepbuffsize(i10, 1) | 0;
+ i18 = HEAP32[i1 >> 2] | 0;
+ }
+ HEAP32[i1 >> 2] = i18 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i18 | 0] = 34;
+ i22 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i22 + -1;
+ if ((i22 | 0) != 0) {
+ while (1) {
+ i18 = HEAP8[i17] | 0;
+ do {
+ if (i18 << 24 >> 24 == 10 | i18 << 24 >> 24 == 92 | i18 << 24 >> 24 == 34) {
+ i18 = HEAP32[i1 >> 2] | 0;
+ if (!(i18 >>> 0 < (HEAP32[i13 >> 2] | 0) >>> 0)) {
+ _luaL_prepbuffsize(i10, 1) | 0;
+ i18 = HEAP32[i1 >> 2] | 0;
+ }
+ HEAP32[i1 >> 2] = i18 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i18 | 0] = 92;
+ i18 = HEAP32[i1 >> 2] | 0;
+ if (!(i18 >>> 0 < (HEAP32[i13 >> 2] | 0) >>> 0)) {
+ _luaL_prepbuffsize(i10, 1) | 0;
+ i18 = HEAP32[i1 >> 2] | 0;
+ }
+ i22 = HEAP8[i17] | 0;
+ HEAP32[i1 >> 2] = i18 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i18 | 0] = i22;
+ } else if (i18 << 24 >> 24 == 0) {
+ i18 = 0;
+ i11 = 44;
+ } else {
+ if ((_iscntrl(i18 & 255 | 0) | 0) != 0) {
+ i18 = HEAP8[i17] | 0;
+ i11 = 44;
+ break;
+ }
+ i18 = HEAP32[i1 >> 2] | 0;
+ if (!(i18 >>> 0 < (HEAP32[i13 >> 2] | 0) >>> 0)) {
+ _luaL_prepbuffsize(i10, 1) | 0;
+ i18 = HEAP32[i1 >> 2] | 0;
+ }
+ i22 = HEAP8[i17] | 0;
+ HEAP32[i1 >> 2] = i18 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i18 | 0] = i22;
+ }
+ } while (0);
+ if ((i11 | 0) == 44) {
+ i11 = 0;
+ i18 = i18 & 255;
+ if (((HEAPU8[i17 + 1 | 0] | 0) + -48 | 0) >>> 0 < 10) {
+ HEAP32[i4 >> 2] = i18;
+ _sprintf(i9 | 0, 7792, i4 | 0) | 0;
+ } else {
+ HEAP32[i4 >> 2] = i18;
+ _sprintf(i9 | 0, 7784, i4 | 0) | 0;
+ }
+ _luaL_addstring(i10, i9);
+ }
+ i22 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i22 + -1;
+ if ((i22 | 0) == 0) {
+ break;
+ } else {
+ i17 = i17 + 1 | 0;
+ }
+ }
+ }
+ i17 = HEAP32[i1 >> 2] | 0;
+ if (!(i17 >>> 0 < (HEAP32[i13 >> 2] | 0) >>> 0)) {
+ _luaL_prepbuffsize(i10, 1) | 0;
+ i17 = HEAP32[i1 >> 2] | 0;
+ }
+ HEAP32[i1 >> 2] = i17 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i17 | 0] = 34;
+ i17 = 0;
+ break;
+ }
+ case 71:
+ case 103:
+ case 102:
+ case 69:
+ case 101:
+ {
+ HEAP8[i5 + (_strlen(i5 | 0) | 0) | 0] = 0;
+ d21 = +_luaL_checknumber(i2, i15);
+ HEAPF64[tempDoublePtr >> 3] = d21;
+ HEAP32[i4 >> 2] = HEAP32[tempDoublePtr >> 2];
+ HEAP32[i4 + 4 >> 2] = HEAP32[tempDoublePtr + 4 >> 2];
+ i17 = _sprintf(i17 | 0, i5 | 0, i4 | 0) | 0;
+ break;
+ }
+ case 105:
+ case 100:
+ {
+ d21 = +_luaL_checknumber(i2, i15);
+ i18 = ~~d21;
+ d21 = d21 - +(i18 | 0);
+ if (!(d21 > -1.0 & d21 < 1.0)) {
+ _luaL_argerror(i2, i15, 7664) | 0;
+ }
+ i22 = _strlen(i5 | 0) | 0;
+ i19 = i5 + (i22 + -1) | 0;
+ i20 = HEAP8[i19] | 0;
+ HEAP8[i19] = 108;
+ HEAP8[i19 + 1 | 0] = 0;
+ HEAP8[i5 + i22 | 0] = i20;
+ HEAP8[i5 + (i22 + 1) | 0] = 0;
+ HEAP32[i4 >> 2] = i18;
+ i17 = _sprintf(i17 | 0, i5 | 0, i4 | 0) | 0;
+ break;
+ }
+ default:
+ {
+ break L3;
+ }
+ }
+ } while (0);
+ HEAP32[i1 >> 2] = (HEAP32[i1 >> 2] | 0) + i17;
+ if (i16 >>> 0 < i3 >>> 0) {
+ i19 = i15;
+ } else {
+ break L1;
+ }
+ }
+ HEAP32[i4 >> 2] = i18;
+ i22 = _luaL_error(i2, 7744, i4) | 0;
+ STACKTOP = i12;
+ return i22 | 0;
+ }
+ } while (0);
+ _luaL_pushresult(i10);
+ i22 = 1;
+ STACKTOP = i12;
+ return i22 | 0;
+}
+function _luaD_precall(i3, i17, i4) {
+ i3 = i3 | 0;
+ i17 = i17 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i8 = i1;
+ i6 = i3 + 28 | 0;
+ i2 = i3 + 8 | 0;
+ i13 = i3 + 24 | 0;
+ i14 = i3 + 32 | 0;
+ while (1) {
+ i15 = HEAP32[i6 >> 2] | 0;
+ i16 = i17;
+ i12 = i15;
+ i5 = i16 - i12 | 0;
+ i11 = HEAP32[i17 + 8 >> 2] & 63;
+ if ((i11 | 0) == 38) {
+ i11 = 4;
+ break;
+ } else if ((i11 | 0) == 22) {
+ i11 = 3;
+ break;
+ } else if ((i11 | 0) == 6) {
+ i11 = 31;
+ break;
+ }
+ i11 = _luaT_gettmbyobj(i3, i17, 16) | 0;
+ i15 = i16 - (HEAP32[i6 >> 2] | 0) | 0;
+ i16 = i11 + 8 | 0;
+ if ((HEAP32[i16 >> 2] & 15 | 0) != 6) {
+ i11 = 54;
+ break;
+ }
+ i19 = HEAP32[i2 >> 2] | 0;
+ if (i19 >>> 0 > i17 >>> 0) {
+ while (1) {
+ i18 = i19 + -16 | 0;
+ i22 = i18;
+ i21 = HEAP32[i22 + 4 >> 2] | 0;
+ i20 = i19;
+ HEAP32[i20 >> 2] = HEAP32[i22 >> 2];
+ HEAP32[i20 + 4 >> 2] = i21;
+ HEAP32[i19 + 8 >> 2] = HEAP32[i19 + -8 >> 2];
+ if (i18 >>> 0 > i17 >>> 0) {
+ i19 = i18;
+ } else {
+ break;
+ }
+ }
+ i19 = HEAP32[i2 >> 2] | 0;
+ }
+ i17 = i19 + 16 | 0;
+ HEAP32[i2 >> 2] = i17;
+ if (((HEAP32[i13 >> 2] | 0) - i17 | 0) < 16) {
+ i18 = HEAP32[i14 >> 2] | 0;
+ if ((i18 | 0) > 1e6) {
+ i11 = 60;
+ break;
+ }
+ i17 = (i17 - (HEAP32[i6 >> 2] | 0) >> 4) + 5 | 0;
+ i18 = i18 << 1;
+ i18 = (i18 | 0) > 1e6 ? 1e6 : i18;
+ i17 = (i18 | 0) < (i17 | 0) ? i17 : i18;
+ if ((i17 | 0) > 1e6) {
+ i11 = 62;
+ break;
+ }
+ _luaD_reallocstack(i3, i17);
+ }
+ i22 = HEAP32[i6 >> 2] | 0;
+ i17 = i22 + i15 | 0;
+ i19 = i11;
+ i20 = HEAP32[i19 + 4 >> 2] | 0;
+ i21 = i17;
+ HEAP32[i21 >> 2] = HEAP32[i19 >> 2];
+ HEAP32[i21 + 4 >> 2] = i20;
+ HEAP32[i22 + (i15 + 8) >> 2] = HEAP32[i16 >> 2];
+ }
+ if ((i11 | 0) == 3) {
+ i10 = i17;
+ } else if ((i11 | 0) == 4) {
+ i10 = (HEAP32[i17 >> 2] | 0) + 12 | 0;
+ } else if ((i11 | 0) == 31) {
+ i10 = HEAP32[(HEAP32[i17 >> 2] | 0) + 12 >> 2] | 0;
+ i18 = HEAP32[i2 >> 2] | 0;
+ i16 = i18;
+ i11 = i10 + 78 | 0;
+ i17 = HEAPU8[i11] | 0;
+ do {
+ if (((HEAP32[i13 >> 2] | 0) - i16 >> 4 | 0) <= (i17 | 0)) {
+ i13 = HEAP32[i14 >> 2] | 0;
+ if ((i13 | 0) > 1e6) {
+ _luaD_throw(i3, 6);
+ }
+ i12 = i17 + 5 + (i16 - i12 >> 4) | 0;
+ i13 = i13 << 1;
+ i13 = (i13 | 0) > 1e6 ? 1e6 : i13;
+ i12 = (i13 | 0) < (i12 | 0) ? i12 : i13;
+ if ((i12 | 0) > 1e6) {
+ _luaD_reallocstack(i3, 1000200);
+ _luaG_runerror(i3, 2224, i8);
+ } else {
+ _luaD_reallocstack(i3, i12);
+ i7 = HEAP32[i6 >> 2] | 0;
+ i9 = HEAP32[i2 >> 2] | 0;
+ break;
+ }
+ } else {
+ i7 = i15;
+ i9 = i18;
+ }
+ } while (0);
+ i6 = i7 + i5 | 0;
+ i22 = i9 - i6 >> 4;
+ i12 = i22 + -1 | 0;
+ i8 = i10 + 76 | 0;
+ i13 = HEAP8[i8] | 0;
+ if ((i22 | 0) > (i13 & 255 | 0)) {
+ i8 = i13;
+ } else {
+ i13 = i9;
+ while (1) {
+ i9 = i13 + 16 | 0;
+ HEAP32[i2 >> 2] = i9;
+ HEAP32[i13 + 8 >> 2] = 0;
+ i12 = i12 + 1 | 0;
+ i13 = HEAP8[i8] | 0;
+ if ((i12 | 0) < (i13 & 255 | 0)) {
+ i13 = i9;
+ } else {
+ i8 = i13;
+ break;
+ }
+ }
+ }
+ if ((HEAP8[i10 + 77 | 0] | 0) != 0) {
+ i5 = i8 & 255;
+ if (!(i8 << 24 >> 24 == 0) ? (i22 = 0 - i12 | 0, HEAP32[i2 >> 2] = i9 + 16, i19 = i9 + (i22 << 4) | 0, i20 = HEAP32[i19 + 4 >> 2] | 0, i21 = i9, HEAP32[i21 >> 2] = HEAP32[i19 >> 2], HEAP32[i21 + 4 >> 2] = i20, i22 = i9 + (i22 << 4) + 8 | 0, HEAP32[i9 + 8 >> 2] = HEAP32[i22 >> 2], HEAP32[i22 >> 2] = 0, (i8 & 255) > 1) : 0) {
+ i7 = 1;
+ do {
+ i21 = HEAP32[i2 >> 2] | 0;
+ i22 = i7 - i12 | 0;
+ HEAP32[i2 >> 2] = i21 + 16;
+ i18 = i9 + (i22 << 4) | 0;
+ i19 = HEAP32[i18 + 4 >> 2] | 0;
+ i20 = i21;
+ HEAP32[i20 >> 2] = HEAP32[i18 >> 2];
+ HEAP32[i20 + 4 >> 2] = i19;
+ i22 = i9 + (i22 << 4) + 8 | 0;
+ HEAP32[i21 + 8 >> 2] = HEAP32[i22 >> 2];
+ HEAP32[i22 >> 2] = 0;
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) < (i5 | 0));
+ }
+ } else {
+ i9 = i7 + (i5 + 16) | 0;
+ }
+ i7 = i3 + 16 | 0;
+ i5 = HEAP32[(HEAP32[i7 >> 2] | 0) + 12 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i5 = _luaE_extendCI(i3) | 0;
+ }
+ HEAP32[i7 >> 2] = i5;
+ HEAP16[i5 + 16 >> 1] = i4;
+ HEAP32[i5 >> 2] = i6;
+ HEAP32[i5 + 24 >> 2] = i9;
+ i22 = i9 + (HEAPU8[i11] << 4) | 0;
+ HEAP32[i5 + 4 >> 2] = i22;
+ i4 = i5 + 28 | 0;
+ HEAP32[i4 >> 2] = HEAP32[i10 + 12 >> 2];
+ i6 = i5 + 18 | 0;
+ HEAP8[i6] = 1;
+ HEAP32[i2 >> 2] = i22;
+ if ((HEAP32[(HEAP32[i3 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ _luaC_step(i3);
+ }
+ if ((HEAP8[i3 + 40 | 0] & 1) == 0) {
+ i22 = 0;
+ STACKTOP = i1;
+ return i22 | 0;
+ }
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + 4;
+ i2 = HEAP32[i5 + 8 >> 2] | 0;
+ if (!((HEAP8[i2 + 18 | 0] & 1) == 0) ? (HEAP32[(HEAP32[i2 + 28 >> 2] | 0) + -4 >> 2] & 63 | 0) == 30 : 0) {
+ HEAP8[i6] = HEAPU8[i6] | 64;
+ i2 = 4;
+ } else {
+ i2 = 0;
+ }
+ _luaD_hook(i3, i2, -1);
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + -4;
+ i22 = 0;
+ STACKTOP = i1;
+ return i22 | 0;
+ } else if ((i11 | 0) == 54) {
+ _luaG_typeerror(i3, i17, 2520);
+ } else if ((i11 | 0) == 60) {
+ _luaD_throw(i3, 6);
+ } else if ((i11 | 0) == 62) {
+ _luaD_reallocstack(i3, 1000200);
+ _luaG_runerror(i3, 2224, i8);
+ }
+ i7 = HEAP32[i10 >> 2] | 0;
+ i9 = HEAP32[i2 >> 2] | 0;
+ do {
+ if (((HEAP32[i13 >> 2] | 0) - i9 | 0) < 336) {
+ i10 = HEAP32[i14 >> 2] | 0;
+ if ((i10 | 0) > 1e6) {
+ _luaD_throw(i3, 6);
+ }
+ i9 = (i9 - i12 >> 4) + 25 | 0;
+ i10 = i10 << 1;
+ i10 = (i10 | 0) > 1e6 ? 1e6 : i10;
+ i9 = (i10 | 0) < (i9 | 0) ? i9 : i10;
+ if ((i9 | 0) > 1e6) {
+ _luaD_reallocstack(i3, 1000200);
+ _luaG_runerror(i3, 2224, i8);
+ } else {
+ _luaD_reallocstack(i3, i9);
+ break;
+ }
+ }
+ } while (0);
+ i8 = i3 + 16 | 0;
+ i9 = HEAP32[(HEAP32[i8 >> 2] | 0) + 12 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ i9 = _luaE_extendCI(i3) | 0;
+ }
+ HEAP32[i8 >> 2] = i9;
+ HEAP16[i9 + 16 >> 1] = i4;
+ HEAP32[i9 >> 2] = (HEAP32[i6 >> 2] | 0) + i5;
+ HEAP32[i9 + 4 >> 2] = (HEAP32[i2 >> 2] | 0) + 320;
+ HEAP8[i9 + 18 | 0] = 0;
+ if ((HEAP32[(HEAP32[i3 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ _luaC_step(i3);
+ }
+ i5 = i3 + 40 | 0;
+ if (!((HEAP8[i5] & 1) == 0)) {
+ _luaD_hook(i3, 0, -1);
+ }
+ i7 = FUNCTION_TABLE_ii[i7 & 255](i3) | 0;
+ i7 = (HEAP32[i2 >> 2] | 0) + (0 - i7 << 4) | 0;
+ i4 = HEAP32[i8 >> 2] | 0;
+ i5 = HEAPU8[i5] | 0;
+ if ((i5 & 6 | 0) == 0) {
+ i5 = i7;
+ i6 = i4 + 8 | 0;
+ } else {
+ if ((i5 & 2 | 0) == 0) {
+ i5 = i7;
+ } else {
+ i5 = i7 - (HEAP32[i6 >> 2] | 0) | 0;
+ _luaD_hook(i3, 1, -1);
+ i5 = (HEAP32[i6 >> 2] | 0) + i5 | 0;
+ }
+ i6 = i4 + 8 | 0;
+ HEAP32[i3 + 20 >> 2] = HEAP32[(HEAP32[i6 >> 2] | 0) + 28 >> 2];
+ }
+ i3 = HEAP32[i4 >> 2] | 0;
+ i4 = HEAP16[i4 + 16 >> 1] | 0;
+ HEAP32[i8 >> 2] = HEAP32[i6 >> 2];
+ L82 : do {
+ if (!(i4 << 16 >> 16 == 0)) {
+ i4 = i4 << 16 >> 16;
+ while (1) {
+ if (!(i5 >>> 0 < (HEAP32[i2 >> 2] | 0) >>> 0)) {
+ break;
+ }
+ i6 = i3 + 16 | 0;
+ i20 = i5;
+ i21 = HEAP32[i20 + 4 >> 2] | 0;
+ i22 = i3;
+ HEAP32[i22 >> 2] = HEAP32[i20 >> 2];
+ HEAP32[i22 + 4 >> 2] = i21;
+ HEAP32[i3 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ i4 = i4 + -1 | 0;
+ if ((i4 | 0) == 0) {
+ i3 = i6;
+ break L82;
+ }
+ i5 = i5 + 16 | 0;
+ i3 = i6;
+ }
+ if ((i4 | 0) > 0) {
+ i5 = i4;
+ i6 = i3;
+ while (1) {
+ i5 = i5 + -1 | 0;
+ HEAP32[i6 + 8 >> 2] = 0;
+ if ((i5 | 0) <= 0) {
+ break;
+ } else {
+ i6 = i6 + 16 | 0;
+ }
+ }
+ i3 = i3 + (i4 << 4) | 0;
+ }
+ }
+ } while (0);
+ HEAP32[i2 >> 2] = i3;
+ i22 = 1;
+ STACKTOP = i1;
+ return i22 | 0;
+}
+function _lua_getinfo(i1, i6, i29) {
+ i1 = i1 | 0;
+ i6 = i6 | 0;
+ i29 = i29 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i30 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i3;
+ if ((HEAP8[i6] | 0) == 62) {
+ i10 = i1 + 8 | 0;
+ i7 = (HEAP32[i10 >> 2] | 0) + -16 | 0;
+ HEAP32[i10 >> 2] = i7;
+ i6 = i6 + 1 | 0;
+ i10 = 0;
+ } else {
+ i7 = HEAP32[i29 + 96 >> 2] | 0;
+ i10 = i7;
+ i7 = HEAP32[i7 >> 2] | 0;
+ }
+ i8 = i7 + 8 | 0;
+ if ((HEAP32[i8 >> 2] & 31 | 0) == 6) {
+ i9 = HEAP32[i7 >> 2] | 0;
+ } else {
+ i9 = 0;
+ }
+ i34 = HEAP8[i6] | 0;
+ L8 : do {
+ if (i34 << 24 >> 24 == 0) {
+ i33 = 1;
+ } else {
+ i12 = (i9 | 0) == 0;
+ i27 = i29 + 16 | 0;
+ i28 = i29 + 24 | 0;
+ i21 = i29 + 28 | 0;
+ i25 = i29 + 12 | 0;
+ i26 = i29 + 36 | 0;
+ i19 = i9 + 4 | 0;
+ i24 = i9 + 12 | 0;
+ i18 = (i10 | 0) == 0;
+ i23 = i29 + 20 | 0;
+ i17 = i10 + 18 | 0;
+ i22 = i10 + 28 | 0;
+ i15 = i29 + 32 | 0;
+ i14 = i29 + 34 | 0;
+ i13 = i29 + 33 | 0;
+ i11 = i9 + 6 | 0;
+ i16 = i29 + 35 | 0;
+ i20 = i29 + 8 | 0;
+ i30 = i29 + 4 | 0;
+ i29 = i10 + 8 | 0;
+ i31 = i1 + 12 | 0;
+ i32 = i6;
+ i33 = 1;
+ while (1) {
+ L12 : do {
+ switch (i34 << 24 >> 24 | 0) {
+ case 116:
+ {
+ if (i18) {
+ i34 = 0;
+ } else {
+ i34 = HEAPU8[i17] & 64;
+ }
+ HEAP8[i16] = i34;
+ break;
+ }
+ case 110:
+ {
+ L18 : do {
+ if ((!i18 ? (HEAP8[i17] & 64) == 0 : 0) ? (i5 = HEAP32[i29 >> 2] | 0, !((HEAP8[i5 + 18 | 0] & 1) == 0)) : 0) {
+ i36 = HEAP32[(HEAP32[HEAP32[i5 >> 2] >> 2] | 0) + 12 >> 2] | 0;
+ i35 = HEAP32[i36 + 12 >> 2] | 0;
+ i34 = ((HEAP32[i5 + 28 >> 2] | 0) - i35 >> 2) + -1 | 0;
+ i35 = HEAP32[i35 + (i34 << 2) >> 2] | 0;
+ switch (i35 & 63 | 0) {
+ case 10:
+ case 8:
+ {
+ i34 = 1;
+ i4 = 46;
+ break;
+ }
+ case 24:
+ {
+ i34 = 5;
+ i4 = 46;
+ break;
+ }
+ case 13:
+ {
+ i34 = 6;
+ i4 = 46;
+ break;
+ }
+ case 14:
+ {
+ i34 = 7;
+ i4 = 46;
+ break;
+ }
+ case 15:
+ {
+ i34 = 8;
+ i4 = 46;
+ break;
+ }
+ case 16:
+ {
+ i34 = 9;
+ i4 = 46;
+ break;
+ }
+ case 17:
+ {
+ i34 = 10;
+ i4 = 46;
+ break;
+ }
+ case 18:
+ {
+ i34 = 11;
+ i4 = 46;
+ break;
+ }
+ case 19:
+ {
+ i34 = 12;
+ i4 = 46;
+ break;
+ }
+ case 21:
+ {
+ i34 = 4;
+ i4 = 46;
+ break;
+ }
+ case 25:
+ {
+ i34 = 13;
+ i4 = 46;
+ break;
+ }
+ case 26:
+ {
+ i34 = 14;
+ i4 = 46;
+ break;
+ }
+ case 22:
+ {
+ i34 = 15;
+ i4 = 46;
+ break;
+ }
+ case 7:
+ case 6:
+ case 12:
+ {
+ i34 = 0;
+ i4 = 46;
+ break;
+ }
+ case 34:
+ {
+ i34 = 2120;
+ i35 = 2120;
+ break;
+ }
+ case 30:
+ case 29:
+ {
+ i36 = _getobjname(i36, i34, i35 >>> 6 & 255, i30) | 0;
+ HEAP32[i20 >> 2] = i36;
+ if ((i36 | 0) == 0) {
+ break L18;
+ } else {
+ break L12;
+ }
+ }
+ default:
+ {
+ i4 = 47;
+ break L18;
+ }
+ }
+ if ((i4 | 0) == 46) {
+ i4 = 0;
+ i34 = (HEAP32[(HEAP32[i31 >> 2] | 0) + (i34 << 2) + 184 >> 2] | 0) + 16 | 0;
+ i35 = 2136;
+ }
+ HEAP32[i30 >> 2] = i34;
+ HEAP32[i20 >> 2] = i35;
+ break L12;
+ } else {
+ i4 = 47;
+ }
+ } while (0);
+ if ((i4 | 0) == 47) {
+ i4 = 0;
+ HEAP32[i20 >> 2] = 0;
+ }
+ HEAP32[i20 >> 2] = 2112;
+ HEAP32[i30 >> 2] = 0;
+ break;
+ }
+ case 108:
+ {
+ if (!i18 ? !((HEAP8[i17] & 1) == 0) : 0) {
+ i35 = HEAP32[(HEAP32[HEAP32[i10 >> 2] >> 2] | 0) + 12 >> 2] | 0;
+ i34 = HEAP32[i35 + 20 >> 2] | 0;
+ if ((i34 | 0) == 0) {
+ i34 = 0;
+ } else {
+ i34 = HEAP32[i34 + (((HEAP32[i22 >> 2] | 0) - (HEAP32[i35 + 12 >> 2] | 0) >> 2) + -1 << 2) >> 2] | 0;
+ }
+ } else {
+ i34 = -1;
+ }
+ HEAP32[i23 >> 2] = i34;
+ break;
+ }
+ case 83:
+ {
+ if (!i12 ? (HEAP8[i19] | 0) != 38 : 0) {
+ i34 = HEAP32[i24 >> 2] | 0;
+ i35 = HEAP32[i34 + 36 >> 2] | 0;
+ if ((i35 | 0) == 0) {
+ i35 = 2168;
+ } else {
+ i35 = i35 + 16 | 0;
+ }
+ HEAP32[i27 >> 2] = i35;
+ i36 = HEAP32[i34 + 64 >> 2] | 0;
+ HEAP32[i28 >> 2] = i36;
+ HEAP32[i21 >> 2] = HEAP32[i34 + 68 >> 2];
+ i34 = (i36 | 0) == 0 ? 2176 : 2184;
+ } else {
+ HEAP32[i27 >> 2] = 2152;
+ HEAP32[i28 >> 2] = -1;
+ HEAP32[i21 >> 2] = -1;
+ i35 = 2152;
+ i34 = 2160;
+ }
+ HEAP32[i25 >> 2] = i34;
+ _luaO_chunkid(i26, i35, 60);
+ break;
+ }
+ case 117:
+ {
+ if (!i12) {
+ HEAP8[i15] = HEAP8[i11] | 0;
+ if ((HEAP8[i19] | 0) != 38) {
+ HEAP8[i14] = HEAP8[(HEAP32[i24 >> 2] | 0) + 77 | 0] | 0;
+ HEAP8[i13] = HEAP8[(HEAP32[i24 >> 2] | 0) + 76 | 0] | 0;
+ break L12;
+ }
+ } else {
+ HEAP8[i15] = 0;
+ }
+ HEAP8[i14] = 1;
+ HEAP8[i13] = 0;
+ break;
+ }
+ case 102:
+ case 76:
+ {
+ break;
+ }
+ default:
+ {
+ i33 = 0;
+ }
+ }
+ } while (0);
+ i32 = i32 + 1 | 0;
+ i34 = HEAP8[i32] | 0;
+ if (i34 << 24 >> 24 == 0) {
+ break L8;
+ }
+ }
+ }
+ } while (0);
+ if ((_strchr(i6, 102) | 0) != 0) {
+ i36 = i1 + 8 | 0;
+ i35 = HEAP32[i36 >> 2] | 0;
+ i31 = i7;
+ i32 = HEAP32[i31 + 4 >> 2] | 0;
+ i34 = i35;
+ HEAP32[i34 >> 2] = HEAP32[i31 >> 2];
+ HEAP32[i34 + 4 >> 2] = i32;
+ HEAP32[i35 + 8 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i36 >> 2] = (HEAP32[i36 >> 2] | 0) + 16;
+ }
+ if ((_strchr(i6, 76) | 0) == 0) {
+ STACKTOP = i3;
+ return i33 | 0;
+ }
+ if ((i9 | 0) != 0 ? (HEAP8[i9 + 4 | 0] | 0) != 38 : 0) {
+ i6 = i9 + 12 | 0;
+ i5 = HEAP32[(HEAP32[i6 >> 2] | 0) + 20 >> 2] | 0;
+ i4 = _luaH_new(i1) | 0;
+ i36 = i1 + 8 | 0;
+ i35 = HEAP32[i36 >> 2] | 0;
+ HEAP32[i35 >> 2] = i4;
+ HEAP32[i35 + 8 >> 2] = 69;
+ HEAP32[i36 >> 2] = (HEAP32[i36 >> 2] | 0) + 16;
+ HEAP32[i2 >> 2] = 1;
+ HEAP32[i2 + 8 >> 2] = 1;
+ if ((HEAP32[(HEAP32[i6 >> 2] | 0) + 52 >> 2] | 0) > 0) {
+ i7 = 0;
+ } else {
+ STACKTOP = i3;
+ return i33 | 0;
+ }
+ do {
+ _luaH_setint(i1, i4, HEAP32[i5 + (i7 << 2) >> 2] | 0, i2);
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) < (HEAP32[(HEAP32[i6 >> 2] | 0) + 52 >> 2] | 0));
+ STACKTOP = i3;
+ return i33 | 0;
+ }
+ i36 = i1 + 8 | 0;
+ i35 = HEAP32[i36 >> 2] | 0;
+ HEAP32[i35 + 8 >> 2] = 0;
+ HEAP32[i36 >> 2] = i35 + 16;
+ STACKTOP = i3;
+ return i33 | 0;
+}
+function _read_long_string(i3, i1, i5) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0;
+ i2 = STACKTOP;
+ i14 = HEAP32[i3 >> 2] | 0;
+ i4 = i3 + 60 | 0;
+ i13 = HEAP32[i4 >> 2] | 0;
+ i15 = i13 + 4 | 0;
+ i16 = HEAP32[i15 >> 2] | 0;
+ i10 = i13 + 8 | 0;
+ i12 = HEAP32[i10 >> 2] | 0;
+ do {
+ if ((i16 + 1 | 0) >>> 0 > i12 >>> 0) {
+ if (i12 >>> 0 > 2147483645) {
+ _lexerror(i3, 12368, 0);
+ }
+ i16 = i12 << 1;
+ i17 = HEAP32[i3 + 52 >> 2] | 0;
+ if ((i16 | 0) == -2) {
+ _luaM_toobig(i17);
+ } else {
+ i8 = _luaM_realloc_(i17, HEAP32[i13 >> 2] | 0, i12, i16) | 0;
+ HEAP32[i13 >> 2] = i8;
+ HEAP32[i10 >> 2] = i16;
+ i9 = HEAP32[i15 >> 2] | 0;
+ break;
+ }
+ } else {
+ i9 = i16;
+ i8 = HEAP32[i13 >> 2] | 0;
+ }
+ } while (0);
+ HEAP32[i15 >> 2] = i9 + 1;
+ HEAP8[i8 + i9 | 0] = i14;
+ i9 = i3 + 56 | 0;
+ i8 = HEAP32[i9 >> 2] | 0;
+ i18 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i18 + -1;
+ if ((i18 | 0) == 0) {
+ i12 = _luaZ_fill(i8) | 0;
+ } else {
+ i18 = i8 + 4 | 0;
+ i12 = HEAP32[i18 >> 2] | 0;
+ HEAP32[i18 >> 2] = i12 + 1;
+ i12 = HEAPU8[i12] | 0;
+ }
+ HEAP32[i3 >> 2] = i12;
+ if ((i12 | 0) == 13 | (i12 | 0) == 10) {
+ _inclinenumber(i3);
+ i11 = 13;
+ }
+ L17 : while (1) {
+ if ((i11 | 0) == 13) {
+ i11 = 0;
+ i12 = HEAP32[i3 >> 2] | 0;
+ }
+ i8 = (i1 | 0) == 0;
+ i10 = i3 + 52 | 0;
+ L21 : do {
+ if (i8) {
+ while (1) {
+ if ((i12 | 0) == 13 | (i12 | 0) == 10) {
+ break L21;
+ } else if ((i12 | 0) == 93) {
+ i11 = 22;
+ break L21;
+ } else if ((i12 | 0) == -1) {
+ i11 = 21;
+ break L17;
+ }
+ i12 = HEAP32[i9 >> 2] | 0;
+ i18 = HEAP32[i12 >> 2] | 0;
+ HEAP32[i12 >> 2] = i18 + -1;
+ if ((i18 | 0) == 0) {
+ i12 = _luaZ_fill(i12) | 0;
+ } else {
+ i18 = i12 + 4 | 0;
+ i12 = HEAP32[i18 >> 2] | 0;
+ HEAP32[i18 >> 2] = i12 + 1;
+ i12 = HEAPU8[i12] | 0;
+ }
+ HEAP32[i3 >> 2] = i12;
+ }
+ } else {
+ while (1) {
+ if ((i12 | 0) == 13 | (i12 | 0) == 10) {
+ break L21;
+ } else if ((i12 | 0) == 93) {
+ i11 = 22;
+ break L21;
+ } else if ((i12 | 0) == -1) {
+ i11 = 21;
+ break L17;
+ }
+ i14 = HEAP32[i4 >> 2] | 0;
+ i13 = i14 + 4 | 0;
+ i17 = HEAP32[i13 >> 2] | 0;
+ i16 = i14 + 8 | 0;
+ i15 = HEAP32[i16 >> 2] | 0;
+ if ((i17 + 1 | 0) >>> 0 > i15 >>> 0) {
+ if (i15 >>> 0 > 2147483645) {
+ i11 = 46;
+ break L17;
+ }
+ i17 = i15 << 1;
+ i18 = HEAP32[i10 >> 2] | 0;
+ if ((i17 | 0) == -2) {
+ i11 = 48;
+ break L17;
+ }
+ i18 = _luaM_realloc_(i18, HEAP32[i14 >> 2] | 0, i15, i17) | 0;
+ HEAP32[i14 >> 2] = i18;
+ HEAP32[i16 >> 2] = i17;
+ i17 = HEAP32[i13 >> 2] | 0;
+ i14 = i18;
+ } else {
+ i14 = HEAP32[i14 >> 2] | 0;
+ }
+ HEAP32[i13 >> 2] = i17 + 1;
+ HEAP8[i14 + i17 | 0] = i12;
+ i12 = HEAP32[i9 >> 2] | 0;
+ i18 = HEAP32[i12 >> 2] | 0;
+ HEAP32[i12 >> 2] = i18 + -1;
+ if ((i18 | 0) == 0) {
+ i12 = _luaZ_fill(i12) | 0;
+ } else {
+ i18 = i12 + 4 | 0;
+ i12 = HEAP32[i18 >> 2] | 0;
+ HEAP32[i18 >> 2] = i12 + 1;
+ i12 = HEAPU8[i12] | 0;
+ }
+ HEAP32[i3 >> 2] = i12;
+ }
+ }
+ } while (0);
+ if ((i11 | 0) == 22) {
+ if ((_skip_sep(i3) | 0) == (i5 | 0)) {
+ i11 = 23;
+ break;
+ } else {
+ i11 = 13;
+ continue;
+ }
+ }
+ i12 = HEAP32[i4 >> 2] | 0;
+ i11 = i12 + 4 | 0;
+ i15 = HEAP32[i11 >> 2] | 0;
+ i14 = i12 + 8 | 0;
+ i13 = HEAP32[i14 >> 2] | 0;
+ if ((i15 + 1 | 0) >>> 0 > i13 >>> 0) {
+ if (i13 >>> 0 > 2147483645) {
+ i11 = 37;
+ break;
+ }
+ i15 = i13 << 1;
+ i10 = HEAP32[i10 >> 2] | 0;
+ if ((i15 | 0) == -2) {
+ i11 = 39;
+ break;
+ }
+ i10 = _luaM_realloc_(i10, HEAP32[i12 >> 2] | 0, i13, i15) | 0;
+ HEAP32[i12 >> 2] = i10;
+ HEAP32[i14 >> 2] = i15;
+ i15 = HEAP32[i11 >> 2] | 0;
+ } else {
+ i10 = HEAP32[i12 >> 2] | 0;
+ }
+ HEAP32[i11 >> 2] = i15 + 1;
+ HEAP8[i10 + i15 | 0] = 10;
+ _inclinenumber(i3);
+ if (!i8) {
+ i11 = 13;
+ continue;
+ }
+ HEAP32[(HEAP32[i4 >> 2] | 0) + 4 >> 2] = 0;
+ i11 = 13;
+ }
+ if ((i11 | 0) == 21) {
+ _lexerror(i3, (i1 | 0) != 0 ? 12512 : 12536, 286);
+ } else if ((i11 | 0) == 23) {
+ i15 = HEAP32[i3 >> 2] | 0;
+ i13 = HEAP32[i4 >> 2] | 0;
+ i14 = i13 + 4 | 0;
+ i16 = HEAP32[i14 >> 2] | 0;
+ i11 = i13 + 8 | 0;
+ i12 = HEAP32[i11 >> 2] | 0;
+ do {
+ if ((i16 + 1 | 0) >>> 0 > i12 >>> 0) {
+ if (i12 >>> 0 > 2147483645) {
+ _lexerror(i3, 12368, 0);
+ }
+ i17 = i12 << 1;
+ i16 = HEAP32[i10 >> 2] | 0;
+ if ((i17 | 0) == -2) {
+ _luaM_toobig(i16);
+ } else {
+ i6 = _luaM_realloc_(i16, HEAP32[i13 >> 2] | 0, i12, i17) | 0;
+ HEAP32[i13 >> 2] = i6;
+ HEAP32[i11 >> 2] = i17;
+ i7 = HEAP32[i14 >> 2] | 0;
+ break;
+ }
+ } else {
+ i7 = i16;
+ i6 = HEAP32[i13 >> 2] | 0;
+ }
+ } while (0);
+ HEAP32[i14 >> 2] = i7 + 1;
+ HEAP8[i6 + i7 | 0] = i15;
+ i6 = HEAP32[i9 >> 2] | 0;
+ i18 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i18 + -1;
+ if ((i18 | 0) == 0) {
+ i6 = _luaZ_fill(i6) | 0;
+ } else {
+ i18 = i6 + 4 | 0;
+ i6 = HEAP32[i18 >> 2] | 0;
+ HEAP32[i18 >> 2] = i6 + 1;
+ i6 = HEAPU8[i6] | 0;
+ }
+ HEAP32[i3 >> 2] = i6;
+ if (i8) {
+ STACKTOP = i2;
+ return;
+ }
+ i4 = HEAP32[i4 >> 2] | 0;
+ i5 = i5 + 2 | 0;
+ i6 = HEAP32[i10 >> 2] | 0;
+ i5 = _luaS_newlstr(i6, (HEAP32[i4 >> 2] | 0) + i5 | 0, (HEAP32[i4 + 4 >> 2] | 0) - (i5 << 1) | 0) | 0;
+ i4 = i6 + 8 | 0;
+ i7 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = i7 + 16;
+ HEAP32[i7 >> 2] = i5;
+ HEAP32[i7 + 8 >> 2] = HEAPU8[i5 + 4 | 0] | 0 | 64;
+ i7 = _luaH_set(i6, HEAP32[(HEAP32[i3 + 48 >> 2] | 0) + 4 >> 2] | 0, (HEAP32[i4 >> 2] | 0) + -16 | 0) | 0;
+ i3 = i7 + 8 | 0;
+ if ((HEAP32[i3 >> 2] | 0) == 0 ? (HEAP32[i7 >> 2] = 1, HEAP32[i3 >> 2] = 1, (HEAP32[(HEAP32[i6 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) : 0) {
+ _luaC_step(i6);
+ }
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + -16;
+ HEAP32[i1 >> 2] = i5;
+ STACKTOP = i2;
+ return;
+ } else if ((i11 | 0) == 37) {
+ _lexerror(i3, 12368, 0);
+ } else if ((i11 | 0) == 39) {
+ _luaM_toobig(i10);
+ } else if ((i11 | 0) == 46) {
+ _lexerror(i3, 12368, 0);
+ } else if ((i11 | 0) == 48) {
+ _luaM_toobig(i18);
+ }
+}
+function _try_realloc_chunk(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0;
+ i2 = STACKTOP;
+ i4 = i1 + 4 | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ i8 = i6 & -8;
+ i5 = i1 + i8 | 0;
+ i10 = HEAP32[12928 >> 2] | 0;
+ if (i1 >>> 0 < i10 >>> 0) {
+ _abort();
+ }
+ i12 = i6 & 3;
+ if (!((i12 | 0) != 1 & i1 >>> 0 < i5 >>> 0)) {
+ _abort();
+ }
+ i7 = i1 + (i8 | 4) | 0;
+ i13 = HEAP32[i7 >> 2] | 0;
+ if ((i13 & 1 | 0) == 0) {
+ _abort();
+ }
+ if ((i12 | 0) == 0) {
+ if (i3 >>> 0 < 256) {
+ i15 = 0;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ if (!(i8 >>> 0 < (i3 + 4 | 0) >>> 0) ? !((i8 - i3 | 0) >>> 0 > HEAP32[13392 >> 2] << 1 >>> 0) : 0) {
+ i15 = i1;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ i15 = 0;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ if (!(i8 >>> 0 < i3 >>> 0)) {
+ i5 = i8 - i3 | 0;
+ if (!(i5 >>> 0 > 15)) {
+ i15 = i1;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ HEAP32[i4 >> 2] = i6 & 1 | i3 | 2;
+ HEAP32[i1 + (i3 + 4) >> 2] = i5 | 3;
+ HEAP32[i7 >> 2] = HEAP32[i7 >> 2] | 1;
+ _dispose_chunk(i1 + i3 | 0, i5);
+ i15 = i1;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ if ((i5 | 0) == (HEAP32[12936 >> 2] | 0)) {
+ i5 = (HEAP32[12924 >> 2] | 0) + i8 | 0;
+ if (!(i5 >>> 0 > i3 >>> 0)) {
+ i15 = 0;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ i15 = i5 - i3 | 0;
+ HEAP32[i4 >> 2] = i6 & 1 | i3 | 2;
+ HEAP32[i1 + (i3 + 4) >> 2] = i15 | 1;
+ HEAP32[12936 >> 2] = i1 + i3;
+ HEAP32[12924 >> 2] = i15;
+ i15 = i1;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ if ((i5 | 0) == (HEAP32[12932 >> 2] | 0)) {
+ i7 = (HEAP32[12920 >> 2] | 0) + i8 | 0;
+ if (i7 >>> 0 < i3 >>> 0) {
+ i15 = 0;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ i5 = i7 - i3 | 0;
+ if (i5 >>> 0 > 15) {
+ HEAP32[i4 >> 2] = i6 & 1 | i3 | 2;
+ HEAP32[i1 + (i3 + 4) >> 2] = i5 | 1;
+ HEAP32[i1 + i7 >> 2] = i5;
+ i15 = i1 + (i7 + 4) | 0;
+ HEAP32[i15 >> 2] = HEAP32[i15 >> 2] & -2;
+ i3 = i1 + i3 | 0;
+ } else {
+ HEAP32[i4 >> 2] = i6 & 1 | i7 | 2;
+ i3 = i1 + (i7 + 4) | 0;
+ HEAP32[i3 >> 2] = HEAP32[i3 >> 2] | 1;
+ i3 = 0;
+ i5 = 0;
+ }
+ HEAP32[12920 >> 2] = i5;
+ HEAP32[12932 >> 2] = i3;
+ i15 = i1;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ if ((i13 & 2 | 0) != 0) {
+ i15 = 0;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ i7 = (i13 & -8) + i8 | 0;
+ if (i7 >>> 0 < i3 >>> 0) {
+ i15 = 0;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ i6 = i7 - i3 | 0;
+ i12 = i13 >>> 3;
+ do {
+ if (!(i13 >>> 0 < 256)) {
+ i11 = HEAP32[i1 + (i8 + 24) >> 2] | 0;
+ i13 = HEAP32[i1 + (i8 + 12) >> 2] | 0;
+ do {
+ if ((i13 | 0) == (i5 | 0)) {
+ i13 = i1 + (i8 + 20) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i13 = i1 + (i8 + 16) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i9 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i15 = i12 + 20 | 0;
+ i14 = HEAP32[i15 >> 2] | 0;
+ if ((i14 | 0) != 0) {
+ i12 = i14;
+ i13 = i15;
+ continue;
+ }
+ i15 = i12 + 16 | 0;
+ i14 = HEAP32[i15 >> 2] | 0;
+ if ((i14 | 0) == 0) {
+ break;
+ } else {
+ i12 = i14;
+ i13 = i15;
+ }
+ }
+ if (i13 >>> 0 < i10 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i13 >> 2] = 0;
+ i9 = i12;
+ break;
+ }
+ } else {
+ i12 = HEAP32[i1 + (i8 + 8) >> 2] | 0;
+ if (i12 >>> 0 < i10 >>> 0) {
+ _abort();
+ }
+ i14 = i12 + 12 | 0;
+ if ((HEAP32[i14 >> 2] | 0) != (i5 | 0)) {
+ _abort();
+ }
+ i10 = i13 + 8 | 0;
+ if ((HEAP32[i10 >> 2] | 0) == (i5 | 0)) {
+ HEAP32[i14 >> 2] = i13;
+ HEAP32[i10 >> 2] = i12;
+ i9 = i13;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i11 | 0) != 0) {
+ i10 = HEAP32[i1 + (i8 + 28) >> 2] | 0;
+ i12 = 13216 + (i10 << 2) | 0;
+ if ((i5 | 0) == (HEAP32[i12 >> 2] | 0)) {
+ HEAP32[i12 >> 2] = i9;
+ if ((i9 | 0) == 0) {
+ HEAP32[12916 >> 2] = HEAP32[12916 >> 2] & ~(1 << i10);
+ break;
+ }
+ } else {
+ if (i11 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i10 = i11 + 16 | 0;
+ if ((HEAP32[i10 >> 2] | 0) == (i5 | 0)) {
+ HEAP32[i10 >> 2] = i9;
+ } else {
+ HEAP32[i11 + 20 >> 2] = i9;
+ }
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ }
+ if (i9 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i9 + 24 >> 2] = i11;
+ i5 = HEAP32[i1 + (i8 + 16) >> 2] | 0;
+ do {
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 16 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ } while (0);
+ i5 = HEAP32[i1 + (i8 + 20) >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[12928 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 20 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ }
+ } else {
+ i9 = HEAP32[i1 + (i8 + 8) >> 2] | 0;
+ i8 = HEAP32[i1 + (i8 + 12) >> 2] | 0;
+ i13 = 12952 + (i12 << 1 << 2) | 0;
+ if ((i9 | 0) != (i13 | 0)) {
+ if (i9 >>> 0 < i10 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i9 + 12 >> 2] | 0) != (i5 | 0)) {
+ _abort();
+ }
+ }
+ if ((i8 | 0) == (i9 | 0)) {
+ HEAP32[3228] = HEAP32[3228] & ~(1 << i12);
+ break;
+ }
+ if ((i8 | 0) != (i13 | 0)) {
+ if (i8 >>> 0 < i10 >>> 0) {
+ _abort();
+ }
+ i10 = i8 + 8 | 0;
+ if ((HEAP32[i10 >> 2] | 0) == (i5 | 0)) {
+ i11 = i10;
+ } else {
+ _abort();
+ }
+ } else {
+ i11 = i8 + 8 | 0;
+ }
+ HEAP32[i9 + 12 >> 2] = i8;
+ HEAP32[i11 >> 2] = i9;
+ }
+ } while (0);
+ if (i6 >>> 0 < 16) {
+ HEAP32[i4 >> 2] = i7 | HEAP32[i4 >> 2] & 1 | 2;
+ i15 = i1 + (i7 | 4) | 0;
+ HEAP32[i15 >> 2] = HEAP32[i15 >> 2] | 1;
+ i15 = i1;
+ STACKTOP = i2;
+ return i15 | 0;
+ } else {
+ HEAP32[i4 >> 2] = HEAP32[i4 >> 2] & 1 | i3 | 2;
+ HEAP32[i1 + (i3 + 4) >> 2] = i6 | 3;
+ i15 = i1 + (i7 | 4) | 0;
+ HEAP32[i15 >> 2] = HEAP32[i15 >> 2] | 1;
+ _dispose_chunk(i1 + i3 | 0, i6);
+ i15 = i1;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ return 0;
+}
+function _luaK_posfix(i3, i16, i1, i4, i14) {
+ i3 = i3 | 0;
+ i16 = i16 | 0;
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i14 = i14 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i15 = 0;
+ i2 = STACKTOP;
+ switch (i16 | 0) {
+ case 14:
+ {
+ _luaK_dischargevars(i3, i4);
+ i6 = i4 + 16 | 0;
+ i5 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if (!((i5 | 0) == -1)) {
+ i9 = HEAP32[i6 >> 2] | 0;
+ if ((i9 | 0) == -1) {
+ HEAP32[i6 >> 2] = i5;
+ break;
+ }
+ i7 = HEAP32[(HEAP32[i3 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i6 = i7 + (i9 << 2) | 0;
+ i8 = HEAP32[i6 >> 2] | 0;
+ i10 = (i8 >>> 14) + -131071 | 0;
+ if ((i10 | 0) == -1) {
+ break;
+ }
+ i10 = i9 + 1 + i10 | 0;
+ if ((i10 | 0) == -1) {
+ break;
+ } else {
+ i9 = i10;
+ }
+ }
+ i5 = i5 + ~i9 | 0;
+ if ((((i5 | 0) > -1 ? i5 : 0 - i5 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i3 + 12 >> 2] | 0, 10624);
+ } else {
+ HEAP32[i6 >> 2] = (i5 << 14) + 2147467264 | i8 & 16383;
+ break;
+ }
+ }
+ } while (0);
+ HEAP32[i1 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i1 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i1 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i1 + 12 >> 2] = HEAP32[i4 + 12 >> 2];
+ HEAP32[i1 + 16 >> 2] = HEAP32[i4 + 16 >> 2];
+ HEAP32[i1 + 20 >> 2] = HEAP32[i4 + 20 >> 2];
+ STACKTOP = i2;
+ return;
+ }
+ case 13:
+ {
+ _luaK_dischargevars(i3, i4);
+ i6 = i4 + 20 | 0;
+ i5 = HEAP32[i1 + 20 >> 2] | 0;
+ do {
+ if (!((i5 | 0) == -1)) {
+ i9 = HEAP32[i6 >> 2] | 0;
+ if ((i9 | 0) == -1) {
+ HEAP32[i6 >> 2] = i5;
+ break;
+ }
+ i7 = HEAP32[(HEAP32[i3 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i8 = i7 + (i9 << 2) | 0;
+ i6 = HEAP32[i8 >> 2] | 0;
+ i10 = (i6 >>> 14) + -131071 | 0;
+ if ((i10 | 0) == -1) {
+ break;
+ }
+ i10 = i9 + 1 + i10 | 0;
+ if ((i10 | 0) == -1) {
+ break;
+ } else {
+ i9 = i10;
+ }
+ }
+ i5 = i5 + ~i9 | 0;
+ if ((((i5 | 0) > -1 ? i5 : 0 - i5 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i3 + 12 >> 2] | 0, 10624);
+ } else {
+ HEAP32[i8 >> 2] = (i5 << 14) + 2147467264 | i6 & 16383;
+ break;
+ }
+ }
+ } while (0);
+ HEAP32[i1 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
+ HEAP32[i1 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
+ HEAP32[i1 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i1 + 12 >> 2] = HEAP32[i4 + 12 >> 2];
+ HEAP32[i1 + 16 >> 2] = HEAP32[i4 + 16 >> 2];
+ HEAP32[i1 + 20 >> 2] = HEAP32[i4 + 20 >> 2];
+ STACKTOP = i2;
+ return;
+ }
+ case 6:
+ {
+ i12 = i4 + 16 | 0;
+ i13 = i4 + 20 | 0;
+ i16 = (HEAP32[i12 >> 2] | 0) == (HEAP32[i13 >> 2] | 0);
+ _luaK_dischargevars(i3, i4);
+ do {
+ if (!i16) {
+ if ((HEAP32[i4 >> 2] | 0) == 6) {
+ i10 = HEAP32[i4 + 8 >> 2] | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (HEAP32[i13 >> 2] | 0)) {
+ break;
+ }
+ if ((i10 | 0) >= (HEAPU8[i3 + 46 | 0] | 0 | 0)) {
+ _exp2reg(i3, i4, i10);
+ break;
+ }
+ }
+ _luaK_exp2nextreg(i3, i4);
+ }
+ } while (0);
+ if ((HEAP32[i4 >> 2] | 0) == 11 ? (i5 = i4 + 8 | 0, i7 = HEAP32[i5 >> 2] | 0, i8 = (HEAP32[i3 >> 2] | 0) + 12 | 0, i9 = HEAP32[i8 >> 2] | 0, i6 = HEAP32[i9 + (i7 << 2) >> 2] | 0, (i6 & 63 | 0) == 22) : 0) {
+ i4 = i1 + 8 | 0;
+ if (((HEAP32[i1 >> 2] | 0) == 6 ? (i11 = HEAP32[i4 >> 2] | 0, (i11 & 256 | 0) == 0) : 0) ? (HEAPU8[i3 + 46 | 0] | 0 | 0) <= (i11 | 0) : 0) {
+ i6 = i3 + 48 | 0;
+ HEAP8[i6] = (HEAP8[i6] | 0) + -1 << 24 >> 24;
+ i6 = HEAP32[i5 >> 2] | 0;
+ i16 = HEAP32[i8 >> 2] | 0;
+ i9 = i16;
+ i7 = i6;
+ i6 = HEAP32[i16 + (i6 << 2) >> 2] | 0;
+ }
+ HEAP32[i9 + (i7 << 2) >> 2] = HEAP32[i4 >> 2] << 23 | i6 & 8388607;
+ HEAP32[i1 >> 2] = 11;
+ HEAP32[i4 >> 2] = HEAP32[i5 >> 2];
+ STACKTOP = i2;
+ return;
+ }
+ _luaK_exp2nextreg(i3, i4);
+ _codearith(i3, 22, i1, i4, i14);
+ STACKTOP = i2;
+ return;
+ }
+ case 9:
+ case 8:
+ case 7:
+ {
+ i7 = i16 + 17 | 0;
+ i6 = _luaK_exp2RK(i3, i1) | 0;
+ i5 = _luaK_exp2RK(i3, i4) | 0;
+ if (((HEAP32[i4 >> 2] | 0) == 6 ? (i15 = HEAP32[i4 + 8 >> 2] | 0, (i15 & 256 | 0) == 0) : 0) ? (HEAPU8[i3 + 46 | 0] | 0 | 0) <= (i15 | 0) : 0) {
+ i16 = i3 + 48 | 0;
+ HEAP8[i16] = (HEAP8[i16] | 0) + -1 << 24 >> 24;
+ }
+ i4 = i1 + 8 | 0;
+ if (((HEAP32[i1 >> 2] | 0) == 6 ? (i10 = HEAP32[i4 >> 2] | 0, (i10 & 256 | 0) == 0) : 0) ? (HEAPU8[i3 + 46 | 0] | 0 | 0) <= (i10 | 0) : 0) {
+ i16 = i3 + 48 | 0;
+ HEAP8[i16] = (HEAP8[i16] | 0) + -1 << 24 >> 24;
+ }
+ HEAP32[i4 >> 2] = _condjump(i3, i7, 1, i6, i5) | 0;
+ HEAP32[i1 >> 2] = 10;
+ STACKTOP = i2;
+ return;
+ }
+ case 12:
+ case 11:
+ case 10:
+ {
+ i7 = i16 + 14 | 0;
+ i6 = _luaK_exp2RK(i3, i1) | 0;
+ i5 = _luaK_exp2RK(i3, i4) | 0;
+ if (((HEAP32[i4 >> 2] | 0) == 6 ? (i13 = HEAP32[i4 + 8 >> 2] | 0, (i13 & 256 | 0) == 0) : 0) ? (HEAPU8[i3 + 46 | 0] | 0 | 0) <= (i13 | 0) : 0) {
+ i16 = i3 + 48 | 0;
+ HEAP8[i16] = (HEAP8[i16] | 0) + -1 << 24 >> 24;
+ }
+ i4 = i1 + 8 | 0;
+ if (((HEAP32[i1 >> 2] | 0) == 6 ? (i12 = HEAP32[i4 >> 2] | 0, (i12 & 256 | 0) == 0) : 0) ? (HEAPU8[i3 + 46 | 0] | 0 | 0) <= (i12 | 0) : 0) {
+ i16 = i3 + 48 | 0;
+ HEAP8[i16] = (HEAP8[i16] | 0) + -1 << 24 >> 24;
+ }
+ i8 = (i7 | 0) == 24;
+ HEAP32[i4 >> 2] = _condjump(i3, i7, i8 & 1 ^ 1, i8 ? i6 : i5, i8 ? i5 : i6) | 0;
+ HEAP32[i1 >> 2] = 10;
+ STACKTOP = i2;
+ return;
+ }
+ case 5:
+ case 4:
+ case 3:
+ case 2:
+ case 1:
+ case 0:
+ {
+ _codearith(i3, i16 + 13 | 0, i1, i4, i14);
+ STACKTOP = i2;
+ return;
+ }
+ default:
+ {
+ STACKTOP = i2;
+ return;
+ }
+ }
+}
+function _body(i1, i4, i13, i5) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i13 = i13 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0;
+ i6 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i3 = i6 + 12 | 0;
+ i14 = i6;
+ i2 = i1 + 48 | 0;
+ i19 = HEAP32[i2 >> 2] | 0;
+ i18 = i1 + 52 | 0;
+ i17 = HEAP32[i18 >> 2] | 0;
+ i16 = HEAP32[i19 >> 2] | 0;
+ i19 = i19 + 36 | 0;
+ i23 = i16 + 56 | 0;
+ i24 = HEAP32[i23 >> 2] | 0;
+ i15 = i16 + 16 | 0;
+ if (((HEAP32[i19 >> 2] | 0) >= (i24 | 0) ? (i21 = _luaM_growaux_(i17, HEAP32[i15 >> 2] | 0, i23, 4, 262143, 6512) | 0, HEAP32[i15 >> 2] = i21, i20 = HEAP32[i23 >> 2] | 0, (i24 | 0) < (i20 | 0)) : 0) ? (i22 = i24 + 1 | 0, HEAP32[i21 + (i24 << 2) >> 2] = 0, (i22 | 0) < (i20 | 0)) : 0) {
+ while (1) {
+ i21 = i22 + 1 | 0;
+ HEAP32[(HEAP32[i15 >> 2] | 0) + (i22 << 2) >> 2] = 0;
+ if ((i21 | 0) == (i20 | 0)) {
+ break;
+ } else {
+ i22 = i21;
+ }
+ }
+ }
+ i20 = _luaF_newproto(i17) | 0;
+ i24 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i24 + 1;
+ HEAP32[(HEAP32[i15 >> 2] | 0) + (i24 << 2) >> 2] = i20;
+ if (!((HEAP8[i20 + 5 | 0] & 3) == 0) ? !((HEAP8[i16 + 5 | 0] & 4) == 0) : 0) {
+ _luaC_barrier_(i17, i16, i20);
+ }
+ HEAP32[i3 >> 2] = i20;
+ HEAP32[i20 + 64 >> 2] = i5;
+ i16 = HEAP32[i18 >> 2] | 0;
+ HEAP32[i3 + 8 >> 2] = HEAP32[i2 >> 2];
+ i17 = i3 + 12 | 0;
+ HEAP32[i17 >> 2] = i1;
+ HEAP32[i2 >> 2] = i3;
+ HEAP32[i3 + 20 >> 2] = 0;
+ HEAP32[i3 + 24 >> 2] = 0;
+ HEAP32[i3 + 28 >> 2] = -1;
+ HEAP32[i3 + 32 >> 2] = 0;
+ HEAP32[i3 + 36 >> 2] = 0;
+ i22 = i3 + 44 | 0;
+ i15 = i1 + 64 | 0;
+ HEAP32[i22 + 0 >> 2] = 0;
+ HEAP8[i22 + 4 | 0] = 0;
+ HEAP32[i3 + 40 >> 2] = HEAP32[(HEAP32[i15 >> 2] | 0) + 4 >> 2];
+ i15 = i3 + 16 | 0;
+ HEAP32[i15 >> 2] = 0;
+ HEAP32[i20 + 36 >> 2] = HEAP32[i1 + 68 >> 2];
+ HEAP8[i20 + 78 | 0] = 2;
+ i22 = _luaH_new(i16) | 0;
+ HEAP32[i3 + 4 >> 2] = i22;
+ i23 = i16 + 8 | 0;
+ i24 = HEAP32[i23 >> 2] | 0;
+ HEAP32[i24 >> 2] = i22;
+ HEAP32[i24 + 8 >> 2] = 69;
+ i24 = (HEAP32[i23 >> 2] | 0) + 16 | 0;
+ HEAP32[i23 >> 2] = i24;
+ if (((HEAP32[i16 + 24 >> 2] | 0) - i24 | 0) < 16) {
+ _luaD_growstack(i16, 0);
+ }
+ HEAP8[i14 + 10 | 0] = 0;
+ HEAP8[i14 + 8 | 0] = HEAP8[i3 + 46 | 0] | 0;
+ i24 = HEAP32[(HEAP32[i17 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i14 + 4 >> 1] = HEAP32[i24 + 28 >> 2];
+ HEAP16[i14 + 6 >> 1] = HEAP32[i24 + 16 >> 2];
+ HEAP8[i14 + 9 | 0] = 0;
+ HEAP32[i14 >> 2] = HEAP32[i15 >> 2];
+ HEAP32[i15 >> 2] = i14;
+ i14 = i1 + 16 | 0;
+ if ((HEAP32[i14 >> 2] | 0) != 40) {
+ _error_expected(i1, 40);
+ }
+ _luaX_next(i1);
+ if ((i13 | 0) != 0) {
+ _new_localvar(i1, _luaX_newstring(i1, 6456, 4) | 0);
+ i24 = HEAP32[i2 >> 2] | 0;
+ i22 = i24 + 46 | 0;
+ i23 = (HEAPU8[i22] | 0) + 1 | 0;
+ HEAP8[i22] = i23;
+ HEAP32[(HEAP32[(HEAP32[i24 >> 2] | 0) + 24 >> 2] | 0) + ((HEAP16[(HEAP32[HEAP32[(HEAP32[i24 + 12 >> 2] | 0) + 64 >> 2] >> 2] | 0) + ((i23 & 255) + -1 + (HEAP32[i24 + 40 >> 2] | 0) << 1) >> 1] | 0) * 12 | 0) + 4 >> 2] = HEAP32[i24 + 20 >> 2];
+ }
+ i13 = HEAP32[i2 >> 2] | 0;
+ i15 = HEAP32[i13 >> 2] | 0;
+ i16 = i15 + 77 | 0;
+ HEAP8[i16] = 0;
+ i19 = HEAP32[i14 >> 2] | 0;
+ L20 : do {
+ if ((i19 | 0) != 41) {
+ i17 = i1 + 24 | 0;
+ i18 = 0;
+ while (1) {
+ if ((i19 | 0) == 280) {
+ i17 = 18;
+ break;
+ } else if ((i19 | 0) != 288) {
+ i17 = 19;
+ break;
+ }
+ i24 = HEAP32[i17 >> 2] | 0;
+ _luaX_next(i1);
+ _new_localvar(i1, i24);
+ i18 = i18 + 1 | 0;
+ if ((HEAP8[i16] | 0) != 0) {
+ i11 = i18;
+ break L20;
+ }
+ if ((HEAP32[i14 >> 2] | 0) != 44) {
+ i11 = i18;
+ break L20;
+ }
+ _luaX_next(i1);
+ i19 = HEAP32[i14 >> 2] | 0;
+ }
+ if ((i17 | 0) == 18) {
+ _luaX_next(i1);
+ HEAP8[i16] = 1;
+ i11 = i18;
+ break;
+ } else if ((i17 | 0) == 19) {
+ _luaX_syntaxerror(i1, 6464);
+ }
+ } else {
+ i11 = 0;
+ }
+ } while (0);
+ i18 = HEAP32[i2 >> 2] | 0;
+ i16 = i18 + 46 | 0;
+ i17 = (HEAPU8[i16] | 0) + i11 | 0;
+ HEAP8[i16] = i17;
+ if ((i11 | 0) != 0 ? (i8 = i18 + 20 | 0, i9 = i18 + 40 | 0, i7 = HEAP32[(HEAP32[i18 >> 2] | 0) + 24 >> 2] | 0, i10 = HEAP32[HEAP32[(HEAP32[i18 + 12 >> 2] | 0) + 64 >> 2] >> 2] | 0, HEAP32[i7 + ((HEAP16[i10 + ((i17 & 255) - i11 + (HEAP32[i9 >> 2] | 0) << 1) >> 1] | 0) * 12 | 0) + 4 >> 2] = HEAP32[i8 >> 2], i12 = i11 + -1 | 0, (i12 | 0) != 0) : 0) {
+ do {
+ HEAP32[i7 + ((HEAP16[i10 + ((HEAPU8[i16] | 0) - i12 + (HEAP32[i9 >> 2] | 0) << 1) >> 1] | 0) * 12 | 0) + 4 >> 2] = HEAP32[i8 >> 2];
+ i12 = i12 + -1 | 0;
+ } while ((i12 | 0) != 0);
+ }
+ i24 = i13 + 46 | 0;
+ HEAP8[i15 + 76 | 0] = HEAP8[i24] | 0;
+ _luaK_reserveregs(i13, HEAPU8[i24] | 0);
+ if ((HEAP32[i14 >> 2] | 0) != 41) {
+ _error_expected(i1, 41);
+ }
+ _luaX_next(i1);
+ L39 : while (1) {
+ i7 = HEAP32[i14 >> 2] | 0;
+ switch (i7 | 0) {
+ case 277:
+ case 286:
+ case 262:
+ case 261:
+ case 260:
+ {
+ i17 = 30;
+ break L39;
+ }
+ default:
+ {}
+ }
+ _statement(i1);
+ if ((i7 | 0) == 274) {
+ i17 = 30;
+ break;
+ }
+ }
+ if ((i17 | 0) == 30) {
+ HEAP32[(HEAP32[i3 >> 2] | 0) + 68 >> 2] = HEAP32[i1 + 4 >> 2];
+ _check_match(i1, 262, 265, i5);
+ i24 = HEAP32[(HEAP32[i2 >> 2] | 0) + 8 >> 2] | 0;
+ i23 = _luaK_codeABx(i24, 37, 0, (HEAP32[i24 + 36 >> 2] | 0) + -1 | 0) | 0;
+ HEAP32[i4 + 16 >> 2] = -1;
+ HEAP32[i4 + 20 >> 2] = -1;
+ HEAP32[i4 >> 2] = 11;
+ HEAP32[i4 + 8 >> 2] = i23;
+ _luaK_exp2nextreg(i24, i4);
+ _close_func(i1);
+ STACKTOP = i6;
+ return;
+ }
+}
+function _luaH_newkey(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, d21 = 0.0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 144 | 0;
+ i8 = i4 + 8 | 0;
+ i10 = i4;
+ i5 = i4 + 16 | 0;
+ i6 = i1 + 8 | 0;
+ i11 = HEAP32[i6 >> 2] | 0;
+ if ((i11 | 0) == 0) {
+ _luaG_runerror(i3, 7968, i8);
+ } else if ((i11 | 0) == 3) {
+ i15 = 3;
+ }
+ if ((i15 | 0) == 3 ? (d21 = +HEAPF64[i1 >> 3], !(d21 == d21 & 0.0 == 0.0)) : 0) {
+ _luaG_runerror(i3, 7992, i8);
+ }
+ i13 = _mainposition(i2, i1) | 0;
+ i14 = i13 + 8 | 0;
+ do {
+ if ((HEAP32[i14 >> 2] | 0) != 0 | (i13 | 0) == 8016) {
+ i18 = i2 + 20 | 0;
+ i11 = i2 + 16 | 0;
+ i17 = HEAP32[i11 >> 2] | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ while (1) {
+ if (!(i16 >>> 0 > i17 >>> 0)) {
+ break;
+ }
+ i12 = i16 + -32 | 0;
+ HEAP32[i18 >> 2] = i12;
+ if ((HEAP32[i16 + -8 >> 2] | 0) == 0) {
+ i15 = 37;
+ break;
+ } else {
+ i16 = i12;
+ }
+ }
+ if ((i15 | 0) == 37) {
+ i5 = _mainposition(i2, i13 + 16 | 0) | 0;
+ if ((i5 | 0) == (i13 | 0)) {
+ i20 = i13 + 28 | 0;
+ HEAP32[i16 + -4 >> 2] = HEAP32[i20 >> 2];
+ HEAP32[i20 >> 2] = i12;
+ break;
+ } else {
+ i7 = i5;
+ }
+ do {
+ i5 = i7 + 28 | 0;
+ i7 = HEAP32[i5 >> 2] | 0;
+ } while ((i7 | 0) != (i13 | 0));
+ HEAP32[i5 >> 2] = i12;
+ HEAP32[i12 + 0 >> 2] = HEAP32[i13 + 0 >> 2];
+ HEAP32[i12 + 4 >> 2] = HEAP32[i13 + 4 >> 2];
+ HEAP32[i12 + 8 >> 2] = HEAP32[i13 + 8 >> 2];
+ HEAP32[i12 + 12 >> 2] = HEAP32[i13 + 12 >> 2];
+ HEAP32[i12 + 16 >> 2] = HEAP32[i13 + 16 >> 2];
+ HEAP32[i12 + 20 >> 2] = HEAP32[i13 + 20 >> 2];
+ HEAP32[i12 + 24 >> 2] = HEAP32[i13 + 24 >> 2];
+ HEAP32[i12 + 28 >> 2] = HEAP32[i13 + 28 >> 2];
+ HEAP32[i13 + 28 >> 2] = 0;
+ HEAP32[i14 >> 2] = 0;
+ i12 = i13;
+ break;
+ }
+ i13 = i5 + 0 | 0;
+ i12 = i13 + 124 | 0;
+ do {
+ HEAP32[i13 >> 2] = 0;
+ i13 = i13 + 4 | 0;
+ } while ((i13 | 0) < (i12 | 0));
+ i15 = i2 + 12 | 0;
+ i13 = HEAP32[i2 + 28 >> 2] | 0;
+ i12 = 0;
+ i20 = 1;
+ i16 = 0;
+ i14 = 1;
+ while (1) {
+ if ((i14 | 0) > (i13 | 0)) {
+ if ((i20 | 0) > (i13 | 0)) {
+ break;
+ } else {
+ i19 = i13;
+ }
+ } else {
+ i19 = i14;
+ }
+ if ((i20 | 0) > (i19 | 0)) {
+ i18 = i20;
+ i17 = 0;
+ } else {
+ i18 = HEAP32[i15 >> 2] | 0;
+ i17 = 0;
+ while (1) {
+ i17 = ((HEAP32[i18 + (i20 + -1 << 4) + 8 >> 2] | 0) != 0) + i17 | 0;
+ if ((i20 | 0) >= (i19 | 0)) {
+ break;
+ } else {
+ i20 = i20 + 1 | 0;
+ }
+ }
+ i18 = i19 + 1 | 0;
+ }
+ i20 = i5 + (i16 << 2) | 0;
+ HEAP32[i20 >> 2] = (HEAP32[i20 >> 2] | 0) + i17;
+ i12 = i17 + i12 | 0;
+ i16 = i16 + 1 | 0;
+ if ((i16 | 0) < 31) {
+ i20 = i18;
+ i14 = i14 << 1;
+ } else {
+ break;
+ }
+ }
+ i14 = 0;
+ i15 = 1 << (HEAPU8[i2 + 7 | 0] | 0);
+ i13 = 0;
+ L32 : while (1) {
+ i16 = i15;
+ while (1) {
+ i15 = i16 + -1 | 0;
+ if ((i16 | 0) == 0) {
+ break L32;
+ }
+ i16 = HEAP32[i11 >> 2] | 0;
+ if ((HEAP32[i16 + (i15 << 5) + 8 >> 2] | 0) == 0) {
+ i16 = i15;
+ } else {
+ break;
+ }
+ }
+ if (((HEAP32[i16 + (i15 << 5) + 24 >> 2] | 0) == 3 ? (d21 = +HEAPF64[i16 + (i15 << 5) + 16 >> 3], HEAPF64[i10 >> 3] = d21 + 6755399441055744.0, i9 = HEAP32[i10 >> 2] | 0, +(i9 | 0) == d21) : 0) ? (i9 + -1 | 0) >>> 0 < 1073741824 : 0) {
+ i16 = i5 + ((_luaO_ceillog2(i9) | 0) << 2) | 0;
+ HEAP32[i16 >> 2] = (HEAP32[i16 >> 2] | 0) + 1;
+ i16 = 1;
+ } else {
+ i16 = 0;
+ }
+ i14 = i16 + i14 | 0;
+ i13 = i13 + 1 | 0;
+ }
+ i9 = i14 + i12 | 0;
+ if (((HEAP32[i6 >> 2] | 0) == 3 ? (d21 = +HEAPF64[i1 >> 3], HEAPF64[i8 >> 3] = d21 + 6755399441055744.0, i7 = HEAP32[i8 >> 2] | 0, +(i7 | 0) == d21) : 0) ? (i7 + -1 | 0) >>> 0 < 1073741824 : 0) {
+ i6 = i5 + ((_luaO_ceillog2(i7) | 0) << 2) | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + 1;
+ i6 = 1;
+ } else {
+ i6 = 0;
+ }
+ i7 = i9 + i6 | 0;
+ L49 : do {
+ if ((i7 | 0) > 0) {
+ i14 = 0;
+ i10 = 0;
+ i6 = 0;
+ i8 = 0;
+ i11 = 0;
+ i9 = 1;
+ while (1) {
+ i15 = HEAP32[i5 + (i6 << 2) >> 2] | 0;
+ if ((i15 | 0) > 0) {
+ i15 = i15 + i10 | 0;
+ i14 = (i15 | 0) > (i14 | 0);
+ i10 = i15;
+ i8 = i14 ? i9 : i8;
+ i11 = i14 ? i15 : i11;
+ }
+ if ((i10 | 0) == (i7 | 0)) {
+ break L49;
+ }
+ i9 = i9 << 1;
+ i14 = (i9 | 0) / 2 | 0;
+ if ((i14 | 0) < (i7 | 0)) {
+ i6 = i6 + 1 | 0;
+ } else {
+ break;
+ }
+ }
+ } else {
+ i8 = 0;
+ i11 = 0;
+ }
+ } while (0);
+ _luaH_resize(i3, i2, i8, i12 + 1 + i13 - i11 | 0);
+ i5 = _luaH_get(i2, i1) | 0;
+ if ((i5 | 0) != 5192) {
+ i20 = i5;
+ STACKTOP = i4;
+ return i20 | 0;
+ }
+ i20 = _luaH_newkey(i3, i2, i1) | 0;
+ STACKTOP = i4;
+ return i20 | 0;
+ } else {
+ i12 = i13;
+ }
+ } while (0);
+ i18 = i1;
+ i19 = HEAP32[i18 + 4 >> 2] | 0;
+ i20 = i12 + 16 | 0;
+ HEAP32[i20 >> 2] = HEAP32[i18 >> 2];
+ HEAP32[i20 + 4 >> 2] = i19;
+ HEAP32[i12 + 24 >> 2] = HEAP32[i6 >> 2];
+ if (((HEAP32[i6 >> 2] & 64 | 0) != 0 ? !((HEAP8[(HEAP32[i1 >> 2] | 0) + 5 | 0] & 3) == 0) : 0) ? !((HEAP8[i2 + 5 | 0] & 4) == 0) : 0) {
+ _luaC_barrierback_(i3, i2);
+ }
+ i20 = i12;
+ STACKTOP = i4;
+ return i20 | 0;
+}
+function _luaV_concat(i7, i10) {
+ i7 = i7 | 0;
+ i10 = i10 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0;
+ i5 = STACKTOP;
+ STACKTOP = STACKTOP + 48 | 0;
+ i9 = i5;
+ i8 = i5 + 8 | 0;
+ i6 = i7 + 8 | 0;
+ i2 = i7 + 12 | 0;
+ i3 = i7 + 28 | 0;
+ i4 = i7 + 16 | 0;
+ i11 = HEAP32[i6 >> 2] | 0;
+ L1 : while (1) {
+ i14 = i11 + -32 | 0;
+ i12 = i11 + -24 | 0;
+ i17 = HEAP32[i12 >> 2] | 0;
+ i13 = i11 + -16 | 0;
+ do {
+ if ((i17 & 15 | 0) == 4 | (i17 | 0) == 3) {
+ i15 = i11 + -8 | 0;
+ i16 = HEAP32[i15 >> 2] | 0;
+ if ((i16 & 15 | 0) == 4) {
+ i16 = i13;
+ } else {
+ if ((i16 | 0) != 3) {
+ i1 = 7;
+ break;
+ }
+ HEAPF64[tempDoublePtr >> 3] = +HEAPF64[i13 >> 3];
+ HEAP32[i9 >> 2] = HEAP32[tempDoublePtr >> 2];
+ HEAP32[i9 + 4 >> 2] = HEAP32[tempDoublePtr + 4 >> 2];
+ i16 = _luaS_newlstr(i7, i8, _sprintf(i8 | 0, 8936, i9 | 0) | 0) | 0;
+ HEAP32[i13 >> 2] = i16;
+ HEAP32[i15 >> 2] = HEAPU8[i16 + 4 | 0] | 0 | 64;
+ i16 = i13;
+ i17 = HEAP32[i12 >> 2] | 0;
+ }
+ i16 = HEAP32[(HEAP32[i16 >> 2] | 0) + 12 >> 2] | 0;
+ i18 = (i17 & 15 | 0) == 4;
+ if ((i16 | 0) == 0) {
+ if (i18) {
+ i12 = 2;
+ break;
+ }
+ if ((i17 | 0) != 3) {
+ i12 = 2;
+ break;
+ }
+ HEAPF64[tempDoublePtr >> 3] = +HEAPF64[i14 >> 3];
+ HEAP32[i9 >> 2] = HEAP32[tempDoublePtr >> 2];
+ HEAP32[i9 + 4 >> 2] = HEAP32[tempDoublePtr + 4 >> 2];
+ i18 = _luaS_newlstr(i7, i8, _sprintf(i8 | 0, 8936, i9 | 0) | 0) | 0;
+ HEAP32[i14 >> 2] = i18;
+ HEAP32[i12 >> 2] = HEAPU8[i18 + 4 | 0] | 0 | 64;
+ i12 = 2;
+ break;
+ }
+ if (i18 ? (HEAP32[(HEAP32[i14 >> 2] | 0) + 12 >> 2] | 0) == 0 : 0) {
+ i16 = i13;
+ i17 = HEAP32[i16 + 4 >> 2] | 0;
+ i18 = i14;
+ HEAP32[i18 >> 2] = HEAP32[i16 >> 2];
+ HEAP32[i18 + 4 >> 2] = i17;
+ HEAP32[i12 >> 2] = HEAP32[i15 >> 2];
+ i12 = 2;
+ break;
+ }
+ L19 : do {
+ if ((i10 | 0) > 1) {
+ i12 = 1;
+ do {
+ i15 = ~i12;
+ i14 = i11 + (i15 << 4) | 0;
+ i15 = i11 + (i15 << 4) + 8 | 0;
+ i13 = HEAP32[i15 >> 2] | 0;
+ if ((i13 & 15 | 0) != 4) {
+ if ((i13 | 0) != 3) {
+ break L19;
+ }
+ HEAPF64[tempDoublePtr >> 3] = +HEAPF64[i14 >> 3];
+ HEAP32[i9 >> 2] = HEAP32[tempDoublePtr >> 2];
+ HEAP32[i9 + 4 >> 2] = HEAP32[tempDoublePtr + 4 >> 2];
+ i18 = _luaS_newlstr(i7, i8, _sprintf(i8 | 0, 8936, i9 | 0) | 0) | 0;
+ HEAP32[i14 >> 2] = i18;
+ HEAP32[i15 >> 2] = HEAPU8[i18 + 4 | 0] | 0 | 64;
+ }
+ i13 = HEAP32[(HEAP32[i14 >> 2] | 0) + 12 >> 2] | 0;
+ if (!(i13 >>> 0 < (-3 - i16 | 0) >>> 0)) {
+ i1 = 24;
+ break L1;
+ }
+ i16 = i13 + i16 | 0;
+ i12 = i12 + 1 | 0;
+ } while ((i12 | 0) < (i10 | 0));
+ } else {
+ i12 = 1;
+ }
+ } while (0);
+ i14 = _luaZ_openspace(i7, (HEAP32[i2 >> 2] | 0) + 144 | 0, i16) | 0;
+ i15 = i12;
+ i13 = 0;
+ do {
+ i17 = HEAP32[i11 + (0 - i15 << 4) >> 2] | 0;
+ i18 = HEAP32[i17 + 12 >> 2] | 0;
+ _memcpy(i14 + i13 | 0, i17 + 16 | 0, i18 | 0) | 0;
+ i13 = i18 + i13 | 0;
+ i15 = i15 + -1 | 0;
+ } while ((i15 | 0) > 0);
+ i18 = 0 - i12 | 0;
+ i17 = _luaS_newlstr(i7, i14, i13) | 0;
+ HEAP32[i11 + (i18 << 4) >> 2] = i17;
+ HEAP32[i11 + (i18 << 4) + 8 >> 2] = HEAPU8[i17 + 4 | 0] | 0 | 64;
+ } else {
+ i1 = 7;
+ }
+ } while (0);
+ if ((i1 | 0) == 7) {
+ i1 = 0;
+ i15 = _luaT_gettmbyobj(i7, i14, 15) | 0;
+ if ((HEAP32[i15 + 8 >> 2] | 0) == 0) {
+ i15 = _luaT_gettmbyobj(i7, i13, 15) | 0;
+ if ((HEAP32[i15 + 8 >> 2] | 0) == 0) {
+ i1 = 10;
+ break;
+ }
+ }
+ i18 = i14 - (HEAP32[i3 >> 2] | 0) | 0;
+ i16 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i16 + 16;
+ i20 = i15;
+ i19 = HEAP32[i20 + 4 >> 2] | 0;
+ i17 = i16;
+ HEAP32[i17 >> 2] = HEAP32[i20 >> 2];
+ HEAP32[i17 + 4 >> 2] = i19;
+ HEAP32[i16 + 8 >> 2] = HEAP32[i15 + 8 >> 2];
+ i15 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i15 + 16;
+ i16 = i14;
+ i17 = HEAP32[i16 + 4 >> 2] | 0;
+ i14 = i15;
+ HEAP32[i14 >> 2] = HEAP32[i16 >> 2];
+ HEAP32[i14 + 4 >> 2] = i17;
+ HEAP32[i15 + 8 >> 2] = HEAP32[i12 >> 2];
+ i12 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i12 + 16;
+ i15 = i13;
+ i14 = HEAP32[i15 + 4 >> 2] | 0;
+ i17 = i12;
+ HEAP32[i17 >> 2] = HEAP32[i15 >> 2];
+ HEAP32[i17 + 4 >> 2] = i14;
+ HEAP32[i12 + 8 >> 2] = HEAP32[i11 + -8 >> 2];
+ _luaD_call(i7, (HEAP32[i6 >> 2] | 0) + -48 | 0, 1, HEAP8[(HEAP32[i4 >> 2] | 0) + 18 | 0] & 1);
+ i12 = HEAP32[i3 >> 2] | 0;
+ i17 = HEAP32[i6 >> 2] | 0;
+ i14 = i17 + -16 | 0;
+ HEAP32[i6 >> 2] = i14;
+ i15 = HEAP32[i14 + 4 >> 2] | 0;
+ i16 = i12 + i18 | 0;
+ HEAP32[i16 >> 2] = HEAP32[i14 >> 2];
+ HEAP32[i16 + 4 >> 2] = i15;
+ HEAP32[i12 + (i18 + 8) >> 2] = HEAP32[i17 + -8 >> 2];
+ i12 = 2;
+ }
+ i10 = i10 + 1 - i12 | 0;
+ i11 = (HEAP32[i6 >> 2] | 0) + (1 - i12 << 4) | 0;
+ HEAP32[i6 >> 2] = i11;
+ if ((i10 | 0) <= 1) {
+ i1 = 30;
+ break;
+ }
+ }
+ if ((i1 | 0) == 10) {
+ _luaG_concaterror(i7, i14, i13);
+ } else if ((i1 | 0) == 24) {
+ _luaG_runerror(i7, 9e3, i9);
+ } else if ((i1 | 0) == 30) {
+ STACKTOP = i5;
+ return;
+ }
+}
+function _str_gsub(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 1344 | 0;
+ i4 = i3;
+ i5 = i3 + 1336 | 0;
+ i14 = i3 + 1332 | 0;
+ i10 = i3 + 1328 | 0;
+ i6 = i3 + 1048 | 0;
+ i2 = i3 + 8 | 0;
+ i20 = _luaL_checklstring(i1, 1, i14) | 0;
+ i13 = _luaL_checklstring(i1, 2, i10) | 0;
+ i8 = _lua_type(i1, 3) | 0;
+ i9 = _luaL_optinteger(i1, 4, (HEAP32[i14 >> 2] | 0) + 1 | 0) | 0;
+ i7 = (HEAP8[i13] | 0) == 94;
+ if (!((i8 + -3 | 0) >>> 0 < 2 | (i8 | 0) == 6 | (i8 | 0) == 5)) {
+ _luaL_argerror(i1, 3, 7528) | 0;
+ }
+ _luaL_buffinit(i1, i2);
+ if (i7) {
+ i15 = (HEAP32[i10 >> 2] | 0) + -1 | 0;
+ HEAP32[i10 >> 2] = i15;
+ i13 = i13 + 1 | 0;
+ } else {
+ i15 = HEAP32[i10 >> 2] | 0;
+ }
+ i11 = i6 + 16 | 0;
+ HEAP32[i11 >> 2] = i1;
+ HEAP32[i6 >> 2] = 200;
+ i12 = i6 + 4 | 0;
+ HEAP32[i12 >> 2] = i20;
+ i10 = i6 + 8 | 0;
+ HEAP32[i10 >> 2] = i20 + (HEAP32[i14 >> 2] | 0);
+ HEAP32[i6 + 12 >> 2] = i13 + i15;
+ i14 = i6 + 20 | 0;
+ i15 = i2 + 8 | 0;
+ i18 = i2 + 4 | 0;
+ i16 = i6 + 28 | 0;
+ i17 = i6 + 24 | 0;
+ i22 = 0;
+ while (1) {
+ if (!(i22 >>> 0 < i9 >>> 0)) {
+ i19 = 48;
+ break;
+ }
+ HEAP32[i14 >> 2] = 0;
+ i21 = _match(i6, i20, i13) | 0;
+ if ((i21 | 0) != 0) {
+ i22 = i22 + 1 | 0;
+ i23 = HEAP32[i11 >> 2] | 0;
+ if ((i8 | 0) == 5) {
+ do {
+ if ((HEAP32[i14 >> 2] | 0) > 0) {
+ i24 = HEAP32[i16 >> 2] | 0;
+ if (!((i24 | 0) == -1)) {
+ i25 = HEAP32[i17 >> 2] | 0;
+ if ((i24 | 0) == -2) {
+ _lua_pushinteger(i23, i25 + 1 - (HEAP32[i12 >> 2] | 0) | 0);
+ break;
+ } else {
+ i19 = i23;
+ }
+ } else {
+ _luaL_error(i23, 7248, i4) | 0;
+ i19 = HEAP32[i11 >> 2] | 0;
+ i25 = HEAP32[i17 >> 2] | 0;
+ }
+ _lua_pushlstring(i19, i25, i24) | 0;
+ } else {
+ _lua_pushlstring(i23, i20, i21 - i20 | 0) | 0;
+ }
+ } while (0);
+ _lua_gettable(i23, 3);
+ i19 = 37;
+ } else if ((i8 | 0) != 6) {
+ i24 = _lua_tolstring(i23, 3, i5) | 0;
+ if ((HEAP32[i5 >> 2] | 0) != 0) {
+ i23 = i21 - i20 | 0;
+ i25 = 0;
+ do {
+ i26 = i24 + i25 | 0;
+ i27 = HEAP8[i26] | 0;
+ do {
+ if (i27 << 24 >> 24 == 37) {
+ i25 = i25 + 1 | 0;
+ i26 = i24 + i25 | 0;
+ i28 = HEAP8[i26] | 0;
+ i27 = i28 << 24 >> 24;
+ if (((i28 & 255) + -48 | 0) >>> 0 < 10) {
+ if (i28 << 24 >> 24 == 48) {
+ _luaL_addlstring(i2, i20, i23);
+ break;
+ } else {
+ _push_onecapture(i6, i27 + -49 | 0, i20, i21);
+ _luaL_addvalue(i2);
+ break;
+ }
+ }
+ if (!(i28 << 24 >> 24 == 37)) {
+ i28 = HEAP32[i11 >> 2] | 0;
+ HEAP32[i4 >> 2] = 37;
+ _luaL_error(i28, 7600, i4) | 0;
+ }
+ i27 = HEAP32[i15 >> 2] | 0;
+ if (!(i27 >>> 0 < (HEAP32[i18 >> 2] | 0) >>> 0)) {
+ _luaL_prepbuffsize(i2, 1) | 0;
+ i27 = HEAP32[i15 >> 2] | 0;
+ }
+ i28 = HEAP8[i26] | 0;
+ HEAP32[i15 >> 2] = i27 + 1;
+ HEAP8[(HEAP32[i2 >> 2] | 0) + i27 | 0] = i28;
+ } else {
+ i28 = HEAP32[i15 >> 2] | 0;
+ if (!(i28 >>> 0 < (HEAP32[i18 >> 2] | 0) >>> 0)) {
+ _luaL_prepbuffsize(i2, 1) | 0;
+ i28 = HEAP32[i15 >> 2] | 0;
+ i27 = HEAP8[i26] | 0;
+ }
+ HEAP32[i15 >> 2] = i28 + 1;
+ HEAP8[(HEAP32[i2 >> 2] | 0) + i28 | 0] = i27;
+ }
+ } while (0);
+ i25 = i25 + 1 | 0;
+ } while (i25 >>> 0 < (HEAP32[i5 >> 2] | 0) >>> 0);
+ }
+ } else {
+ _lua_pushvalue(i23, 3);
+ i19 = HEAP32[i14 >> 2] | 0;
+ i19 = (i19 | 0) != 0 | (i20 | 0) == 0 ? i19 : 1;
+ _luaL_checkstack(HEAP32[i11 >> 2] | 0, i19, 7200);
+ if ((i19 | 0) > 0) {
+ i24 = 0;
+ do {
+ _push_onecapture(i6, i24, i20, i21);
+ i24 = i24 + 1 | 0;
+ } while ((i24 | 0) != (i19 | 0));
+ }
+ _lua_callk(i23, i19, 1, 0, 0);
+ i19 = 37;
+ }
+ if ((i19 | 0) == 37) {
+ i19 = 0;
+ if ((_lua_toboolean(i23, -1) | 0) != 0) {
+ if ((_lua_isstring(i23, -1) | 0) == 0) {
+ HEAP32[i4 >> 2] = _lua_typename(i23, _lua_type(i23, -1) | 0) | 0;
+ _luaL_error(i23, 7560, i4) | 0;
+ }
+ } else {
+ _lua_settop(i23, -2);
+ _lua_pushlstring(i23, i20, i21 - i20 | 0) | 0;
+ }
+ _luaL_addvalue(i2);
+ }
+ if (i21 >>> 0 > i20 >>> 0) {
+ i20 = i21;
+ } else {
+ i19 = 43;
+ }
+ } else {
+ i19 = 43;
+ }
+ if ((i19 | 0) == 43) {
+ i19 = 0;
+ if (!(i20 >>> 0 < (HEAP32[i10 >> 2] | 0) >>> 0)) {
+ i19 = 48;
+ break;
+ }
+ i21 = HEAP32[i15 >> 2] | 0;
+ if (!(i21 >>> 0 < (HEAP32[i18 >> 2] | 0) >>> 0)) {
+ _luaL_prepbuffsize(i2, 1) | 0;
+ i21 = HEAP32[i15 >> 2] | 0;
+ }
+ i28 = HEAP8[i20] | 0;
+ HEAP32[i15 >> 2] = i21 + 1;
+ HEAP8[(HEAP32[i2 >> 2] | 0) + i21 | 0] = i28;
+ i20 = i20 + 1 | 0;
+ }
+ if (i7) {
+ i19 = 48;
+ break;
+ }
+ }
+ if ((i19 | 0) == 48) {
+ _luaL_addlstring(i2, i20, (HEAP32[i10 >> 2] | 0) - i20 | 0);
+ _luaL_pushresult(i2);
+ _lua_pushinteger(i1, i22);
+ STACKTOP = i3;
+ return 2;
+ }
+ return 0;
+}
+function _constructor(i11, i13) {
+ i11 = i11 | 0;
+ i13 = i13 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i12 = 0, i14 = 0, i15 = 0, i16 = 0;
+ i5 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i10 = i5 + 40 | 0;
+ i8 = i5;
+ i12 = i11 + 48 | 0;
+ i6 = HEAP32[i12 >> 2] | 0;
+ i9 = HEAP32[i11 + 4 >> 2] | 0;
+ i2 = _luaK_codeABC(i6, 11, 0, 0, 0) | 0;
+ i7 = i8 + 36 | 0;
+ HEAP32[i7 >> 2] = 0;
+ i4 = i8 + 28 | 0;
+ HEAP32[i4 >> 2] = 0;
+ i3 = i8 + 32 | 0;
+ HEAP32[i3 >> 2] = 0;
+ i1 = i8 + 24 | 0;
+ HEAP32[i1 >> 2] = i13;
+ HEAP32[i13 + 16 >> 2] = -1;
+ HEAP32[i13 + 20 >> 2] = -1;
+ HEAP32[i13 >> 2] = 11;
+ HEAP32[i13 + 8 >> 2] = i2;
+ HEAP32[i8 + 16 >> 2] = -1;
+ HEAP32[i8 + 20 >> 2] = -1;
+ HEAP32[i8 >> 2] = 0;
+ HEAP32[i8 + 8 >> 2] = 0;
+ _luaK_exp2nextreg(HEAP32[i12 >> 2] | 0, i13);
+ i13 = i11 + 16 | 0;
+ if ((HEAP32[i13 >> 2] | 0) != 123) {
+ _error_expected(i11, 123);
+ }
+ _luaX_next(i11);
+ L4 : do {
+ if ((HEAP32[i13 >> 2] | 0) != 125) {
+ L5 : while (1) {
+ if ((HEAP32[i8 >> 2] | 0) != 0 ? (_luaK_exp2nextreg(i6, i8), HEAP32[i8 >> 2] = 0, (HEAP32[i7 >> 2] | 0) == 50) : 0) {
+ _luaK_setlist(i6, HEAP32[(HEAP32[i1 >> 2] | 0) + 8 >> 2] | 0, HEAP32[i3 >> 2] | 0, 50);
+ HEAP32[i7 >> 2] = 0;
+ }
+ i14 = HEAP32[i13 >> 2] | 0;
+ do {
+ if ((i14 | 0) == 288) {
+ if ((_luaX_lookahead(i11) | 0) == 61) {
+ _recfield(i11, i8);
+ break;
+ }
+ _subexpr(i11, i8, 0) | 0;
+ i14 = HEAP32[i12 >> 2] | 0;
+ i15 = HEAP32[i3 >> 2] | 0;
+ if ((i15 | 0) > 2147483645) {
+ i12 = 10;
+ break L5;
+ }
+ HEAP32[i3 >> 2] = i15 + 1;
+ HEAP32[i7 >> 2] = (HEAP32[i7 >> 2] | 0) + 1;
+ } else if ((i14 | 0) == 91) {
+ _recfield(i11, i8);
+ } else {
+ _subexpr(i11, i8, 0) | 0;
+ i14 = HEAP32[i12 >> 2] | 0;
+ i15 = HEAP32[i3 >> 2] | 0;
+ if ((i15 | 0) > 2147483645) {
+ i12 = 17;
+ break L5;
+ }
+ HEAP32[i3 >> 2] = i15 + 1;
+ HEAP32[i7 >> 2] = (HEAP32[i7 >> 2] | 0) + 1;
+ }
+ } while (0);
+ i14 = HEAP32[i13 >> 2] | 0;
+ if ((i14 | 0) == 44) {
+ _luaX_next(i11);
+ } else if ((i14 | 0) == 59) {
+ _luaX_next(i11);
+ } else {
+ break L4;
+ }
+ if ((HEAP32[i13 >> 2] | 0) == 125) {
+ break L4;
+ }
+ }
+ if ((i12 | 0) == 10) {
+ i12 = i14 + 12 | 0;
+ i13 = HEAP32[(HEAP32[i12 >> 2] | 0) + 52 >> 2] | 0;
+ i14 = HEAP32[(HEAP32[i14 >> 2] | 0) + 64 >> 2] | 0;
+ if ((i14 | 0) == 0) {
+ i16 = 6552;
+ HEAP32[i10 >> 2] = 6528;
+ i15 = i10 + 4 | 0;
+ HEAP32[i15 >> 2] = 2147483645;
+ i15 = i10 + 8 | 0;
+ HEAP32[i15 >> 2] = i16;
+ i15 = _luaO_pushfstring(i13, 6592, i10) | 0;
+ i16 = HEAP32[i12 >> 2] | 0;
+ _luaX_syntaxerror(i16, i15);
+ }
+ HEAP32[i10 >> 2] = i14;
+ i15 = _luaO_pushfstring(i13, 6568, i10) | 0;
+ HEAP32[i10 >> 2] = 6528;
+ i16 = i10 + 4 | 0;
+ HEAP32[i16 >> 2] = 2147483645;
+ i16 = i10 + 8 | 0;
+ HEAP32[i16 >> 2] = i15;
+ i16 = _luaO_pushfstring(i13, 6592, i10) | 0;
+ i15 = HEAP32[i12 >> 2] | 0;
+ _luaX_syntaxerror(i15, i16);
+ } else if ((i12 | 0) == 17) {
+ i13 = i14 + 12 | 0;
+ i12 = HEAP32[(HEAP32[i13 >> 2] | 0) + 52 >> 2] | 0;
+ i14 = HEAP32[(HEAP32[i14 >> 2] | 0) + 64 >> 2] | 0;
+ if ((i14 | 0) == 0) {
+ i15 = 6552;
+ HEAP32[i10 >> 2] = 6528;
+ i16 = i10 + 4 | 0;
+ HEAP32[i16 >> 2] = 2147483645;
+ i16 = i10 + 8 | 0;
+ HEAP32[i16 >> 2] = i15;
+ i16 = _luaO_pushfstring(i12, 6592, i10) | 0;
+ i15 = HEAP32[i13 >> 2] | 0;
+ _luaX_syntaxerror(i15, i16);
+ }
+ HEAP32[i10 >> 2] = i14;
+ i15 = _luaO_pushfstring(i12, 6568, i10) | 0;
+ HEAP32[i10 >> 2] = 6528;
+ i16 = i10 + 4 | 0;
+ HEAP32[i16 >> 2] = 2147483645;
+ i16 = i10 + 8 | 0;
+ HEAP32[i16 >> 2] = i15;
+ i16 = _luaO_pushfstring(i12, 6592, i10) | 0;
+ i15 = HEAP32[i13 >> 2] | 0;
+ _luaX_syntaxerror(i15, i16);
+ }
+ }
+ } while (0);
+ _check_match(i11, 125, 123, i9);
+ i9 = HEAP32[i7 >> 2] | 0;
+ do {
+ if ((i9 | 0) != 0) {
+ i10 = HEAP32[i8 >> 2] | 0;
+ if ((i10 | 0) != 0) if ((i10 | 0) == 13 | (i10 | 0) == 12) {
+ _luaK_setreturns(i6, i8, -1);
+ _luaK_setlist(i6, HEAP32[(HEAP32[i1 >> 2] | 0) + 8 >> 2] | 0, HEAP32[i3 >> 2] | 0, -1);
+ HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + -1;
+ break;
+ } else {
+ _luaK_exp2nextreg(i6, i8);
+ i9 = HEAP32[i7 >> 2] | 0;
+ }
+ _luaK_setlist(i6, HEAP32[(HEAP32[i1 >> 2] | 0) + 8 >> 2] | 0, HEAP32[i3 >> 2] | 0, i9);
+ }
+ } while (0);
+ i16 = HEAP32[(HEAP32[(HEAP32[i6 >> 2] | 0) + 12 >> 2] | 0) + (i2 << 2) >> 2] & 8388607;
+ i16 = (_luaO_int2fb(HEAP32[i3 >> 2] | 0) | 0) << 23 | i16;
+ HEAP32[(HEAP32[(HEAP32[i6 >> 2] | 0) + 12 >> 2] | 0) + (i2 << 2) >> 2] = i16;
+ i16 = (_luaO_int2fb(HEAP32[i4 >> 2] | 0) | 0) << 14 & 8372224 | i16 & -8372225;
+ HEAP32[(HEAP32[(HEAP32[i6 >> 2] | 0) + 12 >> 2] | 0) + (i2 << 2) >> 2] = i16;
+ STACKTOP = i5;
+ return;
+}
+function _luaK_prefix(i4, i14, i7, i13) {
+ i4 = i4 | 0;
+ i14 = i14 | 0;
+ i7 = i7 | 0;
+ i13 = i13 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i12 = i1;
+ HEAP32[i12 + 20 >> 2] = -1;
+ HEAP32[i12 + 16 >> 2] = -1;
+ HEAP32[i12 >> 2] = 5;
+ HEAPF64[i12 + 8 >> 3] = 0.0;
+ if ((i14 | 0) == 1) {
+ _luaK_dischargevars(i4, i7);
+ switch (HEAP32[i7 >> 2] | 0) {
+ case 2:
+ case 5:
+ case 4:
+ {
+ HEAP32[i7 >> 2] = 3;
+ break;
+ }
+ case 10:
+ {
+ i13 = HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] | 0;
+ i12 = HEAP32[i7 + 8 >> 2] | 0;
+ i10 = i13 + (i12 << 2) | 0;
+ if (!((i12 | 0) > 0 ? (i11 = i13 + (i12 + -1 << 2) | 0, i9 = HEAP32[i11 >> 2] | 0, (HEAP8[5584 + (i9 & 63) | 0] | 0) < 0) : 0)) {
+ i11 = i10;
+ i9 = HEAP32[i10 >> 2] | 0;
+ }
+ HEAP32[i11 >> 2] = ((i9 & 16320 | 0) == 0) << 6 | i9 & -16321;
+ break;
+ }
+ case 6:
+ {
+ i8 = 25;
+ break;
+ }
+ case 3:
+ case 1:
+ {
+ HEAP32[i7 >> 2] = 2;
+ break;
+ }
+ case 11:
+ {
+ i12 = i4 + 48 | 0;
+ i8 = HEAP8[i12] | 0;
+ i11 = (i8 & 255) + 1 | 0;
+ i9 = (HEAP32[i4 >> 2] | 0) + 78 | 0;
+ do {
+ if (i11 >>> 0 > (HEAPU8[i9] | 0) >>> 0) {
+ if (i11 >>> 0 > 249) {
+ _luaX_syntaxerror(HEAP32[i4 + 12 >> 2] | 0, 10536);
+ } else {
+ HEAP8[i9] = i11;
+ i10 = HEAP8[i12] | 0;
+ break;
+ }
+ } else {
+ i10 = i8;
+ }
+ } while (0);
+ i14 = (i10 & 255) + 1 | 0;
+ HEAP8[i12] = i14;
+ _discharge2reg(i4, i7, (i14 & 255) + -1 | 0);
+ if ((HEAP32[i7 >> 2] | 0) == 6) {
+ i8 = 25;
+ } else {
+ i9 = i7 + 8 | 0;
+ i8 = 28;
+ }
+ break;
+ }
+ default:
+ {}
+ }
+ if ((i8 | 0) == 25) {
+ i8 = i7 + 8 | 0;
+ i9 = HEAP32[i8 >> 2] | 0;
+ if ((i9 & 256 | 0) == 0 ? (HEAPU8[i4 + 46 | 0] | 0) <= (i9 | 0) : 0) {
+ i9 = i4 + 48 | 0;
+ HEAP8[i9] = (HEAP8[i9] | 0) + -1 << 24 >> 24;
+ i9 = i8;
+ i8 = 28;
+ } else {
+ i9 = i8;
+ i8 = 28;
+ }
+ }
+ if ((i8 | 0) == 28) {
+ HEAP32[i9 >> 2] = _luaK_code(i4, HEAP32[i9 >> 2] << 23 | 20) | 0;
+ HEAP32[i7 >> 2] = 11;
+ }
+ i14 = i7 + 20 | 0;
+ i8 = HEAP32[i14 >> 2] | 0;
+ i7 = i7 + 16 | 0;
+ i9 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i14 >> 2] = i9;
+ HEAP32[i7 >> 2] = i8;
+ if (!((i9 | 0) == -1)) {
+ i8 = HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] | 0;
+ do {
+ i12 = i8 + (i9 << 2) | 0;
+ if ((i9 | 0) > 0 ? (i5 = i8 + (i9 + -1 << 2) | 0, i6 = HEAP32[i5 >> 2] | 0, (HEAP8[5584 + (i6 & 63) | 0] | 0) < 0) : 0) {
+ i10 = i5;
+ i11 = i6;
+ } else {
+ i10 = i12;
+ i11 = HEAP32[i12 >> 2] | 0;
+ }
+ if ((i11 & 63 | 0) == 28) {
+ HEAP32[i10 >> 2] = i11 & 8372224 | i11 >>> 23 << 6 | 27;
+ }
+ i10 = ((HEAP32[i12 >> 2] | 0) >>> 14) + -131071 | 0;
+ if ((i10 | 0) == -1) {
+ break;
+ }
+ i9 = i9 + 1 + i10 | 0;
+ } while (!((i9 | 0) == -1));
+ i8 = HEAP32[i7 >> 2] | 0;
+ }
+ if ((i8 | 0) == -1) {
+ STACKTOP = i1;
+ return;
+ }
+ i4 = HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i6 = i4 + (i8 << 2) | 0;
+ if ((i8 | 0) > 0 ? (i2 = i4 + (i8 + -1 << 2) | 0, i3 = HEAP32[i2 >> 2] | 0, (HEAP8[5584 + (i3 & 63) | 0] | 0) < 0) : 0) {
+ i7 = i2;
+ i5 = i3;
+ } else {
+ i7 = i6;
+ i5 = HEAP32[i6 >> 2] | 0;
+ }
+ if ((i5 & 63 | 0) == 28) {
+ HEAP32[i7 >> 2] = i5 & 8372224 | i5 >>> 23 << 6 | 27;
+ }
+ i5 = ((HEAP32[i6 >> 2] | 0) >>> 14) + -131071 | 0;
+ if ((i5 | 0) == -1) {
+ i8 = 54;
+ break;
+ }
+ i8 = i8 + 1 + i5 | 0;
+ if ((i8 | 0) == -1) {
+ i8 = 54;
+ break;
+ }
+ }
+ if ((i8 | 0) == 54) {
+ STACKTOP = i1;
+ return;
+ }
+ } else if ((i14 | 0) == 0) {
+ if (((HEAP32[i7 >> 2] | 0) == 5 ? (HEAP32[i7 + 16 >> 2] | 0) == -1 : 0) ? (HEAP32[i7 + 20 >> 2] | 0) == -1 : 0) {
+ i14 = i7 + 8 | 0;
+ HEAPF64[i14 >> 3] = -+HEAPF64[i14 >> 3];
+ STACKTOP = i1;
+ return;
+ }
+ _luaK_dischargevars(i4, i7);
+ if ((HEAP32[i7 >> 2] | 0) == 6) {
+ i2 = HEAP32[i7 + 8 >> 2] | 0;
+ if ((HEAP32[i7 + 16 >> 2] | 0) != (HEAP32[i7 + 20 >> 2] | 0)) {
+ if ((i2 | 0) < (HEAPU8[i4 + 46 | 0] | 0)) {
+ i8 = 10;
+ } else {
+ _exp2reg(i4, i7, i2);
+ }
+ }
+ } else {
+ i8 = 10;
+ }
+ if ((i8 | 0) == 10) {
+ _luaK_exp2nextreg(i4, i7);
+ }
+ _codearith(i4, 19, i7, i12, i13);
+ STACKTOP = i1;
+ return;
+ } else if ((i14 | 0) == 2) {
+ _luaK_dischargevars(i4, i7);
+ if ((HEAP32[i7 >> 2] | 0) == 6) {
+ i2 = HEAP32[i7 + 8 >> 2] | 0;
+ if ((HEAP32[i7 + 16 >> 2] | 0) != (HEAP32[i7 + 20 >> 2] | 0)) {
+ if ((i2 | 0) < (HEAPU8[i4 + 46 | 0] | 0)) {
+ i8 = 52;
+ } else {
+ _exp2reg(i4, i7, i2);
+ }
+ }
+ } else {
+ i8 = 52;
+ }
+ if ((i8 | 0) == 52) {
+ _luaK_exp2nextreg(i4, i7);
+ }
+ _codearith(i4, 21, i7, i12, i13);
+ STACKTOP = i1;
+ return;
+ } else {
+ STACKTOP = i1;
+ return;
+ }
+}
+function _subexpr(i6, i3, i7) {
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 48 | 0;
+ i11 = i2 + 24 | 0;
+ i5 = i2;
+ i4 = i6 + 48 | 0;
+ i9 = HEAP32[i4 >> 2] | 0;
+ i1 = i6 + 52 | 0;
+ i12 = (HEAP32[i1 >> 2] | 0) + 38 | 0;
+ i13 = (HEAP16[i12 >> 1] | 0) + 1 << 16 >> 16;
+ HEAP16[i12 >> 1] = i13;
+ if ((i13 & 65535) > 200) {
+ i10 = i9 + 12 | 0;
+ i12 = HEAP32[(HEAP32[i10 >> 2] | 0) + 52 >> 2] | 0;
+ i13 = HEAP32[(HEAP32[i9 >> 2] | 0) + 64 >> 2] | 0;
+ if ((i13 | 0) == 0) {
+ i15 = 6552;
+ HEAP32[i11 >> 2] = 6360;
+ i14 = i11 + 4 | 0;
+ HEAP32[i14 >> 2] = 200;
+ i14 = i11 + 8 | 0;
+ HEAP32[i14 >> 2] = i15;
+ i14 = _luaO_pushfstring(i12, 6592, i11) | 0;
+ i15 = HEAP32[i10 >> 2] | 0;
+ _luaX_syntaxerror(i15, i14);
+ }
+ HEAP32[i11 >> 2] = i13;
+ i14 = _luaO_pushfstring(i12, 6568, i11) | 0;
+ HEAP32[i11 >> 2] = 6360;
+ i15 = i11 + 4 | 0;
+ HEAP32[i15 >> 2] = 200;
+ i15 = i11 + 8 | 0;
+ HEAP32[i15 >> 2] = i14;
+ i15 = _luaO_pushfstring(i12, 6592, i11) | 0;
+ i14 = HEAP32[i10 >> 2] | 0;
+ _luaX_syntaxerror(i14, i15);
+ }
+ i10 = i6 + 16 | 0;
+ L8 : do {
+ switch (HEAP32[i10 >> 2] | 0) {
+ case 287:
+ {
+ HEAP32[i3 + 16 >> 2] = -1;
+ HEAP32[i3 + 20 >> 2] = -1;
+ HEAP32[i3 >> 2] = 5;
+ HEAP32[i3 + 8 >> 2] = 0;
+ HEAPF64[i3 + 8 >> 3] = +HEAPF64[i6 + 24 >> 3];
+ i8 = 20;
+ break;
+ }
+ case 271:
+ {
+ i9 = 1;
+ i8 = 8;
+ break;
+ }
+ case 289:
+ {
+ i8 = _luaK_stringK(i9, HEAP32[i6 + 24 >> 2] | 0) | 0;
+ HEAP32[i3 + 16 >> 2] = -1;
+ HEAP32[i3 + 20 >> 2] = -1;
+ HEAP32[i3 >> 2] = 4;
+ HEAP32[i3 + 8 >> 2] = i8;
+ i8 = 20;
+ break;
+ }
+ case 265:
+ {
+ _luaX_next(i6);
+ _body(i6, i3, 0, HEAP32[i6 + 4 >> 2] | 0);
+ break;
+ }
+ case 276:
+ {
+ HEAP32[i3 + 16 >> 2] = -1;
+ HEAP32[i3 + 20 >> 2] = -1;
+ HEAP32[i3 >> 2] = 2;
+ HEAP32[i3 + 8 >> 2] = 0;
+ i8 = 20;
+ break;
+ }
+ case 45:
+ {
+ i9 = 0;
+ i8 = 8;
+ break;
+ }
+ case 35:
+ {
+ i9 = 2;
+ i8 = 8;
+ break;
+ }
+ case 123:
+ {
+ _constructor(i6, i3);
+ break;
+ }
+ case 263:
+ {
+ HEAP32[i3 + 16 >> 2] = -1;
+ HEAP32[i3 + 20 >> 2] = -1;
+ HEAP32[i3 >> 2] = 3;
+ HEAP32[i3 + 8 >> 2] = 0;
+ i8 = 20;
+ break;
+ }
+ case 280:
+ {
+ if ((HEAP8[(HEAP32[i9 >> 2] | 0) + 77 | 0] | 0) == 0) {
+ _luaX_syntaxerror(i6, 6408);
+ } else {
+ i8 = _luaK_codeABC(i9, 38, 0, 1, 0) | 0;
+ HEAP32[i3 + 16 >> 2] = -1;
+ HEAP32[i3 + 20 >> 2] = -1;
+ HEAP32[i3 >> 2] = 13;
+ HEAP32[i3 + 8 >> 2] = i8;
+ i8 = 20;
+ break L8;
+ }
+ break;
+ }
+ case 270:
+ {
+ HEAP32[i3 + 16 >> 2] = -1;
+ HEAP32[i3 + 20 >> 2] = -1;
+ HEAP32[i3 >> 2] = 1;
+ HEAP32[i3 + 8 >> 2] = 0;
+ i8 = 20;
+ break;
+ }
+ default:
+ {
+ _suffixedexp(i6, i3);
+ }
+ }
+ } while (0);
+ if ((i8 | 0) == 8) {
+ i15 = HEAP32[i6 + 4 >> 2] | 0;
+ _luaX_next(i6);
+ _subexpr(i6, i3, 8) | 0;
+ _luaK_prefix(HEAP32[i4 >> 2] | 0, i9, i3, i15);
+ } else if ((i8 | 0) == 20) {
+ _luaX_next(i6);
+ }
+ switch (HEAP32[i10 >> 2] | 0) {
+ case 257:
+ {
+ i9 = 13;
+ break;
+ }
+ case 272:
+ {
+ i9 = 14;
+ break;
+ }
+ case 47:
+ {
+ i9 = 3;
+ break;
+ }
+ case 37:
+ {
+ i9 = 4;
+ break;
+ }
+ case 43:
+ {
+ i9 = 0;
+ break;
+ }
+ case 284:
+ {
+ i9 = 10;
+ break;
+ }
+ case 281:
+ {
+ i9 = 7;
+ break;
+ }
+ case 62:
+ {
+ i9 = 11;
+ break;
+ }
+ case 282:
+ {
+ i9 = 12;
+ break;
+ }
+ case 45:
+ {
+ i9 = 1;
+ break;
+ }
+ case 42:
+ {
+ i9 = 2;
+ break;
+ }
+ case 60:
+ {
+ i9 = 8;
+ break;
+ }
+ case 283:
+ {
+ i9 = 9;
+ break;
+ }
+ case 94:
+ {
+ i9 = 5;
+ break;
+ }
+ case 279:
+ {
+ i9 = 6;
+ break;
+ }
+ default:
+ {
+ i15 = 15;
+ i14 = HEAP32[i1 >> 2] | 0;
+ i14 = i14 + 38 | 0;
+ i13 = HEAP16[i14 >> 1] | 0;
+ i13 = i13 + -1 << 16 >> 16;
+ HEAP16[i14 >> 1] = i13;
+ STACKTOP = i2;
+ return i15 | 0;
+ }
+ }
+ i8 = i6 + 4 | 0;
+ while (1) {
+ if ((HEAPU8[6376 + (i9 << 1) | 0] | 0) <= (i7 | 0)) {
+ i8 = 39;
+ break;
+ }
+ i15 = HEAP32[i8 >> 2] | 0;
+ _luaX_next(i6);
+ _luaK_infix(HEAP32[i4 >> 2] | 0, i9, i3);
+ i10 = _subexpr(i6, i5, HEAPU8[6377 + (i9 << 1) | 0] | 0) | 0;
+ _luaK_posfix(HEAP32[i4 >> 2] | 0, i9, i3, i5, i15);
+ if ((i10 | 0) == 15) {
+ i9 = 15;
+ i8 = 39;
+ break;
+ } else {
+ i9 = i10;
+ }
+ }
+ if ((i8 | 0) == 39) {
+ i15 = HEAP32[i1 >> 2] | 0;
+ i15 = i15 + 38 | 0;
+ i14 = HEAP16[i15 >> 1] | 0;
+ i14 = i14 + -1 << 16 >> 16;
+ HEAP16[i15 >> 1] = i14;
+ STACKTOP = i2;
+ return i9 | 0;
+ }
+ return 0;
+}
+function _luaV_lessequal(i5, i3, i2) {
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i1 = STACKTOP;
+ i4 = i3 + 8 | 0;
+ i7 = HEAP32[i4 >> 2] | 0;
+ if ((i7 | 0) == 3) {
+ if ((HEAP32[i2 + 8 >> 2] | 0) == 3) {
+ i9 = +HEAPF64[i3 >> 3] <= +HEAPF64[i2 >> 3] | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ } else {
+ if ((i7 & 15 | 0) == 4 ? (HEAP32[i2 + 8 >> 2] & 15 | 0) == 4 : 0) {
+ i3 = HEAP32[i3 >> 2] | 0;
+ i6 = HEAP32[i2 >> 2] | 0;
+ i4 = i3 + 16 | 0;
+ i5 = i6 + 16 | 0;
+ i7 = _strcmp(i4, i5) | 0;
+ L8 : do {
+ if ((i7 | 0) == 0) {
+ i2 = HEAP32[i3 + 12 >> 2] | 0;
+ i3 = HEAP32[i6 + 12 >> 2] | 0;
+ i6 = i5;
+ while (1) {
+ i5 = _strlen(i4 | 0) | 0;
+ i7 = (i5 | 0) == (i2 | 0);
+ if ((i5 | 0) == (i3 | 0)) {
+ break;
+ }
+ if (i7) {
+ i7 = -1;
+ break L8;
+ }
+ i5 = i5 + 1 | 0;
+ i4 = i4 + i5 | 0;
+ i6 = i6 + i5 | 0;
+ i7 = _strcmp(i4, i6) | 0;
+ if ((i7 | 0) == 0) {
+ i2 = i2 - i5 | 0;
+ i3 = i3 - i5 | 0;
+ } else {
+ break L8;
+ }
+ }
+ i7 = i7 & 1 ^ 1;
+ }
+ } while (0);
+ i9 = (i7 | 0) < 1 | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ }
+ i7 = i5 + 8 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ i9 = _luaT_gettmbyobj(i5, i3, 14) | 0;
+ if ((HEAP32[i9 + 8 >> 2] | 0) == 0) {
+ i9 = _luaT_gettmbyobj(i5, i2, 14) | 0;
+ if ((HEAP32[i9 + 8 >> 2] | 0) == 0) {
+ i8 = HEAP32[i7 >> 2] | 0;
+ i9 = _luaT_gettmbyobj(i5, i2, 13) | 0;
+ if ((HEAP32[i9 + 8 >> 2] | 0) == 0) {
+ i9 = _luaT_gettmbyobj(i5, i3, 13) | 0;
+ if ((HEAP32[i9 + 8 >> 2] | 0) == 0) {
+ _luaG_ordererror(i5, i3, i2);
+ } else {
+ i6 = i9;
+ }
+ } else {
+ i6 = i9;
+ }
+ i10 = i5 + 28 | 0;
+ i9 = i8 - (HEAP32[i10 >> 2] | 0) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i8 + 16;
+ i13 = i6;
+ i11 = HEAP32[i13 + 4 >> 2] | 0;
+ i12 = i8;
+ HEAP32[i12 >> 2] = HEAP32[i13 >> 2];
+ HEAP32[i12 + 4 >> 2] = i11;
+ HEAP32[i8 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ i8 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i8 + 16;
+ i12 = i2;
+ i11 = HEAP32[i12 + 4 >> 2] | 0;
+ i6 = i8;
+ HEAP32[i6 >> 2] = HEAP32[i12 >> 2];
+ HEAP32[i6 + 4 >> 2] = i11;
+ HEAP32[i8 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ i2 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i2 + 16;
+ i8 = i3;
+ i6 = HEAP32[i8 + 4 >> 2] | 0;
+ i3 = i2;
+ HEAP32[i3 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i3 + 4 >> 2] = i6;
+ HEAP32[i2 + 8 >> 2] = HEAP32[i4 >> 2];
+ _luaD_call(i5, (HEAP32[i7 >> 2] | 0) + -48 | 0, 1, HEAP8[(HEAP32[i5 + 16 >> 2] | 0) + 18 | 0] & 1);
+ i3 = HEAP32[i10 >> 2] | 0;
+ i2 = HEAP32[i7 >> 2] | 0;
+ i5 = i2 + -16 | 0;
+ HEAP32[i7 >> 2] = i5;
+ i6 = HEAP32[i5 + 4 >> 2] | 0;
+ i8 = i3 + i9 | 0;
+ HEAP32[i8 >> 2] = HEAP32[i5 >> 2];
+ HEAP32[i8 + 4 >> 2] = i6;
+ HEAP32[i3 + (i9 + 8) >> 2] = HEAP32[i2 + -8 >> 2];
+ i3 = HEAP32[i7 >> 2] | 0;
+ i2 = HEAP32[i3 + 8 >> 2] | 0;
+ if ((i2 | 0) != 0) {
+ if ((i2 | 0) == 1) {
+ i2 = (HEAP32[i3 >> 2] | 0) != 0;
+ } else {
+ i2 = 1;
+ }
+ } else {
+ i2 = 0;
+ }
+ i13 = i2 & 1 ^ 1;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ }
+ i10 = i5 + 28 | 0;
+ i13 = i8 - (HEAP32[i10 >> 2] | 0) | 0;
+ i11 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i11 + 16;
+ i6 = i9;
+ i8 = HEAP32[i6 + 4 >> 2] | 0;
+ i12 = i11;
+ HEAP32[i12 >> 2] = HEAP32[i6 >> 2];
+ HEAP32[i12 + 4 >> 2] = i8;
+ HEAP32[i11 + 8 >> 2] = HEAP32[i9 + 8 >> 2];
+ i9 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i9 + 16;
+ i11 = i3;
+ i12 = HEAP32[i11 + 4 >> 2] | 0;
+ i3 = i9;
+ HEAP32[i3 >> 2] = HEAP32[i11 >> 2];
+ HEAP32[i3 + 4 >> 2] = i12;
+ HEAP32[i9 + 8 >> 2] = HEAP32[i4 >> 2];
+ i3 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i3 + 16;
+ i9 = i2;
+ i12 = HEAP32[i9 + 4 >> 2] | 0;
+ i11 = i3;
+ HEAP32[i11 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i11 + 4 >> 2] = i12;
+ HEAP32[i3 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ _luaD_call(i5, (HEAP32[i7 >> 2] | 0) + -48 | 0, 1, HEAP8[(HEAP32[i5 + 16 >> 2] | 0) + 18 | 0] & 1);
+ i2 = HEAP32[i10 >> 2] | 0;
+ i3 = HEAP32[i7 >> 2] | 0;
+ i10 = i3 + -16 | 0;
+ HEAP32[i7 >> 2] = i10;
+ i11 = HEAP32[i10 + 4 >> 2] | 0;
+ i12 = i2 + i13 | 0;
+ HEAP32[i12 >> 2] = HEAP32[i10 >> 2];
+ HEAP32[i12 + 4 >> 2] = i11;
+ HEAP32[i2 + (i13 + 8) >> 2] = HEAP32[i3 + -8 >> 2];
+ i2 = HEAP32[i7 >> 2] | 0;
+ i3 = HEAP32[i2 + 8 >> 2] | 0;
+ if ((i3 | 0) != 0) {
+ if ((i3 | 0) == 1) {
+ i2 = (HEAP32[i2 >> 2] | 0) != 0;
+ } else {
+ i2 = 1;
+ }
+ } else {
+ i2 = 0;
+ }
+ i13 = i2 & 1;
+ STACKTOP = i1;
+ return i13 | 0;
+}
+function ___udivmoddi4(i6, i8, i2, i4, i1) {
+ i6 = i6 | 0;
+ i8 = i8 | 0;
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ var i3 = 0, i5 = 0, i7 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0;
+ i5 = i6;
+ i9 = i8;
+ i7 = i9;
+ i10 = i2;
+ i3 = i4;
+ i11 = i3;
+ if ((i7 | 0) == 0) {
+ i2 = (i1 | 0) != 0;
+ if ((i11 | 0) == 0) {
+ if (i2) {
+ HEAP32[i1 >> 2] = (i5 >>> 0) % (i10 >>> 0);
+ HEAP32[i1 + 4 >> 2] = 0;
+ }
+ i11 = 0;
+ i12 = (i5 >>> 0) / (i10 >>> 0) >>> 0;
+ return (tempRet0 = i11, i12) | 0;
+ } else {
+ if (!i2) {
+ i11 = 0;
+ i12 = 0;
+ return (tempRet0 = i11, i12) | 0;
+ }
+ HEAP32[i1 >> 2] = i6 | 0;
+ HEAP32[i1 + 4 >> 2] = i8 & 0;
+ i11 = 0;
+ i12 = 0;
+ return (tempRet0 = i11, i12) | 0;
+ }
+ }
+ i12 = (i11 | 0) == 0;
+ do {
+ if ((i10 | 0) != 0) {
+ if (!i12) {
+ i10 = (_llvm_ctlz_i32(i11 | 0) | 0) - (_llvm_ctlz_i32(i7 | 0) | 0) | 0;
+ if (i10 >>> 0 <= 31) {
+ i11 = i10 + 1 | 0;
+ i12 = 31 - i10 | 0;
+ i8 = i10 - 31 >> 31;
+ i9 = i11;
+ i6 = i5 >>> (i11 >>> 0) & i8 | i7 << i12;
+ i8 = i7 >>> (i11 >>> 0) & i8;
+ i11 = 0;
+ i7 = i5 << i12;
+ break;
+ }
+ if ((i1 | 0) == 0) {
+ i11 = 0;
+ i12 = 0;
+ return (tempRet0 = i11, i12) | 0;
+ }
+ HEAP32[i1 >> 2] = i6 | 0;
+ HEAP32[i1 + 4 >> 2] = i9 | i8 & 0;
+ i11 = 0;
+ i12 = 0;
+ return (tempRet0 = i11, i12) | 0;
+ }
+ i11 = i10 - 1 | 0;
+ if ((i11 & i10 | 0) != 0) {
+ i12 = (_llvm_ctlz_i32(i10 | 0) | 0) + 33 - (_llvm_ctlz_i32(i7 | 0) | 0) | 0;
+ i15 = 64 - i12 | 0;
+ i10 = 32 - i12 | 0;
+ i13 = i10 >> 31;
+ i14 = i12 - 32 | 0;
+ i8 = i14 >> 31;
+ i9 = i12;
+ i6 = i10 - 1 >> 31 & i7 >>> (i14 >>> 0) | (i7 << i10 | i5 >>> (i12 >>> 0)) & i8;
+ i8 = i8 & i7 >>> (i12 >>> 0);
+ i11 = i5 << i15 & i13;
+ i7 = (i7 << i15 | i5 >>> (i14 >>> 0)) & i13 | i5 << i10 & i12 - 33 >> 31;
+ break;
+ }
+ if ((i1 | 0) != 0) {
+ HEAP32[i1 >> 2] = i11 & i5;
+ HEAP32[i1 + 4 >> 2] = 0;
+ }
+ if ((i10 | 0) == 1) {
+ i14 = i9 | i8 & 0;
+ i15 = i6 | 0 | 0;
+ return (tempRet0 = i14, i15) | 0;
+ } else {
+ i15 = _llvm_cttz_i32(i10 | 0) | 0;
+ i14 = i7 >>> (i15 >>> 0) | 0;
+ i15 = i7 << 32 - i15 | i5 >>> (i15 >>> 0) | 0;
+ return (tempRet0 = i14, i15) | 0;
+ }
+ } else {
+ if (i12) {
+ if ((i1 | 0) != 0) {
+ HEAP32[i1 >> 2] = (i7 >>> 0) % (i10 >>> 0);
+ HEAP32[i1 + 4 >> 2] = 0;
+ }
+ i14 = 0;
+ i15 = (i7 >>> 0) / (i10 >>> 0) >>> 0;
+ return (tempRet0 = i14, i15) | 0;
+ }
+ if ((i5 | 0) == 0) {
+ if ((i1 | 0) != 0) {
+ HEAP32[i1 >> 2] = 0;
+ HEAP32[i1 + 4 >> 2] = (i7 >>> 0) % (i11 >>> 0);
+ }
+ i14 = 0;
+ i15 = (i7 >>> 0) / (i11 >>> 0) >>> 0;
+ return (tempRet0 = i14, i15) | 0;
+ }
+ i10 = i11 - 1 | 0;
+ if ((i10 & i11 | 0) == 0) {
+ if ((i1 | 0) != 0) {
+ HEAP32[i1 >> 2] = i6 | 0;
+ HEAP32[i1 + 4 >> 2] = i10 & i7 | i8 & 0;
+ }
+ i14 = 0;
+ i15 = i7 >>> ((_llvm_cttz_i32(i11 | 0) | 0) >>> 0);
+ return (tempRet0 = i14, i15) | 0;
+ }
+ i10 = (_llvm_ctlz_i32(i11 | 0) | 0) - (_llvm_ctlz_i32(i7 | 0) | 0) | 0;
+ if (i10 >>> 0 <= 30) {
+ i8 = i10 + 1 | 0;
+ i15 = 31 - i10 | 0;
+ i9 = i8;
+ i6 = i7 << i15 | i5 >>> (i8 >>> 0);
+ i8 = i7 >>> (i8 >>> 0);
+ i11 = 0;
+ i7 = i5 << i15;
+ break;
+ }
+ if ((i1 | 0) == 0) {
+ i14 = 0;
+ i15 = 0;
+ return (tempRet0 = i14, i15) | 0;
+ }
+ HEAP32[i1 >> 2] = i6 | 0;
+ HEAP32[i1 + 4 >> 2] = i9 | i8 & 0;
+ i14 = 0;
+ i15 = 0;
+ return (tempRet0 = i14, i15) | 0;
+ }
+ } while (0);
+ if ((i9 | 0) == 0) {
+ i12 = i6;
+ i2 = 0;
+ i6 = 0;
+ } else {
+ i2 = i2 | 0 | 0;
+ i3 = i3 | i4 & 0;
+ i4 = _i64Add(i2, i3, -1, -1) | 0;
+ i5 = tempRet0;
+ i10 = i8;
+ i12 = i6;
+ i6 = 0;
+ while (1) {
+ i8 = i11 >>> 31 | i7 << 1;
+ i11 = i6 | i11 << 1;
+ i7 = i12 << 1 | i7 >>> 31 | 0;
+ i10 = i12 >>> 31 | i10 << 1 | 0;
+ _i64Subtract(i4, i5, i7, i10) | 0;
+ i12 = tempRet0;
+ i15 = i12 >> 31 | ((i12 | 0) < 0 ? -1 : 0) << 1;
+ i6 = i15 & 1;
+ i12 = _i64Subtract(i7, i10, i15 & i2, (((i12 | 0) < 0 ? -1 : 0) >> 31 | ((i12 | 0) < 0 ? -1 : 0) << 1) & i3) | 0;
+ i10 = tempRet0;
+ i9 = i9 - 1 | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ } else {
+ i7 = i8;
+ }
+ }
+ i7 = i8;
+ i8 = i10;
+ i2 = 0;
+ }
+ i3 = 0;
+ if ((i1 | 0) != 0) {
+ HEAP32[i1 >> 2] = i12;
+ HEAP32[i1 + 4 >> 2] = i8;
+ }
+ i14 = (i11 | 0) >>> 31 | (i7 | i3) << 1 | (i3 << 1 | i11 >>> 31) & 0 | i2;
+ i15 = (i11 << 1 | 0 >>> 31) & -2 | i6;
+ return (tempRet0 = i14, i15) | 0;
+}
+function _leaveblock(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i5 = i3;
+ i7 = i1 + 16 | 0;
+ i4 = HEAP32[i7 >> 2] | 0;
+ i2 = i1 + 12 | 0;
+ i6 = HEAP32[i2 >> 2] | 0;
+ if ((HEAP32[i4 >> 2] | 0) != 0 ? (HEAP8[i4 + 9 | 0] | 0) != 0 : 0) {
+ i16 = _luaK_jump(i1) | 0;
+ _luaK_patchclose(i1, i16, HEAPU8[i4 + 8 | 0] | 0);
+ _luaK_patchtohere(i1, i16);
+ }
+ L5 : do {
+ if ((HEAP8[i4 + 10 | 0] | 0) != 0) {
+ i15 = i6 + 52 | 0;
+ i14 = _luaS_new(HEAP32[i15 >> 2] | 0, 6304) | 0;
+ i13 = i6 + 64 | 0;
+ i16 = HEAP32[i13 >> 2] | 0;
+ i10 = i16 + 24 | 0;
+ i8 = i6 + 48 | 0;
+ i11 = HEAP32[(HEAP32[i8 >> 2] | 0) + 20 >> 2] | 0;
+ i12 = i16 + 28 | 0;
+ i9 = HEAP32[i12 >> 2] | 0;
+ i16 = i16 + 32 | 0;
+ if ((i9 | 0) < (HEAP32[i16 >> 2] | 0)) {
+ i15 = HEAP32[i10 >> 2] | 0;
+ } else {
+ i15 = _luaM_growaux_(HEAP32[i15 >> 2] | 0, HEAP32[i10 >> 2] | 0, i16, 16, 32767, 6312) | 0;
+ HEAP32[i10 >> 2] = i15;
+ }
+ HEAP32[i15 + (i9 << 4) >> 2] = i14;
+ i16 = HEAP32[i10 >> 2] | 0;
+ HEAP32[i16 + (i9 << 4) + 8 >> 2] = 0;
+ HEAP8[i16 + (i9 << 4) + 12 | 0] = HEAP8[(HEAP32[i8 >> 2] | 0) + 46 | 0] | 0;
+ HEAP32[(HEAP32[i10 >> 2] | 0) + (i9 << 4) + 4 >> 2] = i11;
+ HEAP32[i12 >> 2] = (HEAP32[i12 >> 2] | 0) + 1;
+ i10 = HEAP32[i13 >> 2] | 0;
+ i9 = (HEAP32[i10 + 24 >> 2] | 0) + (i9 << 4) | 0;
+ i11 = HEAP16[(HEAP32[(HEAP32[i8 >> 2] | 0) + 16 >> 2] | 0) + 6 >> 1] | 0;
+ i8 = i10 + 16 | 0;
+ if ((i11 | 0) < (HEAP32[i8 >> 2] | 0)) {
+ i10 = i10 + 12 | 0;
+ do {
+ while (1) {
+ if ((_luaS_eqstr(HEAP32[(HEAP32[i10 >> 2] | 0) + (i11 << 4) >> 2] | 0, HEAP32[i9 >> 2] | 0) | 0) == 0) {
+ break;
+ }
+ _closegoto(i6, i11, i9);
+ if ((i11 | 0) >= (HEAP32[i8 >> 2] | 0)) {
+ break L5;
+ }
+ }
+ i11 = i11 + 1 | 0;
+ } while ((i11 | 0) < (HEAP32[i8 >> 2] | 0));
+ }
+ }
+ } while (0);
+ HEAP32[i7 >> 2] = HEAP32[i4 >> 2];
+ i7 = i4 + 8 | 0;
+ i9 = HEAP8[i7] | 0;
+ i10 = i1 + 46 | 0;
+ i8 = (HEAP32[i2 >> 2] | 0) + 64 | 0;
+ i14 = (HEAP32[i8 >> 2] | 0) + 4 | 0;
+ HEAP32[i14 >> 2] = (i9 & 255) - (HEAPU8[i10] | 0) + (HEAP32[i14 >> 2] | 0);
+ i14 = HEAP8[i10] | 0;
+ if ((i14 & 255) > (i9 & 255)) {
+ i13 = i1 + 20 | 0;
+ i11 = i1 + 40 | 0;
+ i12 = (HEAP32[i1 >> 2] | 0) + 24 | 0;
+ do {
+ i16 = HEAP32[i13 >> 2] | 0;
+ i14 = i14 + -1 << 24 >> 24;
+ HEAP8[i10] = i14;
+ HEAP32[(HEAP32[i12 >> 2] | 0) + ((HEAP16[(HEAP32[HEAP32[i8 >> 2] >> 2] | 0) + ((HEAP32[i11 >> 2] | 0) + (i14 & 255) << 1) >> 1] | 0) * 12 | 0) + 8 >> 2] = i16;
+ i14 = HEAP8[i10] | 0;
+ } while ((i14 & 255) > (i9 & 255));
+ }
+ HEAP8[i1 + 48 | 0] = i14;
+ i10 = HEAP32[i6 + 64 >> 2] | 0;
+ HEAP32[i10 + 28 >> 2] = HEAP16[i4 + 4 >> 1] | 0;
+ i9 = HEAP16[i4 + 6 >> 1] | 0;
+ if ((HEAP32[i4 >> 2] | 0) == 0) {
+ if ((i9 | 0) >= (HEAP32[i10 + 16 >> 2] | 0)) {
+ STACKTOP = i3;
+ return;
+ }
+ i10 = HEAP32[i10 + 12 >> 2] | 0;
+ i11 = HEAP32[i10 + (i9 << 4) >> 2] | 0;
+ if ((HEAP8[i11 + 4 | 0] | 0) != 4) {
+ i16 = 6200;
+ i15 = i6 + 52 | 0;
+ i15 = HEAP32[i15 >> 2] | 0;
+ i14 = i11 + 16 | 0;
+ i13 = i10 + (i9 << 4) + 8 | 0;
+ i13 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i5 >> 2] = i14;
+ i14 = i5 + 4 | 0;
+ HEAP32[i14 >> 2] = i13;
+ i16 = _luaO_pushfstring(i15, i16, i5) | 0;
+ _semerror(i6, i16);
+ }
+ i16 = (HEAP8[i11 + 6 | 0] | 0) != 0 ? 6160 : 6200;
+ i15 = i6 + 52 | 0;
+ i15 = HEAP32[i15 >> 2] | 0;
+ i14 = i11 + 16 | 0;
+ i13 = i10 + (i9 << 4) + 8 | 0;
+ i13 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i5 >> 2] = i14;
+ i14 = i5 + 4 | 0;
+ HEAP32[i14 >> 2] = i13;
+ i16 = _luaO_pushfstring(i15, i16, i5) | 0;
+ _semerror(i6, i16);
+ }
+ i6 = HEAP32[i8 >> 2] | 0;
+ i5 = i6 + 16 | 0;
+ if ((i9 | 0) >= (HEAP32[i5 >> 2] | 0)) {
+ STACKTOP = i3;
+ return;
+ }
+ i6 = i6 + 12 | 0;
+ i4 = i4 + 9 | 0;
+ do {
+ i10 = HEAP32[i6 >> 2] | 0;
+ i8 = i10 + (i9 << 4) + 12 | 0;
+ i11 = HEAP8[i7] | 0;
+ i12 = i11 & 255;
+ if ((HEAPU8[i8] | 0) > (i11 & 255)) {
+ if ((HEAP8[i4] | 0) != 0) {
+ _luaK_patchclose(i1, HEAP32[i10 + (i9 << 4) + 4 >> 2] | 0, i12);
+ i11 = HEAP8[i7] | 0;
+ }
+ HEAP8[i8] = i11;
+ }
+ i9 = ((_findlabel(HEAP32[i2 >> 2] | 0, i9) | 0) == 0) + i9 | 0;
+ } while ((i9 | 0) < (HEAP32[i5 >> 2] | 0));
+ STACKTOP = i3;
+ return;
+}
+function _getobjname(i3, i7, i9, i2) {
+ i3 = i3 | 0;
+ i7 = i7 | 0;
+ i9 = i9 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i1 = STACKTOP;
+ i4 = i3 + 12 | 0;
+ L1 : while (1) {
+ i13 = _luaF_getlocalname(i3, i9 + 1 | 0, i7) | 0;
+ HEAP32[i2 >> 2] = i13;
+ if ((i13 | 0) != 0) {
+ i2 = 2040;
+ i4 = 42;
+ break;
+ }
+ if ((i7 | 0) <= 0) {
+ i2 = 0;
+ i4 = 42;
+ break;
+ }
+ i6 = HEAP32[i4 >> 2] | 0;
+ i8 = 0;
+ i5 = -1;
+ do {
+ i12 = HEAP32[i6 + (i8 << 2) >> 2] | 0;
+ i13 = i12 & 63;
+ i11 = i12 >>> 6 & 255;
+ switch (i13 | 0) {
+ case 27:
+ {
+ i10 = i8;
+ i5 = (i11 | 0) == (i9 | 0) ? i8 : i5;
+ break;
+ }
+ case 30:
+ case 29:
+ {
+ i10 = i8;
+ i5 = (i11 | 0) > (i9 | 0) ? i5 : i8;
+ break;
+ }
+ case 23:
+ {
+ i10 = (i12 >>> 14) + -131071 | 0;
+ i13 = i8 + 1 + i10 | 0;
+ i10 = ((i8 | 0) >= (i13 | 0) | (i13 | 0) > (i7 | 0) ? 0 : i10) + i8 | 0;
+ break;
+ }
+ case 4:
+ {
+ if ((i11 | 0) > (i9 | 0)) {
+ i10 = i8;
+ } else {
+ i10 = i8;
+ i5 = (i11 + (i12 >>> 23) | 0) < (i9 | 0) ? i5 : i8;
+ }
+ break;
+ }
+ case 34:
+ {
+ i10 = i8;
+ i5 = (i11 + 2 | 0) > (i9 | 0) ? i5 : i8;
+ break;
+ }
+ default:
+ {
+ i10 = i8;
+ i5 = (HEAP8[5584 + i13 | 0] & 64) != 0 & (i11 | 0) == (i9 | 0) ? i8 : i5;
+ }
+ }
+ i8 = i10 + 1 | 0;
+ } while ((i8 | 0) < (i7 | 0));
+ if ((i5 | 0) == -1) {
+ i2 = 0;
+ i4 = 42;
+ break;
+ }
+ i7 = HEAP32[i6 + (i5 << 2) >> 2] | 0;
+ i9 = i7 & 63;
+ switch (i9 | 0) {
+ case 0:
+ {
+ break;
+ }
+ case 7:
+ case 6:
+ {
+ i4 = 17;
+ break L1;
+ }
+ case 5:
+ {
+ i4 = 29;
+ break L1;
+ }
+ case 1:
+ {
+ i4 = 32;
+ break L1;
+ }
+ case 2:
+ {
+ i4 = 33;
+ break L1;
+ }
+ case 12:
+ {
+ i4 = 36;
+ break L1;
+ }
+ default:
+ {
+ i2 = 0;
+ i4 = 42;
+ break L1;
+ }
+ }
+ i9 = i7 >>> 23;
+ if (i9 >>> 0 < (i7 >>> 6 & 255) >>> 0) {
+ i7 = i5;
+ } else {
+ i2 = 0;
+ i4 = 42;
+ break;
+ }
+ }
+ if ((i4 | 0) == 17) {
+ i6 = i7 >>> 14;
+ i8 = i6 & 511;
+ i7 = i7 >>> 23;
+ if ((i9 | 0) != 7) {
+ i7 = HEAP32[(HEAP32[i3 + 28 >> 2] | 0) + (i7 << 3) >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i7 = 2104;
+ } else {
+ i7 = i7 + 16 | 0;
+ }
+ } else {
+ i7 = _luaF_getlocalname(i3, i7 + 1 | 0, i5) | 0;
+ }
+ if ((i6 & 256 | 0) == 0) {
+ i3 = _getobjname(i3, i5, i8, i2) | 0;
+ if (!((i3 | 0) != 0 ? (HEAP8[i3] | 0) == 99 : 0)) {
+ i4 = 26;
+ }
+ } else {
+ i5 = i6 & 255;
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ if ((HEAP32[i3 + (i5 << 4) + 8 >> 2] & 15 | 0) == 4) {
+ HEAP32[i2 >> 2] = (HEAP32[i3 + (i5 << 4) >> 2] | 0) + 16;
+ } else {
+ i4 = 26;
+ }
+ }
+ if ((i4 | 0) == 26) {
+ HEAP32[i2 >> 2] = 2104;
+ }
+ if ((i7 | 0) == 0) {
+ i13 = 2064;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ i13 = (_strcmp(i7, 2048) | 0) == 0;
+ i13 = i13 ? 2056 : 2064;
+ STACKTOP = i1;
+ return i13 | 0;
+ } else if ((i4 | 0) == 29) {
+ i3 = HEAP32[(HEAP32[i3 + 28 >> 2] | 0) + (i7 >>> 23 << 3) >> 2] | 0;
+ if ((i3 | 0) == 0) {
+ i3 = 2104;
+ } else {
+ i3 = i3 + 16 | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ i13 = 2072;
+ STACKTOP = i1;
+ return i13 | 0;
+ } else if ((i4 | 0) == 32) {
+ i5 = i7 >>> 14;
+ } else if ((i4 | 0) == 33) {
+ i5 = (HEAP32[i6 + (i5 + 1 << 2) >> 2] | 0) >>> 6;
+ } else if ((i4 | 0) == 36) {
+ i4 = i7 >>> 14;
+ if ((i4 & 256 | 0) == 0) {
+ i3 = _getobjname(i3, i5, i4 & 511, i2) | 0;
+ if ((i3 | 0) != 0 ? (HEAP8[i3] | 0) == 99 : 0) {
+ i13 = 2096;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ } else {
+ i4 = i4 & 255;
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ if ((HEAP32[i3 + (i4 << 4) + 8 >> 2] & 15 | 0) == 4) {
+ HEAP32[i2 >> 2] = (HEAP32[i3 + (i4 << 4) >> 2] | 0) + 16;
+ i13 = 2096;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ }
+ HEAP32[i2 >> 2] = 2104;
+ i13 = 2096;
+ STACKTOP = i1;
+ return i13 | 0;
+ } else if ((i4 | 0) == 42) {
+ STACKTOP = i1;
+ return i2 | 0;
+ }
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ if ((HEAP32[i3 + (i5 << 4) + 8 >> 2] & 15 | 0) != 4) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ HEAP32[i2 >> 2] = (HEAP32[i3 + (i5 << 4) >> 2] | 0) + 16;
+ i13 = 2080;
+ STACKTOP = i1;
+ return i13 | 0;
+}
+function _assignment(i2, i16, i5) {
+ i2 = i2 | 0;
+ i16 = i16 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 80 | 0;
+ i6 = i3 + 56 | 0;
+ i1 = i3 + 32 | 0;
+ i8 = i3;
+ i4 = i16 + 8 | 0;
+ if (!(((HEAP32[i4 >> 2] | 0) + -7 | 0) >>> 0 < 3)) {
+ _luaX_syntaxerror(i2, 6344);
+ }
+ i13 = i2 + 16 | 0;
+ i14 = HEAP32[i13 >> 2] | 0;
+ do {
+ if ((i14 | 0) == 44) {
+ _luaX_next(i2);
+ HEAP32[i8 >> 2] = i16;
+ i14 = i8 + 8 | 0;
+ _suffixedexp(i2, i14);
+ i15 = i2 + 48 | 0;
+ if ((HEAP32[i14 >> 2] | 0) != 9 ? (i10 = HEAP32[i15 >> 2] | 0, i11 = HEAP8[i10 + 48 | 0] | 0, i9 = i11 & 255, (i16 | 0) != 0) : 0) {
+ i13 = i8 + 16 | 0;
+ i12 = i11 & 255;
+ i18 = 0;
+ do {
+ if ((HEAP32[i16 + 8 >> 2] | 0) == 9) {
+ i17 = i16 + 16 | 0;
+ i19 = i17 + 3 | 0;
+ i20 = HEAPU8[i19] | 0;
+ i21 = HEAP32[i14 >> 2] | 0;
+ if ((i20 | 0) == (i21 | 0)) {
+ i21 = i17 + 2 | 0;
+ if ((HEAPU8[i21] | 0) == (HEAP32[i13 >> 2] | 0)) {
+ HEAP8[i19] = 7;
+ HEAP8[i21] = i11;
+ i20 = HEAP32[i14 >> 2] | 0;
+ i18 = 1;
+ }
+ } else {
+ i20 = i21;
+ }
+ if ((i20 | 0) == 7 ? (HEAP16[i17 >> 1] | 0) == (HEAP32[i13 >> 2] | 0) : 0) {
+ HEAP16[i17 >> 1] = i12;
+ i18 = 1;
+ }
+ }
+ i16 = HEAP32[i16 >> 2] | 0;
+ } while ((i16 | 0) != 0);
+ if ((i18 | 0) != 0) {
+ _luaK_codeABC(i10, (HEAP32[i14 >> 2] | 0) == 7 ? 0 : 5, i9, HEAP32[i13 >> 2] | 0, 0) | 0;
+ _luaK_reserveregs(i10, 1);
+ }
+ }
+ i9 = HEAP32[i15 >> 2] | 0;
+ if (((HEAPU16[(HEAP32[i2 + 52 >> 2] | 0) + 38 >> 1] | 0) + i5 | 0) <= 200) {
+ _assignment(i2, i8, i5 + 1 | 0);
+ i7 = i1;
+ break;
+ }
+ i8 = i9 + 12 | 0;
+ i5 = HEAP32[(HEAP32[i8 >> 2] | 0) + 52 >> 2] | 0;
+ i9 = HEAP32[(HEAP32[i9 >> 2] | 0) + 64 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ i20 = 6552;
+ HEAP32[i6 >> 2] = 6360;
+ i21 = i6 + 4 | 0;
+ HEAP32[i21 >> 2] = 200;
+ i21 = i6 + 8 | 0;
+ HEAP32[i21 >> 2] = i20;
+ i21 = _luaO_pushfstring(i5, 6592, i6) | 0;
+ i20 = HEAP32[i8 >> 2] | 0;
+ _luaX_syntaxerror(i20, i21);
+ }
+ HEAP32[i6 >> 2] = i9;
+ i20 = _luaO_pushfstring(i5, 6568, i6) | 0;
+ HEAP32[i6 >> 2] = 6360;
+ i21 = i6 + 4 | 0;
+ HEAP32[i21 >> 2] = 200;
+ i21 = i6 + 8 | 0;
+ HEAP32[i21 >> 2] = i20;
+ i21 = _luaO_pushfstring(i5, 6592, i6) | 0;
+ i20 = HEAP32[i8 >> 2] | 0;
+ _luaX_syntaxerror(i20, i21);
+ } else if ((i14 | 0) == 61) {
+ _luaX_next(i2);
+ _subexpr(i2, i1, 0) | 0;
+ i6 = i2 + 48 | 0;
+ if ((HEAP32[i13 >> 2] | 0) == 44) {
+ i9 = 1;
+ do {
+ _luaX_next(i2);
+ _luaK_exp2nextreg(HEAP32[i6 >> 2] | 0, i1);
+ _subexpr(i2, i1, 0) | 0;
+ i9 = i9 + 1 | 0;
+ } while ((HEAP32[i13 >> 2] | 0) == 44);
+ } else {
+ i9 = 1;
+ }
+ i8 = HEAP32[i6 >> 2] | 0;
+ if ((i9 | 0) == (i5 | 0)) {
+ _luaK_setoneret(i8, i1);
+ _luaK_storevar(HEAP32[i6 >> 2] | 0, i4, i1);
+ STACKTOP = i3;
+ return;
+ }
+ i7 = i5 - i9 | 0;
+ i10 = HEAP32[i1 >> 2] | 0;
+ if ((i10 | 0) == 13 | (i10 | 0) == 12) {
+ i10 = i7 + 1 | 0;
+ i10 = (i10 | 0) < 0 ? 0 : i10;
+ _luaK_setreturns(i8, i1, i10);
+ if ((i10 | 0) > 1) {
+ _luaK_reserveregs(i8, i10 + -1 | 0);
+ }
+ } else if ((i10 | 0) == 0) {
+ i12 = 30;
+ } else {
+ _luaK_exp2nextreg(i8, i1);
+ i12 = 30;
+ }
+ if ((i12 | 0) == 30 ? (i7 | 0) > 0 : 0) {
+ i21 = HEAPU8[i8 + 48 | 0] | 0;
+ _luaK_reserveregs(i8, i7);
+ _luaK_nil(i8, i21, i7);
+ }
+ if ((i9 | 0) > (i5 | 0)) {
+ i21 = (HEAP32[i6 >> 2] | 0) + 48 | 0;
+ HEAP8[i21] = i7 + (HEAPU8[i21] | 0);
+ i7 = i1;
+ } else {
+ i7 = i1;
+ }
+ } else {
+ _error_expected(i2, 61);
+ }
+ } while (0);
+ i21 = HEAP32[i2 + 48 >> 2] | 0;
+ i20 = (HEAPU8[i21 + 48 | 0] | 0) + -1 | 0;
+ HEAP32[i1 + 16 >> 2] = -1;
+ HEAP32[i1 + 20 >> 2] = -1;
+ HEAP32[i7 >> 2] = 6;
+ HEAP32[i1 + 8 >> 2] = i20;
+ _luaK_storevar(i21, i4, i1);
+ STACKTOP = i3;
+ return;
+}
+function _str_find_aux(i3, i7) {
+ i3 = i3 | 0;
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 288 | 0;
+ i9 = i1 + 284 | 0;
+ i5 = i1 + 280 | 0;
+ i4 = i1;
+ i2 = _luaL_checklstring(i3, 1, i9) | 0;
+ i8 = _luaL_checklstring(i3, 2, i5) | 0;
+ i12 = _luaL_optinteger(i3, 3, 1) | 0;
+ i10 = HEAP32[i9 >> 2] | 0;
+ if (!((i12 | 0) > -1)) {
+ if (i10 >>> 0 < (0 - i12 | 0) >>> 0) {
+ i12 = 1;
+ } else {
+ i12 = i12 + 1 + i10 | 0;
+ i6 = 4;
+ }
+ } else {
+ i6 = 4;
+ }
+ if ((i6 | 0) == 4) {
+ if ((i12 | 0) != 0) {
+ if (i12 >>> 0 > (i10 + 1 | 0) >>> 0) {
+ _lua_pushnil(i3);
+ i13 = 1;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ } else {
+ i12 = 1;
+ }
+ }
+ i7 = (i7 | 0) != 0;
+ L10 : do {
+ if (i7) {
+ i13 = (_lua_toboolean(i3, 4) | 0) == 0;
+ i10 = HEAP32[i5 >> 2] | 0;
+ if (i13) {
+ i11 = 0;
+ do {
+ i13 = i8 + i11 | 0;
+ if ((_strpbrk(i13, 7512) | 0) != 0) {
+ i6 = 20;
+ break L10;
+ }
+ i11 = i11 + 1 + (_strlen(i13 | 0) | 0) | 0;
+ } while (!(i11 >>> 0 > i10 >>> 0));
+ }
+ i11 = i2 + (i12 + -1) | 0;
+ i9 = (HEAP32[i9 >> 2] | 0) - i12 + 1 | 0;
+ L17 : do {
+ if ((i10 | 0) == 0) {
+ if ((i11 | 0) == 0) {
+ break L10;
+ }
+ } else {
+ if (i10 >>> 0 > i9 >>> 0) {
+ break L10;
+ }
+ i4 = i10 + -1 | 0;
+ if ((i4 | 0) == (i9 | 0)) {
+ break L10;
+ }
+ i7 = HEAP8[i8] | 0;
+ i8 = i8 + 1 | 0;
+ i9 = i9 - i4 | 0;
+ i12 = i11;
+ while (1) {
+ i11 = _memchr(i12, i7, i9) | 0;
+ if ((i11 | 0) == 0) {
+ break L10;
+ }
+ i10 = i11 + 1 | 0;
+ if ((_memcmp(i10, i8, i4) | 0) == 0) {
+ break L17;
+ }
+ i11 = i10;
+ i9 = i12 + i9 | 0;
+ if ((i9 | 0) == (i11 | 0)) {
+ break L10;
+ } else {
+ i9 = i9 - i11 | 0;
+ i12 = i10;
+ }
+ }
+ }
+ } while (0);
+ i13 = i11 - i2 | 0;
+ _lua_pushinteger(i3, i13 + 1 | 0);
+ _lua_pushinteger(i3, i13 + (HEAP32[i5 >> 2] | 0) | 0);
+ i13 = 2;
+ STACKTOP = i1;
+ return i13 | 0;
+ } else {
+ i6 = 20;
+ }
+ } while (0);
+ L28 : do {
+ if ((i6 | 0) == 20) {
+ i6 = i2 + (i12 + -1) | 0;
+ i10 = (HEAP8[i8] | 0) == 94;
+ if (i10) {
+ i12 = (HEAP32[i5 >> 2] | 0) + -1 | 0;
+ HEAP32[i5 >> 2] = i12;
+ i8 = i8 + 1 | 0;
+ } else {
+ i12 = HEAP32[i5 >> 2] | 0;
+ }
+ i5 = i4 + 16 | 0;
+ HEAP32[i5 >> 2] = i3;
+ HEAP32[i4 >> 2] = 200;
+ HEAP32[i4 + 4 >> 2] = i2;
+ i11 = i4 + 8 | 0;
+ HEAP32[i11 >> 2] = i2 + (HEAP32[i9 >> 2] | 0);
+ HEAP32[i4 + 12 >> 2] = i8 + i12;
+ i9 = i4 + 20 | 0;
+ L34 : do {
+ if (i10) {
+ HEAP32[i9 >> 2] = 0;
+ i8 = _match(i4, i6, i8) | 0;
+ if ((i8 | 0) == 0) {
+ break L28;
+ }
+ } else {
+ while (1) {
+ HEAP32[i9 >> 2] = 0;
+ i10 = _match(i4, i6, i8) | 0;
+ if ((i10 | 0) != 0) {
+ i8 = i10;
+ break L34;
+ }
+ if (!(i6 >>> 0 < (HEAP32[i11 >> 2] | 0) >>> 0)) {
+ break L28;
+ }
+ i6 = i6 + 1 | 0;
+ }
+ }
+ } while (0);
+ if (i7) {
+ _lua_pushinteger(i3, 1 - i2 + i6 | 0);
+ _lua_pushinteger(i3, i8 - i2 | 0);
+ i2 = HEAP32[i9 >> 2] | 0;
+ _luaL_checkstack(HEAP32[i5 >> 2] | 0, i2, 7200);
+ if ((i2 | 0) > 0) {
+ i3 = 0;
+ do {
+ _push_onecapture(i4, i3, 0, 0);
+ i3 = i3 + 1 | 0;
+ } while ((i3 | 0) != (i2 | 0));
+ }
+ i13 = i2 + 2 | 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ } else {
+ i3 = HEAP32[i9 >> 2] | 0;
+ i2 = (i3 | 0) != 0 | (i6 | 0) == 0 ? i3 : 1;
+ _luaL_checkstack(HEAP32[i5 >> 2] | 0, i2, 7200);
+ if ((i2 | 0) > 0) {
+ i3 = 0;
+ } else {
+ i13 = i3;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ do {
+ _push_onecapture(i4, i3, i6, i8);
+ i3 = i3 + 1 | 0;
+ } while ((i3 | 0) != (i2 | 0));
+ STACKTOP = i1;
+ return i2 | 0;
+ }
+ }
+ } while (0);
+ _lua_pushnil(i3);
+ i13 = 1;
+ STACKTOP = i1;
+ return i13 | 0;
+}
+function _luaO_pushvfstring(i2, i13, i10) {
+ i2 = i2 | 0;
+ i13 = i13 | 0;
+ i10 = i10 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i11 = 0, i12 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, d18 = 0.0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 48 | 0;
+ i7 = i3;
+ i9 = i3 + 32 | 0;
+ i8 = i3 + 8 | 0;
+ i14 = _strchr(i13, 37) | 0;
+ i6 = i2 + 24 | 0;
+ i4 = i2 + 8 | 0;
+ i15 = HEAP32[i4 >> 2] | 0;
+ i17 = (HEAP32[i6 >> 2] | 0) - i15 | 0;
+ L1 : do {
+ if ((i14 | 0) == 0) {
+ i5 = i13;
+ i11 = i17;
+ i12 = i15;
+ i1 = 0;
+ } else {
+ i16 = 0;
+ L3 : while (1) {
+ if ((i17 | 0) < 48) {
+ _luaD_growstack(i2, 2);
+ i15 = HEAP32[i4 >> 2] | 0;
+ }
+ HEAP32[i4 >> 2] = i15 + 16;
+ i13 = _luaS_newlstr(i2, i13, i14 - i13 | 0) | 0;
+ HEAP32[i15 >> 2] = i13;
+ HEAP32[i15 + 8 >> 2] = HEAPU8[i13 + 4 | 0] | 64;
+ i13 = HEAP8[i14 + 1 | 0] | 0;
+ switch (i13 | 0) {
+ case 115:
+ {
+ i17 = HEAP32[i10 >> 2] | 0;
+ i13 = HEAP32[i17 >> 2] | 0;
+ HEAP32[i10 >> 2] = i17 + 4;
+ i13 = (i13 | 0) == 0 ? 5480 : i13;
+ i15 = _strlen(i13 | 0) | 0;
+ i17 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = i17 + 16;
+ i15 = _luaS_newlstr(i2, i13, i15) | 0;
+ HEAP32[i17 >> 2] = i15;
+ HEAP32[i17 + 8 >> 2] = HEAPU8[i15 + 4 | 0] | 64;
+ break;
+ }
+ case 100:
+ {
+ i17 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = i17 + 16;
+ i13 = HEAP32[i10 >> 2] | 0;
+ i15 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i10 >> 2] = i13 + 4;
+ HEAPF64[i17 >> 3] = +(i15 | 0);
+ HEAP32[i17 + 8 >> 2] = 3;
+ break;
+ }
+ case 37:
+ {
+ i17 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = i17 + 16;
+ i15 = _luaS_newlstr(i2, 5496, 1) | 0;
+ HEAP32[i17 >> 2] = i15;
+ HEAP32[i17 + 8 >> 2] = HEAPU8[i15 + 4 | 0] | 64;
+ break;
+ }
+ case 99:
+ {
+ i15 = HEAP32[i10 >> 2] | 0;
+ i17 = HEAP32[i15 >> 2] | 0;
+ HEAP32[i10 >> 2] = i15 + 4;
+ HEAP8[i9] = i17;
+ i17 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = i17 + 16;
+ i15 = _luaS_newlstr(i2, i9, 1) | 0;
+ HEAP32[i17 >> 2] = i15;
+ HEAP32[i17 + 8 >> 2] = HEAPU8[i15 + 4 | 0] | 64;
+ break;
+ }
+ case 102:
+ {
+ i17 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = i17 + 16;
+ i15 = HEAP32[i10 >> 2] | 0;
+ d18 = +HEAPF64[i15 >> 3];
+ HEAP32[i10 >> 2] = i15 + 8;
+ HEAPF64[i17 >> 3] = d18;
+ HEAP32[i17 + 8 >> 2] = 3;
+ break;
+ }
+ case 112:
+ {
+ i17 = HEAP32[i10 >> 2] | 0;
+ i15 = HEAP32[i17 >> 2] | 0;
+ HEAP32[i10 >> 2] = i17 + 4;
+ HEAP32[i7 >> 2] = i15;
+ i15 = _sprintf(i8 | 0, 5488, i7 | 0) | 0;
+ i17 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = i17 + 16;
+ i15 = _luaS_newlstr(i2, i8, i15) | 0;
+ HEAP32[i17 >> 2] = i15;
+ HEAP32[i17 + 8 >> 2] = HEAPU8[i15 + 4 | 0] | 64;
+ break;
+ }
+ default:
+ {
+ break L3;
+ }
+ }
+ i16 = i16 + 2 | 0;
+ i13 = i14 + 2 | 0;
+ i14 = _strchr(i13, 37) | 0;
+ i15 = HEAP32[i4 >> 2] | 0;
+ i17 = (HEAP32[i6 >> 2] | 0) - i15 | 0;
+ if ((i14 | 0) == 0) {
+ i5 = i13;
+ i11 = i17;
+ i12 = i15;
+ i1 = i16;
+ break L1;
+ }
+ }
+ HEAP32[i7 >> 2] = i13;
+ _luaG_runerror(i2, 5504, i7);
+ }
+ } while (0);
+ if ((i11 | 0) < 32) {
+ _luaD_growstack(i2, 1);
+ i12 = HEAP32[i4 >> 2] | 0;
+ }
+ i17 = _strlen(i5 | 0) | 0;
+ HEAP32[i4 >> 2] = i12 + 16;
+ i17 = _luaS_newlstr(i2, i5, i17) | 0;
+ HEAP32[i12 >> 2] = i17;
+ HEAP32[i12 + 8 >> 2] = HEAPU8[i17 + 4 | 0] | 64;
+ if ((i1 | 0) <= 0) {
+ i17 = HEAP32[i4 >> 2] | 0;
+ i17 = i17 + -16 | 0;
+ i17 = HEAP32[i17 >> 2] | 0;
+ i17 = i17 + 16 | 0;
+ STACKTOP = i3;
+ return i17 | 0;
+ }
+ _luaV_concat(i2, i1 | 1);
+ i17 = HEAP32[i4 >> 2] | 0;
+ i17 = i17 + -16 | 0;
+ i17 = HEAP32[i17 >> 2] | 0;
+ i17 = i17 + 16 | 0;
+ STACKTOP = i3;
+ return i17 | 0;
+}
+function _luaH_getn(i6) {
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, d11 = 0.0, i12 = 0, i13 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i1;
+ i3 = i6 + 28 | 0;
+ i12 = HEAP32[i3 >> 2] | 0;
+ if ((i12 | 0) != 0 ? (i4 = HEAP32[i6 + 12 >> 2] | 0, (HEAP32[i4 + (i12 + -1 << 4) + 8 >> 2] | 0) == 0) : 0) {
+ if (i12 >>> 0 > 1) {
+ i10 = 0;
+ } else {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ do {
+ i2 = (i10 + i12 | 0) >>> 1;
+ i3 = (HEAP32[i4 + (i2 + -1 << 4) + 8 >> 2] | 0) == 0;
+ i12 = i3 ? i2 : i12;
+ i10 = i3 ? i10 : i2;
+ } while ((i12 - i10 | 0) >>> 0 > 1);
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ i4 = i6 + 16 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == 8016) {
+ i13 = i12;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ i5 = i6 + 12 | 0;
+ i6 = i6 + 7 | 0;
+ i9 = i2 + 4 | 0;
+ i8 = i12 + 1 | 0;
+ i13 = i12;
+ i10 = i12;
+ while (1) {
+ i12 = i8 + -1 | 0;
+ L15 : do {
+ if (i12 >>> 0 < i13 >>> 0) {
+ i12 = (HEAP32[i5 >> 2] | 0) + (i12 << 4) | 0;
+ } else {
+ d11 = +(i8 | 0);
+ HEAPF64[i2 >> 3] = d11 + 1.0;
+ i13 = (HEAP32[i9 >> 2] | 0) + (HEAP32[i2 >> 2] | 0) | 0;
+ if ((i13 | 0) < 0) {
+ i12 = 0 - i13 | 0;
+ i13 = (i13 | 0) == (i12 | 0) ? 0 : i12;
+ }
+ i12 = (HEAP32[i4 >> 2] | 0) + (((i13 | 0) % ((1 << (HEAPU8[i6] | 0)) + -1 | 1 | 0) | 0) << 5) | 0;
+ while (1) {
+ if ((HEAP32[i12 + 24 >> 2] | 0) == 3 ? +HEAPF64[i12 + 16 >> 3] == d11 : 0) {
+ break;
+ }
+ i12 = HEAP32[i12 + 28 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i12 = 5192;
+ break L15;
+ }
+ }
+ }
+ } while (0);
+ if ((HEAP32[i12 + 8 >> 2] | 0) == 0) {
+ break;
+ }
+ i10 = i8 << 1;
+ if (i10 >>> 0 > 2147483645) {
+ i7 = 21;
+ break;
+ }
+ i12 = i8;
+ i8 = i10;
+ i13 = HEAP32[i3 >> 2] | 0;
+ i10 = i12;
+ }
+ if ((i7 | 0) == 21) {
+ i8 = i2 + 4 | 0;
+ i7 = 1;
+ while (1) {
+ i10 = i7 + -1 | 0;
+ L34 : do {
+ if (i10 >>> 0 < (HEAP32[i3 >> 2] | 0) >>> 0) {
+ i9 = (HEAP32[i5 >> 2] | 0) + (i10 << 4) | 0;
+ } else {
+ d11 = +(i7 | 0);
+ HEAPF64[i2 >> 3] = d11 + 1.0;
+ i9 = (HEAP32[i8 >> 2] | 0) + (HEAP32[i2 >> 2] | 0) | 0;
+ if ((i9 | 0) < 0) {
+ i12 = 0 - i9 | 0;
+ i9 = (i9 | 0) == (i12 | 0) ? 0 : i12;
+ }
+ i9 = (HEAP32[i4 >> 2] | 0) + (((i9 | 0) % ((1 << (HEAPU8[i6] | 0)) + -1 | 1 | 0) | 0) << 5) | 0;
+ while (1) {
+ if ((HEAP32[i9 + 24 >> 2] | 0) == 3 ? +HEAPF64[i9 + 16 >> 3] == d11 : 0) {
+ break;
+ }
+ i9 = HEAP32[i9 + 28 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ i9 = 5192;
+ break L34;
+ }
+ }
+ }
+ } while (0);
+ if ((HEAP32[i9 + 8 >> 2] | 0) == 0) {
+ break;
+ }
+ i7 = i7 + 1 | 0;
+ }
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ if (!((i8 - i10 | 0) >>> 0 > 1)) {
+ i13 = i10;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ i7 = i2 + 4 | 0;
+ do {
+ i9 = (i8 + i10 | 0) >>> 1;
+ i12 = i9 + -1 | 0;
+ L55 : do {
+ if (i12 >>> 0 < (HEAP32[i3 >> 2] | 0) >>> 0) {
+ i12 = (HEAP32[i5 >> 2] | 0) + (i12 << 4) | 0;
+ } else {
+ d11 = +(i9 | 0);
+ HEAPF64[i2 >> 3] = d11 + 1.0;
+ i13 = (HEAP32[i7 >> 2] | 0) + (HEAP32[i2 >> 2] | 0) | 0;
+ if ((i13 | 0) < 0) {
+ i12 = 0 - i13 | 0;
+ i13 = (i13 | 0) == (i12 | 0) ? 0 : i12;
+ }
+ i12 = (HEAP32[i4 >> 2] | 0) + (((i13 | 0) % ((1 << (HEAPU8[i6] | 0)) + -1 | 1 | 0) | 0) << 5) | 0;
+ while (1) {
+ if ((HEAP32[i12 + 24 >> 2] | 0) == 3 ? +HEAPF64[i12 + 16 >> 3] == d11 : 0) {
+ break;
+ }
+ i12 = HEAP32[i12 + 28 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i12 = 5192;
+ break L55;
+ }
+ }
+ }
+ } while (0);
+ i12 = (HEAP32[i12 + 8 >> 2] | 0) == 0;
+ i8 = i12 ? i9 : i8;
+ i10 = i12 ? i10 : i9;
+ } while ((i8 - i10 | 0) >>> 0 > 1);
+ STACKTOP = i1;
+ return i10 | 0;
+}
+function _lua_resume(i4, i3, i7) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0;
+ i1 = STACKTOP;
+ if ((i3 | 0) == 0) {
+ i5 = 1;
+ } else {
+ i5 = (HEAPU16[i3 + 38 >> 1] | 0) + 1 & 65535;
+ }
+ i3 = i4 + 38 | 0;
+ HEAP16[i3 >> 1] = i5;
+ i5 = i4 + 36 | 0;
+ HEAP16[i5 >> 1] = 0;
+ i6 = i4 + 8 | 0;
+ i13 = _luaD_rawrunprotected(i4, 4, (HEAP32[i6 >> 2] | 0) + (0 - i7 << 4) | 0) | 0;
+ if ((i13 | 0) == -1) {
+ i18 = 2;
+ HEAP16[i5 >> 1] = 1;
+ i17 = HEAP16[i3 >> 1] | 0;
+ i17 = i17 + -1 << 16 >> 16;
+ HEAP16[i3 >> 1] = i17;
+ STACKTOP = i1;
+ return i18 | 0;
+ }
+ if (!(i13 >>> 0 > 1)) {
+ i18 = i13;
+ HEAP16[i5 >> 1] = 1;
+ i17 = HEAP16[i3 >> 1] | 0;
+ i17 = i17 + -1 << 16 >> 16;
+ HEAP16[i3 >> 1] = i17;
+ STACKTOP = i1;
+ return i18 | 0;
+ }
+ i7 = i4 + 16 | 0;
+ i12 = i4 + 28 | 0;
+ i11 = i4 + 41 | 0;
+ i10 = i4 + 68 | 0;
+ i9 = i4 + 32 | 0;
+ i8 = i4 + 12 | 0;
+ L10 : while (1) {
+ i15 = HEAP32[i7 >> 2] | 0;
+ if ((i15 | 0) == 0) {
+ break;
+ }
+ while (1) {
+ i14 = i15 + 18 | 0;
+ if (!((HEAP8[i14] & 16) == 0)) {
+ break;
+ }
+ i15 = HEAP32[i15 + 8 >> 2] | 0;
+ if ((i15 | 0) == 0) {
+ break L10;
+ }
+ }
+ i16 = HEAP32[i12 >> 2] | 0;
+ i17 = HEAP32[i15 + 20 >> 2] | 0;
+ i18 = i16 + i17 | 0;
+ _luaF_close(i4, i18);
+ if ((i13 | 0) == 4) {
+ i19 = HEAP32[(HEAP32[i8 >> 2] | 0) + 180 >> 2] | 0;
+ HEAP32[i18 >> 2] = i19;
+ HEAP32[i16 + (i17 + 8) >> 2] = HEAPU8[i19 + 4 | 0] | 0 | 64;
+ } else if ((i13 | 0) == 6) {
+ i19 = _luaS_newlstr(i4, 2424, 23) | 0;
+ HEAP32[i18 >> 2] = i19;
+ HEAP32[i16 + (i17 + 8) >> 2] = HEAPU8[i19 + 4 | 0] | 0 | 64;
+ } else {
+ i19 = HEAP32[i6 >> 2] | 0;
+ i21 = i19 + -16 | 0;
+ i20 = HEAP32[i21 + 4 >> 2] | 0;
+ HEAP32[i18 >> 2] = HEAP32[i21 >> 2];
+ HEAP32[i18 + 4 >> 2] = i20;
+ HEAP32[i16 + (i17 + 8) >> 2] = HEAP32[i19 + -8 >> 2];
+ }
+ i17 = i16 + (i17 + 16) | 0;
+ HEAP32[i6 >> 2] = i17;
+ HEAP32[i7 >> 2] = i15;
+ HEAP8[i11] = HEAP8[i15 + 36 | 0] | 0;
+ HEAP16[i5 >> 1] = 0;
+ if ((i15 | 0) != 0) {
+ i16 = i15;
+ do {
+ i18 = HEAP32[i16 + 4 >> 2] | 0;
+ i17 = i17 >>> 0 < i18 >>> 0 ? i18 : i17;
+ i16 = HEAP32[i16 + 8 >> 2] | 0;
+ } while ((i16 | 0) != 0);
+ }
+ i16 = i17 - (HEAP32[i12 >> 2] | 0) | 0;
+ i17 = (i16 >> 4) + 1 | 0;
+ i17 = ((i17 | 0) / 8 | 0) + 10 + i17 | 0;
+ i17 = (i17 | 0) > 1e6 ? 1e6 : i17;
+ if ((i16 | 0) <= 15999984 ? (i17 | 0) < (HEAP32[i9 >> 2] | 0) : 0) {
+ _luaD_reallocstack(i4, i17);
+ }
+ HEAP32[i10 >> 2] = HEAP32[i15 + 32 >> 2];
+ HEAP8[i14] = HEAPU8[i14] | 0 | 32;
+ HEAP8[i15 + 37 | 0] = i13;
+ i13 = _luaD_rawrunprotected(i4, 5, 0) | 0;
+ if (!(i13 >>> 0 > 1)) {
+ i2 = 24;
+ break;
+ }
+ }
+ if ((i2 | 0) == 24) {
+ HEAP16[i5 >> 1] = 1;
+ i21 = HEAP16[i3 >> 1] | 0;
+ i21 = i21 + -1 << 16 >> 16;
+ HEAP16[i3 >> 1] = i21;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ HEAP8[i4 + 6 | 0] = i13;
+ i2 = HEAP32[i6 >> 2] | 0;
+ if ((i13 | 0) == 4) {
+ i21 = HEAP32[(HEAP32[i8 >> 2] | 0) + 180 >> 2] | 0;
+ HEAP32[i2 >> 2] = i21;
+ HEAP32[i2 + 8 >> 2] = HEAPU8[i21 + 4 | 0] | 0 | 64;
+ } else if ((i13 | 0) == 6) {
+ i21 = _luaS_newlstr(i4, 2424, 23) | 0;
+ HEAP32[i2 >> 2] = i21;
+ HEAP32[i2 + 8 >> 2] = HEAPU8[i21 + 4 | 0] | 0 | 64;
+ } else {
+ i19 = i2 + -16 | 0;
+ i20 = HEAP32[i19 + 4 >> 2] | 0;
+ i21 = i2;
+ HEAP32[i21 >> 2] = HEAP32[i19 >> 2];
+ HEAP32[i21 + 4 >> 2] = i20;
+ HEAP32[i2 + 8 >> 2] = HEAP32[i2 + -8 >> 2];
+ }
+ i21 = i2 + 16 | 0;
+ HEAP32[i6 >> 2] = i21;
+ HEAP32[(HEAP32[i7 >> 2] | 0) + 4 >> 2] = i21;
+ i21 = i13;
+ HEAP16[i5 >> 1] = 1;
+ i20 = HEAP16[i3 >> 1] | 0;
+ i20 = i20 + -1 << 16 >> 16;
+ HEAP16[i3 >> 1] = i20;
+ STACKTOP = i1;
+ return i21 | 0;
+}
+function _luaK_goiftrue(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0;
+ i2 = STACKTOP;
+ _luaK_dischargevars(i1, i3);
+ i12 = HEAP32[i3 >> 2] | 0;
+ do {
+ if ((i12 | 0) == 10) {
+ i9 = HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0;
+ i5 = i3 + 8 | 0;
+ i8 = HEAP32[i5 >> 2] | 0;
+ i7 = i9 + (i8 << 2) | 0;
+ if (!((i8 | 0) > 0 ? (i10 = i9 + (i8 + -1 << 2) | 0, i6 = HEAP32[i10 >> 2] | 0, (HEAP8[5584 + (i6 & 63) | 0] | 0) < 0) : 0)) {
+ i10 = i7;
+ i6 = HEAP32[i7 >> 2] | 0;
+ }
+ HEAP32[i10 >> 2] = ((i6 & 16320 | 0) == 0) << 6 | i6 & -16321;
+ i5 = HEAP32[i5 >> 2] | 0;
+ i8 = 18;
+ } else if (!((i12 | 0) == 2 | (i12 | 0) == 5 | (i12 | 0) == 4)) {
+ i5 = i3 + 8 | 0;
+ if ((i12 | 0) == 6) {
+ i8 = 14;
+ } else if ((i12 | 0) == 11 ? (i11 = HEAP32[(HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0) + (HEAP32[i5 >> 2] << 2) >> 2] | 0, (i11 & 63 | 0) == 20) : 0) {
+ i5 = i1 + 20 | 0;
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + -1;
+ i5 = _condjump(i1, 27, i11 >>> 23, 0, 1) | 0;
+ i8 = 18;
+ break;
+ } else {
+ i8 = 9;
+ }
+ if ((i8 | 0) == 9) {
+ i12 = i1 + 48 | 0;
+ i10 = HEAP8[i12] | 0;
+ i11 = (i10 & 255) + 1 | 0;
+ i6 = (HEAP32[i1 >> 2] | 0) + 78 | 0;
+ do {
+ if (i11 >>> 0 > (HEAPU8[i6] | 0) >>> 0) {
+ if (i11 >>> 0 > 249) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10536);
+ } else {
+ HEAP8[i6] = i11;
+ i9 = HEAP8[i12] | 0;
+ break;
+ }
+ } else {
+ i9 = i10;
+ }
+ } while (0);
+ i11 = (i9 & 255) + 1 | 0;
+ HEAP8[i12] = i11;
+ _discharge2reg(i1, i3, (i11 & 255) + -1 | 0);
+ if ((HEAP32[i3 >> 2] | 0) == 6) {
+ i8 = 14;
+ }
+ }
+ if (((i8 | 0) == 14 ? (i7 = HEAP32[i5 >> 2] | 0, (i7 & 256 | 0) == 0) : 0) ? (HEAPU8[i1 + 46 | 0] | 0) <= (i7 | 0) : 0) {
+ i12 = i1 + 48 | 0;
+ HEAP8[i12] = (HEAP8[i12] | 0) + -1 << 24 >> 24;
+ }
+ i5 = _condjump(i1, 28, 255, HEAP32[i5 >> 2] | 0, 0) | 0;
+ i8 = 18;
+ }
+ } while (0);
+ do {
+ if ((i8 | 0) == 18 ? (i4 = i3 + 20 | 0, !((i5 | 0) == -1)) : 0) {
+ i8 = HEAP32[i4 >> 2] | 0;
+ if ((i8 | 0) == -1) {
+ HEAP32[i4 >> 2] = i5;
+ break;
+ }
+ i4 = HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i7 = i4 + (i8 << 2) | 0;
+ i6 = HEAP32[i7 >> 2] | 0;
+ i9 = (i6 >>> 14) + -131071 | 0;
+ if ((i9 | 0) == -1) {
+ break;
+ }
+ i9 = i8 + 1 + i9 | 0;
+ if ((i9 | 0) == -1) {
+ break;
+ } else {
+ i8 = i9;
+ }
+ }
+ i4 = i5 + ~i8 | 0;
+ if ((((i4 | 0) > -1 ? i4 : 0 - i4 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10624);
+ } else {
+ HEAP32[i7 >> 2] = (i4 << 14) + 2147467264 | i6 & 16383;
+ break;
+ }
+ }
+ } while (0);
+ i3 = i3 + 16 | 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i1 + 24 >> 2] = HEAP32[i1 + 20 >> 2];
+ i5 = i1 + 28 | 0;
+ if ((i4 | 0) == -1) {
+ HEAP32[i3 >> 2] = -1;
+ STACKTOP = i2;
+ return;
+ }
+ i8 = HEAP32[i5 >> 2] | 0;
+ if ((i8 | 0) == -1) {
+ HEAP32[i5 >> 2] = i4;
+ HEAP32[i3 >> 2] = -1;
+ STACKTOP = i2;
+ return;
+ }
+ i7 = HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i5 = i7 + (i8 << 2) | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ i9 = (i6 >>> 14) + -131071 | 0;
+ if ((i9 | 0) == -1) {
+ break;
+ }
+ i9 = i8 + 1 + i9 | 0;
+ if ((i9 | 0) == -1) {
+ break;
+ } else {
+ i8 = i9;
+ }
+ }
+ i4 = i4 + ~i8 | 0;
+ if ((((i4 | 0) > -1 ? i4 : 0 - i4 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10624);
+ }
+ HEAP32[i5 >> 2] = (i4 << 14) + 2147467264 | i6 & 16383;
+ HEAP32[i3 >> 2] = -1;
+ STACKTOP = i2;
+ return;
+}
+function _luaO_str2d(i1, i3, i5) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, d9 = 0.0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ if ((_strpbrk(i1, 5464) | 0) != 0) {
+ i13 = 0;
+ STACKTOP = i2;
+ return i13 | 0;
+ }
+ do {
+ if ((_strpbrk(i1, 5472) | 0) == 0) {
+ d9 = +_strtod(i1, i4);
+ i10 = HEAP32[i4 >> 2] | 0;
+ } else {
+ HEAP32[i4 >> 2] = i1;
+ i8 = i1;
+ while (1) {
+ i6 = HEAP8[i8] | 0;
+ i10 = i8 + 1 | 0;
+ if ((HEAP8[(i6 & 255) + 10913 | 0] & 8) == 0) {
+ break;
+ } else {
+ i8 = i10;
+ }
+ }
+ if (i6 << 24 >> 24 == 43) {
+ i6 = 0;
+ i8 = i10;
+ } else if (i6 << 24 >> 24 == 45) {
+ i6 = 1;
+ i8 = i10;
+ } else {
+ i6 = 0;
+ }
+ if ((HEAP8[i8] | 0) == 48 ? (i13 = HEAP8[i8 + 1 | 0] | 0, i13 << 24 >> 24 == 88 | i13 << 24 >> 24 == 120) : 0) {
+ i10 = i8 + 2 | 0;
+ i8 = HEAP8[i10] | 0;
+ i12 = i8 & 255;
+ i11 = HEAP8[i12 + 10913 | 0] | 0;
+ if ((i11 & 16) == 0) {
+ d9 = 0.0;
+ i11 = i8;
+ i8 = 0;
+ } else {
+ d9 = 0.0;
+ i8 = 0;
+ while (1) {
+ if ((i11 & 2) == 0) {
+ i11 = (i12 | 32) + -87 | 0;
+ } else {
+ i11 = i12 + -48 | 0;
+ }
+ d9 = d9 * 16.0 + +(i11 | 0);
+ i8 = i8 + 1 | 0;
+ i10 = i10 + 1 | 0;
+ i13 = HEAP8[i10] | 0;
+ i12 = i13 & 255;
+ i11 = HEAP8[i12 + 10913 | 0] | 0;
+ if ((i11 & 16) == 0) {
+ i11 = i13;
+ break;
+ }
+ }
+ }
+ if (i11 << 24 >> 24 == 46) {
+ i10 = i10 + 1 | 0;
+ i13 = HEAPU8[i10] | 0;
+ i11 = HEAP8[i13 + 10913 | 0] | 0;
+ if ((i11 & 16) == 0) {
+ i12 = 0;
+ } else {
+ i12 = 0;
+ do {
+ if ((i11 & 2) == 0) {
+ i11 = (i13 | 32) + -87 | 0;
+ } else {
+ i11 = i13 + -48 | 0;
+ }
+ d9 = d9 * 16.0 + +(i11 | 0);
+ i12 = i12 + 1 | 0;
+ i10 = i10 + 1 | 0;
+ i13 = HEAPU8[i10] | 0;
+ i11 = HEAP8[i13 + 10913 | 0] | 0;
+ } while (!((i11 & 16) == 0));
+ }
+ } else {
+ i12 = 0;
+ }
+ if ((i12 | i8 | 0) != 0) {
+ i8 = Math_imul(i12, -4) | 0;
+ HEAP32[i4 >> 2] = i10;
+ i13 = HEAP8[i10] | 0;
+ if (i13 << 24 >> 24 == 80 | i13 << 24 >> 24 == 112) {
+ i13 = i10 + 1 | 0;
+ i11 = HEAP8[i13] | 0;
+ if (i11 << 24 >> 24 == 45) {
+ i11 = 1;
+ i13 = i10 + 2 | 0;
+ } else if (i11 << 24 >> 24 == 43) {
+ i11 = 0;
+ i13 = i10 + 2 | 0;
+ } else {
+ i11 = 0;
+ }
+ i12 = HEAP8[i13] | 0;
+ if (!((HEAP8[(i12 & 255) + 10913 | 0] & 2) == 0)) {
+ i10 = i13;
+ i7 = 0;
+ do {
+ i10 = i10 + 1 | 0;
+ i7 = (i12 << 24 >> 24) + -48 + (i7 * 10 | 0) | 0;
+ i12 = HEAP8[i10] | 0;
+ } while (!((HEAP8[(i12 & 255) + 10913 | 0] & 2) == 0));
+ i8 = ((i11 | 0) == 0 ? i7 : 0 - i7 | 0) + i8 | 0;
+ i7 = 29;
+ }
+ } else {
+ i7 = 29;
+ }
+ if ((i7 | 0) == 29) {
+ HEAP32[i4 >> 2] = i10;
+ }
+ if ((i6 | 0) != 0) {
+ d9 = -d9;
+ }
+ d9 = +_ldexp(d9, i8);
+ break;
+ }
+ }
+ HEAPF64[i5 >> 3] = 0.0;
+ i13 = 0;
+ STACKTOP = i2;
+ return i13 | 0;
+ }
+ } while (0);
+ HEAPF64[i5 >> 3] = d9;
+ if ((i10 | 0) == (i1 | 0)) {
+ i13 = 0;
+ STACKTOP = i2;
+ return i13 | 0;
+ }
+ if (!((HEAP8[(HEAPU8[i10] | 0) + 10913 | 0] & 8) == 0)) {
+ do {
+ i10 = i10 + 1 | 0;
+ } while (!((HEAP8[(HEAPU8[i10] | 0) + 10913 | 0] & 8) == 0));
+ HEAP32[i4 >> 2] = i10;
+ }
+ i13 = (i10 | 0) == (i1 + i3 | 0) | 0;
+ STACKTOP = i2;
+ return i13 | 0;
+}
+function _luaV_equalobj_(i2, i4, i5) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i1 = STACKTOP;
+ i3 = i4 + 8 | 0;
+ L1 : do {
+ switch (HEAP32[i3 >> 2] & 63 | 0) {
+ case 7:
+ {
+ i6 = HEAP32[i4 >> 2] | 0;
+ i7 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) == (i7 | 0)) {
+ i7 = 1;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ if ((i2 | 0) == 0) {
+ i7 = 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ } else {
+ i6 = _get_equalTM(i2, HEAP32[i6 + 8 >> 2] | 0, HEAP32[i7 + 8 >> 2] | 0) | 0;
+ break L1;
+ }
+ }
+ case 5:
+ {
+ i7 = HEAP32[i4 >> 2] | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ if ((i7 | 0) == (i6 | 0)) {
+ i7 = 1;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ if ((i2 | 0) == 0) {
+ i7 = 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ } else {
+ i6 = _get_equalTM(i2, HEAP32[i7 + 8 >> 2] | 0, HEAP32[i6 + 8 >> 2] | 0) | 0;
+ break L1;
+ }
+ }
+ case 4:
+ {
+ i7 = (HEAP32[i4 >> 2] | 0) == (HEAP32[i5 >> 2] | 0) | 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ case 20:
+ {
+ i7 = _luaS_eqlngstr(HEAP32[i4 >> 2] | 0, HEAP32[i5 >> 2] | 0) | 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ case 3:
+ {
+ i7 = +HEAPF64[i4 >> 3] == +HEAPF64[i5 >> 3] | 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ case 1:
+ {
+ i7 = (HEAP32[i4 >> 2] | 0) == (HEAP32[i5 >> 2] | 0) | 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ case 22:
+ {
+ i7 = (HEAP32[i4 >> 2] | 0) == (HEAP32[i5 >> 2] | 0) | 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ case 2:
+ {
+ i7 = (HEAP32[i4 >> 2] | 0) == (HEAP32[i5 >> 2] | 0) | 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ case 0:
+ {
+ i7 = 1;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ default:
+ {
+ i7 = (HEAP32[i4 >> 2] | 0) == (HEAP32[i5 >> 2] | 0) | 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ }
+ } while (0);
+ if ((i6 | 0) == 0) {
+ i7 = 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ i7 = i2 + 8 | 0;
+ i10 = HEAP32[i7 >> 2] | 0;
+ i9 = i2 + 28 | 0;
+ i8 = i10 - (HEAP32[i9 >> 2] | 0) | 0;
+ HEAP32[i7 >> 2] = i10 + 16;
+ i13 = i6;
+ i12 = HEAP32[i13 + 4 >> 2] | 0;
+ i11 = i10;
+ HEAP32[i11 >> 2] = HEAP32[i13 >> 2];
+ HEAP32[i11 + 4 >> 2] = i12;
+ HEAP32[i10 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ i10 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i10 + 16;
+ i11 = i4;
+ i4 = HEAP32[i11 + 4 >> 2] | 0;
+ i6 = i10;
+ HEAP32[i6 >> 2] = HEAP32[i11 >> 2];
+ HEAP32[i6 + 4 >> 2] = i4;
+ HEAP32[i10 + 8 >> 2] = HEAP32[i3 >> 2];
+ i3 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i3 + 16;
+ i10 = i5;
+ i6 = HEAP32[i10 + 4 >> 2] | 0;
+ i4 = i3;
+ HEAP32[i4 >> 2] = HEAP32[i10 >> 2];
+ HEAP32[i4 + 4 >> 2] = i6;
+ HEAP32[i3 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ _luaD_call(i2, (HEAP32[i7 >> 2] | 0) + -48 | 0, 1, HEAP8[(HEAP32[i2 + 16 >> 2] | 0) + 18 | 0] & 1);
+ i2 = HEAP32[i9 >> 2] | 0;
+ i3 = HEAP32[i7 >> 2] | 0;
+ i4 = i3 + -16 | 0;
+ HEAP32[i7 >> 2] = i4;
+ i5 = HEAP32[i4 + 4 >> 2] | 0;
+ i6 = i2 + i8 | 0;
+ HEAP32[i6 >> 2] = HEAP32[i4 >> 2];
+ HEAP32[i6 + 4 >> 2] = i5;
+ HEAP32[i2 + (i8 + 8) >> 2] = HEAP32[i3 + -8 >> 2];
+ i2 = HEAP32[i7 >> 2] | 0;
+ i3 = HEAP32[i2 + 8 >> 2] | 0;
+ if ((i3 | 0) != 0) {
+ if ((i3 | 0) == 1) {
+ i2 = (HEAP32[i2 >> 2] | 0) != 0;
+ } else {
+ i2 = 1;
+ }
+ } else {
+ i2 = 0;
+ }
+ i13 = i2 & 1;
+ STACKTOP = i1;
+ return i13 | 0;
+}
+function _forbody(i1, i5, i6, i4, i9) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ i4 = i4 | 0;
+ i9 = i9 | 0;
+ var i2 = 0, i3 = 0, i7 = 0, i8 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i8 = i3 + 12 | 0;
+ i19 = i3;
+ i11 = i1 + 48 | 0;
+ i7 = HEAP32[i11 >> 2] | 0;
+ i18 = i7 + 46 | 0;
+ i22 = (HEAPU8[i18] | 0) + 3 | 0;
+ HEAP8[i18] = i22;
+ i21 = i7 + 20 | 0;
+ i17 = i7 + 12 | 0;
+ i2 = i7 + 40 | 0;
+ i20 = HEAP32[(HEAP32[i7 >> 2] | 0) + 24 >> 2] | 0;
+ i10 = HEAP32[HEAP32[(HEAP32[i17 >> 2] | 0) + 64 >> 2] >> 2] | 0;
+ HEAP32[i20 + ((HEAP16[i10 + ((i22 & 255) + -3 + (HEAP32[i2 >> 2] | 0) << 1) >> 1] | 0) * 12 | 0) + 4 >> 2] = HEAP32[i21 >> 2];
+ HEAP32[i20 + ((HEAP16[i10 + ((HEAPU8[i18] | 0) + -2 + (HEAP32[i2 >> 2] | 0) << 1) >> 1] | 0) * 12 | 0) + 4 >> 2] = HEAP32[i21 >> 2];
+ HEAP32[i20 + ((HEAP16[i10 + ((HEAPU8[i18] | 0) + -1 + (HEAP32[i2 >> 2] | 0) << 1) >> 1] | 0) * 12 | 0) + 4 >> 2] = HEAP32[i21 >> 2];
+ i2 = i1 + 16 | 0;
+ if ((HEAP32[i2 >> 2] | 0) != 259) {
+ _error_expected(i1, 259);
+ }
+ _luaX_next(i1);
+ i10 = (i9 | 0) != 0;
+ if (i10) {
+ i9 = _luaK_codeABx(i7, 33, i5, 131070) | 0;
+ } else {
+ i9 = _luaK_jump(i7) | 0;
+ }
+ HEAP8[i19 + 10 | 0] = 0;
+ HEAP8[i19 + 8 | 0] = HEAP8[i18] | 0;
+ i17 = HEAP32[(HEAP32[i17 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i19 + 4 >> 1] = HEAP32[i17 + 28 >> 2];
+ HEAP16[i19 + 6 >> 1] = HEAP32[i17 + 16 >> 2];
+ HEAP8[i19 + 9 | 0] = 0;
+ i17 = i7 + 16 | 0;
+ HEAP32[i19 >> 2] = HEAP32[i17 >> 2];
+ HEAP32[i17 >> 2] = i19;
+ i19 = HEAP32[i11 >> 2] | 0;
+ i17 = i19 + 46 | 0;
+ i18 = (HEAPU8[i17] | 0) + i4 | 0;
+ HEAP8[i17] = i18;
+ if ((i4 | 0) != 0 ? (i13 = i19 + 20 | 0, i12 = i19 + 40 | 0, i14 = HEAP32[(HEAP32[i19 >> 2] | 0) + 24 >> 2] | 0, i15 = HEAP32[HEAP32[(HEAP32[i19 + 12 >> 2] | 0) + 64 >> 2] >> 2] | 0, HEAP32[i14 + ((HEAP16[i15 + ((i18 & 255) - i4 + (HEAP32[i12 >> 2] | 0) << 1) >> 1] | 0) * 12 | 0) + 4 >> 2] = HEAP32[i13 >> 2], i16 = i4 + -1 | 0, (i16 | 0) != 0) : 0) {
+ do {
+ HEAP32[i14 + ((HEAP16[i15 + ((HEAPU8[i17] | 0) - i16 + (HEAP32[i12 >> 2] | 0) << 1) >> 1] | 0) * 12 | 0) + 4 >> 2] = HEAP32[i13 >> 2];
+ i16 = i16 + -1 | 0;
+ } while ((i16 | 0) != 0);
+ }
+ _luaK_reserveregs(i7, i4);
+ i11 = HEAP32[i11 >> 2] | 0;
+ HEAP8[i8 + 10 | 0] = 0;
+ HEAP8[i8 + 8 | 0] = HEAP8[i11 + 46 | 0] | 0;
+ i22 = HEAP32[(HEAP32[i11 + 12 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i8 + 4 >> 1] = HEAP32[i22 + 28 >> 2];
+ HEAP16[i8 + 6 >> 1] = HEAP32[i22 + 16 >> 2];
+ HEAP8[i8 + 9 | 0] = 0;
+ i22 = i11 + 16 | 0;
+ HEAP32[i8 >> 2] = HEAP32[i22 >> 2];
+ HEAP32[i22 >> 2] = i8;
+ L13 : do {
+ i8 = HEAP32[i2 >> 2] | 0;
+ switch (i8 | 0) {
+ case 277:
+ case 286:
+ case 262:
+ case 261:
+ case 260:
+ {
+ break L13;
+ }
+ default:
+ {}
+ }
+ _statement(i1);
+ } while ((i8 | 0) != 274);
+ _leaveblock(i11);
+ _leaveblock(i7);
+ _luaK_patchtohere(i7, i9);
+ if (i10) {
+ i21 = _luaK_codeABx(i7, 32, i5, 131070) | 0;
+ i22 = i9 + 1 | 0;
+ _luaK_patchlist(i7, i21, i22);
+ _luaK_fixline(i7, i6);
+ STACKTOP = i3;
+ return;
+ } else {
+ _luaK_codeABC(i7, 34, i5, 0, i4) | 0;
+ _luaK_fixline(i7, i6);
+ i21 = _luaK_codeABx(i7, 35, i5 + 2 | 0, 131070) | 0;
+ i22 = i9 + 1 | 0;
+ _luaK_patchlist(i7, i21, i22);
+ _luaK_fixline(i7, i6);
+ STACKTOP = i3;
+ return;
+ }
+}
+function _dotty(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i6 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i6;
+ i4 = i6 + 4 | 0;
+ i2 = HEAP32[20] | 0;
+ HEAP32[20] = 0;
+ _lua_settop(i1, 0);
+ if ((_pushline(i1, 1) | 0) == 0) {
+ _lua_settop(i1, 0);
+ i10 = HEAP32[_stdout >> 2] | 0;
+ _fputc(10, i10 | 0) | 0;
+ _fflush(i10 | 0) | 0;
+ HEAP32[20] = i2;
+ STACKTOP = i6;
+ return;
+ }
+ i5 = HEAP32[_stderr >> 2] | 0;
+ L4 : while (1) {
+ i8 = _lua_tolstring(i1, 1, i4) | 0;
+ i8 = _luaL_loadbufferx(i1, i8, HEAP32[i4 >> 2] | 0, 256, 0) | 0;
+ L6 : do {
+ if ((i8 | 0) == 3) {
+ while (1) {
+ i8 = _lua_tolstring(i1, -1, i3) | 0;
+ i7 = HEAP32[i3 >> 2] | 0;
+ if (!(i7 >>> 0 > 4)) {
+ break;
+ }
+ if ((_strcmp(i8 + (i7 + -5) | 0, 264) | 0) != 0) {
+ break;
+ }
+ _lua_settop(i1, -2);
+ if ((_pushline(i1, 0) | 0) == 0) {
+ i7 = 23;
+ break L4;
+ }
+ _lua_pushlstring(i1, 184, 1) | 0;
+ _lua_insert(i1, -2);
+ _lua_concat(i1, 3);
+ i8 = _lua_tolstring(i1, 1, i4) | 0;
+ i8 = _luaL_loadbufferx(i1, i8, HEAP32[i4 >> 2] | 0, 256, 0) | 0;
+ if ((i8 | 0) != 3) {
+ i7 = 9;
+ break L6;
+ }
+ }
+ _lua_remove(i1, 1);
+ i8 = 3;
+ i7 = 10;
+ } else {
+ i7 = 9;
+ }
+ } while (0);
+ do {
+ if ((i7 | 0) == 9) {
+ _lua_remove(i1, 1);
+ if ((i8 | 0) == -1) {
+ i7 = 23;
+ break L4;
+ } else if ((i8 | 0) != 0) {
+ i7 = 10;
+ break;
+ }
+ i9 = _lua_gettop(i1) | 0;
+ _lua_pushcclosure(i1, 142, 0);
+ _lua_insert(i1, i9);
+ HEAP32[48] = i1;
+ _signal(2, 1) | 0;
+ i10 = _lua_pcallk(i1, 0, -1, i9, 0, 0) | 0;
+ _signal(2, 0) | 0;
+ _lua_remove(i1, i9);
+ if ((i10 | 0) == 0) {
+ i7 = 17;
+ } else {
+ i9 = 0;
+ i7 = 12;
+ }
+ }
+ } while (0);
+ if ((i7 | 0) == 10) {
+ i9 = (i8 | 0) == 0;
+ i7 = 12;
+ }
+ do {
+ if ((i7 | 0) == 12) {
+ i7 = 0;
+ if ((_lua_type(i1, -1) | 0) == 0) {
+ if (i9) {
+ i7 = 17;
+ break;
+ } else {
+ break;
+ }
+ }
+ i10 = _lua_tolstring(i1, -1, 0) | 0;
+ i8 = HEAP32[20] | 0;
+ if ((i8 | 0) != 0) {
+ HEAP32[i3 >> 2] = i8;
+ _fprintf(i5 | 0, 496, i3 | 0) | 0;
+ _fflush(i5 | 0) | 0;
+ }
+ HEAP32[i3 >> 2] = (i10 | 0) == 0 ? 48 : i10;
+ _fprintf(i5 | 0, 912, i3 | 0) | 0;
+ _fflush(i5 | 0) | 0;
+ _lua_settop(i1, -2);
+ _lua_gc(i1, 2, 0) | 0;
+ if (i9) {
+ i7 = 17;
+ }
+ }
+ } while (0);
+ if (((i7 | 0) == 17 ? (0, (_lua_gettop(i1) | 0) > 0) : 0) ? (_luaL_checkstack(i1, 20, 112), _lua_getglobal(i1, 144), _lua_insert(i1, 1), (_lua_pcallk(i1, (_lua_gettop(i1) | 0) + -1 | 0, 0, 0, 0, 0) | 0) != 0) : 0) {
+ i7 = HEAP32[20] | 0;
+ HEAP32[i3 >> 2] = _lua_tolstring(i1, -1, 0) | 0;
+ i8 = _lua_pushfstring(i1, 152, i3) | 0;
+ if ((i7 | 0) != 0) {
+ HEAP32[i3 >> 2] = i7;
+ _fprintf(i5 | 0, 496, i3 | 0) | 0;
+ _fflush(i5 | 0) | 0;
+ }
+ HEAP32[i3 >> 2] = i8;
+ _fprintf(i5 | 0, 912, i3 | 0) | 0;
+ _fflush(i5 | 0) | 0;
+ }
+ _lua_settop(i1, 0);
+ if ((_pushline(i1, 1) | 0) == 0) {
+ i7 = 23;
+ break;
+ }
+ }
+ if ((i7 | 0) == 23) {
+ _lua_settop(i1, 0);
+ i10 = HEAP32[_stdout >> 2] | 0;
+ _fputc(10, i10 | 0) | 0;
+ _fflush(i10 | 0) | 0;
+ HEAP32[20] = i2;
+ STACKTOP = i6;
+ return;
+ }
+}
+function _test_then_block(i5, i1) {
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 48 | 0;
+ i10 = i2 + 24 | 0;
+ i9 = i2;
+ i8 = i5 + 48 | 0;
+ i4 = HEAP32[i8 >> 2] | 0;
+ _luaX_next(i5);
+ _subexpr(i5, i9, 0) | 0;
+ i3 = i5 + 16 | 0;
+ if ((HEAP32[i3 >> 2] | 0) != 275) {
+ _error_expected(i5, 275);
+ }
+ _luaX_next(i5);
+ i14 = HEAP32[i3 >> 2] | 0;
+ do {
+ if ((i14 | 0) == 258 | (i14 | 0) == 266) {
+ _luaK_goiffalse(HEAP32[i8 >> 2] | 0, i9);
+ HEAP8[i10 + 10 | 0] = 0;
+ HEAP8[i10 + 8 | 0] = HEAP8[i4 + 46 | 0] | 0;
+ i11 = HEAP32[(HEAP32[i4 + 12 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i10 + 4 >> 1] = HEAP32[i11 + 28 >> 2];
+ HEAP16[i10 + 6 >> 1] = HEAP32[i11 + 16 >> 2];
+ HEAP8[i10 + 9 | 0] = 0;
+ i11 = i4 + 16 | 0;
+ HEAP32[i10 >> 2] = HEAP32[i11 >> 2];
+ HEAP32[i11 >> 2] = i10;
+ i11 = HEAP32[i9 + 16 >> 2] | 0;
+ i10 = HEAP32[i5 + 4 >> 2] | 0;
+ i14 = (HEAP32[i3 >> 2] | 0) == 266;
+ _luaX_next(i5);
+ do {
+ if (i14) {
+ if ((HEAP32[i3 >> 2] | 0) == 288) {
+ i7 = HEAP32[i5 + 24 >> 2] | 0;
+ _luaX_next(i5);
+ break;
+ } else {
+ _error_expected(i5, 288);
+ }
+ } else {
+ i7 = _luaS_new(HEAP32[i5 + 52 >> 2] | 0, 6304) | 0;
+ }
+ } while (0);
+ i14 = HEAP32[i5 + 64 >> 2] | 0;
+ i12 = i14 + 12 | 0;
+ i13 = i14 + 16 | 0;
+ i9 = HEAP32[i13 >> 2] | 0;
+ i14 = i14 + 20 | 0;
+ if ((i9 | 0) < (HEAP32[i14 >> 2] | 0)) {
+ i14 = HEAP32[i12 >> 2] | 0;
+ } else {
+ i14 = _luaM_growaux_(HEAP32[i5 + 52 >> 2] | 0, HEAP32[i12 >> 2] | 0, i14, 16, 32767, 6312) | 0;
+ HEAP32[i12 >> 2] = i14;
+ }
+ HEAP32[i14 + (i9 << 4) >> 2] = i7;
+ i14 = HEAP32[i12 >> 2] | 0;
+ HEAP32[i14 + (i9 << 4) + 8 >> 2] = i10;
+ HEAP8[i14 + (i9 << 4) + 12 | 0] = HEAP8[(HEAP32[i8 >> 2] | 0) + 46 | 0] | 0;
+ HEAP32[(HEAP32[i12 >> 2] | 0) + (i9 << 4) + 4 >> 2] = i11;
+ HEAP32[i13 >> 2] = (HEAP32[i13 >> 2] | 0) + 1;
+ _findlabel(i5, i9) | 0;
+ L18 : while (1) {
+ switch (HEAP32[i3 >> 2] | 0) {
+ case 286:
+ case 262:
+ case 261:
+ case 260:
+ {
+ break L18;
+ }
+ case 285:
+ case 59:
+ {
+ break;
+ }
+ default:
+ {
+ i6 = 16;
+ break L18;
+ }
+ }
+ _statement(i5);
+ }
+ if ((i6 | 0) == 16) {
+ i6 = _luaK_jump(i4) | 0;
+ break;
+ }
+ _leaveblock(i4);
+ STACKTOP = i2;
+ return;
+ } else {
+ _luaK_goiftrue(HEAP32[i8 >> 2] | 0, i9);
+ HEAP8[i10 + 10 | 0] = 0;
+ HEAP8[i10 + 8 | 0] = HEAP8[i4 + 46 | 0] | 0;
+ i6 = HEAP32[(HEAP32[i4 + 12 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i10 + 4 >> 1] = HEAP32[i6 + 28 >> 2];
+ HEAP16[i10 + 6 >> 1] = HEAP32[i6 + 16 >> 2];
+ HEAP8[i10 + 9 | 0] = 0;
+ i6 = i4 + 16 | 0;
+ HEAP32[i10 >> 2] = HEAP32[i6 >> 2];
+ HEAP32[i6 >> 2] = i10;
+ i6 = HEAP32[i9 + 20 >> 2] | 0;
+ }
+ } while (0);
+ L26 : do {
+ i7 = HEAP32[i3 >> 2] | 0;
+ switch (i7 | 0) {
+ case 277:
+ case 286:
+ case 262:
+ case 261:
+ case 260:
+ {
+ break L26;
+ }
+ default:
+ {}
+ }
+ _statement(i5);
+ } while ((i7 | 0) != 274);
+ _leaveblock(i4);
+ if (((HEAP32[i3 >> 2] | 0) + -260 | 0) >>> 0 < 2) {
+ _luaK_concat(i4, i1, _luaK_jump(i4) | 0);
+ }
+ _luaK_patchtohere(i4, i6);
+ STACKTOP = i2;
+ return;
+}
+function _luaL_gsub(i2, i13, i11, i10) {
+ i2 = i2 | 0;
+ i13 = i13 | 0;
+ i11 = i11 | 0;
+ i10 = i10 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i12 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 1056 | 0;
+ i8 = i1;
+ i4 = i1 + 8 | 0;
+ i9 = _strlen(i11 | 0) | 0;
+ i6 = i4 + 12 | 0;
+ HEAP32[i6 >> 2] = i2;
+ i3 = i4 + 16 | 0;
+ HEAP32[i4 >> 2] = i3;
+ i5 = i4 + 8 | 0;
+ HEAP32[i5 >> 2] = 0;
+ i7 = i4 + 4 | 0;
+ HEAP32[i7 >> 2] = 1024;
+ i12 = _strstr(i13, i11) | 0;
+ if ((i12 | 0) == 0) {
+ i14 = 0;
+ i17 = 1024;
+ i16 = i2;
+ } else {
+ i14 = 0;
+ i17 = 1024;
+ i16 = i2;
+ do {
+ i15 = i12 - i13 | 0;
+ if ((i17 - i14 | 0) >>> 0 < i15 >>> 0) {
+ i17 = i17 << 1;
+ i17 = (i17 - i14 | 0) >>> 0 < i15 >>> 0 ? i14 + i15 | 0 : i17;
+ if (i17 >>> 0 < i14 >>> 0 | (i17 - i14 | 0) >>> 0 < i15 >>> 0) {
+ _luaL_error(i16, 1272, i8) | 0;
+ }
+ i14 = _lua_newuserdata(i16, i17) | 0;
+ _memcpy(i14 | 0, HEAP32[i4 >> 2] | 0, HEAP32[i5 >> 2] | 0) | 0;
+ if ((HEAP32[i4 >> 2] | 0) != (i3 | 0)) {
+ _lua_remove(i16, -2);
+ }
+ HEAP32[i4 >> 2] = i14;
+ HEAP32[i7 >> 2] = i17;
+ i16 = i14;
+ i14 = HEAP32[i5 >> 2] | 0;
+ } else {
+ i16 = HEAP32[i4 >> 2] | 0;
+ }
+ _memcpy(i16 + i14 | 0, i13 | 0, i15 | 0) | 0;
+ i15 = (HEAP32[i5 >> 2] | 0) + i15 | 0;
+ HEAP32[i5 >> 2] = i15;
+ i13 = _strlen(i10 | 0) | 0;
+ i14 = HEAP32[i6 >> 2] | 0;
+ i16 = HEAP32[i7 >> 2] | 0;
+ if ((i16 - i15 | 0) >>> 0 < i13 >>> 0) {
+ i16 = i16 << 1;
+ i16 = (i16 - i15 | 0) >>> 0 < i13 >>> 0 ? i15 + i13 | 0 : i16;
+ if (i16 >>> 0 < i15 >>> 0 | (i16 - i15 | 0) >>> 0 < i13 >>> 0) {
+ _luaL_error(i14, 1272, i8) | 0;
+ }
+ i15 = _lua_newuserdata(i14, i16) | 0;
+ _memcpy(i15 | 0, HEAP32[i4 >> 2] | 0, HEAP32[i5 >> 2] | 0) | 0;
+ if ((HEAP32[i4 >> 2] | 0) != (i3 | 0)) {
+ _lua_remove(i14, -2);
+ }
+ HEAP32[i4 >> 2] = i15;
+ HEAP32[i7 >> 2] = i16;
+ i14 = i15;
+ i15 = HEAP32[i5 >> 2] | 0;
+ } else {
+ i14 = HEAP32[i4 >> 2] | 0;
+ }
+ _memcpy(i14 + i15 | 0, i10 | 0, i13 | 0) | 0;
+ i14 = (HEAP32[i5 >> 2] | 0) + i13 | 0;
+ HEAP32[i5 >> 2] = i14;
+ i13 = i12 + i9 | 0;
+ i12 = _strstr(i13, i11) | 0;
+ i16 = HEAP32[i6 >> 2] | 0;
+ i17 = HEAP32[i7 >> 2] | 0;
+ } while ((i12 | 0) != 0);
+ }
+ i9 = _strlen(i13 | 0) | 0;
+ if ((i17 - i14 | 0) >>> 0 < i9 >>> 0) {
+ i10 = i17 << 1;
+ i10 = (i10 - i14 | 0) >>> 0 < i9 >>> 0 ? i14 + i9 | 0 : i10;
+ if (i10 >>> 0 < i14 >>> 0 | (i10 - i14 | 0) >>> 0 < i9 >>> 0) {
+ _luaL_error(i16, 1272, i8) | 0;
+ }
+ i8 = _lua_newuserdata(i16, i10) | 0;
+ _memcpy(i8 | 0, HEAP32[i4 >> 2] | 0, HEAP32[i5 >> 2] | 0) | 0;
+ if ((HEAP32[i4 >> 2] | 0) != (i3 | 0)) {
+ _lua_remove(i16, -2);
+ }
+ HEAP32[i4 >> 2] = i8;
+ HEAP32[i7 >> 2] = i10;
+ i14 = HEAP32[i5 >> 2] | 0;
+ } else {
+ i8 = HEAP32[i4 >> 2] | 0;
+ }
+ _memcpy(i8 + i14 | 0, i13 | 0, i9 | 0) | 0;
+ i17 = (HEAP32[i5 >> 2] | 0) + i9 | 0;
+ HEAP32[i5 >> 2] = i17;
+ i5 = HEAP32[i6 >> 2] | 0;
+ _lua_pushlstring(i5, HEAP32[i4 >> 2] | 0, i17) | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i3 | 0)) {
+ i17 = _lua_tolstring(i2, -1, 0) | 0;
+ STACKTOP = i1;
+ return i17 | 0;
+ }
+ _lua_remove(i5, -2);
+ i17 = _lua_tolstring(i2, -1, 0) | 0;
+ STACKTOP = i1;
+ return i17 | 0;
+}
+function _luaK_goiffalse(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0;
+ i2 = STACKTOP;
+ _luaK_dischargevars(i1, i3);
+ i9 = HEAP32[i3 >> 2] | 0;
+ do {
+ if ((i9 | 0) == 10) {
+ i4 = HEAP32[i3 + 8 >> 2] | 0;
+ i8 = 15;
+ } else if (!((i9 | 0) == 3 | (i9 | 0) == 1)) {
+ i4 = i3 + 8 | 0;
+ if ((i9 | 0) == 6) {
+ i8 = 11;
+ } else if ((i9 | 0) == 11 ? (i10 = HEAP32[(HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0) + (HEAP32[i4 >> 2] << 2) >> 2] | 0, (i10 & 63 | 0) == 20) : 0) {
+ i4 = i1 + 20 | 0;
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + -1;
+ i4 = _condjump(i1, 27, i10 >>> 23, 0, 0) | 0;
+ i8 = 15;
+ break;
+ } else {
+ i8 = 6;
+ }
+ if ((i8 | 0) == 6) {
+ i9 = i1 + 48 | 0;
+ i11 = HEAP8[i9] | 0;
+ i10 = (i11 & 255) + 1 | 0;
+ i12 = (HEAP32[i1 >> 2] | 0) + 78 | 0;
+ do {
+ if (i10 >>> 0 > (HEAPU8[i12] | 0) >>> 0) {
+ if (i10 >>> 0 > 249) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10536);
+ } else {
+ HEAP8[i12] = i10;
+ i7 = HEAP8[i9] | 0;
+ break;
+ }
+ } else {
+ i7 = i11;
+ }
+ } while (0);
+ i12 = (i7 & 255) + 1 | 0;
+ HEAP8[i9] = i12;
+ _discharge2reg(i1, i3, (i12 & 255) + -1 | 0);
+ if ((HEAP32[i3 >> 2] | 0) == 6) {
+ i8 = 11;
+ }
+ }
+ if (((i8 | 0) == 11 ? (i6 = HEAP32[i4 >> 2] | 0, (i6 & 256 | 0) == 0) : 0) ? (HEAPU8[i1 + 46 | 0] | 0 | 0) <= (i6 | 0) : 0) {
+ i12 = i1 + 48 | 0;
+ HEAP8[i12] = (HEAP8[i12] | 0) + -1 << 24 >> 24;
+ }
+ i4 = _condjump(i1, 28, 255, HEAP32[i4 >> 2] | 0, 1) | 0;
+ i8 = 15;
+ }
+ } while (0);
+ do {
+ if ((i8 | 0) == 15 ? (i5 = i3 + 16 | 0, !((i4 | 0) == -1)) : 0) {
+ i8 = HEAP32[i5 >> 2] | 0;
+ if ((i8 | 0) == -1) {
+ HEAP32[i5 >> 2] = i4;
+ break;
+ }
+ i5 = HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i7 = i5 + (i8 << 2) | 0;
+ i6 = HEAP32[i7 >> 2] | 0;
+ i9 = (i6 >>> 14) + -131071 | 0;
+ if ((i9 | 0) == -1) {
+ break;
+ }
+ i9 = i8 + 1 + i9 | 0;
+ if ((i9 | 0) == -1) {
+ break;
+ } else {
+ i8 = i9;
+ }
+ }
+ i4 = i4 + ~i8 | 0;
+ if ((((i4 | 0) > -1 ? i4 : 0 - i4 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10624);
+ } else {
+ HEAP32[i7 >> 2] = (i4 << 14) + 2147467264 | i6 & 16383;
+ break;
+ }
+ }
+ } while (0);
+ i3 = i3 + 20 | 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i1 + 24 >> 2] = HEAP32[i1 + 20 >> 2];
+ i5 = i1 + 28 | 0;
+ if ((i4 | 0) == -1) {
+ HEAP32[i3 >> 2] = -1;
+ STACKTOP = i2;
+ return;
+ }
+ i8 = HEAP32[i5 >> 2] | 0;
+ if ((i8 | 0) == -1) {
+ HEAP32[i5 >> 2] = i4;
+ HEAP32[i3 >> 2] = -1;
+ STACKTOP = i2;
+ return;
+ }
+ i7 = HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i5 = i7 + (i8 << 2) | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ i9 = (i6 >>> 14) + -131071 | 0;
+ if ((i9 | 0) == -1) {
+ break;
+ }
+ i9 = i8 + 1 + i9 | 0;
+ if ((i9 | 0) == -1) {
+ break;
+ } else {
+ i8 = i9;
+ }
+ }
+ i4 = i4 + ~i8 | 0;
+ if ((((i4 | 0) > -1 ? i4 : 0 - i4 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10624);
+ }
+ HEAP32[i5 >> 2] = (i4 << 14) + 2147467264 | i6 & 16383;
+ HEAP32[i3 >> 2] = -1;
+ STACKTOP = i2;
+ return;
+}
+function _luaV_settable(i2, i11, i7, i9) {
+ i2 = i2 | 0;
+ i11 = i11 | 0;
+ i7 = i7 | 0;
+ i9 = i9 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i10 = 0, i12 = 0, i13 = 0, i14 = 0;
+ i6 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i5 = i6;
+ i4 = i2 + 12 | 0;
+ i3 = i11;
+ i13 = HEAP32[i11 + 8 >> 2] | 0;
+ i12 = 0;
+ while (1) {
+ i11 = i3 + 8 | 0;
+ if ((i13 | 0) != 69) {
+ i14 = _luaT_gettmbyobj(i2, i3, 1) | 0;
+ i13 = HEAP32[i14 + 8 >> 2] | 0;
+ if ((i13 | 0) == 0) {
+ i1 = 16;
+ break;
+ }
+ } else {
+ i8 = HEAP32[i3 >> 2] | 0;
+ i13 = _luaH_get(i8, i7) | 0;
+ if ((HEAP32[i13 + 8 >> 2] | 0) != 0) {
+ i10 = i13;
+ break;
+ }
+ i14 = HEAP32[i8 + 8 >> 2] | 0;
+ if ((i14 | 0) == 0) {
+ i1 = 9;
+ break;
+ }
+ if (!((HEAP8[i14 + 6 | 0] & 2) == 0)) {
+ i1 = 9;
+ break;
+ }
+ i14 = _luaT_gettm(i14, 1, HEAP32[(HEAP32[i4 >> 2] | 0) + 188 >> 2] | 0) | 0;
+ if ((i14 | 0) == 0) {
+ i1 = 9;
+ break;
+ }
+ i13 = HEAP32[i14 + 8 >> 2] | 0;
+ }
+ i12 = i12 + 1 | 0;
+ if ((i13 & 15 | 0) == 6) {
+ i1 = 18;
+ break;
+ }
+ if ((i12 | 0) < 100) {
+ i3 = i14;
+ } else {
+ i1 = 19;
+ break;
+ }
+ }
+ if ((i1 | 0) == 9) {
+ if ((i13 | 0) == 5192) {
+ i10 = _luaH_newkey(i2, i8, i7) | 0;
+ } else {
+ i10 = i13;
+ }
+ } else if ((i1 | 0) == 16) {
+ _luaG_typeerror(i2, i3, 8944);
+ } else if ((i1 | 0) == 18) {
+ i13 = i2 + 8 | 0;
+ i8 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i8 + 16;
+ i5 = i14;
+ i12 = HEAP32[i5 + 4 >> 2] | 0;
+ i10 = i8;
+ HEAP32[i10 >> 2] = HEAP32[i5 >> 2];
+ HEAP32[i10 + 4 >> 2] = i12;
+ HEAP32[i8 + 8 >> 2] = HEAP32[i14 + 8 >> 2];
+ i14 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i14 + 16;
+ i8 = i3;
+ i10 = HEAP32[i8 + 4 >> 2] | 0;
+ i12 = i14;
+ HEAP32[i12 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i12 + 4 >> 2] = i10;
+ HEAP32[i14 + 8 >> 2] = HEAP32[i11 >> 2];
+ i14 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i14 + 16;
+ i12 = i7;
+ i11 = HEAP32[i12 + 4 >> 2] | 0;
+ i10 = i14;
+ HEAP32[i10 >> 2] = HEAP32[i12 >> 2];
+ HEAP32[i10 + 4 >> 2] = i11;
+ HEAP32[i14 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ i14 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i14 + 16;
+ i10 = i9;
+ i11 = HEAP32[i10 + 4 >> 2] | 0;
+ i12 = i14;
+ HEAP32[i12 >> 2] = HEAP32[i10 >> 2];
+ HEAP32[i12 + 4 >> 2] = i11;
+ HEAP32[i14 + 8 >> 2] = HEAP32[i9 + 8 >> 2];
+ _luaD_call(i2, (HEAP32[i13 >> 2] | 0) + -64 | 0, 0, HEAP8[(HEAP32[i2 + 16 >> 2] | 0) + 18 | 0] & 1);
+ STACKTOP = i6;
+ return;
+ } else if ((i1 | 0) == 19) {
+ _luaG_runerror(i2, 8976, i5);
+ }
+ i12 = i9;
+ i13 = HEAP32[i12 + 4 >> 2] | 0;
+ i14 = i10;
+ HEAP32[i14 >> 2] = HEAP32[i12 >> 2];
+ HEAP32[i14 + 4 >> 2] = i13;
+ i14 = i9 + 8 | 0;
+ HEAP32[i10 + 8 >> 2] = HEAP32[i14 >> 2];
+ HEAP8[i8 + 6 | 0] = 0;
+ if ((HEAP32[i14 >> 2] & 64 | 0) == 0) {
+ STACKTOP = i6;
+ return;
+ }
+ if ((HEAP8[(HEAP32[i9 >> 2] | 0) + 5 | 0] & 3) == 0) {
+ STACKTOP = i6;
+ return;
+ }
+ if ((HEAP8[i8 + 5 | 0] & 4) == 0) {
+ STACKTOP = i6;
+ return;
+ }
+ _luaC_barrierback_(i2, i8);
+ STACKTOP = i6;
+ return;
+}
+function _luaK_code(i4, i5) {
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0;
+ i2 = STACKTOP;
+ i1 = HEAP32[i4 >> 2] | 0;
+ i7 = i4 + 28 | 0;
+ i15 = HEAP32[i7 >> 2] | 0;
+ i3 = i4 + 20 | 0;
+ i8 = HEAP32[i3 >> 2] | 0;
+ do {
+ if (!((i15 | 0) == -1)) {
+ i11 = HEAP32[i1 + 12 >> 2] | 0;
+ while (1) {
+ i12 = i11 + (i15 << 2) | 0;
+ i14 = HEAP32[i12 >> 2] | 0;
+ i13 = (i14 >>> 14) + -131071 | 0;
+ if ((i13 | 0) == -1) {
+ i13 = -1;
+ } else {
+ i13 = i15 + 1 + i13 | 0;
+ }
+ if ((i15 | 0) > 0 ? (i9 = i11 + (i15 + -1 << 2) | 0, i10 = HEAP32[i9 >> 2] | 0, (HEAP8[5584 + (i10 & 63) | 0] | 0) < 0) : 0) {
+ i17 = i9;
+ i16 = i10;
+ } else {
+ i17 = i12;
+ i16 = i14;
+ }
+ if ((i16 & 63 | 0) == 28) {
+ HEAP32[i17 >> 2] = i16 & 8372224 | i16 >>> 23 << 6 | 27;
+ i14 = i8 + ~i15 | 0;
+ if ((((i14 | 0) > -1 ? i14 : 0 - i14 | 0) | 0) > 131071) {
+ i8 = 10;
+ break;
+ }
+ i14 = HEAP32[i12 >> 2] & 16383 | (i14 << 14) + 2147467264;
+ } else {
+ i15 = i8 + ~i15 | 0;
+ if ((((i15 | 0) > -1 ? i15 : 0 - i15 | 0) | 0) > 131071) {
+ i8 = 13;
+ break;
+ }
+ i14 = (i15 << 14) + 2147467264 | i14 & 16383;
+ }
+ HEAP32[i12 >> 2] = i14;
+ if ((i13 | 0) == -1) {
+ i8 = 16;
+ break;
+ } else {
+ i15 = i13;
+ }
+ }
+ if ((i8 | 0) == 10) {
+ _luaX_syntaxerror(HEAP32[i4 + 12 >> 2] | 0, 10624);
+ } else if ((i8 | 0) == 13) {
+ _luaX_syntaxerror(HEAP32[i4 + 12 >> 2] | 0, 10624);
+ } else if ((i8 | 0) == 16) {
+ i6 = HEAP32[i3 >> 2] | 0;
+ break;
+ }
+ } else {
+ i6 = i8;
+ }
+ } while (0);
+ HEAP32[i7 >> 2] = -1;
+ i7 = i1 + 48 | 0;
+ if ((i6 | 0) < (HEAP32[i7 >> 2] | 0)) {
+ i7 = i1 + 12 | 0;
+ } else {
+ i6 = i1 + 12 | 0;
+ HEAP32[i6 >> 2] = _luaM_growaux_(HEAP32[(HEAP32[i4 + 12 >> 2] | 0) + 52 >> 2] | 0, HEAP32[i6 >> 2] | 0, i7, 4, 2147483645, 10616) | 0;
+ i7 = i6;
+ i6 = HEAP32[i3 >> 2] | 0;
+ }
+ HEAP32[(HEAP32[i7 >> 2] | 0) + (i6 << 2) >> 2] = i5;
+ i5 = HEAP32[i3 >> 2] | 0;
+ i6 = i1 + 52 | 0;
+ i4 = i4 + 12 | 0;
+ if ((i5 | 0) < (HEAP32[i6 >> 2] | 0)) {
+ i15 = i1 + 20 | 0;
+ i17 = i5;
+ i16 = HEAP32[i4 >> 2] | 0;
+ i16 = i16 + 8 | 0;
+ i16 = HEAP32[i16 >> 2] | 0;
+ i15 = HEAP32[i15 >> 2] | 0;
+ i17 = i15 + (i17 << 2) | 0;
+ HEAP32[i17 >> 2] = i16;
+ i17 = HEAP32[i3 >> 2] | 0;
+ i16 = i17 + 1 | 0;
+ HEAP32[i3 >> 2] = i16;
+ STACKTOP = i2;
+ return i17 | 0;
+ } else {
+ i15 = i1 + 20 | 0;
+ HEAP32[i15 >> 2] = _luaM_growaux_(HEAP32[(HEAP32[i4 >> 2] | 0) + 52 >> 2] | 0, HEAP32[i15 >> 2] | 0, i6, 4, 2147483645, 10616) | 0;
+ i17 = HEAP32[i3 >> 2] | 0;
+ i16 = HEAP32[i4 >> 2] | 0;
+ i16 = i16 + 8 | 0;
+ i16 = HEAP32[i16 >> 2] | 0;
+ i15 = HEAP32[i15 >> 2] | 0;
+ i17 = i15 + (i17 << 2) | 0;
+ HEAP32[i17 >> 2] = i16;
+ i17 = HEAP32[i3 >> 2] | 0;
+ i16 = i17 + 1 | 0;
+ HEAP32[i3 >> 2] = i16;
+ STACKTOP = i2;
+ return i17 | 0;
+ }
+ return 0;
+}
+function _luaH_next(i9, i5, i2) {
+ i9 = i9 | 0;
+ i5 = i5 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, d14 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i8 = i1 + 8 | 0;
+ i11 = i1;
+ i3 = i2 + 8 | 0;
+ i10 = HEAP32[i3 >> 2] | 0;
+ do {
+ if ((i10 | 0) != 0) {
+ if ((((i10 | 0) == 3 ? (d14 = +HEAPF64[i2 >> 3], HEAPF64[i11 >> 3] = d14 + 6755399441055744.0, i12 = HEAP32[i11 >> 2] | 0, +(i12 | 0) == d14) : 0) ? (i12 | 0) > 0 : 0) ? (i13 = HEAP32[i5 + 28 >> 2] | 0, (i12 | 0) <= (i13 | 0)) : 0) {
+ i6 = i13;
+ i7 = i12 + -1 | 0;
+ break;
+ }
+ i10 = _mainposition(i5, i2) | 0;
+ while (1) {
+ i4 = i10 + 16 | 0;
+ i11 = i10 + 24 | 0;
+ i12 = HEAP32[i11 >> 2] | 0;
+ if ((i12 | 0) == (HEAP32[i3 >> 2] | 0)) {
+ if ((_luaV_equalobj_(0, i4, i2) | 0) != 0) {
+ i4 = 15;
+ break;
+ }
+ i12 = HEAP32[i11 >> 2] | 0;
+ }
+ if (((i12 | 0) == 11 ? (HEAP32[i3 >> 2] & 64 | 0) != 0 : 0) ? (HEAP32[i4 >> 2] | 0) == (HEAP32[i2 >> 2] | 0) : 0) {
+ i4 = 15;
+ break;
+ }
+ i10 = HEAP32[i10 + 28 >> 2] | 0;
+ if ((i10 | 0) == 0) {
+ i4 = 18;
+ break;
+ }
+ }
+ if ((i4 | 0) == 15) {
+ i7 = HEAP32[i5 + 28 >> 2] | 0;
+ i6 = i7;
+ i7 = (i10 - (HEAP32[i5 + 16 >> 2] | 0) >> 5) + i7 | 0;
+ break;
+ } else if ((i4 | 0) == 18) {
+ _luaG_runerror(i9, 8064, i8);
+ }
+ } else {
+ i6 = HEAP32[i5 + 28 >> 2] | 0;
+ i7 = -1;
+ }
+ } while (0);
+ i8 = i5 + 12 | 0;
+ while (1) {
+ i9 = i7 + 1 | 0;
+ if ((i9 | 0) >= (i6 | 0)) {
+ break;
+ }
+ i11 = HEAP32[i8 >> 2] | 0;
+ i10 = i11 + (i9 << 4) + 8 | 0;
+ if ((HEAP32[i10 >> 2] | 0) == 0) {
+ i7 = i9;
+ } else {
+ i4 = 21;
+ break;
+ }
+ }
+ if ((i4 | 0) == 21) {
+ HEAPF64[i2 >> 3] = +(i7 + 2 | 0);
+ HEAP32[i3 >> 2] = 3;
+ i11 = i11 + (i9 << 4) | 0;
+ i12 = HEAP32[i11 + 4 >> 2] | 0;
+ i13 = i2 + 16 | 0;
+ HEAP32[i13 >> 2] = HEAP32[i11 >> 2];
+ HEAP32[i13 + 4 >> 2] = i12;
+ HEAP32[i2 + 24 >> 2] = HEAP32[i10 >> 2];
+ i13 = 1;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ i8 = i9 - i6 | 0;
+ i6 = 1 << (HEAPU8[i5 + 7 | 0] | 0);
+ if ((i8 | 0) >= (i6 | 0)) {
+ i13 = 0;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ i7 = i5 + 16 | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ while (1) {
+ i9 = i8 + 1 | 0;
+ if ((HEAP32[i5 + (i8 << 5) + 8 >> 2] | 0) != 0) {
+ break;
+ }
+ if ((i9 | 0) < (i6 | 0)) {
+ i8 = i9;
+ } else {
+ i2 = 0;
+ i4 = 27;
+ break;
+ }
+ }
+ if ((i4 | 0) == 27) {
+ STACKTOP = i1;
+ return i2 | 0;
+ }
+ i11 = i5 + (i8 << 5) + 16 | 0;
+ i10 = HEAP32[i11 + 4 >> 2] | 0;
+ i13 = i2;
+ HEAP32[i13 >> 2] = HEAP32[i11 >> 2];
+ HEAP32[i13 + 4 >> 2] = i10;
+ HEAP32[i3 >> 2] = HEAP32[i5 + (i8 << 5) + 24 >> 2];
+ i13 = HEAP32[i7 >> 2] | 0;
+ i10 = i13 + (i8 << 5) | 0;
+ i11 = HEAP32[i10 + 4 >> 2] | 0;
+ i12 = i2 + 16 | 0;
+ HEAP32[i12 >> 2] = HEAP32[i10 >> 2];
+ HEAP32[i12 + 4 >> 2] = i11;
+ HEAP32[i2 + 24 >> 2] = HEAP32[i13 + (i8 << 5) + 8 >> 2];
+ i13 = 1;
+ STACKTOP = i1;
+ return i13 | 0;
+}
+function _g_read(i1, i3, i2) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 1056 | 0;
+ i7 = i4 + 8 | 0;
+ i9 = i4;
+ i10 = _lua_gettop(i1) | 0;
+ _clearerr(i3 | 0);
+ L1 : do {
+ if ((i10 | 0) == 1) {
+ i11 = i2 + 1 | 0;
+ i12 = _read_line(i1, i3, 1) | 0;
+ } else {
+ _luaL_checkstack(i1, i10 + 19 | 0, 3256);
+ i6 = i7 + 8 | 0;
+ i5 = i7 + 8 | 0;
+ i10 = i10 + -2 | 0;
+ i11 = i2;
+ L4 : while (1) {
+ do {
+ if ((_lua_type(i1, i11) | 0) == 3) {
+ i12 = _lua_tointegerx(i1, i11, 0) | 0;
+ if ((i12 | 0) == 0) {
+ i12 = _fgetc(i3 | 0) | 0;
+ _ungetc(i12 | 0, i3 | 0) | 0;
+ _lua_pushlstring(i1, 0, 0) | 0;
+ i12 = (i12 | 0) != -1 | 0;
+ break;
+ } else {
+ _luaL_buffinit(i1, i7);
+ i12 = _fread(_luaL_prepbuffsize(i7, i12) | 0, 1, i12 | 0, i3 | 0) | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + i12;
+ _luaL_pushresult(i7);
+ i12 = (i12 | 0) != 0 | 0;
+ break;
+ }
+ } else {
+ i12 = _lua_tolstring(i1, i11, 0) | 0;
+ if (!((i12 | 0) != 0 ? (HEAP8[i12] | 0) == 42 : 0)) {
+ _luaL_argerror(i1, i11, 3280) | 0;
+ }
+ i12 = HEAP8[i12 + 1 | 0] | 0;
+ if ((i12 | 0) == 110) {
+ HEAP32[i7 >> 2] = i9;
+ if ((_fscanf(i3 | 0, 3312, i7 | 0) | 0) != 1) {
+ i8 = 14;
+ break L4;
+ }
+ _lua_pushnumber(i1, +HEAPF64[i9 >> 3]);
+ i12 = 1;
+ break;
+ } else if ((i12 | 0) == 108) {
+ i12 = _read_line(i1, i3, 1) | 0;
+ break;
+ } else if ((i12 | 0) == 76) {
+ i12 = _read_line(i1, i3, 0) | 0;
+ break;
+ } else if ((i12 | 0) == 97) {
+ _luaL_buffinit(i1, i7);
+ i12 = _fread(_luaL_prepbuffsize(i7, 1024) | 0, 1, 1024, i3 | 0) | 0;
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + i12;
+ if (!(i12 >>> 0 < 1024)) {
+ i12 = 1024;
+ do {
+ i12 = i12 << (i12 >>> 0 < 1073741824);
+ i13 = _fread(_luaL_prepbuffsize(i7, i12) | 0, 1, i12 | 0, i3 | 0) | 0;
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + i13;
+ } while (!(i13 >>> 0 < i12 >>> 0));
+ }
+ _luaL_pushresult(i7);
+ i12 = 1;
+ break;
+ } else {
+ break L4;
+ }
+ }
+ } while (0);
+ i11 = i11 + 1 | 0;
+ if ((i10 | 0) == 0 | (i12 | 0) == 0) {
+ break L1;
+ } else {
+ i10 = i10 + -1 | 0;
+ }
+ }
+ if ((i8 | 0) == 14) {
+ _lua_pushnil(i1);
+ i11 = i11 + 1 | 0;
+ i12 = 0;
+ break;
+ }
+ i13 = _luaL_argerror(i1, i11, 3296) | 0;
+ STACKTOP = i4;
+ return i13 | 0;
+ }
+ } while (0);
+ if ((_ferror(i3 | 0) | 0) != 0) {
+ i13 = _luaL_fileresult(i1, 0, 0) | 0;
+ STACKTOP = i4;
+ return i13 | 0;
+ }
+ if ((i12 | 0) == 0) {
+ _lua_settop(i1, -2);
+ _lua_pushnil(i1);
+ }
+ i13 = i11 - i2 | 0;
+ STACKTOP = i4;
+ return i13 | 0;
+}
+function _luaY_parser(i8, i12, i10, i11, i9, i13) {
+ i8 = i8 | 0;
+ i12 = i12 | 0;
+ i10 = i10 | 0;
+ i11 = i11 | 0;
+ i9 = i9 | 0;
+ i13 = i13 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i14 = 0, i15 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 176 | 0;
+ i5 = i2 + 156 | 0;
+ i7 = i2 + 80 | 0;
+ i4 = i2;
+ i6 = i2 + 104 | 0;
+ i3 = _luaF_newLclosure(i8, 1) | 0;
+ i15 = i8 + 8 | 0;
+ i14 = HEAP32[i15 >> 2] | 0;
+ HEAP32[i14 >> 2] = i3;
+ HEAP32[i14 + 8 >> 2] = 70;
+ i14 = (HEAP32[i15 >> 2] | 0) + 16 | 0;
+ HEAP32[i15 >> 2] = i14;
+ if (((HEAP32[i8 + 24 >> 2] | 0) - i14 | 0) < 16) {
+ _luaD_growstack(i8, 0);
+ }
+ i14 = _luaF_newproto(i8) | 0;
+ HEAP32[i3 + 12 >> 2] = i14;
+ HEAP32[i6 >> 2] = i14;
+ i9 = _luaS_new(i8, i9) | 0;
+ HEAP32[(HEAP32[i6 >> 2] | 0) + 36 >> 2] = i9;
+ HEAP32[i4 + 60 >> 2] = i10;
+ i9 = i4 + 64 | 0;
+ HEAP32[i9 >> 2] = i11;
+ HEAP32[i11 + 28 >> 2] = 0;
+ HEAP32[i11 + 16 >> 2] = 0;
+ HEAP32[i11 + 4 >> 2] = 0;
+ _luaX_setinput(i8, i4, i12, HEAP32[(HEAP32[i6 >> 2] | 0) + 36 >> 2] | 0, i13);
+ i10 = HEAP32[i4 + 52 >> 2] | 0;
+ i13 = i4 + 48 | 0;
+ HEAP32[i6 + 8 >> 2] = HEAP32[i13 >> 2];
+ i8 = i6 + 12 | 0;
+ HEAP32[i8 >> 2] = i4;
+ HEAP32[i13 >> 2] = i6;
+ HEAP32[i6 + 20 >> 2] = 0;
+ HEAP32[i6 + 24 >> 2] = 0;
+ HEAP32[i6 + 28 >> 2] = -1;
+ HEAP32[i6 + 32 >> 2] = 0;
+ HEAP32[i6 + 36 >> 2] = 0;
+ i13 = i6 + 44 | 0;
+ HEAP32[i13 + 0 >> 2] = 0;
+ HEAP8[i13 + 4 | 0] = 0;
+ HEAP32[i6 + 40 >> 2] = HEAP32[(HEAP32[i9 >> 2] | 0) + 4 >> 2];
+ i9 = i6 + 16 | 0;
+ HEAP32[i9 >> 2] = 0;
+ i13 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i13 + 36 >> 2] = HEAP32[i4 + 68 >> 2];
+ HEAP8[i13 + 78 | 0] = 2;
+ i13 = _luaH_new(i10) | 0;
+ HEAP32[i6 + 4 >> 2] = i13;
+ i14 = i10 + 8 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i15 >> 2] = i13;
+ HEAP32[i15 + 8 >> 2] = 69;
+ i15 = (HEAP32[i14 >> 2] | 0) + 16 | 0;
+ HEAP32[i14 >> 2] = i15;
+ if (((HEAP32[i10 + 24 >> 2] | 0) - i15 | 0) < 16) {
+ _luaD_growstack(i10, 0);
+ }
+ HEAP8[i5 + 10 | 0] = 0;
+ HEAP8[i5 + 8 | 0] = HEAP8[i6 + 46 | 0] | 0;
+ i15 = HEAP32[(HEAP32[i8 >> 2] | 0) + 64 >> 2] | 0;
+ HEAP16[i5 + 4 >> 1] = HEAP32[i15 + 28 >> 2];
+ HEAP16[i5 + 6 >> 1] = HEAP32[i15 + 16 >> 2];
+ HEAP8[i5 + 9 | 0] = 0;
+ HEAP32[i5 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i9 >> 2] = i5;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + 77 | 0] = 1;
+ HEAP32[i7 + 16 >> 2] = -1;
+ HEAP32[i7 + 20 >> 2] = -1;
+ HEAP32[i7 >> 2] = 7;
+ HEAP32[i7 + 8 >> 2] = 0;
+ _newupvalue(i6, HEAP32[i4 + 72 >> 2] | 0, i7) | 0;
+ _luaX_next(i4);
+ i5 = i4 + 16 | 0;
+ L7 : while (1) {
+ i6 = HEAP32[i5 >> 2] | 0;
+ switch (i6 | 0) {
+ case 277:
+ case 286:
+ case 262:
+ case 261:
+ case 260:
+ {
+ break L7;
+ }
+ default:
+ {}
+ }
+ _statement(i4);
+ if ((i6 | 0) == 274) {
+ i1 = 8;
+ break;
+ }
+ }
+ if ((i1 | 0) == 8) {
+ i6 = HEAP32[i5 >> 2] | 0;
+ }
+ if ((i6 | 0) == 286) {
+ _close_func(i4);
+ STACKTOP = i2;
+ return i3 | 0;
+ } else {
+ _error_expected(i4, 286);
+ }
+ return 0;
+}
+function _luaV_lessthan(i5, i4, i2) {
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i1 = STACKTOP;
+ i6 = i4 + 8 | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ if ((i7 | 0) == 3) {
+ if ((HEAP32[i2 + 8 >> 2] | 0) == 3) {
+ i9 = +HEAPF64[i4 >> 3] < +HEAPF64[i2 >> 3] | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ } else {
+ if ((i7 & 15 | 0) == 4 ? (HEAP32[i2 + 8 >> 2] & 15 | 0) == 4 : 0) {
+ i6 = HEAP32[i4 >> 2] | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ i3 = i6 + 16 | 0;
+ i5 = i4 + 16 | 0;
+ i7 = _strcmp(i3, i5) | 0;
+ L8 : do {
+ if ((i7 | 0) == 0) {
+ i2 = HEAP32[i6 + 12 >> 2] | 0;
+ i4 = HEAP32[i4 + 12 >> 2] | 0;
+ while (1) {
+ i7 = _strlen(i3 | 0) | 0;
+ i6 = (i7 | 0) == (i2 | 0);
+ if ((i7 | 0) == (i4 | 0)) {
+ break;
+ }
+ if (i6) {
+ i7 = -1;
+ break L8;
+ }
+ i6 = i7 + 1 | 0;
+ i3 = i3 + i6 | 0;
+ i5 = i5 + i6 | 0;
+ i7 = _strcmp(i3, i5) | 0;
+ if ((i7 | 0) == 0) {
+ i2 = i2 - i6 | 0;
+ i4 = i4 - i6 | 0;
+ } else {
+ break L8;
+ }
+ }
+ i7 = i6 & 1 ^ 1;
+ }
+ } while (0);
+ i9 = i7 >>> 31;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ }
+ i8 = i5 + 8 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ i9 = _luaT_gettmbyobj(i5, i4, 13) | 0;
+ if ((HEAP32[i9 + 8 >> 2] | 0) == 0) {
+ i9 = _luaT_gettmbyobj(i5, i2, 13) | 0;
+ if ((HEAP32[i9 + 8 >> 2] | 0) == 0) {
+ _luaG_ordererror(i5, i4, i2);
+ } else {
+ i3 = i9;
+ }
+ } else {
+ i3 = i9;
+ }
+ i10 = i5 + 28 | 0;
+ i9 = i7 - (HEAP32[i10 >> 2] | 0) | 0;
+ i11 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i11 + 16;
+ i13 = i3;
+ i12 = HEAP32[i13 + 4 >> 2] | 0;
+ i7 = i11;
+ HEAP32[i7 >> 2] = HEAP32[i13 >> 2];
+ HEAP32[i7 + 4 >> 2] = i12;
+ HEAP32[i11 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ i3 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i3 + 16;
+ i11 = i4;
+ i7 = HEAP32[i11 + 4 >> 2] | 0;
+ i4 = i3;
+ HEAP32[i4 >> 2] = HEAP32[i11 >> 2];
+ HEAP32[i4 + 4 >> 2] = i7;
+ HEAP32[i3 + 8 >> 2] = HEAP32[i6 >> 2];
+ i3 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i3 + 16;
+ i4 = i2;
+ i7 = HEAP32[i4 + 4 >> 2] | 0;
+ i6 = i3;
+ HEAP32[i6 >> 2] = HEAP32[i4 >> 2];
+ HEAP32[i6 + 4 >> 2] = i7;
+ HEAP32[i3 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
+ _luaD_call(i5, (HEAP32[i8 >> 2] | 0) + -48 | 0, 1, HEAP8[(HEAP32[i5 + 16 >> 2] | 0) + 18 | 0] & 1);
+ i2 = HEAP32[i10 >> 2] | 0;
+ i3 = HEAP32[i8 >> 2] | 0;
+ i5 = i3 + -16 | 0;
+ HEAP32[i8 >> 2] = i5;
+ i6 = HEAP32[i5 + 4 >> 2] | 0;
+ i7 = i2 + i9 | 0;
+ HEAP32[i7 >> 2] = HEAP32[i5 >> 2];
+ HEAP32[i7 + 4 >> 2] = i6;
+ HEAP32[i2 + (i9 + 8) >> 2] = HEAP32[i3 + -8 >> 2];
+ i2 = HEAP32[i8 >> 2] | 0;
+ i3 = HEAP32[i2 + 8 >> 2] | 0;
+ if ((i3 | 0) != 0) {
+ if ((i3 | 0) == 1) {
+ i2 = (HEAP32[i2 >> 2] | 0) != 0;
+ } else {
+ i2 = 1;
+ }
+ } else {
+ i2 = 0;
+ }
+ i13 = i2 & 1;
+ STACKTOP = i1;
+ return i13 | 0;
+}
+function _discharge2reg(i4, i3, i1) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, d11 = 0.0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i9 = i2 + 16 | 0;
+ i8 = i2;
+ _luaK_dischargevars(i4, i3);
+ i10 = HEAP32[i3 >> 2] | 0;
+ L1 : do {
+ switch (i10 | 0) {
+ case 5:
+ {
+ d11 = +HEAPF64[i3 + 8 >> 3];
+ HEAPF64[i9 >> 3] = d11;
+ i5 = HEAP32[(HEAP32[i4 + 12 >> 2] | 0) + 52 >> 2] | 0;
+ HEAPF64[i8 >> 3] = d11;
+ HEAP32[i8 + 8 >> 2] = 3;
+ if (d11 != d11 | 0.0 != 0.0 | d11 == 0.0) {
+ i10 = i5 + 8 | 0;
+ i7 = HEAP32[i10 >> 2] | 0;
+ HEAP32[i10 >> 2] = i7 + 16;
+ i5 = _luaS_newlstr(i5, i9, 8) | 0;
+ HEAP32[i7 >> 2] = i5;
+ HEAP32[i7 + 8 >> 2] = HEAPU8[i5 + 4 | 0] | 0 | 64;
+ i5 = _addk(i4, (HEAP32[i10 >> 2] | 0) + -16 | 0, i8) | 0;
+ HEAP32[i10 >> 2] = (HEAP32[i10 >> 2] | 0) + -16;
+ } else {
+ i5 = _addk(i4, i8, i8) | 0;
+ }
+ i6 = i1 << 6;
+ if ((i5 | 0) < 262144) {
+ _luaK_code(i4, i6 | i5 << 14 | 1) | 0;
+ break L1;
+ } else {
+ _luaK_code(i4, i6 | 2) | 0;
+ _luaK_code(i4, i5 << 6 | 39) | 0;
+ break L1;
+ }
+ }
+ case 2:
+ case 3:
+ {
+ _luaK_code(i4, i1 << 6 | ((i10 | 0) == 2) << 23 | 3) | 0;
+ break;
+ }
+ case 4:
+ {
+ i6 = HEAP32[i3 + 8 >> 2] | 0;
+ i5 = i1 << 6;
+ if ((i6 | 0) < 262144) {
+ _luaK_code(i4, i5 | i6 << 14 | 1) | 0;
+ break L1;
+ } else {
+ _luaK_code(i4, i5 | 2) | 0;
+ _luaK_code(i4, i6 << 6 | 39) | 0;
+ break L1;
+ }
+ }
+ case 1:
+ {
+ i9 = i1 + 1 | 0;
+ i8 = HEAP32[i4 + 20 >> 2] | 0;
+ do {
+ if ((i8 | 0) > (HEAP32[i4 + 24 >> 2] | 0) ? (i5 = (HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] | 0) + (i8 + -1 << 2) | 0, i6 = HEAP32[i5 >> 2] | 0, (i6 & 63 | 0) == 4) : 0) {
+ i10 = i6 >>> 6 & 255;
+ i8 = i10 + (i6 >>> 23) | 0;
+ if (!((i10 | 0) <= (i1 | 0) ? (i8 + 1 | 0) >= (i1 | 0) : 0)) {
+ i7 = 6;
+ }
+ if ((i7 | 0) == 6 ? (i10 | 0) < (i1 | 0) | (i10 | 0) > (i9 | 0) : 0) {
+ break;
+ }
+ i4 = (i10 | 0) < (i1 | 0) ? i10 : i1;
+ HEAP32[i5 >> 2] = i4 << 6 & 16320 | i6 & 8372287 | ((i8 | 0) > (i1 | 0) ? i8 : i1) - i4 << 23;
+ break L1;
+ }
+ } while (0);
+ _luaK_code(i4, i1 << 6 | 4) | 0;
+ break;
+ }
+ case 6:
+ {
+ i5 = HEAP32[i3 + 8 >> 2] | 0;
+ if ((i5 | 0) != (i1 | 0)) {
+ _luaK_code(i4, i5 << 23 | i1 << 6) | 0;
+ }
+ break;
+ }
+ case 11:
+ {
+ i10 = (HEAP32[(HEAP32[i4 >> 2] | 0) + 12 >> 2] | 0) + (HEAP32[i3 + 8 >> 2] << 2) | 0;
+ HEAP32[i10 >> 2] = HEAP32[i10 >> 2] & -16321 | i1 << 6 & 16320;
+ break;
+ }
+ default:
+ {
+ STACKTOP = i2;
+ return;
+ }
+ }
+ } while (0);
+ HEAP32[i3 + 8 >> 2] = i1;
+ HEAP32[i3 >> 2] = 6;
+ STACKTOP = i2;
+ return;
+}
+function _unroll(i3, i4) {
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0;
+ i9 = STACKTOP;
+ i11 = i3 + 16 | 0;
+ i13 = HEAP32[i11 >> 2] | 0;
+ i5 = i3 + 72 | 0;
+ if ((i13 | 0) == (i5 | 0)) {
+ STACKTOP = i9;
+ return;
+ }
+ i6 = i3 + 8 | 0;
+ i10 = i3 + 40 | 0;
+ i7 = i3 + 20 | 0;
+ i8 = i3 + 28 | 0;
+ i4 = i3 + 68 | 0;
+ do {
+ i12 = i13 + 18 | 0;
+ i14 = HEAP8[i12] | 0;
+ if ((i14 & 1) == 0) {
+ i14 = i14 & 255;
+ if ((i14 & 16 | 0) != 0) {
+ HEAP8[i12] = i14 & 239;
+ HEAP32[i4 >> 2] = HEAP32[i13 + 32 >> 2];
+ }
+ if ((HEAP16[i13 + 16 >> 1] | 0) == -1 ? (i2 = (HEAP32[i11 >> 2] | 0) + 4 | 0, i1 = HEAP32[i6 >> 2] | 0, (HEAP32[i2 >> 2] | 0) >>> 0 < i1 >>> 0) : 0) {
+ HEAP32[i2 >> 2] = i1;
+ }
+ i14 = HEAP8[i12] | 0;
+ if ((i14 & 32) == 0) {
+ HEAP8[i13 + 37 | 0] = 1;
+ }
+ HEAP8[i12] = i14 & 199 | 8;
+ i14 = FUNCTION_TABLE_ii[HEAP32[i13 + 28 >> 2] & 255](i3) | 0;
+ i14 = (HEAP32[i6 >> 2] | 0) + (0 - i14 << 4) | 0;
+ i13 = HEAP32[i11 >> 2] | 0;
+ i12 = HEAPU8[i10] | 0;
+ if ((i12 & 6 | 0) == 0) {
+ i15 = i13 + 8 | 0;
+ } else {
+ if ((i12 & 2 | 0) != 0) {
+ i14 = i14 - (HEAP32[i8 >> 2] | 0) | 0;
+ _luaD_hook(i3, 1, -1);
+ i14 = (HEAP32[i8 >> 2] | 0) + i14 | 0;
+ }
+ i15 = i13 + 8 | 0;
+ HEAP32[i7 >> 2] = HEAP32[(HEAP32[i15 >> 2] | 0) + 28 >> 2];
+ }
+ i12 = HEAP32[i13 >> 2] | 0;
+ i13 = HEAP16[i13 + 16 >> 1] | 0;
+ HEAP32[i11 >> 2] = HEAP32[i15 >> 2];
+ L25 : do {
+ if (!(i13 << 16 >> 16 == 0)) {
+ i15 = i13 << 16 >> 16;
+ if (i14 >>> 0 < (HEAP32[i6 >> 2] | 0) >>> 0) {
+ i13 = i14;
+ i14 = i15;
+ i15 = i12;
+ while (1) {
+ i12 = i15 + 16 | 0;
+ i18 = i13;
+ i17 = HEAP32[i18 + 4 >> 2] | 0;
+ i16 = i15;
+ HEAP32[i16 >> 2] = HEAP32[i18 >> 2];
+ HEAP32[i16 + 4 >> 2] = i17;
+ HEAP32[i15 + 8 >> 2] = HEAP32[i13 + 8 >> 2];
+ i14 = i14 + -1 | 0;
+ i13 = i13 + 16 | 0;
+ if ((i14 | 0) == 0) {
+ break L25;
+ }
+ if (i13 >>> 0 < (HEAP32[i6 >> 2] | 0) >>> 0) {
+ i15 = i12;
+ } else {
+ i13 = i14;
+ break;
+ }
+ }
+ } else {
+ i13 = i15;
+ }
+ if ((i13 | 0) > 0) {
+ i14 = i13;
+ i15 = i12;
+ while (1) {
+ i14 = i14 + -1 | 0;
+ HEAP32[i15 + 8 >> 2] = 0;
+ if ((i14 | 0) <= 0) {
+ break;
+ } else {
+ i15 = i15 + 16 | 0;
+ }
+ }
+ i12 = i12 + (i13 << 4) | 0;
+ }
+ }
+ } while (0);
+ HEAP32[i6 >> 2] = i12;
+ } else {
+ _luaV_finishOp(i3);
+ _luaV_execute(i3);
+ }
+ i13 = HEAP32[i11 >> 2] | 0;
+ } while ((i13 | 0) != (i5 | 0));
+ STACKTOP = i9;
+ return;
+}
+function _traverseephemeron(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0;
+ i3 = STACKTOP;
+ i11 = i2 + 16 | 0;
+ i9 = HEAP32[i11 >> 2] | 0;
+ i5 = i9 + (1 << (HEAPU8[i2 + 7 | 0] | 0) << 5) | 0;
+ i10 = i2 + 28 | 0;
+ i13 = HEAP32[i10 >> 2] | 0;
+ if ((i13 | 0) > 0) {
+ i9 = i2 + 12 | 0;
+ i12 = 0;
+ i8 = 0;
+ do {
+ i14 = HEAP32[i9 >> 2] | 0;
+ if ((HEAP32[i14 + (i12 << 4) + 8 >> 2] & 64 | 0) != 0 ? (i7 = HEAP32[i14 + (i12 << 4) >> 2] | 0, !((HEAP8[i7 + 5 | 0] & 3) == 0)) : 0) {
+ _reallymarkobject(i1, i7);
+ i13 = HEAP32[i10 >> 2] | 0;
+ i8 = 1;
+ }
+ i12 = i12 + 1 | 0;
+ } while ((i12 | 0) < (i13 | 0));
+ i9 = HEAP32[i11 >> 2] | 0;
+ } else {
+ i8 = 0;
+ }
+ if (i9 >>> 0 < i5 >>> 0) {
+ i7 = 0;
+ i10 = 0;
+ do {
+ i11 = i9 + 8 | 0;
+ i12 = HEAP32[i11 >> 2] | 0;
+ i14 = i9 + 24 | 0;
+ i13 = HEAP32[i14 >> 2] | 0;
+ i15 = (i13 & 64 | 0) == 0;
+ L14 : do {
+ if ((i12 | 0) == 0) {
+ if (!i15 ? !((HEAP8[(HEAP32[i9 + 16 >> 2] | 0) + 5 | 0] & 3) == 0) : 0) {
+ HEAP32[i14 >> 2] = 11;
+ }
+ } else {
+ do {
+ if (i15) {
+ i6 = i12;
+ i4 = 18;
+ } else {
+ i14 = HEAP32[i9 + 16 >> 2] | 0;
+ if ((i13 & 15 | 0) == 4) {
+ if ((i14 | 0) == 0) {
+ i6 = i12;
+ i4 = 18;
+ break;
+ }
+ if ((HEAP8[i14 + 5 | 0] & 3) == 0) {
+ i6 = i12;
+ i4 = 18;
+ break;
+ }
+ _reallymarkobject(i1, i14);
+ i6 = HEAP32[i11 >> 2] | 0;
+ i4 = 18;
+ break;
+ }
+ i11 = (i12 & 64 | 0) == 0;
+ if ((HEAP8[i14 + 5 | 0] & 3) == 0) {
+ if (i11) {
+ break L14;
+ } else {
+ break;
+ }
+ }
+ if (i11) {
+ i7 = 1;
+ break L14;
+ }
+ i7 = 1;
+ i10 = (HEAP8[(HEAP32[i9 >> 2] | 0) + 5 | 0] & 3) == 0 ? i10 : 1;
+ break L14;
+ }
+ } while (0);
+ if ((i4 | 0) == 18 ? (i4 = 0, (i6 & 64 | 0) == 0) : 0) {
+ break;
+ }
+ i11 = HEAP32[i9 >> 2] | 0;
+ if (!((HEAP8[i11 + 5 | 0] & 3) == 0)) {
+ _reallymarkobject(i1, i11);
+ i8 = 1;
+ }
+ }
+ } while (0);
+ i9 = i9 + 32 | 0;
+ } while (i9 >>> 0 < i5 >>> 0);
+ if ((i10 | 0) != 0) {
+ i15 = i1 + 96 | 0;
+ HEAP32[i2 + 24 >> 2] = HEAP32[i15 >> 2];
+ HEAP32[i15 >> 2] = i2;
+ i15 = i8;
+ STACKTOP = i3;
+ return i15 | 0;
+ }
+ if ((i7 | 0) != 0) {
+ i15 = i1 + 100 | 0;
+ HEAP32[i2 + 24 >> 2] = HEAP32[i15 >> 2];
+ HEAP32[i15 >> 2] = i2;
+ i15 = i8;
+ STACKTOP = i3;
+ return i15 | 0;
+ }
+ }
+ i15 = i1 + 88 | 0;
+ HEAP32[i2 + 24 >> 2] = HEAP32[i15 >> 2];
+ HEAP32[i15 >> 2] = i2;
+ i15 = i8;
+ STACKTOP = i3;
+ return i15 | 0;
+}
+function _luaV_gettable(i2, i7, i5, i1) {
+ i2 = i2 | 0;
+ i7 = i7 | 0;
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ var i3 = 0, i4 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i6 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i6;
+ i8 = i2 + 12 | 0;
+ i3 = i7;
+ i10 = HEAP32[i7 + 8 >> 2] | 0;
+ i9 = 0;
+ while (1) {
+ i7 = i3 + 8 | 0;
+ if ((i10 | 0) != 69) {
+ i12 = _luaT_gettmbyobj(i2, i3, 0) | 0;
+ i10 = HEAP32[i12 + 8 >> 2] | 0;
+ if ((i10 | 0) == 0) {
+ i8 = 11;
+ break;
+ }
+ } else {
+ i12 = HEAP32[i3 >> 2] | 0;
+ i11 = _luaH_get(i12, i5) | 0;
+ i10 = i11 + 8 | 0;
+ if ((HEAP32[i10 >> 2] | 0) != 0) {
+ i8 = 9;
+ break;
+ }
+ i12 = HEAP32[i12 + 8 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i8 = 9;
+ break;
+ }
+ if (!((HEAP8[i12 + 6 | 0] & 1) == 0)) {
+ i8 = 9;
+ break;
+ }
+ i12 = _luaT_gettm(i12, 0, HEAP32[(HEAP32[i8 >> 2] | 0) + 184 >> 2] | 0) | 0;
+ if ((i12 | 0) == 0) {
+ i8 = 9;
+ break;
+ }
+ i10 = HEAP32[i12 + 8 >> 2] | 0;
+ }
+ i9 = i9 + 1 | 0;
+ if ((i10 & 15 | 0) == 6) {
+ i8 = 13;
+ break;
+ }
+ if ((i9 | 0) < 100) {
+ i3 = i12;
+ } else {
+ i8 = 14;
+ break;
+ }
+ }
+ if ((i8 | 0) == 9) {
+ i9 = i11;
+ i11 = HEAP32[i9 + 4 >> 2] | 0;
+ i12 = i1;
+ HEAP32[i12 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i12 + 4 >> 2] = i11;
+ HEAP32[i1 + 8 >> 2] = HEAP32[i10 >> 2];
+ STACKTOP = i6;
+ return;
+ } else if ((i8 | 0) == 11) {
+ _luaG_typeerror(i2, i3, 8944);
+ } else if ((i8 | 0) == 13) {
+ i10 = i2 + 28 | 0;
+ i11 = i1 - (HEAP32[i10 >> 2] | 0) | 0;
+ i8 = i2 + 8 | 0;
+ i9 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i9 + 16;
+ i13 = i12;
+ i1 = HEAP32[i13 + 4 >> 2] | 0;
+ i4 = i9;
+ HEAP32[i4 >> 2] = HEAP32[i13 >> 2];
+ HEAP32[i4 + 4 >> 2] = i1;
+ HEAP32[i9 + 8 >> 2] = HEAP32[i12 + 8 >> 2];
+ i12 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i12 + 16;
+ i9 = HEAP32[i3 + 4 >> 2] | 0;
+ i4 = i12;
+ HEAP32[i4 >> 2] = HEAP32[i3 >> 2];
+ HEAP32[i4 + 4 >> 2] = i9;
+ HEAP32[i12 + 8 >> 2] = HEAP32[i7 >> 2];
+ i12 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i12 + 16;
+ i4 = i5;
+ i9 = HEAP32[i4 + 4 >> 2] | 0;
+ i7 = i12;
+ HEAP32[i7 >> 2] = HEAP32[i4 >> 2];
+ HEAP32[i7 + 4 >> 2] = i9;
+ HEAP32[i12 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ _luaD_call(i2, (HEAP32[i8 >> 2] | 0) + -48 | 0, 1, HEAP8[(HEAP32[i2 + 16 >> 2] | 0) + 18 | 0] & 1);
+ i12 = HEAP32[i10 >> 2] | 0;
+ i10 = HEAP32[i8 >> 2] | 0;
+ i7 = i10 + -16 | 0;
+ HEAP32[i8 >> 2] = i7;
+ i8 = HEAP32[i7 + 4 >> 2] | 0;
+ i9 = i12 + i11 | 0;
+ HEAP32[i9 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i9 + 4 >> 2] = i8;
+ HEAP32[i12 + (i11 + 8) >> 2] = HEAP32[i10 + -8 >> 2];
+ STACKTOP = i6;
+ return;
+ } else if ((i8 | 0) == 14) {
+ _luaG_runerror(i2, 8952, i4);
+ }
+}
+function _db_getinfo(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 112 | 0;
+ i3 = i2;
+ if ((_lua_type(i1, 1) | 0) == 8) {
+ i4 = _lua_tothread(i1, 1) | 0;
+ i7 = 1;
+ } else {
+ i4 = i1;
+ i7 = 0;
+ }
+ i5 = i7 | 2;
+ i6 = _luaL_optlstring(i1, i5, 11784, 0) | 0;
+ i7 = i7 + 1 | 0;
+ do {
+ if ((_lua_isnumber(i1, i7) | 0) != 0) {
+ if ((_lua_getstack(i4, _lua_tointegerx(i1, i7, 0) | 0, i3) | 0) == 0) {
+ _lua_pushnil(i1);
+ i7 = 1;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ } else {
+ if ((_lua_type(i1, i7) | 0) == 6) {
+ HEAP32[i3 >> 2] = i6;
+ _lua_pushfstring(i1, 11792, i3) | 0;
+ i6 = _lua_tolstring(i1, -1, 0) | 0;
+ _lua_pushvalue(i1, i7);
+ _lua_xmove(i1, i4, 1);
+ break;
+ }
+ i7 = _luaL_argerror(i1, i7, 11800) | 0;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ } while (0);
+ if ((_lua_getinfo(i4, i6, i3) | 0) == 0) {
+ i7 = _luaL_argerror(i1, i5, 11832) | 0;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ _lua_createtable(i1, 0, 2);
+ if ((_strchr(i6, 83) | 0) != 0) {
+ _lua_pushstring(i1, HEAP32[i3 + 16 >> 2] | 0) | 0;
+ _lua_setfield(i1, -2, 11848);
+ _lua_pushstring(i1, i3 + 36 | 0) | 0;
+ _lua_setfield(i1, -2, 11856);
+ _lua_pushinteger(i1, HEAP32[i3 + 24 >> 2] | 0);
+ _lua_setfield(i1, -2, 11872);
+ _lua_pushinteger(i1, HEAP32[i3 + 28 >> 2] | 0);
+ _lua_setfield(i1, -2, 11888);
+ _lua_pushstring(i1, HEAP32[i3 + 12 >> 2] | 0) | 0;
+ _lua_setfield(i1, -2, 11904);
+ }
+ if ((_strchr(i6, 108) | 0) != 0) {
+ _lua_pushinteger(i1, HEAP32[i3 + 20 >> 2] | 0);
+ _lua_setfield(i1, -2, 11912);
+ }
+ if ((_strchr(i6, 117) | 0) != 0) {
+ _lua_pushinteger(i1, HEAPU8[i3 + 32 | 0] | 0);
+ _lua_setfield(i1, -2, 11928);
+ _lua_pushinteger(i1, HEAPU8[i3 + 33 | 0] | 0);
+ _lua_setfield(i1, -2, 11936);
+ _lua_pushboolean(i1, HEAP8[i3 + 34 | 0] | 0);
+ _lua_setfield(i1, -2, 11944);
+ }
+ if ((_strchr(i6, 110) | 0) != 0) {
+ _lua_pushstring(i1, HEAP32[i3 + 4 >> 2] | 0) | 0;
+ _lua_setfield(i1, -2, 11960);
+ _lua_pushstring(i1, HEAP32[i3 + 8 >> 2] | 0) | 0;
+ _lua_setfield(i1, -2, 11968);
+ }
+ if ((_strchr(i6, 116) | 0) != 0) {
+ _lua_pushboolean(i1, HEAP8[i3 + 35 | 0] | 0);
+ _lua_setfield(i1, -2, 11984);
+ }
+ if ((_strchr(i6, 76) | 0) != 0) {
+ if ((i4 | 0) == (i1 | 0)) {
+ _lua_pushvalue(i1, -2);
+ _lua_remove(i1, -3);
+ } else {
+ _lua_xmove(i4, i1, 1);
+ }
+ _lua_setfield(i1, -2, 12e3);
+ }
+ if ((_strchr(i6, 102) | 0) == 0) {
+ i7 = 1;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ if ((i4 | 0) == (i1 | 0)) {
+ _lua_pushvalue(i1, -2);
+ _lua_remove(i1, -3);
+ } else {
+ _lua_xmove(i4, i1, 1);
+ }
+ _lua_setfield(i1, -2, 12016);
+ i7 = 1;
+ STACKTOP = i2;
+ return i7 | 0;
+}
+function _luaL_traceback(i4, i1, i9, i7) {
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ i9 = i9 | 0;
+ i7 = i7 | 0;
+ var i2 = 0, i3 = 0, i5 = 0, i6 = 0, i8 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 208 | 0;
+ i6 = i3;
+ i5 = i3 + 100 | 0;
+ i2 = _lua_gettop(i4) | 0;
+ i8 = 1;
+ i10 = 1;
+ while (1) {
+ if ((_lua_getstack(i1, i8, i6) | 0) == 0) {
+ break;
+ } else {
+ i10 = i8;
+ i8 = i8 << 1;
+ }
+ }
+ if ((i10 | 0) < (i8 | 0)) {
+ while (1) {
+ i11 = (i8 + i10 | 0) / 2 | 0;
+ i12 = (_lua_getstack(i1, i11, i6) | 0) == 0;
+ i8 = i12 ? i11 : i8;
+ i10 = i12 ? i10 : i11 + 1 | 0;
+ if ((i10 | 0) >= (i8 | 0)) {
+ i10 = i8;
+ break;
+ }
+ }
+ } else {
+ i10 = i8;
+ }
+ i8 = (i10 + -1 | 0) > 22 ? 12 : 0;
+ if ((i9 | 0) != 0) {
+ HEAP32[i6 >> 2] = i9;
+ _lua_pushfstring(i4, 944, i6) | 0;
+ }
+ _lua_pushlstring(i4, 952, 16) | 0;
+ if ((_lua_getstack(i1, i7, i5) | 0) == 0) {
+ i17 = _lua_gettop(i4) | 0;
+ i17 = i17 - i2 | 0;
+ _lua_concat(i4, i17);
+ STACKTOP = i3;
+ return;
+ }
+ i10 = i10 + -11 | 0;
+ i13 = i5 + 36 | 0;
+ i9 = i5 + 20 | 0;
+ i16 = i5 + 8 | 0;
+ i12 = i5 + 12 | 0;
+ i15 = i5 + 24 | 0;
+ i14 = i5 + 35 | 0;
+ i11 = i5 + 4 | 0;
+ do {
+ i7 = i7 + 1 | 0;
+ if ((i7 | 0) == (i8 | 0)) {
+ _lua_pushlstring(i4, 976, 5) | 0;
+ i7 = i10;
+ } else {
+ _lua_getinfo(i1, 984, i5) | 0;
+ HEAP32[i6 >> 2] = i13;
+ _lua_pushfstring(i4, 992, i6) | 0;
+ i17 = HEAP32[i9 >> 2] | 0;
+ if ((i17 | 0) > 0) {
+ HEAP32[i6 >> 2] = i17;
+ _lua_pushfstring(i4, 1e3, i6) | 0;
+ }
+ _lua_pushlstring(i4, 1008, 4) | 0;
+ do {
+ if ((HEAP8[HEAP32[i16 >> 2] | 0] | 0) == 0) {
+ i17 = HEAP8[HEAP32[i12 >> 2] | 0] | 0;
+ if (i17 << 24 >> 24 == 109) {
+ _lua_pushlstring(i4, 1800, 10) | 0;
+ break;
+ } else if (i17 << 24 >> 24 == 67) {
+ if ((_pushglobalfuncname(i4, i5) | 0) == 0) {
+ _lua_pushlstring(i4, 1112, 1) | 0;
+ break;
+ } else {
+ HEAP32[i6 >> 2] = _lua_tolstring(i4, -1, 0) | 0;
+ _lua_pushfstring(i4, 1784, i6) | 0;
+ _lua_remove(i4, -2);
+ break;
+ }
+ } else {
+ i17 = HEAP32[i15 >> 2] | 0;
+ HEAP32[i6 >> 2] = i13;
+ HEAP32[i6 + 4 >> 2] = i17;
+ _lua_pushfstring(i4, 1816, i6) | 0;
+ break;
+ }
+ } else {
+ HEAP32[i6 >> 2] = HEAP32[i11 >> 2];
+ _lua_pushfstring(i4, 1784, i6) | 0;
+ }
+ } while (0);
+ if ((HEAP8[i14] | 0) != 0) {
+ _lua_pushlstring(i4, 1016, 20) | 0;
+ }
+ _lua_concat(i4, (_lua_gettop(i4) | 0) - i2 | 0);
+ }
+ } while ((_lua_getstack(i1, i7, i5) | 0) != 0);
+ i17 = _lua_gettop(i4) | 0;
+ i17 = i17 - i2 | 0;
+ _lua_concat(i4, i17);
+ STACKTOP = i3;
+ return;
+}
+function _luaK_exp2RK(i3, i1) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, d11 = 0.0, i12 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i7 = i2 + 16 | 0;
+ i6 = i2;
+ i4 = i1 + 16 | 0;
+ i5 = i1 + 20 | 0;
+ i10 = (HEAP32[i4 >> 2] | 0) == (HEAP32[i5 >> 2] | 0);
+ _luaK_dischargevars(i3, i1);
+ do {
+ if (!i10) {
+ if ((HEAP32[i1 >> 2] | 0) == 6) {
+ i10 = HEAP32[i1 + 8 >> 2] | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (HEAP32[i5 >> 2] | 0)) {
+ break;
+ }
+ if ((i10 | 0) >= (HEAPU8[i3 + 46 | 0] | 0 | 0)) {
+ _exp2reg(i3, i1, i10);
+ break;
+ }
+ }
+ _luaK_exp2nextreg(i3, i1);
+ }
+ } while (0);
+ i10 = HEAP32[i1 >> 2] | 0;
+ switch (i10 | 0) {
+ case 4:
+ {
+ i8 = HEAP32[i1 + 8 >> 2] | 0;
+ i9 = 18;
+ break;
+ }
+ case 1:
+ case 3:
+ case 2:
+ {
+ if ((HEAP32[i3 + 32 >> 2] | 0) < 256) {
+ if ((i10 | 0) == 1) {
+ HEAP32[i6 + 8 >> 2] = 0;
+ HEAP32[i7 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i7 + 8 >> 2] = 69;
+ i3 = _addk(i3, i7, i6) | 0;
+ } else {
+ HEAP32[i7 >> 2] = (i10 | 0) == 2;
+ HEAP32[i7 + 8 >> 2] = 1;
+ i3 = _addk(i3, i7, i7) | 0;
+ }
+ HEAP32[i1 + 8 >> 2] = i3;
+ HEAP32[i1 >> 2] = 4;
+ i10 = i3 | 256;
+ STACKTOP = i2;
+ return i10 | 0;
+ }
+ break;
+ }
+ case 5:
+ {
+ i9 = i1 + 8 | 0;
+ d11 = +HEAPF64[i9 >> 3];
+ HEAPF64[i7 >> 3] = d11;
+ i8 = HEAP32[(HEAP32[i3 + 12 >> 2] | 0) + 52 >> 2] | 0;
+ HEAPF64[i6 >> 3] = d11;
+ HEAP32[i6 + 8 >> 2] = 3;
+ if (d11 != d11 | 0.0 != 0.0 | d11 == 0.0) {
+ i10 = i8 + 8 | 0;
+ i12 = HEAP32[i10 >> 2] | 0;
+ HEAP32[i10 >> 2] = i12 + 16;
+ i8 = _luaS_newlstr(i8, i7, 8) | 0;
+ HEAP32[i12 >> 2] = i8;
+ HEAP32[i12 + 8 >> 2] = HEAPU8[i8 + 4 | 0] | 0 | 64;
+ i8 = _addk(i3, (HEAP32[i10 >> 2] | 0) + -16 | 0, i6) | 0;
+ HEAP32[i10 >> 2] = (HEAP32[i10 >> 2] | 0) + -16;
+ } else {
+ i8 = _addk(i3, i6, i6) | 0;
+ }
+ HEAP32[i9 >> 2] = i8;
+ HEAP32[i1 >> 2] = 4;
+ i9 = 18;
+ break;
+ }
+ default:
+ {}
+ }
+ if ((i9 | 0) == 18 ? (i8 | 0) < 256 : 0) {
+ i12 = i8 | 256;
+ STACKTOP = i2;
+ return i12 | 0;
+ }
+ _luaK_dischargevars(i3, i1);
+ if ((HEAP32[i1 >> 2] | 0) == 6) {
+ i7 = i1 + 8 | 0;
+ i6 = HEAP32[i7 >> 2] | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (HEAP32[i5 >> 2] | 0)) {
+ i12 = i6;
+ STACKTOP = i2;
+ return i12 | 0;
+ }
+ if ((i6 | 0) >= (HEAPU8[i3 + 46 | 0] | 0 | 0)) {
+ _exp2reg(i3, i1, i6);
+ i12 = HEAP32[i7 >> 2] | 0;
+ STACKTOP = i2;
+ return i12 | 0;
+ }
+ } else {
+ i7 = i1 + 8 | 0;
+ }
+ _luaK_exp2nextreg(i3, i1);
+ i12 = HEAP32[i7 >> 2] | 0;
+ STACKTOP = i2;
+ return i12 | 0;
+}
+function _os_date(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 1264 | 0;
+ i4 = i2;
+ i7 = i2 + 1048 | 0;
+ i6 = i2 + 1256 | 0;
+ i3 = i2 + 8 | 0;
+ i5 = i2 + 1056 | 0;
+ i12 = _luaL_optlstring(i1, 1, 6064, 0) | 0;
+ if ((_lua_type(i1, 2) | 0) < 1) {
+ i8 = _time(0) | 0;
+ } else {
+ i8 = ~~+_luaL_checknumber(i1, 2);
+ }
+ HEAP32[i7 >> 2] = i8;
+ if ((HEAP8[i12] | 0) == 33) {
+ i12 = i12 + 1 | 0;
+ i10 = _gmtime(i7 | 0) | 0;
+ } else {
+ i10 = _localtime(i7 | 0) | 0;
+ }
+ if ((i10 | 0) == 0) {
+ _lua_pushnil(i1);
+ STACKTOP = i2;
+ return 1;
+ }
+ if ((_strcmp(i12, 6072) | 0) == 0) {
+ _lua_createtable(i1, 0, 9);
+ _lua_pushinteger(i1, HEAP32[i10 >> 2] | 0);
+ _lua_setfield(i1, -2, 5864);
+ _lua_pushinteger(i1, HEAP32[i10 + 4 >> 2] | 0);
+ _lua_setfield(i1, -2, 5872);
+ _lua_pushinteger(i1, HEAP32[i10 + 8 >> 2] | 0);
+ _lua_setfield(i1, -2, 5880);
+ _lua_pushinteger(i1, HEAP32[i10 + 12 >> 2] | 0);
+ _lua_setfield(i1, -2, 5888);
+ _lua_pushinteger(i1, (HEAP32[i10 + 16 >> 2] | 0) + 1 | 0);
+ _lua_setfield(i1, -2, 5896);
+ _lua_pushinteger(i1, (HEAP32[i10 + 20 >> 2] | 0) + 1900 | 0);
+ _lua_setfield(i1, -2, 5904);
+ _lua_pushinteger(i1, (HEAP32[i10 + 24 >> 2] | 0) + 1 | 0);
+ _lua_setfield(i1, -2, 6080);
+ _lua_pushinteger(i1, (HEAP32[i10 + 28 >> 2] | 0) + 1 | 0);
+ _lua_setfield(i1, -2, 6088);
+ i3 = HEAP32[i10 + 32 >> 2] | 0;
+ if ((i3 | 0) < 0) {
+ STACKTOP = i2;
+ return 1;
+ }
+ _lua_pushboolean(i1, i3);
+ _lua_setfield(i1, -2, 5912);
+ STACKTOP = i2;
+ return 1;
+ }
+ HEAP8[i6] = 37;
+ _luaL_buffinit(i1, i3);
+ i11 = i3 + 8 | 0;
+ i9 = i3 + 4 | 0;
+ i8 = i6 + 1 | 0;
+ i7 = i6 + 2 | 0;
+ while (1) {
+ i14 = HEAP8[i12] | 0;
+ if (i14 << 24 >> 24 == 0) {
+ break;
+ } else if (!(i14 << 24 >> 24 == 37)) {
+ i13 = HEAP32[i11 >> 2] | 0;
+ if (!(i13 >>> 0 < (HEAP32[i9 >> 2] | 0) >>> 0)) {
+ _luaL_prepbuffsize(i3, 1) | 0;
+ i13 = HEAP32[i11 >> 2] | 0;
+ i14 = HEAP8[i12] | 0;
+ }
+ HEAP32[i11 >> 2] = i13 + 1;
+ HEAP8[(HEAP32[i3 >> 2] | 0) + i13 | 0] = i14;
+ i12 = i12 + 1 | 0;
+ continue;
+ }
+ i13 = i12 + 1 | 0;
+ i12 = i12 + 2 | 0;
+ i14 = HEAP8[i13] | 0;
+ if (!(i14 << 24 >> 24 == 0) ? (_memchr(6096, i14 << 24 >> 24, 23) | 0) != 0 : 0) {
+ HEAP8[i8] = i14;
+ HEAP8[i7] = 0;
+ } else {
+ HEAP32[i4 >> 2] = i13;
+ _luaL_argerror(i1, 1, _lua_pushfstring(i1, 6120, i4) | 0) | 0;
+ i12 = i13;
+ }
+ _luaL_addlstring(i3, i5, _strftime(i5 | 0, 200, i6 | 0, i10 | 0) | 0);
+ }
+ _luaL_pushresult(i3);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaV_finishOp(i3) {
+ i3 = i3 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0;
+ i1 = STACKTOP;
+ i8 = HEAP32[i3 + 16 >> 2] | 0;
+ i7 = i8 + 24 | 0;
+ i4 = HEAP32[i7 >> 2] | 0;
+ i5 = i8 + 28 | 0;
+ i2 = HEAP32[(HEAP32[i5 >> 2] | 0) + -4 >> 2] | 0;
+ i6 = i2 & 63;
+ switch (i6 | 0) {
+ case 34:
+ {
+ HEAP32[i3 + 8 >> 2] = HEAP32[i8 + 4 >> 2];
+ STACKTOP = i1;
+ return;
+ }
+ case 24:
+ case 25:
+ case 26:
+ {
+ i7 = i3 + 8 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ i9 = HEAP32[i8 + -8 >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ if ((i9 | 0) == 1) {
+ i9 = (HEAP32[i8 + -16 >> 2] | 0) == 0;
+ } else {
+ i9 = 0;
+ }
+ } else {
+ i9 = 1;
+ }
+ i9 = i9 & 1;
+ i10 = i9 ^ 1;
+ HEAP32[i7 >> 2] = i8 + -16;
+ if ((i6 | 0) == 26) {
+ i8 = (HEAP32[(_luaT_gettmbyobj(i3, i4 + (i2 >>> 23 << 4) | 0, 14) | 0) + 8 >> 2] | 0) == 0;
+ i10 = i8 ? i9 : i10;
+ }
+ if ((i10 | 0) == (i2 >>> 6 & 255 | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + 4;
+ STACKTOP = i1;
+ return;
+ }
+ case 22:
+ {
+ i5 = i3 + 8 | 0;
+ i10 = HEAP32[i5 >> 2] | 0;
+ i6 = i10 + -32 | 0;
+ i4 = i6 - (i4 + (i2 >>> 23 << 4)) | 0;
+ i12 = i10 + -16 | 0;
+ i11 = HEAP32[i12 + 4 >> 2] | 0;
+ i9 = i10 + -48 | 0;
+ HEAP32[i9 >> 2] = HEAP32[i12 >> 2];
+ HEAP32[i9 + 4 >> 2] = i11;
+ HEAP32[i10 + -40 >> 2] = HEAP32[i10 + -8 >> 2];
+ if ((i4 | 0) > 16) {
+ HEAP32[i5 >> 2] = i6;
+ _luaV_concat(i3, i4 >> 4);
+ }
+ i10 = HEAP32[i5 >> 2] | 0;
+ i11 = HEAP32[i7 >> 2] | 0;
+ i12 = i2 >>> 6 & 255;
+ i6 = i10 + -16 | 0;
+ i7 = HEAP32[i6 + 4 >> 2] | 0;
+ i9 = i11 + (i12 << 4) | 0;
+ HEAP32[i9 >> 2] = HEAP32[i6 >> 2];
+ HEAP32[i9 + 4 >> 2] = i7;
+ HEAP32[i11 + (i12 << 4) + 8 >> 2] = HEAP32[i10 + -8 >> 2];
+ HEAP32[i5 >> 2] = HEAP32[i8 + 4 >> 2];
+ STACKTOP = i1;
+ return;
+ }
+ case 12:
+ case 7:
+ case 6:
+ case 21:
+ case 19:
+ case 18:
+ case 17:
+ case 16:
+ case 15:
+ case 14:
+ case 13:
+ {
+ i12 = i3 + 8 | 0;
+ i11 = HEAP32[i12 >> 2] | 0;
+ i8 = i11 + -16 | 0;
+ HEAP32[i12 >> 2] = i8;
+ i12 = i2 >>> 6 & 255;
+ i9 = HEAP32[i8 + 4 >> 2] | 0;
+ i10 = i4 + (i12 << 4) | 0;
+ HEAP32[i10 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i10 + 4 >> 2] = i9;
+ HEAP32[i4 + (i12 << 4) + 8 >> 2] = HEAP32[i11 + -8 >> 2];
+ STACKTOP = i1;
+ return;
+ }
+ case 29:
+ {
+ if ((i2 & 8372224 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[i3 + 8 >> 2] = HEAP32[i8 + 4 >> 2];
+ STACKTOP = i1;
+ return;
+ }
+ default:
+ {
+ STACKTOP = i1;
+ return;
+ }
+ }
+}
+function _auxsort(i2, i4, i5) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i1;
+ if ((i4 | 0) >= (i5 | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ while (1) {
+ _lua_rawgeti(i2, 1, i4);
+ _lua_rawgeti(i2, 1, i5);
+ if ((_sort_comp(i2, -1, -2) | 0) == 0) {
+ _lua_settop(i2, -3);
+ } else {
+ _lua_rawseti(i2, 1, i4);
+ _lua_rawseti(i2, 1, i5);
+ }
+ i6 = i5 - i4 | 0;
+ if ((i6 | 0) == 1) {
+ i2 = 24;
+ break;
+ }
+ i7 = (i5 + i4 | 0) / 2 | 0;
+ _lua_rawgeti(i2, 1, i7);
+ _lua_rawgeti(i2, 1, i4);
+ do {
+ if ((_sort_comp(i2, -2, -1) | 0) == 0) {
+ _lua_settop(i2, -2);
+ _lua_rawgeti(i2, 1, i5);
+ if ((_sort_comp(i2, -1, -2) | 0) == 0) {
+ _lua_settop(i2, -3);
+ break;
+ } else {
+ _lua_rawseti(i2, 1, i7);
+ _lua_rawseti(i2, 1, i5);
+ break;
+ }
+ } else {
+ _lua_rawseti(i2, 1, i7);
+ _lua_rawseti(i2, 1, i4);
+ }
+ } while (0);
+ if ((i6 | 0) == 2) {
+ i2 = 24;
+ break;
+ }
+ _lua_rawgeti(i2, 1, i7);
+ _lua_pushvalue(i2, -1);
+ i6 = i5 + -1 | 0;
+ _lua_rawgeti(i2, 1, i6);
+ _lua_rawseti(i2, 1, i7);
+ _lua_rawseti(i2, 1, i6);
+ i7 = i4;
+ i9 = i6;
+ while (1) {
+ i8 = i7 + 1 | 0;
+ _lua_rawgeti(i2, 1, i8);
+ if ((_sort_comp(i2, -1, -2) | 0) != 0) {
+ i7 = i8;
+ while (1) {
+ if ((i7 | 0) >= (i5 | 0)) {
+ _luaL_error(i2, 8216, i3) | 0;
+ }
+ _lua_settop(i2, -2);
+ i8 = i7 + 1 | 0;
+ _lua_rawgeti(i2, 1, i8);
+ if ((_sort_comp(i2, -1, -2) | 0) == 0) {
+ break;
+ } else {
+ i7 = i8;
+ }
+ }
+ }
+ i10 = i9 + -1 | 0;
+ _lua_rawgeti(i2, 1, i10);
+ if ((_sort_comp(i2, -3, -1) | 0) != 0) {
+ i9 = i10;
+ while (1) {
+ if ((i9 | 0) <= (i4 | 0)) {
+ _luaL_error(i2, 8216, i3) | 0;
+ }
+ _lua_settop(i2, -2);
+ i10 = i9 + -1 | 0;
+ _lua_rawgeti(i2, 1, i10);
+ if ((_sort_comp(i2, -3, -1) | 0) == 0) {
+ break;
+ } else {
+ i9 = i10;
+ }
+ }
+ }
+ if ((i9 | 0) <= (i8 | 0)) {
+ break;
+ }
+ _lua_rawseti(i2, 1, i8);
+ _lua_rawseti(i2, 1, i10);
+ i7 = i8;
+ i9 = i10;
+ }
+ _lua_settop(i2, -4);
+ _lua_rawgeti(i2, 1, i6);
+ _lua_rawgeti(i2, 1, i8);
+ _lua_rawseti(i2, 1, i6);
+ _lua_rawseti(i2, 1, i8);
+ i8 = (i8 - i4 | 0) < (i5 - i8 | 0);
+ i9 = i7 + 2 | 0;
+ i10 = i8 ? i9 : i4;
+ i6 = i8 ? i5 : i7;
+ _auxsort(i2, i8 ? i4 : i9, i8 ? i7 : i5);
+ if ((i10 | 0) < (i6 | 0)) {
+ i4 = i10;
+ i5 = i6;
+ } else {
+ i2 = 24;
+ break;
+ }
+ }
+ if ((i2 | 0) == 24) {
+ STACKTOP = i1;
+ return;
+ }
+}
+function _skip_sep(i3) {
+ i3 = i3 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i1 = STACKTOP;
+ i2 = HEAP32[i3 >> 2] | 0;
+ i4 = i3 + 60 | 0;
+ i10 = HEAP32[i4 >> 2] | 0;
+ i8 = i10 + 4 | 0;
+ i11 = HEAP32[i8 >> 2] | 0;
+ i7 = i10 + 8 | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ do {
+ if ((i11 + 1 | 0) >>> 0 > i5 >>> 0) {
+ if (i5 >>> 0 > 2147483645) {
+ _lexerror(i3, 12368, 0);
+ }
+ i12 = i5 << 1;
+ i11 = HEAP32[i3 + 52 >> 2] | 0;
+ if ((i12 | 0) == -2) {
+ _luaM_toobig(i11);
+ } else {
+ i9 = _luaM_realloc_(i11, HEAP32[i10 >> 2] | 0, i5, i12) | 0;
+ HEAP32[i10 >> 2] = i9;
+ HEAP32[i7 >> 2] = i12;
+ i6 = HEAP32[i8 >> 2] | 0;
+ break;
+ }
+ } else {
+ i6 = i11;
+ i9 = HEAP32[i10 >> 2] | 0;
+ }
+ } while (0);
+ HEAP32[i8 >> 2] = i6 + 1;
+ HEAP8[i9 + i6 | 0] = i2;
+ i5 = i3 + 56 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ i13 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i13 + -1;
+ if ((i13 | 0) == 0) {
+ i6 = _luaZ_fill(i6) | 0;
+ } else {
+ i13 = i6 + 4 | 0;
+ i6 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i6 + 1;
+ i6 = HEAPU8[i6] | 0;
+ }
+ HEAP32[i3 >> 2] = i6;
+ if ((i6 | 0) != 61) {
+ i12 = i6;
+ i13 = 0;
+ i12 = (i12 | 0) != (i2 | 0);
+ i12 = i12 << 31 >> 31;
+ i13 = i12 ^ i13;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ i6 = i3 + 52 | 0;
+ i7 = 0;
+ while (1) {
+ i9 = HEAP32[i4 >> 2] | 0;
+ i8 = i9 + 4 | 0;
+ i10 = HEAP32[i8 >> 2] | 0;
+ i11 = i9 + 8 | 0;
+ i12 = HEAP32[i11 >> 2] | 0;
+ if ((i10 + 1 | 0) >>> 0 > i12 >>> 0) {
+ if (i12 >>> 0 > 2147483645) {
+ i4 = 16;
+ break;
+ }
+ i13 = i12 << 1;
+ i10 = HEAP32[i6 >> 2] | 0;
+ if ((i13 | 0) == -2) {
+ i4 = 18;
+ break;
+ }
+ i12 = _luaM_realloc_(i10, HEAP32[i9 >> 2] | 0, i12, i13) | 0;
+ HEAP32[i9 >> 2] = i12;
+ HEAP32[i11 >> 2] = i13;
+ i10 = HEAP32[i8 >> 2] | 0;
+ i9 = i12;
+ } else {
+ i9 = HEAP32[i9 >> 2] | 0;
+ }
+ HEAP32[i8 >> 2] = i10 + 1;
+ HEAP8[i9 + i10 | 0] = 61;
+ i8 = HEAP32[i5 >> 2] | 0;
+ i13 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i13 + -1;
+ if ((i13 | 0) == 0) {
+ i8 = _luaZ_fill(i8) | 0;
+ } else {
+ i13 = i8 + 4 | 0;
+ i8 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i8 + 1;
+ i8 = HEAPU8[i8] | 0;
+ }
+ HEAP32[i3 >> 2] = i8;
+ i7 = i7 + 1 | 0;
+ if ((i8 | 0) != 61) {
+ i4 = 24;
+ break;
+ }
+ }
+ if ((i4 | 0) == 16) {
+ _lexerror(i3, 12368, 0);
+ } else if ((i4 | 0) == 18) {
+ _luaM_toobig(i10);
+ } else if ((i4 | 0) == 24) {
+ i13 = (i8 | 0) != (i2 | 0);
+ i13 = i13 << 31 >> 31;
+ i13 = i13 ^ i7;
+ STACKTOP = i1;
+ return i13 | 0;
+ }
+ return 0;
+}
+function _luaV_arith(i8, i2, i3, i5, i4) {
+ i8 = i8 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i6 = 0, i7 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, d14 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i9 = i1 + 24 | 0;
+ i13 = i1 + 16 | 0;
+ i12 = i1;
+ i6 = i3 + 8 | 0;
+ i11 = HEAP32[i6 >> 2] | 0;
+ if ((i11 | 0) != 3) {
+ if ((i11 & 15 | 0) == 4 ? (i11 = HEAP32[i3 >> 2] | 0, (_luaO_str2d(i11 + 16 | 0, HEAP32[i11 + 12 >> 2] | 0, i13) | 0) != 0) : 0) {
+ HEAPF64[i12 >> 3] = +HEAPF64[i13 >> 3];
+ HEAP32[i12 + 8 >> 2] = 3;
+ i10 = 5;
+ }
+ } else {
+ i12 = i3;
+ i10 = 5;
+ }
+ do {
+ if ((i10 | 0) == 5) {
+ i10 = HEAP32[i5 + 8 >> 2] | 0;
+ if ((i10 | 0) == 3) {
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ d14 = +HEAPF64[i5 >> 3];
+ } else {
+ if ((i10 & 15 | 0) != 4) {
+ break;
+ }
+ i13 = HEAP32[i5 >> 2] | 0;
+ if ((_luaO_str2d(i13 + 16 | 0, HEAP32[i13 + 12 >> 2] | 0, i9) | 0) == 0) {
+ break;
+ }
+ d14 = +HEAPF64[i9 >> 3];
+ }
+ HEAPF64[i2 >> 3] = +_luaO_arith(i4 + -6 | 0, +HEAPF64[i12 >> 3], d14);
+ HEAP32[i2 + 8 >> 2] = 3;
+ STACKTOP = i1;
+ return;
+ }
+ } while (0);
+ i9 = _luaT_gettmbyobj(i8, i3, i4) | 0;
+ if ((HEAP32[i9 + 8 >> 2] | 0) == 0) {
+ i4 = _luaT_gettmbyobj(i8, i5, i4) | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) == 0) {
+ _luaG_aritherror(i8, i3, i5);
+ } else {
+ i7 = i4;
+ }
+ } else {
+ i7 = i9;
+ }
+ i12 = i8 + 28 | 0;
+ i13 = i2 - (HEAP32[i12 >> 2] | 0) | 0;
+ i9 = i8 + 8 | 0;
+ i11 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = i11 + 16;
+ i2 = i7;
+ i10 = HEAP32[i2 + 4 >> 2] | 0;
+ i4 = i11;
+ HEAP32[i4 >> 2] = HEAP32[i2 >> 2];
+ HEAP32[i4 + 4 >> 2] = i10;
+ HEAP32[i11 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ i11 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = i11 + 16;
+ i4 = i3;
+ i10 = HEAP32[i4 + 4 >> 2] | 0;
+ i7 = i11;
+ HEAP32[i7 >> 2] = HEAP32[i4 >> 2];
+ HEAP32[i7 + 4 >> 2] = i10;
+ HEAP32[i11 + 8 >> 2] = HEAP32[i6 >> 2];
+ i11 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = i11 + 16;
+ i6 = i5;
+ i7 = HEAP32[i6 + 4 >> 2] | 0;
+ i10 = i11;
+ HEAP32[i10 >> 2] = HEAP32[i6 >> 2];
+ HEAP32[i10 + 4 >> 2] = i7;
+ HEAP32[i11 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
+ _luaD_call(i8, (HEAP32[i9 >> 2] | 0) + -48 | 0, 1, HEAP8[(HEAP32[i8 + 16 >> 2] | 0) + 18 | 0] & 1);
+ i12 = HEAP32[i12 >> 2] | 0;
+ i11 = HEAP32[i9 >> 2] | 0;
+ i8 = i11 + -16 | 0;
+ HEAP32[i9 >> 2] = i8;
+ i9 = HEAP32[i8 + 4 >> 2] | 0;
+ i10 = i12 + i13 | 0;
+ HEAP32[i10 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i10 + 4 >> 2] = i9;
+ HEAP32[i12 + (i13 + 8) >> 2] = HEAP32[i11 + -8 >> 2];
+ STACKTOP = i1;
+ return;
+}
+function _new_localvar(i1, i8) {
+ i1 = i1 | 0;
+ i8 = i8 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i3;
+ i5 = HEAP32[i1 + 48 >> 2] | 0;
+ i2 = HEAP32[i1 + 64 >> 2] | 0;
+ i7 = HEAP32[i5 >> 2] | 0;
+ i10 = i7 + 60 | 0;
+ i11 = HEAP32[i10 >> 2] | 0;
+ i6 = i5 + 44 | 0;
+ if ((HEAP16[i6 >> 1] | 0) < (i11 | 0)) {
+ i9 = i7 + 24 | 0;
+ i10 = i11;
+ } else {
+ i9 = i7 + 24 | 0;
+ HEAP32[i9 >> 2] = _luaM_growaux_(HEAP32[i1 + 52 >> 2] | 0, HEAP32[i9 >> 2] | 0, i10, 12, 32767, 6496) | 0;
+ i10 = HEAP32[i10 >> 2] | 0;
+ }
+ if ((i11 | 0) < (i10 | 0)) {
+ i12 = i11;
+ while (1) {
+ i11 = i12 + 1 | 0;
+ HEAP32[(HEAP32[i9 >> 2] | 0) + (i12 * 12 | 0) >> 2] = 0;
+ if ((i11 | 0) == (i10 | 0)) {
+ break;
+ } else {
+ i12 = i11;
+ }
+ }
+ }
+ i10 = HEAP16[i6 >> 1] | 0;
+ HEAP32[(HEAP32[i9 >> 2] | 0) + ((i10 << 16 >> 16) * 12 | 0) >> 2] = i8;
+ if (!((HEAP8[i8 + 5 | 0] & 3) == 0) ? !((HEAP8[i7 + 5 | 0] & 4) == 0) : 0) {
+ _luaC_barrier_(HEAP32[i1 + 52 >> 2] | 0, i7, i8);
+ i7 = HEAP16[i6 >> 1] | 0;
+ } else {
+ i7 = i10;
+ }
+ HEAP16[i6 >> 1] = i7 + 1 << 16 >> 16;
+ i6 = i2 + 4 | 0;
+ i8 = HEAP32[i6 >> 2] | 0;
+ if ((i8 + 1 - (HEAP32[i5 + 40 >> 2] | 0) | 0) > 200) {
+ i10 = i5 + 12 | 0;
+ i9 = HEAP32[(HEAP32[i10 >> 2] | 0) + 52 >> 2] | 0;
+ i5 = HEAP32[(HEAP32[i5 >> 2] | 0) + 64 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i11 = 6552;
+ HEAP32[i4 >> 2] = 6496;
+ i12 = i4 + 4 | 0;
+ HEAP32[i12 >> 2] = 200;
+ i12 = i4 + 8 | 0;
+ HEAP32[i12 >> 2] = i11;
+ i12 = _luaO_pushfstring(i9, 6592, i4) | 0;
+ i11 = HEAP32[i10 >> 2] | 0;
+ _luaX_syntaxerror(i11, i12);
+ }
+ HEAP32[i4 >> 2] = i5;
+ i11 = _luaO_pushfstring(i9, 6568, i4) | 0;
+ HEAP32[i4 >> 2] = 6496;
+ i12 = i4 + 4 | 0;
+ HEAP32[i12 >> 2] = 200;
+ i12 = i4 + 8 | 0;
+ HEAP32[i12 >> 2] = i11;
+ i12 = _luaO_pushfstring(i9, 6592, i4) | 0;
+ i11 = HEAP32[i10 >> 2] | 0;
+ _luaX_syntaxerror(i11, i12);
+ }
+ i4 = i2 + 8 | 0;
+ if ((i8 + 2 | 0) > (HEAP32[i4 >> 2] | 0)) {
+ i11 = _luaM_growaux_(HEAP32[i1 + 52 >> 2] | 0, HEAP32[i2 >> 2] | 0, i4, 2, 2147483645, 6496) | 0;
+ HEAP32[i2 >> 2] = i11;
+ i12 = HEAP32[i6 >> 2] | 0;
+ i10 = i12 + 1 | 0;
+ HEAP32[i6 >> 2] = i10;
+ i12 = i11 + (i12 << 1) | 0;
+ HEAP16[i12 >> 1] = i7;
+ STACKTOP = i3;
+ return;
+ } else {
+ i12 = i8;
+ i11 = HEAP32[i2 >> 2] | 0;
+ i10 = i12 + 1 | 0;
+ HEAP32[i6 >> 2] = i10;
+ i12 = i11 + (i12 << 1) | 0;
+ HEAP16[i12 >> 1] = i7;
+ STACKTOP = i3;
+ return;
+ }
+}
+function _luaC_fullgc(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0;
+ i2 = STACKTOP;
+ i4 = i1 + 12 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i6 = i3 + 62 | 0;
+ i8 = HEAP8[i6] | 0;
+ i5 = (i5 | 0) != 0;
+ if (!i5) {
+ HEAP8[i6] = 0;
+ i9 = (HEAP32[i4 >> 2] | 0) + 104 | 0;
+ i10 = HEAP32[i9 >> 2] | 0;
+ if ((i10 | 0) != 0) {
+ do {
+ i11 = i10 + 5 | 0;
+ HEAP8[i11] = HEAP8[i11] & 191;
+ _GCTM(i1, 1);
+ i10 = HEAP32[i9 >> 2] | 0;
+ } while ((i10 | 0) != 0);
+ if ((HEAP8[i6] | 0) == 2) {
+ i9 = 7;
+ } else {
+ i9 = 6;
+ }
+ } else {
+ i9 = 6;
+ }
+ } else {
+ HEAP8[i6] = 1;
+ i9 = 6;
+ }
+ if ((i9 | 0) == 6 ? (HEAPU8[i3 + 61 | 0] | 0) < 2 : 0) {
+ i9 = 7;
+ }
+ if ((i9 | 0) == 7) {
+ i9 = HEAP32[i4 >> 2] | 0;
+ HEAP8[i9 + 61 | 0] = 2;
+ HEAP32[i9 + 64 >> 2] = 0;
+ i10 = i9 + 72 | 0;
+ do {
+ i11 = _sweeplist(i1, i10, 1) | 0;
+ } while ((i11 | 0) == (i10 | 0));
+ HEAP32[i9 + 80 >> 2] = i11;
+ i11 = i9 + 68 | 0;
+ do {
+ i10 = _sweeplist(i1, i11, 1) | 0;
+ } while ((i10 | 0) == (i11 | 0));
+ HEAP32[i9 + 76 >> 2] = i10;
+ }
+ i11 = HEAP32[i4 >> 2] | 0;
+ i9 = i11 + 61 | 0;
+ if ((HEAP8[i9] | 0) == 5) {
+ i9 = 5;
+ } else {
+ do {
+ _singlestep(i1) | 0;
+ } while ((HEAP8[i9] | 0) != 5);
+ i9 = HEAP32[i4 >> 2] | 0;
+ i11 = i9;
+ i9 = HEAP8[i9 + 61 | 0] | 0;
+ }
+ i10 = i11 + 61 | 0;
+ if ((1 << (i9 & 255) & -33 | 0) == 0) {
+ do {
+ _singlestep(i1) | 0;
+ } while ((1 << HEAPU8[i10] & -33 | 0) == 0);
+ i9 = HEAP32[i4 >> 2] | 0;
+ i11 = i9;
+ i9 = HEAP8[i9 + 61 | 0] | 0;
+ }
+ i10 = i11 + 61 | 0;
+ if (!(i9 << 24 >> 24 == 5)) {
+ do {
+ _singlestep(i1) | 0;
+ } while ((HEAP8[i10] | 0) != 5);
+ }
+ if (i8 << 24 >> 24 == 2 ? (i7 = (HEAP32[i4 >> 2] | 0) + 61 | 0, (HEAP8[i7] | 0) != 0) : 0) {
+ do {
+ _singlestep(i1) | 0;
+ } while ((HEAP8[i7] | 0) != 0);
+ }
+ HEAP8[i6] = i8;
+ i6 = HEAP32[i3 + 8 >> 2] | 0;
+ i7 = HEAP32[i3 + 12 >> 2] | 0;
+ i8 = (i7 + i6 | 0) / 100 | 0;
+ i9 = HEAP32[i3 + 156 >> 2] | 0;
+ if ((i9 | 0) < (2147483644 / (i8 | 0) | 0 | 0)) {
+ i8 = Math_imul(i9, i8) | 0;
+ } else {
+ i8 = 2147483644;
+ }
+ _luaE_setdebt(i3, i6 - i8 + i7 | 0);
+ if (i5) {
+ STACKTOP = i2;
+ return;
+ }
+ i3 = (HEAP32[i4 >> 2] | 0) + 104 | 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ do {
+ i11 = i4 + 5 | 0;
+ HEAP8[i11] = HEAP8[i11] & 191;
+ _GCTM(i1, 1);
+ i4 = HEAP32[i3 >> 2] | 0;
+ } while ((i4 | 0) != 0);
+ STACKTOP = i2;
+ return;
+}
+function _scanexp(i3, i6) {
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0;
+ i1 = STACKTOP;
+ i2 = i3 + 4 | 0;
+ i5 = HEAP32[i2 >> 2] | 0;
+ i4 = i3 + 100 | 0;
+ if (i5 >>> 0 < (HEAP32[i4 >> 2] | 0) >>> 0) {
+ HEAP32[i2 >> 2] = i5 + 1;
+ i8 = HEAPU8[i5] | 0;
+ } else {
+ i8 = ___shgetc(i3) | 0;
+ }
+ if ((i8 | 0) == 43 | (i8 | 0) == 45) {
+ i5 = (i8 | 0) == 45 | 0;
+ i7 = HEAP32[i2 >> 2] | 0;
+ if (i7 >>> 0 < (HEAP32[i4 >> 2] | 0) >>> 0) {
+ HEAP32[i2 >> 2] = i7 + 1;
+ i8 = HEAPU8[i7] | 0;
+ } else {
+ i8 = ___shgetc(i3) | 0;
+ }
+ if (!((i8 + -48 | 0) >>> 0 < 10 | (i6 | 0) == 0) ? (HEAP32[i4 >> 2] | 0) != 0 : 0) {
+ HEAP32[i2 >> 2] = (HEAP32[i2 >> 2] | 0) + -1;
+ }
+ } else {
+ i5 = 0;
+ }
+ if ((i8 + -48 | 0) >>> 0 > 9) {
+ if ((HEAP32[i4 >> 2] | 0) == 0) {
+ i7 = -2147483648;
+ i8 = 0;
+ tempRet0 = i7;
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ HEAP32[i2 >> 2] = (HEAP32[i2 >> 2] | 0) + -1;
+ i7 = -2147483648;
+ i8 = 0;
+ tempRet0 = i7;
+ STACKTOP = i1;
+ return i8 | 0;
+ } else {
+ i6 = 0;
+ }
+ while (1) {
+ i6 = i8 + -48 + i6 | 0;
+ i7 = HEAP32[i2 >> 2] | 0;
+ if (i7 >>> 0 < (HEAP32[i4 >> 2] | 0) >>> 0) {
+ HEAP32[i2 >> 2] = i7 + 1;
+ i8 = HEAPU8[i7] | 0;
+ } else {
+ i8 = ___shgetc(i3) | 0;
+ }
+ if (!((i8 + -48 | 0) >>> 0 < 10 & (i6 | 0) < 214748364)) {
+ break;
+ }
+ i6 = i6 * 10 | 0;
+ }
+ i7 = ((i6 | 0) < 0) << 31 >> 31;
+ if ((i8 + -48 | 0) >>> 0 < 10) {
+ do {
+ i7 = ___muldi3(i6 | 0, i7 | 0, 10, 0) | 0;
+ i6 = tempRet0;
+ i8 = _i64Add(i8 | 0, ((i8 | 0) < 0) << 31 >> 31 | 0, -48, -1) | 0;
+ i6 = _i64Add(i8 | 0, tempRet0 | 0, i7 | 0, i6 | 0) | 0;
+ i7 = tempRet0;
+ i8 = HEAP32[i2 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[i4 >> 2] | 0) >>> 0) {
+ HEAP32[i2 >> 2] = i8 + 1;
+ i8 = HEAPU8[i8] | 0;
+ } else {
+ i8 = ___shgetc(i3) | 0;
+ }
+ } while ((i8 + -48 | 0) >>> 0 < 10 & ((i7 | 0) < 21474836 | (i7 | 0) == 21474836 & i6 >>> 0 < 2061584302));
+ }
+ if ((i8 + -48 | 0) >>> 0 < 10) {
+ do {
+ i8 = HEAP32[i2 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[i4 >> 2] | 0) >>> 0) {
+ HEAP32[i2 >> 2] = i8 + 1;
+ i8 = HEAPU8[i8] | 0;
+ } else {
+ i8 = ___shgetc(i3) | 0;
+ }
+ } while ((i8 + -48 | 0) >>> 0 < 10);
+ }
+ if ((HEAP32[i4 >> 2] | 0) != 0) {
+ HEAP32[i2 >> 2] = (HEAP32[i2 >> 2] | 0) + -1;
+ }
+ i3 = (i5 | 0) != 0;
+ i2 = _i64Subtract(0, 0, i6 | 0, i7 | 0) | 0;
+ i4 = i3 ? tempRet0 : i7;
+ i8 = i3 ? i2 : i6;
+ tempRet0 = i4;
+ STACKTOP = i1;
+ return i8 | 0;
+}
+function _sweeplist(i3, i8, i9) {
+ i3 = i3 | 0;
+ i8 = i8 | 0;
+ i9 = i9 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i10 = 0, i11 = 0, i12 = 0;
+ i1 = STACKTOP;
+ i5 = i3 + 12 | 0;
+ i7 = HEAP32[i5 >> 2] | 0;
+ i6 = HEAPU8[i7 + 60 | 0] | 0;
+ i2 = i6 ^ 3;
+ i7 = (HEAP8[i7 + 62 | 0] | 0) == 2;
+ i4 = i7 ? 255 : 184;
+ i6 = i7 ? 64 : i6 & 3;
+ i7 = i7 ? 64 : 0;
+ i10 = HEAP32[i8 >> 2] | 0;
+ L1 : do {
+ if ((i10 | 0) == 0) {
+ i10 = 0;
+ } else {
+ i11 = i9;
+ L2 : while (1) {
+ i9 = i11 + -1 | 0;
+ if ((i11 | 0) == 0) {
+ break L1;
+ }
+ i11 = i10 + 5 | 0;
+ i12 = HEAPU8[i11] | 0;
+ L5 : do {
+ if (((i12 ^ 3) & i2 | 0) == 0) {
+ HEAP32[i8 >> 2] = HEAP32[i10 >> 2];
+ switch (HEAPU8[i10 + 4 | 0] | 0) {
+ case 4:
+ {
+ i12 = (HEAP32[i5 >> 2] | 0) + 28 | 0;
+ HEAP32[i12 >> 2] = (HEAP32[i12 >> 2] | 0) + -1;
+ break;
+ }
+ case 38:
+ {
+ _luaM_realloc_(i3, i10, (HEAPU8[i10 + 6 | 0] << 4) + 16 | 0, 0) | 0;
+ break L5;
+ }
+ case 6:
+ {
+ _luaM_realloc_(i3, i10, (HEAPU8[i10 + 6 | 0] << 2) + 16 | 0, 0) | 0;
+ break L5;
+ }
+ case 20:
+ {
+ break;
+ }
+ case 5:
+ {
+ _luaH_free(i3, i10);
+ break L5;
+ }
+ case 10:
+ {
+ _luaF_freeupval(i3, i10);
+ break L5;
+ }
+ case 8:
+ {
+ _luaE_freethread(i3, i10);
+ break L5;
+ }
+ case 9:
+ {
+ _luaF_freeproto(i3, i10);
+ break L5;
+ }
+ case 7:
+ {
+ _luaM_realloc_(i3, i10, (HEAP32[i10 + 16 >> 2] | 0) + 24 | 0, 0) | 0;
+ break L5;
+ }
+ default:
+ {
+ break L5;
+ }
+ }
+ _luaM_realloc_(i3, i10, (HEAP32[i10 + 12 >> 2] | 0) + 17 | 0, 0) | 0;
+ } else {
+ if ((i12 & i7 | 0) != 0) {
+ i2 = 0;
+ break L2;
+ }
+ if (((HEAP8[i10 + 4 | 0] | 0) == 8 ? (HEAP32[i10 + 28 >> 2] | 0) != 0 : 0) ? (_sweeplist(i3, i10 + 56 | 0, -3) | 0, _luaE_freeCI(i10), (HEAP8[(HEAP32[i5 >> 2] | 0) + 62 | 0] | 0) != 1) : 0) {
+ _luaD_shrinkstack(i10);
+ }
+ HEAP8[i11] = i12 & i4 | i6;
+ i8 = i10;
+ }
+ } while (0);
+ i10 = HEAP32[i8 >> 2] | 0;
+ if ((i10 | 0) == 0) {
+ i10 = 0;
+ break L1;
+ } else {
+ i11 = i9;
+ }
+ }
+ STACKTOP = i1;
+ return i2 | 0;
+ }
+ } while (0);
+ i12 = (i10 | 0) == 0 ? 0 : i8;
+ STACKTOP = i1;
+ return i12 | 0;
+}
+function _resume(i1, i6) {
+ i1 = i1 | 0;
+ i6 = i6 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i2 = STACKTOP;
+ i3 = i1 + 16 | 0;
+ i5 = HEAP32[i3 >> 2] | 0;
+ if ((HEAPU16[i1 + 38 >> 1] | 0) > 199) {
+ _resume_error(i1, 2240, i6);
+ }
+ i4 = i1 + 6 | 0;
+ i7 = HEAP8[i4] | 0;
+ if (i7 << 24 >> 24 == 0) {
+ if ((i5 | 0) != (i1 + 72 | 0)) {
+ _resume_error(i1, 2448, i6);
+ }
+ if ((_luaD_precall(i1, i6 + -16 | 0, -1) | 0) != 0) {
+ STACKTOP = i2;
+ return;
+ }
+ _luaV_execute(i1);
+ STACKTOP = i2;
+ return;
+ } else if (i7 << 24 >> 24 == 1) {
+ HEAP8[i4] = 0;
+ i4 = i1 + 28 | 0;
+ HEAP32[i5 >> 2] = (HEAP32[i4 >> 2] | 0) + (HEAP32[i5 + 20 >> 2] | 0);
+ i8 = i5 + 18 | 0;
+ i7 = HEAP8[i8] | 0;
+ if ((i7 & 1) == 0) {
+ i9 = HEAP32[i5 + 28 >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ HEAP8[i5 + 37 | 0] = 1;
+ HEAP8[i8] = i7 & 255 | 8;
+ i6 = FUNCTION_TABLE_ii[i9 & 255](i1) | 0;
+ i6 = (HEAP32[i1 + 8 >> 2] | 0) + (0 - i6 << 4) | 0;
+ }
+ i5 = HEAP32[i3 >> 2] | 0;
+ i7 = HEAPU8[i1 + 40 | 0] | 0;
+ if ((i7 & 6 | 0) == 0) {
+ i7 = i5 + 8 | 0;
+ } else {
+ if ((i7 & 2 | 0) != 0) {
+ i6 = i6 - (HEAP32[i4 >> 2] | 0) | 0;
+ _luaD_hook(i1, 1, -1);
+ i6 = (HEAP32[i4 >> 2] | 0) + i6 | 0;
+ }
+ i7 = i5 + 8 | 0;
+ HEAP32[i1 + 20 >> 2] = HEAP32[(HEAP32[i7 >> 2] | 0) + 28 >> 2];
+ }
+ i4 = HEAP32[i5 >> 2] | 0;
+ i5 = HEAP16[i5 + 16 >> 1] | 0;
+ HEAP32[i3 >> 2] = HEAP32[i7 >> 2];
+ i3 = i1 + 8 | 0;
+ L27 : do {
+ if (!(i5 << 16 >> 16 == 0)) {
+ i5 = i5 << 16 >> 16;
+ while (1) {
+ if (!(i6 >>> 0 < (HEAP32[i3 >> 2] | 0) >>> 0)) {
+ break;
+ }
+ i7 = i4 + 16 | 0;
+ i10 = i6;
+ i8 = HEAP32[i10 + 4 >> 2] | 0;
+ i9 = i4;
+ HEAP32[i9 >> 2] = HEAP32[i10 >> 2];
+ HEAP32[i9 + 4 >> 2] = i8;
+ HEAP32[i4 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
+ i5 = i5 + -1 | 0;
+ if ((i5 | 0) == 0) {
+ i4 = i7;
+ break L27;
+ }
+ i6 = i6 + 16 | 0;
+ i4 = i7;
+ }
+ if ((i5 | 0) > 0) {
+ i7 = i5;
+ i6 = i4;
+ while (1) {
+ i7 = i7 + -1 | 0;
+ HEAP32[i6 + 8 >> 2] = 0;
+ if ((i7 | 0) <= 0) {
+ break;
+ } else {
+ i6 = i6 + 16 | 0;
+ }
+ }
+ i4 = i4 + (i5 << 4) | 0;
+ }
+ }
+ } while (0);
+ HEAP32[i3 >> 2] = i4;
+ } else {
+ _luaV_execute(i1);
+ }
+ _unroll(i1, 0);
+ STACKTOP = i2;
+ return;
+ } else {
+ _resume_error(i1, 2488, i6);
+ }
+}
+function _lua_setupvalue(i1, i5, i3) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i2 = STACKTOP;
+ i6 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i5 = (HEAP32[i1 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i5 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i5 | 0;
+ i6 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i6 + 8 >> 2] | 0) != 22 ? (i4 = HEAP32[i6 >> 2] | 0, (i5 | 0) <= (HEAPU8[i4 + 6 | 0] | 0 | 0)) : 0) {
+ i5 = i4 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i5 = 5192;
+ }
+ } else {
+ i4 = (HEAP32[i6 >> 2] | 0) + (i5 << 4) | 0;
+ i5 = i4 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i4 : 5192;
+ }
+ } while (0);
+ i4 = HEAP32[i5 + 8 >> 2] & 63;
+ do {
+ if ((i4 | 0) == 6) {
+ i5 = HEAP32[i5 >> 2] | 0;
+ i4 = HEAP32[i5 + 12 >> 2] | 0;
+ if ((i3 | 0) <= 0) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ if ((HEAP32[i4 + 40 >> 2] | 0) < (i3 | 0)) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ i6 = i3 + -1 | 0;
+ i3 = HEAP32[i5 + 16 + (i6 << 2) >> 2] | 0;
+ i5 = HEAP32[i3 + 8 >> 2] | 0;
+ i4 = HEAP32[(HEAP32[i4 + 28 >> 2] | 0) + (i6 << 3) >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ i4 = 936;
+ } else {
+ i4 = i4 + 16 | 0;
+ }
+ } else if ((i4 | 0) == 38) {
+ i6 = HEAP32[i5 >> 2] | 0;
+ if ((i3 | 0) <= 0) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ if ((HEAPU8[i6 + 6 | 0] | 0 | 0) >= (i3 | 0)) {
+ i4 = 936;
+ i5 = i6 + (i3 + -1 << 4) + 16 | 0;
+ i3 = i6;
+ break;
+ } else {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ } else {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ } while (0);
+ i6 = i1 + 8 | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ i10 = i7 + -16 | 0;
+ HEAP32[i6 >> 2] = i10;
+ i9 = HEAP32[i10 + 4 >> 2] | 0;
+ i8 = i5;
+ HEAP32[i8 >> 2] = HEAP32[i10 >> 2];
+ HEAP32[i8 + 4 >> 2] = i9;
+ HEAP32[i5 + 8 >> 2] = HEAP32[i7 + -8 >> 2];
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i5 + 8 >> 2] & 64 | 0) == 0) {
+ i10 = i4;
+ STACKTOP = i2;
+ return i10 | 0;
+ }
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP8[i5 + 5 | 0] & 3) == 0) {
+ i10 = i4;
+ STACKTOP = i2;
+ return i10 | 0;
+ }
+ if ((HEAP8[i3 + 5 | 0] & 4) == 0) {
+ i10 = i4;
+ STACKTOP = i2;
+ return i10 | 0;
+ }
+ _luaC_barrier_(i1, i3, i5);
+ i10 = i4;
+ STACKTOP = i2;
+ return i10 | 0;
+}
+function _luaC_forcestep(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i1 = STACKTOP;
+ i3 = HEAP32[i2 + 12 >> 2] | 0;
+ do {
+ if ((HEAP8[i3 + 62 | 0] | 0) == 2) {
+ i4 = i3 + 20 | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ do {
+ if ((i6 | 0) != 0) {
+ i5 = i3 + 61 | 0;
+ if ((HEAP8[i5] | 0) != 5) {
+ do {
+ _singlestep(i2) | 0;
+ } while ((HEAP8[i5] | 0) != 5);
+ }
+ HEAP8[i5] = 0;
+ i5 = HEAP32[i3 + 8 >> 2] | 0;
+ i7 = HEAP32[i3 + 12 >> 2] | 0;
+ if ((i7 + i5 | 0) >>> 0 > (Math_imul(HEAP32[i3 + 160 >> 2] | 0, (i6 >>> 0) / 100 | 0) | 0) >>> 0) {
+ HEAP32[i4 >> 2] = 0;
+ break;
+ } else {
+ HEAP32[i4 >> 2] = i6;
+ break;
+ }
+ } else {
+ _luaC_fullgc(i2, 0);
+ i5 = HEAP32[i3 + 8 >> 2] | 0;
+ i7 = HEAP32[i3 + 12 >> 2] | 0;
+ HEAP32[i4 >> 2] = i7 + i5;
+ }
+ } while (0);
+ i4 = i5 + i7 | 0;
+ i5 = (i4 | 0) / 100 | 0;
+ i6 = HEAP32[i3 + 156 >> 2] | 0;
+ if ((i6 | 0) < (2147483644 / (i5 | 0) | 0 | 0)) {
+ i5 = Math_imul(i6, i5) | 0;
+ } else {
+ i5 = 2147483644;
+ }
+ _luaE_setdebt(i3, i4 - i5 | 0);
+ i5 = i3 + 61 | 0;
+ } else {
+ i4 = i3 + 12 | 0;
+ i5 = HEAP32[i3 + 164 >> 2] | 0;
+ i7 = (i5 | 0) < 40 ? 40 : i5;
+ i5 = ((HEAP32[i4 >> 2] | 0) / 200 | 0) + 1 | 0;
+ if ((i5 | 0) < (2147483644 / (i7 | 0) | 0 | 0)) {
+ i8 = Math_imul(i5, i7) | 0;
+ } else {
+ i8 = 2147483644;
+ }
+ i5 = i3 + 61 | 0;
+ do {
+ i8 = i8 - (_singlestep(i2) | 0) | 0;
+ i9 = (HEAP8[i5] | 0) == 5;
+ if (!((i8 | 0) > -1600)) {
+ i6 = 17;
+ break;
+ }
+ } while (!i9);
+ if ((i6 | 0) == 17 ? !i9 : 0) {
+ _luaE_setdebt(i3, ((i8 | 0) / (i7 | 0) | 0) * 200 | 0);
+ break;
+ }
+ i6 = (HEAP32[i3 + 20 >> 2] | 0) / 100 | 0;
+ i7 = HEAP32[i3 + 156 >> 2] | 0;
+ if ((i7 | 0) < (2147483644 / (i6 | 0) | 0 | 0)) {
+ i6 = Math_imul(i7, i6) | 0;
+ } else {
+ i6 = 2147483644;
+ }
+ _luaE_setdebt(i3, (HEAP32[i3 + 8 >> 2] | 0) - i6 + (HEAP32[i4 >> 2] | 0) | 0);
+ }
+ } while (0);
+ i3 = i3 + 104 | 0;
+ if ((HEAP32[i3 >> 2] | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ } else {
+ i4 = 0;
+ }
+ while (1) {
+ if ((i4 | 0) >= 4 ? (HEAP8[i5] | 0) != 5 : 0) {
+ i6 = 26;
+ break;
+ }
+ _GCTM(i2, 1);
+ if ((HEAP32[i3 >> 2] | 0) == 0) {
+ i6 = 26;
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ }
+ }
+ if ((i6 | 0) == 26) {
+ STACKTOP = i1;
+ return;
+ }
+}
+function _luaL_loadfilex(i1, i9, i7) {
+ i1 = i1 | 0;
+ i9 = i9 | 0;
+ i7 = i7 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i10 = 0, i11 = 0;
+ i5 = STACKTOP;
+ STACKTOP = STACKTOP + 1056 | 0;
+ i3 = i5;
+ i6 = i5 + 16 | 0;
+ i8 = i5 + 12 | 0;
+ i2 = (_lua_gettop(i1) | 0) + 1 | 0;
+ i4 = (i9 | 0) == 0;
+ if (!i4) {
+ HEAP32[i3 >> 2] = i9;
+ _lua_pushfstring(i1, 1304, i3) | 0;
+ i10 = _fopen(i9 | 0, 1312) | 0;
+ HEAP32[i6 + 4 >> 2] = i10;
+ if ((i10 | 0) == 0) {
+ i10 = _strerror(HEAP32[(___errno_location() | 0) >> 2] | 0) | 0;
+ i9 = (_lua_tolstring(i1, i2, 0) | 0) + 1 | 0;
+ HEAP32[i3 >> 2] = 1320;
+ HEAP32[i3 + 4 >> 2] = i9;
+ HEAP32[i3 + 8 >> 2] = i10;
+ _lua_pushfstring(i1, 1720, i3) | 0;
+ _lua_remove(i1, i2);
+ i10 = 7;
+ STACKTOP = i5;
+ return i10 | 0;
+ }
+ } else {
+ _lua_pushlstring(i1, 1296, 6) | 0;
+ HEAP32[i6 + 4 >> 2] = HEAP32[_stdin >> 2];
+ }
+ if ((_skipcomment(i6, i8) | 0) != 0) {
+ i10 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i10 + 1;
+ HEAP8[i6 + i10 + 8 | 0] = 10;
+ }
+ i10 = HEAP32[i8 >> 2] | 0;
+ do {
+ if (!((i10 | 0) != 27 | i4)) {
+ i11 = i6 + 4 | 0;
+ i10 = _freopen(i9 | 0, 1328, HEAP32[i11 >> 2] | 0) | 0;
+ HEAP32[i11 >> 2] = i10;
+ if ((i10 | 0) != 0) {
+ _skipcomment(i6, i8) | 0;
+ i10 = HEAP32[i8 >> 2] | 0;
+ break;
+ }
+ i11 = _strerror(HEAP32[(___errno_location() | 0) >> 2] | 0) | 0;
+ i10 = (_lua_tolstring(i1, i2, 0) | 0) + 1 | 0;
+ HEAP32[i3 >> 2] = 1336;
+ HEAP32[i3 + 4 >> 2] = i10;
+ HEAP32[i3 + 8 >> 2] = i11;
+ _lua_pushfstring(i1, 1720, i3) | 0;
+ _lua_remove(i1, i2);
+ i11 = 7;
+ STACKTOP = i5;
+ return i11 | 0;
+ }
+ } while (0);
+ if (!((i10 | 0) == -1)) {
+ i11 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i11 + 1;
+ HEAP8[i6 + i11 + 8 | 0] = i10;
+ }
+ i7 = _lua_load(i1, 1, i6, _lua_tolstring(i1, -1, 0) | 0, i7) | 0;
+ i8 = HEAP32[i6 + 4 >> 2] | 0;
+ i6 = _ferror(i8 | 0) | 0;
+ if (!i4) {
+ _fclose(i8 | 0) | 0;
+ }
+ if ((i6 | 0) == 0) {
+ _lua_remove(i1, i2);
+ i11 = i7;
+ STACKTOP = i5;
+ return i11 | 0;
+ } else {
+ _lua_settop(i1, i2);
+ i11 = _strerror(HEAP32[(___errno_location() | 0) >> 2] | 0) | 0;
+ i10 = (_lua_tolstring(i1, i2, 0) | 0) + 1 | 0;
+ HEAP32[i3 >> 2] = 1344;
+ HEAP32[i3 + 4 >> 2] = i10;
+ HEAP32[i3 + 8 >> 2] = i11;
+ _lua_pushfstring(i1, 1720, i3) | 0;
+ _lua_remove(i1, i2);
+ i11 = 7;
+ STACKTOP = i5;
+ return i11 | 0;
+ }
+ return 0;
+}
+function _newupvalue(i3, i1, i2) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i12 = i4;
+ i5 = HEAP32[i3 >> 2] | 0;
+ i9 = i5 + 40 | 0;
+ i7 = HEAP32[i9 >> 2] | 0;
+ i6 = i3 + 47 | 0;
+ i10 = HEAPU8[i6] | 0;
+ if ((i10 + 1 | 0) >>> 0 > 255) {
+ i11 = i3 + 12 | 0;
+ i8 = HEAP32[(HEAP32[i11 >> 2] | 0) + 52 >> 2] | 0;
+ i13 = HEAP32[i5 + 64 >> 2] | 0;
+ if ((i13 | 0) == 0) {
+ i15 = 6552;
+ HEAP32[i12 >> 2] = 6880;
+ i14 = i12 + 4 | 0;
+ HEAP32[i14 >> 2] = 255;
+ i14 = i12 + 8 | 0;
+ HEAP32[i14 >> 2] = i15;
+ i14 = _luaO_pushfstring(i8, 6592, i12) | 0;
+ i15 = HEAP32[i11 >> 2] | 0;
+ _luaX_syntaxerror(i15, i14);
+ }
+ HEAP32[i12 >> 2] = i13;
+ i14 = _luaO_pushfstring(i8, 6568, i12) | 0;
+ HEAP32[i12 >> 2] = 6880;
+ i15 = i12 + 4 | 0;
+ HEAP32[i15 >> 2] = 255;
+ i15 = i12 + 8 | 0;
+ HEAP32[i15 >> 2] = i14;
+ i15 = _luaO_pushfstring(i8, 6592, i12) | 0;
+ i14 = HEAP32[i11 >> 2] | 0;
+ _luaX_syntaxerror(i14, i15);
+ }
+ if ((i10 | 0) < (i7 | 0)) {
+ i8 = i7;
+ } else {
+ i8 = i5 + 28 | 0;
+ HEAP32[i8 >> 2] = _luaM_growaux_(HEAP32[(HEAP32[i3 + 12 >> 2] | 0) + 52 >> 2] | 0, HEAP32[i8 >> 2] | 0, i9, 8, 255, 6880) | 0;
+ i8 = HEAP32[i9 >> 2] | 0;
+ }
+ i9 = i5 + 28 | 0;
+ if ((i7 | 0) < (i8 | 0)) {
+ while (1) {
+ i10 = i7 + 1 | 0;
+ HEAP32[(HEAP32[i9 >> 2] | 0) + (i7 << 3) >> 2] = 0;
+ if ((i10 | 0) < (i8 | 0)) {
+ i7 = i10;
+ } else {
+ break;
+ }
+ }
+ }
+ HEAP8[(HEAP32[i9 >> 2] | 0) + ((HEAPU8[i6] | 0) << 3) + 4 | 0] = (HEAP32[i2 >> 2] | 0) == 7 | 0;
+ HEAP8[(HEAP32[i9 >> 2] | 0) + ((HEAPU8[i6] | 0) << 3) + 5 | 0] = HEAP32[i2 + 8 >> 2];
+ HEAP32[(HEAP32[i9 >> 2] | 0) + ((HEAPU8[i6] | 0) << 3) >> 2] = i1;
+ if ((HEAP8[i1 + 5 | 0] & 3) == 0) {
+ i15 = HEAP8[i6] | 0;
+ i14 = i15 + 1 << 24 >> 24;
+ HEAP8[i6] = i14;
+ i15 = i15 & 255;
+ STACKTOP = i4;
+ return i15 | 0;
+ }
+ if ((HEAP8[i5 + 5 | 0] & 4) == 0) {
+ i15 = HEAP8[i6] | 0;
+ i14 = i15 + 1 << 24 >> 24;
+ HEAP8[i6] = i14;
+ i15 = i15 & 255;
+ STACKTOP = i4;
+ return i15 | 0;
+ }
+ _luaC_barrier_(HEAP32[(HEAP32[i3 + 12 >> 2] | 0) + 52 >> 2] | 0, i5, i1);
+ i15 = HEAP8[i6] | 0;
+ i14 = i15 + 1 << 24 >> 24;
+ HEAP8[i6] = i14;
+ i15 = i15 & 255;
+ STACKTOP = i4;
+ return i15 | 0;
+}
+function _close_func(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i6 = STACKTOP;
+ i2 = HEAP32[i1 + 52 >> 2] | 0;
+ i5 = i1 + 48 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ _luaK_ret(i4, 0, 0);
+ _leaveblock(i4);
+ i7 = i4 + 20 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if ((i8 + 1 | 0) >>> 0 > 1073741823) {
+ _luaM_toobig(i2);
+ }
+ i10 = i3 + 12 | 0;
+ i9 = i3 + 48 | 0;
+ HEAP32[i10 >> 2] = _luaM_realloc_(i2, HEAP32[i10 >> 2] | 0, HEAP32[i9 >> 2] << 2, i8 << 2) | 0;
+ HEAP32[i9 >> 2] = HEAP32[i7 >> 2];
+ i8 = HEAP32[i7 >> 2] | 0;
+ if ((i8 + 1 | 0) >>> 0 > 1073741823) {
+ _luaM_toobig(i2);
+ }
+ i9 = i3 + 20 | 0;
+ i10 = i3 + 52 | 0;
+ HEAP32[i9 >> 2] = _luaM_realloc_(i2, HEAP32[i9 >> 2] | 0, HEAP32[i10 >> 2] << 2, i8 << 2) | 0;
+ HEAP32[i10 >> 2] = HEAP32[i7 >> 2];
+ i8 = i4 + 32 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 + 1 | 0) >>> 0 > 268435455) {
+ _luaM_toobig(i2);
+ }
+ i9 = i3 + 8 | 0;
+ i10 = i3 + 44 | 0;
+ HEAP32[i9 >> 2] = _luaM_realloc_(i2, HEAP32[i9 >> 2] | 0, HEAP32[i10 >> 2] << 4, i7 << 4) | 0;
+ HEAP32[i10 >> 2] = HEAP32[i8 >> 2];
+ i8 = i4 + 36 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 + 1 | 0) >>> 0 > 1073741823) {
+ _luaM_toobig(i2);
+ }
+ i9 = i3 + 16 | 0;
+ i10 = i3 + 56 | 0;
+ HEAP32[i9 >> 2] = _luaM_realloc_(i2, HEAP32[i9 >> 2] | 0, HEAP32[i10 >> 2] << 2, i7 << 2) | 0;
+ HEAP32[i10 >> 2] = HEAP32[i8 >> 2];
+ i7 = i4 + 44 | 0;
+ i8 = HEAP16[i7 >> 1] | 0;
+ if ((i8 + 1 | 0) >>> 0 > 357913941) {
+ _luaM_toobig(i2);
+ }
+ i10 = i3 + 24 | 0;
+ i9 = i3 + 60 | 0;
+ HEAP32[i10 >> 2] = _luaM_realloc_(i2, HEAP32[i10 >> 2] | 0, (HEAP32[i9 >> 2] | 0) * 12 | 0, i8 * 12 | 0) | 0;
+ HEAP32[i9 >> 2] = HEAP16[i7 >> 1] | 0;
+ i9 = i4 + 47 | 0;
+ i8 = i3 + 28 | 0;
+ i10 = i3 + 40 | 0;
+ HEAP32[i8 >> 2] = _luaM_realloc_(i2, HEAP32[i8 >> 2] | 0, HEAP32[i10 >> 2] << 3, HEAPU8[i9] << 3) | 0;
+ HEAP32[i10 >> 2] = HEAPU8[i9] | 0;
+ HEAP32[i5 >> 2] = HEAP32[i4 + 8 >> 2];
+ if (((HEAP32[i1 + 16 >> 2] | 0) + -288 | 0) >>> 0 < 2) {
+ i10 = HEAP32[i1 + 24 >> 2] | 0;
+ _luaX_newstring(i1, i10 + 16 | 0, HEAP32[i10 + 12 >> 2] | 0) | 0;
+ }
+ i10 = i2 + 8 | 0;
+ HEAP32[i10 >> 2] = (HEAP32[i10 >> 2] | 0) + -16;
+ if ((HEAP32[(HEAP32[i2 + 12 >> 2] | 0) + 12 >> 2] | 0) <= 0) {
+ STACKTOP = i6;
+ return;
+ }
+ _luaC_step(i2);
+ STACKTOP = i6;
+ return;
+}
+function _lua_topointer(i3, i6) {
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i1 = STACKTOP;
+ i4 = HEAP32[i3 + 16 >> 2] | 0;
+ i5 = (i6 | 0) > 0;
+ do {
+ if (!i5) {
+ if (!((i6 | 0) < -1000999)) {
+ i7 = (HEAP32[i3 + 8 >> 2] | 0) + (i6 << 4) | 0;
+ break;
+ }
+ if ((i6 | 0) == -1001e3) {
+ i7 = (HEAP32[i3 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i8 = -1001e3 - i6 | 0;
+ i9 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i9 + 8 >> 2] | 0) != 22 ? (i7 = HEAP32[i9 >> 2] | 0, (i8 | 0) <= (HEAPU8[i7 + 6 | 0] | 0 | 0)) : 0) {
+ i7 = i7 + (i8 + -1 << 4) + 16 | 0;
+ } else {
+ i7 = 5192;
+ }
+ } else {
+ i7 = (HEAP32[i4 >> 2] | 0) + (i6 << 4) | 0;
+ i7 = i7 >>> 0 < (HEAP32[i3 + 8 >> 2] | 0) >>> 0 ? i7 : 5192;
+ }
+ } while (0);
+ switch (HEAP32[i7 + 8 >> 2] & 63 | 0) {
+ case 22:
+ {
+ i9 = HEAP32[i7 >> 2] | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ case 2:
+ case 7:
+ {
+ do {
+ if (!i5) {
+ if (!((i6 | 0) < -1000999)) {
+ i2 = (HEAP32[i3 + 8 >> 2] | 0) + (i6 << 4) | 0;
+ break;
+ }
+ if ((i6 | 0) == -1001e3) {
+ i2 = (HEAP32[i3 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i3 = -1001e3 - i6 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i2 = HEAP32[i4 >> 2] | 0, (i3 | 0) <= (HEAPU8[i2 + 6 | 0] | 0 | 0)) : 0) {
+ i2 = i2 + (i3 + -1 << 4) + 16 | 0;
+ } else {
+ i2 = 5192;
+ }
+ } else {
+ i2 = (HEAP32[i4 >> 2] | 0) + (i6 << 4) | 0;
+ i2 = i2 >>> 0 < (HEAP32[i3 + 8 >> 2] | 0) >>> 0 ? i2 : 5192;
+ }
+ } while (0);
+ i3 = HEAP32[i2 + 8 >> 2] & 15;
+ if ((i3 | 0) == 7) {
+ i9 = (HEAP32[i2 >> 2] | 0) + 24 | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ } else if ((i3 | 0) == 2) {
+ i9 = HEAP32[i2 >> 2] | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ } else {
+ i9 = 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ }
+ case 8:
+ {
+ i9 = HEAP32[i7 >> 2] | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ case 5:
+ {
+ i9 = HEAP32[i7 >> 2] | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ case 38:
+ {
+ i9 = HEAP32[i7 >> 2] | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ case 6:
+ {
+ i9 = HEAP32[i7 >> 2] | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ default:
+ {
+ i9 = 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ }
+ }
+ return 0;
+}
+function _luaH_get(i4, i6) {
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, d5 = 0.0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, d11 = 0.0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i8 = i3 + 8 | 0;
+ i9 = i3;
+ i7 = i6 + 8 | 0;
+ i10 = HEAP32[i7 >> 2] & 63;
+ if ((i10 | 0) == 4) {
+ i6 = HEAP32[i6 >> 2] | 0;
+ i7 = (HEAP32[i4 + 16 >> 2] | 0) + (((1 << (HEAPU8[i4 + 7 | 0] | 0)) + -1 & HEAP32[i6 + 8 >> 2]) << 5) | 0;
+ while (1) {
+ if ((HEAP32[i7 + 24 >> 2] | 0) == 68 ? (HEAP32[i7 + 16 >> 2] | 0) == (i6 | 0) : 0) {
+ break;
+ }
+ i4 = HEAP32[i7 + 28 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ i2 = 5192;
+ i1 = 22;
+ break;
+ } else {
+ i7 = i4;
+ }
+ }
+ if ((i1 | 0) == 22) {
+ STACKTOP = i3;
+ return i2 | 0;
+ }
+ i10 = i7;
+ STACKTOP = i3;
+ return i10 | 0;
+ } else if ((i10 | 0) == 3) {
+ d11 = +HEAPF64[i6 >> 3];
+ HEAPF64[i9 >> 3] = d11 + 6755399441055744.0;
+ i9 = HEAP32[i9 >> 2] | 0;
+ d5 = +(i9 | 0);
+ if (d5 == d11) {
+ i6 = i9 + -1 | 0;
+ if (i6 >>> 0 < (HEAP32[i4 + 28 >> 2] | 0) >>> 0) {
+ i10 = (HEAP32[i4 + 12 >> 2] | 0) + (i6 << 4) | 0;
+ STACKTOP = i3;
+ return i10 | 0;
+ }
+ HEAPF64[i8 >> 3] = d5 + 1.0;
+ i6 = (HEAP32[i8 + 4 >> 2] | 0) + (HEAP32[i8 >> 2] | 0) | 0;
+ if ((i6 | 0) < 0) {
+ i7 = 0 - i6 | 0;
+ i6 = (i6 | 0) == (i7 | 0) ? 0 : i7;
+ }
+ i4 = (HEAP32[i4 + 16 >> 2] | 0) + (((i6 | 0) % ((1 << (HEAPU8[i4 + 7 | 0] | 0)) + -1 | 1 | 0) | 0) << 5) | 0;
+ while (1) {
+ if ((HEAP32[i4 + 24 >> 2] | 0) == 3 ? +HEAPF64[i4 + 16 >> 3] == d5 : 0) {
+ break;
+ }
+ i6 = HEAP32[i4 + 28 >> 2] | 0;
+ if ((i6 | 0) == 0) {
+ i2 = 5192;
+ i1 = 22;
+ break;
+ } else {
+ i4 = i6;
+ }
+ }
+ if ((i1 | 0) == 22) {
+ STACKTOP = i3;
+ return i2 | 0;
+ }
+ i10 = i4;
+ STACKTOP = i3;
+ return i10 | 0;
+ }
+ } else if ((i10 | 0) == 0) {
+ i10 = 5192;
+ STACKTOP = i3;
+ return i10 | 0;
+ }
+ i8 = _mainposition(i4, i6) | 0;
+ while (1) {
+ if ((HEAP32[i8 + 24 >> 2] | 0) == (HEAP32[i7 >> 2] | 0) ? (_luaV_equalobj_(0, i8 + 16 | 0, i6) | 0) != 0 : 0) {
+ break;
+ }
+ i4 = HEAP32[i8 + 28 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ i2 = 5192;
+ i1 = 22;
+ break;
+ } else {
+ i8 = i4;
+ }
+ }
+ if ((i1 | 0) == 22) {
+ STACKTOP = i3;
+ return i2 | 0;
+ }
+ i10 = i8;
+ STACKTOP = i3;
+ return i10 | 0;
+}
+function _suffixedexp(i1, i8) {
+ i1 = i1 | 0;
+ i8 = i8 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 80 | 0;
+ i10 = i2 + 48 | 0;
+ i3 = i2 + 24 | 0;
+ i6 = i2;
+ i4 = i1 + 48 | 0;
+ i9 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[i1 + 4 >> 2] | 0;
+ i7 = i1 + 16 | 0;
+ i12 = HEAP32[i7 >> 2] | 0;
+ if ((i12 | 0) == 40) {
+ _luaX_next(i1);
+ _subexpr(i1, i8, 0) | 0;
+ _check_match(i1, 41, 40, i5);
+ _luaK_dischargevars(HEAP32[i4 >> 2] | 0, i8);
+ i11 = i1 + 24 | 0;
+ } else if ((i12 | 0) == 288) {
+ i11 = i1 + 24 | 0;
+ i13 = HEAP32[i11 >> 2] | 0;
+ _luaX_next(i1);
+ i12 = HEAP32[i4 >> 2] | 0;
+ if ((_singlevaraux(i12, i13, i8, 1) | 0) == 0) {
+ _singlevaraux(i12, HEAP32[i1 + 72 >> 2] | 0, i8, 1) | 0;
+ i13 = _luaK_stringK(HEAP32[i4 >> 2] | 0, i13) | 0;
+ HEAP32[i10 + 16 >> 2] = -1;
+ HEAP32[i10 + 20 >> 2] = -1;
+ HEAP32[i10 >> 2] = 4;
+ HEAP32[i10 + 8 >> 2] = i13;
+ _luaK_indexed(i12, i8, i10);
+ }
+ } else {
+ _luaX_syntaxerror(i1, 6656);
+ }
+ i10 = i6 + 16 | 0;
+ i12 = i6 + 20 | 0;
+ i13 = i6 + 8 | 0;
+ L7 : while (1) {
+ switch (HEAP32[i7 >> 2] | 0) {
+ case 46:
+ {
+ _fieldsel(i1, i8);
+ continue L7;
+ }
+ case 91:
+ {
+ _luaK_exp2anyregup(i9, i8);
+ _luaX_next(i1);
+ _subexpr(i1, i3, 0) | 0;
+ _luaK_exp2val(HEAP32[i4 >> 2] | 0, i3);
+ if ((HEAP32[i7 >> 2] | 0) != 93) {
+ i3 = 10;
+ break L7;
+ }
+ _luaX_next(i1);
+ _luaK_indexed(i9, i8, i3);
+ continue L7;
+ }
+ case 58:
+ {
+ _luaX_next(i1);
+ if ((HEAP32[i7 >> 2] | 0) != 288) {
+ i3 = 13;
+ break L7;
+ }
+ i14 = HEAP32[i11 >> 2] | 0;
+ _luaX_next(i1);
+ i14 = _luaK_stringK(HEAP32[i4 >> 2] | 0, i14) | 0;
+ HEAP32[i10 >> 2] = -1;
+ HEAP32[i12 >> 2] = -1;
+ HEAP32[i6 >> 2] = 4;
+ HEAP32[i13 >> 2] = i14;
+ _luaK_self(i9, i8, i6);
+ _funcargs(i1, i8, i5);
+ continue L7;
+ }
+ case 123:
+ case 289:
+ case 40:
+ {
+ _luaK_exp2nextreg(i9, i8);
+ _funcargs(i1, i8, i5);
+ continue L7;
+ }
+ default:
+ {
+ i3 = 16;
+ break L7;
+ }
+ }
+ }
+ if ((i3 | 0) == 10) {
+ _error_expected(i1, 93);
+ } else if ((i3 | 0) == 13) {
+ _error_expected(i1, 288);
+ } else if ((i3 | 0) == 16) {
+ STACKTOP = i2;
+ return;
+ }
+}
+function _luaK_patchlist(i2, i7, i3) {
+ i2 = i2 | 0;
+ i7 = i7 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0;
+ i1 = STACKTOP;
+ if ((HEAP32[i2 + 20 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i2 + 24 >> 2] = i3;
+ i3 = i2 + 28 | 0;
+ if ((i7 | 0) == -1) {
+ STACKTOP = i1;
+ return;
+ }
+ i6 = HEAP32[i3 >> 2] | 0;
+ if ((i6 | 0) == -1) {
+ HEAP32[i3 >> 2] = i7;
+ STACKTOP = i1;
+ return;
+ }
+ i5 = HEAP32[(HEAP32[i2 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i3 = i5 + (i6 << 2) | 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ i8 = (i4 >>> 14) + -131071 | 0;
+ if ((i8 | 0) == -1) {
+ break;
+ }
+ i8 = i6 + 1 + i8 | 0;
+ if ((i8 | 0) == -1) {
+ break;
+ } else {
+ i6 = i8;
+ }
+ }
+ i5 = ~i6 + i7 | 0;
+ if ((((i5 | 0) > -1 ? i5 : 0 - i5 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i2 + 12 >> 2] | 0, 10624);
+ }
+ HEAP32[i3 >> 2] = (i5 << 14) + 2147467264 | i4 & 16383;
+ STACKTOP = i1;
+ return;
+ }
+ if ((i7 | 0) == -1) {
+ STACKTOP = i1;
+ return;
+ }
+ i6 = HEAP32[(HEAP32[i2 >> 2] | 0) + 12 >> 2] | 0;
+ i10 = i7;
+ while (1) {
+ i7 = i6 + (i10 << 2) | 0;
+ i9 = HEAP32[i7 >> 2] | 0;
+ i8 = (i9 >>> 14) + -131071 | 0;
+ if ((i8 | 0) == -1) {
+ i8 = -1;
+ } else {
+ i8 = i10 + 1 + i8 | 0;
+ }
+ if ((i10 | 0) > 0 ? (i4 = i6 + (i10 + -1 << 2) | 0, i5 = HEAP32[i4 >> 2] | 0, (HEAP8[5584 + (i5 & 63) | 0] | 0) < 0) : 0) {
+ i12 = i4;
+ i11 = i5;
+ } else {
+ i12 = i7;
+ i11 = i9;
+ }
+ if ((i11 & 63 | 0) == 28) {
+ HEAP32[i12 >> 2] = i11 & 8372224 | i11 >>> 23 << 6 | 27;
+ i9 = ~i10 + i3 | 0;
+ if ((((i9 | 0) > -1 ? i9 : 0 - i9 | 0) | 0) > 131071) {
+ i3 = 20;
+ break;
+ }
+ i9 = HEAP32[i7 >> 2] & 16383 | (i9 << 14) + 2147467264;
+ } else {
+ i10 = ~i10 + i3 | 0;
+ if ((((i10 | 0) > -1 ? i10 : 0 - i10 | 0) | 0) > 131071) {
+ i3 = 23;
+ break;
+ }
+ i9 = i9 & 16383 | (i10 << 14) + 2147467264;
+ }
+ HEAP32[i7 >> 2] = i9;
+ if ((i8 | 0) == -1) {
+ i3 = 26;
+ break;
+ } else {
+ i10 = i8;
+ }
+ }
+ if ((i3 | 0) == 20) {
+ _luaX_syntaxerror(HEAP32[i2 + 12 >> 2] | 0, 10624);
+ } else if ((i3 | 0) == 23) {
+ _luaX_syntaxerror(HEAP32[i2 + 12 >> 2] | 0, 10624);
+ } else if ((i3 | 0) == 26) {
+ STACKTOP = i1;
+ return;
+ }
+}
+function _luaG_typeerror(i5, i6, i1) {
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i3 = i2;
+ i2 = i2 + 16 | 0;
+ i8 = HEAP32[i5 + 16 >> 2] | 0;
+ HEAP32[i2 >> 2] = 0;
+ i4 = HEAP32[8528 + ((HEAP32[i6 + 8 >> 2] & 15) + 1 << 2) >> 2] | 0;
+ L1 : do {
+ if (!((HEAP8[i8 + 18 | 0] & 1) == 0)) {
+ i7 = HEAP32[HEAP32[i8 >> 2] >> 2] | 0;
+ i10 = HEAP8[i7 + 6 | 0] | 0;
+ L3 : do {
+ if (!(i10 << 24 >> 24 == 0)) {
+ i9 = i7 + 16 | 0;
+ i11 = i10 & 255;
+ i10 = 0;
+ while (1) {
+ i12 = i10 + 1 | 0;
+ if ((HEAP32[(HEAP32[i9 + (i10 << 2) >> 2] | 0) + 8 >> 2] | 0) == (i6 | 0)) {
+ break;
+ }
+ if ((i12 | 0) < (i11 | 0)) {
+ i10 = i12;
+ } else {
+ break L3;
+ }
+ }
+ i9 = HEAP32[(HEAP32[(HEAP32[i7 + 12 >> 2] | 0) + 28 >> 2] | 0) + (i10 << 3) >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ i9 = 2104;
+ } else {
+ i9 = i9 + 16 | 0;
+ }
+ HEAP32[i2 >> 2] = i9;
+ i11 = i9;
+ i10 = 2072;
+ HEAP32[i3 >> 2] = i1;
+ i12 = i3 + 4 | 0;
+ HEAP32[i12 >> 2] = i10;
+ i12 = i3 + 8 | 0;
+ HEAP32[i12 >> 2] = i11;
+ i12 = i3 + 12 | 0;
+ HEAP32[i12 >> 2] = i4;
+ _luaG_runerror(i5, 1840, i3);
+ }
+ } while (0);
+ i9 = HEAP32[i8 + 24 >> 2] | 0;
+ i10 = HEAP32[i8 + 4 >> 2] | 0;
+ if (i9 >>> 0 < i10 >>> 0) {
+ i12 = i9;
+ while (1) {
+ i11 = i12 + 16 | 0;
+ if ((i12 | 0) == (i6 | 0)) {
+ break;
+ }
+ if (i11 >>> 0 < i10 >>> 0) {
+ i12 = i11;
+ } else {
+ break L1;
+ }
+ }
+ i12 = HEAP32[i7 + 12 >> 2] | 0;
+ i6 = _getobjname(i12, ((HEAP32[i8 + 28 >> 2] | 0) - (HEAP32[i12 + 12 >> 2] | 0) >> 2) + -1 | 0, i6 - i9 >> 4, i2) | 0;
+ if ((i6 | 0) != 0) {
+ i11 = HEAP32[i2 >> 2] | 0;
+ i10 = i6;
+ HEAP32[i3 >> 2] = i1;
+ i12 = i3 + 4 | 0;
+ HEAP32[i12 >> 2] = i10;
+ i12 = i3 + 8 | 0;
+ HEAP32[i12 >> 2] = i11;
+ i12 = i3 + 12 | 0;
+ HEAP32[i12 >> 2] = i4;
+ _luaG_runerror(i5, 1840, i3);
+ }
+ }
+ }
+ } while (0);
+ HEAP32[i3 >> 2] = i1;
+ HEAP32[i3 + 4 >> 2] = i4;
+ _luaG_runerror(i5, 1880, i3);
+}
+function _lua_setmetatable(i1, i7) {
+ i1 = i1 | 0;
+ i7 = i7 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0;
+ i4 = STACKTOP;
+ i6 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i7 | 0) <= 0) {
+ if (!((i7 | 0) < -1000999)) {
+ i5 = (HEAP32[i1 + 8 >> 2] | 0) + (i7 << 4) | 0;
+ break;
+ }
+ if ((i7 | 0) == -1001e3) {
+ i5 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i7 = -1001e3 - i7 | 0;
+ i6 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i6 + 8 >> 2] | 0) != 22 ? (i5 = HEAP32[i6 >> 2] | 0, (i7 | 0) <= (HEAPU8[i5 + 6 | 0] | 0 | 0)) : 0) {
+ i5 = i5 + (i7 + -1 << 4) + 16 | 0;
+ } else {
+ i5 = 5192;
+ }
+ } else {
+ i5 = (HEAP32[i6 >> 2] | 0) + (i7 << 4) | 0;
+ i5 = i5 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i5 : 5192;
+ }
+ } while (0);
+ i6 = i1 + 8 | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i7 + -8 >> 2] | 0) == 0) {
+ i7 = 0;
+ } else {
+ i7 = HEAP32[i7 + -16 >> 2] | 0;
+ }
+ i8 = HEAP32[i5 + 8 >> 2] & 15;
+ if ((i8 | 0) == 5) {
+ HEAP32[(HEAP32[i5 >> 2] | 0) + 8 >> 2] = i7;
+ if ((i7 | 0) == 0) {
+ i8 = HEAP32[i6 >> 2] | 0;
+ i8 = i8 + -16 | 0;
+ HEAP32[i6 >> 2] = i8;
+ STACKTOP = i4;
+ return 1;
+ }
+ if (!((HEAP8[i7 + 5 | 0] & 3) == 0) ? (i2 = HEAP32[i5 >> 2] | 0, !((HEAP8[i2 + 5 | 0] & 4) == 0)) : 0) {
+ _luaC_barrierback_(i1, i2);
+ }
+ _luaC_checkfinalizer(i1, HEAP32[i5 >> 2] | 0, i7);
+ i8 = HEAP32[i6 >> 2] | 0;
+ i8 = i8 + -16 | 0;
+ HEAP32[i6 >> 2] = i8;
+ STACKTOP = i4;
+ return 1;
+ } else if ((i8 | 0) == 7) {
+ HEAP32[(HEAP32[i5 >> 2] | 0) + 8 >> 2] = i7;
+ if ((i7 | 0) == 0) {
+ i8 = HEAP32[i6 >> 2] | 0;
+ i8 = i8 + -16 | 0;
+ HEAP32[i6 >> 2] = i8;
+ STACKTOP = i4;
+ return 1;
+ }
+ if (!((HEAP8[i7 + 5 | 0] & 3) == 0) ? (i3 = HEAP32[i5 >> 2] | 0, !((HEAP8[i3 + 5 | 0] & 4) == 0)) : 0) {
+ _luaC_barrier_(i1, i3, i7);
+ }
+ _luaC_checkfinalizer(i1, HEAP32[i5 >> 2] | 0, i7);
+ i8 = HEAP32[i6 >> 2] | 0;
+ i8 = i8 + -16 | 0;
+ HEAP32[i6 >> 2] = i8;
+ STACKTOP = i4;
+ return 1;
+ } else {
+ HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + (i8 << 2) + 252 >> 2] = i7;
+ i8 = HEAP32[i6 >> 2] | 0;
+ i8 = i8 + -16 | 0;
+ HEAP32[i6 >> 2] = i8;
+ STACKTOP = i4;
+ return 1;
+ }
+ return 0;
+}
+function _recfield(i2, i10) {
+ i2 = i2 | 0;
+ i10 = i10 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i9 = i1 + 48 | 0;
+ i6 = i1 + 24 | 0;
+ i3 = i1;
+ i13 = i2 + 48 | 0;
+ i8 = HEAP32[i13 >> 2] | 0;
+ i5 = i8 + 48 | 0;
+ i4 = HEAP8[i5] | 0;
+ i7 = i2 + 16 | 0;
+ do {
+ if ((HEAP32[i7 >> 2] | 0) != 288) {
+ _luaX_next(i2);
+ _subexpr(i2, i6, 0) | 0;
+ _luaK_exp2val(HEAP32[i13 >> 2] | 0, i6);
+ if ((HEAP32[i7 >> 2] | 0) == 93) {
+ _luaX_next(i2);
+ i11 = i10 + 28 | 0;
+ break;
+ } else {
+ _error_expected(i2, 93);
+ }
+ } else {
+ i12 = i10 + 28 | 0;
+ if ((HEAP32[i12 >> 2] | 0) <= 2147483645) {
+ i11 = HEAP32[i2 + 24 >> 2] | 0;
+ _luaX_next(i2);
+ i11 = _luaK_stringK(HEAP32[i13 >> 2] | 0, i11) | 0;
+ HEAP32[i6 + 16 >> 2] = -1;
+ HEAP32[i6 + 20 >> 2] = -1;
+ HEAP32[i6 >> 2] = 4;
+ HEAP32[i6 + 8 >> 2] = i11;
+ i11 = i12;
+ break;
+ }
+ i14 = i8 + 12 | 0;
+ i13 = HEAP32[(HEAP32[i14 >> 2] | 0) + 52 >> 2] | 0;
+ i12 = HEAP32[(HEAP32[i8 >> 2] | 0) + 64 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i16 = 6552;
+ HEAP32[i9 >> 2] = 6528;
+ i15 = i9 + 4 | 0;
+ HEAP32[i15 >> 2] = 2147483645;
+ i15 = i9 + 8 | 0;
+ HEAP32[i15 >> 2] = i16;
+ i15 = _luaO_pushfstring(i13, 6592, i9) | 0;
+ i16 = HEAP32[i14 >> 2] | 0;
+ _luaX_syntaxerror(i16, i15);
+ }
+ HEAP32[i9 >> 2] = i12;
+ i15 = _luaO_pushfstring(i13, 6568, i9) | 0;
+ HEAP32[i9 >> 2] = 6528;
+ i16 = i9 + 4 | 0;
+ HEAP32[i16 >> 2] = 2147483645;
+ i16 = i9 + 8 | 0;
+ HEAP32[i16 >> 2] = i15;
+ i16 = _luaO_pushfstring(i13, 6592, i9) | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ _luaX_syntaxerror(i15, i16);
+ }
+ } while (0);
+ HEAP32[i11 >> 2] = (HEAP32[i11 >> 2] | 0) + 1;
+ if ((HEAP32[i7 >> 2] | 0) == 61) {
+ _luaX_next(i2);
+ i16 = _luaK_exp2RK(i8, i6) | 0;
+ _subexpr(i2, i3, 0) | 0;
+ i15 = HEAP32[(HEAP32[i10 + 24 >> 2] | 0) + 8 >> 2] | 0;
+ _luaK_codeABC(i8, 10, i15, i16, _luaK_exp2RK(i8, i3) | 0) | 0;
+ HEAP8[i5] = i4;
+ STACKTOP = i1;
+ return;
+ } else {
+ _error_expected(i2, 61);
+ }
+}
+function _lua_newstate(i3, i6) {
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i7 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i5 = i1 + 8 | 0;
+ i4 = i1;
+ i2 = FUNCTION_TABLE_iiiii[i3 & 3](i6, 0, 8, 400) | 0;
+ if ((i2 | 0) == 0) {
+ i6 = 0;
+ STACKTOP = i1;
+ return i6 | 0;
+ }
+ i7 = i2 + 112 | 0;
+ HEAP32[i2 >> 2] = 0;
+ HEAP8[i2 + 4 | 0] = 8;
+ HEAP8[i2 + 172 | 0] = 33;
+ HEAP8[i2 + 5 | 0] = 1;
+ HEAP8[i2 + 174 | 0] = 0;
+ HEAP32[i2 + 12 >> 2] = i7;
+ HEAP32[i2 + 28 >> 2] = 0;
+ HEAP32[i2 + 16 >> 2] = 0;
+ HEAP32[i2 + 32 >> 2] = 0;
+ HEAP32[i2 + 64 >> 2] = 0;
+ HEAP16[i2 + 38 >> 1] = 0;
+ HEAP32[i2 + 52 >> 2] = 0;
+ HEAP8[i2 + 40 | 0] = 0;
+ HEAP32[i2 + 44 >> 2] = 0;
+ HEAP8[i2 + 41 | 0] = 1;
+ HEAP32[i2 + 48 >> 2] = 0;
+ HEAP32[i2 + 56 >> 2] = 0;
+ HEAP16[i2 + 36 >> 1] = 1;
+ HEAP8[i2 + 6 | 0] = 0;
+ HEAP32[i2 + 68 >> 2] = 0;
+ HEAP32[i7 >> 2] = i3;
+ HEAP32[i2 + 116 >> 2] = i6;
+ HEAP32[i2 + 284 >> 2] = i2;
+ i3 = _time(0) | 0;
+ HEAP32[i4 >> 2] = i3;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i5 + 4 >> 2] = i4;
+ HEAP32[i5 + 8 >> 2] = 5192;
+ HEAP32[i5 + 12 >> 2] = 1;
+ HEAP32[i2 + 168 >> 2] = _luaS_hash(i5, 16, i3) | 0;
+ i4 = i2 + 224 | 0;
+ HEAP32[i2 + 240 >> 2] = i4;
+ HEAP32[i2 + 244 >> 2] = i4;
+ HEAP8[i2 + 175 | 0] = 0;
+ i4 = i2 + 132 | 0;
+ HEAP32[i2 + 160 >> 2] = 0;
+ HEAP32[i2 + 256 >> 2] = 0;
+ HEAP32[i2 + 264 >> 2] = 0;
+ HEAP32[i2 + 280 >> 2] = 0;
+ HEAP32[i4 + 0 >> 2] = 0;
+ HEAP32[i4 + 4 >> 2] = 0;
+ HEAP32[i4 + 8 >> 2] = 0;
+ HEAP32[i4 + 12 >> 2] = 0;
+ HEAP32[i2 + 288 >> 2] = _lua_version(0) | 0;
+ HEAP8[i2 + 173 | 0] = 5;
+ i4 = i2 + 120 | 0;
+ i5 = i2 + 180 | 0;
+ i3 = i5 + 40 | 0;
+ do {
+ HEAP32[i5 >> 2] = 0;
+ i5 = i5 + 4 | 0;
+ } while ((i5 | 0) < (i3 | 0));
+ HEAP32[i4 >> 2] = 400;
+ HEAP32[i2 + 124 >> 2] = 0;
+ HEAP32[i2 + 268 >> 2] = 200;
+ HEAP32[i2 + 272 >> 2] = 200;
+ HEAP32[i2 + 276 >> 2] = 200;
+ i5 = i2 + 364 | 0;
+ i3 = i5 + 36 | 0;
+ do {
+ HEAP32[i5 >> 2] = 0;
+ i5 = i5 + 4 | 0;
+ } while ((i5 | 0) < (i3 | 0));
+ if ((_luaD_rawrunprotected(i2, 8, 0) | 0) == 0) {
+ i7 = i2;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ _close_state(i2);
+ i7 = 0;
+ STACKTOP = i1;
+ return i7 | 0;
+}
+function _luaU_undump(i1, i7, i8, i9) {
+ i1 = i1 | 0;
+ i7 = i7 | 0;
+ i8 = i8 | 0;
+ i9 = i9 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i4 = i2 + 16 | 0;
+ i5 = i2 + 34 | 0;
+ i3 = i2;
+ i6 = HEAP8[i9] | 0;
+ if (i6 << 24 >> 24 == 27) {
+ HEAP32[i3 + 12 >> 2] = 8800;
+ } else if (i6 << 24 >> 24 == 61 | i6 << 24 >> 24 == 64) {
+ HEAP32[i3 + 12 >> 2] = i9 + 1;
+ } else {
+ HEAP32[i3 + 12 >> 2] = i9;
+ }
+ HEAP32[i3 >> 2] = i1;
+ HEAP32[i3 + 4 >> 2] = i7;
+ HEAP32[i3 + 8 >> 2] = i8;
+ HEAP32[i4 >> 2] = 1635077147;
+ HEAP8[i4 + 4 | 0] = 82;
+ HEAP8[i4 + 5 | 0] = 0;
+ HEAP8[i4 + 6 | 0] = 1;
+ HEAP8[i4 + 7 | 0] = 4;
+ HEAP8[i4 + 8 | 0] = 4;
+ HEAP8[i4 + 9 | 0] = 4;
+ HEAP8[i4 + 10 | 0] = 8;
+ i9 = i4 + 12 | 0;
+ HEAP8[i4 + 11 | 0] = 0;
+ HEAP8[i9 + 0 | 0] = HEAP8[8816 | 0] | 0;
+ HEAP8[i9 + 1 | 0] = HEAP8[8817 | 0] | 0;
+ HEAP8[i9 + 2 | 0] = HEAP8[8818 | 0] | 0;
+ HEAP8[i9 + 3 | 0] = HEAP8[8819 | 0] | 0;
+ HEAP8[i9 + 4 | 0] = HEAP8[8820 | 0] | 0;
+ HEAP8[i9 + 5 | 0] = HEAP8[8821 | 0] | 0;
+ HEAP8[i5] = 27;
+ if ((_luaZ_read(i7, i5 + 1 | 0, 17) | 0) != 0) {
+ _error(i3, 8824);
+ }
+ if ((_memcmp(i4, i5, 18) | 0) == 0) {
+ i4 = _luaF_newLclosure(i1, 1) | 0;
+ i5 = i1 + 8 | 0;
+ i9 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i9 >> 2] = i4;
+ HEAP32[i9 + 8 >> 2] = 70;
+ i9 = (HEAP32[i5 >> 2] | 0) + 16 | 0;
+ HEAP32[i5 >> 2] = i9;
+ if (((HEAP32[i1 + 24 >> 2] | 0) - i9 | 0) < 16) {
+ _luaD_growstack(i1, 0);
+ }
+ i9 = _luaF_newproto(i1) | 0;
+ i6 = i4 + 12 | 0;
+ HEAP32[i6 >> 2] = i9;
+ _LoadFunction(i3, i9);
+ i6 = HEAP32[i6 >> 2] | 0;
+ i3 = HEAP32[i6 + 40 >> 2] | 0;
+ if ((i3 | 0) == 1) {
+ i9 = i4;
+ STACKTOP = i2;
+ return i9 | 0;
+ }
+ i9 = _luaF_newLclosure(i1, i3) | 0;
+ HEAP32[i9 + 12 >> 2] = i6;
+ i8 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i8 + -16 >> 2] = i9;
+ HEAP32[i8 + -8 >> 2] = 70;
+ STACKTOP = i2;
+ return i9 | 0;
+ }
+ if ((_memcmp(i4, i5, 4) | 0) != 0) {
+ _error(i3, 8888);
+ }
+ if ((_memcmp(i4, i5, 6) | 0) != 0) {
+ _error(i3, 8896);
+ }
+ if ((_memcmp(i4, i5, 12) | 0) == 0) {
+ _error(i3, 8872);
+ } else {
+ _error(i3, 8920);
+ }
+ return 0;
+}
+function _lua_compare(i2, i7, i5, i3) {
+ i2 = i2 | 0;
+ i7 = i7 | 0;
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i4 = 0, i6 = 0, i8 = 0;
+ i1 = STACKTOP;
+ i4 = HEAP32[i2 + 16 >> 2] | 0;
+ do {
+ if ((i7 | 0) <= 0) {
+ if (!((i7 | 0) < -1000999)) {
+ i6 = (HEAP32[i2 + 8 >> 2] | 0) + (i7 << 4) | 0;
+ break;
+ }
+ if ((i7 | 0) == -1001e3) {
+ i6 = (HEAP32[i2 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i7 = -1001e3 - i7 | 0;
+ i8 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i8 + 8 >> 2] | 0) != 22 ? (i6 = HEAP32[i8 >> 2] | 0, (i7 | 0) <= (HEAPU8[i6 + 6 | 0] | 0 | 0)) : 0) {
+ i6 = i6 + (i7 + -1 << 4) + 16 | 0;
+ } else {
+ i6 = 5192;
+ }
+ } else {
+ i6 = (HEAP32[i4 >> 2] | 0) + (i7 << 4) | 0;
+ i6 = i6 >>> 0 < (HEAP32[i2 + 8 >> 2] | 0) >>> 0 ? i6 : 5192;
+ }
+ } while (0);
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i4 = (HEAP32[i2 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i4 = (HEAP32[i2 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) == 22) {
+ i8 = 0;
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((i5 | 0) > (HEAPU8[i4 + 6 | 0] | 0 | 0)) {
+ i8 = 0;
+ STACKTOP = i1;
+ return i8 | 0;
+ } else {
+ i4 = i4 + (i5 + -1 << 4) + 16 | 0;
+ break;
+ }
+ } else {
+ i4 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i4 = i4 >>> 0 < (HEAP32[i2 + 8 >> 2] | 0) >>> 0 ? i4 : 5192;
+ }
+ } while (0);
+ if ((i6 | 0) == 5192 | (i4 | 0) == 5192) {
+ i8 = 0;
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ if ((i3 | 0) == 1) {
+ i8 = _luaV_lessthan(i2, i6, i4) | 0;
+ STACKTOP = i1;
+ return i8 | 0;
+ } else if ((i3 | 0) == 2) {
+ i8 = _luaV_lessequal(i2, i6, i4) | 0;
+ STACKTOP = i1;
+ return i8 | 0;
+ } else if ((i3 | 0) == 0) {
+ if ((HEAP32[i6 + 8 >> 2] | 0) == (HEAP32[i4 + 8 >> 2] | 0)) {
+ i2 = (_luaV_equalobj_(i2, i6, i4) | 0) != 0;
+ } else {
+ i2 = 0;
+ }
+ i8 = i2 & 1;
+ STACKTOP = i1;
+ return i8 | 0;
+ } else {
+ i8 = 0;
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ return 0;
+}
+function _lexerror(i7, i3, i8) {
+ i7 = i7 | 0;
+ i3 = i3 | 0;
+ i8 = i8 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i6 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i12 = STACKTOP;
+ STACKTOP = STACKTOP + 80 | 0;
+ i2 = i12;
+ i12 = i12 + 12 | 0;
+ _luaO_chunkid(i12, (HEAP32[i7 + 68 >> 2] | 0) + 16 | 0, 60);
+ i1 = i7 + 52 | 0;
+ i4 = HEAP32[i1 >> 2] | 0;
+ i13 = HEAP32[i7 + 4 >> 2] | 0;
+ HEAP32[i2 >> 2] = i12;
+ HEAP32[i2 + 4 >> 2] = i13;
+ HEAP32[i2 + 8 >> 2] = i3;
+ i4 = _luaO_pushfstring(i4, 12592, i2) | 0;
+ if ((i8 | 0) == 0) {
+ i13 = HEAP32[i1 >> 2] | 0;
+ _luaD_throw(i13, 3);
+ }
+ i3 = HEAP32[i1 >> 2] | 0;
+ do {
+ if (!((i8 + -287 | 0) >>> 0 < 3)) {
+ if ((i8 | 0) >= 257) {
+ i5 = HEAP32[12096 + (i8 + -257 << 2) >> 2] | 0;
+ if ((i8 | 0) >= 286) {
+ break;
+ }
+ HEAP32[i2 >> 2] = i5;
+ i5 = _luaO_pushfstring(i3, 12256, i2) | 0;
+ break;
+ }
+ if ((HEAP8[i8 + 10913 | 0] & 4) == 0) {
+ HEAP32[i2 >> 2] = i8;
+ i5 = _luaO_pushfstring(i3, 12240, i2) | 0;
+ break;
+ } else {
+ HEAP32[i2 >> 2] = i8;
+ i5 = _luaO_pushfstring(i3, 12232, i2) | 0;
+ break;
+ }
+ } else {
+ i11 = i7 + 60 | 0;
+ i12 = HEAP32[i11 >> 2] | 0;
+ i10 = i12 + 4 | 0;
+ i13 = HEAP32[i10 >> 2] | 0;
+ i8 = i12 + 8 | 0;
+ i9 = HEAP32[i8 >> 2] | 0;
+ do {
+ if ((i13 + 1 | 0) >>> 0 > i9 >>> 0) {
+ if (i9 >>> 0 > 2147483645) {
+ _lexerror(i7, 12368, 0);
+ }
+ i7 = i9 << 1;
+ if ((i7 | 0) == -2) {
+ _luaM_toobig(i3);
+ } else {
+ i6 = _luaM_realloc_(i3, HEAP32[i12 >> 2] | 0, i9, i7) | 0;
+ HEAP32[i12 >> 2] = i6;
+ HEAP32[i8 >> 2] = i7;
+ i5 = HEAP32[i10 >> 2] | 0;
+ break;
+ }
+ } else {
+ i5 = i13;
+ i6 = HEAP32[i12 >> 2] | 0;
+ }
+ } while (0);
+ HEAP32[i10 >> 2] = i5 + 1;
+ HEAP8[i6 + i5 | 0] = 0;
+ i5 = HEAP32[i1 >> 2] | 0;
+ HEAP32[i2 >> 2] = HEAP32[HEAP32[i11 >> 2] >> 2];
+ i5 = _luaO_pushfstring(i5, 12256, i2) | 0;
+ }
+ } while (0);
+ HEAP32[i2 >> 2] = i4;
+ HEAP32[i2 + 4 >> 2] = i5;
+ _luaO_pushfstring(i3, 12608, i2) | 0;
+ i13 = HEAP32[i1 >> 2] | 0;
+ _luaD_throw(i13, 3);
+}
+function _luaV_objlen(i2, i5, i1) {
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ var i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0;
+ i3 = STACKTOP;
+ i4 = i1 + 8 | 0;
+ i8 = HEAP32[i4 >> 2] & 15;
+ do {
+ if ((i8 | 0) == 5) {
+ i7 = HEAP32[i1 >> 2] | 0;
+ i8 = HEAP32[i7 + 8 >> 2] | 0;
+ if (((i8 | 0) != 0 ? (HEAP8[i8 + 6 | 0] & 16) == 0 : 0) ? (i6 = _luaT_gettm(i8, 4, HEAP32[(HEAP32[i2 + 12 >> 2] | 0) + 200 >> 2] | 0) | 0, (i6 | 0) != 0) : 0) {
+ i7 = i6;
+ break;
+ }
+ HEAPF64[i5 >> 3] = +(_luaH_getn(i7) | 0);
+ HEAP32[i5 + 8 >> 2] = 3;
+ STACKTOP = i3;
+ return;
+ } else if ((i8 | 0) != 4) {
+ i6 = _luaT_gettmbyobj(i2, i1, 4) | 0;
+ if ((HEAP32[i6 + 8 >> 2] | 0) == 0) {
+ _luaG_typeerror(i2, i1, 9024);
+ } else {
+ i7 = i6;
+ }
+ } else {
+ HEAPF64[i5 >> 3] = +((HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0) >>> 0);
+ HEAP32[i5 + 8 >> 2] = 3;
+ STACKTOP = i3;
+ return;
+ }
+ } while (0);
+ i6 = i2 + 28 | 0;
+ i8 = i5 - (HEAP32[i6 >> 2] | 0) | 0;
+ i5 = i2 + 8 | 0;
+ i11 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i11 + 16;
+ i12 = i7;
+ i10 = HEAP32[i12 + 4 >> 2] | 0;
+ i9 = i11;
+ HEAP32[i9 >> 2] = HEAP32[i12 >> 2];
+ HEAP32[i9 + 4 >> 2] = i10;
+ HEAP32[i11 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ i7 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i7 + 16;
+ i11 = i1;
+ i9 = HEAP32[i11 + 4 >> 2] | 0;
+ i10 = i7;
+ HEAP32[i10 >> 2] = HEAP32[i11 >> 2];
+ HEAP32[i10 + 4 >> 2] = i9;
+ HEAP32[i7 + 8 >> 2] = HEAP32[i4 >> 2];
+ i7 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i7 + 16;
+ i10 = i1;
+ i9 = HEAP32[i10 + 4 >> 2] | 0;
+ i1 = i7;
+ HEAP32[i1 >> 2] = HEAP32[i10 >> 2];
+ HEAP32[i1 + 4 >> 2] = i9;
+ HEAP32[i7 + 8 >> 2] = HEAP32[i4 >> 2];
+ _luaD_call(i2, (HEAP32[i5 >> 2] | 0) + -48 | 0, 1, HEAP8[(HEAP32[i2 + 16 >> 2] | 0) + 18 | 0] & 1);
+ i7 = HEAP32[i6 >> 2] | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ i2 = i6 + -16 | 0;
+ HEAP32[i5 >> 2] = i2;
+ i4 = HEAP32[i2 + 4 >> 2] | 0;
+ i5 = i7 + i8 | 0;
+ HEAP32[i5 >> 2] = HEAP32[i2 >> 2];
+ HEAP32[i5 + 4 >> 2] = i4;
+ HEAP32[i7 + (i8 + 8) >> 2] = HEAP32[i6 + -8 >> 2];
+ STACKTOP = i3;
+ return;
+}
+function _get_equalTM(i6, i5, i4) {
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i7 = 0;
+ i1 = STACKTOP;
+ L1 : do {
+ if (((i5 | 0) != 0 ? (HEAP8[i5 + 6 | 0] & 32) == 0 : 0) ? (i7 = i6 + 12 | 0, i2 = _luaT_gettm(i5, 5, HEAP32[(HEAP32[i7 >> 2] | 0) + 204 >> 2] | 0) | 0, (i2 | 0) != 0) : 0) {
+ if ((i5 | 0) != (i4 | 0)) {
+ if (((i4 | 0) != 0 ? (HEAP8[i4 + 6 | 0] & 32) == 0 : 0) ? (i3 = _luaT_gettm(i4, 5, HEAP32[(HEAP32[i7 >> 2] | 0) + 204 >> 2] | 0) | 0, (i3 | 0) != 0) : 0) {
+ i4 = HEAP32[i2 + 8 >> 2] | 0;
+ L9 : do {
+ if ((i4 | 0) == (HEAP32[i3 + 8 >> 2] | 0)) {
+ switch (i4 & 63 | 0) {
+ case 3:
+ {
+ i3 = +HEAPF64[i2 >> 3] == +HEAPF64[i3 >> 3] | 0;
+ break;
+ }
+ case 22:
+ {
+ i3 = (HEAP32[i2 >> 2] | 0) == (HEAP32[i3 >> 2] | 0) | 0;
+ break;
+ }
+ case 5:
+ {
+ if ((HEAP32[i2 >> 2] | 0) == (HEAP32[i3 >> 2] | 0)) {
+ break L1;
+ } else {
+ break L9;
+ }
+ }
+ case 1:
+ {
+ i3 = (HEAP32[i2 >> 2] | 0) == (HEAP32[i3 >> 2] | 0) | 0;
+ break;
+ }
+ case 4:
+ {
+ i3 = (HEAP32[i2 >> 2] | 0) == (HEAP32[i3 >> 2] | 0) | 0;
+ break;
+ }
+ case 0:
+ {
+ break L1;
+ }
+ case 7:
+ {
+ if ((HEAP32[i2 >> 2] | 0) == (HEAP32[i3 >> 2] | 0)) {
+ break L1;
+ } else {
+ break L9;
+ }
+ }
+ case 2:
+ {
+ i3 = (HEAP32[i2 >> 2] | 0) == (HEAP32[i3 >> 2] | 0) | 0;
+ break;
+ }
+ case 20:
+ {
+ i3 = _luaS_eqlngstr(HEAP32[i2 >> 2] | 0, HEAP32[i3 >> 2] | 0) | 0;
+ break;
+ }
+ default:
+ {
+ i3 = (HEAP32[i2 >> 2] | 0) == (HEAP32[i3 >> 2] | 0) | 0;
+ }
+ }
+ if ((i3 | 0) != 0) {
+ break L1;
+ }
+ }
+ } while (0);
+ i2 = 0;
+ } else {
+ i2 = 0;
+ }
+ }
+ } else {
+ i2 = 0;
+ }
+ } while (0);
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _luaS_newlstr(i2, i4, i3) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0;
+ i1 = STACKTOP;
+ if (!(i3 >>> 0 < 41)) {
+ if ((i3 + 1 | 0) >>> 0 > 4294967277) {
+ _luaM_toobig(i2);
+ }
+ i10 = HEAP32[(HEAP32[i2 + 12 >> 2] | 0) + 56 >> 2] | 0;
+ i11 = _luaC_newobj(i2, 20, i3 + 17 | 0, 0, 0) | 0;
+ HEAP32[i11 + 12 >> 2] = i3;
+ HEAP32[i11 + 8 >> 2] = i10;
+ HEAP8[i11 + 6 | 0] = 0;
+ i10 = i11 + 16 | 0;
+ _memcpy(i10 | 0, i4 | 0, i3 | 0) | 0;
+ HEAP8[i10 + i3 | 0] = 0;
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ i5 = HEAP32[i2 + 12 >> 2] | 0;
+ i6 = HEAP32[i5 + 56 >> 2] ^ i3;
+ i7 = (i3 >>> 5) + 1 | 0;
+ if (!(i7 >>> 0 > i3 >>> 0)) {
+ i8 = i3;
+ do {
+ i6 = (i6 << 5) + (i6 >>> 2) + (HEAPU8[i4 + (i8 + -1) | 0] | 0) ^ i6;
+ i8 = i8 - i7 | 0;
+ } while (!(i8 >>> 0 < i7 >>> 0));
+ }
+ i10 = i5 + 32 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ i7 = i5 + 24 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ i11 = HEAP32[i8 + ((i9 + -1 & i6) << 2) >> 2] | 0;
+ L12 : do {
+ if ((i11 | 0) != 0) {
+ while (1) {
+ if (((i6 | 0) == (HEAP32[i11 + 8 >> 2] | 0) ? (HEAP32[i11 + 12 >> 2] | 0) == (i3 | 0) : 0) ? (_memcmp(i4, i11 + 16 | 0, i3) | 0) == 0 : 0) {
+ break;
+ }
+ i11 = HEAP32[i11 >> 2] | 0;
+ if ((i11 | 0) == 0) {
+ break L12;
+ }
+ }
+ i2 = i11 + 5 | 0;
+ i3 = (HEAPU8[i2] | 0) ^ 3;
+ if ((((HEAPU8[i5 + 60 | 0] | 0) ^ 3) & i3 | 0) != 0) {
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ HEAP8[i2] = i3;
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ } while (0);
+ i5 = i5 + 28 | 0;
+ if ((HEAP32[i5 >> 2] | 0) >>> 0 >= i9 >>> 0 & (i9 | 0) < 1073741823) {
+ _luaS_resize(i2, i9 << 1);
+ i9 = HEAP32[i10 >> 2] | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ }
+ i11 = _luaC_newobj(i2, 4, i3 + 17 | 0, i8 + ((i9 + -1 & i6) << 2) | 0, 0) | 0;
+ HEAP32[i11 + 12 >> 2] = i3;
+ HEAP32[i11 + 8 >> 2] = i6;
+ HEAP8[i11 + 6 | 0] = 0;
+ i10 = i11 + 16 | 0;
+ _memcpy(i10 | 0, i4 | 0, i3 | 0) | 0;
+ HEAP8[i10 + i3 | 0] = 0;
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + 1;
+ STACKTOP = i1;
+ return i11 | 0;
+}
+function _lua_pcallk(i3, i7, i2, i9, i6, i5) {
+ i3 = i3 | 0;
+ i7 = i7 | 0;
+ i2 = i2 | 0;
+ i9 = i9 | 0;
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i4 = 0, i8 = 0, i10 = 0, i11 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i1;
+ if ((i9 | 0) == 0) {
+ i9 = 0;
+ } else {
+ i10 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i9 | 0) <= 0) {
+ if (!((i9 | 0) < -1000999)) {
+ i8 = (HEAP32[i3 + 8 >> 2] | 0) + (i9 << 4) | 0;
+ break;
+ }
+ if ((i9 | 0) == -1001e3) {
+ i8 = (HEAP32[i3 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i9 = -1001e3 - i9 | 0;
+ i10 = HEAP32[i10 >> 2] | 0;
+ if ((HEAP32[i10 + 8 >> 2] | 0) != 22 ? (i8 = HEAP32[i10 >> 2] | 0, (i9 | 0) <= (HEAPU8[i8 + 6 | 0] | 0)) : 0) {
+ i8 = i8 + (i9 + -1 << 4) + 16 | 0;
+ } else {
+ i8 = 5192;
+ }
+ } else {
+ i8 = (HEAP32[i10 >> 2] | 0) + (i9 << 4) | 0;
+ i8 = i8 >>> 0 < (HEAP32[i3 + 8 >> 2] | 0) >>> 0 ? i8 : 5192;
+ }
+ } while (0);
+ i9 = i8 - (HEAP32[i3 + 28 >> 2] | 0) | 0;
+ }
+ i8 = i3 + 8 | 0;
+ i7 = (HEAP32[i8 >> 2] | 0) + (~i7 << 4) | 0;
+ HEAP32[i4 >> 2] = i7;
+ if ((i5 | 0) != 0 ? (HEAP16[i3 + 36 >> 1] | 0) == 0 : 0) {
+ i11 = HEAP32[i3 + 16 >> 2] | 0;
+ HEAP32[i11 + 28 >> 2] = i5;
+ HEAP32[i11 + 24 >> 2] = i6;
+ HEAP32[i11 + 20 >> 2] = (HEAP32[i4 >> 2] | 0) - (HEAP32[i3 + 28 >> 2] | 0);
+ HEAP8[i11 + 36 | 0] = HEAP8[i3 + 41 | 0] | 0;
+ i10 = i3 + 68 | 0;
+ i7 = i11 + 32 | 0;
+ HEAP32[i7 >> 2] = HEAP32[i10 >> 2];
+ HEAP32[i10 >> 2] = i9;
+ i9 = i11 + 18 | 0;
+ HEAP8[i9] = HEAPU8[i9] | 16;
+ _luaD_call(i3, HEAP32[i4 >> 2] | 0, i2, 1);
+ HEAP8[i9] = HEAP8[i9] & 239;
+ HEAP32[i10 >> 2] = HEAP32[i7 >> 2];
+ i4 = 0;
+ } else {
+ HEAP32[i4 + 4 >> 2] = i2;
+ i4 = _luaD_pcall(i3, 3, i4, i7 - (HEAP32[i3 + 28 >> 2] | 0) | 0, i9) | 0;
+ }
+ if (!((i2 | 0) == -1)) {
+ STACKTOP = i1;
+ return i4 | 0;
+ }
+ i2 = (HEAP32[i3 + 16 >> 2] | 0) + 4 | 0;
+ i3 = HEAP32[i8 >> 2] | 0;
+ if (!((HEAP32[i2 >> 2] | 0) >>> 0 < i3 >>> 0)) {
+ STACKTOP = i1;
+ return i4 | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ STACKTOP = i1;
+ return i4 | 0;
+}
+function _lua_getupvalue(i1, i6, i3) {
+ i1 = i1 | 0;
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ i5 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i6 | 0) <= 0) {
+ if (!((i6 | 0) < -1000999)) {
+ i4 = (HEAP32[i1 + 8 >> 2] | 0) + (i6 << 4) | 0;
+ break;
+ }
+ if ((i6 | 0) == -1001e3) {
+ i4 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i6 = -1001e3 - i6 | 0;
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i5 + 8 >> 2] | 0) != 22 ? (i4 = HEAP32[i5 >> 2] | 0, (i6 | 0) <= (HEAPU8[i4 + 6 | 0] | 0 | 0)) : 0) {
+ i4 = i4 + (i6 + -1 << 4) + 16 | 0;
+ } else {
+ i4 = 5192;
+ }
+ } else {
+ i4 = (HEAP32[i5 >> 2] | 0) + (i6 << 4) | 0;
+ i4 = i4 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i4 : 5192;
+ }
+ } while (0);
+ i5 = HEAP32[i4 + 8 >> 2] & 63;
+ do {
+ if ((i5 | 0) == 38) {
+ i5 = HEAP32[i4 >> 2] | 0;
+ if ((i3 | 0) <= 0) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ if ((HEAPU8[i5 + 6 | 0] | 0 | 0) < (i3 | 0)) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ } else {
+ i4 = 936;
+ i3 = i5 + (i3 + -1 << 4) + 16 | 0;
+ break;
+ }
+ } else if ((i5 | 0) == 6) {
+ i5 = HEAP32[i4 >> 2] | 0;
+ i4 = HEAP32[i5 + 12 >> 2] | 0;
+ if ((i3 | 0) <= 0) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ if ((HEAP32[i4 + 40 >> 2] | 0) < (i3 | 0)) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ i6 = i3 + -1 | 0;
+ i3 = HEAP32[(HEAP32[i5 + 16 + (i6 << 2) >> 2] | 0) + 8 >> 2] | 0;
+ i4 = HEAP32[(HEAP32[i4 + 28 >> 2] | 0) + (i6 << 3) >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ i4 = 936;
+ } else {
+ i4 = i4 + 16 | 0;
+ }
+ } else {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ } while (0);
+ i6 = i1 + 8 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ i8 = i3;
+ i7 = HEAP32[i8 + 4 >> 2] | 0;
+ i1 = i5;
+ HEAP32[i1 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i1 + 4 >> 2] = i7;
+ HEAP32[i5 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + 16;
+ i6 = i4;
+ STACKTOP = i2;
+ return i6 | 0;
+}
+function _lua_copy(i1, i8, i4) {
+ i1 = i1 | 0;
+ i8 = i8 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i9 = 0;
+ i2 = STACKTOP;
+ i3 = i1 + 16 | 0;
+ i6 = HEAP32[i3 >> 2] | 0;
+ do {
+ if ((i8 | 0) <= 0) {
+ if (!((i8 | 0) < -1000999)) {
+ i7 = (HEAP32[i1 + 8 >> 2] | 0) + (i8 << 4) | 0;
+ break;
+ }
+ if ((i8 | 0) == -1001e3) {
+ i7 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i8 = -1001e3 - i8 | 0;
+ i9 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i9 + 8 >> 2] | 0) != 22 ? (i7 = HEAP32[i9 >> 2] | 0, (i8 | 0) <= (HEAPU8[i7 + 6 | 0] | 0 | 0)) : 0) {
+ i7 = i7 + (i8 + -1 << 4) + 16 | 0;
+ } else {
+ i7 = 5192;
+ }
+ } else {
+ i7 = (HEAP32[i6 >> 2] | 0) + (i8 << 4) | 0;
+ i7 = i7 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i7 : 5192;
+ }
+ } while (0);
+ do {
+ if ((i4 | 0) <= 0) {
+ if (!((i4 | 0) < -1000999)) {
+ i5 = (HEAP32[i1 + 8 >> 2] | 0) + (i4 << 4) | 0;
+ break;
+ }
+ if ((i4 | 0) == -1001e3) {
+ i5 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i8 = -1001e3 - i4 | 0;
+ i6 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i6 + 8 >> 2] | 0) != 22 ? (i5 = HEAP32[i6 >> 2] | 0, (i8 | 0) <= (HEAPU8[i5 + 6 | 0] | 0 | 0)) : 0) {
+ i5 = i5 + (i8 + -1 << 4) + 16 | 0;
+ } else {
+ i5 = 5192;
+ }
+ } else {
+ i5 = (HEAP32[i6 >> 2] | 0) + (i4 << 4) | 0;
+ i5 = i5 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i5 : 5192;
+ }
+ } while (0);
+ i8 = i7;
+ i9 = HEAP32[i8 + 4 >> 2] | 0;
+ i6 = i5;
+ HEAP32[i6 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i6 + 4 >> 2] = i9;
+ i6 = i7 + 8 | 0;
+ HEAP32[i5 + 8 >> 2] = HEAP32[i6 >> 2];
+ if (!((i4 | 0) < -1001e3)) {
+ STACKTOP = i2;
+ return;
+ }
+ if ((HEAP32[i6 >> 2] & 64 | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i4 = HEAP32[i7 >> 2] | 0;
+ if ((HEAP8[i4 + 5 | 0] & 3) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i3 = HEAP32[HEAP32[HEAP32[i3 >> 2] >> 2] >> 2] | 0;
+ if ((HEAP8[i3 + 5 | 0] & 4) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ _luaC_barrier_(i1, i3, i4);
+ STACKTOP = i2;
+ return;
+}
+function _lua_tolstring(i4, i5, i1) {
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i2 = STACKTOP;
+ i7 = i4 + 16 | 0;
+ i10 = HEAP32[i7 >> 2] | 0;
+ i6 = (i5 | 0) > 0;
+ do {
+ if (!i6) {
+ if (!((i5 | 0) < -1000999)) {
+ i8 = (HEAP32[i4 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i8 = (HEAP32[i4 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i9 = -1001e3 - i5 | 0;
+ i10 = HEAP32[i10 >> 2] | 0;
+ if ((HEAP32[i10 + 8 >> 2] | 0) != 22 ? (i8 = HEAP32[i10 >> 2] | 0, (i9 | 0) <= (HEAPU8[i8 + 6 | 0] | 0 | 0)) : 0) {
+ i8 = i8 + (i9 + -1 << 4) + 16 | 0;
+ } else {
+ i8 = 5192;
+ }
+ } else {
+ i8 = (HEAP32[i10 >> 2] | 0) + (i5 << 4) | 0;
+ i8 = i8 >>> 0 < (HEAP32[i4 + 8 >> 2] | 0) >>> 0 ? i8 : 5192;
+ }
+ } while (0);
+ do {
+ if ((HEAP32[i8 + 8 >> 2] & 15 | 0) != 4) {
+ if ((_luaV_tostring(i4, i8) | 0) == 0) {
+ if ((i1 | 0) == 0) {
+ i10 = 0;
+ STACKTOP = i2;
+ return i10 | 0;
+ }
+ HEAP32[i1 >> 2] = 0;
+ i10 = 0;
+ STACKTOP = i2;
+ return i10 | 0;
+ }
+ i8 = i4 + 12 | 0;
+ if ((HEAP32[(HEAP32[i8 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ _luaC_step(i4);
+ }
+ i7 = HEAP32[i7 >> 2] | 0;
+ if (i6) {
+ i3 = (HEAP32[i7 >> 2] | 0) + (i5 << 4) | 0;
+ i8 = i3 >>> 0 < (HEAP32[i4 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ break;
+ }
+ if (!((i5 | 0) < -1000999)) {
+ i8 = (HEAP32[i4 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i8 = (HEAP32[i8 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i4 = -1001e3 - i5 | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ if ((HEAP32[i5 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i5 >> 2] | 0, (i4 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i8 = i3 + (i4 + -1 << 4) + 16 | 0;
+ } else {
+ i8 = 5192;
+ }
+ }
+ } while (0);
+ i3 = HEAP32[i8 >> 2] | 0;
+ if ((i1 | 0) != 0) {
+ HEAP32[i1 >> 2] = HEAP32[i3 + 12 >> 2];
+ }
+ i10 = i3 + 16 | 0;
+ STACKTOP = i2;
+ return i10 | 0;
+}
+function _luaD_pcall(i3, i6, i5, i13, i14) {
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ i13 = i13 | 0;
+ i14 = i14 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0;
+ i1 = STACKTOP;
+ i10 = i3 + 16 | 0;
+ i11 = HEAP32[i10 >> 2] | 0;
+ i12 = i3 + 41 | 0;
+ i7 = HEAP8[i12] | 0;
+ i9 = i3 + 36 | 0;
+ i8 = HEAP16[i9 >> 1] | 0;
+ i4 = i3 + 68 | 0;
+ i2 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = i14;
+ i5 = _luaD_rawrunprotected(i3, i6, i5) | 0;
+ if ((i5 | 0) == 0) {
+ HEAP32[i4 >> 2] = i2;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ i6 = i3 + 28 | 0;
+ i14 = HEAP32[i6 >> 2] | 0;
+ i15 = i14 + i13 | 0;
+ _luaF_close(i3, i15);
+ if ((i5 | 0) == 6) {
+ i16 = _luaS_newlstr(i3, 2424, 23) | 0;
+ HEAP32[i15 >> 2] = i16;
+ HEAP32[i14 + (i13 + 8) >> 2] = HEAPU8[i16 + 4 | 0] | 0 | 64;
+ } else if ((i5 | 0) == 4) {
+ i16 = HEAP32[(HEAP32[i3 + 12 >> 2] | 0) + 180 >> 2] | 0;
+ HEAP32[i15 >> 2] = i16;
+ HEAP32[i14 + (i13 + 8) >> 2] = HEAPU8[i16 + 4 | 0] | 0 | 64;
+ } else {
+ i16 = HEAP32[i3 + 8 >> 2] | 0;
+ i18 = i16 + -16 | 0;
+ i17 = HEAP32[i18 + 4 >> 2] | 0;
+ HEAP32[i15 >> 2] = HEAP32[i18 >> 2];
+ HEAP32[i15 + 4 >> 2] = i17;
+ HEAP32[i14 + (i13 + 8) >> 2] = HEAP32[i16 + -8 >> 2];
+ }
+ i13 = i14 + (i13 + 16) | 0;
+ HEAP32[i3 + 8 >> 2] = i13;
+ HEAP32[i10 >> 2] = i11;
+ HEAP8[i12] = i7;
+ HEAP16[i9 >> 1] = i8;
+ if ((i11 | 0) != 0) {
+ do {
+ i7 = HEAP32[i11 + 4 >> 2] | 0;
+ i13 = i13 >>> 0 < i7 >>> 0 ? i7 : i13;
+ i11 = HEAP32[i11 + 8 >> 2] | 0;
+ } while ((i11 | 0) != 0);
+ }
+ i6 = i13 - (HEAP32[i6 >> 2] | 0) | 0;
+ i7 = (i6 >> 4) + 1 | 0;
+ i7 = ((i7 | 0) / 8 | 0) + 10 + i7 | 0;
+ i7 = (i7 | 0) > 1e6 ? 1e6 : i7;
+ if ((i6 | 0) > 15999984) {
+ HEAP32[i4 >> 2] = i2;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ if ((i7 | 0) >= (HEAP32[i3 + 32 >> 2] | 0)) {
+ HEAP32[i4 >> 2] = i2;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ _luaD_reallocstack(i3, i7);
+ HEAP32[i4 >> 2] = i2;
+ STACKTOP = i1;
+ return i5 | 0;
+}
+function _luaH_resize(i1, i4, i6, i9) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ i9 = i9 | 0;
+ var i2 = 0, i3 = 0, i5 = 0, i7 = 0, i8 = 0, i10 = 0, i11 = 0;
+ i3 = STACKTOP;
+ i8 = i4 + 28 | 0;
+ i5 = HEAP32[i8 >> 2] | 0;
+ i7 = HEAPU8[i4 + 7 | 0] | 0;
+ i2 = HEAP32[i4 + 16 >> 2] | 0;
+ if ((i5 | 0) < (i6 | 0)) {
+ if ((i6 + 1 | 0) >>> 0 > 268435455) {
+ _luaM_toobig(i1);
+ }
+ i11 = i4 + 12 | 0;
+ i10 = _luaM_realloc_(i1, HEAP32[i11 >> 2] | 0, i5 << 4, i6 << 4) | 0;
+ HEAP32[i11 >> 2] = i10;
+ i11 = HEAP32[i8 >> 2] | 0;
+ if ((i11 | 0) < (i6 | 0)) {
+ do {
+ HEAP32[i10 + (i11 << 4) + 8 >> 2] = 0;
+ i11 = i11 + 1 | 0;
+ } while ((i11 | 0) != (i6 | 0));
+ }
+ HEAP32[i8 >> 2] = i6;
+ }
+ _setnodevector(i1, i4, i9);
+ do {
+ if ((i5 | 0) > (i6 | 0)) {
+ HEAP32[i8 >> 2] = i6;
+ i8 = i4 + 12 | 0;
+ i9 = i6;
+ do {
+ i10 = HEAP32[i8 >> 2] | 0;
+ if ((HEAP32[i10 + (i9 << 4) + 8 >> 2] | 0) == 0) {
+ i9 = i9 + 1 | 0;
+ } else {
+ i11 = i9 + 1 | 0;
+ _luaH_setint(i1, i4, i11, i10 + (i9 << 4) | 0);
+ i9 = i11;
+ }
+ } while ((i9 | 0) != (i5 | 0));
+ if ((i6 + 1 | 0) >>> 0 > 268435455) {
+ _luaM_toobig(i1);
+ } else {
+ i11 = i4 + 12 | 0;
+ HEAP32[i11 >> 2] = _luaM_realloc_(i1, HEAP32[i11 >> 2] | 0, i5 << 4, i6 << 4) | 0;
+ break;
+ }
+ }
+ } while (0);
+ i5 = 1 << i7;
+ if ((i5 | 0) > 0) {
+ i6 = i5;
+ do {
+ i6 = i6 + -1 | 0;
+ i7 = i2 + (i6 << 5) + 8 | 0;
+ if ((HEAP32[i7 >> 2] | 0) != 0) {
+ i8 = i2 + (i6 << 5) + 16 | 0;
+ i9 = _luaH_get(i4, i8) | 0;
+ if ((i9 | 0) == 5192) {
+ i9 = _luaH_newkey(i1, i4, i8) | 0;
+ }
+ i8 = i2 + (i6 << 5) | 0;
+ i10 = HEAP32[i8 + 4 >> 2] | 0;
+ i11 = i9;
+ HEAP32[i11 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i11 + 4 >> 2] = i10;
+ HEAP32[i9 + 8 >> 2] = HEAP32[i7 >> 2];
+ }
+ } while ((i6 | 0) > 0);
+ }
+ if ((i2 | 0) == 8016) {
+ STACKTOP = i3;
+ return;
+ }
+ _luaM_realloc_(i1, i2, i5 << 5, 0) | 0;
+ STACKTOP = i3;
+ return;
+}
+function _codearith(i4, i3, i2, i6, i5) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, d13 = 0.0;
+ i7 = STACKTOP;
+ if (((((((HEAP32[i2 >> 2] | 0) == 5 ? (HEAP32[i2 + 16 >> 2] | 0) == -1 : 0) ? (HEAP32[i2 + 20 >> 2] | 0) == -1 : 0) ? (HEAP32[i6 >> 2] | 0) == 5 : 0) ? (HEAP32[i6 + 16 >> 2] | 0) == -1 : 0) ? (HEAP32[i6 + 20 >> 2] | 0) == -1 : 0) ? (d13 = +HEAPF64[i6 + 8 >> 3], !((i3 & -2 | 0) == 16 & d13 == 0.0)) : 0) {
+ i12 = i2 + 8 | 0;
+ HEAPF64[i12 >> 3] = +_luaO_arith(i3 + -13 | 0, +HEAPF64[i12 >> 3], d13);
+ STACKTOP = i7;
+ return;
+ }
+ if ((i3 | 0) == 19 | (i3 | 0) == 21) {
+ i11 = 0;
+ } else {
+ i11 = _luaK_exp2RK(i4, i6) | 0;
+ }
+ i12 = _luaK_exp2RK(i4, i2) | 0;
+ if ((i12 | 0) > (i11 | 0)) {
+ if (((HEAP32[i2 >> 2] | 0) == 6 ? (i8 = HEAP32[i2 + 8 >> 2] | 0, (i8 & 256 | 0) == 0) : 0) ? (HEAPU8[i4 + 46 | 0] | 0 | 0) <= (i8 | 0) : 0) {
+ i10 = i4 + 48 | 0;
+ HEAP8[i10] = (HEAP8[i10] | 0) + -1 << 24 >> 24;
+ }
+ if (((HEAP32[i6 >> 2] | 0) == 6 ? (i1 = HEAP32[i6 + 8 >> 2] | 0, (i1 & 256 | 0) == 0) : 0) ? (HEAPU8[i4 + 46 | 0] | 0 | 0) <= (i1 | 0) : 0) {
+ i10 = i4 + 48 | 0;
+ HEAP8[i10] = (HEAP8[i10] | 0) + -1 << 24 >> 24;
+ }
+ } else {
+ if (((HEAP32[i6 >> 2] | 0) == 6 ? (i10 = HEAP32[i6 + 8 >> 2] | 0, (i10 & 256 | 0) == 0) : 0) ? (HEAPU8[i4 + 46 | 0] | 0 | 0) <= (i10 | 0) : 0) {
+ i10 = i4 + 48 | 0;
+ HEAP8[i10] = (HEAP8[i10] | 0) + -1 << 24 >> 24;
+ }
+ if (((HEAP32[i2 >> 2] | 0) == 6 ? (i9 = HEAP32[i2 + 8 >> 2] | 0, (i9 & 256 | 0) == 0) : 0) ? (HEAPU8[i4 + 46 | 0] | 0 | 0) <= (i9 | 0) : 0) {
+ i10 = i4 + 48 | 0;
+ HEAP8[i10] = (HEAP8[i10] | 0) + -1 << 24 >> 24;
+ }
+ }
+ HEAP32[i2 + 8 >> 2] = _luaK_code(i4, i11 << 14 | i3 | i12 << 23) | 0;
+ HEAP32[i2 >> 2] = 11;
+ HEAP32[(HEAP32[(HEAP32[i4 >> 2] | 0) + 20 >> 2] | 0) + ((HEAP32[i4 + 20 >> 2] | 0) + -1 << 2) >> 2] = i5;
+ STACKTOP = i7;
+ return;
+}
+function _GCTM(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i2 = i4 + 16 | 0;
+ i5 = i4;
+ i6 = HEAP32[i1 + 12 >> 2] | 0;
+ i9 = i6 + 104 | 0;
+ i8 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = HEAP32[i8 >> 2];
+ i9 = i6 + 68 | 0;
+ HEAP32[i8 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i9 >> 2] = i8;
+ i9 = i8 + 5 | 0;
+ i7 = HEAPU8[i9] | 0;
+ HEAP8[i9] = i7 & 239;
+ if ((HEAPU8[i6 + 61 | 0] | 0) >= 2) {
+ HEAP8[i9] = HEAP8[i6 + 60 | 0] & 3 | i7 & 168;
+ }
+ HEAP32[i5 >> 2] = i8;
+ i7 = i5 + 8 | 0;
+ HEAP32[i7 >> 2] = HEAPU8[i8 + 4 | 0] | 0 | 64;
+ i8 = _luaT_gettmbyobj(i1, i5, 2) | 0;
+ if ((i8 | 0) == 0) {
+ STACKTOP = i4;
+ return;
+ }
+ i9 = i8 + 8 | 0;
+ if ((HEAP32[i9 >> 2] & 15 | 0) != 6) {
+ STACKTOP = i4;
+ return;
+ }
+ i12 = i1 + 41 | 0;
+ i13 = HEAP8[i12] | 0;
+ i10 = i6 + 63 | 0;
+ i11 = HEAP8[i10] | 0;
+ HEAP8[i12] = 0;
+ HEAP8[i10] = 0;
+ i6 = i1 + 8 | 0;
+ i14 = HEAP32[i6 >> 2] | 0;
+ i16 = i8;
+ i15 = HEAP32[i16 + 4 >> 2] | 0;
+ i8 = i14;
+ HEAP32[i8 >> 2] = HEAP32[i16 >> 2];
+ HEAP32[i8 + 4 >> 2] = i15;
+ HEAP32[i14 + 8 >> 2] = HEAP32[i9 >> 2];
+ i9 = HEAP32[i6 >> 2] | 0;
+ i14 = i5;
+ i8 = HEAP32[i14 + 4 >> 2] | 0;
+ i5 = i9 + 16 | 0;
+ HEAP32[i5 >> 2] = HEAP32[i14 >> 2];
+ HEAP32[i5 + 4 >> 2] = i8;
+ HEAP32[i9 + 24 >> 2] = HEAP32[i7 >> 2];
+ i5 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i5 + 32;
+ i5 = _luaD_pcall(i1, 7, 0, i5 - (HEAP32[i1 + 28 >> 2] | 0) | 0, 0) | 0;
+ HEAP8[i12] = i13;
+ HEAP8[i10] = i11;
+ if ((i5 | 0) == 0 | (i3 | 0) == 0) {
+ STACKTOP = i4;
+ return;
+ }
+ if ((i5 | 0) != 2) {
+ i16 = i5;
+ _luaD_throw(i1, i16);
+ }
+ i3 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i3 + -8 >> 2] & 15 | 0) == 4) {
+ i3 = (HEAP32[i3 + -16 >> 2] | 0) + 16 | 0;
+ } else {
+ i3 = 2528;
+ }
+ HEAP32[i2 >> 2] = i3;
+ _luaO_pushfstring(i1, 2544, i2) | 0;
+ i16 = 5;
+ _luaD_throw(i1, i16);
+}
+function _lua_gc(i3, i5, i4) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0;
+ i1 = STACKTOP;
+ i2 = HEAP32[i3 + 12 >> 2] | 0;
+ L1 : do {
+ switch (i5 | 0) {
+ case 8:
+ {
+ i5 = i2 + 160 | 0;
+ i2 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i4;
+ break;
+ }
+ case 11:
+ {
+ _luaC_changemode(i3, 0);
+ i2 = 0;
+ break;
+ }
+ case 2:
+ {
+ _luaC_fullgc(i3, 0);
+ i2 = 0;
+ break;
+ }
+ case 5:
+ {
+ if ((HEAP8[i2 + 62 | 0] | 0) == 2) {
+ i2 = (HEAP32[i2 + 20 >> 2] | 0) == 0 | 0;
+ _luaC_forcestep(i3);
+ break L1;
+ }
+ i4 = (i4 << 10) + -1600 | 0;
+ if ((HEAP8[i2 + 63 | 0] | 0) == 0) {
+ i5 = i4;
+ _luaE_setdebt(i2, i5);
+ _luaC_forcestep(i3);
+ i5 = i2 + 61 | 0;
+ i5 = HEAP8[i5] | 0;
+ i5 = i5 << 24 >> 24 == 5;
+ i5 = i5 & 1;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ i5 = (HEAP32[i2 + 12 >> 2] | 0) + i4 | 0;
+ _luaE_setdebt(i2, i5);
+ _luaC_forcestep(i3);
+ i5 = i2 + 61 | 0;
+ i5 = HEAP8[i5] | 0;
+ i5 = i5 << 24 >> 24 == 5;
+ i5 = i5 & 1;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ case 4:
+ {
+ i2 = (HEAP32[i2 + 12 >> 2] | 0) + (HEAP32[i2 + 8 >> 2] | 0) & 1023;
+ break;
+ }
+ case 1:
+ {
+ _luaE_setdebt(i2, 0);
+ HEAP8[i2 + 63 | 0] = 1;
+ i2 = 0;
+ break;
+ }
+ case 3:
+ {
+ i2 = ((HEAP32[i2 + 12 >> 2] | 0) + (HEAP32[i2 + 8 >> 2] | 0) | 0) >>> 10;
+ break;
+ }
+ case 7:
+ {
+ i5 = i2 + 164 | 0;
+ i2 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i4;
+ break;
+ }
+ case 0:
+ {
+ HEAP8[i2 + 63 | 0] = 0;
+ i2 = 0;
+ break;
+ }
+ case 6:
+ {
+ i5 = i2 + 156 | 0;
+ i2 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i4;
+ break;
+ }
+ case 9:
+ {
+ i2 = HEAPU8[i2 + 63 | 0] | 0;
+ break;
+ }
+ case 10:
+ {
+ _luaC_changemode(i3, 2);
+ i2 = 0;
+ break;
+ }
+ default:
+ {
+ i2 = -1;
+ }
+ }
+ } while (0);
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _os_time(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i4 = i2;
+ i5 = i2 + 48 | 0;
+ i3 = i2 + 4 | 0;
+ if ((_lua_type(i1, 1) | 0) < 1) {
+ i3 = _time(0) | 0;
+ } else {
+ _luaL_checktype(i1, 1, 5);
+ _lua_settop(i1, 1);
+ _lua_getfield(i1, -1, 5864);
+ i6 = _lua_tointegerx(i1, -1, i4) | 0;
+ i6 = (HEAP32[i4 >> 2] | 0) == 0 ? 0 : i6;
+ _lua_settop(i1, -2);
+ HEAP32[i3 >> 2] = i6;
+ _lua_getfield(i1, -1, 5872);
+ i6 = _lua_tointegerx(i1, -1, i4) | 0;
+ i6 = (HEAP32[i4 >> 2] | 0) == 0 ? 0 : i6;
+ _lua_settop(i1, -2);
+ HEAP32[i3 + 4 >> 2] = i6;
+ _lua_getfield(i1, -1, 5880);
+ i6 = _lua_tointegerx(i1, -1, i4) | 0;
+ i6 = (HEAP32[i4 >> 2] | 0) == 0 ? 12 : i6;
+ _lua_settop(i1, -2);
+ HEAP32[i3 + 8 >> 2] = i6;
+ _lua_getfield(i1, -1, 5888);
+ i6 = _lua_tointegerx(i1, -1, i5) | 0;
+ if ((HEAP32[i5 >> 2] | 0) == 0) {
+ HEAP32[i4 >> 2] = 5888;
+ i6 = _luaL_error(i1, 5920, i4) | 0;
+ } else {
+ _lua_settop(i1, -2);
+ }
+ HEAP32[i3 + 12 >> 2] = i6;
+ _lua_getfield(i1, -1, 5896);
+ i6 = _lua_tointegerx(i1, -1, i5) | 0;
+ if ((HEAP32[i5 >> 2] | 0) == 0) {
+ HEAP32[i4 >> 2] = 5896;
+ i6 = _luaL_error(i1, 5920, i4) | 0;
+ } else {
+ _lua_settop(i1, -2);
+ }
+ HEAP32[i3 + 16 >> 2] = i6 + -1;
+ _lua_getfield(i1, -1, 5904);
+ i6 = _lua_tointegerx(i1, -1, i5) | 0;
+ if ((HEAP32[i5 >> 2] | 0) == 0) {
+ HEAP32[i4 >> 2] = 5904;
+ i6 = _luaL_error(i1, 5920, i4) | 0;
+ } else {
+ _lua_settop(i1, -2);
+ }
+ HEAP32[i3 + 20 >> 2] = i6 + -1900;
+ _lua_getfield(i1, -1, 5912);
+ if ((_lua_type(i1, -1) | 0) == 0) {
+ i4 = -1;
+ } else {
+ i4 = _lua_toboolean(i1, -1) | 0;
+ }
+ _lua_settop(i1, -2);
+ HEAP32[i3 + 32 >> 2] = i4;
+ i3 = _mktime(i3 | 0) | 0;
+ }
+ if ((i3 | 0) == -1) {
+ _lua_pushnil(i1);
+ STACKTOP = i2;
+ return 1;
+ } else {
+ _lua_pushnumber(i1, +(i3 | 0));
+ STACKTOP = i2;
+ return 1;
+ }
+ return 0;
+}
+function _addk(i6, i4, i3) {
+ i6 = i6 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i2 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i10 = i1;
+ i2 = HEAP32[(HEAP32[i6 + 12 >> 2] | 0) + 52 >> 2] | 0;
+ i8 = _luaH_set(i2, HEAP32[i6 + 4 >> 2] | 0, i4) | 0;
+ i4 = HEAP32[i6 >> 2] | 0;
+ i9 = i8 + 8 | 0;
+ if (((HEAP32[i9 >> 2] | 0) == 3 ? (HEAPF64[i10 >> 3] = +HEAPF64[i8 >> 3] + 6755399441055744.0, i7 = HEAP32[i10 >> 2] | 0, i5 = HEAP32[i4 + 8 >> 2] | 0, (HEAP32[i5 + (i7 << 4) + 8 >> 2] | 0) == (HEAP32[i3 + 8 >> 2] | 0)) : 0) ? (_luaV_equalobj_(0, i5 + (i7 << 4) | 0, i3) | 0) != 0 : 0) {
+ i10 = i7;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ i5 = i4 + 44 | 0;
+ i10 = HEAP32[i5 >> 2] | 0;
+ i7 = i6 + 32 | 0;
+ i6 = HEAP32[i7 >> 2] | 0;
+ HEAPF64[i8 >> 3] = +(i6 | 0);
+ HEAP32[i9 >> 2] = 3;
+ i9 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) >= (i9 | 0)) {
+ i9 = i4 + 8 | 0;
+ HEAP32[i9 >> 2] = _luaM_growaux_(i2, HEAP32[i9 >> 2] | 0, i5, 16, 67108863, 10600) | 0;
+ i9 = HEAP32[i5 >> 2] | 0;
+ }
+ i8 = HEAP32[i4 + 8 >> 2] | 0;
+ if ((i10 | 0) < (i9 | 0)) {
+ while (1) {
+ i9 = i10 + 1 | 0;
+ HEAP32[i8 + (i10 << 4) + 8 >> 2] = 0;
+ if ((i9 | 0) < (HEAP32[i5 >> 2] | 0)) {
+ i10 = i9;
+ } else {
+ break;
+ }
+ }
+ }
+ i5 = i3;
+ i9 = HEAP32[i5 + 4 >> 2] | 0;
+ i10 = i8 + (i6 << 4) | 0;
+ HEAP32[i10 >> 2] = HEAP32[i5 >> 2];
+ HEAP32[i10 + 4 >> 2] = i9;
+ i10 = i3 + 8 | 0;
+ HEAP32[i8 + (i6 << 4) + 8 >> 2] = HEAP32[i10 >> 2];
+ HEAP32[i7 >> 2] = (HEAP32[i7 >> 2] | 0) + 1;
+ if ((HEAP32[i10 >> 2] & 64 | 0) == 0) {
+ i10 = i6;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ i3 = HEAP32[i3 >> 2] | 0;
+ if ((HEAP8[i3 + 5 | 0] & 3) == 0) {
+ i10 = i6;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ if ((HEAP8[i4 + 5 | 0] & 4) == 0) {
+ i10 = i6;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ _luaC_barrier_(i2, i4, i3);
+ i10 = i6;
+ STACKTOP = i1;
+ return i10 | 0;
+}
+function _singlevaraux(i5, i4, i2, i11) {
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i11 = i11 | 0;
+ var i1 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i1 = STACKTOP;
+ if ((i5 | 0) == 0) {
+ i11 = 0;
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ i7 = i5 + 12 | 0;
+ i8 = i5 + 40 | 0;
+ i9 = HEAPU8[i5 + 46 | 0] | 0;
+ while (1) {
+ i6 = i9 + -1 | 0;
+ i10 = HEAP32[i5 >> 2] | 0;
+ if ((i9 | 0) <= 0) {
+ break;
+ }
+ if ((_luaS_eqstr(i4, HEAP32[(HEAP32[i10 + 24 >> 2] | 0) + ((HEAP16[(HEAP32[HEAP32[(HEAP32[i7 >> 2] | 0) + 64 >> 2] >> 2] | 0) + ((HEAP32[i8 >> 2] | 0) + i6 << 1) >> 1] | 0) * 12 | 0) >> 2] | 0) | 0) == 0) {
+ i9 = i6;
+ } else {
+ i3 = 5;
+ break;
+ }
+ }
+ if ((i3 | 0) == 5) {
+ HEAP32[i2 + 16 >> 2] = -1;
+ HEAP32[i2 + 20 >> 2] = -1;
+ HEAP32[i2 >> 2] = 7;
+ HEAP32[i2 + 8 >> 2] = i6;
+ if ((i11 | 0) != 0) {
+ i11 = 7;
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ i2 = i5 + 16 | 0;
+ do {
+ i2 = HEAP32[i2 >> 2] | 0;
+ } while ((HEAPU8[i2 + 8 | 0] | 0) > (i6 | 0));
+ HEAP8[i2 + 9 | 0] = 1;
+ i11 = 7;
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ i7 = HEAP32[i10 + 28 >> 2] | 0;
+ i6 = i5 + 47 | 0;
+ L17 : do {
+ if ((HEAP8[i6] | 0) != 0) {
+ i8 = 0;
+ while (1) {
+ i9 = i8 + 1 | 0;
+ if ((_luaS_eqstr(HEAP32[i7 + (i8 << 3) >> 2] | 0, i4) | 0) != 0) {
+ break;
+ }
+ if ((i9 | 0) < (HEAPU8[i6] | 0)) {
+ i8 = i9;
+ } else {
+ i3 = 13;
+ break L17;
+ }
+ }
+ if ((i8 | 0) < 0) {
+ i3 = 13;
+ }
+ } else {
+ i3 = 13;
+ }
+ } while (0);
+ do {
+ if ((i3 | 0) == 13) {
+ if ((_singlevaraux(HEAP32[i5 + 8 >> 2] | 0, i4, i2, 0) | 0) == 0) {
+ i11 = 0;
+ STACKTOP = i1;
+ return i11 | 0;
+ } else {
+ i8 = _newupvalue(i5, i4, i2) | 0;
+ break;
+ }
+ }
+ } while (0);
+ HEAP32[i2 + 16 >> 2] = -1;
+ HEAP32[i2 + 20 >> 2] = -1;
+ HEAP32[i2 >> 2] = 8;
+ HEAP32[i2 + 8 >> 2] = i8;
+ i11 = 8;
+ STACKTOP = i1;
+ return i11 | 0;
+}
+function _mainposition(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ switch (HEAP32[i3 + 8 >> 2] & 63 | 0) {
+ case 3:
+ {
+ HEAPF64[i4 >> 3] = +HEAPF64[i3 >> 3] + 1.0;
+ i3 = (HEAP32[i4 + 4 >> 2] | 0) + (HEAP32[i4 >> 2] | 0) | 0;
+ if ((i3 | 0) < 0) {
+ i4 = 0 - i3 | 0;
+ i3 = (i3 | 0) == (i4 | 0) ? 0 : i4;
+ }
+ i5 = (HEAP32[i1 + 16 >> 2] | 0) + (((i3 | 0) % ((1 << HEAPU8[i1 + 7 | 0]) + -1 | 1 | 0) | 0) << 5) | 0;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ case 2:
+ {
+ i5 = (HEAP32[i1 + 16 >> 2] | 0) + ((((HEAP32[i3 >> 2] | 0) >>> 0) % (((1 << HEAPU8[i1 + 7 | 0]) + -1 | 1) >>> 0) | 0) << 5) | 0;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ case 20:
+ {
+ i5 = HEAP32[i3 >> 2] | 0;
+ i4 = i5 + 6 | 0;
+ if ((HEAP8[i4] | 0) == 0) {
+ i6 = i5 + 8 | 0;
+ HEAP32[i6 >> 2] = _luaS_hash(i5 + 16 | 0, HEAP32[i5 + 12 >> 2] | 0, HEAP32[i6 >> 2] | 0) | 0;
+ HEAP8[i4] = 1;
+ i5 = HEAP32[i3 >> 2] | 0;
+ }
+ i6 = (HEAP32[i1 + 16 >> 2] | 0) + (((1 << HEAPU8[i1 + 7 | 0]) + -1 & HEAP32[i5 + 8 >> 2]) << 5) | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ case 22:
+ {
+ i6 = (HEAP32[i1 + 16 >> 2] | 0) + ((((HEAP32[i3 >> 2] | 0) >>> 0) % (((1 << HEAPU8[i1 + 7 | 0]) + -1 | 1) >>> 0) | 0) << 5) | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ case 4:
+ {
+ i6 = (HEAP32[i1 + 16 >> 2] | 0) + (((1 << HEAPU8[i1 + 7 | 0]) + -1 & HEAP32[(HEAP32[i3 >> 2] | 0) + 8 >> 2]) << 5) | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ case 1:
+ {
+ i6 = (HEAP32[i1 + 16 >> 2] | 0) + (((1 << HEAPU8[i1 + 7 | 0]) + -1 & HEAP32[i3 >> 2]) << 5) | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ default:
+ {
+ i6 = (HEAP32[i1 + 16 >> 2] | 0) + ((((HEAP32[i3 >> 2] | 0) >>> 0) % (((1 << HEAPU8[i1 + 7 | 0]) + -1 | 1) >>> 0) | 0) << 5) | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ }
+ return 0;
+}
+function _clearvalues(i2, i5, i1) {
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ var i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i4 = STACKTOP;
+ if ((i5 | 0) == (i1 | 0)) {
+ STACKTOP = i4;
+ return;
+ }
+ do {
+ i7 = i5 + 16 | 0;
+ i9 = HEAP32[i7 >> 2] | 0;
+ i6 = i9 + (1 << (HEAPU8[i5 + 7 | 0] | 0) << 5) | 0;
+ i8 = i5 + 28 | 0;
+ if ((HEAP32[i8 >> 2] | 0) > 0) {
+ i11 = i5 + 12 | 0;
+ i12 = 0;
+ do {
+ i13 = HEAP32[i11 >> 2] | 0;
+ i10 = i13 + (i12 << 4) + 8 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ do {
+ if ((i9 & 64 | 0) != 0) {
+ i13 = HEAP32[i13 + (i12 << 4) >> 2] | 0;
+ if ((i9 & 15 | 0) != 4) {
+ if ((HEAP8[i13 + 5 | 0] & 3) == 0) {
+ break;
+ }
+ HEAP32[i10 >> 2] = 0;
+ break;
+ }
+ if ((i13 | 0) != 0 ? !((HEAP8[i13 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i2, i13);
+ }
+ }
+ } while (0);
+ i12 = i12 + 1 | 0;
+ } while ((i12 | 0) < (HEAP32[i8 >> 2] | 0));
+ i7 = HEAP32[i7 >> 2] | 0;
+ } else {
+ i7 = i9;
+ }
+ if (i7 >>> 0 < i6 >>> 0) {
+ do {
+ i8 = i7 + 8 | 0;
+ i9 = HEAP32[i8 >> 2] | 0;
+ do {
+ if (!((i9 | 0) == 0 | (i9 & 64 | 0) == 0)) {
+ i10 = HEAP32[i7 >> 2] | 0;
+ if ((i9 & 15 | 0) == 4) {
+ if ((i10 | 0) == 0) {
+ break;
+ }
+ if ((HEAP8[i10 + 5 | 0] & 3) == 0) {
+ break;
+ }
+ _reallymarkobject(i2, i10);
+ break;
+ }
+ if ((!((HEAP8[i10 + 5 | 0] & 3) == 0) ? (HEAP32[i8 >> 2] = 0, i3 = i7 + 24 | 0, (HEAP32[i3 >> 2] & 64 | 0) != 0) : 0) ? !((HEAP8[(HEAP32[i7 + 16 >> 2] | 0) + 5 | 0] & 3) == 0) : 0) {
+ HEAP32[i3 >> 2] = 11;
+ }
+ }
+ } while (0);
+ i7 = i7 + 32 | 0;
+ } while (i7 >>> 0 < i6 >>> 0);
+ }
+ i5 = HEAP32[i5 + 24 >> 2] | 0;
+ } while ((i5 | 0) != (i1 | 0));
+ STACKTOP = i4;
+ return;
+}
+function _reallymarkobject(i1, i4) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i3 = STACKTOP;
+ i2 = i4 + 5 | 0;
+ HEAP8[i2] = HEAP8[i2] & 252;
+ switch (HEAPU8[i4 + 4 | 0] | 0 | 0) {
+ case 6:
+ {
+ i7 = i1 + 84 | 0;
+ HEAP32[i4 + 8 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i7 >> 2] = i4;
+ STACKTOP = i3;
+ return;
+ }
+ case 20:
+ case 4:
+ {
+ i4 = (HEAP32[i4 + 12 >> 2] | 0) + 17 | 0;
+ break;
+ }
+ case 7:
+ {
+ i5 = HEAP32[i4 + 8 >> 2] | 0;
+ if ((i5 | 0) != 0 ? !((HEAP8[i5 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i1, i5);
+ }
+ i5 = HEAP32[i4 + 12 >> 2] | 0;
+ if ((i5 | 0) != 0 ? !((HEAP8[i5 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i1, i5);
+ }
+ i4 = (HEAP32[i4 + 16 >> 2] | 0) + 24 | 0;
+ break;
+ }
+ case 8:
+ {
+ i7 = i1 + 84 | 0;
+ HEAP32[i4 + 60 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i7 >> 2] = i4;
+ STACKTOP = i3;
+ return;
+ }
+ case 10:
+ {
+ i6 = i4 + 8 | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i7 + 8 >> 2] & 64 | 0) != 0 ? (i5 = HEAP32[i7 >> 2] | 0, !((HEAP8[i5 + 5 | 0] & 3) == 0)) : 0) {
+ _reallymarkobject(i1, i5);
+ i7 = HEAP32[i6 >> 2] | 0;
+ }
+ if ((i7 | 0) == (i4 + 16 | 0)) {
+ i4 = 32;
+ } else {
+ STACKTOP = i3;
+ return;
+ }
+ break;
+ }
+ case 5:
+ {
+ i7 = i1 + 84 | 0;
+ HEAP32[i4 + 24 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i7 >> 2] = i4;
+ STACKTOP = i3;
+ return;
+ }
+ case 38:
+ {
+ i7 = i1 + 84 | 0;
+ HEAP32[i4 + 8 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i7 >> 2] = i4;
+ STACKTOP = i3;
+ return;
+ }
+ case 9:
+ {
+ i7 = i1 + 84 | 0;
+ HEAP32[i4 + 72 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i7 >> 2] = i4;
+ STACKTOP = i3;
+ return;
+ }
+ default:
+ {
+ STACKTOP = i3;
+ return;
+ }
+ }
+ HEAP8[i2] = HEAPU8[i2] | 0 | 4;
+ i7 = i1 + 16 | 0;
+ HEAP32[i7 >> 2] = (HEAP32[i7 >> 2] | 0) + i4;
+ STACKTOP = i3;
+ return;
+}
+function _lua_upvaluejoin(i1, i9, i7, i6, i3) {
+ i1 = i1 | 0;
+ i9 = i9 | 0;
+ i7 = i7 | 0;
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i8 = 0, i10 = 0;
+ i2 = STACKTOP;
+ i5 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i9 | 0) <= 0) {
+ if (!((i9 | 0) < -1000999)) {
+ i8 = (HEAP32[i1 + 8 >> 2] | 0) + (i9 << 4) | 0;
+ break;
+ }
+ if ((i9 | 0) == -1001e3) {
+ i8 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i10 = -1001e3 - i9 | 0;
+ i9 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i9 + 8 >> 2] | 0) != 22 ? (i8 = HEAP32[i9 >> 2] | 0, (i10 | 0) <= (HEAPU8[i8 + 6 | 0] | 0 | 0)) : 0) {
+ i8 = i8 + (i10 + -1 << 4) + 16 | 0;
+ } else {
+ i8 = 5192;
+ }
+ } else {
+ i8 = (HEAP32[i5 >> 2] | 0) + (i9 << 4) | 0;
+ i8 = i8 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i8 : 5192;
+ }
+ } while (0);
+ i8 = HEAP32[i8 >> 2] | 0;
+ i7 = i8 + 16 + (i7 + -1 << 2) | 0;
+ do {
+ if ((i6 | 0) <= 0) {
+ if (!((i6 | 0) < -1000999)) {
+ i4 = (HEAP32[i1 + 8 >> 2] | 0) + (i6 << 4) | 0;
+ break;
+ }
+ if ((i6 | 0) == -1001e3) {
+ i4 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i6 = -1001e3 - i6 | 0;
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i5 + 8 >> 2] | 0) != 22 ? (i4 = HEAP32[i5 >> 2] | 0, (i6 | 0) <= (HEAPU8[i4 + 6 | 0] | 0 | 0)) : 0) {
+ i4 = i4 + (i6 + -1 << 4) + 16 | 0;
+ } else {
+ i4 = 5192;
+ }
+ } else {
+ i4 = (HEAP32[i5 >> 2] | 0) + (i6 << 4) | 0;
+ i4 = i4 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i4 : 5192;
+ }
+ } while (0);
+ i3 = (HEAP32[i4 >> 2] | 0) + 16 + (i3 + -1 << 2) | 0;
+ HEAP32[i7 >> 2] = HEAP32[i3 >> 2];
+ i3 = HEAP32[i3 >> 2] | 0;
+ if ((HEAP8[i3 + 5 | 0] & 3) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ if ((HEAP8[i8 + 5 | 0] & 4) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ _luaC_barrier_(i1, i8, i3);
+ STACKTOP = i2;
+ return;
+}
+function _lua_upvalueid(i5, i7, i1) {
+ i5 = i5 | 0;
+ i7 = i7 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i5 + 16 >> 2] | 0;
+ i6 = (i7 | 0) > 0;
+ do {
+ if (!i6) {
+ if (!((i7 | 0) < -1000999)) {
+ i8 = (HEAP32[i5 + 8 >> 2] | 0) + (i7 << 4) | 0;
+ break;
+ }
+ if ((i7 | 0) == -1001e3) {
+ i8 = (HEAP32[i5 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i10 = -1001e3 - i7 | 0;
+ i9 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i9 + 8 >> 2] | 0) != 22 ? (i8 = HEAP32[i9 >> 2] | 0, (i10 | 0) <= (HEAPU8[i8 + 6 | 0] | 0 | 0)) : 0) {
+ i8 = i8 + (i10 + -1 << 4) + 16 | 0;
+ } else {
+ i8 = 5192;
+ }
+ } else {
+ i8 = (HEAP32[i4 >> 2] | 0) + (i7 << 4) | 0;
+ i8 = i8 >>> 0 < (HEAP32[i5 + 8 >> 2] | 0) >>> 0 ? i8 : 5192;
+ }
+ } while (0);
+ i9 = HEAP32[i8 + 8 >> 2] & 63;
+ if ((i9 | 0) == 38) {
+ i10 = (HEAP32[i8 >> 2] | 0) + (i1 + -1 << 4) + 16 | 0;
+ STACKTOP = i2;
+ return i10 | 0;
+ } else if ((i9 | 0) == 6) {
+ do {
+ if (!i6) {
+ if (!((i7 | 0) < -1000999)) {
+ i3 = (HEAP32[i5 + 8 >> 2] | 0) + (i7 << 4) | 0;
+ break;
+ }
+ if ((i7 | 0) == -1001e3) {
+ i3 = (HEAP32[i5 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i7 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i4 >> 2] | 0, (i5 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i3 = i3 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i3 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i4 >> 2] | 0) + (i7 << 4) | 0;
+ i3 = i3 >>> 0 < (HEAP32[i5 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ i10 = HEAP32[(HEAP32[i3 >> 2] | 0) + 16 + (i1 + -1 << 2) >> 2] | 0;
+ STACKTOP = i2;
+ return i10 | 0;
+ } else {
+ i10 = 0;
+ STACKTOP = i2;
+ return i10 | 0;
+ }
+ return 0;
+}
+function _lua_rawequal(i2, i6, i4) {
+ i2 = i2 | 0;
+ i6 = i6 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i3 = 0, i5 = 0, i7 = 0;
+ i1 = STACKTOP;
+ i3 = HEAP32[i2 + 16 >> 2] | 0;
+ do {
+ if ((i6 | 0) <= 0) {
+ if (!((i6 | 0) < -1000999)) {
+ i5 = (HEAP32[i2 + 8 >> 2] | 0) + (i6 << 4) | 0;
+ break;
+ }
+ if ((i6 | 0) == -1001e3) {
+ i5 = (HEAP32[i2 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i7 = -1001e3 - i6 | 0;
+ i6 = HEAP32[i3 >> 2] | 0;
+ if ((HEAP32[i6 + 8 >> 2] | 0) != 22 ? (i5 = HEAP32[i6 >> 2] | 0, (i7 | 0) <= (HEAPU8[i5 + 6 | 0] | 0 | 0)) : 0) {
+ i5 = i5 + (i7 + -1 << 4) + 16 | 0;
+ } else {
+ i5 = 5192;
+ }
+ } else {
+ i5 = (HEAP32[i3 >> 2] | 0) + (i6 << 4) | 0;
+ i5 = i5 >>> 0 < (HEAP32[i2 + 8 >> 2] | 0) >>> 0 ? i5 : 5192;
+ }
+ } while (0);
+ do {
+ if ((i4 | 0) <= 0) {
+ if (!((i4 | 0) < -1000999)) {
+ i2 = (HEAP32[i2 + 8 >> 2] | 0) + (i4 << 4) | 0;
+ break;
+ }
+ if ((i4 | 0) == -1001e3) {
+ i2 = (HEAP32[i2 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i2 = -1001e3 - i4 | 0;
+ i3 = HEAP32[i3 >> 2] | 0;
+ if ((HEAP32[i3 + 8 >> 2] | 0) == 22) {
+ i7 = 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ i3 = HEAP32[i3 >> 2] | 0;
+ if ((i2 | 0) > (HEAPU8[i3 + 6 | 0] | 0 | 0)) {
+ i7 = 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ } else {
+ i2 = i3 + (i2 + -1 << 4) + 16 | 0;
+ break;
+ }
+ } else {
+ i3 = (HEAP32[i3 >> 2] | 0) + (i4 << 4) | 0;
+ i2 = i3 >>> 0 < (HEAP32[i2 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ if ((i5 | 0) == 5192 | (i2 | 0) == 5192) {
+ i7 = 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ if ((HEAP32[i5 + 8 >> 2] | 0) == (HEAP32[i2 + 8 >> 2] | 0)) {
+ i2 = (_luaV_equalobj_(0, i5, i2) | 0) != 0;
+ } else {
+ i2 = 0;
+ }
+ i7 = i2 & 1;
+ STACKTOP = i1;
+ return i7 | 0;
+}
+function _luaO_chunkid(i1, i4, i6) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ var i2 = 0, i3 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i2 = STACKTOP;
+ i3 = _strlen(i4 | 0) | 0;
+ i5 = HEAP8[i4] | 0;
+ if (i5 << 24 >> 24 == 64) {
+ if (i3 >>> 0 > i6 >>> 0) {
+ HEAP8[i1 + 0 | 0] = HEAP8[5552 | 0] | 0;
+ HEAP8[i1 + 1 | 0] = HEAP8[5553 | 0] | 0;
+ HEAP8[i1 + 2 | 0] = HEAP8[5554 | 0] | 0;
+ _memcpy(i1 + 3 | 0, i4 + (4 - i6 + i3) | 0, i6 + -3 | 0) | 0;
+ STACKTOP = i2;
+ return;
+ } else {
+ _memcpy(i1 | 0, i4 + 1 | 0, i3 | 0) | 0;
+ STACKTOP = i2;
+ return;
+ }
+ } else if (i5 << 24 >> 24 == 61) {
+ i4 = i4 + 1 | 0;
+ if (i3 >>> 0 > i6 >>> 0) {
+ i9 = i6 + -1 | 0;
+ _memcpy(i1 | 0, i4 | 0, i9 | 0) | 0;
+ HEAP8[i1 + i9 | 0] = 0;
+ STACKTOP = i2;
+ return;
+ } else {
+ _memcpy(i1 | 0, i4 | 0, i3 | 0) | 0;
+ STACKTOP = i2;
+ return;
+ }
+ } else {
+ i5 = _strchr(i4, 10) | 0;
+ i9 = i1 + 0 | 0;
+ i8 = 5560 | 0;
+ i7 = i9 + 9 | 0;
+ do {
+ HEAP8[i9] = HEAP8[i8] | 0;
+ i9 = i9 + 1 | 0;
+ i8 = i8 + 1 | 0;
+ } while ((i9 | 0) < (i7 | 0));
+ i7 = i1 + 9 | 0;
+ i6 = i6 + -15 | 0;
+ i8 = (i5 | 0) == 0;
+ if (i3 >>> 0 < i6 >>> 0 & i8) {
+ _memcpy(i7 | 0, i4 | 0, i3 | 0) | 0;
+ i3 = i3 + 9 | 0;
+ } else {
+ if (!i8) {
+ i3 = i5 - i4 | 0;
+ }
+ i3 = i3 >>> 0 > i6 >>> 0 ? i6 : i3;
+ _memcpy(i7 | 0, i4 | 0, i3 | 0) | 0;
+ i9 = i1 + (i3 + 9) | 0;
+ HEAP8[i9 + 0 | 0] = HEAP8[5552 | 0] | 0;
+ HEAP8[i9 + 1 | 0] = HEAP8[5553 | 0] | 0;
+ HEAP8[i9 + 2 | 0] = HEAP8[5554 | 0] | 0;
+ i3 = i3 + 12 | 0;
+ }
+ i9 = i1 + i3 | 0;
+ HEAP8[i9 + 0 | 0] = HEAP8[5576 | 0] | 0;
+ HEAP8[i9 + 1 | 0] = HEAP8[5577 | 0] | 0;
+ HEAP8[i9 + 2 | 0] = HEAP8[5578 | 0] | 0;
+ STACKTOP = i2;
+ return;
+ }
+}
+function _luaS_resize(i4, i1) {
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i3 = STACKTOP;
+ i5 = HEAP32[i4 + 12 >> 2] | 0;
+ i2 = i5 + 24 | 0;
+ _luaC_runtilstate(i4, -5);
+ i5 = i5 + 32 | 0;
+ i8 = HEAP32[i5 >> 2] | 0;
+ L1 : do {
+ if ((i8 | 0) < (i1 | 0)) {
+ if ((i1 + 1 | 0) >>> 0 > 1073741823) {
+ _luaM_toobig(i4);
+ }
+ i7 = _luaM_realloc_(i4, HEAP32[i2 >> 2] | 0, i8 << 2, i1 << 2) | 0;
+ HEAP32[i2 >> 2] = i7;
+ i6 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) < (i1 | 0)) {
+ i8 = i6;
+ while (1) {
+ HEAP32[i7 + (i8 << 2) >> 2] = 0;
+ i8 = i8 + 1 | 0;
+ if ((i8 | 0) == (i1 | 0)) {
+ i8 = i6;
+ break L1;
+ }
+ i7 = HEAP32[i2 >> 2] | 0;
+ }
+ } else {
+ i8 = i6;
+ }
+ }
+ } while (0);
+ if ((i8 | 0) > 0) {
+ i6 = i1 + -1 | 0;
+ i7 = 0;
+ do {
+ i10 = (HEAP32[i2 >> 2] | 0) + (i7 << 2) | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ HEAP32[i10 >> 2] = 0;
+ if ((i9 | 0) != 0) {
+ while (1) {
+ i8 = HEAP32[i9 >> 2] | 0;
+ i10 = HEAP32[i9 + 8 >> 2] & i6;
+ HEAP32[i9 >> 2] = HEAP32[(HEAP32[i2 >> 2] | 0) + (i10 << 2) >> 2];
+ HEAP32[(HEAP32[i2 >> 2] | 0) + (i10 << 2) >> 2] = i9;
+ i10 = i9 + 5 | 0;
+ HEAP8[i10] = HEAP8[i10] & 191;
+ if ((i8 | 0) == 0) {
+ break;
+ } else {
+ i9 = i8;
+ }
+ }
+ i8 = HEAP32[i5 >> 2] | 0;
+ }
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) < (i8 | 0));
+ }
+ if ((i8 | 0) <= (i1 | 0)) {
+ HEAP32[i5 >> 2] = i1;
+ STACKTOP = i3;
+ return;
+ }
+ if ((i1 + 1 | 0) >>> 0 > 1073741823) {
+ _luaM_toobig(i4);
+ }
+ HEAP32[i2 >> 2] = _luaM_realloc_(i4, HEAP32[i2 >> 2] | 0, i8 << 2, i1 << 2) | 0;
+ HEAP32[i5 >> 2] = i1;
+ STACKTOP = i3;
+ return;
+}
+function _luaD_poscall(i6, i7) {
+ i6 = i6 | 0;
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0;
+ i1 = STACKTOP;
+ i4 = i6 + 16 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAPU8[i6 + 40 | 0] | 0;
+ if ((i5 & 6 | 0) == 0) {
+ i8 = i3 + 8 | 0;
+ } else {
+ if ((i5 & 2 | 0) != 0) {
+ i8 = i6 + 28 | 0;
+ i7 = i7 - (HEAP32[i8 >> 2] | 0) | 0;
+ _luaD_hook(i6, 1, -1);
+ i7 = (HEAP32[i8 >> 2] | 0) + i7 | 0;
+ }
+ i8 = i3 + 8 | 0;
+ HEAP32[i6 + 20 >> 2] = HEAP32[(HEAP32[i8 >> 2] | 0) + 28 >> 2];
+ }
+ i5 = HEAP32[i3 >> 2] | 0;
+ i9 = HEAP16[i3 + 16 >> 1] | 0;
+ i3 = i9 << 16 >> 16;
+ HEAP32[i4 >> 2] = HEAP32[i8 >> 2];
+ i4 = i6 + 8 | 0;
+ if (i9 << 16 >> 16 == 0) {
+ i9 = i5;
+ HEAP32[i4 >> 2] = i9;
+ i9 = i3 + 1 | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+ } else {
+ i6 = i3;
+ }
+ while (1) {
+ if (!(i7 >>> 0 < (HEAP32[i4 >> 2] | 0) >>> 0)) {
+ break;
+ }
+ i8 = i5 + 16 | 0;
+ i11 = i7;
+ i10 = HEAP32[i11 + 4 >> 2] | 0;
+ i9 = i5;
+ HEAP32[i9 >> 2] = HEAP32[i11 >> 2];
+ HEAP32[i9 + 4 >> 2] = i10;
+ HEAP32[i5 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
+ i6 = i6 + -1 | 0;
+ if ((i6 | 0) == 0) {
+ i2 = 12;
+ break;
+ } else {
+ i7 = i7 + 16 | 0;
+ i5 = i8;
+ }
+ }
+ if ((i2 | 0) == 12) {
+ HEAP32[i4 >> 2] = i8;
+ i11 = i3 + 1 | 0;
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ if ((i6 | 0) > 0) {
+ i2 = i6;
+ i7 = i5;
+ } else {
+ i11 = i5;
+ HEAP32[i4 >> 2] = i11;
+ i11 = i3 + 1 | 0;
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ while (1) {
+ i2 = i2 + -1 | 0;
+ HEAP32[i7 + 8 >> 2] = 0;
+ if ((i2 | 0) <= 0) {
+ break;
+ } else {
+ i7 = i7 + 16 | 0;
+ }
+ }
+ i11 = i5 + (i6 << 4) | 0;
+ HEAP32[i4 >> 2] = i11;
+ i11 = i3 + 1 | 0;
+ STACKTOP = i1;
+ return i11 | 0;
+}
+function _lua_rawset(i1, i4) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i2 = STACKTOP;
+ i5 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i4 | 0) <= 0) {
+ if (!((i4 | 0) < -1000999)) {
+ i5 = (HEAP32[i1 + 8 >> 2] | 0) + (i4 << 4) | 0;
+ break;
+ }
+ if ((i4 | 0) == -1001e3) {
+ i5 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i4 = -1001e3 - i4 | 0;
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i5 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i5 >> 2] | 0, (i4 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i5 = i3 + (i4 + -1 << 4) + 16 | 0;
+ } else {
+ i5 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i5 >> 2] | 0) + (i4 << 4) | 0;
+ i5 = i3 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ i4 = i1 + 8 | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ i3 = _luaH_set(i1, HEAP32[i5 >> 2] | 0, i6 + -32 | 0) | 0;
+ i9 = i6 + -16 | 0;
+ i8 = HEAP32[i9 + 4 >> 2] | 0;
+ i7 = i3;
+ HEAP32[i7 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i7 + 4 >> 2] = i8;
+ HEAP32[i3 + 8 >> 2] = HEAP32[i6 + -8 >> 2];
+ HEAP8[(HEAP32[i5 >> 2] | 0) + 6 | 0] = 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i3 + -8 >> 2] & 64 | 0) == 0) {
+ i9 = i3;
+ i9 = i9 + -32 | 0;
+ HEAP32[i4 >> 2] = i9;
+ STACKTOP = i2;
+ return;
+ }
+ if ((HEAP8[(HEAP32[i3 + -16 >> 2] | 0) + 5 | 0] & 3) == 0) {
+ i9 = i3;
+ i9 = i9 + -32 | 0;
+ HEAP32[i4 >> 2] = i9;
+ STACKTOP = i2;
+ return;
+ }
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP8[i5 + 5 | 0] & 4) == 0) {
+ i9 = i3;
+ i9 = i9 + -32 | 0;
+ HEAP32[i4 >> 2] = i9;
+ STACKTOP = i2;
+ return;
+ }
+ _luaC_barrierback_(i1, i5);
+ i9 = HEAP32[i4 >> 2] | 0;
+ i9 = i9 + -32 | 0;
+ HEAP32[i4 >> 2] = i9;
+ STACKTOP = i2;
+ return;
+}
+function _saveSetjmp(i4, i3, i1) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i2 = 0;
+ setjmpId = setjmpId + 1 | 0;
+ HEAP32[i4 >> 2] = setjmpId;
+ while ((i2 | 0) < 40) {
+ if ((HEAP32[i1 + (i2 << 2) >> 2] | 0) == 0) {
+ HEAP32[i1 + (i2 << 2) >> 2] = setjmpId;
+ HEAP32[i1 + ((i2 << 2) + 4) >> 2] = i3;
+ HEAP32[i1 + ((i2 << 2) + 8) >> 2] = 0;
+ return 0;
+ }
+ i2 = i2 + 2 | 0;
+ }
+ _putchar(116);
+ _putchar(111);
+ _putchar(111);
+ _putchar(32);
+ _putchar(109);
+ _putchar(97);
+ _putchar(110);
+ _putchar(121);
+ _putchar(32);
+ _putchar(115);
+ _putchar(101);
+ _putchar(116);
+ _putchar(106);
+ _putchar(109);
+ _putchar(112);
+ _putchar(115);
+ _putchar(32);
+ _putchar(105);
+ _putchar(110);
+ _putchar(32);
+ _putchar(97);
+ _putchar(32);
+ _putchar(102);
+ _putchar(117);
+ _putchar(110);
+ _putchar(99);
+ _putchar(116);
+ _putchar(105);
+ _putchar(111);
+ _putchar(110);
+ _putchar(32);
+ _putchar(99);
+ _putchar(97);
+ _putchar(108);
+ _putchar(108);
+ _putchar(44);
+ _putchar(32);
+ _putchar(98);
+ _putchar(117);
+ _putchar(105);
+ _putchar(108);
+ _putchar(100);
+ _putchar(32);
+ _putchar(119);
+ _putchar(105);
+ _putchar(116);
+ _putchar(104);
+ _putchar(32);
+ _putchar(97);
+ _putchar(32);
+ _putchar(104);
+ _putchar(105);
+ _putchar(103);
+ _putchar(104);
+ _putchar(101);
+ _putchar(114);
+ _putchar(32);
+ _putchar(118);
+ _putchar(97);
+ _putchar(108);
+ _putchar(117);
+ _putchar(101);
+ _putchar(32);
+ _putchar(102);
+ _putchar(111);
+ _putchar(114);
+ _putchar(32);
+ _putchar(77);
+ _putchar(65);
+ _putchar(88);
+ _putchar(95);
+ _putchar(83);
+ _putchar(69);
+ _putchar(84);
+ _putchar(74);
+ _putchar(77);
+ _putchar(80);
+ _putchar(83);
+ _putchar(10);
+ abort(0);
+ return 0;
+}
+function _lua_newthread(i5) {
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i1 = STACKTOP;
+ i3 = i5 + 12 | 0;
+ if ((HEAP32[(HEAP32[i3 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ _luaC_step(i5);
+ }
+ i2 = _luaC_newobj(i5, 8, 112, 0, 0) | 0;
+ i6 = i5 + 8 | 0;
+ i4 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i4 + 8 >> 2] = 72;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + 16;
+ HEAP32[i2 + 12 >> 2] = HEAP32[i3 >> 2];
+ i6 = i2 + 28 | 0;
+ HEAP32[i6 >> 2] = 0;
+ i4 = i2 + 16 | 0;
+ HEAP32[i4 >> 2] = 0;
+ i3 = i2 + 32 | 0;
+ HEAP32[i3 >> 2] = 0;
+ HEAP32[i2 + 64 >> 2] = 0;
+ HEAP16[i2 + 38 >> 1] = 0;
+ i9 = i2 + 52 | 0;
+ HEAP32[i9 >> 2] = 0;
+ i8 = i2 + 40 | 0;
+ HEAP8[i8] = 0;
+ i10 = i2 + 44 | 0;
+ HEAP32[i10 >> 2] = 0;
+ HEAP8[i2 + 41 | 0] = 1;
+ i7 = i2 + 48 | 0;
+ HEAP32[i7 >> 2] = 0;
+ HEAP32[i2 + 56 >> 2] = 0;
+ HEAP16[i2 + 36 >> 1] = 1;
+ HEAP8[i2 + 6 | 0] = 0;
+ HEAP32[i2 + 68 >> 2] = 0;
+ HEAP8[i8] = HEAP8[i5 + 40 | 0] | 0;
+ i8 = HEAP32[i5 + 44 >> 2] | 0;
+ HEAP32[i10 >> 2] = i8;
+ HEAP32[i9 >> 2] = HEAP32[i5 + 52 >> 2];
+ HEAP32[i7 >> 2] = i8;
+ i5 = _luaM_realloc_(i5, 0, 0, 640) | 0;
+ HEAP32[i6 >> 2] = i5;
+ HEAP32[i3 >> 2] = 40;
+ i6 = 0;
+ do {
+ HEAP32[i5 + (i6 << 4) + 8 >> 2] = 0;
+ i6 = i6 + 1 | 0;
+ } while ((i6 | 0) != 40);
+ HEAP32[i2 + 24 >> 2] = i5 + ((HEAP32[i3 >> 2] | 0) + -5 << 4);
+ i10 = i2 + 72 | 0;
+ HEAP32[i2 + 80 >> 2] = 0;
+ HEAP32[i2 + 84 >> 2] = 0;
+ HEAP8[i2 + 90 | 0] = 0;
+ HEAP32[i10 >> 2] = i5;
+ HEAP32[i2 + 8 >> 2] = i5 + 16;
+ HEAP32[i5 + 8 >> 2] = 0;
+ HEAP32[i2 + 76 >> 2] = i5 + 336;
+ HEAP32[i4 >> 2] = i10;
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _luaK_self(i2, i5, i3) {
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i1 = STACKTOP;
+ _luaK_dischargevars(i2, i5);
+ if ((HEAP32[i5 >> 2] | 0) == 6) {
+ i6 = i5 + 8 | 0;
+ i8 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i5 + 16 >> 2] | 0) != (HEAP32[i5 + 20 >> 2] | 0)) {
+ if ((i8 | 0) < (HEAPU8[i2 + 46 | 0] | 0 | 0)) {
+ i7 = 6;
+ } else {
+ _exp2reg(i2, i5, i8);
+ }
+ }
+ } else {
+ i6 = i5 + 8 | 0;
+ i7 = 6;
+ }
+ if ((i7 | 0) == 6) {
+ _luaK_exp2nextreg(i2, i5);
+ }
+ i8 = HEAP32[i6 >> 2] | 0;
+ if (((HEAP32[i5 >> 2] | 0) == 6 ? (i8 & 256 | 0) == 0 : 0) ? (HEAPU8[i2 + 46 | 0] | 0 | 0) <= (i8 | 0) : 0) {
+ i10 = i2 + 48 | 0;
+ HEAP8[i10] = (HEAP8[i10] | 0) + -1 << 24 >> 24;
+ }
+ i7 = i2 + 48 | 0;
+ HEAP32[i6 >> 2] = HEAPU8[i7] | 0;
+ HEAP32[i5 >> 2] = 6;
+ i10 = HEAP8[i7] | 0;
+ i5 = (i10 & 255) + 2 | 0;
+ i9 = (HEAP32[i2 >> 2] | 0) + 78 | 0;
+ do {
+ if (i5 >>> 0 > (HEAPU8[i9] | 0) >>> 0) {
+ if (i5 >>> 0 > 249) {
+ _luaX_syntaxerror(HEAP32[i2 + 12 >> 2] | 0, 10536);
+ } else {
+ HEAP8[i9] = i5;
+ i4 = HEAP8[i7] | 0;
+ break;
+ }
+ } else {
+ i4 = i10;
+ }
+ } while (0);
+ HEAP8[i7] = (i4 & 255) + 2;
+ i10 = HEAP32[i6 >> 2] | 0;
+ _luaK_code(i2, i8 << 23 | i10 << 6 | (_luaK_exp2RK(i2, i3) | 0) << 14 | 12) | 0;
+ if ((HEAP32[i3 >> 2] | 0) != 6) {
+ STACKTOP = i1;
+ return;
+ }
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ if ((i3 & 256 | 0) != 0) {
+ STACKTOP = i1;
+ return;
+ }
+ if ((HEAPU8[i2 + 46 | 0] | 0 | 0) > (i3 | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP8[i7] = (HEAP8[i7] | 0) + -1 << 24 >> 24;
+ STACKTOP = i1;
+ return;
+}
+function _luaD_rawrunprotected(i10, i9, i11) {
+ i10 = i10 | 0;
+ i9 = i9 | 0;
+ i11 = i11 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i12 = 0, i13 = 0;
+ i7 = STACKTOP;
+ STACKTOP = STACKTOP + 176 | 0;
+ i8 = STACKTOP;
+ STACKTOP = STACKTOP + 168 | 0;
+ HEAP32[i8 >> 2] = 0;
+ i6 = i7;
+ i5 = i10 + 38 | 0;
+ i4 = HEAP16[i5 >> 1] | 0;
+ i1 = i6 + 160 | 0;
+ HEAP32[i1 >> 2] = 0;
+ i3 = i10 + 64 | 0;
+ HEAP32[i6 >> 2] = HEAP32[i3 >> 2];
+ HEAP32[i3 >> 2] = i6;
+ _saveSetjmp(i6 + 4 | 0, 1, i8 | 0) | 0;
+ __THREW__ = 0;
+ i13 = __THREW__;
+ __THREW__ = 0;
+ if ((i13 | 0) != 0 & (threwValue | 0) != 0) {
+ i12 = _testSetjmp(HEAP32[i13 >> 2] | 0, i8) | 0;
+ if ((i12 | 0) == 0) {
+ _longjmp(i13 | 0, threwValue | 0);
+ }
+ tempRet0 = threwValue;
+ } else {
+ i12 = -1;
+ }
+ if ((i12 | 0) == 1) {
+ i12 = tempRet0;
+ } else {
+ i12 = 0;
+ }
+ while (1) {
+ if ((i12 | 0) != 0) {
+ i2 = 6;
+ break;
+ }
+ __THREW__ = 0;
+ invoke_vii(i9 | 0, i10 | 0, i11 | 0);
+ i13 = __THREW__;
+ __THREW__ = 0;
+ if ((i13 | 0) != 0 & (threwValue | 0) != 0) {
+ i12 = _testSetjmp(HEAP32[i13 >> 2] | 0, i8) | 0;
+ if ((i12 | 0) == 0) {
+ _longjmp(i13 | 0, threwValue | 0);
+ }
+ tempRet0 = threwValue;
+ } else {
+ i12 = -1;
+ }
+ if ((i12 | 0) == 1) {
+ i12 = tempRet0;
+ } else {
+ break;
+ }
+ }
+ if ((i2 | 0) == 6) {
+ i13 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i3 >> 2] = i13;
+ HEAP16[i5 >> 1] = i4;
+ i13 = HEAP32[i1 >> 2] | 0;
+ STACKTOP = i7;
+ return i13 | 0;
+ }
+ i13 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i3 >> 2] = i13;
+ HEAP16[i5 >> 1] = i4;
+ i13 = HEAP32[i1 >> 2] | 0;
+ STACKTOP = i7;
+ return i13 | 0;
+}
+function _luaB_tonumber(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, d6 = 0.0, i7 = 0, d8 = 0.0, i9 = 0, i10 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2 + 4 | 0;
+ i4 = i2;
+ do {
+ if ((_lua_type(i1, 2) | 0) >= 1) {
+ i9 = _luaL_checklstring(i1, 1, i4) | 0;
+ i3 = i9 + (HEAP32[i4 >> 2] | 0) | 0;
+ i5 = _luaL_checkinteger(i1, 2) | 0;
+ if (!((i5 + -2 | 0) >>> 0 < 35)) {
+ _luaL_argerror(i1, 2, 9648) | 0;
+ }
+ i10 = _strspn(i9, 9672) | 0;
+ i7 = i9 + i10 | 0;
+ i4 = HEAP8[i7] | 0;
+ if (i4 << 24 >> 24 == 43) {
+ i4 = 0;
+ i7 = i9 + (i10 + 1) | 0;
+ } else if (i4 << 24 >> 24 == 45) {
+ i4 = 1;
+ i7 = i9 + (i10 + 1) | 0;
+ } else {
+ i4 = 0;
+ }
+ if ((_isalnum(HEAPU8[i7] | 0 | 0) | 0) != 0) {
+ d6 = +(i5 | 0);
+ d8 = 0.0;
+ do {
+ i9 = HEAP8[i7] | 0;
+ i10 = i9 & 255;
+ if ((i10 + -48 | 0) >>> 0 < 10) {
+ i9 = (i9 << 24 >> 24) + -48 | 0;
+ } else {
+ i9 = (_toupper(i10 | 0) | 0) + -55 | 0;
+ }
+ if ((i9 | 0) >= (i5 | 0)) {
+ break;
+ }
+ d8 = d6 * d8 + +(i9 | 0);
+ i7 = i7 + 1 | 0;
+ } while ((_isalnum(HEAPU8[i7] | 0 | 0) | 0) != 0);
+ if ((i7 + (_strspn(i7, 9672) | 0) | 0) == (i3 | 0)) {
+ if ((i4 | 0) != 0) {
+ d8 = -d8;
+ }
+ _lua_pushnumber(i1, d8);
+ STACKTOP = i2;
+ return 1;
+ }
+ }
+ } else {
+ d6 = +_lua_tonumberx(i1, 1, i3);
+ if ((HEAP32[i3 >> 2] | 0) == 0) {
+ _luaL_checkany(i1, 1);
+ break;
+ }
+ _lua_pushnumber(i1, d6);
+ STACKTOP = i2;
+ return 1;
+ }
+ } while (0);
+ _lua_pushnil(i1);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaK_storevar(i1, i5, i3) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ i7 = HEAP32[i5 >> 2] | 0;
+ if ((i7 | 0) == 7) {
+ if (((HEAP32[i3 >> 2] | 0) == 6 ? (i6 = HEAP32[i3 + 8 >> 2] | 0, (i6 & 256 | 0) == 0) : 0) ? (HEAPU8[i1 + 46 | 0] | 0) <= (i6 | 0) : 0) {
+ i7 = i1 + 48 | 0;
+ HEAP8[i7] = (HEAP8[i7] | 0) + -1 << 24 >> 24;
+ }
+ _exp2reg(i1, i3, HEAP32[i5 + 8 >> 2] | 0);
+ STACKTOP = i2;
+ return;
+ } else if ((i7 | 0) == 9) {
+ i4 = i5 + 8 | 0;
+ i7 = (HEAP8[i4 + 3 | 0] | 0) == 7 ? 10 : 8;
+ i6 = _luaK_exp2RK(i1, i3) | 0;
+ _luaK_code(i1, i6 << 14 | i7 | HEAPU8[i4 + 2 | 0] << 6 | HEAPU16[i4 >> 1] << 23) | 0;
+ } else if ((i7 | 0) == 8) {
+ _luaK_dischargevars(i1, i3);
+ if ((HEAP32[i3 >> 2] | 0) == 6) {
+ i6 = i3 + 8 | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i3 + 16 >> 2] | 0) != (HEAP32[i3 + 20 >> 2] | 0)) {
+ if ((i7 | 0) < (HEAPU8[i1 + 46 | 0] | 0)) {
+ i4 = 12;
+ } else {
+ _exp2reg(i1, i3, i7);
+ i7 = HEAP32[i6 >> 2] | 0;
+ }
+ }
+ } else {
+ i6 = i3 + 8 | 0;
+ i4 = 12;
+ }
+ if ((i4 | 0) == 12) {
+ _luaK_exp2nextreg(i1, i3);
+ i7 = HEAP32[i6 >> 2] | 0;
+ }
+ _luaK_code(i1, i7 << 6 | HEAP32[i5 + 8 >> 2] << 23 | 9) | 0;
+ }
+ if ((HEAP32[i3 >> 2] | 0) != 6) {
+ STACKTOP = i2;
+ return;
+ }
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ if ((i3 & 256 | 0) != 0) {
+ STACKTOP = i2;
+ return;
+ }
+ if ((HEAPU8[i1 + 46 | 0] | 0) > (i3 | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ i7 = i1 + 48 | 0;
+ HEAP8[i7] = (HEAP8[i7] | 0) + -1 << 24 >> 24;
+ STACKTOP = i2;
+ return;
+}
+function _closegoto(i10, i3, i9) {
+ i10 = i10 | 0;
+ i3 = i3 | 0;
+ i9 = i9 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i11 = 0, i12 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i7 = i1;
+ i4 = HEAP32[i10 + 48 >> 2] | 0;
+ i6 = HEAP32[i10 + 64 >> 2] | 0;
+ i2 = i6 + 12 | 0;
+ i5 = HEAP32[i2 >> 2] | 0;
+ i8 = HEAP8[i5 + (i3 << 4) + 12 | 0] | 0;
+ if ((i8 & 255) < (HEAPU8[i9 + 12 | 0] | 0)) {
+ i11 = HEAP32[i10 + 52 >> 2] | 0;
+ i12 = HEAP32[i5 + (i3 << 4) + 8 >> 2] | 0;
+ i8 = (HEAP32[(HEAP32[(HEAP32[i4 >> 2] | 0) + 24 >> 2] | 0) + ((HEAP16[(HEAP32[HEAP32[(HEAP32[i4 + 12 >> 2] | 0) + 64 >> 2] >> 2] | 0) + ((HEAP32[i4 + 40 >> 2] | 0) + (i8 & 255) << 1) >> 1] | 0) * 12 | 0) >> 2] | 0) + 16 | 0;
+ HEAP32[i7 >> 2] = (HEAP32[i5 + (i3 << 4) >> 2] | 0) + 16;
+ HEAP32[i7 + 4 >> 2] = i12;
+ HEAP32[i7 + 8 >> 2] = i8;
+ _semerror(i10, _luaO_pushfstring(i11, 6248, i7) | 0);
+ }
+ _luaK_patchlist(i4, HEAP32[i5 + (i3 << 4) + 4 >> 2] | 0, HEAP32[i9 + 4 >> 2] | 0);
+ i4 = i6 + 16 | 0;
+ i5 = (HEAP32[i4 >> 2] | 0) + -1 | 0;
+ if ((i5 | 0) <= (i3 | 0)) {
+ i12 = i5;
+ HEAP32[i4 >> 2] = i12;
+ STACKTOP = i1;
+ return;
+ }
+ do {
+ i12 = HEAP32[i2 >> 2] | 0;
+ i5 = i12 + (i3 << 4) | 0;
+ i3 = i3 + 1 | 0;
+ i12 = i12 + (i3 << 4) | 0;
+ HEAP32[i5 + 0 >> 2] = HEAP32[i12 + 0 >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[i12 + 4 >> 2];
+ HEAP32[i5 + 8 >> 2] = HEAP32[i12 + 8 >> 2];
+ HEAP32[i5 + 12 >> 2] = HEAP32[i12 + 12 >> 2];
+ i5 = (HEAP32[i4 >> 2] | 0) + -1 | 0;
+ } while ((i3 | 0) < (i5 | 0));
+ HEAP32[i4 >> 2] = i5;
+ STACKTOP = i1;
+ return;
+}
+function _luaM_growaux_(i4, i5, i1, i7, i8, i9) {
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ i7 = i7 | 0;
+ i8 = i8 | 0;
+ i9 = i9 | 0;
+ var i2 = 0, i3 = 0, i6 = 0, i10 = 0, i11 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i10 = i2;
+ i6 = HEAP32[i1 >> 2] | 0;
+ if ((i6 | 0) >= ((i8 | 0) / 2 | 0 | 0)) {
+ if ((i6 | 0) < (i8 | 0)) {
+ i3 = i8;
+ } else {
+ HEAP32[i10 >> 2] = i9;
+ HEAP32[i10 + 4 >> 2] = i8;
+ _luaG_runerror(i4, 4112, i10);
+ }
+ } else {
+ i3 = i6 << 1;
+ i3 = (i3 | 0) < 4 ? 4 : i3;
+ }
+ if ((i3 + 1 | 0) >>> 0 > (4294967293 / (i7 >>> 0) | 0) >>> 0) {
+ _luaM_toobig(i4);
+ }
+ i6 = Math_imul(i6, i7) | 0;
+ i8 = Math_imul(i3, i7) | 0;
+ i9 = HEAP32[i4 + 12 >> 2] | 0;
+ i7 = (i5 | 0) != 0;
+ i11 = i9 + 4 | 0;
+ i10 = FUNCTION_TABLE_iiiii[HEAP32[i9 >> 2] & 3](HEAP32[i11 >> 2] | 0, i5, i6, i8) | 0;
+ if ((i10 | 0) != 0 | (i8 | 0) == 0) {
+ i5 = i9 + 12 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i6 = 0 - i6 | 0;
+ i11 = i7 ? i6 : 0;
+ i11 = i11 + i8 | 0;
+ i11 = i11 + i4 | 0;
+ HEAP32[i5 >> 2] = i11;
+ HEAP32[i1 >> 2] = i3;
+ STACKTOP = i2;
+ return i10 | 0;
+ }
+ if ((HEAP8[i9 + 63 | 0] | 0) == 0) {
+ _luaD_throw(i4, 4);
+ }
+ _luaC_fullgc(i4, 1);
+ i10 = FUNCTION_TABLE_iiiii[HEAP32[i9 >> 2] & 3](HEAP32[i11 >> 2] | 0, i5, i6, i8) | 0;
+ if ((i10 | 0) == 0) {
+ _luaD_throw(i4, 4);
+ } else {
+ i5 = i9 + 12 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i6 = 0 - i6 | 0;
+ i11 = i7 ? i6 : 0;
+ i11 = i11 + i8 | 0;
+ i11 = i11 + i4 | 0;
+ HEAP32[i5 >> 2] = i11;
+ HEAP32[i1 >> 2] = i3;
+ STACKTOP = i2;
+ return i10 | 0;
+ }
+ return 0;
+}
+function _luaD_hook(i5, i14, i13) {
+ i5 = i5 | 0;
+ i14 = i14 | 0;
+ i13 = i13 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i15 = 0, i16 = 0;
+ i11 = STACKTOP;
+ STACKTOP = STACKTOP + 112 | 0;
+ i4 = i11;
+ i3 = HEAP32[i5 + 52 >> 2] | 0;
+ if ((i3 | 0) == 0) {
+ STACKTOP = i11;
+ return;
+ }
+ i8 = i5 + 41 | 0;
+ if ((HEAP8[i8] | 0) == 0) {
+ STACKTOP = i11;
+ return;
+ }
+ i10 = HEAP32[i5 + 16 >> 2] | 0;
+ i6 = i5 + 8 | 0;
+ i15 = HEAP32[i6 >> 2] | 0;
+ i1 = i5 + 28 | 0;
+ i16 = i15;
+ i12 = HEAP32[i1 >> 2] | 0;
+ i7 = i16 - i12 | 0;
+ i9 = i10 + 4 | 0;
+ i12 = (HEAP32[i9 >> 2] | 0) - i12 | 0;
+ HEAP32[i4 >> 2] = i14;
+ HEAP32[i4 + 20 >> 2] = i13;
+ HEAP32[i4 + 96 >> 2] = i10;
+ do {
+ if (((HEAP32[i5 + 24 >> 2] | 0) - i16 | 0) < 336) {
+ i14 = HEAP32[i5 + 32 >> 2] | 0;
+ if ((i14 | 0) > 1e6) {
+ _luaD_throw(i5, 6);
+ }
+ i13 = (i7 >> 4) + 25 | 0;
+ i14 = i14 << 1;
+ i14 = (i14 | 0) > 1e6 ? 1e6 : i14;
+ i13 = (i14 | 0) < (i13 | 0) ? i13 : i14;
+ if ((i13 | 0) > 1e6) {
+ _luaD_reallocstack(i5, 1000200);
+ _luaG_runerror(i5, 2224, i4);
+ } else {
+ _luaD_reallocstack(i5, i13);
+ i2 = HEAP32[i6 >> 2] | 0;
+ break;
+ }
+ } else {
+ i2 = i15;
+ }
+ } while (0);
+ HEAP32[i9 >> 2] = i2 + 320;
+ HEAP8[i8] = 0;
+ i16 = i10 + 18 | 0;
+ HEAP8[i16] = HEAPU8[i16] | 2;
+ FUNCTION_TABLE_vii[i3 & 15](i5, i4);
+ HEAP8[i8] = 1;
+ HEAP32[i9 >> 2] = (HEAP32[i1 >> 2] | 0) + i12;
+ HEAP32[i6 >> 2] = (HEAP32[i1 >> 2] | 0) + i7;
+ HEAP8[i16] = HEAP8[i16] & 253;
+ STACKTOP = i11;
+ return;
+}
+function _funcargs(i10, i2, i1) {
+ i10 = i10 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i6 = i3;
+ i9 = i10 + 48 | 0;
+ i5 = HEAP32[i9 >> 2] | 0;
+ i7 = i10 + 16 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if ((i8 | 0) == 289) {
+ i9 = _luaK_stringK(i5, HEAP32[i10 + 24 >> 2] | 0) | 0;
+ HEAP32[i6 + 16 >> 2] = -1;
+ HEAP32[i6 + 20 >> 2] = -1;
+ HEAP32[i6 >> 2] = 4;
+ HEAP32[i6 + 8 >> 2] = i9;
+ _luaX_next(i10);
+ } else if ((i8 | 0) == 40) {
+ _luaX_next(i10);
+ if ((HEAP32[i7 >> 2] | 0) == 41) {
+ HEAP32[i6 >> 2] = 0;
+ } else {
+ _subexpr(i10, i6, 0) | 0;
+ if ((HEAP32[i7 >> 2] | 0) == 44) {
+ do {
+ _luaX_next(i10);
+ _luaK_exp2nextreg(HEAP32[i9 >> 2] | 0, i6);
+ _subexpr(i10, i6, 0) | 0;
+ } while ((HEAP32[i7 >> 2] | 0) == 44);
+ }
+ _luaK_setreturns(i5, i6, -1);
+ }
+ _check_match(i10, 41, 40, i1);
+ } else if ((i8 | 0) == 123) {
+ _constructor(i10, i6);
+ } else {
+ _luaX_syntaxerror(i10, 6624);
+ }
+ i8 = i2 + 8 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ i9 = HEAP32[i6 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ i4 = 13;
+ } else if ((i9 | 0) == 13 | (i9 | 0) == 12) {
+ i6 = 0;
+ } else {
+ _luaK_exp2nextreg(i5, i6);
+ i4 = 13;
+ }
+ if ((i4 | 0) == 13) {
+ i6 = (HEAPU8[i5 + 48 | 0] | 0) - i7 | 0;
+ }
+ i10 = _luaK_codeABC(i5, 29, i7, i6, 2) | 0;
+ HEAP32[i2 + 16 >> 2] = -1;
+ HEAP32[i2 + 20 >> 2] = -1;
+ HEAP32[i2 >> 2] = 12;
+ HEAP32[i8 >> 2] = i10;
+ _luaK_fixline(i5, i1);
+ HEAP8[i5 + 48 | 0] = i7 + 1;
+ STACKTOP = i3;
+ return;
+}
+function _luaD_reallocstack(i3, i6) {
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i1 = STACKTOP;
+ i2 = i3 + 28 | 0;
+ i8 = HEAP32[i2 >> 2] | 0;
+ i7 = i3 + 32 | 0;
+ i9 = HEAP32[i7 >> 2] | 0;
+ if ((i6 + 1 | 0) >>> 0 > 268435455) {
+ _luaM_toobig(i3);
+ }
+ i5 = _luaM_realloc_(i3, i8, i9 << 4, i6 << 4) | 0;
+ HEAP32[i2 >> 2] = i5;
+ if ((i9 | 0) < (i6 | 0)) {
+ do {
+ HEAP32[i5 + (i9 << 4) + 8 >> 2] = 0;
+ i9 = i9 + 1 | 0;
+ } while ((i9 | 0) != (i6 | 0));
+ }
+ HEAP32[i7 >> 2] = i6;
+ HEAP32[i3 + 24 >> 2] = i5 + (i6 + -5 << 4);
+ i6 = i3 + 8 | 0;
+ HEAP32[i6 >> 2] = i5 + ((HEAP32[i6 >> 2] | 0) - i8 >> 4 << 4);
+ i6 = HEAP32[i3 + 56 >> 2] | 0;
+ if ((i6 | 0) != 0 ? (i4 = i6 + 8 | 0, HEAP32[i4 >> 2] = i5 + ((HEAP32[i4 >> 2] | 0) - i8 >> 4 << 4), i4 = HEAP32[i6 >> 2] | 0, (i4 | 0) != 0) : 0) {
+ do {
+ i9 = i4 + 8 | 0;
+ HEAP32[i9 >> 2] = (HEAP32[i2 >> 2] | 0) + ((HEAP32[i9 >> 2] | 0) - i8 >> 4 << 4);
+ i4 = HEAP32[i4 >> 2] | 0;
+ } while ((i4 | 0) != 0);
+ }
+ i3 = HEAP32[i3 + 16 >> 2] | 0;
+ if ((i3 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ do {
+ i9 = i3 + 4 | 0;
+ HEAP32[i9 >> 2] = (HEAP32[i2 >> 2] | 0) + ((HEAP32[i9 >> 2] | 0) - i8 >> 4 << 4);
+ HEAP32[i3 >> 2] = (HEAP32[i2 >> 2] | 0) + ((HEAP32[i3 >> 2] | 0) - i8 >> 4 << 4);
+ if (!((HEAP8[i3 + 18 | 0] & 1) == 0)) {
+ i9 = i3 + 24 | 0;
+ HEAP32[i9 >> 2] = (HEAP32[i2 >> 2] | 0) + ((HEAP32[i9 >> 2] | 0) - i8 >> 4 << 4);
+ }
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ } while ((i3 | 0) != 0);
+ STACKTOP = i1;
+ return;
+}
+function _luaF_close(i7, i6) {
+ i7 = i7 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0;
+ i1 = STACKTOP;
+ i4 = HEAP32[i7 + 12 >> 2] | 0;
+ i3 = i7 + 56 | 0;
+ i8 = HEAP32[i3 >> 2] | 0;
+ if ((i8 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i5 = i4 + 60 | 0;
+ i2 = i4 + 68 | 0;
+ while (1) {
+ i9 = i8 + 8 | 0;
+ if ((HEAP32[i9 >> 2] | 0) >>> 0 < i6 >>> 0) {
+ i2 = 10;
+ break;
+ }
+ HEAP32[i3 >> 2] = HEAP32[i8 >> 2];
+ if ((((HEAPU8[i5] | 0) ^ 3) & ((HEAPU8[i8 + 5 | 0] | 0) ^ 3) | 0) == 0) {
+ if ((HEAP32[i9 >> 2] | 0) != (i8 + 16 | 0)) {
+ i9 = i8 + 16 | 0;
+ i10 = i9 + 4 | 0;
+ HEAP32[(HEAP32[i10 >> 2] | 0) + 16 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[(HEAP32[i9 >> 2] | 0) + 20 >> 2] = HEAP32[i10 >> 2];
+ }
+ _luaM_realloc_(i7, i8, 32, 0) | 0;
+ } else {
+ i11 = i8 + 16 | 0;
+ i10 = i11 + 4 | 0;
+ HEAP32[(HEAP32[i10 >> 2] | 0) + 16 >> 2] = HEAP32[i11 >> 2];
+ HEAP32[(HEAP32[i11 >> 2] | 0) + 20 >> 2] = HEAP32[i10 >> 2];
+ i11 = HEAP32[i9 >> 2] | 0;
+ i10 = i8 + 16 | 0;
+ i14 = i11;
+ i13 = HEAP32[i14 + 4 >> 2] | 0;
+ i12 = i10;
+ HEAP32[i12 >> 2] = HEAP32[i14 >> 2];
+ HEAP32[i12 + 4 >> 2] = i13;
+ HEAP32[i8 + 24 >> 2] = HEAP32[i11 + 8 >> 2];
+ HEAP32[i9 >> 2] = i10;
+ HEAP32[i8 >> 2] = HEAP32[i2 >> 2];
+ HEAP32[i2 >> 2] = i8;
+ _luaC_checkupvalcolor(i4, i8);
+ }
+ i8 = HEAP32[i3 >> 2] | 0;
+ if ((i8 | 0) == 0) {
+ i2 = 10;
+ break;
+ }
+ }
+ if ((i2 | 0) == 10) {
+ STACKTOP = i1;
+ return;
+ }
+}
+function _luaK_dischargevars(i3, i1) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ switch (HEAP32[i1 >> 2] | 0) {
+ case 12:
+ {
+ HEAP32[i1 >> 2] = 6;
+ i6 = i1 + 8 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[(HEAP32[(HEAP32[i3 >> 2] | 0) + 12 >> 2] | 0) + (HEAP32[i6 >> 2] << 2) >> 2] | 0) >>> 6 & 255;
+ STACKTOP = i2;
+ return;
+ }
+ case 13:
+ {
+ i6 = (HEAP32[(HEAP32[i3 >> 2] | 0) + 12 >> 2] | 0) + (HEAP32[i1 + 8 >> 2] << 2) | 0;
+ HEAP32[i6 >> 2] = HEAP32[i6 >> 2] & 8388607 | 16777216;
+ HEAP32[i1 >> 2] = 11;
+ STACKTOP = i2;
+ return;
+ }
+ case 9:
+ {
+ i4 = i1 + 8 | 0;
+ i5 = HEAP16[i4 >> 1] | 0;
+ if ((i5 & 256 | 0) == 0 ? (HEAPU8[i3 + 46 | 0] | 0) <= (i5 | 0) : 0) {
+ i6 = i3 + 48 | 0;
+ HEAP8[i6] = (HEAP8[i6] | 0) + -1 << 24 >> 24;
+ }
+ i5 = i4 + 2 | 0;
+ if ((HEAP8[i4 + 3 | 0] | 0) == 7) {
+ if ((HEAPU8[i3 + 46 | 0] | 0) > (HEAPU8[i5] | 0)) {
+ i6 = 7;
+ } else {
+ i6 = i3 + 48 | 0;
+ HEAP8[i6] = (HEAP8[i6] | 0) + -1 << 24 >> 24;
+ i6 = 7;
+ }
+ } else {
+ i6 = 6;
+ }
+ HEAP32[i4 >> 2] = _luaK_code(i3, HEAPU8[i5] << 23 | i6 | HEAP16[i4 >> 1] << 14) | 0;
+ HEAP32[i1 >> 2] = 11;
+ STACKTOP = i2;
+ return;
+ }
+ case 7:
+ {
+ HEAP32[i1 >> 2] = 6;
+ STACKTOP = i2;
+ return;
+ }
+ case 8:
+ {
+ i6 = i1 + 8 | 0;
+ HEAP32[i6 >> 2] = _luaK_code(i3, HEAP32[i6 >> 2] << 23 | 5) | 0;
+ HEAP32[i1 >> 2] = 11;
+ STACKTOP = i2;
+ return;
+ }
+ default:
+ {
+ STACKTOP = i2;
+ return;
+ }
+ }
+}
+function _gmatch_aux(i10) {
+ i10 = i10 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i11 = 0, i12 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 288 | 0;
+ i2 = i1 + 8 | 0;
+ i12 = i1 + 4 | 0;
+ i3 = i1;
+ i8 = _lua_tolstring(i10, -1001001, i12) | 0;
+ i7 = _lua_tolstring(i10, -1001002, i3) | 0;
+ i5 = i2 + 16 | 0;
+ HEAP32[i5 >> 2] = i10;
+ HEAP32[i2 >> 2] = 200;
+ HEAP32[i2 + 4 >> 2] = i8;
+ i9 = i2 + 8 | 0;
+ HEAP32[i9 >> 2] = i8 + (HEAP32[i12 >> 2] | 0);
+ HEAP32[i2 + 12 >> 2] = i7 + (HEAP32[i3 >> 2] | 0);
+ i3 = i8 + (_lua_tointegerx(i10, -1001003, 0) | 0) | 0;
+ if (i3 >>> 0 > (HEAP32[i9 >> 2] | 0) >>> 0) {
+ i12 = 0;
+ STACKTOP = i1;
+ return i12 | 0;
+ }
+ i11 = i2 + 20 | 0;
+ while (1) {
+ HEAP32[i11 >> 2] = 0;
+ i4 = _match(i2, i3, i7) | 0;
+ i12 = i3 + 1 | 0;
+ if ((i4 | 0) != 0) {
+ break;
+ }
+ if (i12 >>> 0 > (HEAP32[i9 >> 2] | 0) >>> 0) {
+ i2 = 0;
+ i6 = 7;
+ break;
+ } else {
+ i3 = i12;
+ }
+ }
+ if ((i6 | 0) == 7) {
+ STACKTOP = i1;
+ return i2 | 0;
+ }
+ _lua_pushinteger(i10, i4 - i8 + ((i4 | 0) == (i3 | 0)) | 0);
+ _lua_replace(i10, -1001003);
+ i7 = HEAP32[i11 >> 2] | 0;
+ i6 = (i7 | 0) != 0 | (i3 | 0) == 0 ? i7 : 1;
+ _luaL_checkstack(HEAP32[i5 >> 2] | 0, i6, 7200);
+ if ((i6 | 0) > 0) {
+ i5 = 0;
+ } else {
+ i12 = i7;
+ STACKTOP = i1;
+ return i12 | 0;
+ }
+ while (1) {
+ _push_onecapture(i2, i5, i3, i4);
+ i5 = i5 + 1 | 0;
+ if ((i5 | 0) == (i6 | 0)) {
+ i2 = i6;
+ break;
+ }
+ }
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _lua_rawseti(i1, i5, i3) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i6 = 0;
+ i2 = STACKTOP;
+ i6 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i5 = (HEAP32[i1 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i5 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i5 | 0;
+ i6 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i6 + 8 >> 2] | 0) != 22 ? (i4 = HEAP32[i6 >> 2] | 0, (i5 | 0) <= (HEAPU8[i4 + 6 | 0] | 0 | 0)) : 0) {
+ i5 = i4 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i5 = 5192;
+ }
+ } else {
+ i4 = (HEAP32[i6 >> 2] | 0) + (i5 << 4) | 0;
+ i5 = i4 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i4 : 5192;
+ }
+ } while (0);
+ i4 = i1 + 8 | 0;
+ _luaH_setint(i1, HEAP32[i5 >> 2] | 0, i3, (HEAP32[i4 >> 2] | 0) + -16 | 0);
+ i3 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i3 + -8 >> 2] & 64 | 0) == 0) {
+ i6 = i3;
+ i6 = i6 + -16 | 0;
+ HEAP32[i4 >> 2] = i6;
+ STACKTOP = i2;
+ return;
+ }
+ if ((HEAP8[(HEAP32[i3 + -16 >> 2] | 0) + 5 | 0] & 3) == 0) {
+ i6 = i3;
+ i6 = i6 + -16 | 0;
+ HEAP32[i4 >> 2] = i6;
+ STACKTOP = i2;
+ return;
+ }
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP8[i5 + 5 | 0] & 4) == 0) {
+ i6 = i3;
+ i6 = i6 + -16 | 0;
+ HEAP32[i4 >> 2] = i6;
+ STACKTOP = i2;
+ return;
+ }
+ _luaC_barrierback_(i1, i5);
+ i6 = HEAP32[i4 >> 2] | 0;
+ i6 = i6 + -16 | 0;
+ HEAP32[i4 >> 2] = i6;
+ STACKTOP = i2;
+ return;
+}
+function _ll_require(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 1056 | 0;
+ i5 = i2;
+ i4 = i2 + 8 | 0;
+ i3 = _luaL_checklstring(i1, 1, 0) | 0;
+ _lua_settop(i1, 1);
+ _lua_getfield(i1, -1001e3, 4576);
+ _lua_getfield(i1, 2, i3);
+ if ((_lua_toboolean(i1, -1) | 0) != 0) {
+ STACKTOP = i2;
+ return 1;
+ }
+ _lua_settop(i1, -2);
+ _luaL_buffinit(i1, i4);
+ _lua_getfield(i1, -1001001, 4240);
+ if ((_lua_type(i1, 3) | 0) == 5) {
+ i6 = 1;
+ } else {
+ _luaL_error(i1, 4656, i5) | 0;
+ i6 = 1;
+ }
+ while (1) {
+ _lua_rawgeti(i1, 3, i6);
+ if ((_lua_type(i1, -1) | 0) == 0) {
+ _lua_settop(i1, -2);
+ _luaL_pushresult(i4);
+ i7 = _lua_tolstring(i1, -1, 0) | 0;
+ HEAP32[i5 >> 2] = i3;
+ HEAP32[i5 + 4 >> 2] = i7;
+ _luaL_error(i1, 4696, i5) | 0;
+ }
+ _lua_pushstring(i1, i3) | 0;
+ _lua_callk(i1, 1, 2, 0, 0);
+ if ((_lua_type(i1, -2) | 0) == 6) {
+ break;
+ }
+ if ((_lua_isstring(i1, -2) | 0) == 0) {
+ _lua_settop(i1, -3);
+ } else {
+ _lua_settop(i1, -2);
+ _luaL_addvalue(i4);
+ }
+ i6 = i6 + 1 | 0;
+ }
+ _lua_pushstring(i1, i3) | 0;
+ _lua_insert(i1, -2);
+ _lua_callk(i1, 2, 1, 0, 0);
+ if ((_lua_type(i1, -1) | 0) != 0) {
+ _lua_setfield(i1, 2, i3);
+ }
+ _lua_getfield(i1, 2, i3);
+ if ((_lua_type(i1, -1) | 0) != 0) {
+ STACKTOP = i2;
+ return 1;
+ }
+ _lua_pushboolean(i1, 1);
+ _lua_pushvalue(i1, -1);
+ _lua_setfield(i1, 2, i3);
+ STACKTOP = i2;
+ return 1;
+}
+function _f_parser(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ i5 = HEAP32[i3 >> 2] | 0;
+ i8 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i8 + -1;
+ if ((i8 | 0) == 0) {
+ i6 = _luaZ_fill(i5) | 0;
+ } else {
+ i8 = i5 + 4 | 0;
+ i6 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i6 + 1;
+ i6 = HEAPU8[i6] | 0;
+ }
+ i5 = HEAP32[i3 + 52 >> 2] | 0;
+ i7 = (i5 | 0) == 0;
+ if ((i6 | 0) == 27) {
+ if (!i7 ? (_strchr(i5, 98) | 0) == 0 : 0) {
+ HEAP32[i4 >> 2] = 2360;
+ HEAP32[i4 + 4 >> 2] = i5;
+ _luaO_pushfstring(i1, 2376, i4) | 0;
+ _luaD_throw(i1, 3);
+ }
+ i8 = _luaU_undump(i1, HEAP32[i3 >> 2] | 0, i3 + 4 | 0, HEAP32[i3 + 56 >> 2] | 0) | 0;
+ } else {
+ if (!i7 ? (_strchr(i5, 116) | 0) == 0 : 0) {
+ HEAP32[i4 >> 2] = 2368;
+ HEAP32[i4 + 4 >> 2] = i5;
+ _luaO_pushfstring(i1, 2376, i4) | 0;
+ _luaD_throw(i1, 3);
+ }
+ i8 = _luaY_parser(i1, HEAP32[i3 >> 2] | 0, i3 + 4 | 0, i3 + 16 | 0, HEAP32[i3 + 56 >> 2] | 0, i6) | 0;
+ }
+ i7 = i8 + 6 | 0;
+ if ((HEAP8[i7] | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i5 = i8 + 16 | 0;
+ i6 = i8 + 5 | 0;
+ i4 = 0;
+ do {
+ i3 = _luaF_newupval(i1) | 0;
+ HEAP32[i5 + (i4 << 2) >> 2] = i3;
+ if (!((HEAP8[i3 + 5 | 0] & 3) == 0) ? !((HEAP8[i6] & 4) == 0) : 0) {
+ _luaC_barrier_(i1, i8, i3);
+ }
+ i4 = i4 + 1 | 0;
+ } while ((i4 | 0) < (HEAPU8[i7] | 0));
+ STACKTOP = i2;
+ return;
+}
+function _str_rep(i9) {
+ i9 = i9 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i10 = 0, i11 = 0, i12 = 0;
+ i6 = STACKTOP;
+ STACKTOP = STACKTOP + 1056 | 0;
+ i4 = i6;
+ i2 = i6 + 1044 | 0;
+ i3 = i6 + 1040 | 0;
+ i1 = _luaL_checklstring(i9, 1, i2) | 0;
+ i8 = _luaL_checkinteger(i9, 2) | 0;
+ i5 = _luaL_optlstring(i9, 3, 7040, i3) | 0;
+ if ((i8 | 0) < 1) {
+ _lua_pushlstring(i9, 7040, 0) | 0;
+ i12 = 1;
+ STACKTOP = i6;
+ return i12 | 0;
+ }
+ i7 = HEAP32[i2 >> 2] | 0;
+ i10 = HEAP32[i3 >> 2] | 0;
+ i11 = i10 + i7 | 0;
+ if (!(i11 >>> 0 < i7 >>> 0) ? i11 >>> 0 < (2147483647 / (i8 >>> 0) | 0) >>> 0 : 0) {
+ i7 = (Math_imul(i10, i8 + -1 | 0) | 0) + (Math_imul(i7, i8) | 0) | 0;
+ i11 = _luaL_buffinitsize(i9, i4, i7) | 0;
+ _memcpy(i11 | 0, i1 | 0, HEAP32[i2 >> 2] | 0) | 0;
+ if ((i8 | 0) > 1) {
+ while (1) {
+ i8 = i8 + -1 | 0;
+ i9 = HEAP32[i2 >> 2] | 0;
+ i10 = i11 + i9 | 0;
+ i12 = HEAP32[i3 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i12 = i9;
+ } else {
+ _memcpy(i10 | 0, i5 | 0, i12 | 0) | 0;
+ i12 = HEAP32[i2 >> 2] | 0;
+ i10 = i11 + ((HEAP32[i3 >> 2] | 0) + i9) | 0;
+ }
+ _memcpy(i10 | 0, i1 | 0, i12 | 0) | 0;
+ if ((i8 | 0) <= 1) {
+ break;
+ } else {
+ i11 = i10;
+ }
+ }
+ }
+ _luaL_pushresultsize(i4, i7);
+ i12 = 1;
+ STACKTOP = i6;
+ return i12 | 0;
+ }
+ i12 = _luaL_error(i9, 7168, i4) | 0;
+ STACKTOP = i6;
+ return i12 | 0;
+}
+function ___strchrnul(i6, i2) {
+ i6 = i6 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0;
+ i1 = STACKTOP;
+ i3 = i2 & 255;
+ if ((i3 | 0) == 0) {
+ i7 = i6 + (_strlen(i6 | 0) | 0) | 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ L5 : do {
+ if ((i6 & 3 | 0) != 0) {
+ i4 = i2 & 255;
+ while (1) {
+ i5 = HEAP8[i6] | 0;
+ if (i5 << 24 >> 24 == 0) {
+ i4 = i6;
+ i5 = 13;
+ break;
+ }
+ i7 = i6 + 1 | 0;
+ if (i5 << 24 >> 24 == i4 << 24 >> 24) {
+ i4 = i6;
+ i5 = 13;
+ break;
+ }
+ if ((i7 & 3 | 0) == 0) {
+ i4 = i7;
+ break L5;
+ } else {
+ i6 = i7;
+ }
+ }
+ if ((i5 | 0) == 13) {
+ STACKTOP = i1;
+ return i4 | 0;
+ }
+ } else {
+ i4 = i6;
+ }
+ } while (0);
+ i3 = Math_imul(i3, 16843009) | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ L15 : do {
+ if (((i6 & -2139062144 ^ -2139062144) & i6 + -16843009 | 0) == 0) {
+ while (1) {
+ i7 = i6 ^ i3;
+ i5 = i4 + 4 | 0;
+ if (((i7 & -2139062144 ^ -2139062144) & i7 + -16843009 | 0) != 0) {
+ break L15;
+ }
+ i6 = HEAP32[i5 >> 2] | 0;
+ if (((i6 & -2139062144 ^ -2139062144) & i6 + -16843009 | 0) == 0) {
+ i4 = i5;
+ } else {
+ i4 = i5;
+ break;
+ }
+ }
+ }
+ } while (0);
+ i2 = i2 & 255;
+ while (1) {
+ i7 = HEAP8[i4] | 0;
+ if (i7 << 24 >> 24 == 0 | i7 << 24 >> 24 == i2 << 24 >> 24) {
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ }
+ }
+ STACKTOP = i1;
+ return i4 | 0;
+}
+function _lua_replace(i2, i6) {
+ i2 = i2 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i3 = STACKTOP;
+ i7 = i2 + 8 | 0;
+ i9 = HEAP32[i7 >> 2] | 0;
+ i5 = i9 + -16 | 0;
+ i4 = i2 + 16 | 0;
+ i12 = HEAP32[i4 >> 2] | 0;
+ do {
+ if ((i6 | 0) <= 0) {
+ if (!((i6 | 0) < -1000999)) {
+ i10 = i9 + (i6 << 4) | 0;
+ break;
+ }
+ if ((i6 | 0) == -1001e3) {
+ i10 = (HEAP32[i2 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i11 = -1001e3 - i6 | 0;
+ i12 = HEAP32[i12 >> 2] | 0;
+ if ((HEAP32[i12 + 8 >> 2] | 0) != 22 ? (i10 = HEAP32[i12 >> 2] | 0, (i11 | 0) <= (HEAPU8[i10 + 6 | 0] | 0 | 0)) : 0) {
+ i10 = i10 + (i11 + -1 << 4) + 16 | 0;
+ } else {
+ i10 = 5192;
+ }
+ } else {
+ i10 = (HEAP32[i12 >> 2] | 0) + (i6 << 4) | 0;
+ i10 = i10 >>> 0 < i9 >>> 0 ? i10 : 5192;
+ }
+ } while (0);
+ i13 = i5;
+ i11 = HEAP32[i13 + 4 >> 2] | 0;
+ i12 = i10;
+ HEAP32[i12 >> 2] = HEAP32[i13 >> 2];
+ HEAP32[i12 + 4 >> 2] = i11;
+ i9 = i9 + -8 | 0;
+ HEAP32[i10 + 8 >> 2] = HEAP32[i9 >> 2];
+ if ((((i6 | 0) < -1001e3 ? (HEAP32[i9 >> 2] & 64 | 0) != 0 : 0) ? (i1 = HEAP32[i5 >> 2] | 0, !((HEAP8[i1 + 5 | 0] & 3) == 0)) : 0) ? (i8 = HEAP32[HEAP32[HEAP32[i4 >> 2] >> 2] >> 2] | 0, !((HEAP8[i8 + 5 | 0] & 4) == 0)) : 0) {
+ _luaC_barrier_(i2, i8, i1);
+ }
+ HEAP32[i7 >> 2] = (HEAP32[i7 >> 2] | 0) + -16;
+ STACKTOP = i3;
+ return;
+}
+function _memchr(i4, i3, i6) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i5 = 0, i7 = 0;
+ i1 = STACKTOP;
+ i2 = i3 & 255;
+ i7 = (i6 | 0) == 0;
+ L1 : do {
+ if ((i4 & 3 | 0) == 0 | i7) {
+ i5 = i6;
+ i6 = 5;
+ } else {
+ i5 = i3 & 255;
+ while (1) {
+ if ((HEAP8[i4] | 0) == i5 << 24 >> 24) {
+ i5 = i6;
+ i6 = 6;
+ break L1;
+ }
+ i4 = i4 + 1 | 0;
+ i6 = i6 + -1 | 0;
+ i7 = (i6 | 0) == 0;
+ if ((i4 & 3 | 0) == 0 | i7) {
+ i5 = i6;
+ i6 = 5;
+ break;
+ }
+ }
+ }
+ } while (0);
+ if ((i6 | 0) == 5) {
+ if (i7) {
+ i5 = 0;
+ } else {
+ i6 = 6;
+ }
+ }
+ L8 : do {
+ if ((i6 | 0) == 6) {
+ i3 = i3 & 255;
+ if (!((HEAP8[i4] | 0) == i3 << 24 >> 24)) {
+ i2 = Math_imul(i2, 16843009) | 0;
+ L11 : do {
+ if (i5 >>> 0 > 3) {
+ do {
+ i7 = HEAP32[i4 >> 2] ^ i2;
+ if (((i7 & -2139062144 ^ -2139062144) & i7 + -16843009 | 0) != 0) {
+ break L11;
+ }
+ i4 = i4 + 4 | 0;
+ i5 = i5 + -4 | 0;
+ } while (i5 >>> 0 > 3);
+ }
+ } while (0);
+ if ((i5 | 0) == 0) {
+ i5 = 0;
+ } else {
+ while (1) {
+ if ((HEAP8[i4] | 0) == i3 << 24 >> 24) {
+ break L8;
+ }
+ i4 = i4 + 1 | 0;
+ i5 = i5 + -1 | 0;
+ if ((i5 | 0) == 0) {
+ i5 = 0;
+ break;
+ }
+ }
+ }
+ }
+ }
+ } while (0);
+ STACKTOP = i1;
+ return ((i5 | 0) != 0 ? i4 : 0) | 0;
+}
+function _lua_insert(i2, i5) {
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i1 = STACKTOP;
+ i4 = HEAP32[i2 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i3 = (HEAP32[i2 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i3 = (HEAP32[i2 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i4 >> 2] | 0, (i5 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i3 = i3 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i3 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i3 = i3 >>> 0 < (HEAP32[i2 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ i2 = i2 + 8 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ if (i4 >>> 0 > i3 >>> 0) {
+ while (1) {
+ i5 = i4 + -16 | 0;
+ i8 = i5;
+ i7 = HEAP32[i8 + 4 >> 2] | 0;
+ i6 = i4;
+ HEAP32[i6 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i6 + 4 >> 2] = i7;
+ HEAP32[i4 + 8 >> 2] = HEAP32[i4 + -8 >> 2];
+ if (i5 >>> 0 > i3 >>> 0) {
+ i4 = i5;
+ } else {
+ break;
+ }
+ }
+ i4 = HEAP32[i2 >> 2] | 0;
+ }
+ i6 = i4;
+ i7 = HEAP32[i6 + 4 >> 2] | 0;
+ i8 = i3;
+ HEAP32[i8 >> 2] = HEAP32[i6 >> 2];
+ HEAP32[i8 + 4 >> 2] = i7;
+ HEAP32[i3 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ STACKTOP = i1;
+ return;
+}
+function _findlocal(i6, i4, i1, i2) {
+ i6 = i6 | 0;
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i5 = 0, i7 = 0, i8 = 0;
+ i3 = STACKTOP;
+ do {
+ if ((HEAP8[i4 + 18 | 0] & 1) == 0) {
+ i7 = (HEAP32[i4 >> 2] | 0) + 16 | 0;
+ i5 = 7;
+ } else {
+ if ((i1 | 0) >= 0) {
+ i8 = HEAP32[i4 + 24 >> 2] | 0;
+ i7 = HEAP32[(HEAP32[HEAP32[i4 >> 2] >> 2] | 0) + 12 >> 2] | 0;
+ i7 = _luaF_getlocalname(i7, i1, ((HEAP32[i4 + 28 >> 2] | 0) - (HEAP32[i7 + 12 >> 2] | 0) >> 2) + -1 | 0) | 0;
+ if ((i7 | 0) == 0) {
+ i7 = i8;
+ i5 = 7;
+ break;
+ } else {
+ break;
+ }
+ }
+ i5 = HEAP32[i4 >> 2] | 0;
+ i6 = HEAPU8[(HEAP32[(HEAP32[i5 >> 2] | 0) + 12 >> 2] | 0) + 76 | 0] | 0;
+ if ((((HEAP32[i4 + 24 >> 2] | 0) - i5 >> 4) - i6 | 0) <= (0 - i1 | 0)) {
+ i8 = 0;
+ STACKTOP = i3;
+ return i8 | 0;
+ }
+ HEAP32[i2 >> 2] = i5 + (i6 - i1 << 4);
+ i8 = 2208;
+ STACKTOP = i3;
+ return i8 | 0;
+ }
+ } while (0);
+ if ((i5 | 0) == 7) {
+ if ((HEAP32[i6 + 16 >> 2] | 0) == (i4 | 0)) {
+ i4 = i6 + 8 | 0;
+ } else {
+ i4 = HEAP32[i4 + 12 >> 2] | 0;
+ }
+ if (((HEAP32[i4 >> 2] | 0) - i7 >> 4 | 0) >= (i1 | 0) & (i1 | 0) > 0) {
+ i8 = i7;
+ i7 = 2192;
+ } else {
+ i8 = 0;
+ STACKTOP = i3;
+ return i8 | 0;
+ }
+ }
+ HEAP32[i2 >> 2] = i8 + (i1 + -1 << 4);
+ i8 = i7;
+ STACKTOP = i3;
+ return i8 | 0;
+}
+function _luaH_setint(i4, i5, i6, i1) {
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, d7 = 0.0, i8 = 0, i9 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i8 = i2 + 16 | 0;
+ i3 = i2;
+ i9 = i6 + -1 | 0;
+ L1 : do {
+ if (i9 >>> 0 < (HEAP32[i5 + 28 >> 2] | 0) >>> 0) {
+ i9 = (HEAP32[i5 + 12 >> 2] | 0) + (i9 << 4) | 0;
+ i8 = 10;
+ } else {
+ d7 = +(i6 | 0);
+ HEAPF64[i8 >> 3] = d7 + 1.0;
+ i8 = (HEAP32[i8 + 4 >> 2] | 0) + (HEAP32[i8 >> 2] | 0) | 0;
+ if ((i8 | 0) < 0) {
+ i9 = 0 - i8 | 0;
+ i8 = (i8 | 0) == (i9 | 0) ? 0 : i9;
+ }
+ i9 = (HEAP32[i5 + 16 >> 2] | 0) + (((i8 | 0) % ((1 << (HEAPU8[i5 + 7 | 0] | 0)) + -1 | 1 | 0) | 0) << 5) | 0;
+ while (1) {
+ if ((HEAP32[i9 + 24 >> 2] | 0) == 3 ? +HEAPF64[i9 + 16 >> 3] == d7 : 0) {
+ break;
+ }
+ i9 = HEAP32[i9 + 28 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ i8 = 12;
+ break L1;
+ }
+ }
+ i8 = 10;
+ }
+ } while (0);
+ if ((i8 | 0) == 10) {
+ if ((i9 | 0) == 5192) {
+ d7 = +(i6 | 0);
+ i8 = 12;
+ }
+ }
+ if ((i8 | 0) == 12) {
+ HEAPF64[i3 >> 3] = d7;
+ HEAP32[i3 + 8 >> 2] = 3;
+ i9 = _luaH_newkey(i4, i5, i3) | 0;
+ }
+ i5 = i1;
+ i6 = HEAP32[i5 + 4 >> 2] | 0;
+ i8 = i9;
+ HEAP32[i8 >> 2] = HEAP32[i5 >> 2];
+ HEAP32[i8 + 4 >> 2] = i6;
+ HEAP32[i9 + 8 >> 2] = HEAP32[i1 + 8 >> 2];
+ STACKTOP = i2;
+ return;
+}
+function _lua_tounsignedx(i6, i8, i1) {
+ i6 = i6 | 0;
+ i8 = i8 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i4 = i2 + 8 | 0;
+ i3 = i2;
+ i7 = HEAP32[i6 + 16 >> 2] | 0;
+ do {
+ if ((i8 | 0) <= 0) {
+ if (!((i8 | 0) < -1000999)) {
+ i5 = (HEAP32[i6 + 8 >> 2] | 0) + (i8 << 4) | 0;
+ break;
+ }
+ if ((i8 | 0) == -1001e3) {
+ i5 = (HEAP32[i6 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i6 = -1001e3 - i8 | 0;
+ i7 = HEAP32[i7 >> 2] | 0;
+ if ((HEAP32[i7 + 8 >> 2] | 0) != 22 ? (i5 = HEAP32[i7 >> 2] | 0, (i6 | 0) <= (HEAPU8[i5 + 6 | 0] | 0 | 0)) : 0) {
+ i5 = i5 + (i6 + -1 << 4) + 16 | 0;
+ } else {
+ i5 = 5192;
+ }
+ } else {
+ i5 = (HEAP32[i7 >> 2] | 0) + (i8 << 4) | 0;
+ i5 = i5 >>> 0 < (HEAP32[i6 + 8 >> 2] | 0) >>> 0 ? i5 : 5192;
+ }
+ } while (0);
+ if ((HEAP32[i5 + 8 >> 2] | 0) != 3) {
+ i5 = _luaV_tonumber(i5, i4) | 0;
+ if ((i5 | 0) == 0) {
+ if ((i1 | 0) == 0) {
+ i8 = 0;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ HEAP32[i1 >> 2] = 0;
+ i8 = 0;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ }
+ HEAPF64[i3 >> 3] = +HEAPF64[i5 >> 3] + 6755399441055744.0;
+ i3 = HEAP32[i3 >> 2] | 0;
+ if ((i1 | 0) == 0) {
+ i8 = i3;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ HEAP32[i1 >> 2] = 1;
+ i8 = i3;
+ STACKTOP = i2;
+ return i8 | 0;
+}
+function _luaC_freeallobjects(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ i5 = i1 + 12 | 0;
+ i3 = HEAP32[i5 >> 2] | 0;
+ i7 = i3 + 104 | 0;
+ while (1) {
+ i4 = HEAP32[i7 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ break;
+ } else {
+ i7 = i4;
+ }
+ }
+ i4 = i3 + 72 | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ if ((i6 | 0) == 0) {
+ i5 = i3;
+ } else {
+ while (1) {
+ i8 = i6 + 5 | 0;
+ HEAP8[i8] = HEAPU8[i8] | 0 | 8;
+ HEAP32[i4 >> 2] = HEAP32[i6 >> 2];
+ HEAP32[i6 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i7 >> 2] = i6;
+ i7 = HEAP32[i4 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ break;
+ } else {
+ i8 = i6;
+ i6 = i7;
+ i7 = i8;
+ }
+ }
+ i5 = HEAP32[i5 >> 2] | 0;
+ }
+ i5 = i5 + 104 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ do {
+ i8 = i6 + 5 | 0;
+ HEAP8[i8] = HEAP8[i8] & 191;
+ _GCTM(i1, 0);
+ i6 = HEAP32[i5 >> 2] | 0;
+ } while ((i6 | 0) != 0);
+ }
+ HEAP8[i3 + 60 | 0] = 3;
+ HEAP8[i3 + 62 | 0] = 0;
+ _sweeplist(i1, i4, -3) | 0;
+ _sweeplist(i1, i3 + 68 | 0, -3) | 0;
+ i4 = i3 + 32 | 0;
+ if ((HEAP32[i4 >> 2] | 0) <= 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i3 = i3 + 24 | 0;
+ i5 = 0;
+ do {
+ _sweeplist(i1, (HEAP32[i3 >> 2] | 0) + (i5 << 2) | 0, -3) | 0;
+ i5 = i5 + 1 | 0;
+ } while ((i5 | 0) < (HEAP32[i4 >> 2] | 0));
+ STACKTOP = i2;
+ return;
+}
+function _strspn(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i3 = i2;
+ HEAP32[i3 + 0 >> 2] = 0;
+ HEAP32[i3 + 4 >> 2] = 0;
+ HEAP32[i3 + 8 >> 2] = 0;
+ HEAP32[i3 + 12 >> 2] = 0;
+ HEAP32[i3 + 16 >> 2] = 0;
+ HEAP32[i3 + 20 >> 2] = 0;
+ HEAP32[i3 + 24 >> 2] = 0;
+ HEAP32[i3 + 28 >> 2] = 0;
+ i4 = HEAP8[i5] | 0;
+ if (i4 << 24 >> 24 == 0) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ if ((HEAP8[i5 + 1 | 0] | 0) == 0) {
+ i3 = i1;
+ while (1) {
+ if ((HEAP8[i3] | 0) == i4 << 24 >> 24) {
+ i3 = i3 + 1 | 0;
+ } else {
+ break;
+ }
+ }
+ i6 = i3 - i1 | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ do {
+ i7 = i4 & 255;
+ i6 = i3 + (i7 >>> 5 << 2) | 0;
+ HEAP32[i6 >> 2] = HEAP32[i6 >> 2] | 1 << (i7 & 31);
+ i5 = i5 + 1 | 0;
+ i4 = HEAP8[i5] | 0;
+ } while (!(i4 << 24 >> 24 == 0));
+ i5 = HEAP8[i1] | 0;
+ L12 : do {
+ if (i5 << 24 >> 24 == 0) {
+ i4 = i1;
+ } else {
+ i4 = i1;
+ while (1) {
+ i7 = i5 & 255;
+ i6 = i4 + 1 | 0;
+ if ((HEAP32[i3 + (i7 >>> 5 << 2) >> 2] & 1 << (i7 & 31) | 0) == 0) {
+ break L12;
+ }
+ i5 = HEAP8[i6] | 0;
+ if (i5 << 24 >> 24 == 0) {
+ i4 = i6;
+ break;
+ } else {
+ i4 = i6;
+ }
+ }
+ }
+ } while (0);
+ i7 = i4 - i1 | 0;
+ STACKTOP = i2;
+ return i7 | 0;
+}
+function _lua_remove(i2, i4) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i1 = STACKTOP;
+ i5 = HEAP32[i2 + 16 >> 2] | 0;
+ do {
+ if ((i4 | 0) <= 0) {
+ if (!((i4 | 0) < -1000999)) {
+ i3 = (HEAP32[i2 + 8 >> 2] | 0) + (i4 << 4) | 0;
+ break;
+ }
+ if ((i4 | 0) == -1001e3) {
+ i3 = (HEAP32[i2 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i4 = -1001e3 - i4 | 0;
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i5 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i5 >> 2] | 0, (i4 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i3 = i3 + (i4 + -1 << 4) + 16 | 0;
+ } else {
+ i3 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i5 >> 2] | 0) + (i4 << 4) | 0;
+ i3 = i3 >>> 0 < (HEAP32[i2 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ i4 = i3 + 16 | 0;
+ i2 = i2 + 8 | 0;
+ i5 = HEAP32[i2 >> 2] | 0;
+ if (!(i4 >>> 0 < i5 >>> 0)) {
+ i5 = i5 + -16 | 0;
+ HEAP32[i2 >> 2] = i5;
+ STACKTOP = i1;
+ return;
+ }
+ while (1) {
+ i7 = i4;
+ i6 = HEAP32[i7 + 4 >> 2] | 0;
+ i5 = i3;
+ HEAP32[i5 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i5 + 4 >> 2] = i6;
+ HEAP32[i3 + 8 >> 2] = HEAP32[i3 + 24 >> 2];
+ i5 = i4 + 16 | 0;
+ i3 = HEAP32[i2 >> 2] | 0;
+ if (i5 >>> 0 < i3 >>> 0) {
+ i3 = i4;
+ i4 = i5;
+ } else {
+ break;
+ }
+ }
+ i7 = i3 + -16 | 0;
+ HEAP32[i2 >> 2] = i7;
+ STACKTOP = i1;
+ return;
+}
+function _luaD_protectedparser(i1, i4, i3, i2) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0;
+ i5 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i13 = i5;
+ i6 = i1 + 36 | 0;
+ HEAP16[i6 >> 1] = (HEAP16[i6 >> 1] | 0) + 1 << 16 >> 16;
+ HEAP32[i13 >> 2] = i4;
+ HEAP32[i13 + 56 >> 2] = i3;
+ HEAP32[i13 + 52 >> 2] = i2;
+ i10 = i13 + 16 | 0;
+ HEAP32[i10 >> 2] = 0;
+ i9 = i13 + 24 | 0;
+ HEAP32[i9 >> 2] = 0;
+ i8 = i13 + 28 | 0;
+ HEAP32[i8 >> 2] = 0;
+ i7 = i13 + 36 | 0;
+ HEAP32[i7 >> 2] = 0;
+ i2 = i13 + 40 | 0;
+ HEAP32[i2 >> 2] = 0;
+ i3 = i13 + 48 | 0;
+ HEAP32[i3 >> 2] = 0;
+ i12 = i13 + 4 | 0;
+ HEAP32[i12 >> 2] = 0;
+ i11 = i13 + 12 | 0;
+ HEAP32[i11 >> 2] = 0;
+ i4 = _luaD_pcall(i1, 6, i13, (HEAP32[i1 + 8 >> 2] | 0) - (HEAP32[i1 + 28 >> 2] | 0) | 0, HEAP32[i1 + 68 >> 2] | 0) | 0;
+ HEAP32[i12 >> 2] = _luaM_realloc_(i1, HEAP32[i12 >> 2] | 0, HEAP32[i11 >> 2] | 0, 0) | 0;
+ HEAP32[i11 >> 2] = 0;
+ _luaM_realloc_(i1, HEAP32[i10 >> 2] | 0, HEAP32[i9 >> 2] << 1, 0) | 0;
+ _luaM_realloc_(i1, HEAP32[i8 >> 2] | 0, HEAP32[i7 >> 2] << 4, 0) | 0;
+ _luaM_realloc_(i1, HEAP32[i2 >> 2] | 0, HEAP32[i3 >> 2] << 4, 0) | 0;
+ HEAP16[i6 >> 1] = (HEAP16[i6 >> 1] | 0) + -1 << 16 >> 16;
+ STACKTOP = i5;
+ return i4 | 0;
+}
+function _markmt(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = HEAP32[i1 + 252 >> 2] | 0;
+ if ((i3 | 0) != 0 ? !((HEAP8[i3 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i1, i3);
+ }
+ i3 = HEAP32[i1 + 256 >> 2] | 0;
+ if ((i3 | 0) != 0 ? !((HEAP8[i3 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i1, i3);
+ }
+ i3 = HEAP32[i1 + 260 >> 2] | 0;
+ if ((i3 | 0) != 0 ? !((HEAP8[i3 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i1, i3);
+ }
+ i3 = HEAP32[i1 + 264 >> 2] | 0;
+ if ((i3 | 0) != 0 ? !((HEAP8[i3 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i1, i3);
+ }
+ i3 = HEAP32[i1 + 268 >> 2] | 0;
+ if ((i3 | 0) != 0 ? !((HEAP8[i3 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i1, i3);
+ }
+ i3 = HEAP32[i1 + 272 >> 2] | 0;
+ if ((i3 | 0) != 0 ? !((HEAP8[i3 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i1, i3);
+ }
+ i3 = HEAP32[i1 + 276 >> 2] | 0;
+ if ((i3 | 0) != 0 ? !((HEAP8[i3 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i1, i3);
+ }
+ i3 = HEAP32[i1 + 280 >> 2] | 0;
+ if ((i3 | 0) != 0 ? !((HEAP8[i3 + 5 | 0] & 3) == 0) : 0) {
+ _reallymarkobject(i1, i3);
+ }
+ i3 = HEAP32[i1 + 284 >> 2] | 0;
+ if ((i3 | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ if ((HEAP8[i3 + 5 | 0] & 3) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ _reallymarkobject(i1, i3);
+ STACKTOP = i2;
+ return;
+}
+function _findlabel(i9, i2) {
+ i9 = i9 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0;
+ i1 = STACKTOP;
+ i3 = i9 + 48 | 0;
+ i7 = HEAP32[(HEAP32[i3 >> 2] | 0) + 16 >> 2] | 0;
+ i10 = HEAP32[i9 + 64 >> 2] | 0;
+ i4 = HEAP32[i10 + 12 >> 2] | 0;
+ i6 = i7 + 4 | 0;
+ i13 = HEAP16[i6 >> 1] | 0;
+ i5 = i10 + 28 | 0;
+ if ((i13 | 0) >= (HEAP32[i5 >> 2] | 0)) {
+ i15 = 0;
+ STACKTOP = i1;
+ return i15 | 0;
+ }
+ i10 = i10 + 24 | 0;
+ i11 = i4 + (i2 << 4) | 0;
+ while (1) {
+ i14 = HEAP32[i10 >> 2] | 0;
+ i12 = i14 + (i13 << 4) | 0;
+ i15 = i13 + 1 | 0;
+ if ((_luaS_eqstr(HEAP32[i12 >> 2] | 0, HEAP32[i11 >> 2] | 0) | 0) != 0) {
+ break;
+ }
+ if ((i15 | 0) < (HEAP32[i5 >> 2] | 0)) {
+ i13 = i15;
+ } else {
+ i2 = 0;
+ i8 = 10;
+ break;
+ }
+ }
+ if ((i8 | 0) == 10) {
+ STACKTOP = i1;
+ return i2 | 0;
+ }
+ i8 = HEAP8[i14 + (i13 << 4) + 12 | 0] | 0;
+ do {
+ if ((HEAPU8[i4 + (i2 << 4) + 12 | 0] | 0) > (i8 & 255)) {
+ if ((HEAP8[i7 + 9 | 0] | 0) == 0 ? (HEAP32[i5 >> 2] | 0) <= (HEAP16[i6 >> 1] | 0) : 0) {
+ break;
+ }
+ _luaK_patchclose(HEAP32[i3 >> 2] | 0, HEAP32[i4 + (i2 << 4) + 4 >> 2] | 0, i8 & 255);
+ }
+ } while (0);
+ _closegoto(i9, i2, i12);
+ i15 = 1;
+ STACKTOP = i1;
+ return i15 | 0;
+}
+function _lua_getmetatable(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i4 = (HEAP32[i1 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i4 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i4 >> 2] | 0, (i5 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i4 = i3 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i4 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i4 = i3 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ i3 = HEAP32[i4 + 8 >> 2] & 15;
+ if ((i3 | 0) == 7) {
+ i3 = HEAP32[(HEAP32[i4 >> 2] | 0) + 8 >> 2] | 0;
+ } else if ((i3 | 0) == 5) {
+ i3 = HEAP32[(HEAP32[i4 >> 2] | 0) + 8 >> 2] | 0;
+ } else {
+ i3 = HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + (i3 << 2) + 252 >> 2] | 0;
+ }
+ if ((i3 | 0) == 0) {
+ i5 = 0;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ i5 = i1 + 8 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i4 >> 2] = i3;
+ HEAP32[i4 + 8 >> 2] = 69;
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + 16;
+ i5 = 1;
+ STACKTOP = i2;
+ return i5 | 0;
+}
+function _str_byte(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i6 = i1;
+ i4 = i1 + 4 | 0;
+ i3 = _luaL_checklstring(i2, 1, i4) | 0;
+ i5 = _luaL_optinteger(i2, 2, 1) | 0;
+ i7 = HEAP32[i4 >> 2] | 0;
+ if (!((i5 | 0) > -1)) {
+ if (i7 >>> 0 < (0 - i5 | 0) >>> 0) {
+ i5 = 0;
+ } else {
+ i5 = i5 + 1 + i7 | 0;
+ }
+ }
+ i8 = _luaL_optinteger(i2, 3, i5) | 0;
+ i7 = HEAP32[i4 >> 2] | 0;
+ if (!((i8 | 0) > -1)) {
+ if (i7 >>> 0 < (0 - i8 | 0) >>> 0) {
+ i8 = 0;
+ } else {
+ i8 = i8 + 1 + i7 | 0;
+ }
+ }
+ i9 = (i5 | 0) == 0 ? 1 : i5;
+ i10 = i8 >>> 0 > i7 >>> 0 ? i7 : i8;
+ if (i9 >>> 0 > i10 >>> 0) {
+ i10 = 0;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ i4 = i10 - i9 + 1 | 0;
+ if ((i10 | 0) == -1) {
+ i10 = _luaL_error(i2, 7944, i6) | 0;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ _luaL_checkstack(i2, i4, 7944);
+ if ((i4 | 0) <= 0) {
+ i10 = i4;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ i6 = i9 + -1 | 0;
+ i8 = ~i8;
+ i7 = ~i7;
+ i5 = 0 - (i8 >>> 0 > i7 >>> 0 ? i8 : i7) - (i5 >>> 0 > 1 ? i5 : 1) | 0;
+ i7 = 0;
+ do {
+ _lua_pushinteger(i2, HEAPU8[i3 + (i6 + i7) | 0] | 0);
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) != (i5 | 0));
+ STACKTOP = i1;
+ return i4 | 0;
+}
+function _lua_setuservalue(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0;
+ i3 = STACKTOP;
+ i6 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i5 = (HEAP32[i1 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i5 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i5 | 0;
+ i6 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i6 + 8 >> 2] | 0) != 22 ? (i4 = HEAP32[i6 >> 2] | 0, (i5 | 0) <= (HEAPU8[i4 + 6 | 0] | 0 | 0)) : 0) {
+ i5 = i4 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i5 = 5192;
+ }
+ } else {
+ i4 = (HEAP32[i6 >> 2] | 0) + (i5 << 4) | 0;
+ i5 = i4 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i4 : 5192;
+ }
+ } while (0);
+ i4 = i1 + 8 | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i6 + -8 >> 2] | 0) != 0) {
+ HEAP32[(HEAP32[i5 >> 2] | 0) + 12 >> 2] = HEAP32[i6 + -16 >> 2];
+ i6 = HEAP32[(HEAP32[i4 >> 2] | 0) + -16 >> 2] | 0;
+ if (!((HEAP8[i6 + 5 | 0] & 3) == 0) ? (i2 = HEAP32[i5 >> 2] | 0, !((HEAP8[i2 + 5 | 0] & 4) == 0)) : 0) {
+ _luaC_barrier_(i1, i2, i6);
+ }
+ } else {
+ HEAP32[(HEAP32[i5 >> 2] | 0) + 12 >> 2] = 0;
+ }
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + -16;
+ STACKTOP = i3;
+ return;
+}
+function _f_luaopen(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i6 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i5 = i6;
+ i4 = HEAP32[i1 + 12 >> 2] | 0;
+ i2 = _luaM_realloc_(i1, 0, 0, 640) | 0;
+ HEAP32[i1 + 28 >> 2] = i2;
+ i3 = i1 + 32 | 0;
+ HEAP32[i3 >> 2] = 40;
+ i7 = 0;
+ do {
+ HEAP32[i2 + (i7 << 4) + 8 >> 2] = 0;
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) != 40);
+ HEAP32[i1 + 24 >> 2] = i2 + ((HEAP32[i3 >> 2] | 0) + -5 << 4);
+ i7 = i1 + 72 | 0;
+ HEAP32[i1 + 80 >> 2] = 0;
+ HEAP32[i1 + 84 >> 2] = 0;
+ HEAP8[i1 + 90 | 0] = 0;
+ HEAP32[i7 >> 2] = i2;
+ HEAP32[i1 + 8 >> 2] = i2 + 16;
+ HEAP32[i2 + 8 >> 2] = 0;
+ HEAP32[i1 + 76 >> 2] = i2 + 336;
+ HEAP32[i1 + 16 >> 2] = i7;
+ i7 = _luaH_new(i1) | 0;
+ HEAP32[i4 + 40 >> 2] = i7;
+ HEAP32[i4 + 48 >> 2] = 69;
+ _luaH_resize(i1, i7, 2, 0);
+ HEAP32[i5 >> 2] = i1;
+ i3 = i5 + 8 | 0;
+ HEAP32[i3 >> 2] = 72;
+ _luaH_setint(i1, i7, 1, i5);
+ HEAP32[i5 >> 2] = _luaH_new(i1) | 0;
+ HEAP32[i3 >> 2] = 69;
+ _luaH_setint(i1, i7, 2, i5);
+ _luaS_resize(i1, 32);
+ _luaT_init(i1);
+ _luaX_init(i1);
+ i7 = _luaS_newlstr(i1, 6896, 17) | 0;
+ HEAP32[i4 + 180 >> 2] = i7;
+ i7 = i7 + 5 | 0;
+ HEAP8[i7] = HEAPU8[i7] | 0 | 32;
+ HEAP8[i4 + 63 | 0] = 1;
+ STACKTOP = i6;
+ return;
+}
+function _lua_tointegerx(i6, i7, i1) {
+ i6 = i6 | 0;
+ i7 = i7 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ i5 = HEAP32[i6 + 16 >> 2] | 0;
+ do {
+ if ((i7 | 0) <= 0) {
+ if (!((i7 | 0) < -1000999)) {
+ i4 = (HEAP32[i6 + 8 >> 2] | 0) + (i7 << 4) | 0;
+ break;
+ }
+ if ((i7 | 0) == -1001e3) {
+ i4 = (HEAP32[i6 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i6 = -1001e3 - i7 | 0;
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i5 + 8 >> 2] | 0) != 22 ? (i4 = HEAP32[i5 >> 2] | 0, (i6 | 0) <= (HEAPU8[i4 + 6 | 0] | 0 | 0)) : 0) {
+ i4 = i4 + (i6 + -1 << 4) + 16 | 0;
+ } else {
+ i4 = 5192;
+ }
+ } else {
+ i4 = (HEAP32[i5 >> 2] | 0) + (i7 << 4) | 0;
+ i4 = i4 >>> 0 < (HEAP32[i6 + 8 >> 2] | 0) >>> 0 ? i4 : 5192;
+ }
+ } while (0);
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 3) {
+ i4 = _luaV_tonumber(i4, i3) | 0;
+ if ((i4 | 0) == 0) {
+ if ((i1 | 0) == 0) {
+ i7 = 0;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ HEAP32[i1 >> 2] = 0;
+ i7 = 0;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ }
+ i3 = ~~+HEAPF64[i4 >> 3];
+ if ((i1 | 0) == 0) {
+ i7 = i3;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ HEAP32[i1 >> 2] = 1;
+ i7 = i3;
+ STACKTOP = i2;
+ return i7 | 0;
+}
+function _close_state(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ i6 = i1 + 12 | 0;
+ i3 = HEAP32[i6 >> 2] | 0;
+ i4 = i1 + 28 | 0;
+ _luaF_close(i1, HEAP32[i4 >> 2] | 0);
+ _luaC_freeallobjects(i1);
+ i6 = HEAP32[i6 >> 2] | 0;
+ _luaM_realloc_(i1, HEAP32[i6 + 24 >> 2] | 0, HEAP32[i6 + 32 >> 2] << 2, 0) | 0;
+ i6 = i3 + 144 | 0;
+ i5 = i3 + 152 | 0;
+ HEAP32[i6 >> 2] = _luaM_realloc_(i1, HEAP32[i6 >> 2] | 0, HEAP32[i5 >> 2] | 0, 0) | 0;
+ HEAP32[i5 >> 2] = 0;
+ i5 = HEAP32[i4 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i5 = HEAP32[i3 >> 2] | 0;
+ i6 = i3 + 4 | 0;
+ i6 = HEAP32[i6 >> 2] | 0;
+ FUNCTION_TABLE_iiiii[i5 & 3](i6, i1, 400, 0) | 0;
+ STACKTOP = i2;
+ return;
+ }
+ HEAP32[i1 + 16 >> 2] = i1 + 72;
+ i7 = i1 + 84 | 0;
+ i6 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = 0;
+ if ((i6 | 0) != 0) {
+ while (1) {
+ i5 = HEAP32[i6 + 12 >> 2] | 0;
+ _luaM_realloc_(i1, i6, 40, 0) | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ } else {
+ i6 = i5;
+ }
+ }
+ i5 = HEAP32[i4 >> 2] | 0;
+ }
+ _luaM_realloc_(i1, i5, HEAP32[i1 + 32 >> 2] << 4, 0) | 0;
+ i6 = HEAP32[i3 >> 2] | 0;
+ i7 = i3 + 4 | 0;
+ i7 = HEAP32[i7 >> 2] | 0;
+ FUNCTION_TABLE_iiiii[i6 & 3](i7, i1, 400, 0) | 0;
+ STACKTOP = i2;
+ return;
+}
+function _ll_module(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 112 | 0;
+ i4 = i2;
+ i5 = i2 + 4 | 0;
+ i6 = _luaL_checklstring(i1, 1, 0) | 0;
+ i3 = _lua_gettop(i1) | 0;
+ _luaL_pushmodule(i1, i6, 1);
+ _lua_getfield(i1, -1, 4728);
+ i7 = (_lua_type(i1, -1) | 0) == 0;
+ _lua_settop(i1, -2);
+ if (i7) {
+ _lua_pushvalue(i1, -1);
+ _lua_setfield(i1, -2, 4784);
+ _lua_pushstring(i1, i6) | 0;
+ _lua_setfield(i1, -2, 4728);
+ i7 = _strrchr(i6, 46) | 0;
+ _lua_pushlstring(i1, i6, ((i7 | 0) == 0 ? i6 : i7 + 1 | 0) - i6 | 0) | 0;
+ _lua_setfield(i1, -2, 4792);
+ }
+ _lua_pushvalue(i1, -1);
+ if (!(((_lua_getstack(i1, 1, i5) | 0) != 0 ? (_lua_getinfo(i1, 4736, i5) | 0) != 0 : 0) ? (_lua_iscfunction(i1, -1) | 0) == 0 : 0)) {
+ _luaL_error(i1, 4744, i4) | 0;
+ }
+ _lua_pushvalue(i1, -2);
+ _lua_setupvalue(i1, -2, 1) | 0;
+ _lua_settop(i1, -2);
+ if ((i3 | 0) < 2) {
+ STACKTOP = i2;
+ return 1;
+ } else {
+ i4 = 2;
+ }
+ while (1) {
+ if ((_lua_type(i1, i4) | 0) == 6) {
+ _lua_pushvalue(i1, i4);
+ _lua_pushvalue(i1, -2);
+ _lua_callk(i1, 1, 0, 0, 0);
+ }
+ if ((i4 | 0) == (i3 | 0)) {
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ }
+ }
+ STACKTOP = i2;
+ return 1;
+}
+function _strcspn(i2, i5) {
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i3 = i1;
+ i4 = HEAP8[i5] | 0;
+ if (!(i4 << 24 >> 24 == 0) ? (HEAP8[i5 + 1 | 0] | 0) != 0 : 0) {
+ HEAP32[i3 + 0 >> 2] = 0;
+ HEAP32[i3 + 4 >> 2] = 0;
+ HEAP32[i3 + 8 >> 2] = 0;
+ HEAP32[i3 + 12 >> 2] = 0;
+ HEAP32[i3 + 16 >> 2] = 0;
+ HEAP32[i3 + 20 >> 2] = 0;
+ HEAP32[i3 + 24 >> 2] = 0;
+ HEAP32[i3 + 28 >> 2] = 0;
+ do {
+ i7 = i4 & 255;
+ i6 = i3 + (i7 >>> 5 << 2) | 0;
+ HEAP32[i6 >> 2] = HEAP32[i6 >> 2] | 1 << (i7 & 31);
+ i5 = i5 + 1 | 0;
+ i4 = HEAP8[i5] | 0;
+ } while (!(i4 << 24 >> 24 == 0));
+ i5 = HEAP8[i2] | 0;
+ L7 : do {
+ if (i5 << 24 >> 24 == 0) {
+ i4 = i2;
+ } else {
+ i4 = i2;
+ while (1) {
+ i7 = i5 & 255;
+ i6 = i4 + 1 | 0;
+ if ((HEAP32[i3 + (i7 >>> 5 << 2) >> 2] & 1 << (i7 & 31) | 0) != 0) {
+ break L7;
+ }
+ i5 = HEAP8[i6] | 0;
+ if (i5 << 24 >> 24 == 0) {
+ i4 = i6;
+ break;
+ } else {
+ i4 = i6;
+ }
+ }
+ }
+ } while (0);
+ i7 = i4 - i2 | 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ i7 = (___strchrnul(i2, i4 << 24 >> 24) | 0) - i2 | 0;
+ STACKTOP = i1;
+ return i7 | 0;
+}
+function _main(i4, i5) {
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i1;
+ i3 = _luaL_newstate() | 0;
+ if ((i3 | 0) == 0) {
+ i4 = HEAP32[i5 >> 2] | 0;
+ i3 = HEAP32[_stderr >> 2] | 0;
+ if ((i4 | 0) != 0) {
+ HEAP32[i2 >> 2] = i4;
+ _fprintf(i3 | 0, 496, i2 | 0) | 0;
+ _fflush(i3 | 0) | 0;
+ }
+ HEAP32[i2 >> 2] = 8;
+ _fprintf(i3 | 0, 912, i2 | 0) | 0;
+ _fflush(i3 | 0) | 0;
+ i8 = 1;
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ _lua_pushcclosure(i3, 141, 0);
+ _lua_pushinteger(i3, i4);
+ _lua_pushlightuserdata(i3, i5);
+ i6 = _lua_pcallk(i3, 2, 1, 0, 0, 0) | 0;
+ i7 = _lua_toboolean(i3, -1) | 0;
+ i6 = (i6 | 0) == 0;
+ if (!i6) {
+ if ((_lua_type(i3, -1) | 0) == 4) {
+ i8 = _lua_tolstring(i3, -1, 0) | 0;
+ } else {
+ i8 = 0;
+ }
+ i4 = HEAP32[20] | 0;
+ i5 = HEAP32[_stderr >> 2] | 0;
+ if ((i4 | 0) != 0) {
+ HEAP32[i2 >> 2] = i4;
+ _fprintf(i5 | 0, 496, i2 | 0) | 0;
+ _fflush(i5 | 0) | 0;
+ }
+ HEAP32[i2 >> 2] = (i8 | 0) == 0 ? 48 : i8;
+ _fprintf(i5 | 0, 912, i2 | 0) | 0;
+ _fflush(i5 | 0) | 0;
+ _lua_settop(i3, -2);
+ }
+ _lua_close(i3);
+ i8 = i6 & (i7 | 0) != 0 & 1 ^ 1;
+ STACKTOP = i1;
+ return i8 | 0;
+}
+function _db_sethook(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i4 = STACKTOP;
+ if ((_lua_type(i1, 1) | 0) == 8) {
+ i2 = _lua_tothread(i1, 1) | 0;
+ i5 = 1;
+ } else {
+ i2 = i1;
+ i5 = 0;
+ }
+ i3 = i5 + 1 | 0;
+ if ((_lua_type(i1, i3) | 0) < 1) {
+ _lua_settop(i1, i3);
+ i6 = 0;
+ i7 = 0;
+ i5 = 0;
+ } else {
+ i6 = _luaL_checklstring(i1, i5 | 2, 0) | 0;
+ _luaL_checktype(i1, i3, 6);
+ i5 = _luaL_optinteger(i1, i5 + 3 | 0, 0) | 0;
+ i7 = (_strchr(i6, 99) | 0) != 0 | 0;
+ i8 = (_strchr(i6, 114) | 0) == 0;
+ i7 = i8 ? i7 : i7 | 2;
+ i8 = (_strchr(i6, 108) | 0) == 0;
+ i8 = i8 ? i7 : i7 | 4;
+ i6 = i5;
+ i7 = 9;
+ i5 = (i5 | 0) > 0 ? i8 | 8 : i8;
+ }
+ if ((_luaL_getsubtable(i1, -1001e3, 11584) | 0) != 0) {
+ _lua_pushthread(i2) | 0;
+ _lua_xmove(i2, i1, 1);
+ _lua_pushvalue(i1, i3);
+ _lua_rawset(i1, -3);
+ _lua_sethook(i2, i7, i5, i6) | 0;
+ STACKTOP = i4;
+ return 0;
+ }
+ _lua_pushstring(i1, 11592) | 0;
+ _lua_setfield(i1, -2, 11600);
+ _lua_pushvalue(i1, -1);
+ _lua_setmetatable(i1, -2) | 0;
+ _lua_pushthread(i2) | 0;
+ _lua_xmove(i2, i1, 1);
+ _lua_pushvalue(i1, i3);
+ _lua_rawset(i1, -3);
+ _lua_sethook(i2, i7, i5, i6) | 0;
+ STACKTOP = i4;
+ return 0;
+}
+function _tconcat(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 1056 | 0;
+ i6 = i3;
+ i2 = i3 + 16 | 0;
+ i5 = i3 + 8 | 0;
+ i4 = _luaL_optlstring(i1, 2, 8208, i5) | 0;
+ _luaL_checktype(i1, 1, 5);
+ i8 = _luaL_optinteger(i1, 3, 1) | 0;
+ if ((_lua_type(i1, 4) | 0) < 1) {
+ i7 = _luaL_len(i1, 1) | 0;
+ } else {
+ i7 = _luaL_checkinteger(i1, 4) | 0;
+ }
+ _luaL_buffinit(i1, i2);
+ if ((i8 | 0) >= (i7 | 0)) {
+ if ((i8 | 0) != (i7 | 0)) {
+ _luaL_pushresult(i2);
+ STACKTOP = i3;
+ return 1;
+ }
+ } else {
+ do {
+ _lua_rawgeti(i1, 1, i8);
+ if ((_lua_isstring(i1, -1) | 0) == 0) {
+ HEAP32[i6 >> 2] = _lua_typename(i1, _lua_type(i1, -1) | 0) | 0;
+ HEAP32[i6 + 4 >> 2] = i8;
+ _luaL_error(i1, 8360, i6) | 0;
+ }
+ _luaL_addvalue(i2);
+ _luaL_addlstring(i2, i4, HEAP32[i5 >> 2] | 0);
+ i8 = i8 + 1 | 0;
+ } while ((i8 | 0) != (i7 | 0));
+ }
+ _lua_rawgeti(i1, 1, i7);
+ if ((_lua_isstring(i1, -1) | 0) == 0) {
+ HEAP32[i6 >> 2] = _lua_typename(i1, _lua_type(i1, -1) | 0) | 0;
+ HEAP32[i6 + 4 >> 2] = i7;
+ _luaL_error(i1, 8360, i6) | 0;
+ }
+ _luaL_addvalue(i2);
+ _luaL_pushresult(i2);
+ STACKTOP = i3;
+ return 1;
+}
+function _searcher_Croot(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ i4 = _luaL_checklstring(i1, 1, 0) | 0;
+ i5 = _strchr(i4, 46) | 0;
+ if ((i5 | 0) == 0) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ _lua_pushlstring(i1, i4, i5 - i4 | 0) | 0;
+ i5 = _lua_tolstring(i1, -1, 0) | 0;
+ _lua_getfield(i1, -1001001, 4440);
+ i6 = _lua_tolstring(i1, -1, 0) | 0;
+ if ((i6 | 0) == 0) {
+ HEAP32[i3 >> 2] = 4440;
+ _luaL_error(i1, 5032, i3) | 0;
+ }
+ i5 = _searchpath(i1, i5, i6, 4936, 4848) | 0;
+ if ((i5 | 0) == 0) {
+ i6 = 1;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ i6 = _loadfunc(i1, i5, i4) | 0;
+ if ((i6 | 0) == 2) {
+ HEAP32[i3 >> 2] = i4;
+ HEAP32[i3 + 4 >> 2] = i5;
+ _lua_pushfstring(i1, 4856, i3) | 0;
+ i6 = 1;
+ STACKTOP = i2;
+ return i6 | 0;
+ } else if ((i6 | 0) == 0) {
+ _lua_pushstring(i1, i5) | 0;
+ i6 = 2;
+ STACKTOP = i2;
+ return i6 | 0;
+ } else {
+ i4 = _lua_tolstring(i1, 1, 0) | 0;
+ i6 = _lua_tolstring(i1, -1, 0) | 0;
+ HEAP32[i3 >> 2] = i4;
+ HEAP32[i3 + 4 >> 2] = i5;
+ HEAP32[i3 + 8 >> 2] = i6;
+ i6 = _luaL_error(i1, 4888, i3) | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ return 0;
+}
+function _lua_tonumberx(i5, i7, i1) {
+ i5 = i5 | 0;
+ i7 = i7 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0, d8 = 0.0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ i6 = HEAP32[i5 + 16 >> 2] | 0;
+ do {
+ if ((i7 | 0) <= 0) {
+ if (!((i7 | 0) < -1000999)) {
+ i4 = (HEAP32[i5 + 8 >> 2] | 0) + (i7 << 4) | 0;
+ break;
+ }
+ if ((i7 | 0) == -1001e3) {
+ i4 = (HEAP32[i5 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i7 | 0;
+ i6 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i6 + 8 >> 2] | 0) != 22 ? (i4 = HEAP32[i6 >> 2] | 0, (i5 | 0) <= (HEAPU8[i4 + 6 | 0] | 0 | 0)) : 0) {
+ i4 = i4 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i4 = 5192;
+ }
+ } else {
+ i4 = (HEAP32[i6 >> 2] | 0) + (i7 << 4) | 0;
+ i4 = i4 >>> 0 < (HEAP32[i5 + 8 >> 2] | 0) >>> 0 ? i4 : 5192;
+ }
+ } while (0);
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 3) {
+ i4 = _luaV_tonumber(i4, i3) | 0;
+ if ((i4 | 0) == 0) {
+ if ((i1 | 0) == 0) {
+ d8 = 0.0;
+ STACKTOP = i2;
+ return +d8;
+ }
+ HEAP32[i1 >> 2] = 0;
+ d8 = 0.0;
+ STACKTOP = i2;
+ return +d8;
+ }
+ }
+ if ((i1 | 0) != 0) {
+ HEAP32[i1 >> 2] = 1;
+ }
+ d8 = +HEAPF64[i4 >> 3];
+ STACKTOP = i2;
+ return +d8;
+}
+function _luaopen_package(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_getsubtable(i1, -1001e3, 4184) | 0;
+ _lua_createtable(i1, 0, 1);
+ _lua_pushcclosure(i1, 158, 0);
+ _lua_setfield(i1, -2, 4192);
+ _lua_setmetatable(i1, -2) | 0;
+ _lua_createtable(i1, 0, 3);
+ _luaL_setfuncs(i1, 4200, 0);
+ _lua_createtable(i1, 4, 0);
+ _lua_pushvalue(i1, -2);
+ _lua_pushcclosure(i1, 159, 1);
+ _lua_rawseti(i1, -2, 1);
+ _lua_pushvalue(i1, -2);
+ _lua_pushcclosure(i1, 160, 1);
+ _lua_rawseti(i1, -2, 2);
+ _lua_pushvalue(i1, -2);
+ _lua_pushcclosure(i1, 161, 1);
+ _lua_rawseti(i1, -2, 3);
+ _lua_pushvalue(i1, -2);
+ _lua_pushcclosure(i1, 162, 1);
+ _lua_rawseti(i1, -2, 4);
+ _lua_pushvalue(i1, -1);
+ _lua_setfield(i1, -3, 4232);
+ _lua_setfield(i1, -2, 4240);
+ _setpath(i1, 4256, 4264, 4280, 4296);
+ _setpath(i1, 4440, 4448, 4464, 4480);
+ _lua_pushlstring(i1, 4552, 10) | 0;
+ _lua_setfield(i1, -2, 4568);
+ _luaL_getsubtable(i1, -1001e3, 4576) | 0;
+ _lua_setfield(i1, -2, 4584);
+ _luaL_getsubtable(i1, -1001e3, 4592) | 0;
+ _lua_setfield(i1, -2, 4608);
+ _lua_rawgeti(i1, -1001e3, 2);
+ _lua_pushvalue(i1, -2);
+ _luaL_setfuncs(i1, 4616, 1);
+ _lua_settop(i1, -2);
+ STACKTOP = i2;
+ return 1;
+}
+function _lua_rawlen(i3, i5) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i4 = 0;
+ i1 = STACKTOP;
+ i4 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i2 = (HEAP32[i3 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i2 = (HEAP32[i3 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i3 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i2 = HEAP32[i4 >> 2] | 0, (i3 | 0) <= (HEAPU8[i2 + 6 | 0] | 0 | 0)) : 0) {
+ i2 = i2 + (i3 + -1 << 4) + 16 | 0;
+ } else {
+ i2 = 5192;
+ }
+ } else {
+ i2 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i2 = i2 >>> 0 < (HEAP32[i3 + 8 >> 2] | 0) >>> 0 ? i2 : 5192;
+ }
+ } while (0);
+ i3 = HEAP32[i2 + 8 >> 2] & 15;
+ if ((i3 | 0) == 5) {
+ i5 = _luaH_getn(HEAP32[i2 >> 2] | 0) | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ } else if ((i3 | 0) == 4) {
+ i5 = HEAP32[(HEAP32[i2 >> 2] | 0) + 12 >> 2] | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ } else if ((i3 | 0) == 7) {
+ i5 = HEAP32[(HEAP32[i2 >> 2] | 0) + 16 >> 2] | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ } else {
+ i5 = 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ return 0;
+}
+function _searchpath(i3, i5, i6, i7, i8) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ i7 = i7 | 0;
+ i8 = i8 | 0;
+ var i1 = 0, i2 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 1056 | 0;
+ i4 = i2;
+ i1 = i2 + 8 | 0;
+ _luaL_buffinit(i3, i1);
+ if ((HEAP8[i7] | 0) != 0) {
+ i5 = _luaL_gsub(i3, i5, i7, i8) | 0;
+ }
+ while (1) {
+ i7 = HEAP8[i6] | 0;
+ if (i7 << 24 >> 24 == 59) {
+ i6 = i6 + 1 | 0;
+ continue;
+ } else if (i7 << 24 >> 24 == 0) {
+ i3 = 12;
+ break;
+ }
+ i8 = _strchr(i6, 59) | 0;
+ if ((i8 | 0) == 0) {
+ i8 = i6 + (_strlen(i6 | 0) | 0) | 0;
+ }
+ _lua_pushlstring(i3, i6, i8 - i6 | 0) | 0;
+ if ((i8 | 0) == 0) {
+ i3 = 12;
+ break;
+ }
+ i6 = _luaL_gsub(i3, _lua_tolstring(i3, -1, 0) | 0, 5064, i5) | 0;
+ _lua_remove(i3, -2);
+ i7 = _fopen(i6 | 0, 5088) | 0;
+ if ((i7 | 0) != 0) {
+ i3 = 10;
+ break;
+ }
+ HEAP32[i4 >> 2] = i6;
+ _lua_pushfstring(i3, 5072, i4) | 0;
+ _lua_remove(i3, -2);
+ _luaL_addvalue(i1);
+ i6 = i8;
+ }
+ if ((i3 | 0) == 10) {
+ _fclose(i7 | 0) | 0;
+ i8 = i6;
+ STACKTOP = i2;
+ return i8 | 0;
+ } else if ((i3 | 0) == 12) {
+ _luaL_pushresult(i1);
+ i8 = 0;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ return 0;
+}
+function _io_readline(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ i4 = _lua_touserdata(i1, -1001001) | 0;
+ i5 = _lua_tointegerx(i1, -1001002, 0) | 0;
+ if ((HEAP32[i4 + 4 >> 2] | 0) == 0) {
+ i6 = _luaL_error(i1, 3344, i3) | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ _lua_settop(i1, 1);
+ if ((i5 | 0) >= 1) {
+ i6 = 1;
+ while (1) {
+ _lua_pushvalue(i1, -1001003 - i6 | 0);
+ if ((i6 | 0) == (i5 | 0)) {
+ break;
+ } else {
+ i6 = i6 + 1 | 0;
+ }
+ }
+ }
+ i4 = _g_read(i1, HEAP32[i4 >> 2] | 0, 2) | 0;
+ if ((_lua_type(i1, 0 - i4 | 0) | 0) != 0) {
+ i6 = i4;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ if ((i4 | 0) > 1) {
+ HEAP32[i3 >> 2] = _lua_tolstring(i1, 1 - i4 | 0, 0) | 0;
+ i6 = _luaL_error(i1, 3368, i3) | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ if ((_lua_toboolean(i1, -1001003) | 0) == 0) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ _lua_settop(i1, 0);
+ _lua_pushvalue(i1, -1001001);
+ i5 = (_luaL_checkudata(i1, 1, 2832) | 0) + 4 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = 0;
+ FUNCTION_TABLE_ii[i6 & 255](i1) | 0;
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+}
+function _luaK_setreturns(i3, i5, i6) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i5 >> 2] | 0;
+ if ((i4 | 0) == 13) {
+ i7 = i5 + 8 | 0;
+ i8 = HEAP32[i3 >> 2] | 0;
+ i4 = HEAP32[i8 + 12 >> 2] | 0;
+ i5 = i4 + (HEAP32[i7 >> 2] << 2) | 0;
+ HEAP32[i5 >> 2] = HEAP32[i5 >> 2] & 8388607 | (i6 << 23) + 8388608;
+ i7 = i4 + (HEAP32[i7 >> 2] << 2) | 0;
+ i4 = i3 + 48 | 0;
+ HEAP32[i7 >> 2] = (HEAPU8[i4] | 0) << 6 | HEAP32[i7 >> 2] & -16321;
+ i7 = HEAP8[i4] | 0;
+ i5 = (i7 & 255) + 1 | 0;
+ i6 = i8 + 78 | 0;
+ do {
+ if (i5 >>> 0 > (HEAPU8[i6] | 0) >>> 0) {
+ if (i5 >>> 0 > 249) {
+ _luaX_syntaxerror(HEAP32[i3 + 12 >> 2] | 0, 10536);
+ } else {
+ HEAP8[i6] = i5;
+ i1 = HEAP8[i4] | 0;
+ break;
+ }
+ } else {
+ i1 = i7;
+ }
+ } while (0);
+ HEAP8[i4] = (i1 & 255) + 1;
+ STACKTOP = i2;
+ return;
+ } else if ((i4 | 0) == 12) {
+ i8 = (HEAP32[(HEAP32[i3 >> 2] | 0) + 12 >> 2] | 0) + (HEAP32[i5 + 8 >> 2] << 2) | 0;
+ HEAP32[i8 >> 2] = HEAP32[i8 >> 2] & -8372225 | (i6 << 14) + 16384 & 8372224;
+ STACKTOP = i2;
+ return;
+ } else {
+ STACKTOP = i2;
+ return;
+ }
+}
+function _luaZ_read(i2, i9, i8) {
+ i2 = i2 | 0;
+ i9 = i9 | 0;
+ i8 = i8 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i10 = 0, i11 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i1;
+ if ((i8 | 0) == 0) {
+ i11 = 0;
+ STACKTOP = i1;
+ return i11 | 0;
+ }
+ i7 = i2 + 16 | 0;
+ i6 = i2 + 8 | 0;
+ i4 = i2 + 12 | 0;
+ i5 = i2 + 4 | 0;
+ i11 = HEAP32[i2 >> 2] | 0;
+ while (1) {
+ if ((i11 | 0) == 0) {
+ i10 = FUNCTION_TABLE_iiii[HEAP32[i6 >> 2] & 3](HEAP32[i7 >> 2] | 0, HEAP32[i4 >> 2] | 0, i3) | 0;
+ if ((i10 | 0) == 0) {
+ i2 = 9;
+ break;
+ }
+ i11 = HEAP32[i3 >> 2] | 0;
+ if ((i11 | 0) == 0) {
+ i2 = 9;
+ break;
+ }
+ HEAP32[i2 >> 2] = i11;
+ HEAP32[i5 >> 2] = i10;
+ } else {
+ i10 = HEAP32[i5 >> 2] | 0;
+ }
+ i11 = i8 >>> 0 > i11 >>> 0 ? i11 : i8;
+ _memcpy(i9 | 0, i10 | 0, i11 | 0) | 0;
+ i10 = (HEAP32[i2 >> 2] | 0) - i11 | 0;
+ HEAP32[i2 >> 2] = i10;
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + i11;
+ if ((i8 | 0) == (i11 | 0)) {
+ i8 = 0;
+ i2 = 9;
+ break;
+ } else {
+ i8 = i8 - i11 | 0;
+ i9 = i9 + i11 | 0;
+ i11 = i10;
+ }
+ }
+ if ((i2 | 0) == 9) {
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ return 0;
+}
+function _lua_load(i1, i5, i4, i3, i6) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ var i2 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i7 = i2;
+ _luaZ_init(i1, i7, i5, i4);
+ i3 = _luaD_protectedparser(i1, i7, (i3 | 0) == 0 ? 928 : i3, i6) | 0;
+ if ((i3 | 0) != 0) {
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ i4 = HEAP32[(HEAP32[i1 + 8 >> 2] | 0) + -16 >> 2] | 0;
+ if ((HEAP8[i4 + 6 | 0] | 0) != 1) {
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ i5 = _luaH_getint(HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 40 >> 2] | 0, 2) | 0;
+ i4 = i4 + 16 | 0;
+ i6 = HEAP32[(HEAP32[i4 >> 2] | 0) + 8 >> 2] | 0;
+ i9 = i5;
+ i8 = HEAP32[i9 + 4 >> 2] | 0;
+ i7 = i6;
+ HEAP32[i7 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i7 + 4 >> 2] = i8;
+ i7 = i5 + 8 | 0;
+ HEAP32[i6 + 8 >> 2] = HEAP32[i7 >> 2];
+ if ((HEAP32[i7 >> 2] & 64 | 0) == 0) {
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP8[i5 + 5 | 0] & 3) == 0) {
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP8[i4 + 5 | 0] & 4) == 0) {
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ _luaC_barrier_(i1, i4, i5);
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _g_write(i1, i4, i8) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i8 = i8 | 0;
+ var i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i9 = 0, d10 = 0.0;
+ i5 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i5;
+ i3 = i5 + 8 | 0;
+ i7 = _lua_gettop(i1) | 0;
+ if ((i7 | 0) == (i8 | 0)) {
+ i9 = 1;
+ STACKTOP = i5;
+ return i9 | 0;
+ }
+ i6 = i8;
+ i7 = i7 - i8 | 0;
+ i9 = 1;
+ while (1) {
+ i7 = i7 + -1 | 0;
+ if ((_lua_type(i1, i6) | 0) == 3) {
+ if ((i9 | 0) == 0) {
+ i8 = 0;
+ } else {
+ d10 = +_lua_tonumberx(i1, i6, 0);
+ HEAPF64[tempDoublePtr >> 3] = d10;
+ HEAP32[i2 >> 2] = HEAP32[tempDoublePtr >> 2];
+ HEAP32[i2 + 4 >> 2] = HEAP32[tempDoublePtr + 4 >> 2];
+ i8 = (_fprintf(i4 | 0, 3072, i2 | 0) | 0) > 0;
+ }
+ } else {
+ i8 = _luaL_checklstring(i1, i6, i3) | 0;
+ if ((i9 | 0) == 0) {
+ i8 = 0;
+ } else {
+ i8 = _fwrite(i8 | 0, 1, HEAP32[i3 >> 2] | 0, i4 | 0) | 0;
+ i8 = (i8 | 0) == (HEAP32[i3 >> 2] | 0);
+ }
+ }
+ if ((i7 | 0) == 0) {
+ break;
+ } else {
+ i6 = i6 + 1 | 0;
+ i9 = i8 & 1;
+ }
+ }
+ if (i8) {
+ i9 = 1;
+ STACKTOP = i5;
+ return i9 | 0;
+ }
+ i9 = _luaL_fileresult(i1, 0, 0) | 0;
+ STACKTOP = i5;
+ return i9 | 0;
+}
+function _lua_getuservalue(i2, i5) {
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i3 = 0, i4 = 0;
+ i1 = STACKTOP;
+ i4 = HEAP32[i2 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i3 = (HEAP32[i2 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i3 = (HEAP32[i2 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i4 >> 2] | 0, (i5 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i3 = i3 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i3 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i3 = i3 >>> 0 < (HEAP32[i2 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ i3 = HEAP32[(HEAP32[i3 >> 2] | 0) + 12 >> 2] | 0;
+ i2 = i2 + 8 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ if ((i3 | 0) == 0) {
+ HEAP32[i4 + 8 >> 2] = 0;
+ i5 = i4;
+ i5 = i5 + 16 | 0;
+ HEAP32[i2 >> 2] = i5;
+ STACKTOP = i1;
+ return;
+ } else {
+ HEAP32[i4 >> 2] = i3;
+ HEAP32[i4 + 8 >> 2] = 69;
+ i5 = HEAP32[i2 >> 2] | 0;
+ i5 = i5 + 16 | 0;
+ HEAP32[i2 >> 2] = i5;
+ STACKTOP = i1;
+ return;
+ }
+}
+function _luaL_addlstring(i7, i6, i1) {
+ i7 = i7 | 0;
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i8 = 0, i9 = 0;
+ i5 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = HEAP32[i7 + 12 >> 2] | 0;
+ i3 = i7 + 4 | 0;
+ i9 = HEAP32[i3 >> 2] | 0;
+ i2 = i7 + 8 | 0;
+ i8 = HEAP32[i2 >> 2] | 0;
+ if (!((i9 - i8 | 0) >>> 0 < i1 >>> 0)) {
+ i7 = HEAP32[i7 >> 2] | 0;
+ i9 = i8;
+ i9 = i7 + i9 | 0;
+ _memcpy(i9 | 0, i6 | 0, i1 | 0) | 0;
+ i9 = HEAP32[i2 >> 2] | 0;
+ i9 = i9 + i1 | 0;
+ HEAP32[i2 >> 2] = i9;
+ STACKTOP = i5;
+ return;
+ }
+ i9 = i9 << 1;
+ i9 = (i9 - i8 | 0) >>> 0 < i1 >>> 0 ? i8 + i1 | 0 : i9;
+ if (i9 >>> 0 < i8 >>> 0 | (i9 - i8 | 0) >>> 0 < i1 >>> 0) {
+ _luaL_error(i4, 1272, i5) | 0;
+ }
+ i8 = _lua_newuserdata(i4, i9) | 0;
+ _memcpy(i8 | 0, HEAP32[i7 >> 2] | 0, HEAP32[i2 >> 2] | 0) | 0;
+ if ((HEAP32[i7 >> 2] | 0) != (i7 + 16 | 0)) {
+ _lua_remove(i4, -2);
+ }
+ HEAP32[i7 >> 2] = i8;
+ HEAP32[i3 >> 2] = i9;
+ i9 = HEAP32[i2 >> 2] | 0;
+ i9 = i8 + i9 | 0;
+ _memcpy(i9 | 0, i6 | 0, i1 | 0) | 0;
+ i9 = HEAP32[i2 >> 2] | 0;
+ i9 = i9 + i1 | 0;
+ HEAP32[i2 >> 2] = i9;
+ STACKTOP = i5;
+ return;
+}
+function _lua_rawgeti(i3, i6, i1) {
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i7 = 0;
+ i2 = STACKTOP;
+ i5 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i6 | 0) <= 0) {
+ if (!((i6 | 0) < -1000999)) {
+ i4 = (HEAP32[i3 + 8 >> 2] | 0) + (i6 << 4) | 0;
+ break;
+ }
+ if ((i6 | 0) == -1001e3) {
+ i4 = (HEAP32[i3 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i6 = -1001e3 - i6 | 0;
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i5 + 8 >> 2] | 0) != 22 ? (i4 = HEAP32[i5 >> 2] | 0, (i6 | 0) <= (HEAPU8[i4 + 6 | 0] | 0 | 0)) : 0) {
+ i4 = i4 + (i6 + -1 << 4) + 16 | 0;
+ } else {
+ i4 = 5192;
+ }
+ } else {
+ i4 = (HEAP32[i5 >> 2] | 0) + (i6 << 4) | 0;
+ i4 = i4 >>> 0 < (HEAP32[i3 + 8 >> 2] | 0) >>> 0 ? i4 : 5192;
+ }
+ } while (0);
+ i4 = _luaH_getint(HEAP32[i4 >> 2] | 0, i1) | 0;
+ i6 = i3 + 8 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ i7 = i4;
+ i1 = HEAP32[i7 + 4 >> 2] | 0;
+ i3 = i5;
+ HEAP32[i3 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i3 + 4 >> 2] = i1;
+ HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + 16;
+ STACKTOP = i2;
+ return;
+}
+function _lua_setfield(i1, i6, i3) {
+ i1 = i1 | 0;
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i5 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i6 | 0) <= 0) {
+ if (!((i6 | 0) < -1000999)) {
+ i4 = (HEAP32[i1 + 8 >> 2] | 0) + (i6 << 4) | 0;
+ break;
+ }
+ if ((i6 | 0) == -1001e3) {
+ i4 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i6 = -1001e3 - i6 | 0;
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i5 + 8 >> 2] | 0) != 22 ? (i4 = HEAP32[i5 >> 2] | 0, (i6 | 0) <= (HEAPU8[i4 + 6 | 0] | 0 | 0)) : 0) {
+ i4 = i4 + (i6 + -1 << 4) + 16 | 0;
+ } else {
+ i4 = 5192;
+ }
+ } else {
+ i4 = (HEAP32[i5 >> 2] | 0) + (i6 << 4) | 0;
+ i4 = i4 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i4 : 5192;
+ }
+ } while (0);
+ i6 = i1 + 8 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i5 + 16;
+ i3 = _luaS_new(i1, i3) | 0;
+ HEAP32[i5 >> 2] = i3;
+ HEAP32[i5 + 8 >> 2] = HEAPU8[i3 + 4 | 0] | 0 | 64;
+ i5 = HEAP32[i6 >> 2] | 0;
+ _luaV_settable(i1, i4, i5 + -16 | 0, i5 + -32 | 0);
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + -32;
+ STACKTOP = i2;
+ return;
+}
+function _luaopen_io(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ _lua_createtable(i1, 0, 11);
+ _luaL_setfuncs(i1, 2680, 0);
+ _luaL_newmetatable(i1, 2832) | 0;
+ _lua_pushvalue(i1, -1);
+ _lua_setfield(i1, -2, 2872);
+ _luaL_setfuncs(i1, 2880, 0);
+ _lua_settop(i1, -2);
+ i5 = HEAP32[_stdin >> 2] | 0;
+ i4 = _lua_newuserdata(i1, 8) | 0;
+ i3 = i4 + 4 | 0;
+ HEAP32[i3 >> 2] = 0;
+ _luaL_setmetatable(i1, 2832);
+ HEAP32[i4 >> 2] = i5;
+ HEAP32[i3 >> 2] = 154;
+ _lua_pushvalue(i1, -1);
+ _lua_setfield(i1, -1001e3, 2776);
+ _lua_setfield(i1, -2, 2792);
+ i3 = HEAP32[_stdout >> 2] | 0;
+ i4 = _lua_newuserdata(i1, 8) | 0;
+ i5 = i4 + 4 | 0;
+ HEAP32[i5 >> 2] = 0;
+ _luaL_setmetatable(i1, 2832);
+ HEAP32[i4 >> 2] = i3;
+ HEAP32[i5 >> 2] = 154;
+ _lua_pushvalue(i1, -1);
+ _lua_setfield(i1, -1001e3, 2800);
+ _lua_setfield(i1, -2, 2816);
+ i5 = HEAP32[_stderr >> 2] | 0;
+ i4 = _lua_newuserdata(i1, 8) | 0;
+ i3 = i4 + 4 | 0;
+ HEAP32[i3 >> 2] = 0;
+ _luaL_setmetatable(i1, 2832);
+ HEAP32[i4 >> 2] = i5;
+ HEAP32[i3 >> 2] = 154;
+ _lua_setfield(i1, -2, 2824);
+ STACKTOP = i2;
+ return 1;
+}
+function _lua_pushcclosure(i1, i4, i5) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i2 = STACKTOP;
+ if ((i5 | 0) == 0) {
+ i6 = HEAP32[i1 + 8 >> 2] | 0;
+ HEAP32[i6 >> 2] = i4;
+ HEAP32[i6 + 8 >> 2] = 22;
+ i6 = i1 + 8 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ i5 = i5 + 16 | 0;
+ HEAP32[i6 >> 2] = i5;
+ STACKTOP = i2;
+ return;
+ }
+ if ((HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ _luaC_step(i1);
+ }
+ i3 = _luaF_newCclosure(i1, i5) | 0;
+ HEAP32[i3 + 12 >> 2] = i4;
+ i4 = i1 + 8 | 0;
+ i6 = (HEAP32[i4 >> 2] | 0) + (0 - i5 << 4) | 0;
+ HEAP32[i4 >> 2] = i6;
+ do {
+ i5 = i5 + -1 | 0;
+ i9 = i6 + (i5 << 4) | 0;
+ i8 = HEAP32[i9 + 4 >> 2] | 0;
+ i7 = i3 + (i5 << 4) + 16 | 0;
+ HEAP32[i7 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i7 + 4 >> 2] = i8;
+ HEAP32[i3 + (i5 << 4) + 24 >> 2] = HEAP32[i6 + (i5 << 4) + 8 >> 2];
+ i6 = HEAP32[i4 >> 2] | 0;
+ } while ((i5 | 0) != 0);
+ HEAP32[i6 >> 2] = i3;
+ HEAP32[i6 + 8 >> 2] = 102;
+ i9 = i1 + 8 | 0;
+ i8 = HEAP32[i9 >> 2] | 0;
+ i8 = i8 + 16 | 0;
+ HEAP32[i9 >> 2] = i8;
+ STACKTOP = i2;
+ return;
+}
+function _luaF_findupval(i3, i4) {
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i1 = STACKTOP;
+ i2 = HEAP32[i3 + 12 >> 2] | 0;
+ i6 = i3 + 56 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ L1 : do {
+ if ((i5 | 0) == 0) {
+ i5 = i6;
+ } else {
+ while (1) {
+ i7 = HEAP32[i5 + 8 >> 2] | 0;
+ if (i7 >>> 0 < i4 >>> 0) {
+ i5 = i6;
+ break L1;
+ }
+ if ((i7 | 0) == (i4 | 0)) {
+ break;
+ }
+ i6 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) == 0) {
+ break L1;
+ } else {
+ i7 = i5;
+ i5 = i6;
+ i6 = i7;
+ }
+ }
+ i4 = i5 + 5 | 0;
+ i3 = (HEAPU8[i4] | 0) ^ 3;
+ if ((((HEAPU8[i2 + 60 | 0] | 0) ^ 3) & i3 | 0) != 0) {
+ i7 = i5;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ HEAP8[i4] = i3;
+ i7 = i5;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ } while (0);
+ i7 = _luaC_newobj(i3, 10, 32, i5, 0) | 0;
+ HEAP32[i7 + 8 >> 2] = i4;
+ i4 = i7 + 16 | 0;
+ HEAP32[i4 >> 2] = i2 + 112;
+ i6 = i2 + 132 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i4 + 4 >> 2] = i5;
+ HEAP32[i5 + 16 >> 2] = i7;
+ HEAP32[i6 >> 2] = i7;
+ STACKTOP = i1;
+ return i7 | 0;
+}
+function _luaC_checkfinalizer(i5, i4, i6) {
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i7 = 0, i8 = 0;
+ i3 = STACKTOP;
+ i1 = HEAP32[i5 + 12 >> 2] | 0;
+ i2 = i4 + 5 | 0;
+ if ((HEAP8[i2] & 24) != 0 | (i6 | 0) == 0) {
+ STACKTOP = i3;
+ return;
+ }
+ if (!((HEAP8[i6 + 6 | 0] & 4) == 0)) {
+ STACKTOP = i3;
+ return;
+ }
+ if ((_luaT_gettm(i6, 2, HEAP32[i1 + 192 >> 2] | 0) | 0) == 0) {
+ STACKTOP = i3;
+ return;
+ }
+ i7 = i1 + 76 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if ((i8 | 0) == (i4 | 0)) {
+ do {
+ i6 = _sweeplist(i5, i8, 1) | 0;
+ } while ((i6 | 0) == (i8 | 0));
+ HEAP32[i7 >> 2] = i6;
+ }
+ i5 = i1 + 68 | 0;
+ while (1) {
+ i6 = HEAP32[i5 >> 2] | 0;
+ if ((i6 | 0) == (i4 | 0)) {
+ break;
+ } else {
+ i5 = i6;
+ }
+ }
+ HEAP32[i5 >> 2] = HEAP32[i4 >> 2];
+ i8 = i1 + 72 | 0;
+ HEAP32[i4 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i8 >> 2] = i4;
+ i4 = HEAPU8[i2] | 0 | 16;
+ HEAP8[i2] = i4;
+ if ((HEAPU8[i1 + 61 | 0] | 0) < 2) {
+ HEAP8[i2] = i4 & 191;
+ STACKTOP = i3;
+ return;
+ } else {
+ HEAP8[i2] = HEAP8[i1 + 60 | 0] & 3 | i4 & 184;
+ STACKTOP = i3;
+ return;
+ }
+}
+function _io_lines(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ if ((_lua_type(i1, 1) | 0) == -1) {
+ _lua_pushnil(i1);
+ }
+ if ((_lua_type(i1, 1) | 0) == 0) {
+ _lua_getfield(i1, -1001e3, 2776);
+ _lua_replace(i1, 1);
+ if ((HEAP32[(_luaL_checkudata(i1, 1, 2832) | 0) + 4 >> 2] | 0) != 0) {
+ i4 = 0;
+ _aux_lines(i1, i4);
+ STACKTOP = i2;
+ return 1;
+ }
+ _luaL_error(i1, 3080, i3) | 0;
+ i4 = 0;
+ _aux_lines(i1, i4);
+ STACKTOP = i2;
+ return 1;
+ } else {
+ i4 = _luaL_checklstring(i1, 1, 0) | 0;
+ i6 = _lua_newuserdata(i1, 8) | 0;
+ i5 = i6 + 4 | 0;
+ HEAP32[i5 >> 2] = 0;
+ _luaL_setmetatable(i1, 2832);
+ HEAP32[i6 >> 2] = 0;
+ HEAP32[i5 >> 2] = 156;
+ i5 = _fopen(i4 | 0, 3480) | 0;
+ HEAP32[i6 >> 2] = i5;
+ if ((i5 | 0) == 0) {
+ i6 = _strerror(HEAP32[(___errno_location() | 0) >> 2] | 0) | 0;
+ HEAP32[i3 >> 2] = i4;
+ HEAP32[i3 + 4 >> 2] = i6;
+ _luaL_error(i1, 3520, i3) | 0;
+ }
+ _lua_replace(i1, 1);
+ i6 = 1;
+ _aux_lines(i1, i6);
+ STACKTOP = i2;
+ return 1;
+ }
+ return 0;
+}
+function _luaC_changemode(i2, i6) {
+ i2 = i2 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i1 = STACKTOP;
+ i3 = i2 + 12 | 0;
+ i5 = HEAP32[i3 >> 2] | 0;
+ i4 = i5 + 62 | 0;
+ if ((HEAPU8[i4] | 0) == (i6 | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ if ((i6 | 0) == 2) {
+ i3 = i5 + 61 | 0;
+ if ((HEAP8[i3] | 0) != 0) {
+ do {
+ _singlestep(i2) | 0;
+ } while ((HEAP8[i3] | 0) != 0);
+ }
+ HEAP32[i5 + 20 >> 2] = (HEAP32[i5 + 12 >> 2] | 0) + (HEAP32[i5 + 8 >> 2] | 0);
+ HEAP8[i4] = 2;
+ STACKTOP = i1;
+ return;
+ }
+ HEAP8[i4] = 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ HEAP8[i4 + 61 | 0] = 2;
+ HEAP32[i4 + 64 >> 2] = 0;
+ i5 = i4 + 72 | 0;
+ do {
+ i6 = _sweeplist(i2, i5, 1) | 0;
+ } while ((i6 | 0) == (i5 | 0));
+ HEAP32[i4 + 80 >> 2] = i6;
+ i5 = i4 + 68 | 0;
+ do {
+ i6 = _sweeplist(i2, i5, 1) | 0;
+ } while ((i6 | 0) == (i5 | 0));
+ HEAP32[i4 + 76 >> 2] = i6;
+ i3 = (HEAP32[i3 >> 2] | 0) + 61 | 0;
+ if ((1 << HEAPU8[i3] & -29 | 0) != 0) {
+ STACKTOP = i1;
+ return;
+ }
+ do {
+ _singlestep(i2) | 0;
+ } while ((1 << HEAPU8[i3] & -29 | 0) == 0);
+ STACKTOP = i1;
+ return;
+}
+function _lua_rawget(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i3 = (HEAP32[i1 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i3 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i4 >> 2] | 0, (i5 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i3 = i3 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i3 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i3 = i3 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ i5 = i1 + 8 | 0;
+ i4 = _luaH_get(HEAP32[i3 >> 2] | 0, (HEAP32[i5 >> 2] | 0) + -16 | 0) | 0;
+ i5 = HEAP32[i5 >> 2] | 0;
+ i6 = i4;
+ i1 = HEAP32[i6 + 4 >> 2] | 0;
+ i3 = i5 + -16 | 0;
+ HEAP32[i3 >> 2] = HEAP32[i6 >> 2];
+ HEAP32[i3 + 4 >> 2] = i1;
+ HEAP32[i5 + -8 >> 2] = HEAP32[i4 + 8 >> 2];
+ STACKTOP = i2;
+ return;
+}
+function _lua_isstring(i2, i4) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i3 = 0;
+ i1 = STACKTOP;
+ i3 = HEAP32[i2 + 16 >> 2] | 0;
+ do {
+ if ((i4 | 0) <= 0) {
+ if (!((i4 | 0) < -1000999)) {
+ i2 = (HEAP32[i2 + 8 >> 2] | 0) + (i4 << 4) | 0;
+ break;
+ }
+ if ((i4 | 0) == -1001e3) {
+ i2 = (HEAP32[i2 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i2 = -1001e3 - i4 | 0;
+ i3 = HEAP32[i3 >> 2] | 0;
+ if ((HEAP32[i3 + 8 >> 2] | 0) == 22) {
+ i4 = 0;
+ i4 = i4 & 1;
+ STACKTOP = i1;
+ return i4 | 0;
+ }
+ i3 = HEAP32[i3 >> 2] | 0;
+ if ((i2 | 0) > (HEAPU8[i3 + 6 | 0] | 0 | 0)) {
+ i4 = 0;
+ i4 = i4 & 1;
+ STACKTOP = i1;
+ return i4 | 0;
+ } else {
+ i2 = i3 + (i2 + -1 << 4) + 16 | 0;
+ break;
+ }
+ } else {
+ i3 = (HEAP32[i3 >> 2] | 0) + (i4 << 4) | 0;
+ i2 = i3 >>> 0 < (HEAP32[i2 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ if ((i2 | 0) == 5192) {
+ i4 = 0;
+ i4 = i4 & 1;
+ STACKTOP = i1;
+ return i4 | 0;
+ }
+ i4 = ((HEAP32[i2 + 8 >> 2] & 15) + -3 | 0) >>> 0 < 2;
+ i4 = i4 & 1;
+ STACKTOP = i1;
+ return i4 | 0;
+}
+function _setnodevector(i5, i1, i3) {
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ if ((i3 | 0) == 0) {
+ HEAP32[i1 + 16 >> 2] = 8016;
+ i6 = 0;
+ i7 = 8016;
+ i4 = 0;
+ i5 = i1 + 7 | 0;
+ HEAP8[i5] = i4;
+ i6 = i7 + (i6 << 5) | 0;
+ i7 = i1 + 20 | 0;
+ HEAP32[i7 >> 2] = i6;
+ STACKTOP = i2;
+ return;
+ }
+ i4 = _luaO_ceillog2(i3) | 0;
+ if ((i4 | 0) > 30) {
+ _luaG_runerror(i5, 8048, i2);
+ }
+ i3 = 1 << i4;
+ if ((i3 + 1 | 0) >>> 0 > 134217727) {
+ _luaM_toobig(i5);
+ }
+ i6 = _luaM_realloc_(i5, 0, 0, i3 << 5) | 0;
+ i5 = i1 + 16 | 0;
+ HEAP32[i5 >> 2] = i6;
+ if ((i3 | 0) > 0) {
+ i7 = 0;
+ do {
+ HEAP32[i6 + (i7 << 5) + 28 >> 2] = 0;
+ HEAP32[i6 + (i7 << 5) + 24 >> 2] = 0;
+ HEAP32[i6 + (i7 << 5) + 8 >> 2] = 0;
+ i7 = i7 + 1 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ } while ((i7 | 0) != (i3 | 0));
+ }
+ i7 = i3;
+ i4 = i4 & 255;
+ i5 = i1 + 7 | 0;
+ HEAP8[i5] = i4;
+ i6 = i6 + (i7 << 5) | 0;
+ i7 = i1 + 20 | 0;
+ HEAP32[i7 >> 2] = i6;
+ STACKTOP = i2;
+ return;
+}
+function _lua_pushvalue(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i3 = (HEAP32[i1 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i3 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i4 >> 2] | 0, (i5 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i3 = i3 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i3 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i3 = i3 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ i5 = i1 + 8 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i7 = i3;
+ i6 = HEAP32[i7 + 4 >> 2] | 0;
+ i1 = i4;
+ HEAP32[i1 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i1 + 4 >> 2] = i6;
+ HEAP32[i4 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + 16;
+ STACKTOP = i2;
+ return;
+}
+function _luaL_setfuncs(i3, i6, i1) {
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ _luaL_checkversion_(i3, 502.0);
+ if ((_lua_checkstack(i3, i1 + 20 | 0) | 0) == 0) {
+ HEAP32[i4 >> 2] = 1472;
+ _luaL_error(i3, 1216, i4) | 0;
+ }
+ if ((HEAP32[i6 >> 2] | 0) == 0) {
+ i7 = ~i1;
+ _lua_settop(i3, i7);
+ STACKTOP = i2;
+ return;
+ }
+ i4 = -2 - i1 | 0;
+ i5 = 0 - i1 | 0;
+ if ((i1 | 0) <= 0) {
+ do {
+ _lua_pushcclosure(i3, HEAP32[i6 + 4 >> 2] | 0, i1);
+ _lua_setfield(i3, i4, HEAP32[i6 >> 2] | 0);
+ i6 = i6 + 8 | 0;
+ } while ((HEAP32[i6 >> 2] | 0) != 0);
+ i7 = ~i1;
+ _lua_settop(i3, i7);
+ STACKTOP = i2;
+ return;
+ }
+ do {
+ i7 = 0;
+ do {
+ _lua_pushvalue(i3, i5);
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) != (i1 | 0));
+ _lua_pushcclosure(i3, HEAP32[i6 + 4 >> 2] | 0, i1);
+ _lua_setfield(i3, i4, HEAP32[i6 >> 2] | 0);
+ i6 = i6 + 8 | 0;
+ } while ((HEAP32[i6 >> 2] | 0) != 0);
+ i7 = ~i1;
+ _lua_settop(i3, i7);
+ STACKTOP = i2;
+ return;
+}
+function _lua_touserdata(i3, i5) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i4 = 0;
+ i1 = STACKTOP;
+ i4 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i2 = (HEAP32[i3 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i2 = (HEAP32[i3 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i3 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i2 = HEAP32[i4 >> 2] | 0, (i3 | 0) <= (HEAPU8[i2 + 6 | 0] | 0 | 0)) : 0) {
+ i2 = i2 + (i3 + -1 << 4) + 16 | 0;
+ } else {
+ i2 = 5192;
+ }
+ } else {
+ i2 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i2 = i2 >>> 0 < (HEAP32[i3 + 8 >> 2] | 0) >>> 0 ? i2 : 5192;
+ }
+ } while (0);
+ i3 = HEAP32[i2 + 8 >> 2] & 15;
+ if ((i3 | 0) == 2) {
+ i5 = HEAP32[i2 >> 2] | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ } else if ((i3 | 0) == 7) {
+ i5 = (HEAP32[i2 >> 2] | 0) + 24 | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ } else {
+ i5 = 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ return 0;
+}
+function _luaL_checkoption(i2, i3, i6, i4) {
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i5 = i1;
+ if ((i6 | 0) == 0) {
+ i6 = _lua_tolstring(i2, i3, 0) | 0;
+ if ((i6 | 0) == 0) {
+ i9 = _lua_typename(i2, 4) | 0;
+ i6 = _lua_typename(i2, _lua_type(i2, i3) | 0) | 0;
+ HEAP32[i5 >> 2] = i9;
+ HEAP32[i5 + 4 >> 2] = i6;
+ _luaL_argerror(i2, i3, _lua_pushfstring(i2, 1744, i5) | 0) | 0;
+ i6 = 0;
+ }
+ } else {
+ i6 = _luaL_optlstring(i2, i3, i6, 0) | 0;
+ }
+ i9 = HEAP32[i4 >> 2] | 0;
+ L6 : do {
+ if ((i9 | 0) != 0) {
+ i8 = 0;
+ while (1) {
+ i7 = i8 + 1 | 0;
+ if ((_strcmp(i9, i6) | 0) == 0) {
+ break;
+ }
+ i9 = HEAP32[i4 + (i7 << 2) >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break L6;
+ } else {
+ i8 = i7;
+ }
+ }
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ } while (0);
+ HEAP32[i5 >> 2] = i6;
+ i9 = _luaL_argerror(i2, i3, _lua_pushfstring(i2, 1192, i5) | 0) | 0;
+ STACKTOP = i1;
+ return i9 | 0;
+}
+function _lua_toboolean(i3, i5) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i4 = 0;
+ i1 = STACKTOP;
+ i4 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i3 = (HEAP32[i3 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i3 = (HEAP32[i3 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i3 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i2 = HEAP32[i4 >> 2] | 0, (i3 | 0) <= (HEAPU8[i2 + 6 | 0] | 0 | 0)) : 0) {
+ i3 = i2 + (i3 + -1 << 4) + 16 | 0;
+ } else {
+ i3 = 5192;
+ }
+ } else {
+ i2 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i3 = i2 >>> 0 < (HEAP32[i3 + 8 >> 2] | 0) >>> 0 ? i2 : 5192;
+ }
+ } while (0);
+ i2 = HEAP32[i3 + 8 >> 2] | 0;
+ if ((i2 | 0) == 0) {
+ i5 = 0;
+ i5 = i5 & 1;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ if ((i2 | 0) != 1) {
+ i5 = 1;
+ i5 = i5 & 1;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ i5 = (HEAP32[i3 >> 2] | 0) != 0;
+ i5 = i5 & 1;
+ STACKTOP = i1;
+ return i5 | 0;
+}
+function _lua_getfield(i1, i6, i3) {
+ i1 = i1 | 0;
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i5 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i6 | 0) <= 0) {
+ if (!((i6 | 0) < -1000999)) {
+ i4 = (HEAP32[i1 + 8 >> 2] | 0) + (i6 << 4) | 0;
+ break;
+ }
+ if ((i6 | 0) == -1001e3) {
+ i4 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i6 = -1001e3 - i6 | 0;
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i5 + 8 >> 2] | 0) != 22 ? (i4 = HEAP32[i5 >> 2] | 0, (i6 | 0) <= (HEAPU8[i4 + 6 | 0] | 0 | 0)) : 0) {
+ i4 = i4 + (i6 + -1 << 4) + 16 | 0;
+ } else {
+ i4 = 5192;
+ }
+ } else {
+ i4 = (HEAP32[i5 >> 2] | 0) + (i6 << 4) | 0;
+ i4 = i4 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i4 : 5192;
+ }
+ } while (0);
+ i5 = i1 + 8 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ i3 = _luaS_new(i1, i3) | 0;
+ HEAP32[i6 >> 2] = i3;
+ HEAP32[i6 + 8 >> 2] = HEAPU8[i3 + 4 | 0] | 0 | 64;
+ i6 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i6 + 16;
+ _luaV_gettable(i1, i4, i6, i6);
+ STACKTOP = i2;
+ return;
+}
+function _luaL_argerror(i1, i6, i3) {
+ i1 = i1 | 0;
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 112 | 0;
+ i2 = i4;
+ i5 = i4 + 12 | 0;
+ if ((_lua_getstack(i1, 0, i5) | 0) == 0) {
+ HEAP32[i2 >> 2] = i6;
+ HEAP32[i2 + 4 >> 2] = i3;
+ i8 = _luaL_error(i1, 1040, i2) | 0;
+ STACKTOP = i4;
+ return i8 | 0;
+ }
+ _lua_getinfo(i1, 1064, i5) | 0;
+ if ((_strcmp(HEAP32[i5 + 8 >> 2] | 0, 1072) | 0) == 0) {
+ i6 = i6 + -1 | 0;
+ if ((i6 | 0) == 0) {
+ HEAP32[i2 >> 2] = HEAP32[i5 + 4 >> 2];
+ HEAP32[i2 + 4 >> 2] = i3;
+ i8 = _luaL_error(i1, 1080, i2) | 0;
+ STACKTOP = i4;
+ return i8 | 0;
+ }
+ }
+ i7 = i5 + 4 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if ((i8 | 0) == 0) {
+ if ((_pushglobalfuncname(i1, i5) | 0) == 0) {
+ i8 = 1112;
+ } else {
+ i8 = _lua_tolstring(i1, -1, 0) | 0;
+ }
+ HEAP32[i7 >> 2] = i8;
+ }
+ HEAP32[i2 >> 2] = i6;
+ HEAP32[i2 + 4 >> 2] = i8;
+ HEAP32[i2 + 8 >> 2] = i3;
+ i8 = _luaL_error(i1, 1120, i2) | 0;
+ STACKTOP = i4;
+ return i8 | 0;
+}
+function _match_class(i3, i2) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i1 = 0;
+ i1 = STACKTOP;
+ switch (_tolower(i2 | 0) | 0) {
+ case 117:
+ {
+ i3 = _isupper(i3 | 0) | 0;
+ break;
+ }
+ case 97:
+ {
+ i3 = _isalpha(i3 | 0) | 0;
+ break;
+ }
+ case 99:
+ {
+ i3 = _iscntrl(i3 | 0) | 0;
+ break;
+ }
+ case 120:
+ {
+ i3 = _isxdigit(i3 | 0) | 0;
+ break;
+ }
+ case 119:
+ {
+ i3 = _isalnum(i3 | 0) | 0;
+ break;
+ }
+ case 112:
+ {
+ i3 = _ispunct(i3 | 0) | 0;
+ break;
+ }
+ case 100:
+ {
+ i3 = (i3 + -48 | 0) >>> 0 < 10 | 0;
+ break;
+ }
+ case 108:
+ {
+ i3 = _islower(i3 | 0) | 0;
+ break;
+ }
+ case 122:
+ {
+ i3 = (i3 | 0) == 0 | 0;
+ break;
+ }
+ case 103:
+ {
+ i3 = _isgraph(i3 | 0) | 0;
+ break;
+ }
+ case 115:
+ {
+ i3 = _isspace(i3 | 0) | 0;
+ break;
+ }
+ default:
+ {
+ i3 = (i2 | 0) == (i3 | 0) | 0;
+ STACKTOP = i1;
+ return i3 | 0;
+ }
+ }
+ if ((_islower(i2 | 0) | 0) != 0) {
+ STACKTOP = i1;
+ return i3 | 0;
+ }
+ i3 = (i3 | 0) == 0 | 0;
+ STACKTOP = i1;
+ return i3 | 0;
+}
+function _condjump(i1, i3, i6, i4, i5) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i2 = STACKTOP;
+ _luaK_code(i1, i6 << 6 | i3 | i4 << 23 | i5 << 14) | 0;
+ i3 = i1 + 28 | 0;
+ i6 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = -1;
+ i3 = _luaK_code(i1, 2147450903) | 0;
+ if ((i6 | 0) == -1) {
+ i9 = i3;
+ STACKTOP = i2;
+ return i9 | 0;
+ }
+ if ((i3 | 0) == -1) {
+ i9 = i6;
+ STACKTOP = i2;
+ return i9 | 0;
+ }
+ i8 = HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0;
+ i7 = i3;
+ while (1) {
+ i4 = i8 + (i7 << 2) | 0;
+ i5 = HEAP32[i4 >> 2] | 0;
+ i9 = (i5 >>> 14) + -131071 | 0;
+ if ((i9 | 0) == -1) {
+ break;
+ }
+ i9 = i7 + 1 + i9 | 0;
+ if ((i9 | 0) == -1) {
+ break;
+ } else {
+ i7 = i9;
+ }
+ }
+ i6 = i6 + ~i7 | 0;
+ if ((((i6 | 0) > -1 ? i6 : 0 - i6 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10624);
+ }
+ HEAP32[i4 >> 2] = (i6 << 14) + 2147467264 | i5 & 16383;
+ i9 = i3;
+ STACKTOP = i2;
+ return i9 | 0;
+}
+function _skipcomment(i6, i1) {
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ HEAP32[i6 >> 2] = 0;
+ i3 = i6 + 4 | 0;
+ i5 = 1712;
+ while (1) {
+ i7 = _fgetc(HEAP32[i3 >> 2] | 0) | 0;
+ if ((i7 | 0) == -1) {
+ i4 = 3;
+ break;
+ }
+ i8 = i5 + 1 | 0;
+ if ((i7 | 0) != (HEAPU8[i5] | 0)) {
+ break;
+ }
+ i5 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i5 + 1;
+ HEAP8[i6 + i5 + 8 | 0] = i7;
+ if ((HEAP8[i8] | 0) == 0) {
+ i4 = 6;
+ break;
+ } else {
+ i5 = i8;
+ }
+ }
+ if ((i4 | 0) == 3) {
+ HEAP32[i1 >> 2] = -1;
+ i8 = 0;
+ STACKTOP = i2;
+ return i8 | 0;
+ } else if ((i4 | 0) == 6) {
+ HEAP32[i6 >> 2] = 0;
+ i7 = _fgetc(HEAP32[i3 >> 2] | 0) | 0;
+ }
+ HEAP32[i1 >> 2] = i7;
+ if ((i7 | 0) != 35) {
+ i8 = 0;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ do {
+ i8 = _fgetc(HEAP32[i3 >> 2] | 0) | 0;
+ } while (!((i8 | 0) == 10 | (i8 | 0) == -1));
+ HEAP32[i1 >> 2] = _fgetc(HEAP32[i3 >> 2] | 0) | 0;
+ i8 = 1;
+ STACKTOP = i2;
+ return i8 | 0;
+}
+function _lua_isnumber(i4, i6) {
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i1;
+ i5 = HEAP32[i4 + 16 >> 2] | 0;
+ do {
+ if ((i6 | 0) <= 0) {
+ if (!((i6 | 0) < -1000999)) {
+ i3 = (HEAP32[i4 + 8 >> 2] | 0) + (i6 << 4) | 0;
+ break;
+ }
+ if ((i6 | 0) == -1001e3) {
+ i3 = (HEAP32[i4 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i4 = -1001e3 - i6 | 0;
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i5 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i5 >> 2] | 0, (i4 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i3 = i3 + (i4 + -1 << 4) + 16 | 0;
+ } else {
+ i3 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i5 >> 2] | 0) + (i6 << 4) | 0;
+ i3 = i3 >>> 0 < (HEAP32[i4 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ if ((HEAP32[i3 + 8 >> 2] | 0) == 3) {
+ i6 = 1;
+ i6 = i6 & 1;
+ STACKTOP = i1;
+ return i6 | 0;
+ }
+ i6 = (_luaV_tonumber(i3, i2) | 0) != 0;
+ i6 = i6 & 1;
+ STACKTOP = i1;
+ return i6 | 0;
+}
+function ___shgetc(i3) {
+ i3 = i3 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ i7 = i3 + 104 | 0;
+ i6 = HEAP32[i7 >> 2] | 0;
+ if (!((i6 | 0) != 0 ? (HEAP32[i3 + 108 >> 2] | 0) >= (i6 | 0) : 0)) {
+ i8 = 3;
+ }
+ if ((i8 | 0) == 3 ? (i1 = ___uflow(i3) | 0, (i1 | 0) >= 0) : 0) {
+ i7 = HEAP32[i7 >> 2] | 0;
+ i6 = HEAP32[i3 + 8 >> 2] | 0;
+ if ((i7 | 0) != 0 ? (i4 = HEAP32[i3 + 4 >> 2] | 0, i5 = i7 - (HEAP32[i3 + 108 >> 2] | 0) + -1 | 0, (i6 - i4 | 0) > (i5 | 0)) : 0) {
+ HEAP32[i3 + 100 >> 2] = i4 + i5;
+ } else {
+ HEAP32[i3 + 100 >> 2] = i6;
+ }
+ i4 = HEAP32[i3 + 4 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i8 = i3 + 108 | 0;
+ HEAP32[i8 >> 2] = i6 + 1 - i4 + (HEAP32[i8 >> 2] | 0);
+ }
+ i3 = i4 + -1 | 0;
+ if ((HEAPU8[i3] | 0 | 0) == (i1 | 0)) {
+ i8 = i1;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ HEAP8[i3] = i1;
+ i8 = i1;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ HEAP32[i3 + 100 >> 2] = 0;
+ i8 = -1;
+ STACKTOP = i2;
+ return i8 | 0;
+}
+function _lua_type(i2, i4) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i3 = 0;
+ i1 = STACKTOP;
+ i3 = HEAP32[i2 + 16 >> 2] | 0;
+ do {
+ if ((i4 | 0) <= 0) {
+ if (!((i4 | 0) < -1000999)) {
+ i2 = (HEAP32[i2 + 8 >> 2] | 0) + (i4 << 4) | 0;
+ break;
+ }
+ if ((i4 | 0) == -1001e3) {
+ i2 = (HEAP32[i2 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i2 = -1001e3 - i4 | 0;
+ i3 = HEAP32[i3 >> 2] | 0;
+ if ((HEAP32[i3 + 8 >> 2] | 0) == 22) {
+ i4 = -1;
+ STACKTOP = i1;
+ return i4 | 0;
+ }
+ i3 = HEAP32[i3 >> 2] | 0;
+ if ((i2 | 0) > (HEAPU8[i3 + 6 | 0] | 0 | 0)) {
+ i4 = -1;
+ STACKTOP = i1;
+ return i4 | 0;
+ } else {
+ i2 = i3 + (i2 + -1 << 4) + 16 | 0;
+ break;
+ }
+ } else {
+ i3 = (HEAP32[i3 >> 2] | 0) + (i4 << 4) | 0;
+ i2 = i3 >>> 0 < (HEAP32[i2 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ if ((i2 | 0) == 5192) {
+ i4 = -1;
+ STACKTOP = i1;
+ return i4 | 0;
+ }
+ i4 = HEAP32[i2 + 8 >> 2] & 15;
+ STACKTOP = i1;
+ return i4 | 0;
+}
+function _g_iofile(i4, i1, i5) {
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ if ((_lua_type(i4, 1) | 0) < 1) {
+ _lua_getfield(i4, -1001e3, i1);
+ STACKTOP = i2;
+ return;
+ }
+ i6 = _lua_tolstring(i4, 1, 0) | 0;
+ if ((i6 | 0) != 0) {
+ i7 = _lua_newuserdata(i4, 8) | 0;
+ i8 = i7 + 4 | 0;
+ HEAP32[i8 >> 2] = 0;
+ _luaL_setmetatable(i4, 2832);
+ HEAP32[i7 >> 2] = 0;
+ HEAP32[i8 >> 2] = 156;
+ i5 = _fopen(i6 | 0, i5 | 0) | 0;
+ HEAP32[i7 >> 2] = i5;
+ if ((i5 | 0) == 0) {
+ i8 = _strerror(HEAP32[(___errno_location() | 0) >> 2] | 0) | 0;
+ HEAP32[i3 >> 2] = i6;
+ HEAP32[i3 + 4 >> 2] = i8;
+ _luaL_error(i4, 3520, i3) | 0;
+ }
+ } else {
+ if ((HEAP32[(_luaL_checkudata(i4, 1, 2832) | 0) + 4 >> 2] | 0) == 0) {
+ _luaL_error(i4, 3080, i3) | 0;
+ }
+ _lua_pushvalue(i4, 1);
+ }
+ _lua_setfield(i4, -1001e3, i1);
+ _lua_getfield(i4, -1001e3, i1);
+ STACKTOP = i2;
+ return;
+}
+function _lua_getlocal(i4, i5, i2) {
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i1;
+ if ((i5 | 0) == 0) {
+ i3 = HEAP32[i4 + 8 >> 2] | 0;
+ if ((HEAP32[i3 + -8 >> 2] | 0) != 70) {
+ i5 = 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ i5 = _luaF_getlocalname(HEAP32[(HEAP32[i3 + -16 >> 2] | 0) + 12 >> 2] | 0, i2, 0) | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ } else {
+ HEAP32[i3 >> 2] = 0;
+ i2 = _findlocal(i4, HEAP32[i5 + 96 >> 2] | 0, i2, i3) | 0;
+ if ((i2 | 0) == 0) {
+ i5 = 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ i3 = HEAP32[i3 >> 2] | 0;
+ i5 = i4 + 8 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i8 = i3;
+ i7 = HEAP32[i8 + 4 >> 2] | 0;
+ i6 = i4;
+ HEAP32[i6 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i6 + 4 >> 2] = i7;
+ HEAP32[i4 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + 16;
+ i5 = i2;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ return 0;
+}
+function _lua_checkstack(i7, i4) {
+ i7 = i7 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i8 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i1;
+ HEAP32[i3 >> 2] = i4;
+ i2 = HEAP32[i7 + 16 >> 2] | 0;
+ i5 = i7 + 8 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ i8 = i6;
+ do {
+ if (((HEAP32[i7 + 24 >> 2] | 0) - i8 >> 4 | 0) <= (i4 | 0)) {
+ if (((i8 - (HEAP32[i7 + 28 >> 2] | 0) >> 4) + 5 | 0) > (1e6 - i4 | 0)) {
+ i8 = 0;
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ i6 = (_luaD_rawrunprotected(i7, 2, i3) | 0) == 0;
+ if (i6) {
+ i5 = HEAP32[i5 >> 2] | 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ i3 = i6 & 1;
+ break;
+ } else {
+ i8 = 0;
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ } else {
+ i5 = i6;
+ i3 = 1;
+ }
+ } while (0);
+ i2 = i2 + 4 | 0;
+ i4 = i5 + (i4 << 4) | 0;
+ if (!((HEAP32[i2 >> 2] | 0) >>> 0 < i4 >>> 0)) {
+ i8 = i3;
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ HEAP32[i2 >> 2] = i4;
+ i8 = i3;
+ STACKTOP = i1;
+ return i8 | 0;
+}
+function _luaK_exp2nextreg(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ _luaK_dischargevars(i1, i3);
+ if (((HEAP32[i3 >> 2] | 0) == 6 ? (i4 = HEAP32[i3 + 8 >> 2] | 0, (i4 & 256 | 0) == 0) : 0) ? (HEAPU8[i1 + 46 | 0] | 0 | 0) <= (i4 | 0) : 0) {
+ i7 = i1 + 48 | 0;
+ HEAP8[i7] = (HEAP8[i7] | 0) + -1 << 24 >> 24;
+ }
+ i4 = i1 + 48 | 0;
+ i5 = HEAP8[i4] | 0;
+ i6 = (i5 & 255) + 1 | 0;
+ i7 = (HEAP32[i1 >> 2] | 0) + 78 | 0;
+ if (!(i6 >>> 0 > (HEAPU8[i7] | 0) >>> 0)) {
+ i7 = i5;
+ i7 = i7 & 255;
+ i7 = i7 + 1 | 0;
+ i6 = i7 & 255;
+ HEAP8[i4] = i6;
+ i7 = i7 & 255;
+ i7 = i7 + -1 | 0;
+ _exp2reg(i1, i3, i7);
+ STACKTOP = i2;
+ return;
+ }
+ if (i6 >>> 0 > 249) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10536);
+ }
+ HEAP8[i7] = i6;
+ i7 = HEAP8[i4] | 0;
+ i7 = i7 & 255;
+ i7 = i7 + 1 | 0;
+ i6 = i7 & 255;
+ HEAP8[i4] = i6;
+ i7 = i7 & 255;
+ i7 = i7 + -1 | 0;
+ _exp2reg(i1, i3, i7);
+ STACKTOP = i2;
+ return;
+}
+function _lua_next(i2, i4) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i3 = 0, i5 = 0;
+ i1 = STACKTOP;
+ i5 = HEAP32[i2 + 16 >> 2] | 0;
+ do {
+ if ((i4 | 0) <= 0) {
+ if (!((i4 | 0) < -1000999)) {
+ i4 = (HEAP32[i2 + 8 >> 2] | 0) + (i4 << 4) | 0;
+ break;
+ }
+ if ((i4 | 0) == -1001e3) {
+ i4 = (HEAP32[i2 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i4 = -1001e3 - i4 | 0;
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i5 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i5 >> 2] | 0, (i4 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i4 = i3 + (i4 + -1 << 4) + 16 | 0;
+ } else {
+ i4 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i5 >> 2] | 0) + (i4 << 4) | 0;
+ i4 = i3 >>> 0 < (HEAP32[i2 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ i3 = i2 + 8 | 0;
+ i2 = _luaH_next(i2, HEAP32[i4 >> 2] | 0, (HEAP32[i3 >> 2] | 0) + -16 | 0) | 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = (i2 | 0) == 0 ? i4 + -16 | 0 : i4 + 16 | 0;
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _inclinenumber(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i1 >> 2] | 0;
+ i3 = i1 + 56 | 0;
+ i5 = HEAP32[i3 >> 2] | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i6 + -1;
+ if ((i6 | 0) == 0) {
+ i5 = _luaZ_fill(i5) | 0;
+ } else {
+ i6 = i5 + 4 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i5 + 1;
+ i5 = HEAPU8[i5] | 0;
+ }
+ HEAP32[i1 >> 2] = i5;
+ if ((i5 | 0) == 13 | (i5 | 0) == 10 ? (i5 | 0) != (i4 | 0) : 0) {
+ i3 = HEAP32[i3 >> 2] | 0;
+ i6 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i6 + -1;
+ if ((i6 | 0) == 0) {
+ i3 = _luaZ_fill(i3) | 0;
+ } else {
+ i6 = i3 + 4 | 0;
+ i3 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i3 + 1;
+ i3 = HEAPU8[i3] | 0;
+ }
+ HEAP32[i1 >> 2] = i3;
+ }
+ i5 = i1 + 4 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i6 + 1;
+ if ((i6 | 0) > 2147483643) {
+ _luaX_syntaxerror(i1, 12560);
+ } else {
+ STACKTOP = i2;
+ return;
+ }
+}
+function _lua_yieldk(i5, i6, i1, i7) {
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ i7 = i7 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ i3 = HEAP32[i5 + 16 >> 2] | 0;
+ if ((HEAP16[i5 + 36 >> 1] | 0) != 0) {
+ if ((HEAP32[(HEAP32[i5 + 12 >> 2] | 0) + 172 >> 2] | 0) == (i5 | 0)) {
+ _luaG_runerror(i5, 2312, i4);
+ } else {
+ _luaG_runerror(i5, 2264, i4);
+ }
+ }
+ HEAP8[i5 + 6 | 0] = 1;
+ HEAP32[i3 + 20 >> 2] = (HEAP32[i3 >> 2] | 0) - (HEAP32[i5 + 28 >> 2] | 0);
+ if (!((HEAP8[i3 + 18 | 0] & 1) == 0)) {
+ STACKTOP = i2;
+ return 0;
+ }
+ HEAP32[i3 + 28 >> 2] = i7;
+ if ((i7 | 0) == 0) {
+ i4 = i5 + 8 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ i7 = ~i6;
+ i7 = i4 + (i7 << 4) | 0;
+ HEAP32[i3 >> 2] = i7;
+ _luaD_throw(i5, 1);
+ }
+ HEAP32[i3 + 24 >> 2] = i1;
+ i4 = i5 + 8 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ i7 = ~i6;
+ i7 = i4 + (i7 << 4) | 0;
+ HEAP32[i3 >> 2] = i7;
+ _luaD_throw(i5, 1);
+ return 0;
+}
+function _luaH_getint(i4, i6) {
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, d3 = 0.0, i5 = 0, i7 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i5 = i1;
+ i7 = i6 + -1 | 0;
+ if (i7 >>> 0 < (HEAP32[i4 + 28 >> 2] | 0) >>> 0) {
+ i7 = (HEAP32[i4 + 12 >> 2] | 0) + (i7 << 4) | 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ d3 = +(i6 | 0);
+ HEAPF64[i5 >> 3] = d3 + 1.0;
+ i5 = (HEAP32[i5 + 4 >> 2] | 0) + (HEAP32[i5 >> 2] | 0) | 0;
+ if ((i5 | 0) < 0) {
+ i6 = 0 - i5 | 0;
+ i5 = (i5 | 0) == (i6 | 0) ? 0 : i6;
+ }
+ i4 = (HEAP32[i4 + 16 >> 2] | 0) + (((i5 | 0) % ((1 << (HEAPU8[i4 + 7 | 0] | 0)) + -1 | 1 | 0) | 0) << 5) | 0;
+ while (1) {
+ if ((HEAP32[i4 + 24 >> 2] | 0) == 3 ? +HEAPF64[i4 + 16 >> 3] == d3 : 0) {
+ break;
+ }
+ i4 = HEAP32[i4 + 28 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ i4 = 5192;
+ i2 = 10;
+ break;
+ }
+ }
+ if ((i2 | 0) == 10) {
+ STACKTOP = i1;
+ return i4 | 0;
+ }
+ i7 = i4;
+ STACKTOP = i1;
+ return i7 | 0;
+}
+function _luaL_checkversion_(i1, d4) {
+ i1 = i1 | 0;
+ d4 = +d4;
+ var i2 = 0, i3 = 0, i5 = 0, d6 = 0.0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ i5 = _lua_version(i1) | 0;
+ if ((i5 | 0) == (_lua_version(0) | 0)) {
+ d6 = +HEAPF64[i5 >> 3];
+ if (d6 != d4) {
+ HEAPF64[tempDoublePtr >> 3] = d4;
+ HEAP32[i3 >> 2] = HEAP32[tempDoublePtr >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[tempDoublePtr + 4 >> 2];
+ i5 = i3 + 8 | 0;
+ HEAPF64[tempDoublePtr >> 3] = d6;
+ HEAP32[i5 >> 2] = HEAP32[tempDoublePtr >> 2];
+ HEAP32[i5 + 4 >> 2] = HEAP32[tempDoublePtr + 4 >> 2];
+ _luaL_error(i1, 1528, i3) | 0;
+ }
+ } else {
+ _luaL_error(i1, 1496, i3) | 0;
+ }
+ _lua_pushnumber(i1, -4660.0);
+ if ((_lua_tointegerx(i1, -1, 0) | 0) == -4660 ? (_lua_tounsignedx(i1, -1, 0) | 0) == -4660 : 0) {
+ _lua_settop(i1, -2);
+ STACKTOP = i2;
+ return;
+ }
+ _luaL_error(i1, 1584, i3) | 0;
+ _lua_settop(i1, -2);
+ STACKTOP = i2;
+ return;
+}
+function _math_random(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, d3 = 0.0, i4 = 0, i5 = 0, d6 = 0.0, d7 = 0.0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ d3 = +((_rand() | 0) % 2147483647 | 0 | 0) / 2147483647.0;
+ i5 = _lua_gettop(i1) | 0;
+ if ((i5 | 0) == 0) {
+ _lua_pushnumber(i1, d3);
+ i5 = 1;
+ STACKTOP = i2;
+ return i5 | 0;
+ } else if ((i5 | 0) == 1) {
+ d6 = +_luaL_checknumber(i1, 1);
+ if (!(d6 >= 1.0)) {
+ _luaL_argerror(i1, 1, 4056) | 0;
+ }
+ _lua_pushnumber(i1, +Math_floor(+(d3 * d6)) + 1.0);
+ i5 = 1;
+ STACKTOP = i2;
+ return i5 | 0;
+ } else if ((i5 | 0) == 2) {
+ d6 = +_luaL_checknumber(i1, 1);
+ d7 = +_luaL_checknumber(i1, 2);
+ if (!(d6 <= d7)) {
+ _luaL_argerror(i1, 2, 4056) | 0;
+ }
+ _lua_pushnumber(i1, d6 + +Math_floor(+(d3 * (d7 - d6 + 1.0))));
+ i5 = 1;
+ STACKTOP = i2;
+ return i5 | 0;
+ } else {
+ i5 = _luaL_error(i1, 4080, i4) | 0;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ return 0;
+}
+function _push_onecapture(i2, i3, i4, i6) {
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i5 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i5 = i1;
+ if ((HEAP32[i2 + 20 >> 2] | 0) <= (i3 | 0)) {
+ i2 = HEAP32[i2 + 16 >> 2] | 0;
+ if ((i3 | 0) == 0) {
+ _lua_pushlstring(i2, i4, i6 - i4 | 0) | 0;
+ STACKTOP = i1;
+ return;
+ } else {
+ _luaL_error(i2, 7224, i5) | 0;
+ STACKTOP = i1;
+ return;
+ }
+ }
+ i4 = HEAP32[i2 + (i3 << 3) + 28 >> 2] | 0;
+ if (!((i4 | 0) == -1)) {
+ i5 = HEAP32[i2 + 16 >> 2] | 0;
+ i3 = HEAP32[i2 + (i3 << 3) + 24 >> 2] | 0;
+ if ((i4 | 0) == -2) {
+ _lua_pushinteger(i5, i3 + 1 - (HEAP32[i2 + 4 >> 2] | 0) | 0);
+ STACKTOP = i1;
+ return;
+ }
+ } else {
+ i6 = i2 + 16 | 0;
+ _luaL_error(HEAP32[i6 >> 2] | 0, 7248, i5) | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ i3 = HEAP32[i2 + (i3 << 3) + 24 >> 2] | 0;
+ }
+ _lua_pushlstring(i5, i3, i4) | 0;
+ STACKTOP = i1;
+ return;
+}
+function _luaK_nil(i7, i6, i5) {
+ i7 = i7 | 0;
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0;
+ i2 = STACKTOP;
+ i9 = i5 + i6 | 0;
+ i1 = i9 + -1 | 0;
+ i10 = HEAP32[i7 + 20 >> 2] | 0;
+ do {
+ if ((i10 | 0) > (HEAP32[i7 + 24 >> 2] | 0) ? (i4 = (HEAP32[(HEAP32[i7 >> 2] | 0) + 12 >> 2] | 0) + (i10 + -1 << 2) | 0, i3 = HEAP32[i4 >> 2] | 0, (i3 & 63 | 0) == 4) : 0) {
+ i11 = i3 >>> 6 & 255;
+ i10 = i11 + (i3 >>> 23) | 0;
+ if (!((i11 | 0) <= (i6 | 0) ? (i10 + 1 | 0) >= (i6 | 0) : 0)) {
+ i8 = 5;
+ }
+ if ((i8 | 0) == 5 ? (i11 | 0) < (i6 | 0) | (i11 | 0) > (i9 | 0) : 0) {
+ break;
+ }
+ i5 = (i11 | 0) < (i6 | 0) ? i11 : i6;
+ HEAP32[i4 >> 2] = ((i10 | 0) > (i1 | 0) ? i10 : i1) - i5 << 23 | i5 << 6 & 16320 | i3 & 8372287;
+ STACKTOP = i2;
+ return;
+ }
+ } while (0);
+ _luaK_code(i7, i6 << 6 | (i5 << 23) + -8388608 | 4) | 0;
+ STACKTOP = i2;
+ return;
+}
+function _lua_settable(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i3 = (HEAP32[i1 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i3 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i4 >> 2] | 0, (i5 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i3 = i3 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i3 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i3 = i3 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ i5 = i1 + 8 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ _luaV_settable(i1, i3, i4 + -32 | 0, i4 + -16 | 0);
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + -32;
+ STACKTOP = i2;
+ return;
+}
+function _luaL_findtable(i3, i6, i5, i4) {
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i7 = 0;
+ i2 = STACKTOP;
+ if ((i6 | 0) != 0) {
+ _lua_pushvalue(i3, i6);
+ }
+ while (1) {
+ i6 = _strchr(i5, 46) | 0;
+ if ((i6 | 0) == 0) {
+ i6 = i5 + (_strlen(i5 | 0) | 0) | 0;
+ }
+ i7 = i6 - i5 | 0;
+ _lua_pushlstring(i3, i5, i7) | 0;
+ _lua_rawget(i3, -2);
+ if ((_lua_type(i3, -1) | 0) != 0) {
+ if ((_lua_type(i3, -1) | 0) != 5) {
+ break;
+ }
+ } else {
+ _lua_settop(i3, -2);
+ _lua_createtable(i3, 0, (HEAP8[i6] | 0) == 46 ? 1 : i4);
+ _lua_pushlstring(i3, i5, i7) | 0;
+ _lua_pushvalue(i3, -2);
+ _lua_settable(i3, -4);
+ }
+ _lua_remove(i3, -2);
+ if ((HEAP8[i6] | 0) == 46) {
+ i5 = i6 + 1 | 0;
+ } else {
+ i3 = 0;
+ i1 = 10;
+ break;
+ }
+ }
+ if ((i1 | 0) == 10) {
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ _lua_settop(i3, -3);
+ i7 = i5;
+ STACKTOP = i2;
+ return i7 | 0;
+}
+function _luaD_call(i1, i4, i5, i8) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i8 = i8 | 0;
+ var i2 = 0, i3 = 0, i6 = 0, i7 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i7 = i3;
+ i2 = i1 + 38 | 0;
+ i6 = (HEAP16[i2 >> 1] | 0) + 1 << 16 >> 16;
+ HEAP16[i2 >> 1] = i6;
+ if ((i6 & 65535) > 199) {
+ if (i6 << 16 >> 16 == 200) {
+ _luaG_runerror(i1, 2240, i7);
+ }
+ if ((i6 & 65535) > 224) {
+ _luaD_throw(i1, 6);
+ }
+ }
+ i6 = (i8 | 0) != 0;
+ if (!i6) {
+ i8 = i1 + 36 | 0;
+ HEAP16[i8 >> 1] = (HEAP16[i8 >> 1] | 0) + 1 << 16 >> 16;
+ }
+ if ((_luaD_precall(i1, i4, i5) | 0) == 0) {
+ _luaV_execute(i1);
+ }
+ if (i6) {
+ i8 = HEAP16[i2 >> 1] | 0;
+ i8 = i8 + -1 << 16 >> 16;
+ HEAP16[i2 >> 1] = i8;
+ STACKTOP = i3;
+ return;
+ }
+ i8 = i1 + 36 | 0;
+ HEAP16[i8 >> 1] = (HEAP16[i8 >> 1] | 0) + -1 << 16 >> 16;
+ i8 = HEAP16[i2 >> 1] | 0;
+ i8 = i8 + -1 << 16 >> 16;
+ HEAP16[i2 >> 1] = i8;
+ STACKTOP = i3;
+ return;
+}
+function _pushline(i6, i1) {
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 528 | 0;
+ i4 = i2;
+ i3 = i2 + 8 | 0;
+ i7 = (i1 | 0) != 0;
+ _lua_getglobal(i6, i7 ? 288 : 296);
+ i8 = _lua_tolstring(i6, -1, 0) | 0;
+ if ((i8 | 0) == 0) {
+ i8 = i7 ? 312 : 320;
+ }
+ i7 = HEAP32[_stdout >> 2] | 0;
+ _fputs(i8 | 0, i7 | 0) | 0;
+ _fflush(i7 | 0) | 0;
+ i8 = (_fgets(i3 | 0, 512, HEAP32[_stdin >> 2] | 0) | 0) == 0;
+ _lua_settop(i6, -2);
+ if (i8) {
+ i8 = 0;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ i7 = _strlen(i3 | 0) | 0;
+ if ((i7 | 0) != 0 ? (i5 = i3 + (i7 + -1) | 0, (HEAP8[i5] | 0) == 10) : 0) {
+ HEAP8[i5] = 0;
+ }
+ if ((i1 | 0) != 0 ? (HEAP8[i3] | 0) == 61 : 0) {
+ HEAP32[i4 >> 2] = i3 + 1;
+ _lua_pushfstring(i6, 272, i4) | 0;
+ i8 = 1;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ _lua_pushstring(i6, i3) | 0;
+ i8 = 1;
+ STACKTOP = i2;
+ return i8 | 0;
+}
+function _db_getlocal(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 112 | 0;
+ i4 = i2;
+ if ((_lua_type(i1, 1) | 0) == 8) {
+ i3 = _lua_tothread(i1, 1) | 0;
+ i6 = 1;
+ } else {
+ i3 = i1;
+ i6 = 0;
+ }
+ i5 = _luaL_checkinteger(i1, i6 | 2) | 0;
+ i6 = i6 + 1 | 0;
+ if ((_lua_type(i1, i6) | 0) == 6) {
+ _lua_pushvalue(i1, i6);
+ _lua_pushstring(i1, _lua_getlocal(i1, 0, i5) | 0) | 0;
+ i6 = 1;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ if ((_lua_getstack(i3, _luaL_checkinteger(i1, i6) | 0, i4) | 0) == 0) {
+ i6 = _luaL_argerror(i1, i6, 11560) | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ i4 = _lua_getlocal(i3, i4, i5) | 0;
+ if ((i4 | 0) == 0) {
+ _lua_pushnil(i1);
+ i6 = 1;
+ STACKTOP = i2;
+ return i6 | 0;
+ } else {
+ _lua_xmove(i3, i1, 1);
+ _lua_pushstring(i1, i4) | 0;
+ _lua_pushvalue(i1, -2);
+ i6 = 2;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ return 0;
+}
+function _luaB_print(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i3;
+ i4 = i3 + 4 | 0;
+ i6 = _lua_gettop(i1) | 0;
+ _lua_getglobal(i1, 9584);
+ i5 = HEAP32[_stdout >> 2] | 0;
+ L1 : do {
+ if ((i6 | 0) >= 1) {
+ i7 = 1;
+ while (1) {
+ _lua_pushvalue(i1, -1);
+ _lua_pushvalue(i1, i7);
+ _lua_callk(i1, 1, 1, 0, 0);
+ i8 = _lua_tolstring(i1, -1, i4) | 0;
+ if ((i8 | 0) == 0) {
+ break;
+ }
+ if ((i7 | 0) > 1) {
+ _fputc(9, i5 | 0) | 0;
+ }
+ _fwrite(i8 | 0, 1, HEAP32[i4 >> 2] | 0, i5 | 0) | 0;
+ _lua_settop(i1, -2);
+ if ((i7 | 0) < (i6 | 0)) {
+ i7 = i7 + 1 | 0;
+ } else {
+ break L1;
+ }
+ }
+ i8 = _luaL_error(i1, 9816, i2) | 0;
+ STACKTOP = i3;
+ return i8 | 0;
+ }
+ } while (0);
+ _fputc(10, i5 | 0) | 0;
+ _fflush(i5 | 0) | 0;
+ i8 = 0;
+ STACKTOP = i3;
+ return i8 | 0;
+}
+function _luaB_load(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i5 = i2;
+ i6 = _lua_tolstring(i1, 1, i5) | 0;
+ i4 = _luaL_optlstring(i1, 3, 9872, 0) | 0;
+ i3 = (_lua_type(i1, 4) | 0) != -1;
+ if ((i6 | 0) == 0) {
+ i6 = _luaL_optlstring(i1, 2, 9880, 0) | 0;
+ _luaL_checktype(i1, 1, 6);
+ _lua_settop(i1, 5);
+ i4 = _lua_load(i1, 3, 0, i6, i4) | 0;
+ } else {
+ i7 = _luaL_optlstring(i1, 2, i6, 0) | 0;
+ i4 = _luaL_loadbufferx(i1, i6, HEAP32[i5 >> 2] | 0, i7, i4) | 0;
+ }
+ if ((i4 | 0) != 0) {
+ _lua_pushnil(i1);
+ _lua_insert(i1, -2);
+ i7 = 2;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ if (!i3) {
+ i7 = 1;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ _lua_pushvalue(i1, i3 ? 4 : 0);
+ if ((_lua_setupvalue(i1, -2, 1) | 0) != 0) {
+ i7 = 1;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ _lua_settop(i1, -2);
+ i7 = 1;
+ STACKTOP = i2;
+ return i7 | 0;
+}
+function _db_debug(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 256 | 0;
+ i6 = i1;
+ i4 = i1 + 4 | 0;
+ i3 = HEAP32[_stderr >> 2] | 0;
+ _fwrite(12040, 11, 1, i3 | 0) | 0;
+ _fflush(i3 | 0) | 0;
+ i5 = HEAP32[_stdin >> 2] | 0;
+ if ((_fgets(i4 | 0, 250, i5 | 0) | 0) == 0) {
+ STACKTOP = i1;
+ return 0;
+ }
+ while (1) {
+ if ((_strcmp(i4, 12056) | 0) == 0) {
+ i2 = 7;
+ break;
+ }
+ if (!((_luaL_loadbufferx(i2, i4, _strlen(i4 | 0) | 0, 12064, 0) | 0) == 0 ? (_lua_pcallk(i2, 0, 0, 0, 0, 0) | 0) == 0 : 0)) {
+ HEAP32[i6 >> 2] = _lua_tolstring(i2, -1, 0) | 0;
+ _fprintf(i3 | 0, 12088, i6 | 0) | 0;
+ _fflush(i3 | 0) | 0;
+ }
+ _lua_settop(i2, 0);
+ _fwrite(12040, 11, 1, i3 | 0) | 0;
+ _fflush(i3 | 0) | 0;
+ if ((_fgets(i4 | 0, 250, i5 | 0) | 0) == 0) {
+ i2 = 7;
+ break;
+ }
+ }
+ if ((i2 | 0) == 7) {
+ STACKTOP = i1;
+ return 0;
+ }
+ return 0;
+}
+function _luaL_prepbuffsize(i2, i7) {
+ i2 = i2 | 0;
+ i7 = i7 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i1 = HEAP32[i2 + 12 >> 2] | 0;
+ i4 = i2 + 4 | 0;
+ i8 = HEAP32[i4 >> 2] | 0;
+ i5 = i2 + 8 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ if (!((i8 - i6 | 0) >>> 0 < i7 >>> 0)) {
+ i7 = HEAP32[i2 >> 2] | 0;
+ i8 = i6;
+ i8 = i7 + i8 | 0;
+ STACKTOP = i3;
+ return i8 | 0;
+ }
+ i8 = i8 << 1;
+ i8 = (i8 - i6 | 0) >>> 0 < i7 >>> 0 ? i6 + i7 | 0 : i8;
+ if (i8 >>> 0 < i6 >>> 0 | (i8 - i6 | 0) >>> 0 < i7 >>> 0) {
+ _luaL_error(i1, 1272, i3) | 0;
+ }
+ i6 = _lua_newuserdata(i1, i8) | 0;
+ _memcpy(i6 | 0, HEAP32[i2 >> 2] | 0, HEAP32[i5 >> 2] | 0) | 0;
+ if ((HEAP32[i2 >> 2] | 0) != (i2 + 16 | 0)) {
+ _lua_remove(i1, -2);
+ }
+ HEAP32[i2 >> 2] = i6;
+ HEAP32[i4 >> 2] = i8;
+ i7 = i6;
+ i8 = HEAP32[i5 >> 2] | 0;
+ i8 = i7 + i8 | 0;
+ STACKTOP = i3;
+ return i8 | 0;
+}
+function _luaG_runerror(i1, i5, i4) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0, i6 = 0, i7 = 0;
+ i6 = STACKTOP;
+ STACKTOP = STACKTOP + 96 | 0;
+ i2 = i6;
+ i3 = i6 + 32 | 0;
+ i6 = i6 + 16 | 0;
+ HEAP32[i6 >> 2] = i4;
+ i4 = _luaO_pushvfstring(i1, i5, i6) | 0;
+ i6 = HEAP32[i1 + 16 >> 2] | 0;
+ if ((HEAP8[i6 + 18 | 0] & 1) == 0) {
+ _luaG_errormsg(i1);
+ }
+ i5 = HEAP32[(HEAP32[HEAP32[i6 >> 2] >> 2] | 0) + 12 >> 2] | 0;
+ i7 = HEAP32[i5 + 20 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i6 = 0;
+ } else {
+ i6 = HEAP32[i7 + (((HEAP32[i6 + 28 >> 2] | 0) - (HEAP32[i5 + 12 >> 2] | 0) >> 2) + -1 << 2) >> 2] | 0;
+ }
+ i5 = HEAP32[i5 + 36 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ HEAP8[i3] = 63;
+ HEAP8[i3 + 1 | 0] = 0;
+ } else {
+ _luaO_chunkid(i3, i5 + 16 | 0, 60);
+ }
+ HEAP32[i2 >> 2] = i3;
+ HEAP32[i2 + 4 >> 2] = i6;
+ HEAP32[i2 + 8 >> 2] = i4;
+ _luaO_pushfstring(i1, 2024, i2) | 0;
+ _luaG_errormsg(i1);
+}
+function _db_upvaluejoin(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 112 | 0;
+ i4 = i3;
+ i2 = _luaL_checkinteger(i1, 2) | 0;
+ _luaL_checktype(i1, 1, 6);
+ _lua_pushvalue(i1, 1);
+ _lua_getinfo(i1, 11728, i4) | 0;
+ if (!((i2 | 0) > 0 ? (i2 | 0) <= (HEAPU8[i4 + 32 | 0] | 0 | 0) : 0)) {
+ _luaL_argerror(i1, 2, 11736) | 0;
+ }
+ i5 = _luaL_checkinteger(i1, 4) | 0;
+ _luaL_checktype(i1, 3, 6);
+ _lua_pushvalue(i1, 3);
+ _lua_getinfo(i1, 11728, i4) | 0;
+ if (!((i5 | 0) > 0 ? (i5 | 0) <= (HEAPU8[i4 + 32 | 0] | 0 | 0) : 0)) {
+ _luaL_argerror(i1, 4, 11736) | 0;
+ }
+ if ((_lua_iscfunction(i1, 1) | 0) != 0) {
+ _luaL_argerror(i1, 1, 11760) | 0;
+ }
+ if ((_lua_iscfunction(i1, 3) | 0) == 0) {
+ _lua_upvaluejoin(i1, 1, i2, 3, i5);
+ STACKTOP = i3;
+ return 0;
+ }
+ _luaL_argerror(i1, 3, 11760) | 0;
+ _lua_upvaluejoin(i1, 1, i2, 3, i5);
+ STACKTOP = i3;
+ return 0;
+}
+function _luaK_jump(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i3 = STACKTOP;
+ i2 = i1 + 28 | 0;
+ i7 = HEAP32[i2 >> 2] | 0;
+ HEAP32[i2 >> 2] = -1;
+ i2 = _luaK_code(i1, 2147450903) | 0;
+ if ((i7 | 0) == -1) {
+ i9 = i2;
+ STACKTOP = i3;
+ return i9 | 0;
+ }
+ if ((i2 | 0) == -1) {
+ i9 = i7;
+ STACKTOP = i3;
+ return i9 | 0;
+ }
+ i6 = HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0;
+ i8 = i2;
+ while (1) {
+ i5 = i6 + (i8 << 2) | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i9 = (i4 >>> 14) + -131071 | 0;
+ if ((i9 | 0) == -1) {
+ break;
+ }
+ i9 = i8 + 1 + i9 | 0;
+ if ((i9 | 0) == -1) {
+ break;
+ } else {
+ i8 = i9;
+ }
+ }
+ i6 = i7 + ~i8 | 0;
+ if ((((i6 | 0) > -1 ? i6 : 0 - i6 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10624);
+ }
+ HEAP32[i5 >> 2] = (i6 << 14) + 2147467264 | i4 & 16383;
+ i9 = i2;
+ STACKTOP = i3;
+ return i9 | 0;
+}
+function _findfield(i2, i3, i4) {
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i1 = 0;
+ i1 = STACKTOP;
+ L1 : do {
+ if (((i4 | 0) != 0 ? (_lua_type(i2, -1) | 0) == 5 : 0) ? (_lua_pushnil(i2), (_lua_next(i2, -2) | 0) != 0) : 0) {
+ i4 = i4 + -1 | 0;
+ while (1) {
+ if ((_lua_type(i2, -2) | 0) == 4) {
+ if ((_lua_rawequal(i2, i3, -1) | 0) != 0) {
+ i3 = 7;
+ break;
+ }
+ if ((_findfield(i2, i3, i4) | 0) != 0) {
+ i3 = 9;
+ break;
+ }
+ }
+ _lua_settop(i2, -2);
+ if ((_lua_next(i2, -2) | 0) == 0) {
+ i2 = 0;
+ break L1;
+ }
+ }
+ if ((i3 | 0) == 7) {
+ _lua_settop(i2, -2);
+ i2 = 1;
+ break;
+ } else if ((i3 | 0) == 9) {
+ _lua_remove(i2, -2);
+ _lua_pushlstring(i2, 1776, 1) | 0;
+ _lua_insert(i2, -2);
+ _lua_concat(i2, 3);
+ i2 = 1;
+ break;
+ }
+ } else {
+ i2 = 0;
+ }
+ } while (0);
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _db_gethook(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i3;
+ if ((_lua_type(i1, 1) | 0) == 8) {
+ i4 = _lua_tothread(i1, 1) | 0;
+ } else {
+ i4 = i1;
+ }
+ i5 = _lua_gethookmask(i4) | 0;
+ i6 = _lua_gethook(i4) | 0;
+ if ((i6 | 0) != 0 & (i6 | 0) != 9) {
+ _lua_pushlstring(i1, 12024, 13) | 0;
+ } else {
+ _luaL_getsubtable(i1, -1001e3, 11584) | 0;
+ _lua_pushthread(i4) | 0;
+ _lua_xmove(i4, i1, 1);
+ _lua_rawget(i1, -2);
+ _lua_remove(i1, -2);
+ }
+ if ((i5 & 1 | 0) == 0) {
+ i6 = 0;
+ } else {
+ HEAP8[i2] = 99;
+ i6 = 1;
+ }
+ if ((i5 & 2 | 0) != 0) {
+ HEAP8[i2 + i6 | 0] = 114;
+ i6 = i6 + 1 | 0;
+ }
+ if ((i5 & 4 | 0) != 0) {
+ HEAP8[i2 + i6 | 0] = 108;
+ i6 = i6 + 1 | 0;
+ }
+ HEAP8[i2 + i6 | 0] = 0;
+ _lua_pushstring(i1, i2) | 0;
+ _lua_pushinteger(i1, _lua_gethookcount(i4) | 0);
+ STACKTOP = i3;
+ return 3;
+}
+function _lua_tothread(i3, i5) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i4 = 0;
+ i1 = STACKTOP;
+ i4 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i2 = (HEAP32[i3 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i2 = (HEAP32[i3 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i3 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i2 = HEAP32[i4 >> 2] | 0, (i3 | 0) <= (HEAPU8[i2 + 6 | 0] | 0 | 0)) : 0) {
+ i2 = i2 + (i3 + -1 << 4) + 16 | 0;
+ } else {
+ i2 = 5192;
+ }
+ } else {
+ i2 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i2 = i2 >>> 0 < (HEAP32[i3 + 8 >> 2] | 0) >>> 0 ? i2 : 5192;
+ }
+ } while (0);
+ if ((HEAP32[i2 + 8 >> 2] | 0) != 72) {
+ i5 = 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ i5 = HEAP32[i2 >> 2] | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+}
+function _luaD_throw(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i3 = i1 + 64 | 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ if ((i4 | 0) != 0) {
+ HEAP32[i4 + 160 >> 2] = i2;
+ _longjmp((HEAP32[i3 >> 2] | 0) + 4 | 0, 1);
+ }
+ HEAP8[i1 + 6 | 0] = i2;
+ i4 = i1 + 12 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[i3 + 172 >> 2] | 0;
+ if ((HEAP32[i5 + 64 >> 2] | 0) != 0) {
+ i6 = HEAP32[i1 + 8 >> 2] | 0;
+ i9 = i5 + 8 | 0;
+ i5 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = i5 + 16;
+ i9 = i6 + -16 | 0;
+ i8 = HEAP32[i9 + 4 >> 2] | 0;
+ i7 = i5;
+ HEAP32[i7 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i7 + 4 >> 2] = i8;
+ HEAP32[i5 + 8 >> 2] = HEAP32[i6 + -8 >> 2];
+ _luaD_throw(HEAP32[(HEAP32[i4 >> 2] | 0) + 172 >> 2] | 0, i2);
+ }
+ i2 = HEAP32[i3 + 168 >> 2] | 0;
+ if ((i2 | 0) == 0) {
+ _abort();
+ }
+ FUNCTION_TABLE_ii[i2 & 255](i1) | 0;
+ _abort();
+}
+function _lua_len(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i3 = (HEAP32[i1 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i3 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i4 >> 2] | 0, (i5 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i3 = i3 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i3 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i3 = i3 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ i5 = i1 + 8 | 0;
+ _luaV_objlen(i1, HEAP32[i5 >> 2] | 0, i3);
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + 16;
+ STACKTOP = i2;
+ return;
+}
+function _read_line(i4, i5, i1) {
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 1040 | 0;
+ i2 = i3;
+ _luaL_buffinit(i4, i2);
+ i7 = _luaL_prepbuffsize(i2, 1024) | 0;
+ L1 : do {
+ if ((_fgets(i7 | 0, 1024, i5 | 0) | 0) != 0) {
+ i6 = i2 + 8 | 0;
+ while (1) {
+ i8 = _strlen(i7 | 0) | 0;
+ if ((i8 | 0) != 0 ? (HEAP8[i7 + (i8 + -1) | 0] | 0) == 10 : 0) {
+ break;
+ }
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + i8;
+ i7 = _luaL_prepbuffsize(i2, 1024) | 0;
+ if ((_fgets(i7 | 0, 1024, i5 | 0) | 0) == 0) {
+ break L1;
+ }
+ }
+ HEAP32[i6 >> 2] = i8 - i1 + (HEAP32[i6 >> 2] | 0);
+ _luaL_pushresult(i2);
+ i8 = 1;
+ STACKTOP = i3;
+ return i8 | 0;
+ }
+ } while (0);
+ _luaL_pushresult(i2);
+ i8 = (_lua_rawlen(i4, -1) | 0) != 0 | 0;
+ STACKTOP = i3;
+ return i8 | 0;
+}
+function _luaL_tolstring(i1, i5, i4) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ do {
+ if ((_luaL_callmeta(i1, i5, 1384) | 0) == 0) {
+ i6 = _lua_type(i1, i5) | 0;
+ if ((i6 | 0) == 0) {
+ _lua_pushlstring(i1, 1416, 3) | 0;
+ break;
+ } else if ((i6 | 0) == 1) {
+ i6 = (_lua_toboolean(i1, i5) | 0) != 0;
+ _lua_pushstring(i1, i6 ? 1400 : 1408) | 0;
+ break;
+ } else if ((i6 | 0) == 4 | (i6 | 0) == 3) {
+ _lua_pushvalue(i1, i5);
+ break;
+ } else {
+ i7 = _lua_typename(i1, _lua_type(i1, i5) | 0) | 0;
+ i6 = _lua_topointer(i1, i5) | 0;
+ HEAP32[i3 >> 2] = i7;
+ HEAP32[i3 + 4 >> 2] = i6;
+ _lua_pushfstring(i1, 1424, i3) | 0;
+ break;
+ }
+ }
+ } while (0);
+ i7 = _lua_tolstring(i1, -1, i4) | 0;
+ STACKTOP = i2;
+ return i7 | 0;
+}
+function _save(i7, i1) {
+ i7 = i7 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i7 + 60 >> 2] | 0;
+ i3 = i4 + 4 | 0;
+ i8 = HEAP32[i3 >> 2] | 0;
+ i6 = i4 + 8 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if (!((i8 + 1 | 0) >>> 0 > i5 >>> 0)) {
+ i6 = HEAP32[i4 >> 2] | 0;
+ i7 = i1 & 255;
+ i5 = i8 + 1 | 0;
+ HEAP32[i3 >> 2] = i5;
+ i8 = i6 + i8 | 0;
+ HEAP8[i8] = i7;
+ STACKTOP = i2;
+ return;
+ }
+ if (i5 >>> 0 > 2147483645) {
+ _lexerror(i7, 12368, 0);
+ }
+ i8 = i5 << 1;
+ i7 = HEAP32[i7 + 52 >> 2] | 0;
+ if ((i8 | 0) == -2) {
+ _luaM_toobig(i7);
+ }
+ i7 = _luaM_realloc_(i7, HEAP32[i4 >> 2] | 0, i5, i8) | 0;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i6 >> 2] = i8;
+ i8 = HEAP32[i3 >> 2] | 0;
+ i6 = i7;
+ i7 = i1 & 255;
+ i5 = i8 + 1 | 0;
+ HEAP32[i3 >> 2] = i5;
+ i8 = i6 + i8 | 0;
+ HEAP8[i8] = i7;
+ STACKTOP = i2;
+ return;
+}
+function _luaK_patchtohere(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ HEAP32[i1 + 24 >> 2] = HEAP32[i1 + 20 >> 2];
+ i4 = i1 + 28 | 0;
+ if ((i3 | 0) == -1) {
+ STACKTOP = i2;
+ return;
+ }
+ i7 = HEAP32[i4 >> 2] | 0;
+ if ((i7 | 0) == -1) {
+ HEAP32[i4 >> 2] = i3;
+ STACKTOP = i2;
+ return;
+ }
+ i4 = HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i6 = i4 + (i7 << 2) | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ i8 = (i5 >>> 14) + -131071 | 0;
+ if ((i8 | 0) == -1) {
+ break;
+ }
+ i8 = i7 + 1 + i8 | 0;
+ if ((i8 | 0) == -1) {
+ break;
+ } else {
+ i7 = i8;
+ }
+ }
+ i3 = ~i7 + i3 | 0;
+ if ((((i3 | 0) > -1 ? i3 : 0 - i3 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10624);
+ }
+ HEAP32[i6 >> 2] = (i3 << 14) + 2147467264 | i5 & 16383;
+ STACKTOP = i2;
+ return;
+}
+function _tinsert(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i7 = i2;
+ _luaL_checktype(i1, 1, 5);
+ i4 = _luaL_len(i1, 1) | 0;
+ i3 = i4 + 1 | 0;
+ i6 = _lua_gettop(i1) | 0;
+ if ((i6 | 0) == 3) {
+ i5 = 2;
+ } else if ((i6 | 0) != 2) {
+ i7 = _luaL_error(i1, 8320, i7) | 0;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ if ((i5 | 0) == 2) {
+ i5 = _luaL_checkinteger(i1, 2) | 0;
+ if ((i5 | 0) < 1 | (i5 | 0) > (i3 | 0)) {
+ _luaL_argerror(i1, 2, 8256) | 0;
+ }
+ if ((i4 | 0) < (i5 | 0)) {
+ i3 = i5;
+ } else {
+ while (1) {
+ i4 = i3 + -1 | 0;
+ _lua_rawgeti(i1, 1, i4);
+ _lua_rawseti(i1, 1, i3);
+ if ((i4 | 0) > (i5 | 0)) {
+ i3 = i4;
+ } else {
+ i3 = i5;
+ break;
+ }
+ }
+ }
+ }
+ _lua_rawseti(i1, 1, i3);
+ i7 = 0;
+ STACKTOP = i2;
+ return i7 | 0;
+}
+function _lua_iscfunction(i3, i5) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i4 = 0;
+ i1 = STACKTOP;
+ i4 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i2 = (HEAP32[i3 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i2 = (HEAP32[i3 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i3 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i2 = HEAP32[i4 >> 2] | 0, (i3 | 0) <= (HEAPU8[i2 + 6 | 0] | 0 | 0)) : 0) {
+ i2 = i2 + (i3 + -1 << 4) + 16 | 0;
+ } else {
+ i2 = 5192;
+ }
+ } else {
+ i2 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i2 = i2 >>> 0 < (HEAP32[i3 + 8 >> 2] | 0) >>> 0 ? i2 : 5192;
+ }
+ } while (0);
+ i5 = HEAP32[i2 + 8 >> 2] | 0;
+ STACKTOP = i1;
+ return ((i5 | 0) == 22 | (i5 | 0) == 102) & 1 | 0;
+}
+function _lua_gettable(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i1 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) <= 0) {
+ if (!((i5 | 0) < -1000999)) {
+ i3 = (HEAP32[i1 + 8 >> 2] | 0) + (i5 << 4) | 0;
+ break;
+ }
+ if ((i5 | 0) == -1001e3) {
+ i3 = (HEAP32[i1 + 12 >> 2] | 0) + 40 | 0;
+ break;
+ }
+ i5 = -1001e3 - i5 | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 22 ? (i3 = HEAP32[i4 >> 2] | 0, (i5 | 0) <= (HEAPU8[i3 + 6 | 0] | 0 | 0)) : 0) {
+ i3 = i3 + (i5 + -1 << 4) + 16 | 0;
+ } else {
+ i3 = 5192;
+ }
+ } else {
+ i3 = (HEAP32[i4 >> 2] | 0) + (i5 << 4) | 0;
+ i3 = i3 >>> 0 < (HEAP32[i1 + 8 >> 2] | 0) >>> 0 ? i3 : 5192;
+ }
+ } while (0);
+ i5 = (HEAP32[i1 + 8 >> 2] | 0) + -16 | 0;
+ _luaV_gettable(i1, i3, i5, i5);
+ STACKTOP = i2;
+ return;
+}
+function _luaG_errormsg(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i2 = HEAP32[i1 + 68 >> 2] | 0;
+ if ((i2 | 0) == 0) {
+ _luaD_throw(i1, 2);
+ }
+ i4 = HEAP32[i1 + 28 >> 2] | 0;
+ i3 = i4 + (i2 + 8) | 0;
+ if ((HEAP32[i3 >> 2] & 15 | 0) != 6) {
+ _luaD_throw(i1, 6);
+ }
+ i5 = i1 + 8 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ i9 = i6 + -16 | 0;
+ i8 = HEAP32[i9 + 4 >> 2] | 0;
+ i7 = i6;
+ HEAP32[i7 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i7 + 4 >> 2] = i8;
+ HEAP32[i6 + 8 >> 2] = HEAP32[i6 + -8 >> 2];
+ i6 = HEAP32[i5 >> 2] | 0;
+ i7 = i4 + i2 | 0;
+ i2 = HEAP32[i7 + 4 >> 2] | 0;
+ i4 = i6 + -16 | 0;
+ HEAP32[i4 >> 2] = HEAP32[i7 >> 2];
+ HEAP32[i4 + 4 >> 2] = i2;
+ HEAP32[i6 + -8 >> 2] = HEAP32[i3 >> 2];
+ i4 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i4 + 16;
+ _luaD_call(i1, i4 + -16 | 0, 1, 0);
+ _luaD_throw(i1, 2);
+}
+function _luaB_costatus(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 112 | 0;
+ i3 = i4;
+ i2 = _lua_tothread(i1, 1) | 0;
+ if ((i2 | 0) == 0) {
+ _luaL_argerror(i1, 1, 10856) | 0;
+ }
+ do {
+ if ((i2 | 0) != (i1 | 0)) {
+ i5 = _lua_status(i2) | 0;
+ if ((i5 | 0) == 0) {
+ if ((_lua_getstack(i2, 0, i3) | 0) > 0) {
+ _lua_pushlstring(i1, 10896, 6) | 0;
+ break;
+ }
+ if ((_lua_gettop(i2) | 0) == 0) {
+ _lua_pushlstring(i1, 10904, 4) | 0;
+ break;
+ } else {
+ _lua_pushlstring(i1, 10880, 9) | 0;
+ break;
+ }
+ } else if ((i5 | 0) == 1) {
+ _lua_pushlstring(i1, 10880, 9) | 0;
+ break;
+ } else {
+ _lua_pushlstring(i1, 10904, 4) | 0;
+ break;
+ }
+ } else {
+ _lua_pushlstring(i1, 10728, 7) | 0;
+ }
+ } while (0);
+ STACKTOP = i4;
+ return 1;
+}
+function _searcher_Lua(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ i4 = _luaL_checklstring(i1, 1, 0) | 0;
+ _lua_getfield(i1, -1001001, 4256);
+ i5 = _lua_tolstring(i1, -1, 0) | 0;
+ if ((i5 | 0) == 0) {
+ HEAP32[i3 >> 2] = 4256;
+ _luaL_error(i1, 5032, i3) | 0;
+ }
+ i4 = _searchpath(i1, i4, i5, 4936, 4848) | 0;
+ if ((i4 | 0) == 0) {
+ i5 = 1;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ if ((_luaL_loadfilex(i1, i4, 0) | 0) == 0) {
+ _lua_pushstring(i1, i4) | 0;
+ i5 = 2;
+ STACKTOP = i2;
+ return i5 | 0;
+ } else {
+ i6 = _lua_tolstring(i1, 1, 0) | 0;
+ i5 = _lua_tolstring(i1, -1, 0) | 0;
+ HEAP32[i3 >> 2] = i6;
+ HEAP32[i3 + 4 >> 2] = i4;
+ HEAP32[i3 + 8 >> 2] = i5;
+ i5 = _luaL_error(i1, 4888, i3) | 0;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ return 0;
+}
+function _str_sub(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i3;
+ i2 = _luaL_checklstring(i1, 1, i4) | 0;
+ i5 = _luaL_checkinteger(i1, 2) | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ if (!((i5 | 0) > -1)) {
+ if (i6 >>> 0 < (0 - i5 | 0) >>> 0) {
+ i5 = 0;
+ } else {
+ i5 = i5 + 1 + i6 | 0;
+ }
+ }
+ i6 = _luaL_optinteger(i1, 3, -1) | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if (!((i6 | 0) > -1)) {
+ if (i4 >>> 0 < (0 - i6 | 0) >>> 0) {
+ i6 = 0;
+ } else {
+ i6 = i6 + 1 + i4 | 0;
+ }
+ }
+ i5 = (i5 | 0) == 0 ? 1 : i5;
+ i4 = i6 >>> 0 > i4 >>> 0 ? i4 : i6;
+ if (i5 >>> 0 > i4 >>> 0) {
+ _lua_pushlstring(i1, 7040, 0) | 0;
+ STACKTOP = i3;
+ return 1;
+ } else {
+ _lua_pushlstring(i1, i2 + (i5 + -1) | 0, 1 - i5 + i4 | 0) | 0;
+ STACKTOP = i3;
+ return 1;
+ }
+ return 0;
+}
+function _searcher_C(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ i4 = _luaL_checklstring(i1, 1, 0) | 0;
+ _lua_getfield(i1, -1001001, 4440);
+ i5 = _lua_tolstring(i1, -1, 0) | 0;
+ if ((i5 | 0) == 0) {
+ HEAP32[i3 >> 2] = 4440;
+ _luaL_error(i1, 5032, i3) | 0;
+ }
+ i5 = _searchpath(i1, i4, i5, 4936, 4848) | 0;
+ if ((i5 | 0) == 0) {
+ i5 = 1;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ if ((_loadfunc(i1, i5, i4) | 0) == 0) {
+ _lua_pushstring(i1, i5) | 0;
+ i5 = 2;
+ STACKTOP = i2;
+ return i5 | 0;
+ } else {
+ i6 = _lua_tolstring(i1, 1, 0) | 0;
+ i4 = _lua_tolstring(i1, -1, 0) | 0;
+ HEAP32[i3 >> 2] = i6;
+ HEAP32[i3 + 4 >> 2] = i5;
+ HEAP32[i3 + 8 >> 2] = i4;
+ i5 = _luaL_error(i1, 4888, i3) | 0;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ return 0;
+}
+function _io_open(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i5 = STACKTOP;
+ i2 = _luaL_checklstring(i1, 1, 0) | 0;
+ i3 = _luaL_optlstring(i1, 2, 3480, 0) | 0;
+ i4 = _lua_newuserdata(i1, 8) | 0;
+ i6 = i4 + 4 | 0;
+ HEAP32[i6 >> 2] = 0;
+ _luaL_setmetatable(i1, 2832);
+ HEAP32[i4 >> 2] = 0;
+ HEAP32[i6 >> 2] = 156;
+ i6 = HEAP8[i3] | 0;
+ if (!((!(i6 << 24 >> 24 == 0) ? (i7 = i3 + 1 | 0, (_memchr(3552, i6 << 24 >> 24, 4) | 0) != 0) : 0) ? (i6 = (HEAP8[i7] | 0) == 43 ? i3 + 2 | 0 : i7, (HEAP8[(HEAP8[i6] | 0) == 98 ? i6 + 1 | 0 : i6] | 0) == 0) : 0)) {
+ _luaL_argerror(i1, 2, 3560) | 0;
+ }
+ i7 = _fopen(i2 | 0, i3 | 0) | 0;
+ HEAP32[i4 >> 2] = i7;
+ if ((i7 | 0) != 0) {
+ i7 = 1;
+ STACKTOP = i5;
+ return i7 | 0;
+ }
+ i7 = _luaL_fileresult(i1, 0, i2) | 0;
+ STACKTOP = i5;
+ return i7 | 0;
+}
+function _unpack(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i6 = i1;
+ _luaL_checktype(i2, 1, 5);
+ i5 = _luaL_optinteger(i2, 2, 1) | 0;
+ if ((_lua_type(i2, 3) | 0) < 1) {
+ i3 = _luaL_len(i2, 1) | 0;
+ } else {
+ i3 = _luaL_checkinteger(i2, 3) | 0;
+ }
+ if ((i5 | 0) > (i3 | 0)) {
+ i6 = 0;
+ STACKTOP = i1;
+ return i6 | 0;
+ }
+ i7 = i3 - i5 | 0;
+ i4 = i7 + 1 | 0;
+ if ((i7 | 0) >= 0 ? (_lua_checkstack(i2, i4) | 0) != 0 : 0) {
+ _lua_rawgeti(i2, 1, i5);
+ if ((i5 | 0) >= (i3 | 0)) {
+ i7 = i4;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ do {
+ i5 = i5 + 1 | 0;
+ _lua_rawgeti(i2, 1, i5);
+ } while ((i5 | 0) != (i3 | 0));
+ STACKTOP = i1;
+ return i4 | 0;
+ }
+ i7 = _luaL_error(i2, 8280, i6) | 0;
+ STACKTOP = i1;
+ return i7 | 0;
+}
+function _luaF_getlocalname(i4, i6, i2) {
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i5 = 0;
+ i1 = STACKTOP;
+ i3 = HEAP32[i4 + 60 >> 2] | 0;
+ if ((i3 | 0) <= 0) {
+ i6 = 0;
+ STACKTOP = i1;
+ return i6 | 0;
+ }
+ i4 = HEAP32[i4 + 24 >> 2] | 0;
+ i5 = 0;
+ while (1) {
+ if ((HEAP32[i4 + (i5 * 12 | 0) + 4 >> 2] | 0) > (i2 | 0)) {
+ i3 = 0;
+ i2 = 8;
+ break;
+ }
+ if ((HEAP32[i4 + (i5 * 12 | 0) + 8 >> 2] | 0) > (i2 | 0)) {
+ i6 = i6 + -1 | 0;
+ if ((i6 | 0) == 0) {
+ i2 = 6;
+ break;
+ }
+ }
+ i5 = i5 + 1 | 0;
+ if ((i5 | 0) >= (i3 | 0)) {
+ i3 = 0;
+ i2 = 8;
+ break;
+ }
+ }
+ if ((i2 | 0) == 6) {
+ i6 = (HEAP32[i4 + (i5 * 12 | 0) >> 2] | 0) + 16 | 0;
+ STACKTOP = i1;
+ return i6 | 0;
+ } else if ((i2 | 0) == 8) {
+ STACKTOP = i1;
+ return i3 | 0;
+ }
+ return 0;
+}
+function _luaK_concat(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ if ((i3 | 0) == -1) {
+ STACKTOP = i2;
+ return;
+ }
+ i7 = HEAP32[i4 >> 2] | 0;
+ if ((i7 | 0) == -1) {
+ HEAP32[i4 >> 2] = i3;
+ STACKTOP = i2;
+ return;
+ }
+ i4 = HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0;
+ while (1) {
+ i6 = i4 + (i7 << 2) | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ i8 = (i5 >>> 14) + -131071 | 0;
+ if ((i8 | 0) == -1) {
+ break;
+ }
+ i8 = i7 + 1 + i8 | 0;
+ if ((i8 | 0) == -1) {
+ break;
+ } else {
+ i7 = i8;
+ }
+ }
+ i3 = ~i7 + i3 | 0;
+ if ((((i3 | 0) > -1 ? i3 : 0 - i3 | 0) | 0) > 131071) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10624);
+ }
+ HEAP32[i6 >> 2] = i5 & 16383 | (i3 << 14) + 2147467264;
+ STACKTOP = i2;
+ return;
+}
+function _scalbn(d3, i2) {
+ d3 = +d3;
+ i2 = i2 | 0;
+ var i1 = 0, i4 = 0;
+ i1 = STACKTOP;
+ if ((i2 | 0) > 1023) {
+ d3 = d3 * 8.98846567431158e+307;
+ i4 = i2 + -1023 | 0;
+ if ((i4 | 0) > 1023) {
+ i2 = i2 + -2046 | 0;
+ i2 = (i2 | 0) > 1023 ? 1023 : i2;
+ d3 = d3 * 8.98846567431158e+307;
+ } else {
+ i2 = i4;
+ }
+ } else {
+ if ((i2 | 0) < -1022) {
+ d3 = d3 * 2.2250738585072014e-308;
+ i4 = i2 + 1022 | 0;
+ if ((i4 | 0) < -1022) {
+ i2 = i2 + 2044 | 0;
+ i2 = (i2 | 0) < -1022 ? -1022 : i2;
+ d3 = d3 * 2.2250738585072014e-308;
+ } else {
+ i2 = i4;
+ }
+ }
+ }
+ i2 = _bitshift64Shl(i2 + 1023 | 0, 0, 52) | 0;
+ i4 = tempRet0;
+ HEAP32[tempDoublePtr >> 2] = i2;
+ HEAP32[tempDoublePtr + 4 >> 2] = i4;
+ d3 = d3 * +HEAPF64[tempDoublePtr >> 3];
+ STACKTOP = i1;
+ return +d3;
+}
+function _luaK_numberK(i1, d6) {
+ i1 = i1 | 0;
+ d6 = +d6;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i4 = i2 + 16 | 0;
+ i3 = i2;
+ HEAPF64[i4 >> 3] = d6;
+ i5 = HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 52 >> 2] | 0;
+ HEAPF64[i3 >> 3] = d6;
+ HEAP32[i3 + 8 >> 2] = 3;
+ if (d6 != d6 | 0.0 != 0.0 | d6 == 0.0) {
+ i7 = i5 + 8 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i8 + 16;
+ i5 = _luaS_newlstr(i5, i4, 8) | 0;
+ HEAP32[i8 >> 2] = i5;
+ HEAP32[i8 + 8 >> 2] = HEAPU8[i5 + 4 | 0] | 0 | 64;
+ i5 = _addk(i1, (HEAP32[i7 >> 2] | 0) + -16 | 0, i3) | 0;
+ HEAP32[i7 >> 2] = (HEAP32[i7 >> 2] | 0) + -16;
+ STACKTOP = i2;
+ return i5 | 0;
+ } else {
+ i8 = _addk(i1, i3, i3) | 0;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ return 0;
+}
+function _auxresume(i2, i3, i4) {
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i1 = 0;
+ i1 = STACKTOP;
+ do {
+ if ((_lua_checkstack(i3, i4) | 0) != 0) {
+ if ((_lua_status(i3) | 0) == 0 ? (_lua_gettop(i3) | 0) == 0 : 0) {
+ _lua_pushlstring(i2, 10792, 28) | 0;
+ i4 = -1;
+ break;
+ }
+ _lua_xmove(i2, i3, i4);
+ if (!((_lua_resume(i3, i2, i4) | 0) >>> 0 < 2)) {
+ _lua_xmove(i3, i2, 1);
+ i4 = -1;
+ break;
+ }
+ i4 = _lua_gettop(i3) | 0;
+ if ((_lua_checkstack(i2, i4 + 1 | 0) | 0) == 0) {
+ _lua_settop(i3, ~i4);
+ _lua_pushlstring(i2, 10824, 26) | 0;
+ i4 = -1;
+ break;
+ } else {
+ _lua_xmove(i3, i2, i4);
+ break;
+ }
+ } else {
+ _lua_pushlstring(i2, 10760, 28) | 0;
+ i4 = -1;
+ }
+ } while (0);
+ STACKTOP = i1;
+ return i4 | 0;
+}
+function _luaX_setinput(i2, i1, i4, i3, i5) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i6 = 0, i7 = 0;
+ i6 = STACKTOP;
+ HEAP8[i1 + 76 | 0] = 46;
+ i7 = i1 + 52 | 0;
+ HEAP32[i7 >> 2] = i2;
+ HEAP32[i1 >> 2] = i5;
+ HEAP32[i1 + 32 >> 2] = 286;
+ HEAP32[i1 + 56 >> 2] = i4;
+ HEAP32[i1 + 48 >> 2] = 0;
+ HEAP32[i1 + 4 >> 2] = 1;
+ HEAP32[i1 + 8 >> 2] = 1;
+ HEAP32[i1 + 68 >> 2] = i3;
+ i5 = _luaS_new(i2, 12264) | 0;
+ HEAP32[i1 + 72 >> 2] = i5;
+ i5 = i5 + 5 | 0;
+ HEAP8[i5] = HEAPU8[i5] | 0 | 32;
+ i5 = i1 + 60 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i4 = _luaM_realloc_(HEAP32[i7 >> 2] | 0, HEAP32[i4 >> 2] | 0, HEAP32[i4 + 8 >> 2] | 0, 32) | 0;
+ HEAP32[HEAP32[i5 >> 2] >> 2] = i4;
+ HEAP32[(HEAP32[i5 >> 2] | 0) + 8 >> 2] = 32;
+ STACKTOP = i6;
+ return;
+}
+function _luaL_optlstring(i2, i4, i6, i5) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i3 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i1;
+ if ((_lua_type(i2, i4) | 0) >= 1) {
+ i5 = _lua_tolstring(i2, i4, i5) | 0;
+ if ((i5 | 0) != 0) {
+ i6 = i5;
+ STACKTOP = i1;
+ return i6 | 0;
+ }
+ i5 = _lua_typename(i2, 4) | 0;
+ i6 = _lua_typename(i2, _lua_type(i2, i4) | 0) | 0;
+ HEAP32[i3 >> 2] = i5;
+ HEAP32[i3 + 4 >> 2] = i6;
+ _luaL_argerror(i2, i4, _lua_pushfstring(i2, 1744, i3) | 0) | 0;
+ i6 = 0;
+ STACKTOP = i1;
+ return i6 | 0;
+ }
+ if ((i5 | 0) == 0) {
+ STACKTOP = i1;
+ return i6 | 0;
+ }
+ if ((i6 | 0) == 0) {
+ i2 = 0;
+ } else {
+ i2 = _strlen(i6 | 0) | 0;
+ }
+ HEAP32[i5 >> 2] = i2;
+ STACKTOP = i1;
+ return i6 | 0;
+}
+function _lua_xmove(i3, i4, i1) {
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i2 = STACKTOP;
+ if ((i3 | 0) == (i4 | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ i3 = i3 + 8 | 0;
+ i5 = (HEAP32[i3 >> 2] | 0) + (0 - i1 << 4) | 0;
+ HEAP32[i3 >> 2] = i5;
+ if ((i1 | 0) <= 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i4 = i4 + 8 | 0;
+ i6 = 0;
+ while (1) {
+ i7 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = i7 + 16;
+ i10 = i5 + (i6 << 4) | 0;
+ i9 = HEAP32[i10 + 4 >> 2] | 0;
+ i8 = i7;
+ HEAP32[i8 >> 2] = HEAP32[i10 >> 2];
+ HEAP32[i8 + 4 >> 2] = i9;
+ HEAP32[i7 + 8 >> 2] = HEAP32[i5 + (i6 << 4) + 8 >> 2];
+ i6 = i6 + 1 | 0;
+ if ((i6 | 0) == (i1 | 0)) {
+ break;
+ }
+ i5 = HEAP32[i3 >> 2] | 0;
+ }
+ STACKTOP = i2;
+ return;
+}
+function _luaM_realloc_(i7, i10, i3, i2) {
+ i7 = i7 | 0;
+ i10 = i10 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0;
+ i5 = STACKTOP;
+ i6 = HEAP32[i7 + 12 >> 2] | 0;
+ i4 = (i10 | 0) != 0;
+ i9 = i6 + 4 | 0;
+ i8 = FUNCTION_TABLE_iiiii[HEAP32[i6 >> 2] & 3](HEAP32[i9 >> 2] | 0, i10, i3, i2) | 0;
+ if (!((i8 | 0) != 0 | (i2 | 0) == 0)) {
+ if ((HEAP8[i6 + 63 | 0] | 0) == 0) {
+ _luaD_throw(i7, 4);
+ }
+ _luaC_fullgc(i7, 1);
+ i8 = FUNCTION_TABLE_iiiii[HEAP32[i6 >> 2] & 3](HEAP32[i9 >> 2] | 0, i10, i3, i2) | 0;
+ if ((i8 | 0) == 0) {
+ _luaD_throw(i7, 4);
+ } else {
+ i1 = i8;
+ }
+ } else {
+ i1 = i8;
+ }
+ i6 = i6 + 12 | 0;
+ HEAP32[i6 >> 2] = (i4 ? 0 - i3 | 0 : 0) + i2 + (HEAP32[i6 >> 2] | 0);
+ STACKTOP = i5;
+ return i1 | 0;
+}
+function _realloc(i2, i3) {
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i4 = 0, i5 = 0;
+ i1 = STACKTOP;
+ do {
+ if ((i2 | 0) != 0) {
+ if (i3 >>> 0 > 4294967231) {
+ HEAP32[(___errno_location() | 0) >> 2] = 12;
+ i4 = 0;
+ break;
+ }
+ if (i3 >>> 0 < 11) {
+ i4 = 16;
+ } else {
+ i4 = i3 + 11 & -8;
+ }
+ i4 = _try_realloc_chunk(i2 + -8 | 0, i4) | 0;
+ if ((i4 | 0) != 0) {
+ i4 = i4 + 8 | 0;
+ break;
+ }
+ i4 = _malloc(i3) | 0;
+ if ((i4 | 0) == 0) {
+ i4 = 0;
+ } else {
+ i5 = HEAP32[i2 + -4 >> 2] | 0;
+ i5 = (i5 & -8) - ((i5 & 3 | 0) == 0 ? 8 : 4) | 0;
+ _memcpy(i4 | 0, i2 | 0, (i5 >>> 0 < i3 >>> 0 ? i5 : i3) | 0) | 0;
+ _free(i2);
+ }
+ } else {
+ i4 = _malloc(i3) | 0;
+ }
+ } while (0);
+ STACKTOP = i1;
+ return i4 | 0;
+}
+function _lua_setlocal(i3, i5, i4) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i1;
+ HEAP32[i2 >> 2] = 0;
+ i4 = _findlocal(i3, HEAP32[i5 + 96 >> 2] | 0, i4, i2) | 0;
+ i3 = i3 + 8 | 0;
+ if ((i4 | 0) == 0) {
+ i5 = HEAP32[i3 >> 2] | 0;
+ i5 = i5 + -16 | 0;
+ HEAP32[i3 >> 2] = i5;
+ STACKTOP = i1;
+ return i4 | 0;
+ }
+ i6 = HEAP32[i3 >> 2] | 0;
+ i5 = HEAP32[i2 >> 2] | 0;
+ i8 = i6 + -16 | 0;
+ i7 = HEAP32[i8 + 4 >> 2] | 0;
+ i2 = i5;
+ HEAP32[i2 >> 2] = HEAP32[i8 >> 2];
+ HEAP32[i2 + 4 >> 2] = i7;
+ HEAP32[i5 + 8 >> 2] = HEAP32[i6 + -8 >> 2];
+ i5 = HEAP32[i3 >> 2] | 0;
+ i5 = i5 + -16 | 0;
+ HEAP32[i3 >> 2] = i5;
+ STACKTOP = i1;
+ return i4 | 0;
+}
+function ___remdi3(i1, i4, i5, i6) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ var i2 = 0, i3 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 8 | 0;
+ i2 = i3 | 0;
+ i7 = i4 >> 31 | ((i4 | 0) < 0 ? -1 : 0) << 1;
+ i8 = ((i4 | 0) < 0 ? -1 : 0) >> 31 | ((i4 | 0) < 0 ? -1 : 0) << 1;
+ i9 = i6 >> 31 | ((i6 | 0) < 0 ? -1 : 0) << 1;
+ i10 = ((i6 | 0) < 0 ? -1 : 0) >> 31 | ((i6 | 0) < 0 ? -1 : 0) << 1;
+ i1 = _i64Subtract(i7 ^ i1, i8 ^ i4, i7, i8) | 0;
+ i4 = tempRet0;
+ ___udivmoddi4(i1, i4, _i64Subtract(i9 ^ i5, i10 ^ i6, i9, i10) | 0, tempRet0, i2) | 0;
+ i9 = _i64Subtract(HEAP32[i2 >> 2] ^ i7, HEAP32[i2 + 4 >> 2] ^ i8, i7, i8) | 0;
+ i8 = tempRet0;
+ STACKTOP = i3;
+ return (tempRet0 = i8, i9) | 0;
+}
+function _luaC_barrierproto_(i3, i4, i2) {
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i5 = 0;
+ i1 = STACKTOP;
+ if ((HEAP32[i4 + 32 >> 2] | 0) != 0) {
+ i5 = HEAP32[i3 + 12 >> 2] | 0;
+ i3 = i4 + 5 | 0;
+ HEAP8[i3] = HEAP8[i3] & 251;
+ i5 = i5 + 88 | 0;
+ HEAP32[i4 + 72 >> 2] = HEAP32[i5 >> 2];
+ HEAP32[i5 >> 2] = i4;
+ STACKTOP = i1;
+ return;
+ }
+ if ((HEAP8[i2 + 5 | 0] & 3) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i5 = i4 + 5 | 0;
+ i4 = HEAP8[i5] | 0;
+ if ((i4 & 4) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i3 = HEAP32[i3 + 12 >> 2] | 0;
+ if ((HEAPU8[i3 + 61 | 0] | 0) < 2) {
+ _reallymarkobject(i3, i2);
+ STACKTOP = i1;
+ return;
+ } else {
+ HEAP8[i5] = HEAP8[i3 + 60 | 0] & 3 | i4 & 184;
+ STACKTOP = i1;
+ return;
+ }
+}
+function _luaL_openlibs(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_requiref(i1, 2592, 144, 1);
+ _lua_settop(i1, -2);
+ _luaL_requiref(i1, 2600, 145, 1);
+ _lua_settop(i1, -2);
+ _luaL_requiref(i1, 2608, 146, 1);
+ _lua_settop(i1, -2);
+ _luaL_requiref(i1, 2624, 147, 1);
+ _lua_settop(i1, -2);
+ _luaL_requiref(i1, 2632, 148, 1);
+ _lua_settop(i1, -2);
+ _luaL_requiref(i1, 2640, 149, 1);
+ _lua_settop(i1, -2);
+ _luaL_requiref(i1, 2648, 150, 1);
+ _lua_settop(i1, -2);
+ _luaL_requiref(i1, 2656, 151, 1);
+ _lua_settop(i1, -2);
+ _luaL_requiref(i1, 2664, 152, 1);
+ _lua_settop(i1, -2);
+ _luaL_requiref(i1, 2672, 153, 1);
+ _lua_settop(i1, -2);
+ _luaL_getsubtable(i1, -1001e3, 2576) | 0;
+ _lua_settop(i1, -2);
+ STACKTOP = i2;
+ return;
+}
+function _luaX_token2str(i4, i3) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i2 = 0, i5 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i1;
+ if ((i3 | 0) >= 257) {
+ i5 = HEAP32[12096 + (i3 + -257 << 2) >> 2] | 0;
+ if ((i3 | 0) >= 286) {
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ i4 = HEAP32[i4 + 52 >> 2] | 0;
+ HEAP32[i2 >> 2] = i5;
+ i5 = _luaO_pushfstring(i4, 12256, i2) | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ i4 = HEAP32[i4 + 52 >> 2] | 0;
+ if ((HEAP8[i3 + 10913 | 0] & 4) == 0) {
+ HEAP32[i2 >> 2] = i3;
+ i5 = _luaO_pushfstring(i4, 12240, i2) | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ } else {
+ HEAP32[i2 >> 2] = i3;
+ i5 = _luaO_pushfstring(i4, 12232, i2) | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ return 0;
+}
+function _luaL_buffinitsize(i6, i1, i7) {
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ i7 = i7 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i8 = 0;
+ i2 = STACKTOP;
+ HEAP32[i1 + 12 >> 2] = i6;
+ i3 = i1 + 16 | 0;
+ HEAP32[i1 >> 2] = i3;
+ i5 = i1 + 8 | 0;
+ HEAP32[i5 >> 2] = 0;
+ i4 = i1 + 4 | 0;
+ HEAP32[i4 >> 2] = 1024;
+ if (!(i7 >>> 0 > 1024)) {
+ i7 = i3;
+ i8 = 0;
+ i8 = i7 + i8 | 0;
+ STACKTOP = i2;
+ return i8 | 0;
+ }
+ i8 = i7 >>> 0 > 2048 ? i7 : 2048;
+ i7 = _lua_newuserdata(i6, i8) | 0;
+ _memcpy(i7 | 0, HEAP32[i1 >> 2] | 0, HEAP32[i5 >> 2] | 0) | 0;
+ if ((HEAP32[i1 >> 2] | 0) != (i3 | 0)) {
+ _lua_remove(i6, -2);
+ }
+ HEAP32[i1 >> 2] = i7;
+ HEAP32[i4 >> 2] = i8;
+ i8 = HEAP32[i5 >> 2] | 0;
+ i8 = i7 + i8 | 0;
+ STACKTOP = i2;
+ return i8 | 0;
+}
+function _luaE_freethread(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ i4 = i3 + 28 | 0;
+ _luaF_close(i3, HEAP32[i4 >> 2] | 0);
+ i5 = HEAP32[i4 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ _luaM_realloc_(i1, i3, 112, 0) | 0;
+ STACKTOP = i2;
+ return;
+ }
+ HEAP32[i3 + 16 >> 2] = i3 + 72;
+ i7 = i3 + 84 | 0;
+ i6 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = 0;
+ if ((i6 | 0) != 0) {
+ while (1) {
+ i5 = HEAP32[i6 + 12 >> 2] | 0;
+ _luaM_realloc_(i3, i6, 40, 0) | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ } else {
+ i6 = i5;
+ }
+ }
+ i5 = HEAP32[i4 >> 2] | 0;
+ }
+ _luaM_realloc_(i3, i5, HEAP32[i3 + 32 >> 2] << 4, 0) | 0;
+ _luaM_realloc_(i1, i3, 112, 0) | 0;
+ STACKTOP = i2;
+ return;
+}
+function ___toread(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i3 = STACKTOP;
+ i4 = i1 + 74 | 0;
+ i2 = HEAP8[i4] | 0;
+ HEAP8[i4] = i2 + 255 | i2;
+ i4 = i1 + 20 | 0;
+ i2 = i1 + 44 | 0;
+ if ((HEAP32[i4 >> 2] | 0) >>> 0 > (HEAP32[i2 >> 2] | 0) >>> 0) {
+ FUNCTION_TABLE_iiii[HEAP32[i1 + 36 >> 2] & 3](i1, 0, 0) | 0;
+ }
+ HEAP32[i1 + 16 >> 2] = 0;
+ HEAP32[i1 + 28 >> 2] = 0;
+ HEAP32[i4 >> 2] = 0;
+ i4 = HEAP32[i1 >> 2] | 0;
+ if ((i4 & 20 | 0) == 0) {
+ i4 = HEAP32[i2 >> 2] | 0;
+ HEAP32[i1 + 8 >> 2] = i4;
+ HEAP32[i1 + 4 >> 2] = i4;
+ i4 = 0;
+ STACKTOP = i3;
+ return i4 | 0;
+ }
+ if ((i4 & 4 | 0) == 0) {
+ i4 = -1;
+ STACKTOP = i3;
+ return i4 | 0;
+ }
+ HEAP32[i1 >> 2] = i4 | 32;
+ i4 = -1;
+ STACKTOP = i3;
+ return i4 | 0;
+}
+function _lua_callk(i3, i7, i4, i6, i5) {
+ i3 = i3 | 0;
+ i7 = i7 | 0;
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i8 = 0;
+ i1 = STACKTOP;
+ i2 = i3 + 8 | 0;
+ i7 = (HEAP32[i2 >> 2] | 0) + (~i7 << 4) | 0;
+ if ((i5 | 0) != 0 ? (HEAP16[i3 + 36 >> 1] | 0) == 0 : 0) {
+ i8 = i3 + 16 | 0;
+ HEAP32[(HEAP32[i8 >> 2] | 0) + 28 >> 2] = i5;
+ HEAP32[(HEAP32[i8 >> 2] | 0) + 24 >> 2] = i6;
+ _luaD_call(i3, i7, i4, 1);
+ } else {
+ _luaD_call(i3, i7, i4, 0);
+ }
+ if (!((i4 | 0) == -1)) {
+ STACKTOP = i1;
+ return;
+ }
+ i3 = (HEAP32[i3 + 16 >> 2] | 0) + 4 | 0;
+ i2 = HEAP32[i2 >> 2] | 0;
+ if (!((HEAP32[i3 >> 2] | 0) >>> 0 < i2 >>> 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[i3 >> 2] = i2;
+ STACKTOP = i1;
+ return;
+}
+function _luaX_newstring(i3, i5, i4) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i6 = 0;
+ i1 = STACKTOP;
+ i2 = HEAP32[i3 + 52 >> 2] | 0;
+ i5 = _luaS_newlstr(i2, i5, i4) | 0;
+ i4 = i2 + 8 | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = i6 + 16;
+ HEAP32[i6 >> 2] = i5;
+ HEAP32[i6 + 8 >> 2] = HEAPU8[i5 + 4 | 0] | 0 | 64;
+ i6 = _luaH_set(i2, HEAP32[(HEAP32[i3 + 48 >> 2] | 0) + 4 >> 2] | 0, (HEAP32[i4 >> 2] | 0) + -16 | 0) | 0;
+ i3 = i6 + 8 | 0;
+ if ((HEAP32[i3 >> 2] | 0) == 0 ? (HEAP32[i6 >> 2] = 1, HEAP32[i3 >> 2] = 1, (HEAP32[(HEAP32[i2 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) : 0) {
+ _luaC_step(i2);
+ }
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + -16;
+ STACKTOP = i1;
+ return i5 | 0;
+}
+function _strtod(i3, i2) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i4 = 0, d5 = 0.0, i6 = 0, i7 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 112 | 0;
+ i4 = i1;
+ i7 = i4 + 0 | 0;
+ i6 = i7 + 112 | 0;
+ do {
+ HEAP32[i7 >> 2] = 0;
+ i7 = i7 + 4 | 0;
+ } while ((i7 | 0) < (i6 | 0));
+ i6 = i4 + 4 | 0;
+ HEAP32[i6 >> 2] = i3;
+ i7 = i4 + 8 | 0;
+ HEAP32[i7 >> 2] = -1;
+ HEAP32[i4 + 44 >> 2] = i3;
+ HEAP32[i4 + 76 >> 2] = -1;
+ ___shlim(i4, 0);
+ d5 = +___floatscan(i4, 1, 1);
+ i4 = (HEAP32[i6 >> 2] | 0) - (HEAP32[i7 >> 2] | 0) + (HEAP32[i4 + 108 >> 2] | 0) | 0;
+ if ((i2 | 0) == 0) {
+ STACKTOP = i1;
+ return +d5;
+ }
+ if ((i4 | 0) != 0) {
+ i3 = i3 + i4 | 0;
+ }
+ HEAP32[i2 >> 2] = i3;
+ STACKTOP = i1;
+ return +d5;
+}
+function _f_seek(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, d6 = 0.0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = _luaL_checkudata(i1, 1, 2832) | 0;
+ if ((HEAP32[i3 + 4 >> 2] | 0) == 0) {
+ _luaL_error(i1, 3080, i2) | 0;
+ }
+ i3 = HEAP32[i3 >> 2] | 0;
+ i5 = _luaL_checkoption(i1, 2, 3208, 3184) | 0;
+ d6 = +_luaL_optnumber(i1, 3, 0.0);
+ i4 = ~~d6;
+ if (!(+(i4 | 0) == d6)) {
+ _luaL_argerror(i1, 3, 3224) | 0;
+ }
+ if ((_fseek(i3 | 0, i4 | 0, HEAP32[3168 + (i5 << 2) >> 2] | 0) | 0) == 0) {
+ _lua_pushnumber(i1, +(_ftell(i3 | 0) | 0));
+ i5 = 1;
+ STACKTOP = i2;
+ return i5 | 0;
+ } else {
+ i5 = _luaL_fileresult(i1, 0, 0) | 0;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ return 0;
+}
+function _setpath(i1, i4, i8, i7, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i8 = i8 | 0;
+ i7 = i7 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ i8 = _getenv(i8 | 0) | 0;
+ if ((i8 | 0) == 0) {
+ i7 = _getenv(i7 | 0) | 0;
+ if ((i7 | 0) != 0) {
+ i5 = i7;
+ i6 = 3;
+ }
+ } else {
+ i5 = i8;
+ i6 = 3;
+ }
+ if ((i6 | 0) == 3 ? (_lua_getfield(i1, -1001e3, 4832), i8 = _lua_toboolean(i1, -1) | 0, _lua_settop(i1, -2), (i8 | 0) == 0) : 0) {
+ _luaL_gsub(i1, _luaL_gsub(i1, i5, 4808, 4816) | 0, 4824, i3) | 0;
+ _lua_remove(i1, -2);
+ _lua_setfield(i1, -2, i4);
+ STACKTOP = i2;
+ return;
+ }
+ _lua_pushstring(i1, i3) | 0;
+ _lua_setfield(i1, -2, i4);
+ STACKTOP = i2;
+ return;
+}
+function _luaU_header(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ HEAP8[i1] = 1635077147;
+ HEAP8[i1 + 1 | 0] = 6387020;
+ HEAP8[i1 + 2 | 0] = 24949;
+ HEAP8[i1 + 3 | 0] = 97;
+ HEAP8[i1 + 4 | 0] = 82;
+ HEAP8[i1 + 5 | 0] = 0;
+ HEAP8[i1 + 6 | 0] = 1;
+ HEAP8[i1 + 7 | 0] = 4;
+ HEAP8[i1 + 8 | 0] = 4;
+ HEAP8[i1 + 9 | 0] = 4;
+ HEAP8[i1 + 10 | 0] = 8;
+ i3 = i1 + 12 | 0;
+ HEAP8[i1 + 11 | 0] = 0;
+ HEAP8[i3 + 0 | 0] = HEAP8[8816 | 0] | 0;
+ HEAP8[i3 + 1 | 0] = HEAP8[8817 | 0] | 0;
+ HEAP8[i3 + 2 | 0] = HEAP8[8818 | 0] | 0;
+ HEAP8[i3 + 3 | 0] = HEAP8[8819 | 0] | 0;
+ HEAP8[i3 + 4 | 0] = HEAP8[8820 | 0] | 0;
+ HEAP8[i3 + 5 | 0] = HEAP8[8821 | 0] | 0;
+ STACKTOP = i2;
+ return;
+}
+function _db_setlocal(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 112 | 0;
+ i3 = i2;
+ if ((_lua_type(i1, 1) | 0) == 8) {
+ i5 = _lua_tothread(i1, 1) | 0;
+ i4 = 1;
+ } else {
+ i5 = i1;
+ i4 = 0;
+ }
+ i6 = i4 + 1 | 0;
+ if ((_lua_getstack(i5, _luaL_checkinteger(i1, i6) | 0, i3) | 0) == 0) {
+ i6 = _luaL_argerror(i1, i6, 11560) | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ } else {
+ i6 = i4 + 3 | 0;
+ _luaL_checkany(i1, i6);
+ _lua_settop(i1, i6);
+ _lua_xmove(i1, i5, 1);
+ _lua_pushstring(i1, _lua_setlocal(i5, i3, _luaL_checkinteger(i1, i4 | 2) | 0) | 0) | 0;
+ i6 = 1;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ return 0;
+}
+function _tremove(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ _luaL_checktype(i1, 1, 5);
+ i3 = _luaL_len(i1, 1) | 0;
+ i4 = _luaL_optinteger(i1, 2, i3) | 0;
+ if ((i4 | 0) != (i3 | 0) ? (i4 | 0) < 1 | (i4 | 0) > (i3 + 1 | 0) : 0) {
+ _luaL_argerror(i1, 1, 8256) | 0;
+ }
+ _lua_rawgeti(i1, 1, i4);
+ if ((i4 | 0) >= (i3 | 0)) {
+ i5 = i4;
+ _lua_pushnil(i1);
+ _lua_rawseti(i1, 1, i5);
+ STACKTOP = i2;
+ return 1;
+ }
+ while (1) {
+ i5 = i4 + 1 | 0;
+ _lua_rawgeti(i1, 1, i5);
+ _lua_rawseti(i1, 1, i4);
+ if ((i5 | 0) == (i3 | 0)) {
+ break;
+ } else {
+ i4 = i5;
+ }
+ }
+ _lua_pushnil(i1);
+ _lua_rawseti(i1, 1, i3);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaL_checkudata(i1, i7, i5) {
+ i1 = i1 | 0;
+ i7 = i7 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ i3 = _lua_touserdata(i1, i7) | 0;
+ if (((i3 | 0) != 0 ? (_lua_getmetatable(i1, i7) | 0) != 0 : 0) ? (_lua_getfield(i1, -1001e3, i5), i6 = (_lua_rawequal(i1, -1, -2) | 0) == 0, i6 = i6 ? 0 : i3, _lua_settop(i1, -3), (i6 | 0) != 0) : 0) {
+ i7 = i6;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ i6 = _lua_typename(i1, _lua_type(i1, i7) | 0) | 0;
+ HEAP32[i4 >> 2] = i5;
+ HEAP32[i4 + 4 >> 2] = i6;
+ _luaL_argerror(i1, i7, _lua_pushfstring(i1, 1744, i4) | 0) | 0;
+ i7 = 0;
+ STACKTOP = i2;
+ return i7 | 0;
+}
+function _luaL_error(i1, i5, i7) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i7 = i7 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 128 | 0;
+ i3 = i4;
+ i2 = i4 + 24 | 0;
+ i4 = i4 + 8 | 0;
+ HEAP32[i4 >> 2] = i7;
+ if ((_lua_getstack(i1, 1, i2) | 0) != 0 ? (_lua_getinfo(i1, 1152, i2) | 0, i6 = HEAP32[i2 + 20 >> 2] | 0, (i6 | 0) > 0) : 0) {
+ HEAP32[i3 >> 2] = i2 + 36;
+ HEAP32[i3 + 4 >> 2] = i6;
+ _lua_pushfstring(i1, 1160, i3) | 0;
+ _lua_pushvfstring(i1, i5, i4) | 0;
+ _lua_concat(i1, 2);
+ _lua_error(i1) | 0;
+ }
+ _lua_pushlstring(i1, 1168, 0) | 0;
+ _lua_pushvfstring(i1, i5, i4) | 0;
+ _lua_concat(i1, 2);
+ _lua_error(i1) | 0;
+ return 0;
+}
+function _luaK_infix(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ L1 : do {
+ switch (i4 | 0) {
+ case 6:
+ {
+ _luaK_exp2nextreg(i1, i3);
+ break;
+ }
+ case 5:
+ case 4:
+ case 3:
+ case 2:
+ case 1:
+ case 0:
+ {
+ if (((HEAP32[i3 >> 2] | 0) == 5 ? (HEAP32[i3 + 16 >> 2] | 0) == -1 : 0) ? (HEAP32[i3 + 20 >> 2] | 0) == -1 : 0) {
+ break L1;
+ }
+ _luaK_exp2RK(i1, i3) | 0;
+ break;
+ }
+ case 13:
+ {
+ _luaK_goiftrue(i1, i3);
+ break;
+ }
+ case 14:
+ {
+ _luaK_goiffalse(i1, i3);
+ break;
+ }
+ default:
+ {
+ _luaK_exp2RK(i1, i3) | 0;
+ }
+ }
+ } while (0);
+ STACKTOP = i2;
+ return;
+}
+function _luaD_shrinkstack(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i1 + 8 >> 2] | 0;
+ i3 = HEAP32[i1 + 16 >> 2] | 0;
+ if ((i3 | 0) != 0) {
+ do {
+ i5 = HEAP32[i3 + 4 >> 2] | 0;
+ i4 = i4 >>> 0 < i5 >>> 0 ? i5 : i4;
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ } while ((i3 | 0) != 0);
+ }
+ i3 = i4 - (HEAP32[i1 + 28 >> 2] | 0) | 0;
+ i4 = (i3 >> 4) + 1 | 0;
+ i4 = ((i4 | 0) / 8 | 0) + 10 + i4 | 0;
+ i4 = (i4 | 0) > 1e6 ? 1e6 : i4;
+ if ((i3 | 0) > 15999984) {
+ STACKTOP = i2;
+ return;
+ }
+ if ((i4 | 0) >= (HEAP32[i1 + 32 >> 2] | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ _luaD_reallocstack(i1, i4);
+ STACKTOP = i2;
+ return;
+}
+function _luaF_newproto(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i1 = _luaC_newobj(i1, 9, 80, 0, 0) | 0;
+ HEAP32[i1 + 8 >> 2] = 0;
+ HEAP32[i1 + 44 >> 2] = 0;
+ HEAP32[i1 + 16 >> 2] = 0;
+ HEAP32[i1 + 56 >> 2] = 0;
+ HEAP32[i1 + 12 >> 2] = 0;
+ HEAP32[i1 + 32 >> 2] = 0;
+ HEAP32[i1 + 48 >> 2] = 0;
+ HEAP32[i1 + 20 >> 2] = 0;
+ HEAP32[i1 + 52 >> 2] = 0;
+ HEAP32[i1 + 28 >> 2] = 0;
+ HEAP32[i1 + 40 >> 2] = 0;
+ HEAP8[i1 + 76 | 0] = 0;
+ HEAP8[i1 + 77 | 0] = 0;
+ HEAP8[i1 + 78 | 0] = 0;
+ HEAP32[i1 + 24 >> 2] = 0;
+ HEAP32[i1 + 60 >> 2] = 0;
+ HEAP32[i1 + 64 >> 2] = 0;
+ HEAP32[i1 + 68 >> 2] = 0;
+ HEAP32[i1 + 36 >> 2] = 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _luaF_freeproto(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ _luaM_realloc_(i2, HEAP32[i1 + 12 >> 2] | 0, HEAP32[i1 + 48 >> 2] << 2, 0) | 0;
+ _luaM_realloc_(i2, HEAP32[i1 + 16 >> 2] | 0, HEAP32[i1 + 56 >> 2] << 2, 0) | 0;
+ _luaM_realloc_(i2, HEAP32[i1 + 8 >> 2] | 0, HEAP32[i1 + 44 >> 2] << 4, 0) | 0;
+ _luaM_realloc_(i2, HEAP32[i1 + 20 >> 2] | 0, HEAP32[i1 + 52 >> 2] << 2, 0) | 0;
+ _luaM_realloc_(i2, HEAP32[i1 + 24 >> 2] | 0, (HEAP32[i1 + 60 >> 2] | 0) * 12 | 0, 0) | 0;
+ _luaM_realloc_(i2, HEAP32[i1 + 28 >> 2] | 0, HEAP32[i1 + 40 >> 2] << 3, 0) | 0;
+ _luaM_realloc_(i2, i1, 80, 0) | 0;
+ STACKTOP = i3;
+ return;
+}
+function _luaK_patchclose(i3, i7, i4) {
+ i3 = i3 | 0;
+ i7 = i7 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i5 = 0, i6 = 0, i8 = 0;
+ i2 = STACKTOP;
+ if ((i7 | 0) == -1) {
+ STACKTOP = i2;
+ return;
+ }
+ i3 = HEAP32[(HEAP32[i3 >> 2] | 0) + 12 >> 2] | 0;
+ i4 = (i4 << 6) + 64 & 16320;
+ while (1) {
+ i6 = i3 + (i7 << 2) | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ i8 = (i5 >>> 14) + -131071 | 0;
+ if ((i8 | 0) == -1) {
+ break;
+ }
+ i7 = i7 + 1 + i8 | 0;
+ HEAP32[i6 >> 2] = i5 & -16321 | i4;
+ if ((i7 | 0) == -1) {
+ i1 = 6;
+ break;
+ }
+ }
+ if ((i1 | 0) == 6) {
+ STACKTOP = i2;
+ return;
+ }
+ HEAP32[i6 >> 2] = i5 & -16321 | i4;
+ STACKTOP = i2;
+ return;
+}
+function _loadfunc(i1, i4, i5) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ i6 = _luaL_gsub(i1, i5, 4936, 4944) | 0;
+ i5 = _strchr(i6, 45) | 0;
+ do {
+ if ((i5 | 0) != 0) {
+ HEAP32[i3 >> 2] = _lua_pushlstring(i1, i6, i5 - i6 | 0) | 0;
+ i6 = _ll_loadfunc(i1, i4, _lua_pushfstring(i1, 4952, i3) | 0) | 0;
+ if ((i6 | 0) == 2) {
+ i6 = i5 + 1 | 0;
+ break;
+ } else {
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ }
+ } while (0);
+ HEAP32[i3 >> 2] = i6;
+ i6 = _ll_loadfunc(i1, i4, _lua_pushfstring(i1, 4952, i3) | 0) | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+}
+function _luaK_setlist(i1, i3, i4, i5) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i4 = ((i4 + -1 | 0) / 50 | 0) + 1 | 0;
+ i5 = (i5 | 0) == -1 ? 0 : i5;
+ if ((i4 | 0) < 512) {
+ _luaK_code(i1, i3 << 6 | i5 << 23 | i4 << 14 | 36) | 0;
+ i4 = i3 + 1 | 0;
+ i4 = i4 & 255;
+ i5 = i1 + 48 | 0;
+ HEAP8[i5] = i4;
+ STACKTOP = i2;
+ return;
+ }
+ if ((i4 | 0) >= 67108864) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10576);
+ }
+ _luaK_code(i1, i3 << 6 | i5 << 23 | 36) | 0;
+ _luaK_code(i1, i4 << 6 | 39) | 0;
+ i4 = i3 + 1 | 0;
+ i4 = i4 & 255;
+ i5 = i1 + 48 | 0;
+ HEAP8[i5] = i4;
+ STACKTOP = i2;
+ return;
+}
+function _lua_getstack(i2, i6, i3) {
+ i2 = i2 | 0;
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i4 = 0, i5 = 0;
+ i1 = STACKTOP;
+ L1 : do {
+ if ((i6 | 0) >= 0) {
+ i5 = HEAP32[i2 + 16 >> 2] | 0;
+ if ((i6 | 0) > 0) {
+ i4 = i2 + 72 | 0;
+ do {
+ if ((i5 | 0) == (i4 | 0)) {
+ i2 = 0;
+ break L1;
+ }
+ i6 = i6 + -1 | 0;
+ i5 = HEAP32[i5 + 8 >> 2] | 0;
+ } while ((i6 | 0) > 0);
+ if ((i6 | 0) != 0) {
+ i2 = 0;
+ break;
+ }
+ }
+ if ((i5 | 0) != (i2 + 72 | 0)) {
+ HEAP32[i3 + 96 >> 2] = i5;
+ i2 = 1;
+ } else {
+ i2 = 0;
+ }
+ } else {
+ i2 = 0;
+ }
+ } while (0);
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _luaC_checkupvalcolor(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i4 = i5 + 5 | 0;
+ i3 = HEAPU8[i4] | 0;
+ if ((i3 & 7 | 0) != 0) {
+ STACKTOP = i2;
+ return;
+ }
+ if ((HEAP8[i1 + 62 | 0] | 0) != 2 ? (HEAPU8[i1 + 61 | 0] | 0) >= 2 : 0) {
+ HEAP8[i4] = HEAP8[i1 + 60 | 0] & 3 | i3 & 184;
+ STACKTOP = i2;
+ return;
+ }
+ HEAP8[i4] = i3 & 187 | 4;
+ i3 = HEAP32[i5 + 8 >> 2] | 0;
+ if ((HEAP32[i3 + 8 >> 2] & 64 | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i3 = HEAP32[i3 >> 2] | 0;
+ if ((HEAP8[i3 + 5 | 0] & 3) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ _reallymarkobject(i1, i3);
+ STACKTOP = i2;
+ return;
+}
+function _luaB_collectgarbage(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[10160 + ((_luaL_checkoption(i1, 1, 10040, 9976) | 0) << 2) >> 2] | 0;
+ i3 = _lua_gc(i1, i4, _luaL_optinteger(i1, 2, 0) | 0) | 0;
+ if ((i4 | 0) == 3) {
+ i4 = _lua_gc(i1, 4, 0) | 0;
+ _lua_pushnumber(i1, +(i3 | 0) + +(i4 | 0) * .0009765625);
+ _lua_pushinteger(i1, i4);
+ i4 = 2;
+ STACKTOP = i2;
+ return i4 | 0;
+ } else if ((i4 | 0) == 9 | (i4 | 0) == 5) {
+ _lua_pushboolean(i1, i3);
+ i4 = 1;
+ STACKTOP = i2;
+ return i4 | 0;
+ } else {
+ _lua_pushinteger(i1, i3);
+ i4 = 1;
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ return 0;
+}
+function _maxn(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, d3 = 0.0, d4 = 0.0;
+ i2 = STACKTOP;
+ _luaL_checktype(i1, 1, 5);
+ _lua_pushnil(i1);
+ L1 : do {
+ if ((_lua_next(i1, 1) | 0) == 0) {
+ d3 = 0.0;
+ } else {
+ d4 = 0.0;
+ while (1) {
+ while (1) {
+ _lua_settop(i1, -2);
+ if ((_lua_type(i1, -1) | 0) == 3 ? (d3 = +_lua_tonumberx(i1, -1, 0), d3 > d4) : 0) {
+ break;
+ }
+ if ((_lua_next(i1, 1) | 0) == 0) {
+ d3 = d4;
+ break L1;
+ }
+ }
+ if ((_lua_next(i1, 1) | 0) == 0) {
+ break;
+ } else {
+ d4 = d3;
+ }
+ }
+ }
+ } while (0);
+ _lua_pushnumber(i1, d3);
+ STACKTOP = i2;
+ return 1;
+}
+function _str_char(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 1040 | 0;
+ i4 = i2;
+ i3 = _lua_gettop(i1) | 0;
+ i5 = _luaL_buffinitsize(i1, i4, i3) | 0;
+ if ((i3 | 0) < 1) {
+ _luaL_pushresultsize(i4, i3);
+ STACKTOP = i2;
+ return 1;
+ } else {
+ i6 = 1;
+ }
+ while (1) {
+ i7 = _luaL_checkinteger(i1, i6) | 0;
+ if ((i7 & 255 | 0) != (i7 | 0)) {
+ _luaL_argerror(i1, i6, 7920) | 0;
+ }
+ HEAP8[i5 + (i6 + -1) | 0] = i7;
+ if ((i6 | 0) == (i3 | 0)) {
+ break;
+ } else {
+ i6 = i6 + 1 | 0;
+ }
+ }
+ _luaL_pushresultsize(i4, i3);
+ STACKTOP = i2;
+ return 1;
+}
+function _memcpy(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ if ((i1 | 0) >= 4096) return _emscripten_memcpy_big(i3 | 0, i2 | 0, i1 | 0) | 0;
+ i4 = i3 | 0;
+ if ((i3 & 3) == (i2 & 3)) {
+ while (i3 & 3) {
+ if ((i1 | 0) == 0) return i4 | 0;
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ while ((i1 | 0) >= 4) {
+ HEAP32[i3 >> 2] = HEAP32[i2 >> 2];
+ i3 = i3 + 4 | 0;
+ i2 = i2 + 4 | 0;
+ i1 = i1 - 4 | 0;
+ }
+ }
+ while ((i1 | 0) > 0) {
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ return i4 | 0;
+}
+function _luaK_exp2val(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0;
+ i2 = STACKTOP;
+ i3 = i5 + 16 | 0;
+ i4 = i5 + 20 | 0;
+ if ((HEAP32[i3 >> 2] | 0) == (HEAP32[i4 >> 2] | 0)) {
+ _luaK_dischargevars(i1, i5);
+ STACKTOP = i2;
+ return;
+ }
+ _luaK_dischargevars(i1, i5);
+ if ((HEAP32[i5 >> 2] | 0) == 6) {
+ i6 = HEAP32[i5 + 8 >> 2] | 0;
+ if ((HEAP32[i3 >> 2] | 0) == (HEAP32[i4 >> 2] | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ if ((i6 | 0) >= (HEAPU8[i1 + 46 | 0] | 0 | 0)) {
+ _exp2reg(i1, i5, i6);
+ STACKTOP = i2;
+ return;
+ }
+ }
+ _luaK_exp2nextreg(i1, i5);
+ STACKTOP = i2;
+ return;
+}
+function _str_reverse(i5) {
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 1056 | 0;
+ i4 = i2 + 1040 | 0;
+ i1 = i2;
+ i3 = _luaL_checklstring(i5, 1, i4) | 0;
+ i5 = _luaL_buffinitsize(i5, i1, HEAP32[i4 >> 2] | 0) | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ if ((i6 | 0) == 0) {
+ i7 = 0;
+ _luaL_pushresultsize(i1, i7);
+ STACKTOP = i2;
+ return 1;
+ } else {
+ i7 = 0;
+ }
+ do {
+ HEAP8[i5 + i7 | 0] = HEAP8[i3 + (i6 + ~i7) | 0] | 0;
+ i7 = i7 + 1 | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ } while (i7 >>> 0 < i6 >>> 0);
+ _luaL_pushresultsize(i1, i6);
+ STACKTOP = i2;
+ return 1;
+}
+function _str_upper(i5) {
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 1056 | 0;
+ i4 = i1 + 1040 | 0;
+ i2 = i1;
+ i3 = _luaL_checklstring(i5, 1, i4) | 0;
+ i5 = _luaL_buffinitsize(i5, i2, HEAP32[i4 >> 2] | 0) | 0;
+ if ((HEAP32[i4 >> 2] | 0) == 0) {
+ i7 = 0;
+ _luaL_pushresultsize(i2, i7);
+ STACKTOP = i1;
+ return 1;
+ } else {
+ i6 = 0;
+ }
+ do {
+ HEAP8[i5 + i6 | 0] = _toupper(HEAPU8[i3 + i6 | 0] | 0 | 0) | 0;
+ i6 = i6 + 1 | 0;
+ i7 = HEAP32[i4 >> 2] | 0;
+ } while (i6 >>> 0 < i7 >>> 0);
+ _luaL_pushresultsize(i2, i7);
+ STACKTOP = i1;
+ return 1;
+}
+function _str_lower(i5) {
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 1056 | 0;
+ i4 = i1 + 1040 | 0;
+ i2 = i1;
+ i3 = _luaL_checklstring(i5, 1, i4) | 0;
+ i5 = _luaL_buffinitsize(i5, i2, HEAP32[i4 >> 2] | 0) | 0;
+ if ((HEAP32[i4 >> 2] | 0) == 0) {
+ i7 = 0;
+ _luaL_pushresultsize(i2, i7);
+ STACKTOP = i1;
+ return 1;
+ } else {
+ i6 = 0;
+ }
+ do {
+ HEAP8[i5 + i6 | 0] = _tolower(HEAPU8[i3 + i6 | 0] | 0 | 0) | 0;
+ i6 = i6 + 1 | 0;
+ i7 = HEAP32[i4 >> 2] | 0;
+ } while (i6 >>> 0 < i7 >>> 0);
+ _luaL_pushresultsize(i2, i7);
+ STACKTOP = i1;
+ return 1;
+}
+function ___divdi3(i1, i2, i3, i4) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i5 = 0, i6 = 0, i7 = 0, i8 = 0;
+ i5 = i2 >> 31 | ((i2 | 0) < 0 ? -1 : 0) << 1;
+ i6 = ((i2 | 0) < 0 ? -1 : 0) >> 31 | ((i2 | 0) < 0 ? -1 : 0) << 1;
+ i7 = i4 >> 31 | ((i4 | 0) < 0 ? -1 : 0) << 1;
+ i8 = ((i4 | 0) < 0 ? -1 : 0) >> 31 | ((i4 | 0) < 0 ? -1 : 0) << 1;
+ i1 = _i64Subtract(i5 ^ i1, i6 ^ i2, i5, i6) | 0;
+ i2 = tempRet0;
+ i5 = i7 ^ i5;
+ i6 = i8 ^ i6;
+ i7 = _i64Subtract((___udivmoddi4(i1, i2, _i64Subtract(i7 ^ i3, i8 ^ i4, i7, i8) | 0, tempRet0, 0) | 0) ^ i5, tempRet0 ^ i6, i5, i6) | 0;
+ return i7 | 0;
+}
+function _luaK_setoneret(i1, i4) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = HEAP32[i4 >> 2] | 0;
+ if ((i3 | 0) == 13) {
+ i3 = (HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0) + (HEAP32[i4 + 8 >> 2] << 2) | 0;
+ HEAP32[i3 >> 2] = HEAP32[i3 >> 2] & 8388607 | 16777216;
+ HEAP32[i4 >> 2] = 11;
+ STACKTOP = i2;
+ return;
+ } else if ((i3 | 0) == 12) {
+ HEAP32[i4 >> 2] = 6;
+ i4 = i4 + 8 | 0;
+ HEAP32[i4 >> 2] = (HEAP32[(HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] | 0) + (HEAP32[i4 >> 2] << 2) >> 2] | 0) >>> 6 & 255;
+ STACKTOP = i2;
+ return;
+ } else {
+ STACKTOP = i2;
+ return;
+ }
+}
+function _luaV_tostring(i6, i1) {
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 48 | 0;
+ i3 = i2;
+ i4 = i2 + 8 | 0;
+ i5 = i1 + 8 | 0;
+ if ((HEAP32[i5 >> 2] | 0) != 3) {
+ i6 = 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ HEAPF64[tempDoublePtr >> 3] = +HEAPF64[i1 >> 3];
+ HEAP32[i3 >> 2] = HEAP32[tempDoublePtr >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[tempDoublePtr + 4 >> 2];
+ i6 = _luaS_newlstr(i6, i4, _sprintf(i4 | 0, 8936, i3 | 0) | 0) | 0;
+ HEAP32[i1 >> 2] = i6;
+ HEAP32[i5 >> 2] = HEAPU8[i6 + 4 | 0] | 0 | 64;
+ i6 = 1;
+ STACKTOP = i2;
+ return i6 | 0;
+}
+function _strcmp(i4, i2) {
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i5 = 0;
+ i1 = STACKTOP;
+ i5 = HEAP8[i4] | 0;
+ i3 = HEAP8[i2] | 0;
+ if (i5 << 24 >> 24 != i3 << 24 >> 24 | i5 << 24 >> 24 == 0 | i3 << 24 >> 24 == 0) {
+ i4 = i5;
+ i5 = i3;
+ i4 = i4 & 255;
+ i5 = i5 & 255;
+ i5 = i4 - i5 | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ do {
+ i4 = i4 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i5 = HEAP8[i4] | 0;
+ i3 = HEAP8[i2] | 0;
+ } while (!(i5 << 24 >> 24 != i3 << 24 >> 24 | i5 << 24 >> 24 == 0 | i3 << 24 >> 24 == 0));
+ i4 = i5 & 255;
+ i5 = i3 & 255;
+ i5 = i4 - i5 | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+}
+function _lua_pushstring(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0;
+ i2 = STACKTOP;
+ if ((i3 | 0) == 0) {
+ i3 = i1 + 8 | 0;
+ i1 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i1 + 8 >> 2] = 0;
+ HEAP32[i3 >> 2] = i1 + 16;
+ i3 = 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ if ((HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ _luaC_step(i1);
+ }
+ i3 = _luaS_new(i1, i3) | 0;
+ i1 = i1 + 8 | 0;
+ i4 = HEAP32[i1 >> 2] | 0;
+ HEAP32[i4 >> 2] = i3;
+ HEAP32[i4 + 8 >> 2] = HEAPU8[i3 + 4 | 0] | 0 | 64;
+ HEAP32[i1 >> 2] = (HEAP32[i1 >> 2] | 0) + 16;
+ i3 = i3 + 16 | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _luaK_exp2anyreg(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ _luaK_dischargevars(i1, i3);
+ if ((HEAP32[i3 >> 2] | 0) == 6) {
+ i5 = i3 + 8 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ if ((HEAP32[i3 + 16 >> 2] | 0) == (HEAP32[i3 + 20 >> 2] | 0)) {
+ i5 = i4;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ if ((i4 | 0) >= (HEAPU8[i1 + 46 | 0] | 0 | 0)) {
+ _exp2reg(i1, i3, i4);
+ i5 = HEAP32[i5 >> 2] | 0;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ } else {
+ i5 = i3 + 8 | 0;
+ }
+ _luaK_exp2nextreg(i1, i3);
+ i5 = HEAP32[i5 >> 2] | 0;
+ STACKTOP = i2;
+ return i5 | 0;
+}
+function _check_match(i1, i4, i5, i6) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ if ((HEAP32[i1 + 16 >> 2] | 0) == (i4 | 0)) {
+ _luaX_next(i1);
+ STACKTOP = i2;
+ return;
+ }
+ if ((HEAP32[i1 + 4 >> 2] | 0) == (i6 | 0)) {
+ _error_expected(i1, i4);
+ } else {
+ i2 = HEAP32[i1 + 52 >> 2] | 0;
+ i4 = _luaX_token2str(i1, i4) | 0;
+ i5 = _luaX_token2str(i1, i5) | 0;
+ HEAP32[i3 >> 2] = i4;
+ HEAP32[i3 + 4 >> 2] = i5;
+ HEAP32[i3 + 8 >> 2] = i6;
+ _luaX_syntaxerror(i1, _luaO_pushfstring(i2, 6840, i3) | 0);
+ }
+}
+function _fieldsel(i1, i6) {
+ i1 = i1 | 0;
+ i6 = i6 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i3 = i2;
+ i5 = i1 + 48 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ _luaK_exp2anyregup(i4, i6);
+ _luaX_next(i1);
+ if ((HEAP32[i1 + 16 >> 2] | 0) == 288) {
+ i7 = HEAP32[i1 + 24 >> 2] | 0;
+ _luaX_next(i1);
+ i5 = _luaK_stringK(HEAP32[i5 >> 2] | 0, i7) | 0;
+ HEAP32[i3 + 16 >> 2] = -1;
+ HEAP32[i3 + 20 >> 2] = -1;
+ HEAP32[i3 >> 2] = 4;
+ HEAP32[i3 + 8 >> 2] = i5;
+ _luaK_indexed(i4, i6, i3);
+ STACKTOP = i2;
+ return;
+ } else {
+ _error_expected(i1, 288);
+ }
+}
+function _luaK_exp2anyregup(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0;
+ i2 = STACKTOP;
+ if ((HEAP32[i3 >> 2] | 0) == 8 ? (HEAP32[i3 + 16 >> 2] | 0) == (HEAP32[i3 + 20 >> 2] | 0) : 0) {
+ STACKTOP = i2;
+ return;
+ }
+ _luaK_dischargevars(i1, i3);
+ if ((HEAP32[i3 >> 2] | 0) == 6) {
+ i4 = HEAP32[i3 + 8 >> 2] | 0;
+ if ((HEAP32[i3 + 16 >> 2] | 0) == (HEAP32[i3 + 20 >> 2] | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ if ((i4 | 0) >= (HEAPU8[i1 + 46 | 0] | 0 | 0)) {
+ _exp2reg(i1, i3, i4);
+ STACKTOP = i2;
+ return;
+ }
+ }
+ _luaK_exp2nextreg(i1, i3);
+ STACKTOP = i2;
+ return;
+}
+function _lua_settop(i3, i5) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i4 = 0;
+ i1 = STACKTOP;
+ if (!((i5 | 0) > -1)) {
+ i4 = i3 + 8 | 0;
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + (i5 + 1 << 4);
+ STACKTOP = i1;
+ return;
+ }
+ i2 = i3 + 8 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ i3 = (HEAP32[HEAP32[i3 + 16 >> 2] >> 2] | 0) + (i5 + 1 << 4) | 0;
+ if (i4 >>> 0 < i3 >>> 0) {
+ while (1) {
+ i5 = i4 + 16 | 0;
+ HEAP32[i4 + 8 >> 2] = 0;
+ if (i5 >>> 0 < i3 >>> 0) {
+ i4 = i5;
+ } else {
+ break;
+ }
+ }
+ HEAP32[i2 >> 2] = i5;
+ }
+ HEAP32[i2 >> 2] = i3;
+ STACKTOP = i1;
+ return;
+}
+function _luaL_fileresult(i1, i6, i5) {
+ i1 = i1 | 0;
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ i3 = HEAP32[(___errno_location() | 0) >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ _lua_pushboolean(i1, 1);
+ i6 = 1;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ _lua_pushnil(i1);
+ i6 = _strerror(i3 | 0) | 0;
+ if ((i5 | 0) == 0) {
+ _lua_pushstring(i1, i6) | 0;
+ } else {
+ HEAP32[i4 >> 2] = i5;
+ HEAP32[i4 + 4 >> 2] = i6;
+ _lua_pushfstring(i1, 1176, i4) | 0;
+ }
+ _lua_pushinteger(i1, i3);
+ i6 = 3;
+ STACKTOP = i2;
+ return i6 | 0;
+}
+function _luaL_pushmodule(i1, i4, i5) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ _luaL_findtable(i1, -1001e3, 1432, 1) | 0;
+ _lua_getfield(i1, -1, i4);
+ if ((_lua_type(i1, -1) | 0) == 5) {
+ _lua_remove(i1, -2);
+ STACKTOP = i2;
+ return;
+ }
+ _lua_settop(i1, -2);
+ _lua_rawgeti(i1, -1001e3, 2);
+ if ((_luaL_findtable(i1, 0, i4, i5) | 0) != 0) {
+ HEAP32[i3 >> 2] = i4;
+ _luaL_error(i1, 1440, i3) | 0;
+ }
+ _lua_pushvalue(i1, -1);
+ _lua_setfield(i1, -3, i4);
+ _lua_remove(i1, -2);
+ STACKTOP = i2;
+ return;
+}
+function _b_replace(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i6 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = _luaL_checkunsigned(i1, 1) | 0;
+ i5 = _luaL_checkunsigned(i1, 2) | 0;
+ i4 = _luaL_checkinteger(i1, 3) | 0;
+ i2 = _luaL_optinteger(i1, 4, 1) | 0;
+ if (!((i4 | 0) > -1)) {
+ _luaL_argerror(i1, 3, 10440) | 0;
+ }
+ if ((i2 | 0) <= 0) {
+ _luaL_argerror(i1, 4, 10472) | 0;
+ }
+ if ((i2 + i4 | 0) > 32) {
+ _luaL_error(i1, 10496, i6) | 0;
+ }
+ i2 = ~(-2 << i2 + -1);
+ _lua_pushunsigned(i1, i3 & ~(i2 << i4) | (i5 & i2) << i4);
+ STACKTOP = i6;
+ return 1;
+}
+function _luaT_gettmbyobj(i1, i5, i3) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i5 + 8 >> 2] & 15;
+ if ((i4 | 0) == 5) {
+ i4 = HEAP32[(HEAP32[i5 >> 2] | 0) + 8 >> 2] | 0;
+ } else if ((i4 | 0) == 7) {
+ i4 = HEAP32[(HEAP32[i5 >> 2] | 0) + 8 >> 2] | 0;
+ } else {
+ i4 = HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + (i4 << 2) + 252 >> 2] | 0;
+ }
+ if ((i4 | 0) == 0) {
+ i5 = 5192;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ i5 = _luaH_getstr(i4, HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + (i3 << 2) + 184 >> 2] | 0) | 0;
+ STACKTOP = i2;
+ return i5 | 0;
+}
+function _luaS_eqstr(i2, i3) {
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i4 = 0;
+ i1 = STACKTOP;
+ i4 = HEAP8[i2 + 4 | 0] | 0;
+ do {
+ if (i4 << 24 >> 24 == (HEAP8[i3 + 4 | 0] | 0)) {
+ if (i4 << 24 >> 24 == 4) {
+ i2 = (i2 | 0) == (i3 | 0);
+ break;
+ }
+ i4 = HEAP32[i2 + 12 >> 2] | 0;
+ if ((i2 | 0) != (i3 | 0)) {
+ if ((i4 | 0) == (HEAP32[i3 + 12 >> 2] | 0)) {
+ i2 = (_memcmp(i2 + 16 | 0, i3 + 16 | 0, i4) | 0) == 0;
+ } else {
+ i2 = 0;
+ }
+ } else {
+ i2 = 1;
+ }
+ } else {
+ i2 = 0;
+ }
+ } while (0);
+ STACKTOP = i1;
+ return i2 & 1 | 0;
+}
+function _lua_concat(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0;
+ i2 = STACKTOP;
+ if ((i3 | 0) > 1) {
+ if ((HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ _luaC_step(i1);
+ }
+ _luaV_concat(i1, i3);
+ STACKTOP = i2;
+ return;
+ } else {
+ if ((i3 | 0) != 0) {
+ STACKTOP = i2;
+ return;
+ }
+ i3 = i1 + 8 | 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ i1 = _luaS_newlstr(i1, 936, 0) | 0;
+ HEAP32[i4 >> 2] = i1;
+ HEAP32[i4 + 8 >> 2] = HEAPU8[i1 + 4 | 0] | 0 | 64;
+ HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + 16;
+ STACKTOP = i2;
+ return;
+ }
+}
+function _ll_loadfunc(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_getfield(i1, -1001e3, 4184);
+ _lua_getfield(i1, -1, i4);
+ i4 = _lua_touserdata(i1, -1) | 0;
+ _lua_settop(i1, -3);
+ if ((i4 | 0) == 0) {
+ _lua_pushlstring(i1, 4968, 58) | 0;
+ i4 = 1;
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ if ((HEAP8[i3] | 0) == 42) {
+ _lua_pushboolean(i1, 1);
+ i4 = 0;
+ STACKTOP = i2;
+ return i4 | 0;
+ } else {
+ _lua_pushlstring(i1, 4968, 58) | 0;
+ i4 = 2;
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ return 0;
+}
+function _memset(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = i1 + i3 | 0;
+ if ((i3 | 0) >= 20) {
+ i4 = i4 & 255;
+ i7 = i1 & 3;
+ i6 = i4 | i4 << 8 | i4 << 16 | i4 << 24;
+ i5 = i2 & ~3;
+ if (i7) {
+ i7 = i1 + 4 - i7 | 0;
+ while ((i1 | 0) < (i7 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ }
+ while ((i1 | 0) < (i5 | 0)) {
+ HEAP32[i1 >> 2] = i6;
+ i1 = i1 + 4 | 0;
+ }
+ }
+ while ((i1 | 0) < (i2 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ return i1 - i3 | 0;
+}
+function _luaD_growstack(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = HEAP32[i1 + 32 >> 2] | 0;
+ if ((i4 | 0) > 1e6) {
+ _luaD_throw(i1, 6);
+ }
+ i3 = i3 + 5 + ((HEAP32[i1 + 8 >> 2] | 0) - (HEAP32[i1 + 28 >> 2] | 0) >> 4) | 0;
+ i4 = i4 << 1;
+ i4 = (i4 | 0) > 1e6 ? 1e6 : i4;
+ i3 = (i4 | 0) < (i3 | 0) ? i3 : i4;
+ if ((i3 | 0) > 1e6) {
+ _luaD_reallocstack(i1, 1000200);
+ _luaG_runerror(i1, 2224, i2);
+ } else {
+ _luaD_reallocstack(i1, i3);
+ STACKTOP = i2;
+ return;
+ }
+}
+function _luaL_callmeta(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i4 = _lua_absindex(i1, i4) | 0;
+ if ((_lua_getmetatable(i1, i4) | 0) == 0) {
+ i4 = 0;
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ _lua_pushstring(i1, i3) | 0;
+ _lua_rawget(i1, -2);
+ if ((_lua_type(i1, -1) | 0) == 0) {
+ _lua_settop(i1, -3);
+ i4 = 0;
+ STACKTOP = i2;
+ return i4 | 0;
+ } else {
+ _lua_remove(i1, -2);
+ _lua_pushvalue(i1, i4);
+ _lua_callk(i1, 1, 1, 0, 0);
+ i4 = 1;
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ return 0;
+}
+function _luaK_reserveregs(i8, i7) {
+ i8 = i8 | 0;
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i3 = STACKTOP;
+ i2 = i8 + 48 | 0;
+ i6 = HEAP8[i2] | 0;
+ i4 = (i6 & 255) + i7 | 0;
+ i5 = (HEAP32[i8 >> 2] | 0) + 78 | 0;
+ do {
+ if ((i4 | 0) > (HEAPU8[i5] | 0 | 0)) {
+ if ((i4 | 0) > 249) {
+ _luaX_syntaxerror(HEAP32[i8 + 12 >> 2] | 0, 10536);
+ } else {
+ HEAP8[i5] = i4;
+ i1 = HEAP8[i2] | 0;
+ break;
+ }
+ } else {
+ i1 = i6;
+ }
+ } while (0);
+ HEAP8[i2] = (i1 & 255) + i7;
+ STACKTOP = i3;
+ return;
+}
+function _aux_lines(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0;
+ i4 = STACKTOP;
+ i3 = _lua_gettop(i1) | 0;
+ i2 = i3 + -1 | 0;
+ if ((i3 | 0) >= 19) {
+ _luaL_argerror(i1, 17, 3320) | 0;
+ }
+ _lua_pushvalue(i1, 1);
+ _lua_pushinteger(i1, i2);
+ _lua_pushboolean(i1, i5);
+ if ((i3 | 0) >= 2) {
+ i5 = 1;
+ while (1) {
+ i6 = i5 + 1 | 0;
+ _lua_pushvalue(i1, i6);
+ if ((i5 | 0) < (i2 | 0)) {
+ i5 = i6;
+ } else {
+ break;
+ }
+ }
+ }
+ _lua_pushcclosure(i1, 155, i3 + 2 | 0);
+ STACKTOP = i4;
+ return;
+}
+function _memcmp(i2, i4, i3) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i5 = 0, i6 = 0;
+ i1 = STACKTOP;
+ L1 : do {
+ if ((i3 | 0) == 0) {
+ i2 = 0;
+ } else {
+ while (1) {
+ i6 = HEAP8[i2] | 0;
+ i5 = HEAP8[i4] | 0;
+ if (!(i6 << 24 >> 24 == i5 << 24 >> 24)) {
+ break;
+ }
+ i3 = i3 + -1 | 0;
+ if ((i3 | 0) == 0) {
+ i2 = 0;
+ break L1;
+ } else {
+ i2 = i2 + 1 | 0;
+ i4 = i4 + 1 | 0;
+ }
+ }
+ i2 = (i6 & 255) - (i5 & 255) | 0;
+ }
+ } while (0);
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _b_arshift(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i3 = _luaL_checkunsigned(i1, 1) | 0;
+ i4 = _luaL_checkinteger(i1, 2) | 0;
+ if ((i4 | 0) > -1 & (i3 | 0) < 0) {
+ if ((i4 | 0) > 31) {
+ i3 = -1;
+ } else {
+ i3 = i3 >>> i4 | ~(-1 >>> i4);
+ }
+ _lua_pushunsigned(i1, i3);
+ STACKTOP = i2;
+ return 1;
+ }
+ i5 = 0 - i4 | 0;
+ if ((i4 | 0) > 0) {
+ i3 = (i4 | 0) > 31 ? 0 : i3 >>> i4;
+ } else {
+ i3 = (i5 | 0) > 31 ? 0 : i3 << i5;
+ }
+ _lua_pushunsigned(i1, i3);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaL_checkunsigned(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i3;
+ i6 = i3 + 8 | 0;
+ i2 = _lua_tounsignedx(i1, i5, i6) | 0;
+ if ((HEAP32[i6 >> 2] | 0) != 0) {
+ STACKTOP = i3;
+ return i2 | 0;
+ }
+ i7 = _lua_typename(i1, 3) | 0;
+ i6 = _lua_typename(i1, _lua_type(i1, i5) | 0) | 0;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i4 + 4 >> 2] = i6;
+ _luaL_argerror(i1, i5, _lua_pushfstring(i1, 1744, i4) | 0) | 0;
+ STACKTOP = i3;
+ return i2 | 0;
+}
+function _luaB_loadfile(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i1 = STACKTOP;
+ i4 = _luaL_optlstring(i2, 1, 0, 0) | 0;
+ i5 = _luaL_optlstring(i2, 2, 0, 0) | 0;
+ i3 = (_lua_type(i2, 3) | 0) != -1;
+ i6 = i3 ? 3 : 0;
+ if ((_luaL_loadfilex(i2, i4, i5) | 0) == 0) {
+ if (i3 ? (_lua_pushvalue(i2, i6), (_lua_setupvalue(i2, -2, 1) | 0) == 0) : 0) {
+ _lua_settop(i2, -2);
+ i2 = 1;
+ } else {
+ i2 = 1;
+ }
+ } else {
+ _lua_pushnil(i2);
+ _lua_insert(i2, -2);
+ i2 = 2;
+ }
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _luaL_checkinteger(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i3;
+ i6 = i3 + 8 | 0;
+ i2 = _lua_tointegerx(i1, i5, i6) | 0;
+ if ((HEAP32[i6 >> 2] | 0) != 0) {
+ STACKTOP = i3;
+ return i2 | 0;
+ }
+ i7 = _lua_typename(i1, 3) | 0;
+ i6 = _lua_typename(i1, _lua_type(i1, i5) | 0) | 0;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i4 + 4 >> 2] = i6;
+ _luaL_argerror(i1, i5, _lua_pushfstring(i1, 1744, i4) | 0) | 0;
+ STACKTOP = i3;
+ return i2 | 0;
+}
+function _luaB_select(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i3 = STACKTOP;
+ i2 = _lua_gettop(i1) | 0;
+ if ((_lua_type(i1, 1) | 0) == 4 ? (HEAP8[_lua_tolstring(i1, 1, 0) | 0] | 0) == 35 : 0) {
+ _lua_pushinteger(i1, i2 + -1 | 0);
+ i4 = 1;
+ STACKTOP = i3;
+ return i4 | 0;
+ }
+ i4 = _luaL_checkinteger(i1, 1) | 0;
+ if ((i4 | 0) < 0) {
+ i4 = i4 + i2 | 0;
+ } else {
+ i4 = (i4 | 0) > (i2 | 0) ? i2 : i4;
+ }
+ if ((i4 | 0) <= 0) {
+ _luaL_argerror(i1, 1, 9760) | 0;
+ }
+ i4 = i2 - i4 | 0;
+ STACKTOP = i3;
+ return i4 | 0;
+}
+function _luaX_next(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ HEAP32[i1 + 8 >> 2] = HEAP32[i1 + 4 >> 2];
+ i3 = i1 + 32 | 0;
+ if ((HEAP32[i3 >> 2] | 0) == 286) {
+ HEAP32[i1 + 16 >> 2] = _llex(i1, i1 + 24 | 0) | 0;
+ STACKTOP = i2;
+ return;
+ } else {
+ i1 = i1 + 16 | 0;
+ HEAP32[i1 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
+ HEAP32[i1 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
+ HEAP32[i1 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
+ HEAP32[i1 + 12 >> 2] = HEAP32[i3 + 12 >> 2];
+ HEAP32[i3 >> 2] = 286;
+ STACKTOP = i2;
+ return;
+ }
+}
+function _lua_setglobal(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i3 = STACKTOP;
+ i5 = _luaH_getint(HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 40 >> 2] | 0, 2) | 0;
+ i4 = i1 + 8 | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = i6 + 16;
+ i2 = _luaS_new(i1, i2) | 0;
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i6 + 8 >> 2] = HEAPU8[i2 + 4 | 0] | 0 | 64;
+ i2 = HEAP32[i4 >> 2] | 0;
+ _luaV_settable(i1, i5, i2 + -16 | 0, i2 + -32 | 0);
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + -32;
+ STACKTOP = i3;
+ return;
+}
+function _luaL_checknumber(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var d2 = 0.0, i3 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i3;
+ i6 = i3 + 8 | 0;
+ d2 = +_lua_tonumberx(i1, i5, i6);
+ if ((HEAP32[i6 >> 2] | 0) != 0) {
+ STACKTOP = i3;
+ return +d2;
+ }
+ i7 = _lua_typename(i1, 3) | 0;
+ i6 = _lua_typename(i1, _lua_type(i1, i5) | 0) | 0;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i4 + 4 >> 2] = i6;
+ _luaL_argerror(i1, i5, _lua_pushfstring(i1, 1744, i4) | 0) | 0;
+ STACKTOP = i3;
+ return +d2;
+}
+function _luaZ_fill(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ i3 = FUNCTION_TABLE_iiii[HEAP32[i1 + 8 >> 2] & 3](HEAP32[i1 + 16 >> 2] | 0, HEAP32[i1 + 12 >> 2] | 0, i4) | 0;
+ if ((i3 | 0) == 0) {
+ i4 = -1;
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ i4 = -1;
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ HEAP32[i1 >> 2] = i4 + -1;
+ HEAP32[i1 + 4 >> 2] = i3 + 1;
+ i4 = HEAPU8[i3] | 0;
+ STACKTOP = i2;
+ return i4 | 0;
+}
+function _lua_createtable(i1, i3, i4) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ if ((HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ _luaC_step(i1);
+ }
+ i5 = _luaH_new(i1) | 0;
+ i6 = i1 + 8 | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i7 >> 2] = i5;
+ HEAP32[i7 + 8 >> 2] = 69;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + 16;
+ if (!((i3 | 0) > 0 | (i4 | 0) > 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ _luaH_resize(i1, i5, i3, i4);
+ STACKTOP = i2;
+ return;
+}
+function _generic_reader(i1, i3, i2) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ _luaL_checkstack(i1, 2, 9888);
+ _lua_pushvalue(i1, 1);
+ _lua_callk(i1, 0, 1, 0, 0);
+ if ((_lua_type(i1, -1) | 0) == 0) {
+ _lua_settop(i1, -2);
+ HEAP32[i2 >> 2] = 0;
+ i2 = 0;
+ STACKTOP = i3;
+ return i2 | 0;
+ }
+ if ((_lua_isstring(i1, -1) | 0) == 0) {
+ _luaL_error(i1, 9920, i3) | 0;
+ }
+ _lua_replace(i1, 5);
+ i2 = _lua_tolstring(i1, 5, i2) | 0;
+ STACKTOP = i3;
+ return i2 | 0;
+}
+function _luaZ_openspace(i5, i1, i6) {
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ i6 = i6 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i4 = i1 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ if (!(i3 >>> 0 < i6 >>> 0)) {
+ i6 = HEAP32[i1 >> 2] | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ i6 = i6 >>> 0 < 32 ? 32 : i6;
+ if ((i6 + 1 | 0) >>> 0 > 4294967293) {
+ _luaM_toobig(i5);
+ }
+ i5 = _luaM_realloc_(i5, HEAP32[i1 >> 2] | 0, i3, i6) | 0;
+ HEAP32[i1 >> 2] = i5;
+ HEAP32[i4 >> 2] = i6;
+ i6 = i5;
+ STACKTOP = i2;
+ return i6 | 0;
+}
+function _luaH_getstr(i4, i3) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i2 = 0;
+ i2 = STACKTOP;
+ i4 = (HEAP32[i4 + 16 >> 2] | 0) + (((1 << (HEAPU8[i4 + 7 | 0] | 0)) + -1 & HEAP32[i3 + 8 >> 2]) << 5) | 0;
+ while (1) {
+ if ((HEAP32[i4 + 24 >> 2] | 0) == 68 ? (HEAP32[i4 + 16 >> 2] | 0) == (i3 | 0) : 0) {
+ break;
+ }
+ i4 = HEAP32[i4 + 28 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ i3 = 5192;
+ i1 = 6;
+ break;
+ }
+ }
+ if ((i1 | 0) == 6) {
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ STACKTOP = i2;
+ return i4 | 0;
+}
+function _b_extract(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i5 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = _luaL_checkunsigned(i1, 1) | 0;
+ i3 = _luaL_checkinteger(i1, 2) | 0;
+ i4 = _luaL_optinteger(i1, 3, 1) | 0;
+ if (!((i3 | 0) > -1)) {
+ _luaL_argerror(i1, 2, 10440) | 0;
+ }
+ if ((i4 | 0) <= 0) {
+ _luaL_argerror(i1, 3, 10472) | 0;
+ }
+ if ((i4 + i3 | 0) > 32) {
+ _luaL_error(i1, 10496, i5) | 0;
+ }
+ _lua_pushunsigned(i1, i2 >>> i3 & ~(-2 << i4 + -1));
+ STACKTOP = i5;
+ return 1;
+}
+function _luaL_checklstring(i1, i4, i5) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i6 = 0, i7 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ i5 = _lua_tolstring(i1, i4, i5) | 0;
+ if ((i5 | 0) != 0) {
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ i7 = _lua_typename(i1, 4) | 0;
+ i6 = _lua_typename(i1, _lua_type(i1, i4) | 0) | 0;
+ HEAP32[i3 >> 2] = i7;
+ HEAP32[i3 + 4 >> 2] = i6;
+ _luaL_argerror(i1, i4, _lua_pushfstring(i1, 1744, i3) | 0) | 0;
+ STACKTOP = i2;
+ return i5 | 0;
+}
+function _db_traceback(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ if ((_lua_type(i1, 1) | 0) == 8) {
+ i3 = _lua_tothread(i1, 1) | 0;
+ i4 = 1;
+ } else {
+ i3 = i1;
+ i4 = 0;
+ }
+ i5 = i4 + 1 | 0;
+ i6 = _lua_tolstring(i1, i5, 0) | 0;
+ if ((i6 | 0) == 0 ? (_lua_type(i1, i5) | 0) >= 1 : 0) {
+ _lua_pushvalue(i1, i5);
+ STACKTOP = i2;
+ return 1;
+ }
+ _luaL_traceback(i1, i3, i6, _luaL_optinteger(i1, i4 | 2, (i3 | 0) == (i1 | 0) | 0) | 0);
+ STACKTOP = i2;
+ return 1;
+}
+function _f_setvbuf(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = _luaL_checkudata(i1, 1, 2832) | 0;
+ if ((HEAP32[i3 + 4 >> 2] | 0) == 0) {
+ _luaL_error(i1, 3080, i2) | 0;
+ }
+ i5 = HEAP32[i3 >> 2] | 0;
+ i4 = _luaL_checkoption(i1, 2, 0, 3128) | 0;
+ i3 = _luaL_optinteger(i1, 3, 1024) | 0;
+ i3 = _luaL_fileresult(i1, (_setvbuf(i5 | 0, 0, HEAP32[3112 + (i4 << 2) >> 2] | 0, i3 | 0) | 0) == 0 | 0, 0) | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _luaU_dump(i3, i1, i4, i2, i5) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ var i6 = 0, i7 = 0, i8 = 0;
+ i6 = STACKTOP;
+ STACKTOP = STACKTOP + 48 | 0;
+ i8 = i6 + 20 | 0;
+ i7 = i6;
+ HEAP32[i7 >> 2] = i3;
+ HEAP32[i7 + 4 >> 2] = i4;
+ HEAP32[i7 + 8 >> 2] = i2;
+ HEAP32[i7 + 12 >> 2] = i5;
+ i5 = i7 + 16 | 0;
+ _luaU_header(i8);
+ HEAP32[i5 >> 2] = FUNCTION_TABLE_iiiii[i4 & 3](i3, i8, 18, i2) | 0;
+ _DumpFunction(i1, i7);
+ STACKTOP = i6;
+ return HEAP32[i5 >> 2] | 0;
+}
+function _luaB_setmetatable(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = _lua_type(i1, 2) | 0;
+ _luaL_checktype(i1, 1, 5);
+ if (!((i3 | 0) == 0 | (i3 | 0) == 5)) {
+ _luaL_argerror(i1, 2, 9680) | 0;
+ }
+ if ((_luaL_getmetafield(i1, 1, 9704) | 0) == 0) {
+ _lua_settop(i1, 2);
+ _lua_setmetatable(i1, 1) | 0;
+ i3 = 1;
+ STACKTOP = i2;
+ return i3 | 0;
+ } else {
+ i3 = _luaL_error(i1, 9720, i2) | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ return 0;
+}
+function _getF(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ i3 = STACKTOP;
+ i4 = HEAP32[i2 >> 2] | 0;
+ if ((i4 | 0) > 0) {
+ HEAP32[i1 >> 2] = i4;
+ HEAP32[i2 >> 2] = 0;
+ i4 = i2 + 8 | 0;
+ STACKTOP = i3;
+ return i4 | 0;
+ }
+ i4 = i2 + 4 | 0;
+ if ((_feof(HEAP32[i4 >> 2] | 0) | 0) != 0) {
+ i4 = 0;
+ STACKTOP = i3;
+ return i4 | 0;
+ }
+ i2 = i2 + 8 | 0;
+ HEAP32[i1 >> 2] = _fread(i2 | 0, 1, 1024, HEAP32[i4 >> 2] | 0) | 0;
+ i4 = i2;
+ STACKTOP = i3;
+ return i4 | 0;
+}
+function _luaL_where(i1, i6) {
+ i1 = i1 | 0;
+ i6 = i6 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 112 | 0;
+ i3 = i4;
+ i2 = i4 + 8 | 0;
+ if ((_lua_getstack(i1, i6, i2) | 0) != 0 ? (_lua_getinfo(i1, 1152, i2) | 0, i5 = HEAP32[i2 + 20 >> 2] | 0, (i5 | 0) > 0) : 0) {
+ HEAP32[i3 >> 2] = i2 + 36;
+ HEAP32[i3 + 4 >> 2] = i5;
+ _lua_pushfstring(i1, 1160, i3) | 0;
+ STACKTOP = i4;
+ return;
+ }
+ _lua_pushlstring(i1, 1168, 0) | 0;
+ STACKTOP = i4;
+ return;
+}
+function _hookf(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_getsubtable(i1, -1001e3, 11584) | 0;
+ _lua_pushthread(i1) | 0;
+ _lua_rawget(i1, -2);
+ if ((_lua_type(i1, -1) | 0) != 6) {
+ STACKTOP = i2;
+ return;
+ }
+ _lua_pushstring(i1, HEAP32[11608 + (HEAP32[i3 >> 2] << 2) >> 2] | 0) | 0;
+ i3 = HEAP32[i3 + 20 >> 2] | 0;
+ if ((i3 | 0) > -1) {
+ _lua_pushinteger(i1, i3);
+ } else {
+ _lua_pushnil(i1);
+ }
+ _lua_callk(i1, 2, 0, 0, 0);
+ STACKTOP = i2;
+ return;
+}
+function _luaV_tonumber(i5, i2) {
+ i5 = i5 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i1;
+ i4 = HEAP32[i5 + 8 >> 2] | 0;
+ if ((i4 | 0) != 3) {
+ if ((i4 & 15 | 0) == 4 ? (i5 = HEAP32[i5 >> 2] | 0, (_luaO_str2d(i5 + 16 | 0, HEAP32[i5 + 12 >> 2] | 0, i3) | 0) != 0) : 0) {
+ HEAPF64[i2 >> 3] = +HEAPF64[i3 >> 3];
+ HEAP32[i2 + 8 >> 2] = 3;
+ } else {
+ i2 = 0;
+ }
+ } else {
+ i2 = i5;
+ }
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _luaO_arith(i3, d1, d2) {
+ i3 = i3 | 0;
+ d1 = +d1;
+ d2 = +d2;
+ switch (i3 | 0) {
+ case 4:
+ {
+ d1 = d1 - +Math_floor(+(d1 / d2)) * d2;
+ break;
+ }
+ case 6:
+ {
+ d1 = -d1;
+ break;
+ }
+ case 0:
+ {
+ d1 = d1 + d2;
+ break;
+ }
+ case 1:
+ {
+ d1 = d1 - d2;
+ break;
+ }
+ case 5:
+ {
+ d1 = +Math_pow(+d1, +d2);
+ break;
+ }
+ case 3:
+ {
+ d1 = d1 / d2;
+ break;
+ }
+ case 2:
+ {
+ d1 = d1 * d2;
+ break;
+ }
+ default:
+ {
+ d1 = 0.0;
+ }
+ }
+ return +d1;
+}
+function _luaB_coresume(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _lua_tothread(i1, 1) | 0;
+ if ((i3 | 0) == 0) {
+ _luaL_argerror(i1, 1, 10856) | 0;
+ }
+ i3 = _auxresume(i1, i3, (_lua_gettop(i1) | 0) + -1 | 0) | 0;
+ if ((i3 | 0) < 0) {
+ _lua_pushboolean(i1, 0);
+ _lua_insert(i1, -2);
+ i3 = 2;
+ STACKTOP = i2;
+ return i3 | 0;
+ } else {
+ _lua_pushboolean(i1, 1);
+ _lua_insert(i1, ~i3);
+ i3 = i3 + 1 | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ return 0;
+}
+function _pairsmeta(i1, i5, i4, i3) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((_luaL_getmetafield(i1, 1, i5) | 0) != 0) {
+ _lua_pushvalue(i1, 1);
+ _lua_callk(i1, 1, 3, 0, 0);
+ STACKTOP = i2;
+ return;
+ }
+ _luaL_checktype(i1, 1, 5);
+ _lua_pushcclosure(i1, i3, 0);
+ _lua_pushvalue(i1, 1);
+ if ((i4 | 0) == 0) {
+ _lua_pushnil(i1);
+ STACKTOP = i2;
+ return;
+ } else {
+ _lua_pushinteger(i1, 0);
+ STACKTOP = i2;
+ return;
+ }
+}
+function _io_close(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ if ((_lua_type(i1, 1) | 0) == -1) {
+ _lua_getfield(i1, -1001e3, 2800);
+ }
+ if ((HEAP32[(_luaL_checkudata(i1, 1, 2832) | 0) + 4 >> 2] | 0) == 0) {
+ _luaL_error(i1, 3080, i2) | 0;
+ }
+ i4 = (_luaL_checkudata(i1, 1, 2832) | 0) + 4 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = 0;
+ i1 = FUNCTION_TABLE_ii[i3 & 255](i1) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _pack(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _lua_gettop(i1) | 0;
+ _lua_createtable(i1, i3, 1);
+ _lua_pushinteger(i1, i3);
+ _lua_setfield(i1, -2, 8312);
+ if ((i3 | 0) <= 0) {
+ STACKTOP = i2;
+ return 1;
+ }
+ _lua_pushvalue(i1, 1);
+ _lua_rawseti(i1, -2, 1);
+ _lua_replace(i1, 1);
+ if ((i3 | 0) <= 1) {
+ STACKTOP = i2;
+ return 1;
+ }
+ do {
+ _lua_rawseti(i1, 1, i3);
+ i3 = i3 + -1 | 0;
+ } while ((i3 | 0) > 1);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaL_execresult(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((i3 | 0) == -1) {
+ i3 = HEAP32[(___errno_location() | 0) >> 2] | 0;
+ _lua_pushnil(i1);
+ _lua_pushstring(i1, _strerror(i3 | 0) | 0) | 0;
+ _lua_pushinteger(i1, i3);
+ STACKTOP = i2;
+ return 3;
+ } else if ((i3 | 0) == 0) {
+ _lua_pushboolean(i1, 1);
+ } else {
+ _lua_pushnil(i1);
+ }
+ _lua_pushstring(i1, 1184) | 0;
+ _lua_pushinteger(i1, i3);
+ STACKTOP = i2;
+ return 3;
+}
+function _lua_getglobal(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i3 = STACKTOP;
+ i4 = _luaH_getint(HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 40 >> 2] | 0, 2) | 0;
+ i5 = i1 + 8 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i6 + 16;
+ i2 = _luaS_new(i1, i2) | 0;
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i6 + 8 >> 2] = HEAPU8[i2 + 4 | 0] | 0 | 64;
+ i2 = (HEAP32[i5 >> 2] | 0) + -16 | 0;
+ _luaV_gettable(i1, i4, i2, i2);
+ STACKTOP = i3;
+ return;
+}
+function _luaL_checktype(i1, i5, i4) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ if ((_lua_type(i1, i5) | 0) == (i4 | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ i6 = _lua_typename(i1, i4) | 0;
+ i4 = _lua_typename(i1, _lua_type(i1, i5) | 0) | 0;
+ HEAP32[i3 >> 2] = i6;
+ HEAP32[i3 + 4 >> 2] = i4;
+ _luaL_argerror(i1, i5, _lua_pushfstring(i1, 1744, i3) | 0) | 0;
+ STACKTOP = i2;
+ return;
+}
+function _luaC_newobj(i7, i4, i6, i5, i1) {
+ i7 = i7 | 0;
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = HEAP32[i7 + 12 >> 2] | 0;
+ i7 = _luaM_realloc_(i7, 0, i4 & 15, i6) | 0;
+ i6 = i7 + i1 | 0;
+ i5 = (i5 | 0) == 0 ? i3 + 68 | 0 : i5;
+ HEAP8[i7 + (i1 + 5) | 0] = HEAP8[i3 + 60 | 0] & 3;
+ HEAP8[i7 + (i1 + 4) | 0] = i4;
+ HEAP32[i6 >> 2] = HEAP32[i5 >> 2];
+ HEAP32[i5 >> 2] = i6;
+ STACKTOP = i2;
+ return i6 | 0;
+}
+function _luaL_requiref(i1, i3, i5, i4) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushcclosure(i1, i5, 0);
+ _lua_pushstring(i1, i3) | 0;
+ _lua_callk(i1, 1, 1, 0, 0);
+ _luaL_getsubtable(i1, -1001e3, 1432) | 0;
+ _lua_pushvalue(i1, -2);
+ _lua_setfield(i1, -2, i3);
+ _lua_settop(i1, -2);
+ if ((i4 | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ _lua_pushvalue(i1, -1);
+ _lua_setglobal(i1, i3);
+ STACKTOP = i2;
+ return;
+}
+function _luaG_ordererror(i1, i3, i4) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = HEAP32[8528 + ((HEAP32[i3 + 8 >> 2] & 15) + 1 << 2) >> 2] | 0;
+ i4 = HEAP32[8528 + ((HEAP32[i4 + 8 >> 2] & 15) + 1 << 2) >> 2] | 0;
+ if ((i3 | 0) == (i4 | 0)) {
+ HEAP32[i2 >> 2] = i3;
+ _luaG_runerror(i1, 1952, i2);
+ } else {
+ HEAP32[i2 >> 2] = i3;
+ HEAP32[i2 + 4 >> 2] = i4;
+ _luaG_runerror(i1, 1992, i2);
+ }
+}
+function _io_popen(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = _luaL_checklstring(i1, 1, 0) | 0;
+ _luaL_optlstring(i1, 2, 3480, 0) | 0;
+ i5 = _lua_newuserdata(i1, 8) | 0;
+ i4 = i5 + 4 | 0;
+ HEAP32[i4 >> 2] = 0;
+ _luaL_setmetatable(i1, 2832);
+ _luaL_error(i1, 3488, i2) | 0;
+ HEAP32[i5 >> 2] = 0;
+ HEAP32[i4 >> 2] = 157;
+ i1 = _luaL_fileresult(i1, 0, i3) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _sort_comp(i1, i3, i4) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((_lua_type(i1, 2) | 0) == 0) {
+ i4 = _lua_compare(i1, i3, i4, 1) | 0;
+ STACKTOP = i2;
+ return i4 | 0;
+ } else {
+ _lua_pushvalue(i1, 2);
+ _lua_pushvalue(i1, i3 + -1 | 0);
+ _lua_pushvalue(i1, i4 + -2 | 0);
+ _lua_callk(i1, 2, 1, 0, 0);
+ i4 = _lua_toboolean(i1, -1) | 0;
+ _lua_settop(i1, -2);
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ return 0;
+}
+function _db_upvalueid(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 112 | 0;
+ i4 = i3;
+ i2 = _luaL_checkinteger(i1, 2) | 0;
+ _luaL_checktype(i1, 1, 6);
+ _lua_pushvalue(i1, 1);
+ _lua_getinfo(i1, 11728, i4) | 0;
+ if (!((i2 | 0) > 0 ? (i2 | 0) <= (HEAPU8[i4 + 32 | 0] | 0 | 0) : 0)) {
+ _luaL_argerror(i1, 2, 11736) | 0;
+ }
+ _lua_pushlightuserdata(i1, _lua_upvalueid(i1, 1, i2) | 0);
+ STACKTOP = i3;
+ return 1;
+}
+function _luaL_getmetafield(i2, i4, i3) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i1 = 0;
+ i1 = STACKTOP;
+ do {
+ if ((_lua_getmetatable(i2, i4) | 0) != 0) {
+ _lua_pushstring(i2, i3) | 0;
+ _lua_rawget(i2, -2);
+ if ((_lua_type(i2, -1) | 0) == 0) {
+ _lua_settop(i2, -3);
+ i2 = 0;
+ break;
+ } else {
+ _lua_remove(i2, -2);
+ i2 = 1;
+ break;
+ }
+ } else {
+ i2 = 0;
+ }
+ } while (0);
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _luaF_freeupval(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ if ((HEAP32[i3 + 8 >> 2] | 0) == (i3 + 16 | 0)) {
+ _luaM_realloc_(i1, i3, 32, 0) | 0;
+ STACKTOP = i2;
+ return;
+ }
+ i4 = i3 + 16 | 0;
+ i5 = i4 + 4 | 0;
+ HEAP32[(HEAP32[i5 >> 2] | 0) + 16 >> 2] = HEAP32[i4 >> 2];
+ HEAP32[(HEAP32[i4 >> 2] | 0) + 20 >> 2] = HEAP32[i5 >> 2];
+ _luaM_realloc_(i1, i3, 32, 0) | 0;
+ STACKTOP = i2;
+ return;
+}
+function _luaL_addvalue(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ i5 = HEAP32[i1 + 12 >> 2] | 0;
+ i3 = _lua_tolstring(i5, -1, i4) | 0;
+ i6 = i1 + 16 | 0;
+ if ((HEAP32[i1 >> 2] | 0) != (i6 | 0)) {
+ _lua_insert(i5, -2);
+ }
+ _luaL_addlstring(i1, i3, HEAP32[i4 >> 2] | 0);
+ _lua_remove(i5, (HEAP32[i1 >> 2] | 0) != (i6 | 0) ? -2 : -1);
+ STACKTOP = i2;
+ return;
+}
+function _escerror(i1, i4, i3, i2) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i5 = 0, i6 = 0;
+ HEAP32[(HEAP32[i1 + 60 >> 2] | 0) + 4 >> 2] = 0;
+ _save(i1, 92);
+ L1 : do {
+ if ((i3 | 0) > 0) {
+ i5 = 0;
+ do {
+ i6 = HEAP32[i4 + (i5 << 2) >> 2] | 0;
+ if ((i6 | 0) == -1) {
+ break L1;
+ }
+ _save(i1, i6);
+ i5 = i5 + 1 | 0;
+ } while ((i5 | 0) < (i3 | 0));
+ }
+ } while (0);
+ _lexerror(i1, i2, 289);
+}
+function _pushglobalfuncname(i1, i4) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _lua_gettop(i1) | 0;
+ _lua_getinfo(i1, 1768, i4) | 0;
+ _lua_rawgeti(i1, -1001e3, 2);
+ i4 = i3 + 1 | 0;
+ if ((_findfield(i1, i4, 2) | 0) == 0) {
+ _lua_settop(i1, i3);
+ i4 = 0;
+ STACKTOP = i2;
+ return i4 | 0;
+ } else {
+ _lua_copy(i1, -1, i4);
+ _lua_settop(i1, -3);
+ i4 = 1;
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ return 0;
+}
+function copyTempDouble(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+ HEAP8[tempDoublePtr + 4 | 0] = HEAP8[i1 + 4 | 0];
+ HEAP8[tempDoublePtr + 5 | 0] = HEAP8[i1 + 5 | 0];
+ HEAP8[tempDoublePtr + 6 | 0] = HEAP8[i1 + 6 | 0];
+ HEAP8[tempDoublePtr + 7 | 0] = HEAP8[i1 + 7 | 0];
+}
+function _lua_pushlstring(i1, i3, i4) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ _luaC_step(i1);
+ }
+ i4 = _luaS_newlstr(i1, i3, i4) | 0;
+ i3 = i1 + 8 | 0;
+ i1 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i1 >> 2] = i4;
+ HEAP32[i1 + 8 >> 2] = HEAPU8[i4 + 4 | 0] | 0 | 64;
+ HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + 16;
+ STACKTOP = i2;
+ return i4 + 16 | 0;
+}
+function _ll_searchpath(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i5 = _luaL_checklstring(i1, 1, 0) | 0;
+ i4 = _luaL_checklstring(i1, 2, 0) | 0;
+ i3 = _luaL_optlstring(i1, 3, 4936, 0) | 0;
+ if ((_searchpath(i1, i5, i4, i3, _luaL_optlstring(i1, 4, 4848, 0) | 0) | 0) != 0) {
+ i5 = 1;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ _lua_pushnil(i1);
+ _lua_insert(i1, -2);
+ i5 = 2;
+ STACKTOP = i2;
+ return i5 | 0;
+}
+function _math_log(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, d3 = 0.0, d4 = 0.0;
+ i2 = STACKTOP;
+ d3 = +_luaL_checknumber(i1, 1);
+ do {
+ if ((_lua_type(i1, 2) | 0) >= 1) {
+ d4 = +_luaL_checknumber(i1, 2);
+ if (d4 == 10.0) {
+ d3 = +_log10(+d3);
+ break;
+ } else {
+ d3 = +Math_log(+d3) / +Math_log(+d4);
+ break;
+ }
+ } else {
+ d3 = +Math_log(+d3);
+ }
+ } while (0);
+ _lua_pushnumber(i1, d3);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaT_init(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i3 = i1 + 12 | 0;
+ i4 = 0;
+ do {
+ i5 = _luaS_new(i1, HEAP32[8576 + (i4 << 2) >> 2] | 0) | 0;
+ HEAP32[(HEAP32[i3 >> 2] | 0) + (i4 << 2) + 184 >> 2] = i5;
+ i5 = (HEAP32[(HEAP32[i3 >> 2] | 0) + (i4 << 2) + 184 >> 2] | 0) + 5 | 0;
+ HEAP8[i5] = HEAPU8[i5] | 0 | 32;
+ i4 = i4 + 1 | 0;
+ } while ((i4 | 0) != 17);
+ STACKTOP = i2;
+ return;
+}
+function _f_gc(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i3 = _luaL_checkudata(i1, 1, 2832) | 0;
+ if ((HEAP32[i3 + 4 >> 2] | 0) == 0) {
+ STACKTOP = i2;
+ return 0;
+ }
+ if ((HEAP32[i3 >> 2] | 0) == 0) {
+ STACKTOP = i2;
+ return 0;
+ }
+ i4 = (_luaL_checkudata(i1, 1, 2832) | 0) + 4 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = 0;
+ FUNCTION_TABLE_ii[i3 & 255](i1) | 0;
+ STACKTOP = i2;
+ return 0;
+}
+function ___shlim(i1, i5) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i6 = 0;
+ i2 = STACKTOP;
+ HEAP32[i1 + 104 >> 2] = i5;
+ i4 = HEAP32[i1 + 8 >> 2] | 0;
+ i3 = HEAP32[i1 + 4 >> 2] | 0;
+ i6 = i4 - i3 | 0;
+ HEAP32[i1 + 108 >> 2] = i6;
+ if ((i5 | 0) != 0 & (i6 | 0) > (i5 | 0)) {
+ HEAP32[i1 + 100 >> 2] = i3 + i5;
+ STACKTOP = i2;
+ return;
+ } else {
+ HEAP32[i1 + 100 >> 2] = i4;
+ STACKTOP = i2;
+ return;
+ }
+}
+function _lua_sethook(i4, i6, i1, i5) {
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = (i6 | 0) == 0 | (i1 | 0) == 0;
+ i3 = HEAP32[i4 + 16 >> 2] | 0;
+ if (!((HEAP8[i3 + 18 | 0] & 1) == 0)) {
+ HEAP32[i4 + 20 >> 2] = HEAP32[i3 + 28 >> 2];
+ }
+ HEAP32[i4 + 52 >> 2] = i2 ? 0 : i6;
+ HEAP32[i4 + 44 >> 2] = i5;
+ HEAP32[i4 + 48 >> 2] = i5;
+ HEAP8[i4 + 40 | 0] = i2 ? 0 : i1 & 255;
+ return 1;
+}
+function _io_tmpfile(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i4 = _lua_newuserdata(i1, 8) | 0;
+ i3 = i4 + 4 | 0;
+ HEAP32[i3 >> 2] = 0;
+ _luaL_setmetatable(i1, 2832);
+ HEAP32[i4 >> 2] = 0;
+ HEAP32[i3 >> 2] = 156;
+ i3 = _tmpfile() | 0;
+ HEAP32[i4 >> 2] = i3;
+ if ((i3 | 0) != 0) {
+ i4 = 1;
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ i4 = _luaL_fileresult(i1, 0, 0) | 0;
+ STACKTOP = i2;
+ return i4 | 0;
+}
+function _luaL_checkstack(i1, i5, i4) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ if ((_lua_checkstack(i1, i5 + 20 | 0) | 0) != 0) {
+ STACKTOP = i2;
+ return;
+ }
+ if ((i4 | 0) == 0) {
+ _luaL_error(i1, 1240, i3) | 0;
+ STACKTOP = i2;
+ return;
+ } else {
+ HEAP32[i3 >> 2] = i4;
+ _luaL_error(i1, 1216, i3) | 0;
+ STACKTOP = i2;
+ return;
+ }
+}
+function _b_rshift(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i4 = _luaL_checkunsigned(i1, 1) | 0;
+ i3 = _luaL_checkinteger(i1, 2) | 0;
+ i5 = 0 - i3 | 0;
+ if ((i3 | 0) > 0) {
+ i5 = (i3 | 0) > 31 ? 0 : i4 >>> i3;
+ _lua_pushunsigned(i1, i5);
+ STACKTOP = i2;
+ return 1;
+ } else {
+ i5 = (i5 | 0) > 31 ? 0 : i4 << i5;
+ _lua_pushunsigned(i1, i5);
+ STACKTOP = i2;
+ return 1;
+ }
+ return 0;
+}
+function _b_lshift(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i3 = _luaL_checkunsigned(i1, 1) | 0;
+ i4 = _luaL_checkinteger(i1, 2) | 0;
+ if ((i4 | 0) < 0) {
+ i4 = 0 - i4 | 0;
+ i4 = (i4 | 0) > 31 ? 0 : i3 >>> i4;
+ _lua_pushunsigned(i1, i4);
+ STACKTOP = i2;
+ return 1;
+ } else {
+ i4 = (i4 | 0) > 31 ? 0 : i3 << i4;
+ _lua_pushunsigned(i1, i4);
+ STACKTOP = i2;
+ return 1;
+ }
+ return 0;
+}
+function _math_min(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, d5 = 0.0, d6 = 0.0;
+ i2 = STACKTOP;
+ i3 = _lua_gettop(i1) | 0;
+ d5 = +_luaL_checknumber(i1, 1);
+ if ((i3 | 0) >= 2) {
+ i4 = 2;
+ while (1) {
+ d6 = +_luaL_checknumber(i1, i4);
+ d5 = d6 < d5 ? d6 : d5;
+ if ((i4 | 0) == (i3 | 0)) {
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ }
+ }
+ }
+ _lua_pushnumber(i1, d5);
+ STACKTOP = i2;
+ return 1;
+}
+function _math_max(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, d5 = 0.0, d6 = 0.0;
+ i2 = STACKTOP;
+ i3 = _lua_gettop(i1) | 0;
+ d5 = +_luaL_checknumber(i1, 1);
+ if ((i3 | 0) >= 2) {
+ i4 = 2;
+ while (1) {
+ d6 = +_luaL_checknumber(i1, i4);
+ d5 = d6 > d5 ? d6 : d5;
+ if ((i4 | 0) == (i3 | 0)) {
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ }
+ }
+ }
+ _lua_pushnumber(i1, d5);
+ STACKTOP = i2;
+ return 1;
+}
+function _io_type(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ _luaL_checkany(i1, 1);
+ i3 = _luaL_testudata(i1, 1, 2832) | 0;
+ if ((i3 | 0) == 0) {
+ _lua_pushnil(i1);
+ STACKTOP = i2;
+ return 1;
+ }
+ if ((HEAP32[i3 + 4 >> 2] | 0) == 0) {
+ _lua_pushlstring(i1, 3456, 11) | 0;
+ STACKTOP = i2;
+ return 1;
+ } else {
+ _lua_pushlstring(i1, 3472, 4) | 0;
+ STACKTOP = i2;
+ return 1;
+ }
+ return 0;
+}
+function _luaF_newLclosure(i3, i2) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i4 = 0;
+ i1 = STACKTOP;
+ i3 = _luaC_newobj(i3, 6, (i2 << 2) + 16 | 0, 0, 0) | 0;
+ HEAP32[i3 + 12 >> 2] = 0;
+ HEAP8[i3 + 6 | 0] = i2;
+ if ((i2 | 0) == 0) {
+ STACKTOP = i1;
+ return i3 | 0;
+ }
+ i4 = i3 + 16 | 0;
+ do {
+ i2 = i2 + -1 | 0;
+ HEAP32[i4 + (i2 << 2) >> 2] = 0;
+ } while ((i2 | 0) != 0);
+ STACKTOP = i1;
+ return i3 | 0;
+}
+function _io_flush(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ _lua_getfield(i1, -1001e3, 2800);
+ i3 = _lua_touserdata(i1, -1) | 0;
+ if ((HEAP32[i3 + 4 >> 2] | 0) == 0) {
+ HEAP32[i4 >> 2] = 2804;
+ _luaL_error(i1, 3424, i4) | 0;
+ }
+ i4 = _luaL_fileresult(i1, (_fflush(HEAP32[i3 >> 2] | 0) | 0) == 0 | 0, 0) | 0;
+ STACKTOP = i2;
+ return i4 | 0;
+}
+function _b_test(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i3 = _lua_gettop(i1) | 0;
+ if ((i3 | 0) < 1) {
+ i3 = 1;
+ } else {
+ i4 = 1;
+ i5 = -1;
+ while (1) {
+ i5 = (_luaL_checkunsigned(i1, i4) | 0) & i5;
+ if ((i4 | 0) == (i3 | 0)) {
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ }
+ }
+ i3 = (i5 | 0) != 0;
+ }
+ _lua_pushboolean(i1, i3 & 1);
+ STACKTOP = i2;
+ return 1;
+}
+function ___muldsi3(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ i6 = i2 & 65535;
+ i4 = i1 & 65535;
+ i3 = Math_imul(i4, i6) | 0;
+ i5 = i2 >>> 16;
+ i4 = (i3 >>> 16) + (Math_imul(i4, i5) | 0) | 0;
+ i1 = i1 >>> 16;
+ i2 = Math_imul(i1, i6) | 0;
+ return (tempRet0 = (i4 >>> 16) + (Math_imul(i1, i5) | 0) + (((i4 & 65535) + i2 | 0) >>> 16) | 0, i4 + i2 << 16 | i3 & 65535 | 0) | 0;
+}
+function _str_dump(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 1056 | 0;
+ i3 = i2 + 8 | 0;
+ _luaL_checktype(i1, 1, 6);
+ _lua_settop(i1, 1);
+ _luaL_buffinit(i1, i3);
+ if ((_lua_dump(i1, 2, i3) | 0) == 0) {
+ _luaL_pushresult(i3);
+ i3 = 1;
+ STACKTOP = i2;
+ return i3 | 0;
+ } else {
+ i3 = _luaL_error(i1, 7888, i2) | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ return 0;
+}
+function ___memrchr(i2, i3, i5) {
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i4 = 0;
+ i1 = STACKTOP;
+ i3 = i3 & 255;
+ while (1) {
+ i4 = i5 + -1 | 0;
+ if ((i5 | 0) == 0) {
+ i5 = 0;
+ i2 = 4;
+ break;
+ }
+ i5 = i2 + i4 | 0;
+ if ((HEAP8[i5] | 0) == i3 << 24 >> 24) {
+ i2 = 4;
+ break;
+ } else {
+ i5 = i4;
+ }
+ }
+ if ((i2 | 0) == 4) {
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ return 0;
+}
+function _luaL_getsubtable(i1, i3, i4) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_getfield(i1, i3, i4);
+ if ((_lua_type(i1, -1) | 0) == 5) {
+ i4 = 1;
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ _lua_settop(i1, -2);
+ i3 = _lua_absindex(i1, i3) | 0;
+ _lua_createtable(i1, 0, 0);
+ _lua_pushvalue(i1, -1);
+ _lua_setfield(i1, i3, i4);
+ i4 = 0;
+ STACKTOP = i2;
+ return i4 | 0;
+}
+function _luaE_freeCI(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i4 = (HEAP32[i1 + 16 >> 2] | 0) + 12 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ HEAP32[i4 >> 2] = 0;
+ if ((i3 | 0) == 0) {
+ STACKTOP = i2;
+ return;
+ }
+ while (1) {
+ i4 = HEAP32[i3 + 12 >> 2] | 0;
+ _luaM_realloc_(i1, i3, 40, 0) | 0;
+ if ((i4 | 0) == 0) {
+ break;
+ } else {
+ i3 = i4;
+ }
+ }
+ STACKTOP = i2;
+ return;
+}
+function _f_tostring(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ i4 = _luaL_checkudata(i1, 1, 2832) | 0;
+ if ((HEAP32[i4 + 4 >> 2] | 0) == 0) {
+ _lua_pushlstring(i1, 3040, 13) | 0;
+ STACKTOP = i2;
+ return 1;
+ } else {
+ HEAP32[i3 >> 2] = HEAP32[i4 >> 2];
+ _lua_pushfstring(i1, 3056, i3) | 0;
+ STACKTOP = i2;
+ return 1;
+ }
+ return 0;
+}
+function _lua_newuserdata(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0;
+ i2 = STACKTOP;
+ if ((HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ _luaC_step(i1);
+ }
+ i3 = _luaS_newudata(i1, i3, 0) | 0;
+ i1 = i1 + 8 | 0;
+ i4 = HEAP32[i1 >> 2] | 0;
+ HEAP32[i4 >> 2] = i3;
+ HEAP32[i4 + 8 >> 2] = 71;
+ HEAP32[i1 >> 2] = (HEAP32[i1 >> 2] | 0) + 16;
+ STACKTOP = i2;
+ return i3 + 24 | 0;
+}
+function _luaL_pushresultsize(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i5 = i1 + 8 | 0;
+ i4 = (HEAP32[i5 >> 2] | 0) + i3 | 0;
+ HEAP32[i5 >> 2] = i4;
+ i3 = HEAP32[i1 + 12 >> 2] | 0;
+ _lua_pushlstring(i3, HEAP32[i1 >> 2] | 0, i4) | 0;
+ if ((HEAP32[i1 >> 2] | 0) == (i1 + 16 | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ _lua_remove(i3, -2);
+ STACKTOP = i2;
+ return;
+}
+function _luaL_testudata(i2, i5, i4) {
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i3 = 0;
+ i1 = STACKTOP;
+ i3 = _lua_touserdata(i2, i5) | 0;
+ if ((i3 | 0) != 0 ? (_lua_getmetatable(i2, i5) | 0) != 0 : 0) {
+ _lua_getfield(i2, -1001e3, i4);
+ i5 = (_lua_rawequal(i2, -1, -2) | 0) == 0;
+ _lua_settop(i2, -3);
+ i2 = i5 ? 0 : i3;
+ } else {
+ i2 = 0;
+ }
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _finishpcall(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((_lua_checkstack(i1, 1) | 0) == 0) {
+ _lua_settop(i1, 0);
+ _lua_pushboolean(i1, 0);
+ _lua_pushstring(i1, 9632) | 0;
+ i3 = 2;
+ STACKTOP = i2;
+ return i3 | 0;
+ } else {
+ _lua_pushboolean(i1, i3);
+ _lua_replace(i1, 1);
+ i3 = _lua_gettop(i1) | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ return 0;
+}
+function _searcher_preload(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ i3 = _luaL_checklstring(i1, 1, 0) | 0;
+ _lua_getfield(i1, -1001e3, 4592);
+ _lua_getfield(i1, -1, i3);
+ if ((_lua_type(i1, -1) | 0) != 0) {
+ STACKTOP = i2;
+ return 1;
+ }
+ HEAP32[i4 >> 2] = i3;
+ _lua_pushfstring(i1, 5096, i4) | 0;
+ STACKTOP = i2;
+ return 1;
+}
+function _luaB_auxwrap(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i3 = STACKTOP;
+ i2 = _lua_tothread(i1, -1001001) | 0;
+ i2 = _auxresume(i1, i2, _lua_gettop(i1) | 0) | 0;
+ if ((i2 | 0) >= 0) {
+ STACKTOP = i3;
+ return i2 | 0;
+ }
+ if ((_lua_isstring(i1, -1) | 0) == 0) {
+ _lua_error(i1) | 0;
+ }
+ _luaL_where(i1, 1);
+ _lua_insert(i1, -2);
+ _lua_concat(i1, 2);
+ _lua_error(i1) | 0;
+ return 0;
+}
+function _ll_loadlib(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _luaL_checklstring(i1, 1, 0) | 0;
+ i3 = _ll_loadfunc(i1, i3, _luaL_checklstring(i1, 2, 0) | 0) | 0;
+ if ((i3 | 0) == 0) {
+ i3 = 1;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ _lua_pushnil(i1);
+ _lua_insert(i1, -2);
+ _lua_pushstring(i1, (i3 | 0) == 1 ? 5176 : 5184) | 0;
+ i3 = 3;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _luaS_hash(i2, i4, i3) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i5 = 0;
+ i1 = STACKTOP;
+ i5 = i3 ^ i4;
+ i3 = (i4 >>> 5) + 1 | 0;
+ if (i3 >>> 0 > i4 >>> 0) {
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ do {
+ i5 = (i5 << 5) + (i5 >>> 2) + (HEAPU8[i2 + (i4 + -1) | 0] | 0) ^ i5;
+ i4 = i4 - i3 | 0;
+ } while (!(i4 >>> 0 < i3 >>> 0));
+ STACKTOP = i1;
+ return i5 | 0;
+}
+function _b_and(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i3 = _lua_gettop(i1) | 0;
+ if ((i3 | 0) < 1) {
+ i5 = -1;
+ } else {
+ i4 = 1;
+ i5 = -1;
+ while (1) {
+ i5 = (_luaL_checkunsigned(i1, i4) | 0) & i5;
+ if ((i4 | 0) == (i3 | 0)) {
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ }
+ }
+ }
+ _lua_pushunsigned(i1, i5);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaopen_string(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_createtable(i1, 0, 14);
+ _luaL_setfuncs(i1, 6920, 0);
+ _lua_createtable(i1, 0, 1);
+ _lua_pushlstring(i1, 7040, 0) | 0;
+ _lua_pushvalue(i1, -2);
+ _lua_setmetatable(i1, -2) | 0;
+ _lua_settop(i1, -2);
+ _lua_pushvalue(i1, -2);
+ _lua_setfield(i1, -2, 7048);
+ _lua_settop(i1, -2);
+ STACKTOP = i2;
+ return 1;
+}
+function _b_xor(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i3 = _lua_gettop(i1) | 0;
+ if ((i3 | 0) < 1) {
+ i5 = 0;
+ } else {
+ i4 = 1;
+ i5 = 0;
+ while (1) {
+ i5 = (_luaL_checkunsigned(i1, i4) | 0) ^ i5;
+ if ((i4 | 0) == (i3 | 0)) {
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ }
+ }
+ }
+ _lua_pushunsigned(i1, i5);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaB_assert(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ if ((_lua_toboolean(i1, 1) | 0) == 0) {
+ HEAP32[i3 >> 2] = _luaL_optlstring(i1, 2, 10216, 0) | 0;
+ i3 = _luaL_error(i1, 10208, i3) | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ } else {
+ i3 = _lua_gettop(i1) | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ return 0;
+}
+function _b_or(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i3 = _lua_gettop(i1) | 0;
+ if ((i3 | 0) < 1) {
+ i5 = 0;
+ } else {
+ i4 = 1;
+ i5 = 0;
+ while (1) {
+ i5 = _luaL_checkunsigned(i1, i4) | 0 | i5;
+ if ((i4 | 0) == (i3 | 0)) {
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ }
+ }
+ }
+ _lua_pushunsigned(i1, i5);
+ STACKTOP = i2;
+ return 1;
+}
+function _io_write(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ _lua_getfield(i1, -1001e3, 2800);
+ i3 = _lua_touserdata(i1, -1) | 0;
+ if ((HEAP32[i3 + 4 >> 2] | 0) == 0) {
+ HEAP32[i4 >> 2] = 2804;
+ _luaL_error(i1, 3424, i4) | 0;
+ }
+ i4 = _g_write(i1, HEAP32[i3 >> 2] | 0, 1) | 0;
+ STACKTOP = i2;
+ return i4 | 0;
+}
+function _luaK_checkstack(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i3 = (HEAPU8[i1 + 48 | 0] | 0) + i3 | 0;
+ i4 = (HEAP32[i1 >> 2] | 0) + 78 | 0;
+ if ((i3 | 0) <= (HEAPU8[i4] | 0 | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ if ((i3 | 0) > 249) {
+ _luaX_syntaxerror(HEAP32[i1 + 12 >> 2] | 0, 10536);
+ }
+ HEAP8[i4] = i3;
+ STACKTOP = i2;
+ return;
+}
+function _io_read(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ _lua_getfield(i1, -1001e3, 2776);
+ i3 = _lua_touserdata(i1, -1) | 0;
+ if ((HEAP32[i3 + 4 >> 2] | 0) == 0) {
+ HEAP32[i4 >> 2] = 2780;
+ _luaL_error(i1, 3424, i4) | 0;
+ }
+ i4 = _g_read(i1, HEAP32[i3 >> 2] | 0, 1) | 0;
+ STACKTOP = i2;
+ return i4 | 0;
+}
+function _db_setupvalue(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ _luaL_checkany(i1, 3);
+ i3 = _luaL_checkinteger(i1, 2) | 0;
+ _luaL_checktype(i1, 1, 6);
+ i3 = _lua_setupvalue(i1, 1, i3) | 0;
+ if ((i3 | 0) == 0) {
+ i3 = 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ _lua_pushstring(i1, i3) | 0;
+ _lua_insert(i1, -1);
+ i3 = 1;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function ___uflow(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i1;
+ if ((HEAP32[i2 + 8 >> 2] | 0) == 0 ? (___toread(i2) | 0) != 0 : 0) {
+ i2 = -1;
+ } else {
+ if ((FUNCTION_TABLE_iiii[HEAP32[i2 + 32 >> 2] & 3](i2, i3, 1) | 0) == 1) {
+ i2 = HEAPU8[i3] | 0;
+ } else {
+ i2 = -1;
+ }
+ }
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _llvm_cttz_i32(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = HEAP8[cttz_i8 + (i1 & 255) | 0] | 0;
+ if ((i2 | 0) < 8) return i2 | 0;
+ i2 = HEAP8[cttz_i8 + (i1 >> 8 & 255) | 0] | 0;
+ if ((i2 | 0) < 8) return i2 + 8 | 0;
+ i2 = HEAP8[cttz_i8 + (i1 >> 16 & 255) | 0] | 0;
+ if ((i2 | 0) < 8) return i2 + 16 | 0;
+ return (HEAP8[cttz_i8 + (i1 >>> 24) | 0] | 0) + 24 | 0;
+}
+function _llvm_ctlz_i32(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = HEAP8[ctlz_i8 + (i1 >>> 24) | 0] | 0;
+ if ((i2 | 0) < 8) return i2 | 0;
+ i2 = HEAP8[ctlz_i8 + (i1 >> 16 & 255) | 0] | 0;
+ if ((i2 | 0) < 8) return i2 + 8 | 0;
+ i2 = HEAP8[ctlz_i8 + (i1 >> 8 & 255) | 0] | 0;
+ if ((i2 | 0) < 8) return i2 + 16 | 0;
+ return (HEAP8[ctlz_i8 + (i1 & 255) | 0] | 0) + 24 | 0;
+}
+function _luaO_ceillog2(i2) {
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i4 = 0;
+ i1 = STACKTOP;
+ i2 = i2 + -1 | 0;
+ if (i2 >>> 0 > 255) {
+ i3 = 0;
+ while (1) {
+ i3 = i3 + 8 | 0;
+ i4 = i2 >>> 8;
+ if (i2 >>> 0 > 65535) {
+ i2 = i4;
+ } else {
+ i2 = i4;
+ break;
+ }
+ }
+ } else {
+ i3 = 0;
+ }
+ STACKTOP = i1;
+ return (HEAPU8[5208 + i2 | 0] | 0) + i3 | 0;
+}
+function _os_exit(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ if ((_lua_type(i1, 1) | 0) == 1) {
+ i3 = (_lua_toboolean(i1, 1) | 0) == 0 | 0;
+ } else {
+ i3 = _luaL_optinteger(i1, 1, 0) | 0;
+ }
+ if ((_lua_toboolean(i1, 2) | 0) != 0) {
+ _lua_close(i1);
+ }
+ if ((i1 | 0) == 0) {
+ STACKTOP = i2;
+ return 0;
+ } else {
+ _exit(i3 | 0);
+ }
+ return 0;
+}
+function _luaL_newmetatable(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_getfield(i1, -1001e3, i3);
+ if ((_lua_type(i1, -1) | 0) != 0) {
+ i3 = 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ _lua_settop(i1, -2);
+ _lua_createtable(i1, 0, 0);
+ _lua_pushvalue(i1, -1);
+ _lua_setfield(i1, -1001e3, i3);
+ i3 = 1;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _luaH_free(i1, i4) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = HEAP32[i4 + 16 >> 2] | 0;
+ if ((i3 | 0) != 8016) {
+ _luaM_realloc_(i1, i3, 32 << (HEAPU8[i4 + 7 | 0] | 0), 0) | 0;
+ }
+ _luaM_realloc_(i1, HEAP32[i4 + 12 >> 2] | 0, HEAP32[i4 + 28 >> 2] << 4, 0) | 0;
+ _luaM_realloc_(i1, i4, 32, 0) | 0;
+ STACKTOP = i2;
+ return;
+}
+function _luaO_int2fb(i3) {
+ i3 = i3 | 0;
+ var i1 = 0, i2 = 0, i4 = 0;
+ i1 = STACKTOP;
+ if (i3 >>> 0 < 8) {
+ STACKTOP = i1;
+ return i3 | 0;
+ }
+ if (i3 >>> 0 > 15) {
+ i2 = 1;
+ do {
+ i4 = i3 + 1 | 0;
+ i3 = i4 >>> 1;
+ i2 = i2 + 1 | 0;
+ } while (i4 >>> 0 > 31);
+ i2 = i2 << 3;
+ } else {
+ i2 = 8;
+ }
+ i4 = i2 | i3 + -8;
+ STACKTOP = i1;
+ return i4 | 0;
+}
+function _luaK_codek(i3, i4, i1) {
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i4 = i4 << 6;
+ if ((i1 | 0) < 262144) {
+ i4 = _luaK_code(i3, i4 | i1 << 14 | 1) | 0;
+ STACKTOP = i2;
+ return i4 | 0;
+ } else {
+ i4 = _luaK_code(i3, i4 | 2) | 0;
+ _luaK_code(i3, i1 << 6 | 39) | 0;
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ return 0;
+}
+function _luaB_xpcall(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _lua_gettop(i1) | 0;
+ if ((i3 | 0) <= 1) {
+ _luaL_argerror(i1, 2, 9616) | 0;
+ }
+ _lua_pushvalue(i1, 1);
+ _lua_copy(i1, 2, 1);
+ _lua_replace(i1, 2);
+ i3 = _finishpcall(i1, (_lua_pcallk(i1, i3 + -2 | 0, -1, 1, 0, 166) | 0) == 0 | 0) | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _luaS_newudata(i1, i3, i4) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if (i3 >>> 0 > 4294967269) {
+ _luaM_toobig(i1);
+ } else {
+ i1 = _luaC_newobj(i1, 7, i3 + 24 | 0, 0, 0) | 0;
+ HEAP32[i1 + 16 >> 2] = i3;
+ HEAP32[i1 + 8 >> 2] = 0;
+ HEAP32[i1 + 12 >> 2] = i4;
+ STACKTOP = i2;
+ return i1 | 0;
+ }
+ return 0;
+}
+function _lua_dump(i1, i4, i5) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = HEAP32[i1 + 8 >> 2] | 0;
+ if ((HEAP32[i3 + -8 >> 2] | 0) != 70) {
+ i5 = 1;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ i5 = _luaU_dump(i1, HEAP32[(HEAP32[i3 + -16 >> 2] | 0) + 12 >> 2] | 0, i4, i5, 0) | 0;
+ STACKTOP = i2;
+ return i5 | 0;
+}
+function _luaS_eqlngstr(i2, i4) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i3 = 0;
+ i1 = STACKTOP;
+ i3 = HEAP32[i2 + 12 >> 2] | 0;
+ if ((i2 | 0) != (i4 | 0)) {
+ if ((i3 | 0) == (HEAP32[i4 + 12 >> 2] | 0)) {
+ i2 = (_memcmp(i2 + 16 | 0, i4 + 16 | 0, i3) | 0) == 0;
+ } else {
+ i2 = 0;
+ }
+ } else {
+ i2 = 1;
+ }
+ STACKTOP = i1;
+ return i2 & 1 | 0;
+}
+function _luaC_barrier_(i4, i3, i1) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i4 = HEAP32[i4 + 12 >> 2] | 0;
+ if ((HEAPU8[i4 + 61 | 0] | 0) < 2) {
+ _reallymarkobject(i4, i1);
+ STACKTOP = i2;
+ return;
+ } else {
+ i3 = i3 + 5 | 0;
+ HEAP8[i3] = HEAP8[i4 + 60 | 0] & 3 | HEAP8[i3] & 184;
+ STACKTOP = i2;
+ return;
+ }
+}
+function _db_getupvalue(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _luaL_checkinteger(i1, 2) | 0;
+ _luaL_checktype(i1, 1, 6);
+ i3 = _lua_getupvalue(i1, 1, i3) | 0;
+ if ((i3 | 0) == 0) {
+ i3 = 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ _lua_pushstring(i1, i3) | 0;
+ _lua_insert(i1, -2);
+ i3 = 2;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _os_execute(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i4 = _luaL_optlstring(i1, 1, 0, 0) | 0;
+ i3 = _system(i4 | 0) | 0;
+ if ((i4 | 0) == 0) {
+ _lua_pushboolean(i1, i3);
+ i4 = 1;
+ STACKTOP = i2;
+ return i4 | 0;
+ } else {
+ i4 = _luaL_execresult(i1, i3) | 0;
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ return 0;
+}
+function _lua_pushfstring(i4, i5, i1) {
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ if ((HEAP32[(HEAP32[i4 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ _luaC_step(i4);
+ }
+ HEAP32[i3 >> 2] = i1;
+ i5 = _luaO_pushvfstring(i4, i5, i3) | 0;
+ STACKTOP = i2;
+ return i5 | 0;
+}
+function _luaB_dofile(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _luaL_optlstring(i1, 1, 0, 0) | 0;
+ _lua_settop(i1, 1);
+ if ((_luaL_loadfilex(i1, i3, 0) | 0) == 0) {
+ _lua_callk(i1, 0, -1, 0, 164);
+ i3 = (_lua_gettop(i1) | 0) + -1 | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ } else {
+ _lua_error(i1) | 0;
+ }
+ return 0;
+}
+function _f_write(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = _luaL_checkudata(i1, 1, 2832) | 0;
+ if ((HEAP32[i3 + 4 >> 2] | 0) == 0) {
+ _luaL_error(i1, 3080, i2) | 0;
+ }
+ i3 = HEAP32[i3 >> 2] | 0;
+ _lua_pushvalue(i1, 1);
+ i3 = _g_write(i1, i3, 2) | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _lua_getctx(i3, i1) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i3 = HEAP32[i3 + 16 >> 2] | 0;
+ if ((HEAP8[i3 + 18 | 0] & 8) == 0) {
+ i3 = 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ if ((i1 | 0) != 0) {
+ HEAP32[i1 >> 2] = HEAP32[i3 + 24 >> 2];
+ }
+ i3 = HEAPU8[i3 + 37 | 0] | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _f_flush(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = _luaL_checkudata(i1, 1, 2832) | 0;
+ if ((HEAP32[i3 + 4 >> 2] | 0) == 0) {
+ _luaL_error(i1, 3080, i2) | 0;
+ }
+ i3 = _luaL_fileresult(i1, (_fflush(HEAP32[i3 >> 2] | 0) | 0) == 0 | 0, 0) | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _os_tmpname(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i3 = i2 + 4 | 0;
+ if ((_tmpnam(i3 | 0) | 0) == 0) {
+ i3 = _luaL_error(i1, 5824, i2) | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+ } else {
+ _lua_pushstring(i1, i3) | 0;
+ i3 = 1;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ return 0;
+}
+function _traceback(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _lua_tolstring(i1, 1, 0) | 0;
+ if ((i3 | 0) == 0) {
+ if ((_lua_type(i1, 1) | 0) >= 1 ? (_luaL_callmeta(i1, 1, 216) | 0) == 0 : 0) {
+ _lua_pushlstring(i1, 232, 18) | 0;
+ }
+ } else {
+ _luaL_traceback(i1, i1, i3, 1);
+ }
+ STACKTOP = i2;
+ return 1;
+}
+function _luaH_new(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i1 = _luaC_newobj(i1, 5, 32, 0, 0) | 0;
+ HEAP32[i1 + 8 >> 2] = 0;
+ HEAP8[i1 + 6 | 0] = -1;
+ HEAP32[i1 + 12 >> 2] = 0;
+ HEAP32[i1 + 28 >> 2] = 0;
+ HEAP32[i1 + 16 >> 2] = 8016;
+ HEAP8[i1 + 7 | 0] = 0;
+ HEAP32[i1 + 20 >> 2] = 8016;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _luaL_len(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2 + 4 | 0;
+ _lua_len(i1, i3);
+ i3 = _lua_tointegerx(i1, -1, i4) | 0;
+ if ((HEAP32[i4 >> 2] | 0) == 0) {
+ _luaL_error(i1, 1352, i2) | 0;
+ }
+ _lua_settop(i1, -2);
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _getS(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0, i5 = 0;
+ i3 = STACKTOP;
+ i5 = i2 + 4 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ i5 = 0;
+ STACKTOP = i3;
+ return i5 | 0;
+ }
+ HEAP32[i1 >> 2] = i4;
+ HEAP32[i5 >> 2] = 0;
+ i5 = HEAP32[i2 >> 2] | 0;
+ STACKTOP = i3;
+ return i5 | 0;
+}
+function _luaC_runtilstate(i1, i4) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = (HEAP32[i1 + 12 >> 2] | 0) + 61 | 0;
+ if ((1 << (HEAPU8[i3] | 0) & i4 | 0) != 0) {
+ STACKTOP = i2;
+ return;
+ }
+ do {
+ _singlestep(i1) | 0;
+ } while ((1 << (HEAPU8[i3] | 0) & i4 | 0) == 0);
+ STACKTOP = i2;
+ return;
+}
+function _luaX_init(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ i3 = 0;
+ do {
+ i4 = _luaS_new(i1, HEAP32[12096 + (i3 << 2) >> 2] | 0) | 0;
+ i5 = i4 + 5 | 0;
+ HEAP8[i5] = HEAPU8[i5] | 0 | 32;
+ i3 = i3 + 1 | 0;
+ HEAP8[i4 + 6 | 0] = i3;
+ } while ((i3 | 0) != 22);
+ STACKTOP = i2;
+ return;
+}
+function _luaK_indexed(i5, i1, i4) {
+ i5 = i5 | 0;
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i3 = 0;
+ i3 = STACKTOP;
+ i2 = i1 + 8 | 0;
+ HEAP8[i2 + 2 | 0] = HEAP32[i2 >> 2];
+ HEAP16[i2 >> 1] = _luaK_exp2RK(i5, i4) | 0;
+ HEAP8[i2 + 3 | 0] = (HEAP32[i1 >> 2] | 0) == 8 ? 8 : 7;
+ HEAP32[i1 >> 2] = 9;
+ STACKTOP = i3;
+ return;
+}
+function _db_setuservalue(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((_lua_type(i1, 1) | 0) == 2) {
+ _luaL_argerror(i1, 1, 11680) | 0;
+ }
+ _luaL_checktype(i1, 1, 7);
+ if ((_lua_type(i1, 2) | 0) >= 1) {
+ _luaL_checktype(i1, 2, 5);
+ }
+ _lua_settop(i1, 2);
+ _lua_setuservalue(i1, 1);
+ STACKTOP = i2;
+ return 1;
+}
+function _ll_seeall(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_checktype(i1, 1, 5);
+ if ((_lua_getmetatable(i1, 1) | 0) == 0) {
+ _lua_createtable(i1, 0, 1);
+ _lua_pushvalue(i1, -1);
+ _lua_setmetatable(i1, 1) | 0;
+ }
+ _lua_rawgeti(i1, -1001e3, 2);
+ _lua_setfield(i1, -2, 5168);
+ STACKTOP = i2;
+ return 0;
+}
+function _luaL_loadbufferx(i3, i5, i4, i2, i1) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i6 = 0, i7 = 0;
+ i6 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i7 = i6;
+ HEAP32[i7 >> 2] = i5;
+ HEAP32[i7 + 4 >> 2] = i4;
+ i5 = _lua_load(i3, 2, i7, i2, i1) | 0;
+ STACKTOP = i6;
+ return i5 | 0;
+}
+function _luaT_gettm(i1, i3, i4) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i4 = _luaH_getstr(i1, i4) | 0;
+ if ((HEAP32[i4 + 8 >> 2] | 0) != 0) {
+ STACKTOP = i2;
+ return i4 | 0;
+ }
+ i4 = i1 + 6 | 0;
+ HEAP8[i4] = HEAPU8[i4] | 0 | 1 << i3;
+ i4 = 0;
+ STACKTOP = i2;
+ return i4 | 0;
+}
+function _luaL_pushresult(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = HEAP32[i1 + 12 >> 2] | 0;
+ _lua_pushlstring(i3, HEAP32[i1 >> 2] | 0, HEAP32[i1 + 8 >> 2] | 0) | 0;
+ if ((HEAP32[i1 >> 2] | 0) == (i1 + 16 | 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ _lua_remove(i3, -2);
+ STACKTOP = i2;
+ return;
+}
+function _resume_error(i1, i3, i2) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i4 = 0;
+ i4 = i1 + 8 | 0;
+ HEAP32[i4 >> 2] = i2;
+ i3 = _luaS_new(i1, i3) | 0;
+ HEAP32[i2 >> 2] = i3;
+ HEAP32[i2 + 8 >> 2] = HEAPU8[i3 + 4 | 0] | 0 | 64;
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + 16;
+ _luaD_throw(i1, -1);
+}
+function _lua_absindex(i3, i1) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((i1 + 1000999 | 0) >>> 0 > 1000999) {
+ i3 = i1;
+ STACKTOP = i2;
+ return i3 | 0;
+ }
+ i3 = ((HEAP32[i3 + 8 >> 2] | 0) - (HEAP32[HEAP32[i3 + 16 >> 2] >> 2] | 0) >> 4) + i1 | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function ___uremdi3(i4, i3, i2, i1) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i5 = 0, i6 = 0;
+ i6 = STACKTOP;
+ STACKTOP = STACKTOP + 8 | 0;
+ i5 = i6 | 0;
+ ___udivmoddi4(i4, i3, i2, i1, i5) | 0;
+ STACKTOP = i6;
+ return (tempRet0 = HEAP32[i5 + 4 >> 2] | 0, HEAP32[i5 >> 2] | 0) | 0;
+}
+function _f_read(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = _luaL_checkudata(i1, 1, 2832) | 0;
+ if ((HEAP32[i3 + 4 >> 2] | 0) == 0) {
+ _luaL_error(i1, 3080, i2) | 0;
+ }
+ i3 = _g_read(i1, HEAP32[i3 >> 2] | 0, 2) | 0;
+ STACKTOP = i2;
+ return i3 | 0;
+}
+function _sort(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ _luaL_checktype(i1, 1, 5);
+ i3 = _luaL_len(i1, 1) | 0;
+ _luaL_checkstack(i1, 40, 8208);
+ if ((_lua_type(i1, 2) | 0) >= 1) {
+ _luaL_checktype(i1, 2, 6);
+ }
+ _lua_settop(i1, 2);
+ _auxsort(i1, 1, i3);
+ STACKTOP = i2;
+ return 0;
+}
+function _luaB_error(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = _luaL_optinteger(i1, 2, 1) | 0;
+ _lua_settop(i1, 1);
+ if (!((_lua_isstring(i1, 1) | 0) != 0 & (i2 | 0) > 0)) {
+ _lua_error(i1) | 0;
+ }
+ _luaL_where(i1, i2);
+ _lua_pushvalue(i1, 1);
+ _lua_concat(i1, 2);
+ _lua_error(i1) | 0;
+ return 0;
+}
+function _error(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = HEAP32[i1 >> 2] | 0;
+ HEAP32[i3 >> 2] = HEAP32[i1 + 12 >> 2];
+ HEAP32[i3 + 4 >> 2] = i2;
+ _luaO_pushfstring(i4, 8840, i3) | 0;
+ _luaD_throw(HEAP32[i1 >> 2] | 0, 3);
+}
+function _ipairsaux(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _luaL_checkinteger(i1, 2) | 0;
+ _luaL_checktype(i1, 1, 5);
+ i3 = i3 + 1 | 0;
+ _lua_pushinteger(i1, i3);
+ _lua_rawgeti(i1, 1, i3);
+ i1 = (_lua_type(i1, -1) | 0) == 0;
+ STACKTOP = i2;
+ return (i1 ? 1 : 2) | 0;
+}
+function _panic(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ i3 = HEAP32[_stderr >> 2] | 0;
+ HEAP32[i4 >> 2] = _lua_tolstring(i1, -1, 0) | 0;
+ _fprintf(i3 | 0, 1656, i4 | 0) | 0;
+ _fflush(i3 | 0) | 0;
+ STACKTOP = i2;
+ return 0;
+}
+function _testSetjmp(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0;
+ while ((i3 | 0) < 20) {
+ i4 = HEAP32[i2 + (i3 << 2) >> 2] | 0;
+ if ((i4 | 0) == 0) break;
+ if ((i4 | 0) == (i1 | 0)) {
+ return HEAP32[i2 + ((i3 << 2) + 4) >> 2] | 0;
+ }
+ i3 = i3 + 2 | 0;
+ }
+ return 0;
+}
+function _luaopen_math(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_createtable(i1, 0, 28);
+ _luaL_setfuncs(i1, 3576, 0);
+ _lua_pushnumber(i1, 3.141592653589793);
+ _lua_setfield(i1, -2, 3808);
+ _lua_pushnumber(i1, inf);
+ _lua_setfield(i1, -2, 3816);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaopen_base(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_rawgeti(i1, -1001e3, 2);
+ _lua_rawgeti(i1, -1001e3, 2);
+ _lua_setfield(i1, -2, 9144);
+ _luaL_setfuncs(i1, 9152, 0);
+ _lua_pushlstring(i1, 9344, 7) | 0;
+ _lua_setfield(i1, -2, 9352);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaE_extendCI(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i3 = STACKTOP;
+ i2 = _luaM_realloc_(i1, 0, 0, 40) | 0;
+ i1 = i1 + 16 | 0;
+ HEAP32[(HEAP32[i1 >> 2] | 0) + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = HEAP32[i1 >> 2];
+ HEAP32[i2 + 12 >> 2] = 0;
+ STACKTOP = i3;
+ return i2 | 0;
+}
+function _luaB_getmetatable(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_checkany(i1, 1);
+ if ((_lua_getmetatable(i1, 1) | 0) == 0) {
+ _lua_pushnil(i1);
+ STACKTOP = i2;
+ return 1;
+ } else {
+ _luaL_getmetafield(i1, 1, 9704) | 0;
+ STACKTOP = i2;
+ return 1;
+ }
+ return 0;
+}
+function _lua_pushunsigned(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var d3 = 0.0;
+ if ((i2 | 0) > -1) {
+ d3 = +(i2 | 0);
+ } else {
+ d3 = +(i2 >>> 0);
+ }
+ i2 = i1 + 8 | 0;
+ i1 = HEAP32[i2 >> 2] | 0;
+ HEAPF64[i1 >> 3] = d3;
+ HEAP32[i1 + 8 >> 2] = 3;
+ HEAP32[i2 >> 2] = i1 + 16;
+ return;
+}
+function _lua_pushthread(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = i1 + 8 | 0;
+ i3 = HEAP32[i2 >> 2] | 0;
+ HEAP32[i3 >> 2] = i1;
+ HEAP32[i3 + 8 >> 2] = 72;
+ HEAP32[i2 >> 2] = (HEAP32[i2 >> 2] | 0) + 16;
+ return (HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 172 >> 2] | 0) == (i1 | 0) | 0;
+}
+function _gctm(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _luaL_len(i1, 1) | 0;
+ if ((i3 | 0) <= 0) {
+ STACKTOP = i2;
+ return 0;
+ }
+ do {
+ _lua_rawgeti(i1, 1, i3);
+ _lua_settop(i1, -2);
+ i3 = i3 + -1 | 0;
+ } while ((i3 | 0) > 0);
+ STACKTOP = i2;
+ return 0;
+}
+function ___muldi3(i4, i2, i3, i1) {
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i5 = 0, i6 = 0;
+ i5 = i4;
+ i6 = i3;
+ i4 = ___muldsi3(i5, i6) | 0;
+ i3 = tempRet0;
+ return (tempRet0 = (Math_imul(i2, i6) | 0) + (Math_imul(i1, i5) | 0) + i3 | i3 & 0, i4 | 0 | 0) | 0;
+}
+function _luaH_resizearray(i1, i3, i4) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i5 = 0;
+ i2 = STACKTOP;
+ if ((HEAP32[i3 + 16 >> 2] | 0) == 8016) {
+ i5 = 0;
+ } else {
+ i5 = 1 << (HEAPU8[i3 + 7 | 0] | 0);
+ }
+ _luaH_resize(i1, i3, i4, i5);
+ STACKTOP = i2;
+ return;
+}
+function _luaK_stringK(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i3;
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i4 + 8 >> 2] = HEAPU8[i2 + 4 | 0] | 0 | 64;
+ i2 = _addk(i1, i4, i4) | 0;
+ STACKTOP = i3;
+ return i2 | 0;
+}
+function _math_modf(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, d3 = 0.0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i2;
+ d3 = +_modf(+(+_luaL_checknumber(i1, 1)), i4 | 0);
+ _lua_pushnumber(i1, +HEAPF64[i4 >> 3]);
+ _lua_pushnumber(i1, d3);
+ STACKTOP = i2;
+ return 2;
+}
+function _os_setlocale(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _luaL_optlstring(i1, 1, 0, 0) | 0;
+ _lua_pushstring(i1, _setlocale(HEAP32[5960 + ((_luaL_checkoption(i1, 2, 6016, 5984) | 0) << 2) >> 2] | 0, i3 | 0) | 0) | 0;
+ STACKTOP = i2;
+ return 1;
+}
+function _luaB_pcall(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_checkany(i1, 1);
+ _lua_pushnil(i1);
+ _lua_insert(i1, 1);
+ i1 = _finishpcall(i1, (_lua_pcallk(i1, (_lua_gettop(i1) | 0) + -2 | 0, -1, 0, 0, 166) | 0) == 0 | 0) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _error_expected(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0, i4 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = HEAP32[i1 + 52 >> 2] | 0;
+ HEAP32[i3 >> 2] = _luaX_token2str(i1, i2) | 0;
+ _luaX_syntaxerror(i1, _luaO_pushfstring(i4, 6328, i3) | 0);
+}
+function _lua_pushvfstring(i1, i3, i4) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 12 >> 2] | 0) > 0) {
+ _luaC_step(i1);
+ }
+ i4 = _luaO_pushvfstring(i1, i3, i4) | 0;
+ STACKTOP = i2;
+ return i4 | 0;
+}
+function _db_setmetatable(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _lua_type(i1, 2) | 0;
+ if (!((i3 | 0) == 0 | (i3 | 0) == 5)) {
+ _luaL_argerror(i1, 2, 11536) | 0;
+ }
+ _lua_settop(i1, 2);
+ _lua_setmetatable(i1, 1) | 0;
+ STACKTOP = i2;
+ return 1;
+}
+function _b_rrot(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i3 = 0 - (_luaL_checkinteger(i1, 2) | 0) | 0;
+ i4 = _luaL_checkunsigned(i1, 1) | 0;
+ i3 = i3 & 31;
+ _lua_pushunsigned(i1, i4 >>> (32 - i3 | 0) | i4 << i3);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaC_step(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = HEAP32[i1 + 12 >> 2] | 0;
+ if ((HEAP8[i3 + 63 | 0] | 0) == 0) {
+ _luaE_setdebt(i3, -1600);
+ STACKTOP = i2;
+ return;
+ } else {
+ _luaC_forcestep(i1);
+ STACKTOP = i2;
+ return;
+ }
+}
+function _math_frexp(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ _lua_pushnumber(i1, +_frexp(+(+_luaL_checknumber(i1, 1)), i3 | 0));
+ _lua_pushinteger(i1, HEAP32[i3 >> 2] | 0);
+ STACKTOP = i2;
+ return 2;
+}
+function _luaO_pushfstring(i2, i1, i3) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i4 = 0, i5 = 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i5 = i4;
+ HEAP32[i5 >> 2] = i3;
+ i3 = _luaO_pushvfstring(i2, i1, i5) | 0;
+ STACKTOP = i4;
+ return i3 | 0;
+}
+function _luaO_hexavalue(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((HEAP8[i1 + 10913 | 0] & 2) == 0) {
+ i1 = (i1 | 32) + -87 | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+ } else {
+ i1 = i1 + -48 | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+ }
+ return 0;
+}
+function _b_lrot(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ i3 = _luaL_checkinteger(i1, 2) | 0;
+ i4 = _luaL_checkunsigned(i1, 1) | 0;
+ i3 = i3 & 31;
+ _lua_pushunsigned(i1, i4 >>> (32 - i3 | 0) | i4 << i3);
+ STACKTOP = i2;
+ return 1;
+}
+function _f_lines(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ if ((HEAP32[(_luaL_checkudata(i1, 1, 2832) | 0) + 4 >> 2] | 0) == 0) {
+ _luaL_error(i1, 3080, i2) | 0;
+ }
+ _aux_lines(i1, 0);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaC_barrierback_(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i2 = HEAP32[i2 + 12 >> 2] | 0;
+ i3 = i1 + 5 | 0;
+ HEAP8[i3] = HEAP8[i3] & 251;
+ i2 = i2 + 88 | 0;
+ HEAP32[i1 + 24 >> 2] = HEAP32[i2 >> 2];
+ HEAP32[i2 >> 2] = i1;
+ return;
+}
+function _os_rename(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _luaL_checklstring(i1, 1, 0) | 0;
+ i1 = _luaL_fileresult(i1, (_rename(i3 | 0, _luaL_checklstring(i1, 2, 0) | 0) | 0) == 0 | 0, 0) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _bitshift64Ashr(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ if ((i1 | 0) < 32) {
+ tempRet0 = i2 >> i1;
+ return i3 >>> i1 | (i2 & (1 << i1) - 1) << 32 - i1;
+ }
+ tempRet0 = (i2 | 0) < 0 ? -1 : 0;
+ return i2 >> i1 - 32 | 0;
+}
+function _luaB_cowrap(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ _luaL_checktype(i1, 1, 6);
+ i3 = _lua_newthread(i1) | 0;
+ _lua_pushvalue(i1, 1);
+ _lua_xmove(i1, i3, 1);
+ _lua_pushcclosure(i1, 167, 1);
+ STACKTOP = i2;
+ return 1;
+}
+function _gmatch(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_checklstring(i1, 1, 0) | 0;
+ _luaL_checklstring(i1, 2, 0) | 0;
+ _lua_settop(i1, 2);
+ _lua_pushinteger(i1, 0);
+ _lua_pushcclosure(i1, 163, 3);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaB_next(i2) {
+ i2 = i2 | 0;
+ var i1 = 0;
+ i1 = STACKTOP;
+ _luaL_checktype(i2, 1, 5);
+ _lua_settop(i2, 2);
+ if ((_lua_next(i2, 1) | 0) == 0) {
+ _lua_pushnil(i2);
+ i2 = 1;
+ } else {
+ i2 = 2;
+ }
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _luaK_codeABC(i5, i3, i4, i2, i1) {
+ i5 = i5 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i6 = 0;
+ i6 = STACKTOP;
+ i5 = _luaK_code(i5, i4 << 6 | i3 | i2 << 23 | i1 << 14) | 0;
+ STACKTOP = i6;
+ return i5 | 0;
+}
+function _luaH_set(i2, i4, i5) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i3 = 0;
+ i1 = STACKTOP;
+ i3 = _luaH_get(i4, i5) | 0;
+ if ((i3 | 0) == 5192) {
+ i3 = _luaH_newkey(i2, i4, i5) | 0;
+ }
+ STACKTOP = i1;
+ return i3 | 0;
+}
+function _luaZ_init(i4, i1, i3, i2) {
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ HEAP32[i1 + 16 >> 2] = i4;
+ HEAP32[i1 + 8 >> 2] = i3;
+ HEAP32[i1 + 12 >> 2] = i2;
+ HEAP32[i1 >> 2] = 0;
+ HEAP32[i1 + 4 >> 2] = 0;
+ return;
+}
+function _lua_pushlightuserdata(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i2 = i2 + 8 | 0;
+ i3 = HEAP32[i2 >> 2] | 0;
+ HEAP32[i3 >> 2] = i1;
+ HEAP32[i3 + 8 >> 2] = 2;
+ HEAP32[i2 >> 2] = (HEAP32[i2 >> 2] | 0) + 16;
+ return;
+}
+function copyTempFloat(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+}
+function _bitshift64Shl(i2, i3, i1) {
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ if ((i1 | 0) < 32) {
+ tempRet0 = i3 << i1 | (i2 & (1 << i1) - 1 << 32 - i1) >>> 32 - i1;
+ return i2 << i1;
+ }
+ tempRet0 = i2 << i1 - 32;
+ return 0;
+}
+function _luaB_rawlen(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if (((_lua_type(i1, 1) | 0) & -2 | 0) != 4) {
+ _luaL_argerror(i1, 1, 9784) | 0;
+ }
+ _lua_pushinteger(i1, _lua_rawlen(i1, 1) | 0);
+ STACKTOP = i2;
+ return 1;
+}
+function _l_alloc(i3, i1, i4, i2) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i3 = STACKTOP;
+ if ((i2 | 0) == 0) {
+ _free(i1);
+ i1 = 0;
+ } else {
+ i1 = _realloc(i1, i2) | 0;
+ }
+ STACKTOP = i3;
+ return i1 | 0;
+}
+function _bitshift64Lshr(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ if ((i1 | 0) < 32) {
+ tempRet0 = i2 >>> i1;
+ return i3 >>> i1 | (i2 & (1 << i1) - 1) << 32 - i1;
+ }
+ tempRet0 = 0;
+ return i2 >>> i1 - 32 | 0;
+}
+function _luaG_aritherror(i3, i1, i2) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i4 = 0;
+ i4 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = (_luaV_tonumber(i1, i4) | 0) == 0;
+ _luaG_typeerror(i3, i4 ? i1 : i2, 1928);
+}
+function _str_len(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i3 = i2;
+ _luaL_checklstring(i1, 1, i3) | 0;
+ _lua_pushinteger(i1, HEAP32[i3 >> 2] | 0);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaL_optinteger(i3, i4, i2) {
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ var i1 = 0;
+ i1 = STACKTOP;
+ if ((_lua_type(i3, i4) | 0) >= 1) {
+ i2 = _luaL_checkinteger(i3, i4) | 0;
+ }
+ STACKTOP = i1;
+ return i2 | 0;
+}
+function _os_difftime(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = ~~+_luaL_checknumber(i1, 1);
+ _lua_pushnumber(i1, +_difftime(i3 | 0, ~~+_luaL_optnumber(i1, 2, 0.0) | 0));
+ STACKTOP = i2;
+ return 1;
+}
+function _lua_pushboolean(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i2 = i2 + 8 | 0;
+ i3 = HEAP32[i2 >> 2] | 0;
+ HEAP32[i3 >> 2] = (i1 | 0) != 0;
+ HEAP32[i3 + 8 >> 2] = 1;
+ HEAP32[i2 >> 2] = i3 + 16;
+ return;
+}
+function _os_remove(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = _luaL_checklstring(i1, 1, 0) | 0;
+ i1 = _luaL_fileresult(i1, (_remove(i3 | 0) | 0) == 0 | 0, i3) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _luaopen_table(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_createtable(i1, 0, 7);
+ _luaL_setfuncs(i1, 8088, 0);
+ _lua_getfield(i1, -1, 8152);
+ _lua_setglobal(i1, 8152);
+ STACKTOP = i2;
+ return 1;
+}
+function _lua_pushinteger(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i2 = i2 + 8 | 0;
+ i3 = HEAP32[i2 >> 2] | 0;
+ HEAPF64[i3 >> 3] = +(i1 | 0);
+ HEAP32[i3 + 8 >> 2] = 3;
+ HEAP32[i2 >> 2] = i3 + 16;
+ return;
+}
+function _luaB_rawset(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_checktype(i1, 1, 5);
+ _luaL_checkany(i1, 2);
+ _luaL_checkany(i1, 3);
+ _lua_settop(i1, 3);
+ _lua_rawset(i1, 1);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaE_setdebt(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = i2 + 12 | 0;
+ i2 = i2 + 8 | 0;
+ HEAP32[i2 >> 2] = (HEAP32[i3 >> 2] | 0) - i1 + (HEAP32[i2 >> 2] | 0);
+ HEAP32[i3 >> 2] = i1;
+ return;
+}
+function _luaB_cocreate(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ _luaL_checktype(i1, 1, 6);
+ i3 = _lua_newthread(i1) | 0;
+ _lua_pushvalue(i1, 1);
+ _lua_xmove(i1, i3, 1);
+ STACKTOP = i2;
+ return 1;
+}
+function _io_noclose(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ HEAP32[(_luaL_checkudata(i1, 1, 2832) | 0) + 4 >> 2] = 154;
+ _lua_pushnil(i1);
+ _lua_pushlstring(i1, 2840, 26) | 0;
+ STACKTOP = i2;
+ return 2;
+}
+function _io_fclose(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i1 = _luaL_fileresult(i1, (_fclose(HEAP32[(_luaL_checkudata(i1, 1, 2832) | 0) >> 2] | 0) | 0) == 0 | 0, 0) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _luaL_optnumber(i3, i4, d2) {
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ d2 = +d2;
+ var i1 = 0;
+ i1 = STACKTOP;
+ if ((_lua_type(i3, i4) | 0) >= 1) {
+ d2 = +_luaL_checknumber(i3, i4);
+ }
+ STACKTOP = i1;
+ return +d2;
+}
+function _math_atan2(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, d3 = 0.0;
+ i2 = STACKTOP;
+ d3 = +_luaL_checknumber(i1, 1);
+ _lua_pushnumber(i1, +Math_atan2(+d3, +(+_luaL_checknumber(i1, 2))));
+ STACKTOP = i2;
+ return 1;
+}
+function _luaK_codeABx(i4, i2, i3, i1) {
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ var i5 = 0;
+ i5 = STACKTOP;
+ i4 = _luaK_code(i4, i3 << 6 | i2 | i1 << 14) | 0;
+ STACKTOP = i5;
+ return i4 | 0;
+}
+function _luaF_newCclosure(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ i2 = _luaC_newobj(i2, 38, (i1 << 4) + 16 | 0, 0, 0) | 0;
+ HEAP8[i2 + 6 | 0] = i1;
+ STACKTOP = i3;
+ return i2 | 0;
+}
+function _math_pow(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, d3 = 0.0;
+ i2 = STACKTOP;
+ d3 = +_luaL_checknumber(i1, 1);
+ _lua_pushnumber(i1, +Math_pow(+d3, +(+_luaL_checknumber(i1, 2))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_ldexp(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, d3 = 0.0;
+ i2 = STACKTOP;
+ d3 = +_luaL_checknumber(i1, 1);
+ _lua_pushnumber(i1, +_ldexp(d3, _luaL_checkinteger(i1, 2) | 0));
+ STACKTOP = i2;
+ return 1;
+}
+function _luaF_newupval(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i1 = _luaC_newobj(i1, 10, 32, 0, 0) | 0;
+ HEAP32[i1 + 8 >> 2] = i1 + 16;
+ HEAP32[i1 + 24 >> 2] = 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _lua_pushnumber(i2, d1) {
+ i2 = i2 | 0;
+ d1 = +d1;
+ var i3 = 0;
+ i2 = i2 + 8 | 0;
+ i3 = HEAP32[i2 >> 2] | 0;
+ HEAPF64[i3 >> 3] = d1;
+ HEAP32[i3 + 8 >> 2] = 3;
+ HEAP32[i2 >> 2] = i3 + 16;
+ return;
+}
+function _math_fmod(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, d3 = 0.0;
+ i2 = STACKTOP;
+ d3 = +_luaL_checknumber(i1, 1);
+ _lua_pushnumber(i1, +_fmod(+d3, +(+_luaL_checknumber(i1, 2))));
+ STACKTOP = i2;
+ return 1;
+}
+function _luaG_concaterror(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ i4 = HEAP32[i2 + 8 >> 2] | 0;
+ _luaG_typeerror(i3, (i4 & 15 | 0) == 4 | (i4 | 0) == 3 ? i1 : i2, 1912);
+}
+function _luaB_rawequal(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_checkany(i1, 1);
+ _luaL_checkany(i1, 2);
+ _lua_pushboolean(i1, _lua_rawequal(i1, 1, 2) | 0);
+ STACKTOP = i2;
+ return 1;
+}
+function _db_getuservalue(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((_lua_type(i1, 1) | 0) == 7) {
+ _lua_getuservalue(i1, 1);
+ } else {
+ _lua_pushnil(i1);
+ }
+ STACKTOP = i2;
+ return 1;
+}
+function _strchr(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ i2 = ___strchrnul(i2, i1) | 0;
+ STACKTOP = i3;
+ return ((HEAP8[i2] | 0) == (i1 & 255) << 24 >> 24 ? i2 : 0) | 0;
+}
+function runPostSets() {}
+function _rand_r(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = (Math_imul(HEAP32[i1 >> 2] | 0, 31010991) | 0) + 1735287159 & 2147483647;
+ HEAP32[i1 >> 2] = i2;
+ return i2 | 0;
+}
+function _luaL_checkany(i1, i3) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ if ((_lua_type(i1, i3) | 0) == -1) {
+ _luaL_argerror(i1, i3, 1256) | 0;
+ }
+ STACKTOP = i2;
+ return;
+}
+function _i64Subtract(i2, i4, i1, i3) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 - i3 - (i1 >>> 0 > i2 >>> 0 | 0) >>> 0;
+ return (tempRet0 = i4, i2 - i1 >>> 0 | 0) | 0;
+}
+function _db_getmetatable(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_checkany(i1, 1);
+ if ((_lua_getmetatable(i1, 1) | 0) == 0) {
+ _lua_pushnil(i1);
+ }
+ STACKTOP = i2;
+ return 1;
+}
+function _luaB_rawget(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_checktype(i1, 1, 5);
+ _luaL_checkany(i1, 2);
+ _lua_settop(i1, 2);
+ _lua_rawget(i1, 1);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaB_type(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_checkany(i1, 1);
+ _lua_pushstring(i1, _lua_typename(i1, _lua_type(i1, 1) | 0) | 0) | 0;
+ STACKTOP = i2;
+ return 1;
+}
+function dynCall_iiiii(i5, i4, i3, i2, i1) {
+ i5 = i5 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ return FUNCTION_TABLE_iiiii[i5 & 3](i4 | 0, i3 | 0, i2 | 0, i1 | 0) | 0;
+}
+function _lstop(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ _lua_sethook(i1, 0, 0, 0) | 0;
+ _luaL_error(i1, 200, i2) | 0;
+ STACKTOP = i2;
+ return;
+}
+function _i64Add(i1, i3, i4, i2) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i4 = i1 + i4 >>> 0;
+ return (tempRet0 = i3 + i2 + (i4 >>> 0 < i1 >>> 0 | 0) >>> 0, i4 | 0) | 0;
+}
+function _luaK_ret(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ i4 = STACKTOP;
+ _luaK_code(i3, i2 << 6 | (i1 << 23) + 8388608 | 31) | 0;
+ STACKTOP = i4;
+ return;
+}
+function _strpbrk(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ i1 = i2 + (_strcspn(i2, i1) | 0) | 0;
+ STACKTOP = i3;
+ return ((HEAP8[i1] | 0) != 0 ? i1 : 0) | 0;
+}
+function _luaL_setmetatable(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ _lua_getfield(i1, -1001e3, i2);
+ _lua_setmetatable(i1, -2) | 0;
+ STACKTOP = i3;
+ return;
+}
+function _lua_atpanic(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = (HEAP32[i2 + 12 >> 2] | 0) + 168 | 0;
+ i2 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i3 >> 2] = i1;
+ return i2 | 0;
+}
+function _luaL_newstate() {
+ var i1 = 0, i2 = 0;
+ i2 = STACKTOP;
+ i1 = _lua_newstate(1, 0) | 0;
+ if ((i1 | 0) != 0) {
+ _lua_atpanic(i1, 143) | 0;
+ }
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _luaL_buffinit(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ HEAP32[i1 + 12 >> 2] = i2;
+ HEAP32[i1 >> 2] = i1 + 16;
+ HEAP32[i1 + 8 >> 2] = 0;
+ HEAP32[i1 + 4 >> 2] = 1024;
+ return;
+}
+function _strrchr(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ i2 = ___memrchr(i1, i2, (_strlen(i1 | 0) | 0) + 1 | 0) | 0;
+ STACKTOP = i3;
+ return i2 | 0;
+}
+function _luaK_fixline(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ HEAP32[(HEAP32[(HEAP32[i1 >> 2] | 0) + 20 >> 2] | 0) + ((HEAP32[i1 + 20 >> 2] | 0) + -1 << 2) >> 2] = i2;
+ return;
+}
+function _luaX_lookahead(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i3 = STACKTOP;
+ i2 = _llex(i1, i1 + 40 | 0) | 0;
+ HEAP32[i1 + 32 >> 2] = i2;
+ STACKTOP = i3;
+ return i2 | 0;
+}
+function _f_call(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ _luaD_call(i2, HEAP32[i1 >> 2] | 0, HEAP32[i1 + 4 >> 2] | 0, 0);
+ STACKTOP = i3;
+ return;
+}
+function _io_pclose(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_checkudata(i1, 1, 2832) | 0;
+ i1 = _luaL_execresult(i1, -1) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _luaS_new(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ i2 = _luaS_newlstr(i2, i1, _strlen(i1 | 0) | 0) | 0;
+ STACKTOP = i3;
+ return i2 | 0;
+}
+function _os_getenv(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushstring(i1, _getenv(_luaL_checklstring(i1, 1, 0) | 0) | 0) | 0;
+ STACKTOP = i2;
+ return 1;
+}
+function _math_rad(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +_luaL_checknumber(i1, 1) * .017453292519943295);
+ STACKTOP = i2;
+ return 1;
+}
+function _math_deg(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +_luaL_checknumber(i1, 1) / .017453292519943295);
+ STACKTOP = i2;
+ return 1;
+}
+function _writer(i4, i2, i1, i3) {
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = STACKTOP;
+ _luaL_addlstring(i3, i2, i1);
+ STACKTOP = i4;
+ return 0;
+}
+function _luaL_addstring(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ _luaL_addlstring(i2, i1, _strlen(i1 | 0) | 0);
+ STACKTOP = i3;
+ return;
+}
+function _pcallcont(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i1 = _finishpcall(i1, (_lua_getctx(i1, 0) | 0) == 1 | 0) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _luaopen_coroutine(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_createtable(i1, 0, 6);
+ _luaL_setfuncs(i1, 10656, 0);
+ STACKTOP = i2;
+ return 1;
+}
+function _lua_version(i1) {
+ i1 = i1 | 0;
+ if ((i1 | 0) == 0) {
+ i1 = 920;
+ } else {
+ i1 = HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 176 >> 2] | 0;
+ }
+ return i1 | 0;
+}
+function _lua_pushnil(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i1 = i1 + 8 | 0;
+ i2 = HEAP32[i1 >> 2] | 0;
+ HEAP32[i2 + 8 >> 2] = 0;
+ HEAP32[i1 >> 2] = i2 + 16;
+ return;
+}
+function _math_floor(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +Math_floor(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _laction(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _signal(i1 | 0, 0) | 0;
+ _lua_sethook(HEAP32[48] | 0, 1, 11, 1) | 0;
+ STACKTOP = i2;
+ return;
+}
+function dynCall_iiii(i4, i3, i2, i1) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ return FUNCTION_TABLE_iiii[i4 & 3](i3 | 0, i2 | 0, i1 | 0) | 0;
+}
+function _luaopen_debug(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_createtable(i1, 0, 16);
+ _luaL_setfuncs(i1, 11176, 0);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaopen_bit32(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_createtable(i1, 0, 12);
+ _luaL_setfuncs(i1, 10240, 0);
+ STACKTOP = i2;
+ return 1;
+}
+function _math_sqrt(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +Math_sqrt(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_ceil(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +Math_ceil(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_atan(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +Math_atan(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_asin(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +Math_asin(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_acos(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +Math_acos(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _lua_close(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _close_state(HEAP32[(HEAP32[i1 + 12 >> 2] | 0) + 172 >> 2] | 0);
+ STACKTOP = i2;
+ return;
+}
+function _dothecall(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i2 = STACKTOP;
+ _luaD_call(i1, (HEAP32[i1 + 8 >> 2] | 0) + -32 | 0, 0, 0);
+ STACKTOP = i2;
+ return;
+}
+function _math_tan(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +Math_tan(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_sin(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +Math_sin(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_log10(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +_log10(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_exp(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +Math_exp(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_cos(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +Math_cos(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_abs(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +Math_abs(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_randomseed(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _srand(_luaL_checkunsigned(i1, 1) | 0);
+ _rand() | 0;
+ STACKTOP = i2;
+ return 0;
+}
+function _luaopen_os(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_createtable(i1, 0, 11);
+ _luaL_setfuncs(i1, 5624, 0);
+ STACKTOP = i2;
+ return 1;
+}
+function _math_tanh(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +_tanh(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_sinh(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +_sinh(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _math_cosh(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +_cosh(+(+_luaL_checknumber(i1, 1))));
+ STACKTOP = i2;
+ return 1;
+}
+function _luaB_yield(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i1 = _lua_yieldk(i1, _lua_gettop(i1) | 0, 0, 0) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _luaB_tostring(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _luaL_checkany(i1, 1);
+ _luaL_tolstring(i1, 1, 0) | 0;
+ STACKTOP = i2;
+ return 1;
+}
+function _growstack(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ _luaD_growstack(i2, HEAP32[i1 >> 2] | 0);
+ STACKTOP = i3;
+ return;
+}
+function ___udivdi3(i4, i3, i2, i1) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ i4 = ___udivmoddi4(i4, i3, i2, i1, 0) | 0;
+ return i4 | 0;
+}
+function _b_not(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushunsigned(i1, ~(_luaL_checkunsigned(i1, 1) | 0));
+ STACKTOP = i2;
+ return 1;
+}
+function _luaO_fb2int(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = i1 >>> 3 & 31;
+ if ((i2 | 0) != 0) {
+ i1 = (i1 & 7 | 8) << i2 + -1;
+ }
+ return i1 | 0;
+}
+function _luaB_corunning(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushboolean(i1, _lua_pushthread(i1) | 0);
+ STACKTOP = i2;
+ return 2;
+}
+function stackAlloc(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + i1 | 0;
+ STACKTOP = STACKTOP + 7 & -8;
+ return i2 | 0;
+}
+function _strcoll(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ i2 = _strcmp(i2, i1) | 0;
+ STACKTOP = i3;
+ return i2 | 0;
+}
+function _os_clock(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushnumber(i1, +(_clock() | 0) / 1.0e6);
+ STACKTOP = i2;
+ return 1;
+}
+function _dofilecont(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i1 = (_lua_gettop(i1) | 0) + -1 | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _scalbnl(d2, i1) {
+ d2 = +d2;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ d2 = +_scalbn(d2, i1);
+ STACKTOP = i3;
+ return +d2;
+}
+function _tolower(i1) {
+ i1 = i1 | 0;
+ if ((i1 | 0) < 65) return i1 | 0;
+ if ((i1 | 0) > 90) return i1 | 0;
+ return i1 - 65 + 97 | 0;
+}
+function _lua_gettop(i1) {
+ i1 = i1 | 0;
+ return (HEAP32[i1 + 8 >> 2] | 0) - ((HEAP32[HEAP32[i1 + 16 >> 2] >> 2] | 0) + 16) >> 4 | 0;
+}
+function dynCall_iii(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ return FUNCTION_TABLE_iii[i3 & 1](i2 | 0, i1 | 0) | 0;
+}
+function _str_match(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i1 = _str_find_aux(i1, 0) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _luaM_toobig(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ _luaG_runerror(i1, 4144, i2);
+}
+function _luaK_getlabel(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = HEAP32[i1 + 20 >> 2] | 0;
+ HEAP32[i1 + 24 >> 2] = i2;
+ return i2 | 0;
+}
+function _ldexp(d2, i1) {
+ d2 = +d2;
+ i1 = i1 | 0;
+ var i3 = 0;
+ i3 = STACKTOP;
+ d2 = +_scalbn(d2, i1);
+ STACKTOP = i3;
+ return +d2;
+}
+function _str_find(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ i1 = _str_find_aux(i1, 1) | 0;
+ STACKTOP = i2;
+ return i1 | 0;
+}
+function _db_getregistry(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _lua_pushvalue(i1, -1001e3);
+ STACKTOP = i2;
+ return 1;
+}
+function _luaB_ipairs(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _pairsmeta(i1, 9960, 1, 165);
+ STACKTOP = i2;
+ return 3;
+}
+function _strlen(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = i1;
+ while (HEAP8[i2] | 0) {
+ i2 = i2 + 1 | 0;
+ }
+ return i2 - i1 | 0;
+}
+function _luaB_pairs(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _pairsmeta(i1, 9864, 0, 93);
+ STACKTOP = i2;
+ return 3;
+}
+function setThrew(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ if ((__THREW__ | 0) == 0) {
+ __THREW__ = i1;
+ threwValue = i2;
+ }
+}
+function _io_output(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _g_iofile(i1, 2800, 3512);
+ STACKTOP = i2;
+ return 1;
+}
+function dynCall_vii(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ FUNCTION_TABLE_vii[i3 & 15](i2 | 0, i1 | 0);
+}
+function _io_input(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ _g_iofile(i1, 2776, 3480);
+ STACKTOP = i2;
+ return 1;
+}
+function _semerror(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ HEAP32[i2 + 16 >> 2] = 0;
+ _luaX_syntaxerror(i2, i1);
+}
+function _luaX_syntaxerror(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ _lexerror(i1, i2, HEAP32[i1 + 16 >> 2] | 0);
+}
+function b4(i1, i2, i3, i4) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ abort(4);
+ return 0;
+}
+function _lua_typename(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ return HEAP32[8528 + (i1 + 1 << 2) >> 2] | 0;
+}
+function dynCall_ii(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ return FUNCTION_TABLE_ii[i2 & 255](i1 | 0) | 0;
+}
+function dynCall_vi(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ FUNCTION_TABLE_vi[i2 & 1](i1 | 0);
+}
+function b0(i1, i2, i3) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ abort(0);
+ return 0;
+}
+function _lua_gethookmask(i1) {
+ i1 = i1 | 0;
+ return HEAPU8[i1 + 40 | 0] | 0 | 0;
+}
+function _lua_gethookcount(i1) {
+ i1 = i1 | 0;
+ return HEAP32[i1 + 44 >> 2] | 0;
+}
+function _lua_status(i1) {
+ i1 = i1 | 0;
+ return HEAPU8[i1 + 6 | 0] | 0 | 0;
+}
+function _lua_gethook(i1) {
+ i1 = i1 | 0;
+ return HEAP32[i1 + 52 >> 2] | 0;
+}
+function b5(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ abort(5);
+ return 0;
+}
+function _lua_error(i1) {
+ i1 = i1 | 0;
+ _luaG_errormsg(i1);
+ return 0;
+}
+function b2(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ abort(2);
+}
+function stackRestore(i1) {
+ i1 = i1 | 0;
+ STACKTOP = i1;
+}
+function setTempRet9(i1) {
+ i1 = i1 | 0;
+ tempRet9 = i1;
+}
+function setTempRet8(i1) {
+ i1 = i1 | 0;
+ tempRet8 = i1;
+}
+function setTempRet7(i1) {
+ i1 = i1 | 0;
+ tempRet7 = i1;
+}
+function setTempRet6(i1) {
+ i1 = i1 | 0;
+ tempRet6 = i1;
+}
+function setTempRet5(i1) {
+ i1 = i1 | 0;
+ tempRet5 = i1;
+}
+function setTempRet4(i1) {
+ i1 = i1 | 0;
+ tempRet4 = i1;
+}
+function setTempRet3(i1) {
+ i1 = i1 | 0;
+ tempRet3 = i1;
+}
+function setTempRet2(i1) {
+ i1 = i1 | 0;
+ tempRet2 = i1;
+}
+function setTempRet1(i1) {
+ i1 = i1 | 0;
+ tempRet1 = i1;
+}
+function setTempRet0(i1) {
+ i1 = i1 | 0;
+ tempRet0 = i1;
+}
+function b3(i1) {
+ i1 = i1 | 0;
+ abort(3);
+ return 0;
+}
+function _rand() {
+ return _rand_r(___rand_seed) | 0;
+}
+function stackSave() {
+ return STACKTOP | 0;
+}
+function b1(i1) {
+ i1 = i1 | 0;
+ abort(1);
+}
+
+// EMSCRIPTEN_END_FUNCS
+ var FUNCTION_TABLE_iiii = [b0,_getF,_getS,_generic_reader];
+ var FUNCTION_TABLE_vi = [b1,_laction];
+ var FUNCTION_TABLE_vii = [b2,_lstop,_growstack,_f_call,_resume,_unroll,_f_parser,_dothecall,_f_luaopen,_hookf,b2,b2,b2,b2,b2,b2];
+ var FUNCTION_TABLE_ii = [b3,_io_close,_io_flush,_io_input,_io_lines,_io_open,_io_output,_io_popen,_io_read,_io_tmpfile,_io_type,_io_write,_f_flush,_f_lines,_f_read,_f_seek,_f_setvbuf,_f_write,_f_gc,_f_tostring,_math_abs,_math_acos,_math_asin,_math_atan2,_math_atan,_math_ceil,_math_cosh,_math_cos,_math_deg
+ ,_math_exp,_math_floor,_math_fmod,_math_frexp,_math_ldexp,_math_log10,_math_log,_math_max,_math_min,_math_modf,_math_pow,_math_rad,_math_random,_math_randomseed,_math_sinh,_math_sin,_math_sqrt,_math_tanh,_math_tan,_ll_loadlib,_ll_searchpath,_ll_seeall,_ll_module,_ll_require,_os_clock,_os_date,_os_difftime,_os_execute,_os_exit,_os_getenv
+ ,_os_remove,_os_rename,_os_setlocale,_os_time,_os_tmpname,_str_byte,_str_char,_str_dump,_str_find,_str_format,_gmatch,_str_gsub,_str_len,_str_lower,_str_match,_str_rep,_str_reverse,_str_sub,_str_upper,_tconcat,_maxn,_tinsert,_pack,_unpack,_tremove,_sort,_luaB_assert,_luaB_collectgarbage,_luaB_dofile,_luaB_error
+ ,_luaB_getmetatable,_luaB_ipairs,_luaB_loadfile,_luaB_load,_luaB_next,_luaB_pairs,_luaB_pcall,_luaB_print,_luaB_rawequal,_luaB_rawlen,_luaB_rawget,_luaB_rawset,_luaB_select,_luaB_setmetatable,_luaB_tonumber,_luaB_tostring,_luaB_type,_luaB_xpcall,_b_arshift,_b_and,_b_not,_b_or,_b_xor,_b_test,_b_extract,_b_lrot,_b_lshift,_b_replace,_b_rrot,_b_rshift
+ ,_luaB_cocreate,_luaB_coresume,_luaB_corunning,_luaB_costatus,_luaB_cowrap,_luaB_yield,_db_debug,_db_getuservalue,_db_gethook,_db_getinfo,_db_getlocal,_db_getregistry,_db_getmetatable,_db_getupvalue,_db_upvaluejoin,_db_upvalueid,_db_setuservalue,_db_sethook,_db_setlocal,_db_setmetatable,_db_setupvalue,_db_traceback,_pmain,_traceback,_panic,_luaopen_base,_luaopen_package,_luaopen_coroutine,_luaopen_table,_luaopen_io
+ ,_luaopen_os,_luaopen_string,_luaopen_bit32,_luaopen_math,_luaopen_debug,_io_noclose,_io_readline,_io_fclose,_io_pclose,_gctm,_searcher_preload,_searcher_Lua,_searcher_C,_searcher_Croot,_gmatch_aux,_dofilecont,_ipairsaux,_pcallcont,_luaB_auxwrap,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3
+ ,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3
+ ,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3
+ ,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3,b3];
+ var FUNCTION_TABLE_iiiii = [b4,_l_alloc,_writer,b4];
+ var FUNCTION_TABLE_iii = [b5,_lua_newstate];
+
+ return { _testSetjmp: _testSetjmp, _i64Subtract: _i64Subtract, _free: _free, _main: _main, _rand_r: _rand_r, _realloc: _realloc, _i64Add: _i64Add, _tolower: _tolower, _saveSetjmp: _saveSetjmp, _memset: _memset, _malloc: _malloc, _memcpy: _memcpy, _strlen: _strlen, _rand: _rand, _bitshift64Shl: _bitshift64Shl, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, setThrew: setThrew, setTempRet0: setTempRet0, setTempRet1: setTempRet1, setTempRet2: setTempRet2, setTempRet3: setTempRet3, setTempRet4: setTempRet4, setTempRet5: setTempRet5, setTempRet6: setTempRet6, setTempRet7: setTempRet7, setTempRet8: setTempRet8, setTempRet9: setTempRet9, dynCall_iiii: dynCall_iiii, dynCall_vi: dynCall_vi, dynCall_vii: dynCall_vii, dynCall_ii: dynCall_ii, dynCall_iiiii: dynCall_iiiii, dynCall_iii: dynCall_iii };
+})
+// EMSCRIPTEN_END_ASM
+({ "Math": Math, "Int8Array": Int8Array, "Int16Array": Int16Array, "Int32Array": Int32Array, "Uint8Array": Uint8Array, "Uint16Array": Uint16Array, "Uint32Array": Uint32Array, "Float32Array": Float32Array, "Float64Array": Float64Array }, { "abort": abort, "assert": assert, "asmPrintInt": asmPrintInt, "asmPrintFloat": asmPrintFloat, "min": Math_min, "invoke_iiii": invoke_iiii, "invoke_vi": invoke_vi, "invoke_vii": invoke_vii, "invoke_ii": invoke_ii, "invoke_iiiii": invoke_iiiii, "invoke_iii": invoke_iii, "_isalnum": _isalnum, "_fabs": _fabs, "_frexp": _frexp, "_exp": _exp, "_fread": _fread, "__reallyNegative": __reallyNegative, "_longjmp": _longjmp, "__addDays": __addDays, "_fsync": _fsync, "_signal": _signal, "_rename": _rename, "_sbrk": _sbrk, "_emscripten_memcpy_big": _emscripten_memcpy_big, "_sinh": _sinh, "_sysconf": _sysconf, "_close": _close, "_ferror": _ferror, "_clock": _clock, "_cos": _cos, "_tanh": _tanh, "_unlink": _unlink, "_write": _write, "__isLeapYear": __isLeapYear, "_ftell": _ftell, "_isupper": _isupper, "_gmtime_r": _gmtime_r, "_islower": _islower, "_tmpnam": _tmpnam, "_tmpfile": _tmpfile, "_send": _send, "_abort": _abort, "_setvbuf": _setvbuf, "_atan2": _atan2, "_setlocale": _setlocale, "_isgraph": _isgraph, "_modf": _modf, "_strerror_r": _strerror_r, "_fscanf": _fscanf, "___setErrNo": ___setErrNo, "_isalpha": _isalpha, "_srand": _srand, "_mktime": _mktime, "_putchar": _putchar, "_gmtime": _gmtime, "_localeconv": _localeconv, "_sprintf": _sprintf, "_localtime": _localtime, "_read": _read, "_fwrite": _fwrite, "_time": _time, "_fprintf": _fprintf, "_exit": _exit, "_freopen": _freopen, "_llvm_pow_f64": _llvm_pow_f64, "_fgetc": _fgetc, "_fmod": _fmod, "_lseek": _lseek, "_rmdir": _rmdir, "_asin": _asin, "_floor": _floor, "_pwrite": _pwrite, "_localtime_r": _localtime_r, "_tzset": _tzset, "_open": _open, "_remove": _remove, "_snprintf": _snprintf, "__scanString": __scanString, "_strftime": _strftime, "_fseek": _fseek, "_iscntrl": _iscntrl, "_isxdigit": _isxdigit, "_fclose": _fclose, "_log": _log, "_recv": _recv, "_tan": _tan, "_copysign": _copysign, "__getFloat": __getFloat, "_fputc": _fputc, "_ispunct": _ispunct, "_ceil": _ceil, "_isspace": _isspace, "_fopen": _fopen, "_sin": _sin, "_acos": _acos, "_cosh": _cosh, "___buildEnvironment": ___buildEnvironment, "_difftime": _difftime, "_ungetc": _ungetc, "_system": _system, "_fflush": _fflush, "_log10": _log10, "_fileno": _fileno, "__exit": __exit, "__arraySum": __arraySum, "_fgets": _fgets, "_atan": _atan, "_pread": _pread, "_mkport": _mkport, "_toupper": _toupper, "_feof": _feof, "___errno_location": ___errno_location, "_clearerr": _clearerr, "_getenv": _getenv, "_strerror": _strerror, "_emscripten_longjmp": _emscripten_longjmp, "__formatString": __formatString, "_fputs": _fputs, "_sqrt": _sqrt, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX, "tempDoublePtr": tempDoublePtr, "ABORT": ABORT, "cttz_i8": cttz_i8, "ctlz_i8": ctlz_i8, "___rand_seed": ___rand_seed, "NaN": NaN, "Infinity": Infinity, "_stderr": _stderr, "_stdin": _stdin, "_stdout": _stdout }, buffer);
+var _testSetjmp = Module["_testSetjmp"] = asm["_testSetjmp"];
+var _i64Subtract = Module["_i64Subtract"] = asm["_i64Subtract"];
+var _free = Module["_free"] = asm["_free"];
+var _main = Module["_main"] = asm["_main"];
+var _rand_r = Module["_rand_r"] = asm["_rand_r"];
+var _realloc = Module["_realloc"] = asm["_realloc"];
+var _i64Add = Module["_i64Add"] = asm["_i64Add"];
+var _tolower = Module["_tolower"] = asm["_tolower"];
+var _saveSetjmp = Module["_saveSetjmp"] = asm["_saveSetjmp"];
+var _memset = Module["_memset"] = asm["_memset"];
+var _malloc = Module["_malloc"] = asm["_malloc"];
+var _memcpy = Module["_memcpy"] = asm["_memcpy"];
+var _strlen = Module["_strlen"] = asm["_strlen"];
+var _rand = Module["_rand"] = asm["_rand"];
+var _bitshift64Shl = Module["_bitshift64Shl"] = asm["_bitshift64Shl"];
+var runPostSets = Module["runPostSets"] = asm["runPostSets"];
+var dynCall_iiii = Module["dynCall_iiii"] = asm["dynCall_iiii"];
+var dynCall_vi = Module["dynCall_vi"] = asm["dynCall_vi"];
+var dynCall_vii = Module["dynCall_vii"] = asm["dynCall_vii"];
+var dynCall_ii = Module["dynCall_ii"] = asm["dynCall_ii"];
+var dynCall_iiiii = Module["dynCall_iiiii"] = asm["dynCall_iiiii"];
+var dynCall_iii = Module["dynCall_iii"] = asm["dynCall_iii"];
+
+Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
+Runtime.stackSave = function() { return asm['stackSave']() };
+Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
+
+
+// TODO: strip out parts of this we do not need
+
+//======= begin closure i64 code =======
+
+// Copyright 2009 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Defines a Long class for representing a 64-bit two's-complement
+ * integer value, which faithfully simulates the behavior of a Java "long". This
+ * implementation is derived from LongLib in GWT.
+ *
+ */
+
+var i64Math = (function() { // Emscripten wrapper
+ var goog = { math: {} };
+
+
+ /**
+ * Constructs a 64-bit two's-complement integer, given its low and high 32-bit
+ * values as *signed* integers. See the from* functions below for more
+ * convenient ways of constructing Longs.
+ *
+ * The internal representation of a long is the two given signed, 32-bit values.
+ * We use 32-bit pieces because these are the size of integers on which
+ * Javascript performs bit-operations. For operations like addition and
+ * multiplication, we split each number into 16-bit pieces, which can easily be
+ * multiplied within Javascript's floating-point representation without overflow
+ * or change in sign.
+ *
+ * In the algorithms below, we frequently reduce the negative case to the
+ * positive case by negating the input(s) and then post-processing the result.
+ * Note that we must ALWAYS check specially whether those values are MIN_VALUE
+ * (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
+ * a positive number, it overflows back into a negative). Not handling this
+ * case would often result in infinite recursion.
+ *
+ * @param {number} low The low (signed) 32 bits of the long.
+ * @param {number} high The high (signed) 32 bits of the long.
+ * @constructor
+ */
+ goog.math.Long = function(low, high) {
+ /**
+ * @type {number}
+ * @private
+ */
+ this.low_ = low | 0; // force into 32 signed bits.
+
+ /**
+ * @type {number}
+ * @private
+ */
+ this.high_ = high | 0; // force into 32 signed bits.
+ };
+
+
+ // NOTE: Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the
+ // from* methods on which they depend.
+
+
+ /**
+ * A cache of the Long representations of small integer values.
+ * @type {!Object}
+ * @private
+ */
+ goog.math.Long.IntCache_ = {};
+
+
+ /**
+ * Returns a Long representing the given (32-bit) integer value.
+ * @param {number} value The 32-bit integer in question.
+ * @return {!goog.math.Long} The corresponding Long value.
+ */
+ goog.math.Long.fromInt = function(value) {
+ if (-128 <= value && value < 128) {
+ var cachedObj = goog.math.Long.IntCache_[value];
+ if (cachedObj) {
+ return cachedObj;
+ }
+ }
+
+ var obj = new goog.math.Long(value | 0, value < 0 ? -1 : 0);
+ if (-128 <= value && value < 128) {
+ goog.math.Long.IntCache_[value] = obj;
+ }
+ return obj;
+ };
+
+
+ /**
+ * Returns a Long representing the given value, provided that it is a finite
+ * number. Otherwise, zero is returned.
+ * @param {number} value The number in question.
+ * @return {!goog.math.Long} The corresponding Long value.
+ */
+ goog.math.Long.fromNumber = function(value) {
+ if (isNaN(value) || !isFinite(value)) {
+ return goog.math.Long.ZERO;
+ } else if (value <= -goog.math.Long.TWO_PWR_63_DBL_) {
+ return goog.math.Long.MIN_VALUE;
+ } else if (value + 1 >= goog.math.Long.TWO_PWR_63_DBL_) {
+ return goog.math.Long.MAX_VALUE;
+ } else if (value < 0) {
+ return goog.math.Long.fromNumber(-value).negate();
+ } else {
+ return new goog.math.Long(
+ (value % goog.math.Long.TWO_PWR_32_DBL_) | 0,
+ (value / goog.math.Long.TWO_PWR_32_DBL_) | 0);
+ }
+ };
+
+
+ /**
+ * Returns a Long representing the 64-bit integer that comes by concatenating
+ * the given high and low bits. Each is assumed to use 32 bits.
+ * @param {number} lowBits The low 32-bits.
+ * @param {number} highBits The high 32-bits.
+ * @return {!goog.math.Long} The corresponding Long value.
+ */
+ goog.math.Long.fromBits = function(lowBits, highBits) {
+ return new goog.math.Long(lowBits, highBits);
+ };
+
+
+ /**
+ * Returns a Long representation of the given string, written using the given
+ * radix.
+ * @param {string} str The textual representation of the Long.
+ * @param {number=} opt_radix The radix in which the text is written.
+ * @return {!goog.math.Long} The corresponding Long value.
+ */
+ goog.math.Long.fromString = function(str, opt_radix) {
+ if (str.length == 0) {
+ throw Error('number format error: empty string');
+ }
+
+ var radix = opt_radix || 10;
+ if (radix < 2 || 36 < radix) {
+ throw Error('radix out of range: ' + radix);
+ }
+
+ if (str.charAt(0) == '-') {
+ return goog.math.Long.fromString(str.substring(1), radix).negate();
+ } else if (str.indexOf('-') >= 0) {
+ throw Error('number format error: interior "-" character: ' + str);
+ }
+
+ // Do several (8) digits each time through the loop, so as to
+ // minimize the calls to the very expensive emulated div.
+ var radixToPower = goog.math.Long.fromNumber(Math.pow(radix, 8));
+
+ var result = goog.math.Long.ZERO;
+ for (var i = 0; i < str.length; i += 8) {
+ var size = Math.min(8, str.length - i);
+ var value = parseInt(str.substring(i, i + size), radix);
+ if (size < 8) {
+ var power = goog.math.Long.fromNumber(Math.pow(radix, size));
+ result = result.multiply(power).add(goog.math.Long.fromNumber(value));
+ } else {
+ result = result.multiply(radixToPower);
+ result = result.add(goog.math.Long.fromNumber(value));
+ }
+ }
+ return result;
+ };
+
+
+ // NOTE: the compiler should inline these constant values below and then remove
+ // these variables, so there should be no runtime penalty for these.
+
+
+ /**
+ * Number used repeated below in calculations. This must appear before the
+ * first call to any from* function below.
+ * @type {number}
+ * @private
+ */
+ goog.math.Long.TWO_PWR_16_DBL_ = 1 << 16;
+
+
+ /**
+ * @type {number}
+ * @private
+ */
+ goog.math.Long.TWO_PWR_24_DBL_ = 1 << 24;
+
+
+ /**
+ * @type {number}
+ * @private
+ */
+ goog.math.Long.TWO_PWR_32_DBL_ =
+ goog.math.Long.TWO_PWR_16_DBL_ * goog.math.Long.TWO_PWR_16_DBL_;
+
+
+ /**
+ * @type {number}
+ * @private
+ */
+ goog.math.Long.TWO_PWR_31_DBL_ =
+ goog.math.Long.TWO_PWR_32_DBL_ / 2;
+
+
+ /**
+ * @type {number}
+ * @private
+ */
+ goog.math.Long.TWO_PWR_48_DBL_ =
+ goog.math.Long.TWO_PWR_32_DBL_ * goog.math.Long.TWO_PWR_16_DBL_;
+
+
+ /**
+ * @type {number}
+ * @private
+ */
+ goog.math.Long.TWO_PWR_64_DBL_ =
+ goog.math.Long.TWO_PWR_32_DBL_ * goog.math.Long.TWO_PWR_32_DBL_;
+
+
+ /**
+ * @type {number}
+ * @private
+ */
+ goog.math.Long.TWO_PWR_63_DBL_ =
+ goog.math.Long.TWO_PWR_64_DBL_ / 2;
+
+
+ /** @type {!goog.math.Long} */
+ goog.math.Long.ZERO = goog.math.Long.fromInt(0);
+
+
+ /** @type {!goog.math.Long} */
+ goog.math.Long.ONE = goog.math.Long.fromInt(1);
+
+
+ /** @type {!goog.math.Long} */
+ goog.math.Long.NEG_ONE = goog.math.Long.fromInt(-1);
+
+
+ /** @type {!goog.math.Long} */
+ goog.math.Long.MAX_VALUE =
+ goog.math.Long.fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0);
+
+
+ /** @type {!goog.math.Long} */
+ goog.math.Long.MIN_VALUE = goog.math.Long.fromBits(0, 0x80000000 | 0);
+
+
+ /**
+ * @type {!goog.math.Long}
+ * @private
+ */
+ goog.math.Long.TWO_PWR_24_ = goog.math.Long.fromInt(1 << 24);
+
+
+ /** @return {number} The value, assuming it is a 32-bit integer. */
+ goog.math.Long.prototype.toInt = function() {
+ return this.low_;
+ };
+
+
+ /** @return {number} The closest floating-point representation to this value. */
+ goog.math.Long.prototype.toNumber = function() {
+ return this.high_ * goog.math.Long.TWO_PWR_32_DBL_ +
+ this.getLowBitsUnsigned();
+ };
+
+
+ /**
+ * @param {number=} opt_radix The radix in which the text should be written.
+ * @return {string} The textual representation of this value.
+ */
+ goog.math.Long.prototype.toString = function(opt_radix) {
+ var radix = opt_radix || 10;
+ if (radix < 2 || 36 < radix) {
+ throw Error('radix out of range: ' + radix);
+ }
+
+ if (this.isZero()) {
+ return '0';
+ }
+
+ if (this.isNegative()) {
+ if (this.equals(goog.math.Long.MIN_VALUE)) {
+ // We need to change the Long value before it can be negated, so we remove
+ // the bottom-most digit in this base and then recurse to do the rest.
+ var radixLong = goog.math.Long.fromNumber(radix);
+ var div = this.div(radixLong);
+ var rem = div.multiply(radixLong).subtract(this);
+ return div.toString(radix) + rem.toInt().toString(radix);
+ } else {
+ return '-' + this.negate().toString(radix);
+ }
+ }
+
+ // Do several (6) digits each time through the loop, so as to
+ // minimize the calls to the very expensive emulated div.
+ var radixToPower = goog.math.Long.fromNumber(Math.pow(radix, 6));
+
+ var rem = this;
+ var result = '';
+ while (true) {
+ var remDiv = rem.div(radixToPower);
+ var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt();
+ var digits = intval.toString(radix);
+
+ rem = remDiv;
+ if (rem.isZero()) {
+ return digits + result;
+ } else {
+ while (digits.length < 6) {
+ digits = '0' + digits;
+ }
+ result = '' + digits + result;
+ }
+ }
+ };
+
+
+ /** @return {number} The high 32-bits as a signed value. */
+ goog.math.Long.prototype.getHighBits = function() {
+ return this.high_;
+ };
+
+
+ /** @return {number} The low 32-bits as a signed value. */
+ goog.math.Long.prototype.getLowBits = function() {
+ return this.low_;
+ };
+
+
+ /** @return {number} The low 32-bits as an unsigned value. */
+ goog.math.Long.prototype.getLowBitsUnsigned = function() {
+ return (this.low_ >= 0) ?
+ this.low_ : goog.math.Long.TWO_PWR_32_DBL_ + this.low_;
+ };
+
+
+ /**
+ * @return {number} Returns the number of bits needed to represent the absolute
+ * value of this Long.
+ */
+ goog.math.Long.prototype.getNumBitsAbs = function() {
+ if (this.isNegative()) {
+ if (this.equals(goog.math.Long.MIN_VALUE)) {
+ return 64;
+ } else {
+ return this.negate().getNumBitsAbs();
+ }
+ } else {
+ var val = this.high_ != 0 ? this.high_ : this.low_;
+ for (var bit = 31; bit > 0; bit--) {
+ if ((val & (1 << bit)) != 0) {
+ break;
+ }
+ }
+ return this.high_ != 0 ? bit + 33 : bit + 1;
+ }
+ };
+
+
+ /** @return {boolean} Whether this value is zero. */
+ goog.math.Long.prototype.isZero = function() {
+ return this.high_ == 0 && this.low_ == 0;
+ };
+
+
+ /** @return {boolean} Whether this value is negative. */
+ goog.math.Long.prototype.isNegative = function() {
+ return this.high_ < 0;
+ };
+
+
+ /** @return {boolean} Whether this value is odd. */
+ goog.math.Long.prototype.isOdd = function() {
+ return (this.low_ & 1) == 1;
+ };
+
+
+ /**
+ * @param {goog.math.Long} other Long to compare against.
+ * @return {boolean} Whether this Long equals the other.
+ */
+ goog.math.Long.prototype.equals = function(other) {
+ return (this.high_ == other.high_) && (this.low_ == other.low_);
+ };
+
+
+ /**
+ * @param {goog.math.Long} other Long to compare against.
+ * @return {boolean} Whether this Long does not equal the other.
+ */
+ goog.math.Long.prototype.notEquals = function(other) {
+ return (this.high_ != other.high_) || (this.low_ != other.low_);
+ };
+
+
+ /**
+ * @param {goog.math.Long} other Long to compare against.
+ * @return {boolean} Whether this Long is less than the other.
+ */
+ goog.math.Long.prototype.lessThan = function(other) {
+ return this.compare(other) < 0;
+ };
+
+
+ /**
+ * @param {goog.math.Long} other Long to compare against.
+ * @return {boolean} Whether this Long is less than or equal to the other.
+ */
+ goog.math.Long.prototype.lessThanOrEqual = function(other) {
+ return this.compare(other) <= 0;
+ };
+
+
+ /**
+ * @param {goog.math.Long} other Long to compare against.
+ * @return {boolean} Whether this Long is greater than the other.
+ */
+ goog.math.Long.prototype.greaterThan = function(other) {
+ return this.compare(other) > 0;
+ };
+
+
+ /**
+ * @param {goog.math.Long} other Long to compare against.
+ * @return {boolean} Whether this Long is greater than or equal to the other.
+ */
+ goog.math.Long.prototype.greaterThanOrEqual = function(other) {
+ return this.compare(other) >= 0;
+ };
+
+
+ /**
+ * Compares this Long with the given one.
+ * @param {goog.math.Long} other Long to compare against.
+ * @return {number} 0 if they are the same, 1 if the this is greater, and -1
+ * if the given one is greater.
+ */
+ goog.math.Long.prototype.compare = function(other) {
+ if (this.equals(other)) {
+ return 0;
+ }
+
+ var thisNeg = this.isNegative();
+ var otherNeg = other.isNegative();
+ if (thisNeg && !otherNeg) {
+ return -1;
+ }
+ if (!thisNeg && otherNeg) {
+ return 1;
+ }
+
+ // at this point, the signs are the same, so subtraction will not overflow
+ if (this.subtract(other).isNegative()) {
+ return -1;
+ } else {
+ return 1;
+ }
+ };
+
+
+ /** @return {!goog.math.Long} The negation of this value. */
+ goog.math.Long.prototype.negate = function() {
+ if (this.equals(goog.math.Long.MIN_VALUE)) {
+ return goog.math.Long.MIN_VALUE;
+ } else {
+ return this.not().add(goog.math.Long.ONE);
+ }
+ };
+
+
+ /**
+ * Returns the sum of this and the given Long.
+ * @param {goog.math.Long} other Long to add to this one.
+ * @return {!goog.math.Long} The sum of this and the given Long.
+ */
+ goog.math.Long.prototype.add = function(other) {
+ // Divide each number into 4 chunks of 16 bits, and then sum the chunks.
+
+ var a48 = this.high_ >>> 16;
+ var a32 = this.high_ & 0xFFFF;
+ var a16 = this.low_ >>> 16;
+ var a00 = this.low_ & 0xFFFF;
+
+ var b48 = other.high_ >>> 16;
+ var b32 = other.high_ & 0xFFFF;
+ var b16 = other.low_ >>> 16;
+ var b00 = other.low_ & 0xFFFF;
+
+ var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
+ c00 += a00 + b00;
+ c16 += c00 >>> 16;
+ c00 &= 0xFFFF;
+ c16 += a16 + b16;
+ c32 += c16 >>> 16;
+ c16 &= 0xFFFF;
+ c32 += a32 + b32;
+ c48 += c32 >>> 16;
+ c32 &= 0xFFFF;
+ c48 += a48 + b48;
+ c48 &= 0xFFFF;
+ return goog.math.Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32);
+ };
+
+
+ /**
+ * Returns the difference of this and the given Long.
+ * @param {goog.math.Long} other Long to subtract from this.
+ * @return {!goog.math.Long} The difference of this and the given Long.
+ */
+ goog.math.Long.prototype.subtract = function(other) {
+ return this.add(other.negate());
+ };
+
+
+ /**
+ * Returns the product of this and the given long.
+ * @param {goog.math.Long} other Long to multiply with this.
+ * @return {!goog.math.Long} The product of this and the other.
+ */
+ goog.math.Long.prototype.multiply = function(other) {
+ if (this.isZero()) {
+ return goog.math.Long.ZERO;
+ } else if (other.isZero()) {
+ return goog.math.Long.ZERO;
+ }
+
+ if (this.equals(goog.math.Long.MIN_VALUE)) {
+ return other.isOdd() ? goog.math.Long.MIN_VALUE : goog.math.Long.ZERO;
+ } else if (other.equals(goog.math.Long.MIN_VALUE)) {
+ return this.isOdd() ? goog.math.Long.MIN_VALUE : goog.math.Long.ZERO;
+ }
+
+ if (this.isNegative()) {
+ if (other.isNegative()) {
+ return this.negate().multiply(other.negate());
+ } else {
+ return this.negate().multiply(other).negate();
+ }
+ } else if (other.isNegative()) {
+ return this.multiply(other.negate()).negate();
+ }
+
+ // If both longs are small, use float multiplication
+ if (this.lessThan(goog.math.Long.TWO_PWR_24_) &&
+ other.lessThan(goog.math.Long.TWO_PWR_24_)) {
+ return goog.math.Long.fromNumber(this.toNumber() * other.toNumber());
+ }
+
+ // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.
+ // We can skip products that would overflow.
+
+ var a48 = this.high_ >>> 16;
+ var a32 = this.high_ & 0xFFFF;
+ var a16 = this.low_ >>> 16;
+ var a00 = this.low_ & 0xFFFF;
+
+ var b48 = other.high_ >>> 16;
+ var b32 = other.high_ & 0xFFFF;
+ var b16 = other.low_ >>> 16;
+ var b00 = other.low_ & 0xFFFF;
+
+ var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
+ c00 += a00 * b00;
+ c16 += c00 >>> 16;
+ c00 &= 0xFFFF;
+ c16 += a16 * b00;
+ c32 += c16 >>> 16;
+ c16 &= 0xFFFF;
+ c16 += a00 * b16;
+ c32 += c16 >>> 16;
+ c16 &= 0xFFFF;
+ c32 += a32 * b00;
+ c48 += c32 >>> 16;
+ c32 &= 0xFFFF;
+ c32 += a16 * b16;
+ c48 += c32 >>> 16;
+ c32 &= 0xFFFF;
+ c32 += a00 * b32;
+ c48 += c32 >>> 16;
+ c32 &= 0xFFFF;
+ c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
+ c48 &= 0xFFFF;
+ return goog.math.Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32);
+ };
+
+
+ /**
+ * Returns this Long divided by the given one.
+ * @param {goog.math.Long} other Long by which to divide.
+ * @return {!goog.math.Long} This Long divided by the given one.
+ */
+ goog.math.Long.prototype.div = function(other) {
+ if (other.isZero()) {
+ throw Error('division by zero');
+ } else if (this.isZero()) {
+ return goog.math.Long.ZERO;
+ }
+
+ if (this.equals(goog.math.Long.MIN_VALUE)) {
+ if (other.equals(goog.math.Long.ONE) ||
+ other.equals(goog.math.Long.NEG_ONE)) {
+ return goog.math.Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
+ } else if (other.equals(goog.math.Long.MIN_VALUE)) {
+ return goog.math.Long.ONE;
+ } else {
+ // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
+ var halfThis = this.shiftRight(1);
+ var approx = halfThis.div(other).shiftLeft(1);
+ if (approx.equals(goog.math.Long.ZERO)) {
+ return other.isNegative() ? goog.math.Long.ONE : goog.math.Long.NEG_ONE;
+ } else {
+ var rem = this.subtract(other.multiply(approx));
+ var result = approx.add(rem.div(other));
+ return result;
+ }
+ }
+ } else if (other.equals(goog.math.Long.MIN_VALUE)) {
+ return goog.math.Long.ZERO;
+ }
+
+ if (this.isNegative()) {
+ if (other.isNegative()) {
+ return this.negate().div(other.negate());
+ } else {
+ return this.negate().div(other).negate();
+ }
+ } else if (other.isNegative()) {
+ return this.div(other.negate()).negate();
+ }
+
+ // Repeat the following until the remainder is less than other: find a
+ // floating-point that approximates remainder / other *from below*, add this
+ // into the result, and subtract it from the remainder. It is critical that
+ // the approximate value is less than or equal to the real value so that the
+ // remainder never becomes negative.
+ var res = goog.math.Long.ZERO;
+ var rem = this;
+ while (rem.greaterThanOrEqual(other)) {
+ // Approximate the result of division. This may be a little greater or
+ // smaller than the actual value.
+ var approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber()));
+
+ // We will tweak the approximate result by changing it in the 48-th digit or
+ // the smallest non-fractional digit, whichever is larger.
+ var log2 = Math.ceil(Math.log(approx) / Math.LN2);
+ var delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48);
+
+ // Decrease the approximation until it is smaller than the remainder. Note
+ // that if it is too large, the product overflows and is negative.
+ var approxRes = goog.math.Long.fromNumber(approx);
+ var approxRem = approxRes.multiply(other);
+ while (approxRem.isNegative() || approxRem.greaterThan(rem)) {
+ approx -= delta;
+ approxRes = goog.math.Long.fromNumber(approx);
+ approxRem = approxRes.multiply(other);
+ }
+
+ // We know the answer can't be zero... and actually, zero would cause
+ // infinite recursion since we would make no progress.
+ if (approxRes.isZero()) {
+ approxRes = goog.math.Long.ONE;
+ }
+
+ res = res.add(approxRes);
+ rem = rem.subtract(approxRem);
+ }
+ return res;
+ };
+
+
+ /**
+ * Returns this Long modulo the given one.
+ * @param {goog.math.Long} other Long by which to mod.
+ * @return {!goog.math.Long} This Long modulo the given one.
+ */
+ goog.math.Long.prototype.modulo = function(other) {
+ return this.subtract(this.div(other).multiply(other));
+ };
+
+
+ /** @return {!goog.math.Long} The bitwise-NOT of this value. */
+ goog.math.Long.prototype.not = function() {
+ return goog.math.Long.fromBits(~this.low_, ~this.high_);
+ };
+
+
+ /**
+ * Returns the bitwise-AND of this Long and the given one.
+ * @param {goog.math.Long} other The Long with which to AND.
+ * @return {!goog.math.Long} The bitwise-AND of this and the other.
+ */
+ goog.math.Long.prototype.and = function(other) {
+ return goog.math.Long.fromBits(this.low_ & other.low_,
+ this.high_ & other.high_);
+ };
+
+
+ /**
+ * Returns the bitwise-OR of this Long and the given one.
+ * @param {goog.math.Long} other The Long with which to OR.
+ * @return {!goog.math.Long} The bitwise-OR of this and the other.
+ */
+ goog.math.Long.prototype.or = function(other) {
+ return goog.math.Long.fromBits(this.low_ | other.low_,
+ this.high_ | other.high_);
+ };
+
+
+ /**
+ * Returns the bitwise-XOR of this Long and the given one.
+ * @param {goog.math.Long} other The Long with which to XOR.
+ * @return {!goog.math.Long} The bitwise-XOR of this and the other.
+ */
+ goog.math.Long.prototype.xor = function(other) {
+ return goog.math.Long.fromBits(this.low_ ^ other.low_,
+ this.high_ ^ other.high_);
+ };
+
+
+ /**
+ * Returns this Long with bits shifted to the left by the given amount.
+ * @param {number} numBits The number of bits by which to shift.
+ * @return {!goog.math.Long} This shifted to the left by the given amount.
+ */
+ goog.math.Long.prototype.shiftLeft = function(numBits) {
+ numBits &= 63;
+ if (numBits == 0) {
+ return this;
+ } else {
+ var low = this.low_;
+ if (numBits < 32) {
+ var high = this.high_;
+ return goog.math.Long.fromBits(
+ low << numBits,
+ (high << numBits) | (low >>> (32 - numBits)));
+ } else {
+ return goog.math.Long.fromBits(0, low << (numBits - 32));
+ }
+ }
+ };
+
+
+ /**
+ * Returns this Long with bits shifted to the right by the given amount.
+ * @param {number} numBits The number of bits by which to shift.
+ * @return {!goog.math.Long} This shifted to the right by the given amount.
+ */
+ goog.math.Long.prototype.shiftRight = function(numBits) {
+ numBits &= 63;
+ if (numBits == 0) {
+ return this;
+ } else {
+ var high = this.high_;
+ if (numBits < 32) {
+ var low = this.low_;
+ return goog.math.Long.fromBits(
+ (low >>> numBits) | (high << (32 - numBits)),
+ high >> numBits);
+ } else {
+ return goog.math.Long.fromBits(
+ high >> (numBits - 32),
+ high >= 0 ? 0 : -1);
+ }
+ }
+ };
+
+
+ /**
+ * Returns this Long with bits shifted to the right by the given amount, with
+ * the new top bits matching the current sign bit.
+ * @param {number} numBits The number of bits by which to shift.
+ * @return {!goog.math.Long} This shifted to the right by the given amount, with
+ * zeros placed into the new leading bits.
+ */
+ goog.math.Long.prototype.shiftRightUnsigned = function(numBits) {
+ numBits &= 63;
+ if (numBits == 0) {
+ return this;
+ } else {
+ var high = this.high_;
+ if (numBits < 32) {
+ var low = this.low_;
+ return goog.math.Long.fromBits(
+ (low >>> numBits) | (high << (32 - numBits)),
+ high >>> numBits);
+ } else if (numBits == 32) {
+ return goog.math.Long.fromBits(high, 0);
+ } else {
+ return goog.math.Long.fromBits(high >>> (numBits - 32), 0);
+ }
+ }
+ };
+
+ //======= begin jsbn =======
+
+ var navigator = { appName: 'Modern Browser' }; // polyfill a little
+
+ // Copyright (c) 2005 Tom Wu
+ // All Rights Reserved.
+ // http://www-cs-students.stanford.edu/~tjw/jsbn/
+
+ /*
+ * Copyright (c) 2003-2005 Tom Wu
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
+ * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * In addition, the following condition applies:
+ *
+ * All redistributions must retain an intact copy of this copyright notice
+ * and disclaimer.
+ */
+
+ // Basic JavaScript BN library - subset useful for RSA encryption.
+
+ // Bits per digit
+ var dbits;
+
+ // JavaScript engine analysis
+ var canary = 0xdeadbeefcafe;
+ var j_lm = ((canary&0xffffff)==0xefcafe);
+
+ // (public) Constructor
+ function BigInteger(a,b,c) {
+ if(a != null)
+ if("number" == typeof a) this.fromNumber(a,b,c);
+ else if(b == null && "string" != typeof a) this.fromString(a,256);
+ else this.fromString(a,b);
+ }
+
+ // return new, unset BigInteger
+ function nbi() { return new BigInteger(null); }
+
+ // am: Compute w_j += (x*this_i), propagate carries,
+ // c is initial carry, returns final carry.
+ // c < 3*dvalue, x < 2*dvalue, this_i < dvalue
+ // We need to select the fastest one that works in this environment.
+
+ // am1: use a single mult and divide to get the high bits,
+ // max digit bits should be 26 because
+ // max internal value = 2*dvalue^2-2*dvalue (< 2^53)
+ function am1(i,x,w,j,c,n) {
+ while(--n >= 0) {
+ var v = x*this[i++]+w[j]+c;
+ c = Math.floor(v/0x4000000);
+ w[j++] = v&0x3ffffff;
+ }
+ return c;
+ }
+ // am2 avoids a big mult-and-extract completely.
+ // Max digit bits should be <= 30 because we do bitwise ops
+ // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
+ function am2(i,x,w,j,c,n) {
+ var xl = x&0x7fff, xh = x>>15;
+ while(--n >= 0) {
+ var l = this[i]&0x7fff;
+ var h = this[i++]>>15;
+ var m = xh*l+h*xl;
+ l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
+ c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
+ w[j++] = l&0x3fffffff;
+ }
+ return c;
+ }
+ // Alternately, set max digit bits to 28 since some
+ // browsers slow down when dealing with 32-bit numbers.
+ function am3(i,x,w,j,c,n) {
+ var xl = x&0x3fff, xh = x>>14;
+ while(--n >= 0) {
+ var l = this[i]&0x3fff;
+ var h = this[i++]>>14;
+ var m = xh*l+h*xl;
+ l = xl*l+((m&0x3fff)<<14)+w[j]+c;
+ c = (l>>28)+(m>>14)+xh*h;
+ w[j++] = l&0xfffffff;
+ }
+ return c;
+ }
+ if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
+ BigInteger.prototype.am = am2;
+ dbits = 30;
+ }
+ else if(j_lm && (navigator.appName != "Netscape")) {
+ BigInteger.prototype.am = am1;
+ dbits = 26;
+ }
+ else { // Mozilla/Netscape seems to prefer am3
+ BigInteger.prototype.am = am3;
+ dbits = 28;
+ }
+
+ BigInteger.prototype.DB = dbits;
+ BigInteger.prototype.DM = ((1<<dbits)-1);
+ BigInteger.prototype.DV = (1<<dbits);
+
+ var BI_FP = 52;
+ BigInteger.prototype.FV = Math.pow(2,BI_FP);
+ BigInteger.prototype.F1 = BI_FP-dbits;
+ BigInteger.prototype.F2 = 2*dbits-BI_FP;
+
+ // Digit conversions
+ var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
+ var BI_RC = new Array();
+ var rr,vv;
+ rr = "0".charCodeAt(0);
+ for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
+ rr = "a".charCodeAt(0);
+ for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
+ rr = "A".charCodeAt(0);
+ for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
+
+ function int2char(n) { return BI_RM.charAt(n); }
+ function intAt(s,i) {
+ var c = BI_RC[s.charCodeAt(i)];
+ return (c==null)?-1:c;
+ }
+
+ // (protected) copy this to r
+ function bnpCopyTo(r) {
+ for(var i = this.t-1; i >= 0; --i) r[i] = this[i];
+ r.t = this.t;
+ r.s = this.s;
+ }
+
+ // (protected) set from integer value x, -DV <= x < DV
+ function bnpFromInt(x) {
+ this.t = 1;
+ this.s = (x<0)?-1:0;
+ if(x > 0) this[0] = x;
+ else if(x < -1) this[0] = x+DV;
+ else this.t = 0;
+ }
+
+ // return bigint initialized to value
+ function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
+
+ // (protected) set from string and radix
+ function bnpFromString(s,b) {
+ var k;
+ if(b == 16) k = 4;
+ else if(b == 8) k = 3;
+ else if(b == 256) k = 8; // byte array
+ else if(b == 2) k = 1;
+ else if(b == 32) k = 5;
+ else if(b == 4) k = 2;
+ else { this.fromRadix(s,b); return; }
+ this.t = 0;
+ this.s = 0;
+ var i = s.length, mi = false, sh = 0;
+ while(--i >= 0) {
+ var x = (k==8)?s[i]&0xff:intAt(s,i);
+ if(x < 0) {
+ if(s.charAt(i) == "-") mi = true;
+ continue;
+ }
+ mi = false;
+ if(sh == 0)
+ this[this.t++] = x;
+ else if(sh+k > this.DB) {
+ this[this.t-1] |= (x&((1<<(this.DB-sh))-1))<<sh;
+ this[this.t++] = (x>>(this.DB-sh));
+ }
+ else
+ this[this.t-1] |= x<<sh;
+ sh += k;
+ if(sh >= this.DB) sh -= this.DB;
+ }
+ if(k == 8 && (s[0]&0x80) != 0) {
+ this.s = -1;
+ if(sh > 0) this[this.t-1] |= ((1<<(this.DB-sh))-1)<<sh;
+ }
+ this.clamp();
+ if(mi) BigInteger.ZERO.subTo(this,this);
+ }
+
+ // (protected) clamp off excess high words
+ function bnpClamp() {
+ var c = this.s&this.DM;
+ while(this.t > 0 && this[this.t-1] == c) --this.t;
+ }
+
+ // (public) return string representation in given radix
+ function bnToString(b) {
+ if(this.s < 0) return "-"+this.negate().toString(b);
+ var k;
+ if(b == 16) k = 4;
+ else if(b == 8) k = 3;
+ else if(b == 2) k = 1;
+ else if(b == 32) k = 5;
+ else if(b == 4) k = 2;
+ else return this.toRadix(b);
+ var km = (1<<k)-1, d, m = false, r = "", i = this.t;
+ var p = this.DB-(i*this.DB)%k;
+ if(i-- > 0) {
+ if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); }
+ while(i >= 0) {
+ if(p < k) {
+ d = (this[i]&((1<<p)-1))<<(k-p);
+ d |= this[--i]>>(p+=this.DB-k);
+ }
+ else {
+ d = (this[i]>>(p-=k))&km;
+ if(p <= 0) { p += this.DB; --i; }
+ }
+ if(d > 0) m = true;
+ if(m) r += int2char(d);
+ }
+ }
+ return m?r:"0";
+ }
+
+ // (public) -this
+ function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
+
+ // (public) |this|
+ function bnAbs() { return (this.s<0)?this.negate():this; }
+
+ // (public) return + if this > a, - if this < a, 0 if equal
+ function bnCompareTo(a) {
+ var r = this.s-a.s;
+ if(r != 0) return r;
+ var i = this.t;
+ r = i-a.t;
+ if(r != 0) return (this.s<0)?-r:r;
+ while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
+ return 0;
+ }
+
+ // returns bit length of the integer x
+ function nbits(x) {
+ var r = 1, t;
+ if((t=x>>>16) != 0) { x = t; r += 16; }
+ if((t=x>>8) != 0) { x = t; r += 8; }
+ if((t=x>>4) != 0) { x = t; r += 4; }
+ if((t=x>>2) != 0) { x = t; r += 2; }
+ if((t=x>>1) != 0) { x = t; r += 1; }
+ return r;
+ }
+
+ // (public) return the number of bits in "this"
+ function bnBitLength() {
+ if(this.t <= 0) return 0;
+ return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
+ }
+
+ // (protected) r = this << n*DB
+ function bnpDLShiftTo(n,r) {
+ var i;
+ for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
+ for(i = n-1; i >= 0; --i) r[i] = 0;
+ r.t = this.t+n;
+ r.s = this.s;
+ }
+
+ // (protected) r = this >> n*DB
+ function bnpDRShiftTo(n,r) {
+ for(var i = n; i < this.t; ++i) r[i-n] = this[i];
+ r.t = Math.max(this.t-n,0);
+ r.s = this.s;
+ }
+
+ // (protected) r = this << n
+ function bnpLShiftTo(n,r) {
+ var bs = n%this.DB;
+ var cbs = this.DB-bs;
+ var bm = (1<<cbs)-1;
+ var ds = Math.floor(n/this.DB), c = (this.s<<bs)&this.DM, i;
+ for(i = this.t-1; i >= 0; --i) {
+ r[i+ds+1] = (this[i]>>cbs)|c;
+ c = (this[i]&bm)<<bs;
+ }
+ for(i = ds-1; i >= 0; --i) r[i] = 0;
+ r[ds] = c;
+ r.t = this.t+ds+1;
+ r.s = this.s;
+ r.clamp();
+ }
+
+ // (protected) r = this >> n
+ function bnpRShiftTo(n,r) {
+ r.s = this.s;
+ var ds = Math.floor(n/this.DB);
+ if(ds >= this.t) { r.t = 0; return; }
+ var bs = n%this.DB;
+ var cbs = this.DB-bs;
+ var bm = (1<<bs)-1;
+ r[0] = this[ds]>>bs;
+ for(var i = ds+1; i < this.t; ++i) {
+ r[i-ds-1] |= (this[i]&bm)<<cbs;
+ r[i-ds] = this[i]>>bs;
+ }
+ if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<<cbs;
+ r.t = this.t-ds;
+ r.clamp();
+ }
+
+ // (protected) r = this - a
+ function bnpSubTo(a,r) {
+ var i = 0, c = 0, m = Math.min(a.t,this.t);
+ while(i < m) {
+ c += this[i]-a[i];
+ r[i++] = c&this.DM;
+ c >>= this.DB;
+ }
+ if(a.t < this.t) {
+ c -= a.s;
+ while(i < this.t) {
+ c += this[i];
+ r[i++] = c&this.DM;
+ c >>= this.DB;
+ }
+ c += this.s;
+ }
+ else {
+ c += this.s;
+ while(i < a.t) {
+ c -= a[i];
+ r[i++] = c&this.DM;
+ c >>= this.DB;
+ }
+ c -= a.s;
+ }
+ r.s = (c<0)?-1:0;
+ if(c < -1) r[i++] = this.DV+c;
+ else if(c > 0) r[i++] = c;
+ r.t = i;
+ r.clamp();
+ }
+
+ // (protected) r = this * a, r != this,a (HAC 14.12)
+ // "this" should be the larger one if appropriate.
+ function bnpMultiplyTo(a,r) {
+ var x = this.abs(), y = a.abs();
+ var i = x.t;
+ r.t = i+y.t;
+ while(--i >= 0) r[i] = 0;
+ for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
+ r.s = 0;
+ r.clamp();
+ if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
+ }
+
+ // (protected) r = this^2, r != this (HAC 14.16)
+ function bnpSquareTo(r) {
+ var x = this.abs();
+ var i = r.t = 2*x.t;
+ while(--i >= 0) r[i] = 0;
+ for(i = 0; i < x.t-1; ++i) {
+ var c = x.am(i,x[i],r,2*i,0,1);
+ if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
+ r[i+x.t] -= x.DV;
+ r[i+x.t+1] = 1;
+ }
+ }
+ if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
+ r.s = 0;
+ r.clamp();
+ }
+
+ // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
+ // r != q, this != m. q or r may be null.
+ function bnpDivRemTo(m,q,r) {
+ var pm = m.abs();
+ if(pm.t <= 0) return;
+ var pt = this.abs();
+ if(pt.t < pm.t) {
+ if(q != null) q.fromInt(0);
+ if(r != null) this.copyTo(r);
+ return;
+ }
+ if(r == null) r = nbi();
+ var y = nbi(), ts = this.s, ms = m.s;
+ var nsh = this.DB-nbits(pm[pm.t-1]); // normalize modulus
+ if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
+ else { pm.copyTo(y); pt.copyTo(r); }
+ var ys = y.t;
+ var y0 = y[ys-1];
+ if(y0 == 0) return;
+ var yt = y0*(1<<this.F1)+((ys>1)?y[ys-2]>>this.F2:0);
+ var d1 = this.FV/yt, d2 = (1<<this.F1)/yt, e = 1<<this.F2;
+ var i = r.t, j = i-ys, t = (q==null)?nbi():q;
+ y.dlShiftTo(j,t);
+ if(r.compareTo(t) >= 0) {
+ r[r.t++] = 1;
+ r.subTo(t,r);
+ }
+ BigInteger.ONE.dlShiftTo(ys,t);
+ t.subTo(y,y); // "negative" y so we can replace sub with am later
+ while(y.t < ys) y[y.t++] = 0;
+ while(--j >= 0) {
+ // Estimate quotient digit
+ var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
+ if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
+ y.dlShiftTo(j,t);
+ r.subTo(t,r);
+ while(r[i] < --qd) r.subTo(t,r);
+ }
+ }
+ if(q != null) {
+ r.drShiftTo(ys,q);
+ if(ts != ms) BigInteger.ZERO.subTo(q,q);
+ }
+ r.t = ys;
+ r.clamp();
+ if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
+ if(ts < 0) BigInteger.ZERO.subTo(r,r);
+ }
+
+ // (public) this mod a
+ function bnMod(a) {
+ var r = nbi();
+ this.abs().divRemTo(a,null,r);
+ if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
+ return r;
+ }
+
+ // Modular reduction using "classic" algorithm
+ function Classic(m) { this.m = m; }
+ function cConvert(x) {
+ if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
+ else return x;
+ }
+ function cRevert(x) { return x; }
+ function cReduce(x) { x.divRemTo(this.m,null,x); }
+ function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
+ function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
+
+ Classic.prototype.convert = cConvert;
+ Classic.prototype.revert = cRevert;
+ Classic.prototype.reduce = cReduce;
+ Classic.prototype.mulTo = cMulTo;
+ Classic.prototype.sqrTo = cSqrTo;
+
+ // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
+ // justification:
+ // xy == 1 (mod m)
+ // xy = 1+km
+ // xy(2-xy) = (1+km)(1-km)
+ // x[y(2-xy)] = 1-k^2m^2
+ // x[y(2-xy)] == 1 (mod m^2)
+ // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
+ // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
+ // JS multiply "overflows" differently from C/C++, so care is needed here.
+ function bnpInvDigit() {
+ if(this.t < 1) return 0;
+ var x = this[0];
+ if((x&1) == 0) return 0;
+ var y = x&3; // y == 1/x mod 2^2
+ y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
+ y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
+ y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
+ // last step - calculate inverse mod DV directly;
+ // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
+ y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits
+ // we really want the negative inverse, and -DV < y < DV
+ return (y>0)?this.DV-y:-y;
+ }
+
+ // Montgomery reduction
+ function Montgomery(m) {
+ this.m = m;
+ this.mp = m.invDigit();
+ this.mpl = this.mp&0x7fff;
+ this.mph = this.mp>>15;
+ this.um = (1<<(m.DB-15))-1;
+ this.mt2 = 2*m.t;
+ }
+
+ // xR mod m
+ function montConvert(x) {
+ var r = nbi();
+ x.abs().dlShiftTo(this.m.t,r);
+ r.divRemTo(this.m,null,r);
+ if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
+ return r;
+ }
+
+ // x/R mod m
+ function montRevert(x) {
+ var r = nbi();
+ x.copyTo(r);
+ this.reduce(r);
+ return r;
+ }
+
+ // x = x/R mod m (HAC 14.32)
+ function montReduce(x) {
+ while(x.t <= this.mt2) // pad x so am has enough room later
+ x[x.t++] = 0;
+ for(var i = 0; i < this.m.t; ++i) {
+ // faster way of calculating u0 = x[i]*mp mod DV
+ var j = x[i]&0x7fff;
+ var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
+ // use am to combine the multiply-shift-add into one call
+ j = i+this.m.t;
+ x[j] += this.m.am(0,u0,x,i,0,this.m.t);
+ // propagate carry
+ while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
+ }
+ x.clamp();
+ x.drShiftTo(this.m.t,x);
+ if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
+ }
+
+ // r = "x^2/R mod m"; x != r
+ function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
+
+ // r = "xy/R mod m"; x,y != r
+ function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
+
+ Montgomery.prototype.convert = montConvert;
+ Montgomery.prototype.revert = montRevert;
+ Montgomery.prototype.reduce = montReduce;
+ Montgomery.prototype.mulTo = montMulTo;
+ Montgomery.prototype.sqrTo = montSqrTo;
+
+ // (protected) true iff this is even
+ function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
+
+ // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
+ function bnpExp(e,z) {
+ if(e > 0xffffffff || e < 1) return BigInteger.ONE;
+ var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
+ g.copyTo(r);
+ while(--i >= 0) {
+ z.sqrTo(r,r2);
+ if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
+ else { var t = r; r = r2; r2 = t; }
+ }
+ return z.revert(r);
+ }
+
+ // (public) this^e % m, 0 <= e < 2^32
+ function bnModPowInt(e,m) {
+ var z;
+ if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
+ return this.exp(e,z);
+ }
+
+ // protected
+ BigInteger.prototype.copyTo = bnpCopyTo;
+ BigInteger.prototype.fromInt = bnpFromInt;
+ BigInteger.prototype.fromString = bnpFromString;
+ BigInteger.prototype.clamp = bnpClamp;
+ BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
+ BigInteger.prototype.drShiftTo = bnpDRShiftTo;
+ BigInteger.prototype.lShiftTo = bnpLShiftTo;
+ BigInteger.prototype.rShiftTo = bnpRShiftTo;
+ BigInteger.prototype.subTo = bnpSubTo;
+ BigInteger.prototype.multiplyTo = bnpMultiplyTo;
+ BigInteger.prototype.squareTo = bnpSquareTo;
+ BigInteger.prototype.divRemTo = bnpDivRemTo;
+ BigInteger.prototype.invDigit = bnpInvDigit;
+ BigInteger.prototype.isEven = bnpIsEven;
+ BigInteger.prototype.exp = bnpExp;
+
+ // public
+ BigInteger.prototype.toString = bnToString;
+ BigInteger.prototype.negate = bnNegate;
+ BigInteger.prototype.abs = bnAbs;
+ BigInteger.prototype.compareTo = bnCompareTo;
+ BigInteger.prototype.bitLength = bnBitLength;
+ BigInteger.prototype.mod = bnMod;
+ BigInteger.prototype.modPowInt = bnModPowInt;
+
+ // "constants"
+ BigInteger.ZERO = nbv(0);
+ BigInteger.ONE = nbv(1);
+
+ // jsbn2 stuff
+
+ // (protected) convert from radix string
+ function bnpFromRadix(s,b) {
+ this.fromInt(0);
+ if(b == null) b = 10;
+ var cs = this.chunkSize(b);
+ var d = Math.pow(b,cs), mi = false, j = 0, w = 0;
+ for(var i = 0; i < s.length; ++i) {
+ var x = intAt(s,i);
+ if(x < 0) {
+ if(s.charAt(i) == "-" && this.signum() == 0) mi = true;
+ continue;
+ }
+ w = b*w+x;
+ if(++j >= cs) {
+ this.dMultiply(d);
+ this.dAddOffset(w,0);
+ j = 0;
+ w = 0;
+ }
+ }
+ if(j > 0) {
+ this.dMultiply(Math.pow(b,j));
+ this.dAddOffset(w,0);
+ }
+ if(mi) BigInteger.ZERO.subTo(this,this);
+ }
+
+ // (protected) return x s.t. r^x < DV
+ function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
+
+ // (public) 0 if this == 0, 1 if this > 0
+ function bnSigNum() {
+ if(this.s < 0) return -1;
+ else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
+ else return 1;
+ }
+
+ // (protected) this *= n, this >= 0, 1 < n < DV
+ function bnpDMultiply(n) {
+ this[this.t] = this.am(0,n-1,this,0,0,this.t);
+ ++this.t;
+ this.clamp();
+ }
+
+ // (protected) this += n << w words, this >= 0
+ function bnpDAddOffset(n,w) {
+ if(n == 0) return;
+ while(this.t <= w) this[this.t++] = 0;
+ this[w] += n;
+ while(this[w] >= this.DV) {
+ this[w] -= this.DV;
+ if(++w >= this.t) this[this.t++] = 0;
+ ++this[w];
+ }
+ }
+
+ // (protected) convert to radix string
+ function bnpToRadix(b) {
+ if(b == null) b = 10;
+ if(this.signum() == 0 || b < 2 || b > 36) return "0";
+ var cs = this.chunkSize(b);
+ var a = Math.pow(b,cs);
+ var d = nbv(a), y = nbi(), z = nbi(), r = "";
+ this.divRemTo(d,y,z);
+ while(y.signum() > 0) {
+ r = (a+z.intValue()).toString(b).substr(1) + r;
+ y.divRemTo(d,y,z);
+ }
+ return z.intValue().toString(b) + r;
+ }
+
+ // (public) return value as integer
+ function bnIntValue() {
+ if(this.s < 0) {
+ if(this.t == 1) return this[0]-this.DV;
+ else if(this.t == 0) return -1;
+ }
+ else if(this.t == 1) return this[0];
+ else if(this.t == 0) return 0;
+ // assumes 16 < DB < 32
+ return ((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0];
+ }
+
+ // (protected) r = this + a
+ function bnpAddTo(a,r) {
+ var i = 0, c = 0, m = Math.min(a.t,this.t);
+ while(i < m) {
+ c += this[i]+a[i];
+ r[i++] = c&this.DM;
+ c >>= this.DB;
+ }
+ if(a.t < this.t) {
+ c += a.s;
+ while(i < this.t) {
+ c += this[i];
+ r[i++] = c&this.DM;
+ c >>= this.DB;
+ }
+ c += this.s;
+ }
+ else {
+ c += this.s;
+ while(i < a.t) {
+ c += a[i];
+ r[i++] = c&this.DM;
+ c >>= this.DB;
+ }
+ c += a.s;
+ }
+ r.s = (c<0)?-1:0;
+ if(c > 0) r[i++] = c;
+ else if(c < -1) r[i++] = this.DV+c;
+ r.t = i;
+ r.clamp();
+ }
+
+ BigInteger.prototype.fromRadix = bnpFromRadix;
+ BigInteger.prototype.chunkSize = bnpChunkSize;
+ BigInteger.prototype.signum = bnSigNum;
+ BigInteger.prototype.dMultiply = bnpDMultiply;
+ BigInteger.prototype.dAddOffset = bnpDAddOffset;
+ BigInteger.prototype.toRadix = bnpToRadix;
+ BigInteger.prototype.intValue = bnIntValue;
+ BigInteger.prototype.addTo = bnpAddTo;
+
+ //======= end jsbn =======
+
+ // Emscripten wrapper
+ var Wrapper = {
+ abs: function(l, h) {
+ var x = new goog.math.Long(l, h);
+ var ret;
+ if (x.isNegative()) {
+ ret = x.negate();
+ } else {
+ ret = x;
+ }
+ HEAP32[tempDoublePtr>>2] = ret.low_;
+ HEAP32[tempDoublePtr+4>>2] = ret.high_;
+ },
+ ensureTemps: function() {
+ if (Wrapper.ensuredTemps) return;
+ Wrapper.ensuredTemps = true;
+ Wrapper.two32 = new BigInteger();
+ Wrapper.two32.fromString('4294967296', 10);
+ Wrapper.two64 = new BigInteger();
+ Wrapper.two64.fromString('18446744073709551616', 10);
+ Wrapper.temp1 = new BigInteger();
+ Wrapper.temp2 = new BigInteger();
+ },
+ lh2bignum: function(l, h) {
+ var a = new BigInteger();
+ a.fromString(h.toString(), 10);
+ var b = new BigInteger();
+ a.multiplyTo(Wrapper.two32, b);
+ var c = new BigInteger();
+ c.fromString(l.toString(), 10);
+ var d = new BigInteger();
+ c.addTo(b, d);
+ return d;
+ },
+ stringify: function(l, h, unsigned) {
+ var ret = new goog.math.Long(l, h).toString();
+ if (unsigned && ret[0] == '-') {
+ // unsign slowly using jsbn bignums
+ Wrapper.ensureTemps();
+ var bignum = new BigInteger();
+ bignum.fromString(ret, 10);
+ ret = new BigInteger();
+ Wrapper.two64.addTo(bignum, ret);
+ ret = ret.toString(10);
+ }
+ return ret;
+ },
+ fromString: function(str, base, min, max, unsigned) {
+ Wrapper.ensureTemps();
+ var bignum = new BigInteger();
+ bignum.fromString(str, base);
+ var bigmin = new BigInteger();
+ bigmin.fromString(min, 10);
+ var bigmax = new BigInteger();
+ bigmax.fromString(max, 10);
+ if (unsigned && bignum.compareTo(BigInteger.ZERO) < 0) {
+ var temp = new BigInteger();
+ bignum.addTo(Wrapper.two64, temp);
+ bignum = temp;
+ }
+ var error = false;
+ if (bignum.compareTo(bigmin) < 0) {
+ bignum = bigmin;
+ error = true;
+ } else if (bignum.compareTo(bigmax) > 0) {
+ bignum = bigmax;
+ error = true;
+ }
+ var ret = goog.math.Long.fromString(bignum.toString()); // min-max checks should have clamped this to a range goog.math.Long can handle well
+ HEAP32[tempDoublePtr>>2] = ret.low_;
+ HEAP32[tempDoublePtr+4>>2] = ret.high_;
+ if (error) throw 'range error';
+ }
+ };
+ return Wrapper;
+})();
+
+//======= end closure i64 code =======
+
+
+
+// === Auto-generated postamble setup entry stuff ===
+
+if (memoryInitializer) {
+ if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
+ var data = Module['readBinary'](memoryInitializer);
+ HEAPU8.set(data, STATIC_BASE);
+ } else {
+ addRunDependency('memory initializer');
+ Browser.asyncLoad(memoryInitializer, function(data) {
+ HEAPU8.set(data, STATIC_BASE);
+ removeRunDependency('memory initializer');
+ }, function(data) {
+ throw 'could not load memory initializer ' + memoryInitializer;
+ });
+ }
+}
+
+function ExitStatus(status) {
+ this.name = "ExitStatus";
+ this.message = "Program terminated with exit(" + status + ")";
+ this.status = status;
+};
+ExitStatus.prototype = new Error();
+ExitStatus.prototype.constructor = ExitStatus;
+
+var initialStackTop;
+var preloadStartTime = null;
+var calledMain = false;
+
+dependenciesFulfilled = function runCaller() {
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
+ if (!Module['calledRun'] && shouldRunNow) run(['binarytrees.lua'].concat(Module["arguments"]));
+ if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
+}
+
+Module['callMain'] = Module.callMain = function callMain(args) {
+ assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');
+ assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
+
+ args = args || [];
+
+ ensureInitRuntime();
+
+ var argc = args.length+1;
+ function pad() {
+ for (var i = 0; i < 4-1; i++) {
+ argv.push(0);
+ }
+ }
+ var argv = [allocate(intArrayFromString("/bin/this.program"), 'i8', ALLOC_NORMAL) ];
+ pad();
+ for (var i = 0; i < argc-1; i = i + 1) {
+ argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL));
+ pad();
+ }
+ argv.push(0);
+ argv = allocate(argv, 'i32', ALLOC_NORMAL);
+
+ initialStackTop = STACKTOP;
+
+ try {
+
+ var ret = Module['_main'](argc, argv, 0);
+
+
+ // if we're not running an evented main loop, it's time to exit
+ if (!Module['noExitRuntime']) {
+ exit(ret);
+ }
+ }
+ catch(e) {
+ if (e instanceof ExitStatus) {
+ // exit() throws this once it's done to make sure execution
+ // has been stopped completely
+ return;
+ } else if (e == 'SimulateInfiniteLoop') {
+ // running an evented main loop, don't immediately exit
+ Module['noExitRuntime'] = true;
+ return;
+ } else {
+ if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
+ throw e;
+ }
+ } finally {
+ calledMain = true;
+ }
+}
+
+
+
+
+function run(args) {
+ args = args || Module['arguments'];
+
+ if (preloadStartTime === null) preloadStartTime = Date.now();
+
+ if (runDependencies > 0) {
+ Module.printErr('run() called, but dependencies remain, so not running');
+ return;
+ }
+
+ preRun();
+
+ if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
+ if (Module['calledRun']) return; // run may have just been called through dependencies being fulfilled just in this very frame
+
+ function doRun() {
+ if (Module['calledRun']) return; // run may have just been called while the async setStatus time below was happening
+ Module['calledRun'] = true;
+
+ ensureInitRuntime();
+
+ preMain();
+
+ if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) {
+ Module.printErr('pre-main prep time: ' + (Date.now() - preloadStartTime) + ' ms');
+ }
+
+ if (Module['_main'] && shouldRunNow) {
+ Module['callMain'](args);
+ }
+
+ postRun();
+ }
+
+ if (Module['setStatus']) {
+ Module['setStatus']('Running...');
+ setTimeout(function() {
+ setTimeout(function() {
+ Module['setStatus']('');
+ }, 1);
+ if (!ABORT) doRun();
+ }, 1);
+ } else {
+ doRun();
+ }
+}
+Module['run'] = Module.run = run;
+
+function exit(status) {
+ ABORT = true;
+ EXITSTATUS = status;
+ STACKTOP = initialStackTop;
+
+ // exit the runtime
+ exitRuntime();
+
+ // TODO We should handle this differently based on environment.
+ // In the browser, the best we can do is throw an exception
+ // to halt execution, but in node we could process.exit and
+ // I'd imagine SM shell would have something equivalent.
+ // This would let us set a proper exit status (which
+ // would be great for checking test exit statuses).
+ // https://github.com/kripken/emscripten/issues/1371
+
+ // throw an exception to halt the current execution
+ throw new ExitStatus(status);
+}
+Module['exit'] = Module.exit = exit;
+
+function abort(text) {
+ if (text) {
+ Module.print(text);
+ Module.printErr(text);
+ }
+
+ ABORT = true;
+ EXITSTATUS = 1;
+
+ var extra = '\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.';
+
+ throw 'abort() at ' + stackTrace() + extra;
+}
+Module['abort'] = Module.abort = abort;
+
+// {{PRE_RUN_ADDITIONS}}
+
+if (Module['preInit']) {
+ if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
+ while (Module['preInit'].length > 0) {
+ Module['preInit'].pop()();
+ }
+}
+
+// shouldRunNow refers to calling main(), not run().
+var shouldRunNow = true;
+if (Module['noInitialRun']) {
+ shouldRunNow = false;
+}
+
+
+run(['binarytrees.lua'].concat(Module["arguments"]));
diff --git a/test/mjsunit/asm/embenchen/memops.js b/test/mjsunit/asm/embenchen/memops.js
new file mode 100644
index 000000000..1deb305a1
--- /dev/null
+++ b/test/mjsunit/asm/embenchen/memops.js
@@ -0,0 +1,8091 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var EXPECTED_OUTPUT = 'final: 840.\n';
+var Module = {
+ arguments: [1],
+ print: function(x) {Module.printBuffer += x + '\n';},
+ preRun: [function() {Module.printBuffer = ''}],
+ postRun: [function() {
+ assertEquals(EXPECTED_OUTPUT, Module.printBuffer);
+ }],
+};
+// The Module object: Our interface to the outside world. We import
+// and export values on it, and do the work to get that through
+// closure compiler if necessary. There are various ways Module can be used:
+// 1. Not defined. We create it here
+// 2. A function parameter, function(Module) { ..generated code.. }
+// 3. pre-run appended it, var Module = {}; ..generated code..
+// 4. External script tag defines var Module.
+// We need to do an eval in order to handle the closure compiler
+// case, where this code here is minified but Module was defined
+// elsewhere (e.g. case 4 above). We also need to check if Module
+// already exists (e.g. case 3 above).
+// Note that if you want to run closure, and also to use Module
+// after the generated code, you will need to define var Module = {};
+// before the code. Then that object will be used in the code, and you
+// can continue to use Module afterwards as well.
+var Module;
+if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {};
+
+// Sometimes an existing Module object exists with properties
+// meant to overwrite the default module functionality. Here
+// we collect those properties and reapply _after_ we configure
+// the current environment's defaults to avoid having to be so
+// defensive during initialization.
+var moduleOverrides = {};
+for (var key in Module) {
+ if (Module.hasOwnProperty(key)) {
+ moduleOverrides[key] = Module[key];
+ }
+}
+
+// The environment setup code below is customized to use Module.
+// *** Environment setup code ***
+var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
+var ENVIRONMENT_IS_WEB = typeof window === 'object';
+var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
+var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+
+if (ENVIRONMENT_IS_NODE) {
+ // Expose functionality in the same simple way that the shells work
+ // Note that we pollute the global namespace here, otherwise we break in node
+ if (!Module['print']) Module['print'] = function print(x) {
+ process['stdout'].write(x + '\n');
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ process['stderr'].write(x + '\n');
+ };
+
+ var nodeFS = require('fs');
+ var nodePath = require('path');
+
+ Module['read'] = function read(filename, binary) {
+ filename = nodePath['normalize'](filename);
+ var ret = nodeFS['readFileSync'](filename);
+ // The path is absolute if the normalized version is the same as the resolved.
+ if (!ret && filename != nodePath['resolve'](filename)) {
+ filename = path.join(__dirname, '..', 'src', filename);
+ ret = nodeFS['readFileSync'](filename);
+ }
+ if (ret && !binary) ret = ret.toString();
+ return ret;
+ };
+
+ Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
+
+ Module['load'] = function load(f) {
+ globalEval(read(f));
+ };
+
+ Module['arguments'] = process['argv'].slice(2);
+
+ module['exports'] = Module;
+}
+else if (ENVIRONMENT_IS_SHELL) {
+ if (!Module['print']) Module['print'] = print;
+ if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
+
+ if (typeof read != 'undefined') {
+ Module['read'] = read;
+ } else {
+ Module['read'] = function read() { throw 'no read() available (jsc?)' };
+ }
+
+ Module['readBinary'] = function readBinary(f) {
+ return read(f, 'binary');
+ };
+
+ if (typeof scriptArgs != 'undefined') {
+ Module['arguments'] = scriptArgs;
+ } else if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ this['Module'] = Module;
+
+ eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
+}
+else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
+ Module['read'] = function read(url) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ xhr.send(null);
+ return xhr.responseText;
+ };
+
+ if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ if (typeof console !== 'undefined') {
+ if (!Module['print']) Module['print'] = function print(x) {
+ console.log(x);
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ console.log(x);
+ };
+ } else {
+ // Probably a worker, and without console.log. We can do very little here...
+ var TRY_USE_DUMP = false;
+ if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
+ dump(x);
+ }) : (function(x) {
+ // self.postMessage(x); // enable this if you want stdout to be sent as messages
+ }));
+ }
+
+ if (ENVIRONMENT_IS_WEB) {
+ window['Module'] = Module;
+ } else {
+ Module['load'] = importScripts;
+ }
+}
+else {
+ // Unreachable because SHELL is dependant on the others
+ throw 'Unknown runtime environment. Where are we?';
+}
+
+function globalEval(x) {
+ eval.call(null, x);
+}
+if (!Module['load'] == 'undefined' && Module['read']) {
+ Module['load'] = function load(f) {
+ globalEval(Module['read'](f));
+ };
+}
+if (!Module['print']) {
+ Module['print'] = function(){};
+}
+if (!Module['printErr']) {
+ Module['printErr'] = Module['print'];
+}
+if (!Module['arguments']) {
+ Module['arguments'] = [];
+}
+// *** Environment setup code ***
+
+// Closure helpers
+Module.print = Module['print'];
+Module.printErr = Module['printErr'];
+
+// Callbacks
+Module['preRun'] = [];
+Module['postRun'] = [];
+
+// Merge back in the overrides
+for (var key in moduleOverrides) {
+ if (moduleOverrides.hasOwnProperty(key)) {
+ Module[key] = moduleOverrides[key];
+ }
+}
+
+
+
+// === Auto-generated preamble library stuff ===
+
+//========================================
+// Runtime code shared with compiler
+//========================================
+
+var Runtime = {
+ stackSave: function () {
+ return STACKTOP;
+ },
+ stackRestore: function (stackTop) {
+ STACKTOP = stackTop;
+ },
+ forceAlign: function (target, quantum) {
+ quantum = quantum || 4;
+ if (quantum == 1) return target;
+ if (isNumber(target) && isNumber(quantum)) {
+ return Math.ceil(target/quantum)*quantum;
+ } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
+ return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')';
+ }
+ return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
+ },
+ isNumberType: function (type) {
+ return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
+ },
+ isPointerType: function isPointerType(type) {
+ return type[type.length-1] == '*';
+},
+ isStructType: function isStructType(type) {
+ if (isPointerType(type)) return false;
+ if (isArrayType(type)) return true;
+ if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
+ // See comment in isStructPointerType()
+ return type[0] == '%';
+},
+ INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
+ FLOAT_TYPES: {"float":0,"double":0},
+ or64: function (x, y) {
+ var l = (x | 0) | (y | 0);
+ var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ and64: function (x, y) {
+ var l = (x | 0) & (y | 0);
+ var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ xor64: function (x, y) {
+ var l = (x | 0) ^ (y | 0);
+ var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ getNativeTypeSize: function (type) {
+ switch (type) {
+ case 'i1': case 'i8': return 1;
+ case 'i16': return 2;
+ case 'i32': return 4;
+ case 'i64': return 8;
+ case 'float': return 4;
+ case 'double': return 8;
+ default: {
+ if (type[type.length-1] === '*') {
+ return Runtime.QUANTUM_SIZE; // A pointer
+ } else if (type[0] === 'i') {
+ var bits = parseInt(type.substr(1));
+ assert(bits % 8 === 0);
+ return bits/8;
+ } else {
+ return 0;
+ }
+ }
+ }
+ },
+ getNativeFieldSize: function (type) {
+ return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
+ },
+ dedup: function dedup(items, ident) {
+ var seen = {};
+ if (ident) {
+ return items.filter(function(item) {
+ if (seen[item[ident]]) return false;
+ seen[item[ident]] = true;
+ return true;
+ });
+ } else {
+ return items.filter(function(item) {
+ if (seen[item]) return false;
+ seen[item] = true;
+ return true;
+ });
+ }
+},
+ set: function set() {
+ var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
+ var ret = {};
+ for (var i = 0; i < args.length; i++) {
+ ret[args[i]] = 0;
+ }
+ return ret;
+},
+ STACK_ALIGN: 8,
+ getAlignSize: function (type, size, vararg) {
+ // we align i64s and doubles on 64-bit boundaries, unlike x86
+ if (!vararg && (type == 'i64' || type == 'double')) return 8;
+ if (!type) return Math.min(size, 8); // align structures internally to 64 bits
+ return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
+ },
+ calculateStructAlignment: function calculateStructAlignment(type) {
+ type.flatSize = 0;
+ type.alignSize = 0;
+ var diffs = [];
+ var prev = -1;
+ var index = 0;
+ type.flatIndexes = type.fields.map(function(field) {
+ index++;
+ var size, alignSize;
+ if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
+ size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
+ alignSize = Runtime.getAlignSize(field, size);
+ } else if (Runtime.isStructType(field)) {
+ if (field[1] === '0') {
+ // this is [0 x something]. When inside another structure like here, it must be at the end,
+ // and it adds no size
+ // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');
+ size = 0;
+ if (Types.types[field]) {
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ } else {
+ alignSize = type.alignSize || QUANTUM_SIZE;
+ }
+ } else {
+ size = Types.types[field].flatSize;
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ }
+ } else if (field[0] == 'b') {
+ // bN, large number field, like a [N x i8]
+ size = field.substr(1)|0;
+ alignSize = 1;
+ } else if (field[0] === '<') {
+ // vector type
+ size = alignSize = Types.types[field].flatSize; // fully aligned
+ } else if (field[0] === 'i') {
+ // illegal integer field, that could not be legalized because it is an internal structure field
+ // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
+ size = alignSize = parseInt(field.substr(1))/8;
+ assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
+ } else {
+ assert(false, 'invalid type for calculateStructAlignment');
+ }
+ if (type.packed) alignSize = 1;
+ type.alignSize = Math.max(type.alignSize, alignSize);
+ var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
+ type.flatSize = curr + size;
+ if (prev >= 0) {
+ diffs.push(curr-prev);
+ }
+ prev = curr;
+ return curr;
+ });
+ if (type.name_ && type.name_[0] === '[') {
+ // arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
+ // allocating a potentially huge array for [999999 x i8] etc.
+ type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
+ }
+ type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
+ if (diffs.length == 0) {
+ type.flatFactor = type.flatSize;
+ } else if (Runtime.dedup(diffs).length == 1) {
+ type.flatFactor = diffs[0];
+ }
+ type.needsFlattening = (type.flatFactor != 1);
+ return type.flatIndexes;
+ },
+ generateStructInfo: function (struct, typeName, offset) {
+ var type, alignment;
+ if (typeName) {
+ offset = offset || 0;
+ type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
+ if (!type) return null;
+ if (type.fields.length != struct.length) {
+ printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');
+ return null;
+ }
+ alignment = type.flatIndexes;
+ } else {
+ var type = { fields: struct.map(function(item) { return item[0] }) };
+ alignment = Runtime.calculateStructAlignment(type);
+ }
+ var ret = {
+ __size__: type.flatSize
+ };
+ if (typeName) {
+ struct.forEach(function(item, i) {
+ if (typeof item === 'string') {
+ ret[item] = alignment[i] + offset;
+ } else {
+ // embedded struct
+ var key;
+ for (var k in item) key = k;
+ ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
+ }
+ });
+ } else {
+ struct.forEach(function(item, i) {
+ ret[item[1]] = alignment[i];
+ });
+ }
+ return ret;
+ },
+ dynCall: function (sig, ptr, args) {
+ if (args && args.length) {
+ if (!args.splice) args = Array.prototype.slice.call(args);
+ args.splice(0, 0, ptr);
+ return Module['dynCall_' + sig].apply(null, args);
+ } else {
+ return Module['dynCall_' + sig].call(null, ptr);
+ }
+ },
+ functionPointers: [],
+ addFunction: function (func) {
+ for (var i = 0; i < Runtime.functionPointers.length; i++) {
+ if (!Runtime.functionPointers[i]) {
+ Runtime.functionPointers[i] = func;
+ return 2*(1 + i);
+ }
+ }
+ throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
+ },
+ removeFunction: function (index) {
+ Runtime.functionPointers[(index-2)/2] = null;
+ },
+ getAsmConst: function (code, numArgs) {
+ // code is a constant string on the heap, so we can cache these
+ if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
+ var func = Runtime.asmConstCache[code];
+ if (func) return func;
+ var args = [];
+ for (var i = 0; i < numArgs; i++) {
+ args.push(String.fromCharCode(36) + i); // $0, $1 etc
+ }
+ var source = Pointer_stringify(code);
+ if (source[0] === '"') {
+ // tolerate EM_ASM("..code..") even though EM_ASM(..code..) is correct
+ if (source.indexOf('"', 1) === source.length-1) {
+ source = source.substr(1, source.length-2);
+ } else {
+ // something invalid happened, e.g. EM_ASM("..code($0)..", input)
+ abort('invalid EM_ASM input |' + source + '|. Please use EM_ASM(..code..) (no quotes) or EM_ASM({ ..code($0).. }, input) (to input values)');
+ }
+ }
+ try {
+ var evalled = eval('(function(' + args.join(',') + '){ ' + source + ' })'); // new Function does not allow upvars in node
+ } catch(e) {
+ Module.printErr('error in executing inline EM_ASM code: ' + e + ' on: \n\n' + source + '\n\nwith args |' + args + '| (make sure to use the right one out of EM_ASM, EM_ASM_ARGS, etc.)');
+ throw e;
+ }
+ return Runtime.asmConstCache[code] = evalled;
+ },
+ warnOnce: function (text) {
+ if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
+ if (!Runtime.warnOnce.shown[text]) {
+ Runtime.warnOnce.shown[text] = 1;
+ Module.printErr(text);
+ }
+ },
+ funcWrappers: {},
+ getFuncWrapper: function (func, sig) {
+ assert(sig);
+ if (!Runtime.funcWrappers[func]) {
+ Runtime.funcWrappers[func] = function dynCall_wrapper() {
+ return Runtime.dynCall(sig, func, arguments);
+ };
+ }
+ return Runtime.funcWrappers[func];
+ },
+ UTF8Processor: function () {
+ var buffer = [];
+ var needed = 0;
+ this.processCChar = function (code) {
+ code = code & 0xFF;
+
+ if (buffer.length == 0) {
+ if ((code & 0x80) == 0x00) { // 0xxxxxxx
+ return String.fromCharCode(code);
+ }
+ buffer.push(code);
+ if ((code & 0xE0) == 0xC0) { // 110xxxxx
+ needed = 1;
+ } else if ((code & 0xF0) == 0xE0) { // 1110xxxx
+ needed = 2;
+ } else { // 11110xxx
+ needed = 3;
+ }
+ return '';
+ }
+
+ if (needed) {
+ buffer.push(code);
+ needed--;
+ if (needed > 0) return '';
+ }
+
+ var c1 = buffer[0];
+ var c2 = buffer[1];
+ var c3 = buffer[2];
+ var c4 = buffer[3];
+ var ret;
+ if (buffer.length == 2) {
+ ret = String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ } else if (buffer.length == 3) {
+ ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ } else {
+ // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |
+ ((c3 & 0x3F) << 6) | (c4 & 0x3F);
+ ret = String.fromCharCode(
+ Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,
+ (codePoint - 0x10000) % 0x400 + 0xDC00);
+ }
+ buffer.length = 0;
+ return ret;
+ }
+ this.processJSString = function processJSString(string) {
+ /* TODO: use TextEncoder when present,
+ var encoder = new TextEncoder();
+ encoder['encoding'] = "utf-8";
+ var utf8Array = encoder['encode'](aMsg.data);
+ */
+ string = unescape(encodeURIComponent(string));
+ var ret = [];
+ for (var i = 0; i < string.length; i++) {
+ ret.push(string.charCodeAt(i));
+ }
+ return ret;
+ }
+ },
+ getCompilerSetting: function (name) {
+ throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
+ },
+ stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+7)&-8); return ret; },
+ staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = (((STATICTOP)+7)&-8); return ret; },
+ dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = (((DYNAMICTOP)+7)&-8); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
+ alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },
+ makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*(+4294967296))) : ((+((low>>>0)))+((+((high|0)))*(+4294967296)))); return ret; },
+ GLOBAL_BASE: 8,
+ QUANTUM_SIZE: 4,
+ __dummy__: 0
+}
+
+
+Module['Runtime'] = Runtime;
+
+
+
+
+
+
+
+
+
+//========================================
+// Runtime essentials
+//========================================
+
+var __THREW__ = 0; // Used in checking for thrown exceptions.
+
+var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()
+var EXITSTATUS = 0;
+
+var undef = 0;
+// tempInt is used for 32-bit signed values or smaller. tempBigInt is used
+// for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
+var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
+var tempI64, tempI64b;
+var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
+
+function assert(condition, text) {
+ if (!condition) {
+ abort('Assertion failed: ' + text);
+ }
+}
+
+var globalScope = this;
+
+// C calling interface. A convenient way to call C functions (in C files, or
+// defined with extern "C").
+//
+// Note: LLVM optimizations can inline and remove functions, after which you will not be
+// able to call them. Closure can also do so. To avoid that, add your function to
+// the exports using something like
+//
+// -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]'
+//
+// @param ident The name of the C function (note that C++ functions will be name-mangled - use extern "C")
+// @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and
+// 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).
+// @param argTypes An array of the types of arguments for the function (if there are no arguments, this can be ommitted). Types are as in returnType,
+// except that 'array' is not possible (there is no way for us to know the length of the array)
+// @param args An array of the arguments to the function, as native JS values (as in returnType)
+// Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).
+// @return The return value, as a native JS value (as in returnType)
+function ccall(ident, returnType, argTypes, args) {
+ return ccallFunc(getCFunc(ident), returnType, argTypes, args);
+}
+Module["ccall"] = ccall;
+
+// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
+function getCFunc(ident) {
+ try {
+ var func = Module['_' + ident]; // closure exported function
+ if (!func) func = eval('_' + ident); // explicit lookup
+ } catch(e) {
+ }
+ assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
+ return func;
+}
+
+// Internal function that does a C call using a function, not an identifier
+function ccallFunc(func, returnType, argTypes, args) {
+ var stack = 0;
+ function toC(value, type) {
+ if (type == 'string') {
+ if (value === null || value === undefined || value === 0) return 0; // null string
+ value = intArrayFromString(value);
+ type = 'array';
+ }
+ if (type == 'array') {
+ if (!stack) stack = Runtime.stackSave();
+ var ret = Runtime.stackAlloc(value.length);
+ writeArrayToMemory(value, ret);
+ return ret;
+ }
+ return value;
+ }
+ function fromC(value, type) {
+ if (type == 'string') {
+ return Pointer_stringify(value);
+ }
+ assert(type != 'array');
+ return value;
+ }
+ var i = 0;
+ var cArgs = args ? args.map(function(arg) {
+ return toC(arg, argTypes[i++]);
+ }) : [];
+ var ret = fromC(func.apply(null, cArgs), returnType);
+ if (stack) Runtime.stackRestore(stack);
+ return ret;
+}
+
+// Returns a native JS wrapper for a C function. This is similar to ccall, but
+// returns a function you can call repeatedly in a normal way. For example:
+//
+// var my_function = cwrap('my_c_function', 'number', ['number', 'number']);
+// alert(my_function(5, 22));
+// alert(my_function(99, 12));
+//
+function cwrap(ident, returnType, argTypes) {
+ var func = getCFunc(ident);
+ return function() {
+ return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));
+ }
+}
+Module["cwrap"] = cwrap;
+
+// Sets a value in memory in a dynamic way at run-time. Uses the
+// type data. This is the same as makeSetValue, except that
+// makeSetValue is done at compile-time and generates the needed
+// code then, whereas this function picks the right code at
+// run-time.
+// Note that setValue and getValue only do *aligned* writes and reads!
+// Note that ccall uses JS types as for defining types, while setValue and
+// getValue need LLVM types ('i8', 'i32') - this is a lower-level operation
+function setValue(ptr, value, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': HEAP8[(ptr)]=value; break;
+ case 'i8': HEAP8[(ptr)]=value; break;
+ case 'i16': HEAP16[((ptr)>>1)]=value; break;
+ case 'i32': HEAP32[((ptr)>>2)]=value; break;
+ case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= (+1) ? (tempDouble > (+0) ? ((Math_min((+(Math_floor((tempDouble)/(+4294967296)))), (+4294967295)))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+4294967296))))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
+ case 'float': HEAPF32[((ptr)>>2)]=value; break;
+ case 'double': HEAPF64[((ptr)>>3)]=value; break;
+ default: abort('invalid type for setValue: ' + type);
+ }
+}
+Module['setValue'] = setValue;
+
+// Parallel to setValue.
+function getValue(ptr, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': return HEAP8[(ptr)];
+ case 'i8': return HEAP8[(ptr)];
+ case 'i16': return HEAP16[((ptr)>>1)];
+ case 'i32': return HEAP32[((ptr)>>2)];
+ case 'i64': return HEAP32[((ptr)>>2)];
+ case 'float': return HEAPF32[((ptr)>>2)];
+ case 'double': return HEAPF64[((ptr)>>3)];
+ default: abort('invalid type for setValue: ' + type);
+ }
+ return null;
+}
+Module['getValue'] = getValue;
+
+var ALLOC_NORMAL = 0; // Tries to use _malloc()
+var ALLOC_STACK = 1; // Lives for the duration of the current function call
+var ALLOC_STATIC = 2; // Cannot be freed
+var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
+var ALLOC_NONE = 4; // Do not allocate
+Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
+Module['ALLOC_STACK'] = ALLOC_STACK;
+Module['ALLOC_STATIC'] = ALLOC_STATIC;
+Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;
+Module['ALLOC_NONE'] = ALLOC_NONE;
+
+// allocate(): This is for internal use. You can use it yourself as well, but the interface
+// is a little tricky (see docs right below). The reason is that it is optimized
+// for multiple syntaxes to save space in generated code. So you should
+// normally not use allocate(), and instead allocate memory using _malloc(),
+// initialize it with setValue(), and so forth.
+// @slab: An array of data, or a number. If a number, then the size of the block to allocate,
+// in *bytes* (note that this is sometimes confusing: the next parameter does not
+// affect this!)
+// @types: Either an array of types, one for each byte (or 0 if no type at that position),
+// or a single type which is used for the entire block. This only matters if there
+// is initial data - if @slab is a number, then this does not matter at all and is
+// ignored.
+// @allocator: How to allocate memory, see ALLOC_*
+function allocate(slab, types, allocator, ptr) {
+ var zeroinit, size;
+ if (typeof slab === 'number') {
+ zeroinit = true;
+ size = slab;
+ } else {
+ zeroinit = false;
+ size = slab.length;
+ }
+
+ var singleType = typeof types === 'string' ? types : null;
+
+ var ret;
+ if (allocator == ALLOC_NONE) {
+ ret = ptr;
+ } else {
+ ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
+ }
+
+ if (zeroinit) {
+ var ptr = ret, stop;
+ assert((ret & 3) == 0);
+ stop = ret + (size & ~3);
+ for (; ptr < stop; ptr += 4) {
+ HEAP32[((ptr)>>2)]=0;
+ }
+ stop = ret + size;
+ while (ptr < stop) {
+ HEAP8[((ptr++)|0)]=0;
+ }
+ return ret;
+ }
+
+ if (singleType === 'i8') {
+ if (slab.subarray || slab.slice) {
+ HEAPU8.set(slab, ret);
+ } else {
+ HEAPU8.set(new Uint8Array(slab), ret);
+ }
+ return ret;
+ }
+
+ var i = 0, type, typeSize, previousType;
+ while (i < size) {
+ var curr = slab[i];
+
+ if (typeof curr === 'function') {
+ curr = Runtime.getFunctionIndex(curr);
+ }
+
+ type = singleType || types[i];
+ if (type === 0) {
+ i++;
+ continue;
+ }
+
+ if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
+
+ setValue(ret+i, curr, type);
+
+ // no need to look up size unless type changes, so cache it
+ if (previousType !== type) {
+ typeSize = Runtime.getNativeTypeSize(type);
+ previousType = type;
+ }
+ i += typeSize;
+ }
+
+ return ret;
+}
+Module['allocate'] = allocate;
+
+function Pointer_stringify(ptr, /* optional */ length) {
+ // TODO: use TextDecoder
+ // Find the length, and check for UTF while doing so
+ var hasUtf = false;
+ var t;
+ var i = 0;
+ while (1) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ if (t >= 128) hasUtf = true;
+ else if (t == 0 && !length) break;
+ i++;
+ if (length && i == length) break;
+ }
+ if (!length) length = i;
+
+ var ret = '';
+
+ if (!hasUtf) {
+ var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
+ var curr;
+ while (length > 0) {
+ curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
+ ret = ret ? ret + curr : curr;
+ ptr += MAX_CHUNK;
+ length -= MAX_CHUNK;
+ }
+ return ret;
+ }
+
+ var utf8 = new Runtime.UTF8Processor();
+ for (i = 0; i < length; i++) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ ret += utf8.processCChar(t);
+ }
+ return ret;
+}
+Module['Pointer_stringify'] = Pointer_stringify;
+
+// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF16ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
+ if (codeUnit == 0)
+ return str;
+ ++i;
+ // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
+ str += String.fromCharCode(codeUnit);
+ }
+}
+Module['UTF16ToString'] = UTF16ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
+function stringToUTF16(str, outPtr) {
+ for(var i = 0; i < str.length; ++i) {
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
+ HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP16[(((outPtr)+(str.length*2))>>1)]=0;
+}
+Module['stringToUTF16'] = stringToUTF16;
+
+// Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF32ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
+ if (utf32 == 0)
+ return str;
+ ++i;
+ // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
+ if (utf32 >= 0x10000) {
+ var ch = utf32 - 0x10000;
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
+ } else {
+ str += String.fromCharCode(utf32);
+ }
+ }
+}
+Module['UTF32ToString'] = UTF32ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
+// but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.
+function stringToUTF32(str, outPtr) {
+ var iChar = 0;
+ for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
+ var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
+ var trailSurrogate = str.charCodeAt(++iCodeUnit);
+ codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
+ }
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit;
+ ++iChar;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=0;
+}
+Module['stringToUTF32'] = stringToUTF32;
+
+function demangle(func) {
+ var i = 3;
+ // params, etc.
+ var basicTypes = {
+ 'v': 'void',
+ 'b': 'bool',
+ 'c': 'char',
+ 's': 'short',
+ 'i': 'int',
+ 'l': 'long',
+ 'f': 'float',
+ 'd': 'double',
+ 'w': 'wchar_t',
+ 'a': 'signed char',
+ 'h': 'unsigned char',
+ 't': 'unsigned short',
+ 'j': 'unsigned int',
+ 'm': 'unsigned long',
+ 'x': 'long long',
+ 'y': 'unsigned long long',
+ 'z': '...'
+ };
+ var subs = [];
+ var first = true;
+ function dump(x) {
+ //return;
+ if (x) Module.print(x);
+ Module.print(func);
+ var pre = '';
+ for (var a = 0; a < i; a++) pre += ' ';
+ Module.print (pre + '^');
+ }
+ function parseNested() {
+ i++;
+ if (func[i] === 'K') i++; // ignore const
+ var parts = [];
+ while (func[i] !== 'E') {
+ if (func[i] === 'S') { // substitution
+ i++;
+ var next = func.indexOf('_', i);
+ var num = func.substring(i, next) || 0;
+ parts.push(subs[num] || '?');
+ i = next+1;
+ continue;
+ }
+ if (func[i] === 'C') { // constructor
+ parts.push(parts[parts.length-1]);
+ i += 2;
+ continue;
+ }
+ var size = parseInt(func.substr(i));
+ var pre = size.toString().length;
+ if (!size || !pre) { i--; break; } // counter i++ below us
+ var curr = func.substr(i + pre, size);
+ parts.push(curr);
+ subs.push(curr);
+ i += pre + size;
+ }
+ i++; // skip E
+ return parts;
+ }
+ function parse(rawList, limit, allowVoid) { // main parser
+ limit = limit || Infinity;
+ var ret = '', list = [];
+ function flushList() {
+ return '(' + list.join(', ') + ')';
+ }
+ var name;
+ if (func[i] === 'N') {
+ // namespaced N-E
+ name = parseNested().join('::');
+ limit--;
+ if (limit === 0) return rawList ? [name] : name;
+ } else {
+ // not namespaced
+ if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
+ var size = parseInt(func.substr(i));
+ if (size) {
+ var pre = size.toString().length;
+ name = func.substr(i + pre, size);
+ i += pre + size;
+ }
+ }
+ first = false;
+ if (func[i] === 'I') {
+ i++;
+ var iList = parse(true);
+ var iRet = parse(true, 1, true);
+ ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
+ } else {
+ ret = name;
+ }
+ paramLoop: while (i < func.length && limit-- > 0) {
+ //dump('paramLoop');
+ var c = func[i++];
+ if (c in basicTypes) {
+ list.push(basicTypes[c]);
+ } else {
+ switch (c) {
+ case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
+ case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
+ case 'L': { // literal
+ i++; // skip basic type
+ var end = func.indexOf('E', i);
+ var size = end - i;
+ list.push(func.substr(i, size));
+ i += size + 2; // size + 'EE'
+ break;
+ }
+ case 'A': { // array
+ var size = parseInt(func.substr(i));
+ i += size.toString().length;
+ if (func[i] !== '_') throw '?';
+ i++; // skip _
+ list.push(parse(true, 1, true)[0] + ' [' + size + ']');
+ break;
+ }
+ case 'E': break paramLoop;
+ default: ret += '?' + c; break paramLoop;
+ }
+ }
+ }
+ if (!allowVoid && list.length === 1 && list[0] === 'void') list = []; // avoid (void)
+ if (rawList) {
+ if (ret) {
+ list.push(ret + '?');
+ }
+ return list;
+ } else {
+ return ret + flushList();
+ }
+ }
+ try {
+ // Special-case the entry point, since its name differs from other name mangling.
+ if (func == 'Object._main' || func == '_main') {
+ return 'main()';
+ }
+ if (typeof func === 'number') func = Pointer_stringify(func);
+ if (func[0] !== '_') return func;
+ if (func[1] !== '_') return func; // C function
+ if (func[2] !== 'Z') return func;
+ switch (func[3]) {
+ case 'n': return 'operator new()';
+ case 'd': return 'operator delete()';
+ }
+ return parse();
+ } catch(e) {
+ return func;
+ }
+}
+
+function demangleAll(text) {
+ return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });
+}
+
+function stackTrace() {
+ var stack = new Error().stack;
+ return stack ? demangleAll(stack) : '(no stack trace available)'; // Stack trace is not available at least on IE10 and Safari 6.
+}
+
+// Memory management
+
+var PAGE_SIZE = 4096;
+function alignMemoryPage(x) {
+ return (x+4095)&-4096;
+}
+
+var HEAP;
+var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
+
+var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area
+var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area
+var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk
+
+function enlargeMemory() {
+ abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
+}
+
+var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
+var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 134217728;
+var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
+
+var totalMemory = 4096;
+while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
+ if (totalMemory < 16*1024*1024) {
+ totalMemory *= 2;
+ } else {
+ totalMemory += 16*1024*1024
+ }
+}
+if (totalMemory !== TOTAL_MEMORY) {
+ Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
+ TOTAL_MEMORY = totalMemory;
+}
+
+// Initialize the runtime's memory
+// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
+assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
+ 'JS engine does not provide full typed array support');
+
+var buffer = new ArrayBuffer(TOTAL_MEMORY);
+HEAP8 = new Int8Array(buffer);
+HEAP16 = new Int16Array(buffer);
+HEAP32 = new Int32Array(buffer);
+HEAPU8 = new Uint8Array(buffer);
+HEAPU16 = new Uint16Array(buffer);
+HEAPU32 = new Uint32Array(buffer);
+HEAPF32 = new Float32Array(buffer);
+HEAPF64 = new Float64Array(buffer);
+
+// Endianness check (note: assumes compiler arch was little-endian)
+HEAP32[0] = 255;
+assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
+
+Module['HEAP'] = HEAP;
+Module['HEAP8'] = HEAP8;
+Module['HEAP16'] = HEAP16;
+Module['HEAP32'] = HEAP32;
+Module['HEAPU8'] = HEAPU8;
+Module['HEAPU16'] = HEAPU16;
+Module['HEAPU32'] = HEAPU32;
+Module['HEAPF32'] = HEAPF32;
+Module['HEAPF64'] = HEAPF64;
+
+function callRuntimeCallbacks(callbacks) {
+ while(callbacks.length > 0) {
+ var callback = callbacks.shift();
+ if (typeof callback == 'function') {
+ callback();
+ continue;
+ }
+ var func = callback.func;
+ if (typeof func === 'number') {
+ if (callback.arg === undefined) {
+ Runtime.dynCall('v', func);
+ } else {
+ Runtime.dynCall('vi', func, [callback.arg]);
+ }
+ } else {
+ func(callback.arg === undefined ? null : callback.arg);
+ }
+ }
+}
+
+var __ATPRERUN__ = []; // functions called before the runtime is initialized
+var __ATINIT__ = []; // functions called during startup
+var __ATMAIN__ = []; // functions called when main() is to be run
+var __ATEXIT__ = []; // functions called during shutdown
+var __ATPOSTRUN__ = []; // functions called after the runtime has exited
+
+var runtimeInitialized = false;
+
+function preRun() {
+ // compatibility - merge in anything from Module['preRun'] at this time
+ if (Module['preRun']) {
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
+ while (Module['preRun'].length) {
+ addOnPreRun(Module['preRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPRERUN__);
+}
+
+function ensureInitRuntime() {
+ if (runtimeInitialized) return;
+ runtimeInitialized = true;
+ callRuntimeCallbacks(__ATINIT__);
+}
+
+function preMain() {
+ callRuntimeCallbacks(__ATMAIN__);
+}
+
+function exitRuntime() {
+ callRuntimeCallbacks(__ATEXIT__);
+}
+
+function postRun() {
+ // compatibility - merge in anything from Module['postRun'] at this time
+ if (Module['postRun']) {
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
+ while (Module['postRun'].length) {
+ addOnPostRun(Module['postRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPOSTRUN__);
+}
+
+function addOnPreRun(cb) {
+ __ATPRERUN__.unshift(cb);
+}
+Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;
+
+function addOnInit(cb) {
+ __ATINIT__.unshift(cb);
+}
+Module['addOnInit'] = Module.addOnInit = addOnInit;
+
+function addOnPreMain(cb) {
+ __ATMAIN__.unshift(cb);
+}
+Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;
+
+function addOnExit(cb) {
+ __ATEXIT__.unshift(cb);
+}
+Module['addOnExit'] = Module.addOnExit = addOnExit;
+
+function addOnPostRun(cb) {
+ __ATPOSTRUN__.unshift(cb);
+}
+Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;
+
+// Tools
+
+// This processes a JS string into a C-line array of numbers, 0-terminated.
+// For LLVM-originating strings, see parser.js:parseLLVMString function
+function intArrayFromString(stringy, dontAddNull, length /* optional */) {
+ var ret = (new Runtime.UTF8Processor()).processJSString(stringy);
+ if (length) {
+ ret.length = length;
+ }
+ if (!dontAddNull) {
+ ret.push(0);
+ }
+ return ret;
+}
+Module['intArrayFromString'] = intArrayFromString;
+
+function intArrayToString(array) {
+ var ret = [];
+ for (var i = 0; i < array.length; i++) {
+ var chr = array[i];
+ if (chr > 0xFF) {
+ chr &= 0xFF;
+ }
+ ret.push(String.fromCharCode(chr));
+ }
+ return ret.join('');
+}
+Module['intArrayToString'] = intArrayToString;
+
+// Write a Javascript array to somewhere in the heap
+function writeStringToMemory(string, buffer, dontAddNull) {
+ var array = intArrayFromString(string, dontAddNull);
+ var i = 0;
+ while (i < array.length) {
+ var chr = array[i];
+ HEAP8[(((buffer)+(i))|0)]=chr;
+ i = i + 1;
+ }
+}
+Module['writeStringToMemory'] = writeStringToMemory;
+
+function writeArrayToMemory(array, buffer) {
+ for (var i = 0; i < array.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=array[i];
+ }
+}
+Module['writeArrayToMemory'] = writeArrayToMemory;
+
+function writeAsciiToMemory(str, buffer, dontAddNull) {
+ for (var i = 0; i < str.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=str.charCodeAt(i);
+ }
+ if (!dontAddNull) HEAP8[(((buffer)+(str.length))|0)]=0;
+}
+Module['writeAsciiToMemory'] = writeAsciiToMemory;
+
+function unSign(value, bits, ignore) {
+ if (value >= 0) {
+ return value;
+ }
+ return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
+ : Math.pow(2, bits) + value;
+}
+function reSign(value, bits, ignore) {
+ if (value <= 0) {
+ return value;
+ }
+ var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
+ : Math.pow(2, bits-1);
+ if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
+ // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
+ // TODO: In i64 mode 1, resign the two parts separately and safely
+ value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
+ }
+ return value;
+}
+
+// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
+if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
+ var ah = a >>> 16;
+ var al = a & 0xffff;
+ var bh = b >>> 16;
+ var bl = b & 0xffff;
+ return (al*bl + ((ah*bl + al*bh) << 16))|0;
+};
+Math.imul = Math['imul'];
+
+
+var Math_abs = Math.abs;
+var Math_cos = Math.cos;
+var Math_sin = Math.sin;
+var Math_tan = Math.tan;
+var Math_acos = Math.acos;
+var Math_asin = Math.asin;
+var Math_atan = Math.atan;
+var Math_atan2 = Math.atan2;
+var Math_exp = Math.exp;
+var Math_log = Math.log;
+var Math_sqrt = Math.sqrt;
+var Math_ceil = Math.ceil;
+var Math_floor = Math.floor;
+var Math_pow = Math.pow;
+var Math_imul = Math.imul;
+var Math_fround = Math.fround;
+var Math_min = Math.min;
+
+// A counter of dependencies for calling run(). If we need to
+// do asynchronous work before running, increment this and
+// decrement it. Incrementing must happen in a place like
+// PRE_RUN_ADDITIONS (used by emcc to add file preloading).
+// Note that you can add dependencies in preRun, even though
+// it happens right before run - run will be postponed until
+// the dependencies are met.
+var runDependencies = 0;
+var runDependencyWatcher = null;
+var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
+
+function addRunDependency(id) {
+ runDependencies++;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+}
+Module['addRunDependency'] = addRunDependency;
+function removeRunDependency(id) {
+ runDependencies--;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+ if (runDependencies == 0) {
+ if (runDependencyWatcher !== null) {
+ clearInterval(runDependencyWatcher);
+ runDependencyWatcher = null;
+ }
+ if (dependenciesFulfilled) {
+ var callback = dependenciesFulfilled;
+ dependenciesFulfilled = null;
+ callback(); // can add another dependenciesFulfilled
+ }
+ }
+}
+Module['removeRunDependency'] = removeRunDependency;
+
+Module["preloadedImages"] = {}; // maps url to image data
+Module["preloadedAudios"] = {}; // maps url to audio data
+
+
+var memoryInitializer = null;
+
+// === Body ===
+
+
+
+
+
+STATIC_BASE = 8;
+
+STATICTOP = STATIC_BASE + Runtime.alignMemory(531);
+/* global initializers */ __ATINIT__.push();
+
+
+/* memory initializer */ allocate([101,114,114,111,114,58,32,37,100,10,0,0,0,0,0,0,102,105,110,97,108,58,32,37,100,46,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
+
+
+
+
+var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8);
+
+assert(tempDoublePtr % 8 == 0);
+
+function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+}
+
+function copyTempDouble(ptr) {
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+ HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
+
+ HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
+
+ HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
+
+ HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
+
+}
+
+
+
+
+
+
+ var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};
+
+ var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
+
+
+ var ___errno_state=0;function ___setErrNo(value) {
+ // For convenient setting and returning of errno.
+ HEAP32[((___errno_state)>>2)]=value;
+ return value;
+ }
+
+ var PATH={splitPath:function (filename) {
+ var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
+ return splitPathRe.exec(filename).slice(1);
+ },normalizeArray:function (parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length - 1; i >= 0; i--) {
+ var last = parts[i];
+ if (last === '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+ return parts;
+ },normalize:function (path) {
+ var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.substr(-1) === '/';
+ // Normalize the path
+ path = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+ return (isAbsolute ? '/' : '') + path;
+ },dirname:function (path) {
+ var result = PATH.splitPath(path),
+ root = result[0],
+ dir = result[1];
+ if (!root && !dir) {
+ // No dirname whatsoever
+ return '.';
+ }
+ if (dir) {
+ // It has a dirname, strip trailing slash
+ dir = dir.substr(0, dir.length - 1);
+ }
+ return root + dir;
+ },basename:function (path) {
+ // EMSCRIPTEN return '/'' for '/', not an empty string
+ if (path === '/') return '/';
+ var lastSlash = path.lastIndexOf('/');
+ if (lastSlash === -1) return path;
+ return path.substr(lastSlash+1);
+ },extname:function (path) {
+ return PATH.splitPath(path)[3];
+ },join:function () {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return PATH.normalize(paths.join('/'));
+ },join2:function (l, r) {
+ return PATH.normalize(l + '/' + r);
+ },resolve:function () {
+ var resolvedPath = '',
+ resolvedAbsolute = false;
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0) ? arguments[i] : FS.cwd();
+ // Skip empty and invalid entries
+ if (typeof path !== 'string') {
+ throw new TypeError('Arguments to path.resolve must be strings');
+ } else if (!path) {
+ continue;
+ }
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+ }
+ // At this point the path should be resolved to a full absolute path, but
+ // handle relative paths to be safe (might happen when process.cwd() fails)
+ resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+ },relative:function (from, to) {
+ from = PATH.resolve(from).substr(1);
+ to = PATH.resolve(to).substr(1);
+ function trim(arr) {
+ var start = 0;
+ for (; start < arr.length; start++) {
+ if (arr[start] !== '') break;
+ }
+ var end = arr.length - 1;
+ for (; end >= 0; end--) {
+ if (arr[end] !== '') break;
+ }
+ if (start > end) return [];
+ return arr.slice(start, end - start + 1);
+ }
+ var fromParts = trim(from.split('/'));
+ var toParts = trim(to.split('/'));
+ var length = Math.min(fromParts.length, toParts.length);
+ var samePartsLength = length;
+ for (var i = 0; i < length; i++) {
+ if (fromParts[i] !== toParts[i]) {
+ samePartsLength = i;
+ break;
+ }
+ }
+ var outputParts = [];
+ for (var i = samePartsLength; i < fromParts.length; i++) {
+ outputParts.push('..');
+ }
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
+ return outputParts.join('/');
+ }};
+
+ var TTY={ttys:[],init:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // currently, FS.init does not distinguish if process.stdin is a file or TTY
+ // // device, it always assumes it's a TTY device. because of this, we're forcing
+ // // process.stdin to UTF8 encoding to at least make stdin reading compatible
+ // // with text files until FS.init can be refactored.
+ // process['stdin']['setEncoding']('utf8');
+ // }
+ },shutdown:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
+ // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
+ // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
+ // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
+ // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
+ // process['stdin']['pause']();
+ // }
+ },register:function (dev, ops) {
+ TTY.ttys[dev] = { input: [], output: [], ops: ops };
+ FS.registerDevice(dev, TTY.stream_ops);
+ },stream_ops:{open:function (stream) {
+ var tty = TTY.ttys[stream.node.rdev];
+ if (!tty) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ stream.tty = tty;
+ stream.seekable = false;
+ },close:function (stream) {
+ // flush any pending line data
+ if (stream.tty.output.length) {
+ stream.tty.ops.put_char(stream.tty, 10);
+ }
+ },read:function (stream, buffer, offset, length, pos /* ignored */) {
+ if (!stream.tty || !stream.tty.ops.get_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = stream.tty.ops.get_char(stream.tty);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, pos) {
+ if (!stream.tty || !stream.tty.ops.put_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ for (var i = 0; i < length; i++) {
+ try {
+ stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }},default_tty_ops:{get_char:function (tty) {
+ if (!tty.input.length) {
+ var result = null;
+ if (ENVIRONMENT_IS_NODE) {
+ result = process['stdin']['read']();
+ if (!result) {
+ if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
+ return null; // EOF
+ }
+ return undefined; // no data available
+ }
+ } else if (typeof window != 'undefined' &&
+ typeof window.prompt == 'function') {
+ // Browser.
+ result = window.prompt('Input: '); // returns null on cancel
+ if (result !== null) {
+ result += '\n';
+ }
+ } else if (typeof readline == 'function') {
+ // Command line.
+ result = readline();
+ if (result !== null) {
+ result += '\n';
+ }
+ }
+ if (!result) {
+ return null;
+ }
+ tty.input = intArrayFromString(result, true);
+ }
+ return tty.input.shift();
+ },put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['print'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }},default_tty1_ops:{put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['printErr'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }}};
+
+ var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
+ return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
+ // no supported
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (!MEMFS.ops_table) {
+ MEMFS.ops_table = {
+ dir: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ lookup: MEMFS.node_ops.lookup,
+ mknod: MEMFS.node_ops.mknod,
+ rename: MEMFS.node_ops.rename,
+ unlink: MEMFS.node_ops.unlink,
+ rmdir: MEMFS.node_ops.rmdir,
+ readdir: MEMFS.node_ops.readdir,
+ symlink: MEMFS.node_ops.symlink
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek
+ }
+ },
+ file: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek,
+ read: MEMFS.stream_ops.read,
+ write: MEMFS.stream_ops.write,
+ allocate: MEMFS.stream_ops.allocate,
+ mmap: MEMFS.stream_ops.mmap
+ }
+ },
+ link: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ readlink: MEMFS.node_ops.readlink
+ },
+ stream: {}
+ },
+ chrdev: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: FS.chrdev_stream_ops
+ },
+ };
+ }
+ var node = FS.createNode(parent, name, mode, dev);
+ if (FS.isDir(node.mode)) {
+ node.node_ops = MEMFS.ops_table.dir.node;
+ node.stream_ops = MEMFS.ops_table.dir.stream;
+ node.contents = {};
+ } else if (FS.isFile(node.mode)) {
+ node.node_ops = MEMFS.ops_table.file.node;
+ node.stream_ops = MEMFS.ops_table.file.stream;
+ node.contents = [];
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ } else if (FS.isLink(node.mode)) {
+ node.node_ops = MEMFS.ops_table.link.node;
+ node.stream_ops = MEMFS.ops_table.link.stream;
+ } else if (FS.isChrdev(node.mode)) {
+ node.node_ops = MEMFS.ops_table.chrdev.node;
+ node.stream_ops = MEMFS.ops_table.chrdev.stream;
+ }
+ node.timestamp = Date.now();
+ // add the new node to the parent
+ if (parent) {
+ parent.contents[name] = node;
+ }
+ return node;
+ },ensureFlexible:function (node) {
+ if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
+ var contents = node.contents;
+ node.contents = Array.prototype.slice.call(contents);
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ }
+ },node_ops:{getattr:function (node) {
+ var attr = {};
+ // device numbers reuse inode numbers.
+ attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
+ attr.ino = node.id;
+ attr.mode = node.mode;
+ attr.nlink = 1;
+ attr.uid = 0;
+ attr.gid = 0;
+ attr.rdev = node.rdev;
+ if (FS.isDir(node.mode)) {
+ attr.size = 4096;
+ } else if (FS.isFile(node.mode)) {
+ attr.size = node.contents.length;
+ } else if (FS.isLink(node.mode)) {
+ attr.size = node.link.length;
+ } else {
+ attr.size = 0;
+ }
+ attr.atime = new Date(node.timestamp);
+ attr.mtime = new Date(node.timestamp);
+ attr.ctime = new Date(node.timestamp);
+ // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
+ // but this is not required by the standard.
+ attr.blksize = 4096;
+ attr.blocks = Math.ceil(attr.size / attr.blksize);
+ return attr;
+ },setattr:function (node, attr) {
+ if (attr.mode !== undefined) {
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ node.timestamp = attr.timestamp;
+ }
+ if (attr.size !== undefined) {
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ if (attr.size < contents.length) contents.length = attr.size;
+ else while (attr.size > contents.length) contents.push(0);
+ }
+ },lookup:function (parent, name) {
+ throw FS.genericErrors[ERRNO_CODES.ENOENT];
+ },mknod:function (parent, name, mode, dev) {
+ return MEMFS.createNode(parent, name, mode, dev);
+ },rename:function (old_node, new_dir, new_name) {
+ // if we're overwriting a directory at new_name, make sure it's empty.
+ if (FS.isDir(old_node.mode)) {
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ }
+ if (new_node) {
+ for (var i in new_node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ }
+ }
+ // do the internal rewiring
+ delete old_node.parent.contents[old_node.name];
+ old_node.name = new_name;
+ new_dir.contents[new_name] = old_node;
+ old_node.parent = new_dir;
+ },unlink:function (parent, name) {
+ delete parent.contents[name];
+ },rmdir:function (parent, name) {
+ var node = FS.lookupNode(parent, name);
+ for (var i in node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ delete parent.contents[name];
+ },readdir:function (node) {
+ var entries = ['.', '..']
+ for (var key in node.contents) {
+ if (!node.contents.hasOwnProperty(key)) {
+ continue;
+ }
+ entries.push(key);
+ }
+ return entries;
+ },symlink:function (parent, newname, oldpath) {
+ var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
+ node.link = oldpath;
+ return node;
+ },readlink:function (node) {
+ if (!FS.isLink(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return node.link;
+ }},stream_ops:{read:function (stream, buffer, offset, length, position) {
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (size > 8 && contents.subarray) { // non-trivial, and typed array
+ buffer.set(contents.subarray(position, position + size), offset);
+ } else
+ {
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ }
+ return size;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ var node = stream.node;
+ node.timestamp = Date.now();
+ var contents = node.contents;
+ if (length && contents.length === 0 && position === 0 && buffer.subarray) {
+ // just replace it with the new data
+ if (canOwn && offset === 0) {
+ node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
+ node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
+ } else {
+ node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
+ node.contentMode = MEMFS.CONTENT_FIXED;
+ }
+ return length;
+ }
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ while (contents.length < position) contents.push(0);
+ for (var i = 0; i < length; i++) {
+ contents[position + i] = buffer[offset + i];
+ }
+ return length;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ position += stream.node.contents.length;
+ }
+ }
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ stream.ungotten = [];
+ stream.position = position;
+ return position;
+ },allocate:function (stream, offset, length) {
+ MEMFS.ensureFlexible(stream.node);
+ var contents = stream.node.contents;
+ var limit = offset + length;
+ while (limit > contents.length) contents.push(0);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ if (!FS.isFile(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ var ptr;
+ var allocated;
+ var contents = stream.node.contents;
+ // Only make a new copy when MAP_PRIVATE is specified.
+ if ( !(flags & 2) &&
+ (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
+ // We can't emulate MAP_SHARED when the file is not backed by the buffer
+ // we're mapping to (e.g. the HEAP buffer).
+ allocated = false;
+ ptr = contents.byteOffset;
+ } else {
+ // Try to avoid unnecessary slices.
+ if (position > 0 || position + length < contents.length) {
+ if (contents.subarray) {
+ contents = contents.subarray(position, position + length);
+ } else {
+ contents = Array.prototype.slice.call(contents, position, position + length);
+ }
+ }
+ allocated = true;
+ ptr = _malloc(length);
+ if (!ptr) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
+ }
+ buffer.set(contents, ptr);
+ }
+ return { ptr: ptr, allocated: allocated };
+ }}};
+
+ var IDBFS={dbs:{},indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
+ // reuse all of the core MEMFS functionality
+ return MEMFS.mount.apply(null, arguments);
+ },syncfs:function (mount, populate, callback) {
+ IDBFS.getLocalSet(mount, function(err, local) {
+ if (err) return callback(err);
+
+ IDBFS.getRemoteSet(mount, function(err, remote) {
+ if (err) return callback(err);
+
+ var src = populate ? remote : local;
+ var dst = populate ? local : remote;
+
+ IDBFS.reconcile(src, dst, callback);
+ });
+ });
+ },getDB:function (name, callback) {
+ // check the cache first
+ var db = IDBFS.dbs[name];
+ if (db) {
+ return callback(null, db);
+ }
+
+ var req;
+ try {
+ req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
+ } catch (e) {
+ return callback(e);
+ }
+ req.onupgradeneeded = function(e) {
+ var db = e.target.result;
+ var transaction = e.target.transaction;
+
+ var fileStore;
+
+ if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
+ fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ } else {
+ fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
+ }
+
+ fileStore.createIndex('timestamp', 'timestamp', { unique: false });
+ };
+ req.onsuccess = function() {
+ db = req.result;
+
+ // add to the cache
+ IDBFS.dbs[name] = db;
+ callback(null, db);
+ };
+ req.onerror = function() {
+ callback(this.error);
+ };
+ },getLocalSet:function (mount, callback) {
+ var entries = {};
+
+ function isRealDir(p) {
+ return p !== '.' && p !== '..';
+ };
+ function toAbsolute(root) {
+ return function(p) {
+ return PATH.join2(root, p);
+ }
+ };
+
+ var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
+
+ while (check.length) {
+ var path = check.pop();
+ var stat;
+
+ try {
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
+ }
+
+ entries[path] = { timestamp: stat.mtime };
+ }
+
+ return callback(null, { type: 'local', entries: entries });
+ },getRemoteSet:function (mount, callback) {
+ var entries = {};
+
+ IDBFS.getDB(mount.mountpoint, function(err, db) {
+ if (err) return callback(err);
+
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
+ transaction.onerror = function() { callback(this.error); };
+
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ var index = store.index('timestamp');
+
+ index.openKeyCursor().onsuccess = function(event) {
+ var cursor = event.target.result;
+
+ if (!cursor) {
+ return callback(null, { type: 'remote', db: db, entries: entries });
+ }
+
+ entries[cursor.primaryKey] = { timestamp: cursor.key };
+
+ cursor.continue();
+ };
+ });
+ },loadLocalEntry:function (path, callback) {
+ var stat, node;
+
+ try {
+ var lookup = FS.lookupPath(path);
+ node = lookup.node;
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode });
+ } else if (FS.isFile(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+ },storeLocalEntry:function (path, entry, callback) {
+ try {
+ if (FS.isDir(entry.mode)) {
+ FS.mkdir(path, entry.mode);
+ } else if (FS.isFile(entry.mode)) {
+ FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+
+ FS.utime(path, entry.timestamp, entry.timestamp);
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },removeLocalEntry:function (path, callback) {
+ try {
+ var lookup = FS.lookupPath(path);
+ var stat = FS.stat(path);
+
+ if (FS.isDir(stat.mode)) {
+ FS.rmdir(path);
+ } else if (FS.isFile(stat.mode)) {
+ FS.unlink(path);
+ }
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },loadRemoteEntry:function (store, path, callback) {
+ var req = store.get(path);
+ req.onsuccess = function(event) { callback(null, event.target.result); };
+ req.onerror = function() { callback(this.error); };
+ },storeRemoteEntry:function (store, path, entry, callback) {
+ var req = store.put(entry, path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },removeRemoteEntry:function (store, path, callback) {
+ var req = store.delete(path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },reconcile:function (src, dst, callback) {
+ var total = 0;
+
+ var create = [];
+ Object.keys(src.entries).forEach(function (key) {
+ var e = src.entries[key];
+ var e2 = dst.entries[key];
+ if (!e2 || e.timestamp > e2.timestamp) {
+ create.push(key);
+ total++;
+ }
+ });
+
+ var remove = [];
+ Object.keys(dst.entries).forEach(function (key) {
+ var e = dst.entries[key];
+ var e2 = src.entries[key];
+ if (!e2) {
+ remove.push(key);
+ total++;
+ }
+ });
+
+ if (!total) {
+ return callback(null);
+ }
+
+ var errored = false;
+ var completed = 0;
+ var db = src.type === 'remote' ? src.db : dst.db;
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= total) {
+ return callback(null);
+ }
+ };
+
+ transaction.onerror = function() { done(this.error); };
+
+ // sort paths in ascending order so directory entries are created
+ // before the files inside them
+ create.sort().forEach(function (path) {
+ if (dst.type === 'local') {
+ IDBFS.loadRemoteEntry(store, path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeLocalEntry(path, entry, done);
+ });
+ } else {
+ IDBFS.loadLocalEntry(path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeRemoteEntry(store, path, entry, done);
+ });
+ }
+ });
+
+ // sort paths in descending order so files are deleted before their
+ // parent directories
+ remove.sort().reverse().forEach(function(path) {
+ if (dst.type === 'local') {
+ IDBFS.removeLocalEntry(path, done);
+ } else {
+ IDBFS.removeRemoteEntry(store, path, done);
+ }
+ });
+ }};
+
+ var NODEFS={isWindows:false,staticInit:function () {
+ NODEFS.isWindows = !!process.platform.match(/^win/);
+ },mount:function (mount) {
+ assert(ENVIRONMENT_IS_NODE);
+ return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node = FS.createNode(parent, name, mode);
+ node.node_ops = NODEFS.node_ops;
+ node.stream_ops = NODEFS.stream_ops;
+ return node;
+ },getMode:function (path) {
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ if (NODEFS.isWindows) {
+ // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so
+ // propagate write bits to execute bits.
+ stat.mode = stat.mode | ((stat.mode & 146) >> 1);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return stat.mode;
+ },realPath:function (node) {
+ var parts = [];
+ while (node.parent !== node) {
+ parts.push(node.name);
+ node = node.parent;
+ }
+ parts.push(node.mount.opts.root);
+ parts.reverse();
+ return PATH.join.apply(null, parts);
+ },flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function (flags) {
+ if (flags in NODEFS.flagsToPermissionStringMap) {
+ return NODEFS.flagsToPermissionStringMap[flags];
+ } else {
+ return flags;
+ }
+ },node_ops:{getattr:function (node) {
+ var path = NODEFS.realPath(node);
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
+ // See http://support.microsoft.com/kb/140365
+ if (NODEFS.isWindows && !stat.blksize) {
+ stat.blksize = 4096;
+ }
+ if (NODEFS.isWindows && !stat.blocks) {
+ stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
+ }
+ return {
+ dev: stat.dev,
+ ino: stat.ino,
+ mode: stat.mode,
+ nlink: stat.nlink,
+ uid: stat.uid,
+ gid: stat.gid,
+ rdev: stat.rdev,
+ size: stat.size,
+ atime: stat.atime,
+ mtime: stat.mtime,
+ ctime: stat.ctime,
+ blksize: stat.blksize,
+ blocks: stat.blocks
+ };
+ },setattr:function (node, attr) {
+ var path = NODEFS.realPath(node);
+ try {
+ if (attr.mode !== undefined) {
+ fs.chmodSync(path, attr.mode);
+ // update the common node structure mode as well
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ var date = new Date(attr.timestamp);
+ fs.utimesSync(path, date, date);
+ }
+ if (attr.size !== undefined) {
+ fs.truncateSync(path, attr.size);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },lookup:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ var mode = NODEFS.getMode(path);
+ return NODEFS.createNode(parent, name, mode);
+ },mknod:function (parent, name, mode, dev) {
+ var node = NODEFS.createNode(parent, name, mode, dev);
+ // create the backing node for this in the fs root as well
+ var path = NODEFS.realPath(node);
+ try {
+ if (FS.isDir(node.mode)) {
+ fs.mkdirSync(path, node.mode);
+ } else {
+ fs.writeFileSync(path, '', { mode: node.mode });
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return node;
+ },rename:function (oldNode, newDir, newName) {
+ var oldPath = NODEFS.realPath(oldNode);
+ var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
+ try {
+ fs.renameSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },unlink:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.unlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },rmdir:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.rmdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readdir:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },symlink:function (parent, newName, oldPath) {
+ var newPath = PATH.join2(NODEFS.realPath(parent), newName);
+ try {
+ fs.symlinkSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readlink:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }},stream_ops:{open:function (stream) {
+ var path = NODEFS.realPath(stream.node);
+ try {
+ if (FS.isFile(stream.node.mode)) {
+ stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },close:function (stream) {
+ try {
+ if (FS.isFile(stream.node.mode) && stream.nfd) {
+ fs.closeSync(stream.nfd);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },read:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(length);
+ var res;
+ try {
+ res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ if (res > 0) {
+ for (var i = 0; i < res; i++) {
+ buffer[offset + i] = nbuffer[i];
+ }
+ }
+ return res;
+ },write:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
+ var res;
+ try {
+ res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return res;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ try {
+ var stat = fs.fstatSync(stream.nfd);
+ position += stat.size;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }
+ }
+
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ stream.position = position;
+ return position;
+ }}};
+
+ var _stdin=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stdout=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stderr=allocate(1, "i32*", ALLOC_STATIC);
+
+ function _fflush(stream) {
+ // int fflush(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html
+ // we don't currently perform any user-space buffering of data
+ }var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},handleFSError:function (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
+ return ___setErrNo(e.errno);
+ },lookupPath:function (path, opts) {
+ path = PATH.resolve(FS.cwd(), path);
+ opts = opts || {};
+
+ var defaults = {
+ follow_mount: true,
+ recurse_count: 0
+ };
+ for (var key in defaults) {
+ if (opts[key] === undefined) {
+ opts[key] = defaults[key];
+ }
+ }
+
+ if (opts.recurse_count > 8) { // max recursive lookup of 8
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+
+ // split the path
+ var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), false);
+
+ // start at the root
+ var current = FS.root;
+ var current_path = '/';
+
+ for (var i = 0; i < parts.length; i++) {
+ var islast = (i === parts.length-1);
+ if (islast && opts.parent) {
+ // stop resolving
+ break;
+ }
+
+ current = FS.lookupNode(current, parts[i]);
+ current_path = PATH.join2(current_path, parts[i]);
+
+ // jump to the mount's root node if this is a mountpoint
+ if (FS.isMountpoint(current)) {
+ if (!islast || (islast && opts.follow_mount)) {
+ current = current.mounted.root;
+ }
+ }
+
+ // by default, lookupPath will not follow a symlink if it is the final path component.
+ // setting opts.follow = true will override this behavior.
+ if (!islast || opts.follow) {
+ var count = 0;
+ while (FS.isLink(current.mode)) {
+ var link = FS.readlink(current_path);
+ current_path = PATH.resolve(PATH.dirname(current_path), link);
+
+ var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
+ current = lookup.node;
+
+ if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+ }
+ }
+ }
+
+ return { path: current_path, node: current };
+ },getPath:function (node) {
+ var path;
+ while (true) {
+ if (FS.isRoot(node)) {
+ var mount = node.mount.mountpoint;
+ if (!path) return mount;
+ return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
+ }
+ path = path ? node.name + '/' + path : node.name;
+ node = node.parent;
+ }
+ },hashName:function (parentid, name) {
+ var hash = 0;
+
+
+ for (var i = 0; i < name.length; i++) {
+ hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
+ }
+ return ((parentid + hash) >>> 0) % FS.nameTable.length;
+ },hashAddNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ node.name_next = FS.nameTable[hash];
+ FS.nameTable[hash] = node;
+ },hashRemoveNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ if (FS.nameTable[hash] === node) {
+ FS.nameTable[hash] = node.name_next;
+ } else {
+ var current = FS.nameTable[hash];
+ while (current) {
+ if (current.name_next === node) {
+ current.name_next = node.name_next;
+ break;
+ }
+ current = current.name_next;
+ }
+ }
+ },lookupNode:function (parent, name) {
+ var err = FS.mayLookup(parent);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ var hash = FS.hashName(parent.id, name);
+ for (var node = FS.nameTable[hash]; node; node = node.name_next) {
+ var nodeName = node.name;
+ if (node.parent.id === parent.id && nodeName === name) {
+ return node;
+ }
+ }
+ // if we failed to find it in the cache, call into the VFS
+ return FS.lookup(parent, name);
+ },createNode:function (parent, name, mode, rdev) {
+ if (!FS.FSNode) {
+ FS.FSNode = function(parent, name, mode, rdev) {
+ if (!parent) {
+ parent = this; // root node sets parent to itself
+ }
+ this.parent = parent;
+ this.mount = parent.mount;
+ this.mounted = null;
+ this.id = FS.nextInode++;
+ this.name = name;
+ this.mode = mode;
+ this.node_ops = {};
+ this.stream_ops = {};
+ this.rdev = rdev;
+ };
+
+ FS.FSNode.prototype = {};
+
+ // compatibility
+ var readMode = 292 | 73;
+ var writeMode = 146;
+
+ // NOTE we must use Object.defineProperties instead of individual calls to
+ // Object.defineProperty in order to make closure compiler happy
+ Object.defineProperties(FS.FSNode.prototype, {
+ read: {
+ get: function() { return (this.mode & readMode) === readMode; },
+ set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
+ },
+ write: {
+ get: function() { return (this.mode & writeMode) === writeMode; },
+ set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
+ },
+ isFolder: {
+ get: function() { return FS.isDir(this.mode); },
+ },
+ isDevice: {
+ get: function() { return FS.isChrdev(this.mode); },
+ },
+ });
+ }
+
+ var node = new FS.FSNode(parent, name, mode, rdev);
+
+ FS.hashAddNode(node);
+
+ return node;
+ },destroyNode:function (node) {
+ FS.hashRemoveNode(node);
+ },isRoot:function (node) {
+ return node === node.parent;
+ },isMountpoint:function (node) {
+ return !!node.mounted;
+ },isFile:function (mode) {
+ return (mode & 61440) === 32768;
+ },isDir:function (mode) {
+ return (mode & 61440) === 16384;
+ },isLink:function (mode) {
+ return (mode & 61440) === 40960;
+ },isChrdev:function (mode) {
+ return (mode & 61440) === 8192;
+ },isBlkdev:function (mode) {
+ return (mode & 61440) === 24576;
+ },isFIFO:function (mode) {
+ return (mode & 61440) === 4096;
+ },isSocket:function (mode) {
+ return (mode & 49152) === 49152;
+ },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
+ var flags = FS.flagModes[str];
+ if (typeof flags === 'undefined') {
+ throw new Error('Unknown file open mode: ' + str);
+ }
+ return flags;
+ },flagsToPermissionString:function (flag) {
+ var accmode = flag & 2097155;
+ var perms = ['r', 'w', 'rw'][accmode];
+ if ((flag & 512)) {
+ perms += 'w';
+ }
+ return perms;
+ },nodePermissions:function (node, perms) {
+ if (FS.ignorePermissions) {
+ return 0;
+ }
+ // return 0 if any user, group or owner bits are set.
+ if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
+ return ERRNO_CODES.EACCES;
+ }
+ return 0;
+ },mayLookup:function (dir) {
+ return FS.nodePermissions(dir, 'x');
+ },mayCreate:function (dir, name) {
+ try {
+ var node = FS.lookupNode(dir, name);
+ return ERRNO_CODES.EEXIST;
+ } catch (e) {
+ }
+ return FS.nodePermissions(dir, 'wx');
+ },mayDelete:function (dir, name, isdir) {
+ var node;
+ try {
+ node = FS.lookupNode(dir, name);
+ } catch (e) {
+ return e.errno;
+ }
+ var err = FS.nodePermissions(dir, 'wx');
+ if (err) {
+ return err;
+ }
+ if (isdir) {
+ if (!FS.isDir(node.mode)) {
+ return ERRNO_CODES.ENOTDIR;
+ }
+ if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
+ return ERRNO_CODES.EBUSY;
+ }
+ } else {
+ if (FS.isDir(node.mode)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return 0;
+ },mayOpen:function (node, flags) {
+ if (!node) {
+ return ERRNO_CODES.ENOENT;
+ }
+ if (FS.isLink(node.mode)) {
+ return ERRNO_CODES.ELOOP;
+ } else if (FS.isDir(node.mode)) {
+ if ((flags & 2097155) !== 0 || // opening for write
+ (flags & 512)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
+ },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
+ fd_start = fd_start || 0;
+ fd_end = fd_end || FS.MAX_OPEN_FDS;
+ for (var fd = fd_start; fd <= fd_end; fd++) {
+ if (!FS.streams[fd]) {
+ return fd;
+ }
+ }
+ throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
+ },getStream:function (fd) {
+ return FS.streams[fd];
+ },createStream:function (stream, fd_start, fd_end) {
+ if (!FS.FSStream) {
+ FS.FSStream = function(){};
+ FS.FSStream.prototype = {};
+ // compatibility
+ Object.defineProperties(FS.FSStream.prototype, {
+ object: {
+ get: function() { return this.node; },
+ set: function(val) { this.node = val; }
+ },
+ isRead: {
+ get: function() { return (this.flags & 2097155) !== 1; }
+ },
+ isWrite: {
+ get: function() { return (this.flags & 2097155) !== 0; }
+ },
+ isAppend: {
+ get: function() { return (this.flags & 1024); }
+ }
+ });
+ }
+ if (0) {
+ // reuse the object
+ stream.__proto__ = FS.FSStream.prototype;
+ } else {
+ var newStream = new FS.FSStream();
+ for (var p in stream) {
+ newStream[p] = stream[p];
+ }
+ stream = newStream;
+ }
+ var fd = FS.nextfd(fd_start, fd_end);
+ stream.fd = fd;
+ FS.streams[fd] = stream;
+ return stream;
+ },closeStream:function (fd) {
+ FS.streams[fd] = null;
+ },getStreamFromPtr:function (ptr) {
+ return FS.streams[ptr - 1];
+ },getPtrForStream:function (stream) {
+ return stream ? stream.fd + 1 : 0;
+ },chrdev_stream_ops:{open:function (stream) {
+ var device = FS.getDevice(stream.node.rdev);
+ // override node's stream ops with the device's
+ stream.stream_ops = device.stream_ops;
+ // forward the open call
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ },llseek:function () {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }},major:function (dev) {
+ return ((dev) >> 8);
+ },minor:function (dev) {
+ return ((dev) & 0xff);
+ },makedev:function (ma, mi) {
+ return ((ma) << 8 | (mi));
+ },registerDevice:function (dev, ops) {
+ FS.devices[dev] = { stream_ops: ops };
+ },getDevice:function (dev) {
+ return FS.devices[dev];
+ },getMounts:function (mount) {
+ var mounts = [];
+ var check = [mount];
+
+ while (check.length) {
+ var m = check.pop();
+
+ mounts.push(m);
+
+ check.push.apply(check, m.mounts);
+ }
+
+ return mounts;
+ },syncfs:function (populate, callback) {
+ if (typeof(populate) === 'function') {
+ callback = populate;
+ populate = false;
+ }
+
+ var mounts = FS.getMounts(FS.root.mount);
+ var completed = 0;
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= mounts.length) {
+ callback(null);
+ }
+ };
+
+ // sync all mounts
+ mounts.forEach(function (mount) {
+ if (!mount.type.syncfs) {
+ return done(null);
+ }
+ mount.type.syncfs(mount, populate, done);
+ });
+ },mount:function (type, opts, mountpoint) {
+ var root = mountpoint === '/';
+ var pseudo = !mountpoint;
+ var node;
+
+ if (root && FS.root) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ } else if (!root && !pseudo) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ mountpoint = lookup.path; // use the absolute path
+ node = lookup.node;
+
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+
+ if (!FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ }
+
+ var mount = {
+ type: type,
+ opts: opts,
+ mountpoint: mountpoint,
+ mounts: []
+ };
+
+ // create a root node for the fs
+ var mountRoot = type.mount(mount);
+ mountRoot.mount = mount;
+ mount.root = mountRoot;
+
+ if (root) {
+ FS.root = mountRoot;
+ } else if (node) {
+ // set as a mountpoint
+ node.mounted = mount;
+
+ // add the new mount to the current mount's children
+ if (node.mount) {
+ node.mount.mounts.push(mount);
+ }
+ }
+
+ return mountRoot;
+ },unmount:function (mountpoint) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ if (!FS.isMountpoint(lookup.node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ // destroy the nodes for this mount, and all its child mounts
+ var node = lookup.node;
+ var mount = node.mounted;
+ var mounts = FS.getMounts(mount);
+
+ Object.keys(FS.nameTable).forEach(function (hash) {
+ var current = FS.nameTable[hash];
+
+ while (current) {
+ var next = current.name_next;
+
+ if (mounts.indexOf(current.mount) !== -1) {
+ FS.destroyNode(current);
+ }
+
+ current = next;
+ }
+ });
+
+ // no longer a mountpoint
+ node.mounted = null;
+
+ // remove this mount from the child mounts
+ var idx = node.mount.mounts.indexOf(mount);
+ assert(idx !== -1);
+ node.mount.mounts.splice(idx, 1);
+ },lookup:function (parent, name) {
+ return parent.node_ops.lookup(parent, name);
+ },mknod:function (path, mode, dev) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var err = FS.mayCreate(parent, name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.mknod) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.mknod(parent, name, mode, dev);
+ },create:function (path, mode) {
+ mode = mode !== undefined ? mode : 438 /* 0666 */;
+ mode &= 4095;
+ mode |= 32768;
+ return FS.mknod(path, mode, 0);
+ },mkdir:function (path, mode) {
+ mode = mode !== undefined ? mode : 511 /* 0777 */;
+ mode &= 511 | 512;
+ mode |= 16384;
+ return FS.mknod(path, mode, 0);
+ },mkdev:function (path, mode, dev) {
+ if (typeof(dev) === 'undefined') {
+ dev = mode;
+ mode = 438 /* 0666 */;
+ }
+ mode |= 8192;
+ return FS.mknod(path, mode, dev);
+ },symlink:function (oldpath, newpath) {
+ var lookup = FS.lookupPath(newpath, { parent: true });
+ var parent = lookup.node;
+ var newname = PATH.basename(newpath);
+ var err = FS.mayCreate(parent, newname);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.symlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.symlink(parent, newname, oldpath);
+ },rename:function (old_path, new_path) {
+ var old_dirname = PATH.dirname(old_path);
+ var new_dirname = PATH.dirname(new_path);
+ var old_name = PATH.basename(old_path);
+ var new_name = PATH.basename(new_path);
+ // parents must exist
+ var lookup, old_dir, new_dir;
+ try {
+ lookup = FS.lookupPath(old_path, { parent: true });
+ old_dir = lookup.node;
+ lookup = FS.lookupPath(new_path, { parent: true });
+ new_dir = lookup.node;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // need to be part of the same mount
+ if (old_dir.mount !== new_dir.mount) {
+ throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
+ }
+ // source must exist
+ var old_node = FS.lookupNode(old_dir, old_name);
+ // old path should not be an ancestor of the new path
+ var relative = PATH.relative(old_path, new_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ // new path should not be an ancestor of the old path
+ relative = PATH.relative(new_path, old_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ // see if the new path already exists
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ // not fatal
+ }
+ // early out if nothing needs to change
+ if (old_node === new_node) {
+ return;
+ }
+ // we'll need to delete the old entry
+ var isdir = FS.isDir(old_node.mode);
+ var err = FS.mayDelete(old_dir, old_name, isdir);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // need delete permissions if we'll be overwriting.
+ // need create permissions if new doesn't already exist.
+ err = new_node ?
+ FS.mayDelete(new_dir, new_name, isdir) :
+ FS.mayCreate(new_dir, new_name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!old_dir.node_ops.rename) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // if we are going to change the parent, check write permissions
+ if (new_dir !== old_dir) {
+ err = FS.nodePermissions(old_dir, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ }
+ // remove the node from the lookup hash
+ FS.hashRemoveNode(old_node);
+ // do the underlying fs rename
+ try {
+ old_dir.node_ops.rename(old_node, new_dir, new_name);
+ } catch (e) {
+ throw e;
+ } finally {
+ // add the node back to the hash (in case node_ops.rename
+ // changed its name)
+ FS.hashAddNode(old_node);
+ }
+ },rmdir:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, true);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.rmdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.rmdir(parent, name);
+ FS.destroyNode(node);
+ },readdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ if (!node.node_ops.readdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ return node.node_ops.readdir(node);
+ },unlink:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, false);
+ if (err) {
+ // POSIX says unlink should set EPERM, not EISDIR
+ if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.unlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.unlink(parent, name);
+ FS.destroyNode(node);
+ },readlink:function (path) {
+ var lookup = FS.lookupPath(path);
+ var link = lookup.node;
+ if (!link.node_ops.readlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return link.node_ops.readlink(link);
+ },stat:function (path, dontFollow) {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ var node = lookup.node;
+ if (!node.node_ops.getattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return node.node_ops.getattr(node);
+ },lstat:function (path) {
+ return FS.stat(path, true);
+ },chmod:function (path, mode, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ mode: (mode & 4095) | (node.mode & ~4095),
+ timestamp: Date.now()
+ });
+ },lchmod:function (path, mode) {
+ FS.chmod(path, mode, true);
+ },fchmod:function (fd, mode) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chmod(stream.node, mode);
+ },chown:function (path, uid, gid, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ timestamp: Date.now()
+ // we ignore the uid / gid for now
+ });
+ },lchown:function (path, uid, gid) {
+ FS.chown(path, uid, gid, true);
+ },fchown:function (fd, uid, gid) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chown(stream.node, uid, gid);
+ },truncate:function (path, len) {
+ if (len < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: true });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!FS.isFile(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var err = FS.nodePermissions(node, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ node.node_ops.setattr(node, {
+ size: len,
+ timestamp: Date.now()
+ });
+ },ftruncate:function (fd, len) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ FS.truncate(stream.node, len);
+ },utime:function (path, atime, mtime) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ node.node_ops.setattr(node, {
+ timestamp: Math.max(atime, mtime)
+ });
+ },open:function (path, flags, mode, fd_start, fd_end) {
+ flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
+ mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
+ if ((flags & 64)) {
+ mode = (mode & 4095) | 32768;
+ } else {
+ mode = 0;
+ }
+ var node;
+ if (typeof path === 'object') {
+ node = path;
+ } else {
+ path = PATH.normalize(path);
+ try {
+ var lookup = FS.lookupPath(path, {
+ follow: !(flags & 131072)
+ });
+ node = lookup.node;
+ } catch (e) {
+ // ignore
+ }
+ }
+ // perhaps we need to create the node
+ if ((flags & 64)) {
+ if (node) {
+ // if O_CREAT and O_EXCL are set, error out if the node already exists
+ if ((flags & 128)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
+ }
+ } else {
+ // node doesn't exist, try to create it
+ node = FS.mknod(path, mode, 0);
+ }
+ }
+ if (!node) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
+ }
+ // can't truncate a device
+ if (FS.isChrdev(node.mode)) {
+ flags &= ~512;
+ }
+ // check permissions
+ var err = FS.mayOpen(node, flags);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // do truncation if necessary
+ if ((flags & 512)) {
+ FS.truncate(node, 0);
+ }
+ // we've already handled these, don't pass down to the underlying vfs
+ flags &= ~(128 | 512);
+
+ // register the stream with the filesystem
+ var stream = FS.createStream({
+ node: node,
+ path: FS.getPath(node), // we want the absolute path to the node
+ flags: flags,
+ seekable: true,
+ position: 0,
+ stream_ops: node.stream_ops,
+ // used by the file family libc calls (fopen, fwrite, ferror, etc.)
+ ungotten: [],
+ error: false
+ }, fd_start, fd_end);
+ // call the new stream's open function
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ if (Module['logReadFiles'] && !(flags & 1)) {
+ if (!FS.readFiles) FS.readFiles = {};
+ if (!(path in FS.readFiles)) {
+ FS.readFiles[path] = 1;
+ Module['printErr']('read file: ' + path);
+ }
+ }
+ return stream;
+ },close:function (stream) {
+ try {
+ if (stream.stream_ops.close) {
+ stream.stream_ops.close(stream);
+ }
+ } catch (e) {
+ throw e;
+ } finally {
+ FS.closeStream(stream.fd);
+ }
+ },llseek:function (stream, offset, whence) {
+ if (!stream.seekable || !stream.stream_ops.llseek) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ return stream.stream_ops.llseek(stream, offset, whence);
+ },read:function (stream, buffer, offset, length, position) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.read) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
+ if (!seeking) stream.position += bytesRead;
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.write) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ if (stream.flags & 1024) {
+ // seek to the end before writing in append mode
+ FS.llseek(stream, 0, 2);
+ }
+ var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
+ if (!seeking) stream.position += bytesWritten;
+ return bytesWritten;
+ },allocate:function (stream, offset, length) {
+ if (offset < 0 || length <= 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ if (!stream.stream_ops.allocate) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ stream.stream_ops.allocate(stream, offset, length);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ // TODO if PROT is PROT_WRITE, make sure we have write access
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EACCES);
+ }
+ if (!stream.stream_ops.mmap) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
+ },ioctl:function (stream, cmd, arg) {
+ if (!stream.stream_ops.ioctl) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
+ }
+ return stream.stream_ops.ioctl(stream, cmd, arg);
+ },readFile:function (path, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'r';
+ opts.encoding = opts.encoding || 'binary';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var ret;
+ var stream = FS.open(path, opts.flags);
+ var stat = FS.stat(path);
+ var length = stat.size;
+ var buf = new Uint8Array(length);
+ FS.read(stream, buf, 0, length, 0);
+ if (opts.encoding === 'utf8') {
+ ret = '';
+ var utf8 = new Runtime.UTF8Processor();
+ for (var i = 0; i < length; i++) {
+ ret += utf8.processCChar(buf[i]);
+ }
+ } else if (opts.encoding === 'binary') {
+ ret = buf;
+ }
+ FS.close(stream);
+ return ret;
+ },writeFile:function (path, data, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'w';
+ opts.encoding = opts.encoding || 'utf8';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var stream = FS.open(path, opts.flags, opts.mode);
+ if (opts.encoding === 'utf8') {
+ var utf8 = new Runtime.UTF8Processor();
+ var buf = new Uint8Array(utf8.processJSString(data));
+ FS.write(stream, buf, 0, buf.length, 0, opts.canOwn);
+ } else if (opts.encoding === 'binary') {
+ FS.write(stream, data, 0, data.length, 0, opts.canOwn);
+ }
+ FS.close(stream);
+ },cwd:function () {
+ return FS.currentPath;
+ },chdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ if (!FS.isDir(lookup.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ var err = FS.nodePermissions(lookup.node, 'x');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ FS.currentPath = lookup.path;
+ },createDefaultDirectories:function () {
+ FS.mkdir('/tmp');
+ },createDefaultDevices:function () {
+ // create /dev
+ FS.mkdir('/dev');
+ // setup /dev/null
+ FS.registerDevice(FS.makedev(1, 3), {
+ read: function() { return 0; },
+ write: function() { return 0; }
+ });
+ FS.mkdev('/dev/null', FS.makedev(1, 3));
+ // setup /dev/tty and /dev/tty1
+ // stderr needs to print output using Module['printErr']
+ // so we register a second tty just for it.
+ TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
+ TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
+ FS.mkdev('/dev/tty', FS.makedev(5, 0));
+ FS.mkdev('/dev/tty1', FS.makedev(6, 0));
+ // we're not going to emulate the actual shm device,
+ // just create the tmp dirs that reside in it commonly
+ FS.mkdir('/dev/shm');
+ FS.mkdir('/dev/shm/tmp');
+ },createStandardStreams:function () {
+ // TODO deprecate the old functionality of a single
+ // input / output callback and that utilizes FS.createDevice
+ // and instead require a unique set of stream ops
+
+ // by default, we symlink the standard streams to the
+ // default tty devices. however, if the standard streams
+ // have been overwritten we create a unique device for
+ // them instead.
+ if (Module['stdin']) {
+ FS.createDevice('/dev', 'stdin', Module['stdin']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdin');
+ }
+ if (Module['stdout']) {
+ FS.createDevice('/dev', 'stdout', null, Module['stdout']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdout');
+ }
+ if (Module['stderr']) {
+ FS.createDevice('/dev', 'stderr', null, Module['stderr']);
+ } else {
+ FS.symlink('/dev/tty1', '/dev/stderr');
+ }
+
+ // open default streams for the stdin, stdout and stderr devices
+ var stdin = FS.open('/dev/stdin', 'r');
+ HEAP32[((_stdin)>>2)]=FS.getPtrForStream(stdin);
+ assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
+
+ var stdout = FS.open('/dev/stdout', 'w');
+ HEAP32[((_stdout)>>2)]=FS.getPtrForStream(stdout);
+ assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
+
+ var stderr = FS.open('/dev/stderr', 'w');
+ HEAP32[((_stderr)>>2)]=FS.getPtrForStream(stderr);
+ assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
+ },ensureErrnoError:function () {
+ if (FS.ErrnoError) return;
+ FS.ErrnoError = function ErrnoError(errno) {
+ this.errno = errno;
+ for (var key in ERRNO_CODES) {
+ if (ERRNO_CODES[key] === errno) {
+ this.code = key;
+ break;
+ }
+ }
+ this.message = ERRNO_MESSAGES[errno];
+ };
+ FS.ErrnoError.prototype = new Error();
+ FS.ErrnoError.prototype.constructor = FS.ErrnoError;
+ // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
+ [ERRNO_CODES.ENOENT].forEach(function(code) {
+ FS.genericErrors[code] = new FS.ErrnoError(code);
+ FS.genericErrors[code].stack = '<generic error, no stack>';
+ });
+ },staticInit:function () {
+ FS.ensureErrnoError();
+
+ FS.nameTable = new Array(4096);
+
+ FS.mount(MEMFS, {}, '/');
+
+ FS.createDefaultDirectories();
+ FS.createDefaultDevices();
+ },init:function (input, output, error) {
+ assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
+ FS.init.initialized = true;
+
+ FS.ensureErrnoError();
+
+ // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
+ Module['stdin'] = input || Module['stdin'];
+ Module['stdout'] = output || Module['stdout'];
+ Module['stderr'] = error || Module['stderr'];
+
+ FS.createStandardStreams();
+ },quit:function () {
+ FS.init.initialized = false;
+ for (var i = 0; i < FS.streams.length; i++) {
+ var stream = FS.streams[i];
+ if (!stream) {
+ continue;
+ }
+ FS.close(stream);
+ }
+ },getMode:function (canRead, canWrite) {
+ var mode = 0;
+ if (canRead) mode |= 292 | 73;
+ if (canWrite) mode |= 146;
+ return mode;
+ },joinPath:function (parts, forceRelative) {
+ var path = PATH.join.apply(null, parts);
+ if (forceRelative && path[0] == '/') path = path.substr(1);
+ return path;
+ },absolutePath:function (relative, base) {
+ return PATH.resolve(base, relative);
+ },standardizePath:function (path) {
+ return PATH.normalize(path);
+ },findObject:function (path, dontResolveLastLink) {
+ var ret = FS.analyzePath(path, dontResolveLastLink);
+ if (ret.exists) {
+ return ret.object;
+ } else {
+ ___setErrNo(ret.error);
+ return null;
+ }
+ },analyzePath:function (path, dontResolveLastLink) {
+ // operate from within the context of the symlink's target
+ try {
+ var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ path = lookup.path;
+ } catch (e) {
+ }
+ var ret = {
+ isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
+ parentExists: false, parentPath: null, parentObject: null
+ };
+ try {
+ var lookup = FS.lookupPath(path, { parent: true });
+ ret.parentExists = true;
+ ret.parentPath = lookup.path;
+ ret.parentObject = lookup.node;
+ ret.name = PATH.basename(path);
+ lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ ret.exists = true;
+ ret.path = lookup.path;
+ ret.object = lookup.node;
+ ret.name = lookup.node.name;
+ ret.isRoot = lookup.path === '/';
+ } catch (e) {
+ ret.error = e.errno;
+ };
+ return ret;
+ },createFolder:function (parent, name, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.mkdir(path, mode);
+ },createPath:function (parent, path, canRead, canWrite) {
+ parent = typeof parent === 'string' ? parent : FS.getPath(parent);
+ var parts = path.split('/').reverse();
+ while (parts.length) {
+ var part = parts.pop();
+ if (!part) continue;
+ var current = PATH.join2(parent, part);
+ try {
+ FS.mkdir(current);
+ } catch (e) {
+ // ignore EEXIST
+ }
+ parent = current;
+ }
+ return current;
+ },createFile:function (parent, name, properties, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.create(path, mode);
+ },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
+ var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
+ var mode = FS.getMode(canRead, canWrite);
+ var node = FS.create(path, mode);
+ if (data) {
+ if (typeof data === 'string') {
+ var arr = new Array(data.length);
+ for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
+ data = arr;
+ }
+ // make sure we can write to the file
+ FS.chmod(node, mode | 146);
+ var stream = FS.open(node, 'w');
+ FS.write(stream, data, 0, data.length, 0, canOwn);
+ FS.close(stream);
+ FS.chmod(node, mode);
+ }
+ return node;
+ },createDevice:function (parent, name, input, output) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(!!input, !!output);
+ if (!FS.createDevice.major) FS.createDevice.major = 64;
+ var dev = FS.makedev(FS.createDevice.major++, 0);
+ // Create a fake device that a set of stream ops to emulate
+ // the old behavior.
+ FS.registerDevice(dev, {
+ open: function(stream) {
+ stream.seekable = false;
+ },
+ close: function(stream) {
+ // flush any pending line data
+ if (output && output.buffer && output.buffer.length) {
+ output(10);
+ }
+ },
+ read: function(stream, buffer, offset, length, pos /* ignored */) {
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = input();
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },
+ write: function(stream, buffer, offset, length, pos) {
+ for (var i = 0; i < length; i++) {
+ try {
+ output(buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }
+ });
+ return FS.mkdev(path, mode, dev);
+ },createLink:function (parent, name, target, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ return FS.symlink(target, path);
+ },forceLoadFile:function (obj) {
+ if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
+ var success = true;
+ if (typeof XMLHttpRequest !== 'undefined') {
+ throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
+ } else if (Module['read']) {
+ // Command-line.
+ try {
+ // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
+ // read() will try to parse UTF8.
+ obj.contents = intArrayFromString(Module['read'](obj.url), true);
+ } catch (e) {
+ success = false;
+ }
+ } else {
+ throw new Error('Cannot load without read() or XMLHttpRequest.');
+ }
+ if (!success) ___setErrNo(ERRNO_CODES.EIO);
+ return success;
+ },createLazyFile:function (parent, name, url, canRead, canWrite) {
+ // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
+ function LazyUint8Array() {
+ this.lengthKnown = false;
+ this.chunks = []; // Loaded chunks. Index is the chunk number
+ }
+ LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
+ if (idx > this.length-1 || idx < 0) {
+ return undefined;
+ }
+ var chunkOffset = idx % this.chunkSize;
+ var chunkNum = Math.floor(idx / this.chunkSize);
+ return this.getter(chunkNum)[chunkOffset];
+ }
+ LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
+ this.getter = getter;
+ }
+ LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
+ // Find length
+ var xhr = new XMLHttpRequest();
+ xhr.open('HEAD', url, false);
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ var datalength = Number(xhr.getResponseHeader("Content-length"));
+ var header;
+ var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
+ var chunkSize = 1024*1024; // Chunk size in bytes
+
+ if (!hasByteServing) chunkSize = datalength;
+
+ // Function to get a range from the remote URL.
+ var doXHR = (function(from, to) {
+ if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
+ if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
+
+ // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
+
+ // Some hints to the browser that we want binary data.
+ if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
+ if (xhr.overrideMimeType) {
+ xhr.overrideMimeType('text/plain; charset=x-user-defined');
+ }
+
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ if (xhr.response !== undefined) {
+ return new Uint8Array(xhr.response || []);
+ } else {
+ return intArrayFromString(xhr.responseText || '', true);
+ }
+ });
+ var lazyArray = this;
+ lazyArray.setDataGetter(function(chunkNum) {
+ var start = chunkNum * chunkSize;
+ var end = (chunkNum+1) * chunkSize - 1; // including this byte
+ end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
+ lazyArray.chunks[chunkNum] = doXHR(start, end);
+ }
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
+ return lazyArray.chunks[chunkNum];
+ });
+
+ this._length = datalength;
+ this._chunkSize = chunkSize;
+ this.lengthKnown = true;
+ }
+ if (typeof XMLHttpRequest !== 'undefined') {
+ if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
+ var lazyArray = new LazyUint8Array();
+ Object.defineProperty(lazyArray, "length", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._length;
+ }
+ });
+ Object.defineProperty(lazyArray, "chunkSize", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._chunkSize;
+ }
+ });
+
+ var properties = { isDevice: false, contents: lazyArray };
+ } else {
+ var properties = { isDevice: false, url: url };
+ }
+
+ var node = FS.createFile(parent, name, properties, canRead, canWrite);
+ // This is a total hack, but I want to get this lazy file code out of the
+ // core of MEMFS. If we want to keep this lazy file concept I feel it should
+ // be its own thin LAZYFS proxying calls to MEMFS.
+ if (properties.contents) {
+ node.contents = properties.contents;
+ } else if (properties.url) {
+ node.contents = null;
+ node.url = properties.url;
+ }
+ // override each stream op with one that tries to force load the lazy file first
+ var stream_ops = {};
+ var keys = Object.keys(node.stream_ops);
+ keys.forEach(function(key) {
+ var fn = node.stream_ops[key];
+ stream_ops[key] = function forceLoadLazyFile() {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ return fn.apply(null, arguments);
+ };
+ });
+ // use a custom read function
+ stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (contents.slice) { // normal array
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ } else {
+ for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
+ buffer[offset + i] = contents.get(position + i);
+ }
+ }
+ return size;
+ };
+ node.stream_ops = stream_ops;
+ return node;
+ },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {
+ Browser.init();
+ // TODO we should allow people to just pass in a complete filename instead
+ // of parent and name being that we just join them anyways
+ var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
+ function processData(byteArray) {
+ function finish(byteArray) {
+ if (!dontCreateFile) {
+ FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
+ }
+ if (onload) onload();
+ removeRunDependency('cp ' + fullname);
+ }
+ var handled = false;
+ Module['preloadPlugins'].forEach(function(plugin) {
+ if (handled) return;
+ if (plugin['canHandle'](fullname)) {
+ plugin['handle'](byteArray, fullname, finish, function() {
+ if (onerror) onerror();
+ removeRunDependency('cp ' + fullname);
+ });
+ handled = true;
+ }
+ });
+ if (!handled) finish(byteArray);
+ }
+ addRunDependency('cp ' + fullname);
+ if (typeof url == 'string') {
+ Browser.asyncLoad(url, function(byteArray) {
+ processData(byteArray);
+ }, onerror);
+ } else {
+ processData(url);
+ }
+ },indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_NAME:function () {
+ return 'EM_FS_' + window.location.pathname;
+ },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
+ console.log('creating db');
+ var db = openRequest.result;
+ db.createObjectStore(FS.DB_STORE_NAME);
+ };
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var putRequest = files.put(FS.analyzePath(path).object.contents, path);
+ putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
+ putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ },loadFilesFromDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = onerror; // no database to load from
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ try {
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
+ } catch(e) {
+ onerror(e);
+ return;
+ }
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var getRequest = files.get(path);
+ getRequest.onsuccess = function getRequest_onsuccess() {
+ if (FS.analyzePath(path).exists) {
+ FS.unlink(path);
+ }
+ FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
+ ok++;
+ if (ok + fail == total) finish();
+ };
+ getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ }};
+
+
+
+
+ function _mkport() { throw 'TODO' }var SOCKFS={mount:function (mount) {
+ return FS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createSocket:function (family, type, protocol) {
+ var streaming = type == 1;
+ if (protocol) {
+ assert(streaming == (protocol == 6)); // if SOCK_STREAM, must be tcp
+ }
+
+ // create our internal socket structure
+ var sock = {
+ family: family,
+ type: type,
+ protocol: protocol,
+ server: null,
+ peers: {},
+ pending: [],
+ recv_queue: [],
+ sock_ops: SOCKFS.websocket_sock_ops
+ };
+
+ // create the filesystem node to store the socket structure
+ var name = SOCKFS.nextname();
+ var node = FS.createNode(SOCKFS.root, name, 49152, 0);
+ node.sock = sock;
+
+ // and the wrapping stream that enables library functions such
+ // as read and write to indirectly interact with the socket
+ var stream = FS.createStream({
+ path: name,
+ node: node,
+ flags: FS.modeStringToFlags('r+'),
+ seekable: false,
+ stream_ops: SOCKFS.stream_ops
+ });
+
+ // map the new stream to the socket structure (sockets have a 1:1
+ // relationship with a stream)
+ sock.stream = stream;
+
+ return sock;
+ },getSocket:function (fd) {
+ var stream = FS.getStream(fd);
+ if (!stream || !FS.isSocket(stream.node.mode)) {
+ return null;
+ }
+ return stream.node.sock;
+ },stream_ops:{poll:function (stream) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.poll(sock);
+ },ioctl:function (stream, request, varargs) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.ioctl(sock, request, varargs);
+ },read:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ var msg = sock.sock_ops.recvmsg(sock, length);
+ if (!msg) {
+ // socket is closed
+ return 0;
+ }
+ buffer.set(msg.buffer, offset);
+ return msg.buffer.length;
+ },write:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.sendmsg(sock, buffer, offset, length);
+ },close:function (stream) {
+ var sock = stream.node.sock;
+ sock.sock_ops.close(sock);
+ }},nextname:function () {
+ if (!SOCKFS.nextname.current) {
+ SOCKFS.nextname.current = 0;
+ }
+ return 'socket[' + (SOCKFS.nextname.current++) + ']';
+ },websocket_sock_ops:{createPeer:function (sock, addr, port) {
+ var ws;
+
+ if (typeof addr === 'object') {
+ ws = addr;
+ addr = null;
+ port = null;
+ }
+
+ if (ws) {
+ // for sockets that've already connected (e.g. we're the server)
+ // we can inspect the _socket property for the address
+ if (ws._socket) {
+ addr = ws._socket.remoteAddress;
+ port = ws._socket.remotePort;
+ }
+ // if we're just now initializing a connection to the remote,
+ // inspect the url property
+ else {
+ var result = /ws[s]?:\/\/([^:]+):(\d+)/.exec(ws.url);
+ if (!result) {
+ throw new Error('WebSocket URL must be in the format ws(s)://address:port');
+ }
+ addr = result[1];
+ port = parseInt(result[2], 10);
+ }
+ } else {
+ // create the actual websocket object and connect
+ try {
+ // runtimeConfig gets set to true if WebSocket runtime configuration is available.
+ var runtimeConfig = (Module['websocket'] && ('object' === typeof Module['websocket']));
+
+ // The default value is 'ws://' the replace is needed because the compiler replaces "//" comments with '#'
+ // comments without checking context, so we'd end up with ws:#, the replace swaps the "#" for "//" again.
+ var url = 'ws:#'.replace('#', '//');
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['url']) {
+ url = Module['websocket']['url']; // Fetch runtime WebSocket URL config.
+ }
+ }
+
+ if (url === 'ws://' || url === 'wss://') { // Is the supplied URL config just a prefix, if so complete it.
+ url = url + addr + ':' + port;
+ }
+
+ // Make the WebSocket subprotocol (Sec-WebSocket-Protocol) default to binary if no configuration is set.
+ var subProtocols = 'binary'; // The default value is 'binary'
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['subprotocol']) {
+ subProtocols = Module['websocket']['subprotocol']; // Fetch runtime WebSocket subprotocol config.
+ }
+ }
+
+ // The regex trims the string (removes spaces at the beginning and end, then splits the string by
+ // <any space>,<any space> into an Array. Whitespace removal is important for Websockify and ws.
+ subProtocols = subProtocols.replace(/^ +| +$/g,"").split(/ *, */);
+
+ // The node ws library API for specifying optional subprotocol is slightly different than the browser's.
+ var opts = ENVIRONMENT_IS_NODE ? {'protocol': subProtocols.toString()} : subProtocols;
+
+ // If node we use the ws library.
+ var WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : window['WebSocket'];
+ ws = new WebSocket(url, opts);
+ ws.binaryType = 'arraybuffer';
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EHOSTUNREACH);
+ }
+ }
+
+
+ var peer = {
+ addr: addr,
+ port: port,
+ socket: ws,
+ dgram_send_queue: []
+ };
+
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);
+
+ // if this is a bound dgram socket, send the port number first to allow
+ // us to override the ephemeral port reported to us by remotePort on the
+ // remote end.
+ if (sock.type === 2 && typeof sock.sport !== 'undefined') {
+ peer.dgram_send_queue.push(new Uint8Array([
+ 255, 255, 255, 255,
+ 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),
+ ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)
+ ]));
+ }
+
+ return peer;
+ },getPeer:function (sock, addr, port) {
+ return sock.peers[addr + ':' + port];
+ },addPeer:function (sock, peer) {
+ sock.peers[peer.addr + ':' + peer.port] = peer;
+ },removePeer:function (sock, peer) {
+ delete sock.peers[peer.addr + ':' + peer.port];
+ },handlePeerEvents:function (sock, peer) {
+ var first = true;
+
+ var handleOpen = function () {
+ try {
+ var queued = peer.dgram_send_queue.shift();
+ while (queued) {
+ peer.socket.send(queued);
+ queued = peer.dgram_send_queue.shift();
+ }
+ } catch (e) {
+ // not much we can do here in the way of proper error handling as we've already
+ // lied and said this data was sent. shut it down.
+ peer.socket.close();
+ }
+ };
+
+ function handleMessage(data) {
+ assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer
+ data = new Uint8Array(data); // make a typed array view on the array buffer
+
+
+ // if this is the port message, override the peer's port with it
+ var wasfirst = first;
+ first = false;
+ if (wasfirst &&
+ data.length === 10 &&
+ data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&
+ data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {
+ // update the peer's port and it's key in the peer map
+ var newport = ((data[8] << 8) | data[9]);
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ peer.port = newport;
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ return;
+ }
+
+ sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });
+ };
+
+ if (ENVIRONMENT_IS_NODE) {
+ peer.socket.on('open', handleOpen);
+ peer.socket.on('message', function(data, flags) {
+ if (!flags.binary) {
+ return;
+ }
+ handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
+ });
+ peer.socket.on('error', function() {
+ // don't throw
+ });
+ } else {
+ peer.socket.onopen = handleOpen;
+ peer.socket.onmessage = function peer_socket_onmessage(event) {
+ handleMessage(event.data);
+ };
+ }
+ },poll:function (sock) {
+ if (sock.type === 1 && sock.server) {
+ // listen sockets should only say they're available for reading
+ // if there are pending clients.
+ return sock.pending.length ? (64 | 1) : 0;
+ }
+
+ var mask = 0;
+ var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets
+ SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :
+ null;
+
+ if (sock.recv_queue.length ||
+ !dest || // connection-less sockets are always ready to read
+ (dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed
+ mask |= (64 | 1);
+ }
+
+ if (!dest || // connection-less sockets are always ready to write
+ (dest && dest.socket.readyState === dest.socket.OPEN)) {
+ mask |= 4;
+ }
+
+ if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) {
+ mask |= 16;
+ }
+
+ return mask;
+ },ioctl:function (sock, request, arg) {
+ switch (request) {
+ case 21531:
+ var bytes = 0;
+ if (sock.recv_queue.length) {
+ bytes = sock.recv_queue[0].data.length;
+ }
+ HEAP32[((arg)>>2)]=bytes;
+ return 0;
+ default:
+ return ERRNO_CODES.EINVAL;
+ }
+ },close:function (sock) {
+ // if we've spawned a listen server, close it
+ if (sock.server) {
+ try {
+ sock.server.close();
+ } catch (e) {
+ }
+ sock.server = null;
+ }
+ // close any peer connections
+ var peers = Object.keys(sock.peers);
+ for (var i = 0; i < peers.length; i++) {
+ var peer = sock.peers[peers[i]];
+ try {
+ peer.socket.close();
+ } catch (e) {
+ }
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ }
+ return 0;
+ },bind:function (sock, addr, port) {
+ if (typeof sock.saddr !== 'undefined' || typeof sock.sport !== 'undefined') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already bound
+ }
+ sock.saddr = addr;
+ sock.sport = port || _mkport();
+ // in order to emulate dgram sockets, we need to launch a listen server when
+ // binding on a connection-less socket
+ // note: this is only required on the server side
+ if (sock.type === 2) {
+ // close the existing server if it exists
+ if (sock.server) {
+ sock.server.close();
+ sock.server = null;
+ }
+ // swallow error operation not supported error that occurs when binding in the
+ // browser where this isn't supported
+ try {
+ sock.sock_ops.listen(sock, 0);
+ } catch (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e;
+ if (e.errno !== ERRNO_CODES.EOPNOTSUPP) throw e;
+ }
+ }
+ },connect:function (sock, addr, port) {
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODS.EOPNOTSUPP);
+ }
+
+ // TODO autobind
+ // if (!sock.addr && sock.type == 2) {
+ // }
+
+ // early out if we're already connected / in the middle of connecting
+ if (typeof sock.daddr !== 'undefined' && typeof sock.dport !== 'undefined') {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+ if (dest) {
+ if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EALREADY);
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EISCONN);
+ }
+ }
+ }
+
+ // add the socket to our peer list and set our
+ // destination address / port to match
+ var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ sock.daddr = peer.addr;
+ sock.dport = peer.port;
+
+ // always "fail" in non-blocking mode
+ throw new FS.ErrnoError(ERRNO_CODES.EINPROGRESS);
+ },listen:function (sock, backlog) {
+ if (!ENVIRONMENT_IS_NODE) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already listening
+ }
+ var WebSocketServer = require('ws').Server;
+ var host = sock.saddr;
+ sock.server = new WebSocketServer({
+ host: host,
+ port: sock.sport
+ // TODO support backlog
+ });
+
+ sock.server.on('connection', function(ws) {
+ if (sock.type === 1) {
+ var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);
+
+ // create a peer on the new socket
+ var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);
+ newsock.daddr = peer.addr;
+ newsock.dport = peer.port;
+
+ // push to queue for accept to pick up
+ sock.pending.push(newsock);
+ } else {
+ // create a peer on the listen socket so calling sendto
+ // with the listen socket and an address will resolve
+ // to the correct client
+ SOCKFS.websocket_sock_ops.createPeer(sock, ws);
+ }
+ });
+ sock.server.on('closed', function() {
+ sock.server = null;
+ });
+ sock.server.on('error', function() {
+ // don't throw
+ });
+ },accept:function (listensock) {
+ if (!listensock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var newsock = listensock.pending.shift();
+ newsock.stream.flags = listensock.stream.flags;
+ return newsock;
+ },getname:function (sock, peer) {
+ var addr, port;
+ if (peer) {
+ if (sock.daddr === undefined || sock.dport === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ addr = sock.daddr;
+ port = sock.dport;
+ } else {
+ // TODO saddr and sport will be set for bind()'d UDP sockets, but what
+ // should we be returning for TCP sockets that've been connect()'d?
+ addr = sock.saddr || 0;
+ port = sock.sport || 0;
+ }
+ return { addr: addr, port: port };
+ },sendmsg:function (sock, buffer, offset, length, addr, port) {
+ if (sock.type === 2) {
+ // connection-less sockets will honor the message address,
+ // and otherwise fall back to the bound destination address
+ if (addr === undefined || port === undefined) {
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+ // if there was no address to fall back to, error out
+ if (addr === undefined || port === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.EDESTADDRREQ);
+ }
+ } else {
+ // connection-based sockets will only use the bound
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+
+ // find the peer for the destination address
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);
+
+ // early out if not connected with a connection-based socket
+ if (sock.type === 1) {
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ } else if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // create a copy of the incoming data to send, as the WebSocket API
+ // doesn't work entirely with an ArrayBufferView, it'll just send
+ // the entire underlying buffer
+ var data;
+ if (buffer instanceof Array || buffer instanceof ArrayBuffer) {
+ data = buffer.slice(offset, offset + length);
+ } else { // ArrayBufferView
+ data = buffer.buffer.slice(buffer.byteOffset + offset, buffer.byteOffset + offset + length);
+ }
+
+ // if we're emulating a connection-less dgram socket and don't have
+ // a cached connection, queue the buffer to send upon connect and
+ // lie, saying the data was sent now.
+ if (sock.type === 2) {
+ if (!dest || dest.socket.readyState !== dest.socket.OPEN) {
+ // if we're not connected, open a new connection
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ }
+ dest.dgram_send_queue.push(data);
+ return length;
+ }
+ }
+
+ try {
+ // send the actual data
+ dest.socket.send(data);
+ return length;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ },recvmsg:function (sock, length) {
+ // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html
+ if (sock.type === 1 && sock.server) {
+ // tcp servers should not be recv()'ing on the listen socket
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+
+ var queued = sock.recv_queue.shift();
+ if (!queued) {
+ if (sock.type === 1) {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+
+ if (!dest) {
+ // if we have a destination address but are not connected, error out
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ else if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ // return null if the socket has closed
+ return null;
+ }
+ else {
+ // else, our socket is in a valid state but truly has nothing available
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // queued.data will be an ArrayBuffer if it's unadulterated, but if it's
+ // requeued TCP data it'll be an ArrayBufferView
+ var queuedLength = queued.data.byteLength || queued.data.length;
+ var queuedOffset = queued.data.byteOffset || 0;
+ var queuedBuffer = queued.data.buffer || queued.data;
+ var bytesRead = Math.min(length, queuedLength);
+ var res = {
+ buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),
+ addr: queued.addr,
+ port: queued.port
+ };
+
+
+ // push back any unread data for TCP connections
+ if (sock.type === 1 && bytesRead < queuedLength) {
+ var bytesRemaining = queuedLength - bytesRead;
+ queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
+ sock.recv_queue.unshift(queued);
+ }
+
+ return res;
+ }}};function _send(fd, buf, len, flags) {
+ var sock = SOCKFS.getSocket(fd);
+ if (!sock) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ // TODO honor flags
+ return _write(fd, buf, len);
+ }
+
+ function _pwrite(fildes, buf, nbyte, offset) {
+ // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte, offset);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _write(fildes, buf, nbyte) {
+ // ssize_t write(int fildes, const void *buf, size_t nbyte);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+
+
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }
+
+ function _fileno(stream) {
+ // int fileno(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fileno.html
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) return -1;
+ return stream.fd;
+ }function _fwrite(ptr, size, nitems, stream) {
+ // size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html
+ var bytesToWrite = nitems * size;
+ if (bytesToWrite == 0) return 0;
+ var fd = _fileno(stream);
+ var bytesWritten = _write(fd, ptr, bytesToWrite);
+ if (bytesWritten == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return 0;
+ } else {
+ return Math.floor(bytesWritten / size);
+ }
+ }
+
+
+
+ Module["_strlen"] = _strlen;
+
+ function __reallyNegative(x) {
+ return x < 0 || (x === 0 && (1/x) === -Infinity);
+ }function __formatString(format, varargs) {
+ var textIndex = format;
+ var argIndex = 0;
+ function getNextArg(type) {
+ // NOTE: Explicitly ignoring type safety. Otherwise this fails:
+ // int x = 4; printf("%c\n", (char)x);
+ var ret;
+ if (type === 'double') {
+ ret = HEAPF64[(((varargs)+(argIndex))>>3)];
+ } else if (type == 'i64') {
+ ret = [HEAP32[(((varargs)+(argIndex))>>2)],
+ HEAP32[(((varargs)+(argIndex+4))>>2)]];
+
+ } else {
+ type = 'i32'; // varargs are always i32, i64, or double
+ ret = HEAP32[(((varargs)+(argIndex))>>2)];
+ }
+ argIndex += Runtime.getNativeFieldSize(type);
+ return ret;
+ }
+
+ var ret = [];
+ var curr, next, currArg;
+ while(1) {
+ var startTextIndex = textIndex;
+ curr = HEAP8[(textIndex)];
+ if (curr === 0) break;
+ next = HEAP8[((textIndex+1)|0)];
+ if (curr == 37) {
+ // Handle flags.
+ var flagAlwaysSigned = false;
+ var flagLeftAlign = false;
+ var flagAlternative = false;
+ var flagZeroPad = false;
+ var flagPadSign = false;
+ flagsLoop: while (1) {
+ switch (next) {
+ case 43:
+ flagAlwaysSigned = true;
+ break;
+ case 45:
+ flagLeftAlign = true;
+ break;
+ case 35:
+ flagAlternative = true;
+ break;
+ case 48:
+ if (flagZeroPad) {
+ break flagsLoop;
+ } else {
+ flagZeroPad = true;
+ break;
+ }
+ case 32:
+ flagPadSign = true;
+ break;
+ default:
+ break flagsLoop;
+ }
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+
+ // Handle width.
+ var width = 0;
+ if (next == 42) {
+ width = getNextArg('i32');
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ } else {
+ while (next >= 48 && next <= 57) {
+ width = width * 10 + (next - 48);
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ }
+
+ // Handle precision.
+ var precisionSet = false, precision = -1;
+ if (next == 46) {
+ precision = 0;
+ precisionSet = true;
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ if (next == 42) {
+ precision = getNextArg('i32');
+ textIndex++;
+ } else {
+ while(1) {
+ var precisionChr = HEAP8[((textIndex+1)|0)];
+ if (precisionChr < 48 ||
+ precisionChr > 57) break;
+ precision = precision * 10 + (precisionChr - 48);
+ textIndex++;
+ }
+ }
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ if (precision < 0) {
+ precision = 6; // Standard default.
+ precisionSet = false;
+ }
+
+ // Handle integer sizes. WARNING: These assume a 32-bit architecture!
+ var argSize;
+ switch (String.fromCharCode(next)) {
+ case 'h':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 104) {
+ textIndex++;
+ argSize = 1; // char (actually i32 in varargs)
+ } else {
+ argSize = 2; // short (actually i32 in varargs)
+ }
+ break;
+ case 'l':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 108) {
+ textIndex++;
+ argSize = 8; // long long
+ } else {
+ argSize = 4; // long
+ }
+ break;
+ case 'L': // long long
+ case 'q': // int64_t
+ case 'j': // intmax_t
+ argSize = 8;
+ break;
+ case 'z': // size_t
+ case 't': // ptrdiff_t
+ case 'I': // signed ptrdiff_t or unsigned size_t
+ argSize = 4;
+ break;
+ default:
+ argSize = null;
+ }
+ if (argSize) textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+
+ // Handle type specifier.
+ switch (String.fromCharCode(next)) {
+ case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {
+ // Integer.
+ var signed = next == 100 || next == 105;
+ argSize = argSize || 4;
+ var currArg = getNextArg('i' + (argSize * 8));
+ var argText;
+ // Flatten i64-1 [low, high] into a (slightly rounded) double
+ if (argSize == 8) {
+ currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);
+ }
+ // Truncate to requested size.
+ if (argSize <= 4) {
+ var limit = Math.pow(256, argSize) - 1;
+ currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);
+ }
+ // Format the number.
+ var currAbsArg = Math.abs(currArg);
+ var prefix = '';
+ if (next == 100 || next == 105) {
+ argText = reSign(currArg, 8 * argSize, 1).toString(10);
+ } else if (next == 117) {
+ argText = unSign(currArg, 8 * argSize, 1).toString(10);
+ currArg = Math.abs(currArg);
+ } else if (next == 111) {
+ argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
+ } else if (next == 120 || next == 88) {
+ prefix = (flagAlternative && currArg != 0) ? '0x' : '';
+ if (currArg < 0) {
+ // Represent negative numbers in hex as 2's complement.
+ currArg = -currArg;
+ argText = (currAbsArg - 1).toString(16);
+ var buffer = [];
+ for (var i = 0; i < argText.length; i++) {
+ buffer.push((0xF - parseInt(argText[i], 16)).toString(16));
+ }
+ argText = buffer.join('');
+ while (argText.length < argSize * 2) argText = 'f' + argText;
+ } else {
+ argText = currAbsArg.toString(16);
+ }
+ if (next == 88) {
+ prefix = prefix.toUpperCase();
+ argText = argText.toUpperCase();
+ }
+ } else if (next == 112) {
+ if (currAbsArg === 0) {
+ argText = '(nil)';
+ } else {
+ prefix = '0x';
+ argText = currAbsArg.toString(16);
+ }
+ }
+ if (precisionSet) {
+ while (argText.length < precision) {
+ argText = '0' + argText;
+ }
+ }
+
+ // Add sign if needed
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ prefix = '+' + prefix;
+ } else if (flagPadSign) {
+ prefix = ' ' + prefix;
+ }
+ }
+
+ // Move sign to prefix so we zero-pad after the sign
+ if (argText.charAt(0) == '-') {
+ prefix = '-' + prefix;
+ argText = argText.substr(1);
+ }
+
+ // Add padding.
+ while (prefix.length + argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad) {
+ argText = '0' + argText;
+ } else {
+ prefix = ' ' + prefix;
+ }
+ }
+ }
+
+ // Insert the result into the buffer.
+ argText = prefix + argText;
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {
+ // Float.
+ var currArg = getNextArg('double');
+ var argText;
+ if (isNaN(currArg)) {
+ argText = 'nan';
+ flagZeroPad = false;
+ } else if (!isFinite(currArg)) {
+ argText = (currArg < 0 ? '-' : '') + 'inf';
+ flagZeroPad = false;
+ } else {
+ var isGeneral = false;
+ var effectivePrecision = Math.min(precision, 20);
+
+ // Convert g/G to f/F or e/E, as per:
+ // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
+ if (next == 103 || next == 71) {
+ isGeneral = true;
+ precision = precision || 1;
+ var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);
+ if (precision > exponent && exponent >= -4) {
+ next = ((next == 103) ? 'f' : 'F').charCodeAt(0);
+ precision -= exponent + 1;
+ } else {
+ next = ((next == 103) ? 'e' : 'E').charCodeAt(0);
+ precision--;
+ }
+ effectivePrecision = Math.min(precision, 20);
+ }
+
+ if (next == 101 || next == 69) {
+ argText = currArg.toExponential(effectivePrecision);
+ // Make sure the exponent has at least 2 digits.
+ if (/[eE][-+]\d$/.test(argText)) {
+ argText = argText.slice(0, -1) + '0' + argText.slice(-1);
+ }
+ } else if (next == 102 || next == 70) {
+ argText = currArg.toFixed(effectivePrecision);
+ if (currArg === 0 && __reallyNegative(currArg)) {
+ argText = '-' + argText;
+ }
+ }
+
+ var parts = argText.split('e');
+ if (isGeneral && !flagAlternative) {
+ // Discard trailing zeros and periods.
+ while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&
+ (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {
+ parts[0] = parts[0].slice(0, -1);
+ }
+ } else {
+ // Make sure we have a period in alternative mode.
+ if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';
+ // Zero pad until required precision.
+ while (precision > effectivePrecision++) parts[0] += '0';
+ }
+ argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');
+
+ // Capitalize 'E' if needed.
+ if (next == 69) argText = argText.toUpperCase();
+
+ // Add sign.
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ argText = '+' + argText;
+ } else if (flagPadSign) {
+ argText = ' ' + argText;
+ }
+ }
+ }
+
+ // Add padding.
+ while (argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {
+ argText = argText[0] + '0' + argText.slice(1);
+ } else {
+ argText = (flagZeroPad ? '0' : ' ') + argText;
+ }
+ }
+ }
+
+ // Adjust case.
+ if (next < 97) argText = argText.toUpperCase();
+
+ // Insert the result into the buffer.
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 's': {
+ // String.
+ var arg = getNextArg('i8*');
+ var argLength = arg ? _strlen(arg) : '(null)'.length;
+ if (precisionSet) argLength = Math.min(argLength, precision);
+ if (!flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ if (arg) {
+ for (var i = 0; i < argLength; i++) {
+ ret.push(HEAPU8[((arg++)|0)]);
+ }
+ } else {
+ ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true));
+ }
+ if (flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ break;
+ }
+ case 'c': {
+ // Character.
+ if (flagLeftAlign) ret.push(getNextArg('i8'));
+ while (--width > 0) {
+ ret.push(32);
+ }
+ if (!flagLeftAlign) ret.push(getNextArg('i8'));
+ break;
+ }
+ case 'n': {
+ // Write the length written so far to the next parameter.
+ var ptr = getNextArg('i32*');
+ HEAP32[((ptr)>>2)]=ret.length;
+ break;
+ }
+ case '%': {
+ // Literal percent sign.
+ ret.push(curr);
+ break;
+ }
+ default: {
+ // Unknown specifiers remain untouched.
+ for (var i = startTextIndex; i < textIndex + 2; i++) {
+ ret.push(HEAP8[(i)]);
+ }
+ }
+ }
+ textIndex += 2;
+ // TODO: Support a/A (hex float) and m (last error) specifiers.
+ // TODO: Support %1${specifier} for arg selection.
+ } else {
+ ret.push(curr);
+ textIndex += 1;
+ }
+ }
+ return ret;
+ }function _fprintf(stream, format, varargs) {
+ // int fprintf(FILE *restrict stream, const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var result = __formatString(format, varargs);
+ var stack = Runtime.stackSave();
+ var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);
+ Runtime.stackRestore(stack);
+ return ret;
+ }function _printf(format, varargs) {
+ // int printf(const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var stdout = HEAP32[((_stdout)>>2)];
+ return _fprintf(stdout, format, varargs);
+ }
+
+ function _sbrk(bytes) {
+ // Implement a Linux-like 'memory area' for our 'process'.
+ // Changes the size of the memory area by |bytes|; returns the
+ // address of the previous top ('break') of the memory area
+ // We control the "dynamic" memory - DYNAMIC_BASE to DYNAMICTOP
+ var self = _sbrk;
+ if (!self.called) {
+ DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned
+ self.called = true;
+ assert(Runtime.dynamicAlloc);
+ self.alloc = Runtime.dynamicAlloc;
+ Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') };
+ }
+ var ret = DYNAMICTOP;
+ if (bytes != 0) self.alloc(bytes);
+ return ret; // Previous break location.
+ }
+
+ function _sysconf(name) {
+ // long sysconf(int name);
+ // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html
+ switch(name) {
+ case 30: return PAGE_SIZE;
+ case 132:
+ case 133:
+ case 12:
+ case 137:
+ case 138:
+ case 15:
+ case 235:
+ case 16:
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ case 149:
+ case 13:
+ case 10:
+ case 236:
+ case 153:
+ case 9:
+ case 21:
+ case 22:
+ case 159:
+ case 154:
+ case 14:
+ case 77:
+ case 78:
+ case 139:
+ case 80:
+ case 81:
+ case 79:
+ case 82:
+ case 68:
+ case 67:
+ case 164:
+ case 11:
+ case 29:
+ case 47:
+ case 48:
+ case 95:
+ case 52:
+ case 51:
+ case 46:
+ return 200809;
+ case 27:
+ case 246:
+ case 127:
+ case 128:
+ case 23:
+ case 24:
+ case 160:
+ case 161:
+ case 181:
+ case 182:
+ case 242:
+ case 183:
+ case 184:
+ case 243:
+ case 244:
+ case 245:
+ case 165:
+ case 178:
+ case 179:
+ case 49:
+ case 50:
+ case 168:
+ case 169:
+ case 175:
+ case 170:
+ case 171:
+ case 172:
+ case 97:
+ case 76:
+ case 32:
+ case 173:
+ case 35:
+ return -1;
+ case 176:
+ case 177:
+ case 7:
+ case 155:
+ case 8:
+ case 157:
+ case 125:
+ case 126:
+ case 92:
+ case 93:
+ case 129:
+ case 130:
+ case 131:
+ case 94:
+ case 91:
+ return 1;
+ case 74:
+ case 60:
+ case 69:
+ case 70:
+ case 4:
+ return 1024;
+ case 31:
+ case 42:
+ case 72:
+ return 32;
+ case 87:
+ case 26:
+ case 33:
+ return 2147483647;
+ case 34:
+ case 1:
+ return 47839;
+ case 38:
+ case 36:
+ return 99;
+ case 43:
+ case 37:
+ return 2048;
+ case 0: return 2097152;
+ case 3: return 65536;
+ case 28: return 32768;
+ case 44: return 32767;
+ case 75: return 16384;
+ case 39: return 1000;
+ case 89: return 700;
+ case 71: return 256;
+ case 40: return 255;
+ case 2: return 100;
+ case 180: return 64;
+ case 25: return 20;
+ case 5: return 16;
+ case 6: return 6;
+ case 73: return 4;
+ case 84: return 1;
+ }
+ ___setErrNo(ERRNO_CODES.EINVAL);
+ return -1;
+ }
+
+
+ Module["_memset"] = _memset;
+
+ function ___errno_location() {
+ return ___errno_state;
+ }
+
+ function _abort() {
+ Module['abort']();
+ }
+
+ var Browser={mainLoop:{scheduler:null,method:"",shouldPause:false,paused:false,queue:[],pause:function () {
+ Browser.mainLoop.shouldPause = true;
+ },resume:function () {
+ if (Browser.mainLoop.paused) {
+ Browser.mainLoop.paused = false;
+ Browser.mainLoop.scheduler();
+ }
+ Browser.mainLoop.shouldPause = false;
+ },updateStatus:function () {
+ if (Module['setStatus']) {
+ var message = Module['statusMessage'] || 'Please wait...';
+ var remaining = Browser.mainLoop.remainingBlockers;
+ var expected = Browser.mainLoop.expectedBlockers;
+ if (remaining) {
+ if (remaining < expected) {
+ Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');
+ } else {
+ Module['setStatus'](message);
+ }
+ } else {
+ Module['setStatus']('');
+ }
+ }
+ }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {
+ if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers
+
+ if (Browser.initted || ENVIRONMENT_IS_WORKER) return;
+ Browser.initted = true;
+
+ try {
+ new Blob();
+ Browser.hasBlobConstructor = true;
+ } catch(e) {
+ Browser.hasBlobConstructor = false;
+ console.log("warning: no blob constructor, cannot create blobs with mimetypes");
+ }
+ Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null));
+ Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
+ if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {
+ console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
+ Module.noImageDecoding = true;
+ }
+
+ // Support for plugins that can process preloaded files. You can add more of these to
+ // your app by creating and appending to Module.preloadPlugins.
+ //
+ // Each plugin is asked if it can handle a file based on the file's name. If it can,
+ // it is given the file's raw data. When it is done, it calls a callback with the file's
+ // (possibly modified) data. For example, a plugin might decompress a file, or it
+ // might create some side data structure for use later (like an Image element, etc.).
+
+ var imagePlugin = {};
+ imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
+ return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
+ };
+ imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
+ var b = null;
+ if (Browser.hasBlobConstructor) {
+ try {
+ b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ if (b.size !== byteArray.length) { // Safari bug #118630
+ // Safari's Blob can only take an ArrayBuffer
+ b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
+ }
+ } catch(e) {
+ Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');
+ }
+ }
+ if (!b) {
+ var bb = new Browser.BlobBuilder();
+ bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range
+ b = bb.getBlob();
+ }
+ var url = Browser.URLObject.createObjectURL(b);
+ var img = new Image();
+ img.onload = function img_onload() {
+ assert(img.complete, 'Image ' + name + ' could not be decoded');
+ var canvas = document.createElement('canvas');
+ canvas.width = img.width;
+ canvas.height = img.height;
+ var ctx = canvas.getContext('2d');
+ ctx.drawImage(img, 0, 0);
+ Module["preloadedImages"][name] = canvas;
+ Browser.URLObject.revokeObjectURL(url);
+ if (onload) onload(byteArray);
+ };
+ img.onerror = function img_onerror(event) {
+ console.log('Image ' + url + ' could not be decoded');
+ if (onerror) onerror();
+ };
+ img.src = url;
+ };
+ Module['preloadPlugins'].push(imagePlugin);
+
+ var audioPlugin = {};
+ audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
+ return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
+ };
+ audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
+ var done = false;
+ function finish(audio) {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = audio;
+ if (onload) onload(byteArray);
+ }
+ function fail() {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = new Audio(); // empty shim
+ if (onerror) onerror();
+ }
+ if (Browser.hasBlobConstructor) {
+ try {
+ var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ } catch(e) {
+ return fail();
+ }
+ var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
+ var audio = new Audio();
+ audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
+ audio.onerror = function audio_onerror(event) {
+ if (done) return;
+ console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
+ function encode64(data) {
+ var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ var PAD = '=';
+ var ret = '';
+ var leftchar = 0;
+ var leftbits = 0;
+ for (var i = 0; i < data.length; i++) {
+ leftchar = (leftchar << 8) | data[i];
+ leftbits += 8;
+ while (leftbits >= 6) {
+ var curr = (leftchar >> (leftbits-6)) & 0x3f;
+ leftbits -= 6;
+ ret += BASE[curr];
+ }
+ }
+ if (leftbits == 2) {
+ ret += BASE[(leftchar&3) << 4];
+ ret += PAD + PAD;
+ } else if (leftbits == 4) {
+ ret += BASE[(leftchar&0xf) << 2];
+ ret += PAD;
+ }
+ return ret;
+ }
+ audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);
+ finish(audio); // we don't wait for confirmation this worked - but it's worth trying
+ };
+ audio.src = url;
+ // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror
+ Browser.safeSetTimeout(function() {
+ finish(audio); // try to use it even though it is not necessarily ready to play
+ }, 10000);
+ } else {
+ return fail();
+ }
+ };
+ Module['preloadPlugins'].push(audioPlugin);
+
+ // Canvas event setup
+
+ var canvas = Module['canvas'];
+
+ // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module
+ // Module['forcedAspectRatio'] = 4 / 3;
+
+ canvas.requestPointerLock = canvas['requestPointerLock'] ||
+ canvas['mozRequestPointerLock'] ||
+ canvas['webkitRequestPointerLock'] ||
+ canvas['msRequestPointerLock'] ||
+ function(){};
+ canvas.exitPointerLock = document['exitPointerLock'] ||
+ document['mozExitPointerLock'] ||
+ document['webkitExitPointerLock'] ||
+ document['msExitPointerLock'] ||
+ function(){}; // no-op if function does not exist
+ canvas.exitPointerLock = canvas.exitPointerLock.bind(document);
+
+ function pointerLockChange() {
+ Browser.pointerLock = document['pointerLockElement'] === canvas ||
+ document['mozPointerLockElement'] === canvas ||
+ document['webkitPointerLockElement'] === canvas ||
+ document['msPointerLockElement'] === canvas;
+ }
+
+ document.addEventListener('pointerlockchange', pointerLockChange, false);
+ document.addEventListener('mozpointerlockchange', pointerLockChange, false);
+ document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
+ document.addEventListener('mspointerlockchange', pointerLockChange, false);
+
+ if (Module['elementPointerLock']) {
+ canvas.addEventListener("click", function(ev) {
+ if (!Browser.pointerLock && canvas.requestPointerLock) {
+ canvas.requestPointerLock();
+ ev.preventDefault();
+ }
+ }, false);
+ }
+ },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) {
+ var ctx;
+ var errorInfo = '?';
+ function onContextCreationError(event) {
+ errorInfo = event.statusMessage || errorInfo;
+ }
+ try {
+ if (useWebGL) {
+ var contextAttributes = {
+ antialias: false,
+ alpha: false
+ };
+
+ if (webGLContextAttributes) {
+ for (var attribute in webGLContextAttributes) {
+ contextAttributes[attribute] = webGLContextAttributes[attribute];
+ }
+ }
+
+
+ canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
+ try {
+ ['experimental-webgl', 'webgl'].some(function(webglId) {
+ return ctx = canvas.getContext(webglId, contextAttributes);
+ });
+ } finally {
+ canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
+ }
+ } else {
+ ctx = canvas.getContext('2d');
+ }
+ if (!ctx) throw ':(';
+ } catch (e) {
+ Module.print('Could not create canvas: ' + [errorInfo, e]);
+ return null;
+ }
+ if (useWebGL) {
+ // Set the background of the WebGL canvas to black
+ canvas.style.backgroundColor = "black";
+
+ // Warn on context loss
+ canvas.addEventListener('webglcontextlost', function(event) {
+ alert('WebGL context lost. You will need to reload the page.');
+ }, false);
+ }
+ if (setInModule) {
+ GLctx = Module.ctx = ctx;
+ Module.useWebGL = useWebGL;
+ Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
+ Browser.init();
+ }
+ return ctx;
+ },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {
+ Browser.lockPointer = lockPointer;
+ Browser.resizeCanvas = resizeCanvas;
+ if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;
+ if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;
+
+ var canvas = Module['canvas'];
+ function fullScreenChange() {
+ Browser.isFullScreen = false;
+ var canvasContainer = canvas.parentNode;
+ if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvasContainer) {
+ canvas.cancelFullScreen = document['cancelFullScreen'] ||
+ document['mozCancelFullScreen'] ||
+ document['webkitCancelFullScreen'] ||
+ document['msExitFullscreen'] ||
+ document['exitFullscreen'] ||
+ function() {};
+ canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);
+ if (Browser.lockPointer) canvas.requestPointerLock();
+ Browser.isFullScreen = true;
+ if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();
+ } else {
+
+ // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen
+ canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
+ canvasContainer.parentNode.removeChild(canvasContainer);
+
+ if (Browser.resizeCanvas) Browser.setWindowedCanvasSize();
+ }
+ if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);
+ Browser.updateCanvasDimensions(canvas);
+ }
+
+ if (!Browser.fullScreenHandlersInstalled) {
+ Browser.fullScreenHandlersInstalled = true;
+ document.addEventListener('fullscreenchange', fullScreenChange, false);
+ document.addEventListener('mozfullscreenchange', fullScreenChange, false);
+ document.addEventListener('webkitfullscreenchange', fullScreenChange, false);
+ document.addEventListener('MSFullscreenChange', fullScreenChange, false);
+ }
+
+ // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root
+ var canvasContainer = document.createElement("div");
+ canvas.parentNode.insertBefore(canvasContainer, canvas);
+ canvasContainer.appendChild(canvas);
+
+ // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size)
+ canvasContainer.requestFullScreen = canvasContainer['requestFullScreen'] ||
+ canvasContainer['mozRequestFullScreen'] ||
+ canvasContainer['msRequestFullscreen'] ||
+ (canvasContainer['webkitRequestFullScreen'] ? function() { canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);
+ canvasContainer.requestFullScreen();
+ },requestAnimationFrame:function requestAnimationFrame(func) {
+ if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
+ setTimeout(func, 1000/60);
+ } else {
+ if (!window.requestAnimationFrame) {
+ window.requestAnimationFrame = window['requestAnimationFrame'] ||
+ window['mozRequestAnimationFrame'] ||
+ window['webkitRequestAnimationFrame'] ||
+ window['msRequestAnimationFrame'] ||
+ window['oRequestAnimationFrame'] ||
+ window['setTimeout'];
+ }
+ window.requestAnimationFrame(func);
+ }
+ },safeCallback:function (func) {
+ return function() {
+ if (!ABORT) return func.apply(null, arguments);
+ };
+ },safeRequestAnimationFrame:function (func) {
+ return Browser.requestAnimationFrame(function() {
+ if (!ABORT) func();
+ });
+ },safeSetTimeout:function (func, timeout) {
+ return setTimeout(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },safeSetInterval:function (func, timeout) {
+ return setInterval(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },getMimetype:function (name) {
+ return {
+ 'jpg': 'image/jpeg',
+ 'jpeg': 'image/jpeg',
+ 'png': 'image/png',
+ 'bmp': 'image/bmp',
+ 'ogg': 'audio/ogg',
+ 'wav': 'audio/wav',
+ 'mp3': 'audio/mpeg'
+ }[name.substr(name.lastIndexOf('.')+1)];
+ },getUserMedia:function (func) {
+ if(!window.getUserMedia) {
+ window.getUserMedia = navigator['getUserMedia'] ||
+ navigator['mozGetUserMedia'];
+ }
+ window.getUserMedia(func);
+ },getMovementX:function (event) {
+ return event['movementX'] ||
+ event['mozMovementX'] ||
+ event['webkitMovementX'] ||
+ 0;
+ },getMovementY:function (event) {
+ return event['movementY'] ||
+ event['mozMovementY'] ||
+ event['webkitMovementY'] ||
+ 0;
+ },getMouseWheelDelta:function (event) {
+ return Math.max(-1, Math.min(1, event.type === 'DOMMouseScroll' ? event.detail : -event.wheelDelta));
+ },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup
+ if (Browser.pointerLock) {
+ // When the pointer is locked, calculate the coordinates
+ // based on the movement of the mouse.
+ // Workaround for Firefox bug 764498
+ if (event.type != 'mousemove' &&
+ ('mozMovementX' in event)) {
+ Browser.mouseMovementX = Browser.mouseMovementY = 0;
+ } else {
+ Browser.mouseMovementX = Browser.getMovementX(event);
+ Browser.mouseMovementY = Browser.getMovementY(event);
+ }
+
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
+ Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
+ } else {
+ // just add the mouse delta to the current absolut mouse position
+ // FIXME: ideally this should be clamped against the canvas size and zero
+ Browser.mouseX += Browser.mouseMovementX;
+ Browser.mouseY += Browser.mouseMovementY;
+ }
+ } else {
+ // Otherwise, calculate the movement based on the changes
+ // in the coordinates.
+ var rect = Module["canvas"].getBoundingClientRect();
+ var x, y;
+
+ // Neither .scrollX or .pageXOffset are defined in a spec, but
+ // we prefer .scrollX because it is currently in a spec draft.
+ // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
+ var scrollX = ((typeof window.scrollX !== 'undefined') ? window.scrollX : window.pageXOffset);
+ var scrollY = ((typeof window.scrollY !== 'undefined') ? window.scrollY : window.pageYOffset);
+ if (event.type == 'touchstart' ||
+ event.type == 'touchend' ||
+ event.type == 'touchmove') {
+ var t = event.touches.item(0);
+ if (t) {
+ x = t.pageX - (scrollX + rect.left);
+ y = t.pageY - (scrollY + rect.top);
+ } else {
+ return;
+ }
+ } else {
+ x = event.pageX - (scrollX + rect.left);
+ y = event.pageY - (scrollY + rect.top);
+ }
+
+ // the canvas might be CSS-scaled compared to its backbuffer;
+ // SDL-using content will want mouse coordinates in terms
+ // of backbuffer units.
+ var cw = Module["canvas"].width;
+ var ch = Module["canvas"].height;
+ x = x * (cw / rect.width);
+ y = y * (ch / rect.height);
+
+ Browser.mouseMovementX = x - Browser.mouseX;
+ Browser.mouseMovementY = y - Browser.mouseY;
+ Browser.mouseX = x;
+ Browser.mouseY = y;
+ }
+ },xhrLoad:function (url, onload, onerror) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, true);
+ xhr.responseType = 'arraybuffer';
+ xhr.onload = function xhr_onload() {
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
+ onload(xhr.response);
+ } else {
+ onerror();
+ }
+ };
+ xhr.onerror = onerror;
+ xhr.send(null);
+ },asyncLoad:function (url, onload, onerror, noRunDep) {
+ Browser.xhrLoad(url, function(arrayBuffer) {
+ assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
+ onload(new Uint8Array(arrayBuffer));
+ if (!noRunDep) removeRunDependency('al ' + url);
+ }, function(event) {
+ if (onerror) {
+ onerror();
+ } else {
+ throw 'Loading data file "' + url + '" failed.';
+ }
+ });
+ if (!noRunDep) addRunDependency('al ' + url);
+ },resizeListeners:[],updateResizeListeners:function () {
+ var canvas = Module['canvas'];
+ Browser.resizeListeners.forEach(function(listener) {
+ listener(canvas.width, canvas.height);
+ });
+ },setCanvasSize:function (width, height, noUpdates) {
+ var canvas = Module['canvas'];
+ Browser.updateCanvasDimensions(canvas, width, height);
+ if (!noUpdates) Browser.updateResizeListeners();
+ },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },setWindowedCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },updateCanvasDimensions:function (canvas, wNative, hNative) {
+ if (wNative && hNative) {
+ canvas.widthNative = wNative;
+ canvas.heightNative = hNative;
+ } else {
+ wNative = canvas.widthNative;
+ hNative = canvas.heightNative;
+ }
+ var w = wNative;
+ var h = hNative;
+ if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) {
+ if (w/h < Module['forcedAspectRatio']) {
+ w = Math.round(h * Module['forcedAspectRatio']);
+ } else {
+ h = Math.round(w / Module['forcedAspectRatio']);
+ }
+ }
+ if (((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
+ var factor = Math.min(screen.width / w, screen.height / h);
+ w = Math.round(w * factor);
+ h = Math.round(h * factor);
+ }
+ if (Browser.resizeCanvas) {
+ if (canvas.width != w) canvas.width = w;
+ if (canvas.height != h) canvas.height = h;
+ if (typeof canvas.style != 'undefined') {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ } else {
+ if (canvas.width != wNative) canvas.width = wNative;
+ if (canvas.height != hNative) canvas.height = hNative;
+ if (typeof canvas.style != 'undefined') {
+ if (w != wNative || h != hNative) {
+ canvas.style.setProperty( "width", w + "px", "important");
+ canvas.style.setProperty("height", h + "px", "important");
+ } else {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ }
+ }
+ }};
+
+ function _time(ptr) {
+ var ret = Math.floor(Date.now()/1000);
+ if (ptr) {
+ HEAP32[((ptr)>>2)]=ret;
+ }
+ return ret;
+ }
+
+
+
+ function _emscripten_memcpy_big(dest, src, num) {
+ HEAPU8.set(HEAPU8.subarray(src, src+num), dest);
+ return dest;
+ }
+ Module["_memcpy"] = _memcpy;
+FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;
+___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;
+__ATINIT__.unshift({ func: function() { TTY.init() } });__ATEXIT__.push({ func: function() { TTY.shutdown() } });TTY.utf8 = new Runtime.UTF8Processor();
+if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); NODEFS.staticInit(); }
+__ATINIT__.push({ func: function() { SOCKFS.root = FS.mount(SOCKFS, {}, null); } });
+Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };
+ Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };
+ Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };
+ Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };
+ Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };
+ Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }
+STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);
+
+staticSealed = true; // seal the static portion of memory
+
+STACK_MAX = STACK_BASE + 5242880;
+
+DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);
+
+assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");
+
+
+var Math_min = Math.min;
+function asmPrintInt(x, y) {
+ Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+function asmPrintFloat(x, y) {
+ Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+// EMSCRIPTEN_START_ASM
+var asm = (function(global, env, buffer) {
+ 'use asm';
+ var HEAP8 = new global.Int8Array(buffer);
+ var HEAP16 = new global.Int16Array(buffer);
+ var HEAP32 = new global.Int32Array(buffer);
+ var HEAPU8 = new global.Uint8Array(buffer);
+ var HEAPU16 = new global.Uint16Array(buffer);
+ var HEAPU32 = new global.Uint32Array(buffer);
+ var HEAPF32 = new global.Float32Array(buffer);
+ var HEAPF64 = new global.Float64Array(buffer);
+
+ var STACKTOP=env.STACKTOP|0;
+ var STACK_MAX=env.STACK_MAX|0;
+ var tempDoublePtr=env.tempDoublePtr|0;
+ var ABORT=env.ABORT|0;
+
+ var __THREW__ = 0;
+ var threwValue = 0;
+ var setjmpId = 0;
+ var undef = 0;
+ var nan = +env.NaN, inf = +env.Infinity;
+ var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0;
+
+ var tempRet0 = 0;
+ var tempRet1 = 0;
+ var tempRet2 = 0;
+ var tempRet3 = 0;
+ var tempRet4 = 0;
+ var tempRet5 = 0;
+ var tempRet6 = 0;
+ var tempRet7 = 0;
+ var tempRet8 = 0;
+ var tempRet9 = 0;
+ var Math_floor=global.Math.floor;
+ var Math_abs=global.Math.abs;
+ var Math_sqrt=global.Math.sqrt;
+ var Math_pow=global.Math.pow;
+ var Math_cos=global.Math.cos;
+ var Math_sin=global.Math.sin;
+ var Math_tan=global.Math.tan;
+ var Math_acos=global.Math.acos;
+ var Math_asin=global.Math.asin;
+ var Math_atan=global.Math.atan;
+ var Math_atan2=global.Math.atan2;
+ var Math_exp=global.Math.exp;
+ var Math_log=global.Math.log;
+ var Math_ceil=global.Math.ceil;
+ var Math_imul=global.Math.imul;
+ var abort=env.abort;
+ var assert=env.assert;
+ var asmPrintInt=env.asmPrintInt;
+ var asmPrintFloat=env.asmPrintFloat;
+ var Math_min=env.min;
+ var _fflush=env._fflush;
+ var _emscripten_memcpy_big=env._emscripten_memcpy_big;
+ var _printf=env._printf;
+ var _send=env._send;
+ var _pwrite=env._pwrite;
+ var _abort=env._abort;
+ var ___setErrNo=env.___setErrNo;
+ var _fwrite=env._fwrite;
+ var _sbrk=env._sbrk;
+ var _time=env._time;
+ var _mkport=env._mkport;
+ var __reallyNegative=env.__reallyNegative;
+ var __formatString=env.__formatString;
+ var _fileno=env._fileno;
+ var _write=env._write;
+ var _fprintf=env._fprintf;
+ var _sysconf=env._sysconf;
+ var ___errno_location=env.___errno_location;
+ var tempFloat = 0.0;
+
+// EMSCRIPTEN_START_FUNCS
+function _malloc(i12) {
+ i12 = i12 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0;
+ i1 = STACKTOP;
+ do {
+ if (i12 >>> 0 < 245) {
+ if (i12 >>> 0 < 11) {
+ i12 = 16;
+ } else {
+ i12 = i12 + 11 & -8;
+ }
+ i20 = i12 >>> 3;
+ i18 = HEAP32[10] | 0;
+ i21 = i18 >>> i20;
+ if ((i21 & 3 | 0) != 0) {
+ i6 = (i21 & 1 ^ 1) + i20 | 0;
+ i5 = i6 << 1;
+ i3 = 80 + (i5 << 2) | 0;
+ i5 = 80 + (i5 + 2 << 2) | 0;
+ i7 = HEAP32[i5 >> 2] | 0;
+ i2 = i7 + 8 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ do {
+ if ((i3 | 0) != (i4 | 0)) {
+ if (i4 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i4 + 12 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i7 | 0)) {
+ HEAP32[i8 >> 2] = i3;
+ HEAP32[i5 >> 2] = i4;
+ break;
+ } else {
+ _abort();
+ }
+ } else {
+ HEAP32[10] = i18 & ~(1 << i6);
+ }
+ } while (0);
+ i32 = i6 << 3;
+ HEAP32[i7 + 4 >> 2] = i32 | 3;
+ i32 = i7 + (i32 | 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ i32 = i2;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ if (i12 >>> 0 > (HEAP32[48 >> 2] | 0) >>> 0) {
+ if ((i21 | 0) != 0) {
+ i7 = 2 << i20;
+ i7 = i21 << i20 & (i7 | 0 - i7);
+ i7 = (i7 & 0 - i7) + -1 | 0;
+ i2 = i7 >>> 12 & 16;
+ i7 = i7 >>> i2;
+ i6 = i7 >>> 5 & 8;
+ i7 = i7 >>> i6;
+ i5 = i7 >>> 2 & 4;
+ i7 = i7 >>> i5;
+ i4 = i7 >>> 1 & 2;
+ i7 = i7 >>> i4;
+ i3 = i7 >>> 1 & 1;
+ i3 = (i6 | i2 | i5 | i4 | i3) + (i7 >>> i3) | 0;
+ i7 = i3 << 1;
+ i4 = 80 + (i7 << 2) | 0;
+ i7 = 80 + (i7 + 2 << 2) | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ i2 = i5 + 8 | 0;
+ i6 = HEAP32[i2 >> 2] | 0;
+ do {
+ if ((i4 | 0) != (i6 | 0)) {
+ if (i6 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i6 + 12 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i5 | 0)) {
+ HEAP32[i8 >> 2] = i4;
+ HEAP32[i7 >> 2] = i6;
+ break;
+ } else {
+ _abort();
+ }
+ } else {
+ HEAP32[10] = i18 & ~(1 << i3);
+ }
+ } while (0);
+ i6 = i3 << 3;
+ i4 = i6 - i12 | 0;
+ HEAP32[i5 + 4 >> 2] = i12 | 3;
+ i3 = i5 + i12 | 0;
+ HEAP32[i5 + (i12 | 4) >> 2] = i4 | 1;
+ HEAP32[i5 + i6 >> 2] = i4;
+ i6 = HEAP32[48 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i5 = HEAP32[60 >> 2] | 0;
+ i8 = i6 >>> 3;
+ i9 = i8 << 1;
+ i6 = 80 + (i9 << 2) | 0;
+ i7 = HEAP32[10] | 0;
+ i8 = 1 << i8;
+ if ((i7 & i8 | 0) != 0) {
+ i7 = 80 + (i9 + 2 << 2) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i28 = i7;
+ i27 = i8;
+ }
+ } else {
+ HEAP32[10] = i7 | i8;
+ i28 = 80 + (i9 + 2 << 2) | 0;
+ i27 = i6;
+ }
+ HEAP32[i28 >> 2] = i5;
+ HEAP32[i27 + 12 >> 2] = i5;
+ HEAP32[i5 + 8 >> 2] = i27;
+ HEAP32[i5 + 12 >> 2] = i6;
+ }
+ HEAP32[48 >> 2] = i4;
+ HEAP32[60 >> 2] = i3;
+ i32 = i2;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i18 = HEAP32[44 >> 2] | 0;
+ if ((i18 | 0) != 0) {
+ i2 = (i18 & 0 - i18) + -1 | 0;
+ i31 = i2 >>> 12 & 16;
+ i2 = i2 >>> i31;
+ i30 = i2 >>> 5 & 8;
+ i2 = i2 >>> i30;
+ i32 = i2 >>> 2 & 4;
+ i2 = i2 >>> i32;
+ i6 = i2 >>> 1 & 2;
+ i2 = i2 >>> i6;
+ i3 = i2 >>> 1 & 1;
+ i3 = HEAP32[344 + ((i30 | i31 | i32 | i6 | i3) + (i2 >>> i3) << 2) >> 2] | 0;
+ i2 = (HEAP32[i3 + 4 >> 2] & -8) - i12 | 0;
+ i6 = i3;
+ while (1) {
+ i5 = HEAP32[i6 + 16 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i5 = HEAP32[i6 + 20 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ }
+ i6 = (HEAP32[i5 + 4 >> 2] & -8) - i12 | 0;
+ i4 = i6 >>> 0 < i2 >>> 0;
+ i2 = i4 ? i6 : i2;
+ i6 = i5;
+ i3 = i4 ? i5 : i3;
+ }
+ i6 = HEAP32[56 >> 2] | 0;
+ if (i3 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ i4 = i3 + i12 | 0;
+ if (!(i3 >>> 0 < i4 >>> 0)) {
+ _abort();
+ }
+ i5 = HEAP32[i3 + 24 >> 2] | 0;
+ i7 = HEAP32[i3 + 12 >> 2] | 0;
+ do {
+ if ((i7 | 0) == (i3 | 0)) {
+ i8 = i3 + 20 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i8 = i3 + 16 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i26 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i10 = i7 + 20 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ i7 = i9;
+ i8 = i10;
+ continue;
+ }
+ i10 = i7 + 16 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ } else {
+ i7 = i9;
+ i8 = i10;
+ }
+ }
+ if (i8 >>> 0 < i6 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i8 >> 2] = 0;
+ i26 = i7;
+ break;
+ }
+ } else {
+ i8 = HEAP32[i3 + 8 >> 2] | 0;
+ if (i8 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ i6 = i8 + 12 | 0;
+ if ((HEAP32[i6 >> 2] | 0) != (i3 | 0)) {
+ _abort();
+ }
+ i9 = i7 + 8 | 0;
+ if ((HEAP32[i9 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i6 >> 2] = i7;
+ HEAP32[i9 >> 2] = i8;
+ i26 = i7;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ do {
+ if ((i5 | 0) != 0) {
+ i7 = HEAP32[i3 + 28 >> 2] | 0;
+ i6 = 344 + (i7 << 2) | 0;
+ if ((i3 | 0) == (HEAP32[i6 >> 2] | 0)) {
+ HEAP32[i6 >> 2] = i26;
+ if ((i26 | 0) == 0) {
+ HEAP32[44 >> 2] = HEAP32[44 >> 2] & ~(1 << i7);
+ break;
+ }
+ } else {
+ if (i5 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i6 = i5 + 16 | 0;
+ if ((HEAP32[i6 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i6 >> 2] = i26;
+ } else {
+ HEAP32[i5 + 20 >> 2] = i26;
+ }
+ if ((i26 | 0) == 0) {
+ break;
+ }
+ }
+ if (i26 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i26 + 24 >> 2] = i5;
+ i5 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i26 + 16 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i26;
+ break;
+ }
+ }
+ } while (0);
+ i5 = HEAP32[i3 + 20 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i26 + 20 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i26;
+ break;
+ }
+ }
+ }
+ } while (0);
+ if (i2 >>> 0 < 16) {
+ i32 = i2 + i12 | 0;
+ HEAP32[i3 + 4 >> 2] = i32 | 3;
+ i32 = i3 + (i32 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ } else {
+ HEAP32[i3 + 4 >> 2] = i12 | 3;
+ HEAP32[i3 + (i12 | 4) >> 2] = i2 | 1;
+ HEAP32[i3 + (i2 + i12) >> 2] = i2;
+ i6 = HEAP32[48 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i5 = HEAP32[60 >> 2] | 0;
+ i8 = i6 >>> 3;
+ i9 = i8 << 1;
+ i6 = 80 + (i9 << 2) | 0;
+ i7 = HEAP32[10] | 0;
+ i8 = 1 << i8;
+ if ((i7 & i8 | 0) != 0) {
+ i7 = 80 + (i9 + 2 << 2) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i25 = i7;
+ i24 = i8;
+ }
+ } else {
+ HEAP32[10] = i7 | i8;
+ i25 = 80 + (i9 + 2 << 2) | 0;
+ i24 = i6;
+ }
+ HEAP32[i25 >> 2] = i5;
+ HEAP32[i24 + 12 >> 2] = i5;
+ HEAP32[i5 + 8 >> 2] = i24;
+ HEAP32[i5 + 12 >> 2] = i6;
+ }
+ HEAP32[48 >> 2] = i2;
+ HEAP32[60 >> 2] = i4;
+ }
+ i32 = i3 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ } else {
+ if (!(i12 >>> 0 > 4294967231)) {
+ i24 = i12 + 11 | 0;
+ i12 = i24 & -8;
+ i26 = HEAP32[44 >> 2] | 0;
+ if ((i26 | 0) != 0) {
+ i25 = 0 - i12 | 0;
+ i24 = i24 >>> 8;
+ if ((i24 | 0) != 0) {
+ if (i12 >>> 0 > 16777215) {
+ i27 = 31;
+ } else {
+ i31 = (i24 + 1048320 | 0) >>> 16 & 8;
+ i32 = i24 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i27 = (i32 + 245760 | 0) >>> 16 & 2;
+ i27 = 14 - (i30 | i31 | i27) + (i32 << i27 >>> 15) | 0;
+ i27 = i12 >>> (i27 + 7 | 0) & 1 | i27 << 1;
+ }
+ } else {
+ i27 = 0;
+ }
+ i30 = HEAP32[344 + (i27 << 2) >> 2] | 0;
+ L126 : do {
+ if ((i30 | 0) == 0) {
+ i29 = 0;
+ i24 = 0;
+ } else {
+ if ((i27 | 0) == 31) {
+ i24 = 0;
+ } else {
+ i24 = 25 - (i27 >>> 1) | 0;
+ }
+ i29 = 0;
+ i28 = i12 << i24;
+ i24 = 0;
+ while (1) {
+ i32 = HEAP32[i30 + 4 >> 2] & -8;
+ i31 = i32 - i12 | 0;
+ if (i31 >>> 0 < i25 >>> 0) {
+ if ((i32 | 0) == (i12 | 0)) {
+ i25 = i31;
+ i29 = i30;
+ i24 = i30;
+ break L126;
+ } else {
+ i25 = i31;
+ i24 = i30;
+ }
+ }
+ i31 = HEAP32[i30 + 20 >> 2] | 0;
+ i30 = HEAP32[i30 + (i28 >>> 31 << 2) + 16 >> 2] | 0;
+ i29 = (i31 | 0) == 0 | (i31 | 0) == (i30 | 0) ? i29 : i31;
+ if ((i30 | 0) == 0) {
+ break;
+ } else {
+ i28 = i28 << 1;
+ }
+ }
+ }
+ } while (0);
+ if ((i29 | 0) == 0 & (i24 | 0) == 0) {
+ i32 = 2 << i27;
+ i26 = i26 & (i32 | 0 - i32);
+ if ((i26 | 0) == 0) {
+ break;
+ }
+ i32 = (i26 & 0 - i26) + -1 | 0;
+ i28 = i32 >>> 12 & 16;
+ i32 = i32 >>> i28;
+ i27 = i32 >>> 5 & 8;
+ i32 = i32 >>> i27;
+ i30 = i32 >>> 2 & 4;
+ i32 = i32 >>> i30;
+ i31 = i32 >>> 1 & 2;
+ i32 = i32 >>> i31;
+ i29 = i32 >>> 1 & 1;
+ i29 = HEAP32[344 + ((i27 | i28 | i30 | i31 | i29) + (i32 >>> i29) << 2) >> 2] | 0;
+ }
+ if ((i29 | 0) != 0) {
+ while (1) {
+ i27 = (HEAP32[i29 + 4 >> 2] & -8) - i12 | 0;
+ i26 = i27 >>> 0 < i25 >>> 0;
+ i25 = i26 ? i27 : i25;
+ i24 = i26 ? i29 : i24;
+ i26 = HEAP32[i29 + 16 >> 2] | 0;
+ if ((i26 | 0) != 0) {
+ i29 = i26;
+ continue;
+ }
+ i29 = HEAP32[i29 + 20 >> 2] | 0;
+ if ((i29 | 0) == 0) {
+ break;
+ }
+ }
+ }
+ if ((i24 | 0) != 0 ? i25 >>> 0 < ((HEAP32[48 >> 2] | 0) - i12 | 0) >>> 0 : 0) {
+ i4 = HEAP32[56 >> 2] | 0;
+ if (i24 >>> 0 < i4 >>> 0) {
+ _abort();
+ }
+ i2 = i24 + i12 | 0;
+ if (!(i24 >>> 0 < i2 >>> 0)) {
+ _abort();
+ }
+ i3 = HEAP32[i24 + 24 >> 2] | 0;
+ i6 = HEAP32[i24 + 12 >> 2] | 0;
+ do {
+ if ((i6 | 0) == (i24 | 0)) {
+ i6 = i24 + 20 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i6 = i24 + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i22 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i8 = i5 + 20 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) != 0) {
+ i5 = i7;
+ i6 = i8;
+ continue;
+ }
+ i7 = i5 + 16 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if ((i8 | 0) == 0) {
+ break;
+ } else {
+ i5 = i8;
+ i6 = i7;
+ }
+ }
+ if (i6 >>> 0 < i4 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = 0;
+ i22 = i5;
+ break;
+ }
+ } else {
+ i5 = HEAP32[i24 + 8 >> 2] | 0;
+ if (i5 >>> 0 < i4 >>> 0) {
+ _abort();
+ }
+ i7 = i5 + 12 | 0;
+ if ((HEAP32[i7 >> 2] | 0) != (i24 | 0)) {
+ _abort();
+ }
+ i4 = i6 + 8 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
+ HEAP32[i7 >> 2] = i6;
+ HEAP32[i4 >> 2] = i5;
+ i22 = i6;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ do {
+ if ((i3 | 0) != 0) {
+ i4 = HEAP32[i24 + 28 >> 2] | 0;
+ i5 = 344 + (i4 << 2) | 0;
+ if ((i24 | 0) == (HEAP32[i5 >> 2] | 0)) {
+ HEAP32[i5 >> 2] = i22;
+ if ((i22 | 0) == 0) {
+ HEAP32[44 >> 2] = HEAP32[44 >> 2] & ~(1 << i4);
+ break;
+ }
+ } else {
+ if (i3 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i4 = i3 + 16 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
+ HEAP32[i4 >> 2] = i22;
+ } else {
+ HEAP32[i3 + 20 >> 2] = i22;
+ }
+ if ((i22 | 0) == 0) {
+ break;
+ }
+ }
+ if (i22 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i22 + 24 >> 2] = i3;
+ i3 = HEAP32[i24 + 16 >> 2] | 0;
+ do {
+ if ((i3 | 0) != 0) {
+ if (i3 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i22 + 16 >> 2] = i3;
+ HEAP32[i3 + 24 >> 2] = i22;
+ break;
+ }
+ }
+ } while (0);
+ i3 = HEAP32[i24 + 20 >> 2] | 0;
+ if ((i3 | 0) != 0) {
+ if (i3 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i22 + 20 >> 2] = i3;
+ HEAP32[i3 + 24 >> 2] = i22;
+ break;
+ }
+ }
+ }
+ } while (0);
+ L204 : do {
+ if (!(i25 >>> 0 < 16)) {
+ HEAP32[i24 + 4 >> 2] = i12 | 3;
+ HEAP32[i24 + (i12 | 4) >> 2] = i25 | 1;
+ HEAP32[i24 + (i25 + i12) >> 2] = i25;
+ i4 = i25 >>> 3;
+ if (i25 >>> 0 < 256) {
+ i6 = i4 << 1;
+ i3 = 80 + (i6 << 2) | 0;
+ i5 = HEAP32[10] | 0;
+ i4 = 1 << i4;
+ if ((i5 & i4 | 0) != 0) {
+ i5 = 80 + (i6 + 2 << 2) | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ if (i4 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i21 = i5;
+ i20 = i4;
+ }
+ } else {
+ HEAP32[10] = i5 | i4;
+ i21 = 80 + (i6 + 2 << 2) | 0;
+ i20 = i3;
+ }
+ HEAP32[i21 >> 2] = i2;
+ HEAP32[i20 + 12 >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i20;
+ HEAP32[i24 + (i12 + 12) >> 2] = i3;
+ break;
+ }
+ i3 = i25 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i25 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i25 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i6 = 344 + (i3 << 2) | 0;
+ HEAP32[i24 + (i12 + 28) >> 2] = i3;
+ HEAP32[i24 + (i12 + 20) >> 2] = 0;
+ HEAP32[i24 + (i12 + 16) >> 2] = 0;
+ i4 = HEAP32[44 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i4 & i5 | 0) == 0) {
+ HEAP32[44 >> 2] = i4 | i5;
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i24 + (i12 + 24) >> 2] = i6;
+ HEAP32[i24 + (i12 + 12) >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i2;
+ break;
+ }
+ i4 = HEAP32[i6 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L225 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i25 | 0)) {
+ i3 = i25 << i3;
+ while (1) {
+ i6 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i25 | 0)) {
+ i18 = i5;
+ break L225;
+ } else {
+ i3 = i3 << 1;
+ i4 = i5;
+ }
+ }
+ if (i6 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i24 + (i12 + 24) >> 2] = i4;
+ HEAP32[i24 + (i12 + 12) >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i2;
+ break L204;
+ }
+ } else {
+ i18 = i4;
+ }
+ } while (0);
+ i4 = i18 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[56 >> 2] | 0;
+ if (i18 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i2;
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i3;
+ HEAP32[i24 + (i12 + 12) >> 2] = i18;
+ HEAP32[i24 + (i12 + 24) >> 2] = 0;
+ break;
+ }
+ } else {
+ i32 = i25 + i12 | 0;
+ HEAP32[i24 + 4 >> 2] = i32 | 3;
+ i32 = i24 + (i32 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ }
+ } while (0);
+ i32 = i24 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ } else {
+ i12 = -1;
+ }
+ }
+ } while (0);
+ i18 = HEAP32[48 >> 2] | 0;
+ if (!(i12 >>> 0 > i18 >>> 0)) {
+ i3 = i18 - i12 | 0;
+ i2 = HEAP32[60 >> 2] | 0;
+ if (i3 >>> 0 > 15) {
+ HEAP32[60 >> 2] = i2 + i12;
+ HEAP32[48 >> 2] = i3;
+ HEAP32[i2 + (i12 + 4) >> 2] = i3 | 1;
+ HEAP32[i2 + i18 >> 2] = i3;
+ HEAP32[i2 + 4 >> 2] = i12 | 3;
+ } else {
+ HEAP32[48 >> 2] = 0;
+ HEAP32[60 >> 2] = 0;
+ HEAP32[i2 + 4 >> 2] = i18 | 3;
+ i32 = i2 + (i18 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ }
+ i32 = i2 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i18 = HEAP32[52 >> 2] | 0;
+ if (i12 >>> 0 < i18 >>> 0) {
+ i31 = i18 - i12 | 0;
+ HEAP32[52 >> 2] = i31;
+ i32 = HEAP32[64 >> 2] | 0;
+ HEAP32[64 >> 2] = i32 + i12;
+ HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
+ HEAP32[i32 + 4 >> 2] = i12 | 3;
+ i32 = i32 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ do {
+ if ((HEAP32[128] | 0) == 0) {
+ i18 = _sysconf(30) | 0;
+ if ((i18 + -1 & i18 | 0) == 0) {
+ HEAP32[520 >> 2] = i18;
+ HEAP32[516 >> 2] = i18;
+ HEAP32[524 >> 2] = -1;
+ HEAP32[528 >> 2] = -1;
+ HEAP32[532 >> 2] = 0;
+ HEAP32[484 >> 2] = 0;
+ HEAP32[128] = (_time(0) | 0) & -16 ^ 1431655768;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ i20 = i12 + 48 | 0;
+ i25 = HEAP32[520 >> 2] | 0;
+ i21 = i12 + 47 | 0;
+ i22 = i25 + i21 | 0;
+ i25 = 0 - i25 | 0;
+ i18 = i22 & i25;
+ if (!(i18 >>> 0 > i12 >>> 0)) {
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i24 = HEAP32[480 >> 2] | 0;
+ if ((i24 | 0) != 0 ? (i31 = HEAP32[472 >> 2] | 0, i32 = i31 + i18 | 0, i32 >>> 0 <= i31 >>> 0 | i32 >>> 0 > i24 >>> 0) : 0) {
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ L269 : do {
+ if ((HEAP32[484 >> 2] & 4 | 0) == 0) {
+ i26 = HEAP32[64 >> 2] | 0;
+ L271 : do {
+ if ((i26 | 0) != 0) {
+ i24 = 488 | 0;
+ while (1) {
+ i27 = HEAP32[i24 >> 2] | 0;
+ if (!(i27 >>> 0 > i26 >>> 0) ? (i23 = i24 + 4 | 0, (i27 + (HEAP32[i23 >> 2] | 0) | 0) >>> 0 > i26 >>> 0) : 0) {
+ break;
+ }
+ i24 = HEAP32[i24 + 8 >> 2] | 0;
+ if ((i24 | 0) == 0) {
+ i13 = 182;
+ break L271;
+ }
+ }
+ if ((i24 | 0) != 0) {
+ i25 = i22 - (HEAP32[52 >> 2] | 0) & i25;
+ if (i25 >>> 0 < 2147483647) {
+ i13 = _sbrk(i25 | 0) | 0;
+ i26 = (i13 | 0) == ((HEAP32[i24 >> 2] | 0) + (HEAP32[i23 >> 2] | 0) | 0);
+ i22 = i13;
+ i24 = i25;
+ i23 = i26 ? i13 : -1;
+ i25 = i26 ? i25 : 0;
+ i13 = 191;
+ } else {
+ i25 = 0;
+ }
+ } else {
+ i13 = 182;
+ }
+ } else {
+ i13 = 182;
+ }
+ } while (0);
+ do {
+ if ((i13 | 0) == 182) {
+ i23 = _sbrk(0) | 0;
+ if ((i23 | 0) != (-1 | 0)) {
+ i24 = i23;
+ i22 = HEAP32[516 >> 2] | 0;
+ i25 = i22 + -1 | 0;
+ if ((i25 & i24 | 0) == 0) {
+ i25 = i18;
+ } else {
+ i25 = i18 - i24 + (i25 + i24 & 0 - i22) | 0;
+ }
+ i24 = HEAP32[472 >> 2] | 0;
+ i26 = i24 + i25 | 0;
+ if (i25 >>> 0 > i12 >>> 0 & i25 >>> 0 < 2147483647) {
+ i22 = HEAP32[480 >> 2] | 0;
+ if ((i22 | 0) != 0 ? i26 >>> 0 <= i24 >>> 0 | i26 >>> 0 > i22 >>> 0 : 0) {
+ i25 = 0;
+ break;
+ }
+ i22 = _sbrk(i25 | 0) | 0;
+ i13 = (i22 | 0) == (i23 | 0);
+ i24 = i25;
+ i23 = i13 ? i23 : -1;
+ i25 = i13 ? i25 : 0;
+ i13 = 191;
+ } else {
+ i25 = 0;
+ }
+ } else {
+ i25 = 0;
+ }
+ }
+ } while (0);
+ L291 : do {
+ if ((i13 | 0) == 191) {
+ i13 = 0 - i24 | 0;
+ if ((i23 | 0) != (-1 | 0)) {
+ i17 = i23;
+ i14 = i25;
+ i13 = 202;
+ break L269;
+ }
+ do {
+ if ((i22 | 0) != (-1 | 0) & i24 >>> 0 < 2147483647 & i24 >>> 0 < i20 >>> 0 ? (i19 = HEAP32[520 >> 2] | 0, i19 = i21 - i24 + i19 & 0 - i19, i19 >>> 0 < 2147483647) : 0) {
+ if ((_sbrk(i19 | 0) | 0) == (-1 | 0)) {
+ _sbrk(i13 | 0) | 0;
+ break L291;
+ } else {
+ i24 = i19 + i24 | 0;
+ break;
+ }
+ }
+ } while (0);
+ if ((i22 | 0) != (-1 | 0)) {
+ i17 = i22;
+ i14 = i24;
+ i13 = 202;
+ break L269;
+ }
+ }
+ } while (0);
+ HEAP32[484 >> 2] = HEAP32[484 >> 2] | 4;
+ i13 = 199;
+ } else {
+ i25 = 0;
+ i13 = 199;
+ }
+ } while (0);
+ if ((((i13 | 0) == 199 ? i18 >>> 0 < 2147483647 : 0) ? (i17 = _sbrk(i18 | 0) | 0, i16 = _sbrk(0) | 0, (i16 | 0) != (-1 | 0) & (i17 | 0) != (-1 | 0) & i17 >>> 0 < i16 >>> 0) : 0) ? (i15 = i16 - i17 | 0, i14 = i15 >>> 0 > (i12 + 40 | 0) >>> 0, i14) : 0) {
+ i14 = i14 ? i15 : i25;
+ i13 = 202;
+ }
+ if ((i13 | 0) == 202) {
+ i15 = (HEAP32[472 >> 2] | 0) + i14 | 0;
+ HEAP32[472 >> 2] = i15;
+ if (i15 >>> 0 > (HEAP32[476 >> 2] | 0) >>> 0) {
+ HEAP32[476 >> 2] = i15;
+ }
+ i15 = HEAP32[64 >> 2] | 0;
+ L311 : do {
+ if ((i15 | 0) != 0) {
+ i21 = 488 | 0;
+ while (1) {
+ i16 = HEAP32[i21 >> 2] | 0;
+ i19 = i21 + 4 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i17 | 0) == (i16 + i20 | 0)) {
+ i13 = 214;
+ break;
+ }
+ i18 = HEAP32[i21 + 8 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ break;
+ } else {
+ i21 = i18;
+ }
+ }
+ if (((i13 | 0) == 214 ? (HEAP32[i21 + 12 >> 2] & 8 | 0) == 0 : 0) ? i15 >>> 0 >= i16 >>> 0 & i15 >>> 0 < i17 >>> 0 : 0) {
+ HEAP32[i19 >> 2] = i20 + i14;
+ i2 = (HEAP32[52 >> 2] | 0) + i14 | 0;
+ i3 = i15 + 8 | 0;
+ if ((i3 & 7 | 0) == 0) {
+ i3 = 0;
+ } else {
+ i3 = 0 - i3 & 7;
+ }
+ i32 = i2 - i3 | 0;
+ HEAP32[64 >> 2] = i15 + i3;
+ HEAP32[52 >> 2] = i32;
+ HEAP32[i15 + (i3 + 4) >> 2] = i32 | 1;
+ HEAP32[i15 + (i2 + 4) >> 2] = 40;
+ HEAP32[68 >> 2] = HEAP32[528 >> 2];
+ break;
+ }
+ if (i17 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ HEAP32[56 >> 2] = i17;
+ }
+ i19 = i17 + i14 | 0;
+ i16 = 488 | 0;
+ while (1) {
+ if ((HEAP32[i16 >> 2] | 0) == (i19 | 0)) {
+ i13 = 224;
+ break;
+ }
+ i18 = HEAP32[i16 + 8 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ break;
+ } else {
+ i16 = i18;
+ }
+ }
+ if ((i13 | 0) == 224 ? (HEAP32[i16 + 12 >> 2] & 8 | 0) == 0 : 0) {
+ HEAP32[i16 >> 2] = i17;
+ i6 = i16 + 4 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + i14;
+ i6 = i17 + 8 | 0;
+ if ((i6 & 7 | 0) == 0) {
+ i6 = 0;
+ } else {
+ i6 = 0 - i6 & 7;
+ }
+ i7 = i17 + (i14 + 8) | 0;
+ if ((i7 & 7 | 0) == 0) {
+ i13 = 0;
+ } else {
+ i13 = 0 - i7 & 7;
+ }
+ i15 = i17 + (i13 + i14) | 0;
+ i8 = i6 + i12 | 0;
+ i7 = i17 + i8 | 0;
+ i10 = i15 - (i17 + i6) - i12 | 0;
+ HEAP32[i17 + (i6 + 4) >> 2] = i12 | 3;
+ L348 : do {
+ if ((i15 | 0) != (HEAP32[64 >> 2] | 0)) {
+ if ((i15 | 0) == (HEAP32[60 >> 2] | 0)) {
+ i32 = (HEAP32[48 >> 2] | 0) + i10 | 0;
+ HEAP32[48 >> 2] = i32;
+ HEAP32[60 >> 2] = i7;
+ HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i32 + i8) >> 2] = i32;
+ break;
+ }
+ i12 = i14 + 4 | 0;
+ i18 = HEAP32[i17 + (i12 + i13) >> 2] | 0;
+ if ((i18 & 3 | 0) == 1) {
+ i11 = i18 & -8;
+ i16 = i18 >>> 3;
+ do {
+ if (!(i18 >>> 0 < 256)) {
+ i9 = HEAP32[i17 + ((i13 | 24) + i14) >> 2] | 0;
+ i19 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
+ do {
+ if ((i19 | 0) == (i15 | 0)) {
+ i19 = i13 | 16;
+ i18 = i17 + (i12 + i19) | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ if ((i16 | 0) == 0) {
+ i18 = i17 + (i19 + i14) | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ if ((i16 | 0) == 0) {
+ i5 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i20 = i16 + 20 | 0;
+ i19 = HEAP32[i20 >> 2] | 0;
+ if ((i19 | 0) != 0) {
+ i16 = i19;
+ i18 = i20;
+ continue;
+ }
+ i19 = i16 + 16 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i20 | 0) == 0) {
+ break;
+ } else {
+ i16 = i20;
+ i18 = i19;
+ }
+ }
+ if (i18 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i18 >> 2] = 0;
+ i5 = i16;
+ break;
+ }
+ } else {
+ i18 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
+ if (i18 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i18 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != (i15 | 0)) {
+ _abort();
+ }
+ i20 = i19 + 8 | 0;
+ if ((HEAP32[i20 >> 2] | 0) == (i15 | 0)) {
+ HEAP32[i16 >> 2] = i19;
+ HEAP32[i20 >> 2] = i18;
+ i5 = i19;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i9 | 0) != 0) {
+ i16 = HEAP32[i17 + (i14 + 28 + i13) >> 2] | 0;
+ i18 = 344 + (i16 << 2) | 0;
+ if ((i15 | 0) == (HEAP32[i18 >> 2] | 0)) {
+ HEAP32[i18 >> 2] = i5;
+ if ((i5 | 0) == 0) {
+ HEAP32[44 >> 2] = HEAP32[44 >> 2] & ~(1 << i16);
+ break;
+ }
+ } else {
+ if (i9 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i9 + 16 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
+ HEAP32[i16 >> 2] = i5;
+ } else {
+ HEAP32[i9 + 20 >> 2] = i5;
+ }
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i5 + 24 >> 2] = i9;
+ i15 = i13 | 16;
+ i9 = HEAP32[i17 + (i15 + i14) >> 2] | 0;
+ do {
+ if ((i9 | 0) != 0) {
+ if (i9 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 + 16 >> 2] = i9;
+ HEAP32[i9 + 24 >> 2] = i5;
+ break;
+ }
+ }
+ } while (0);
+ i9 = HEAP32[i17 + (i12 + i15) >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ if (i9 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 + 20 >> 2] = i9;
+ HEAP32[i9 + 24 >> 2] = i5;
+ break;
+ }
+ }
+ }
+ } else {
+ i5 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
+ i12 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
+ i18 = 80 + (i16 << 1 << 2) | 0;
+ if ((i5 | 0) != (i18 | 0)) {
+ if (i5 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i5 + 12 >> 2] | 0) != (i15 | 0)) {
+ _abort();
+ }
+ }
+ if ((i12 | 0) == (i5 | 0)) {
+ HEAP32[10] = HEAP32[10] & ~(1 << i16);
+ break;
+ }
+ if ((i12 | 0) != (i18 | 0)) {
+ if (i12 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i12 + 8 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
+ i9 = i16;
+ } else {
+ _abort();
+ }
+ } else {
+ i9 = i12 + 8 | 0;
+ }
+ HEAP32[i5 + 12 >> 2] = i12;
+ HEAP32[i9 >> 2] = i5;
+ }
+ } while (0);
+ i15 = i17 + ((i11 | i13) + i14) | 0;
+ i10 = i11 + i10 | 0;
+ }
+ i5 = i15 + 4 | 0;
+ HEAP32[i5 >> 2] = HEAP32[i5 >> 2] & -2;
+ HEAP32[i17 + (i8 + 4) >> 2] = i10 | 1;
+ HEAP32[i17 + (i10 + i8) >> 2] = i10;
+ i5 = i10 >>> 3;
+ if (i10 >>> 0 < 256) {
+ i10 = i5 << 1;
+ i2 = 80 + (i10 << 2) | 0;
+ i9 = HEAP32[10] | 0;
+ i5 = 1 << i5;
+ if ((i9 & i5 | 0) != 0) {
+ i9 = 80 + (i10 + 2 << 2) | 0;
+ i5 = HEAP32[i9 >> 2] | 0;
+ if (i5 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i3 = i9;
+ i4 = i5;
+ }
+ } else {
+ HEAP32[10] = i9 | i5;
+ i3 = 80 + (i10 + 2 << 2) | 0;
+ i4 = i2;
+ }
+ HEAP32[i3 >> 2] = i7;
+ HEAP32[i4 + 12 >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i2;
+ break;
+ }
+ i3 = i10 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i10 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i10 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i4 = 344 + (i3 << 2) | 0;
+ HEAP32[i17 + (i8 + 28) >> 2] = i3;
+ HEAP32[i17 + (i8 + 20) >> 2] = 0;
+ HEAP32[i17 + (i8 + 16) >> 2] = 0;
+ i9 = HEAP32[44 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i9 & i5 | 0) == 0) {
+ HEAP32[44 >> 2] = i9 | i5;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i17 + (i8 + 24) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i7;
+ break;
+ }
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L444 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i10 | 0)) {
+ i3 = i10 << i3;
+ while (1) {
+ i5 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i9 = HEAP32[i5 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i9 + 4 >> 2] & -8 | 0) == (i10 | 0)) {
+ i2 = i9;
+ break L444;
+ } else {
+ i3 = i3 << 1;
+ i4 = i9;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 >> 2] = i7;
+ HEAP32[i17 + (i8 + 24) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i7;
+ break L348;
+ }
+ } else {
+ i2 = i4;
+ }
+ } while (0);
+ i4 = i2 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[56 >> 2] | 0;
+ if (i2 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i7;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i3;
+ HEAP32[i17 + (i8 + 12) >> 2] = i2;
+ HEAP32[i17 + (i8 + 24) >> 2] = 0;
+ break;
+ }
+ } else {
+ i32 = (HEAP32[52 >> 2] | 0) + i10 | 0;
+ HEAP32[52 >> 2] = i32;
+ HEAP32[64 >> 2] = i7;
+ HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
+ }
+ } while (0);
+ i32 = i17 + (i6 | 8) | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i3 = 488 | 0;
+ while (1) {
+ i2 = HEAP32[i3 >> 2] | 0;
+ if (!(i2 >>> 0 > i15 >>> 0) ? (i11 = HEAP32[i3 + 4 >> 2] | 0, i10 = i2 + i11 | 0, i10 >>> 0 > i15 >>> 0) : 0) {
+ break;
+ }
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ }
+ i3 = i2 + (i11 + -39) | 0;
+ if ((i3 & 7 | 0) == 0) {
+ i3 = 0;
+ } else {
+ i3 = 0 - i3 & 7;
+ }
+ i2 = i2 + (i11 + -47 + i3) | 0;
+ i2 = i2 >>> 0 < (i15 + 16 | 0) >>> 0 ? i15 : i2;
+ i3 = i2 + 8 | 0;
+ i4 = i17 + 8 | 0;
+ if ((i4 & 7 | 0) == 0) {
+ i4 = 0;
+ } else {
+ i4 = 0 - i4 & 7;
+ }
+ i32 = i14 + -40 - i4 | 0;
+ HEAP32[64 >> 2] = i17 + i4;
+ HEAP32[52 >> 2] = i32;
+ HEAP32[i17 + (i4 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i14 + -36) >> 2] = 40;
+ HEAP32[68 >> 2] = HEAP32[528 >> 2];
+ HEAP32[i2 + 4 >> 2] = 27;
+ HEAP32[i3 + 0 >> 2] = HEAP32[488 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[492 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[496 >> 2];
+ HEAP32[i3 + 12 >> 2] = HEAP32[500 >> 2];
+ HEAP32[488 >> 2] = i17;
+ HEAP32[492 >> 2] = i14;
+ HEAP32[500 >> 2] = 0;
+ HEAP32[496 >> 2] = i3;
+ i4 = i2 + 28 | 0;
+ HEAP32[i4 >> 2] = 7;
+ if ((i2 + 32 | 0) >>> 0 < i10 >>> 0) {
+ while (1) {
+ i3 = i4 + 4 | 0;
+ HEAP32[i3 >> 2] = 7;
+ if ((i4 + 8 | 0) >>> 0 < i10 >>> 0) {
+ i4 = i3;
+ } else {
+ break;
+ }
+ }
+ }
+ if ((i2 | 0) != (i15 | 0)) {
+ i2 = i2 - i15 | 0;
+ i3 = i15 + (i2 + 4) | 0;
+ HEAP32[i3 >> 2] = HEAP32[i3 >> 2] & -2;
+ HEAP32[i15 + 4 >> 2] = i2 | 1;
+ HEAP32[i15 + i2 >> 2] = i2;
+ i3 = i2 >>> 3;
+ if (i2 >>> 0 < 256) {
+ i4 = i3 << 1;
+ i2 = 80 + (i4 << 2) | 0;
+ i5 = HEAP32[10] | 0;
+ i3 = 1 << i3;
+ if ((i5 & i3 | 0) != 0) {
+ i4 = 80 + (i4 + 2 << 2) | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ if (i3 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i7 = i4;
+ i8 = i3;
+ }
+ } else {
+ HEAP32[10] = i5 | i3;
+ i7 = 80 + (i4 + 2 << 2) | 0;
+ i8 = i2;
+ }
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i8 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i8;
+ HEAP32[i15 + 12 >> 2] = i2;
+ break;
+ }
+ i3 = i2 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i2 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i2 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i7 = 344 + (i3 << 2) | 0;
+ HEAP32[i15 + 28 >> 2] = i3;
+ HEAP32[i15 + 20 >> 2] = 0;
+ HEAP32[i15 + 16 >> 2] = 0;
+ i4 = HEAP32[44 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i4 & i5 | 0) == 0) {
+ HEAP32[44 >> 2] = i4 | i5;
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i7;
+ HEAP32[i15 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i15;
+ break;
+ }
+ i4 = HEAP32[i7 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L499 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i2 | 0)) {
+ i3 = i2 << i3;
+ while (1) {
+ i7 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i2 | 0)) {
+ i6 = i5;
+ break L499;
+ } else {
+ i3 = i3 << 1;
+ i4 = i5;
+ }
+ }
+ if (i7 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i4;
+ HEAP32[i15 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i15;
+ break L311;
+ }
+ } else {
+ i6 = i4;
+ }
+ } while (0);
+ i4 = i6 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i2 = HEAP32[56 >> 2] | 0;
+ if (i6 >>> 0 < i2 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i2 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i15;
+ HEAP32[i4 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i3;
+ HEAP32[i15 + 12 >> 2] = i6;
+ HEAP32[i15 + 24 >> 2] = 0;
+ break;
+ }
+ }
+ } else {
+ i32 = HEAP32[56 >> 2] | 0;
+ if ((i32 | 0) == 0 | i17 >>> 0 < i32 >>> 0) {
+ HEAP32[56 >> 2] = i17;
+ }
+ HEAP32[488 >> 2] = i17;
+ HEAP32[492 >> 2] = i14;
+ HEAP32[500 >> 2] = 0;
+ HEAP32[76 >> 2] = HEAP32[128];
+ HEAP32[72 >> 2] = -1;
+ i2 = 0;
+ do {
+ i32 = i2 << 1;
+ i31 = 80 + (i32 << 2) | 0;
+ HEAP32[80 + (i32 + 3 << 2) >> 2] = i31;
+ HEAP32[80 + (i32 + 2 << 2) >> 2] = i31;
+ i2 = i2 + 1 | 0;
+ } while ((i2 | 0) != 32);
+ i2 = i17 + 8 | 0;
+ if ((i2 & 7 | 0) == 0) {
+ i2 = 0;
+ } else {
+ i2 = 0 - i2 & 7;
+ }
+ i32 = i14 + -40 - i2 | 0;
+ HEAP32[64 >> 2] = i17 + i2;
+ HEAP32[52 >> 2] = i32;
+ HEAP32[i17 + (i2 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i14 + -36) >> 2] = 40;
+ HEAP32[68 >> 2] = HEAP32[528 >> 2];
+ }
+ } while (0);
+ i2 = HEAP32[52 >> 2] | 0;
+ if (i2 >>> 0 > i12 >>> 0) {
+ i31 = i2 - i12 | 0;
+ HEAP32[52 >> 2] = i31;
+ i32 = HEAP32[64 >> 2] | 0;
+ HEAP32[64 >> 2] = i32 + i12;
+ HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
+ HEAP32[i32 + 4 >> 2] = i12 | 3;
+ i32 = i32 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ HEAP32[(___errno_location() | 0) >> 2] = 12;
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+}
+function _free(i7) {
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0;
+ i1 = STACKTOP;
+ if ((i7 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i15 = i7 + -8 | 0;
+ i16 = HEAP32[56 >> 2] | 0;
+ if (i15 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i13 = HEAP32[i7 + -4 >> 2] | 0;
+ i12 = i13 & 3;
+ if ((i12 | 0) == 1) {
+ _abort();
+ }
+ i8 = i13 & -8;
+ i6 = i7 + (i8 + -8) | 0;
+ do {
+ if ((i13 & 1 | 0) == 0) {
+ i19 = HEAP32[i15 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i15 = -8 - i19 | 0;
+ i13 = i7 + i15 | 0;
+ i12 = i19 + i8 | 0;
+ if (i13 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ if ((i13 | 0) == (HEAP32[60 >> 2] | 0)) {
+ i2 = i7 + (i8 + -4) | 0;
+ if ((HEAP32[i2 >> 2] & 3 | 0) != 3) {
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ HEAP32[48 >> 2] = i12;
+ HEAP32[i2 >> 2] = HEAP32[i2 >> 2] & -2;
+ HEAP32[i7 + (i15 + 4) >> 2] = i12 | 1;
+ HEAP32[i6 >> 2] = i12;
+ STACKTOP = i1;
+ return;
+ }
+ i18 = i19 >>> 3;
+ if (i19 >>> 0 < 256) {
+ i2 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
+ i11 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
+ i14 = 80 + (i18 << 1 << 2) | 0;
+ if ((i2 | 0) != (i14 | 0)) {
+ if (i2 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i2 + 12 >> 2] | 0) != (i13 | 0)) {
+ _abort();
+ }
+ }
+ if ((i11 | 0) == (i2 | 0)) {
+ HEAP32[10] = HEAP32[10] & ~(1 << i18);
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ if ((i11 | 0) != (i14 | 0)) {
+ if (i11 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i14 = i11 + 8 | 0;
+ if ((HEAP32[i14 >> 2] | 0) == (i13 | 0)) {
+ i17 = i14;
+ } else {
+ _abort();
+ }
+ } else {
+ i17 = i11 + 8 | 0;
+ }
+ HEAP32[i2 + 12 >> 2] = i11;
+ HEAP32[i17 >> 2] = i2;
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ i17 = HEAP32[i7 + (i15 + 24) >> 2] | 0;
+ i18 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
+ do {
+ if ((i18 | 0) == (i13 | 0)) {
+ i19 = i7 + (i15 + 20) | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ i19 = i7 + (i15 + 16) | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ i14 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i21 = i18 + 20 | 0;
+ i20 = HEAP32[i21 >> 2] | 0;
+ if ((i20 | 0) != 0) {
+ i18 = i20;
+ i19 = i21;
+ continue;
+ }
+ i20 = i18 + 16 | 0;
+ i21 = HEAP32[i20 >> 2] | 0;
+ if ((i21 | 0) == 0) {
+ break;
+ } else {
+ i18 = i21;
+ i19 = i20;
+ }
+ }
+ if (i19 >>> 0 < i16 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i19 >> 2] = 0;
+ i14 = i18;
+ break;
+ }
+ } else {
+ i19 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
+ if (i19 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i16 = i19 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != (i13 | 0)) {
+ _abort();
+ }
+ i20 = i18 + 8 | 0;
+ if ((HEAP32[i20 >> 2] | 0) == (i13 | 0)) {
+ HEAP32[i16 >> 2] = i18;
+ HEAP32[i20 >> 2] = i19;
+ i14 = i18;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i17 | 0) != 0) {
+ i18 = HEAP32[i7 + (i15 + 28) >> 2] | 0;
+ i16 = 344 + (i18 << 2) | 0;
+ if ((i13 | 0) == (HEAP32[i16 >> 2] | 0)) {
+ HEAP32[i16 >> 2] = i14;
+ if ((i14 | 0) == 0) {
+ HEAP32[44 >> 2] = HEAP32[44 >> 2] & ~(1 << i18);
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ } else {
+ if (i17 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i17 + 16 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i13 | 0)) {
+ HEAP32[i16 >> 2] = i14;
+ } else {
+ HEAP32[i17 + 20 >> 2] = i14;
+ }
+ if ((i14 | 0) == 0) {
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ }
+ if (i14 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i14 + 24 >> 2] = i17;
+ i16 = HEAP32[i7 + (i15 + 16) >> 2] | 0;
+ do {
+ if ((i16 | 0) != 0) {
+ if (i16 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i14 + 16 >> 2] = i16;
+ HEAP32[i16 + 24 >> 2] = i14;
+ break;
+ }
+ }
+ } while (0);
+ i15 = HEAP32[i7 + (i15 + 20) >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ if (i15 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i14 + 20 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i14;
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ } else {
+ i2 = i13;
+ i11 = i12;
+ }
+ } else {
+ i2 = i13;
+ i11 = i12;
+ }
+ } else {
+ i2 = i15;
+ i11 = i8;
+ }
+ } while (0);
+ if (!(i2 >>> 0 < i6 >>> 0)) {
+ _abort();
+ }
+ i12 = i7 + (i8 + -4) | 0;
+ i13 = HEAP32[i12 >> 2] | 0;
+ if ((i13 & 1 | 0) == 0) {
+ _abort();
+ }
+ if ((i13 & 2 | 0) == 0) {
+ if ((i6 | 0) == (HEAP32[64 >> 2] | 0)) {
+ i21 = (HEAP32[52 >> 2] | 0) + i11 | 0;
+ HEAP32[52 >> 2] = i21;
+ HEAP32[64 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i21 | 1;
+ if ((i2 | 0) != (HEAP32[60 >> 2] | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[60 >> 2] = 0;
+ HEAP32[48 >> 2] = 0;
+ STACKTOP = i1;
+ return;
+ }
+ if ((i6 | 0) == (HEAP32[60 >> 2] | 0)) {
+ i21 = (HEAP32[48 >> 2] | 0) + i11 | 0;
+ HEAP32[48 >> 2] = i21;
+ HEAP32[60 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i21 | 1;
+ HEAP32[i2 + i21 >> 2] = i21;
+ STACKTOP = i1;
+ return;
+ }
+ i11 = (i13 & -8) + i11 | 0;
+ i12 = i13 >>> 3;
+ do {
+ if (!(i13 >>> 0 < 256)) {
+ i10 = HEAP32[i7 + (i8 + 16) >> 2] | 0;
+ i15 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
+ do {
+ if ((i15 | 0) == (i6 | 0)) {
+ i13 = i7 + (i8 + 12) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i13 = i7 + (i8 + 8) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i9 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i14 = i12 + 20 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ i12 = i15;
+ i13 = i14;
+ continue;
+ }
+ i14 = i12 + 16 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) == 0) {
+ break;
+ } else {
+ i12 = i15;
+ i13 = i14;
+ }
+ }
+ if (i13 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i13 >> 2] = 0;
+ i9 = i12;
+ break;
+ }
+ } else {
+ i13 = HEAP32[i7 + i8 >> 2] | 0;
+ if (i13 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i14 = i13 + 12 | 0;
+ if ((HEAP32[i14 >> 2] | 0) != (i6 | 0)) {
+ _abort();
+ }
+ i12 = i15 + 8 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i14 >> 2] = i15;
+ HEAP32[i12 >> 2] = i13;
+ i9 = i15;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i10 | 0) != 0) {
+ i12 = HEAP32[i7 + (i8 + 20) >> 2] | 0;
+ i13 = 344 + (i12 << 2) | 0;
+ if ((i6 | 0) == (HEAP32[i13 >> 2] | 0)) {
+ HEAP32[i13 >> 2] = i9;
+ if ((i9 | 0) == 0) {
+ HEAP32[44 >> 2] = HEAP32[44 >> 2] & ~(1 << i12);
+ break;
+ }
+ } else {
+ if (i10 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i12 = i10 + 16 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i12 >> 2] = i9;
+ } else {
+ HEAP32[i10 + 20 >> 2] = i9;
+ }
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ }
+ if (i9 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i9 + 24 >> 2] = i10;
+ i6 = HEAP32[i7 + (i8 + 8) >> 2] | 0;
+ do {
+ if ((i6 | 0) != 0) {
+ if (i6 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 16 >> 2] = i6;
+ HEAP32[i6 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ } while (0);
+ i6 = HEAP32[i7 + (i8 + 12) >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ if (i6 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 20 >> 2] = i6;
+ HEAP32[i6 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ }
+ } else {
+ i9 = HEAP32[i7 + i8 >> 2] | 0;
+ i7 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
+ i8 = 80 + (i12 << 1 << 2) | 0;
+ if ((i9 | 0) != (i8 | 0)) {
+ if (i9 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i9 + 12 >> 2] | 0) != (i6 | 0)) {
+ _abort();
+ }
+ }
+ if ((i7 | 0) == (i9 | 0)) {
+ HEAP32[10] = HEAP32[10] & ~(1 << i12);
+ break;
+ }
+ if ((i7 | 0) != (i8 | 0)) {
+ if (i7 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i7 + 8 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i6 | 0)) {
+ i10 = i8;
+ } else {
+ _abort();
+ }
+ } else {
+ i10 = i7 + 8 | 0;
+ }
+ HEAP32[i9 + 12 >> 2] = i7;
+ HEAP32[i10 >> 2] = i9;
+ }
+ } while (0);
+ HEAP32[i2 + 4 >> 2] = i11 | 1;
+ HEAP32[i2 + i11 >> 2] = i11;
+ if ((i2 | 0) == (HEAP32[60 >> 2] | 0)) {
+ HEAP32[48 >> 2] = i11;
+ STACKTOP = i1;
+ return;
+ }
+ } else {
+ HEAP32[i12 >> 2] = i13 & -2;
+ HEAP32[i2 + 4 >> 2] = i11 | 1;
+ HEAP32[i2 + i11 >> 2] = i11;
+ }
+ i6 = i11 >>> 3;
+ if (i11 >>> 0 < 256) {
+ i7 = i6 << 1;
+ i3 = 80 + (i7 << 2) | 0;
+ i8 = HEAP32[10] | 0;
+ i6 = 1 << i6;
+ if ((i8 & i6 | 0) != 0) {
+ i6 = 80 + (i7 + 2 << 2) | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ if (i7 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i4 = i6;
+ i5 = i7;
+ }
+ } else {
+ HEAP32[10] = i8 | i6;
+ i4 = 80 + (i7 + 2 << 2) | 0;
+ i5 = i3;
+ }
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i5 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i5;
+ HEAP32[i2 + 12 >> 2] = i3;
+ STACKTOP = i1;
+ return;
+ }
+ i4 = i11 >>> 8;
+ if ((i4 | 0) != 0) {
+ if (i11 >>> 0 > 16777215) {
+ i4 = 31;
+ } else {
+ i20 = (i4 + 1048320 | 0) >>> 16 & 8;
+ i21 = i4 << i20;
+ i19 = (i21 + 520192 | 0) >>> 16 & 4;
+ i21 = i21 << i19;
+ i4 = (i21 + 245760 | 0) >>> 16 & 2;
+ i4 = 14 - (i19 | i20 | i4) + (i21 << i4 >>> 15) | 0;
+ i4 = i11 >>> (i4 + 7 | 0) & 1 | i4 << 1;
+ }
+ } else {
+ i4 = 0;
+ }
+ i5 = 344 + (i4 << 2) | 0;
+ HEAP32[i2 + 28 >> 2] = i4;
+ HEAP32[i2 + 20 >> 2] = 0;
+ HEAP32[i2 + 16 >> 2] = 0;
+ i7 = HEAP32[44 >> 2] | 0;
+ i6 = 1 << i4;
+ L199 : do {
+ if ((i7 & i6 | 0) != 0) {
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((i4 | 0) == 31) {
+ i4 = 0;
+ } else {
+ i4 = 25 - (i4 >>> 1) | 0;
+ }
+ L205 : do {
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) != (i11 | 0)) {
+ i4 = i11 << i4;
+ i7 = i5;
+ while (1) {
+ i6 = i7 + (i4 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i11 | 0)) {
+ i3 = i5;
+ break L205;
+ } else {
+ i4 = i4 << 1;
+ i7 = i5;
+ }
+ }
+ if (i6 >>> 0 < (HEAP32[56 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i7;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ break L199;
+ }
+ } else {
+ i3 = i5;
+ }
+ } while (0);
+ i5 = i3 + 8 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i6 = HEAP32[56 >> 2] | 0;
+ if (i3 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ if (i4 >>> 0 < i6 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i4 + 12 >> 2] = i2;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i4;
+ HEAP32[i2 + 12 >> 2] = i3;
+ HEAP32[i2 + 24 >> 2] = 0;
+ break;
+ }
+ } else {
+ HEAP32[44 >> 2] = i7 | i6;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i5;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ }
+ } while (0);
+ i21 = (HEAP32[72 >> 2] | 0) + -1 | 0;
+ HEAP32[72 >> 2] = i21;
+ if ((i21 | 0) == 0) {
+ i2 = 496 | 0;
+ } else {
+ STACKTOP = i1;
+ return;
+ }
+ while (1) {
+ i2 = HEAP32[i2 >> 2] | 0;
+ if ((i2 | 0) == 0) {
+ break;
+ } else {
+ i2 = i2 + 8 | 0;
+ }
+ }
+ HEAP32[72 >> 2] = -1;
+ STACKTOP = i1;
+ return;
+}
+function _main(i3, i5) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i6 = 0, i7 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i1;
+ L1 : do {
+ if ((i3 | 0) > 1) {
+ i3 = HEAP8[HEAP32[i5 + 4 >> 2] | 0] | 0;
+ switch (i3 | 0) {
+ case 50:
+ {
+ i3 = 400;
+ break L1;
+ }
+ case 51:
+ {
+ i4 = 4;
+ break L1;
+ }
+ case 52:
+ {
+ i3 = 4e3;
+ break L1;
+ }
+ case 53:
+ {
+ i3 = 8e3;
+ break L1;
+ }
+ case 49:
+ {
+ i3 = 55;
+ break L1;
+ }
+ case 48:
+ {
+ i7 = 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ default:
+ {
+ HEAP32[i2 >> 2] = i3 + -48;
+ _printf(8, i2 | 0) | 0;
+ i7 = -1;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ }
+ } else {
+ i4 = 4;
+ }
+ } while (0);
+ if ((i4 | 0) == 4) {
+ i3 = 800;
+ }
+ i5 = _malloc(1048576) | 0;
+ i6 = 0;
+ i4 = 0;
+ do {
+ i7 = 0;
+ while (1) {
+ HEAP8[i5 + i7 | 0] = i7 + i6;
+ i7 = i7 + 1 | 0;
+ if ((i7 | 0) == 1048576) {
+ i7 = 0;
+ break;
+ }
+ }
+ do {
+ i6 = (HEAP8[i5 + i7 | 0] & 1) + i6 | 0;
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) != 1048576);
+ i6 = (i6 | 0) % 1e3 | 0;
+ i4 = i4 + 1 | 0;
+ } while ((i4 | 0) < (i3 | 0));
+ HEAP32[i2 >> 2] = i6;
+ _printf(24, i2 | 0) | 0;
+ i7 = 0;
+ STACKTOP = i1;
+ return i7 | 0;
+}
+function _memcpy(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ if ((i1 | 0) >= 4096) return _emscripten_memcpy_big(i3 | 0, i2 | 0, i1 | 0) | 0;
+ i4 = i3 | 0;
+ if ((i3 & 3) == (i2 & 3)) {
+ while (i3 & 3) {
+ if ((i1 | 0) == 0) return i4 | 0;
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ while ((i1 | 0) >= 4) {
+ HEAP32[i3 >> 2] = HEAP32[i2 >> 2];
+ i3 = i3 + 4 | 0;
+ i2 = i2 + 4 | 0;
+ i1 = i1 - 4 | 0;
+ }
+ }
+ while ((i1 | 0) > 0) {
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ return i4 | 0;
+}
+function _memset(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = i1 + i3 | 0;
+ if ((i3 | 0) >= 20) {
+ i4 = i4 & 255;
+ i7 = i1 & 3;
+ i6 = i4 | i4 << 8 | i4 << 16 | i4 << 24;
+ i5 = i2 & ~3;
+ if (i7) {
+ i7 = i1 + 4 - i7 | 0;
+ while ((i1 | 0) < (i7 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ }
+ while ((i1 | 0) < (i5 | 0)) {
+ HEAP32[i1 >> 2] = i6;
+ i1 = i1 + 4 | 0;
+ }
+ }
+ while ((i1 | 0) < (i2 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ return i1 - i3 | 0;
+}
+function copyTempDouble(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+ HEAP8[tempDoublePtr + 4 | 0] = HEAP8[i1 + 4 | 0];
+ HEAP8[tempDoublePtr + 5 | 0] = HEAP8[i1 + 5 | 0];
+ HEAP8[tempDoublePtr + 6 | 0] = HEAP8[i1 + 6 | 0];
+ HEAP8[tempDoublePtr + 7 | 0] = HEAP8[i1 + 7 | 0];
+}
+function copyTempFloat(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+}
+function runPostSets() {}
+function _strlen(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = i1;
+ while (HEAP8[i2] | 0) {
+ i2 = i2 + 1 | 0;
+ }
+ return i2 - i1 | 0;
+}
+function stackAlloc(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + i1 | 0;
+ STACKTOP = STACKTOP + 7 & -8;
+ return i2 | 0;
+}
+function setThrew(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ if ((__THREW__ | 0) == 0) {
+ __THREW__ = i1;
+ threwValue = i2;
+ }
+}
+function stackRestore(i1) {
+ i1 = i1 | 0;
+ STACKTOP = i1;
+}
+function setTempRet9(i1) {
+ i1 = i1 | 0;
+ tempRet9 = i1;
+}
+function setTempRet8(i1) {
+ i1 = i1 | 0;
+ tempRet8 = i1;
+}
+function setTempRet7(i1) {
+ i1 = i1 | 0;
+ tempRet7 = i1;
+}
+function setTempRet6(i1) {
+ i1 = i1 | 0;
+ tempRet6 = i1;
+}
+function setTempRet5(i1) {
+ i1 = i1 | 0;
+ tempRet5 = i1;
+}
+function setTempRet4(i1) {
+ i1 = i1 | 0;
+ tempRet4 = i1;
+}
+function setTempRet3(i1) {
+ i1 = i1 | 0;
+ tempRet3 = i1;
+}
+function setTempRet2(i1) {
+ i1 = i1 | 0;
+ tempRet2 = i1;
+}
+function setTempRet1(i1) {
+ i1 = i1 | 0;
+ tempRet1 = i1;
+}
+function setTempRet0(i1) {
+ i1 = i1 | 0;
+ tempRet0 = i1;
+}
+function stackSave() {
+ return STACKTOP | 0;
+}
+
+// EMSCRIPTEN_END_FUNCS
+
+
+ return { _strlen: _strlen, _free: _free, _main: _main, _memset: _memset, _malloc: _malloc, _memcpy: _memcpy, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, setThrew: setThrew, setTempRet0: setTempRet0, setTempRet1: setTempRet1, setTempRet2: setTempRet2, setTempRet3: setTempRet3, setTempRet4: setTempRet4, setTempRet5: setTempRet5, setTempRet6: setTempRet6, setTempRet7: setTempRet7, setTempRet8: setTempRet8, setTempRet9: setTempRet9 };
+})
+// EMSCRIPTEN_END_ASM
+({ "Math": Math, "Int8Array": Int8Array, "Int16Array": Int16Array, "Int32Array": Int32Array, "Uint8Array": Uint8Array, "Uint16Array": Uint16Array, "Uint32Array": Uint32Array, "Float32Array": Float32Array, "Float64Array": Float64Array }, { "abort": abort, "assert": assert, "asmPrintInt": asmPrintInt, "asmPrintFloat": asmPrintFloat, "min": Math_min, "_fflush": _fflush, "_emscripten_memcpy_big": _emscripten_memcpy_big, "_printf": _printf, "_send": _send, "_pwrite": _pwrite, "_abort": _abort, "___setErrNo": ___setErrNo, "_fwrite": _fwrite, "_sbrk": _sbrk, "_time": _time, "_mkport": _mkport, "__reallyNegative": __reallyNegative, "__formatString": __formatString, "_fileno": _fileno, "_write": _write, "_fprintf": _fprintf, "_sysconf": _sysconf, "___errno_location": ___errno_location, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX, "tempDoublePtr": tempDoublePtr, "ABORT": ABORT, "NaN": NaN, "Infinity": Infinity }, buffer);
+var _strlen = Module["_strlen"] = asm["_strlen"];
+var _free = Module["_free"] = asm["_free"];
+var _main = Module["_main"] = asm["_main"];
+var _memset = Module["_memset"] = asm["_memset"];
+var _malloc = Module["_malloc"] = asm["_malloc"];
+var _memcpy = Module["_memcpy"] = asm["_memcpy"];
+var runPostSets = Module["runPostSets"] = asm["runPostSets"];
+
+Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
+Runtime.stackSave = function() { return asm['stackSave']() };
+Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
+
+
+// Warning: printing of i64 values may be slightly rounded! No deep i64 math used, so precise i64 code not included
+var i64Math = null;
+
+// === Auto-generated postamble setup entry stuff ===
+
+if (memoryInitializer) {
+ if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
+ var data = Module['readBinary'](memoryInitializer);
+ HEAPU8.set(data, STATIC_BASE);
+ } else {
+ addRunDependency('memory initializer');
+ Browser.asyncLoad(memoryInitializer, function(data) {
+ HEAPU8.set(data, STATIC_BASE);
+ removeRunDependency('memory initializer');
+ }, function(data) {
+ throw 'could not load memory initializer ' + memoryInitializer;
+ });
+ }
+}
+
+function ExitStatus(status) {
+ this.name = "ExitStatus";
+ this.message = "Program terminated with exit(" + status + ")";
+ this.status = status;
+};
+ExitStatus.prototype = new Error();
+ExitStatus.prototype.constructor = ExitStatus;
+
+var initialStackTop;
+var preloadStartTime = null;
+var calledMain = false;
+
+dependenciesFulfilled = function runCaller() {
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
+ if (!Module['calledRun'] && shouldRunNow) run([].concat(Module["arguments"]));
+ if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
+}
+
+Module['callMain'] = Module.callMain = function callMain(args) {
+ assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');
+ assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
+
+ args = args || [];
+
+ ensureInitRuntime();
+
+ var argc = args.length+1;
+ function pad() {
+ for (var i = 0; i < 4-1; i++) {
+ argv.push(0);
+ }
+ }
+ var argv = [allocate(intArrayFromString("/bin/this.program"), 'i8', ALLOC_NORMAL) ];
+ pad();
+ for (var i = 0; i < argc-1; i = i + 1) {
+ argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL));
+ pad();
+ }
+ argv.push(0);
+ argv = allocate(argv, 'i32', ALLOC_NORMAL);
+
+ initialStackTop = STACKTOP;
+
+ try {
+
+ var ret = Module['_main'](argc, argv, 0);
+
+
+ // if we're not running an evented main loop, it's time to exit
+ if (!Module['noExitRuntime']) {
+ exit(ret);
+ }
+ }
+ catch(e) {
+ if (e instanceof ExitStatus) {
+ // exit() throws this once it's done to make sure execution
+ // has been stopped completely
+ return;
+ } else if (e == 'SimulateInfiniteLoop') {
+ // running an evented main loop, don't immediately exit
+ Module['noExitRuntime'] = true;
+ return;
+ } else {
+ if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
+ throw e;
+ }
+ } finally {
+ calledMain = true;
+ }
+}
+
+
+
+
+function run(args) {
+ args = args || Module['arguments'];
+
+ if (preloadStartTime === null) preloadStartTime = Date.now();
+
+ if (runDependencies > 0) {
+ Module.printErr('run() called, but dependencies remain, so not running');
+ return;
+ }
+
+ preRun();
+
+ if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
+ if (Module['calledRun']) return; // run may have just been called through dependencies being fulfilled just in this very frame
+
+ function doRun() {
+ if (Module['calledRun']) return; // run may have just been called while the async setStatus time below was happening
+ Module['calledRun'] = true;
+
+ ensureInitRuntime();
+
+ preMain();
+
+ if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) {
+ Module.printErr('pre-main prep time: ' + (Date.now() - preloadStartTime) + ' ms');
+ }
+
+ if (Module['_main'] && shouldRunNow) {
+ Module['callMain'](args);
+ }
+
+ postRun();
+ }
+
+ if (Module['setStatus']) {
+ Module['setStatus']('Running...');
+ setTimeout(function() {
+ setTimeout(function() {
+ Module['setStatus']('');
+ }, 1);
+ if (!ABORT) doRun();
+ }, 1);
+ } else {
+ doRun();
+ }
+}
+Module['run'] = Module.run = run;
+
+function exit(status) {
+ ABORT = true;
+ EXITSTATUS = status;
+ STACKTOP = initialStackTop;
+
+ // exit the runtime
+ exitRuntime();
+
+ // TODO We should handle this differently based on environment.
+ // In the browser, the best we can do is throw an exception
+ // to halt execution, but in node we could process.exit and
+ // I'd imagine SM shell would have something equivalent.
+ // This would let us set a proper exit status (which
+ // would be great for checking test exit statuses).
+ // https://github.com/kripken/emscripten/issues/1371
+
+ // throw an exception to halt the current execution
+ throw new ExitStatus(status);
+}
+Module['exit'] = Module.exit = exit;
+
+function abort(text) {
+ if (text) {
+ Module.print(text);
+ Module.printErr(text);
+ }
+
+ ABORT = true;
+ EXITSTATUS = 1;
+
+ var extra = '\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.';
+
+ throw 'abort() at ' + stackTrace() + extra;
+}
+Module['abort'] = Module.abort = abort;
+
+// {{PRE_RUN_ADDITIONS}}
+
+if (Module['preInit']) {
+ if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
+ while (Module['preInit'].length > 0) {
+ Module['preInit'].pop()();
+ }
+}
+
+// shouldRunNow refers to calling main(), not run().
+var shouldRunNow = true;
+if (Module['noInitialRun']) {
+ shouldRunNow = false;
+}
+
+
+run([].concat(Module["arguments"]));
diff --git a/test/mjsunit/asm/embenchen/primes.js b/test/mjsunit/asm/embenchen/primes.js
new file mode 100644
index 000000000..9c9c0470b
--- /dev/null
+++ b/test/mjsunit/asm/embenchen/primes.js
@@ -0,0 +1,5988 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var EXPECTED_OUTPUT = 'lastprime: 387677.\n';
+var Module = {
+ arguments: [1],
+ print: function(x) {Module.printBuffer += x + '\n';},
+ preRun: [function() {Module.printBuffer = ''}],
+ postRun: [function() {
+ assertEquals(EXPECTED_OUTPUT, Module.printBuffer);
+ }],
+};
+// The Module object: Our interface to the outside world. We import
+// and export values on it, and do the work to get that through
+// closure compiler if necessary. There are various ways Module can be used:
+// 1. Not defined. We create it here
+// 2. A function parameter, function(Module) { ..generated code.. }
+// 3. pre-run appended it, var Module = {}; ..generated code..
+// 4. External script tag defines var Module.
+// We need to do an eval in order to handle the closure compiler
+// case, where this code here is minified but Module was defined
+// elsewhere (e.g. case 4 above). We also need to check if Module
+// already exists (e.g. case 3 above).
+// Note that if you want to run closure, and also to use Module
+// after the generated code, you will need to define var Module = {};
+// before the code. Then that object will be used in the code, and you
+// can continue to use Module afterwards as well.
+var Module;
+if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {};
+
+// Sometimes an existing Module object exists with properties
+// meant to overwrite the default module functionality. Here
+// we collect those properties and reapply _after_ we configure
+// the current environment's defaults to avoid having to be so
+// defensive during initialization.
+var moduleOverrides = {};
+for (var key in Module) {
+ if (Module.hasOwnProperty(key)) {
+ moduleOverrides[key] = Module[key];
+ }
+}
+
+// The environment setup code below is customized to use Module.
+// *** Environment setup code ***
+var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
+var ENVIRONMENT_IS_WEB = typeof window === 'object';
+var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
+var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+
+if (ENVIRONMENT_IS_NODE) {
+ // Expose functionality in the same simple way that the shells work
+ // Note that we pollute the global namespace here, otherwise we break in node
+ if (!Module['print']) Module['print'] = function print(x) {
+ process['stdout'].write(x + '\n');
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ process['stderr'].write(x + '\n');
+ };
+
+ var nodeFS = require('fs');
+ var nodePath = require('path');
+
+ Module['read'] = function read(filename, binary) {
+ filename = nodePath['normalize'](filename);
+ var ret = nodeFS['readFileSync'](filename);
+ // The path is absolute if the normalized version is the same as the resolved.
+ if (!ret && filename != nodePath['resolve'](filename)) {
+ filename = path.join(__dirname, '..', 'src', filename);
+ ret = nodeFS['readFileSync'](filename);
+ }
+ if (ret && !binary) ret = ret.toString();
+ return ret;
+ };
+
+ Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
+
+ Module['load'] = function load(f) {
+ globalEval(read(f));
+ };
+
+ Module['arguments'] = process['argv'].slice(2);
+
+ module['exports'] = Module;
+}
+else if (ENVIRONMENT_IS_SHELL) {
+ if (!Module['print']) Module['print'] = print;
+ if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
+
+ if (typeof read != 'undefined') {
+ Module['read'] = read;
+ } else {
+ Module['read'] = function read() { throw 'no read() available (jsc?)' };
+ }
+
+ Module['readBinary'] = function readBinary(f) {
+ return read(f, 'binary');
+ };
+
+ if (typeof scriptArgs != 'undefined') {
+ Module['arguments'] = scriptArgs;
+ } else if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ this['Module'] = Module;
+
+ eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
+}
+else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
+ Module['read'] = function read(url) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ xhr.send(null);
+ return xhr.responseText;
+ };
+
+ if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ if (typeof console !== 'undefined') {
+ if (!Module['print']) Module['print'] = function print(x) {
+ console.log(x);
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ console.log(x);
+ };
+ } else {
+ // Probably a worker, and without console.log. We can do very little here...
+ var TRY_USE_DUMP = false;
+ if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
+ dump(x);
+ }) : (function(x) {
+ // self.postMessage(x); // enable this if you want stdout to be sent as messages
+ }));
+ }
+
+ if (ENVIRONMENT_IS_WEB) {
+ window['Module'] = Module;
+ } else {
+ Module['load'] = importScripts;
+ }
+}
+else {
+ // Unreachable because SHELL is dependant on the others
+ throw 'Unknown runtime environment. Where are we?';
+}
+
+function globalEval(x) {
+ eval.call(null, x);
+}
+if (!Module['load'] == 'undefined' && Module['read']) {
+ Module['load'] = function load(f) {
+ globalEval(Module['read'](f));
+ };
+}
+if (!Module['print']) {
+ Module['print'] = function(){};
+}
+if (!Module['printErr']) {
+ Module['printErr'] = Module['print'];
+}
+if (!Module['arguments']) {
+ Module['arguments'] = [];
+}
+// *** Environment setup code ***
+
+// Closure helpers
+Module.print = Module['print'];
+Module.printErr = Module['printErr'];
+
+// Callbacks
+Module['preRun'] = [];
+Module['postRun'] = [];
+
+// Merge back in the overrides
+for (var key in moduleOverrides) {
+ if (moduleOverrides.hasOwnProperty(key)) {
+ Module[key] = moduleOverrides[key];
+ }
+}
+
+
+
+// === Auto-generated preamble library stuff ===
+
+//========================================
+// Runtime code shared with compiler
+//========================================
+
+var Runtime = {
+ stackSave: function () {
+ return STACKTOP;
+ },
+ stackRestore: function (stackTop) {
+ STACKTOP = stackTop;
+ },
+ forceAlign: function (target, quantum) {
+ quantum = quantum || 4;
+ if (quantum == 1) return target;
+ if (isNumber(target) && isNumber(quantum)) {
+ return Math.ceil(target/quantum)*quantum;
+ } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
+ return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')';
+ }
+ return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
+ },
+ isNumberType: function (type) {
+ return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
+ },
+ isPointerType: function isPointerType(type) {
+ return type[type.length-1] == '*';
+},
+ isStructType: function isStructType(type) {
+ if (isPointerType(type)) return false;
+ if (isArrayType(type)) return true;
+ if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
+ // See comment in isStructPointerType()
+ return type[0] == '%';
+},
+ INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
+ FLOAT_TYPES: {"float":0,"double":0},
+ or64: function (x, y) {
+ var l = (x | 0) | (y | 0);
+ var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ and64: function (x, y) {
+ var l = (x | 0) & (y | 0);
+ var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ xor64: function (x, y) {
+ var l = (x | 0) ^ (y | 0);
+ var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ getNativeTypeSize: function (type) {
+ switch (type) {
+ case 'i1': case 'i8': return 1;
+ case 'i16': return 2;
+ case 'i32': return 4;
+ case 'i64': return 8;
+ case 'float': return 4;
+ case 'double': return 8;
+ default: {
+ if (type[type.length-1] === '*') {
+ return Runtime.QUANTUM_SIZE; // A pointer
+ } else if (type[0] === 'i') {
+ var bits = parseInt(type.substr(1));
+ assert(bits % 8 === 0);
+ return bits/8;
+ } else {
+ return 0;
+ }
+ }
+ }
+ },
+ getNativeFieldSize: function (type) {
+ return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
+ },
+ dedup: function dedup(items, ident) {
+ var seen = {};
+ if (ident) {
+ return items.filter(function(item) {
+ if (seen[item[ident]]) return false;
+ seen[item[ident]] = true;
+ return true;
+ });
+ } else {
+ return items.filter(function(item) {
+ if (seen[item]) return false;
+ seen[item] = true;
+ return true;
+ });
+ }
+},
+ set: function set() {
+ var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
+ var ret = {};
+ for (var i = 0; i < args.length; i++) {
+ ret[args[i]] = 0;
+ }
+ return ret;
+},
+ STACK_ALIGN: 8,
+ getAlignSize: function (type, size, vararg) {
+ // we align i64s and doubles on 64-bit boundaries, unlike x86
+ if (!vararg && (type == 'i64' || type == 'double')) return 8;
+ if (!type) return Math.min(size, 8); // align structures internally to 64 bits
+ return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
+ },
+ calculateStructAlignment: function calculateStructAlignment(type) {
+ type.flatSize = 0;
+ type.alignSize = 0;
+ var diffs = [];
+ var prev = -1;
+ var index = 0;
+ type.flatIndexes = type.fields.map(function(field) {
+ index++;
+ var size, alignSize;
+ if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
+ size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
+ alignSize = Runtime.getAlignSize(field, size);
+ } else if (Runtime.isStructType(field)) {
+ if (field[1] === '0') {
+ // this is [0 x something]. When inside another structure like here, it must be at the end,
+ // and it adds no size
+ // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');
+ size = 0;
+ if (Types.types[field]) {
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ } else {
+ alignSize = type.alignSize || QUANTUM_SIZE;
+ }
+ } else {
+ size = Types.types[field].flatSize;
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ }
+ } else if (field[0] == 'b') {
+ // bN, large number field, like a [N x i8]
+ size = field.substr(1)|0;
+ alignSize = 1;
+ } else if (field[0] === '<') {
+ // vector type
+ size = alignSize = Types.types[field].flatSize; // fully aligned
+ } else if (field[0] === 'i') {
+ // illegal integer field, that could not be legalized because it is an internal structure field
+ // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
+ size = alignSize = parseInt(field.substr(1))/8;
+ assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
+ } else {
+ assert(false, 'invalid type for calculateStructAlignment');
+ }
+ if (type.packed) alignSize = 1;
+ type.alignSize = Math.max(type.alignSize, alignSize);
+ var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
+ type.flatSize = curr + size;
+ if (prev >= 0) {
+ diffs.push(curr-prev);
+ }
+ prev = curr;
+ return curr;
+ });
+ if (type.name_ && type.name_[0] === '[') {
+ // arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
+ // allocating a potentially huge array for [999999 x i8] etc.
+ type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
+ }
+ type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
+ if (diffs.length == 0) {
+ type.flatFactor = type.flatSize;
+ } else if (Runtime.dedup(diffs).length == 1) {
+ type.flatFactor = diffs[0];
+ }
+ type.needsFlattening = (type.flatFactor != 1);
+ return type.flatIndexes;
+ },
+ generateStructInfo: function (struct, typeName, offset) {
+ var type, alignment;
+ if (typeName) {
+ offset = offset || 0;
+ type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
+ if (!type) return null;
+ if (type.fields.length != struct.length) {
+ printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');
+ return null;
+ }
+ alignment = type.flatIndexes;
+ } else {
+ var type = { fields: struct.map(function(item) { return item[0] }) };
+ alignment = Runtime.calculateStructAlignment(type);
+ }
+ var ret = {
+ __size__: type.flatSize
+ };
+ if (typeName) {
+ struct.forEach(function(item, i) {
+ if (typeof item === 'string') {
+ ret[item] = alignment[i] + offset;
+ } else {
+ // embedded struct
+ var key;
+ for (var k in item) key = k;
+ ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
+ }
+ });
+ } else {
+ struct.forEach(function(item, i) {
+ ret[item[1]] = alignment[i];
+ });
+ }
+ return ret;
+ },
+ dynCall: function (sig, ptr, args) {
+ if (args && args.length) {
+ if (!args.splice) args = Array.prototype.slice.call(args);
+ args.splice(0, 0, ptr);
+ return Module['dynCall_' + sig].apply(null, args);
+ } else {
+ return Module['dynCall_' + sig].call(null, ptr);
+ }
+ },
+ functionPointers: [],
+ addFunction: function (func) {
+ for (var i = 0; i < Runtime.functionPointers.length; i++) {
+ if (!Runtime.functionPointers[i]) {
+ Runtime.functionPointers[i] = func;
+ return 2*(1 + i);
+ }
+ }
+ throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
+ },
+ removeFunction: function (index) {
+ Runtime.functionPointers[(index-2)/2] = null;
+ },
+ getAsmConst: function (code, numArgs) {
+ // code is a constant string on the heap, so we can cache these
+ if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
+ var func = Runtime.asmConstCache[code];
+ if (func) return func;
+ var args = [];
+ for (var i = 0; i < numArgs; i++) {
+ args.push(String.fromCharCode(36) + i); // $0, $1 etc
+ }
+ var source = Pointer_stringify(code);
+ if (source[0] === '"') {
+ // tolerate EM_ASM("..code..") even though EM_ASM(..code..) is correct
+ if (source.indexOf('"', 1) === source.length-1) {
+ source = source.substr(1, source.length-2);
+ } else {
+ // something invalid happened, e.g. EM_ASM("..code($0)..", input)
+ abort('invalid EM_ASM input |' + source + '|. Please use EM_ASM(..code..) (no quotes) or EM_ASM({ ..code($0).. }, input) (to input values)');
+ }
+ }
+ try {
+ var evalled = eval('(function(' + args.join(',') + '){ ' + source + ' })'); // new Function does not allow upvars in node
+ } catch(e) {
+ Module.printErr('error in executing inline EM_ASM code: ' + e + ' on: \n\n' + source + '\n\nwith args |' + args + '| (make sure to use the right one out of EM_ASM, EM_ASM_ARGS, etc.)');
+ throw e;
+ }
+ return Runtime.asmConstCache[code] = evalled;
+ },
+ warnOnce: function (text) {
+ if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
+ if (!Runtime.warnOnce.shown[text]) {
+ Runtime.warnOnce.shown[text] = 1;
+ Module.printErr(text);
+ }
+ },
+ funcWrappers: {},
+ getFuncWrapper: function (func, sig) {
+ assert(sig);
+ if (!Runtime.funcWrappers[func]) {
+ Runtime.funcWrappers[func] = function dynCall_wrapper() {
+ return Runtime.dynCall(sig, func, arguments);
+ };
+ }
+ return Runtime.funcWrappers[func];
+ },
+ UTF8Processor: function () {
+ var buffer = [];
+ var needed = 0;
+ this.processCChar = function (code) {
+ code = code & 0xFF;
+
+ if (buffer.length == 0) {
+ if ((code & 0x80) == 0x00) { // 0xxxxxxx
+ return String.fromCharCode(code);
+ }
+ buffer.push(code);
+ if ((code & 0xE0) == 0xC0) { // 110xxxxx
+ needed = 1;
+ } else if ((code & 0xF0) == 0xE0) { // 1110xxxx
+ needed = 2;
+ } else { // 11110xxx
+ needed = 3;
+ }
+ return '';
+ }
+
+ if (needed) {
+ buffer.push(code);
+ needed--;
+ if (needed > 0) return '';
+ }
+
+ var c1 = buffer[0];
+ var c2 = buffer[1];
+ var c3 = buffer[2];
+ var c4 = buffer[3];
+ var ret;
+ if (buffer.length == 2) {
+ ret = String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ } else if (buffer.length == 3) {
+ ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ } else {
+ // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |
+ ((c3 & 0x3F) << 6) | (c4 & 0x3F);
+ ret = String.fromCharCode(
+ Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,
+ (codePoint - 0x10000) % 0x400 + 0xDC00);
+ }
+ buffer.length = 0;
+ return ret;
+ }
+ this.processJSString = function processJSString(string) {
+ /* TODO: use TextEncoder when present,
+ var encoder = new TextEncoder();
+ encoder['encoding'] = "utf-8";
+ var utf8Array = encoder['encode'](aMsg.data);
+ */
+ string = unescape(encodeURIComponent(string));
+ var ret = [];
+ for (var i = 0; i < string.length; i++) {
+ ret.push(string.charCodeAt(i));
+ }
+ return ret;
+ }
+ },
+ getCompilerSetting: function (name) {
+ throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
+ },
+ stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+7)&-8); return ret; },
+ staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = (((STATICTOP)+7)&-8); return ret; },
+ dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = (((DYNAMICTOP)+7)&-8); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
+ alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },
+ makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*(+4294967296))) : ((+((low>>>0)))+((+((high|0)))*(+4294967296)))); return ret; },
+ GLOBAL_BASE: 8,
+ QUANTUM_SIZE: 4,
+ __dummy__: 0
+}
+
+
+Module['Runtime'] = Runtime;
+
+
+
+
+
+
+
+
+
+//========================================
+// Runtime essentials
+//========================================
+
+var __THREW__ = 0; // Used in checking for thrown exceptions.
+
+var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()
+var EXITSTATUS = 0;
+
+var undef = 0;
+// tempInt is used for 32-bit signed values or smaller. tempBigInt is used
+// for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
+var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
+var tempI64, tempI64b;
+var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
+
+function assert(condition, text) {
+ if (!condition) {
+ abort('Assertion failed: ' + text);
+ }
+}
+
+var globalScope = this;
+
+// C calling interface. A convenient way to call C functions (in C files, or
+// defined with extern "C").
+//
+// Note: LLVM optimizations can inline and remove functions, after which you will not be
+// able to call them. Closure can also do so. To avoid that, add your function to
+// the exports using something like
+//
+// -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]'
+//
+// @param ident The name of the C function (note that C++ functions will be name-mangled - use extern "C")
+// @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and
+// 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).
+// @param argTypes An array of the types of arguments for the function (if there are no arguments, this can be ommitted). Types are as in returnType,
+// except that 'array' is not possible (there is no way for us to know the length of the array)
+// @param args An array of the arguments to the function, as native JS values (as in returnType)
+// Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).
+// @return The return value, as a native JS value (as in returnType)
+function ccall(ident, returnType, argTypes, args) {
+ return ccallFunc(getCFunc(ident), returnType, argTypes, args);
+}
+Module["ccall"] = ccall;
+
+// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
+function getCFunc(ident) {
+ try {
+ var func = Module['_' + ident]; // closure exported function
+ if (!func) func = eval('_' + ident); // explicit lookup
+ } catch(e) {
+ }
+ assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
+ return func;
+}
+
+// Internal function that does a C call using a function, not an identifier
+function ccallFunc(func, returnType, argTypes, args) {
+ var stack = 0;
+ function toC(value, type) {
+ if (type == 'string') {
+ if (value === null || value === undefined || value === 0) return 0; // null string
+ value = intArrayFromString(value);
+ type = 'array';
+ }
+ if (type == 'array') {
+ if (!stack) stack = Runtime.stackSave();
+ var ret = Runtime.stackAlloc(value.length);
+ writeArrayToMemory(value, ret);
+ return ret;
+ }
+ return value;
+ }
+ function fromC(value, type) {
+ if (type == 'string') {
+ return Pointer_stringify(value);
+ }
+ assert(type != 'array');
+ return value;
+ }
+ var i = 0;
+ var cArgs = args ? args.map(function(arg) {
+ return toC(arg, argTypes[i++]);
+ }) : [];
+ var ret = fromC(func.apply(null, cArgs), returnType);
+ if (stack) Runtime.stackRestore(stack);
+ return ret;
+}
+
+// Returns a native JS wrapper for a C function. This is similar to ccall, but
+// returns a function you can call repeatedly in a normal way. For example:
+//
+// var my_function = cwrap('my_c_function', 'number', ['number', 'number']);
+// alert(my_function(5, 22));
+// alert(my_function(99, 12));
+//
+function cwrap(ident, returnType, argTypes) {
+ var func = getCFunc(ident);
+ return function() {
+ return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));
+ }
+}
+Module["cwrap"] = cwrap;
+
+// Sets a value in memory in a dynamic way at run-time. Uses the
+// type data. This is the same as makeSetValue, except that
+// makeSetValue is done at compile-time and generates the needed
+// code then, whereas this function picks the right code at
+// run-time.
+// Note that setValue and getValue only do *aligned* writes and reads!
+// Note that ccall uses JS types as for defining types, while setValue and
+// getValue need LLVM types ('i8', 'i32') - this is a lower-level operation
+function setValue(ptr, value, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': HEAP8[(ptr)]=value; break;
+ case 'i8': HEAP8[(ptr)]=value; break;
+ case 'i16': HEAP16[((ptr)>>1)]=value; break;
+ case 'i32': HEAP32[((ptr)>>2)]=value; break;
+ case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= (+1) ? (tempDouble > (+0) ? ((Math_min((+(Math_floor((tempDouble)/(+4294967296)))), (+4294967295)))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+4294967296))))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
+ case 'float': HEAPF32[((ptr)>>2)]=value; break;
+ case 'double': HEAPF64[((ptr)>>3)]=value; break;
+ default: abort('invalid type for setValue: ' + type);
+ }
+}
+Module['setValue'] = setValue;
+
+// Parallel to setValue.
+function getValue(ptr, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': return HEAP8[(ptr)];
+ case 'i8': return HEAP8[(ptr)];
+ case 'i16': return HEAP16[((ptr)>>1)];
+ case 'i32': return HEAP32[((ptr)>>2)];
+ case 'i64': return HEAP32[((ptr)>>2)];
+ case 'float': return HEAPF32[((ptr)>>2)];
+ case 'double': return HEAPF64[((ptr)>>3)];
+ default: abort('invalid type for setValue: ' + type);
+ }
+ return null;
+}
+Module['getValue'] = getValue;
+
+var ALLOC_NORMAL = 0; // Tries to use _malloc()
+var ALLOC_STACK = 1; // Lives for the duration of the current function call
+var ALLOC_STATIC = 2; // Cannot be freed
+var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
+var ALLOC_NONE = 4; // Do not allocate
+Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
+Module['ALLOC_STACK'] = ALLOC_STACK;
+Module['ALLOC_STATIC'] = ALLOC_STATIC;
+Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;
+Module['ALLOC_NONE'] = ALLOC_NONE;
+
+// allocate(): This is for internal use. You can use it yourself as well, but the interface
+// is a little tricky (see docs right below). The reason is that it is optimized
+// for multiple syntaxes to save space in generated code. So you should
+// normally not use allocate(), and instead allocate memory using _malloc(),
+// initialize it with setValue(), and so forth.
+// @slab: An array of data, or a number. If a number, then the size of the block to allocate,
+// in *bytes* (note that this is sometimes confusing: the next parameter does not
+// affect this!)
+// @types: Either an array of types, one for each byte (or 0 if no type at that position),
+// or a single type which is used for the entire block. This only matters if there
+// is initial data - if @slab is a number, then this does not matter at all and is
+// ignored.
+// @allocator: How to allocate memory, see ALLOC_*
+function allocate(slab, types, allocator, ptr) {
+ var zeroinit, size;
+ if (typeof slab === 'number') {
+ zeroinit = true;
+ size = slab;
+ } else {
+ zeroinit = false;
+ size = slab.length;
+ }
+
+ var singleType = typeof types === 'string' ? types : null;
+
+ var ret;
+ if (allocator == ALLOC_NONE) {
+ ret = ptr;
+ } else {
+ ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
+ }
+
+ if (zeroinit) {
+ var ptr = ret, stop;
+ assert((ret & 3) == 0);
+ stop = ret + (size & ~3);
+ for (; ptr < stop; ptr += 4) {
+ HEAP32[((ptr)>>2)]=0;
+ }
+ stop = ret + size;
+ while (ptr < stop) {
+ HEAP8[((ptr++)|0)]=0;
+ }
+ return ret;
+ }
+
+ if (singleType === 'i8') {
+ if (slab.subarray || slab.slice) {
+ HEAPU8.set(slab, ret);
+ } else {
+ HEAPU8.set(new Uint8Array(slab), ret);
+ }
+ return ret;
+ }
+
+ var i = 0, type, typeSize, previousType;
+ while (i < size) {
+ var curr = slab[i];
+
+ if (typeof curr === 'function') {
+ curr = Runtime.getFunctionIndex(curr);
+ }
+
+ type = singleType || types[i];
+ if (type === 0) {
+ i++;
+ continue;
+ }
+
+ if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
+
+ setValue(ret+i, curr, type);
+
+ // no need to look up size unless type changes, so cache it
+ if (previousType !== type) {
+ typeSize = Runtime.getNativeTypeSize(type);
+ previousType = type;
+ }
+ i += typeSize;
+ }
+
+ return ret;
+}
+Module['allocate'] = allocate;
+
+function Pointer_stringify(ptr, /* optional */ length) {
+ // TODO: use TextDecoder
+ // Find the length, and check for UTF while doing so
+ var hasUtf = false;
+ var t;
+ var i = 0;
+ while (1) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ if (t >= 128) hasUtf = true;
+ else if (t == 0 && !length) break;
+ i++;
+ if (length && i == length) break;
+ }
+ if (!length) length = i;
+
+ var ret = '';
+
+ if (!hasUtf) {
+ var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
+ var curr;
+ while (length > 0) {
+ curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
+ ret = ret ? ret + curr : curr;
+ ptr += MAX_CHUNK;
+ length -= MAX_CHUNK;
+ }
+ return ret;
+ }
+
+ var utf8 = new Runtime.UTF8Processor();
+ for (i = 0; i < length; i++) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ ret += utf8.processCChar(t);
+ }
+ return ret;
+}
+Module['Pointer_stringify'] = Pointer_stringify;
+
+// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF16ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
+ if (codeUnit == 0)
+ return str;
+ ++i;
+ // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
+ str += String.fromCharCode(codeUnit);
+ }
+}
+Module['UTF16ToString'] = UTF16ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
+function stringToUTF16(str, outPtr) {
+ for(var i = 0; i < str.length; ++i) {
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
+ HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP16[(((outPtr)+(str.length*2))>>1)]=0;
+}
+Module['stringToUTF16'] = stringToUTF16;
+
+// Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF32ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
+ if (utf32 == 0)
+ return str;
+ ++i;
+ // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
+ if (utf32 >= 0x10000) {
+ var ch = utf32 - 0x10000;
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
+ } else {
+ str += String.fromCharCode(utf32);
+ }
+ }
+}
+Module['UTF32ToString'] = UTF32ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
+// but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.
+function stringToUTF32(str, outPtr) {
+ var iChar = 0;
+ for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
+ var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
+ var trailSurrogate = str.charCodeAt(++iCodeUnit);
+ codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
+ }
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit;
+ ++iChar;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=0;
+}
+Module['stringToUTF32'] = stringToUTF32;
+
+function demangle(func) {
+ var i = 3;
+ // params, etc.
+ var basicTypes = {
+ 'v': 'void',
+ 'b': 'bool',
+ 'c': 'char',
+ 's': 'short',
+ 'i': 'int',
+ 'l': 'long',
+ 'f': 'float',
+ 'd': 'double',
+ 'w': 'wchar_t',
+ 'a': 'signed char',
+ 'h': 'unsigned char',
+ 't': 'unsigned short',
+ 'j': 'unsigned int',
+ 'm': 'unsigned long',
+ 'x': 'long long',
+ 'y': 'unsigned long long',
+ 'z': '...'
+ };
+ var subs = [];
+ var first = true;
+ function dump(x) {
+ //return;
+ if (x) Module.print(x);
+ Module.print(func);
+ var pre = '';
+ for (var a = 0; a < i; a++) pre += ' ';
+ Module.print (pre + '^');
+ }
+ function parseNested() {
+ i++;
+ if (func[i] === 'K') i++; // ignore const
+ var parts = [];
+ while (func[i] !== 'E') {
+ if (func[i] === 'S') { // substitution
+ i++;
+ var next = func.indexOf('_', i);
+ var num = func.substring(i, next) || 0;
+ parts.push(subs[num] || '?');
+ i = next+1;
+ continue;
+ }
+ if (func[i] === 'C') { // constructor
+ parts.push(parts[parts.length-1]);
+ i += 2;
+ continue;
+ }
+ var size = parseInt(func.substr(i));
+ var pre = size.toString().length;
+ if (!size || !pre) { i--; break; } // counter i++ below us
+ var curr = func.substr(i + pre, size);
+ parts.push(curr);
+ subs.push(curr);
+ i += pre + size;
+ }
+ i++; // skip E
+ return parts;
+ }
+ function parse(rawList, limit, allowVoid) { // main parser
+ limit = limit || Infinity;
+ var ret = '', list = [];
+ function flushList() {
+ return '(' + list.join(', ') + ')';
+ }
+ var name;
+ if (func[i] === 'N') {
+ // namespaced N-E
+ name = parseNested().join('::');
+ limit--;
+ if (limit === 0) return rawList ? [name] : name;
+ } else {
+ // not namespaced
+ if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
+ var size = parseInt(func.substr(i));
+ if (size) {
+ var pre = size.toString().length;
+ name = func.substr(i + pre, size);
+ i += pre + size;
+ }
+ }
+ first = false;
+ if (func[i] === 'I') {
+ i++;
+ var iList = parse(true);
+ var iRet = parse(true, 1, true);
+ ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
+ } else {
+ ret = name;
+ }
+ paramLoop: while (i < func.length && limit-- > 0) {
+ //dump('paramLoop');
+ var c = func[i++];
+ if (c in basicTypes) {
+ list.push(basicTypes[c]);
+ } else {
+ switch (c) {
+ case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
+ case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
+ case 'L': { // literal
+ i++; // skip basic type
+ var end = func.indexOf('E', i);
+ var size = end - i;
+ list.push(func.substr(i, size));
+ i += size + 2; // size + 'EE'
+ break;
+ }
+ case 'A': { // array
+ var size = parseInt(func.substr(i));
+ i += size.toString().length;
+ if (func[i] !== '_') throw '?';
+ i++; // skip _
+ list.push(parse(true, 1, true)[0] + ' [' + size + ']');
+ break;
+ }
+ case 'E': break paramLoop;
+ default: ret += '?' + c; break paramLoop;
+ }
+ }
+ }
+ if (!allowVoid && list.length === 1 && list[0] === 'void') list = []; // avoid (void)
+ if (rawList) {
+ if (ret) {
+ list.push(ret + '?');
+ }
+ return list;
+ } else {
+ return ret + flushList();
+ }
+ }
+ try {
+ // Special-case the entry point, since its name differs from other name mangling.
+ if (func == 'Object._main' || func == '_main') {
+ return 'main()';
+ }
+ if (typeof func === 'number') func = Pointer_stringify(func);
+ if (func[0] !== '_') return func;
+ if (func[1] !== '_') return func; // C function
+ if (func[2] !== 'Z') return func;
+ switch (func[3]) {
+ case 'n': return 'operator new()';
+ case 'd': return 'operator delete()';
+ }
+ return parse();
+ } catch(e) {
+ return func;
+ }
+}
+
+function demangleAll(text) {
+ return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });
+}
+
+function stackTrace() {
+ var stack = new Error().stack;
+ return stack ? demangleAll(stack) : '(no stack trace available)'; // Stack trace is not available at least on IE10 and Safari 6.
+}
+
+// Memory management
+
+var PAGE_SIZE = 4096;
+function alignMemoryPage(x) {
+ return (x+4095)&-4096;
+}
+
+var HEAP;
+var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
+
+var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area
+var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area
+var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk
+
+function enlargeMemory() {
+ abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
+}
+
+var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
+var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 134217728;
+var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
+
+var totalMemory = 4096;
+while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
+ if (totalMemory < 16*1024*1024) {
+ totalMemory *= 2;
+ } else {
+ totalMemory += 16*1024*1024
+ }
+}
+if (totalMemory !== TOTAL_MEMORY) {
+ Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
+ TOTAL_MEMORY = totalMemory;
+}
+
+// Initialize the runtime's memory
+// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
+assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
+ 'JS engine does not provide full typed array support');
+
+var buffer = new ArrayBuffer(TOTAL_MEMORY);
+HEAP8 = new Int8Array(buffer);
+HEAP16 = new Int16Array(buffer);
+HEAP32 = new Int32Array(buffer);
+HEAPU8 = new Uint8Array(buffer);
+HEAPU16 = new Uint16Array(buffer);
+HEAPU32 = new Uint32Array(buffer);
+HEAPF32 = new Float32Array(buffer);
+HEAPF64 = new Float64Array(buffer);
+
+// Endianness check (note: assumes compiler arch was little-endian)
+HEAP32[0] = 255;
+assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
+
+Module['HEAP'] = HEAP;
+Module['HEAP8'] = HEAP8;
+Module['HEAP16'] = HEAP16;
+Module['HEAP32'] = HEAP32;
+Module['HEAPU8'] = HEAPU8;
+Module['HEAPU16'] = HEAPU16;
+Module['HEAPU32'] = HEAPU32;
+Module['HEAPF32'] = HEAPF32;
+Module['HEAPF64'] = HEAPF64;
+
+function callRuntimeCallbacks(callbacks) {
+ while(callbacks.length > 0) {
+ var callback = callbacks.shift();
+ if (typeof callback == 'function') {
+ callback();
+ continue;
+ }
+ var func = callback.func;
+ if (typeof func === 'number') {
+ if (callback.arg === undefined) {
+ Runtime.dynCall('v', func);
+ } else {
+ Runtime.dynCall('vi', func, [callback.arg]);
+ }
+ } else {
+ func(callback.arg === undefined ? null : callback.arg);
+ }
+ }
+}
+
+var __ATPRERUN__ = []; // functions called before the runtime is initialized
+var __ATINIT__ = []; // functions called during startup
+var __ATMAIN__ = []; // functions called when main() is to be run
+var __ATEXIT__ = []; // functions called during shutdown
+var __ATPOSTRUN__ = []; // functions called after the runtime has exited
+
+var runtimeInitialized = false;
+
+function preRun() {
+ // compatibility - merge in anything from Module['preRun'] at this time
+ if (Module['preRun']) {
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
+ while (Module['preRun'].length) {
+ addOnPreRun(Module['preRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPRERUN__);
+}
+
+function ensureInitRuntime() {
+ if (runtimeInitialized) return;
+ runtimeInitialized = true;
+ callRuntimeCallbacks(__ATINIT__);
+}
+
+function preMain() {
+ callRuntimeCallbacks(__ATMAIN__);
+}
+
+function exitRuntime() {
+ callRuntimeCallbacks(__ATEXIT__);
+}
+
+function postRun() {
+ // compatibility - merge in anything from Module['postRun'] at this time
+ if (Module['postRun']) {
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
+ while (Module['postRun'].length) {
+ addOnPostRun(Module['postRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPOSTRUN__);
+}
+
+function addOnPreRun(cb) {
+ __ATPRERUN__.unshift(cb);
+}
+Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;
+
+function addOnInit(cb) {
+ __ATINIT__.unshift(cb);
+}
+Module['addOnInit'] = Module.addOnInit = addOnInit;
+
+function addOnPreMain(cb) {
+ __ATMAIN__.unshift(cb);
+}
+Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;
+
+function addOnExit(cb) {
+ __ATEXIT__.unshift(cb);
+}
+Module['addOnExit'] = Module.addOnExit = addOnExit;
+
+function addOnPostRun(cb) {
+ __ATPOSTRUN__.unshift(cb);
+}
+Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;
+
+// Tools
+
+// This processes a JS string into a C-line array of numbers, 0-terminated.
+// For LLVM-originating strings, see parser.js:parseLLVMString function
+function intArrayFromString(stringy, dontAddNull, length /* optional */) {
+ var ret = (new Runtime.UTF8Processor()).processJSString(stringy);
+ if (length) {
+ ret.length = length;
+ }
+ if (!dontAddNull) {
+ ret.push(0);
+ }
+ return ret;
+}
+Module['intArrayFromString'] = intArrayFromString;
+
+function intArrayToString(array) {
+ var ret = [];
+ for (var i = 0; i < array.length; i++) {
+ var chr = array[i];
+ if (chr > 0xFF) {
+ chr &= 0xFF;
+ }
+ ret.push(String.fromCharCode(chr));
+ }
+ return ret.join('');
+}
+Module['intArrayToString'] = intArrayToString;
+
+// Write a Javascript array to somewhere in the heap
+function writeStringToMemory(string, buffer, dontAddNull) {
+ var array = intArrayFromString(string, dontAddNull);
+ var i = 0;
+ while (i < array.length) {
+ var chr = array[i];
+ HEAP8[(((buffer)+(i))|0)]=chr;
+ i = i + 1;
+ }
+}
+Module['writeStringToMemory'] = writeStringToMemory;
+
+function writeArrayToMemory(array, buffer) {
+ for (var i = 0; i < array.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=array[i];
+ }
+}
+Module['writeArrayToMemory'] = writeArrayToMemory;
+
+function writeAsciiToMemory(str, buffer, dontAddNull) {
+ for (var i = 0; i < str.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=str.charCodeAt(i);
+ }
+ if (!dontAddNull) HEAP8[(((buffer)+(str.length))|0)]=0;
+}
+Module['writeAsciiToMemory'] = writeAsciiToMemory;
+
+function unSign(value, bits, ignore) {
+ if (value >= 0) {
+ return value;
+ }
+ return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
+ : Math.pow(2, bits) + value;
+}
+function reSign(value, bits, ignore) {
+ if (value <= 0) {
+ return value;
+ }
+ var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
+ : Math.pow(2, bits-1);
+ if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
+ // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
+ // TODO: In i64 mode 1, resign the two parts separately and safely
+ value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
+ }
+ return value;
+}
+
+// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
+if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
+ var ah = a >>> 16;
+ var al = a & 0xffff;
+ var bh = b >>> 16;
+ var bl = b & 0xffff;
+ return (al*bl + ((ah*bl + al*bh) << 16))|0;
+};
+Math.imul = Math['imul'];
+
+
+var Math_abs = Math.abs;
+var Math_cos = Math.cos;
+var Math_sin = Math.sin;
+var Math_tan = Math.tan;
+var Math_acos = Math.acos;
+var Math_asin = Math.asin;
+var Math_atan = Math.atan;
+var Math_atan2 = Math.atan2;
+var Math_exp = Math.exp;
+var Math_log = Math.log;
+var Math_sqrt = Math.sqrt;
+var Math_ceil = Math.ceil;
+var Math_floor = Math.floor;
+var Math_pow = Math.pow;
+var Math_imul = Math.imul;
+var Math_fround = Math.fround;
+var Math_min = Math.min;
+
+// A counter of dependencies for calling run(). If we need to
+// do asynchronous work before running, increment this and
+// decrement it. Incrementing must happen in a place like
+// PRE_RUN_ADDITIONS (used by emcc to add file preloading).
+// Note that you can add dependencies in preRun, even though
+// it happens right before run - run will be postponed until
+// the dependencies are met.
+var runDependencies = 0;
+var runDependencyWatcher = null;
+var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
+
+function addRunDependency(id) {
+ runDependencies++;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+}
+Module['addRunDependency'] = addRunDependency;
+function removeRunDependency(id) {
+ runDependencies--;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+ if (runDependencies == 0) {
+ if (runDependencyWatcher !== null) {
+ clearInterval(runDependencyWatcher);
+ runDependencyWatcher = null;
+ }
+ if (dependenciesFulfilled) {
+ var callback = dependenciesFulfilled;
+ dependenciesFulfilled = null;
+ callback(); // can add another dependenciesFulfilled
+ }
+ }
+}
+Module['removeRunDependency'] = removeRunDependency;
+
+Module["preloadedImages"] = {}; // maps url to image data
+Module["preloadedAudios"] = {}; // maps url to audio data
+
+
+var memoryInitializer = null;
+
+// === Body ===
+
+
+
+
+
+STATIC_BASE = 8;
+
+STATICTOP = STATIC_BASE + Runtime.alignMemory(35);
+/* global initializers */ __ATINIT__.push();
+
+
+/* memory initializer */ allocate([101,114,114,111,114,58,32,37,100,92,110,0,0,0,0,0,108,97,115,116,112,114,105,109,101,58,32,37,100,46,10,0], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
+
+
+
+
+var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8);
+
+assert(tempDoublePtr % 8 == 0);
+
+function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+}
+
+function copyTempDouble(ptr) {
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+ HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
+
+ HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
+
+ HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
+
+ HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
+
+}
+
+
+ function _malloc(bytes) {
+ /* Over-allocate to make sure it is byte-aligned by 8.
+ * This will leak memory, but this is only the dummy
+ * implementation (replaced by dlmalloc normally) so
+ * not an issue.
+ */
+ var ptr = Runtime.dynamicAlloc(bytes + 8);
+ return (ptr+8) & 0xFFFFFFF8;
+ }
+ Module["_malloc"] = _malloc;
+
+
+ Module["_memset"] = _memset;
+
+ function _free() {
+ }
+ Module["_free"] = _free;
+
+
+ function _emscripten_memcpy_big(dest, src, num) {
+ HEAPU8.set(HEAPU8.subarray(src, src+num), dest);
+ return dest;
+ }
+ Module["_memcpy"] = _memcpy;
+
+
+
+
+ var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};
+
+ var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
+
+
+ var ___errno_state=0;function ___setErrNo(value) {
+ // For convenient setting and returning of errno.
+ HEAP32[((___errno_state)>>2)]=value;
+ return value;
+ }
+
+ var TTY={ttys:[],init:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // currently, FS.init does not distinguish if process.stdin is a file or TTY
+ // // device, it always assumes it's a TTY device. because of this, we're forcing
+ // // process.stdin to UTF8 encoding to at least make stdin reading compatible
+ // // with text files until FS.init can be refactored.
+ // process['stdin']['setEncoding']('utf8');
+ // }
+ },shutdown:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
+ // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
+ // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
+ // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
+ // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
+ // process['stdin']['pause']();
+ // }
+ },register:function (dev, ops) {
+ TTY.ttys[dev] = { input: [], output: [], ops: ops };
+ FS.registerDevice(dev, TTY.stream_ops);
+ },stream_ops:{open:function (stream) {
+ var tty = TTY.ttys[stream.node.rdev];
+ if (!tty) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ stream.tty = tty;
+ stream.seekable = false;
+ },close:function (stream) {
+ // flush any pending line data
+ if (stream.tty.output.length) {
+ stream.tty.ops.put_char(stream.tty, 10);
+ }
+ },read:function (stream, buffer, offset, length, pos /* ignored */) {
+ if (!stream.tty || !stream.tty.ops.get_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = stream.tty.ops.get_char(stream.tty);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, pos) {
+ if (!stream.tty || !stream.tty.ops.put_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ for (var i = 0; i < length; i++) {
+ try {
+ stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }},default_tty_ops:{get_char:function (tty) {
+ if (!tty.input.length) {
+ var result = null;
+ if (ENVIRONMENT_IS_NODE) {
+ result = process['stdin']['read']();
+ if (!result) {
+ if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
+ return null; // EOF
+ }
+ return undefined; // no data available
+ }
+ } else if (typeof window != 'undefined' &&
+ typeof window.prompt == 'function') {
+ // Browser.
+ result = window.prompt('Input: '); // returns null on cancel
+ if (result !== null) {
+ result += '\n';
+ }
+ } else if (typeof readline == 'function') {
+ // Command line.
+ result = readline();
+ if (result !== null) {
+ result += '\n';
+ }
+ }
+ if (!result) {
+ return null;
+ }
+ tty.input = intArrayFromString(result, true);
+ }
+ return tty.input.shift();
+ },put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['print'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }},default_tty1_ops:{put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['printErr'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }}};
+
+ var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
+ return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
+ // no supported
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (!MEMFS.ops_table) {
+ MEMFS.ops_table = {
+ dir: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ lookup: MEMFS.node_ops.lookup,
+ mknod: MEMFS.node_ops.mknod,
+ rename: MEMFS.node_ops.rename,
+ unlink: MEMFS.node_ops.unlink,
+ rmdir: MEMFS.node_ops.rmdir,
+ readdir: MEMFS.node_ops.readdir,
+ symlink: MEMFS.node_ops.symlink
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek
+ }
+ },
+ file: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek,
+ read: MEMFS.stream_ops.read,
+ write: MEMFS.stream_ops.write,
+ allocate: MEMFS.stream_ops.allocate,
+ mmap: MEMFS.stream_ops.mmap
+ }
+ },
+ link: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ readlink: MEMFS.node_ops.readlink
+ },
+ stream: {}
+ },
+ chrdev: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: FS.chrdev_stream_ops
+ },
+ };
+ }
+ var node = FS.createNode(parent, name, mode, dev);
+ if (FS.isDir(node.mode)) {
+ node.node_ops = MEMFS.ops_table.dir.node;
+ node.stream_ops = MEMFS.ops_table.dir.stream;
+ node.contents = {};
+ } else if (FS.isFile(node.mode)) {
+ node.node_ops = MEMFS.ops_table.file.node;
+ node.stream_ops = MEMFS.ops_table.file.stream;
+ node.contents = [];
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ } else if (FS.isLink(node.mode)) {
+ node.node_ops = MEMFS.ops_table.link.node;
+ node.stream_ops = MEMFS.ops_table.link.stream;
+ } else if (FS.isChrdev(node.mode)) {
+ node.node_ops = MEMFS.ops_table.chrdev.node;
+ node.stream_ops = MEMFS.ops_table.chrdev.stream;
+ }
+ node.timestamp = Date.now();
+ // add the new node to the parent
+ if (parent) {
+ parent.contents[name] = node;
+ }
+ return node;
+ },ensureFlexible:function (node) {
+ if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
+ var contents = node.contents;
+ node.contents = Array.prototype.slice.call(contents);
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ }
+ },node_ops:{getattr:function (node) {
+ var attr = {};
+ // device numbers reuse inode numbers.
+ attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
+ attr.ino = node.id;
+ attr.mode = node.mode;
+ attr.nlink = 1;
+ attr.uid = 0;
+ attr.gid = 0;
+ attr.rdev = node.rdev;
+ if (FS.isDir(node.mode)) {
+ attr.size = 4096;
+ } else if (FS.isFile(node.mode)) {
+ attr.size = node.contents.length;
+ } else if (FS.isLink(node.mode)) {
+ attr.size = node.link.length;
+ } else {
+ attr.size = 0;
+ }
+ attr.atime = new Date(node.timestamp);
+ attr.mtime = new Date(node.timestamp);
+ attr.ctime = new Date(node.timestamp);
+ // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
+ // but this is not required by the standard.
+ attr.blksize = 4096;
+ attr.blocks = Math.ceil(attr.size / attr.blksize);
+ return attr;
+ },setattr:function (node, attr) {
+ if (attr.mode !== undefined) {
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ node.timestamp = attr.timestamp;
+ }
+ if (attr.size !== undefined) {
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ if (attr.size < contents.length) contents.length = attr.size;
+ else while (attr.size > contents.length) contents.push(0);
+ }
+ },lookup:function (parent, name) {
+ throw FS.genericErrors[ERRNO_CODES.ENOENT];
+ },mknod:function (parent, name, mode, dev) {
+ return MEMFS.createNode(parent, name, mode, dev);
+ },rename:function (old_node, new_dir, new_name) {
+ // if we're overwriting a directory at new_name, make sure it's empty.
+ if (FS.isDir(old_node.mode)) {
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ }
+ if (new_node) {
+ for (var i in new_node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ }
+ }
+ // do the internal rewiring
+ delete old_node.parent.contents[old_node.name];
+ old_node.name = new_name;
+ new_dir.contents[new_name] = old_node;
+ old_node.parent = new_dir;
+ },unlink:function (parent, name) {
+ delete parent.contents[name];
+ },rmdir:function (parent, name) {
+ var node = FS.lookupNode(parent, name);
+ for (var i in node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ delete parent.contents[name];
+ },readdir:function (node) {
+ var entries = ['.', '..']
+ for (var key in node.contents) {
+ if (!node.contents.hasOwnProperty(key)) {
+ continue;
+ }
+ entries.push(key);
+ }
+ return entries;
+ },symlink:function (parent, newname, oldpath) {
+ var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
+ node.link = oldpath;
+ return node;
+ },readlink:function (node) {
+ if (!FS.isLink(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return node.link;
+ }},stream_ops:{read:function (stream, buffer, offset, length, position) {
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (size > 8 && contents.subarray) { // non-trivial, and typed array
+ buffer.set(contents.subarray(position, position + size), offset);
+ } else
+ {
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ }
+ return size;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ var node = stream.node;
+ node.timestamp = Date.now();
+ var contents = node.contents;
+ if (length && contents.length === 0 && position === 0 && buffer.subarray) {
+ // just replace it with the new data
+ if (canOwn && offset === 0) {
+ node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
+ node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
+ } else {
+ node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
+ node.contentMode = MEMFS.CONTENT_FIXED;
+ }
+ return length;
+ }
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ while (contents.length < position) contents.push(0);
+ for (var i = 0; i < length; i++) {
+ contents[position + i] = buffer[offset + i];
+ }
+ return length;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ position += stream.node.contents.length;
+ }
+ }
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ stream.ungotten = [];
+ stream.position = position;
+ return position;
+ },allocate:function (stream, offset, length) {
+ MEMFS.ensureFlexible(stream.node);
+ var contents = stream.node.contents;
+ var limit = offset + length;
+ while (limit > contents.length) contents.push(0);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ if (!FS.isFile(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ var ptr;
+ var allocated;
+ var contents = stream.node.contents;
+ // Only make a new copy when MAP_PRIVATE is specified.
+ if ( !(flags & 2) &&
+ (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
+ // We can't emulate MAP_SHARED when the file is not backed by the buffer
+ // we're mapping to (e.g. the HEAP buffer).
+ allocated = false;
+ ptr = contents.byteOffset;
+ } else {
+ // Try to avoid unnecessary slices.
+ if (position > 0 || position + length < contents.length) {
+ if (contents.subarray) {
+ contents = contents.subarray(position, position + length);
+ } else {
+ contents = Array.prototype.slice.call(contents, position, position + length);
+ }
+ }
+ allocated = true;
+ ptr = _malloc(length);
+ if (!ptr) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
+ }
+ buffer.set(contents, ptr);
+ }
+ return { ptr: ptr, allocated: allocated };
+ }}};
+
+ var IDBFS={dbs:{},indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
+ // reuse all of the core MEMFS functionality
+ return MEMFS.mount.apply(null, arguments);
+ },syncfs:function (mount, populate, callback) {
+ IDBFS.getLocalSet(mount, function(err, local) {
+ if (err) return callback(err);
+
+ IDBFS.getRemoteSet(mount, function(err, remote) {
+ if (err) return callback(err);
+
+ var src = populate ? remote : local;
+ var dst = populate ? local : remote;
+
+ IDBFS.reconcile(src, dst, callback);
+ });
+ });
+ },getDB:function (name, callback) {
+ // check the cache first
+ var db = IDBFS.dbs[name];
+ if (db) {
+ return callback(null, db);
+ }
+
+ var req;
+ try {
+ req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
+ } catch (e) {
+ return callback(e);
+ }
+ req.onupgradeneeded = function(e) {
+ var db = e.target.result;
+ var transaction = e.target.transaction;
+
+ var fileStore;
+
+ if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
+ fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ } else {
+ fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
+ }
+
+ fileStore.createIndex('timestamp', 'timestamp', { unique: false });
+ };
+ req.onsuccess = function() {
+ db = req.result;
+
+ // add to the cache
+ IDBFS.dbs[name] = db;
+ callback(null, db);
+ };
+ req.onerror = function() {
+ callback(this.error);
+ };
+ },getLocalSet:function (mount, callback) {
+ var entries = {};
+
+ function isRealDir(p) {
+ return p !== '.' && p !== '..';
+ };
+ function toAbsolute(root) {
+ return function(p) {
+ return PATH.join2(root, p);
+ }
+ };
+
+ var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
+
+ while (check.length) {
+ var path = check.pop();
+ var stat;
+
+ try {
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
+ }
+
+ entries[path] = { timestamp: stat.mtime };
+ }
+
+ return callback(null, { type: 'local', entries: entries });
+ },getRemoteSet:function (mount, callback) {
+ var entries = {};
+
+ IDBFS.getDB(mount.mountpoint, function(err, db) {
+ if (err) return callback(err);
+
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
+ transaction.onerror = function() { callback(this.error); };
+
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ var index = store.index('timestamp');
+
+ index.openKeyCursor().onsuccess = function(event) {
+ var cursor = event.target.result;
+
+ if (!cursor) {
+ return callback(null, { type: 'remote', db: db, entries: entries });
+ }
+
+ entries[cursor.primaryKey] = { timestamp: cursor.key };
+
+ cursor.continue();
+ };
+ });
+ },loadLocalEntry:function (path, callback) {
+ var stat, node;
+
+ try {
+ var lookup = FS.lookupPath(path);
+ node = lookup.node;
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode });
+ } else if (FS.isFile(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+ },storeLocalEntry:function (path, entry, callback) {
+ try {
+ if (FS.isDir(entry.mode)) {
+ FS.mkdir(path, entry.mode);
+ } else if (FS.isFile(entry.mode)) {
+ FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+
+ FS.utime(path, entry.timestamp, entry.timestamp);
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },removeLocalEntry:function (path, callback) {
+ try {
+ var lookup = FS.lookupPath(path);
+ var stat = FS.stat(path);
+
+ if (FS.isDir(stat.mode)) {
+ FS.rmdir(path);
+ } else if (FS.isFile(stat.mode)) {
+ FS.unlink(path);
+ }
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },loadRemoteEntry:function (store, path, callback) {
+ var req = store.get(path);
+ req.onsuccess = function(event) { callback(null, event.target.result); };
+ req.onerror = function() { callback(this.error); };
+ },storeRemoteEntry:function (store, path, entry, callback) {
+ var req = store.put(entry, path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },removeRemoteEntry:function (store, path, callback) {
+ var req = store.delete(path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },reconcile:function (src, dst, callback) {
+ var total = 0;
+
+ var create = [];
+ Object.keys(src.entries).forEach(function (key) {
+ var e = src.entries[key];
+ var e2 = dst.entries[key];
+ if (!e2 || e.timestamp > e2.timestamp) {
+ create.push(key);
+ total++;
+ }
+ });
+
+ var remove = [];
+ Object.keys(dst.entries).forEach(function (key) {
+ var e = dst.entries[key];
+ var e2 = src.entries[key];
+ if (!e2) {
+ remove.push(key);
+ total++;
+ }
+ });
+
+ if (!total) {
+ return callback(null);
+ }
+
+ var errored = false;
+ var completed = 0;
+ var db = src.type === 'remote' ? src.db : dst.db;
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= total) {
+ return callback(null);
+ }
+ };
+
+ transaction.onerror = function() { done(this.error); };
+
+ // sort paths in ascending order so directory entries are created
+ // before the files inside them
+ create.sort().forEach(function (path) {
+ if (dst.type === 'local') {
+ IDBFS.loadRemoteEntry(store, path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeLocalEntry(path, entry, done);
+ });
+ } else {
+ IDBFS.loadLocalEntry(path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeRemoteEntry(store, path, entry, done);
+ });
+ }
+ });
+
+ // sort paths in descending order so files are deleted before their
+ // parent directories
+ remove.sort().reverse().forEach(function(path) {
+ if (dst.type === 'local') {
+ IDBFS.removeLocalEntry(path, done);
+ } else {
+ IDBFS.removeRemoteEntry(store, path, done);
+ }
+ });
+ }};
+
+ var NODEFS={isWindows:false,staticInit:function () {
+ NODEFS.isWindows = !!process.platform.match(/^win/);
+ },mount:function (mount) {
+ assert(ENVIRONMENT_IS_NODE);
+ return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node = FS.createNode(parent, name, mode);
+ node.node_ops = NODEFS.node_ops;
+ node.stream_ops = NODEFS.stream_ops;
+ return node;
+ },getMode:function (path) {
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ if (NODEFS.isWindows) {
+ // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so
+ // propagate write bits to execute bits.
+ stat.mode = stat.mode | ((stat.mode & 146) >> 1);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return stat.mode;
+ },realPath:function (node) {
+ var parts = [];
+ while (node.parent !== node) {
+ parts.push(node.name);
+ node = node.parent;
+ }
+ parts.push(node.mount.opts.root);
+ parts.reverse();
+ return PATH.join.apply(null, parts);
+ },flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function (flags) {
+ if (flags in NODEFS.flagsToPermissionStringMap) {
+ return NODEFS.flagsToPermissionStringMap[flags];
+ } else {
+ return flags;
+ }
+ },node_ops:{getattr:function (node) {
+ var path = NODEFS.realPath(node);
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
+ // See http://support.microsoft.com/kb/140365
+ if (NODEFS.isWindows && !stat.blksize) {
+ stat.blksize = 4096;
+ }
+ if (NODEFS.isWindows && !stat.blocks) {
+ stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
+ }
+ return {
+ dev: stat.dev,
+ ino: stat.ino,
+ mode: stat.mode,
+ nlink: stat.nlink,
+ uid: stat.uid,
+ gid: stat.gid,
+ rdev: stat.rdev,
+ size: stat.size,
+ atime: stat.atime,
+ mtime: stat.mtime,
+ ctime: stat.ctime,
+ blksize: stat.blksize,
+ blocks: stat.blocks
+ };
+ },setattr:function (node, attr) {
+ var path = NODEFS.realPath(node);
+ try {
+ if (attr.mode !== undefined) {
+ fs.chmodSync(path, attr.mode);
+ // update the common node structure mode as well
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ var date = new Date(attr.timestamp);
+ fs.utimesSync(path, date, date);
+ }
+ if (attr.size !== undefined) {
+ fs.truncateSync(path, attr.size);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },lookup:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ var mode = NODEFS.getMode(path);
+ return NODEFS.createNode(parent, name, mode);
+ },mknod:function (parent, name, mode, dev) {
+ var node = NODEFS.createNode(parent, name, mode, dev);
+ // create the backing node for this in the fs root as well
+ var path = NODEFS.realPath(node);
+ try {
+ if (FS.isDir(node.mode)) {
+ fs.mkdirSync(path, node.mode);
+ } else {
+ fs.writeFileSync(path, '', { mode: node.mode });
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return node;
+ },rename:function (oldNode, newDir, newName) {
+ var oldPath = NODEFS.realPath(oldNode);
+ var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
+ try {
+ fs.renameSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },unlink:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.unlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },rmdir:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.rmdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readdir:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },symlink:function (parent, newName, oldPath) {
+ var newPath = PATH.join2(NODEFS.realPath(parent), newName);
+ try {
+ fs.symlinkSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readlink:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }},stream_ops:{open:function (stream) {
+ var path = NODEFS.realPath(stream.node);
+ try {
+ if (FS.isFile(stream.node.mode)) {
+ stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },close:function (stream) {
+ try {
+ if (FS.isFile(stream.node.mode) && stream.nfd) {
+ fs.closeSync(stream.nfd);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },read:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(length);
+ var res;
+ try {
+ res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ if (res > 0) {
+ for (var i = 0; i < res; i++) {
+ buffer[offset + i] = nbuffer[i];
+ }
+ }
+ return res;
+ },write:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
+ var res;
+ try {
+ res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return res;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ try {
+ var stat = fs.fstatSync(stream.nfd);
+ position += stat.size;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }
+ }
+
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ stream.position = position;
+ return position;
+ }}};
+
+ var _stdin=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stdout=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stderr=allocate(1, "i32*", ALLOC_STATIC);
+
+ function _fflush(stream) {
+ // int fflush(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html
+ // we don't currently perform any user-space buffering of data
+ }var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},handleFSError:function (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
+ return ___setErrNo(e.errno);
+ },lookupPath:function (path, opts) {
+ path = PATH.resolve(FS.cwd(), path);
+ opts = opts || {};
+
+ var defaults = {
+ follow_mount: true,
+ recurse_count: 0
+ };
+ for (var key in defaults) {
+ if (opts[key] === undefined) {
+ opts[key] = defaults[key];
+ }
+ }
+
+ if (opts.recurse_count > 8) { // max recursive lookup of 8
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+
+ // split the path
+ var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), false);
+
+ // start at the root
+ var current = FS.root;
+ var current_path = '/';
+
+ for (var i = 0; i < parts.length; i++) {
+ var islast = (i === parts.length-1);
+ if (islast && opts.parent) {
+ // stop resolving
+ break;
+ }
+
+ current = FS.lookupNode(current, parts[i]);
+ current_path = PATH.join2(current_path, parts[i]);
+
+ // jump to the mount's root node if this is a mountpoint
+ if (FS.isMountpoint(current)) {
+ if (!islast || (islast && opts.follow_mount)) {
+ current = current.mounted.root;
+ }
+ }
+
+ // by default, lookupPath will not follow a symlink if it is the final path component.
+ // setting opts.follow = true will override this behavior.
+ if (!islast || opts.follow) {
+ var count = 0;
+ while (FS.isLink(current.mode)) {
+ var link = FS.readlink(current_path);
+ current_path = PATH.resolve(PATH.dirname(current_path), link);
+
+ var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
+ current = lookup.node;
+
+ if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+ }
+ }
+ }
+
+ return { path: current_path, node: current };
+ },getPath:function (node) {
+ var path;
+ while (true) {
+ if (FS.isRoot(node)) {
+ var mount = node.mount.mountpoint;
+ if (!path) return mount;
+ return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
+ }
+ path = path ? node.name + '/' + path : node.name;
+ node = node.parent;
+ }
+ },hashName:function (parentid, name) {
+ var hash = 0;
+
+
+ for (var i = 0; i < name.length; i++) {
+ hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
+ }
+ return ((parentid + hash) >>> 0) % FS.nameTable.length;
+ },hashAddNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ node.name_next = FS.nameTable[hash];
+ FS.nameTable[hash] = node;
+ },hashRemoveNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ if (FS.nameTable[hash] === node) {
+ FS.nameTable[hash] = node.name_next;
+ } else {
+ var current = FS.nameTable[hash];
+ while (current) {
+ if (current.name_next === node) {
+ current.name_next = node.name_next;
+ break;
+ }
+ current = current.name_next;
+ }
+ }
+ },lookupNode:function (parent, name) {
+ var err = FS.mayLookup(parent);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ var hash = FS.hashName(parent.id, name);
+ for (var node = FS.nameTable[hash]; node; node = node.name_next) {
+ var nodeName = node.name;
+ if (node.parent.id === parent.id && nodeName === name) {
+ return node;
+ }
+ }
+ // if we failed to find it in the cache, call into the VFS
+ return FS.lookup(parent, name);
+ },createNode:function (parent, name, mode, rdev) {
+ if (!FS.FSNode) {
+ FS.FSNode = function(parent, name, mode, rdev) {
+ if (!parent) {
+ parent = this; // root node sets parent to itself
+ }
+ this.parent = parent;
+ this.mount = parent.mount;
+ this.mounted = null;
+ this.id = FS.nextInode++;
+ this.name = name;
+ this.mode = mode;
+ this.node_ops = {};
+ this.stream_ops = {};
+ this.rdev = rdev;
+ };
+
+ FS.FSNode.prototype = {};
+
+ // compatibility
+ var readMode = 292 | 73;
+ var writeMode = 146;
+
+ // NOTE we must use Object.defineProperties instead of individual calls to
+ // Object.defineProperty in order to make closure compiler happy
+ Object.defineProperties(FS.FSNode.prototype, {
+ read: {
+ get: function() { return (this.mode & readMode) === readMode; },
+ set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
+ },
+ write: {
+ get: function() { return (this.mode & writeMode) === writeMode; },
+ set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
+ },
+ isFolder: {
+ get: function() { return FS.isDir(this.mode); },
+ },
+ isDevice: {
+ get: function() { return FS.isChrdev(this.mode); },
+ },
+ });
+ }
+
+ var node = new FS.FSNode(parent, name, mode, rdev);
+
+ FS.hashAddNode(node);
+
+ return node;
+ },destroyNode:function (node) {
+ FS.hashRemoveNode(node);
+ },isRoot:function (node) {
+ return node === node.parent;
+ },isMountpoint:function (node) {
+ return !!node.mounted;
+ },isFile:function (mode) {
+ return (mode & 61440) === 32768;
+ },isDir:function (mode) {
+ return (mode & 61440) === 16384;
+ },isLink:function (mode) {
+ return (mode & 61440) === 40960;
+ },isChrdev:function (mode) {
+ return (mode & 61440) === 8192;
+ },isBlkdev:function (mode) {
+ return (mode & 61440) === 24576;
+ },isFIFO:function (mode) {
+ return (mode & 61440) === 4096;
+ },isSocket:function (mode) {
+ return (mode & 49152) === 49152;
+ },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
+ var flags = FS.flagModes[str];
+ if (typeof flags === 'undefined') {
+ throw new Error('Unknown file open mode: ' + str);
+ }
+ return flags;
+ },flagsToPermissionString:function (flag) {
+ var accmode = flag & 2097155;
+ var perms = ['r', 'w', 'rw'][accmode];
+ if ((flag & 512)) {
+ perms += 'w';
+ }
+ return perms;
+ },nodePermissions:function (node, perms) {
+ if (FS.ignorePermissions) {
+ return 0;
+ }
+ // return 0 if any user, group or owner bits are set.
+ if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
+ return ERRNO_CODES.EACCES;
+ }
+ return 0;
+ },mayLookup:function (dir) {
+ return FS.nodePermissions(dir, 'x');
+ },mayCreate:function (dir, name) {
+ try {
+ var node = FS.lookupNode(dir, name);
+ return ERRNO_CODES.EEXIST;
+ } catch (e) {
+ }
+ return FS.nodePermissions(dir, 'wx');
+ },mayDelete:function (dir, name, isdir) {
+ var node;
+ try {
+ node = FS.lookupNode(dir, name);
+ } catch (e) {
+ return e.errno;
+ }
+ var err = FS.nodePermissions(dir, 'wx');
+ if (err) {
+ return err;
+ }
+ if (isdir) {
+ if (!FS.isDir(node.mode)) {
+ return ERRNO_CODES.ENOTDIR;
+ }
+ if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
+ return ERRNO_CODES.EBUSY;
+ }
+ } else {
+ if (FS.isDir(node.mode)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return 0;
+ },mayOpen:function (node, flags) {
+ if (!node) {
+ return ERRNO_CODES.ENOENT;
+ }
+ if (FS.isLink(node.mode)) {
+ return ERRNO_CODES.ELOOP;
+ } else if (FS.isDir(node.mode)) {
+ if ((flags & 2097155) !== 0 || // opening for write
+ (flags & 512)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
+ },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
+ fd_start = fd_start || 0;
+ fd_end = fd_end || FS.MAX_OPEN_FDS;
+ for (var fd = fd_start; fd <= fd_end; fd++) {
+ if (!FS.streams[fd]) {
+ return fd;
+ }
+ }
+ throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
+ },getStream:function (fd) {
+ return FS.streams[fd];
+ },createStream:function (stream, fd_start, fd_end) {
+ if (!FS.FSStream) {
+ FS.FSStream = function(){};
+ FS.FSStream.prototype = {};
+ // compatibility
+ Object.defineProperties(FS.FSStream.prototype, {
+ object: {
+ get: function() { return this.node; },
+ set: function(val) { this.node = val; }
+ },
+ isRead: {
+ get: function() { return (this.flags & 2097155) !== 1; }
+ },
+ isWrite: {
+ get: function() { return (this.flags & 2097155) !== 0; }
+ },
+ isAppend: {
+ get: function() { return (this.flags & 1024); }
+ }
+ });
+ }
+ if (0) {
+ // reuse the object
+ stream.__proto__ = FS.FSStream.prototype;
+ } else {
+ var newStream = new FS.FSStream();
+ for (var p in stream) {
+ newStream[p] = stream[p];
+ }
+ stream = newStream;
+ }
+ var fd = FS.nextfd(fd_start, fd_end);
+ stream.fd = fd;
+ FS.streams[fd] = stream;
+ return stream;
+ },closeStream:function (fd) {
+ FS.streams[fd] = null;
+ },getStreamFromPtr:function (ptr) {
+ return FS.streams[ptr - 1];
+ },getPtrForStream:function (stream) {
+ return stream ? stream.fd + 1 : 0;
+ },chrdev_stream_ops:{open:function (stream) {
+ var device = FS.getDevice(stream.node.rdev);
+ // override node's stream ops with the device's
+ stream.stream_ops = device.stream_ops;
+ // forward the open call
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ },llseek:function () {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }},major:function (dev) {
+ return ((dev) >> 8);
+ },minor:function (dev) {
+ return ((dev) & 0xff);
+ },makedev:function (ma, mi) {
+ return ((ma) << 8 | (mi));
+ },registerDevice:function (dev, ops) {
+ FS.devices[dev] = { stream_ops: ops };
+ },getDevice:function (dev) {
+ return FS.devices[dev];
+ },getMounts:function (mount) {
+ var mounts = [];
+ var check = [mount];
+
+ while (check.length) {
+ var m = check.pop();
+
+ mounts.push(m);
+
+ check.push.apply(check, m.mounts);
+ }
+
+ return mounts;
+ },syncfs:function (populate, callback) {
+ if (typeof(populate) === 'function') {
+ callback = populate;
+ populate = false;
+ }
+
+ var mounts = FS.getMounts(FS.root.mount);
+ var completed = 0;
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= mounts.length) {
+ callback(null);
+ }
+ };
+
+ // sync all mounts
+ mounts.forEach(function (mount) {
+ if (!mount.type.syncfs) {
+ return done(null);
+ }
+ mount.type.syncfs(mount, populate, done);
+ });
+ },mount:function (type, opts, mountpoint) {
+ var root = mountpoint === '/';
+ var pseudo = !mountpoint;
+ var node;
+
+ if (root && FS.root) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ } else if (!root && !pseudo) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ mountpoint = lookup.path; // use the absolute path
+ node = lookup.node;
+
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+
+ if (!FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ }
+
+ var mount = {
+ type: type,
+ opts: opts,
+ mountpoint: mountpoint,
+ mounts: []
+ };
+
+ // create a root node for the fs
+ var mountRoot = type.mount(mount);
+ mountRoot.mount = mount;
+ mount.root = mountRoot;
+
+ if (root) {
+ FS.root = mountRoot;
+ } else if (node) {
+ // set as a mountpoint
+ node.mounted = mount;
+
+ // add the new mount to the current mount's children
+ if (node.mount) {
+ node.mount.mounts.push(mount);
+ }
+ }
+
+ return mountRoot;
+ },unmount:function (mountpoint) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ if (!FS.isMountpoint(lookup.node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ // destroy the nodes for this mount, and all its child mounts
+ var node = lookup.node;
+ var mount = node.mounted;
+ var mounts = FS.getMounts(mount);
+
+ Object.keys(FS.nameTable).forEach(function (hash) {
+ var current = FS.nameTable[hash];
+
+ while (current) {
+ var next = current.name_next;
+
+ if (mounts.indexOf(current.mount) !== -1) {
+ FS.destroyNode(current);
+ }
+
+ current = next;
+ }
+ });
+
+ // no longer a mountpoint
+ node.mounted = null;
+
+ // remove this mount from the child mounts
+ var idx = node.mount.mounts.indexOf(mount);
+ assert(idx !== -1);
+ node.mount.mounts.splice(idx, 1);
+ },lookup:function (parent, name) {
+ return parent.node_ops.lookup(parent, name);
+ },mknod:function (path, mode, dev) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var err = FS.mayCreate(parent, name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.mknod) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.mknod(parent, name, mode, dev);
+ },create:function (path, mode) {
+ mode = mode !== undefined ? mode : 438 /* 0666 */;
+ mode &= 4095;
+ mode |= 32768;
+ return FS.mknod(path, mode, 0);
+ },mkdir:function (path, mode) {
+ mode = mode !== undefined ? mode : 511 /* 0777 */;
+ mode &= 511 | 512;
+ mode |= 16384;
+ return FS.mknod(path, mode, 0);
+ },mkdev:function (path, mode, dev) {
+ if (typeof(dev) === 'undefined') {
+ dev = mode;
+ mode = 438 /* 0666 */;
+ }
+ mode |= 8192;
+ return FS.mknod(path, mode, dev);
+ },symlink:function (oldpath, newpath) {
+ var lookup = FS.lookupPath(newpath, { parent: true });
+ var parent = lookup.node;
+ var newname = PATH.basename(newpath);
+ var err = FS.mayCreate(parent, newname);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.symlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.symlink(parent, newname, oldpath);
+ },rename:function (old_path, new_path) {
+ var old_dirname = PATH.dirname(old_path);
+ var new_dirname = PATH.dirname(new_path);
+ var old_name = PATH.basename(old_path);
+ var new_name = PATH.basename(new_path);
+ // parents must exist
+ var lookup, old_dir, new_dir;
+ try {
+ lookup = FS.lookupPath(old_path, { parent: true });
+ old_dir = lookup.node;
+ lookup = FS.lookupPath(new_path, { parent: true });
+ new_dir = lookup.node;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // need to be part of the same mount
+ if (old_dir.mount !== new_dir.mount) {
+ throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
+ }
+ // source must exist
+ var old_node = FS.lookupNode(old_dir, old_name);
+ // old path should not be an ancestor of the new path
+ var relative = PATH.relative(old_path, new_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ // new path should not be an ancestor of the old path
+ relative = PATH.relative(new_path, old_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ // see if the new path already exists
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ // not fatal
+ }
+ // early out if nothing needs to change
+ if (old_node === new_node) {
+ return;
+ }
+ // we'll need to delete the old entry
+ var isdir = FS.isDir(old_node.mode);
+ var err = FS.mayDelete(old_dir, old_name, isdir);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // need delete permissions if we'll be overwriting.
+ // need create permissions if new doesn't already exist.
+ err = new_node ?
+ FS.mayDelete(new_dir, new_name, isdir) :
+ FS.mayCreate(new_dir, new_name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!old_dir.node_ops.rename) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // if we are going to change the parent, check write permissions
+ if (new_dir !== old_dir) {
+ err = FS.nodePermissions(old_dir, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ }
+ // remove the node from the lookup hash
+ FS.hashRemoveNode(old_node);
+ // do the underlying fs rename
+ try {
+ old_dir.node_ops.rename(old_node, new_dir, new_name);
+ } catch (e) {
+ throw e;
+ } finally {
+ // add the node back to the hash (in case node_ops.rename
+ // changed its name)
+ FS.hashAddNode(old_node);
+ }
+ },rmdir:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, true);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.rmdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.rmdir(parent, name);
+ FS.destroyNode(node);
+ },readdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ if (!node.node_ops.readdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ return node.node_ops.readdir(node);
+ },unlink:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, false);
+ if (err) {
+ // POSIX says unlink should set EPERM, not EISDIR
+ if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.unlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.unlink(parent, name);
+ FS.destroyNode(node);
+ },readlink:function (path) {
+ var lookup = FS.lookupPath(path);
+ var link = lookup.node;
+ if (!link.node_ops.readlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return link.node_ops.readlink(link);
+ },stat:function (path, dontFollow) {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ var node = lookup.node;
+ if (!node.node_ops.getattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return node.node_ops.getattr(node);
+ },lstat:function (path) {
+ return FS.stat(path, true);
+ },chmod:function (path, mode, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ mode: (mode & 4095) | (node.mode & ~4095),
+ timestamp: Date.now()
+ });
+ },lchmod:function (path, mode) {
+ FS.chmod(path, mode, true);
+ },fchmod:function (fd, mode) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chmod(stream.node, mode);
+ },chown:function (path, uid, gid, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ timestamp: Date.now()
+ // we ignore the uid / gid for now
+ });
+ },lchown:function (path, uid, gid) {
+ FS.chown(path, uid, gid, true);
+ },fchown:function (fd, uid, gid) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chown(stream.node, uid, gid);
+ },truncate:function (path, len) {
+ if (len < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: true });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!FS.isFile(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var err = FS.nodePermissions(node, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ node.node_ops.setattr(node, {
+ size: len,
+ timestamp: Date.now()
+ });
+ },ftruncate:function (fd, len) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ FS.truncate(stream.node, len);
+ },utime:function (path, atime, mtime) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ node.node_ops.setattr(node, {
+ timestamp: Math.max(atime, mtime)
+ });
+ },open:function (path, flags, mode, fd_start, fd_end) {
+ flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
+ mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
+ if ((flags & 64)) {
+ mode = (mode & 4095) | 32768;
+ } else {
+ mode = 0;
+ }
+ var node;
+ if (typeof path === 'object') {
+ node = path;
+ } else {
+ path = PATH.normalize(path);
+ try {
+ var lookup = FS.lookupPath(path, {
+ follow: !(flags & 131072)
+ });
+ node = lookup.node;
+ } catch (e) {
+ // ignore
+ }
+ }
+ // perhaps we need to create the node
+ if ((flags & 64)) {
+ if (node) {
+ // if O_CREAT and O_EXCL are set, error out if the node already exists
+ if ((flags & 128)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
+ }
+ } else {
+ // node doesn't exist, try to create it
+ node = FS.mknod(path, mode, 0);
+ }
+ }
+ if (!node) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
+ }
+ // can't truncate a device
+ if (FS.isChrdev(node.mode)) {
+ flags &= ~512;
+ }
+ // check permissions
+ var err = FS.mayOpen(node, flags);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // do truncation if necessary
+ if ((flags & 512)) {
+ FS.truncate(node, 0);
+ }
+ // we've already handled these, don't pass down to the underlying vfs
+ flags &= ~(128 | 512);
+
+ // register the stream with the filesystem
+ var stream = FS.createStream({
+ node: node,
+ path: FS.getPath(node), // we want the absolute path to the node
+ flags: flags,
+ seekable: true,
+ position: 0,
+ stream_ops: node.stream_ops,
+ // used by the file family libc calls (fopen, fwrite, ferror, etc.)
+ ungotten: [],
+ error: false
+ }, fd_start, fd_end);
+ // call the new stream's open function
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ if (Module['logReadFiles'] && !(flags & 1)) {
+ if (!FS.readFiles) FS.readFiles = {};
+ if (!(path in FS.readFiles)) {
+ FS.readFiles[path] = 1;
+ Module['printErr']('read file: ' + path);
+ }
+ }
+ return stream;
+ },close:function (stream) {
+ try {
+ if (stream.stream_ops.close) {
+ stream.stream_ops.close(stream);
+ }
+ } catch (e) {
+ throw e;
+ } finally {
+ FS.closeStream(stream.fd);
+ }
+ },llseek:function (stream, offset, whence) {
+ if (!stream.seekable || !stream.stream_ops.llseek) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ return stream.stream_ops.llseek(stream, offset, whence);
+ },read:function (stream, buffer, offset, length, position) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.read) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
+ if (!seeking) stream.position += bytesRead;
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.write) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ if (stream.flags & 1024) {
+ // seek to the end before writing in append mode
+ FS.llseek(stream, 0, 2);
+ }
+ var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
+ if (!seeking) stream.position += bytesWritten;
+ return bytesWritten;
+ },allocate:function (stream, offset, length) {
+ if (offset < 0 || length <= 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ if (!stream.stream_ops.allocate) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ stream.stream_ops.allocate(stream, offset, length);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ // TODO if PROT is PROT_WRITE, make sure we have write access
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EACCES);
+ }
+ if (!stream.stream_ops.mmap) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
+ },ioctl:function (stream, cmd, arg) {
+ if (!stream.stream_ops.ioctl) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
+ }
+ return stream.stream_ops.ioctl(stream, cmd, arg);
+ },readFile:function (path, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'r';
+ opts.encoding = opts.encoding || 'binary';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var ret;
+ var stream = FS.open(path, opts.flags);
+ var stat = FS.stat(path);
+ var length = stat.size;
+ var buf = new Uint8Array(length);
+ FS.read(stream, buf, 0, length, 0);
+ if (opts.encoding === 'utf8') {
+ ret = '';
+ var utf8 = new Runtime.UTF8Processor();
+ for (var i = 0; i < length; i++) {
+ ret += utf8.processCChar(buf[i]);
+ }
+ } else if (opts.encoding === 'binary') {
+ ret = buf;
+ }
+ FS.close(stream);
+ return ret;
+ },writeFile:function (path, data, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'w';
+ opts.encoding = opts.encoding || 'utf8';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var stream = FS.open(path, opts.flags, opts.mode);
+ if (opts.encoding === 'utf8') {
+ var utf8 = new Runtime.UTF8Processor();
+ var buf = new Uint8Array(utf8.processJSString(data));
+ FS.write(stream, buf, 0, buf.length, 0, opts.canOwn);
+ } else if (opts.encoding === 'binary') {
+ FS.write(stream, data, 0, data.length, 0, opts.canOwn);
+ }
+ FS.close(stream);
+ },cwd:function () {
+ return FS.currentPath;
+ },chdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ if (!FS.isDir(lookup.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ var err = FS.nodePermissions(lookup.node, 'x');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ FS.currentPath = lookup.path;
+ },createDefaultDirectories:function () {
+ FS.mkdir('/tmp');
+ },createDefaultDevices:function () {
+ // create /dev
+ FS.mkdir('/dev');
+ // setup /dev/null
+ FS.registerDevice(FS.makedev(1, 3), {
+ read: function() { return 0; },
+ write: function() { return 0; }
+ });
+ FS.mkdev('/dev/null', FS.makedev(1, 3));
+ // setup /dev/tty and /dev/tty1
+ // stderr needs to print output using Module['printErr']
+ // so we register a second tty just for it.
+ TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
+ TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
+ FS.mkdev('/dev/tty', FS.makedev(5, 0));
+ FS.mkdev('/dev/tty1', FS.makedev(6, 0));
+ // we're not going to emulate the actual shm device,
+ // just create the tmp dirs that reside in it commonly
+ FS.mkdir('/dev/shm');
+ FS.mkdir('/dev/shm/tmp');
+ },createStandardStreams:function () {
+ // TODO deprecate the old functionality of a single
+ // input / output callback and that utilizes FS.createDevice
+ // and instead require a unique set of stream ops
+
+ // by default, we symlink the standard streams to the
+ // default tty devices. however, if the standard streams
+ // have been overwritten we create a unique device for
+ // them instead.
+ if (Module['stdin']) {
+ FS.createDevice('/dev', 'stdin', Module['stdin']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdin');
+ }
+ if (Module['stdout']) {
+ FS.createDevice('/dev', 'stdout', null, Module['stdout']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdout');
+ }
+ if (Module['stderr']) {
+ FS.createDevice('/dev', 'stderr', null, Module['stderr']);
+ } else {
+ FS.symlink('/dev/tty1', '/dev/stderr');
+ }
+
+ // open default streams for the stdin, stdout and stderr devices
+ var stdin = FS.open('/dev/stdin', 'r');
+ HEAP32[((_stdin)>>2)]=FS.getPtrForStream(stdin);
+ assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
+
+ var stdout = FS.open('/dev/stdout', 'w');
+ HEAP32[((_stdout)>>2)]=FS.getPtrForStream(stdout);
+ assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
+
+ var stderr = FS.open('/dev/stderr', 'w');
+ HEAP32[((_stderr)>>2)]=FS.getPtrForStream(stderr);
+ assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
+ },ensureErrnoError:function () {
+ if (FS.ErrnoError) return;
+ FS.ErrnoError = function ErrnoError(errno) {
+ this.errno = errno;
+ for (var key in ERRNO_CODES) {
+ if (ERRNO_CODES[key] === errno) {
+ this.code = key;
+ break;
+ }
+ }
+ this.message = ERRNO_MESSAGES[errno];
+ };
+ FS.ErrnoError.prototype = new Error();
+ FS.ErrnoError.prototype.constructor = FS.ErrnoError;
+ // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
+ [ERRNO_CODES.ENOENT].forEach(function(code) {
+ FS.genericErrors[code] = new FS.ErrnoError(code);
+ FS.genericErrors[code].stack = '<generic error, no stack>';
+ });
+ },staticInit:function () {
+ FS.ensureErrnoError();
+
+ FS.nameTable = new Array(4096);
+
+ FS.mount(MEMFS, {}, '/');
+
+ FS.createDefaultDirectories();
+ FS.createDefaultDevices();
+ },init:function (input, output, error) {
+ assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
+ FS.init.initialized = true;
+
+ FS.ensureErrnoError();
+
+ // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
+ Module['stdin'] = input || Module['stdin'];
+ Module['stdout'] = output || Module['stdout'];
+ Module['stderr'] = error || Module['stderr'];
+
+ FS.createStandardStreams();
+ },quit:function () {
+ FS.init.initialized = false;
+ for (var i = 0; i < FS.streams.length; i++) {
+ var stream = FS.streams[i];
+ if (!stream) {
+ continue;
+ }
+ FS.close(stream);
+ }
+ },getMode:function (canRead, canWrite) {
+ var mode = 0;
+ if (canRead) mode |= 292 | 73;
+ if (canWrite) mode |= 146;
+ return mode;
+ },joinPath:function (parts, forceRelative) {
+ var path = PATH.join.apply(null, parts);
+ if (forceRelative && path[0] == '/') path = path.substr(1);
+ return path;
+ },absolutePath:function (relative, base) {
+ return PATH.resolve(base, relative);
+ },standardizePath:function (path) {
+ return PATH.normalize(path);
+ },findObject:function (path, dontResolveLastLink) {
+ var ret = FS.analyzePath(path, dontResolveLastLink);
+ if (ret.exists) {
+ return ret.object;
+ } else {
+ ___setErrNo(ret.error);
+ return null;
+ }
+ },analyzePath:function (path, dontResolveLastLink) {
+ // operate from within the context of the symlink's target
+ try {
+ var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ path = lookup.path;
+ } catch (e) {
+ }
+ var ret = {
+ isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
+ parentExists: false, parentPath: null, parentObject: null
+ };
+ try {
+ var lookup = FS.lookupPath(path, { parent: true });
+ ret.parentExists = true;
+ ret.parentPath = lookup.path;
+ ret.parentObject = lookup.node;
+ ret.name = PATH.basename(path);
+ lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ ret.exists = true;
+ ret.path = lookup.path;
+ ret.object = lookup.node;
+ ret.name = lookup.node.name;
+ ret.isRoot = lookup.path === '/';
+ } catch (e) {
+ ret.error = e.errno;
+ };
+ return ret;
+ },createFolder:function (parent, name, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.mkdir(path, mode);
+ },createPath:function (parent, path, canRead, canWrite) {
+ parent = typeof parent === 'string' ? parent : FS.getPath(parent);
+ var parts = path.split('/').reverse();
+ while (parts.length) {
+ var part = parts.pop();
+ if (!part) continue;
+ var current = PATH.join2(parent, part);
+ try {
+ FS.mkdir(current);
+ } catch (e) {
+ // ignore EEXIST
+ }
+ parent = current;
+ }
+ return current;
+ },createFile:function (parent, name, properties, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.create(path, mode);
+ },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
+ var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
+ var mode = FS.getMode(canRead, canWrite);
+ var node = FS.create(path, mode);
+ if (data) {
+ if (typeof data === 'string') {
+ var arr = new Array(data.length);
+ for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
+ data = arr;
+ }
+ // make sure we can write to the file
+ FS.chmod(node, mode | 146);
+ var stream = FS.open(node, 'w');
+ FS.write(stream, data, 0, data.length, 0, canOwn);
+ FS.close(stream);
+ FS.chmod(node, mode);
+ }
+ return node;
+ },createDevice:function (parent, name, input, output) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(!!input, !!output);
+ if (!FS.createDevice.major) FS.createDevice.major = 64;
+ var dev = FS.makedev(FS.createDevice.major++, 0);
+ // Create a fake device that a set of stream ops to emulate
+ // the old behavior.
+ FS.registerDevice(dev, {
+ open: function(stream) {
+ stream.seekable = false;
+ },
+ close: function(stream) {
+ // flush any pending line data
+ if (output && output.buffer && output.buffer.length) {
+ output(10);
+ }
+ },
+ read: function(stream, buffer, offset, length, pos /* ignored */) {
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = input();
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },
+ write: function(stream, buffer, offset, length, pos) {
+ for (var i = 0; i < length; i++) {
+ try {
+ output(buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }
+ });
+ return FS.mkdev(path, mode, dev);
+ },createLink:function (parent, name, target, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ return FS.symlink(target, path);
+ },forceLoadFile:function (obj) {
+ if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
+ var success = true;
+ if (typeof XMLHttpRequest !== 'undefined') {
+ throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
+ } else if (Module['read']) {
+ // Command-line.
+ try {
+ // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
+ // read() will try to parse UTF8.
+ obj.contents = intArrayFromString(Module['read'](obj.url), true);
+ } catch (e) {
+ success = false;
+ }
+ } else {
+ throw new Error('Cannot load without read() or XMLHttpRequest.');
+ }
+ if (!success) ___setErrNo(ERRNO_CODES.EIO);
+ return success;
+ },createLazyFile:function (parent, name, url, canRead, canWrite) {
+ // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
+ function LazyUint8Array() {
+ this.lengthKnown = false;
+ this.chunks = []; // Loaded chunks. Index is the chunk number
+ }
+ LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
+ if (idx > this.length-1 || idx < 0) {
+ return undefined;
+ }
+ var chunkOffset = idx % this.chunkSize;
+ var chunkNum = Math.floor(idx / this.chunkSize);
+ return this.getter(chunkNum)[chunkOffset];
+ }
+ LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
+ this.getter = getter;
+ }
+ LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
+ // Find length
+ var xhr = new XMLHttpRequest();
+ xhr.open('HEAD', url, false);
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ var datalength = Number(xhr.getResponseHeader("Content-length"));
+ var header;
+ var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
+ var chunkSize = 1024*1024; // Chunk size in bytes
+
+ if (!hasByteServing) chunkSize = datalength;
+
+ // Function to get a range from the remote URL.
+ var doXHR = (function(from, to) {
+ if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
+ if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
+
+ // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
+
+ // Some hints to the browser that we want binary data.
+ if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
+ if (xhr.overrideMimeType) {
+ xhr.overrideMimeType('text/plain; charset=x-user-defined');
+ }
+
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ if (xhr.response !== undefined) {
+ return new Uint8Array(xhr.response || []);
+ } else {
+ return intArrayFromString(xhr.responseText || '', true);
+ }
+ });
+ var lazyArray = this;
+ lazyArray.setDataGetter(function(chunkNum) {
+ var start = chunkNum * chunkSize;
+ var end = (chunkNum+1) * chunkSize - 1; // including this byte
+ end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
+ lazyArray.chunks[chunkNum] = doXHR(start, end);
+ }
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
+ return lazyArray.chunks[chunkNum];
+ });
+
+ this._length = datalength;
+ this._chunkSize = chunkSize;
+ this.lengthKnown = true;
+ }
+ if (typeof XMLHttpRequest !== 'undefined') {
+ if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
+ var lazyArray = new LazyUint8Array();
+ Object.defineProperty(lazyArray, "length", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._length;
+ }
+ });
+ Object.defineProperty(lazyArray, "chunkSize", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._chunkSize;
+ }
+ });
+
+ var properties = { isDevice: false, contents: lazyArray };
+ } else {
+ var properties = { isDevice: false, url: url };
+ }
+
+ var node = FS.createFile(parent, name, properties, canRead, canWrite);
+ // This is a total hack, but I want to get this lazy file code out of the
+ // core of MEMFS. If we want to keep this lazy file concept I feel it should
+ // be its own thin LAZYFS proxying calls to MEMFS.
+ if (properties.contents) {
+ node.contents = properties.contents;
+ } else if (properties.url) {
+ node.contents = null;
+ node.url = properties.url;
+ }
+ // override each stream op with one that tries to force load the lazy file first
+ var stream_ops = {};
+ var keys = Object.keys(node.stream_ops);
+ keys.forEach(function(key) {
+ var fn = node.stream_ops[key];
+ stream_ops[key] = function forceLoadLazyFile() {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ return fn.apply(null, arguments);
+ };
+ });
+ // use a custom read function
+ stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (contents.slice) { // normal array
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ } else {
+ for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
+ buffer[offset + i] = contents.get(position + i);
+ }
+ }
+ return size;
+ };
+ node.stream_ops = stream_ops;
+ return node;
+ },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {
+ Browser.init();
+ // TODO we should allow people to just pass in a complete filename instead
+ // of parent and name being that we just join them anyways
+ var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
+ function processData(byteArray) {
+ function finish(byteArray) {
+ if (!dontCreateFile) {
+ FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
+ }
+ if (onload) onload();
+ removeRunDependency('cp ' + fullname);
+ }
+ var handled = false;
+ Module['preloadPlugins'].forEach(function(plugin) {
+ if (handled) return;
+ if (plugin['canHandle'](fullname)) {
+ plugin['handle'](byteArray, fullname, finish, function() {
+ if (onerror) onerror();
+ removeRunDependency('cp ' + fullname);
+ });
+ handled = true;
+ }
+ });
+ if (!handled) finish(byteArray);
+ }
+ addRunDependency('cp ' + fullname);
+ if (typeof url == 'string') {
+ Browser.asyncLoad(url, function(byteArray) {
+ processData(byteArray);
+ }, onerror);
+ } else {
+ processData(url);
+ }
+ },indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_NAME:function () {
+ return 'EM_FS_' + window.location.pathname;
+ },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
+ console.log('creating db');
+ var db = openRequest.result;
+ db.createObjectStore(FS.DB_STORE_NAME);
+ };
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var putRequest = files.put(FS.analyzePath(path).object.contents, path);
+ putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
+ putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ },loadFilesFromDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = onerror; // no database to load from
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ try {
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
+ } catch(e) {
+ onerror(e);
+ return;
+ }
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var getRequest = files.get(path);
+ getRequest.onsuccess = function getRequest_onsuccess() {
+ if (FS.analyzePath(path).exists) {
+ FS.unlink(path);
+ }
+ FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
+ ok++;
+ if (ok + fail == total) finish();
+ };
+ getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ }};var PATH={splitPath:function (filename) {
+ var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
+ return splitPathRe.exec(filename).slice(1);
+ },normalizeArray:function (parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length - 1; i >= 0; i--) {
+ var last = parts[i];
+ if (last === '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+ return parts;
+ },normalize:function (path) {
+ var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.substr(-1) === '/';
+ // Normalize the path
+ path = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+ return (isAbsolute ? '/' : '') + path;
+ },dirname:function (path) {
+ var result = PATH.splitPath(path),
+ root = result[0],
+ dir = result[1];
+ if (!root && !dir) {
+ // No dirname whatsoever
+ return '.';
+ }
+ if (dir) {
+ // It has a dirname, strip trailing slash
+ dir = dir.substr(0, dir.length - 1);
+ }
+ return root + dir;
+ },basename:function (path) {
+ // EMSCRIPTEN return '/'' for '/', not an empty string
+ if (path === '/') return '/';
+ var lastSlash = path.lastIndexOf('/');
+ if (lastSlash === -1) return path;
+ return path.substr(lastSlash+1);
+ },extname:function (path) {
+ return PATH.splitPath(path)[3];
+ },join:function () {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return PATH.normalize(paths.join('/'));
+ },join2:function (l, r) {
+ return PATH.normalize(l + '/' + r);
+ },resolve:function () {
+ var resolvedPath = '',
+ resolvedAbsolute = false;
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0) ? arguments[i] : FS.cwd();
+ // Skip empty and invalid entries
+ if (typeof path !== 'string') {
+ throw new TypeError('Arguments to path.resolve must be strings');
+ } else if (!path) {
+ continue;
+ }
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+ }
+ // At this point the path should be resolved to a full absolute path, but
+ // handle relative paths to be safe (might happen when process.cwd() fails)
+ resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+ },relative:function (from, to) {
+ from = PATH.resolve(from).substr(1);
+ to = PATH.resolve(to).substr(1);
+ function trim(arr) {
+ var start = 0;
+ for (; start < arr.length; start++) {
+ if (arr[start] !== '') break;
+ }
+ var end = arr.length - 1;
+ for (; end >= 0; end--) {
+ if (arr[end] !== '') break;
+ }
+ if (start > end) return [];
+ return arr.slice(start, end - start + 1);
+ }
+ var fromParts = trim(from.split('/'));
+ var toParts = trim(to.split('/'));
+ var length = Math.min(fromParts.length, toParts.length);
+ var samePartsLength = length;
+ for (var i = 0; i < length; i++) {
+ if (fromParts[i] !== toParts[i]) {
+ samePartsLength = i;
+ break;
+ }
+ }
+ var outputParts = [];
+ for (var i = samePartsLength; i < fromParts.length; i++) {
+ outputParts.push('..');
+ }
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
+ return outputParts.join('/');
+ }};var Browser={mainLoop:{scheduler:null,method:"",shouldPause:false,paused:false,queue:[],pause:function () {
+ Browser.mainLoop.shouldPause = true;
+ },resume:function () {
+ if (Browser.mainLoop.paused) {
+ Browser.mainLoop.paused = false;
+ Browser.mainLoop.scheduler();
+ }
+ Browser.mainLoop.shouldPause = false;
+ },updateStatus:function () {
+ if (Module['setStatus']) {
+ var message = Module['statusMessage'] || 'Please wait...';
+ var remaining = Browser.mainLoop.remainingBlockers;
+ var expected = Browser.mainLoop.expectedBlockers;
+ if (remaining) {
+ if (remaining < expected) {
+ Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');
+ } else {
+ Module['setStatus'](message);
+ }
+ } else {
+ Module['setStatus']('');
+ }
+ }
+ }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {
+ if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers
+
+ if (Browser.initted || ENVIRONMENT_IS_WORKER) return;
+ Browser.initted = true;
+
+ try {
+ new Blob();
+ Browser.hasBlobConstructor = true;
+ } catch(e) {
+ Browser.hasBlobConstructor = false;
+ console.log("warning: no blob constructor, cannot create blobs with mimetypes");
+ }
+ Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null));
+ Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
+ if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {
+ console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
+ Module.noImageDecoding = true;
+ }
+
+ // Support for plugins that can process preloaded files. You can add more of these to
+ // your app by creating and appending to Module.preloadPlugins.
+ //
+ // Each plugin is asked if it can handle a file based on the file's name. If it can,
+ // it is given the file's raw data. When it is done, it calls a callback with the file's
+ // (possibly modified) data. For example, a plugin might decompress a file, or it
+ // might create some side data structure for use later (like an Image element, etc.).
+
+ var imagePlugin = {};
+ imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
+ return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
+ };
+ imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
+ var b = null;
+ if (Browser.hasBlobConstructor) {
+ try {
+ b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ if (b.size !== byteArray.length) { // Safari bug #118630
+ // Safari's Blob can only take an ArrayBuffer
+ b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
+ }
+ } catch(e) {
+ Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');
+ }
+ }
+ if (!b) {
+ var bb = new Browser.BlobBuilder();
+ bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range
+ b = bb.getBlob();
+ }
+ var url = Browser.URLObject.createObjectURL(b);
+ var img = new Image();
+ img.onload = function img_onload() {
+ assert(img.complete, 'Image ' + name + ' could not be decoded');
+ var canvas = document.createElement('canvas');
+ canvas.width = img.width;
+ canvas.height = img.height;
+ var ctx = canvas.getContext('2d');
+ ctx.drawImage(img, 0, 0);
+ Module["preloadedImages"][name] = canvas;
+ Browser.URLObject.revokeObjectURL(url);
+ if (onload) onload(byteArray);
+ };
+ img.onerror = function img_onerror(event) {
+ console.log('Image ' + url + ' could not be decoded');
+ if (onerror) onerror();
+ };
+ img.src = url;
+ };
+ Module['preloadPlugins'].push(imagePlugin);
+
+ var audioPlugin = {};
+ audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
+ return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
+ };
+ audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
+ var done = false;
+ function finish(audio) {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = audio;
+ if (onload) onload(byteArray);
+ }
+ function fail() {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = new Audio(); // empty shim
+ if (onerror) onerror();
+ }
+ if (Browser.hasBlobConstructor) {
+ try {
+ var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ } catch(e) {
+ return fail();
+ }
+ var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
+ var audio = new Audio();
+ audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
+ audio.onerror = function audio_onerror(event) {
+ if (done) return;
+ console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
+ function encode64(data) {
+ var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ var PAD = '=';
+ var ret = '';
+ var leftchar = 0;
+ var leftbits = 0;
+ for (var i = 0; i < data.length; i++) {
+ leftchar = (leftchar << 8) | data[i];
+ leftbits += 8;
+ while (leftbits >= 6) {
+ var curr = (leftchar >> (leftbits-6)) & 0x3f;
+ leftbits -= 6;
+ ret += BASE[curr];
+ }
+ }
+ if (leftbits == 2) {
+ ret += BASE[(leftchar&3) << 4];
+ ret += PAD + PAD;
+ } else if (leftbits == 4) {
+ ret += BASE[(leftchar&0xf) << 2];
+ ret += PAD;
+ }
+ return ret;
+ }
+ audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);
+ finish(audio); // we don't wait for confirmation this worked - but it's worth trying
+ };
+ audio.src = url;
+ // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror
+ Browser.safeSetTimeout(function() {
+ finish(audio); // try to use it even though it is not necessarily ready to play
+ }, 10000);
+ } else {
+ return fail();
+ }
+ };
+ Module['preloadPlugins'].push(audioPlugin);
+
+ // Canvas event setup
+
+ var canvas = Module['canvas'];
+
+ // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module
+ // Module['forcedAspectRatio'] = 4 / 3;
+
+ canvas.requestPointerLock = canvas['requestPointerLock'] ||
+ canvas['mozRequestPointerLock'] ||
+ canvas['webkitRequestPointerLock'] ||
+ canvas['msRequestPointerLock'] ||
+ function(){};
+ canvas.exitPointerLock = document['exitPointerLock'] ||
+ document['mozExitPointerLock'] ||
+ document['webkitExitPointerLock'] ||
+ document['msExitPointerLock'] ||
+ function(){}; // no-op if function does not exist
+ canvas.exitPointerLock = canvas.exitPointerLock.bind(document);
+
+ function pointerLockChange() {
+ Browser.pointerLock = document['pointerLockElement'] === canvas ||
+ document['mozPointerLockElement'] === canvas ||
+ document['webkitPointerLockElement'] === canvas ||
+ document['msPointerLockElement'] === canvas;
+ }
+
+ document.addEventListener('pointerlockchange', pointerLockChange, false);
+ document.addEventListener('mozpointerlockchange', pointerLockChange, false);
+ document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
+ document.addEventListener('mspointerlockchange', pointerLockChange, false);
+
+ if (Module['elementPointerLock']) {
+ canvas.addEventListener("click", function(ev) {
+ if (!Browser.pointerLock && canvas.requestPointerLock) {
+ canvas.requestPointerLock();
+ ev.preventDefault();
+ }
+ }, false);
+ }
+ },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) {
+ var ctx;
+ var errorInfo = '?';
+ function onContextCreationError(event) {
+ errorInfo = event.statusMessage || errorInfo;
+ }
+ try {
+ if (useWebGL) {
+ var contextAttributes = {
+ antialias: false,
+ alpha: false
+ };
+
+ if (webGLContextAttributes) {
+ for (var attribute in webGLContextAttributes) {
+ contextAttributes[attribute] = webGLContextAttributes[attribute];
+ }
+ }
+
+
+ canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
+ try {
+ ['experimental-webgl', 'webgl'].some(function(webglId) {
+ return ctx = canvas.getContext(webglId, contextAttributes);
+ });
+ } finally {
+ canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
+ }
+ } else {
+ ctx = canvas.getContext('2d');
+ }
+ if (!ctx) throw ':(';
+ } catch (e) {
+ Module.print('Could not create canvas: ' + [errorInfo, e]);
+ return null;
+ }
+ if (useWebGL) {
+ // Set the background of the WebGL canvas to black
+ canvas.style.backgroundColor = "black";
+
+ // Warn on context loss
+ canvas.addEventListener('webglcontextlost', function(event) {
+ alert('WebGL context lost. You will need to reload the page.');
+ }, false);
+ }
+ if (setInModule) {
+ GLctx = Module.ctx = ctx;
+ Module.useWebGL = useWebGL;
+ Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
+ Browser.init();
+ }
+ return ctx;
+ },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {
+ Browser.lockPointer = lockPointer;
+ Browser.resizeCanvas = resizeCanvas;
+ if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;
+ if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;
+
+ var canvas = Module['canvas'];
+ function fullScreenChange() {
+ Browser.isFullScreen = false;
+ var canvasContainer = canvas.parentNode;
+ if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvasContainer) {
+ canvas.cancelFullScreen = document['cancelFullScreen'] ||
+ document['mozCancelFullScreen'] ||
+ document['webkitCancelFullScreen'] ||
+ document['msExitFullscreen'] ||
+ document['exitFullscreen'] ||
+ function() {};
+ canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);
+ if (Browser.lockPointer) canvas.requestPointerLock();
+ Browser.isFullScreen = true;
+ if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();
+ } else {
+
+ // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen
+ canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
+ canvasContainer.parentNode.removeChild(canvasContainer);
+
+ if (Browser.resizeCanvas) Browser.setWindowedCanvasSize();
+ }
+ if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);
+ Browser.updateCanvasDimensions(canvas);
+ }
+
+ if (!Browser.fullScreenHandlersInstalled) {
+ Browser.fullScreenHandlersInstalled = true;
+ document.addEventListener('fullscreenchange', fullScreenChange, false);
+ document.addEventListener('mozfullscreenchange', fullScreenChange, false);
+ document.addEventListener('webkitfullscreenchange', fullScreenChange, false);
+ document.addEventListener('MSFullscreenChange', fullScreenChange, false);
+ }
+
+ // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root
+ var canvasContainer = document.createElement("div");
+ canvas.parentNode.insertBefore(canvasContainer, canvas);
+ canvasContainer.appendChild(canvas);
+
+ // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size)
+ canvasContainer.requestFullScreen = canvasContainer['requestFullScreen'] ||
+ canvasContainer['mozRequestFullScreen'] ||
+ canvasContainer['msRequestFullscreen'] ||
+ (canvasContainer['webkitRequestFullScreen'] ? function() { canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);
+ canvasContainer.requestFullScreen();
+ },requestAnimationFrame:function requestAnimationFrame(func) {
+ if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
+ setTimeout(func, 1000/60);
+ } else {
+ if (!window.requestAnimationFrame) {
+ window.requestAnimationFrame = window['requestAnimationFrame'] ||
+ window['mozRequestAnimationFrame'] ||
+ window['webkitRequestAnimationFrame'] ||
+ window['msRequestAnimationFrame'] ||
+ window['oRequestAnimationFrame'] ||
+ window['setTimeout'];
+ }
+ window.requestAnimationFrame(func);
+ }
+ },safeCallback:function (func) {
+ return function() {
+ if (!ABORT) return func.apply(null, arguments);
+ };
+ },safeRequestAnimationFrame:function (func) {
+ return Browser.requestAnimationFrame(function() {
+ if (!ABORT) func();
+ });
+ },safeSetTimeout:function (func, timeout) {
+ return setTimeout(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },safeSetInterval:function (func, timeout) {
+ return setInterval(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },getMimetype:function (name) {
+ return {
+ 'jpg': 'image/jpeg',
+ 'jpeg': 'image/jpeg',
+ 'png': 'image/png',
+ 'bmp': 'image/bmp',
+ 'ogg': 'audio/ogg',
+ 'wav': 'audio/wav',
+ 'mp3': 'audio/mpeg'
+ }[name.substr(name.lastIndexOf('.')+1)];
+ },getUserMedia:function (func) {
+ if(!window.getUserMedia) {
+ window.getUserMedia = navigator['getUserMedia'] ||
+ navigator['mozGetUserMedia'];
+ }
+ window.getUserMedia(func);
+ },getMovementX:function (event) {
+ return event['movementX'] ||
+ event['mozMovementX'] ||
+ event['webkitMovementX'] ||
+ 0;
+ },getMovementY:function (event) {
+ return event['movementY'] ||
+ event['mozMovementY'] ||
+ event['webkitMovementY'] ||
+ 0;
+ },getMouseWheelDelta:function (event) {
+ return Math.max(-1, Math.min(1, event.type === 'DOMMouseScroll' ? event.detail : -event.wheelDelta));
+ },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup
+ if (Browser.pointerLock) {
+ // When the pointer is locked, calculate the coordinates
+ // based on the movement of the mouse.
+ // Workaround for Firefox bug 764498
+ if (event.type != 'mousemove' &&
+ ('mozMovementX' in event)) {
+ Browser.mouseMovementX = Browser.mouseMovementY = 0;
+ } else {
+ Browser.mouseMovementX = Browser.getMovementX(event);
+ Browser.mouseMovementY = Browser.getMovementY(event);
+ }
+
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
+ Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
+ } else {
+ // just add the mouse delta to the current absolut mouse position
+ // FIXME: ideally this should be clamped against the canvas size and zero
+ Browser.mouseX += Browser.mouseMovementX;
+ Browser.mouseY += Browser.mouseMovementY;
+ }
+ } else {
+ // Otherwise, calculate the movement based on the changes
+ // in the coordinates.
+ var rect = Module["canvas"].getBoundingClientRect();
+ var x, y;
+
+ // Neither .scrollX or .pageXOffset are defined in a spec, but
+ // we prefer .scrollX because it is currently in a spec draft.
+ // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
+ var scrollX = ((typeof window.scrollX !== 'undefined') ? window.scrollX : window.pageXOffset);
+ var scrollY = ((typeof window.scrollY !== 'undefined') ? window.scrollY : window.pageYOffset);
+ if (event.type == 'touchstart' ||
+ event.type == 'touchend' ||
+ event.type == 'touchmove') {
+ var t = event.touches.item(0);
+ if (t) {
+ x = t.pageX - (scrollX + rect.left);
+ y = t.pageY - (scrollY + rect.top);
+ } else {
+ return;
+ }
+ } else {
+ x = event.pageX - (scrollX + rect.left);
+ y = event.pageY - (scrollY + rect.top);
+ }
+
+ // the canvas might be CSS-scaled compared to its backbuffer;
+ // SDL-using content will want mouse coordinates in terms
+ // of backbuffer units.
+ var cw = Module["canvas"].width;
+ var ch = Module["canvas"].height;
+ x = x * (cw / rect.width);
+ y = y * (ch / rect.height);
+
+ Browser.mouseMovementX = x - Browser.mouseX;
+ Browser.mouseMovementY = y - Browser.mouseY;
+ Browser.mouseX = x;
+ Browser.mouseY = y;
+ }
+ },xhrLoad:function (url, onload, onerror) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, true);
+ xhr.responseType = 'arraybuffer';
+ xhr.onload = function xhr_onload() {
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
+ onload(xhr.response);
+ } else {
+ onerror();
+ }
+ };
+ xhr.onerror = onerror;
+ xhr.send(null);
+ },asyncLoad:function (url, onload, onerror, noRunDep) {
+ Browser.xhrLoad(url, function(arrayBuffer) {
+ assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
+ onload(new Uint8Array(arrayBuffer));
+ if (!noRunDep) removeRunDependency('al ' + url);
+ }, function(event) {
+ if (onerror) {
+ onerror();
+ } else {
+ throw 'Loading data file "' + url + '" failed.';
+ }
+ });
+ if (!noRunDep) addRunDependency('al ' + url);
+ },resizeListeners:[],updateResizeListeners:function () {
+ var canvas = Module['canvas'];
+ Browser.resizeListeners.forEach(function(listener) {
+ listener(canvas.width, canvas.height);
+ });
+ },setCanvasSize:function (width, height, noUpdates) {
+ var canvas = Module['canvas'];
+ Browser.updateCanvasDimensions(canvas, width, height);
+ if (!noUpdates) Browser.updateResizeListeners();
+ },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },setWindowedCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },updateCanvasDimensions:function (canvas, wNative, hNative) {
+ if (wNative && hNative) {
+ canvas.widthNative = wNative;
+ canvas.heightNative = hNative;
+ } else {
+ wNative = canvas.widthNative;
+ hNative = canvas.heightNative;
+ }
+ var w = wNative;
+ var h = hNative;
+ if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) {
+ if (w/h < Module['forcedAspectRatio']) {
+ w = Math.round(h * Module['forcedAspectRatio']);
+ } else {
+ h = Math.round(w / Module['forcedAspectRatio']);
+ }
+ }
+ if (((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
+ var factor = Math.min(screen.width / w, screen.height / h);
+ w = Math.round(w * factor);
+ h = Math.round(h * factor);
+ }
+ if (Browser.resizeCanvas) {
+ if (canvas.width != w) canvas.width = w;
+ if (canvas.height != h) canvas.height = h;
+ if (typeof canvas.style != 'undefined') {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ } else {
+ if (canvas.width != wNative) canvas.width = wNative;
+ if (canvas.height != hNative) canvas.height = hNative;
+ if (typeof canvas.style != 'undefined') {
+ if (w != wNative || h != hNative) {
+ canvas.style.setProperty( "width", w + "px", "important");
+ canvas.style.setProperty("height", h + "px", "important");
+ } else {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ }
+ }
+ }};
+
+
+
+
+
+
+
+ function _mkport() { throw 'TODO' }var SOCKFS={mount:function (mount) {
+ return FS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createSocket:function (family, type, protocol) {
+ var streaming = type == 1;
+ if (protocol) {
+ assert(streaming == (protocol == 6)); // if SOCK_STREAM, must be tcp
+ }
+
+ // create our internal socket structure
+ var sock = {
+ family: family,
+ type: type,
+ protocol: protocol,
+ server: null,
+ peers: {},
+ pending: [],
+ recv_queue: [],
+ sock_ops: SOCKFS.websocket_sock_ops
+ };
+
+ // create the filesystem node to store the socket structure
+ var name = SOCKFS.nextname();
+ var node = FS.createNode(SOCKFS.root, name, 49152, 0);
+ node.sock = sock;
+
+ // and the wrapping stream that enables library functions such
+ // as read and write to indirectly interact with the socket
+ var stream = FS.createStream({
+ path: name,
+ node: node,
+ flags: FS.modeStringToFlags('r+'),
+ seekable: false,
+ stream_ops: SOCKFS.stream_ops
+ });
+
+ // map the new stream to the socket structure (sockets have a 1:1
+ // relationship with a stream)
+ sock.stream = stream;
+
+ return sock;
+ },getSocket:function (fd) {
+ var stream = FS.getStream(fd);
+ if (!stream || !FS.isSocket(stream.node.mode)) {
+ return null;
+ }
+ return stream.node.sock;
+ },stream_ops:{poll:function (stream) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.poll(sock);
+ },ioctl:function (stream, request, varargs) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.ioctl(sock, request, varargs);
+ },read:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ var msg = sock.sock_ops.recvmsg(sock, length);
+ if (!msg) {
+ // socket is closed
+ return 0;
+ }
+ buffer.set(msg.buffer, offset);
+ return msg.buffer.length;
+ },write:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.sendmsg(sock, buffer, offset, length);
+ },close:function (stream) {
+ var sock = stream.node.sock;
+ sock.sock_ops.close(sock);
+ }},nextname:function () {
+ if (!SOCKFS.nextname.current) {
+ SOCKFS.nextname.current = 0;
+ }
+ return 'socket[' + (SOCKFS.nextname.current++) + ']';
+ },websocket_sock_ops:{createPeer:function (sock, addr, port) {
+ var ws;
+
+ if (typeof addr === 'object') {
+ ws = addr;
+ addr = null;
+ port = null;
+ }
+
+ if (ws) {
+ // for sockets that've already connected (e.g. we're the server)
+ // we can inspect the _socket property for the address
+ if (ws._socket) {
+ addr = ws._socket.remoteAddress;
+ port = ws._socket.remotePort;
+ }
+ // if we're just now initializing a connection to the remote,
+ // inspect the url property
+ else {
+ var result = /ws[s]?:\/\/([^:]+):(\d+)/.exec(ws.url);
+ if (!result) {
+ throw new Error('WebSocket URL must be in the format ws(s)://address:port');
+ }
+ addr = result[1];
+ port = parseInt(result[2], 10);
+ }
+ } else {
+ // create the actual websocket object and connect
+ try {
+ // runtimeConfig gets set to true if WebSocket runtime configuration is available.
+ var runtimeConfig = (Module['websocket'] && ('object' === typeof Module['websocket']));
+
+ // The default value is 'ws://' the replace is needed because the compiler replaces "//" comments with '#'
+ // comments without checking context, so we'd end up with ws:#, the replace swaps the "#" for "//" again.
+ var url = 'ws:#'.replace('#', '//');
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['url']) {
+ url = Module['websocket']['url']; // Fetch runtime WebSocket URL config.
+ }
+ }
+
+ if (url === 'ws://' || url === 'wss://') { // Is the supplied URL config just a prefix, if so complete it.
+ url = url + addr + ':' + port;
+ }
+
+ // Make the WebSocket subprotocol (Sec-WebSocket-Protocol) default to binary if no configuration is set.
+ var subProtocols = 'binary'; // The default value is 'binary'
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['subprotocol']) {
+ subProtocols = Module['websocket']['subprotocol']; // Fetch runtime WebSocket subprotocol config.
+ }
+ }
+
+ // The regex trims the string (removes spaces at the beginning and end, then splits the string by
+ // <any space>,<any space> into an Array. Whitespace removal is important for Websockify and ws.
+ subProtocols = subProtocols.replace(/^ +| +$/g,"").split(/ *, */);
+
+ // The node ws library API for specifying optional subprotocol is slightly different than the browser's.
+ var opts = ENVIRONMENT_IS_NODE ? {'protocol': subProtocols.toString()} : subProtocols;
+
+ // If node we use the ws library.
+ var WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : window['WebSocket'];
+ ws = new WebSocket(url, opts);
+ ws.binaryType = 'arraybuffer';
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EHOSTUNREACH);
+ }
+ }
+
+
+ var peer = {
+ addr: addr,
+ port: port,
+ socket: ws,
+ dgram_send_queue: []
+ };
+
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);
+
+ // if this is a bound dgram socket, send the port number first to allow
+ // us to override the ephemeral port reported to us by remotePort on the
+ // remote end.
+ if (sock.type === 2 && typeof sock.sport !== 'undefined') {
+ peer.dgram_send_queue.push(new Uint8Array([
+ 255, 255, 255, 255,
+ 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),
+ ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)
+ ]));
+ }
+
+ return peer;
+ },getPeer:function (sock, addr, port) {
+ return sock.peers[addr + ':' + port];
+ },addPeer:function (sock, peer) {
+ sock.peers[peer.addr + ':' + peer.port] = peer;
+ },removePeer:function (sock, peer) {
+ delete sock.peers[peer.addr + ':' + peer.port];
+ },handlePeerEvents:function (sock, peer) {
+ var first = true;
+
+ var handleOpen = function () {
+ try {
+ var queued = peer.dgram_send_queue.shift();
+ while (queued) {
+ peer.socket.send(queued);
+ queued = peer.dgram_send_queue.shift();
+ }
+ } catch (e) {
+ // not much we can do here in the way of proper error handling as we've already
+ // lied and said this data was sent. shut it down.
+ peer.socket.close();
+ }
+ };
+
+ function handleMessage(data) {
+ assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer
+ data = new Uint8Array(data); // make a typed array view on the array buffer
+
+
+ // if this is the port message, override the peer's port with it
+ var wasfirst = first;
+ first = false;
+ if (wasfirst &&
+ data.length === 10 &&
+ data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&
+ data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {
+ // update the peer's port and it's key in the peer map
+ var newport = ((data[8] << 8) | data[9]);
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ peer.port = newport;
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ return;
+ }
+
+ sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });
+ };
+
+ if (ENVIRONMENT_IS_NODE) {
+ peer.socket.on('open', handleOpen);
+ peer.socket.on('message', function(data, flags) {
+ if (!flags.binary) {
+ return;
+ }
+ handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
+ });
+ peer.socket.on('error', function() {
+ // don't throw
+ });
+ } else {
+ peer.socket.onopen = handleOpen;
+ peer.socket.onmessage = function peer_socket_onmessage(event) {
+ handleMessage(event.data);
+ };
+ }
+ },poll:function (sock) {
+ if (sock.type === 1 && sock.server) {
+ // listen sockets should only say they're available for reading
+ // if there are pending clients.
+ return sock.pending.length ? (64 | 1) : 0;
+ }
+
+ var mask = 0;
+ var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets
+ SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :
+ null;
+
+ if (sock.recv_queue.length ||
+ !dest || // connection-less sockets are always ready to read
+ (dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed
+ mask |= (64 | 1);
+ }
+
+ if (!dest || // connection-less sockets are always ready to write
+ (dest && dest.socket.readyState === dest.socket.OPEN)) {
+ mask |= 4;
+ }
+
+ if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) {
+ mask |= 16;
+ }
+
+ return mask;
+ },ioctl:function (sock, request, arg) {
+ switch (request) {
+ case 21531:
+ var bytes = 0;
+ if (sock.recv_queue.length) {
+ bytes = sock.recv_queue[0].data.length;
+ }
+ HEAP32[((arg)>>2)]=bytes;
+ return 0;
+ default:
+ return ERRNO_CODES.EINVAL;
+ }
+ },close:function (sock) {
+ // if we've spawned a listen server, close it
+ if (sock.server) {
+ try {
+ sock.server.close();
+ } catch (e) {
+ }
+ sock.server = null;
+ }
+ // close any peer connections
+ var peers = Object.keys(sock.peers);
+ for (var i = 0; i < peers.length; i++) {
+ var peer = sock.peers[peers[i]];
+ try {
+ peer.socket.close();
+ } catch (e) {
+ }
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ }
+ return 0;
+ },bind:function (sock, addr, port) {
+ if (typeof sock.saddr !== 'undefined' || typeof sock.sport !== 'undefined') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already bound
+ }
+ sock.saddr = addr;
+ sock.sport = port || _mkport();
+ // in order to emulate dgram sockets, we need to launch a listen server when
+ // binding on a connection-less socket
+ // note: this is only required on the server side
+ if (sock.type === 2) {
+ // close the existing server if it exists
+ if (sock.server) {
+ sock.server.close();
+ sock.server = null;
+ }
+ // swallow error operation not supported error that occurs when binding in the
+ // browser where this isn't supported
+ try {
+ sock.sock_ops.listen(sock, 0);
+ } catch (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e;
+ if (e.errno !== ERRNO_CODES.EOPNOTSUPP) throw e;
+ }
+ }
+ },connect:function (sock, addr, port) {
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODS.EOPNOTSUPP);
+ }
+
+ // TODO autobind
+ // if (!sock.addr && sock.type == 2) {
+ // }
+
+ // early out if we're already connected / in the middle of connecting
+ if (typeof sock.daddr !== 'undefined' && typeof sock.dport !== 'undefined') {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+ if (dest) {
+ if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EALREADY);
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EISCONN);
+ }
+ }
+ }
+
+ // add the socket to our peer list and set our
+ // destination address / port to match
+ var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ sock.daddr = peer.addr;
+ sock.dport = peer.port;
+
+ // always "fail" in non-blocking mode
+ throw new FS.ErrnoError(ERRNO_CODES.EINPROGRESS);
+ },listen:function (sock, backlog) {
+ if (!ENVIRONMENT_IS_NODE) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already listening
+ }
+ var WebSocketServer = require('ws').Server;
+ var host = sock.saddr;
+ sock.server = new WebSocketServer({
+ host: host,
+ port: sock.sport
+ // TODO support backlog
+ });
+
+ sock.server.on('connection', function(ws) {
+ if (sock.type === 1) {
+ var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);
+
+ // create a peer on the new socket
+ var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);
+ newsock.daddr = peer.addr;
+ newsock.dport = peer.port;
+
+ // push to queue for accept to pick up
+ sock.pending.push(newsock);
+ } else {
+ // create a peer on the listen socket so calling sendto
+ // with the listen socket and an address will resolve
+ // to the correct client
+ SOCKFS.websocket_sock_ops.createPeer(sock, ws);
+ }
+ });
+ sock.server.on('closed', function() {
+ sock.server = null;
+ });
+ sock.server.on('error', function() {
+ // don't throw
+ });
+ },accept:function (listensock) {
+ if (!listensock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var newsock = listensock.pending.shift();
+ newsock.stream.flags = listensock.stream.flags;
+ return newsock;
+ },getname:function (sock, peer) {
+ var addr, port;
+ if (peer) {
+ if (sock.daddr === undefined || sock.dport === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ addr = sock.daddr;
+ port = sock.dport;
+ } else {
+ // TODO saddr and sport will be set for bind()'d UDP sockets, but what
+ // should we be returning for TCP sockets that've been connect()'d?
+ addr = sock.saddr || 0;
+ port = sock.sport || 0;
+ }
+ return { addr: addr, port: port };
+ },sendmsg:function (sock, buffer, offset, length, addr, port) {
+ if (sock.type === 2) {
+ // connection-less sockets will honor the message address,
+ // and otherwise fall back to the bound destination address
+ if (addr === undefined || port === undefined) {
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+ // if there was no address to fall back to, error out
+ if (addr === undefined || port === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.EDESTADDRREQ);
+ }
+ } else {
+ // connection-based sockets will only use the bound
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+
+ // find the peer for the destination address
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);
+
+ // early out if not connected with a connection-based socket
+ if (sock.type === 1) {
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ } else if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // create a copy of the incoming data to send, as the WebSocket API
+ // doesn't work entirely with an ArrayBufferView, it'll just send
+ // the entire underlying buffer
+ var data;
+ if (buffer instanceof Array || buffer instanceof ArrayBuffer) {
+ data = buffer.slice(offset, offset + length);
+ } else { // ArrayBufferView
+ data = buffer.buffer.slice(buffer.byteOffset + offset, buffer.byteOffset + offset + length);
+ }
+
+ // if we're emulating a connection-less dgram socket and don't have
+ // a cached connection, queue the buffer to send upon connect and
+ // lie, saying the data was sent now.
+ if (sock.type === 2) {
+ if (!dest || dest.socket.readyState !== dest.socket.OPEN) {
+ // if we're not connected, open a new connection
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ }
+ dest.dgram_send_queue.push(data);
+ return length;
+ }
+ }
+
+ try {
+ // send the actual data
+ dest.socket.send(data);
+ return length;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ },recvmsg:function (sock, length) {
+ // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html
+ if (sock.type === 1 && sock.server) {
+ // tcp servers should not be recv()'ing on the listen socket
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+
+ var queued = sock.recv_queue.shift();
+ if (!queued) {
+ if (sock.type === 1) {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+
+ if (!dest) {
+ // if we have a destination address but are not connected, error out
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ else if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ // return null if the socket has closed
+ return null;
+ }
+ else {
+ // else, our socket is in a valid state but truly has nothing available
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // queued.data will be an ArrayBuffer if it's unadulterated, but if it's
+ // requeued TCP data it'll be an ArrayBufferView
+ var queuedLength = queued.data.byteLength || queued.data.length;
+ var queuedOffset = queued.data.byteOffset || 0;
+ var queuedBuffer = queued.data.buffer || queued.data;
+ var bytesRead = Math.min(length, queuedLength);
+ var res = {
+ buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),
+ addr: queued.addr,
+ port: queued.port
+ };
+
+
+ // push back any unread data for TCP connections
+ if (sock.type === 1 && bytesRead < queuedLength) {
+ var bytesRemaining = queuedLength - bytesRead;
+ queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
+ sock.recv_queue.unshift(queued);
+ }
+
+ return res;
+ }}};function _send(fd, buf, len, flags) {
+ var sock = SOCKFS.getSocket(fd);
+ if (!sock) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ // TODO honor flags
+ return _write(fd, buf, len);
+ }
+
+ function _pwrite(fildes, buf, nbyte, offset) {
+ // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte, offset);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _write(fildes, buf, nbyte) {
+ // ssize_t write(int fildes, const void *buf, size_t nbyte);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+
+
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }
+
+ function _fileno(stream) {
+ // int fileno(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fileno.html
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) return -1;
+ return stream.fd;
+ }function _fwrite(ptr, size, nitems, stream) {
+ // size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html
+ var bytesToWrite = nitems * size;
+ if (bytesToWrite == 0) return 0;
+ var fd = _fileno(stream);
+ var bytesWritten = _write(fd, ptr, bytesToWrite);
+ if (bytesWritten == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return 0;
+ } else {
+ return Math.floor(bytesWritten / size);
+ }
+ }
+
+
+
+ Module["_strlen"] = _strlen;
+
+ function __reallyNegative(x) {
+ return x < 0 || (x === 0 && (1/x) === -Infinity);
+ }function __formatString(format, varargs) {
+ var textIndex = format;
+ var argIndex = 0;
+ function getNextArg(type) {
+ // NOTE: Explicitly ignoring type safety. Otherwise this fails:
+ // int x = 4; printf("%c\n", (char)x);
+ var ret;
+ if (type === 'double') {
+ ret = HEAPF64[(((varargs)+(argIndex))>>3)];
+ } else if (type == 'i64') {
+ ret = [HEAP32[(((varargs)+(argIndex))>>2)],
+ HEAP32[(((varargs)+(argIndex+4))>>2)]];
+
+ } else {
+ type = 'i32'; // varargs are always i32, i64, or double
+ ret = HEAP32[(((varargs)+(argIndex))>>2)];
+ }
+ argIndex += Runtime.getNativeFieldSize(type);
+ return ret;
+ }
+
+ var ret = [];
+ var curr, next, currArg;
+ while(1) {
+ var startTextIndex = textIndex;
+ curr = HEAP8[(textIndex)];
+ if (curr === 0) break;
+ next = HEAP8[((textIndex+1)|0)];
+ if (curr == 37) {
+ // Handle flags.
+ var flagAlwaysSigned = false;
+ var flagLeftAlign = false;
+ var flagAlternative = false;
+ var flagZeroPad = false;
+ var flagPadSign = false;
+ flagsLoop: while (1) {
+ switch (next) {
+ case 43:
+ flagAlwaysSigned = true;
+ break;
+ case 45:
+ flagLeftAlign = true;
+ break;
+ case 35:
+ flagAlternative = true;
+ break;
+ case 48:
+ if (flagZeroPad) {
+ break flagsLoop;
+ } else {
+ flagZeroPad = true;
+ break;
+ }
+ case 32:
+ flagPadSign = true;
+ break;
+ default:
+ break flagsLoop;
+ }
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+
+ // Handle width.
+ var width = 0;
+ if (next == 42) {
+ width = getNextArg('i32');
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ } else {
+ while (next >= 48 && next <= 57) {
+ width = width * 10 + (next - 48);
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ }
+
+ // Handle precision.
+ var precisionSet = false, precision = -1;
+ if (next == 46) {
+ precision = 0;
+ precisionSet = true;
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ if (next == 42) {
+ precision = getNextArg('i32');
+ textIndex++;
+ } else {
+ while(1) {
+ var precisionChr = HEAP8[((textIndex+1)|0)];
+ if (precisionChr < 48 ||
+ precisionChr > 57) break;
+ precision = precision * 10 + (precisionChr - 48);
+ textIndex++;
+ }
+ }
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ if (precision < 0) {
+ precision = 6; // Standard default.
+ precisionSet = false;
+ }
+
+ // Handle integer sizes. WARNING: These assume a 32-bit architecture!
+ var argSize;
+ switch (String.fromCharCode(next)) {
+ case 'h':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 104) {
+ textIndex++;
+ argSize = 1; // char (actually i32 in varargs)
+ } else {
+ argSize = 2; // short (actually i32 in varargs)
+ }
+ break;
+ case 'l':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 108) {
+ textIndex++;
+ argSize = 8; // long long
+ } else {
+ argSize = 4; // long
+ }
+ break;
+ case 'L': // long long
+ case 'q': // int64_t
+ case 'j': // intmax_t
+ argSize = 8;
+ break;
+ case 'z': // size_t
+ case 't': // ptrdiff_t
+ case 'I': // signed ptrdiff_t or unsigned size_t
+ argSize = 4;
+ break;
+ default:
+ argSize = null;
+ }
+ if (argSize) textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+
+ // Handle type specifier.
+ switch (String.fromCharCode(next)) {
+ case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {
+ // Integer.
+ var signed = next == 100 || next == 105;
+ argSize = argSize || 4;
+ var currArg = getNextArg('i' + (argSize * 8));
+ var argText;
+ // Flatten i64-1 [low, high] into a (slightly rounded) double
+ if (argSize == 8) {
+ currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);
+ }
+ // Truncate to requested size.
+ if (argSize <= 4) {
+ var limit = Math.pow(256, argSize) - 1;
+ currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);
+ }
+ // Format the number.
+ var currAbsArg = Math.abs(currArg);
+ var prefix = '';
+ if (next == 100 || next == 105) {
+ argText = reSign(currArg, 8 * argSize, 1).toString(10);
+ } else if (next == 117) {
+ argText = unSign(currArg, 8 * argSize, 1).toString(10);
+ currArg = Math.abs(currArg);
+ } else if (next == 111) {
+ argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
+ } else if (next == 120 || next == 88) {
+ prefix = (flagAlternative && currArg != 0) ? '0x' : '';
+ if (currArg < 0) {
+ // Represent negative numbers in hex as 2's complement.
+ currArg = -currArg;
+ argText = (currAbsArg - 1).toString(16);
+ var buffer = [];
+ for (var i = 0; i < argText.length; i++) {
+ buffer.push((0xF - parseInt(argText[i], 16)).toString(16));
+ }
+ argText = buffer.join('');
+ while (argText.length < argSize * 2) argText = 'f' + argText;
+ } else {
+ argText = currAbsArg.toString(16);
+ }
+ if (next == 88) {
+ prefix = prefix.toUpperCase();
+ argText = argText.toUpperCase();
+ }
+ } else if (next == 112) {
+ if (currAbsArg === 0) {
+ argText = '(nil)';
+ } else {
+ prefix = '0x';
+ argText = currAbsArg.toString(16);
+ }
+ }
+ if (precisionSet) {
+ while (argText.length < precision) {
+ argText = '0' + argText;
+ }
+ }
+
+ // Add sign if needed
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ prefix = '+' + prefix;
+ } else if (flagPadSign) {
+ prefix = ' ' + prefix;
+ }
+ }
+
+ // Move sign to prefix so we zero-pad after the sign
+ if (argText.charAt(0) == '-') {
+ prefix = '-' + prefix;
+ argText = argText.substr(1);
+ }
+
+ // Add padding.
+ while (prefix.length + argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad) {
+ argText = '0' + argText;
+ } else {
+ prefix = ' ' + prefix;
+ }
+ }
+ }
+
+ // Insert the result into the buffer.
+ argText = prefix + argText;
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {
+ // Float.
+ var currArg = getNextArg('double');
+ var argText;
+ if (isNaN(currArg)) {
+ argText = 'nan';
+ flagZeroPad = false;
+ } else if (!isFinite(currArg)) {
+ argText = (currArg < 0 ? '-' : '') + 'inf';
+ flagZeroPad = false;
+ } else {
+ var isGeneral = false;
+ var effectivePrecision = Math.min(precision, 20);
+
+ // Convert g/G to f/F or e/E, as per:
+ // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
+ if (next == 103 || next == 71) {
+ isGeneral = true;
+ precision = precision || 1;
+ var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);
+ if (precision > exponent && exponent >= -4) {
+ next = ((next == 103) ? 'f' : 'F').charCodeAt(0);
+ precision -= exponent + 1;
+ } else {
+ next = ((next == 103) ? 'e' : 'E').charCodeAt(0);
+ precision--;
+ }
+ effectivePrecision = Math.min(precision, 20);
+ }
+
+ if (next == 101 || next == 69) {
+ argText = currArg.toExponential(effectivePrecision);
+ // Make sure the exponent has at least 2 digits.
+ if (/[eE][-+]\d$/.test(argText)) {
+ argText = argText.slice(0, -1) + '0' + argText.slice(-1);
+ }
+ } else if (next == 102 || next == 70) {
+ argText = currArg.toFixed(effectivePrecision);
+ if (currArg === 0 && __reallyNegative(currArg)) {
+ argText = '-' + argText;
+ }
+ }
+
+ var parts = argText.split('e');
+ if (isGeneral && !flagAlternative) {
+ // Discard trailing zeros and periods.
+ while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&
+ (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {
+ parts[0] = parts[0].slice(0, -1);
+ }
+ } else {
+ // Make sure we have a period in alternative mode.
+ if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';
+ // Zero pad until required precision.
+ while (precision > effectivePrecision++) parts[0] += '0';
+ }
+ argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');
+
+ // Capitalize 'E' if needed.
+ if (next == 69) argText = argText.toUpperCase();
+
+ // Add sign.
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ argText = '+' + argText;
+ } else if (flagPadSign) {
+ argText = ' ' + argText;
+ }
+ }
+ }
+
+ // Add padding.
+ while (argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {
+ argText = argText[0] + '0' + argText.slice(1);
+ } else {
+ argText = (flagZeroPad ? '0' : ' ') + argText;
+ }
+ }
+ }
+
+ // Adjust case.
+ if (next < 97) argText = argText.toUpperCase();
+
+ // Insert the result into the buffer.
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 's': {
+ // String.
+ var arg = getNextArg('i8*');
+ var argLength = arg ? _strlen(arg) : '(null)'.length;
+ if (precisionSet) argLength = Math.min(argLength, precision);
+ if (!flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ if (arg) {
+ for (var i = 0; i < argLength; i++) {
+ ret.push(HEAPU8[((arg++)|0)]);
+ }
+ } else {
+ ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true));
+ }
+ if (flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ break;
+ }
+ case 'c': {
+ // Character.
+ if (flagLeftAlign) ret.push(getNextArg('i8'));
+ while (--width > 0) {
+ ret.push(32);
+ }
+ if (!flagLeftAlign) ret.push(getNextArg('i8'));
+ break;
+ }
+ case 'n': {
+ // Write the length written so far to the next parameter.
+ var ptr = getNextArg('i32*');
+ HEAP32[((ptr)>>2)]=ret.length;
+ break;
+ }
+ case '%': {
+ // Literal percent sign.
+ ret.push(curr);
+ break;
+ }
+ default: {
+ // Unknown specifiers remain untouched.
+ for (var i = startTextIndex; i < textIndex + 2; i++) {
+ ret.push(HEAP8[(i)]);
+ }
+ }
+ }
+ textIndex += 2;
+ // TODO: Support a/A (hex float) and m (last error) specifiers.
+ // TODO: Support %1${specifier} for arg selection.
+ } else {
+ ret.push(curr);
+ textIndex += 1;
+ }
+ }
+ return ret;
+ }function _fprintf(stream, format, varargs) {
+ // int fprintf(FILE *restrict stream, const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var result = __formatString(format, varargs);
+ var stack = Runtime.stackSave();
+ var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);
+ Runtime.stackRestore(stack);
+ return ret;
+ }function _printf(format, varargs) {
+ // int printf(const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var stdout = HEAP32[((_stdout)>>2)];
+ return _fprintf(stdout, format, varargs);
+ }
+
+
+ var _sqrtf=Math_sqrt;
+Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };
+ Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };
+ Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };
+ Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };
+ Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };
+ Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }
+FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;
+___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;
+__ATINIT__.unshift({ func: function() { TTY.init() } });__ATEXIT__.push({ func: function() { TTY.shutdown() } });TTY.utf8 = new Runtime.UTF8Processor();
+if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); NODEFS.staticInit(); }
+__ATINIT__.push({ func: function() { SOCKFS.root = FS.mount(SOCKFS, {}, null); } });
+STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);
+
+staticSealed = true; // seal the static portion of memory
+
+STACK_MAX = STACK_BASE + 5242880;
+
+DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);
+
+assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");
+
+
+var Math_min = Math.min;
+function asmPrintInt(x, y) {
+ Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+function asmPrintFloat(x, y) {
+ Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+// EMSCRIPTEN_START_ASM
+var asm = (function(global, env, buffer) {
+ 'use asm';
+ var HEAP8 = new global.Int8Array(buffer);
+ var HEAP16 = new global.Int16Array(buffer);
+ var HEAP32 = new global.Int32Array(buffer);
+ var HEAPU8 = new global.Uint8Array(buffer);
+ var HEAPU16 = new global.Uint16Array(buffer);
+ var HEAPU32 = new global.Uint32Array(buffer);
+ var HEAPF32 = new global.Float32Array(buffer);
+ var HEAPF64 = new global.Float64Array(buffer);
+
+ var STACKTOP=env.STACKTOP|0;
+ var STACK_MAX=env.STACK_MAX|0;
+ var tempDoublePtr=env.tempDoublePtr|0;
+ var ABORT=env.ABORT|0;
+
+ var __THREW__ = 0;
+ var threwValue = 0;
+ var setjmpId = 0;
+ var undef = 0;
+ var nan = +env.NaN, inf = +env.Infinity;
+ var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0;
+
+ var tempRet0 = 0;
+ var tempRet1 = 0;
+ var tempRet2 = 0;
+ var tempRet3 = 0;
+ var tempRet4 = 0;
+ var tempRet5 = 0;
+ var tempRet6 = 0;
+ var tempRet7 = 0;
+ var tempRet8 = 0;
+ var tempRet9 = 0;
+ var Math_floor=global.Math.floor;
+ var Math_abs=global.Math.abs;
+ var Math_sqrt=global.Math.sqrt;
+ var Math_pow=global.Math.pow;
+ var Math_cos=global.Math.cos;
+ var Math_sin=global.Math.sin;
+ var Math_tan=global.Math.tan;
+ var Math_acos=global.Math.acos;
+ var Math_asin=global.Math.asin;
+ var Math_atan=global.Math.atan;
+ var Math_atan2=global.Math.atan2;
+ var Math_exp=global.Math.exp;
+ var Math_log=global.Math.log;
+ var Math_ceil=global.Math.ceil;
+ var Math_imul=global.Math.imul;
+ var abort=env.abort;
+ var assert=env.assert;
+ var asmPrintInt=env.asmPrintInt;
+ var asmPrintFloat=env.asmPrintFloat;
+ var Math_min=env.min;
+ var _free=env._free;
+ var _emscripten_memcpy_big=env._emscripten_memcpy_big;
+ var _printf=env._printf;
+ var _send=env._send;
+ var _pwrite=env._pwrite;
+ var _sqrtf=env._sqrtf;
+ var __reallyNegative=env.__reallyNegative;
+ var _fwrite=env._fwrite;
+ var _malloc=env._malloc;
+ var _mkport=env._mkport;
+ var _fprintf=env._fprintf;
+ var ___setErrNo=env.___setErrNo;
+ var __formatString=env.__formatString;
+ var _fileno=env._fileno;
+ var _fflush=env._fflush;
+ var _write=env._write;
+ var tempFloat = 0.0;
+
+// EMSCRIPTEN_START_FUNCS
+function _main(i3, i5) {
+ i3 = i3 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i6 = 0, i7 = 0, d8 = 0.0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i1;
+ L1 : do {
+ if ((i3 | 0) > 1) {
+ i3 = HEAP8[HEAP32[i5 + 4 >> 2] | 0] | 0;
+ switch (i3 | 0) {
+ case 50:
+ {
+ i3 = 13e4;
+ break L1;
+ }
+ case 51:
+ {
+ i4 = 4;
+ break L1;
+ }
+ case 52:
+ {
+ i3 = 61e4;
+ break L1;
+ }
+ case 53:
+ {
+ i3 = 101e4;
+ break L1;
+ }
+ case 49:
+ {
+ i3 = 33e3;
+ break L1;
+ }
+ case 48:
+ {
+ i7 = 0;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ default:
+ {
+ HEAP32[i2 >> 2] = i3 + -48;
+ _printf(8, i2 | 0) | 0;
+ i7 = -1;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ }
+ } else {
+ i4 = 4;
+ }
+ } while (0);
+ if ((i4 | 0) == 4) {
+ i3 = 22e4;
+ }
+ i4 = 2;
+ i5 = 0;
+ while (1) {
+ d8 = +Math_sqrt(+(+(i4 | 0)));
+ L15 : do {
+ if (d8 > 2.0) {
+ i7 = 2;
+ while (1) {
+ i6 = i7 + 1 | 0;
+ if (((i4 | 0) % (i7 | 0) | 0 | 0) == 0) {
+ i6 = 0;
+ break L15;
+ }
+ if (+(i6 | 0) < d8) {
+ i7 = i6;
+ } else {
+ i6 = 1;
+ break;
+ }
+ }
+ } else {
+ i6 = 1;
+ }
+ } while (0);
+ i5 = i6 + i5 | 0;
+ if ((i5 | 0) >= (i3 | 0)) {
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ }
+ }
+ HEAP32[i2 >> 2] = i4;
+ _printf(24, i2 | 0) | 0;
+ i7 = 0;
+ STACKTOP = i1;
+ return i7 | 0;
+}
+function _memcpy(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ if ((i1 | 0) >= 4096) return _emscripten_memcpy_big(i3 | 0, i2 | 0, i1 | 0) | 0;
+ i4 = i3 | 0;
+ if ((i3 & 3) == (i2 & 3)) {
+ while (i3 & 3) {
+ if ((i1 | 0) == 0) return i4 | 0;
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ while ((i1 | 0) >= 4) {
+ HEAP32[i3 >> 2] = HEAP32[i2 >> 2];
+ i3 = i3 + 4 | 0;
+ i2 = i2 + 4 | 0;
+ i1 = i1 - 4 | 0;
+ }
+ }
+ while ((i1 | 0) > 0) {
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ return i4 | 0;
+}
+function runPostSets() {}
+function _memset(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = i1 + i3 | 0;
+ if ((i3 | 0) >= 20) {
+ i4 = i4 & 255;
+ i7 = i1 & 3;
+ i6 = i4 | i4 << 8 | i4 << 16 | i4 << 24;
+ i5 = i2 & ~3;
+ if (i7) {
+ i7 = i1 + 4 - i7 | 0;
+ while ((i1 | 0) < (i7 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ }
+ while ((i1 | 0) < (i5 | 0)) {
+ HEAP32[i1 >> 2] = i6;
+ i1 = i1 + 4 | 0;
+ }
+ }
+ while ((i1 | 0) < (i2 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ return i1 - i3 | 0;
+}
+function copyTempDouble(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+ HEAP8[tempDoublePtr + 4 | 0] = HEAP8[i1 + 4 | 0];
+ HEAP8[tempDoublePtr + 5 | 0] = HEAP8[i1 + 5 | 0];
+ HEAP8[tempDoublePtr + 6 | 0] = HEAP8[i1 + 6 | 0];
+ HEAP8[tempDoublePtr + 7 | 0] = HEAP8[i1 + 7 | 0];
+}
+function copyTempFloat(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+}
+function stackAlloc(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + i1 | 0;
+ STACKTOP = STACKTOP + 7 & -8;
+ return i2 | 0;
+}
+function _strlen(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = i1;
+ while (HEAP8[i2] | 0) {
+ i2 = i2 + 1 | 0;
+ }
+ return i2 - i1 | 0;
+}
+function setThrew(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ if ((__THREW__ | 0) == 0) {
+ __THREW__ = i1;
+ threwValue = i2;
+ }
+}
+function stackRestore(i1) {
+ i1 = i1 | 0;
+ STACKTOP = i1;
+}
+function setTempRet9(i1) {
+ i1 = i1 | 0;
+ tempRet9 = i1;
+}
+function setTempRet8(i1) {
+ i1 = i1 | 0;
+ tempRet8 = i1;
+}
+function setTempRet7(i1) {
+ i1 = i1 | 0;
+ tempRet7 = i1;
+}
+function setTempRet6(i1) {
+ i1 = i1 | 0;
+ tempRet6 = i1;
+}
+function setTempRet5(i1) {
+ i1 = i1 | 0;
+ tempRet5 = i1;
+}
+function setTempRet4(i1) {
+ i1 = i1 | 0;
+ tempRet4 = i1;
+}
+function setTempRet3(i1) {
+ i1 = i1 | 0;
+ tempRet3 = i1;
+}
+function setTempRet2(i1) {
+ i1 = i1 | 0;
+ tempRet2 = i1;
+}
+function setTempRet1(i1) {
+ i1 = i1 | 0;
+ tempRet1 = i1;
+}
+function setTempRet0(i1) {
+ i1 = i1 | 0;
+ tempRet0 = i1;
+}
+function stackSave() {
+ return STACKTOP | 0;
+}
+
+// EMSCRIPTEN_END_FUNCS
+
+
+ return { _strlen: _strlen, _memcpy: _memcpy, _main: _main, _memset: _memset, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, setThrew: setThrew, setTempRet0: setTempRet0, setTempRet1: setTempRet1, setTempRet2: setTempRet2, setTempRet3: setTempRet3, setTempRet4: setTempRet4, setTempRet5: setTempRet5, setTempRet6: setTempRet6, setTempRet7: setTempRet7, setTempRet8: setTempRet8, setTempRet9: setTempRet9 };
+})
+// EMSCRIPTEN_END_ASM
+({ "Math": Math, "Int8Array": Int8Array, "Int16Array": Int16Array, "Int32Array": Int32Array, "Uint8Array": Uint8Array, "Uint16Array": Uint16Array, "Uint32Array": Uint32Array, "Float32Array": Float32Array, "Float64Array": Float64Array }, { "abort": abort, "assert": assert, "asmPrintInt": asmPrintInt, "asmPrintFloat": asmPrintFloat, "min": Math_min, "_free": _free, "_emscripten_memcpy_big": _emscripten_memcpy_big, "_printf": _printf, "_send": _send, "_pwrite": _pwrite, "_sqrtf": _sqrtf, "__reallyNegative": __reallyNegative, "_fwrite": _fwrite, "_malloc": _malloc, "_mkport": _mkport, "_fprintf": _fprintf, "___setErrNo": ___setErrNo, "__formatString": __formatString, "_fileno": _fileno, "_fflush": _fflush, "_write": _write, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX, "tempDoublePtr": tempDoublePtr, "ABORT": ABORT, "NaN": NaN, "Infinity": Infinity }, buffer);
+var _strlen = Module["_strlen"] = asm["_strlen"];
+var _memcpy = Module["_memcpy"] = asm["_memcpy"];
+var _main = Module["_main"] = asm["_main"];
+var _memset = Module["_memset"] = asm["_memset"];
+var runPostSets = Module["runPostSets"] = asm["runPostSets"];
+
+Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
+Runtime.stackSave = function() { return asm['stackSave']() };
+Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
+
+
+// Warning: printing of i64 values may be slightly rounded! No deep i64 math used, so precise i64 code not included
+var i64Math = null;
+
+// === Auto-generated postamble setup entry stuff ===
+
+if (memoryInitializer) {
+ if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
+ var data = Module['readBinary'](memoryInitializer);
+ HEAPU8.set(data, STATIC_BASE);
+ } else {
+ addRunDependency('memory initializer');
+ Browser.asyncLoad(memoryInitializer, function(data) {
+ HEAPU8.set(data, STATIC_BASE);
+ removeRunDependency('memory initializer');
+ }, function(data) {
+ throw 'could not load memory initializer ' + memoryInitializer;
+ });
+ }
+}
+
+function ExitStatus(status) {
+ this.name = "ExitStatus";
+ this.message = "Program terminated with exit(" + status + ")";
+ this.status = status;
+};
+ExitStatus.prototype = new Error();
+ExitStatus.prototype.constructor = ExitStatus;
+
+var initialStackTop;
+var preloadStartTime = null;
+var calledMain = false;
+
+dependenciesFulfilled = function runCaller() {
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
+ if (!Module['calledRun'] && shouldRunNow) run([].concat(Module["arguments"]));
+ if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
+}
+
+Module['callMain'] = Module.callMain = function callMain(args) {
+ assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');
+ assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
+
+ args = args || [];
+
+ ensureInitRuntime();
+
+ var argc = args.length+1;
+ function pad() {
+ for (var i = 0; i < 4-1; i++) {
+ argv.push(0);
+ }
+ }
+ var argv = [allocate(intArrayFromString("/bin/this.program"), 'i8', ALLOC_NORMAL) ];
+ pad();
+ for (var i = 0; i < argc-1; i = i + 1) {
+ argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL));
+ pad();
+ }
+ argv.push(0);
+ argv = allocate(argv, 'i32', ALLOC_NORMAL);
+
+ initialStackTop = STACKTOP;
+
+ try {
+
+ var ret = Module['_main'](argc, argv, 0);
+
+
+ // if we're not running an evented main loop, it's time to exit
+ if (!Module['noExitRuntime']) {
+ exit(ret);
+ }
+ }
+ catch(e) {
+ if (e instanceof ExitStatus) {
+ // exit() throws this once it's done to make sure execution
+ // has been stopped completely
+ return;
+ } else if (e == 'SimulateInfiniteLoop') {
+ // running an evented main loop, don't immediately exit
+ Module['noExitRuntime'] = true;
+ return;
+ } else {
+ if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
+ throw e;
+ }
+ } finally {
+ calledMain = true;
+ }
+}
+
+
+
+
+function run(args) {
+ args = args || Module['arguments'];
+
+ if (preloadStartTime === null) preloadStartTime = Date.now();
+
+ if (runDependencies > 0) {
+ Module.printErr('run() called, but dependencies remain, so not running');
+ return;
+ }
+
+ preRun();
+
+ if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
+ if (Module['calledRun']) return; // run may have just been called through dependencies being fulfilled just in this very frame
+
+ function doRun() {
+ if (Module['calledRun']) return; // run may have just been called while the async setStatus time below was happening
+ Module['calledRun'] = true;
+
+ ensureInitRuntime();
+
+ preMain();
+
+ if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) {
+ Module.printErr('pre-main prep time: ' + (Date.now() - preloadStartTime) + ' ms');
+ }
+
+ if (Module['_main'] && shouldRunNow) {
+ Module['callMain'](args);
+ }
+
+ postRun();
+ }
+
+ if (Module['setStatus']) {
+ Module['setStatus']('Running...');
+ setTimeout(function() {
+ setTimeout(function() {
+ Module['setStatus']('');
+ }, 1);
+ if (!ABORT) doRun();
+ }, 1);
+ } else {
+ doRun();
+ }
+}
+Module['run'] = Module.run = run;
+
+function exit(status) {
+ ABORT = true;
+ EXITSTATUS = status;
+ STACKTOP = initialStackTop;
+
+ // exit the runtime
+ exitRuntime();
+
+ // TODO We should handle this differently based on environment.
+ // In the browser, the best we can do is throw an exception
+ // to halt execution, but in node we could process.exit and
+ // I'd imagine SM shell would have something equivalent.
+ // This would let us set a proper exit status (which
+ // would be great for checking test exit statuses).
+ // https://github.com/kripken/emscripten/issues/1371
+
+ // throw an exception to halt the current execution
+ throw new ExitStatus(status);
+}
+Module['exit'] = Module.exit = exit;
+
+function abort(text) {
+ if (text) {
+ Module.print(text);
+ Module.printErr(text);
+ }
+
+ ABORT = true;
+ EXITSTATUS = 1;
+
+ var extra = '\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.';
+
+ throw 'abort() at ' + stackTrace() + extra;
+}
+Module['abort'] = Module.abort = abort;
+
+// {{PRE_RUN_ADDITIONS}}
+
+if (Module['preInit']) {
+ if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
+ while (Module['preInit'].length > 0) {
+ Module['preInit'].pop()();
+ }
+}
+
+// shouldRunNow refers to calling main(), not run().
+var shouldRunNow = true;
+if (Module['noInitialRun']) {
+ shouldRunNow = false;
+}
+
+
+run([].concat(Module["arguments"]));
diff --git a/test/mjsunit/asm/embenchen/zlib.js b/test/mjsunit/asm/embenchen/zlib.js
new file mode 100644
index 000000000..c64317c56
--- /dev/null
+++ b/test/mjsunit/asm/embenchen/zlib.js
@@ -0,0 +1,14756 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var EXPECTED_OUTPUT = 'sizes: 100000,25906\nok.\n';
+var Module = {
+ arguments: [1],
+ print: function(x) {Module.printBuffer += x + '\n';},
+ preRun: [function() {Module.printBuffer = ''}],
+ postRun: [function() {
+ assertEquals(EXPECTED_OUTPUT, Module.printBuffer);
+ }],
+};
+// The Module object: Our interface to the outside world. We import
+// and export values on it, and do the work to get that through
+// closure compiler if necessary. There are various ways Module can be used:
+// 1. Not defined. We create it here
+// 2. A function parameter, function(Module) { ..generated code.. }
+// 3. pre-run appended it, var Module = {}; ..generated code..
+// 4. External script tag defines var Module.
+// We need to do an eval in order to handle the closure compiler
+// case, where this code here is minified but Module was defined
+// elsewhere (e.g. case 4 above). We also need to check if Module
+// already exists (e.g. case 3 above).
+// Note that if you want to run closure, and also to use Module
+// after the generated code, you will need to define var Module = {};
+// before the code. Then that object will be used in the code, and you
+// can continue to use Module afterwards as well.
+var Module;
+if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {};
+
+// Sometimes an existing Module object exists with properties
+// meant to overwrite the default module functionality. Here
+// we collect those properties and reapply _after_ we configure
+// the current environment's defaults to avoid having to be so
+// defensive during initialization.
+var moduleOverrides = {};
+for (var key in Module) {
+ if (Module.hasOwnProperty(key)) {
+ moduleOverrides[key] = Module[key];
+ }
+}
+
+// The environment setup code below is customized to use Module.
+// *** Environment setup code ***
+var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
+var ENVIRONMENT_IS_WEB = typeof window === 'object';
+var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
+var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+
+if (ENVIRONMENT_IS_NODE) {
+ // Expose functionality in the same simple way that the shells work
+ // Note that we pollute the global namespace here, otherwise we break in node
+ if (!Module['print']) Module['print'] = function print(x) {
+ process['stdout'].write(x + '\n');
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ process['stderr'].write(x + '\n');
+ };
+
+ var nodeFS = require('fs');
+ var nodePath = require('path');
+
+ Module['read'] = function read(filename, binary) {
+ filename = nodePath['normalize'](filename);
+ var ret = nodeFS['readFileSync'](filename);
+ // The path is absolute if the normalized version is the same as the resolved.
+ if (!ret && filename != nodePath['resolve'](filename)) {
+ filename = path.join(__dirname, '..', 'src', filename);
+ ret = nodeFS['readFileSync'](filename);
+ }
+ if (ret && !binary) ret = ret.toString();
+ return ret;
+ };
+
+ Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
+
+ Module['load'] = function load(f) {
+ globalEval(read(f));
+ };
+
+ Module['arguments'] = process['argv'].slice(2);
+
+ module['exports'] = Module;
+}
+else if (ENVIRONMENT_IS_SHELL) {
+ if (!Module['print']) Module['print'] = print;
+ if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
+
+ if (typeof read != 'undefined') {
+ Module['read'] = read;
+ } else {
+ Module['read'] = function read() { throw 'no read() available (jsc?)' };
+ }
+
+ Module['readBinary'] = function readBinary(f) {
+ return read(f, 'binary');
+ };
+
+ if (typeof scriptArgs != 'undefined') {
+ Module['arguments'] = scriptArgs;
+ } else if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ this['Module'] = Module;
+
+ eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
+}
+else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
+ Module['read'] = function read(url) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ xhr.send(null);
+ return xhr.responseText;
+ };
+
+ if (typeof arguments != 'undefined') {
+ Module['arguments'] = arguments;
+ }
+
+ if (typeof console !== 'undefined') {
+ if (!Module['print']) Module['print'] = function print(x) {
+ console.log(x);
+ };
+ if (!Module['printErr']) Module['printErr'] = function printErr(x) {
+ console.log(x);
+ };
+ } else {
+ // Probably a worker, and without console.log. We can do very little here...
+ var TRY_USE_DUMP = false;
+ if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
+ dump(x);
+ }) : (function(x) {
+ // self.postMessage(x); // enable this if you want stdout to be sent as messages
+ }));
+ }
+
+ if (ENVIRONMENT_IS_WEB) {
+ window['Module'] = Module;
+ } else {
+ Module['load'] = importScripts;
+ }
+}
+else {
+ // Unreachable because SHELL is dependant on the others
+ throw 'Unknown runtime environment. Where are we?';
+}
+
+function globalEval(x) {
+ eval.call(null, x);
+}
+if (!Module['load'] == 'undefined' && Module['read']) {
+ Module['load'] = function load(f) {
+ globalEval(Module['read'](f));
+ };
+}
+if (!Module['print']) {
+ Module['print'] = function(){};
+}
+if (!Module['printErr']) {
+ Module['printErr'] = Module['print'];
+}
+if (!Module['arguments']) {
+ Module['arguments'] = [];
+}
+// *** Environment setup code ***
+
+// Closure helpers
+Module.print = Module['print'];
+Module.printErr = Module['printErr'];
+
+// Callbacks
+Module['preRun'] = [];
+Module['postRun'] = [];
+
+// Merge back in the overrides
+for (var key in moduleOverrides) {
+ if (moduleOverrides.hasOwnProperty(key)) {
+ Module[key] = moduleOverrides[key];
+ }
+}
+
+
+
+// === Auto-generated preamble library stuff ===
+
+//========================================
+// Runtime code shared with compiler
+//========================================
+
+var Runtime = {
+ stackSave: function () {
+ return STACKTOP;
+ },
+ stackRestore: function (stackTop) {
+ STACKTOP = stackTop;
+ },
+ forceAlign: function (target, quantum) {
+ quantum = quantum || 4;
+ if (quantum == 1) return target;
+ if (isNumber(target) && isNumber(quantum)) {
+ return Math.ceil(target/quantum)*quantum;
+ } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
+ return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')';
+ }
+ return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
+ },
+ isNumberType: function (type) {
+ return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
+ },
+ isPointerType: function isPointerType(type) {
+ return type[type.length-1] == '*';
+},
+ isStructType: function isStructType(type) {
+ if (isPointerType(type)) return false;
+ if (isArrayType(type)) return true;
+ if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
+ // See comment in isStructPointerType()
+ return type[0] == '%';
+},
+ INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
+ FLOAT_TYPES: {"float":0,"double":0},
+ or64: function (x, y) {
+ var l = (x | 0) | (y | 0);
+ var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ and64: function (x, y) {
+ var l = (x | 0) & (y | 0);
+ var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ xor64: function (x, y) {
+ var l = (x | 0) ^ (y | 0);
+ var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
+ return l + h;
+ },
+ getNativeTypeSize: function (type) {
+ switch (type) {
+ case 'i1': case 'i8': return 1;
+ case 'i16': return 2;
+ case 'i32': return 4;
+ case 'i64': return 8;
+ case 'float': return 4;
+ case 'double': return 8;
+ default: {
+ if (type[type.length-1] === '*') {
+ return Runtime.QUANTUM_SIZE; // A pointer
+ } else if (type[0] === 'i') {
+ var bits = parseInt(type.substr(1));
+ assert(bits % 8 === 0);
+ return bits/8;
+ } else {
+ return 0;
+ }
+ }
+ }
+ },
+ getNativeFieldSize: function (type) {
+ return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
+ },
+ dedup: function dedup(items, ident) {
+ var seen = {};
+ if (ident) {
+ return items.filter(function(item) {
+ if (seen[item[ident]]) return false;
+ seen[item[ident]] = true;
+ return true;
+ });
+ } else {
+ return items.filter(function(item) {
+ if (seen[item]) return false;
+ seen[item] = true;
+ return true;
+ });
+ }
+},
+ set: function set() {
+ var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
+ var ret = {};
+ for (var i = 0; i < args.length; i++) {
+ ret[args[i]] = 0;
+ }
+ return ret;
+},
+ STACK_ALIGN: 8,
+ getAlignSize: function (type, size, vararg) {
+ // we align i64s and doubles on 64-bit boundaries, unlike x86
+ if (!vararg && (type == 'i64' || type == 'double')) return 8;
+ if (!type) return Math.min(size, 8); // align structures internally to 64 bits
+ return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
+ },
+ calculateStructAlignment: function calculateStructAlignment(type) {
+ type.flatSize = 0;
+ type.alignSize = 0;
+ var diffs = [];
+ var prev = -1;
+ var index = 0;
+ type.flatIndexes = type.fields.map(function(field) {
+ index++;
+ var size, alignSize;
+ if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
+ size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
+ alignSize = Runtime.getAlignSize(field, size);
+ } else if (Runtime.isStructType(field)) {
+ if (field[1] === '0') {
+ // this is [0 x something]. When inside another structure like here, it must be at the end,
+ // and it adds no size
+ // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');
+ size = 0;
+ if (Types.types[field]) {
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ } else {
+ alignSize = type.alignSize || QUANTUM_SIZE;
+ }
+ } else {
+ size = Types.types[field].flatSize;
+ alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
+ }
+ } else if (field[0] == 'b') {
+ // bN, large number field, like a [N x i8]
+ size = field.substr(1)|0;
+ alignSize = 1;
+ } else if (field[0] === '<') {
+ // vector type
+ size = alignSize = Types.types[field].flatSize; // fully aligned
+ } else if (field[0] === 'i') {
+ // illegal integer field, that could not be legalized because it is an internal structure field
+ // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
+ size = alignSize = parseInt(field.substr(1))/8;
+ assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
+ } else {
+ assert(false, 'invalid type for calculateStructAlignment');
+ }
+ if (type.packed) alignSize = 1;
+ type.alignSize = Math.max(type.alignSize, alignSize);
+ var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
+ type.flatSize = curr + size;
+ if (prev >= 0) {
+ diffs.push(curr-prev);
+ }
+ prev = curr;
+ return curr;
+ });
+ if (type.name_ && type.name_[0] === '[') {
+ // arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
+ // allocating a potentially huge array for [999999 x i8] etc.
+ type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
+ }
+ type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
+ if (diffs.length == 0) {
+ type.flatFactor = type.flatSize;
+ } else if (Runtime.dedup(diffs).length == 1) {
+ type.flatFactor = diffs[0];
+ }
+ type.needsFlattening = (type.flatFactor != 1);
+ return type.flatIndexes;
+ },
+ generateStructInfo: function (struct, typeName, offset) {
+ var type, alignment;
+ if (typeName) {
+ offset = offset || 0;
+ type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
+ if (!type) return null;
+ if (type.fields.length != struct.length) {
+ printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');
+ return null;
+ }
+ alignment = type.flatIndexes;
+ } else {
+ var type = { fields: struct.map(function(item) { return item[0] }) };
+ alignment = Runtime.calculateStructAlignment(type);
+ }
+ var ret = {
+ __size__: type.flatSize
+ };
+ if (typeName) {
+ struct.forEach(function(item, i) {
+ if (typeof item === 'string') {
+ ret[item] = alignment[i] + offset;
+ } else {
+ // embedded struct
+ var key;
+ for (var k in item) key = k;
+ ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
+ }
+ });
+ } else {
+ struct.forEach(function(item, i) {
+ ret[item[1]] = alignment[i];
+ });
+ }
+ return ret;
+ },
+ dynCall: function (sig, ptr, args) {
+ if (args && args.length) {
+ if (!args.splice) args = Array.prototype.slice.call(args);
+ args.splice(0, 0, ptr);
+ return Module['dynCall_' + sig].apply(null, args);
+ } else {
+ return Module['dynCall_' + sig].call(null, ptr);
+ }
+ },
+ functionPointers: [],
+ addFunction: function (func) {
+ for (var i = 0; i < Runtime.functionPointers.length; i++) {
+ if (!Runtime.functionPointers[i]) {
+ Runtime.functionPointers[i] = func;
+ return 2*(1 + i);
+ }
+ }
+ throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
+ },
+ removeFunction: function (index) {
+ Runtime.functionPointers[(index-2)/2] = null;
+ },
+ getAsmConst: function (code, numArgs) {
+ // code is a constant string on the heap, so we can cache these
+ if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
+ var func = Runtime.asmConstCache[code];
+ if (func) return func;
+ var args = [];
+ for (var i = 0; i < numArgs; i++) {
+ args.push(String.fromCharCode(36) + i); // $0, $1 etc
+ }
+ var source = Pointer_stringify(code);
+ if (source[0] === '"') {
+ // tolerate EM_ASM("..code..") even though EM_ASM(..code..) is correct
+ if (source.indexOf('"', 1) === source.length-1) {
+ source = source.substr(1, source.length-2);
+ } else {
+ // something invalid happened, e.g. EM_ASM("..code($0)..", input)
+ abort('invalid EM_ASM input |' + source + '|. Please use EM_ASM(..code..) (no quotes) or EM_ASM({ ..code($0).. }, input) (to input values)');
+ }
+ }
+ try {
+ var evalled = eval('(function(' + args.join(',') + '){ ' + source + ' })'); // new Function does not allow upvars in node
+ } catch(e) {
+ Module.printErr('error in executing inline EM_ASM code: ' + e + ' on: \n\n' + source + '\n\nwith args |' + args + '| (make sure to use the right one out of EM_ASM, EM_ASM_ARGS, etc.)');
+ throw e;
+ }
+ return Runtime.asmConstCache[code] = evalled;
+ },
+ warnOnce: function (text) {
+ if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
+ if (!Runtime.warnOnce.shown[text]) {
+ Runtime.warnOnce.shown[text] = 1;
+ Module.printErr(text);
+ }
+ },
+ funcWrappers: {},
+ getFuncWrapper: function (func, sig) {
+ assert(sig);
+ if (!Runtime.funcWrappers[func]) {
+ Runtime.funcWrappers[func] = function dynCall_wrapper() {
+ return Runtime.dynCall(sig, func, arguments);
+ };
+ }
+ return Runtime.funcWrappers[func];
+ },
+ UTF8Processor: function () {
+ var buffer = [];
+ var needed = 0;
+ this.processCChar = function (code) {
+ code = code & 0xFF;
+
+ if (buffer.length == 0) {
+ if ((code & 0x80) == 0x00) { // 0xxxxxxx
+ return String.fromCharCode(code);
+ }
+ buffer.push(code);
+ if ((code & 0xE0) == 0xC0) { // 110xxxxx
+ needed = 1;
+ } else if ((code & 0xF0) == 0xE0) { // 1110xxxx
+ needed = 2;
+ } else { // 11110xxx
+ needed = 3;
+ }
+ return '';
+ }
+
+ if (needed) {
+ buffer.push(code);
+ needed--;
+ if (needed > 0) return '';
+ }
+
+ var c1 = buffer[0];
+ var c2 = buffer[1];
+ var c3 = buffer[2];
+ var c4 = buffer[3];
+ var ret;
+ if (buffer.length == 2) {
+ ret = String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ } else if (buffer.length == 3) {
+ ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ } else {
+ // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |
+ ((c3 & 0x3F) << 6) | (c4 & 0x3F);
+ ret = String.fromCharCode(
+ Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,
+ (codePoint - 0x10000) % 0x400 + 0xDC00);
+ }
+ buffer.length = 0;
+ return ret;
+ }
+ this.processJSString = function processJSString(string) {
+ /* TODO: use TextEncoder when present,
+ var encoder = new TextEncoder();
+ encoder['encoding'] = "utf-8";
+ var utf8Array = encoder['encode'](aMsg.data);
+ */
+ string = unescape(encodeURIComponent(string));
+ var ret = [];
+ for (var i = 0; i < string.length; i++) {
+ ret.push(string.charCodeAt(i));
+ }
+ return ret;
+ }
+ },
+ getCompilerSetting: function (name) {
+ throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
+ },
+ stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+7)&-8); return ret; },
+ staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = (((STATICTOP)+7)&-8); return ret; },
+ dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = (((DYNAMICTOP)+7)&-8); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
+ alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },
+ makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*(+4294967296))) : ((+((low>>>0)))+((+((high|0)))*(+4294967296)))); return ret; },
+ GLOBAL_BASE: 8,
+ QUANTUM_SIZE: 4,
+ __dummy__: 0
+}
+
+
+Module['Runtime'] = Runtime;
+
+
+
+
+
+
+
+
+
+//========================================
+// Runtime essentials
+//========================================
+
+var __THREW__ = 0; // Used in checking for thrown exceptions.
+
+var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()
+var EXITSTATUS = 0;
+
+var undef = 0;
+// tempInt is used for 32-bit signed values or smaller. tempBigInt is used
+// for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
+var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
+var tempI64, tempI64b;
+var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
+
+function assert(condition, text) {
+ if (!condition) {
+ abort('Assertion failed: ' + text);
+ }
+}
+
+var globalScope = this;
+
+// C calling interface. A convenient way to call C functions (in C files, or
+// defined with extern "C").
+//
+// Note: LLVM optimizations can inline and remove functions, after which you will not be
+// able to call them. Closure can also do so. To avoid that, add your function to
+// the exports using something like
+//
+// -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]'
+//
+// @param ident The name of the C function (note that C++ functions will be name-mangled - use extern "C")
+// @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and
+// 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).
+// @param argTypes An array of the types of arguments for the function (if there are no arguments, this can be ommitted). Types are as in returnType,
+// except that 'array' is not possible (there is no way for us to know the length of the array)
+// @param args An array of the arguments to the function, as native JS values (as in returnType)
+// Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).
+// @return The return value, as a native JS value (as in returnType)
+function ccall(ident, returnType, argTypes, args) {
+ return ccallFunc(getCFunc(ident), returnType, argTypes, args);
+}
+Module["ccall"] = ccall;
+
+// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
+function getCFunc(ident) {
+ try {
+ var func = Module['_' + ident]; // closure exported function
+ if (!func) func = eval('_' + ident); // explicit lookup
+ } catch(e) {
+ }
+ assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
+ return func;
+}
+
+// Internal function that does a C call using a function, not an identifier
+function ccallFunc(func, returnType, argTypes, args) {
+ var stack = 0;
+ function toC(value, type) {
+ if (type == 'string') {
+ if (value === null || value === undefined || value === 0) return 0; // null string
+ value = intArrayFromString(value);
+ type = 'array';
+ }
+ if (type == 'array') {
+ if (!stack) stack = Runtime.stackSave();
+ var ret = Runtime.stackAlloc(value.length);
+ writeArrayToMemory(value, ret);
+ return ret;
+ }
+ return value;
+ }
+ function fromC(value, type) {
+ if (type == 'string') {
+ return Pointer_stringify(value);
+ }
+ assert(type != 'array');
+ return value;
+ }
+ var i = 0;
+ var cArgs = args ? args.map(function(arg) {
+ return toC(arg, argTypes[i++]);
+ }) : [];
+ var ret = fromC(func.apply(null, cArgs), returnType);
+ if (stack) Runtime.stackRestore(stack);
+ return ret;
+}
+
+// Returns a native JS wrapper for a C function. This is similar to ccall, but
+// returns a function you can call repeatedly in a normal way. For example:
+//
+// var my_function = cwrap('my_c_function', 'number', ['number', 'number']);
+// alert(my_function(5, 22));
+// alert(my_function(99, 12));
+//
+function cwrap(ident, returnType, argTypes) {
+ var func = getCFunc(ident);
+ return function() {
+ return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));
+ }
+}
+Module["cwrap"] = cwrap;
+
+// Sets a value in memory in a dynamic way at run-time. Uses the
+// type data. This is the same as makeSetValue, except that
+// makeSetValue is done at compile-time and generates the needed
+// code then, whereas this function picks the right code at
+// run-time.
+// Note that setValue and getValue only do *aligned* writes and reads!
+// Note that ccall uses JS types as for defining types, while setValue and
+// getValue need LLVM types ('i8', 'i32') - this is a lower-level operation
+function setValue(ptr, value, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': HEAP8[(ptr)]=value; break;
+ case 'i8': HEAP8[(ptr)]=value; break;
+ case 'i16': HEAP16[((ptr)>>1)]=value; break;
+ case 'i32': HEAP32[((ptr)>>2)]=value; break;
+ case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= (+1) ? (tempDouble > (+0) ? ((Math_min((+(Math_floor((tempDouble)/(+4294967296)))), (+4294967295)))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+4294967296))))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
+ case 'float': HEAPF32[((ptr)>>2)]=value; break;
+ case 'double': HEAPF64[((ptr)>>3)]=value; break;
+ default: abort('invalid type for setValue: ' + type);
+ }
+}
+Module['setValue'] = setValue;
+
+// Parallel to setValue.
+function getValue(ptr, type, noSafe) {
+ type = type || 'i8';
+ if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
+ switch(type) {
+ case 'i1': return HEAP8[(ptr)];
+ case 'i8': return HEAP8[(ptr)];
+ case 'i16': return HEAP16[((ptr)>>1)];
+ case 'i32': return HEAP32[((ptr)>>2)];
+ case 'i64': return HEAP32[((ptr)>>2)];
+ case 'float': return HEAPF32[((ptr)>>2)];
+ case 'double': return HEAPF64[((ptr)>>3)];
+ default: abort('invalid type for setValue: ' + type);
+ }
+ return null;
+}
+Module['getValue'] = getValue;
+
+var ALLOC_NORMAL = 0; // Tries to use _malloc()
+var ALLOC_STACK = 1; // Lives for the duration of the current function call
+var ALLOC_STATIC = 2; // Cannot be freed
+var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
+var ALLOC_NONE = 4; // Do not allocate
+Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
+Module['ALLOC_STACK'] = ALLOC_STACK;
+Module['ALLOC_STATIC'] = ALLOC_STATIC;
+Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;
+Module['ALLOC_NONE'] = ALLOC_NONE;
+
+// allocate(): This is for internal use. You can use it yourself as well, but the interface
+// is a little tricky (see docs right below). The reason is that it is optimized
+// for multiple syntaxes to save space in generated code. So you should
+// normally not use allocate(), and instead allocate memory using _malloc(),
+// initialize it with setValue(), and so forth.
+// @slab: An array of data, or a number. If a number, then the size of the block to allocate,
+// in *bytes* (note that this is sometimes confusing: the next parameter does not
+// affect this!)
+// @types: Either an array of types, one for each byte (or 0 if no type at that position),
+// or a single type which is used for the entire block. This only matters if there
+// is initial data - if @slab is a number, then this does not matter at all and is
+// ignored.
+// @allocator: How to allocate memory, see ALLOC_*
+function allocate(slab, types, allocator, ptr) {
+ var zeroinit, size;
+ if (typeof slab === 'number') {
+ zeroinit = true;
+ size = slab;
+ } else {
+ zeroinit = false;
+ size = slab.length;
+ }
+
+ var singleType = typeof types === 'string' ? types : null;
+
+ var ret;
+ if (allocator == ALLOC_NONE) {
+ ret = ptr;
+ } else {
+ ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
+ }
+
+ if (zeroinit) {
+ var ptr = ret, stop;
+ assert((ret & 3) == 0);
+ stop = ret + (size & ~3);
+ for (; ptr < stop; ptr += 4) {
+ HEAP32[((ptr)>>2)]=0;
+ }
+ stop = ret + size;
+ while (ptr < stop) {
+ HEAP8[((ptr++)|0)]=0;
+ }
+ return ret;
+ }
+
+ if (singleType === 'i8') {
+ if (slab.subarray || slab.slice) {
+ HEAPU8.set(slab, ret);
+ } else {
+ HEAPU8.set(new Uint8Array(slab), ret);
+ }
+ return ret;
+ }
+
+ var i = 0, type, typeSize, previousType;
+ while (i < size) {
+ var curr = slab[i];
+
+ if (typeof curr === 'function') {
+ curr = Runtime.getFunctionIndex(curr);
+ }
+
+ type = singleType || types[i];
+ if (type === 0) {
+ i++;
+ continue;
+ }
+
+ if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
+
+ setValue(ret+i, curr, type);
+
+ // no need to look up size unless type changes, so cache it
+ if (previousType !== type) {
+ typeSize = Runtime.getNativeTypeSize(type);
+ previousType = type;
+ }
+ i += typeSize;
+ }
+
+ return ret;
+}
+Module['allocate'] = allocate;
+
+function Pointer_stringify(ptr, /* optional */ length) {
+ // TODO: use TextDecoder
+ // Find the length, and check for UTF while doing so
+ var hasUtf = false;
+ var t;
+ var i = 0;
+ while (1) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ if (t >= 128) hasUtf = true;
+ else if (t == 0 && !length) break;
+ i++;
+ if (length && i == length) break;
+ }
+ if (!length) length = i;
+
+ var ret = '';
+
+ if (!hasUtf) {
+ var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
+ var curr;
+ while (length > 0) {
+ curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
+ ret = ret ? ret + curr : curr;
+ ptr += MAX_CHUNK;
+ length -= MAX_CHUNK;
+ }
+ return ret;
+ }
+
+ var utf8 = new Runtime.UTF8Processor();
+ for (i = 0; i < length; i++) {
+ t = HEAPU8[(((ptr)+(i))|0)];
+ ret += utf8.processCChar(t);
+ }
+ return ret;
+}
+Module['Pointer_stringify'] = Pointer_stringify;
+
+// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF16ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
+ if (codeUnit == 0)
+ return str;
+ ++i;
+ // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
+ str += String.fromCharCode(codeUnit);
+ }
+}
+Module['UTF16ToString'] = UTF16ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
+function stringToUTF16(str, outPtr) {
+ for(var i = 0; i < str.length; ++i) {
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
+ HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP16[(((outPtr)+(str.length*2))>>1)]=0;
+}
+Module['stringToUTF16'] = stringToUTF16;
+
+// Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns
+// a copy of that string as a Javascript String object.
+function UTF32ToString(ptr) {
+ var i = 0;
+
+ var str = '';
+ while (1) {
+ var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
+ if (utf32 == 0)
+ return str;
+ ++i;
+ // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
+ if (utf32 >= 0x10000) {
+ var ch = utf32 - 0x10000;
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
+ } else {
+ str += String.fromCharCode(utf32);
+ }
+ }
+}
+Module['UTF32ToString'] = UTF32ToString;
+
+// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
+// null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
+// but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.
+function stringToUTF32(str, outPtr) {
+ var iChar = 0;
+ for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
+ var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
+ var trailSurrogate = str.charCodeAt(++iCodeUnit);
+ codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
+ }
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit;
+ ++iChar;
+ }
+ // Null-terminate the pointer to the HEAP.
+ HEAP32[(((outPtr)+(iChar*4))>>2)]=0;
+}
+Module['stringToUTF32'] = stringToUTF32;
+
+function demangle(func) {
+ var i = 3;
+ // params, etc.
+ var basicTypes = {
+ 'v': 'void',
+ 'b': 'bool',
+ 'c': 'char',
+ 's': 'short',
+ 'i': 'int',
+ 'l': 'long',
+ 'f': 'float',
+ 'd': 'double',
+ 'w': 'wchar_t',
+ 'a': 'signed char',
+ 'h': 'unsigned char',
+ 't': 'unsigned short',
+ 'j': 'unsigned int',
+ 'm': 'unsigned long',
+ 'x': 'long long',
+ 'y': 'unsigned long long',
+ 'z': '...'
+ };
+ var subs = [];
+ var first = true;
+ function dump(x) {
+ //return;
+ if (x) Module.print(x);
+ Module.print(func);
+ var pre = '';
+ for (var a = 0; a < i; a++) pre += ' ';
+ Module.print (pre + '^');
+ }
+ function parseNested() {
+ i++;
+ if (func[i] === 'K') i++; // ignore const
+ var parts = [];
+ while (func[i] !== 'E') {
+ if (func[i] === 'S') { // substitution
+ i++;
+ var next = func.indexOf('_', i);
+ var num = func.substring(i, next) || 0;
+ parts.push(subs[num] || '?');
+ i = next+1;
+ continue;
+ }
+ if (func[i] === 'C') { // constructor
+ parts.push(parts[parts.length-1]);
+ i += 2;
+ continue;
+ }
+ var size = parseInt(func.substr(i));
+ var pre = size.toString().length;
+ if (!size || !pre) { i--; break; } // counter i++ below us
+ var curr = func.substr(i + pre, size);
+ parts.push(curr);
+ subs.push(curr);
+ i += pre + size;
+ }
+ i++; // skip E
+ return parts;
+ }
+ function parse(rawList, limit, allowVoid) { // main parser
+ limit = limit || Infinity;
+ var ret = '', list = [];
+ function flushList() {
+ return '(' + list.join(', ') + ')';
+ }
+ var name;
+ if (func[i] === 'N') {
+ // namespaced N-E
+ name = parseNested().join('::');
+ limit--;
+ if (limit === 0) return rawList ? [name] : name;
+ } else {
+ // not namespaced
+ if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
+ var size = parseInt(func.substr(i));
+ if (size) {
+ var pre = size.toString().length;
+ name = func.substr(i + pre, size);
+ i += pre + size;
+ }
+ }
+ first = false;
+ if (func[i] === 'I') {
+ i++;
+ var iList = parse(true);
+ var iRet = parse(true, 1, true);
+ ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
+ } else {
+ ret = name;
+ }
+ paramLoop: while (i < func.length && limit-- > 0) {
+ //dump('paramLoop');
+ var c = func[i++];
+ if (c in basicTypes) {
+ list.push(basicTypes[c]);
+ } else {
+ switch (c) {
+ case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
+ case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
+ case 'L': { // literal
+ i++; // skip basic type
+ var end = func.indexOf('E', i);
+ var size = end - i;
+ list.push(func.substr(i, size));
+ i += size + 2; // size + 'EE'
+ break;
+ }
+ case 'A': { // array
+ var size = parseInt(func.substr(i));
+ i += size.toString().length;
+ if (func[i] !== '_') throw '?';
+ i++; // skip _
+ list.push(parse(true, 1, true)[0] + ' [' + size + ']');
+ break;
+ }
+ case 'E': break paramLoop;
+ default: ret += '?' + c; break paramLoop;
+ }
+ }
+ }
+ if (!allowVoid && list.length === 1 && list[0] === 'void') list = []; // avoid (void)
+ if (rawList) {
+ if (ret) {
+ list.push(ret + '?');
+ }
+ return list;
+ } else {
+ return ret + flushList();
+ }
+ }
+ try {
+ // Special-case the entry point, since its name differs from other name mangling.
+ if (func == 'Object._main' || func == '_main') {
+ return 'main()';
+ }
+ if (typeof func === 'number') func = Pointer_stringify(func);
+ if (func[0] !== '_') return func;
+ if (func[1] !== '_') return func; // C function
+ if (func[2] !== 'Z') return func;
+ switch (func[3]) {
+ case 'n': return 'operator new()';
+ case 'd': return 'operator delete()';
+ }
+ return parse();
+ } catch(e) {
+ return func;
+ }
+}
+
+function demangleAll(text) {
+ return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });
+}
+
+function stackTrace() {
+ var stack = new Error().stack;
+ return stack ? demangleAll(stack) : '(no stack trace available)'; // Stack trace is not available at least on IE10 and Safari 6.
+}
+
+// Memory management
+
+var PAGE_SIZE = 4096;
+function alignMemoryPage(x) {
+ return (x+4095)&-4096;
+}
+
+var HEAP;
+var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
+
+var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area
+var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area
+var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk
+
+function enlargeMemory() {
+ abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
+}
+
+var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
+var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 134217728;
+var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
+
+var totalMemory = 4096;
+while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
+ if (totalMemory < 16*1024*1024) {
+ totalMemory *= 2;
+ } else {
+ totalMemory += 16*1024*1024
+ }
+}
+if (totalMemory !== TOTAL_MEMORY) {
+ Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
+ TOTAL_MEMORY = totalMemory;
+}
+
+// Initialize the runtime's memory
+// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
+assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
+ 'JS engine does not provide full typed array support');
+
+var buffer = new ArrayBuffer(TOTAL_MEMORY);
+HEAP8 = new Int8Array(buffer);
+HEAP16 = new Int16Array(buffer);
+HEAP32 = new Int32Array(buffer);
+HEAPU8 = new Uint8Array(buffer);
+HEAPU16 = new Uint16Array(buffer);
+HEAPU32 = new Uint32Array(buffer);
+HEAPF32 = new Float32Array(buffer);
+HEAPF64 = new Float64Array(buffer);
+
+// Endianness check (note: assumes compiler arch was little-endian)
+HEAP32[0] = 255;
+assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
+
+Module['HEAP'] = HEAP;
+Module['HEAP8'] = HEAP8;
+Module['HEAP16'] = HEAP16;
+Module['HEAP32'] = HEAP32;
+Module['HEAPU8'] = HEAPU8;
+Module['HEAPU16'] = HEAPU16;
+Module['HEAPU32'] = HEAPU32;
+Module['HEAPF32'] = HEAPF32;
+Module['HEAPF64'] = HEAPF64;
+
+function callRuntimeCallbacks(callbacks) {
+ while(callbacks.length > 0) {
+ var callback = callbacks.shift();
+ if (typeof callback == 'function') {
+ callback();
+ continue;
+ }
+ var func = callback.func;
+ if (typeof func === 'number') {
+ if (callback.arg === undefined) {
+ Runtime.dynCall('v', func);
+ } else {
+ Runtime.dynCall('vi', func, [callback.arg]);
+ }
+ } else {
+ func(callback.arg === undefined ? null : callback.arg);
+ }
+ }
+}
+
+var __ATPRERUN__ = []; // functions called before the runtime is initialized
+var __ATINIT__ = []; // functions called during startup
+var __ATMAIN__ = []; // functions called when main() is to be run
+var __ATEXIT__ = []; // functions called during shutdown
+var __ATPOSTRUN__ = []; // functions called after the runtime has exited
+
+var runtimeInitialized = false;
+
+function preRun() {
+ // compatibility - merge in anything from Module['preRun'] at this time
+ if (Module['preRun']) {
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
+ while (Module['preRun'].length) {
+ addOnPreRun(Module['preRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPRERUN__);
+}
+
+function ensureInitRuntime() {
+ if (runtimeInitialized) return;
+ runtimeInitialized = true;
+ callRuntimeCallbacks(__ATINIT__);
+}
+
+function preMain() {
+ callRuntimeCallbacks(__ATMAIN__);
+}
+
+function exitRuntime() {
+ callRuntimeCallbacks(__ATEXIT__);
+}
+
+function postRun() {
+ // compatibility - merge in anything from Module['postRun'] at this time
+ if (Module['postRun']) {
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
+ while (Module['postRun'].length) {
+ addOnPostRun(Module['postRun'].shift());
+ }
+ }
+ callRuntimeCallbacks(__ATPOSTRUN__);
+}
+
+function addOnPreRun(cb) {
+ __ATPRERUN__.unshift(cb);
+}
+Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;
+
+function addOnInit(cb) {
+ __ATINIT__.unshift(cb);
+}
+Module['addOnInit'] = Module.addOnInit = addOnInit;
+
+function addOnPreMain(cb) {
+ __ATMAIN__.unshift(cb);
+}
+Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;
+
+function addOnExit(cb) {
+ __ATEXIT__.unshift(cb);
+}
+Module['addOnExit'] = Module.addOnExit = addOnExit;
+
+function addOnPostRun(cb) {
+ __ATPOSTRUN__.unshift(cb);
+}
+Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;
+
+// Tools
+
+// This processes a JS string into a C-line array of numbers, 0-terminated.
+// For LLVM-originating strings, see parser.js:parseLLVMString function
+function intArrayFromString(stringy, dontAddNull, length /* optional */) {
+ var ret = (new Runtime.UTF8Processor()).processJSString(stringy);
+ if (length) {
+ ret.length = length;
+ }
+ if (!dontAddNull) {
+ ret.push(0);
+ }
+ return ret;
+}
+Module['intArrayFromString'] = intArrayFromString;
+
+function intArrayToString(array) {
+ var ret = [];
+ for (var i = 0; i < array.length; i++) {
+ var chr = array[i];
+ if (chr > 0xFF) {
+ chr &= 0xFF;
+ }
+ ret.push(String.fromCharCode(chr));
+ }
+ return ret.join('');
+}
+Module['intArrayToString'] = intArrayToString;
+
+// Write a Javascript array to somewhere in the heap
+function writeStringToMemory(string, buffer, dontAddNull) {
+ var array = intArrayFromString(string, dontAddNull);
+ var i = 0;
+ while (i < array.length) {
+ var chr = array[i];
+ HEAP8[(((buffer)+(i))|0)]=chr;
+ i = i + 1;
+ }
+}
+Module['writeStringToMemory'] = writeStringToMemory;
+
+function writeArrayToMemory(array, buffer) {
+ for (var i = 0; i < array.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=array[i];
+ }
+}
+Module['writeArrayToMemory'] = writeArrayToMemory;
+
+function writeAsciiToMemory(str, buffer, dontAddNull) {
+ for (var i = 0; i < str.length; i++) {
+ HEAP8[(((buffer)+(i))|0)]=str.charCodeAt(i);
+ }
+ if (!dontAddNull) HEAP8[(((buffer)+(str.length))|0)]=0;
+}
+Module['writeAsciiToMemory'] = writeAsciiToMemory;
+
+function unSign(value, bits, ignore) {
+ if (value >= 0) {
+ return value;
+ }
+ return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
+ : Math.pow(2, bits) + value;
+}
+function reSign(value, bits, ignore) {
+ if (value <= 0) {
+ return value;
+ }
+ var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
+ : Math.pow(2, bits-1);
+ if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
+ // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
+ // TODO: In i64 mode 1, resign the two parts separately and safely
+ value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
+ }
+ return value;
+}
+
+// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
+if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
+ var ah = a >>> 16;
+ var al = a & 0xffff;
+ var bh = b >>> 16;
+ var bl = b & 0xffff;
+ return (al*bl + ((ah*bl + al*bh) << 16))|0;
+};
+Math.imul = Math['imul'];
+
+
+var Math_abs = Math.abs;
+var Math_cos = Math.cos;
+var Math_sin = Math.sin;
+var Math_tan = Math.tan;
+var Math_acos = Math.acos;
+var Math_asin = Math.asin;
+var Math_atan = Math.atan;
+var Math_atan2 = Math.atan2;
+var Math_exp = Math.exp;
+var Math_log = Math.log;
+var Math_sqrt = Math.sqrt;
+var Math_ceil = Math.ceil;
+var Math_floor = Math.floor;
+var Math_pow = Math.pow;
+var Math_imul = Math.imul;
+var Math_fround = Math.fround;
+var Math_min = Math.min;
+
+// A counter of dependencies for calling run(). If we need to
+// do asynchronous work before running, increment this and
+// decrement it. Incrementing must happen in a place like
+// PRE_RUN_ADDITIONS (used by emcc to add file preloading).
+// Note that you can add dependencies in preRun, even though
+// it happens right before run - run will be postponed until
+// the dependencies are met.
+var runDependencies = 0;
+var runDependencyWatcher = null;
+var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
+
+function addRunDependency(id) {
+ runDependencies++;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+}
+Module['addRunDependency'] = addRunDependency;
+function removeRunDependency(id) {
+ runDependencies--;
+ if (Module['monitorRunDependencies']) {
+ Module['monitorRunDependencies'](runDependencies);
+ }
+ if (runDependencies == 0) {
+ if (runDependencyWatcher !== null) {
+ clearInterval(runDependencyWatcher);
+ runDependencyWatcher = null;
+ }
+ if (dependenciesFulfilled) {
+ var callback = dependenciesFulfilled;
+ dependenciesFulfilled = null;
+ callback(); // can add another dependenciesFulfilled
+ }
+ }
+}
+Module['removeRunDependency'] = removeRunDependency;
+
+Module["preloadedImages"] = {}; // maps url to image data
+Module["preloadedAudios"] = {}; // maps url to audio data
+
+
+var memoryInitializer = null;
+
+// === Body ===
+
+
+
+
+
+STATIC_BASE = 8;
+
+STATICTOP = STATIC_BASE + Runtime.alignMemory(14963);
+/* global initializers */ __ATINIT__.push();
+
+
+/* memory initializer */ allocate([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,115,105,122,101,115,58,32,37,100,44,37,100,10,0,0,0,100,101,99,111,109,112,114,101,115,115,101,100,83,105,122,101,32,61,61,32,115,105,122,101,0,0,0,0,0,0,0,0,47,116,109,112,47,101,109,115,99,114,105,112,116,101,110,95,116,101,109,112,47,122,108,105,98,46,99,0,0,0,0,0,100,111,105,116,0,0,0,0,115,116,114,99,109,112,40,98,117,102,102,101,114,44,32,98,117,102,102,101,114,51,41,32,61,61,32,48,0,0,0,0,101,114,114,111,114,58,32,37,100,92,110,0,0,0,0,0,111,107,46,0,0,0,0,0,49,46,50,46,53,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,4,0,4,0,8,0,4,0,2,0,0,0,4,0,5,0,16,0,8,0,2,0,0,0,4,0,6,0,32,0,32,0,2,0,0,0,4,0,4,0,16,0,16,0,3,0,0,0,8,0,16,0,32,0,32,0,3,0,0,0,8,0,16,0,128,0,128,0,3,0,0,0,8,0,32,0,128,0,0,1,3,0,0,0,32,0,128,0,2,1,0,4,3,0,0,0,32,0,2,1,2,1,0,16,3,0,0,0,0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,16,17,18,18,19,19,20,20,20,20,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,0,1,2,3,4,5,6,7,8,8,9,9,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,112,4,0,0,104,9,0,0,1,1,0,0,30,1,0,0,15,0,0,0,0,0,0,0,240,8,0,0,88,10,0,0,0,0,0,0,30,0,0,0,15,0,0,0,0,0,0,0,0,0,0,0,96,11,0,0,0,0,0,0,19,0,0,0,7,0,0,0,0,0,0,0,12,0,8,0,140,0,8,0,76,0,8,0,204,0,8,0,44,0,8,0,172,0,8,0,108,0,8,0,236,0,8,0,28,0,8,0,156,0,8,0,92,0,8,0,220,0,8,0,60,0,8,0,188,0,8,0,124,0,8,0,252,0,8,0,2,0,8,0,130,0,8,0,66,0,8,0,194,0,8,0,34,0,8,0,162,0,8,0,98,0,8,0,226,0,8,0,18,0,8,0,146,0,8,0,82,0,8,0,210,0,8,0,50,0,8,0,178,0,8,0,114,0,8,0,242,0,8,0,10,0,8,0,138,0,8,0,74,0,8,0,202,0,8,0,42,0,8,0,170,0,8,0,106,0,8,0,234,0,8,0,26,0,8,0,154,0,8,0,90,0,8,0,218,0,8,0,58,0,8,0,186,0,8,0,122,0,8,0,250,0,8,0,6,0,8,0,134,0,8,0,70,0,8,0,198,0,8,0,38,0,8,0,166,0,8,0,102,0,8,0,230,0,8,0,22,0,8,0,150,0,8,0,86,0,8,0,214,0,8,0,54,0,8,0,182,0,8,0,118,0,8,0,246,0,8,0,14,0,8,0,142,0,8,0,78,0,8,0,206,0,8,0,46,0,8,0,174,0,8,0,110,0,8,0,238,0,8,0,30,0,8,0,158,0,8,0,94,0,8,0,222,0,8,0,62,0,8,0,190,0,8,0,126,0,8,0,254,0,8,0,1,0,8,0,129,0,8,0,65,0,8,0,193,0,8,0,33,0,8,0,161,0,8,0,97,0,8,0,225,0,8,0,17,0,8,0,145,0,8,0,81,0,8,0,209,0,8,0,49,0,8,0,177,0,8,0,113,0,8,0,241,0,8,0,9,0,8,0,137,0,8,0,73,0,8,0,201,0,8,0,41,0,8,0,169,0,8,0,105,0,8,0,233,0,8,0,25,0,8,0,153,0,8,0,89,0,8,0,217,0,8,0,57,0,8,0,185,0,8,0,121,0,8,0,249,0,8,0,5,0,8,0,133,0,8,0,69,0,8,0,197,0,8,0,37,0,8,0,165,0,8,0,101,0,8,0,229,0,8,0,21,0,8,0,149,0,8,0,85,0,8,0,213,0,8,0,53,0,8,0,181,0,8,0,117,0,8,0,245,0,8,0,13,0,8,0,141,0,8,0,77,0,8,0,205,0,8,0,45,0,8,0,173,0,8,0,109,0,8,0,237,0,8,0,29,0,8,0,157,0,8,0,93,0,8,0,221,0,8,0,61,0,8,0,189,0,8,0,125,0,8,0,253,0,8,0,19,0,9,0,19,1,9,0,147,0,9,0,147,1,9,0,83,0,9,0,83,1,9,0,211,0,9,0,211,1,9,0,51,0,9,0,51,1,9,0,179,0,9,0,179,1,9,0,115,0,9,0,115,1,9,0,243,0,9,0,243,1,9,0,11,0,9,0,11,1,9,0,139,0,9,0,139,1,9,0,75,0,9,0,75,1,9,0,203,0,9,0,203,1,9,0,43,0,9,0,43,1,9,0,171,0,9,0,171,1,9,0,107,0,9,0,107,1,9,0,235,0,9,0,235,1,9,0,27,0,9,0,27,1,9,0,155,0,9,0,155,1,9,0,91,0,9,0,91,1,9,0,219,0,9,0,219,1,9,0,59,0,9,0,59,1,9,0,187,0,9,0,187,1,9,0,123,0,9,0,123,1,9,0,251,0,9,0,251,1,9,0,7,0,9,0,7,1,9,0,135,0,9,0,135,1,9,0,71,0,9,0,71,1,9,0,199,0,9,0,199,1,9,0,39,0,9,0,39,1,9,0,167,0,9,0,167,1,9,0,103,0,9,0,103,1,9,0,231,0,9,0,231,1,9,0,23,0,9,0,23,1,9,0,151,0,9,0,151,1,9,0,87,0,9,0,87,1,9,0,215,0,9,0,215,1,9,0,55,0,9,0,55,1,9,0,183,0,9,0,183,1,9,0,119,0,9,0,119,1,9,0,247,0,9,0,247,1,9,0,15,0,9,0,15,1,9,0,143,0,9,0,143,1,9,0,79,0,9,0,79,1,9,0,207,0,9,0,207,1,9,0,47,0,9,0,47,1,9,0,175,0,9,0,175,1,9,0,111,0,9,0,111,1,9,0,239,0,9,0,239,1,9,0,31,0,9,0,31,1,9,0,159,0,9,0,159,1,9,0,95,0,9,0,95,1,9,0,223,0,9,0,223,1,9,0,63,0,9,0,63,1,9,0,191,0,9,0,191,1,9,0,127,0,9,0,127,1,9,0,255,0,9,0,255,1,9,0,0,0,7,0,64,0,7,0,32,0,7,0,96,0,7,0,16,0,7,0,80,0,7,0,48,0,7,0,112,0,7,0,8,0,7,0,72,0,7,0,40,0,7,0,104,0,7,0,24,0,7,0,88,0,7,0,56,0,7,0,120,0,7,0,4,0,7,0,68,0,7,0,36,0,7,0,100,0,7,0,20,0,7,0,84,0,7,0,52,0,7,0,116,0,7,0,3,0,8,0,131,0,8,0,67,0,8,0,195,0,8,0,35,0,8,0,163,0,8,0,99,0,8,0,227,0,8,0,0,0,5,0,16,0,5,0,8,0,5,0,24,0,5,0,4,0,5,0,20,0,5,0,12,0,5,0,28,0,5,0,2,0,5,0,18,0,5,0,10,0,5,0,26,0,5,0,6,0,5,0,22,0,5,0,14,0,5,0,30,0,5,0,1,0,5,0,17,0,5,0,9,0,5,0,25,0,5,0,5,0,5,0,21,0,5,0,13,0,5,0,29,0,5,0,3,0,5,0,19,0,5,0,11,0,5,0,27,0,5,0,7,0,5,0,23,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,4,0,0,0,4,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,10,0,0,0,12,0,0,0,14,0,0,0,16,0,0,0,20,0,0,0,24,0,0,0,28,0,0,0,32,0,0,0,40,0,0,0,48,0,0,0,56,0,0,0,64,0,0,0,80,0,0,0,96,0,0,0,112,0,0,0,128,0,0,0,160,0,0,0,192,0,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,5,0,0,0,5,0,0,0,6,0,0,0,6,0,0,0,7,0,0,0,7,0,0,0,8,0,0,0,8,0,0,0,9,0,0,0,9,0,0,0,10,0,0,0,10,0,0,0,11,0,0,0,11,0,0,0,12,0,0,0,12,0,0,0,13,0,0,0,13,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,12,0,0,0,16,0,0,0,24,0,0,0,32,0,0,0,48,0,0,0,64,0,0,0,96,0,0,0,128,0,0,0,192,0,0,0,0,1,0,0,128,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,12,0,0,0,16,0,0,0,24,0,0,0,32,0,0,0,48,0,0,0,64,0,0,0,96,0,0,16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,7,0,0,0,0,0,0,0,49,46,50,46,53,0,0,0,110,101,101,100,32,100,105,99,116,105,111,110,97,114,121,0,115,116,114,101,97,109,32,101,110,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,102,105,108,101,32,101,114,114,111,114,0,0,0,0,0,0,115,116,114,101,97,109,32,101,114,114,111,114,0,0,0,0,100,97,116,97,32,101,114,114,111,114,0,0,0,0,0,0,105,110,115,117,102,102,105,99,105,101,110,116,32,109,101,109,111,114,121,0,0,0,0,0,98,117,102,102,101,114,32,101,114,114,111,114,0,0,0,0,105,110,99,111,109,112,97,116,105,98,108,101,32,118,101,114,115,105,111,110,0,0,0,0,184,11,0,0,200,11,0,0,216,11,0,0,224,11,0,0,240,11,0,0,0,12,0,0,16,12,0,0,40,12,0,0,56,12,0,0,216,11,0,0,0,0,0,0,150,48,7,119,44,97,14,238,186,81,9,153,25,196,109,7,143,244,106,112,53,165,99,233,163,149,100,158,50,136,219,14,164,184,220,121,30,233,213,224,136,217,210,151,43,76,182,9,189,124,177,126,7,45,184,231,145,29,191,144,100,16,183,29,242,32,176,106,72,113,185,243,222,65,190,132,125,212,218,26,235,228,221,109,81,181,212,244,199,133,211,131,86,152,108,19,192,168,107,100,122,249,98,253,236,201,101,138,79,92,1,20,217,108,6,99,99,61,15,250,245,13,8,141,200,32,110,59,94,16,105,76,228,65,96,213,114,113,103,162,209,228,3,60,71,212,4,75,253,133,13,210,107,181,10,165,250,168,181,53,108,152,178,66,214,201,187,219,64,249,188,172,227,108,216,50,117,92,223,69,207,13,214,220,89,61,209,171,172,48,217,38,58,0,222,81,128,81,215,200,22,97,208,191,181,244,180,33,35,196,179,86,153,149,186,207,15,165,189,184,158,184,2,40,8,136,5,95,178,217,12,198,36,233,11,177,135,124,111,47,17,76,104,88,171,29,97,193,61,45,102,182,144,65,220,118,6,113,219,1,188,32,210,152,42,16,213,239,137,133,177,113,31,181,182,6,165,228,191,159,51,212,184,232,162,201,7,120,52,249,0,15,142,168,9,150,24,152,14,225,187,13,106,127,45,61,109,8,151,108,100,145,1,92,99,230,244,81,107,107,98,97,108,28,216,48,101,133,78,0,98,242,237,149,6,108,123,165,1,27,193,244,8,130,87,196,15,245,198,217,176,101,80,233,183,18,234,184,190,139,124,136,185,252,223,29,221,98,73,45,218,21,243,124,211,140,101,76,212,251,88,97,178,77,206,81,181,58,116,0,188,163,226,48,187,212,65,165,223,74,215,149,216,61,109,196,209,164,251,244,214,211,106,233,105,67,252,217,110,52,70,136,103,173,208,184,96,218,115,45,4,68,229,29,3,51,95,76,10,170,201,124,13,221,60,113,5,80,170,65,2,39,16,16,11,190,134,32,12,201,37,181,104,87,179,133,111,32,9,212,102,185,159,228,97,206,14,249,222,94,152,201,217,41,34,152,208,176,180,168,215,199,23,61,179,89,129,13,180,46,59,92,189,183,173,108,186,192,32,131,184,237,182,179,191,154,12,226,182,3,154,210,177,116,57,71,213,234,175,119,210,157,21,38,219,4,131,22,220,115,18,11,99,227,132,59,100,148,62,106,109,13,168,90,106,122,11,207,14,228,157,255,9,147,39,174,0,10,177,158,7,125,68,147,15,240,210,163,8,135,104,242,1,30,254,194,6,105,93,87,98,247,203,103,101,128,113,54,108,25,231,6,107,110,118,27,212,254,224,43,211,137,90,122,218,16,204,74,221,103,111,223,185,249,249,239,190,142,67,190,183,23,213,142,176,96,232,163,214,214,126,147,209,161,196,194,216,56,82,242,223,79,241,103,187,209,103,87,188,166,221,6,181,63,75,54,178,72,218,43,13,216,76,27,10,175,246,74,3,54,96,122,4,65,195,239,96,223,85,223,103,168,239,142,110,49,121,190,105,70,140,179,97,203,26,131,102,188,160,210,111,37,54,226,104,82,149,119,12,204,3,71,11,187,185,22,2,34,47,38,5,85,190,59,186,197,40,11,189,178,146,90,180,43,4,106,179,92,167,255,215,194,49,207,208,181,139,158,217,44,29,174,222,91,176,194,100,155,38,242,99,236,156,163,106,117,10,147,109,2,169,6,9,156,63,54,14,235,133,103,7,114,19,87,0,5,130,74,191,149,20,122,184,226,174,43,177,123,56,27,182,12,155,142,210,146,13,190,213,229,183,239,220,124,33,223,219,11,212,210,211,134,66,226,212,241,248,179,221,104,110,131,218,31,205,22,190,129,91,38,185,246,225,119,176,111,119,71,183,24,230,90,8,136,112,106,15,255,202,59,6,102,92,11,1,17,255,158,101,143,105,174,98,248,211,255,107,97,69,207,108,22,120,226,10,160,238,210,13,215,84,131,4,78,194,179,3,57,97,38,103,167,247,22,96,208,77,71,105,73,219,119,110,62,74,106,209,174,220,90,214,217,102,11,223,64,240,59,216,55,83,174,188,169,197,158,187,222,127,207,178,71,233,255,181,48,28,242,189,189,138,194,186,202,48,147,179,83,166,163,180,36,5,54,208,186,147,6,215,205,41,87,222,84,191,103,217,35,46,122,102,179,184,74,97,196,2,27,104,93,148,43,111,42,55,190,11,180,161,142,12,195,27,223,5,90,141,239,2,45,0,0,0,0,65,49,27,25,130,98,54,50,195,83,45,43,4,197,108,100,69,244,119,125,134,167,90,86,199,150,65,79,8,138,217,200,73,187,194,209,138,232,239,250,203,217,244,227,12,79,181,172,77,126,174,181,142,45,131,158,207,28,152,135,81,18,194,74,16,35,217,83,211,112,244,120,146,65,239,97,85,215,174,46,20,230,181,55,215,181,152,28,150,132,131,5,89,152,27,130,24,169,0,155,219,250,45,176,154,203,54,169,93,93,119,230,28,108,108,255,223,63,65,212,158,14,90,205,162,36,132,149,227,21,159,140,32,70,178,167,97,119,169,190,166,225,232,241,231,208,243,232,36,131,222,195,101,178,197,218,170,174,93,93,235,159,70,68,40,204,107,111,105,253,112,118,174,107,49,57,239,90,42,32,44,9,7,11,109,56,28,18,243,54,70,223,178,7,93,198,113,84,112,237,48,101,107,244,247,243,42,187,182,194,49,162,117,145,28,137,52,160,7,144,251,188,159,23,186,141,132,14,121,222,169,37,56,239,178,60,255,121,243,115,190,72,232,106,125,27,197,65,60,42,222,88,5,79,121,240,68,126,98,233,135,45,79,194,198,28,84,219,1,138,21,148,64,187,14,141,131,232,35,166,194,217,56,191,13,197,160,56,76,244,187,33,143,167,150,10,206,150,141,19,9,0,204,92,72,49,215,69,139,98,250,110,202,83,225,119,84,93,187,186,21,108,160,163,214,63,141,136,151,14,150,145,80,152,215,222,17,169,204,199,210,250,225,236,147,203,250,245,92,215,98,114,29,230,121,107,222,181,84,64,159,132,79,89,88,18,14,22,25,35,21,15,218,112,56,36,155,65,35,61,167,107,253,101,230,90,230,124,37,9,203,87,100,56,208,78,163,174,145,1,226,159,138,24,33,204,167,51,96,253,188,42,175,225,36,173,238,208,63,180,45,131,18,159,108,178,9,134,171,36,72,201,234,21,83,208,41,70,126,251,104,119,101,226,246,121,63,47,183,72,36,54,116,27,9,29,53,42,18,4,242,188,83,75,179,141,72,82,112,222,101,121,49,239,126,96,254,243,230,231,191,194,253,254,124,145,208,213,61,160,203,204,250,54,138,131,187,7,145,154,120,84,188,177,57,101,167,168,75,152,131,59,10,169,152,34,201,250,181,9,136,203,174,16,79,93,239,95,14,108,244,70,205,63,217,109,140,14,194,116,67,18,90,243,2,35,65,234,193,112,108,193,128,65,119,216,71,215,54,151,6,230,45,142,197,181,0,165,132,132,27,188,26,138,65,113,91,187,90,104,152,232,119,67,217,217,108,90,30,79,45,21,95,126,54,12,156,45,27,39,221,28,0,62,18,0,152,185,83,49,131,160,144,98,174,139,209,83,181,146,22,197,244,221,87,244,239,196,148,167,194,239,213,150,217,246,233,188,7,174,168,141,28,183,107,222,49,156,42,239,42,133,237,121,107,202,172,72,112,211,111,27,93,248,46,42,70,225,225,54,222,102,160,7,197,127,99,84,232,84,34,101,243,77,229,243,178,2,164,194,169,27,103,145,132,48,38,160,159,41,184,174,197,228,249,159,222,253,58,204,243,214,123,253,232,207,188,107,169,128,253,90,178,153,62,9,159,178,127,56,132,171,176,36,28,44,241,21,7,53,50,70,42,30,115,119,49,7,180,225,112,72,245,208,107,81,54,131,70,122,119,178,93,99,78,215,250,203,15,230,225,210,204,181,204,249,141,132,215,224,74,18,150,175,11,35,141,182,200,112,160,157,137,65,187,132,70,93,35,3,7,108,56,26,196,63,21,49,133,14,14,40,66,152,79,103,3,169,84,126,192,250,121,85,129,203,98,76,31,197,56,129,94,244,35,152,157,167,14,179,220,150,21,170,27,0,84,229,90,49,79,252,153,98,98,215,216,83,121,206,23,79,225,73,86,126,250,80,149,45,215,123,212,28,204,98,19,138,141,45,82,187,150,52,145,232,187,31,208,217,160,6,236,243,126,94,173,194,101,71,110,145,72,108,47,160,83,117,232,54,18,58,169,7,9,35,106,84,36,8,43,101,63,17,228,121,167,150,165,72,188,143,102,27,145,164,39,42,138,189,224,188,203,242,161,141,208,235,98,222,253,192,35,239,230,217,189,225,188,20,252,208,167,13,63,131,138,38,126,178,145,63,185,36,208,112,248,21,203,105,59,70,230,66,122,119,253,91,181,107,101,220,244,90,126,197,55,9,83,238,118,56,72,247,177,174,9,184,240,159,18,161,51,204,63,138,114,253,36,147,0,0,0,0,55,106,194,1,110,212,132,3,89,190,70,2,220,168,9,7,235,194,203,6,178,124,141,4,133,22,79,5,184,81,19,14,143,59,209,15,214,133,151,13,225,239,85,12,100,249,26,9,83,147,216,8,10,45,158,10,61,71,92,11,112,163,38,28,71,201,228,29,30,119,162,31,41,29,96,30,172,11,47,27,155,97,237,26,194,223,171,24,245,181,105,25,200,242,53,18,255,152,247,19,166,38,177,17,145,76,115,16,20,90,60,21,35,48,254,20,122,142,184,22,77,228,122,23,224,70,77,56,215,44,143,57,142,146,201,59,185,248,11,58,60,238,68,63,11,132,134,62,82,58,192,60,101,80,2,61,88,23,94,54,111,125,156,55,54,195,218,53,1,169,24,52,132,191,87,49,179,213,149,48,234,107,211,50,221,1,17,51,144,229,107,36,167,143,169,37,254,49,239,39,201,91,45,38,76,77,98,35,123,39,160,34,34,153,230,32,21,243,36,33,40,180,120,42,31,222,186,43,70,96,252,41,113,10,62,40,244,28,113,45,195,118,179,44,154,200,245,46,173,162,55,47,192,141,154,112,247,231,88,113,174,89,30,115,153,51,220,114,28,37,147,119,43,79,81,118,114,241,23,116,69,155,213,117,120,220,137,126,79,182,75,127,22,8,13,125,33,98,207,124,164,116,128,121,147,30,66,120,202,160,4,122,253,202,198,123,176,46,188,108,135,68,126,109,222,250,56,111,233,144,250,110,108,134,181,107,91,236,119,106,2,82,49,104,53,56,243,105,8,127,175,98,63,21,109,99,102,171,43,97,81,193,233,96,212,215,166,101,227,189,100,100,186,3,34,102,141,105,224,103,32,203,215,72,23,161,21,73,78,31,83,75,121,117,145,74,252,99,222,79,203,9,28,78,146,183,90,76,165,221,152,77,152,154,196,70,175,240,6,71,246,78,64,69,193,36,130,68,68,50,205,65,115,88,15,64,42,230,73,66,29,140,139,67,80,104,241,84,103,2,51,85,62,188,117,87,9,214,183,86,140,192,248,83,187,170,58,82,226,20,124,80,213,126,190,81,232,57,226,90,223,83,32,91,134,237,102,89,177,135,164,88,52,145,235,93,3,251,41,92,90,69,111,94,109,47,173,95,128,27,53,225,183,113,247,224,238,207,177,226,217,165,115,227,92,179,60,230,107,217,254,231,50,103,184,229,5,13,122,228,56,74,38,239,15,32,228,238,86,158,162,236,97,244,96,237,228,226,47,232,211,136,237,233,138,54,171,235,189,92,105,234,240,184,19,253,199,210,209,252,158,108,151,254,169,6,85,255,44,16,26,250,27,122,216,251,66,196,158,249,117,174,92,248,72,233,0,243,127,131,194,242,38,61,132,240,17,87,70,241,148,65,9,244,163,43,203,245,250,149,141,247,205,255,79,246,96,93,120,217,87,55,186,216,14,137,252,218,57,227,62,219,188,245,113,222,139,159,179,223,210,33,245,221,229,75,55,220,216,12,107,215,239,102,169,214,182,216,239,212,129,178,45,213,4,164,98,208,51,206,160,209,106,112,230,211,93,26,36,210,16,254,94,197,39,148,156,196,126,42,218,198,73,64,24,199,204,86,87,194,251,60,149,195,162,130,211,193,149,232,17,192,168,175,77,203,159,197,143,202,198,123,201,200,241,17,11,201,116,7,68,204,67,109,134,205,26,211,192,207,45,185,2,206,64,150,175,145,119,252,109,144,46,66,43,146,25,40,233,147,156,62,166,150,171,84,100,151,242,234,34,149,197,128,224,148,248,199,188,159,207,173,126,158,150,19,56,156,161,121,250,157,36,111,181,152,19,5,119,153,74,187,49,155,125,209,243,154,48,53,137,141,7,95,75,140,94,225,13,142,105,139,207,143,236,157,128,138,219,247,66,139,130,73,4,137,181,35,198,136,136,100,154,131,191,14,88,130,230,176,30,128,209,218,220,129,84,204,147,132,99,166,81,133,58,24,23,135,13,114,213,134,160,208,226,169,151,186,32,168,206,4,102,170,249,110,164,171,124,120,235,174,75,18,41,175,18,172,111,173,37,198,173,172,24,129,241,167,47,235,51,166,118,85,117,164,65,63,183,165,196,41,248,160,243,67,58,161,170,253,124,163,157,151,190,162,208,115,196,181,231,25,6,180,190,167,64,182,137,205,130,183,12,219,205,178,59,177,15,179,98,15,73,177,85,101,139,176,104,34,215,187,95,72,21,186,6,246,83,184,49,156,145,185,180,138,222,188,131,224,28,189,218,94,90,191,237,52,152,190,0,0,0,0,101,103,188,184,139,200,9,170,238,175,181,18,87,151,98,143,50,240,222,55,220,95,107,37,185,56,215,157,239,40,180,197,138,79,8,125,100,224,189,111,1,135,1,215,184,191,214,74,221,216,106,242,51,119,223,224,86,16,99,88,159,87,25,80,250,48,165,232,20,159,16,250,113,248,172,66,200,192,123,223,173,167,199,103,67,8,114,117,38,111,206,205,112,127,173,149,21,24,17,45,251,183,164,63,158,208,24,135,39,232,207,26,66,143,115,162,172,32,198,176,201,71,122,8,62,175,50,160,91,200,142,24,181,103,59,10,208,0,135,178,105,56,80,47,12,95,236,151,226,240,89,133,135,151,229,61,209,135,134,101,180,224,58,221,90,79,143,207,63,40,51,119,134,16,228,234,227,119,88,82,13,216,237,64,104,191,81,248,161,248,43,240,196,159,151,72,42,48,34,90,79,87,158,226,246,111,73,127,147,8,245,199,125,167,64,213,24,192,252,109,78,208,159,53,43,183,35,141,197,24,150,159,160,127,42,39,25,71,253,186,124,32,65,2,146,143,244,16,247,232,72,168,61,88,20,155,88,63,168,35,182,144,29,49,211,247,161,137,106,207,118,20,15,168,202,172,225,7,127,190,132,96,195,6,210,112,160,94,183,23,28,230,89,184,169,244,60,223,21,76,133,231,194,209,224,128,126,105,14,47,203,123,107,72,119,195,162,15,13,203,199,104,177,115,41,199,4,97,76,160,184,217,245,152,111,68,144,255,211,252,126,80,102,238,27,55,218,86,77,39,185,14,40,64,5,182,198,239,176,164,163,136,12,28,26,176,219,129,127,215,103,57,145,120,210,43,244,31,110,147,3,247,38,59,102,144,154,131,136,63,47,145,237,88,147,41,84,96,68,180,49,7,248,12,223,168,77,30,186,207,241,166,236,223,146,254,137,184,46,70,103,23,155,84,2,112,39,236,187,72,240,113,222,47,76,201,48,128,249,219,85,231,69,99,156,160,63,107,249,199,131,211,23,104,54,193,114,15,138,121,203,55,93,228,174,80,225,92,64,255,84,78,37,152,232,246,115,136,139,174,22,239,55,22,248,64,130,4,157,39,62,188,36,31,233,33,65,120,85,153,175,215,224,139,202,176,92,51,59,182,89,237,94,209,229,85,176,126,80,71,213,25,236,255,108,33,59,98,9,70,135,218,231,233,50,200,130,142,142,112,212,158,237,40,177,249,81,144,95,86,228,130,58,49,88,58,131,9,143,167,230,110,51,31,8,193,134,13,109,166,58,181,164,225,64,189,193,134,252,5,47,41,73,23,74,78,245,175,243,118,34,50,150,17,158,138,120,190,43,152,29,217,151,32,75,201,244,120,46,174,72,192,192,1,253,210,165,102,65,106,28,94,150,247,121,57,42,79,151,150,159,93,242,241,35,229,5,25,107,77,96,126,215,245,142,209,98,231,235,182,222,95,82,142,9,194,55,233,181,122,217,70,0,104,188,33,188,208,234,49,223,136,143,86,99,48,97,249,214,34,4,158,106,154,189,166,189,7,216,193,1,191,54,110,180,173,83,9,8,21,154,78,114,29,255,41,206,165,17,134,123,183,116,225,199,15,205,217,16,146,168,190,172,42,70,17,25,56,35,118,165,128,117,102,198,216,16,1,122,96,254,174,207,114,155,201,115,202,34,241,164,87,71,150,24,239,169,57,173,253,204,94,17,69,6,238,77,118,99,137,241,206,141,38,68,220,232,65,248,100,81,121,47,249,52,30,147,65,218,177,38,83,191,214,154,235,233,198,249,179,140,161,69,11,98,14,240,25,7,105,76,161,190,81,155,60,219,54,39,132,53,153,146,150,80,254,46,46,153,185,84,38,252,222,232,158,18,113,93,140,119,22,225,52,206,46,54,169,171,73,138,17,69,230,63,3,32,129,131,187,118,145,224,227,19,246,92,91,253,89,233,73,152,62,85,241,33,6,130,108,68,97,62,212,170,206,139,198,207,169,55,126,56,65,127,214,93,38,195,110,179,137,118,124,214,238,202,196,111,214,29,89,10,177,161,225,228,30,20,243,129,121,168,75,215,105,203,19,178,14,119,171,92,161,194,185,57,198,126,1,128,254,169,156,229,153,21,36,11,54,160,54,110,81,28,142,167,22,102,134,194,113,218,62,44,222,111,44,73,185,211,148,240,129,4,9,149,230,184,177,123,73,13,163,30,46,177,27,72,62,210,67,45,89,110,251,195,246,219,233,166,145,103,81,31,169,176,204,122,206,12,116,148,97,185,102,241,6,5,222,0,0,0,0,119,7,48,150,238,14,97,44,153,9,81,186,7,109,196,25,112,106,244,143,233,99,165,53,158,100,149,163,14,219,136,50,121,220,184,164,224,213,233,30,151,210,217,136,9,182,76,43,126,177,124,189,231,184,45,7,144,191,29,145,29,183,16,100,106,176,32,242,243,185,113,72,132,190,65,222,26,218,212,125,109,221,228,235,244,212,181,81,131,211,133,199,19,108,152,86,100,107,168,192,253,98,249,122,138,101,201,236,20,1,92,79,99,6,108,217,250,15,61,99,141,8,13,245,59,110,32,200,76,105,16,94,213,96,65,228,162,103,113,114,60,3,228,209,75,4,212,71,210,13,133,253,165,10,181,107,53,181,168,250,66,178,152,108,219,187,201,214,172,188,249,64,50,216,108,227,69,223,92,117,220,214,13,207,171,209,61,89,38,217,48,172,81,222,0,58,200,215,81,128,191,208,97,22,33,180,244,181,86,179,196,35,207,186,149,153,184,189,165,15,40,2,184,158,95,5,136,8,198,12,217,178,177,11,233,36,47,111,124,135,88,104,76,17,193,97,29,171,182,102,45,61,118,220,65,144,1,219,113,6,152,210,32,188,239,213,16,42,113,177,133,137,6,182,181,31,159,191,228,165,232,184,212,51,120,7,201,162,15,0,249,52,150,9,168,142,225,14,152,24,127,106,13,187,8,109,61,45,145,100,108,151,230,99,92,1,107,107,81,244,28,108,97,98,133,101,48,216,242,98,0,78,108,6,149,237,27,1,165,123,130,8,244,193,245,15,196,87,101,176,217,198,18,183,233,80,139,190,184,234,252,185,136,124,98,221,29,223,21,218,45,73,140,211,124,243,251,212,76,101,77,178,97,88,58,181,81,206,163,188,0,116,212,187,48,226,74,223,165,65,61,216,149,215,164,209,196,109,211,214,244,251,67,105,233,106,52,110,217,252,173,103,136,70,218,96,184,208,68,4,45,115,51,3,29,229,170,10,76,95,221,13,124,201,80,5,113,60,39,2,65,170,190,11,16,16,201,12,32,134,87,104,181,37,32,111,133,179,185,102,212,9,206,97,228,159,94,222,249,14,41,217,201,152,176,208,152,34,199,215,168,180,89,179,61,23,46,180,13,129,183,189,92,59,192,186,108,173,237,184,131,32,154,191,179,182,3,182,226,12,116,177,210,154,234,213,71,57,157,210,119,175,4,219,38,21,115,220,22,131,227,99,11,18,148,100,59,132,13,109,106,62,122,106,90,168,228,14,207,11,147,9,255,157,10,0,174,39,125,7,158,177,240,15,147,68,135,8,163,210,30,1,242,104,105,6,194,254,247,98,87,93,128,101,103,203,25,108,54,113,110,107,6,231,254,212,27,118,137,211,43,224,16,218,122,90,103,221,74,204,249,185,223,111,142,190,239,249,23,183,190,67,96,176,142,213,214,214,163,232,161,209,147,126,56,216,194,196,79,223,242,82,209,187,103,241,166,188,87,103,63,181,6,221,72,178,54,75,216,13,43,218,175,10,27,76,54,3,74,246,65,4,122,96,223,96,239,195,168,103,223,85,49,110,142,239,70,105,190,121,203,97,179,140,188,102,131,26,37,111,210,160,82,104,226,54,204,12,119,149,187,11,71,3,34,2,22,185,85,5,38,47,197,186,59,190,178,189,11,40,43,180,90,146,92,179,106,4,194,215,255,167,181,208,207,49,44,217,158,139,91,222,174,29,155,100,194,176,236,99,242,38,117,106,163,156,2,109,147,10,156,9,6,169,235,14,54,63,114,7,103,133,5,0,87,19,149,191,74,130,226,184,122,20,123,177,43,174,12,182,27,56,146,210,142,155,229,213,190,13,124,220,239,183,11,219,223,33,134,211,210,212,241,212,226,66,104,221,179,248,31,218,131,110,129,190,22,205,246,185,38,91,111,176,119,225,24,183,71,119,136,8,90,230,255,15,106,112,102,6,59,202,17,1,11,92,143,101,158,255,248,98,174,105,97,107,255,211,22,108,207,69,160,10,226,120,215,13,210,238,78,4,131,84,57,3,179,194,167,103,38,97,208,96,22,247,73,105,71,77,62,110,119,219,174,209,106,74,217,214,90,220,64,223,11,102,55,216,59,240,169,188,174,83,222,187,158,197,71,178,207,127,48,181,255,233,189,189,242,28,202,186,194,138,83,179,147,48,36,180,163,166,186,208,54,5,205,215,6,147,84,222,87,41,35,217,103,191,179,102,122,46,196,97,74,184,93,104,27,2,42,111,43,148,180,11,190,55,195,12,142,161,90,5,223,27,45,2,239,141,0,0,0,0,25,27,49,65,50,54,98,130,43,45,83,195,100,108,197,4,125,119,244,69,86,90,167,134,79,65,150,199,200,217,138,8,209,194,187,73,250,239,232,138,227,244,217,203,172,181,79,12,181,174,126,77,158,131,45,142,135,152,28,207,74,194,18,81,83,217,35,16,120,244,112,211,97,239,65,146,46,174,215,85,55,181,230,20,28,152,181,215,5,131,132,150,130,27,152,89,155,0,169,24,176,45,250,219,169,54,203,154,230,119,93,93,255,108,108,28,212,65,63,223,205,90,14,158,149,132,36,162,140,159,21,227,167,178,70,32,190,169,119,97,241,232,225,166,232,243,208,231,195,222,131,36,218,197,178,101,93,93,174,170,68,70,159,235,111,107,204,40,118,112,253,105,57,49,107,174,32,42,90,239,11,7,9,44,18,28,56,109,223,70,54,243,198,93,7,178,237,112,84,113,244,107,101,48,187,42,243,247,162,49,194,182,137,28,145,117,144,7,160,52,23,159,188,251,14,132,141,186,37,169,222,121,60,178,239,56,115,243,121,255,106,232,72,190,65,197,27,125,88,222,42,60,240,121,79,5,233,98,126,68,194,79,45,135,219,84,28,198,148,21,138,1,141,14,187,64,166,35,232,131,191,56,217,194,56,160,197,13,33,187,244,76,10,150,167,143,19,141,150,206,92,204,0,9,69,215,49,72,110,250,98,139,119,225,83,202,186,187,93,84,163,160,108,21,136,141,63,214,145,150,14,151,222,215,152,80,199,204,169,17,236,225,250,210,245,250,203,147,114,98,215,92,107,121,230,29,64,84,181,222,89,79,132,159,22,14,18,88,15,21,35,25,36,56,112,218,61,35,65,155,101,253,107,167,124,230,90,230,87,203,9,37,78,208,56,100,1,145,174,163,24,138,159,226,51,167,204,33,42,188,253,96,173,36,225,175,180,63,208,238,159,18,131,45,134,9,178,108,201,72,36,171,208,83,21,234,251,126,70,41,226,101,119,104,47,63,121,246,54,36,72,183,29,9,27,116,4,18,42,53,75,83,188,242,82,72,141,179,121,101,222,112,96,126,239,49,231,230,243,254,254,253,194,191,213,208,145,124,204,203,160,61,131,138,54,250,154,145,7,187,177,188,84,120,168,167,101,57,59,131,152,75,34,152,169,10,9,181,250,201,16,174,203,136,95,239,93,79,70,244,108,14,109,217,63,205,116,194,14,140,243,90,18,67,234,65,35,2,193,108,112,193,216,119,65,128,151,54,215,71,142,45,230,6,165,0,181,197,188,27,132,132,113,65,138,26,104,90,187,91,67,119,232,152,90,108,217,217,21,45,79,30,12,54,126,95,39,27,45,156,62,0,28,221,185,152,0,18,160,131,49,83,139,174,98,144,146,181,83,209,221,244,197,22,196,239,244,87,239,194,167,148,246,217,150,213,174,7,188,233,183,28,141,168,156,49,222,107,133,42,239,42,202,107,121,237,211,112,72,172,248,93,27,111,225,70,42,46,102,222,54,225,127,197,7,160,84,232,84,99,77,243,101,34,2,178,243,229,27,169,194,164,48,132,145,103,41,159,160,38,228,197,174,184,253,222,159,249,214,243,204,58,207,232,253,123,128,169,107,188,153,178,90,253,178,159,9,62,171,132,56,127,44,28,36,176,53,7,21,241,30,42,70,50,7,49,119,115,72,112,225,180,81,107,208,245,122,70,131,54,99,93,178,119,203,250,215,78,210,225,230,15,249,204,181,204,224,215,132,141,175,150,18,74,182,141,35,11,157,160,112,200,132,187,65,137,3,35,93,70,26,56,108,7,49,21,63,196,40,14,14,133,103,79,152,66,126,84,169,3,85,121,250,192,76,98,203,129,129,56,197,31,152,35,244,94,179,14,167,157,170,21,150,220,229,84,0,27,252,79,49,90,215,98,98,153,206,121,83,216,73,225,79,23,80,250,126,86,123,215,45,149,98,204,28,212,45,141,138,19,52,150,187,82,31,187,232,145,6,160,217,208,94,126,243,236,71,101,194,173,108,72,145,110,117,83,160,47,58,18,54,232,35,9,7,169,8,36,84,106,17,63,101,43,150,167,121,228,143,188,72,165,164,145,27,102,189,138,42,39,242,203,188,224,235,208,141,161,192,253,222,98,217,230,239,35,20,188,225,189,13,167,208,252,38,138,131,63,63,145,178,126,112,208,36,185,105,203,21,248,66,230,70,59,91,253,119,122,220,101,107,181,197,126,90,244,238,83,9,55,247,72,56,118,184,9,174,177,161,18,159,240,138,63,204,51,147,36,253,114,0,0,0,0,1,194,106,55,3,132,212,110,2,70,190,89,7,9,168,220,6,203,194,235,4,141,124,178,5,79,22,133,14,19,81,184,15,209,59,143,13,151,133,214,12,85,239,225,9,26,249,100,8,216,147,83,10,158,45,10,11,92,71,61,28,38,163,112,29,228,201,71,31,162,119,30,30,96,29,41,27,47,11,172,26,237,97,155,24,171,223,194,25,105,181,245,18,53,242,200,19,247,152,255,17,177,38,166,16,115,76,145,21,60,90,20,20,254,48,35,22,184,142,122,23,122,228,77,56,77,70,224,57,143,44,215,59,201,146,142,58,11,248,185,63,68,238,60,62,134,132,11,60,192,58,82,61,2,80,101,54,94,23,88,55,156,125,111,53,218,195,54,52,24,169,1,49,87,191,132,48,149,213,179,50,211,107,234,51,17,1,221,36,107,229,144,37,169,143,167,39,239,49,254,38,45,91,201,35,98,77,76,34,160,39,123,32,230,153,34,33,36,243,21,42,120,180,40,43,186,222,31,41,252,96,70,40,62,10,113,45,113,28,244,44,179,118,195,46,245,200,154,47,55,162,173,112,154,141,192,113,88,231,247,115,30,89,174,114,220,51,153,119,147,37,28,118,81,79,43,116,23,241,114,117,213,155,69,126,137,220,120,127,75,182,79,125,13,8,22,124,207,98,33,121,128,116,164,120,66,30,147,122,4,160,202,123,198,202,253,108,188,46,176,109,126,68,135,111,56,250,222,110,250,144,233,107,181,134,108,106,119,236,91,104,49,82,2,105,243,56,53,98,175,127,8,99,109,21,63,97,43,171,102,96,233,193,81,101,166,215,212,100,100,189,227,102,34,3,186,103,224,105,141,72,215,203,32,73,21,161,23,75,83,31,78,74,145,117,121,79,222,99,252,78,28,9,203,76,90,183,146,77,152,221,165,70,196,154,152,71,6,240,175,69,64,78,246,68,130,36,193,65,205,50,68,64,15,88,115,66,73,230,42,67,139,140,29,84,241,104,80,85,51,2,103,87,117,188,62,86,183,214,9,83,248,192,140,82,58,170,187,80,124,20,226,81,190,126,213,90,226,57,232,91,32,83,223,89,102,237,134,88,164,135,177,93,235,145,52,92,41,251,3,94,111,69,90,95,173,47,109,225,53,27,128,224,247,113,183,226,177,207,238,227,115,165,217,230,60,179,92,231,254,217,107,229,184,103,50,228,122,13,5,239,38,74,56,238,228,32,15,236,162,158,86,237,96,244,97,232,47,226,228,233,237,136,211,235,171,54,138,234,105,92,189,253,19,184,240,252,209,210,199,254,151,108,158,255,85,6,169,250,26,16,44,251,216,122,27,249,158,196,66,248,92,174,117,243,0,233,72,242,194,131,127,240,132,61,38,241,70,87,17,244,9,65,148,245,203,43,163,247,141,149,250,246,79,255,205,217,120,93,96,216,186,55,87,218,252,137,14,219,62,227,57,222,113,245,188,223,179,159,139,221,245,33,210,220,55,75,229,215,107,12,216,214,169,102,239,212,239,216,182,213,45,178,129,208,98,164,4,209,160,206,51,211,230,112,106,210,36,26,93,197,94,254,16,196,156,148,39,198,218,42,126,199,24,64,73,194,87,86,204,195,149,60,251,193,211,130,162,192,17,232,149,203,77,175,168,202,143,197,159,200,201,123,198,201,11,17,241,204,68,7,116,205,134,109,67,207,192,211,26,206,2,185,45,145,175,150,64,144,109,252,119,146,43,66,46,147,233,40,25,150,166,62,156,151,100,84,171,149,34,234,242,148,224,128,197,159,188,199,248,158,126,173,207,156,56,19,150,157,250,121,161,152,181,111,36,153,119,5,19,155,49,187,74,154,243,209,125,141,137,53,48,140,75,95,7,142,13,225,94,143,207,139,105,138,128,157,236,139,66,247,219,137,4,73,130,136,198,35,181,131,154,100,136,130,88,14,191,128,30,176,230,129,220,218,209,132,147,204,84,133,81,166,99,135,23,24,58,134,213,114,13,169,226,208,160,168,32,186,151,170,102,4,206,171,164,110,249], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
+/* memory initializer */ allocate([174,235,120,124,175,41,18,75,173,111,172,18,172,173,198,37,167,241,129,24,166,51,235,47,164,117,85,118,165,183,63,65,160,248,41,196,161,58,67,243,163,124,253,170,162,190,151,157,181,196,115,208,180,6,25,231,182,64,167,190,183,130,205,137,178,205,219,12,179,15,177,59,177,73,15,98,176,139,101,85,187,215,34,104,186,21,72,95,184,83,246,6,185,145,156,49,188,222,138,180,189,28,224,131,191,90,94,218,190,152,52,237,0,0,0,0,184,188,103,101,170,9,200,139,18,181,175,238,143,98,151,87,55,222,240,50,37,107,95,220,157,215,56,185,197,180,40,239,125,8,79,138,111,189,224,100,215,1,135,1,74,214,191,184,242,106,216,221,224,223,119,51,88,99,16,86,80,25,87,159,232,165,48,250,250,16,159,20,66,172,248,113,223,123,192,200,103,199,167,173,117,114,8,67,205,206,111,38,149,173,127,112,45,17,24,21,63,164,183,251,135,24,208,158,26,207,232,39,162,115,143,66,176,198,32,172,8,122,71,201,160,50,175,62,24,142,200,91,10,59,103,181,178,135,0,208,47,80,56,105,151,236,95,12,133,89,240,226,61,229,151,135,101,134,135,209,221,58,224,180,207,143,79,90,119,51,40,63,234,228,16,134,82,88,119,227,64,237,216,13,248,81,191,104,240,43,248,161,72,151,159,196,90,34,48,42,226,158,87,79,127,73,111,246,199,245,8,147,213,64,167,125,109,252,192,24,53,159,208,78,141,35,183,43,159,150,24,197,39,42,127,160,186,253,71,25,2,65,32,124,16,244,143,146,168,72,232,247,155,20,88,61,35,168,63,88,49,29,144,182,137,161,247,211,20,118,207,106,172,202,168,15,190,127,7,225,6,195,96,132,94,160,112,210,230,28,23,183,244,169,184,89,76,21,223,60,209,194,231,133,105,126,128,224,123,203,47,14,195,119,72,107,203,13,15,162,115,177,104,199,97,4,199,41,217,184,160,76,68,111,152,245,252,211,255,144,238,102,80,126,86,218,55,27,14,185,39,77,182,5,64,40,164,176,239,198,28,12,136,163,129,219,176,26,57,103,215,127,43,210,120,145,147,110,31,244,59,38,247,3,131,154,144,102,145,47,63,136,41,147,88,237,180,68,96,84,12,248,7,49,30,77,168,223,166,241,207,186,254,146,223,236,70,46,184,137,84,155,23,103,236,39,112,2,113,240,72,187,201,76,47,222,219,249,128,48,99,69,231,85,107,63,160,156,211,131,199,249,193,54,104,23,121,138,15,114,228,93,55,203,92,225,80,174,78,84,255,64,246,232,152,37,174,139,136,115,22,55,239,22,4,130,64,248,188,62,39,157,33,233,31,36,153,85,120,65,139,224,215,175,51,92,176,202,237,89,182,59,85,229,209,94,71,80,126,176,255,236,25,213,98,59,33,108,218,135,70,9,200,50,233,231,112,142,142,130,40,237,158,212,144,81,249,177,130,228,86,95,58,88,49,58,167,143,9,131,31,51,110,230,13,134,193,8,181,58,166,109,189,64,225,164,5,252,134,193,23,73,41,47,175,245,78,74,50,34,118,243,138,158,17,150,152,43,190,120,32,151,217,29,120,244,201,75,192,72,174,46,210,253,1,192,106,65,102,165,247,150,94,28,79,42,57,121,93,159,150,151,229,35,241,242,77,107,25,5,245,215,126,96,231,98,209,142,95,222,182,235,194,9,142,82,122,181,233,55,104,0,70,217,208,188,33,188,136,223,49,234,48,99,86,143,34,214,249,97,154,106,158,4,7,189,166,189,191,1,193,216,173,180,110,54,21,8,9,83,29,114,78,154,165,206,41,255,183,123,134,17,15,199,225,116,146,16,217,205,42,172,190,168,56,25,17,70,128,165,118,35,216,198,102,117,96,122,1,16,114,207,174,254,202,115,201,155,87,164,241,34,239,24,150,71,253,173,57,169,69,17,94,204,118,77,238,6,206,241,137,99,220,68,38,141,100,248,65,232,249,47,121,81,65,147,30,52,83,38,177,218,235,154,214,191,179,249,198,233,11,69,161,140,25,240,14,98,161,76,105,7,60,155,81,190,132,39,54,219,150,146,153,53,46,46,254,80,38,84,185,153,158,232,222,252,140,93,113,18,52,225,22,119,169,54,46,206,17,138,73,171,3,63,230,69,187,131,129,32,227,224,145,118,91,92,246,19,73,233,89,253,241,85,62,152,108,130,6,33,212,62,97,68,198,139,206,170,126,55,169,207,214,127,65,56,110,195,38,93,124,118,137,179,196,202,238,214,89,29,214,111,225,161,177,10,243,20,30,228,75,168,121,129,19,203,105,215,171,119,14,178,185,194,161,92,1,126,198,57,156,169,254,128,36,21,153,229,54,160,54,11,142,28,81,110,134,102,22,167,62,218,113,194,44,111,222,44,148,211,185,73,9,4,129,240,177,184,230,149,163,13,73,123,27,177,46,30,67,210,62,72,251,110,89,45,233,219,246,195,81,103,145,166,204,176,169,31,116,12,206,122,102,185,97,148,222,5,6,241,16,0,17,0,18,0,0,0,8,0,7,0,9,0,6,0,10,0,5,0,11,0,4,0,12,0,3,0,13,0,2,0,14,0,1,0,15,0,0,0,105,110,99,111,114,114,101,99,116,32,104,101,97,100,101,114,32,99,104,101,99,107,0,0,117,110,107,110,111,119,110,32,99,111,109,112,114,101,115,115,105,111,110,32,109,101,116,104,111,100,0,0,0,0,0,0,105,110,118,97,108,105,100,32,119,105,110,100,111,119,32,115,105,122,101,0,0,0,0,0,117,110,107,110,111,119,110,32,104,101,97,100,101,114,32,102,108,97,103,115,32,115,101,116,0,0,0,0,0,0,0,0,104,101,97,100,101,114,32,99,114,99,32,109,105,115,109,97,116,99,104,0,0,0,0,0,105,110,118,97,108,105,100,32,98,108,111,99,107,32,116,121,112,101,0,0,0,0,0,0,105,110,118,97,108,105,100,32,115,116,111,114,101,100,32,98,108,111,99,107,32,108,101,110,103,116,104,115,0,0,0,0,116,111,111,32,109,97,110,121,32,108,101,110,103,116,104,32,111,114,32,100,105,115,116,97,110,99,101,32,115,121,109,98,111,108,115,0,0,0,0,0,105,110,118,97,108,105,100,32,99,111,100,101,32,108,101,110,103,116,104,115,32,115,101,116,0,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,98,105,116,32,108,101,110,103,116,104,32,114,101,112,101,97,116,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,99,111,100,101,32,45,45,32,109,105,115,115,105,110,103,32,101,110,100,45,111,102,45,98,108,111,99,107,0,0,0,0,105,110,118,97,108,105,100,32,108,105,116,101,114,97,108,47,108,101,110,103,116,104,115,32,115,101,116,0,0,0,0,0,105,110,118,97,108,105,100,32,100,105,115,116,97,110,99,101,115,32,115,101,116,0,0,0,105,110,118,97,108,105,100,32,108,105,116,101,114,97,108,47,108,101,110,103,116,104,32,99,111,100,101,0,0,0,0,0,105,110,118,97,108,105,100,32,100,105,115,116,97,110,99,101,32,99,111,100,101,0,0,0,105,110,118,97,108,105,100,32,100,105,115,116,97,110,99,101,32,116,111,111,32,102,97,114,32,98,97,99,107,0,0,0,105,110,99,111,114,114,101,99,116,32,100,97,116,97,32,99,104,101,99,107,0,0,0,0,105,110,99,111,114,114,101,99,116,32,108,101,110,103,116,104,32,99,104,101,99,107,0,0,96,7,0,0,0,8,80,0,0,8,16,0,20,8,115,0,18,7,31,0,0,8,112,0,0,8,48,0,0,9,192,0,16,7,10,0,0,8,96,0,0,8,32,0,0,9,160,0,0,8,0,0,0,8,128,0,0,8,64,0,0,9,224,0,16,7,6,0,0,8,88,0,0,8,24,0,0,9,144,0,19,7,59,0,0,8,120,0,0,8,56,0,0,9,208,0,17,7,17,0,0,8,104,0,0,8,40,0,0,9,176,0,0,8,8,0,0,8,136,0,0,8,72,0,0,9,240,0,16,7,4,0,0,8,84,0,0,8,20,0,21,8,227,0,19,7,43,0,0,8,116,0,0,8,52,0,0,9,200,0,17,7,13,0,0,8,100,0,0,8,36,0,0,9,168,0,0,8,4,0,0,8,132,0,0,8,68,0,0,9,232,0,16,7,8,0,0,8,92,0,0,8,28,0,0,9,152,0,20,7,83,0,0,8,124,0,0,8,60,0,0,9,216,0,18,7,23,0,0,8,108,0,0,8,44,0,0,9,184,0,0,8,12,0,0,8,140,0,0,8,76,0,0,9,248,0,16,7,3,0,0,8,82,0,0,8,18,0,21,8,163,0,19,7,35,0,0,8,114,0,0,8,50,0,0,9,196,0,17,7,11,0,0,8,98,0,0,8,34,0,0,9,164,0,0,8,2,0,0,8,130,0,0,8,66,0,0,9,228,0,16,7,7,0,0,8,90,0,0,8,26,0,0,9,148,0,20,7,67,0,0,8,122,0,0,8,58,0,0,9,212,0,18,7,19,0,0,8,106,0,0,8,42,0,0,9,180,0,0,8,10,0,0,8,138,0,0,8,74,0,0,9,244,0,16,7,5,0,0,8,86,0,0,8,22,0,64,8,0,0,19,7,51,0,0,8,118,0,0,8,54,0,0,9,204,0,17,7,15,0,0,8,102,0,0,8,38,0,0,9,172,0,0,8,6,0,0,8,134,0,0,8,70,0,0,9,236,0,16,7,9,0,0,8,94,0,0,8,30,0,0,9,156,0,20,7,99,0,0,8,126,0,0,8,62,0,0,9,220,0,18,7,27,0,0,8,110,0,0,8,46,0,0,9,188,0,0,8,14,0,0,8,142,0,0,8,78,0,0,9,252,0,96,7,0,0,0,8,81,0,0,8,17,0,21,8,131,0,18,7,31,0,0,8,113,0,0,8,49,0,0,9,194,0,16,7,10,0,0,8,97,0,0,8,33,0,0,9,162,0,0,8,1,0,0,8,129,0,0,8,65,0,0,9,226,0,16,7,6,0,0,8,89,0,0,8,25,0,0,9,146,0,19,7,59,0,0,8,121,0,0,8,57,0,0,9,210,0,17,7,17,0,0,8,105,0,0,8,41,0,0,9,178,0,0,8,9,0,0,8,137,0,0,8,73,0,0,9,242,0,16,7,4,0,0,8,85,0,0,8,21,0,16,8,2,1,19,7,43,0,0,8,117,0,0,8,53,0,0,9,202,0,17,7,13,0,0,8,101,0,0,8,37,0,0,9,170,0,0,8,5,0,0,8,133,0,0,8,69,0,0,9,234,0,16,7,8,0,0,8,93,0,0,8,29,0,0,9,154,0,20,7,83,0,0,8,125,0,0,8,61,0,0,9,218,0,18,7,23,0,0,8,109,0,0,8,45,0,0,9,186,0,0,8,13,0,0,8,141,0,0,8,77,0,0,9,250,0,16,7,3,0,0,8,83,0,0,8,19,0,21,8,195,0,19,7,35,0,0,8,115,0,0,8,51,0,0,9,198,0,17,7,11,0,0,8,99,0,0,8,35,0,0,9,166,0,0,8,3,0,0,8,131,0,0,8,67,0,0,9,230,0,16,7,7,0,0,8,91,0,0,8,27,0,0,9,150,0,20,7,67,0,0,8,123,0,0,8,59,0,0,9,214,0,18,7,19,0,0,8,107,0,0,8,43,0,0,9,182,0,0,8,11,0,0,8,139,0,0,8,75,0,0,9,246,0,16,7,5,0,0,8,87,0,0,8,23,0,64,8,0,0,19,7,51,0,0,8,119,0,0,8,55,0,0,9,206,0,17,7,15,0,0,8,103,0,0,8,39,0,0,9,174,0,0,8,7,0,0,8,135,0,0,8,71,0,0,9,238,0,16,7,9,0,0,8,95,0,0,8,31,0,0,9,158,0,20,7,99,0,0,8,127,0,0,8,63,0,0,9,222,0,18,7,27,0,0,8,111,0,0,8,47,0,0,9,190,0,0,8,15,0,0,8,143,0,0,8,79,0,0,9,254,0,96,7,0,0,0,8,80,0,0,8,16,0,20,8,115,0,18,7,31,0,0,8,112,0,0,8,48,0,0,9,193,0,16,7,10,0,0,8,96,0,0,8,32,0,0,9,161,0,0,8,0,0,0,8,128,0,0,8,64,0,0,9,225,0,16,7,6,0,0,8,88,0,0,8,24,0,0,9,145,0,19,7,59,0,0,8,120,0,0,8,56,0,0,9,209,0,17,7,17,0,0,8,104,0,0,8,40,0,0,9,177,0,0,8,8,0,0,8,136,0,0,8,72,0,0,9,241,0,16,7,4,0,0,8,84,0,0,8,20,0,21,8,227,0,19,7,43,0,0,8,116,0,0,8,52,0,0,9,201,0,17,7,13,0,0,8,100,0,0,8,36,0,0,9,169,0,0,8,4,0,0,8,132,0,0,8,68,0,0,9,233,0,16,7,8,0,0,8,92,0,0,8,28,0,0,9,153,0,20,7,83,0,0,8,124,0,0,8,60,0,0,9,217,0,18,7,23,0,0,8,108,0,0,8,44,0,0,9,185,0,0,8,12,0,0,8,140,0,0,8,76,0,0,9,249,0,16,7,3,0,0,8,82,0,0,8,18,0,21,8,163,0,19,7,35,0,0,8,114,0,0,8,50,0,0,9,197,0,17,7,11,0,0,8,98,0,0,8,34,0,0,9,165,0,0,8,2,0,0,8,130,0,0,8,66,0,0,9,229,0,16,7,7,0,0,8,90,0,0,8,26,0,0,9,149,0,20,7,67,0,0,8,122,0,0,8,58,0,0,9,213,0,18,7,19,0,0,8,106,0,0,8,42,0,0,9,181,0,0,8,10,0,0,8,138,0,0,8,74,0,0,9,245,0,16,7,5,0,0,8,86,0,0,8,22,0,64,8,0,0,19,7,51,0,0,8,118,0,0,8,54,0,0,9,205,0,17,7,15,0,0,8,102,0,0,8,38,0,0,9,173,0,0,8,6,0,0,8,134,0,0,8,70,0,0,9,237,0,16,7,9,0,0,8,94,0,0,8,30,0,0,9,157,0,20,7,99,0,0,8,126,0,0,8,62,0,0,9,221,0,18,7,27,0,0,8,110,0,0,8,46,0,0,9,189,0,0,8,14,0,0,8,142,0,0,8,78,0,0,9,253,0,96,7,0,0,0,8,81,0,0,8,17,0,21,8,131,0,18,7,31,0,0,8,113,0,0,8,49,0,0,9,195,0,16,7,10,0,0,8,97,0,0,8,33,0,0,9,163,0,0,8,1,0,0,8,129,0,0,8,65,0,0,9,227,0,16,7,6,0,0,8,89,0,0,8,25,0,0,9,147,0,19,7,59,0,0,8,121,0,0,8,57,0,0,9,211,0,17,7,17,0,0,8,105,0,0,8,41,0,0,9,179,0,0,8,9,0,0,8,137,0,0,8,73,0,0,9,243,0,16,7,4,0,0,8,85,0,0,8,21,0,16,8,2,1,19,7,43,0,0,8,117,0,0,8,53,0,0,9,203,0,17,7,13,0,0,8,101,0,0,8,37,0,0,9,171,0,0,8,5,0,0,8,133,0,0,8,69,0,0,9,235,0,16,7,8,0,0,8,93,0,0,8,29,0,0,9,155,0,20,7,83,0,0,8,125,0,0,8,61,0,0,9,219,0,18,7,23,0,0,8,109,0,0,8,45,0,0,9,187,0,0,8,13,0,0,8,141,0,0,8,77,0,0,9,251,0,16,7,3,0,0,8,83,0,0,8,19,0,21,8,195,0,19,7,35,0,0,8,115,0,0,8,51,0,0,9,199,0,17,7,11,0,0,8,99,0,0,8,35,0,0,9,167,0,0,8,3,0,0,8,131,0,0,8,67,0,0,9,231,0,16,7,7,0,0,8,91,0,0,8,27,0,0,9,151,0,20,7,67,0,0,8,123,0,0,8,59,0,0,9,215,0,18,7,19,0,0,8,107,0,0,8,43,0,0,9,183,0,0,8,11,0,0,8,139,0,0,8,75,0,0,9,247,0,16,7,5,0,0,8,87,0,0,8,23,0,64,8,0,0,19,7,51,0,0,8,119,0,0,8,55,0,0,9,207,0,17,7,15,0,0,8,103,0,0,8,39,0,0,9,175,0,0,8,7,0,0,8,135,0,0,8,71,0,0,9,239,0,16,7,9,0,0,8,95,0,0,8,31,0,0,9,159,0,20,7,99,0,0,8,127,0,0,8,63,0,0,9,223,0,18,7,27,0,0,8,111,0,0,8,47,0,0,9,191,0,0,8,15,0,0,8,143,0,0,8,79,0,0,9,255,0,16,5,1,0,23,5,1,1,19,5,17,0,27,5,1,16,17,5,5,0,25,5,1,4,21,5,65,0,29,5,1,64,16,5,3,0,24,5,1,2,20,5,33,0,28,5,1,32,18,5,9,0,26,5,1,8,22,5,129,0,64,5,0,0,16,5,2,0,23,5,129,1,19,5,25,0,27,5,1,24,17,5,7,0,25,5,1,6,21,5,97,0,29,5,1,96,16,5,4,0,24,5,1,3,20,5,49,0,28,5,1,48,18,5,13,0,26,5,1,12,22,5,193,0,64,5,0,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,13,0,15,0,17,0,19,0,23,0,27,0,31,0,35,0,43,0,51,0,59,0,67,0,83,0,99,0,115,0,131,0,163,0,195,0,227,0,2,1,0,0,0,0,0,0,16,0,16,0,16,0,16,0,16,0,16,0,16,0,16,0,17,0,17,0,17,0,17,0,18,0,18,0,18,0,18,0,19,0,19,0,19,0,19,0,20,0,20,0,20,0,20,0,21,0,21,0,21,0,21,0,16,0,73,0,195,0,0,0,1,0,2,0,3,0,4,0,5,0,7,0,9,0,13,0,17,0,25,0,33,0,49,0,65,0,97,0,129,0,193,0,1,1,129,1,1,2,1,3,1,4,1,6,1,8,1,12,1,16,1,24,1,32,1,48,1,64,1,96,0,0,0,0,16,0,16,0,16,0,16,0,17,0,17,0,18,0,18,0,19,0,19,0,20,0,20,0,21,0,21,0,22,0,22,0,23,0,23,0,24,0,24,0,25,0,25,0,26,0,26,0,27,0,27,0,28,0,28,0,29,0,29,0,64,0,64,0,105,110,118,97,108,105,100,32,100,105,115,116,97,110,99,101,32,116,111,111,32,102,97,114,32,98,97,99,107,0,0,0,105,110,118,97,108,105,100,32,100,105,115,116,97,110,99,101,32,99,111,100,101,0,0,0,105,110,118,97,108,105,100,32,108,105,116,101,114,97,108,47,108,101,110,103,116,104,32,99,111,100,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE+10240);
+
+
+
+
+var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8);
+
+assert(tempDoublePtr % 8 == 0);
+
+function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+}
+
+function copyTempDouble(ptr) {
+
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+
+ HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
+
+ HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
+
+ HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
+
+ HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
+
+}
+
+
+
+
+
+
+ var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};
+
+ var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
+
+
+ var ___errno_state=0;function ___setErrNo(value) {
+ // For convenient setting and returning of errno.
+ HEAP32[((___errno_state)>>2)]=value;
+ return value;
+ }
+
+ var PATH={splitPath:function (filename) {
+ var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
+ return splitPathRe.exec(filename).slice(1);
+ },normalizeArray:function (parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length - 1; i >= 0; i--) {
+ var last = parts[i];
+ if (last === '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+ return parts;
+ },normalize:function (path) {
+ var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.substr(-1) === '/';
+ // Normalize the path
+ path = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+ return (isAbsolute ? '/' : '') + path;
+ },dirname:function (path) {
+ var result = PATH.splitPath(path),
+ root = result[0],
+ dir = result[1];
+ if (!root && !dir) {
+ // No dirname whatsoever
+ return '.';
+ }
+ if (dir) {
+ // It has a dirname, strip trailing slash
+ dir = dir.substr(0, dir.length - 1);
+ }
+ return root + dir;
+ },basename:function (path) {
+ // EMSCRIPTEN return '/'' for '/', not an empty string
+ if (path === '/') return '/';
+ var lastSlash = path.lastIndexOf('/');
+ if (lastSlash === -1) return path;
+ return path.substr(lastSlash+1);
+ },extname:function (path) {
+ return PATH.splitPath(path)[3];
+ },join:function () {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return PATH.normalize(paths.join('/'));
+ },join2:function (l, r) {
+ return PATH.normalize(l + '/' + r);
+ },resolve:function () {
+ var resolvedPath = '',
+ resolvedAbsolute = false;
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0) ? arguments[i] : FS.cwd();
+ // Skip empty and invalid entries
+ if (typeof path !== 'string') {
+ throw new TypeError('Arguments to path.resolve must be strings');
+ } else if (!path) {
+ continue;
+ }
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+ }
+ // At this point the path should be resolved to a full absolute path, but
+ // handle relative paths to be safe (might happen when process.cwd() fails)
+ resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+ },relative:function (from, to) {
+ from = PATH.resolve(from).substr(1);
+ to = PATH.resolve(to).substr(1);
+ function trim(arr) {
+ var start = 0;
+ for (; start < arr.length; start++) {
+ if (arr[start] !== '') break;
+ }
+ var end = arr.length - 1;
+ for (; end >= 0; end--) {
+ if (arr[end] !== '') break;
+ }
+ if (start > end) return [];
+ return arr.slice(start, end - start + 1);
+ }
+ var fromParts = trim(from.split('/'));
+ var toParts = trim(to.split('/'));
+ var length = Math.min(fromParts.length, toParts.length);
+ var samePartsLength = length;
+ for (var i = 0; i < length; i++) {
+ if (fromParts[i] !== toParts[i]) {
+ samePartsLength = i;
+ break;
+ }
+ }
+ var outputParts = [];
+ for (var i = samePartsLength; i < fromParts.length; i++) {
+ outputParts.push('..');
+ }
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
+ return outputParts.join('/');
+ }};
+
+ var TTY={ttys:[],init:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // currently, FS.init does not distinguish if process.stdin is a file or TTY
+ // // device, it always assumes it's a TTY device. because of this, we're forcing
+ // // process.stdin to UTF8 encoding to at least make stdin reading compatible
+ // // with text files until FS.init can be refactored.
+ // process['stdin']['setEncoding']('utf8');
+ // }
+ },shutdown:function () {
+ // https://github.com/kripken/emscripten/pull/1555
+ // if (ENVIRONMENT_IS_NODE) {
+ // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
+ // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
+ // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
+ // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
+ // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
+ // process['stdin']['pause']();
+ // }
+ },register:function (dev, ops) {
+ TTY.ttys[dev] = { input: [], output: [], ops: ops };
+ FS.registerDevice(dev, TTY.stream_ops);
+ },stream_ops:{open:function (stream) {
+ var tty = TTY.ttys[stream.node.rdev];
+ if (!tty) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ stream.tty = tty;
+ stream.seekable = false;
+ },close:function (stream) {
+ // flush any pending line data
+ if (stream.tty.output.length) {
+ stream.tty.ops.put_char(stream.tty, 10);
+ }
+ },read:function (stream, buffer, offset, length, pos /* ignored */) {
+ if (!stream.tty || !stream.tty.ops.get_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = stream.tty.ops.get_char(stream.tty);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, pos) {
+ if (!stream.tty || !stream.tty.ops.put_char) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
+ }
+ for (var i = 0; i < length; i++) {
+ try {
+ stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }},default_tty_ops:{get_char:function (tty) {
+ if (!tty.input.length) {
+ var result = null;
+ if (ENVIRONMENT_IS_NODE) {
+ result = process['stdin']['read']();
+ if (!result) {
+ if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
+ return null; // EOF
+ }
+ return undefined; // no data available
+ }
+ } else if (typeof window != 'undefined' &&
+ typeof window.prompt == 'function') {
+ // Browser.
+ result = window.prompt('Input: '); // returns null on cancel
+ if (result !== null) {
+ result += '\n';
+ }
+ } else if (typeof readline == 'function') {
+ // Command line.
+ result = readline();
+ if (result !== null) {
+ result += '\n';
+ }
+ }
+ if (!result) {
+ return null;
+ }
+ tty.input = intArrayFromString(result, true);
+ }
+ return tty.input.shift();
+ },put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['print'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }},default_tty1_ops:{put_char:function (tty, val) {
+ if (val === null || val === 10) {
+ Module['printErr'](tty.output.join(''));
+ tty.output = [];
+ } else {
+ tty.output.push(TTY.utf8.processCChar(val));
+ }
+ }}};
+
+ var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
+ return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
+ // no supported
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (!MEMFS.ops_table) {
+ MEMFS.ops_table = {
+ dir: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ lookup: MEMFS.node_ops.lookup,
+ mknod: MEMFS.node_ops.mknod,
+ rename: MEMFS.node_ops.rename,
+ unlink: MEMFS.node_ops.unlink,
+ rmdir: MEMFS.node_ops.rmdir,
+ readdir: MEMFS.node_ops.readdir,
+ symlink: MEMFS.node_ops.symlink
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek
+ }
+ },
+ file: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: {
+ llseek: MEMFS.stream_ops.llseek,
+ read: MEMFS.stream_ops.read,
+ write: MEMFS.stream_ops.write,
+ allocate: MEMFS.stream_ops.allocate,
+ mmap: MEMFS.stream_ops.mmap
+ }
+ },
+ link: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr,
+ readlink: MEMFS.node_ops.readlink
+ },
+ stream: {}
+ },
+ chrdev: {
+ node: {
+ getattr: MEMFS.node_ops.getattr,
+ setattr: MEMFS.node_ops.setattr
+ },
+ stream: FS.chrdev_stream_ops
+ },
+ };
+ }
+ var node = FS.createNode(parent, name, mode, dev);
+ if (FS.isDir(node.mode)) {
+ node.node_ops = MEMFS.ops_table.dir.node;
+ node.stream_ops = MEMFS.ops_table.dir.stream;
+ node.contents = {};
+ } else if (FS.isFile(node.mode)) {
+ node.node_ops = MEMFS.ops_table.file.node;
+ node.stream_ops = MEMFS.ops_table.file.stream;
+ node.contents = [];
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ } else if (FS.isLink(node.mode)) {
+ node.node_ops = MEMFS.ops_table.link.node;
+ node.stream_ops = MEMFS.ops_table.link.stream;
+ } else if (FS.isChrdev(node.mode)) {
+ node.node_ops = MEMFS.ops_table.chrdev.node;
+ node.stream_ops = MEMFS.ops_table.chrdev.stream;
+ }
+ node.timestamp = Date.now();
+ // add the new node to the parent
+ if (parent) {
+ parent.contents[name] = node;
+ }
+ return node;
+ },ensureFlexible:function (node) {
+ if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
+ var contents = node.contents;
+ node.contents = Array.prototype.slice.call(contents);
+ node.contentMode = MEMFS.CONTENT_FLEXIBLE;
+ }
+ },node_ops:{getattr:function (node) {
+ var attr = {};
+ // device numbers reuse inode numbers.
+ attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
+ attr.ino = node.id;
+ attr.mode = node.mode;
+ attr.nlink = 1;
+ attr.uid = 0;
+ attr.gid = 0;
+ attr.rdev = node.rdev;
+ if (FS.isDir(node.mode)) {
+ attr.size = 4096;
+ } else if (FS.isFile(node.mode)) {
+ attr.size = node.contents.length;
+ } else if (FS.isLink(node.mode)) {
+ attr.size = node.link.length;
+ } else {
+ attr.size = 0;
+ }
+ attr.atime = new Date(node.timestamp);
+ attr.mtime = new Date(node.timestamp);
+ attr.ctime = new Date(node.timestamp);
+ // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
+ // but this is not required by the standard.
+ attr.blksize = 4096;
+ attr.blocks = Math.ceil(attr.size / attr.blksize);
+ return attr;
+ },setattr:function (node, attr) {
+ if (attr.mode !== undefined) {
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ node.timestamp = attr.timestamp;
+ }
+ if (attr.size !== undefined) {
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ if (attr.size < contents.length) contents.length = attr.size;
+ else while (attr.size > contents.length) contents.push(0);
+ }
+ },lookup:function (parent, name) {
+ throw FS.genericErrors[ERRNO_CODES.ENOENT];
+ },mknod:function (parent, name, mode, dev) {
+ return MEMFS.createNode(parent, name, mode, dev);
+ },rename:function (old_node, new_dir, new_name) {
+ // if we're overwriting a directory at new_name, make sure it's empty.
+ if (FS.isDir(old_node.mode)) {
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ }
+ if (new_node) {
+ for (var i in new_node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ }
+ }
+ // do the internal rewiring
+ delete old_node.parent.contents[old_node.name];
+ old_node.name = new_name;
+ new_dir.contents[new_name] = old_node;
+ old_node.parent = new_dir;
+ },unlink:function (parent, name) {
+ delete parent.contents[name];
+ },rmdir:function (parent, name) {
+ var node = FS.lookupNode(parent, name);
+ for (var i in node.contents) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ delete parent.contents[name];
+ },readdir:function (node) {
+ var entries = ['.', '..']
+ for (var key in node.contents) {
+ if (!node.contents.hasOwnProperty(key)) {
+ continue;
+ }
+ entries.push(key);
+ }
+ return entries;
+ },symlink:function (parent, newname, oldpath) {
+ var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
+ node.link = oldpath;
+ return node;
+ },readlink:function (node) {
+ if (!FS.isLink(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return node.link;
+ }},stream_ops:{read:function (stream, buffer, offset, length, position) {
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (size > 8 && contents.subarray) { // non-trivial, and typed array
+ buffer.set(contents.subarray(position, position + size), offset);
+ } else
+ {
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ }
+ return size;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ var node = stream.node;
+ node.timestamp = Date.now();
+ var contents = node.contents;
+ if (length && contents.length === 0 && position === 0 && buffer.subarray) {
+ // just replace it with the new data
+ if (canOwn && offset === 0) {
+ node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
+ node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
+ } else {
+ node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
+ node.contentMode = MEMFS.CONTENT_FIXED;
+ }
+ return length;
+ }
+ MEMFS.ensureFlexible(node);
+ var contents = node.contents;
+ while (contents.length < position) contents.push(0);
+ for (var i = 0; i < length; i++) {
+ contents[position + i] = buffer[offset + i];
+ }
+ return length;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ position += stream.node.contents.length;
+ }
+ }
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ stream.ungotten = [];
+ stream.position = position;
+ return position;
+ },allocate:function (stream, offset, length) {
+ MEMFS.ensureFlexible(stream.node);
+ var contents = stream.node.contents;
+ var limit = offset + length;
+ while (limit > contents.length) contents.push(0);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ if (!FS.isFile(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ var ptr;
+ var allocated;
+ var contents = stream.node.contents;
+ // Only make a new copy when MAP_PRIVATE is specified.
+ if ( !(flags & 2) &&
+ (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
+ // We can't emulate MAP_SHARED when the file is not backed by the buffer
+ // we're mapping to (e.g. the HEAP buffer).
+ allocated = false;
+ ptr = contents.byteOffset;
+ } else {
+ // Try to avoid unnecessary slices.
+ if (position > 0 || position + length < contents.length) {
+ if (contents.subarray) {
+ contents = contents.subarray(position, position + length);
+ } else {
+ contents = Array.prototype.slice.call(contents, position, position + length);
+ }
+ }
+ allocated = true;
+ ptr = _malloc(length);
+ if (!ptr) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
+ }
+ buffer.set(contents, ptr);
+ }
+ return { ptr: ptr, allocated: allocated };
+ }}};
+
+ var IDBFS={dbs:{},indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
+ // reuse all of the core MEMFS functionality
+ return MEMFS.mount.apply(null, arguments);
+ },syncfs:function (mount, populate, callback) {
+ IDBFS.getLocalSet(mount, function(err, local) {
+ if (err) return callback(err);
+
+ IDBFS.getRemoteSet(mount, function(err, remote) {
+ if (err) return callback(err);
+
+ var src = populate ? remote : local;
+ var dst = populate ? local : remote;
+
+ IDBFS.reconcile(src, dst, callback);
+ });
+ });
+ },getDB:function (name, callback) {
+ // check the cache first
+ var db = IDBFS.dbs[name];
+ if (db) {
+ return callback(null, db);
+ }
+
+ var req;
+ try {
+ req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
+ } catch (e) {
+ return callback(e);
+ }
+ req.onupgradeneeded = function(e) {
+ var db = e.target.result;
+ var transaction = e.target.transaction;
+
+ var fileStore;
+
+ if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
+ fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ } else {
+ fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
+ }
+
+ fileStore.createIndex('timestamp', 'timestamp', { unique: false });
+ };
+ req.onsuccess = function() {
+ db = req.result;
+
+ // add to the cache
+ IDBFS.dbs[name] = db;
+ callback(null, db);
+ };
+ req.onerror = function() {
+ callback(this.error);
+ };
+ },getLocalSet:function (mount, callback) {
+ var entries = {};
+
+ function isRealDir(p) {
+ return p !== '.' && p !== '..';
+ };
+ function toAbsolute(root) {
+ return function(p) {
+ return PATH.join2(root, p);
+ }
+ };
+
+ var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
+
+ while (check.length) {
+ var path = check.pop();
+ var stat;
+
+ try {
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
+ }
+
+ entries[path] = { timestamp: stat.mtime };
+ }
+
+ return callback(null, { type: 'local', entries: entries });
+ },getRemoteSet:function (mount, callback) {
+ var entries = {};
+
+ IDBFS.getDB(mount.mountpoint, function(err, db) {
+ if (err) return callback(err);
+
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
+ transaction.onerror = function() { callback(this.error); };
+
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+ var index = store.index('timestamp');
+
+ index.openKeyCursor().onsuccess = function(event) {
+ var cursor = event.target.result;
+
+ if (!cursor) {
+ return callback(null, { type: 'remote', db: db, entries: entries });
+ }
+
+ entries[cursor.primaryKey] = { timestamp: cursor.key };
+
+ cursor.continue();
+ };
+ });
+ },loadLocalEntry:function (path, callback) {
+ var stat, node;
+
+ try {
+ var lookup = FS.lookupPath(path);
+ node = lookup.node;
+ stat = FS.stat(path);
+ } catch (e) {
+ return callback(e);
+ }
+
+ if (FS.isDir(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode });
+ } else if (FS.isFile(stat.mode)) {
+ return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+ },storeLocalEntry:function (path, entry, callback) {
+ try {
+ if (FS.isDir(entry.mode)) {
+ FS.mkdir(path, entry.mode);
+ } else if (FS.isFile(entry.mode)) {
+ FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
+ } else {
+ return callback(new Error('node type not supported'));
+ }
+
+ FS.utime(path, entry.timestamp, entry.timestamp);
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },removeLocalEntry:function (path, callback) {
+ try {
+ var lookup = FS.lookupPath(path);
+ var stat = FS.stat(path);
+
+ if (FS.isDir(stat.mode)) {
+ FS.rmdir(path);
+ } else if (FS.isFile(stat.mode)) {
+ FS.unlink(path);
+ }
+ } catch (e) {
+ return callback(e);
+ }
+
+ callback(null);
+ },loadRemoteEntry:function (store, path, callback) {
+ var req = store.get(path);
+ req.onsuccess = function(event) { callback(null, event.target.result); };
+ req.onerror = function() { callback(this.error); };
+ },storeRemoteEntry:function (store, path, entry, callback) {
+ var req = store.put(entry, path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },removeRemoteEntry:function (store, path, callback) {
+ var req = store.delete(path);
+ req.onsuccess = function() { callback(null); };
+ req.onerror = function() { callback(this.error); };
+ },reconcile:function (src, dst, callback) {
+ var total = 0;
+
+ var create = [];
+ Object.keys(src.entries).forEach(function (key) {
+ var e = src.entries[key];
+ var e2 = dst.entries[key];
+ if (!e2 || e.timestamp > e2.timestamp) {
+ create.push(key);
+ total++;
+ }
+ });
+
+ var remove = [];
+ Object.keys(dst.entries).forEach(function (key) {
+ var e = dst.entries[key];
+ var e2 = src.entries[key];
+ if (!e2) {
+ remove.push(key);
+ total++;
+ }
+ });
+
+ if (!total) {
+ return callback(null);
+ }
+
+ var errored = false;
+ var completed = 0;
+ var db = src.type === 'remote' ? src.db : dst.db;
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= total) {
+ return callback(null);
+ }
+ };
+
+ transaction.onerror = function() { done(this.error); };
+
+ // sort paths in ascending order so directory entries are created
+ // before the files inside them
+ create.sort().forEach(function (path) {
+ if (dst.type === 'local') {
+ IDBFS.loadRemoteEntry(store, path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeLocalEntry(path, entry, done);
+ });
+ } else {
+ IDBFS.loadLocalEntry(path, function (err, entry) {
+ if (err) return done(err);
+ IDBFS.storeRemoteEntry(store, path, entry, done);
+ });
+ }
+ });
+
+ // sort paths in descending order so files are deleted before their
+ // parent directories
+ remove.sort().reverse().forEach(function(path) {
+ if (dst.type === 'local') {
+ IDBFS.removeLocalEntry(path, done);
+ } else {
+ IDBFS.removeRemoteEntry(store, path, done);
+ }
+ });
+ }};
+
+ var NODEFS={isWindows:false,staticInit:function () {
+ NODEFS.isWindows = !!process.platform.match(/^win/);
+ },mount:function (mount) {
+ assert(ENVIRONMENT_IS_NODE);
+ return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
+ },createNode:function (parent, name, mode, dev) {
+ if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node = FS.createNode(parent, name, mode);
+ node.node_ops = NODEFS.node_ops;
+ node.stream_ops = NODEFS.stream_ops;
+ return node;
+ },getMode:function (path) {
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ if (NODEFS.isWindows) {
+ // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so
+ // propagate write bits to execute bits.
+ stat.mode = stat.mode | ((stat.mode & 146) >> 1);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return stat.mode;
+ },realPath:function (node) {
+ var parts = [];
+ while (node.parent !== node) {
+ parts.push(node.name);
+ node = node.parent;
+ }
+ parts.push(node.mount.opts.root);
+ parts.reverse();
+ return PATH.join.apply(null, parts);
+ },flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function (flags) {
+ if (flags in NODEFS.flagsToPermissionStringMap) {
+ return NODEFS.flagsToPermissionStringMap[flags];
+ } else {
+ return flags;
+ }
+ },node_ops:{getattr:function (node) {
+ var path = NODEFS.realPath(node);
+ var stat;
+ try {
+ stat = fs.lstatSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
+ // See http://support.microsoft.com/kb/140365
+ if (NODEFS.isWindows && !stat.blksize) {
+ stat.blksize = 4096;
+ }
+ if (NODEFS.isWindows && !stat.blocks) {
+ stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
+ }
+ return {
+ dev: stat.dev,
+ ino: stat.ino,
+ mode: stat.mode,
+ nlink: stat.nlink,
+ uid: stat.uid,
+ gid: stat.gid,
+ rdev: stat.rdev,
+ size: stat.size,
+ atime: stat.atime,
+ mtime: stat.mtime,
+ ctime: stat.ctime,
+ blksize: stat.blksize,
+ blocks: stat.blocks
+ };
+ },setattr:function (node, attr) {
+ var path = NODEFS.realPath(node);
+ try {
+ if (attr.mode !== undefined) {
+ fs.chmodSync(path, attr.mode);
+ // update the common node structure mode as well
+ node.mode = attr.mode;
+ }
+ if (attr.timestamp !== undefined) {
+ var date = new Date(attr.timestamp);
+ fs.utimesSync(path, date, date);
+ }
+ if (attr.size !== undefined) {
+ fs.truncateSync(path, attr.size);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },lookup:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ var mode = NODEFS.getMode(path);
+ return NODEFS.createNode(parent, name, mode);
+ },mknod:function (parent, name, mode, dev) {
+ var node = NODEFS.createNode(parent, name, mode, dev);
+ // create the backing node for this in the fs root as well
+ var path = NODEFS.realPath(node);
+ try {
+ if (FS.isDir(node.mode)) {
+ fs.mkdirSync(path, node.mode);
+ } else {
+ fs.writeFileSync(path, '', { mode: node.mode });
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return node;
+ },rename:function (oldNode, newDir, newName) {
+ var oldPath = NODEFS.realPath(oldNode);
+ var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
+ try {
+ fs.renameSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },unlink:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.unlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },rmdir:function (parent, name) {
+ var path = PATH.join2(NODEFS.realPath(parent), name);
+ try {
+ fs.rmdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readdir:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readdirSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },symlink:function (parent, newName, oldPath) {
+ var newPath = PATH.join2(NODEFS.realPath(parent), newName);
+ try {
+ fs.symlinkSync(oldPath, newPath);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },readlink:function (node) {
+ var path = NODEFS.realPath(node);
+ try {
+ return fs.readlinkSync(path);
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }},stream_ops:{open:function (stream) {
+ var path = NODEFS.realPath(stream.node);
+ try {
+ if (FS.isFile(stream.node.mode)) {
+ stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },close:function (stream) {
+ try {
+ if (FS.isFile(stream.node.mode) && stream.nfd) {
+ fs.closeSync(stream.nfd);
+ }
+ } catch (e) {
+ if (!e.code) throw e;
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ },read:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(length);
+ var res;
+ try {
+ res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ if (res > 0) {
+ for (var i = 0; i < res; i++) {
+ buffer[offset + i] = nbuffer[i];
+ }
+ }
+ return res;
+ },write:function (stream, buffer, offset, length, position) {
+ // FIXME this is terrible.
+ var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
+ var res;
+ try {
+ res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ return res;
+ },llseek:function (stream, offset, whence) {
+ var position = offset;
+ if (whence === 1) { // SEEK_CUR.
+ position += stream.position;
+ } else if (whence === 2) { // SEEK_END.
+ if (FS.isFile(stream.node.mode)) {
+ try {
+ var stat = fs.fstatSync(stream.nfd);
+ position += stat.size;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES[e.code]);
+ }
+ }
+ }
+
+ if (position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ stream.position = position;
+ return position;
+ }}};
+
+ var _stdin=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stdout=allocate(1, "i32*", ALLOC_STATIC);
+
+ var _stderr=allocate(1, "i32*", ALLOC_STATIC);
+
+ function _fflush(stream) {
+ // int fflush(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html
+ // we don't currently perform any user-space buffering of data
+ }var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},handleFSError:function (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
+ return ___setErrNo(e.errno);
+ },lookupPath:function (path, opts) {
+ path = PATH.resolve(FS.cwd(), path);
+ opts = opts || {};
+
+ var defaults = {
+ follow_mount: true,
+ recurse_count: 0
+ };
+ for (var key in defaults) {
+ if (opts[key] === undefined) {
+ opts[key] = defaults[key];
+ }
+ }
+
+ if (opts.recurse_count > 8) { // max recursive lookup of 8
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+
+ // split the path
+ var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
+ return !!p;
+ }), false);
+
+ // start at the root
+ var current = FS.root;
+ var current_path = '/';
+
+ for (var i = 0; i < parts.length; i++) {
+ var islast = (i === parts.length-1);
+ if (islast && opts.parent) {
+ // stop resolving
+ break;
+ }
+
+ current = FS.lookupNode(current, parts[i]);
+ current_path = PATH.join2(current_path, parts[i]);
+
+ // jump to the mount's root node if this is a mountpoint
+ if (FS.isMountpoint(current)) {
+ if (!islast || (islast && opts.follow_mount)) {
+ current = current.mounted.root;
+ }
+ }
+
+ // by default, lookupPath will not follow a symlink if it is the final path component.
+ // setting opts.follow = true will override this behavior.
+ if (!islast || opts.follow) {
+ var count = 0;
+ while (FS.isLink(current.mode)) {
+ var link = FS.readlink(current_path);
+ current_path = PATH.resolve(PATH.dirname(current_path), link);
+
+ var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
+ current = lookup.node;
+
+ if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
+ throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
+ }
+ }
+ }
+ }
+
+ return { path: current_path, node: current };
+ },getPath:function (node) {
+ var path;
+ while (true) {
+ if (FS.isRoot(node)) {
+ var mount = node.mount.mountpoint;
+ if (!path) return mount;
+ return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
+ }
+ path = path ? node.name + '/' + path : node.name;
+ node = node.parent;
+ }
+ },hashName:function (parentid, name) {
+ var hash = 0;
+
+
+ for (var i = 0; i < name.length; i++) {
+ hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
+ }
+ return ((parentid + hash) >>> 0) % FS.nameTable.length;
+ },hashAddNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ node.name_next = FS.nameTable[hash];
+ FS.nameTable[hash] = node;
+ },hashRemoveNode:function (node) {
+ var hash = FS.hashName(node.parent.id, node.name);
+ if (FS.nameTable[hash] === node) {
+ FS.nameTable[hash] = node.name_next;
+ } else {
+ var current = FS.nameTable[hash];
+ while (current) {
+ if (current.name_next === node) {
+ current.name_next = node.name_next;
+ break;
+ }
+ current = current.name_next;
+ }
+ }
+ },lookupNode:function (parent, name) {
+ var err = FS.mayLookup(parent);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ var hash = FS.hashName(parent.id, name);
+ for (var node = FS.nameTable[hash]; node; node = node.name_next) {
+ var nodeName = node.name;
+ if (node.parent.id === parent.id && nodeName === name) {
+ return node;
+ }
+ }
+ // if we failed to find it in the cache, call into the VFS
+ return FS.lookup(parent, name);
+ },createNode:function (parent, name, mode, rdev) {
+ if (!FS.FSNode) {
+ FS.FSNode = function(parent, name, mode, rdev) {
+ if (!parent) {
+ parent = this; // root node sets parent to itself
+ }
+ this.parent = parent;
+ this.mount = parent.mount;
+ this.mounted = null;
+ this.id = FS.nextInode++;
+ this.name = name;
+ this.mode = mode;
+ this.node_ops = {};
+ this.stream_ops = {};
+ this.rdev = rdev;
+ };
+
+ FS.FSNode.prototype = {};
+
+ // compatibility
+ var readMode = 292 | 73;
+ var writeMode = 146;
+
+ // NOTE we must use Object.defineProperties instead of individual calls to
+ // Object.defineProperty in order to make closure compiler happy
+ Object.defineProperties(FS.FSNode.prototype, {
+ read: {
+ get: function() { return (this.mode & readMode) === readMode; },
+ set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
+ },
+ write: {
+ get: function() { return (this.mode & writeMode) === writeMode; },
+ set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
+ },
+ isFolder: {
+ get: function() { return FS.isDir(this.mode); },
+ },
+ isDevice: {
+ get: function() { return FS.isChrdev(this.mode); },
+ },
+ });
+ }
+
+ var node = new FS.FSNode(parent, name, mode, rdev);
+
+ FS.hashAddNode(node);
+
+ return node;
+ },destroyNode:function (node) {
+ FS.hashRemoveNode(node);
+ },isRoot:function (node) {
+ return node === node.parent;
+ },isMountpoint:function (node) {
+ return !!node.mounted;
+ },isFile:function (mode) {
+ return (mode & 61440) === 32768;
+ },isDir:function (mode) {
+ return (mode & 61440) === 16384;
+ },isLink:function (mode) {
+ return (mode & 61440) === 40960;
+ },isChrdev:function (mode) {
+ return (mode & 61440) === 8192;
+ },isBlkdev:function (mode) {
+ return (mode & 61440) === 24576;
+ },isFIFO:function (mode) {
+ return (mode & 61440) === 4096;
+ },isSocket:function (mode) {
+ return (mode & 49152) === 49152;
+ },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
+ var flags = FS.flagModes[str];
+ if (typeof flags === 'undefined') {
+ throw new Error('Unknown file open mode: ' + str);
+ }
+ return flags;
+ },flagsToPermissionString:function (flag) {
+ var accmode = flag & 2097155;
+ var perms = ['r', 'w', 'rw'][accmode];
+ if ((flag & 512)) {
+ perms += 'w';
+ }
+ return perms;
+ },nodePermissions:function (node, perms) {
+ if (FS.ignorePermissions) {
+ return 0;
+ }
+ // return 0 if any user, group or owner bits are set.
+ if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
+ return ERRNO_CODES.EACCES;
+ } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
+ return ERRNO_CODES.EACCES;
+ }
+ return 0;
+ },mayLookup:function (dir) {
+ return FS.nodePermissions(dir, 'x');
+ },mayCreate:function (dir, name) {
+ try {
+ var node = FS.lookupNode(dir, name);
+ return ERRNO_CODES.EEXIST;
+ } catch (e) {
+ }
+ return FS.nodePermissions(dir, 'wx');
+ },mayDelete:function (dir, name, isdir) {
+ var node;
+ try {
+ node = FS.lookupNode(dir, name);
+ } catch (e) {
+ return e.errno;
+ }
+ var err = FS.nodePermissions(dir, 'wx');
+ if (err) {
+ return err;
+ }
+ if (isdir) {
+ if (!FS.isDir(node.mode)) {
+ return ERRNO_CODES.ENOTDIR;
+ }
+ if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
+ return ERRNO_CODES.EBUSY;
+ }
+ } else {
+ if (FS.isDir(node.mode)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return 0;
+ },mayOpen:function (node, flags) {
+ if (!node) {
+ return ERRNO_CODES.ENOENT;
+ }
+ if (FS.isLink(node.mode)) {
+ return ERRNO_CODES.ELOOP;
+ } else if (FS.isDir(node.mode)) {
+ if ((flags & 2097155) !== 0 || // opening for write
+ (flags & 512)) {
+ return ERRNO_CODES.EISDIR;
+ }
+ }
+ return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
+ },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
+ fd_start = fd_start || 0;
+ fd_end = fd_end || FS.MAX_OPEN_FDS;
+ for (var fd = fd_start; fd <= fd_end; fd++) {
+ if (!FS.streams[fd]) {
+ return fd;
+ }
+ }
+ throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
+ },getStream:function (fd) {
+ return FS.streams[fd];
+ },createStream:function (stream, fd_start, fd_end) {
+ if (!FS.FSStream) {
+ FS.FSStream = function(){};
+ FS.FSStream.prototype = {};
+ // compatibility
+ Object.defineProperties(FS.FSStream.prototype, {
+ object: {
+ get: function() { return this.node; },
+ set: function(val) { this.node = val; }
+ },
+ isRead: {
+ get: function() { return (this.flags & 2097155) !== 1; }
+ },
+ isWrite: {
+ get: function() { return (this.flags & 2097155) !== 0; }
+ },
+ isAppend: {
+ get: function() { return (this.flags & 1024); }
+ }
+ });
+ }
+ if (0) {
+ // reuse the object
+ stream.__proto__ = FS.FSStream.prototype;
+ } else {
+ var newStream = new FS.FSStream();
+ for (var p in stream) {
+ newStream[p] = stream[p];
+ }
+ stream = newStream;
+ }
+ var fd = FS.nextfd(fd_start, fd_end);
+ stream.fd = fd;
+ FS.streams[fd] = stream;
+ return stream;
+ },closeStream:function (fd) {
+ FS.streams[fd] = null;
+ },getStreamFromPtr:function (ptr) {
+ return FS.streams[ptr - 1];
+ },getPtrForStream:function (stream) {
+ return stream ? stream.fd + 1 : 0;
+ },chrdev_stream_ops:{open:function (stream) {
+ var device = FS.getDevice(stream.node.rdev);
+ // override node's stream ops with the device's
+ stream.stream_ops = device.stream_ops;
+ // forward the open call
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ },llseek:function () {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }},major:function (dev) {
+ return ((dev) >> 8);
+ },minor:function (dev) {
+ return ((dev) & 0xff);
+ },makedev:function (ma, mi) {
+ return ((ma) << 8 | (mi));
+ },registerDevice:function (dev, ops) {
+ FS.devices[dev] = { stream_ops: ops };
+ },getDevice:function (dev) {
+ return FS.devices[dev];
+ },getMounts:function (mount) {
+ var mounts = [];
+ var check = [mount];
+
+ while (check.length) {
+ var m = check.pop();
+
+ mounts.push(m);
+
+ check.push.apply(check, m.mounts);
+ }
+
+ return mounts;
+ },syncfs:function (populate, callback) {
+ if (typeof(populate) === 'function') {
+ callback = populate;
+ populate = false;
+ }
+
+ var mounts = FS.getMounts(FS.root.mount);
+ var completed = 0;
+
+ function done(err) {
+ if (err) {
+ if (!done.errored) {
+ done.errored = true;
+ return callback(err);
+ }
+ return;
+ }
+ if (++completed >= mounts.length) {
+ callback(null);
+ }
+ };
+
+ // sync all mounts
+ mounts.forEach(function (mount) {
+ if (!mount.type.syncfs) {
+ return done(null);
+ }
+ mount.type.syncfs(mount, populate, done);
+ });
+ },mount:function (type, opts, mountpoint) {
+ var root = mountpoint === '/';
+ var pseudo = !mountpoint;
+ var node;
+
+ if (root && FS.root) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ } else if (!root && !pseudo) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ mountpoint = lookup.path; // use the absolute path
+ node = lookup.node;
+
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+
+ if (!FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ }
+
+ var mount = {
+ type: type,
+ opts: opts,
+ mountpoint: mountpoint,
+ mounts: []
+ };
+
+ // create a root node for the fs
+ var mountRoot = type.mount(mount);
+ mountRoot.mount = mount;
+ mount.root = mountRoot;
+
+ if (root) {
+ FS.root = mountRoot;
+ } else if (node) {
+ // set as a mountpoint
+ node.mounted = mount;
+
+ // add the new mount to the current mount's children
+ if (node.mount) {
+ node.mount.mounts.push(mount);
+ }
+ }
+
+ return mountRoot;
+ },unmount:function (mountpoint) {
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
+
+ if (!FS.isMountpoint(lookup.node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+
+ // destroy the nodes for this mount, and all its child mounts
+ var node = lookup.node;
+ var mount = node.mounted;
+ var mounts = FS.getMounts(mount);
+
+ Object.keys(FS.nameTable).forEach(function (hash) {
+ var current = FS.nameTable[hash];
+
+ while (current) {
+ var next = current.name_next;
+
+ if (mounts.indexOf(current.mount) !== -1) {
+ FS.destroyNode(current);
+ }
+
+ current = next;
+ }
+ });
+
+ // no longer a mountpoint
+ node.mounted = null;
+
+ // remove this mount from the child mounts
+ var idx = node.mount.mounts.indexOf(mount);
+ assert(idx !== -1);
+ node.mount.mounts.splice(idx, 1);
+ },lookup:function (parent, name) {
+ return parent.node_ops.lookup(parent, name);
+ },mknod:function (path, mode, dev) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var err = FS.mayCreate(parent, name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.mknod) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.mknod(parent, name, mode, dev);
+ },create:function (path, mode) {
+ mode = mode !== undefined ? mode : 438 /* 0666 */;
+ mode &= 4095;
+ mode |= 32768;
+ return FS.mknod(path, mode, 0);
+ },mkdir:function (path, mode) {
+ mode = mode !== undefined ? mode : 511 /* 0777 */;
+ mode &= 511 | 512;
+ mode |= 16384;
+ return FS.mknod(path, mode, 0);
+ },mkdev:function (path, mode, dev) {
+ if (typeof(dev) === 'undefined') {
+ dev = mode;
+ mode = 438 /* 0666 */;
+ }
+ mode |= 8192;
+ return FS.mknod(path, mode, dev);
+ },symlink:function (oldpath, newpath) {
+ var lookup = FS.lookupPath(newpath, { parent: true });
+ var parent = lookup.node;
+ var newname = PATH.basename(newpath);
+ var err = FS.mayCreate(parent, newname);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.symlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return parent.node_ops.symlink(parent, newname, oldpath);
+ },rename:function (old_path, new_path) {
+ var old_dirname = PATH.dirname(old_path);
+ var new_dirname = PATH.dirname(new_path);
+ var old_name = PATH.basename(old_path);
+ var new_name = PATH.basename(new_path);
+ // parents must exist
+ var lookup, old_dir, new_dir;
+ try {
+ lookup = FS.lookupPath(old_path, { parent: true });
+ old_dir = lookup.node;
+ lookup = FS.lookupPath(new_path, { parent: true });
+ new_dir = lookup.node;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // need to be part of the same mount
+ if (old_dir.mount !== new_dir.mount) {
+ throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
+ }
+ // source must exist
+ var old_node = FS.lookupNode(old_dir, old_name);
+ // old path should not be an ancestor of the new path
+ var relative = PATH.relative(old_path, new_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ // new path should not be an ancestor of the old path
+ relative = PATH.relative(new_path, old_dirname);
+ if (relative.charAt(0) !== '.') {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
+ }
+ // see if the new path already exists
+ var new_node;
+ try {
+ new_node = FS.lookupNode(new_dir, new_name);
+ } catch (e) {
+ // not fatal
+ }
+ // early out if nothing needs to change
+ if (old_node === new_node) {
+ return;
+ }
+ // we'll need to delete the old entry
+ var isdir = FS.isDir(old_node.mode);
+ var err = FS.mayDelete(old_dir, old_name, isdir);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // need delete permissions if we'll be overwriting.
+ // need create permissions if new doesn't already exist.
+ err = new_node ?
+ FS.mayDelete(new_dir, new_name, isdir) :
+ FS.mayCreate(new_dir, new_name);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!old_dir.node_ops.rename) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ // if we are going to change the parent, check write permissions
+ if (new_dir !== old_dir) {
+ err = FS.nodePermissions(old_dir, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ }
+ // remove the node from the lookup hash
+ FS.hashRemoveNode(old_node);
+ // do the underlying fs rename
+ try {
+ old_dir.node_ops.rename(old_node, new_dir, new_name);
+ } catch (e) {
+ throw e;
+ } finally {
+ // add the node back to the hash (in case node_ops.rename
+ // changed its name)
+ FS.hashAddNode(old_node);
+ }
+ },rmdir:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, true);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.rmdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.rmdir(parent, name);
+ FS.destroyNode(node);
+ },readdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ if (!node.node_ops.readdir) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ return node.node_ops.readdir(node);
+ },unlink:function (path) {
+ var lookup = FS.lookupPath(path, { parent: true });
+ var parent = lookup.node;
+ var name = PATH.basename(path);
+ var node = FS.lookupNode(parent, name);
+ var err = FS.mayDelete(parent, name, false);
+ if (err) {
+ // POSIX says unlink should set EPERM, not EISDIR
+ if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;
+ throw new FS.ErrnoError(err);
+ }
+ if (!parent.node_ops.unlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isMountpoint(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
+ }
+ parent.node_ops.unlink(parent, name);
+ FS.destroyNode(node);
+ },readlink:function (path) {
+ var lookup = FS.lookupPath(path);
+ var link = lookup.node;
+ if (!link.node_ops.readlink) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ return link.node_ops.readlink(link);
+ },stat:function (path, dontFollow) {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ var node = lookup.node;
+ if (!node.node_ops.getattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ return node.node_ops.getattr(node);
+ },lstat:function (path) {
+ return FS.stat(path, true);
+ },chmod:function (path, mode, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ mode: (mode & 4095) | (node.mode & ~4095),
+ timestamp: Date.now()
+ });
+ },lchmod:function (path, mode) {
+ FS.chmod(path, mode, true);
+ },fchmod:function (fd, mode) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chmod(stream.node, mode);
+ },chown:function (path, uid, gid, dontFollow) {
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ node.node_ops.setattr(node, {
+ timestamp: Date.now()
+ // we ignore the uid / gid for now
+ });
+ },lchown:function (path, uid, gid) {
+ FS.chown(path, uid, gid, true);
+ },fchown:function (fd, uid, gid) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ FS.chown(stream.node, uid, gid);
+ },truncate:function (path, len) {
+ if (len < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var node;
+ if (typeof path === 'string') {
+ var lookup = FS.lookupPath(path, { follow: true });
+ node = lookup.node;
+ } else {
+ node = path;
+ }
+ if (!node.node_ops.setattr) {
+ throw new FS.ErrnoError(ERRNO_CODES.EPERM);
+ }
+ if (FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!FS.isFile(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var err = FS.nodePermissions(node, 'w');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ node.node_ops.setattr(node, {
+ size: len,
+ timestamp: Date.now()
+ });
+ },ftruncate:function (fd, len) {
+ var stream = FS.getStream(fd);
+ if (!stream) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ FS.truncate(stream.node, len);
+ },utime:function (path, atime, mtime) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ var node = lookup.node;
+ node.node_ops.setattr(node, {
+ timestamp: Math.max(atime, mtime)
+ });
+ },open:function (path, flags, mode, fd_start, fd_end) {
+ flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
+ mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
+ if ((flags & 64)) {
+ mode = (mode & 4095) | 32768;
+ } else {
+ mode = 0;
+ }
+ var node;
+ if (typeof path === 'object') {
+ node = path;
+ } else {
+ path = PATH.normalize(path);
+ try {
+ var lookup = FS.lookupPath(path, {
+ follow: !(flags & 131072)
+ });
+ node = lookup.node;
+ } catch (e) {
+ // ignore
+ }
+ }
+ // perhaps we need to create the node
+ if ((flags & 64)) {
+ if (node) {
+ // if O_CREAT and O_EXCL are set, error out if the node already exists
+ if ((flags & 128)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
+ }
+ } else {
+ // node doesn't exist, try to create it
+ node = FS.mknod(path, mode, 0);
+ }
+ }
+ if (!node) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
+ }
+ // can't truncate a device
+ if (FS.isChrdev(node.mode)) {
+ flags &= ~512;
+ }
+ // check permissions
+ var err = FS.mayOpen(node, flags);
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ // do truncation if necessary
+ if ((flags & 512)) {
+ FS.truncate(node, 0);
+ }
+ // we've already handled these, don't pass down to the underlying vfs
+ flags &= ~(128 | 512);
+
+ // register the stream with the filesystem
+ var stream = FS.createStream({
+ node: node,
+ path: FS.getPath(node), // we want the absolute path to the node
+ flags: flags,
+ seekable: true,
+ position: 0,
+ stream_ops: node.stream_ops,
+ // used by the file family libc calls (fopen, fwrite, ferror, etc.)
+ ungotten: [],
+ error: false
+ }, fd_start, fd_end);
+ // call the new stream's open function
+ if (stream.stream_ops.open) {
+ stream.stream_ops.open(stream);
+ }
+ if (Module['logReadFiles'] && !(flags & 1)) {
+ if (!FS.readFiles) FS.readFiles = {};
+ if (!(path in FS.readFiles)) {
+ FS.readFiles[path] = 1;
+ Module['printErr']('read file: ' + path);
+ }
+ }
+ return stream;
+ },close:function (stream) {
+ try {
+ if (stream.stream_ops.close) {
+ stream.stream_ops.close(stream);
+ }
+ } catch (e) {
+ throw e;
+ } finally {
+ FS.closeStream(stream.fd);
+ }
+ },llseek:function (stream, offset, whence) {
+ if (!stream.seekable || !stream.stream_ops.llseek) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ return stream.stream_ops.llseek(stream, offset, whence);
+ },read:function (stream, buffer, offset, length, position) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.read) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
+ if (!seeking) stream.position += bytesRead;
+ return bytesRead;
+ },write:function (stream, buffer, offset, length, position, canOwn) {
+ if (length < 0 || position < 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (FS.isDir(stream.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
+ }
+ if (!stream.stream_ops.write) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var seeking = true;
+ if (typeof position === 'undefined') {
+ position = stream.position;
+ seeking = false;
+ } else if (!stream.seekable) {
+ throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
+ }
+ if (stream.flags & 1024) {
+ // seek to the end before writing in append mode
+ FS.llseek(stream, 0, 2);
+ }
+ var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
+ if (!seeking) stream.position += bytesWritten;
+ return bytesWritten;
+ },allocate:function (stream, offset, length) {
+ if (offset < 0 || length <= 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ if ((stream.flags & 2097155) === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EBADF);
+ }
+ if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ if (!stream.stream_ops.allocate) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ stream.stream_ops.allocate(stream, offset, length);
+ },mmap:function (stream, buffer, offset, length, position, prot, flags) {
+ // TODO if PROT is PROT_WRITE, make sure we have write access
+ if ((stream.flags & 2097155) === 1) {
+ throw new FS.ErrnoError(ERRNO_CODES.EACCES);
+ }
+ if (!stream.stream_ops.mmap) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
+ }
+ return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
+ },ioctl:function (stream, cmd, arg) {
+ if (!stream.stream_ops.ioctl) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
+ }
+ return stream.stream_ops.ioctl(stream, cmd, arg);
+ },readFile:function (path, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'r';
+ opts.encoding = opts.encoding || 'binary';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var ret;
+ var stream = FS.open(path, opts.flags);
+ var stat = FS.stat(path);
+ var length = stat.size;
+ var buf = new Uint8Array(length);
+ FS.read(stream, buf, 0, length, 0);
+ if (opts.encoding === 'utf8') {
+ ret = '';
+ var utf8 = new Runtime.UTF8Processor();
+ for (var i = 0; i < length; i++) {
+ ret += utf8.processCChar(buf[i]);
+ }
+ } else if (opts.encoding === 'binary') {
+ ret = buf;
+ }
+ FS.close(stream);
+ return ret;
+ },writeFile:function (path, data, opts) {
+ opts = opts || {};
+ opts.flags = opts.flags || 'w';
+ opts.encoding = opts.encoding || 'utf8';
+ if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
+ throw new Error('Invalid encoding type "' + opts.encoding + '"');
+ }
+ var stream = FS.open(path, opts.flags, opts.mode);
+ if (opts.encoding === 'utf8') {
+ var utf8 = new Runtime.UTF8Processor();
+ var buf = new Uint8Array(utf8.processJSString(data));
+ FS.write(stream, buf, 0, buf.length, 0, opts.canOwn);
+ } else if (opts.encoding === 'binary') {
+ FS.write(stream, data, 0, data.length, 0, opts.canOwn);
+ }
+ FS.close(stream);
+ },cwd:function () {
+ return FS.currentPath;
+ },chdir:function (path) {
+ var lookup = FS.lookupPath(path, { follow: true });
+ if (!FS.isDir(lookup.node.mode)) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
+ }
+ var err = FS.nodePermissions(lookup.node, 'x');
+ if (err) {
+ throw new FS.ErrnoError(err);
+ }
+ FS.currentPath = lookup.path;
+ },createDefaultDirectories:function () {
+ FS.mkdir('/tmp');
+ },createDefaultDevices:function () {
+ // create /dev
+ FS.mkdir('/dev');
+ // setup /dev/null
+ FS.registerDevice(FS.makedev(1, 3), {
+ read: function() { return 0; },
+ write: function() { return 0; }
+ });
+ FS.mkdev('/dev/null', FS.makedev(1, 3));
+ // setup /dev/tty and /dev/tty1
+ // stderr needs to print output using Module['printErr']
+ // so we register a second tty just for it.
+ TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
+ TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
+ FS.mkdev('/dev/tty', FS.makedev(5, 0));
+ FS.mkdev('/dev/tty1', FS.makedev(6, 0));
+ // we're not going to emulate the actual shm device,
+ // just create the tmp dirs that reside in it commonly
+ FS.mkdir('/dev/shm');
+ FS.mkdir('/dev/shm/tmp');
+ },createStandardStreams:function () {
+ // TODO deprecate the old functionality of a single
+ // input / output callback and that utilizes FS.createDevice
+ // and instead require a unique set of stream ops
+
+ // by default, we symlink the standard streams to the
+ // default tty devices. however, if the standard streams
+ // have been overwritten we create a unique device for
+ // them instead.
+ if (Module['stdin']) {
+ FS.createDevice('/dev', 'stdin', Module['stdin']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdin');
+ }
+ if (Module['stdout']) {
+ FS.createDevice('/dev', 'stdout', null, Module['stdout']);
+ } else {
+ FS.symlink('/dev/tty', '/dev/stdout');
+ }
+ if (Module['stderr']) {
+ FS.createDevice('/dev', 'stderr', null, Module['stderr']);
+ } else {
+ FS.symlink('/dev/tty1', '/dev/stderr');
+ }
+
+ // open default streams for the stdin, stdout and stderr devices
+ var stdin = FS.open('/dev/stdin', 'r');
+ HEAP32[((_stdin)>>2)]=FS.getPtrForStream(stdin);
+ assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
+
+ var stdout = FS.open('/dev/stdout', 'w');
+ HEAP32[((_stdout)>>2)]=FS.getPtrForStream(stdout);
+ assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
+
+ var stderr = FS.open('/dev/stderr', 'w');
+ HEAP32[((_stderr)>>2)]=FS.getPtrForStream(stderr);
+ assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
+ },ensureErrnoError:function () {
+ if (FS.ErrnoError) return;
+ FS.ErrnoError = function ErrnoError(errno) {
+ this.errno = errno;
+ for (var key in ERRNO_CODES) {
+ if (ERRNO_CODES[key] === errno) {
+ this.code = key;
+ break;
+ }
+ }
+ this.message = ERRNO_MESSAGES[errno];
+ };
+ FS.ErrnoError.prototype = new Error();
+ FS.ErrnoError.prototype.constructor = FS.ErrnoError;
+ // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
+ [ERRNO_CODES.ENOENT].forEach(function(code) {
+ FS.genericErrors[code] = new FS.ErrnoError(code);
+ FS.genericErrors[code].stack = '<generic error, no stack>';
+ });
+ },staticInit:function () {
+ FS.ensureErrnoError();
+
+ FS.nameTable = new Array(4096);
+
+ FS.mount(MEMFS, {}, '/');
+
+ FS.createDefaultDirectories();
+ FS.createDefaultDevices();
+ },init:function (input, output, error) {
+ assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
+ FS.init.initialized = true;
+
+ FS.ensureErrnoError();
+
+ // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
+ Module['stdin'] = input || Module['stdin'];
+ Module['stdout'] = output || Module['stdout'];
+ Module['stderr'] = error || Module['stderr'];
+
+ FS.createStandardStreams();
+ },quit:function () {
+ FS.init.initialized = false;
+ for (var i = 0; i < FS.streams.length; i++) {
+ var stream = FS.streams[i];
+ if (!stream) {
+ continue;
+ }
+ FS.close(stream);
+ }
+ },getMode:function (canRead, canWrite) {
+ var mode = 0;
+ if (canRead) mode |= 292 | 73;
+ if (canWrite) mode |= 146;
+ return mode;
+ },joinPath:function (parts, forceRelative) {
+ var path = PATH.join.apply(null, parts);
+ if (forceRelative && path[0] == '/') path = path.substr(1);
+ return path;
+ },absolutePath:function (relative, base) {
+ return PATH.resolve(base, relative);
+ },standardizePath:function (path) {
+ return PATH.normalize(path);
+ },findObject:function (path, dontResolveLastLink) {
+ var ret = FS.analyzePath(path, dontResolveLastLink);
+ if (ret.exists) {
+ return ret.object;
+ } else {
+ ___setErrNo(ret.error);
+ return null;
+ }
+ },analyzePath:function (path, dontResolveLastLink) {
+ // operate from within the context of the symlink's target
+ try {
+ var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ path = lookup.path;
+ } catch (e) {
+ }
+ var ret = {
+ isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
+ parentExists: false, parentPath: null, parentObject: null
+ };
+ try {
+ var lookup = FS.lookupPath(path, { parent: true });
+ ret.parentExists = true;
+ ret.parentPath = lookup.path;
+ ret.parentObject = lookup.node;
+ ret.name = PATH.basename(path);
+ lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
+ ret.exists = true;
+ ret.path = lookup.path;
+ ret.object = lookup.node;
+ ret.name = lookup.node.name;
+ ret.isRoot = lookup.path === '/';
+ } catch (e) {
+ ret.error = e.errno;
+ };
+ return ret;
+ },createFolder:function (parent, name, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.mkdir(path, mode);
+ },createPath:function (parent, path, canRead, canWrite) {
+ parent = typeof parent === 'string' ? parent : FS.getPath(parent);
+ var parts = path.split('/').reverse();
+ while (parts.length) {
+ var part = parts.pop();
+ if (!part) continue;
+ var current = PATH.join2(parent, part);
+ try {
+ FS.mkdir(current);
+ } catch (e) {
+ // ignore EEXIST
+ }
+ parent = current;
+ }
+ return current;
+ },createFile:function (parent, name, properties, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(canRead, canWrite);
+ return FS.create(path, mode);
+ },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
+ var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
+ var mode = FS.getMode(canRead, canWrite);
+ var node = FS.create(path, mode);
+ if (data) {
+ if (typeof data === 'string') {
+ var arr = new Array(data.length);
+ for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
+ data = arr;
+ }
+ // make sure we can write to the file
+ FS.chmod(node, mode | 146);
+ var stream = FS.open(node, 'w');
+ FS.write(stream, data, 0, data.length, 0, canOwn);
+ FS.close(stream);
+ FS.chmod(node, mode);
+ }
+ return node;
+ },createDevice:function (parent, name, input, output) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ var mode = FS.getMode(!!input, !!output);
+ if (!FS.createDevice.major) FS.createDevice.major = 64;
+ var dev = FS.makedev(FS.createDevice.major++, 0);
+ // Create a fake device that a set of stream ops to emulate
+ // the old behavior.
+ FS.registerDevice(dev, {
+ open: function(stream) {
+ stream.seekable = false;
+ },
+ close: function(stream) {
+ // flush any pending line data
+ if (output && output.buffer && output.buffer.length) {
+ output(10);
+ }
+ },
+ read: function(stream, buffer, offset, length, pos /* ignored */) {
+ var bytesRead = 0;
+ for (var i = 0; i < length; i++) {
+ var result;
+ try {
+ result = input();
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ if (result === undefined && bytesRead === 0) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ if (result === null || result === undefined) break;
+ bytesRead++;
+ buffer[offset+i] = result;
+ }
+ if (bytesRead) {
+ stream.node.timestamp = Date.now();
+ }
+ return bytesRead;
+ },
+ write: function(stream, buffer, offset, length, pos) {
+ for (var i = 0; i < length; i++) {
+ try {
+ output(buffer[offset+i]);
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ }
+ if (length) {
+ stream.node.timestamp = Date.now();
+ }
+ return i;
+ }
+ });
+ return FS.mkdev(path, mode, dev);
+ },createLink:function (parent, name, target, canRead, canWrite) {
+ var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
+ return FS.symlink(target, path);
+ },forceLoadFile:function (obj) {
+ if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
+ var success = true;
+ if (typeof XMLHttpRequest !== 'undefined') {
+ throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
+ } else if (Module['read']) {
+ // Command-line.
+ try {
+ // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
+ // read() will try to parse UTF8.
+ obj.contents = intArrayFromString(Module['read'](obj.url), true);
+ } catch (e) {
+ success = false;
+ }
+ } else {
+ throw new Error('Cannot load without read() or XMLHttpRequest.');
+ }
+ if (!success) ___setErrNo(ERRNO_CODES.EIO);
+ return success;
+ },createLazyFile:function (parent, name, url, canRead, canWrite) {
+ // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
+ function LazyUint8Array() {
+ this.lengthKnown = false;
+ this.chunks = []; // Loaded chunks. Index is the chunk number
+ }
+ LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
+ if (idx > this.length-1 || idx < 0) {
+ return undefined;
+ }
+ var chunkOffset = idx % this.chunkSize;
+ var chunkNum = Math.floor(idx / this.chunkSize);
+ return this.getter(chunkNum)[chunkOffset];
+ }
+ LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
+ this.getter = getter;
+ }
+ LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
+ // Find length
+ var xhr = new XMLHttpRequest();
+ xhr.open('HEAD', url, false);
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ var datalength = Number(xhr.getResponseHeader("Content-length"));
+ var header;
+ var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
+ var chunkSize = 1024*1024; // Chunk size in bytes
+
+ if (!hasByteServing) chunkSize = datalength;
+
+ // Function to get a range from the remote URL.
+ var doXHR = (function(from, to) {
+ if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
+ if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
+
+ // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
+
+ // Some hints to the browser that we want binary data.
+ if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
+ if (xhr.overrideMimeType) {
+ xhr.overrideMimeType('text/plain; charset=x-user-defined');
+ }
+
+ xhr.send(null);
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
+ if (xhr.response !== undefined) {
+ return new Uint8Array(xhr.response || []);
+ } else {
+ return intArrayFromString(xhr.responseText || '', true);
+ }
+ });
+ var lazyArray = this;
+ lazyArray.setDataGetter(function(chunkNum) {
+ var start = chunkNum * chunkSize;
+ var end = (chunkNum+1) * chunkSize - 1; // including this byte
+ end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
+ lazyArray.chunks[chunkNum] = doXHR(start, end);
+ }
+ if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
+ return lazyArray.chunks[chunkNum];
+ });
+
+ this._length = datalength;
+ this._chunkSize = chunkSize;
+ this.lengthKnown = true;
+ }
+ if (typeof XMLHttpRequest !== 'undefined') {
+ if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
+ var lazyArray = new LazyUint8Array();
+ Object.defineProperty(lazyArray, "length", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._length;
+ }
+ });
+ Object.defineProperty(lazyArray, "chunkSize", {
+ get: function() {
+ if(!this.lengthKnown) {
+ this.cacheLength();
+ }
+ return this._chunkSize;
+ }
+ });
+
+ var properties = { isDevice: false, contents: lazyArray };
+ } else {
+ var properties = { isDevice: false, url: url };
+ }
+
+ var node = FS.createFile(parent, name, properties, canRead, canWrite);
+ // This is a total hack, but I want to get this lazy file code out of the
+ // core of MEMFS. If we want to keep this lazy file concept I feel it should
+ // be its own thin LAZYFS proxying calls to MEMFS.
+ if (properties.contents) {
+ node.contents = properties.contents;
+ } else if (properties.url) {
+ node.contents = null;
+ node.url = properties.url;
+ }
+ // override each stream op with one that tries to force load the lazy file first
+ var stream_ops = {};
+ var keys = Object.keys(node.stream_ops);
+ keys.forEach(function(key) {
+ var fn = node.stream_ops[key];
+ stream_ops[key] = function forceLoadLazyFile() {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ return fn.apply(null, arguments);
+ };
+ });
+ // use a custom read function
+ stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
+ if (!FS.forceLoadFile(node)) {
+ throw new FS.ErrnoError(ERRNO_CODES.EIO);
+ }
+ var contents = stream.node.contents;
+ if (position >= contents.length)
+ return 0;
+ var size = Math.min(contents.length - position, length);
+ assert(size >= 0);
+ if (contents.slice) { // normal array
+ for (var i = 0; i < size; i++) {
+ buffer[offset + i] = contents[position + i];
+ }
+ } else {
+ for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
+ buffer[offset + i] = contents.get(position + i);
+ }
+ }
+ return size;
+ };
+ node.stream_ops = stream_ops;
+ return node;
+ },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {
+ Browser.init();
+ // TODO we should allow people to just pass in a complete filename instead
+ // of parent and name being that we just join them anyways
+ var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
+ function processData(byteArray) {
+ function finish(byteArray) {
+ if (!dontCreateFile) {
+ FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
+ }
+ if (onload) onload();
+ removeRunDependency('cp ' + fullname);
+ }
+ var handled = false;
+ Module['preloadPlugins'].forEach(function(plugin) {
+ if (handled) return;
+ if (plugin['canHandle'](fullname)) {
+ plugin['handle'](byteArray, fullname, finish, function() {
+ if (onerror) onerror();
+ removeRunDependency('cp ' + fullname);
+ });
+ handled = true;
+ }
+ });
+ if (!handled) finish(byteArray);
+ }
+ addRunDependency('cp ' + fullname);
+ if (typeof url == 'string') {
+ Browser.asyncLoad(url, function(byteArray) {
+ processData(byteArray);
+ }, onerror);
+ } else {
+ processData(url);
+ }
+ },indexedDB:function () {
+ return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+ },DB_NAME:function () {
+ return 'EM_FS_' + window.location.pathname;
+ },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
+ console.log('creating db');
+ var db = openRequest.result;
+ db.createObjectStore(FS.DB_STORE_NAME);
+ };
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var putRequest = files.put(FS.analyzePath(path).object.contents, path);
+ putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
+ putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ },loadFilesFromDB:function (paths, onload, onerror) {
+ onload = onload || function(){};
+ onerror = onerror || function(){};
+ var indexedDB = FS.indexedDB();
+ try {
+ var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
+ } catch (e) {
+ return onerror(e);
+ }
+ openRequest.onupgradeneeded = onerror; // no database to load from
+ openRequest.onsuccess = function openRequest_onsuccess() {
+ var db = openRequest.result;
+ try {
+ var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
+ } catch(e) {
+ onerror(e);
+ return;
+ }
+ var files = transaction.objectStore(FS.DB_STORE_NAME);
+ var ok = 0, fail = 0, total = paths.length;
+ function finish() {
+ if (fail == 0) onload(); else onerror();
+ }
+ paths.forEach(function(path) {
+ var getRequest = files.get(path);
+ getRequest.onsuccess = function getRequest_onsuccess() {
+ if (FS.analyzePath(path).exists) {
+ FS.unlink(path);
+ }
+ FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
+ ok++;
+ if (ok + fail == total) finish();
+ };
+ getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
+ });
+ transaction.onerror = onerror;
+ };
+ openRequest.onerror = onerror;
+ }};
+
+
+
+
+ function _mkport() { throw 'TODO' }var SOCKFS={mount:function (mount) {
+ return FS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
+ },createSocket:function (family, type, protocol) {
+ var streaming = type == 1;
+ if (protocol) {
+ assert(streaming == (protocol == 6)); // if SOCK_STREAM, must be tcp
+ }
+
+ // create our internal socket structure
+ var sock = {
+ family: family,
+ type: type,
+ protocol: protocol,
+ server: null,
+ peers: {},
+ pending: [],
+ recv_queue: [],
+ sock_ops: SOCKFS.websocket_sock_ops
+ };
+
+ // create the filesystem node to store the socket structure
+ var name = SOCKFS.nextname();
+ var node = FS.createNode(SOCKFS.root, name, 49152, 0);
+ node.sock = sock;
+
+ // and the wrapping stream that enables library functions such
+ // as read and write to indirectly interact with the socket
+ var stream = FS.createStream({
+ path: name,
+ node: node,
+ flags: FS.modeStringToFlags('r+'),
+ seekable: false,
+ stream_ops: SOCKFS.stream_ops
+ });
+
+ // map the new stream to the socket structure (sockets have a 1:1
+ // relationship with a stream)
+ sock.stream = stream;
+
+ return sock;
+ },getSocket:function (fd) {
+ var stream = FS.getStream(fd);
+ if (!stream || !FS.isSocket(stream.node.mode)) {
+ return null;
+ }
+ return stream.node.sock;
+ },stream_ops:{poll:function (stream) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.poll(sock);
+ },ioctl:function (stream, request, varargs) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.ioctl(sock, request, varargs);
+ },read:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ var msg = sock.sock_ops.recvmsg(sock, length);
+ if (!msg) {
+ // socket is closed
+ return 0;
+ }
+ buffer.set(msg.buffer, offset);
+ return msg.buffer.length;
+ },write:function (stream, buffer, offset, length, position /* ignored */) {
+ var sock = stream.node.sock;
+ return sock.sock_ops.sendmsg(sock, buffer, offset, length);
+ },close:function (stream) {
+ var sock = stream.node.sock;
+ sock.sock_ops.close(sock);
+ }},nextname:function () {
+ if (!SOCKFS.nextname.current) {
+ SOCKFS.nextname.current = 0;
+ }
+ return 'socket[' + (SOCKFS.nextname.current++) + ']';
+ },websocket_sock_ops:{createPeer:function (sock, addr, port) {
+ var ws;
+
+ if (typeof addr === 'object') {
+ ws = addr;
+ addr = null;
+ port = null;
+ }
+
+ if (ws) {
+ // for sockets that've already connected (e.g. we're the server)
+ // we can inspect the _socket property for the address
+ if (ws._socket) {
+ addr = ws._socket.remoteAddress;
+ port = ws._socket.remotePort;
+ }
+ // if we're just now initializing a connection to the remote,
+ // inspect the url property
+ else {
+ var result = /ws[s]?:\/\/([^:]+):(\d+)/.exec(ws.url);
+ if (!result) {
+ throw new Error('WebSocket URL must be in the format ws(s)://address:port');
+ }
+ addr = result[1];
+ port = parseInt(result[2], 10);
+ }
+ } else {
+ // create the actual websocket object and connect
+ try {
+ // runtimeConfig gets set to true if WebSocket runtime configuration is available.
+ var runtimeConfig = (Module['websocket'] && ('object' === typeof Module['websocket']));
+
+ // The default value is 'ws://' the replace is needed because the compiler replaces "//" comments with '#'
+ // comments without checking context, so we'd end up with ws:#, the replace swaps the "#" for "//" again.
+ var url = 'ws:#'.replace('#', '//');
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['url']) {
+ url = Module['websocket']['url']; // Fetch runtime WebSocket URL config.
+ }
+ }
+
+ if (url === 'ws://' || url === 'wss://') { // Is the supplied URL config just a prefix, if so complete it.
+ url = url + addr + ':' + port;
+ }
+
+ // Make the WebSocket subprotocol (Sec-WebSocket-Protocol) default to binary if no configuration is set.
+ var subProtocols = 'binary'; // The default value is 'binary'
+
+ if (runtimeConfig) {
+ if ('string' === typeof Module['websocket']['subprotocol']) {
+ subProtocols = Module['websocket']['subprotocol']; // Fetch runtime WebSocket subprotocol config.
+ }
+ }
+
+ // The regex trims the string (removes spaces at the beginning and end, then splits the string by
+ // <any space>,<any space> into an Array. Whitespace removal is important for Websockify and ws.
+ subProtocols = subProtocols.replace(/^ +| +$/g,"").split(/ *, */);
+
+ // The node ws library API for specifying optional subprotocol is slightly different than the browser's.
+ var opts = ENVIRONMENT_IS_NODE ? {'protocol': subProtocols.toString()} : subProtocols;
+
+ // If node we use the ws library.
+ var WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : window['WebSocket'];
+ ws = new WebSocket(url, opts);
+ ws.binaryType = 'arraybuffer';
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EHOSTUNREACH);
+ }
+ }
+
+
+ var peer = {
+ addr: addr,
+ port: port,
+ socket: ws,
+ dgram_send_queue: []
+ };
+
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);
+
+ // if this is a bound dgram socket, send the port number first to allow
+ // us to override the ephemeral port reported to us by remotePort on the
+ // remote end.
+ if (sock.type === 2 && typeof sock.sport !== 'undefined') {
+ peer.dgram_send_queue.push(new Uint8Array([
+ 255, 255, 255, 255,
+ 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),
+ ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)
+ ]));
+ }
+
+ return peer;
+ },getPeer:function (sock, addr, port) {
+ return sock.peers[addr + ':' + port];
+ },addPeer:function (sock, peer) {
+ sock.peers[peer.addr + ':' + peer.port] = peer;
+ },removePeer:function (sock, peer) {
+ delete sock.peers[peer.addr + ':' + peer.port];
+ },handlePeerEvents:function (sock, peer) {
+ var first = true;
+
+ var handleOpen = function () {
+ try {
+ var queued = peer.dgram_send_queue.shift();
+ while (queued) {
+ peer.socket.send(queued);
+ queued = peer.dgram_send_queue.shift();
+ }
+ } catch (e) {
+ // not much we can do here in the way of proper error handling as we've already
+ // lied and said this data was sent. shut it down.
+ peer.socket.close();
+ }
+ };
+
+ function handleMessage(data) {
+ assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer
+ data = new Uint8Array(data); // make a typed array view on the array buffer
+
+
+ // if this is the port message, override the peer's port with it
+ var wasfirst = first;
+ first = false;
+ if (wasfirst &&
+ data.length === 10 &&
+ data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&
+ data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {
+ // update the peer's port and it's key in the peer map
+ var newport = ((data[8] << 8) | data[9]);
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ peer.port = newport;
+ SOCKFS.websocket_sock_ops.addPeer(sock, peer);
+ return;
+ }
+
+ sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });
+ };
+
+ if (ENVIRONMENT_IS_NODE) {
+ peer.socket.on('open', handleOpen);
+ peer.socket.on('message', function(data, flags) {
+ if (!flags.binary) {
+ return;
+ }
+ handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
+ });
+ peer.socket.on('error', function() {
+ // don't throw
+ });
+ } else {
+ peer.socket.onopen = handleOpen;
+ peer.socket.onmessage = function peer_socket_onmessage(event) {
+ handleMessage(event.data);
+ };
+ }
+ },poll:function (sock) {
+ if (sock.type === 1 && sock.server) {
+ // listen sockets should only say they're available for reading
+ // if there are pending clients.
+ return sock.pending.length ? (64 | 1) : 0;
+ }
+
+ var mask = 0;
+ var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets
+ SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :
+ null;
+
+ if (sock.recv_queue.length ||
+ !dest || // connection-less sockets are always ready to read
+ (dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed
+ mask |= (64 | 1);
+ }
+
+ if (!dest || // connection-less sockets are always ready to write
+ (dest && dest.socket.readyState === dest.socket.OPEN)) {
+ mask |= 4;
+ }
+
+ if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||
+ (dest && dest.socket.readyState === dest.socket.CLOSED)) {
+ mask |= 16;
+ }
+
+ return mask;
+ },ioctl:function (sock, request, arg) {
+ switch (request) {
+ case 21531:
+ var bytes = 0;
+ if (sock.recv_queue.length) {
+ bytes = sock.recv_queue[0].data.length;
+ }
+ HEAP32[((arg)>>2)]=bytes;
+ return 0;
+ default:
+ return ERRNO_CODES.EINVAL;
+ }
+ },close:function (sock) {
+ // if we've spawned a listen server, close it
+ if (sock.server) {
+ try {
+ sock.server.close();
+ } catch (e) {
+ }
+ sock.server = null;
+ }
+ // close any peer connections
+ var peers = Object.keys(sock.peers);
+ for (var i = 0; i < peers.length; i++) {
+ var peer = sock.peers[peers[i]];
+ try {
+ peer.socket.close();
+ } catch (e) {
+ }
+ SOCKFS.websocket_sock_ops.removePeer(sock, peer);
+ }
+ return 0;
+ },bind:function (sock, addr, port) {
+ if (typeof sock.saddr !== 'undefined' || typeof sock.sport !== 'undefined') {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already bound
+ }
+ sock.saddr = addr;
+ sock.sport = port || _mkport();
+ // in order to emulate dgram sockets, we need to launch a listen server when
+ // binding on a connection-less socket
+ // note: this is only required on the server side
+ if (sock.type === 2) {
+ // close the existing server if it exists
+ if (sock.server) {
+ sock.server.close();
+ sock.server = null;
+ }
+ // swallow error operation not supported error that occurs when binding in the
+ // browser where this isn't supported
+ try {
+ sock.sock_ops.listen(sock, 0);
+ } catch (e) {
+ if (!(e instanceof FS.ErrnoError)) throw e;
+ if (e.errno !== ERRNO_CODES.EOPNOTSUPP) throw e;
+ }
+ }
+ },connect:function (sock, addr, port) {
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODS.EOPNOTSUPP);
+ }
+
+ // TODO autobind
+ // if (!sock.addr && sock.type == 2) {
+ // }
+
+ // early out if we're already connected / in the middle of connecting
+ if (typeof sock.daddr !== 'undefined' && typeof sock.dport !== 'undefined') {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+ if (dest) {
+ if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EALREADY);
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EISCONN);
+ }
+ }
+ }
+
+ // add the socket to our peer list and set our
+ // destination address / port to match
+ var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ sock.daddr = peer.addr;
+ sock.dport = peer.port;
+
+ // always "fail" in non-blocking mode
+ throw new FS.ErrnoError(ERRNO_CODES.EINPROGRESS);
+ },listen:function (sock, backlog) {
+ if (!ENVIRONMENT_IS_NODE) {
+ throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
+ }
+ if (sock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already listening
+ }
+ var WebSocketServer = require('ws').Server;
+ var host = sock.saddr;
+ sock.server = new WebSocketServer({
+ host: host,
+ port: sock.sport
+ // TODO support backlog
+ });
+
+ sock.server.on('connection', function(ws) {
+ if (sock.type === 1) {
+ var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);
+
+ // create a peer on the new socket
+ var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);
+ newsock.daddr = peer.addr;
+ newsock.dport = peer.port;
+
+ // push to queue for accept to pick up
+ sock.pending.push(newsock);
+ } else {
+ // create a peer on the listen socket so calling sendto
+ // with the listen socket and an address will resolve
+ // to the correct client
+ SOCKFS.websocket_sock_ops.createPeer(sock, ws);
+ }
+ });
+ sock.server.on('closed', function() {
+ sock.server = null;
+ });
+ sock.server.on('error', function() {
+ // don't throw
+ });
+ },accept:function (listensock) {
+ if (!listensock.server) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ var newsock = listensock.pending.shift();
+ newsock.stream.flags = listensock.stream.flags;
+ return newsock;
+ },getname:function (sock, peer) {
+ var addr, port;
+ if (peer) {
+ if (sock.daddr === undefined || sock.dport === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ addr = sock.daddr;
+ port = sock.dport;
+ } else {
+ // TODO saddr and sport will be set for bind()'d UDP sockets, but what
+ // should we be returning for TCP sockets that've been connect()'d?
+ addr = sock.saddr || 0;
+ port = sock.sport || 0;
+ }
+ return { addr: addr, port: port };
+ },sendmsg:function (sock, buffer, offset, length, addr, port) {
+ if (sock.type === 2) {
+ // connection-less sockets will honor the message address,
+ // and otherwise fall back to the bound destination address
+ if (addr === undefined || port === undefined) {
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+ // if there was no address to fall back to, error out
+ if (addr === undefined || port === undefined) {
+ throw new FS.ErrnoError(ERRNO_CODES.EDESTADDRREQ);
+ }
+ } else {
+ // connection-based sockets will only use the bound
+ addr = sock.daddr;
+ port = sock.dport;
+ }
+
+ // find the peer for the destination address
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);
+
+ // early out if not connected with a connection-based socket
+ if (sock.type === 1) {
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ } else if (dest.socket.readyState === dest.socket.CONNECTING) {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // create a copy of the incoming data to send, as the WebSocket API
+ // doesn't work entirely with an ArrayBufferView, it'll just send
+ // the entire underlying buffer
+ var data;
+ if (buffer instanceof Array || buffer instanceof ArrayBuffer) {
+ data = buffer.slice(offset, offset + length);
+ } else { // ArrayBufferView
+ data = buffer.buffer.slice(buffer.byteOffset + offset, buffer.byteOffset + offset + length);
+ }
+
+ // if we're emulating a connection-less dgram socket and don't have
+ // a cached connection, queue the buffer to send upon connect and
+ // lie, saying the data was sent now.
+ if (sock.type === 2) {
+ if (!dest || dest.socket.readyState !== dest.socket.OPEN) {
+ // if we're not connected, open a new connection
+ if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
+ }
+ dest.dgram_send_queue.push(data);
+ return length;
+ }
+ }
+
+ try {
+ // send the actual data
+ dest.socket.send(data);
+ return length;
+ } catch (e) {
+ throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
+ }
+ },recvmsg:function (sock, length) {
+ // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html
+ if (sock.type === 1 && sock.server) {
+ // tcp servers should not be recv()'ing on the listen socket
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+
+ var queued = sock.recv_queue.shift();
+ if (!queued) {
+ if (sock.type === 1) {
+ var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
+
+ if (!dest) {
+ // if we have a destination address but are not connected, error out
+ throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
+ }
+ else if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
+ // return null if the socket has closed
+ return null;
+ }
+ else {
+ // else, our socket is in a valid state but truly has nothing available
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ } else {
+ throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
+ }
+ }
+
+ // queued.data will be an ArrayBuffer if it's unadulterated, but if it's
+ // requeued TCP data it'll be an ArrayBufferView
+ var queuedLength = queued.data.byteLength || queued.data.length;
+ var queuedOffset = queued.data.byteOffset || 0;
+ var queuedBuffer = queued.data.buffer || queued.data;
+ var bytesRead = Math.min(length, queuedLength);
+ var res = {
+ buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),
+ addr: queued.addr,
+ port: queued.port
+ };
+
+
+ // push back any unread data for TCP connections
+ if (sock.type === 1 && bytesRead < queuedLength) {
+ var bytesRemaining = queuedLength - bytesRead;
+ queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
+ sock.recv_queue.unshift(queued);
+ }
+
+ return res;
+ }}};function _send(fd, buf, len, flags) {
+ var sock = SOCKFS.getSocket(fd);
+ if (!sock) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ // TODO honor flags
+ return _write(fd, buf, len);
+ }
+
+ function _pwrite(fildes, buf, nbyte, offset) {
+ // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte, offset);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }function _write(fildes, buf, nbyte) {
+ // ssize_t write(int fildes, const void *buf, size_t nbyte);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
+ var stream = FS.getStream(fildes);
+ if (!stream) {
+ ___setErrNo(ERRNO_CODES.EBADF);
+ return -1;
+ }
+
+
+ try {
+ var slab = HEAP8;
+ return FS.write(stream, slab, buf, nbyte);
+ } catch (e) {
+ FS.handleFSError(e);
+ return -1;
+ }
+ }
+
+ function _fileno(stream) {
+ // int fileno(FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fileno.html
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) return -1;
+ return stream.fd;
+ }function _fwrite(ptr, size, nitems, stream) {
+ // size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html
+ var bytesToWrite = nitems * size;
+ if (bytesToWrite == 0) return 0;
+ var fd = _fileno(stream);
+ var bytesWritten = _write(fd, ptr, bytesToWrite);
+ if (bytesWritten == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return 0;
+ } else {
+ return Math.floor(bytesWritten / size);
+ }
+ }
+
+
+
+ Module["_strlen"] = _strlen;
+
+ function __reallyNegative(x) {
+ return x < 0 || (x === 0 && (1/x) === -Infinity);
+ }function __formatString(format, varargs) {
+ var textIndex = format;
+ var argIndex = 0;
+ function getNextArg(type) {
+ // NOTE: Explicitly ignoring type safety. Otherwise this fails:
+ // int x = 4; printf("%c\n", (char)x);
+ var ret;
+ if (type === 'double') {
+ ret = HEAPF64[(((varargs)+(argIndex))>>3)];
+ } else if (type == 'i64') {
+ ret = [HEAP32[(((varargs)+(argIndex))>>2)],
+ HEAP32[(((varargs)+(argIndex+4))>>2)]];
+
+ } else {
+ type = 'i32'; // varargs are always i32, i64, or double
+ ret = HEAP32[(((varargs)+(argIndex))>>2)];
+ }
+ argIndex += Runtime.getNativeFieldSize(type);
+ return ret;
+ }
+
+ var ret = [];
+ var curr, next, currArg;
+ while(1) {
+ var startTextIndex = textIndex;
+ curr = HEAP8[(textIndex)];
+ if (curr === 0) break;
+ next = HEAP8[((textIndex+1)|0)];
+ if (curr == 37) {
+ // Handle flags.
+ var flagAlwaysSigned = false;
+ var flagLeftAlign = false;
+ var flagAlternative = false;
+ var flagZeroPad = false;
+ var flagPadSign = false;
+ flagsLoop: while (1) {
+ switch (next) {
+ case 43:
+ flagAlwaysSigned = true;
+ break;
+ case 45:
+ flagLeftAlign = true;
+ break;
+ case 35:
+ flagAlternative = true;
+ break;
+ case 48:
+ if (flagZeroPad) {
+ break flagsLoop;
+ } else {
+ flagZeroPad = true;
+ break;
+ }
+ case 32:
+ flagPadSign = true;
+ break;
+ default:
+ break flagsLoop;
+ }
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+
+ // Handle width.
+ var width = 0;
+ if (next == 42) {
+ width = getNextArg('i32');
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ } else {
+ while (next >= 48 && next <= 57) {
+ width = width * 10 + (next - 48);
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ }
+
+ // Handle precision.
+ var precisionSet = false, precision = -1;
+ if (next == 46) {
+ precision = 0;
+ precisionSet = true;
+ textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+ if (next == 42) {
+ precision = getNextArg('i32');
+ textIndex++;
+ } else {
+ while(1) {
+ var precisionChr = HEAP8[((textIndex+1)|0)];
+ if (precisionChr < 48 ||
+ precisionChr > 57) break;
+ precision = precision * 10 + (precisionChr - 48);
+ textIndex++;
+ }
+ }
+ next = HEAP8[((textIndex+1)|0)];
+ }
+ if (precision < 0) {
+ precision = 6; // Standard default.
+ precisionSet = false;
+ }
+
+ // Handle integer sizes. WARNING: These assume a 32-bit architecture!
+ var argSize;
+ switch (String.fromCharCode(next)) {
+ case 'h':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 104) {
+ textIndex++;
+ argSize = 1; // char (actually i32 in varargs)
+ } else {
+ argSize = 2; // short (actually i32 in varargs)
+ }
+ break;
+ case 'l':
+ var nextNext = HEAP8[((textIndex+2)|0)];
+ if (nextNext == 108) {
+ textIndex++;
+ argSize = 8; // long long
+ } else {
+ argSize = 4; // long
+ }
+ break;
+ case 'L': // long long
+ case 'q': // int64_t
+ case 'j': // intmax_t
+ argSize = 8;
+ break;
+ case 'z': // size_t
+ case 't': // ptrdiff_t
+ case 'I': // signed ptrdiff_t or unsigned size_t
+ argSize = 4;
+ break;
+ default:
+ argSize = null;
+ }
+ if (argSize) textIndex++;
+ next = HEAP8[((textIndex+1)|0)];
+
+ // Handle type specifier.
+ switch (String.fromCharCode(next)) {
+ case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {
+ // Integer.
+ var signed = next == 100 || next == 105;
+ argSize = argSize || 4;
+ var currArg = getNextArg('i' + (argSize * 8));
+ var argText;
+ // Flatten i64-1 [low, high] into a (slightly rounded) double
+ if (argSize == 8) {
+ currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);
+ }
+ // Truncate to requested size.
+ if (argSize <= 4) {
+ var limit = Math.pow(256, argSize) - 1;
+ currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);
+ }
+ // Format the number.
+ var currAbsArg = Math.abs(currArg);
+ var prefix = '';
+ if (next == 100 || next == 105) {
+ argText = reSign(currArg, 8 * argSize, 1).toString(10);
+ } else if (next == 117) {
+ argText = unSign(currArg, 8 * argSize, 1).toString(10);
+ currArg = Math.abs(currArg);
+ } else if (next == 111) {
+ argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
+ } else if (next == 120 || next == 88) {
+ prefix = (flagAlternative && currArg != 0) ? '0x' : '';
+ if (currArg < 0) {
+ // Represent negative numbers in hex as 2's complement.
+ currArg = -currArg;
+ argText = (currAbsArg - 1).toString(16);
+ var buffer = [];
+ for (var i = 0; i < argText.length; i++) {
+ buffer.push((0xF - parseInt(argText[i], 16)).toString(16));
+ }
+ argText = buffer.join('');
+ while (argText.length < argSize * 2) argText = 'f' + argText;
+ } else {
+ argText = currAbsArg.toString(16);
+ }
+ if (next == 88) {
+ prefix = prefix.toUpperCase();
+ argText = argText.toUpperCase();
+ }
+ } else if (next == 112) {
+ if (currAbsArg === 0) {
+ argText = '(nil)';
+ } else {
+ prefix = '0x';
+ argText = currAbsArg.toString(16);
+ }
+ }
+ if (precisionSet) {
+ while (argText.length < precision) {
+ argText = '0' + argText;
+ }
+ }
+
+ // Add sign if needed
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ prefix = '+' + prefix;
+ } else if (flagPadSign) {
+ prefix = ' ' + prefix;
+ }
+ }
+
+ // Move sign to prefix so we zero-pad after the sign
+ if (argText.charAt(0) == '-') {
+ prefix = '-' + prefix;
+ argText = argText.substr(1);
+ }
+
+ // Add padding.
+ while (prefix.length + argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad) {
+ argText = '0' + argText;
+ } else {
+ prefix = ' ' + prefix;
+ }
+ }
+ }
+
+ // Insert the result into the buffer.
+ argText = prefix + argText;
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {
+ // Float.
+ var currArg = getNextArg('double');
+ var argText;
+ if (isNaN(currArg)) {
+ argText = 'nan';
+ flagZeroPad = false;
+ } else if (!isFinite(currArg)) {
+ argText = (currArg < 0 ? '-' : '') + 'inf';
+ flagZeroPad = false;
+ } else {
+ var isGeneral = false;
+ var effectivePrecision = Math.min(precision, 20);
+
+ // Convert g/G to f/F or e/E, as per:
+ // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
+ if (next == 103 || next == 71) {
+ isGeneral = true;
+ precision = precision || 1;
+ var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);
+ if (precision > exponent && exponent >= -4) {
+ next = ((next == 103) ? 'f' : 'F').charCodeAt(0);
+ precision -= exponent + 1;
+ } else {
+ next = ((next == 103) ? 'e' : 'E').charCodeAt(0);
+ precision--;
+ }
+ effectivePrecision = Math.min(precision, 20);
+ }
+
+ if (next == 101 || next == 69) {
+ argText = currArg.toExponential(effectivePrecision);
+ // Make sure the exponent has at least 2 digits.
+ if (/[eE][-+]\d$/.test(argText)) {
+ argText = argText.slice(0, -1) + '0' + argText.slice(-1);
+ }
+ } else if (next == 102 || next == 70) {
+ argText = currArg.toFixed(effectivePrecision);
+ if (currArg === 0 && __reallyNegative(currArg)) {
+ argText = '-' + argText;
+ }
+ }
+
+ var parts = argText.split('e');
+ if (isGeneral && !flagAlternative) {
+ // Discard trailing zeros and periods.
+ while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&
+ (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {
+ parts[0] = parts[0].slice(0, -1);
+ }
+ } else {
+ // Make sure we have a period in alternative mode.
+ if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';
+ // Zero pad until required precision.
+ while (precision > effectivePrecision++) parts[0] += '0';
+ }
+ argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');
+
+ // Capitalize 'E' if needed.
+ if (next == 69) argText = argText.toUpperCase();
+
+ // Add sign.
+ if (currArg >= 0) {
+ if (flagAlwaysSigned) {
+ argText = '+' + argText;
+ } else if (flagPadSign) {
+ argText = ' ' + argText;
+ }
+ }
+ }
+
+ // Add padding.
+ while (argText.length < width) {
+ if (flagLeftAlign) {
+ argText += ' ';
+ } else {
+ if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {
+ argText = argText[0] + '0' + argText.slice(1);
+ } else {
+ argText = (flagZeroPad ? '0' : ' ') + argText;
+ }
+ }
+ }
+
+ // Adjust case.
+ if (next < 97) argText = argText.toUpperCase();
+
+ // Insert the result into the buffer.
+ argText.split('').forEach(function(chr) {
+ ret.push(chr.charCodeAt(0));
+ });
+ break;
+ }
+ case 's': {
+ // String.
+ var arg = getNextArg('i8*');
+ var argLength = arg ? _strlen(arg) : '(null)'.length;
+ if (precisionSet) argLength = Math.min(argLength, precision);
+ if (!flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ if (arg) {
+ for (var i = 0; i < argLength; i++) {
+ ret.push(HEAPU8[((arg++)|0)]);
+ }
+ } else {
+ ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true));
+ }
+ if (flagLeftAlign) {
+ while (argLength < width--) {
+ ret.push(32);
+ }
+ }
+ break;
+ }
+ case 'c': {
+ // Character.
+ if (flagLeftAlign) ret.push(getNextArg('i8'));
+ while (--width > 0) {
+ ret.push(32);
+ }
+ if (!flagLeftAlign) ret.push(getNextArg('i8'));
+ break;
+ }
+ case 'n': {
+ // Write the length written so far to the next parameter.
+ var ptr = getNextArg('i32*');
+ HEAP32[((ptr)>>2)]=ret.length;
+ break;
+ }
+ case '%': {
+ // Literal percent sign.
+ ret.push(curr);
+ break;
+ }
+ default: {
+ // Unknown specifiers remain untouched.
+ for (var i = startTextIndex; i < textIndex + 2; i++) {
+ ret.push(HEAP8[(i)]);
+ }
+ }
+ }
+ textIndex += 2;
+ // TODO: Support a/A (hex float) and m (last error) specifiers.
+ // TODO: Support %1${specifier} for arg selection.
+ } else {
+ ret.push(curr);
+ textIndex += 1;
+ }
+ }
+ return ret;
+ }function _fprintf(stream, format, varargs) {
+ // int fprintf(FILE *restrict stream, const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var result = __formatString(format, varargs);
+ var stack = Runtime.stackSave();
+ var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);
+ Runtime.stackRestore(stack);
+ return ret;
+ }function _printf(format, varargs) {
+ // int printf(const char *restrict format, ...);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
+ var stdout = HEAP32[((_stdout)>>2)];
+ return _fprintf(stdout, format, varargs);
+ }
+
+
+ function _fputs(s, stream) {
+ // int fputs(const char *restrict s, FILE *restrict stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputs.html
+ var fd = _fileno(stream);
+ return _write(fd, s, _strlen(s));
+ }
+
+ function _fputc(c, stream) {
+ // int fputc(int c, FILE *stream);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputc.html
+ var chr = unSign(c & 0xFF);
+ HEAP8[((_fputc.ret)|0)]=chr;
+ var fd = _fileno(stream);
+ var ret = _write(fd, _fputc.ret, 1);
+ if (ret == -1) {
+ var streamObj = FS.getStreamFromPtr(stream);
+ if (streamObj) streamObj.error = true;
+ return -1;
+ } else {
+ return chr;
+ }
+ }function _puts(s) {
+ // int puts(const char *s);
+ // http://pubs.opengroup.org/onlinepubs/000095399/functions/puts.html
+ // NOTE: puts() always writes an extra newline.
+ var stdout = HEAP32[((_stdout)>>2)];
+ var ret = _fputs(s, stdout);
+ if (ret < 0) {
+ return ret;
+ } else {
+ var newlineRet = _fputc(10, stdout);
+ return (newlineRet < 0) ? -1 : ret + 1;
+ }
+ }
+
+ function _sysconf(name) {
+ // long sysconf(int name);
+ // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html
+ switch(name) {
+ case 30: return PAGE_SIZE;
+ case 132:
+ case 133:
+ case 12:
+ case 137:
+ case 138:
+ case 15:
+ case 235:
+ case 16:
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ case 149:
+ case 13:
+ case 10:
+ case 236:
+ case 153:
+ case 9:
+ case 21:
+ case 22:
+ case 159:
+ case 154:
+ case 14:
+ case 77:
+ case 78:
+ case 139:
+ case 80:
+ case 81:
+ case 79:
+ case 82:
+ case 68:
+ case 67:
+ case 164:
+ case 11:
+ case 29:
+ case 47:
+ case 48:
+ case 95:
+ case 52:
+ case 51:
+ case 46:
+ return 200809;
+ case 27:
+ case 246:
+ case 127:
+ case 128:
+ case 23:
+ case 24:
+ case 160:
+ case 161:
+ case 181:
+ case 182:
+ case 242:
+ case 183:
+ case 184:
+ case 243:
+ case 244:
+ case 245:
+ case 165:
+ case 178:
+ case 179:
+ case 49:
+ case 50:
+ case 168:
+ case 169:
+ case 175:
+ case 170:
+ case 171:
+ case 172:
+ case 97:
+ case 76:
+ case 32:
+ case 173:
+ case 35:
+ return -1;
+ case 176:
+ case 177:
+ case 7:
+ case 155:
+ case 8:
+ case 157:
+ case 125:
+ case 126:
+ case 92:
+ case 93:
+ case 129:
+ case 130:
+ case 131:
+ case 94:
+ case 91:
+ return 1;
+ case 74:
+ case 60:
+ case 69:
+ case 70:
+ case 4:
+ return 1024;
+ case 31:
+ case 42:
+ case 72:
+ return 32;
+ case 87:
+ case 26:
+ case 33:
+ return 2147483647;
+ case 34:
+ case 1:
+ return 47839;
+ case 38:
+ case 36:
+ return 99;
+ case 43:
+ case 37:
+ return 2048;
+ case 0: return 2097152;
+ case 3: return 65536;
+ case 28: return 32768;
+ case 44: return 32767;
+ case 75: return 16384;
+ case 39: return 1000;
+ case 89: return 700;
+ case 71: return 256;
+ case 40: return 255;
+ case 2: return 100;
+ case 180: return 64;
+ case 25: return 20;
+ case 5: return 16;
+ case 6: return 6;
+ case 73: return 4;
+ case 84: return 1;
+ }
+ ___setErrNo(ERRNO_CODES.EINVAL);
+ return -1;
+ }
+
+
+ Module["_memset"] = _memset;
+
+ function ___errno_location() {
+ return ___errno_state;
+ }
+
+ function _abort() {
+ Module['abort']();
+ }
+
+ var Browser={mainLoop:{scheduler:null,method:"",shouldPause:false,paused:false,queue:[],pause:function () {
+ Browser.mainLoop.shouldPause = true;
+ },resume:function () {
+ if (Browser.mainLoop.paused) {
+ Browser.mainLoop.paused = false;
+ Browser.mainLoop.scheduler();
+ }
+ Browser.mainLoop.shouldPause = false;
+ },updateStatus:function () {
+ if (Module['setStatus']) {
+ var message = Module['statusMessage'] || 'Please wait...';
+ var remaining = Browser.mainLoop.remainingBlockers;
+ var expected = Browser.mainLoop.expectedBlockers;
+ if (remaining) {
+ if (remaining < expected) {
+ Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');
+ } else {
+ Module['setStatus'](message);
+ }
+ } else {
+ Module['setStatus']('');
+ }
+ }
+ }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {
+ if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers
+
+ if (Browser.initted || ENVIRONMENT_IS_WORKER) return;
+ Browser.initted = true;
+
+ try {
+ new Blob();
+ Browser.hasBlobConstructor = true;
+ } catch(e) {
+ Browser.hasBlobConstructor = false;
+ console.log("warning: no blob constructor, cannot create blobs with mimetypes");
+ }
+ Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null));
+ Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
+ if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {
+ console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
+ Module.noImageDecoding = true;
+ }
+
+ // Support for plugins that can process preloaded files. You can add more of these to
+ // your app by creating and appending to Module.preloadPlugins.
+ //
+ // Each plugin is asked if it can handle a file based on the file's name. If it can,
+ // it is given the file's raw data. When it is done, it calls a callback with the file's
+ // (possibly modified) data. For example, a plugin might decompress a file, or it
+ // might create some side data structure for use later (like an Image element, etc.).
+
+ var imagePlugin = {};
+ imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
+ return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
+ };
+ imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
+ var b = null;
+ if (Browser.hasBlobConstructor) {
+ try {
+ b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ if (b.size !== byteArray.length) { // Safari bug #118630
+ // Safari's Blob can only take an ArrayBuffer
+ b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
+ }
+ } catch(e) {
+ Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');
+ }
+ }
+ if (!b) {
+ var bb = new Browser.BlobBuilder();
+ bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range
+ b = bb.getBlob();
+ }
+ var url = Browser.URLObject.createObjectURL(b);
+ var img = new Image();
+ img.onload = function img_onload() {
+ assert(img.complete, 'Image ' + name + ' could not be decoded');
+ var canvas = document.createElement('canvas');
+ canvas.width = img.width;
+ canvas.height = img.height;
+ var ctx = canvas.getContext('2d');
+ ctx.drawImage(img, 0, 0);
+ Module["preloadedImages"][name] = canvas;
+ Browser.URLObject.revokeObjectURL(url);
+ if (onload) onload(byteArray);
+ };
+ img.onerror = function img_onerror(event) {
+ console.log('Image ' + url + ' could not be decoded');
+ if (onerror) onerror();
+ };
+ img.src = url;
+ };
+ Module['preloadPlugins'].push(imagePlugin);
+
+ var audioPlugin = {};
+ audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
+ return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
+ };
+ audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
+ var done = false;
+ function finish(audio) {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = audio;
+ if (onload) onload(byteArray);
+ }
+ function fail() {
+ if (done) return;
+ done = true;
+ Module["preloadedAudios"][name] = new Audio(); // empty shim
+ if (onerror) onerror();
+ }
+ if (Browser.hasBlobConstructor) {
+ try {
+ var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
+ } catch(e) {
+ return fail();
+ }
+ var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
+ var audio = new Audio();
+ audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
+ audio.onerror = function audio_onerror(event) {
+ if (done) return;
+ console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
+ function encode64(data) {
+ var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ var PAD = '=';
+ var ret = '';
+ var leftchar = 0;
+ var leftbits = 0;
+ for (var i = 0; i < data.length; i++) {
+ leftchar = (leftchar << 8) | data[i];
+ leftbits += 8;
+ while (leftbits >= 6) {
+ var curr = (leftchar >> (leftbits-6)) & 0x3f;
+ leftbits -= 6;
+ ret += BASE[curr];
+ }
+ }
+ if (leftbits == 2) {
+ ret += BASE[(leftchar&3) << 4];
+ ret += PAD + PAD;
+ } else if (leftbits == 4) {
+ ret += BASE[(leftchar&0xf) << 2];
+ ret += PAD;
+ }
+ return ret;
+ }
+ audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);
+ finish(audio); // we don't wait for confirmation this worked - but it's worth trying
+ };
+ audio.src = url;
+ // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror
+ Browser.safeSetTimeout(function() {
+ finish(audio); // try to use it even though it is not necessarily ready to play
+ }, 10000);
+ } else {
+ return fail();
+ }
+ };
+ Module['preloadPlugins'].push(audioPlugin);
+
+ // Canvas event setup
+
+ var canvas = Module['canvas'];
+
+ // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module
+ // Module['forcedAspectRatio'] = 4 / 3;
+
+ canvas.requestPointerLock = canvas['requestPointerLock'] ||
+ canvas['mozRequestPointerLock'] ||
+ canvas['webkitRequestPointerLock'] ||
+ canvas['msRequestPointerLock'] ||
+ function(){};
+ canvas.exitPointerLock = document['exitPointerLock'] ||
+ document['mozExitPointerLock'] ||
+ document['webkitExitPointerLock'] ||
+ document['msExitPointerLock'] ||
+ function(){}; // no-op if function does not exist
+ canvas.exitPointerLock = canvas.exitPointerLock.bind(document);
+
+ function pointerLockChange() {
+ Browser.pointerLock = document['pointerLockElement'] === canvas ||
+ document['mozPointerLockElement'] === canvas ||
+ document['webkitPointerLockElement'] === canvas ||
+ document['msPointerLockElement'] === canvas;
+ }
+
+ document.addEventListener('pointerlockchange', pointerLockChange, false);
+ document.addEventListener('mozpointerlockchange', pointerLockChange, false);
+ document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
+ document.addEventListener('mspointerlockchange', pointerLockChange, false);
+
+ if (Module['elementPointerLock']) {
+ canvas.addEventListener("click", function(ev) {
+ if (!Browser.pointerLock && canvas.requestPointerLock) {
+ canvas.requestPointerLock();
+ ev.preventDefault();
+ }
+ }, false);
+ }
+ },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) {
+ var ctx;
+ var errorInfo = '?';
+ function onContextCreationError(event) {
+ errorInfo = event.statusMessage || errorInfo;
+ }
+ try {
+ if (useWebGL) {
+ var contextAttributes = {
+ antialias: false,
+ alpha: false
+ };
+
+ if (webGLContextAttributes) {
+ for (var attribute in webGLContextAttributes) {
+ contextAttributes[attribute] = webGLContextAttributes[attribute];
+ }
+ }
+
+
+ canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
+ try {
+ ['experimental-webgl', 'webgl'].some(function(webglId) {
+ return ctx = canvas.getContext(webglId, contextAttributes);
+ });
+ } finally {
+ canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
+ }
+ } else {
+ ctx = canvas.getContext('2d');
+ }
+ if (!ctx) throw ':(';
+ } catch (e) {
+ Module.print('Could not create canvas: ' + [errorInfo, e]);
+ return null;
+ }
+ if (useWebGL) {
+ // Set the background of the WebGL canvas to black
+ canvas.style.backgroundColor = "black";
+
+ // Warn on context loss
+ canvas.addEventListener('webglcontextlost', function(event) {
+ alert('WebGL context lost. You will need to reload the page.');
+ }, false);
+ }
+ if (setInModule) {
+ GLctx = Module.ctx = ctx;
+ Module.useWebGL = useWebGL;
+ Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
+ Browser.init();
+ }
+ return ctx;
+ },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {
+ Browser.lockPointer = lockPointer;
+ Browser.resizeCanvas = resizeCanvas;
+ if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;
+ if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;
+
+ var canvas = Module['canvas'];
+ function fullScreenChange() {
+ Browser.isFullScreen = false;
+ var canvasContainer = canvas.parentNode;
+ if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvasContainer) {
+ canvas.cancelFullScreen = document['cancelFullScreen'] ||
+ document['mozCancelFullScreen'] ||
+ document['webkitCancelFullScreen'] ||
+ document['msExitFullscreen'] ||
+ document['exitFullscreen'] ||
+ function() {};
+ canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);
+ if (Browser.lockPointer) canvas.requestPointerLock();
+ Browser.isFullScreen = true;
+ if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();
+ } else {
+
+ // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen
+ canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
+ canvasContainer.parentNode.removeChild(canvasContainer);
+
+ if (Browser.resizeCanvas) Browser.setWindowedCanvasSize();
+ }
+ if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);
+ Browser.updateCanvasDimensions(canvas);
+ }
+
+ if (!Browser.fullScreenHandlersInstalled) {
+ Browser.fullScreenHandlersInstalled = true;
+ document.addEventListener('fullscreenchange', fullScreenChange, false);
+ document.addEventListener('mozfullscreenchange', fullScreenChange, false);
+ document.addEventListener('webkitfullscreenchange', fullScreenChange, false);
+ document.addEventListener('MSFullscreenChange', fullScreenChange, false);
+ }
+
+ // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root
+ var canvasContainer = document.createElement("div");
+ canvas.parentNode.insertBefore(canvasContainer, canvas);
+ canvasContainer.appendChild(canvas);
+
+ // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size)
+ canvasContainer.requestFullScreen = canvasContainer['requestFullScreen'] ||
+ canvasContainer['mozRequestFullScreen'] ||
+ canvasContainer['msRequestFullscreen'] ||
+ (canvasContainer['webkitRequestFullScreen'] ? function() { canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);
+ canvasContainer.requestFullScreen();
+ },requestAnimationFrame:function requestAnimationFrame(func) {
+ if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
+ setTimeout(func, 1000/60);
+ } else {
+ if (!window.requestAnimationFrame) {
+ window.requestAnimationFrame = window['requestAnimationFrame'] ||
+ window['mozRequestAnimationFrame'] ||
+ window['webkitRequestAnimationFrame'] ||
+ window['msRequestAnimationFrame'] ||
+ window['oRequestAnimationFrame'] ||
+ window['setTimeout'];
+ }
+ window.requestAnimationFrame(func);
+ }
+ },safeCallback:function (func) {
+ return function() {
+ if (!ABORT) return func.apply(null, arguments);
+ };
+ },safeRequestAnimationFrame:function (func) {
+ return Browser.requestAnimationFrame(function() {
+ if (!ABORT) func();
+ });
+ },safeSetTimeout:function (func, timeout) {
+ return setTimeout(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },safeSetInterval:function (func, timeout) {
+ return setInterval(function() {
+ if (!ABORT) func();
+ }, timeout);
+ },getMimetype:function (name) {
+ return {
+ 'jpg': 'image/jpeg',
+ 'jpeg': 'image/jpeg',
+ 'png': 'image/png',
+ 'bmp': 'image/bmp',
+ 'ogg': 'audio/ogg',
+ 'wav': 'audio/wav',
+ 'mp3': 'audio/mpeg'
+ }[name.substr(name.lastIndexOf('.')+1)];
+ },getUserMedia:function (func) {
+ if(!window.getUserMedia) {
+ window.getUserMedia = navigator['getUserMedia'] ||
+ navigator['mozGetUserMedia'];
+ }
+ window.getUserMedia(func);
+ },getMovementX:function (event) {
+ return event['movementX'] ||
+ event['mozMovementX'] ||
+ event['webkitMovementX'] ||
+ 0;
+ },getMovementY:function (event) {
+ return event['movementY'] ||
+ event['mozMovementY'] ||
+ event['webkitMovementY'] ||
+ 0;
+ },getMouseWheelDelta:function (event) {
+ return Math.max(-1, Math.min(1, event.type === 'DOMMouseScroll' ? event.detail : -event.wheelDelta));
+ },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup
+ if (Browser.pointerLock) {
+ // When the pointer is locked, calculate the coordinates
+ // based on the movement of the mouse.
+ // Workaround for Firefox bug 764498
+ if (event.type != 'mousemove' &&
+ ('mozMovementX' in event)) {
+ Browser.mouseMovementX = Browser.mouseMovementY = 0;
+ } else {
+ Browser.mouseMovementX = Browser.getMovementX(event);
+ Browser.mouseMovementY = Browser.getMovementY(event);
+ }
+
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
+ Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
+ } else {
+ // just add the mouse delta to the current absolut mouse position
+ // FIXME: ideally this should be clamped against the canvas size and zero
+ Browser.mouseX += Browser.mouseMovementX;
+ Browser.mouseY += Browser.mouseMovementY;
+ }
+ } else {
+ // Otherwise, calculate the movement based on the changes
+ // in the coordinates.
+ var rect = Module["canvas"].getBoundingClientRect();
+ var x, y;
+
+ // Neither .scrollX or .pageXOffset are defined in a spec, but
+ // we prefer .scrollX because it is currently in a spec draft.
+ // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
+ var scrollX = ((typeof window.scrollX !== 'undefined') ? window.scrollX : window.pageXOffset);
+ var scrollY = ((typeof window.scrollY !== 'undefined') ? window.scrollY : window.pageYOffset);
+ if (event.type == 'touchstart' ||
+ event.type == 'touchend' ||
+ event.type == 'touchmove') {
+ var t = event.touches.item(0);
+ if (t) {
+ x = t.pageX - (scrollX + rect.left);
+ y = t.pageY - (scrollY + rect.top);
+ } else {
+ return;
+ }
+ } else {
+ x = event.pageX - (scrollX + rect.left);
+ y = event.pageY - (scrollY + rect.top);
+ }
+
+ // the canvas might be CSS-scaled compared to its backbuffer;
+ // SDL-using content will want mouse coordinates in terms
+ // of backbuffer units.
+ var cw = Module["canvas"].width;
+ var ch = Module["canvas"].height;
+ x = x * (cw / rect.width);
+ y = y * (ch / rect.height);
+
+ Browser.mouseMovementX = x - Browser.mouseX;
+ Browser.mouseMovementY = y - Browser.mouseY;
+ Browser.mouseX = x;
+ Browser.mouseY = y;
+ }
+ },xhrLoad:function (url, onload, onerror) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, true);
+ xhr.responseType = 'arraybuffer';
+ xhr.onload = function xhr_onload() {
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
+ onload(xhr.response);
+ } else {
+ onerror();
+ }
+ };
+ xhr.onerror = onerror;
+ xhr.send(null);
+ },asyncLoad:function (url, onload, onerror, noRunDep) {
+ Browser.xhrLoad(url, function(arrayBuffer) {
+ assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
+ onload(new Uint8Array(arrayBuffer));
+ if (!noRunDep) removeRunDependency('al ' + url);
+ }, function(event) {
+ if (onerror) {
+ onerror();
+ } else {
+ throw 'Loading data file "' + url + '" failed.';
+ }
+ });
+ if (!noRunDep) addRunDependency('al ' + url);
+ },resizeListeners:[],updateResizeListeners:function () {
+ var canvas = Module['canvas'];
+ Browser.resizeListeners.forEach(function(listener) {
+ listener(canvas.width, canvas.height);
+ });
+ },setCanvasSize:function (width, height, noUpdates) {
+ var canvas = Module['canvas'];
+ Browser.updateCanvasDimensions(canvas, width, height);
+ if (!noUpdates) Browser.updateResizeListeners();
+ },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },setWindowedCanvasSize:function () {
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
+ flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
+ HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
+ }
+ Browser.updateResizeListeners();
+ },updateCanvasDimensions:function (canvas, wNative, hNative) {
+ if (wNative && hNative) {
+ canvas.widthNative = wNative;
+ canvas.heightNative = hNative;
+ } else {
+ wNative = canvas.widthNative;
+ hNative = canvas.heightNative;
+ }
+ var w = wNative;
+ var h = hNative;
+ if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) {
+ if (w/h < Module['forcedAspectRatio']) {
+ w = Math.round(h * Module['forcedAspectRatio']);
+ } else {
+ h = Math.round(w / Module['forcedAspectRatio']);
+ }
+ }
+ if (((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
+ document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
+ document['fullScreenElement'] || document['fullscreenElement'] ||
+ document['msFullScreenElement'] || document['msFullscreenElement'] ||
+ document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
+ var factor = Math.min(screen.width / w, screen.height / h);
+ w = Math.round(w * factor);
+ h = Math.round(h * factor);
+ }
+ if (Browser.resizeCanvas) {
+ if (canvas.width != w) canvas.width = w;
+ if (canvas.height != h) canvas.height = h;
+ if (typeof canvas.style != 'undefined') {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ } else {
+ if (canvas.width != wNative) canvas.width = wNative;
+ if (canvas.height != hNative) canvas.height = hNative;
+ if (typeof canvas.style != 'undefined') {
+ if (w != wNative || h != hNative) {
+ canvas.style.setProperty( "width", w + "px", "important");
+ canvas.style.setProperty("height", h + "px", "important");
+ } else {
+ canvas.style.removeProperty( "width");
+ canvas.style.removeProperty("height");
+ }
+ }
+ }
+ }};
+
+ function _sbrk(bytes) {
+ // Implement a Linux-like 'memory area' for our 'process'.
+ // Changes the size of the memory area by |bytes|; returns the
+ // address of the previous top ('break') of the memory area
+ // We control the "dynamic" memory - DYNAMIC_BASE to DYNAMICTOP
+ var self = _sbrk;
+ if (!self.called) {
+ DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned
+ self.called = true;
+ assert(Runtime.dynamicAlloc);
+ self.alloc = Runtime.dynamicAlloc;
+ Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') };
+ }
+ var ret = DYNAMICTOP;
+ if (bytes != 0) self.alloc(bytes);
+ return ret; // Previous break location.
+ }
+
+ function ___assert_fail(condition, filename, line, func) {
+ ABORT = true;
+ throw 'Assertion failed: ' + Pointer_stringify(condition) + ', at: ' + [filename ? Pointer_stringify(filename) : 'unknown filename', line, func ? Pointer_stringify(func) : 'unknown function'] + ' at ' + stackTrace();
+ }
+
+ function _time(ptr) {
+ var ret = Math.floor(Date.now()/1000);
+ if (ptr) {
+ HEAP32[((ptr)>>2)]=ret;
+ }
+ return ret;
+ }
+
+ function _llvm_bswap_i32(x) {
+ return ((x&0xff)<<24) | (((x>>8)&0xff)<<16) | (((x>>16)&0xff)<<8) | (x>>>24);
+ }
+
+
+
+ function _emscripten_memcpy_big(dest, src, num) {
+ HEAPU8.set(HEAPU8.subarray(src, src+num), dest);
+ return dest;
+ }
+ Module["_memcpy"] = _memcpy;
+FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;
+___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;
+__ATINIT__.unshift({ func: function() { TTY.init() } });__ATEXIT__.push({ func: function() { TTY.shutdown() } });TTY.utf8 = new Runtime.UTF8Processor();
+if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); NODEFS.staticInit(); }
+__ATINIT__.push({ func: function() { SOCKFS.root = FS.mount(SOCKFS, {}, null); } });
+_fputc.ret = allocate([0], "i8", ALLOC_STATIC);
+Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };
+ Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };
+ Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };
+ Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };
+ Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };
+ Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }
+STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);
+
+staticSealed = true; // seal the static portion of memory
+
+STACK_MAX = STACK_BASE + 5242880;
+
+DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);
+
+assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");
+
+
+var Math_min = Math.min;
+function invoke_iiii(index,a1,a2,a3) {
+ try {
+ return Module["dynCall_iiii"](index,a1,a2,a3);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_vii(index,a1,a2) {
+ try {
+ Module["dynCall_vii"](index,a1,a2);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function invoke_iii(index,a1,a2) {
+ try {
+ return Module["dynCall_iii"](index,a1,a2);
+ } catch(e) {
+ if (typeof e !== 'number' && e !== 'longjmp') throw e;
+ asm["setThrew"](1, 0);
+ }
+}
+
+function asmPrintInt(x, y) {
+ Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+function asmPrintFloat(x, y) {
+ Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);
+}
+// EMSCRIPTEN_START_ASM
+var asm = (function(global, env, buffer) {
+ 'use asm';
+ var HEAP8 = new global.Int8Array(buffer);
+ var HEAP16 = new global.Int16Array(buffer);
+ var HEAP32 = new global.Int32Array(buffer);
+ var HEAPU8 = new global.Uint8Array(buffer);
+ var HEAPU16 = new global.Uint16Array(buffer);
+ var HEAPU32 = new global.Uint32Array(buffer);
+ var HEAPF32 = new global.Float32Array(buffer);
+ var HEAPF64 = new global.Float64Array(buffer);
+
+ var STACKTOP=env.STACKTOP|0;
+ var STACK_MAX=env.STACK_MAX|0;
+ var tempDoublePtr=env.tempDoublePtr|0;
+ var ABORT=env.ABORT|0;
+
+ var __THREW__ = 0;
+ var threwValue = 0;
+ var setjmpId = 0;
+ var undef = 0;
+ var nan = +env.NaN, inf = +env.Infinity;
+ var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0;
+
+ var tempRet0 = 0;
+ var tempRet1 = 0;
+ var tempRet2 = 0;
+ var tempRet3 = 0;
+ var tempRet4 = 0;
+ var tempRet5 = 0;
+ var tempRet6 = 0;
+ var tempRet7 = 0;
+ var tempRet8 = 0;
+ var tempRet9 = 0;
+ var Math_floor=global.Math.floor;
+ var Math_abs=global.Math.abs;
+ var Math_sqrt=global.Math.sqrt;
+ var Math_pow=global.Math.pow;
+ var Math_cos=global.Math.cos;
+ var Math_sin=global.Math.sin;
+ var Math_tan=global.Math.tan;
+ var Math_acos=global.Math.acos;
+ var Math_asin=global.Math.asin;
+ var Math_atan=global.Math.atan;
+ var Math_atan2=global.Math.atan2;
+ var Math_exp=global.Math.exp;
+ var Math_log=global.Math.log;
+ var Math_ceil=global.Math.ceil;
+ var Math_imul=global.Math.imul;
+ var abort=env.abort;
+ var assert=env.assert;
+ var asmPrintInt=env.asmPrintInt;
+ var asmPrintFloat=env.asmPrintFloat;
+ var Math_min=env.min;
+ var invoke_iiii=env.invoke_iiii;
+ var invoke_vii=env.invoke_vii;
+ var invoke_iii=env.invoke_iii;
+ var _send=env._send;
+ var ___setErrNo=env.___setErrNo;
+ var ___assert_fail=env.___assert_fail;
+ var _fflush=env._fflush;
+ var _pwrite=env._pwrite;
+ var __reallyNegative=env.__reallyNegative;
+ var _sbrk=env._sbrk;
+ var ___errno_location=env.___errno_location;
+ var _emscripten_memcpy_big=env._emscripten_memcpy_big;
+ var _fileno=env._fileno;
+ var _sysconf=env._sysconf;
+ var _puts=env._puts;
+ var _mkport=env._mkport;
+ var _write=env._write;
+ var _llvm_bswap_i32=env._llvm_bswap_i32;
+ var _fputc=env._fputc;
+ var _abort=env._abort;
+ var _fwrite=env._fwrite;
+ var _time=env._time;
+ var _fprintf=env._fprintf;
+ var __formatString=env.__formatString;
+ var _fputs=env._fputs;
+ var _printf=env._printf;
+ var tempFloat = 0.0;
+
+// EMSCRIPTEN_START_FUNCS
+function _inflate(i2, i3) {
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0, i37 = 0, i38 = 0, i39 = 0, i40 = 0, i41 = 0, i42 = 0, i43 = 0, i44 = 0, i45 = 0, i46 = 0, i47 = 0, i48 = 0, i49 = 0, i50 = 0, i51 = 0, i52 = 0, i53 = 0, i54 = 0, i55 = 0, i56 = 0, i57 = 0, i58 = 0, i59 = 0, i60 = 0, i61 = 0, i62 = 0, i63 = 0, i64 = 0, i65 = 0, i66 = 0, i67 = 0, i68 = 0, i69 = 0, i70 = 0, i71 = 0, i72 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i25 = i1;
+ if ((i2 | 0) == 0) {
+ i72 = -2;
+ STACKTOP = i1;
+ return i72 | 0;
+ }
+ i4 = HEAP32[i2 + 28 >> 2] | 0;
+ if ((i4 | 0) == 0) {
+ i72 = -2;
+ STACKTOP = i1;
+ return i72 | 0;
+ }
+ i8 = i2 + 12 | 0;
+ i19 = HEAP32[i8 >> 2] | 0;
+ if ((i19 | 0) == 0) {
+ i72 = -2;
+ STACKTOP = i1;
+ return i72 | 0;
+ }
+ i62 = HEAP32[i2 >> 2] | 0;
+ if ((i62 | 0) == 0 ? (HEAP32[i2 + 4 >> 2] | 0) != 0 : 0) {
+ i72 = -2;
+ STACKTOP = i1;
+ return i72 | 0;
+ }
+ i68 = HEAP32[i4 >> 2] | 0;
+ if ((i68 | 0) == 11) {
+ HEAP32[i4 >> 2] = 12;
+ i68 = 12;
+ i62 = HEAP32[i2 >> 2] | 0;
+ i19 = HEAP32[i8 >> 2] | 0;
+ }
+ i15 = i2 + 16 | 0;
+ i59 = HEAP32[i15 >> 2] | 0;
+ i16 = i2 + 4 | 0;
+ i5 = HEAP32[i16 >> 2] | 0;
+ i17 = i4 + 56 | 0;
+ i6 = i4 + 60 | 0;
+ i12 = i4 + 8 | 0;
+ i10 = i4 + 24 | 0;
+ i39 = i25 + 1 | 0;
+ i11 = i4 + 16 | 0;
+ i38 = i4 + 32 | 0;
+ i35 = i2 + 24 | 0;
+ i40 = i4 + 36 | 0;
+ i41 = i4 + 20 | 0;
+ i9 = i2 + 48 | 0;
+ i42 = i4 + 64 | 0;
+ i46 = i4 + 12 | 0;
+ i47 = (i3 + -5 | 0) >>> 0 < 2;
+ i7 = i4 + 4 | 0;
+ i48 = i4 + 76 | 0;
+ i49 = i4 + 84 | 0;
+ i50 = i4 + 80 | 0;
+ i51 = i4 + 88 | 0;
+ i43 = (i3 | 0) == 6;
+ i57 = i4 + 7108 | 0;
+ i37 = i4 + 72 | 0;
+ i58 = i4 + 7112 | 0;
+ i54 = i4 + 68 | 0;
+ i28 = i4 + 44 | 0;
+ i29 = i4 + 7104 | 0;
+ i30 = i4 + 48 | 0;
+ i31 = i4 + 52 | 0;
+ i18 = i4 + 40 | 0;
+ i13 = i2 + 20 | 0;
+ i14 = i4 + 28 | 0;
+ i32 = i4 + 96 | 0;
+ i33 = i4 + 100 | 0;
+ i34 = i4 + 92 | 0;
+ i36 = i4 + 104 | 0;
+ i52 = i4 + 1328 | 0;
+ i53 = i4 + 108 | 0;
+ i27 = i4 + 112 | 0;
+ i55 = i4 + 752 | 0;
+ i56 = i4 + 624 | 0;
+ i44 = i25 + 2 | 0;
+ i45 = i25 + 3 | 0;
+ i67 = HEAP32[i6 >> 2] | 0;
+ i65 = i5;
+ i64 = HEAP32[i17 >> 2] | 0;
+ i26 = i59;
+ i61 = 0;
+ L17 : while (1) {
+ L19 : do {
+ switch (i68 | 0) {
+ case 16:
+ {
+ if (i67 >>> 0 < 14) {
+ i63 = i67;
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i66 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 14) {
+ i62 = i66;
+ } else {
+ i62 = i66;
+ break;
+ }
+ }
+ } else {
+ i63 = i67;
+ }
+ i71 = (i64 & 31) + 257 | 0;
+ HEAP32[i32 >> 2] = i71;
+ i72 = (i64 >>> 5 & 31) + 1 | 0;
+ HEAP32[i33 >> 2] = i72;
+ HEAP32[i34 >> 2] = (i64 >>> 10 & 15) + 4;
+ i64 = i64 >>> 14;
+ i63 = i63 + -14 | 0;
+ if (i71 >>> 0 > 286 | i72 >>> 0 > 30) {
+ HEAP32[i35 >> 2] = 11616;
+ HEAP32[i4 >> 2] = 29;
+ i66 = i26;
+ break L19;
+ } else {
+ HEAP32[i36 >> 2] = 0;
+ HEAP32[i4 >> 2] = 17;
+ i66 = 0;
+ i60 = 154;
+ break L19;
+ }
+ }
+ case 2:
+ {
+ if (i67 >>> 0 < 32) {
+ i63 = i67;
+ i60 = 47;
+ } else {
+ i60 = 49;
+ }
+ break;
+ }
+ case 23:
+ {
+ i66 = HEAP32[i37 >> 2] | 0;
+ i63 = i67;
+ i60 = 240;
+ break;
+ }
+ case 18:
+ {
+ i63 = HEAP32[i36 >> 2] | 0;
+ i69 = i65;
+ i60 = 164;
+ break;
+ }
+ case 1:
+ {
+ if (i67 >>> 0 < 16) {
+ i63 = i67;
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i66 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 16) {
+ i62 = i66;
+ } else {
+ i62 = i66;
+ break;
+ }
+ }
+ } else {
+ i63 = i67;
+ }
+ HEAP32[i11 >> 2] = i64;
+ if ((i64 & 255 | 0) != 8) {
+ HEAP32[i35 >> 2] = 11448;
+ HEAP32[i4 >> 2] = 29;
+ i66 = i26;
+ break L19;
+ }
+ if ((i64 & 57344 | 0) != 0) {
+ HEAP32[i35 >> 2] = 11504;
+ HEAP32[i4 >> 2] = 29;
+ i66 = i26;
+ break L19;
+ }
+ i60 = HEAP32[i38 >> 2] | 0;
+ if ((i60 | 0) == 0) {
+ i60 = i64;
+ } else {
+ HEAP32[i60 >> 2] = i64 >>> 8 & 1;
+ i60 = HEAP32[i11 >> 2] | 0;
+ }
+ if ((i60 & 512 | 0) != 0) {
+ HEAP8[i25] = i64;
+ HEAP8[i39] = i64 >>> 8;
+ HEAP32[i10 >> 2] = _crc32(HEAP32[i10 >> 2] | 0, i25, 2) | 0;
+ }
+ HEAP32[i4 >> 2] = 2;
+ i63 = 0;
+ i64 = 0;
+ i60 = 47;
+ break;
+ }
+ case 8:
+ {
+ i63 = i67;
+ i60 = 109;
+ break;
+ }
+ case 22:
+ {
+ i63 = i67;
+ i60 = 228;
+ break;
+ }
+ case 24:
+ {
+ i63 = i67;
+ i60 = 246;
+ break;
+ }
+ case 19:
+ {
+ i63 = i67;
+ i60 = 201;
+ break;
+ }
+ case 20:
+ {
+ i63 = i67;
+ i60 = 202;
+ break;
+ }
+ case 21:
+ {
+ i66 = HEAP32[i37 >> 2] | 0;
+ i63 = i67;
+ i60 = 221;
+ break;
+ }
+ case 10:
+ {
+ i63 = i67;
+ i60 = 121;
+ break;
+ }
+ case 11:
+ {
+ i63 = i67;
+ i60 = 124;
+ break;
+ }
+ case 12:
+ {
+ i63 = i67;
+ i60 = 125;
+ break;
+ }
+ case 5:
+ {
+ i63 = i67;
+ i60 = 73;
+ break;
+ }
+ case 4:
+ {
+ i63 = i67;
+ i60 = 62;
+ break;
+ }
+ case 0:
+ {
+ i66 = HEAP32[i12 >> 2] | 0;
+ if ((i66 | 0) == 0) {
+ HEAP32[i4 >> 2] = 12;
+ i63 = i67;
+ i66 = i26;
+ break L19;
+ }
+ if (i67 >>> 0 < 16) {
+ i63 = i67;
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i67 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 16) {
+ i62 = i67;
+ } else {
+ i62 = i67;
+ break;
+ }
+ }
+ } else {
+ i63 = i67;
+ }
+ if ((i66 & 2 | 0) != 0 & (i64 | 0) == 35615) {
+ HEAP32[i10 >> 2] = _crc32(0, 0, 0) | 0;
+ HEAP8[i25] = 31;
+ HEAP8[i39] = -117;
+ HEAP32[i10 >> 2] = _crc32(HEAP32[i10 >> 2] | 0, i25, 2) | 0;
+ HEAP32[i4 >> 2] = 1;
+ i63 = 0;
+ i64 = 0;
+ i66 = i26;
+ break L19;
+ }
+ HEAP32[i11 >> 2] = 0;
+ i67 = HEAP32[i38 >> 2] | 0;
+ if ((i67 | 0) != 0) {
+ HEAP32[i67 + 48 >> 2] = -1;
+ i66 = HEAP32[i12 >> 2] | 0;
+ }
+ if ((i66 & 1 | 0) != 0 ? ((((i64 << 8 & 65280) + (i64 >>> 8) | 0) >>> 0) % 31 | 0 | 0) == 0 : 0) {
+ if ((i64 & 15 | 0) != 8) {
+ HEAP32[i35 >> 2] = 11448;
+ HEAP32[i4 >> 2] = 29;
+ i66 = i26;
+ break L19;
+ }
+ i66 = i64 >>> 4;
+ i63 = i63 + -4 | 0;
+ i68 = (i66 & 15) + 8 | 0;
+ i67 = HEAP32[i40 >> 2] | 0;
+ if ((i67 | 0) != 0) {
+ if (i68 >>> 0 > i67 >>> 0) {
+ HEAP32[i35 >> 2] = 11480;
+ HEAP32[i4 >> 2] = 29;
+ i64 = i66;
+ i66 = i26;
+ break L19;
+ }
+ } else {
+ HEAP32[i40 >> 2] = i68;
+ }
+ HEAP32[i41 >> 2] = 1 << i68;
+ i63 = _adler32(0, 0, 0) | 0;
+ HEAP32[i10 >> 2] = i63;
+ HEAP32[i9 >> 2] = i63;
+ HEAP32[i4 >> 2] = i64 >>> 12 & 2 ^ 11;
+ i63 = 0;
+ i64 = 0;
+ i66 = i26;
+ break L19;
+ }
+ HEAP32[i35 >> 2] = 11424;
+ HEAP32[i4 >> 2] = 29;
+ i66 = i26;
+ break;
+ }
+ case 26:
+ {
+ if ((HEAP32[i12 >> 2] | 0) != 0) {
+ if (i67 >>> 0 < 32) {
+ i63 = i67;
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i66 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 32) {
+ i62 = i66;
+ } else {
+ i62 = i66;
+ break;
+ }
+ }
+ } else {
+ i63 = i67;
+ }
+ i66 = i59 - i26 | 0;
+ HEAP32[i13 >> 2] = (HEAP32[i13 >> 2] | 0) + i66;
+ HEAP32[i14 >> 2] = (HEAP32[i14 >> 2] | 0) + i66;
+ if ((i59 | 0) != (i26 | 0)) {
+ i59 = HEAP32[i10 >> 2] | 0;
+ i67 = i19 + (0 - i66) | 0;
+ if ((HEAP32[i11 >> 2] | 0) == 0) {
+ i59 = _adler32(i59, i67, i66) | 0;
+ } else {
+ i59 = _crc32(i59, i67, i66) | 0;
+ }
+ HEAP32[i10 >> 2] = i59;
+ HEAP32[i9 >> 2] = i59;
+ }
+ if ((HEAP32[i11 >> 2] | 0) == 0) {
+ i59 = _llvm_bswap_i32(i64 | 0) | 0;
+ } else {
+ i59 = i64;
+ }
+ if ((i59 | 0) == (HEAP32[i10 >> 2] | 0)) {
+ i63 = 0;
+ i64 = 0;
+ i59 = i26;
+ } else {
+ HEAP32[i35 >> 2] = 11904;
+ HEAP32[i4 >> 2] = 29;
+ i66 = i26;
+ i59 = i26;
+ break L19;
+ }
+ } else {
+ i63 = i67;
+ }
+ HEAP32[i4 >> 2] = 27;
+ i60 = 277;
+ break;
+ }
+ case 27:
+ {
+ i63 = i67;
+ i60 = 277;
+ break;
+ }
+ case 28:
+ {
+ i63 = i67;
+ i61 = 1;
+ i60 = 285;
+ break L17;
+ }
+ case 29:
+ {
+ i63 = i67;
+ i61 = -3;
+ break L17;
+ }
+ case 25:
+ {
+ if ((i26 | 0) == 0) {
+ i63 = i67;
+ i26 = 0;
+ i60 = 285;
+ break L17;
+ }
+ HEAP8[i19] = HEAP32[i42 >> 2];
+ HEAP32[i4 >> 2] = 20;
+ i63 = i67;
+ i66 = i26 + -1 | 0;
+ i19 = i19 + 1 | 0;
+ break;
+ }
+ case 17:
+ {
+ i66 = HEAP32[i36 >> 2] | 0;
+ if (i66 >>> 0 < (HEAP32[i34 >> 2] | 0) >>> 0) {
+ i63 = i67;
+ i60 = 154;
+ } else {
+ i60 = 158;
+ }
+ break;
+ }
+ case 13:
+ {
+ i63 = i67 & 7;
+ i64 = i64 >>> i63;
+ i63 = i67 - i63 | 0;
+ if (i63 >>> 0 < 32) {
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i66 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 32) {
+ i62 = i66;
+ } else {
+ i62 = i66;
+ break;
+ }
+ }
+ }
+ i66 = i64 & 65535;
+ if ((i66 | 0) == (i64 >>> 16 ^ 65535 | 0)) {
+ HEAP32[i42 >> 2] = i66;
+ HEAP32[i4 >> 2] = 14;
+ if (i43) {
+ i63 = 0;
+ i64 = 0;
+ i60 = 285;
+ break L17;
+ } else {
+ i63 = 0;
+ i64 = 0;
+ i60 = 143;
+ break L19;
+ }
+ } else {
+ HEAP32[i35 >> 2] = 11584;
+ HEAP32[i4 >> 2] = 29;
+ i66 = i26;
+ break L19;
+ }
+ }
+ case 7:
+ {
+ i63 = i67;
+ i60 = 96;
+ break;
+ }
+ case 14:
+ {
+ i63 = i67;
+ i60 = 143;
+ break;
+ }
+ case 15:
+ {
+ i63 = i67;
+ i60 = 144;
+ break;
+ }
+ case 9:
+ {
+ if (i67 >>> 0 < 32) {
+ i63 = i67;
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i66 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 32) {
+ i62 = i66;
+ } else {
+ i62 = i66;
+ break;
+ }
+ }
+ }
+ i63 = _llvm_bswap_i32(i64 | 0) | 0;
+ HEAP32[i10 >> 2] = i63;
+ HEAP32[i9 >> 2] = i63;
+ HEAP32[i4 >> 2] = 10;
+ i63 = 0;
+ i64 = 0;
+ i60 = 121;
+ break;
+ }
+ case 30:
+ {
+ i60 = 299;
+ break L17;
+ }
+ case 6:
+ {
+ i63 = i67;
+ i60 = 83;
+ break;
+ }
+ case 3:
+ {
+ if (i67 >>> 0 < 16) {
+ i63 = i67;
+ i66 = i62;
+ i60 = 55;
+ } else {
+ i60 = 57;
+ }
+ break;
+ }
+ default:
+ {
+ i2 = -2;
+ i60 = 300;
+ break L17;
+ }
+ }
+ } while (0);
+ if ((i60 | 0) == 47) {
+ while (1) {
+ i60 = 0;
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i60 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 32) {
+ i62 = i60;
+ i60 = 47;
+ } else {
+ i62 = i60;
+ i60 = 49;
+ break;
+ }
+ }
+ } else if ((i60 | 0) == 121) {
+ if ((HEAP32[i46 >> 2] | 0) == 0) {
+ i60 = 122;
+ break;
+ }
+ i60 = _adler32(0, 0, 0) | 0;
+ HEAP32[i10 >> 2] = i60;
+ HEAP32[i9 >> 2] = i60;
+ HEAP32[i4 >> 2] = 11;
+ i60 = 124;
+ } else if ((i60 | 0) == 143) {
+ HEAP32[i4 >> 2] = 15;
+ i60 = 144;
+ } else if ((i60 | 0) == 154) {
+ while (1) {
+ i60 = 0;
+ if (i63 >>> 0 < 3) {
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i67 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 3) {
+ i62 = i67;
+ } else {
+ i62 = i67;
+ break;
+ }
+ }
+ }
+ HEAP32[i36 >> 2] = i66 + 1;
+ HEAP16[i4 + (HEAPU16[11384 + (i66 << 1) >> 1] << 1) + 112 >> 1] = i64 & 7;
+ i64 = i64 >>> 3;
+ i63 = i63 + -3 | 0;
+ i66 = HEAP32[i36 >> 2] | 0;
+ if (i66 >>> 0 < (HEAP32[i34 >> 2] | 0) >>> 0) {
+ i60 = 154;
+ } else {
+ i67 = i63;
+ i60 = 158;
+ break;
+ }
+ }
+ } else if ((i60 | 0) == 277) {
+ i60 = 0;
+ if ((HEAP32[i12 >> 2] | 0) == 0) {
+ i60 = 284;
+ break;
+ }
+ if ((HEAP32[i11 >> 2] | 0) == 0) {
+ i60 = 284;
+ break;
+ }
+ if (i63 >>> 0 < 32) {
+ i66 = i62;
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ i62 = i66;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i62 = i66 + 1 | 0;
+ i64 = (HEAPU8[i66] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 32) {
+ i66 = i62;
+ } else {
+ break;
+ }
+ }
+ }
+ if ((i64 | 0) == (HEAP32[i14 >> 2] | 0)) {
+ i63 = 0;
+ i64 = 0;
+ i60 = 284;
+ break;
+ }
+ HEAP32[i35 >> 2] = 11928;
+ HEAP32[i4 >> 2] = 29;
+ i66 = i26;
+ }
+ do {
+ if ((i60 | 0) == 49) {
+ i60 = HEAP32[i38 >> 2] | 0;
+ if ((i60 | 0) != 0) {
+ HEAP32[i60 + 4 >> 2] = i64;
+ }
+ if ((HEAP32[i11 >> 2] & 512 | 0) != 0) {
+ HEAP8[i25] = i64;
+ HEAP8[i39] = i64 >>> 8;
+ HEAP8[i44] = i64 >>> 16;
+ HEAP8[i45] = i64 >>> 24;
+ HEAP32[i10 >> 2] = _crc32(HEAP32[i10 >> 2] | 0, i25, 4) | 0;
+ }
+ HEAP32[i4 >> 2] = 3;
+ i63 = 0;
+ i64 = 0;
+ i66 = i62;
+ i60 = 55;
+ } else if ((i60 | 0) == 124) {
+ if (i47) {
+ i60 = 285;
+ break L17;
+ } else {
+ i60 = 125;
+ }
+ } else if ((i60 | 0) == 144) {
+ i60 = 0;
+ i66 = HEAP32[i42 >> 2] | 0;
+ if ((i66 | 0) == 0) {
+ HEAP32[i4 >> 2] = 11;
+ i66 = i26;
+ break;
+ }
+ i66 = i66 >>> 0 > i65 >>> 0 ? i65 : i66;
+ i67 = i66 >>> 0 > i26 >>> 0 ? i26 : i66;
+ if ((i67 | 0) == 0) {
+ i60 = 285;
+ break L17;
+ }
+ _memcpy(i19 | 0, i62 | 0, i67 | 0) | 0;
+ HEAP32[i42 >> 2] = (HEAP32[i42 >> 2] | 0) - i67;
+ i65 = i65 - i67 | 0;
+ i66 = i26 - i67 | 0;
+ i62 = i62 + i67 | 0;
+ i19 = i19 + i67 | 0;
+ } else if ((i60 | 0) == 158) {
+ i60 = 0;
+ if (i66 >>> 0 < 19) {
+ while (1) {
+ i61 = i66 + 1 | 0;
+ HEAP16[i4 + (HEAPU16[11384 + (i66 << 1) >> 1] << 1) + 112 >> 1] = 0;
+ if ((i61 | 0) == 19) {
+ break;
+ } else {
+ i66 = i61;
+ }
+ }
+ HEAP32[i36 >> 2] = 19;
+ }
+ HEAP32[i53 >> 2] = i52;
+ HEAP32[i48 >> 2] = i52;
+ HEAP32[i49 >> 2] = 7;
+ i61 = _inflate_table(0, i27, 19, i53, i49, i55) | 0;
+ if ((i61 | 0) == 0) {
+ HEAP32[i36 >> 2] = 0;
+ HEAP32[i4 >> 2] = 18;
+ i63 = 0;
+ i69 = i65;
+ i61 = 0;
+ i60 = 164;
+ break;
+ } else {
+ HEAP32[i35 >> 2] = 11656;
+ HEAP32[i4 >> 2] = 29;
+ i63 = i67;
+ i66 = i26;
+ break;
+ }
+ }
+ } while (0);
+ L163 : do {
+ if ((i60 | 0) == 55) {
+ while (1) {
+ i60 = 0;
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ i62 = i66;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i62 = i66 + 1 | 0;
+ i64 = (HEAPU8[i66] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 16) {
+ i66 = i62;
+ i60 = 55;
+ } else {
+ i60 = 57;
+ break;
+ }
+ }
+ } else if ((i60 | 0) == 125) {
+ i60 = 0;
+ if ((HEAP32[i7 >> 2] | 0) != 0) {
+ i66 = i63 & 7;
+ HEAP32[i4 >> 2] = 26;
+ i63 = i63 - i66 | 0;
+ i64 = i64 >>> i66;
+ i66 = i26;
+ break;
+ }
+ if (i63 >>> 0 < 3) {
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i66 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 3) {
+ i62 = i66;
+ } else {
+ i62 = i66;
+ break;
+ }
+ }
+ }
+ HEAP32[i7 >> 2] = i64 & 1;
+ i66 = i64 >>> 1 & 3;
+ if ((i66 | 0) == 0) {
+ HEAP32[i4 >> 2] = 13;
+ } else if ((i66 | 0) == 1) {
+ HEAP32[i48 >> 2] = 11952;
+ HEAP32[i49 >> 2] = 9;
+ HEAP32[i50 >> 2] = 14e3;
+ HEAP32[i51 >> 2] = 5;
+ HEAP32[i4 >> 2] = 19;
+ if (i43) {
+ i60 = 133;
+ break L17;
+ }
+ } else if ((i66 | 0) == 2) {
+ HEAP32[i4 >> 2] = 16;
+ } else if ((i66 | 0) == 3) {
+ HEAP32[i35 >> 2] = 11560;
+ HEAP32[i4 >> 2] = 29;
+ }
+ i63 = i63 + -3 | 0;
+ i64 = i64 >>> 3;
+ i66 = i26;
+ } else if ((i60 | 0) == 164) {
+ i60 = 0;
+ i65 = HEAP32[i32 >> 2] | 0;
+ i66 = HEAP32[i33 >> 2] | 0;
+ do {
+ if (i63 >>> 0 < (i66 + i65 | 0) >>> 0) {
+ i71 = i67;
+ L181 : while (1) {
+ i70 = (1 << HEAP32[i49 >> 2]) + -1 | 0;
+ i72 = i70 & i64;
+ i68 = HEAP32[i48 >> 2] | 0;
+ i67 = HEAPU8[i68 + (i72 << 2) + 1 | 0] | 0;
+ if (i67 >>> 0 > i71 >>> 0) {
+ i67 = i71;
+ while (1) {
+ if ((i69 | 0) == 0) {
+ i63 = i67;
+ i65 = 0;
+ break L17;
+ }
+ i69 = i69 + -1 | 0;
+ i71 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i67) + i64 | 0;
+ i62 = i67 + 8 | 0;
+ i72 = i70 & i64;
+ i67 = HEAPU8[i68 + (i72 << 2) + 1 | 0] | 0;
+ if (i67 >>> 0 > i62 >>> 0) {
+ i67 = i62;
+ i62 = i71;
+ } else {
+ i70 = i62;
+ i62 = i71;
+ break;
+ }
+ }
+ } else {
+ i70 = i71;
+ }
+ i68 = HEAP16[i68 + (i72 << 2) + 2 >> 1] | 0;
+ L188 : do {
+ if ((i68 & 65535) < 16) {
+ if (i70 >>> 0 < i67 >>> 0) {
+ while (1) {
+ if ((i69 | 0) == 0) {
+ i63 = i70;
+ i65 = 0;
+ break L17;
+ }
+ i69 = i69 + -1 | 0;
+ i65 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i70) + i64 | 0;
+ i70 = i70 + 8 | 0;
+ if (i70 >>> 0 < i67 >>> 0) {
+ i62 = i65;
+ } else {
+ i62 = i65;
+ break;
+ }
+ }
+ }
+ HEAP32[i36 >> 2] = i63 + 1;
+ HEAP16[i4 + (i63 << 1) + 112 >> 1] = i68;
+ i71 = i70 - i67 | 0;
+ i64 = i64 >>> i67;
+ } else {
+ if (i68 << 16 >> 16 == 16) {
+ i68 = i67 + 2 | 0;
+ if (i70 >>> 0 < i68 >>> 0) {
+ i71 = i62;
+ while (1) {
+ if ((i69 | 0) == 0) {
+ i63 = i70;
+ i65 = 0;
+ i62 = i71;
+ break L17;
+ }
+ i69 = i69 + -1 | 0;
+ i62 = i71 + 1 | 0;
+ i64 = (HEAPU8[i71] << i70) + i64 | 0;
+ i70 = i70 + 8 | 0;
+ if (i70 >>> 0 < i68 >>> 0) {
+ i71 = i62;
+ } else {
+ break;
+ }
+ }
+ }
+ i64 = i64 >>> i67;
+ i67 = i70 - i67 | 0;
+ if ((i63 | 0) == 0) {
+ i60 = 181;
+ break L181;
+ }
+ i67 = i67 + -2 | 0;
+ i68 = (i64 & 3) + 3 | 0;
+ i64 = i64 >>> 2;
+ i70 = HEAP16[i4 + (i63 + -1 << 1) + 112 >> 1] | 0;
+ } else if (i68 << 16 >> 16 == 17) {
+ i68 = i67 + 3 | 0;
+ if (i70 >>> 0 < i68 >>> 0) {
+ i71 = i62;
+ while (1) {
+ if ((i69 | 0) == 0) {
+ i63 = i70;
+ i65 = 0;
+ i62 = i71;
+ break L17;
+ }
+ i69 = i69 + -1 | 0;
+ i62 = i71 + 1 | 0;
+ i64 = (HEAPU8[i71] << i70) + i64 | 0;
+ i70 = i70 + 8 | 0;
+ if (i70 >>> 0 < i68 >>> 0) {
+ i71 = i62;
+ } else {
+ break;
+ }
+ }
+ }
+ i64 = i64 >>> i67;
+ i67 = -3 - i67 + i70 | 0;
+ i68 = (i64 & 7) + 3 | 0;
+ i64 = i64 >>> 3;
+ i70 = 0;
+ } else {
+ i68 = i67 + 7 | 0;
+ if (i70 >>> 0 < i68 >>> 0) {
+ i71 = i62;
+ while (1) {
+ if ((i69 | 0) == 0) {
+ i63 = i70;
+ i65 = 0;
+ i62 = i71;
+ break L17;
+ }
+ i69 = i69 + -1 | 0;
+ i62 = i71 + 1 | 0;
+ i64 = (HEAPU8[i71] << i70) + i64 | 0;
+ i70 = i70 + 8 | 0;
+ if (i70 >>> 0 < i68 >>> 0) {
+ i71 = i62;
+ } else {
+ break;
+ }
+ }
+ }
+ i64 = i64 >>> i67;
+ i67 = -7 - i67 + i70 | 0;
+ i68 = (i64 & 127) + 11 | 0;
+ i64 = i64 >>> 7;
+ i70 = 0;
+ }
+ if ((i63 + i68 | 0) >>> 0 > (i66 + i65 | 0) >>> 0) {
+ i60 = 190;
+ break L181;
+ }
+ while (1) {
+ i68 = i68 + -1 | 0;
+ HEAP32[i36 >> 2] = i63 + 1;
+ HEAP16[i4 + (i63 << 1) + 112 >> 1] = i70;
+ if ((i68 | 0) == 0) {
+ i71 = i67;
+ break L188;
+ }
+ i63 = HEAP32[i36 >> 2] | 0;
+ }
+ }
+ } while (0);
+ i63 = HEAP32[i36 >> 2] | 0;
+ i65 = HEAP32[i32 >> 2] | 0;
+ i66 = HEAP32[i33 >> 2] | 0;
+ if (!(i63 >>> 0 < (i66 + i65 | 0) >>> 0)) {
+ i60 = 193;
+ break;
+ }
+ }
+ if ((i60 | 0) == 181) {
+ i60 = 0;
+ HEAP32[i35 >> 2] = 11688;
+ HEAP32[i4 >> 2] = 29;
+ i63 = i67;
+ i65 = i69;
+ i66 = i26;
+ break L163;
+ } else if ((i60 | 0) == 190) {
+ i60 = 0;
+ HEAP32[i35 >> 2] = 11688;
+ HEAP32[i4 >> 2] = 29;
+ i63 = i67;
+ i65 = i69;
+ i66 = i26;
+ break L163;
+ } else if ((i60 | 0) == 193) {
+ i60 = 0;
+ if ((HEAP32[i4 >> 2] | 0) == 29) {
+ i63 = i71;
+ i65 = i69;
+ i66 = i26;
+ break L163;
+ } else {
+ i63 = i71;
+ break;
+ }
+ }
+ } else {
+ i63 = i67;
+ }
+ } while (0);
+ if ((HEAP16[i56 >> 1] | 0) == 0) {
+ HEAP32[i35 >> 2] = 11720;
+ HEAP32[i4 >> 2] = 29;
+ i65 = i69;
+ i66 = i26;
+ break;
+ }
+ HEAP32[i53 >> 2] = i52;
+ HEAP32[i48 >> 2] = i52;
+ HEAP32[i49 >> 2] = 9;
+ i61 = _inflate_table(1, i27, i65, i53, i49, i55) | 0;
+ if ((i61 | 0) != 0) {
+ HEAP32[i35 >> 2] = 11760;
+ HEAP32[i4 >> 2] = 29;
+ i65 = i69;
+ i66 = i26;
+ break;
+ }
+ HEAP32[i50 >> 2] = HEAP32[i53 >> 2];
+ HEAP32[i51 >> 2] = 6;
+ i61 = _inflate_table(2, i4 + (HEAP32[i32 >> 2] << 1) + 112 | 0, HEAP32[i33 >> 2] | 0, i53, i51, i55) | 0;
+ if ((i61 | 0) == 0) {
+ HEAP32[i4 >> 2] = 19;
+ if (i43) {
+ i65 = i69;
+ i61 = 0;
+ i60 = 285;
+ break L17;
+ } else {
+ i65 = i69;
+ i61 = 0;
+ i60 = 201;
+ break;
+ }
+ } else {
+ HEAP32[i35 >> 2] = 11792;
+ HEAP32[i4 >> 2] = 29;
+ i65 = i69;
+ i66 = i26;
+ break;
+ }
+ }
+ } while (0);
+ if ((i60 | 0) == 57) {
+ i60 = HEAP32[i38 >> 2] | 0;
+ if ((i60 | 0) != 0) {
+ HEAP32[i60 + 8 >> 2] = i64 & 255;
+ HEAP32[i60 + 12 >> 2] = i64 >>> 8;
+ }
+ if ((HEAP32[i11 >> 2] & 512 | 0) != 0) {
+ HEAP8[i25] = i64;
+ HEAP8[i39] = i64 >>> 8;
+ HEAP32[i10 >> 2] = _crc32(HEAP32[i10 >> 2] | 0, i25, 2) | 0;
+ }
+ HEAP32[i4 >> 2] = 4;
+ i63 = 0;
+ i64 = 0;
+ i60 = 62;
+ } else if ((i60 | 0) == 201) {
+ HEAP32[i4 >> 2] = 20;
+ i60 = 202;
+ }
+ do {
+ if ((i60 | 0) == 62) {
+ i60 = 0;
+ i66 = HEAP32[i11 >> 2] | 0;
+ if ((i66 & 1024 | 0) == 0) {
+ i60 = HEAP32[i38 >> 2] | 0;
+ if ((i60 | 0) != 0) {
+ HEAP32[i60 + 16 >> 2] = 0;
+ }
+ } else {
+ if (i63 >>> 0 < 16) {
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i67 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 16) {
+ i62 = i67;
+ } else {
+ i62 = i67;
+ break;
+ }
+ }
+ }
+ HEAP32[i42 >> 2] = i64;
+ i60 = HEAP32[i38 >> 2] | 0;
+ if ((i60 | 0) != 0) {
+ HEAP32[i60 + 20 >> 2] = i64;
+ i66 = HEAP32[i11 >> 2] | 0;
+ }
+ if ((i66 & 512 | 0) == 0) {
+ i63 = 0;
+ i64 = 0;
+ } else {
+ HEAP8[i25] = i64;
+ HEAP8[i39] = i64 >>> 8;
+ HEAP32[i10 >> 2] = _crc32(HEAP32[i10 >> 2] | 0, i25, 2) | 0;
+ i63 = 0;
+ i64 = 0;
+ }
+ }
+ HEAP32[i4 >> 2] = 5;
+ i60 = 73;
+ } else if ((i60 | 0) == 202) {
+ i60 = 0;
+ if (i65 >>> 0 > 5 & i26 >>> 0 > 257) {
+ HEAP32[i8 >> 2] = i19;
+ HEAP32[i15 >> 2] = i26;
+ HEAP32[i2 >> 2] = i62;
+ HEAP32[i16 >> 2] = i65;
+ HEAP32[i17 >> 2] = i64;
+ HEAP32[i6 >> 2] = i63;
+ _inflate_fast(i2, i59);
+ i19 = HEAP32[i8 >> 2] | 0;
+ i66 = HEAP32[i15 >> 2] | 0;
+ i62 = HEAP32[i2 >> 2] | 0;
+ i65 = HEAP32[i16 >> 2] | 0;
+ i64 = HEAP32[i17 >> 2] | 0;
+ i63 = HEAP32[i6 >> 2] | 0;
+ if ((HEAP32[i4 >> 2] | 0) != 11) {
+ break;
+ }
+ HEAP32[i57 >> 2] = -1;
+ break;
+ }
+ HEAP32[i57 >> 2] = 0;
+ i69 = (1 << HEAP32[i49 >> 2]) + -1 | 0;
+ i71 = i69 & i64;
+ i66 = HEAP32[i48 >> 2] | 0;
+ i68 = HEAP8[i66 + (i71 << 2) + 1 | 0] | 0;
+ i67 = i68 & 255;
+ if (i67 >>> 0 > i63 >>> 0) {
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i70 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ i71 = i69 & i64;
+ i68 = HEAP8[i66 + (i71 << 2) + 1 | 0] | 0;
+ i67 = i68 & 255;
+ if (i67 >>> 0 > i63 >>> 0) {
+ i62 = i70;
+ } else {
+ i62 = i70;
+ break;
+ }
+ }
+ }
+ i69 = HEAP8[i66 + (i71 << 2) | 0] | 0;
+ i70 = HEAP16[i66 + (i71 << 2) + 2 >> 1] | 0;
+ i71 = i69 & 255;
+ if (!(i69 << 24 >> 24 == 0)) {
+ if ((i71 & 240 | 0) == 0) {
+ i69 = i70 & 65535;
+ i70 = (1 << i67 + i71) + -1 | 0;
+ i71 = ((i64 & i70) >>> i67) + i69 | 0;
+ i68 = HEAP8[i66 + (i71 << 2) + 1 | 0] | 0;
+ if (((i68 & 255) + i67 | 0) >>> 0 > i63 >>> 0) {
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i71 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ i62 = ((i64 & i70) >>> i67) + i69 | 0;
+ i68 = HEAP8[i66 + (i62 << 2) + 1 | 0] | 0;
+ if (((i68 & 255) + i67 | 0) >>> 0 > i63 >>> 0) {
+ i62 = i71;
+ } else {
+ i69 = i62;
+ i62 = i71;
+ break;
+ }
+ }
+ } else {
+ i69 = i71;
+ }
+ i70 = HEAP16[i66 + (i69 << 2) + 2 >> 1] | 0;
+ i69 = HEAP8[i66 + (i69 << 2) | 0] | 0;
+ HEAP32[i57 >> 2] = i67;
+ i66 = i67;
+ i63 = i63 - i67 | 0;
+ i64 = i64 >>> i67;
+ } else {
+ i66 = 0;
+ }
+ } else {
+ i66 = 0;
+ i69 = 0;
+ }
+ i72 = i68 & 255;
+ i64 = i64 >>> i72;
+ i63 = i63 - i72 | 0;
+ HEAP32[i57 >> 2] = i66 + i72;
+ HEAP32[i42 >> 2] = i70 & 65535;
+ i66 = i69 & 255;
+ if (i69 << 24 >> 24 == 0) {
+ HEAP32[i4 >> 2] = 25;
+ i66 = i26;
+ break;
+ }
+ if ((i66 & 32 | 0) != 0) {
+ HEAP32[i57 >> 2] = -1;
+ HEAP32[i4 >> 2] = 11;
+ i66 = i26;
+ break;
+ }
+ if ((i66 & 64 | 0) == 0) {
+ i66 = i66 & 15;
+ HEAP32[i37 >> 2] = i66;
+ HEAP32[i4 >> 2] = 21;
+ i60 = 221;
+ break;
+ } else {
+ HEAP32[i35 >> 2] = 11816;
+ HEAP32[i4 >> 2] = 29;
+ i66 = i26;
+ break;
+ }
+ }
+ } while (0);
+ if ((i60 | 0) == 73) {
+ i68 = HEAP32[i11 >> 2] | 0;
+ if ((i68 & 1024 | 0) != 0) {
+ i67 = HEAP32[i42 >> 2] | 0;
+ i60 = i67 >>> 0 > i65 >>> 0 ? i65 : i67;
+ if ((i60 | 0) != 0) {
+ i66 = HEAP32[i38 >> 2] | 0;
+ if ((i66 | 0) != 0 ? (i20 = HEAP32[i66 + 16 >> 2] | 0, (i20 | 0) != 0) : 0) {
+ i67 = (HEAP32[i66 + 20 >> 2] | 0) - i67 | 0;
+ i66 = HEAP32[i66 + 24 >> 2] | 0;
+ _memcpy(i20 + i67 | 0, i62 | 0, ((i67 + i60 | 0) >>> 0 > i66 >>> 0 ? i66 - i67 | 0 : i60) | 0) | 0;
+ i68 = HEAP32[i11 >> 2] | 0;
+ }
+ if ((i68 & 512 | 0) != 0) {
+ HEAP32[i10 >> 2] = _crc32(HEAP32[i10 >> 2] | 0, i62, i60) | 0;
+ }
+ i67 = (HEAP32[i42 >> 2] | 0) - i60 | 0;
+ HEAP32[i42 >> 2] = i67;
+ i65 = i65 - i60 | 0;
+ i62 = i62 + i60 | 0;
+ }
+ if ((i67 | 0) != 0) {
+ i60 = 285;
+ break;
+ }
+ }
+ HEAP32[i42 >> 2] = 0;
+ HEAP32[i4 >> 2] = 6;
+ i60 = 83;
+ } else if ((i60 | 0) == 221) {
+ i60 = 0;
+ if ((i66 | 0) == 0) {
+ i60 = HEAP32[i42 >> 2] | 0;
+ } else {
+ if (i63 >>> 0 < i66 >>> 0) {
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i67 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < i66 >>> 0) {
+ i62 = i67;
+ } else {
+ i62 = i67;
+ break;
+ }
+ }
+ }
+ i60 = (HEAP32[i42 >> 2] | 0) + ((1 << i66) + -1 & i64) | 0;
+ HEAP32[i42 >> 2] = i60;
+ HEAP32[i57 >> 2] = (HEAP32[i57 >> 2] | 0) + i66;
+ i63 = i63 - i66 | 0;
+ i64 = i64 >>> i66;
+ }
+ HEAP32[i58 >> 2] = i60;
+ HEAP32[i4 >> 2] = 22;
+ i60 = 228;
+ }
+ do {
+ if ((i60 | 0) == 83) {
+ if ((HEAP32[i11 >> 2] & 2048 | 0) == 0) {
+ i60 = HEAP32[i38 >> 2] | 0;
+ if ((i60 | 0) != 0) {
+ HEAP32[i60 + 28 >> 2] = 0;
+ }
+ } else {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ i60 = 285;
+ break L17;
+ } else {
+ i66 = 0;
+ }
+ while (1) {
+ i60 = i66 + 1 | 0;
+ i67 = HEAP8[i62 + i66 | 0] | 0;
+ i66 = HEAP32[i38 >> 2] | 0;
+ if (((i66 | 0) != 0 ? (i23 = HEAP32[i66 + 28 >> 2] | 0, (i23 | 0) != 0) : 0) ? (i21 = HEAP32[i42 >> 2] | 0, i21 >>> 0 < (HEAP32[i66 + 32 >> 2] | 0) >>> 0) : 0) {
+ HEAP32[i42 >> 2] = i21 + 1;
+ HEAP8[i23 + i21 | 0] = i67;
+ }
+ i66 = i67 << 24 >> 24 != 0;
+ if (i66 & i60 >>> 0 < i65 >>> 0) {
+ i66 = i60;
+ } else {
+ break;
+ }
+ }
+ if ((HEAP32[i11 >> 2] & 512 | 0) != 0) {
+ HEAP32[i10 >> 2] = _crc32(HEAP32[i10 >> 2] | 0, i62, i60) | 0;
+ }
+ i65 = i65 - i60 | 0;
+ i62 = i62 + i60 | 0;
+ if (i66) {
+ i60 = 285;
+ break L17;
+ }
+ }
+ HEAP32[i42 >> 2] = 0;
+ HEAP32[i4 >> 2] = 7;
+ i60 = 96;
+ } else if ((i60 | 0) == 228) {
+ i60 = 0;
+ i69 = (1 << HEAP32[i51 >> 2]) + -1 | 0;
+ i71 = i69 & i64;
+ i66 = HEAP32[i50 >> 2] | 0;
+ i68 = HEAP8[i66 + (i71 << 2) + 1 | 0] | 0;
+ i67 = i68 & 255;
+ if (i67 >>> 0 > i63 >>> 0) {
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i70 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ i71 = i69 & i64;
+ i68 = HEAP8[i66 + (i71 << 2) + 1 | 0] | 0;
+ i67 = i68 & 255;
+ if (i67 >>> 0 > i63 >>> 0) {
+ i62 = i70;
+ } else {
+ i62 = i70;
+ break;
+ }
+ }
+ }
+ i69 = HEAP8[i66 + (i71 << 2) | 0] | 0;
+ i70 = HEAP16[i66 + (i71 << 2) + 2 >> 1] | 0;
+ i71 = i69 & 255;
+ if ((i71 & 240 | 0) == 0) {
+ i69 = i70 & 65535;
+ i70 = (1 << i67 + i71) + -1 | 0;
+ i71 = ((i64 & i70) >>> i67) + i69 | 0;
+ i68 = HEAP8[i66 + (i71 << 2) + 1 | 0] | 0;
+ if (((i68 & 255) + i67 | 0) >>> 0 > i63 >>> 0) {
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i71 = i62 + 1 | 0;
+ i64 = (HEAPU8[i62] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ i62 = ((i64 & i70) >>> i67) + i69 | 0;
+ i68 = HEAP8[i66 + (i62 << 2) + 1 | 0] | 0;
+ if (((i68 & 255) + i67 | 0) >>> 0 > i63 >>> 0) {
+ i62 = i71;
+ } else {
+ i69 = i62;
+ i62 = i71;
+ break;
+ }
+ }
+ } else {
+ i69 = i71;
+ }
+ i70 = HEAP16[i66 + (i69 << 2) + 2 >> 1] | 0;
+ i69 = HEAP8[i66 + (i69 << 2) | 0] | 0;
+ i66 = (HEAP32[i57 >> 2] | 0) + i67 | 0;
+ HEAP32[i57 >> 2] = i66;
+ i63 = i63 - i67 | 0;
+ i64 = i64 >>> i67;
+ } else {
+ i66 = HEAP32[i57 >> 2] | 0;
+ }
+ i72 = i68 & 255;
+ i64 = i64 >>> i72;
+ i63 = i63 - i72 | 0;
+ HEAP32[i57 >> 2] = i66 + i72;
+ i66 = i69 & 255;
+ if ((i66 & 64 | 0) == 0) {
+ HEAP32[i54 >> 2] = i70 & 65535;
+ i66 = i66 & 15;
+ HEAP32[i37 >> 2] = i66;
+ HEAP32[i4 >> 2] = 23;
+ i60 = 240;
+ break;
+ } else {
+ HEAP32[i35 >> 2] = 11848;
+ HEAP32[i4 >> 2] = 29;
+ i66 = i26;
+ break;
+ }
+ }
+ } while (0);
+ if ((i60 | 0) == 96) {
+ if ((HEAP32[i11 >> 2] & 4096 | 0) == 0) {
+ i60 = HEAP32[i38 >> 2] | 0;
+ if ((i60 | 0) != 0) {
+ HEAP32[i60 + 36 >> 2] = 0;
+ }
+ } else {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ i60 = 285;
+ break;
+ } else {
+ i66 = 0;
+ }
+ while (1) {
+ i60 = i66 + 1 | 0;
+ i66 = HEAP8[i62 + i66 | 0] | 0;
+ i67 = HEAP32[i38 >> 2] | 0;
+ if (((i67 | 0) != 0 ? (i24 = HEAP32[i67 + 36 >> 2] | 0, (i24 | 0) != 0) : 0) ? (i22 = HEAP32[i42 >> 2] | 0, i22 >>> 0 < (HEAP32[i67 + 40 >> 2] | 0) >>> 0) : 0) {
+ HEAP32[i42 >> 2] = i22 + 1;
+ HEAP8[i24 + i22 | 0] = i66;
+ }
+ i66 = i66 << 24 >> 24 != 0;
+ if (i66 & i60 >>> 0 < i65 >>> 0) {
+ i66 = i60;
+ } else {
+ break;
+ }
+ }
+ if ((HEAP32[i11 >> 2] & 512 | 0) != 0) {
+ HEAP32[i10 >> 2] = _crc32(HEAP32[i10 >> 2] | 0, i62, i60) | 0;
+ }
+ i65 = i65 - i60 | 0;
+ i62 = i62 + i60 | 0;
+ if (i66) {
+ i60 = 285;
+ break;
+ }
+ }
+ HEAP32[i4 >> 2] = 8;
+ i60 = 109;
+ } else if ((i60 | 0) == 240) {
+ i60 = 0;
+ if ((i66 | 0) != 0) {
+ if (i63 >>> 0 < i66 >>> 0) {
+ i67 = i62;
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ i62 = i67;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i62 = i67 + 1 | 0;
+ i64 = (HEAPU8[i67] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < i66 >>> 0) {
+ i67 = i62;
+ } else {
+ break;
+ }
+ }
+ }
+ HEAP32[i54 >> 2] = (HEAP32[i54 >> 2] | 0) + ((1 << i66) + -1 & i64);
+ HEAP32[i57 >> 2] = (HEAP32[i57 >> 2] | 0) + i66;
+ i63 = i63 - i66 | 0;
+ i64 = i64 >>> i66;
+ }
+ HEAP32[i4 >> 2] = 24;
+ i60 = 246;
+ }
+ do {
+ if ((i60 | 0) == 109) {
+ i60 = 0;
+ i66 = HEAP32[i11 >> 2] | 0;
+ if ((i66 & 512 | 0) != 0) {
+ if (i63 >>> 0 < 16) {
+ i67 = i62;
+ while (1) {
+ if ((i65 | 0) == 0) {
+ i65 = 0;
+ i62 = i67;
+ break L17;
+ }
+ i65 = i65 + -1 | 0;
+ i62 = i67 + 1 | 0;
+ i64 = (HEAPU8[i67] << i63) + i64 | 0;
+ i63 = i63 + 8 | 0;
+ if (i63 >>> 0 < 16) {
+ i67 = i62;
+ } else {
+ break;
+ }
+ }
+ }
+ if ((i64 | 0) == (HEAP32[i10 >> 2] & 65535 | 0)) {
+ i63 = 0;
+ i64 = 0;
+ } else {
+ HEAP32[i35 >> 2] = 11536;
+ HEAP32[i4 >> 2] = 29;
+ i66 = i26;
+ break;
+ }
+ }
+ i67 = HEAP32[i38 >> 2] | 0;
+ if ((i67 | 0) != 0) {
+ HEAP32[i67 + 44 >> 2] = i66 >>> 9 & 1;
+ HEAP32[i67 + 48 >> 2] = 1;
+ }
+ i66 = _crc32(0, 0, 0) | 0;
+ HEAP32[i10 >> 2] = i66;
+ HEAP32[i9 >> 2] = i66;
+ HEAP32[i4 >> 2] = 11;
+ i66 = i26;
+ } else if ((i60 | 0) == 246) {
+ i60 = 0;
+ if ((i26 | 0) == 0) {
+ i26 = 0;
+ i60 = 285;
+ break L17;
+ }
+ i67 = i59 - i26 | 0;
+ i66 = HEAP32[i54 >> 2] | 0;
+ if (i66 >>> 0 > i67 >>> 0) {
+ i67 = i66 - i67 | 0;
+ if (i67 >>> 0 > (HEAP32[i28 >> 2] | 0) >>> 0 ? (HEAP32[i29 >> 2] | 0) != 0 : 0) {
+ HEAP32[i35 >> 2] = 11872;
+ HEAP32[i4 >> 2] = 29;
+ i66 = i26;
+ break;
+ }
+ i68 = HEAP32[i30 >> 2] | 0;
+ if (i67 >>> 0 > i68 >>> 0) {
+ i68 = i67 - i68 | 0;
+ i66 = i68;
+ i68 = (HEAP32[i31 >> 2] | 0) + ((HEAP32[i18 >> 2] | 0) - i68) | 0;
+ } else {
+ i66 = i67;
+ i68 = (HEAP32[i31 >> 2] | 0) + (i68 - i67) | 0;
+ }
+ i69 = HEAP32[i42 >> 2] | 0;
+ i67 = i69;
+ i69 = i66 >>> 0 > i69 >>> 0 ? i69 : i66;
+ } else {
+ i69 = HEAP32[i42 >> 2] | 0;
+ i67 = i69;
+ i68 = i19 + (0 - i66) | 0;
+ }
+ i66 = i69 >>> 0 > i26 >>> 0 ? i26 : i69;
+ HEAP32[i42 >> 2] = i67 - i66;
+ i67 = ~i26;
+ i69 = ~i69;
+ i67 = i67 >>> 0 > i69 >>> 0 ? i67 : i69;
+ i69 = i66;
+ i70 = i19;
+ while (1) {
+ HEAP8[i70] = HEAP8[i68] | 0;
+ i69 = i69 + -1 | 0;
+ if ((i69 | 0) == 0) {
+ break;
+ } else {
+ i68 = i68 + 1 | 0;
+ i70 = i70 + 1 | 0;
+ }
+ }
+ i66 = i26 - i66 | 0;
+ i19 = i19 + ~i67 | 0;
+ if ((HEAP32[i42 >> 2] | 0) == 0) {
+ HEAP32[i4 >> 2] = 20;
+ }
+ }
+ } while (0);
+ i68 = HEAP32[i4 >> 2] | 0;
+ i67 = i63;
+ i26 = i66;
+ }
+ if ((i60 | 0) == 122) {
+ HEAP32[i8 >> 2] = i19;
+ HEAP32[i15 >> 2] = i26;
+ HEAP32[i2 >> 2] = i62;
+ HEAP32[i16 >> 2] = i65;
+ HEAP32[i17 >> 2] = i64;
+ HEAP32[i6 >> 2] = i63;
+ i72 = 2;
+ STACKTOP = i1;
+ return i72 | 0;
+ } else if ((i60 | 0) == 133) {
+ i63 = i63 + -3 | 0;
+ i64 = i64 >>> 3;
+ } else if ((i60 | 0) == 284) {
+ HEAP32[i4 >> 2] = 28;
+ i61 = 1;
+ } else if ((i60 | 0) != 285) if ((i60 | 0) == 299) {
+ i72 = -4;
+ STACKTOP = i1;
+ return i72 | 0;
+ } else if ((i60 | 0) == 300) {
+ STACKTOP = i1;
+ return i2 | 0;
+ }
+ HEAP32[i8 >> 2] = i19;
+ HEAP32[i15 >> 2] = i26;
+ HEAP32[i2 >> 2] = i62;
+ HEAP32[i16 >> 2] = i65;
+ HEAP32[i17 >> 2] = i64;
+ HEAP32[i6 >> 2] = i63;
+ if ((HEAP32[i18 >> 2] | 0) == 0) {
+ if ((HEAP32[i4 >> 2] | 0) >>> 0 < 26 ? (i59 | 0) != (HEAP32[i15 >> 2] | 0) : 0) {
+ i60 = 289;
+ }
+ } else {
+ i60 = 289;
+ }
+ if ((i60 | 0) == 289 ? (_updatewindow(i2, i59) | 0) != 0 : 0) {
+ HEAP32[i4 >> 2] = 30;
+ i72 = -4;
+ STACKTOP = i1;
+ return i72 | 0;
+ }
+ i16 = HEAP32[i16 >> 2] | 0;
+ i72 = HEAP32[i15 >> 2] | 0;
+ i15 = i59 - i72 | 0;
+ i71 = i2 + 8 | 0;
+ HEAP32[i71 >> 2] = i5 - i16 + (HEAP32[i71 >> 2] | 0);
+ HEAP32[i13 >> 2] = (HEAP32[i13 >> 2] | 0) + i15;
+ HEAP32[i14 >> 2] = (HEAP32[i14 >> 2] | 0) + i15;
+ i13 = (i59 | 0) == (i72 | 0);
+ if (!((HEAP32[i12 >> 2] | 0) == 0 | i13)) {
+ i12 = HEAP32[i10 >> 2] | 0;
+ i8 = (HEAP32[i8 >> 2] | 0) + (0 - i15) | 0;
+ if ((HEAP32[i11 >> 2] | 0) == 0) {
+ i8 = _adler32(i12, i8, i15) | 0;
+ } else {
+ i8 = _crc32(i12, i8, i15) | 0;
+ }
+ HEAP32[i10 >> 2] = i8;
+ HEAP32[i9 >> 2] = i8;
+ }
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((i4 | 0) == 19) {
+ i8 = 256;
+ } else {
+ i8 = (i4 | 0) == 14 ? 256 : 0;
+ }
+ HEAP32[i2 + 44 >> 2] = ((HEAP32[i7 >> 2] | 0) != 0 ? 64 : 0) + (HEAP32[i6 >> 2] | 0) + ((i4 | 0) == 11 ? 128 : 0) + i8;
+ i72 = ((i5 | 0) == (i16 | 0) & i13 | (i3 | 0) == 4) & (i61 | 0) == 0 ? -5 : i61;
+ STACKTOP = i1;
+ return i72 | 0;
+}
+function _malloc(i12) {
+ i12 = i12 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0;
+ i1 = STACKTOP;
+ do {
+ if (i12 >>> 0 < 245) {
+ if (i12 >>> 0 < 11) {
+ i12 = 16;
+ } else {
+ i12 = i12 + 11 & -8;
+ }
+ i20 = i12 >>> 3;
+ i18 = HEAP32[3618] | 0;
+ i21 = i18 >>> i20;
+ if ((i21 & 3 | 0) != 0) {
+ i6 = (i21 & 1 ^ 1) + i20 | 0;
+ i5 = i6 << 1;
+ i3 = 14512 + (i5 << 2) | 0;
+ i5 = 14512 + (i5 + 2 << 2) | 0;
+ i7 = HEAP32[i5 >> 2] | 0;
+ i2 = i7 + 8 | 0;
+ i4 = HEAP32[i2 >> 2] | 0;
+ do {
+ if ((i3 | 0) != (i4 | 0)) {
+ if (i4 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i4 + 12 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i7 | 0)) {
+ HEAP32[i8 >> 2] = i3;
+ HEAP32[i5 >> 2] = i4;
+ break;
+ } else {
+ _abort();
+ }
+ } else {
+ HEAP32[3618] = i18 & ~(1 << i6);
+ }
+ } while (0);
+ i32 = i6 << 3;
+ HEAP32[i7 + 4 >> 2] = i32 | 3;
+ i32 = i7 + (i32 | 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ i32 = i2;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ if (i12 >>> 0 > (HEAP32[14480 >> 2] | 0) >>> 0) {
+ if ((i21 | 0) != 0) {
+ i7 = 2 << i20;
+ i7 = i21 << i20 & (i7 | 0 - i7);
+ i7 = (i7 & 0 - i7) + -1 | 0;
+ i2 = i7 >>> 12 & 16;
+ i7 = i7 >>> i2;
+ i6 = i7 >>> 5 & 8;
+ i7 = i7 >>> i6;
+ i5 = i7 >>> 2 & 4;
+ i7 = i7 >>> i5;
+ i4 = i7 >>> 1 & 2;
+ i7 = i7 >>> i4;
+ i3 = i7 >>> 1 & 1;
+ i3 = (i6 | i2 | i5 | i4 | i3) + (i7 >>> i3) | 0;
+ i7 = i3 << 1;
+ i4 = 14512 + (i7 << 2) | 0;
+ i7 = 14512 + (i7 + 2 << 2) | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ i2 = i5 + 8 | 0;
+ i6 = HEAP32[i2 >> 2] | 0;
+ do {
+ if ((i4 | 0) != (i6 | 0)) {
+ if (i6 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i6 + 12 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i5 | 0)) {
+ HEAP32[i8 >> 2] = i4;
+ HEAP32[i7 >> 2] = i6;
+ break;
+ } else {
+ _abort();
+ }
+ } else {
+ HEAP32[3618] = i18 & ~(1 << i3);
+ }
+ } while (0);
+ i6 = i3 << 3;
+ i4 = i6 - i12 | 0;
+ HEAP32[i5 + 4 >> 2] = i12 | 3;
+ i3 = i5 + i12 | 0;
+ HEAP32[i5 + (i12 | 4) >> 2] = i4 | 1;
+ HEAP32[i5 + i6 >> 2] = i4;
+ i6 = HEAP32[14480 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i5 = HEAP32[14492 >> 2] | 0;
+ i8 = i6 >>> 3;
+ i9 = i8 << 1;
+ i6 = 14512 + (i9 << 2) | 0;
+ i7 = HEAP32[3618] | 0;
+ i8 = 1 << i8;
+ if ((i7 & i8 | 0) != 0) {
+ i7 = 14512 + (i9 + 2 << 2) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i28 = i7;
+ i27 = i8;
+ }
+ } else {
+ HEAP32[3618] = i7 | i8;
+ i28 = 14512 + (i9 + 2 << 2) | 0;
+ i27 = i6;
+ }
+ HEAP32[i28 >> 2] = i5;
+ HEAP32[i27 + 12 >> 2] = i5;
+ HEAP32[i5 + 8 >> 2] = i27;
+ HEAP32[i5 + 12 >> 2] = i6;
+ }
+ HEAP32[14480 >> 2] = i4;
+ HEAP32[14492 >> 2] = i3;
+ i32 = i2;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i18 = HEAP32[14476 >> 2] | 0;
+ if ((i18 | 0) != 0) {
+ i2 = (i18 & 0 - i18) + -1 | 0;
+ i31 = i2 >>> 12 & 16;
+ i2 = i2 >>> i31;
+ i30 = i2 >>> 5 & 8;
+ i2 = i2 >>> i30;
+ i32 = i2 >>> 2 & 4;
+ i2 = i2 >>> i32;
+ i6 = i2 >>> 1 & 2;
+ i2 = i2 >>> i6;
+ i3 = i2 >>> 1 & 1;
+ i3 = HEAP32[14776 + ((i30 | i31 | i32 | i6 | i3) + (i2 >>> i3) << 2) >> 2] | 0;
+ i2 = (HEAP32[i3 + 4 >> 2] & -8) - i12 | 0;
+ i6 = i3;
+ while (1) {
+ i5 = HEAP32[i6 + 16 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i5 = HEAP32[i6 + 20 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ }
+ i6 = (HEAP32[i5 + 4 >> 2] & -8) - i12 | 0;
+ i4 = i6 >>> 0 < i2 >>> 0;
+ i2 = i4 ? i6 : i2;
+ i6 = i5;
+ i3 = i4 ? i5 : i3;
+ }
+ i6 = HEAP32[14488 >> 2] | 0;
+ if (i3 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ i4 = i3 + i12 | 0;
+ if (!(i3 >>> 0 < i4 >>> 0)) {
+ _abort();
+ }
+ i5 = HEAP32[i3 + 24 >> 2] | 0;
+ i7 = HEAP32[i3 + 12 >> 2] | 0;
+ do {
+ if ((i7 | 0) == (i3 | 0)) {
+ i8 = i3 + 20 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i8 = i3 + 16 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) == 0) {
+ i26 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i10 = i7 + 20 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ i7 = i9;
+ i8 = i10;
+ continue;
+ }
+ i10 = i7 + 16 | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ } else {
+ i7 = i9;
+ i8 = i10;
+ }
+ }
+ if (i8 >>> 0 < i6 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i8 >> 2] = 0;
+ i26 = i7;
+ break;
+ }
+ } else {
+ i8 = HEAP32[i3 + 8 >> 2] | 0;
+ if (i8 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ i6 = i8 + 12 | 0;
+ if ((HEAP32[i6 >> 2] | 0) != (i3 | 0)) {
+ _abort();
+ }
+ i9 = i7 + 8 | 0;
+ if ((HEAP32[i9 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i6 >> 2] = i7;
+ HEAP32[i9 >> 2] = i8;
+ i26 = i7;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ do {
+ if ((i5 | 0) != 0) {
+ i7 = HEAP32[i3 + 28 >> 2] | 0;
+ i6 = 14776 + (i7 << 2) | 0;
+ if ((i3 | 0) == (HEAP32[i6 >> 2] | 0)) {
+ HEAP32[i6 >> 2] = i26;
+ if ((i26 | 0) == 0) {
+ HEAP32[14476 >> 2] = HEAP32[14476 >> 2] & ~(1 << i7);
+ break;
+ }
+ } else {
+ if (i5 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i6 = i5 + 16 | 0;
+ if ((HEAP32[i6 >> 2] | 0) == (i3 | 0)) {
+ HEAP32[i6 >> 2] = i26;
+ } else {
+ HEAP32[i5 + 20 >> 2] = i26;
+ }
+ if ((i26 | 0) == 0) {
+ break;
+ }
+ }
+ if (i26 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i26 + 24 >> 2] = i5;
+ i5 = HEAP32[i3 + 16 >> 2] | 0;
+ do {
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i26 + 16 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i26;
+ break;
+ }
+ }
+ } while (0);
+ i5 = HEAP32[i3 + 20 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i26 + 20 >> 2] = i5;
+ HEAP32[i5 + 24 >> 2] = i26;
+ break;
+ }
+ }
+ }
+ } while (0);
+ if (i2 >>> 0 < 16) {
+ i32 = i2 + i12 | 0;
+ HEAP32[i3 + 4 >> 2] = i32 | 3;
+ i32 = i3 + (i32 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ } else {
+ HEAP32[i3 + 4 >> 2] = i12 | 3;
+ HEAP32[i3 + (i12 | 4) >> 2] = i2 | 1;
+ HEAP32[i3 + (i2 + i12) >> 2] = i2;
+ i6 = HEAP32[14480 >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ i5 = HEAP32[14492 >> 2] | 0;
+ i8 = i6 >>> 3;
+ i9 = i8 << 1;
+ i6 = 14512 + (i9 << 2) | 0;
+ i7 = HEAP32[3618] | 0;
+ i8 = 1 << i8;
+ if ((i7 & i8 | 0) != 0) {
+ i7 = 14512 + (i9 + 2 << 2) | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if (i8 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i25 = i7;
+ i24 = i8;
+ }
+ } else {
+ HEAP32[3618] = i7 | i8;
+ i25 = 14512 + (i9 + 2 << 2) | 0;
+ i24 = i6;
+ }
+ HEAP32[i25 >> 2] = i5;
+ HEAP32[i24 + 12 >> 2] = i5;
+ HEAP32[i5 + 8 >> 2] = i24;
+ HEAP32[i5 + 12 >> 2] = i6;
+ }
+ HEAP32[14480 >> 2] = i2;
+ HEAP32[14492 >> 2] = i4;
+ }
+ i32 = i3 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ } else {
+ if (!(i12 >>> 0 > 4294967231)) {
+ i24 = i12 + 11 | 0;
+ i12 = i24 & -8;
+ i26 = HEAP32[14476 >> 2] | 0;
+ if ((i26 | 0) != 0) {
+ i25 = 0 - i12 | 0;
+ i24 = i24 >>> 8;
+ if ((i24 | 0) != 0) {
+ if (i12 >>> 0 > 16777215) {
+ i27 = 31;
+ } else {
+ i31 = (i24 + 1048320 | 0) >>> 16 & 8;
+ i32 = i24 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i27 = (i32 + 245760 | 0) >>> 16 & 2;
+ i27 = 14 - (i30 | i31 | i27) + (i32 << i27 >>> 15) | 0;
+ i27 = i12 >>> (i27 + 7 | 0) & 1 | i27 << 1;
+ }
+ } else {
+ i27 = 0;
+ }
+ i30 = HEAP32[14776 + (i27 << 2) >> 2] | 0;
+ L126 : do {
+ if ((i30 | 0) == 0) {
+ i29 = 0;
+ i24 = 0;
+ } else {
+ if ((i27 | 0) == 31) {
+ i24 = 0;
+ } else {
+ i24 = 25 - (i27 >>> 1) | 0;
+ }
+ i29 = 0;
+ i28 = i12 << i24;
+ i24 = 0;
+ while (1) {
+ i32 = HEAP32[i30 + 4 >> 2] & -8;
+ i31 = i32 - i12 | 0;
+ if (i31 >>> 0 < i25 >>> 0) {
+ if ((i32 | 0) == (i12 | 0)) {
+ i25 = i31;
+ i29 = i30;
+ i24 = i30;
+ break L126;
+ } else {
+ i25 = i31;
+ i24 = i30;
+ }
+ }
+ i31 = HEAP32[i30 + 20 >> 2] | 0;
+ i30 = HEAP32[i30 + (i28 >>> 31 << 2) + 16 >> 2] | 0;
+ i29 = (i31 | 0) == 0 | (i31 | 0) == (i30 | 0) ? i29 : i31;
+ if ((i30 | 0) == 0) {
+ break;
+ } else {
+ i28 = i28 << 1;
+ }
+ }
+ }
+ } while (0);
+ if ((i29 | 0) == 0 & (i24 | 0) == 0) {
+ i32 = 2 << i27;
+ i26 = i26 & (i32 | 0 - i32);
+ if ((i26 | 0) == 0) {
+ break;
+ }
+ i32 = (i26 & 0 - i26) + -1 | 0;
+ i28 = i32 >>> 12 & 16;
+ i32 = i32 >>> i28;
+ i27 = i32 >>> 5 & 8;
+ i32 = i32 >>> i27;
+ i30 = i32 >>> 2 & 4;
+ i32 = i32 >>> i30;
+ i31 = i32 >>> 1 & 2;
+ i32 = i32 >>> i31;
+ i29 = i32 >>> 1 & 1;
+ i29 = HEAP32[14776 + ((i27 | i28 | i30 | i31 | i29) + (i32 >>> i29) << 2) >> 2] | 0;
+ }
+ if ((i29 | 0) != 0) {
+ while (1) {
+ i27 = (HEAP32[i29 + 4 >> 2] & -8) - i12 | 0;
+ i26 = i27 >>> 0 < i25 >>> 0;
+ i25 = i26 ? i27 : i25;
+ i24 = i26 ? i29 : i24;
+ i26 = HEAP32[i29 + 16 >> 2] | 0;
+ if ((i26 | 0) != 0) {
+ i29 = i26;
+ continue;
+ }
+ i29 = HEAP32[i29 + 20 >> 2] | 0;
+ if ((i29 | 0) == 0) {
+ break;
+ }
+ }
+ }
+ if ((i24 | 0) != 0 ? i25 >>> 0 < ((HEAP32[14480 >> 2] | 0) - i12 | 0) >>> 0 : 0) {
+ i4 = HEAP32[14488 >> 2] | 0;
+ if (i24 >>> 0 < i4 >>> 0) {
+ _abort();
+ }
+ i2 = i24 + i12 | 0;
+ if (!(i24 >>> 0 < i2 >>> 0)) {
+ _abort();
+ }
+ i3 = HEAP32[i24 + 24 >> 2] | 0;
+ i6 = HEAP32[i24 + 12 >> 2] | 0;
+ do {
+ if ((i6 | 0) == (i24 | 0)) {
+ i6 = i24 + 20 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i6 = i24 + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i22 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i8 = i5 + 20 | 0;
+ i7 = HEAP32[i8 >> 2] | 0;
+ if ((i7 | 0) != 0) {
+ i5 = i7;
+ i6 = i8;
+ continue;
+ }
+ i7 = i5 + 16 | 0;
+ i8 = HEAP32[i7 >> 2] | 0;
+ if ((i8 | 0) == 0) {
+ break;
+ } else {
+ i5 = i8;
+ i6 = i7;
+ }
+ }
+ if (i6 >>> 0 < i4 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = 0;
+ i22 = i5;
+ break;
+ }
+ } else {
+ i5 = HEAP32[i24 + 8 >> 2] | 0;
+ if (i5 >>> 0 < i4 >>> 0) {
+ _abort();
+ }
+ i7 = i5 + 12 | 0;
+ if ((HEAP32[i7 >> 2] | 0) != (i24 | 0)) {
+ _abort();
+ }
+ i4 = i6 + 8 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
+ HEAP32[i7 >> 2] = i6;
+ HEAP32[i4 >> 2] = i5;
+ i22 = i6;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ do {
+ if ((i3 | 0) != 0) {
+ i4 = HEAP32[i24 + 28 >> 2] | 0;
+ i5 = 14776 + (i4 << 2) | 0;
+ if ((i24 | 0) == (HEAP32[i5 >> 2] | 0)) {
+ HEAP32[i5 >> 2] = i22;
+ if ((i22 | 0) == 0) {
+ HEAP32[14476 >> 2] = HEAP32[14476 >> 2] & ~(1 << i4);
+ break;
+ }
+ } else {
+ if (i3 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i4 = i3 + 16 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
+ HEAP32[i4 >> 2] = i22;
+ } else {
+ HEAP32[i3 + 20 >> 2] = i22;
+ }
+ if ((i22 | 0) == 0) {
+ break;
+ }
+ }
+ if (i22 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i22 + 24 >> 2] = i3;
+ i3 = HEAP32[i24 + 16 >> 2] | 0;
+ do {
+ if ((i3 | 0) != 0) {
+ if (i3 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i22 + 16 >> 2] = i3;
+ HEAP32[i3 + 24 >> 2] = i22;
+ break;
+ }
+ }
+ } while (0);
+ i3 = HEAP32[i24 + 20 >> 2] | 0;
+ if ((i3 | 0) != 0) {
+ if (i3 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i22 + 20 >> 2] = i3;
+ HEAP32[i3 + 24 >> 2] = i22;
+ break;
+ }
+ }
+ }
+ } while (0);
+ L204 : do {
+ if (!(i25 >>> 0 < 16)) {
+ HEAP32[i24 + 4 >> 2] = i12 | 3;
+ HEAP32[i24 + (i12 | 4) >> 2] = i25 | 1;
+ HEAP32[i24 + (i25 + i12) >> 2] = i25;
+ i4 = i25 >>> 3;
+ if (i25 >>> 0 < 256) {
+ i6 = i4 << 1;
+ i3 = 14512 + (i6 << 2) | 0;
+ i5 = HEAP32[3618] | 0;
+ i4 = 1 << i4;
+ if ((i5 & i4 | 0) != 0) {
+ i5 = 14512 + (i6 + 2 << 2) | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ if (i4 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i21 = i5;
+ i20 = i4;
+ }
+ } else {
+ HEAP32[3618] = i5 | i4;
+ i21 = 14512 + (i6 + 2 << 2) | 0;
+ i20 = i3;
+ }
+ HEAP32[i21 >> 2] = i2;
+ HEAP32[i20 + 12 >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i20;
+ HEAP32[i24 + (i12 + 12) >> 2] = i3;
+ break;
+ }
+ i3 = i25 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i25 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i25 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i6 = 14776 + (i3 << 2) | 0;
+ HEAP32[i24 + (i12 + 28) >> 2] = i3;
+ HEAP32[i24 + (i12 + 20) >> 2] = 0;
+ HEAP32[i24 + (i12 + 16) >> 2] = 0;
+ i4 = HEAP32[14476 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i4 & i5 | 0) == 0) {
+ HEAP32[14476 >> 2] = i4 | i5;
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i24 + (i12 + 24) >> 2] = i6;
+ HEAP32[i24 + (i12 + 12) >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i2;
+ break;
+ }
+ i4 = HEAP32[i6 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L225 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i25 | 0)) {
+ i3 = i25 << i3;
+ while (1) {
+ i6 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i25 | 0)) {
+ i18 = i5;
+ break L225;
+ } else {
+ i3 = i3 << 1;
+ i4 = i5;
+ }
+ }
+ if (i6 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i24 + (i12 + 24) >> 2] = i4;
+ HEAP32[i24 + (i12 + 12) >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i2;
+ break L204;
+ }
+ } else {
+ i18 = i4;
+ }
+ } while (0);
+ i4 = i18 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[14488 >> 2] | 0;
+ if (i18 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i2;
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i24 + (i12 + 8) >> 2] = i3;
+ HEAP32[i24 + (i12 + 12) >> 2] = i18;
+ HEAP32[i24 + (i12 + 24) >> 2] = 0;
+ break;
+ }
+ } else {
+ i32 = i25 + i12 | 0;
+ HEAP32[i24 + 4 >> 2] = i32 | 3;
+ i32 = i24 + (i32 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ }
+ } while (0);
+ i32 = i24 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ } else {
+ i12 = -1;
+ }
+ }
+ } while (0);
+ i18 = HEAP32[14480 >> 2] | 0;
+ if (!(i12 >>> 0 > i18 >>> 0)) {
+ i3 = i18 - i12 | 0;
+ i2 = HEAP32[14492 >> 2] | 0;
+ if (i3 >>> 0 > 15) {
+ HEAP32[14492 >> 2] = i2 + i12;
+ HEAP32[14480 >> 2] = i3;
+ HEAP32[i2 + (i12 + 4) >> 2] = i3 | 1;
+ HEAP32[i2 + i18 >> 2] = i3;
+ HEAP32[i2 + 4 >> 2] = i12 | 3;
+ } else {
+ HEAP32[14480 >> 2] = 0;
+ HEAP32[14492 >> 2] = 0;
+ HEAP32[i2 + 4 >> 2] = i18 | 3;
+ i32 = i2 + (i18 + 4) | 0;
+ HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
+ }
+ i32 = i2 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i18 = HEAP32[14484 >> 2] | 0;
+ if (i12 >>> 0 < i18 >>> 0) {
+ i31 = i18 - i12 | 0;
+ HEAP32[14484 >> 2] = i31;
+ i32 = HEAP32[14496 >> 2] | 0;
+ HEAP32[14496 >> 2] = i32 + i12;
+ HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
+ HEAP32[i32 + 4 >> 2] = i12 | 3;
+ i32 = i32 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ do {
+ if ((HEAP32[3736] | 0) == 0) {
+ i18 = _sysconf(30) | 0;
+ if ((i18 + -1 & i18 | 0) == 0) {
+ HEAP32[14952 >> 2] = i18;
+ HEAP32[14948 >> 2] = i18;
+ HEAP32[14956 >> 2] = -1;
+ HEAP32[14960 >> 2] = -1;
+ HEAP32[14964 >> 2] = 0;
+ HEAP32[14916 >> 2] = 0;
+ HEAP32[3736] = (_time(0) | 0) & -16 ^ 1431655768;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ i20 = i12 + 48 | 0;
+ i25 = HEAP32[14952 >> 2] | 0;
+ i21 = i12 + 47 | 0;
+ i22 = i25 + i21 | 0;
+ i25 = 0 - i25 | 0;
+ i18 = i22 & i25;
+ if (!(i18 >>> 0 > i12 >>> 0)) {
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i24 = HEAP32[14912 >> 2] | 0;
+ if ((i24 | 0) != 0 ? (i31 = HEAP32[14904 >> 2] | 0, i32 = i31 + i18 | 0, i32 >>> 0 <= i31 >>> 0 | i32 >>> 0 > i24 >>> 0) : 0) {
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ L269 : do {
+ if ((HEAP32[14916 >> 2] & 4 | 0) == 0) {
+ i26 = HEAP32[14496 >> 2] | 0;
+ L271 : do {
+ if ((i26 | 0) != 0) {
+ i24 = 14920 | 0;
+ while (1) {
+ i27 = HEAP32[i24 >> 2] | 0;
+ if (!(i27 >>> 0 > i26 >>> 0) ? (i23 = i24 + 4 | 0, (i27 + (HEAP32[i23 >> 2] | 0) | 0) >>> 0 > i26 >>> 0) : 0) {
+ break;
+ }
+ i24 = HEAP32[i24 + 8 >> 2] | 0;
+ if ((i24 | 0) == 0) {
+ i13 = 182;
+ break L271;
+ }
+ }
+ if ((i24 | 0) != 0) {
+ i25 = i22 - (HEAP32[14484 >> 2] | 0) & i25;
+ if (i25 >>> 0 < 2147483647) {
+ i13 = _sbrk(i25 | 0) | 0;
+ i26 = (i13 | 0) == ((HEAP32[i24 >> 2] | 0) + (HEAP32[i23 >> 2] | 0) | 0);
+ i22 = i13;
+ i24 = i25;
+ i23 = i26 ? i13 : -1;
+ i25 = i26 ? i25 : 0;
+ i13 = 191;
+ } else {
+ i25 = 0;
+ }
+ } else {
+ i13 = 182;
+ }
+ } else {
+ i13 = 182;
+ }
+ } while (0);
+ do {
+ if ((i13 | 0) == 182) {
+ i23 = _sbrk(0) | 0;
+ if ((i23 | 0) != (-1 | 0)) {
+ i24 = i23;
+ i22 = HEAP32[14948 >> 2] | 0;
+ i25 = i22 + -1 | 0;
+ if ((i25 & i24 | 0) == 0) {
+ i25 = i18;
+ } else {
+ i25 = i18 - i24 + (i25 + i24 & 0 - i22) | 0;
+ }
+ i24 = HEAP32[14904 >> 2] | 0;
+ i26 = i24 + i25 | 0;
+ if (i25 >>> 0 > i12 >>> 0 & i25 >>> 0 < 2147483647) {
+ i22 = HEAP32[14912 >> 2] | 0;
+ if ((i22 | 0) != 0 ? i26 >>> 0 <= i24 >>> 0 | i26 >>> 0 > i22 >>> 0 : 0) {
+ i25 = 0;
+ break;
+ }
+ i22 = _sbrk(i25 | 0) | 0;
+ i13 = (i22 | 0) == (i23 | 0);
+ i24 = i25;
+ i23 = i13 ? i23 : -1;
+ i25 = i13 ? i25 : 0;
+ i13 = 191;
+ } else {
+ i25 = 0;
+ }
+ } else {
+ i25 = 0;
+ }
+ }
+ } while (0);
+ L291 : do {
+ if ((i13 | 0) == 191) {
+ i13 = 0 - i24 | 0;
+ if ((i23 | 0) != (-1 | 0)) {
+ i17 = i23;
+ i14 = i25;
+ i13 = 202;
+ break L269;
+ }
+ do {
+ if ((i22 | 0) != (-1 | 0) & i24 >>> 0 < 2147483647 & i24 >>> 0 < i20 >>> 0 ? (i19 = HEAP32[14952 >> 2] | 0, i19 = i21 - i24 + i19 & 0 - i19, i19 >>> 0 < 2147483647) : 0) {
+ if ((_sbrk(i19 | 0) | 0) == (-1 | 0)) {
+ _sbrk(i13 | 0) | 0;
+ break L291;
+ } else {
+ i24 = i19 + i24 | 0;
+ break;
+ }
+ }
+ } while (0);
+ if ((i22 | 0) != (-1 | 0)) {
+ i17 = i22;
+ i14 = i24;
+ i13 = 202;
+ break L269;
+ }
+ }
+ } while (0);
+ HEAP32[14916 >> 2] = HEAP32[14916 >> 2] | 4;
+ i13 = 199;
+ } else {
+ i25 = 0;
+ i13 = 199;
+ }
+ } while (0);
+ if ((((i13 | 0) == 199 ? i18 >>> 0 < 2147483647 : 0) ? (i17 = _sbrk(i18 | 0) | 0, i16 = _sbrk(0) | 0, (i16 | 0) != (-1 | 0) & (i17 | 0) != (-1 | 0) & i17 >>> 0 < i16 >>> 0) : 0) ? (i15 = i16 - i17 | 0, i14 = i15 >>> 0 > (i12 + 40 | 0) >>> 0, i14) : 0) {
+ i14 = i14 ? i15 : i25;
+ i13 = 202;
+ }
+ if ((i13 | 0) == 202) {
+ i15 = (HEAP32[14904 >> 2] | 0) + i14 | 0;
+ HEAP32[14904 >> 2] = i15;
+ if (i15 >>> 0 > (HEAP32[14908 >> 2] | 0) >>> 0) {
+ HEAP32[14908 >> 2] = i15;
+ }
+ i15 = HEAP32[14496 >> 2] | 0;
+ L311 : do {
+ if ((i15 | 0) != 0) {
+ i21 = 14920 | 0;
+ while (1) {
+ i16 = HEAP32[i21 >> 2] | 0;
+ i19 = i21 + 4 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i17 | 0) == (i16 + i20 | 0)) {
+ i13 = 214;
+ break;
+ }
+ i18 = HEAP32[i21 + 8 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ break;
+ } else {
+ i21 = i18;
+ }
+ }
+ if (((i13 | 0) == 214 ? (HEAP32[i21 + 12 >> 2] & 8 | 0) == 0 : 0) ? i15 >>> 0 >= i16 >>> 0 & i15 >>> 0 < i17 >>> 0 : 0) {
+ HEAP32[i19 >> 2] = i20 + i14;
+ i2 = (HEAP32[14484 >> 2] | 0) + i14 | 0;
+ i3 = i15 + 8 | 0;
+ if ((i3 & 7 | 0) == 0) {
+ i3 = 0;
+ } else {
+ i3 = 0 - i3 & 7;
+ }
+ i32 = i2 - i3 | 0;
+ HEAP32[14496 >> 2] = i15 + i3;
+ HEAP32[14484 >> 2] = i32;
+ HEAP32[i15 + (i3 + 4) >> 2] = i32 | 1;
+ HEAP32[i15 + (i2 + 4) >> 2] = 40;
+ HEAP32[14500 >> 2] = HEAP32[14960 >> 2];
+ break;
+ }
+ if (i17 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ HEAP32[14488 >> 2] = i17;
+ }
+ i19 = i17 + i14 | 0;
+ i16 = 14920 | 0;
+ while (1) {
+ if ((HEAP32[i16 >> 2] | 0) == (i19 | 0)) {
+ i13 = 224;
+ break;
+ }
+ i18 = HEAP32[i16 + 8 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ break;
+ } else {
+ i16 = i18;
+ }
+ }
+ if ((i13 | 0) == 224 ? (HEAP32[i16 + 12 >> 2] & 8 | 0) == 0 : 0) {
+ HEAP32[i16 >> 2] = i17;
+ i6 = i16 + 4 | 0;
+ HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + i14;
+ i6 = i17 + 8 | 0;
+ if ((i6 & 7 | 0) == 0) {
+ i6 = 0;
+ } else {
+ i6 = 0 - i6 & 7;
+ }
+ i7 = i17 + (i14 + 8) | 0;
+ if ((i7 & 7 | 0) == 0) {
+ i13 = 0;
+ } else {
+ i13 = 0 - i7 & 7;
+ }
+ i15 = i17 + (i13 + i14) | 0;
+ i8 = i6 + i12 | 0;
+ i7 = i17 + i8 | 0;
+ i10 = i15 - (i17 + i6) - i12 | 0;
+ HEAP32[i17 + (i6 + 4) >> 2] = i12 | 3;
+ L348 : do {
+ if ((i15 | 0) != (HEAP32[14496 >> 2] | 0)) {
+ if ((i15 | 0) == (HEAP32[14492 >> 2] | 0)) {
+ i32 = (HEAP32[14480 >> 2] | 0) + i10 | 0;
+ HEAP32[14480 >> 2] = i32;
+ HEAP32[14492 >> 2] = i7;
+ HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i32 + i8) >> 2] = i32;
+ break;
+ }
+ i12 = i14 + 4 | 0;
+ i18 = HEAP32[i17 + (i12 + i13) >> 2] | 0;
+ if ((i18 & 3 | 0) == 1) {
+ i11 = i18 & -8;
+ i16 = i18 >>> 3;
+ do {
+ if (!(i18 >>> 0 < 256)) {
+ i9 = HEAP32[i17 + ((i13 | 24) + i14) >> 2] | 0;
+ i19 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
+ do {
+ if ((i19 | 0) == (i15 | 0)) {
+ i19 = i13 | 16;
+ i18 = i17 + (i12 + i19) | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ if ((i16 | 0) == 0) {
+ i18 = i17 + (i19 + i14) | 0;
+ i16 = HEAP32[i18 >> 2] | 0;
+ if ((i16 | 0) == 0) {
+ i5 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i20 = i16 + 20 | 0;
+ i19 = HEAP32[i20 >> 2] | 0;
+ if ((i19 | 0) != 0) {
+ i16 = i19;
+ i18 = i20;
+ continue;
+ }
+ i19 = i16 + 16 | 0;
+ i20 = HEAP32[i19 >> 2] | 0;
+ if ((i20 | 0) == 0) {
+ break;
+ } else {
+ i16 = i20;
+ i18 = i19;
+ }
+ }
+ if (i18 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i18 >> 2] = 0;
+ i5 = i16;
+ break;
+ }
+ } else {
+ i18 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
+ if (i18 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i18 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != (i15 | 0)) {
+ _abort();
+ }
+ i20 = i19 + 8 | 0;
+ if ((HEAP32[i20 >> 2] | 0) == (i15 | 0)) {
+ HEAP32[i16 >> 2] = i19;
+ HEAP32[i20 >> 2] = i18;
+ i5 = i19;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i9 | 0) != 0) {
+ i16 = HEAP32[i17 + (i14 + 28 + i13) >> 2] | 0;
+ i18 = 14776 + (i16 << 2) | 0;
+ if ((i15 | 0) == (HEAP32[i18 >> 2] | 0)) {
+ HEAP32[i18 >> 2] = i5;
+ if ((i5 | 0) == 0) {
+ HEAP32[14476 >> 2] = HEAP32[14476 >> 2] & ~(1 << i16);
+ break;
+ }
+ } else {
+ if (i9 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i9 + 16 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
+ HEAP32[i16 >> 2] = i5;
+ } else {
+ HEAP32[i9 + 20 >> 2] = i5;
+ }
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i5 + 24 >> 2] = i9;
+ i15 = i13 | 16;
+ i9 = HEAP32[i17 + (i15 + i14) >> 2] | 0;
+ do {
+ if ((i9 | 0) != 0) {
+ if (i9 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 + 16 >> 2] = i9;
+ HEAP32[i9 + 24 >> 2] = i5;
+ break;
+ }
+ }
+ } while (0);
+ i9 = HEAP32[i17 + (i12 + i15) >> 2] | 0;
+ if ((i9 | 0) != 0) {
+ if (i9 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 + 20 >> 2] = i9;
+ HEAP32[i9 + 24 >> 2] = i5;
+ break;
+ }
+ }
+ }
+ } else {
+ i5 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
+ i12 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
+ i18 = 14512 + (i16 << 1 << 2) | 0;
+ if ((i5 | 0) != (i18 | 0)) {
+ if (i5 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i5 + 12 >> 2] | 0) != (i15 | 0)) {
+ _abort();
+ }
+ }
+ if ((i12 | 0) == (i5 | 0)) {
+ HEAP32[3618] = HEAP32[3618] & ~(1 << i16);
+ break;
+ }
+ if ((i12 | 0) != (i18 | 0)) {
+ if (i12 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i12 + 8 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
+ i9 = i16;
+ } else {
+ _abort();
+ }
+ } else {
+ i9 = i12 + 8 | 0;
+ }
+ HEAP32[i5 + 12 >> 2] = i12;
+ HEAP32[i9 >> 2] = i5;
+ }
+ } while (0);
+ i15 = i17 + ((i11 | i13) + i14) | 0;
+ i10 = i11 + i10 | 0;
+ }
+ i5 = i15 + 4 | 0;
+ HEAP32[i5 >> 2] = HEAP32[i5 >> 2] & -2;
+ HEAP32[i17 + (i8 + 4) >> 2] = i10 | 1;
+ HEAP32[i17 + (i10 + i8) >> 2] = i10;
+ i5 = i10 >>> 3;
+ if (i10 >>> 0 < 256) {
+ i10 = i5 << 1;
+ i2 = 14512 + (i10 << 2) | 0;
+ i9 = HEAP32[3618] | 0;
+ i5 = 1 << i5;
+ if ((i9 & i5 | 0) != 0) {
+ i9 = 14512 + (i10 + 2 << 2) | 0;
+ i5 = HEAP32[i9 >> 2] | 0;
+ if (i5 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i3 = i9;
+ i4 = i5;
+ }
+ } else {
+ HEAP32[3618] = i9 | i5;
+ i3 = 14512 + (i10 + 2 << 2) | 0;
+ i4 = i2;
+ }
+ HEAP32[i3 >> 2] = i7;
+ HEAP32[i4 + 12 >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i2;
+ break;
+ }
+ i3 = i10 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i10 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i10 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i4 = 14776 + (i3 << 2) | 0;
+ HEAP32[i17 + (i8 + 28) >> 2] = i3;
+ HEAP32[i17 + (i8 + 20) >> 2] = 0;
+ HEAP32[i17 + (i8 + 16) >> 2] = 0;
+ i9 = HEAP32[14476 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i9 & i5 | 0) == 0) {
+ HEAP32[14476 >> 2] = i9 | i5;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i17 + (i8 + 24) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i7;
+ break;
+ }
+ i4 = HEAP32[i4 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L444 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i10 | 0)) {
+ i3 = i10 << i3;
+ while (1) {
+ i5 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i9 = HEAP32[i5 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i9 + 4 >> 2] & -8 | 0) == (i10 | 0)) {
+ i2 = i9;
+ break L444;
+ } else {
+ i3 = i3 << 1;
+ i4 = i9;
+ }
+ }
+ if (i5 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i5 >> 2] = i7;
+ HEAP32[i17 + (i8 + 24) >> 2] = i4;
+ HEAP32[i17 + (i8 + 12) >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i7;
+ break L348;
+ }
+ } else {
+ i2 = i4;
+ }
+ } while (0);
+ i4 = i2 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i5 = HEAP32[14488 >> 2] | 0;
+ if (i2 >>> 0 < i5 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i5 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i7;
+ HEAP32[i4 >> 2] = i7;
+ HEAP32[i17 + (i8 + 8) >> 2] = i3;
+ HEAP32[i17 + (i8 + 12) >> 2] = i2;
+ HEAP32[i17 + (i8 + 24) >> 2] = 0;
+ break;
+ }
+ } else {
+ i32 = (HEAP32[14484 >> 2] | 0) + i10 | 0;
+ HEAP32[14484 >> 2] = i32;
+ HEAP32[14496 >> 2] = i7;
+ HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
+ }
+ } while (0);
+ i32 = i17 + (i6 | 8) | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ i3 = 14920 | 0;
+ while (1) {
+ i2 = HEAP32[i3 >> 2] | 0;
+ if (!(i2 >>> 0 > i15 >>> 0) ? (i11 = HEAP32[i3 + 4 >> 2] | 0, i10 = i2 + i11 | 0, i10 >>> 0 > i15 >>> 0) : 0) {
+ break;
+ }
+ i3 = HEAP32[i3 + 8 >> 2] | 0;
+ }
+ i3 = i2 + (i11 + -39) | 0;
+ if ((i3 & 7 | 0) == 0) {
+ i3 = 0;
+ } else {
+ i3 = 0 - i3 & 7;
+ }
+ i2 = i2 + (i11 + -47 + i3) | 0;
+ i2 = i2 >>> 0 < (i15 + 16 | 0) >>> 0 ? i15 : i2;
+ i3 = i2 + 8 | 0;
+ i4 = i17 + 8 | 0;
+ if ((i4 & 7 | 0) == 0) {
+ i4 = 0;
+ } else {
+ i4 = 0 - i4 & 7;
+ }
+ i32 = i14 + -40 - i4 | 0;
+ HEAP32[14496 >> 2] = i17 + i4;
+ HEAP32[14484 >> 2] = i32;
+ HEAP32[i17 + (i4 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i14 + -36) >> 2] = 40;
+ HEAP32[14500 >> 2] = HEAP32[14960 >> 2];
+ HEAP32[i2 + 4 >> 2] = 27;
+ HEAP32[i3 + 0 >> 2] = HEAP32[14920 >> 2];
+ HEAP32[i3 + 4 >> 2] = HEAP32[14924 >> 2];
+ HEAP32[i3 + 8 >> 2] = HEAP32[14928 >> 2];
+ HEAP32[i3 + 12 >> 2] = HEAP32[14932 >> 2];
+ HEAP32[14920 >> 2] = i17;
+ HEAP32[14924 >> 2] = i14;
+ HEAP32[14932 >> 2] = 0;
+ HEAP32[14928 >> 2] = i3;
+ i4 = i2 + 28 | 0;
+ HEAP32[i4 >> 2] = 7;
+ if ((i2 + 32 | 0) >>> 0 < i10 >>> 0) {
+ while (1) {
+ i3 = i4 + 4 | 0;
+ HEAP32[i3 >> 2] = 7;
+ if ((i4 + 8 | 0) >>> 0 < i10 >>> 0) {
+ i4 = i3;
+ } else {
+ break;
+ }
+ }
+ }
+ if ((i2 | 0) != (i15 | 0)) {
+ i2 = i2 - i15 | 0;
+ i3 = i15 + (i2 + 4) | 0;
+ HEAP32[i3 >> 2] = HEAP32[i3 >> 2] & -2;
+ HEAP32[i15 + 4 >> 2] = i2 | 1;
+ HEAP32[i15 + i2 >> 2] = i2;
+ i3 = i2 >>> 3;
+ if (i2 >>> 0 < 256) {
+ i4 = i3 << 1;
+ i2 = 14512 + (i4 << 2) | 0;
+ i5 = HEAP32[3618] | 0;
+ i3 = 1 << i3;
+ if ((i5 & i3 | 0) != 0) {
+ i4 = 14512 + (i4 + 2 << 2) | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ if (i3 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i7 = i4;
+ i8 = i3;
+ }
+ } else {
+ HEAP32[3618] = i5 | i3;
+ i7 = 14512 + (i4 + 2 << 2) | 0;
+ i8 = i2;
+ }
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i8 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i8;
+ HEAP32[i15 + 12 >> 2] = i2;
+ break;
+ }
+ i3 = i2 >>> 8;
+ if ((i3 | 0) != 0) {
+ if (i2 >>> 0 > 16777215) {
+ i3 = 31;
+ } else {
+ i31 = (i3 + 1048320 | 0) >>> 16 & 8;
+ i32 = i3 << i31;
+ i30 = (i32 + 520192 | 0) >>> 16 & 4;
+ i32 = i32 << i30;
+ i3 = (i32 + 245760 | 0) >>> 16 & 2;
+ i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
+ i3 = i2 >>> (i3 + 7 | 0) & 1 | i3 << 1;
+ }
+ } else {
+ i3 = 0;
+ }
+ i7 = 14776 + (i3 << 2) | 0;
+ HEAP32[i15 + 28 >> 2] = i3;
+ HEAP32[i15 + 20 >> 2] = 0;
+ HEAP32[i15 + 16 >> 2] = 0;
+ i4 = HEAP32[14476 >> 2] | 0;
+ i5 = 1 << i3;
+ if ((i4 & i5 | 0) == 0) {
+ HEAP32[14476 >> 2] = i4 | i5;
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i7;
+ HEAP32[i15 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i15;
+ break;
+ }
+ i4 = HEAP32[i7 >> 2] | 0;
+ if ((i3 | 0) == 31) {
+ i3 = 0;
+ } else {
+ i3 = 25 - (i3 >>> 1) | 0;
+ }
+ L499 : do {
+ if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i2 | 0)) {
+ i3 = i2 << i3;
+ while (1) {
+ i7 = i4 + (i3 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i2 | 0)) {
+ i6 = i5;
+ break L499;
+ } else {
+ i3 = i3 << 1;
+ i4 = i5;
+ }
+ }
+ if (i7 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i7 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i4;
+ HEAP32[i15 + 12 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i15;
+ break L311;
+ }
+ } else {
+ i6 = i4;
+ }
+ } while (0);
+ i4 = i6 + 8 | 0;
+ i3 = HEAP32[i4 >> 2] | 0;
+ i2 = HEAP32[14488 >> 2] | 0;
+ if (i6 >>> 0 < i2 >>> 0) {
+ _abort();
+ }
+ if (i3 >>> 0 < i2 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i3 + 12 >> 2] = i15;
+ HEAP32[i4 >> 2] = i15;
+ HEAP32[i15 + 8 >> 2] = i3;
+ HEAP32[i15 + 12 >> 2] = i6;
+ HEAP32[i15 + 24 >> 2] = 0;
+ break;
+ }
+ }
+ } else {
+ i32 = HEAP32[14488 >> 2] | 0;
+ if ((i32 | 0) == 0 | i17 >>> 0 < i32 >>> 0) {
+ HEAP32[14488 >> 2] = i17;
+ }
+ HEAP32[14920 >> 2] = i17;
+ HEAP32[14924 >> 2] = i14;
+ HEAP32[14932 >> 2] = 0;
+ HEAP32[14508 >> 2] = HEAP32[3736];
+ HEAP32[14504 >> 2] = -1;
+ i2 = 0;
+ do {
+ i32 = i2 << 1;
+ i31 = 14512 + (i32 << 2) | 0;
+ HEAP32[14512 + (i32 + 3 << 2) >> 2] = i31;
+ HEAP32[14512 + (i32 + 2 << 2) >> 2] = i31;
+ i2 = i2 + 1 | 0;
+ } while ((i2 | 0) != 32);
+ i2 = i17 + 8 | 0;
+ if ((i2 & 7 | 0) == 0) {
+ i2 = 0;
+ } else {
+ i2 = 0 - i2 & 7;
+ }
+ i32 = i14 + -40 - i2 | 0;
+ HEAP32[14496 >> 2] = i17 + i2;
+ HEAP32[14484 >> 2] = i32;
+ HEAP32[i17 + (i2 + 4) >> 2] = i32 | 1;
+ HEAP32[i17 + (i14 + -36) >> 2] = 40;
+ HEAP32[14500 >> 2] = HEAP32[14960 >> 2];
+ }
+ } while (0);
+ i2 = HEAP32[14484 >> 2] | 0;
+ if (i2 >>> 0 > i12 >>> 0) {
+ i31 = i2 - i12 | 0;
+ HEAP32[14484 >> 2] = i31;
+ i32 = HEAP32[14496 >> 2] | 0;
+ HEAP32[14496 >> 2] = i32 + i12;
+ HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
+ HEAP32[i32 + 4 >> 2] = i12 | 3;
+ i32 = i32 + 8 | 0;
+ STACKTOP = i1;
+ return i32 | 0;
+ }
+ }
+ HEAP32[(___errno_location() | 0) >> 2] = 12;
+ i32 = 0;
+ STACKTOP = i1;
+ return i32 | 0;
+}
+function _deflate(i2, i10) {
+ i2 = i2 | 0;
+ i10 = i10 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0, i37 = 0;
+ i1 = STACKTOP;
+ if ((i2 | 0) == 0) {
+ i37 = -2;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ i5 = i2 + 28 | 0;
+ i7 = HEAP32[i5 >> 2] | 0;
+ if ((i7 | 0) == 0 | i10 >>> 0 > 5) {
+ i37 = -2;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ i4 = i2 + 12 | 0;
+ do {
+ if ((HEAP32[i4 >> 2] | 0) != 0) {
+ if ((HEAP32[i2 >> 2] | 0) == 0 ? (HEAP32[i2 + 4 >> 2] | 0) != 0 : 0) {
+ break;
+ }
+ i11 = i7 + 4 | 0;
+ i29 = HEAP32[i11 >> 2] | 0;
+ i9 = (i10 | 0) == 4;
+ if ((i29 | 0) != 666 | i9) {
+ i3 = i2 + 16 | 0;
+ if ((HEAP32[i3 >> 2] | 0) == 0) {
+ HEAP32[i2 + 24 >> 2] = HEAP32[3180 >> 2];
+ i37 = -5;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ HEAP32[i7 >> 2] = i2;
+ i8 = i7 + 40 | 0;
+ i18 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i10;
+ do {
+ if ((i29 | 0) == 42) {
+ if ((HEAP32[i7 + 24 >> 2] | 0) != 2) {
+ i17 = (HEAP32[i7 + 48 >> 2] << 12) + -30720 | 0;
+ if ((HEAP32[i7 + 136 >> 2] | 0) <= 1 ? (i28 = HEAP32[i7 + 132 >> 2] | 0, (i28 | 0) >= 2) : 0) {
+ if ((i28 | 0) < 6) {
+ i28 = 64;
+ } else {
+ i28 = (i28 | 0) == 6 ? 128 : 192;
+ }
+ } else {
+ i28 = 0;
+ }
+ i28 = i28 | i17;
+ i17 = i7 + 108 | 0;
+ i37 = (HEAP32[i17 >> 2] | 0) == 0 ? i28 : i28 | 32;
+ HEAP32[i11 >> 2] = 113;
+ i29 = i7 + 20 | 0;
+ i30 = HEAP32[i29 >> 2] | 0;
+ HEAP32[i29 >> 2] = i30 + 1;
+ i28 = i7 + 8 | 0;
+ HEAP8[(HEAP32[i28 >> 2] | 0) + i30 | 0] = i37 >>> 8;
+ i30 = HEAP32[i29 >> 2] | 0;
+ HEAP32[i29 >> 2] = i30 + 1;
+ HEAP8[(HEAP32[i28 >> 2] | 0) + i30 | 0] = (i37 | ((i37 >>> 0) % 31 | 0)) ^ 31;
+ i30 = i2 + 48 | 0;
+ if ((HEAP32[i17 >> 2] | 0) != 0) {
+ i37 = HEAP32[i30 >> 2] | 0;
+ i36 = HEAP32[i29 >> 2] | 0;
+ HEAP32[i29 >> 2] = i36 + 1;
+ HEAP8[(HEAP32[i28 >> 2] | 0) + i36 | 0] = i37 >>> 24;
+ i36 = HEAP32[i29 >> 2] | 0;
+ HEAP32[i29 >> 2] = i36 + 1;
+ HEAP8[(HEAP32[i28 >> 2] | 0) + i36 | 0] = i37 >>> 16;
+ i36 = HEAP32[i30 >> 2] | 0;
+ i37 = HEAP32[i29 >> 2] | 0;
+ HEAP32[i29 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i28 >> 2] | 0) + i37 | 0] = i36 >>> 8;
+ i37 = HEAP32[i29 >> 2] | 0;
+ HEAP32[i29 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i28 >> 2] | 0) + i37 | 0] = i36;
+ }
+ HEAP32[i30 >> 2] = _adler32(0, 0, 0) | 0;
+ i31 = HEAP32[i11 >> 2] | 0;
+ i17 = 32;
+ break;
+ }
+ i32 = i2 + 48 | 0;
+ HEAP32[i32 >> 2] = _crc32(0, 0, 0) | 0;
+ i30 = i7 + 20 | 0;
+ i28 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i28 + 1;
+ i29 = i7 + 8 | 0;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i28 | 0] = 31;
+ i28 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i28 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i28 | 0] = -117;
+ i28 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i28 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i28 | 0] = 8;
+ i28 = i7 + 28 | 0;
+ i33 = HEAP32[i28 >> 2] | 0;
+ if ((i33 | 0) == 0) {
+ i22 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i22 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i22 | 0] = 0;
+ i22 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i22 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i22 | 0] = 0;
+ i22 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i22 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i22 | 0] = 0;
+ i22 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i22 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i22 | 0] = 0;
+ i22 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i22 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i22 | 0] = 0;
+ i22 = HEAP32[i7 + 132 >> 2] | 0;
+ if ((i22 | 0) != 9) {
+ if ((HEAP32[i7 + 136 >> 2] | 0) > 1) {
+ i22 = 4;
+ } else {
+ i22 = (i22 | 0) < 2 ? 4 : 0;
+ }
+ } else {
+ i22 = 2;
+ }
+ i37 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i37 | 0] = i22;
+ i37 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i37 | 0] = 3;
+ HEAP32[i11 >> 2] = 113;
+ break;
+ }
+ i37 = (((HEAP32[i33 + 44 >> 2] | 0) != 0 ? 2 : 0) | (HEAP32[i33 >> 2] | 0) != 0 | ((HEAP32[i33 + 16 >> 2] | 0) == 0 ? 0 : 4) | ((HEAP32[i33 + 28 >> 2] | 0) == 0 ? 0 : 8) | ((HEAP32[i33 + 36 >> 2] | 0) == 0 ? 0 : 16)) & 255;
+ i17 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i17 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i17 | 0] = i37;
+ i17 = HEAP32[(HEAP32[i28 >> 2] | 0) + 4 >> 2] & 255;
+ i37 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i37 | 0] = i17;
+ i37 = (HEAP32[(HEAP32[i28 >> 2] | 0) + 4 >> 2] | 0) >>> 8 & 255;
+ i17 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i17 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i17 | 0] = i37;
+ i17 = (HEAP32[(HEAP32[i28 >> 2] | 0) + 4 >> 2] | 0) >>> 16 & 255;
+ i37 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i37 | 0] = i17;
+ i37 = (HEAP32[(HEAP32[i28 >> 2] | 0) + 4 >> 2] | 0) >>> 24 & 255;
+ i17 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i17 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i17 | 0] = i37;
+ i17 = HEAP32[i7 + 132 >> 2] | 0;
+ if ((i17 | 0) != 9) {
+ if ((HEAP32[i7 + 136 >> 2] | 0) > 1) {
+ i17 = 4;
+ } else {
+ i17 = (i17 | 0) < 2 ? 4 : 0;
+ }
+ } else {
+ i17 = 2;
+ }
+ i37 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i37 | 0] = i17;
+ i37 = HEAP32[(HEAP32[i28 >> 2] | 0) + 12 >> 2] & 255;
+ i17 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i17 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i17 | 0] = i37;
+ i17 = HEAP32[i28 >> 2] | 0;
+ if ((HEAP32[i17 + 16 >> 2] | 0) != 0) {
+ i17 = HEAP32[i17 + 20 >> 2] & 255;
+ i37 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i37 | 0] = i17;
+ i37 = (HEAP32[(HEAP32[i28 >> 2] | 0) + 20 >> 2] | 0) >>> 8 & 255;
+ i17 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i17 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i17 | 0] = i37;
+ i17 = HEAP32[i28 >> 2] | 0;
+ }
+ if ((HEAP32[i17 + 44 >> 2] | 0) != 0) {
+ HEAP32[i32 >> 2] = _crc32(HEAP32[i32 >> 2] | 0, HEAP32[i29 >> 2] | 0, HEAP32[i30 >> 2] | 0) | 0;
+ }
+ HEAP32[i7 + 32 >> 2] = 0;
+ HEAP32[i11 >> 2] = 69;
+ i17 = 34;
+ } else {
+ i31 = i29;
+ i17 = 32;
+ }
+ } while (0);
+ if ((i17 | 0) == 32) {
+ if ((i31 | 0) == 69) {
+ i28 = i7 + 28 | 0;
+ i17 = 34;
+ } else {
+ i17 = 55;
+ }
+ }
+ do {
+ if ((i17 | 0) == 34) {
+ i37 = HEAP32[i28 >> 2] | 0;
+ if ((HEAP32[i37 + 16 >> 2] | 0) == 0) {
+ HEAP32[i11 >> 2] = 73;
+ i17 = 57;
+ break;
+ }
+ i29 = i7 + 20 | 0;
+ i34 = HEAP32[i29 >> 2] | 0;
+ i17 = i7 + 32 | 0;
+ i36 = HEAP32[i17 >> 2] | 0;
+ L55 : do {
+ if (i36 >>> 0 < (HEAP32[i37 + 20 >> 2] & 65535) >>> 0) {
+ i30 = i7 + 12 | 0;
+ i32 = i2 + 48 | 0;
+ i31 = i7 + 8 | 0;
+ i33 = i2 + 20 | 0;
+ i35 = i34;
+ while (1) {
+ if ((i35 | 0) == (HEAP32[i30 >> 2] | 0)) {
+ if ((HEAP32[i37 + 44 >> 2] | 0) != 0 & i35 >>> 0 > i34 >>> 0) {
+ HEAP32[i32 >> 2] = _crc32(HEAP32[i32 >> 2] | 0, (HEAP32[i31 >> 2] | 0) + i34 | 0, i35 - i34 | 0) | 0;
+ }
+ i34 = HEAP32[i5 >> 2] | 0;
+ i35 = HEAP32[i34 + 20 >> 2] | 0;
+ i36 = HEAP32[i3 >> 2] | 0;
+ i35 = i35 >>> 0 > i36 >>> 0 ? i36 : i35;
+ if ((i35 | 0) != 0 ? (_memcpy(HEAP32[i4 >> 2] | 0, HEAP32[i34 + 16 >> 2] | 0, i35 | 0) | 0, HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + i35, i27 = (HEAP32[i5 >> 2] | 0) + 16 | 0, HEAP32[i27 >> 2] = (HEAP32[i27 >> 2] | 0) + i35, HEAP32[i33 >> 2] = (HEAP32[i33 >> 2] | 0) + i35, HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) - i35, i27 = HEAP32[i5 >> 2] | 0, i36 = i27 + 20 | 0, i37 = HEAP32[i36 >> 2] | 0, HEAP32[i36 >> 2] = i37 - i35, (i37 | 0) == (i35 | 0)) : 0) {
+ HEAP32[i27 + 16 >> 2] = HEAP32[i27 + 8 >> 2];
+ }
+ i34 = HEAP32[i29 >> 2] | 0;
+ if ((i34 | 0) == (HEAP32[i30 >> 2] | 0)) {
+ break;
+ }
+ i37 = HEAP32[i28 >> 2] | 0;
+ i36 = HEAP32[i17 >> 2] | 0;
+ i35 = i34;
+ }
+ i36 = HEAP8[(HEAP32[i37 + 16 >> 2] | 0) + i36 | 0] | 0;
+ HEAP32[i29 >> 2] = i35 + 1;
+ HEAP8[(HEAP32[i31 >> 2] | 0) + i35 | 0] = i36;
+ i36 = (HEAP32[i17 >> 2] | 0) + 1 | 0;
+ HEAP32[i17 >> 2] = i36;
+ i37 = HEAP32[i28 >> 2] | 0;
+ if (!(i36 >>> 0 < (HEAP32[i37 + 20 >> 2] & 65535) >>> 0)) {
+ break L55;
+ }
+ i35 = HEAP32[i29 >> 2] | 0;
+ }
+ i37 = HEAP32[i28 >> 2] | 0;
+ }
+ } while (0);
+ if ((HEAP32[i37 + 44 >> 2] | 0) != 0 ? (i26 = HEAP32[i29 >> 2] | 0, i26 >>> 0 > i34 >>> 0) : 0) {
+ i37 = i2 + 48 | 0;
+ HEAP32[i37 >> 2] = _crc32(HEAP32[i37 >> 2] | 0, (HEAP32[i7 + 8 >> 2] | 0) + i34 | 0, i26 - i34 | 0) | 0;
+ i37 = HEAP32[i28 >> 2] | 0;
+ }
+ if ((HEAP32[i17 >> 2] | 0) == (HEAP32[i37 + 20 >> 2] | 0)) {
+ HEAP32[i17 >> 2] = 0;
+ HEAP32[i11 >> 2] = 73;
+ i17 = 57;
+ break;
+ } else {
+ i31 = HEAP32[i11 >> 2] | 0;
+ i17 = 55;
+ break;
+ }
+ }
+ } while (0);
+ if ((i17 | 0) == 55) {
+ if ((i31 | 0) == 73) {
+ i37 = HEAP32[i7 + 28 >> 2] | 0;
+ i17 = 57;
+ } else {
+ i17 = 76;
+ }
+ }
+ do {
+ if ((i17 | 0) == 57) {
+ i26 = i7 + 28 | 0;
+ if ((HEAP32[i37 + 28 >> 2] | 0) == 0) {
+ HEAP32[i11 >> 2] = 91;
+ i17 = 78;
+ break;
+ }
+ i27 = i7 + 20 | 0;
+ i35 = HEAP32[i27 >> 2] | 0;
+ i32 = i7 + 12 | 0;
+ i29 = i2 + 48 | 0;
+ i28 = i7 + 8 | 0;
+ i31 = i2 + 20 | 0;
+ i30 = i7 + 32 | 0;
+ i33 = i35;
+ while (1) {
+ if ((i33 | 0) == (HEAP32[i32 >> 2] | 0)) {
+ if ((HEAP32[(HEAP32[i26 >> 2] | 0) + 44 >> 2] | 0) != 0 & i33 >>> 0 > i35 >>> 0) {
+ HEAP32[i29 >> 2] = _crc32(HEAP32[i29 >> 2] | 0, (HEAP32[i28 >> 2] | 0) + i35 | 0, i33 - i35 | 0) | 0;
+ }
+ i33 = HEAP32[i5 >> 2] | 0;
+ i34 = HEAP32[i33 + 20 >> 2] | 0;
+ i35 = HEAP32[i3 >> 2] | 0;
+ i34 = i34 >>> 0 > i35 >>> 0 ? i35 : i34;
+ if ((i34 | 0) != 0 ? (_memcpy(HEAP32[i4 >> 2] | 0, HEAP32[i33 + 16 >> 2] | 0, i34 | 0) | 0, HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + i34, i25 = (HEAP32[i5 >> 2] | 0) + 16 | 0, HEAP32[i25 >> 2] = (HEAP32[i25 >> 2] | 0) + i34, HEAP32[i31 >> 2] = (HEAP32[i31 >> 2] | 0) + i34, HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) - i34, i25 = HEAP32[i5 >> 2] | 0, i36 = i25 + 20 | 0, i37 = HEAP32[i36 >> 2] | 0, HEAP32[i36 >> 2] = i37 - i34, (i37 | 0) == (i34 | 0)) : 0) {
+ HEAP32[i25 + 16 >> 2] = HEAP32[i25 + 8 >> 2];
+ }
+ i35 = HEAP32[i27 >> 2] | 0;
+ if ((i35 | 0) == (HEAP32[i32 >> 2] | 0)) {
+ i25 = 1;
+ break;
+ } else {
+ i33 = i35;
+ }
+ }
+ i34 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i34 + 1;
+ i34 = HEAP8[(HEAP32[(HEAP32[i26 >> 2] | 0) + 28 >> 2] | 0) + i34 | 0] | 0;
+ HEAP32[i27 >> 2] = i33 + 1;
+ HEAP8[(HEAP32[i28 >> 2] | 0) + i33 | 0] = i34;
+ if (i34 << 24 >> 24 == 0) {
+ i17 = 68;
+ break;
+ }
+ i33 = HEAP32[i27 >> 2] | 0;
+ }
+ if ((i17 | 0) == 68) {
+ i25 = i34 & 255;
+ }
+ if ((HEAP32[(HEAP32[i26 >> 2] | 0) + 44 >> 2] | 0) != 0 ? (i24 = HEAP32[i27 >> 2] | 0, i24 >>> 0 > i35 >>> 0) : 0) {
+ HEAP32[i29 >> 2] = _crc32(HEAP32[i29 >> 2] | 0, (HEAP32[i28 >> 2] | 0) + i35 | 0, i24 - i35 | 0) | 0;
+ }
+ if ((i25 | 0) == 0) {
+ HEAP32[i30 >> 2] = 0;
+ HEAP32[i11 >> 2] = 91;
+ i17 = 78;
+ break;
+ } else {
+ i31 = HEAP32[i11 >> 2] | 0;
+ i17 = 76;
+ break;
+ }
+ }
+ } while (0);
+ if ((i17 | 0) == 76) {
+ if ((i31 | 0) == 91) {
+ i26 = i7 + 28 | 0;
+ i17 = 78;
+ } else {
+ i17 = 97;
+ }
+ }
+ do {
+ if ((i17 | 0) == 78) {
+ if ((HEAP32[(HEAP32[i26 >> 2] | 0) + 36 >> 2] | 0) == 0) {
+ HEAP32[i11 >> 2] = 103;
+ i17 = 99;
+ break;
+ }
+ i24 = i7 + 20 | 0;
+ i32 = HEAP32[i24 >> 2] | 0;
+ i29 = i7 + 12 | 0;
+ i27 = i2 + 48 | 0;
+ i25 = i7 + 8 | 0;
+ i28 = i2 + 20 | 0;
+ i30 = i7 + 32 | 0;
+ i31 = i32;
+ while (1) {
+ if ((i31 | 0) == (HEAP32[i29 >> 2] | 0)) {
+ if ((HEAP32[(HEAP32[i26 >> 2] | 0) + 44 >> 2] | 0) != 0 & i31 >>> 0 > i32 >>> 0) {
+ HEAP32[i27 >> 2] = _crc32(HEAP32[i27 >> 2] | 0, (HEAP32[i25 >> 2] | 0) + i32 | 0, i31 - i32 | 0) | 0;
+ }
+ i31 = HEAP32[i5 >> 2] | 0;
+ i33 = HEAP32[i31 + 20 >> 2] | 0;
+ i32 = HEAP32[i3 >> 2] | 0;
+ i32 = i33 >>> 0 > i32 >>> 0 ? i32 : i33;
+ if ((i32 | 0) != 0 ? (_memcpy(HEAP32[i4 >> 2] | 0, HEAP32[i31 + 16 >> 2] | 0, i32 | 0) | 0, HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + i32, i23 = (HEAP32[i5 >> 2] | 0) + 16 | 0, HEAP32[i23 >> 2] = (HEAP32[i23 >> 2] | 0) + i32, HEAP32[i28 >> 2] = (HEAP32[i28 >> 2] | 0) + i32, HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) - i32, i23 = HEAP32[i5 >> 2] | 0, i36 = i23 + 20 | 0, i37 = HEAP32[i36 >> 2] | 0, HEAP32[i36 >> 2] = i37 - i32, (i37 | 0) == (i32 | 0)) : 0) {
+ HEAP32[i23 + 16 >> 2] = HEAP32[i23 + 8 >> 2];
+ }
+ i32 = HEAP32[i24 >> 2] | 0;
+ if ((i32 | 0) == (HEAP32[i29 >> 2] | 0)) {
+ i23 = 1;
+ break;
+ } else {
+ i31 = i32;
+ }
+ }
+ i33 = HEAP32[i30 >> 2] | 0;
+ HEAP32[i30 >> 2] = i33 + 1;
+ i33 = HEAP8[(HEAP32[(HEAP32[i26 >> 2] | 0) + 36 >> 2] | 0) + i33 | 0] | 0;
+ HEAP32[i24 >> 2] = i31 + 1;
+ HEAP8[(HEAP32[i25 >> 2] | 0) + i31 | 0] = i33;
+ if (i33 << 24 >> 24 == 0) {
+ i17 = 89;
+ break;
+ }
+ i31 = HEAP32[i24 >> 2] | 0;
+ }
+ if ((i17 | 0) == 89) {
+ i23 = i33 & 255;
+ }
+ if ((HEAP32[(HEAP32[i26 >> 2] | 0) + 44 >> 2] | 0) != 0 ? (i22 = HEAP32[i24 >> 2] | 0, i22 >>> 0 > i32 >>> 0) : 0) {
+ HEAP32[i27 >> 2] = _crc32(HEAP32[i27 >> 2] | 0, (HEAP32[i25 >> 2] | 0) + i32 | 0, i22 - i32 | 0) | 0;
+ }
+ if ((i23 | 0) == 0) {
+ HEAP32[i11 >> 2] = 103;
+ i17 = 99;
+ break;
+ } else {
+ i31 = HEAP32[i11 >> 2] | 0;
+ i17 = 97;
+ break;
+ }
+ }
+ } while (0);
+ if ((i17 | 0) == 97 ? (i31 | 0) == 103 : 0) {
+ i26 = i7 + 28 | 0;
+ i17 = 99;
+ }
+ do {
+ if ((i17 | 0) == 99) {
+ if ((HEAP32[(HEAP32[i26 >> 2] | 0) + 44 >> 2] | 0) == 0) {
+ HEAP32[i11 >> 2] = 113;
+ break;
+ }
+ i17 = i7 + 20 | 0;
+ i22 = i7 + 12 | 0;
+ if ((((HEAP32[i17 >> 2] | 0) + 2 | 0) >>> 0 > (HEAP32[i22 >> 2] | 0) >>> 0 ? (i20 = HEAP32[i5 >> 2] | 0, i21 = HEAP32[i20 + 20 >> 2] | 0, i23 = HEAP32[i3 >> 2] | 0, i21 = i21 >>> 0 > i23 >>> 0 ? i23 : i21, (i21 | 0) != 0) : 0) ? (_memcpy(HEAP32[i4 >> 2] | 0, HEAP32[i20 + 16 >> 2] | 0, i21 | 0) | 0, HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + i21, i19 = (HEAP32[i5 >> 2] | 0) + 16 | 0, HEAP32[i19 >> 2] = (HEAP32[i19 >> 2] | 0) + i21, i19 = i2 + 20 | 0, HEAP32[i19 >> 2] = (HEAP32[i19 >> 2] | 0) + i21, HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) - i21, i19 = HEAP32[i5 >> 2] | 0, i36 = i19 + 20 | 0, i37 = HEAP32[i36 >> 2] | 0, HEAP32[i36 >> 2] = i37 - i21, (i37 | 0) == (i21 | 0)) : 0) {
+ HEAP32[i19 + 16 >> 2] = HEAP32[i19 + 8 >> 2];
+ }
+ i19 = HEAP32[i17 >> 2] | 0;
+ if (!((i19 + 2 | 0) >>> 0 > (HEAP32[i22 >> 2] | 0) >>> 0)) {
+ i37 = i2 + 48 | 0;
+ i34 = HEAP32[i37 >> 2] & 255;
+ HEAP32[i17 >> 2] = i19 + 1;
+ i35 = i7 + 8 | 0;
+ HEAP8[(HEAP32[i35 >> 2] | 0) + i19 | 0] = i34;
+ i34 = (HEAP32[i37 >> 2] | 0) >>> 8 & 255;
+ i36 = HEAP32[i17 >> 2] | 0;
+ HEAP32[i17 >> 2] = i36 + 1;
+ HEAP8[(HEAP32[i35 >> 2] | 0) + i36 | 0] = i34;
+ HEAP32[i37 >> 2] = _crc32(0, 0, 0) | 0;
+ HEAP32[i11 >> 2] = 113;
+ }
+ }
+ } while (0);
+ i19 = i7 + 20 | 0;
+ if ((HEAP32[i19 >> 2] | 0) == 0) {
+ if ((HEAP32[i2 + 4 >> 2] | 0) == 0 ? (i18 | 0) >= (i10 | 0) & (i10 | 0) != 4 : 0) {
+ HEAP32[i2 + 24 >> 2] = HEAP32[3180 >> 2];
+ i37 = -5;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ } else {
+ i17 = HEAP32[i5 >> 2] | 0;
+ i20 = HEAP32[i17 + 20 >> 2] | 0;
+ i18 = HEAP32[i3 >> 2] | 0;
+ i20 = i20 >>> 0 > i18 >>> 0 ? i18 : i20;
+ if ((i20 | 0) != 0) {
+ _memcpy(HEAP32[i4 >> 2] | 0, HEAP32[i17 + 16 >> 2] | 0, i20 | 0) | 0;
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + i20;
+ i17 = (HEAP32[i5 >> 2] | 0) + 16 | 0;
+ HEAP32[i17 >> 2] = (HEAP32[i17 >> 2] | 0) + i20;
+ i17 = i2 + 20 | 0;
+ HEAP32[i17 >> 2] = (HEAP32[i17 >> 2] | 0) + i20;
+ HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) - i20;
+ i17 = HEAP32[i5 >> 2] | 0;
+ i36 = i17 + 20 | 0;
+ i37 = HEAP32[i36 >> 2] | 0;
+ HEAP32[i36 >> 2] = i37 - i20;
+ if ((i37 | 0) == (i20 | 0)) {
+ HEAP32[i17 + 16 >> 2] = HEAP32[i17 + 8 >> 2];
+ }
+ i18 = HEAP32[i3 >> 2] | 0;
+ }
+ if ((i18 | 0) == 0) {
+ HEAP32[i8 >> 2] = -1;
+ i37 = 0;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ }
+ i18 = (HEAP32[i11 >> 2] | 0) == 666;
+ i17 = (HEAP32[i2 + 4 >> 2] | 0) == 0;
+ if (i18) {
+ if (i17) {
+ i17 = 121;
+ } else {
+ HEAP32[i2 + 24 >> 2] = HEAP32[3180 >> 2];
+ i37 = -5;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ } else {
+ if (i17) {
+ i17 = 121;
+ } else {
+ i17 = 124;
+ }
+ }
+ do {
+ if ((i17 | 0) == 121) {
+ if ((HEAP32[i7 + 116 >> 2] | 0) == 0) {
+ if ((i10 | 0) != 0) {
+ if (i18) {
+ break;
+ } else {
+ i17 = 124;
+ break;
+ }
+ } else {
+ i37 = 0;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ } else {
+ i17 = 124;
+ }
+ }
+ } while (0);
+ do {
+ if ((i17 | 0) == 124) {
+ i18 = HEAP32[i7 + 136 >> 2] | 0;
+ L185 : do {
+ if ((i18 | 0) == 2) {
+ i22 = i7 + 116 | 0;
+ i18 = i7 + 96 | 0;
+ i13 = i7 + 108 | 0;
+ i14 = i7 + 56 | 0;
+ i21 = i7 + 5792 | 0;
+ i20 = i7 + 5796 | 0;
+ i24 = i7 + 5784 | 0;
+ i23 = i7 + 5788 | 0;
+ i12 = i7 + 92 | 0;
+ while (1) {
+ if ((HEAP32[i22 >> 2] | 0) == 0 ? (_fill_window(i7), (HEAP32[i22 >> 2] | 0) == 0) : 0) {
+ break;
+ }
+ HEAP32[i18 >> 2] = 0;
+ i37 = HEAP8[(HEAP32[i14 >> 2] | 0) + (HEAP32[i13 >> 2] | 0) | 0] | 0;
+ i26 = HEAP32[i21 >> 2] | 0;
+ HEAP16[(HEAP32[i20 >> 2] | 0) + (i26 << 1) >> 1] = 0;
+ HEAP32[i21 >> 2] = i26 + 1;
+ HEAP8[(HEAP32[i24 >> 2] | 0) + i26 | 0] = i37;
+ i37 = i7 + ((i37 & 255) << 2) + 148 | 0;
+ HEAP16[i37 >> 1] = (HEAP16[i37 >> 1] | 0) + 1 << 16 >> 16;
+ i37 = (HEAP32[i21 >> 2] | 0) == ((HEAP32[i23 >> 2] | 0) + -1 | 0);
+ HEAP32[i22 >> 2] = (HEAP32[i22 >> 2] | 0) + -1;
+ i26 = (HEAP32[i13 >> 2] | 0) + 1 | 0;
+ HEAP32[i13 >> 2] = i26;
+ if (!i37) {
+ continue;
+ }
+ i25 = HEAP32[i12 >> 2] | 0;
+ if ((i25 | 0) > -1) {
+ i27 = (HEAP32[i14 >> 2] | 0) + i25 | 0;
+ } else {
+ i27 = 0;
+ }
+ __tr_flush_block(i7, i27, i26 - i25 | 0, 0);
+ HEAP32[i12 >> 2] = HEAP32[i13 >> 2];
+ i26 = HEAP32[i7 >> 2] | 0;
+ i25 = i26 + 28 | 0;
+ i27 = HEAP32[i25 >> 2] | 0;
+ i30 = HEAP32[i27 + 20 >> 2] | 0;
+ i28 = i26 + 16 | 0;
+ i29 = HEAP32[i28 >> 2] | 0;
+ i29 = i30 >>> 0 > i29 >>> 0 ? i29 : i30;
+ if ((i29 | 0) != 0 ? (i16 = i26 + 12 | 0, _memcpy(HEAP32[i16 >> 2] | 0, HEAP32[i27 + 16 >> 2] | 0, i29 | 0) | 0, HEAP32[i16 >> 2] = (HEAP32[i16 >> 2] | 0) + i29, i16 = (HEAP32[i25 >> 2] | 0) + 16 | 0, HEAP32[i16 >> 2] = (HEAP32[i16 >> 2] | 0) + i29, i16 = i26 + 20 | 0, HEAP32[i16 >> 2] = (HEAP32[i16 >> 2] | 0) + i29, HEAP32[i28 >> 2] = (HEAP32[i28 >> 2] | 0) - i29, i16 = HEAP32[i25 >> 2] | 0, i36 = i16 + 20 | 0, i37 = HEAP32[i36 >> 2] | 0, HEAP32[i36 >> 2] = i37 - i29, (i37 | 0) == (i29 | 0)) : 0) {
+ HEAP32[i16 + 16 >> 2] = HEAP32[i16 + 8 >> 2];
+ }
+ if ((HEAP32[(HEAP32[i7 >> 2] | 0) + 16 >> 2] | 0) == 0) {
+ break L185;
+ }
+ }
+ if ((i10 | 0) != 0) {
+ i16 = HEAP32[i12 >> 2] | 0;
+ if ((i16 | 0) > -1) {
+ i14 = (HEAP32[i14 >> 2] | 0) + i16 | 0;
+ } else {
+ i14 = 0;
+ }
+ __tr_flush_block(i7, i14, (HEAP32[i13 >> 2] | 0) - i16 | 0, i9 & 1);
+ HEAP32[i12 >> 2] = HEAP32[i13 >> 2];
+ i14 = HEAP32[i7 >> 2] | 0;
+ i13 = i14 + 28 | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ i17 = HEAP32[i12 + 20 >> 2] | 0;
+ i16 = i14 + 16 | 0;
+ i18 = HEAP32[i16 >> 2] | 0;
+ i17 = i17 >>> 0 > i18 >>> 0 ? i18 : i17;
+ if ((i17 | 0) != 0 ? (i15 = i14 + 12 | 0, _memcpy(HEAP32[i15 >> 2] | 0, HEAP32[i12 + 16 >> 2] | 0, i17 | 0) | 0, HEAP32[i15 >> 2] = (HEAP32[i15 >> 2] | 0) + i17, i15 = (HEAP32[i13 >> 2] | 0) + 16 | 0, HEAP32[i15 >> 2] = (HEAP32[i15 >> 2] | 0) + i17, i15 = i14 + 20 | 0, HEAP32[i15 >> 2] = (HEAP32[i15 >> 2] | 0) + i17, HEAP32[i16 >> 2] = (HEAP32[i16 >> 2] | 0) - i17, i15 = HEAP32[i13 >> 2] | 0, i36 = i15 + 20 | 0, i37 = HEAP32[i36 >> 2] | 0, HEAP32[i36 >> 2] = i37 - i17, (i37 | 0) == (i17 | 0)) : 0) {
+ HEAP32[i15 + 16 >> 2] = HEAP32[i15 + 8 >> 2];
+ }
+ if ((HEAP32[(HEAP32[i7 >> 2] | 0) + 16 >> 2] | 0) == 0) {
+ i12 = i9 ? 2 : 0;
+ i17 = 183;
+ break;
+ } else {
+ i12 = i9 ? 3 : 1;
+ i17 = 183;
+ break;
+ }
+ }
+ } else if ((i18 | 0) == 3) {
+ i27 = i7 + 116 | 0;
+ i26 = (i10 | 0) == 0;
+ i22 = i7 + 96 | 0;
+ i15 = i7 + 108 | 0;
+ i20 = i7 + 5792 | 0;
+ i24 = i7 + 5796 | 0;
+ i23 = i7 + 5784 | 0;
+ i21 = i7 + (HEAPU8[296] << 2) + 2440 | 0;
+ i25 = i7 + 5788 | 0;
+ i18 = i7 + 56 | 0;
+ i16 = i7 + 92 | 0;
+ while (1) {
+ i29 = HEAP32[i27 >> 2] | 0;
+ if (i29 >>> 0 < 258) {
+ _fill_window(i7);
+ i29 = HEAP32[i27 >> 2] | 0;
+ if (i29 >>> 0 < 258 & i26) {
+ break L185;
+ }
+ if ((i29 | 0) == 0) {
+ break;
+ }
+ HEAP32[i22 >> 2] = 0;
+ if (i29 >>> 0 > 2) {
+ i17 = 151;
+ } else {
+ i28 = HEAP32[i15 >> 2] | 0;
+ i17 = 166;
+ }
+ } else {
+ HEAP32[i22 >> 2] = 0;
+ i17 = 151;
+ }
+ if ((i17 | 0) == 151) {
+ i17 = 0;
+ i28 = HEAP32[i15 >> 2] | 0;
+ if ((i28 | 0) != 0) {
+ i31 = HEAP32[i18 >> 2] | 0;
+ i30 = HEAP8[i31 + (i28 + -1) | 0] | 0;
+ if ((i30 << 24 >> 24 == (HEAP8[i31 + i28 | 0] | 0) ? i30 << 24 >> 24 == (HEAP8[i31 + (i28 + 1) | 0] | 0) : 0) ? (i14 = i31 + (i28 + 2) | 0, i30 << 24 >> 24 == (HEAP8[i14] | 0)) : 0) {
+ i31 = i31 + (i28 + 258) | 0;
+ i32 = i14;
+ do {
+ i33 = i32 + 1 | 0;
+ if (!(i30 << 24 >> 24 == (HEAP8[i33] | 0))) {
+ i32 = i33;
+ break;
+ }
+ i33 = i32 + 2 | 0;
+ if (!(i30 << 24 >> 24 == (HEAP8[i33] | 0))) {
+ i32 = i33;
+ break;
+ }
+ i33 = i32 + 3 | 0;
+ if (!(i30 << 24 >> 24 == (HEAP8[i33] | 0))) {
+ i32 = i33;
+ break;
+ }
+ i33 = i32 + 4 | 0;
+ if (!(i30 << 24 >> 24 == (HEAP8[i33] | 0))) {
+ i32 = i33;
+ break;
+ }
+ i33 = i32 + 5 | 0;
+ if (!(i30 << 24 >> 24 == (HEAP8[i33] | 0))) {
+ i32 = i33;
+ break;
+ }
+ i33 = i32 + 6 | 0;
+ if (!(i30 << 24 >> 24 == (HEAP8[i33] | 0))) {
+ i32 = i33;
+ break;
+ }
+ i33 = i32 + 7 | 0;
+ if (!(i30 << 24 >> 24 == (HEAP8[i33] | 0))) {
+ i32 = i33;
+ break;
+ }
+ i32 = i32 + 8 | 0;
+ } while (i30 << 24 >> 24 == (HEAP8[i32] | 0) & i32 >>> 0 < i31 >>> 0);
+ i30 = i32 - i31 + 258 | 0;
+ i29 = i30 >>> 0 > i29 >>> 0 ? i29 : i30;
+ HEAP32[i22 >> 2] = i29;
+ if (i29 >>> 0 > 2) {
+ i29 = i29 + 253 | 0;
+ i28 = HEAP32[i20 >> 2] | 0;
+ HEAP16[(HEAP32[i24 >> 2] | 0) + (i28 << 1) >> 1] = 1;
+ HEAP32[i20 >> 2] = i28 + 1;
+ HEAP8[(HEAP32[i23 >> 2] | 0) + i28 | 0] = i29;
+ i29 = i7 + ((HEAPU8[808 + (i29 & 255) | 0] | 256) + 1 << 2) + 148 | 0;
+ HEAP16[i29 >> 1] = (HEAP16[i29 >> 1] | 0) + 1 << 16 >> 16;
+ HEAP16[i21 >> 1] = (HEAP16[i21 >> 1] | 0) + 1 << 16 >> 16;
+ i29 = (HEAP32[i20 >> 2] | 0) == ((HEAP32[i25 >> 2] | 0) + -1 | 0) | 0;
+ i28 = HEAP32[i22 >> 2] | 0;
+ HEAP32[i27 >> 2] = (HEAP32[i27 >> 2] | 0) - i28;
+ i28 = (HEAP32[i15 >> 2] | 0) + i28 | 0;
+ HEAP32[i15 >> 2] = i28;
+ HEAP32[i22 >> 2] = 0;
+ } else {
+ i17 = 166;
+ }
+ } else {
+ i17 = 166;
+ }
+ } else {
+ i28 = 0;
+ i17 = 166;
+ }
+ }
+ if ((i17 | 0) == 166) {
+ i17 = 0;
+ i29 = HEAP8[(HEAP32[i18 >> 2] | 0) + i28 | 0] | 0;
+ i28 = HEAP32[i20 >> 2] | 0;
+ HEAP16[(HEAP32[i24 >> 2] | 0) + (i28 << 1) >> 1] = 0;
+ HEAP32[i20 >> 2] = i28 + 1;
+ HEAP8[(HEAP32[i23 >> 2] | 0) + i28 | 0] = i29;
+ i29 = i7 + ((i29 & 255) << 2) + 148 | 0;
+ HEAP16[i29 >> 1] = (HEAP16[i29 >> 1] | 0) + 1 << 16 >> 16;
+ i29 = (HEAP32[i20 >> 2] | 0) == ((HEAP32[i25 >> 2] | 0) + -1 | 0) | 0;
+ HEAP32[i27 >> 2] = (HEAP32[i27 >> 2] | 0) + -1;
+ i28 = (HEAP32[i15 >> 2] | 0) + 1 | 0;
+ HEAP32[i15 >> 2] = i28;
+ }
+ if ((i29 | 0) == 0) {
+ continue;
+ }
+ i29 = HEAP32[i16 >> 2] | 0;
+ if ((i29 | 0) > -1) {
+ i30 = (HEAP32[i18 >> 2] | 0) + i29 | 0;
+ } else {
+ i30 = 0;
+ }
+ __tr_flush_block(i7, i30, i28 - i29 | 0, 0);
+ HEAP32[i16 >> 2] = HEAP32[i15 >> 2];
+ i30 = HEAP32[i7 >> 2] | 0;
+ i28 = i30 + 28 | 0;
+ i29 = HEAP32[i28 >> 2] | 0;
+ i33 = HEAP32[i29 + 20 >> 2] | 0;
+ i31 = i30 + 16 | 0;
+ i32 = HEAP32[i31 >> 2] | 0;
+ i32 = i33 >>> 0 > i32 >>> 0 ? i32 : i33;
+ if ((i32 | 0) != 0 ? (i13 = i30 + 12 | 0, _memcpy(HEAP32[i13 >> 2] | 0, HEAP32[i29 + 16 >> 2] | 0, i32 | 0) | 0, HEAP32[i13 >> 2] = (HEAP32[i13 >> 2] | 0) + i32, i13 = (HEAP32[i28 >> 2] | 0) + 16 | 0, HEAP32[i13 >> 2] = (HEAP32[i13 >> 2] | 0) + i32, i13 = i30 + 20 | 0, HEAP32[i13 >> 2] = (HEAP32[i13 >> 2] | 0) + i32, HEAP32[i31 >> 2] = (HEAP32[i31 >> 2] | 0) - i32, i13 = HEAP32[i28 >> 2] | 0, i36 = i13 + 20 | 0, i37 = HEAP32[i36 >> 2] | 0, HEAP32[i36 >> 2] = i37 - i32, (i37 | 0) == (i32 | 0)) : 0) {
+ HEAP32[i13 + 16 >> 2] = HEAP32[i13 + 8 >> 2];
+ }
+ if ((HEAP32[(HEAP32[i7 >> 2] | 0) + 16 >> 2] | 0) == 0) {
+ break L185;
+ }
+ }
+ i13 = HEAP32[i16 >> 2] | 0;
+ if ((i13 | 0) > -1) {
+ i14 = (HEAP32[i18 >> 2] | 0) + i13 | 0;
+ } else {
+ i14 = 0;
+ }
+ __tr_flush_block(i7, i14, (HEAP32[i15 >> 2] | 0) - i13 | 0, i9 & 1);
+ HEAP32[i16 >> 2] = HEAP32[i15 >> 2];
+ i14 = HEAP32[i7 >> 2] | 0;
+ i16 = i14 + 28 | 0;
+ i15 = HEAP32[i16 >> 2] | 0;
+ i18 = HEAP32[i15 + 20 >> 2] | 0;
+ i13 = i14 + 16 | 0;
+ i17 = HEAP32[i13 >> 2] | 0;
+ i17 = i18 >>> 0 > i17 >>> 0 ? i17 : i18;
+ if ((i17 | 0) != 0 ? (i12 = i14 + 12 | 0, _memcpy(HEAP32[i12 >> 2] | 0, HEAP32[i15 + 16 >> 2] | 0, i17 | 0) | 0, HEAP32[i12 >> 2] = (HEAP32[i12 >> 2] | 0) + i17, i12 = (HEAP32[i16 >> 2] | 0) + 16 | 0, HEAP32[i12 >> 2] = (HEAP32[i12 >> 2] | 0) + i17, i12 = i14 + 20 | 0, HEAP32[i12 >> 2] = (HEAP32[i12 >> 2] | 0) + i17, HEAP32[i13 >> 2] = (HEAP32[i13 >> 2] | 0) - i17, i12 = HEAP32[i16 >> 2] | 0, i36 = i12 + 20 | 0, i37 = HEAP32[i36 >> 2] | 0, HEAP32[i36 >> 2] = i37 - i17, (i37 | 0) == (i17 | 0)) : 0) {
+ HEAP32[i12 + 16 >> 2] = HEAP32[i12 + 8 >> 2];
+ }
+ if ((HEAP32[(HEAP32[i7 >> 2] | 0) + 16 >> 2] | 0) == 0) {
+ i12 = i9 ? 2 : 0;
+ i17 = 183;
+ break;
+ } else {
+ i12 = i9 ? 3 : 1;
+ i17 = 183;
+ break;
+ }
+ } else {
+ i12 = FUNCTION_TABLE_iii[HEAP32[184 + ((HEAP32[i7 + 132 >> 2] | 0) * 12 | 0) >> 2] & 3](i7, i10) | 0;
+ i17 = 183;
+ }
+ } while (0);
+ if ((i17 | 0) == 183) {
+ if ((i12 & -2 | 0) == 2) {
+ HEAP32[i11 >> 2] = 666;
+ }
+ if ((i12 & -3 | 0) != 0) {
+ if ((i12 | 0) != 1) {
+ break;
+ }
+ if ((i10 | 0) == 1) {
+ __tr_align(i7);
+ } else if (((i10 | 0) != 5 ? (__tr_stored_block(i7, 0, 0, 0), (i10 | 0) == 3) : 0) ? (i37 = HEAP32[i7 + 76 >> 2] | 0, i36 = HEAP32[i7 + 68 >> 2] | 0, HEAP16[i36 + (i37 + -1 << 1) >> 1] = 0, _memset(i36 | 0, 0, (i37 << 1) + -2 | 0) | 0, (HEAP32[i7 + 116 >> 2] | 0) == 0) : 0) {
+ HEAP32[i7 + 108 >> 2] = 0;
+ HEAP32[i7 + 92 >> 2] = 0;
+ }
+ i11 = HEAP32[i5 >> 2] | 0;
+ i12 = HEAP32[i11 + 20 >> 2] | 0;
+ i10 = HEAP32[i3 >> 2] | 0;
+ i12 = i12 >>> 0 > i10 >>> 0 ? i10 : i12;
+ if ((i12 | 0) != 0) {
+ _memcpy(HEAP32[i4 >> 2] | 0, HEAP32[i11 + 16 >> 2] | 0, i12 | 0) | 0;
+ HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + i12;
+ i10 = (HEAP32[i5 >> 2] | 0) + 16 | 0;
+ HEAP32[i10 >> 2] = (HEAP32[i10 >> 2] | 0) + i12;
+ i10 = i2 + 20 | 0;
+ HEAP32[i10 >> 2] = (HEAP32[i10 >> 2] | 0) + i12;
+ HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) - i12;
+ i10 = HEAP32[i5 >> 2] | 0;
+ i36 = i10 + 20 | 0;
+ i37 = HEAP32[i36 >> 2] | 0;
+ HEAP32[i36 >> 2] = i37 - i12;
+ if ((i37 | 0) == (i12 | 0)) {
+ HEAP32[i10 + 16 >> 2] = HEAP32[i10 + 8 >> 2];
+ }
+ i10 = HEAP32[i3 >> 2] | 0;
+ }
+ if ((i10 | 0) != 0) {
+ break;
+ }
+ HEAP32[i8 >> 2] = -1;
+ i37 = 0;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ }
+ if ((HEAP32[i3 >> 2] | 0) != 0) {
+ i37 = 0;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ HEAP32[i8 >> 2] = -1;
+ i37 = 0;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ } while (0);
+ if (!i9) {
+ i37 = 0;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ i8 = i7 + 24 | 0;
+ i10 = HEAP32[i8 >> 2] | 0;
+ if ((i10 | 0) < 1) {
+ i37 = 1;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ i11 = i2 + 48 | 0;
+ i9 = HEAP32[i11 >> 2] | 0;
+ if ((i10 | 0) == 2) {
+ i34 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i34 + 1;
+ i36 = i7 + 8 | 0;
+ HEAP8[(HEAP32[i36 >> 2] | 0) + i34 | 0] = i9;
+ i34 = (HEAP32[i11 >> 2] | 0) >>> 8 & 255;
+ i35 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i35 + 1;
+ HEAP8[(HEAP32[i36 >> 2] | 0) + i35 | 0] = i34;
+ i35 = (HEAP32[i11 >> 2] | 0) >>> 16 & 255;
+ i34 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i34 + 1;
+ HEAP8[(HEAP32[i36 >> 2] | 0) + i34 | 0] = i35;
+ i34 = (HEAP32[i11 >> 2] | 0) >>> 24 & 255;
+ i35 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i35 + 1;
+ HEAP8[(HEAP32[i36 >> 2] | 0) + i35 | 0] = i34;
+ i35 = i2 + 8 | 0;
+ i34 = HEAP32[i35 >> 2] & 255;
+ i37 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i36 >> 2] | 0) + i37 | 0] = i34;
+ i37 = (HEAP32[i35 >> 2] | 0) >>> 8 & 255;
+ i34 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i34 + 1;
+ HEAP8[(HEAP32[i36 >> 2] | 0) + i34 | 0] = i37;
+ i34 = (HEAP32[i35 >> 2] | 0) >>> 16 & 255;
+ i37 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i36 >> 2] | 0) + i37 | 0] = i34;
+ i35 = (HEAP32[i35 >> 2] | 0) >>> 24 & 255;
+ i37 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i36 >> 2] | 0) + i37 | 0] = i35;
+ } else {
+ i35 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i35 + 1;
+ i36 = i7 + 8 | 0;
+ HEAP8[(HEAP32[i36 >> 2] | 0) + i35 | 0] = i9 >>> 24;
+ i35 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i35 + 1;
+ HEAP8[(HEAP32[i36 >> 2] | 0) + i35 | 0] = i9 >>> 16;
+ i35 = HEAP32[i11 >> 2] | 0;
+ i37 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i36 >> 2] | 0) + i37 | 0] = i35 >>> 8;
+ i37 = HEAP32[i19 >> 2] | 0;
+ HEAP32[i19 >> 2] = i37 + 1;
+ HEAP8[(HEAP32[i36 >> 2] | 0) + i37 | 0] = i35;
+ }
+ i7 = HEAP32[i5 >> 2] | 0;
+ i10 = HEAP32[i7 + 20 >> 2] | 0;
+ i9 = HEAP32[i3 >> 2] | 0;
+ i9 = i10 >>> 0 > i9 >>> 0 ? i9 : i10;
+ if ((i9 | 0) != 0 ? (_memcpy(HEAP32[i4 >> 2] | 0, HEAP32[i7 + 16 >> 2] | 0, i9 | 0) | 0, HEAP32[i4 >> 2] = (HEAP32[i4 >> 2] | 0) + i9, i6 = (HEAP32[i5 >> 2] | 0) + 16 | 0, HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + i9, i6 = i2 + 20 | 0, HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + i9, HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) - i9, i6 = HEAP32[i5 >> 2] | 0, i36 = i6 + 20 | 0, i37 = HEAP32[i36 >> 2] | 0, HEAP32[i36 >> 2] = i37 - i9, (i37 | 0) == (i9 | 0)) : 0) {
+ HEAP32[i6 + 16 >> 2] = HEAP32[i6 + 8 >> 2];
+ }
+ i2 = HEAP32[i8 >> 2] | 0;
+ if ((i2 | 0) > 0) {
+ HEAP32[i8 >> 2] = 0 - i2;
+ }
+ i37 = (HEAP32[i19 >> 2] | 0) == 0 | 0;
+ STACKTOP = i1;
+ return i37 | 0;
+ }
+ }
+ } while (0);
+ HEAP32[i2 + 24 >> 2] = HEAP32[3168 >> 2];
+ i37 = -2;
+ STACKTOP = i1;
+ return i37 | 0;
+}
+function _free(i7) {
+ i7 = i7 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0;
+ i1 = STACKTOP;
+ if ((i7 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i15 = i7 + -8 | 0;
+ i16 = HEAP32[14488 >> 2] | 0;
+ if (i15 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i13 = HEAP32[i7 + -4 >> 2] | 0;
+ i12 = i13 & 3;
+ if ((i12 | 0) == 1) {
+ _abort();
+ }
+ i8 = i13 & -8;
+ i6 = i7 + (i8 + -8) | 0;
+ do {
+ if ((i13 & 1 | 0) == 0) {
+ i19 = HEAP32[i15 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i15 = -8 - i19 | 0;
+ i13 = i7 + i15 | 0;
+ i12 = i19 + i8 | 0;
+ if (i13 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ if ((i13 | 0) == (HEAP32[14492 >> 2] | 0)) {
+ i2 = i7 + (i8 + -4) | 0;
+ if ((HEAP32[i2 >> 2] & 3 | 0) != 3) {
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ HEAP32[14480 >> 2] = i12;
+ HEAP32[i2 >> 2] = HEAP32[i2 >> 2] & -2;
+ HEAP32[i7 + (i15 + 4) >> 2] = i12 | 1;
+ HEAP32[i6 >> 2] = i12;
+ STACKTOP = i1;
+ return;
+ }
+ i18 = i19 >>> 3;
+ if (i19 >>> 0 < 256) {
+ i2 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
+ i11 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
+ i14 = 14512 + (i18 << 1 << 2) | 0;
+ if ((i2 | 0) != (i14 | 0)) {
+ if (i2 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i2 + 12 >> 2] | 0) != (i13 | 0)) {
+ _abort();
+ }
+ }
+ if ((i11 | 0) == (i2 | 0)) {
+ HEAP32[3618] = HEAP32[3618] & ~(1 << i18);
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ if ((i11 | 0) != (i14 | 0)) {
+ if (i11 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i14 = i11 + 8 | 0;
+ if ((HEAP32[i14 >> 2] | 0) == (i13 | 0)) {
+ i17 = i14;
+ } else {
+ _abort();
+ }
+ } else {
+ i17 = i11 + 8 | 0;
+ }
+ HEAP32[i2 + 12 >> 2] = i11;
+ HEAP32[i17 >> 2] = i2;
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ i17 = HEAP32[i7 + (i15 + 24) >> 2] | 0;
+ i18 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
+ do {
+ if ((i18 | 0) == (i13 | 0)) {
+ i19 = i7 + (i15 + 20) | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ i19 = i7 + (i15 + 16) | 0;
+ i18 = HEAP32[i19 >> 2] | 0;
+ if ((i18 | 0) == 0) {
+ i14 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i21 = i18 + 20 | 0;
+ i20 = HEAP32[i21 >> 2] | 0;
+ if ((i20 | 0) != 0) {
+ i18 = i20;
+ i19 = i21;
+ continue;
+ }
+ i20 = i18 + 16 | 0;
+ i21 = HEAP32[i20 >> 2] | 0;
+ if ((i21 | 0) == 0) {
+ break;
+ } else {
+ i18 = i21;
+ i19 = i20;
+ }
+ }
+ if (i19 >>> 0 < i16 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i19 >> 2] = 0;
+ i14 = i18;
+ break;
+ }
+ } else {
+ i19 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
+ if (i19 >>> 0 < i16 >>> 0) {
+ _abort();
+ }
+ i16 = i19 + 12 | 0;
+ if ((HEAP32[i16 >> 2] | 0) != (i13 | 0)) {
+ _abort();
+ }
+ i20 = i18 + 8 | 0;
+ if ((HEAP32[i20 >> 2] | 0) == (i13 | 0)) {
+ HEAP32[i16 >> 2] = i18;
+ HEAP32[i20 >> 2] = i19;
+ i14 = i18;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i17 | 0) != 0) {
+ i18 = HEAP32[i7 + (i15 + 28) >> 2] | 0;
+ i16 = 14776 + (i18 << 2) | 0;
+ if ((i13 | 0) == (HEAP32[i16 >> 2] | 0)) {
+ HEAP32[i16 >> 2] = i14;
+ if ((i14 | 0) == 0) {
+ HEAP32[14476 >> 2] = HEAP32[14476 >> 2] & ~(1 << i18);
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ } else {
+ if (i17 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i16 = i17 + 16 | 0;
+ if ((HEAP32[i16 >> 2] | 0) == (i13 | 0)) {
+ HEAP32[i16 >> 2] = i14;
+ } else {
+ HEAP32[i17 + 20 >> 2] = i14;
+ }
+ if ((i14 | 0) == 0) {
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ }
+ if (i14 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i14 + 24 >> 2] = i17;
+ i16 = HEAP32[i7 + (i15 + 16) >> 2] | 0;
+ do {
+ if ((i16 | 0) != 0) {
+ if (i16 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i14 + 16 >> 2] = i16;
+ HEAP32[i16 + 24 >> 2] = i14;
+ break;
+ }
+ }
+ } while (0);
+ i15 = HEAP32[i7 + (i15 + 20) >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ if (i15 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i14 + 20 >> 2] = i15;
+ HEAP32[i15 + 24 >> 2] = i14;
+ i2 = i13;
+ i11 = i12;
+ break;
+ }
+ } else {
+ i2 = i13;
+ i11 = i12;
+ }
+ } else {
+ i2 = i13;
+ i11 = i12;
+ }
+ } else {
+ i2 = i15;
+ i11 = i8;
+ }
+ } while (0);
+ if (!(i2 >>> 0 < i6 >>> 0)) {
+ _abort();
+ }
+ i12 = i7 + (i8 + -4) | 0;
+ i13 = HEAP32[i12 >> 2] | 0;
+ if ((i13 & 1 | 0) == 0) {
+ _abort();
+ }
+ if ((i13 & 2 | 0) == 0) {
+ if ((i6 | 0) == (HEAP32[14496 >> 2] | 0)) {
+ i21 = (HEAP32[14484 >> 2] | 0) + i11 | 0;
+ HEAP32[14484 >> 2] = i21;
+ HEAP32[14496 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i21 | 1;
+ if ((i2 | 0) != (HEAP32[14492 >> 2] | 0)) {
+ STACKTOP = i1;
+ return;
+ }
+ HEAP32[14492 >> 2] = 0;
+ HEAP32[14480 >> 2] = 0;
+ STACKTOP = i1;
+ return;
+ }
+ if ((i6 | 0) == (HEAP32[14492 >> 2] | 0)) {
+ i21 = (HEAP32[14480 >> 2] | 0) + i11 | 0;
+ HEAP32[14480 >> 2] = i21;
+ HEAP32[14492 >> 2] = i2;
+ HEAP32[i2 + 4 >> 2] = i21 | 1;
+ HEAP32[i2 + i21 >> 2] = i21;
+ STACKTOP = i1;
+ return;
+ }
+ i11 = (i13 & -8) + i11 | 0;
+ i12 = i13 >>> 3;
+ do {
+ if (!(i13 >>> 0 < 256)) {
+ i10 = HEAP32[i7 + (i8 + 16) >> 2] | 0;
+ i15 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
+ do {
+ if ((i15 | 0) == (i6 | 0)) {
+ i13 = i7 + (i8 + 12) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i13 = i7 + (i8 + 8) | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ if ((i12 | 0) == 0) {
+ i9 = 0;
+ break;
+ }
+ }
+ while (1) {
+ i14 = i12 + 20 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) != 0) {
+ i12 = i15;
+ i13 = i14;
+ continue;
+ }
+ i14 = i12 + 16 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ if ((i15 | 0) == 0) {
+ break;
+ } else {
+ i12 = i15;
+ i13 = i14;
+ }
+ }
+ if (i13 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i13 >> 2] = 0;
+ i9 = i12;
+ break;
+ }
+ } else {
+ i13 = HEAP32[i7 + i8 >> 2] | 0;
+ if (i13 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i14 = i13 + 12 | 0;
+ if ((HEAP32[i14 >> 2] | 0) != (i6 | 0)) {
+ _abort();
+ }
+ i12 = i15 + 8 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i14 >> 2] = i15;
+ HEAP32[i12 >> 2] = i13;
+ i9 = i15;
+ break;
+ } else {
+ _abort();
+ }
+ }
+ } while (0);
+ if ((i10 | 0) != 0) {
+ i12 = HEAP32[i7 + (i8 + 20) >> 2] | 0;
+ i13 = 14776 + (i12 << 2) | 0;
+ if ((i6 | 0) == (HEAP32[i13 >> 2] | 0)) {
+ HEAP32[i13 >> 2] = i9;
+ if ((i9 | 0) == 0) {
+ HEAP32[14476 >> 2] = HEAP32[14476 >> 2] & ~(1 << i12);
+ break;
+ }
+ } else {
+ if (i10 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i12 = i10 + 16 | 0;
+ if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
+ HEAP32[i12 >> 2] = i9;
+ } else {
+ HEAP32[i10 + 20 >> 2] = i9;
+ }
+ if ((i9 | 0) == 0) {
+ break;
+ }
+ }
+ if (i9 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ HEAP32[i9 + 24 >> 2] = i10;
+ i6 = HEAP32[i7 + (i8 + 8) >> 2] | 0;
+ do {
+ if ((i6 | 0) != 0) {
+ if (i6 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 16 >> 2] = i6;
+ HEAP32[i6 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ } while (0);
+ i6 = HEAP32[i7 + (i8 + 12) >> 2] | 0;
+ if ((i6 | 0) != 0) {
+ if (i6 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i9 + 20 >> 2] = i6;
+ HEAP32[i6 + 24 >> 2] = i9;
+ break;
+ }
+ }
+ }
+ } else {
+ i9 = HEAP32[i7 + i8 >> 2] | 0;
+ i7 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
+ i8 = 14512 + (i12 << 1 << 2) | 0;
+ if ((i9 | 0) != (i8 | 0)) {
+ if (i9 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ if ((HEAP32[i9 + 12 >> 2] | 0) != (i6 | 0)) {
+ _abort();
+ }
+ }
+ if ((i7 | 0) == (i9 | 0)) {
+ HEAP32[3618] = HEAP32[3618] & ~(1 << i12);
+ break;
+ }
+ if ((i7 | 0) != (i8 | 0)) {
+ if (i7 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ }
+ i8 = i7 + 8 | 0;
+ if ((HEAP32[i8 >> 2] | 0) == (i6 | 0)) {
+ i10 = i8;
+ } else {
+ _abort();
+ }
+ } else {
+ i10 = i7 + 8 | 0;
+ }
+ HEAP32[i9 + 12 >> 2] = i7;
+ HEAP32[i10 >> 2] = i9;
+ }
+ } while (0);
+ HEAP32[i2 + 4 >> 2] = i11 | 1;
+ HEAP32[i2 + i11 >> 2] = i11;
+ if ((i2 | 0) == (HEAP32[14492 >> 2] | 0)) {
+ HEAP32[14480 >> 2] = i11;
+ STACKTOP = i1;
+ return;
+ }
+ } else {
+ HEAP32[i12 >> 2] = i13 & -2;
+ HEAP32[i2 + 4 >> 2] = i11 | 1;
+ HEAP32[i2 + i11 >> 2] = i11;
+ }
+ i6 = i11 >>> 3;
+ if (i11 >>> 0 < 256) {
+ i7 = i6 << 1;
+ i3 = 14512 + (i7 << 2) | 0;
+ i8 = HEAP32[3618] | 0;
+ i6 = 1 << i6;
+ if ((i8 & i6 | 0) != 0) {
+ i6 = 14512 + (i7 + 2 << 2) | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ if (i7 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ i4 = i6;
+ i5 = i7;
+ }
+ } else {
+ HEAP32[3618] = i8 | i6;
+ i4 = 14512 + (i7 + 2 << 2) | 0;
+ i5 = i3;
+ }
+ HEAP32[i4 >> 2] = i2;
+ HEAP32[i5 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i5;
+ HEAP32[i2 + 12 >> 2] = i3;
+ STACKTOP = i1;
+ return;
+ }
+ i4 = i11 >>> 8;
+ if ((i4 | 0) != 0) {
+ if (i11 >>> 0 > 16777215) {
+ i4 = 31;
+ } else {
+ i20 = (i4 + 1048320 | 0) >>> 16 & 8;
+ i21 = i4 << i20;
+ i19 = (i21 + 520192 | 0) >>> 16 & 4;
+ i21 = i21 << i19;
+ i4 = (i21 + 245760 | 0) >>> 16 & 2;
+ i4 = 14 - (i19 | i20 | i4) + (i21 << i4 >>> 15) | 0;
+ i4 = i11 >>> (i4 + 7 | 0) & 1 | i4 << 1;
+ }
+ } else {
+ i4 = 0;
+ }
+ i5 = 14776 + (i4 << 2) | 0;
+ HEAP32[i2 + 28 >> 2] = i4;
+ HEAP32[i2 + 20 >> 2] = 0;
+ HEAP32[i2 + 16 >> 2] = 0;
+ i7 = HEAP32[14476 >> 2] | 0;
+ i6 = 1 << i4;
+ L199 : do {
+ if ((i7 & i6 | 0) != 0) {
+ i5 = HEAP32[i5 >> 2] | 0;
+ if ((i4 | 0) == 31) {
+ i4 = 0;
+ } else {
+ i4 = 25 - (i4 >>> 1) | 0;
+ }
+ L204 : do {
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) != (i11 | 0)) {
+ i4 = i11 << i4;
+ i7 = i5;
+ while (1) {
+ i6 = i7 + (i4 >>> 31 << 2) + 16 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ }
+ if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i11 | 0)) {
+ i3 = i5;
+ break L204;
+ } else {
+ i4 = i4 << 1;
+ i7 = i5;
+ }
+ }
+ if (i6 >>> 0 < (HEAP32[14488 >> 2] | 0) >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i6 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i7;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ break L199;
+ }
+ } else {
+ i3 = i5;
+ }
+ } while (0);
+ i5 = i3 + 8 | 0;
+ i4 = HEAP32[i5 >> 2] | 0;
+ i6 = HEAP32[14488 >> 2] | 0;
+ if (i3 >>> 0 < i6 >>> 0) {
+ _abort();
+ }
+ if (i4 >>> 0 < i6 >>> 0) {
+ _abort();
+ } else {
+ HEAP32[i4 + 12 >> 2] = i2;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i4;
+ HEAP32[i2 + 12 >> 2] = i3;
+ HEAP32[i2 + 24 >> 2] = 0;
+ break;
+ }
+ } else {
+ HEAP32[14476 >> 2] = i7 | i6;
+ HEAP32[i5 >> 2] = i2;
+ HEAP32[i2 + 24 >> 2] = i5;
+ HEAP32[i2 + 12 >> 2] = i2;
+ HEAP32[i2 + 8 >> 2] = i2;
+ }
+ } while (0);
+ i21 = (HEAP32[14504 >> 2] | 0) + -1 | 0;
+ HEAP32[14504 >> 2] = i21;
+ if ((i21 | 0) == 0) {
+ i2 = 14928 | 0;
+ } else {
+ STACKTOP = i1;
+ return;
+ }
+ while (1) {
+ i2 = HEAP32[i2 >> 2] | 0;
+ if ((i2 | 0) == 0) {
+ break;
+ } else {
+ i2 = i2 + 8 | 0;
+ }
+ }
+ HEAP32[14504 >> 2] = -1;
+ STACKTOP = i1;
+ return;
+}
+function _build_tree(i4, i9) {
+ i4 = i4 | 0;
+ i9 = i9 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 32 | 0;
+ i1 = i2;
+ i3 = HEAP32[i9 >> 2] | 0;
+ i7 = i9 + 8 | 0;
+ i11 = HEAP32[i7 >> 2] | 0;
+ i12 = HEAP32[i11 >> 2] | 0;
+ i11 = HEAP32[i11 + 12 >> 2] | 0;
+ i8 = i4 + 5200 | 0;
+ HEAP32[i8 >> 2] = 0;
+ i6 = i4 + 5204 | 0;
+ HEAP32[i6 >> 2] = 573;
+ if ((i11 | 0) > 0) {
+ i5 = -1;
+ i13 = 0;
+ do {
+ if ((HEAP16[i3 + (i13 << 2) >> 1] | 0) == 0) {
+ HEAP16[i3 + (i13 << 2) + 2 >> 1] = 0;
+ } else {
+ i5 = (HEAP32[i8 >> 2] | 0) + 1 | 0;
+ HEAP32[i8 >> 2] = i5;
+ HEAP32[i4 + (i5 << 2) + 2908 >> 2] = i13;
+ HEAP8[i4 + i13 + 5208 | 0] = 0;
+ i5 = i13;
+ }
+ i13 = i13 + 1 | 0;
+ } while ((i13 | 0) != (i11 | 0));
+ i14 = HEAP32[i8 >> 2] | 0;
+ if ((i14 | 0) < 2) {
+ i10 = 3;
+ }
+ } else {
+ i14 = 0;
+ i5 = -1;
+ i10 = 3;
+ }
+ if ((i10 | 0) == 3) {
+ i10 = i4 + 5800 | 0;
+ i13 = i4 + 5804 | 0;
+ if ((i12 | 0) == 0) {
+ do {
+ i12 = (i5 | 0) < 2;
+ i13 = i5 + 1 | 0;
+ i5 = i12 ? i13 : i5;
+ i23 = i12 ? i13 : 0;
+ i14 = i14 + 1 | 0;
+ HEAP32[i8 >> 2] = i14;
+ HEAP32[i4 + (i14 << 2) + 2908 >> 2] = i23;
+ HEAP16[i3 + (i23 << 2) >> 1] = 1;
+ HEAP8[i4 + i23 + 5208 | 0] = 0;
+ HEAP32[i10 >> 2] = (HEAP32[i10 >> 2] | 0) + -1;
+ i14 = HEAP32[i8 >> 2] | 0;
+ } while ((i14 | 0) < 2);
+ } else {
+ do {
+ i15 = (i5 | 0) < 2;
+ i16 = i5 + 1 | 0;
+ i5 = i15 ? i16 : i5;
+ i23 = i15 ? i16 : 0;
+ i14 = i14 + 1 | 0;
+ HEAP32[i8 >> 2] = i14;
+ HEAP32[i4 + (i14 << 2) + 2908 >> 2] = i23;
+ HEAP16[i3 + (i23 << 2) >> 1] = 1;
+ HEAP8[i4 + i23 + 5208 | 0] = 0;
+ HEAP32[i10 >> 2] = (HEAP32[i10 >> 2] | 0) + -1;
+ HEAP32[i13 >> 2] = (HEAP32[i13 >> 2] | 0) - (HEAPU16[i12 + (i23 << 2) + 2 >> 1] | 0);
+ i14 = HEAP32[i8 >> 2] | 0;
+ } while ((i14 | 0) < 2);
+ }
+ }
+ i10 = i9 + 4 | 0;
+ HEAP32[i10 >> 2] = i5;
+ i12 = HEAP32[i8 >> 2] | 0;
+ if ((i12 | 0) > 1) {
+ i18 = i12;
+ i13 = (i12 | 0) / 2 | 0;
+ do {
+ i12 = HEAP32[i4 + (i13 << 2) + 2908 >> 2] | 0;
+ i14 = i4 + i12 + 5208 | 0;
+ i17 = i13 << 1;
+ L21 : do {
+ if ((i17 | 0) > (i18 | 0)) {
+ i15 = i13;
+ } else {
+ i16 = i3 + (i12 << 2) | 0;
+ i15 = i13;
+ while (1) {
+ do {
+ if ((i17 | 0) < (i18 | 0)) {
+ i18 = i17 | 1;
+ i19 = HEAP32[i4 + (i18 << 2) + 2908 >> 2] | 0;
+ i22 = HEAP16[i3 + (i19 << 2) >> 1] | 0;
+ i20 = HEAP32[i4 + (i17 << 2) + 2908 >> 2] | 0;
+ i21 = HEAP16[i3 + (i20 << 2) >> 1] | 0;
+ if (!((i22 & 65535) < (i21 & 65535))) {
+ if (!(i22 << 16 >> 16 == i21 << 16 >> 16)) {
+ break;
+ }
+ if ((HEAPU8[i4 + i19 + 5208 | 0] | 0) > (HEAPU8[i4 + i20 + 5208 | 0] | 0)) {
+ break;
+ }
+ }
+ i17 = i18;
+ }
+ } while (0);
+ i19 = HEAP16[i16 >> 1] | 0;
+ i18 = HEAP32[i4 + (i17 << 2) + 2908 >> 2] | 0;
+ i20 = HEAP16[i3 + (i18 << 2) >> 1] | 0;
+ if ((i19 & 65535) < (i20 & 65535)) {
+ break L21;
+ }
+ if (i19 << 16 >> 16 == i20 << 16 >> 16 ? (HEAPU8[i14] | 0) <= (HEAPU8[i4 + i18 + 5208 | 0] | 0) : 0) {
+ break L21;
+ }
+ HEAP32[i4 + (i15 << 2) + 2908 >> 2] = i18;
+ i19 = i17 << 1;
+ i18 = HEAP32[i8 >> 2] | 0;
+ if ((i19 | 0) > (i18 | 0)) {
+ i15 = i17;
+ break;
+ } else {
+ i15 = i17;
+ i17 = i19;
+ }
+ }
+ }
+ } while (0);
+ HEAP32[i4 + (i15 << 2) + 2908 >> 2] = i12;
+ i13 = i13 + -1 | 0;
+ i18 = HEAP32[i8 >> 2] | 0;
+ } while ((i13 | 0) > 0);
+ } else {
+ i18 = i12;
+ }
+ i12 = i4 + 2912 | 0;
+ while (1) {
+ i13 = HEAP32[i12 >> 2] | 0;
+ i20 = i18 + -1 | 0;
+ HEAP32[i8 >> 2] = i20;
+ i14 = HEAP32[i4 + (i18 << 2) + 2908 >> 2] | 0;
+ HEAP32[i12 >> 2] = i14;
+ i15 = i4 + i14 + 5208 | 0;
+ L40 : do {
+ if ((i18 | 0) < 3) {
+ i17 = 1;
+ } else {
+ i16 = i3 + (i14 << 2) | 0;
+ i17 = 1;
+ i18 = 2;
+ while (1) {
+ do {
+ if ((i18 | 0) < (i20 | 0)) {
+ i22 = i18 | 1;
+ i21 = HEAP32[i4 + (i22 << 2) + 2908 >> 2] | 0;
+ i23 = HEAP16[i3 + (i21 << 2) >> 1] | 0;
+ i20 = HEAP32[i4 + (i18 << 2) + 2908 >> 2] | 0;
+ i19 = HEAP16[i3 + (i20 << 2) >> 1] | 0;
+ if (!((i23 & 65535) < (i19 & 65535))) {
+ if (!(i23 << 16 >> 16 == i19 << 16 >> 16)) {
+ break;
+ }
+ if ((HEAPU8[i4 + i21 + 5208 | 0] | 0) > (HEAPU8[i4 + i20 + 5208 | 0] | 0)) {
+ break;
+ }
+ }
+ i18 = i22;
+ }
+ } while (0);
+ i21 = HEAP16[i16 >> 1] | 0;
+ i20 = HEAP32[i4 + (i18 << 2) + 2908 >> 2] | 0;
+ i19 = HEAP16[i3 + (i20 << 2) >> 1] | 0;
+ if ((i21 & 65535) < (i19 & 65535)) {
+ break L40;
+ }
+ if (i21 << 16 >> 16 == i19 << 16 >> 16 ? (HEAPU8[i15] | 0) <= (HEAPU8[i4 + i20 + 5208 | 0] | 0) : 0) {
+ break L40;
+ }
+ HEAP32[i4 + (i17 << 2) + 2908 >> 2] = i20;
+ i19 = i18 << 1;
+ i20 = HEAP32[i8 >> 2] | 0;
+ if ((i19 | 0) > (i20 | 0)) {
+ i17 = i18;
+ break;
+ } else {
+ i17 = i18;
+ i18 = i19;
+ }
+ }
+ }
+ } while (0);
+ HEAP32[i4 + (i17 << 2) + 2908 >> 2] = i14;
+ i17 = HEAP32[i12 >> 2] | 0;
+ i14 = (HEAP32[i6 >> 2] | 0) + -1 | 0;
+ HEAP32[i6 >> 2] = i14;
+ HEAP32[i4 + (i14 << 2) + 2908 >> 2] = i13;
+ i14 = (HEAP32[i6 >> 2] | 0) + -1 | 0;
+ HEAP32[i6 >> 2] = i14;
+ HEAP32[i4 + (i14 << 2) + 2908 >> 2] = i17;
+ i14 = i3 + (i11 << 2) | 0;
+ HEAP16[i14 >> 1] = (HEAPU16[i3 + (i17 << 2) >> 1] | 0) + (HEAPU16[i3 + (i13 << 2) >> 1] | 0);
+ i18 = HEAP8[i4 + i13 + 5208 | 0] | 0;
+ i16 = HEAP8[i4 + i17 + 5208 | 0] | 0;
+ i15 = i4 + i11 + 5208 | 0;
+ HEAP8[i15] = (((i18 & 255) < (i16 & 255) ? i16 : i18) & 255) + 1;
+ i19 = i11 & 65535;
+ HEAP16[i3 + (i17 << 2) + 2 >> 1] = i19;
+ HEAP16[i3 + (i13 << 2) + 2 >> 1] = i19;
+ i13 = i11 + 1 | 0;
+ HEAP32[i12 >> 2] = i11;
+ i19 = HEAP32[i8 >> 2] | 0;
+ L56 : do {
+ if ((i19 | 0) < 2) {
+ i16 = 1;
+ } else {
+ i16 = 1;
+ i17 = 2;
+ while (1) {
+ do {
+ if ((i17 | 0) < (i19 | 0)) {
+ i21 = i17 | 1;
+ i22 = HEAP32[i4 + (i21 << 2) + 2908 >> 2] | 0;
+ i19 = HEAP16[i3 + (i22 << 2) >> 1] | 0;
+ i18 = HEAP32[i4 + (i17 << 2) + 2908 >> 2] | 0;
+ i20 = HEAP16[i3 + (i18 << 2) >> 1] | 0;
+ if (!((i19 & 65535) < (i20 & 65535))) {
+ if (!(i19 << 16 >> 16 == i20 << 16 >> 16)) {
+ break;
+ }
+ if ((HEAPU8[i4 + i22 + 5208 | 0] | 0) > (HEAPU8[i4 + i18 + 5208 | 0] | 0)) {
+ break;
+ }
+ }
+ i17 = i21;
+ }
+ } while (0);
+ i19 = HEAP16[i14 >> 1] | 0;
+ i20 = HEAP32[i4 + (i17 << 2) + 2908 >> 2] | 0;
+ i18 = HEAP16[i3 + (i20 << 2) >> 1] | 0;
+ if ((i19 & 65535) < (i18 & 65535)) {
+ break L56;
+ }
+ if (i19 << 16 >> 16 == i18 << 16 >> 16 ? (HEAPU8[i15] | 0) <= (HEAPU8[i4 + i20 + 5208 | 0] | 0) : 0) {
+ break L56;
+ }
+ HEAP32[i4 + (i16 << 2) + 2908 >> 2] = i20;
+ i18 = i17 << 1;
+ i19 = HEAP32[i8 >> 2] | 0;
+ if ((i18 | 0) > (i19 | 0)) {
+ i16 = i17;
+ break;
+ } else {
+ i16 = i17;
+ i17 = i18;
+ }
+ }
+ }
+ } while (0);
+ HEAP32[i4 + (i16 << 2) + 2908 >> 2] = i11;
+ i18 = HEAP32[i8 >> 2] | 0;
+ if ((i18 | 0) > 1) {
+ i11 = i13;
+ } else {
+ break;
+ }
+ }
+ i12 = HEAP32[i12 >> 2] | 0;
+ i8 = (HEAP32[i6 >> 2] | 0) + -1 | 0;
+ HEAP32[i6 >> 2] = i8;
+ HEAP32[i4 + (i8 << 2) + 2908 >> 2] = i12;
+ i8 = HEAP32[i9 >> 2] | 0;
+ i9 = HEAP32[i10 >> 2] | 0;
+ i7 = HEAP32[i7 >> 2] | 0;
+ i12 = HEAP32[i7 >> 2] | 0;
+ i11 = HEAP32[i7 + 4 >> 2] | 0;
+ i10 = HEAP32[i7 + 8 >> 2] | 0;
+ i7 = HEAP32[i7 + 16 >> 2] | 0;
+ i13 = i4 + 2876 | 0;
+ i14 = i13 + 32 | 0;
+ do {
+ HEAP16[i13 >> 1] = 0;
+ i13 = i13 + 2 | 0;
+ } while ((i13 | 0) < (i14 | 0));
+ i14 = HEAP32[i6 >> 2] | 0;
+ HEAP16[i8 + (HEAP32[i4 + (i14 << 2) + 2908 >> 2] << 2) + 2 >> 1] = 0;
+ i14 = i14 + 1 | 0;
+ L72 : do {
+ if ((i14 | 0) < 573) {
+ i6 = i4 + 5800 | 0;
+ i13 = i4 + 5804 | 0;
+ if ((i12 | 0) == 0) {
+ i18 = 0;
+ do {
+ i12 = HEAP32[i4 + (i14 << 2) + 2908 >> 2] | 0;
+ i13 = i8 + (i12 << 2) + 2 | 0;
+ i15 = HEAPU16[i8 + (HEAPU16[i13 >> 1] << 2) + 2 >> 1] | 0;
+ i16 = (i15 | 0) < (i7 | 0);
+ i15 = i16 ? i15 + 1 | 0 : i7;
+ i18 = (i16 & 1 ^ 1) + i18 | 0;
+ HEAP16[i13 >> 1] = i15;
+ if ((i12 | 0) <= (i9 | 0)) {
+ i23 = i4 + (i15 << 1) + 2876 | 0;
+ HEAP16[i23 >> 1] = (HEAP16[i23 >> 1] | 0) + 1 << 16 >> 16;
+ if ((i12 | 0) < (i10 | 0)) {
+ i13 = 0;
+ } else {
+ i13 = HEAP32[i11 + (i12 - i10 << 2) >> 2] | 0;
+ }
+ i23 = Math_imul(HEAPU16[i8 + (i12 << 2) >> 1] | 0, i13 + i15 | 0) | 0;
+ HEAP32[i6 >> 2] = i23 + (HEAP32[i6 >> 2] | 0);
+ }
+ i14 = i14 + 1 | 0;
+ } while ((i14 | 0) != 573);
+ } else {
+ i18 = 0;
+ do {
+ i15 = HEAP32[i4 + (i14 << 2) + 2908 >> 2] | 0;
+ i16 = i8 + (i15 << 2) + 2 | 0;
+ i17 = HEAPU16[i8 + (HEAPU16[i16 >> 1] << 2) + 2 >> 1] | 0;
+ i19 = (i17 | 0) < (i7 | 0);
+ i17 = i19 ? i17 + 1 | 0 : i7;
+ i18 = (i19 & 1 ^ 1) + i18 | 0;
+ HEAP16[i16 >> 1] = i17;
+ if ((i15 | 0) <= (i9 | 0)) {
+ i23 = i4 + (i17 << 1) + 2876 | 0;
+ HEAP16[i23 >> 1] = (HEAP16[i23 >> 1] | 0) + 1 << 16 >> 16;
+ if ((i15 | 0) < (i10 | 0)) {
+ i16 = 0;
+ } else {
+ i16 = HEAP32[i11 + (i15 - i10 << 2) >> 2] | 0;
+ }
+ i23 = HEAPU16[i8 + (i15 << 2) >> 1] | 0;
+ i22 = Math_imul(i23, i16 + i17 | 0) | 0;
+ HEAP32[i6 >> 2] = i22 + (HEAP32[i6 >> 2] | 0);
+ i23 = Math_imul((HEAPU16[i12 + (i15 << 2) + 2 >> 1] | 0) + i16 | 0, i23) | 0;
+ HEAP32[i13 >> 2] = i23 + (HEAP32[i13 >> 2] | 0);
+ }
+ i14 = i14 + 1 | 0;
+ } while ((i14 | 0) != 573);
+ }
+ if ((i18 | 0) != 0) {
+ i10 = i4 + (i7 << 1) + 2876 | 0;
+ do {
+ i12 = i7;
+ while (1) {
+ i11 = i12 + -1 | 0;
+ i13 = i4 + (i11 << 1) + 2876 | 0;
+ i14 = HEAP16[i13 >> 1] | 0;
+ if (i14 << 16 >> 16 == 0) {
+ i12 = i11;
+ } else {
+ break;
+ }
+ }
+ HEAP16[i13 >> 1] = i14 + -1 << 16 >> 16;
+ i11 = i4 + (i12 << 1) + 2876 | 0;
+ HEAP16[i11 >> 1] = (HEAPU16[i11 >> 1] | 0) + 2;
+ i11 = (HEAP16[i10 >> 1] | 0) + -1 << 16 >> 16;
+ HEAP16[i10 >> 1] = i11;
+ i18 = i18 + -2 | 0;
+ } while ((i18 | 0) > 0);
+ if ((i7 | 0) != 0) {
+ i12 = 573;
+ while (1) {
+ i10 = i7 & 65535;
+ if (!(i11 << 16 >> 16 == 0)) {
+ i11 = i11 & 65535;
+ do {
+ do {
+ i12 = i12 + -1 | 0;
+ i15 = HEAP32[i4 + (i12 << 2) + 2908 >> 2] | 0;
+ } while ((i15 | 0) > (i9 | 0));
+ i13 = i8 + (i15 << 2) + 2 | 0;
+ i14 = HEAPU16[i13 >> 1] | 0;
+ if ((i14 | 0) != (i7 | 0)) {
+ i23 = Math_imul(HEAPU16[i8 + (i15 << 2) >> 1] | 0, i7 - i14 | 0) | 0;
+ HEAP32[i6 >> 2] = i23 + (HEAP32[i6 >> 2] | 0);
+ HEAP16[i13 >> 1] = i10;
+ }
+ i11 = i11 + -1 | 0;
+ } while ((i11 | 0) != 0);
+ }
+ i7 = i7 + -1 | 0;
+ if ((i7 | 0) == 0) {
+ break L72;
+ }
+ i11 = HEAP16[i4 + (i7 << 1) + 2876 >> 1] | 0;
+ }
+ }
+ }
+ }
+ } while (0);
+ i7 = 1;
+ i6 = 0;
+ do {
+ i6 = (HEAPU16[i4 + (i7 + -1 << 1) + 2876 >> 1] | 0) + (i6 & 65534) << 1;
+ HEAP16[i1 + (i7 << 1) >> 1] = i6;
+ i7 = i7 + 1 | 0;
+ } while ((i7 | 0) != 16);
+ if ((i5 | 0) < 0) {
+ STACKTOP = i2;
+ return;
+ } else {
+ i4 = 0;
+ }
+ while (1) {
+ i23 = HEAP16[i3 + (i4 << 2) + 2 >> 1] | 0;
+ i7 = i23 & 65535;
+ if (!(i23 << 16 >> 16 == 0)) {
+ i8 = i1 + (i7 << 1) | 0;
+ i6 = HEAP16[i8 >> 1] | 0;
+ HEAP16[i8 >> 1] = i6 + 1 << 16 >> 16;
+ i6 = i6 & 65535;
+ i8 = 0;
+ while (1) {
+ i8 = i8 | i6 & 1;
+ i7 = i7 + -1 | 0;
+ if ((i7 | 0) <= 0) {
+ break;
+ } else {
+ i6 = i6 >>> 1;
+ i8 = i8 << 1;
+ }
+ }
+ HEAP16[i3 + (i4 << 2) >> 1] = i8;
+ }
+ if ((i4 | 0) == (i5 | 0)) {
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ }
+ }
+ STACKTOP = i2;
+ return;
+}
+function _deflate_slow(i2, i6) {
+ i2 = i2 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0;
+ i1 = STACKTOP;
+ i15 = i2 + 116 | 0;
+ i16 = (i6 | 0) == 0;
+ i17 = i2 + 72 | 0;
+ i18 = i2 + 88 | 0;
+ i5 = i2 + 108 | 0;
+ i7 = i2 + 56 | 0;
+ i19 = i2 + 84 | 0;
+ i20 = i2 + 68 | 0;
+ i22 = i2 + 52 | 0;
+ i21 = i2 + 64 | 0;
+ i9 = i2 + 96 | 0;
+ i10 = i2 + 120 | 0;
+ i11 = i2 + 112 | 0;
+ i12 = i2 + 100 | 0;
+ i26 = i2 + 5792 | 0;
+ i27 = i2 + 5796 | 0;
+ i29 = i2 + 5784 | 0;
+ i23 = i2 + 5788 | 0;
+ i8 = i2 + 104 | 0;
+ i4 = i2 + 92 | 0;
+ i24 = i2 + 128 | 0;
+ i14 = i2 + 44 | 0;
+ i13 = i2 + 136 | 0;
+ L1 : while (1) {
+ i30 = HEAP32[i15 >> 2] | 0;
+ while (1) {
+ if (i30 >>> 0 < 262) {
+ _fill_window(i2);
+ i30 = HEAP32[i15 >> 2] | 0;
+ if (i30 >>> 0 < 262 & i16) {
+ i2 = 0;
+ i30 = 50;
+ break L1;
+ }
+ if ((i30 | 0) == 0) {
+ i30 = 40;
+ break L1;
+ }
+ if (!(i30 >>> 0 > 2)) {
+ HEAP32[i10 >> 2] = HEAP32[i9 >> 2];
+ HEAP32[i12 >> 2] = HEAP32[i11 >> 2];
+ HEAP32[i9 >> 2] = 2;
+ i32 = 2;
+ i30 = 16;
+ } else {
+ i30 = 8;
+ }
+ } else {
+ i30 = 8;
+ }
+ do {
+ if ((i30 | 0) == 8) {
+ i30 = 0;
+ i34 = HEAP32[i5 >> 2] | 0;
+ i31 = ((HEAPU8[(HEAP32[i7 >> 2] | 0) + (i34 + 2) | 0] | 0) ^ HEAP32[i17 >> 2] << HEAP32[i18 >> 2]) & HEAP32[i19 >> 2];
+ HEAP32[i17 >> 2] = i31;
+ i31 = (HEAP32[i20 >> 2] | 0) + (i31 << 1) | 0;
+ i35 = HEAP16[i31 >> 1] | 0;
+ HEAP16[(HEAP32[i21 >> 2] | 0) + ((HEAP32[i22 >> 2] & i34) << 1) >> 1] = i35;
+ i32 = i35 & 65535;
+ HEAP16[i31 >> 1] = i34;
+ i31 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i10 >> 2] = i31;
+ HEAP32[i12 >> 2] = HEAP32[i11 >> 2];
+ HEAP32[i9 >> 2] = 2;
+ if (!(i35 << 16 >> 16 == 0)) {
+ if (i31 >>> 0 < (HEAP32[i24 >> 2] | 0) >>> 0) {
+ if (!(((HEAP32[i5 >> 2] | 0) - i32 | 0) >>> 0 > ((HEAP32[i14 >> 2] | 0) + -262 | 0) >>> 0)) {
+ i32 = _longest_match(i2, i32) | 0;
+ HEAP32[i9 >> 2] = i32;
+ if (i32 >>> 0 < 6) {
+ if ((HEAP32[i13 >> 2] | 0) != 1) {
+ if ((i32 | 0) != 3) {
+ i30 = 16;
+ break;
+ }
+ if (!(((HEAP32[i5 >> 2] | 0) - (HEAP32[i11 >> 2] | 0) | 0) >>> 0 > 4096)) {
+ i32 = 3;
+ i30 = 16;
+ break;
+ }
+ }
+ HEAP32[i9 >> 2] = 2;
+ i32 = 2;
+ i30 = 16;
+ } else {
+ i30 = 16;
+ }
+ } else {
+ i32 = 2;
+ i30 = 16;
+ }
+ } else {
+ i32 = 2;
+ }
+ } else {
+ i32 = 2;
+ i30 = 16;
+ }
+ }
+ } while (0);
+ if ((i30 | 0) == 16) {
+ i31 = HEAP32[i10 >> 2] | 0;
+ }
+ if (!(i31 >>> 0 < 3 | i32 >>> 0 > i31 >>> 0)) {
+ break;
+ }
+ if ((HEAP32[i8 >> 2] | 0) == 0) {
+ HEAP32[i8 >> 2] = 1;
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + 1;
+ i30 = (HEAP32[i15 >> 2] | 0) + -1 | 0;
+ HEAP32[i15 >> 2] = i30;
+ continue;
+ }
+ i35 = HEAP8[(HEAP32[i7 >> 2] | 0) + ((HEAP32[i5 >> 2] | 0) + -1) | 0] | 0;
+ i34 = HEAP32[i26 >> 2] | 0;
+ HEAP16[(HEAP32[i27 >> 2] | 0) + (i34 << 1) >> 1] = 0;
+ HEAP32[i26 >> 2] = i34 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i34 | 0] = i35;
+ i35 = i2 + ((i35 & 255) << 2) + 148 | 0;
+ HEAP16[i35 >> 1] = (HEAP16[i35 >> 1] | 0) + 1 << 16 >> 16;
+ if ((HEAP32[i26 >> 2] | 0) == ((HEAP32[i23 >> 2] | 0) + -1 | 0)) {
+ i30 = HEAP32[i4 >> 2] | 0;
+ if ((i30 | 0) > -1) {
+ i31 = (HEAP32[i7 >> 2] | 0) + i30 | 0;
+ } else {
+ i31 = 0;
+ }
+ __tr_flush_block(i2, i31, (HEAP32[i5 >> 2] | 0) - i30 | 0, 0);
+ HEAP32[i4 >> 2] = HEAP32[i5 >> 2];
+ i33 = HEAP32[i2 >> 2] | 0;
+ i32 = i33 + 28 | 0;
+ i30 = HEAP32[i32 >> 2] | 0;
+ i35 = HEAP32[i30 + 20 >> 2] | 0;
+ i31 = i33 + 16 | 0;
+ i34 = HEAP32[i31 >> 2] | 0;
+ i34 = i35 >>> 0 > i34 >>> 0 ? i34 : i35;
+ if ((i34 | 0) != 0 ? (i28 = i33 + 12 | 0, _memcpy(HEAP32[i28 >> 2] | 0, HEAP32[i30 + 16 >> 2] | 0, i34 | 0) | 0, HEAP32[i28 >> 2] = (HEAP32[i28 >> 2] | 0) + i34, i28 = (HEAP32[i32 >> 2] | 0) + 16 | 0, HEAP32[i28 >> 2] = (HEAP32[i28 >> 2] | 0) + i34, i28 = i33 + 20 | 0, HEAP32[i28 >> 2] = (HEAP32[i28 >> 2] | 0) + i34, HEAP32[i31 >> 2] = (HEAP32[i31 >> 2] | 0) - i34, i28 = HEAP32[i32 >> 2] | 0, i33 = i28 + 20 | 0, i35 = HEAP32[i33 >> 2] | 0, HEAP32[i33 >> 2] = i35 - i34, (i35 | 0) == (i34 | 0)) : 0) {
+ HEAP32[i28 + 16 >> 2] = HEAP32[i28 + 8 >> 2];
+ }
+ }
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + 1;
+ i30 = (HEAP32[i15 >> 2] | 0) + -1 | 0;
+ HEAP32[i15 >> 2] = i30;
+ if ((HEAP32[(HEAP32[i2 >> 2] | 0) + 16 >> 2] | 0) == 0) {
+ i2 = 0;
+ i30 = 50;
+ break L1;
+ }
+ }
+ i34 = HEAP32[i5 >> 2] | 0;
+ i30 = i34 + -3 + (HEAP32[i15 >> 2] | 0) | 0;
+ i35 = i31 + 253 | 0;
+ i31 = i34 + 65535 - (HEAP32[i12 >> 2] | 0) | 0;
+ i34 = HEAP32[i26 >> 2] | 0;
+ HEAP16[(HEAP32[i27 >> 2] | 0) + (i34 << 1) >> 1] = i31;
+ HEAP32[i26 >> 2] = i34 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i34 | 0] = i35;
+ i35 = i2 + ((HEAPU8[808 + (i35 & 255) | 0] | 0 | 256) + 1 << 2) + 148 | 0;
+ HEAP16[i35 >> 1] = (HEAP16[i35 >> 1] | 0) + 1 << 16 >> 16;
+ i31 = i31 + 65535 & 65535;
+ if (!(i31 >>> 0 < 256)) {
+ i31 = (i31 >>> 7) + 256 | 0;
+ }
+ i32 = i2 + ((HEAPU8[296 + i31 | 0] | 0) << 2) + 2440 | 0;
+ HEAP16[i32 >> 1] = (HEAP16[i32 >> 1] | 0) + 1 << 16 >> 16;
+ i32 = HEAP32[i26 >> 2] | 0;
+ i31 = (HEAP32[i23 >> 2] | 0) + -1 | 0;
+ i34 = HEAP32[i10 >> 2] | 0;
+ HEAP32[i15 >> 2] = 1 - i34 + (HEAP32[i15 >> 2] | 0);
+ i34 = i34 + -2 | 0;
+ HEAP32[i10 >> 2] = i34;
+ i33 = HEAP32[i5 >> 2] | 0;
+ while (1) {
+ i35 = i33 + 1 | 0;
+ HEAP32[i5 >> 2] = i35;
+ if (!(i35 >>> 0 > i30 >>> 0)) {
+ i36 = ((HEAPU8[(HEAP32[i7 >> 2] | 0) + (i33 + 3) | 0] | 0) ^ HEAP32[i17 >> 2] << HEAP32[i18 >> 2]) & HEAP32[i19 >> 2];
+ HEAP32[i17 >> 2] = i36;
+ i36 = (HEAP32[i20 >> 2] | 0) + (i36 << 1) | 0;
+ HEAP16[(HEAP32[i21 >> 2] | 0) + ((HEAP32[i22 >> 2] & i35) << 1) >> 1] = HEAP16[i36 >> 1] | 0;
+ HEAP16[i36 >> 1] = i35;
+ }
+ i34 = i34 + -1 | 0;
+ HEAP32[i10 >> 2] = i34;
+ if ((i34 | 0) == 0) {
+ break;
+ } else {
+ i33 = i35;
+ }
+ }
+ HEAP32[i8 >> 2] = 0;
+ HEAP32[i9 >> 2] = 2;
+ i30 = i33 + 2 | 0;
+ HEAP32[i5 >> 2] = i30;
+ if ((i32 | 0) != (i31 | 0)) {
+ continue;
+ }
+ i32 = HEAP32[i4 >> 2] | 0;
+ if ((i32 | 0) > -1) {
+ i31 = (HEAP32[i7 >> 2] | 0) + i32 | 0;
+ } else {
+ i31 = 0;
+ }
+ __tr_flush_block(i2, i31, i30 - i32 | 0, 0);
+ HEAP32[i4 >> 2] = HEAP32[i5 >> 2];
+ i33 = HEAP32[i2 >> 2] | 0;
+ i31 = i33 + 28 | 0;
+ i32 = HEAP32[i31 >> 2] | 0;
+ i35 = HEAP32[i32 + 20 >> 2] | 0;
+ i30 = i33 + 16 | 0;
+ i34 = HEAP32[i30 >> 2] | 0;
+ i34 = i35 >>> 0 > i34 >>> 0 ? i34 : i35;
+ if ((i34 | 0) != 0 ? (i25 = i33 + 12 | 0, _memcpy(HEAP32[i25 >> 2] | 0, HEAP32[i32 + 16 >> 2] | 0, i34 | 0) | 0, HEAP32[i25 >> 2] = (HEAP32[i25 >> 2] | 0) + i34, i25 = (HEAP32[i31 >> 2] | 0) + 16 | 0, HEAP32[i25 >> 2] = (HEAP32[i25 >> 2] | 0) + i34, i25 = i33 + 20 | 0, HEAP32[i25 >> 2] = (HEAP32[i25 >> 2] | 0) + i34, HEAP32[i30 >> 2] = (HEAP32[i30 >> 2] | 0) - i34, i25 = HEAP32[i31 >> 2] | 0, i35 = i25 + 20 | 0, i36 = HEAP32[i35 >> 2] | 0, HEAP32[i35 >> 2] = i36 - i34, (i36 | 0) == (i34 | 0)) : 0) {
+ HEAP32[i25 + 16 >> 2] = HEAP32[i25 + 8 >> 2];
+ }
+ if ((HEAP32[(HEAP32[i2 >> 2] | 0) + 16 >> 2] | 0) == 0) {
+ i2 = 0;
+ i30 = 50;
+ break;
+ }
+ }
+ if ((i30 | 0) == 40) {
+ if ((HEAP32[i8 >> 2] | 0) != 0) {
+ i36 = HEAP8[(HEAP32[i7 >> 2] | 0) + ((HEAP32[i5 >> 2] | 0) + -1) | 0] | 0;
+ i35 = HEAP32[i26 >> 2] | 0;
+ HEAP16[(HEAP32[i27 >> 2] | 0) + (i35 << 1) >> 1] = 0;
+ HEAP32[i26 >> 2] = i35 + 1;
+ HEAP8[(HEAP32[i29 >> 2] | 0) + i35 | 0] = i36;
+ i36 = i2 + ((i36 & 255) << 2) + 148 | 0;
+ HEAP16[i36 >> 1] = (HEAP16[i36 >> 1] | 0) + 1 << 16 >> 16;
+ HEAP32[i8 >> 2] = 0;
+ }
+ i8 = HEAP32[i4 >> 2] | 0;
+ if ((i8 | 0) > -1) {
+ i7 = (HEAP32[i7 >> 2] | 0) + i8 | 0;
+ } else {
+ i7 = 0;
+ }
+ i6 = (i6 | 0) == 4;
+ __tr_flush_block(i2, i7, (HEAP32[i5 >> 2] | 0) - i8 | 0, i6 & 1);
+ HEAP32[i4 >> 2] = HEAP32[i5 >> 2];
+ i4 = HEAP32[i2 >> 2] | 0;
+ i7 = i4 + 28 | 0;
+ i5 = HEAP32[i7 >> 2] | 0;
+ i10 = HEAP32[i5 + 20 >> 2] | 0;
+ i8 = i4 + 16 | 0;
+ i9 = HEAP32[i8 >> 2] | 0;
+ i9 = i10 >>> 0 > i9 >>> 0 ? i9 : i10;
+ if ((i9 | 0) != 0 ? (i3 = i4 + 12 | 0, _memcpy(HEAP32[i3 >> 2] | 0, HEAP32[i5 + 16 >> 2] | 0, i9 | 0) | 0, HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + i9, i3 = (HEAP32[i7 >> 2] | 0) + 16 | 0, HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + i9, i3 = i4 + 20 | 0, HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + i9, HEAP32[i8 >> 2] = (HEAP32[i8 >> 2] | 0) - i9, i3 = HEAP32[i7 >> 2] | 0, i35 = i3 + 20 | 0, i36 = HEAP32[i35 >> 2] | 0, HEAP32[i35 >> 2] = i36 - i9, (i36 | 0) == (i9 | 0)) : 0) {
+ HEAP32[i3 + 16 >> 2] = HEAP32[i3 + 8 >> 2];
+ }
+ if ((HEAP32[(HEAP32[i2 >> 2] | 0) + 16 >> 2] | 0) == 0) {
+ i36 = i6 ? 2 : 0;
+ STACKTOP = i1;
+ return i36 | 0;
+ } else {
+ i36 = i6 ? 3 : 1;
+ STACKTOP = i1;
+ return i36 | 0;
+ }
+ } else if ((i30 | 0) == 50) {
+ STACKTOP = i1;
+ return i2 | 0;
+ }
+ return 0;
+}
+function _inflate_fast(i7, i19) {
+ i7 = i7 | 0;
+ i19 = i19 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0, i37 = 0;
+ i1 = STACKTOP;
+ i11 = HEAP32[i7 + 28 >> 2] | 0;
+ i29 = HEAP32[i7 >> 2] | 0;
+ i5 = i7 + 4 | 0;
+ i8 = i29 + ((HEAP32[i5 >> 2] | 0) + -6) | 0;
+ i9 = i7 + 12 | 0;
+ i28 = HEAP32[i9 >> 2] | 0;
+ i4 = i7 + 16 | 0;
+ i25 = HEAP32[i4 >> 2] | 0;
+ i6 = i28 + (i25 + -258) | 0;
+ i17 = HEAP32[i11 + 44 >> 2] | 0;
+ i12 = HEAP32[i11 + 48 >> 2] | 0;
+ i18 = HEAP32[i11 + 52 >> 2] | 0;
+ i3 = i11 + 56 | 0;
+ i2 = i11 + 60 | 0;
+ i16 = HEAP32[i11 + 76 >> 2] | 0;
+ i13 = HEAP32[i11 + 80 >> 2] | 0;
+ i14 = (1 << HEAP32[i11 + 84 >> 2]) + -1 | 0;
+ i15 = (1 << HEAP32[i11 + 88 >> 2]) + -1 | 0;
+ i19 = i28 + (i25 + ~i19) | 0;
+ i25 = i11 + 7104 | 0;
+ i20 = i18 + -1 | 0;
+ i27 = (i12 | 0) == 0;
+ i24 = (HEAP32[i11 + 40 >> 2] | 0) + -1 | 0;
+ i21 = i24 + i12 | 0;
+ i22 = i12 + -1 | 0;
+ i23 = i19 + -1 | 0;
+ i26 = i19 - i12 | 0;
+ i31 = HEAP32[i2 >> 2] | 0;
+ i30 = HEAP32[i3 >> 2] | 0;
+ i29 = i29 + -1 | 0;
+ i28 = i28 + -1 | 0;
+ L1 : do {
+ if (i31 >>> 0 < 15) {
+ i37 = i29 + 2 | 0;
+ i33 = i31 + 16 | 0;
+ i30 = ((HEAPU8[i29 + 1 | 0] | 0) << i31) + i30 + ((HEAPU8[i37] | 0) << i31 + 8) | 0;
+ i29 = i37;
+ } else {
+ i33 = i31;
+ }
+ i31 = i30 & i14;
+ i34 = HEAP8[i16 + (i31 << 2) | 0] | 0;
+ i32 = HEAP16[i16 + (i31 << 2) + 2 >> 1] | 0;
+ i31 = HEAPU8[i16 + (i31 << 2) + 1 | 0] | 0;
+ i30 = i30 >>> i31;
+ i31 = i33 - i31 | 0;
+ do {
+ if (!(i34 << 24 >> 24 == 0)) {
+ i33 = i34 & 255;
+ while (1) {
+ if ((i33 & 16 | 0) != 0) {
+ break;
+ }
+ if ((i33 & 64 | 0) != 0) {
+ i10 = 55;
+ break L1;
+ }
+ i37 = (i30 & (1 << i33) + -1) + (i32 & 65535) | 0;
+ i33 = HEAP8[i16 + (i37 << 2) | 0] | 0;
+ i32 = HEAP16[i16 + (i37 << 2) + 2 >> 1] | 0;
+ i37 = HEAPU8[i16 + (i37 << 2) + 1 | 0] | 0;
+ i30 = i30 >>> i37;
+ i31 = i31 - i37 | 0;
+ if (i33 << 24 >> 24 == 0) {
+ i10 = 6;
+ break;
+ } else {
+ i33 = i33 & 255;
+ }
+ }
+ if ((i10 | 0) == 6) {
+ i32 = i32 & 255;
+ i10 = 7;
+ break;
+ }
+ i32 = i32 & 65535;
+ i33 = i33 & 15;
+ if ((i33 | 0) != 0) {
+ if (i31 >>> 0 < i33 >>> 0) {
+ i29 = i29 + 1 | 0;
+ i35 = i31 + 8 | 0;
+ i34 = ((HEAPU8[i29] | 0) << i31) + i30 | 0;
+ } else {
+ i35 = i31;
+ i34 = i30;
+ }
+ i31 = i35 - i33 | 0;
+ i30 = i34 >>> i33;
+ i32 = (i34 & (1 << i33) + -1) + i32 | 0;
+ }
+ if (i31 >>> 0 < 15) {
+ i37 = i29 + 2 | 0;
+ i34 = i31 + 16 | 0;
+ i30 = ((HEAPU8[i29 + 1 | 0] | 0) << i31) + i30 + ((HEAPU8[i37] | 0) << i31 + 8) | 0;
+ i29 = i37;
+ } else {
+ i34 = i31;
+ }
+ i37 = i30 & i15;
+ i33 = HEAP16[i13 + (i37 << 2) + 2 >> 1] | 0;
+ i31 = HEAPU8[i13 + (i37 << 2) + 1 | 0] | 0;
+ i30 = i30 >>> i31;
+ i31 = i34 - i31 | 0;
+ i34 = HEAPU8[i13 + (i37 << 2) | 0] | 0;
+ if ((i34 & 16 | 0) == 0) {
+ do {
+ if ((i34 & 64 | 0) != 0) {
+ i10 = 52;
+ break L1;
+ }
+ i34 = (i30 & (1 << i34) + -1) + (i33 & 65535) | 0;
+ i33 = HEAP16[i13 + (i34 << 2) + 2 >> 1] | 0;
+ i37 = HEAPU8[i13 + (i34 << 2) + 1 | 0] | 0;
+ i30 = i30 >>> i37;
+ i31 = i31 - i37 | 0;
+ i34 = HEAPU8[i13 + (i34 << 2) | 0] | 0;
+ } while ((i34 & 16 | 0) == 0);
+ }
+ i33 = i33 & 65535;
+ i34 = i34 & 15;
+ if (i31 >>> 0 < i34 >>> 0) {
+ i35 = i29 + 1 | 0;
+ i30 = ((HEAPU8[i35] | 0) << i31) + i30 | 0;
+ i36 = i31 + 8 | 0;
+ if (i36 >>> 0 < i34 >>> 0) {
+ i29 = i29 + 2 | 0;
+ i31 = i31 + 16 | 0;
+ i30 = ((HEAPU8[i29] | 0) << i36) + i30 | 0;
+ } else {
+ i31 = i36;
+ i29 = i35;
+ }
+ }
+ i33 = (i30 & (1 << i34) + -1) + i33 | 0;
+ i30 = i30 >>> i34;
+ i31 = i31 - i34 | 0;
+ i35 = i28;
+ i34 = i35 - i19 | 0;
+ if (!(i33 >>> 0 > i34 >>> 0)) {
+ i34 = i28 + (0 - i33) | 0;
+ while (1) {
+ HEAP8[i28 + 1 | 0] = HEAP8[i34 + 1 | 0] | 0;
+ HEAP8[i28 + 2 | 0] = HEAP8[i34 + 2 | 0] | 0;
+ i35 = i34 + 3 | 0;
+ i33 = i28 + 3 | 0;
+ HEAP8[i33] = HEAP8[i35] | 0;
+ i32 = i32 + -3 | 0;
+ if (!(i32 >>> 0 > 2)) {
+ break;
+ } else {
+ i34 = i35;
+ i28 = i33;
+ }
+ }
+ if ((i32 | 0) == 0) {
+ i28 = i33;
+ break;
+ }
+ i33 = i28 + 4 | 0;
+ HEAP8[i33] = HEAP8[i34 + 4 | 0] | 0;
+ if (!(i32 >>> 0 > 1)) {
+ i28 = i33;
+ break;
+ }
+ i28 = i28 + 5 | 0;
+ HEAP8[i28] = HEAP8[i34 + 5 | 0] | 0;
+ break;
+ }
+ i34 = i33 - i34 | 0;
+ if (i34 >>> 0 > i17 >>> 0 ? (HEAP32[i25 >> 2] | 0) != 0 : 0) {
+ i10 = 22;
+ break L1;
+ }
+ do {
+ if (i27) {
+ i36 = i18 + (i24 - i34) | 0;
+ if (i34 >>> 0 < i32 >>> 0) {
+ i32 = i32 - i34 | 0;
+ i35 = i33 - i35 | 0;
+ i37 = i28;
+ do {
+ i36 = i36 + 1 | 0;
+ i37 = i37 + 1 | 0;
+ HEAP8[i37] = HEAP8[i36] | 0;
+ i34 = i34 + -1 | 0;
+ } while ((i34 | 0) != 0);
+ i33 = i28 + (i23 + i35 + (1 - i33)) | 0;
+ i28 = i28 + (i19 + i35) | 0;
+ } else {
+ i33 = i36;
+ }
+ } else {
+ if (!(i12 >>> 0 < i34 >>> 0)) {
+ i36 = i18 + (i22 - i34) | 0;
+ if (!(i34 >>> 0 < i32 >>> 0)) {
+ i33 = i36;
+ break;
+ }
+ i32 = i32 - i34 | 0;
+ i35 = i33 - i35 | 0;
+ i37 = i28;
+ do {
+ i36 = i36 + 1 | 0;
+ i37 = i37 + 1 | 0;
+ HEAP8[i37] = HEAP8[i36] | 0;
+ i34 = i34 + -1 | 0;
+ } while ((i34 | 0) != 0);
+ i33 = i28 + (i23 + i35 + (1 - i33)) | 0;
+ i28 = i28 + (i19 + i35) | 0;
+ break;
+ }
+ i37 = i18 + (i21 - i34) | 0;
+ i36 = i34 - i12 | 0;
+ if (i36 >>> 0 < i32 >>> 0) {
+ i32 = i32 - i36 | 0;
+ i34 = i33 - i35 | 0;
+ i35 = i28;
+ do {
+ i37 = i37 + 1 | 0;
+ i35 = i35 + 1 | 0;
+ HEAP8[i35] = HEAP8[i37] | 0;
+ i36 = i36 + -1 | 0;
+ } while ((i36 | 0) != 0);
+ i35 = i28 + (i26 + i34) | 0;
+ if (i12 >>> 0 < i32 >>> 0) {
+ i32 = i32 - i12 | 0;
+ i37 = i20;
+ i36 = i12;
+ do {
+ i37 = i37 + 1 | 0;
+ i35 = i35 + 1 | 0;
+ HEAP8[i35] = HEAP8[i37] | 0;
+ i36 = i36 + -1 | 0;
+ } while ((i36 | 0) != 0);
+ i33 = i28 + (i23 + i34 + (1 - i33)) | 0;
+ i28 = i28 + (i19 + i34) | 0;
+ } else {
+ i33 = i20;
+ i28 = i35;
+ }
+ } else {
+ i33 = i37;
+ }
+ }
+ } while (0);
+ if (i32 >>> 0 > 2) {
+ do {
+ HEAP8[i28 + 1 | 0] = HEAP8[i33 + 1 | 0] | 0;
+ HEAP8[i28 + 2 | 0] = HEAP8[i33 + 2 | 0] | 0;
+ i33 = i33 + 3 | 0;
+ i28 = i28 + 3 | 0;
+ HEAP8[i28] = HEAP8[i33] | 0;
+ i32 = i32 + -3 | 0;
+ } while (i32 >>> 0 > 2);
+ }
+ if ((i32 | 0) != 0) {
+ i34 = i28 + 1 | 0;
+ HEAP8[i34] = HEAP8[i33 + 1 | 0] | 0;
+ if (i32 >>> 0 > 1) {
+ i28 = i28 + 2 | 0;
+ HEAP8[i28] = HEAP8[i33 + 2 | 0] | 0;
+ } else {
+ i28 = i34;
+ }
+ }
+ } else {
+ i32 = i32 & 255;
+ i10 = 7;
+ }
+ } while (0);
+ if ((i10 | 0) == 7) {
+ i10 = 0;
+ i28 = i28 + 1 | 0;
+ HEAP8[i28] = i32;
+ }
+ } while (i29 >>> 0 < i8 >>> 0 & i28 >>> 0 < i6 >>> 0);
+ do {
+ if ((i10 | 0) == 22) {
+ HEAP32[i7 + 24 >> 2] = 14384;
+ HEAP32[i11 >> 2] = 29;
+ } else if ((i10 | 0) == 52) {
+ HEAP32[i7 + 24 >> 2] = 14416;
+ HEAP32[i11 >> 2] = 29;
+ } else if ((i10 | 0) == 55) {
+ if ((i33 & 32 | 0) == 0) {
+ HEAP32[i7 + 24 >> 2] = 14440;
+ HEAP32[i11 >> 2] = 29;
+ break;
+ } else {
+ HEAP32[i11 >> 2] = 11;
+ break;
+ }
+ }
+ } while (0);
+ i37 = i31 >>> 3;
+ i11 = i29 + (0 - i37) | 0;
+ i10 = i31 - (i37 << 3) | 0;
+ i12 = (1 << i10) + -1 & i30;
+ HEAP32[i7 >> 2] = i29 + (1 - i37);
+ HEAP32[i9 >> 2] = i28 + 1;
+ if (i11 >>> 0 < i8 >>> 0) {
+ i7 = i8 - i11 | 0;
+ } else {
+ i7 = i8 - i11 | 0;
+ }
+ HEAP32[i5 >> 2] = i7 + 5;
+ if (i28 >>> 0 < i6 >>> 0) {
+ i37 = i6 - i28 | 0;
+ i37 = i37 + 257 | 0;
+ HEAP32[i4 >> 2] = i37;
+ HEAP32[i3 >> 2] = i12;
+ HEAP32[i2 >> 2] = i10;
+ STACKTOP = i1;
+ return;
+ } else {
+ i37 = i6 - i28 | 0;
+ i37 = i37 + 257 | 0;
+ HEAP32[i4 >> 2] = i37;
+ HEAP32[i3 >> 2] = i12;
+ HEAP32[i2 >> 2] = i10;
+ STACKTOP = i1;
+ return;
+ }
+}
+function _send_tree(i2, i13, i12) {
+ i2 = i2 | 0;
+ i13 = i13 | 0;
+ i12 = i12 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0;
+ i11 = STACKTOP;
+ i15 = HEAP16[i13 + 2 >> 1] | 0;
+ i16 = i15 << 16 >> 16 == 0;
+ i7 = i2 + 2754 | 0;
+ i4 = i2 + 5820 | 0;
+ i8 = i2 + 2752 | 0;
+ i3 = i2 + 5816 | 0;
+ i14 = i2 + 20 | 0;
+ i10 = i2 + 8 | 0;
+ i9 = i2 + 2758 | 0;
+ i1 = i2 + 2756 | 0;
+ i5 = i2 + 2750 | 0;
+ i6 = i2 + 2748 | 0;
+ i21 = i16 ? 138 : 7;
+ i23 = i16 ? 3 : 4;
+ i18 = 0;
+ i15 = i15 & 65535;
+ i24 = -1;
+ L1 : while (1) {
+ i20 = 0;
+ while (1) {
+ if ((i18 | 0) > (i12 | 0)) {
+ break L1;
+ }
+ i18 = i18 + 1 | 0;
+ i19 = HEAP16[i13 + (i18 << 2) + 2 >> 1] | 0;
+ i16 = i19 & 65535;
+ i22 = i20 + 1 | 0;
+ i17 = (i15 | 0) == (i16 | 0);
+ if (!((i22 | 0) < (i21 | 0) & i17)) {
+ break;
+ } else {
+ i20 = i22;
+ }
+ }
+ do {
+ if ((i22 | 0) >= (i23 | 0)) {
+ if ((i15 | 0) != 0) {
+ if ((i15 | 0) == (i24 | 0)) {
+ i23 = HEAP16[i3 >> 1] | 0;
+ i21 = HEAP32[i4 >> 2] | 0;
+ i20 = i22;
+ } else {
+ i22 = HEAPU16[i2 + (i15 << 2) + 2686 >> 1] | 0;
+ i21 = HEAP32[i4 >> 2] | 0;
+ i24 = HEAPU16[i2 + (i15 << 2) + 2684 >> 1] | 0;
+ i25 = HEAPU16[i3 >> 1] | 0 | i24 << i21;
+ i23 = i25 & 65535;
+ HEAP16[i3 >> 1] = i23;
+ if ((i21 | 0) > (16 - i22 | 0)) {
+ i23 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i23 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i23 | 0] = i25;
+ i23 = (HEAPU16[i3 >> 1] | 0) >>> 8 & 255;
+ i21 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i21 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i21 | 0] = i23;
+ i21 = HEAP32[i4 >> 2] | 0;
+ i23 = i24 >>> (16 - i21 | 0) & 65535;
+ HEAP16[i3 >> 1] = i23;
+ i21 = i22 + -16 + i21 | 0;
+ } else {
+ i21 = i21 + i22 | 0;
+ }
+ HEAP32[i4 >> 2] = i21;
+ }
+ i22 = HEAPU16[i5 >> 1] | 0;
+ i24 = HEAPU16[i6 >> 1] | 0;
+ i23 = i23 & 65535 | i24 << i21;
+ HEAP16[i3 >> 1] = i23;
+ if ((i21 | 0) > (16 - i22 | 0)) {
+ i21 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i21 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i21 | 0] = i23;
+ i23 = (HEAPU16[i3 >> 1] | 0) >>> 8 & 255;
+ i21 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i21 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i21 | 0] = i23;
+ i21 = HEAP32[i4 >> 2] | 0;
+ i23 = i24 >>> (16 - i21 | 0);
+ HEAP16[i3 >> 1] = i23;
+ i21 = i22 + -16 + i21 | 0;
+ } else {
+ i21 = i21 + i22 | 0;
+ }
+ HEAP32[i4 >> 2] = i21;
+ i20 = i20 + 65533 & 65535;
+ i22 = i23 & 65535 | i20 << i21;
+ HEAP16[i3 >> 1] = i22;
+ if ((i21 | 0) > 14) {
+ i26 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i26 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i26 | 0] = i22;
+ i26 = (HEAPU16[i3 >> 1] | 0) >>> 8 & 255;
+ i27 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i27 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i27 | 0] = i26;
+ i27 = HEAP32[i4 >> 2] | 0;
+ HEAP16[i3 >> 1] = i20 >>> (16 - i27 | 0);
+ HEAP32[i4 >> 2] = i27 + -14;
+ break;
+ } else {
+ HEAP32[i4 >> 2] = i21 + 2;
+ break;
+ }
+ }
+ if ((i22 | 0) < 11) {
+ i24 = HEAPU16[i7 >> 1] | 0;
+ i23 = HEAP32[i4 >> 2] | 0;
+ i21 = HEAPU16[i8 >> 1] | 0;
+ i22 = HEAPU16[i3 >> 1] | 0 | i21 << i23;
+ HEAP16[i3 >> 1] = i22;
+ if ((i23 | 0) > (16 - i24 | 0)) {
+ i27 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i27 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i27 | 0] = i22;
+ i22 = (HEAPU16[i3 >> 1] | 0) >>> 8 & 255;
+ i27 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i27 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i27 | 0] = i22;
+ i27 = HEAP32[i4 >> 2] | 0;
+ i22 = i21 >>> (16 - i27 | 0);
+ HEAP16[i3 >> 1] = i22;
+ i21 = i24 + -16 + i27 | 0;
+ } else {
+ i21 = i23 + i24 | 0;
+ }
+ HEAP32[i4 >> 2] = i21;
+ i20 = i20 + 65534 & 65535;
+ i22 = i22 & 65535 | i20 << i21;
+ HEAP16[i3 >> 1] = i22;
+ if ((i21 | 0) > 13) {
+ i26 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i26 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i26 | 0] = i22;
+ i26 = (HEAPU16[i3 >> 1] | 0) >>> 8 & 255;
+ i27 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i27 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i27 | 0] = i26;
+ i27 = HEAP32[i4 >> 2] | 0;
+ HEAP16[i3 >> 1] = i20 >>> (16 - i27 | 0);
+ HEAP32[i4 >> 2] = i27 + -13;
+ break;
+ } else {
+ HEAP32[i4 >> 2] = i21 + 3;
+ break;
+ }
+ } else {
+ i21 = HEAPU16[i9 >> 1] | 0;
+ i24 = HEAP32[i4 >> 2] | 0;
+ i23 = HEAPU16[i1 >> 1] | 0;
+ i22 = HEAPU16[i3 >> 1] | 0 | i23 << i24;
+ HEAP16[i3 >> 1] = i22;
+ if ((i24 | 0) > (16 - i21 | 0)) {
+ i27 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i27 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i27 | 0] = i22;
+ i22 = (HEAPU16[i3 >> 1] | 0) >>> 8 & 255;
+ i27 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i27 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i27 | 0] = i22;
+ i27 = HEAP32[i4 >> 2] | 0;
+ i22 = i23 >>> (16 - i27 | 0);
+ HEAP16[i3 >> 1] = i22;
+ i21 = i21 + -16 + i27 | 0;
+ } else {
+ i21 = i24 + i21 | 0;
+ }
+ HEAP32[i4 >> 2] = i21;
+ i20 = i20 + 65526 & 65535;
+ i22 = i22 & 65535 | i20 << i21;
+ HEAP16[i3 >> 1] = i22;
+ if ((i21 | 0) > 9) {
+ i26 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i26 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i26 | 0] = i22;
+ i26 = (HEAPU16[i3 >> 1] | 0) >>> 8 & 255;
+ i27 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i27 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i27 | 0] = i26;
+ i27 = HEAP32[i4 >> 2] | 0;
+ HEAP16[i3 >> 1] = i20 >>> (16 - i27 | 0);
+ HEAP32[i4 >> 2] = i27 + -9;
+ break;
+ } else {
+ HEAP32[i4 >> 2] = i21 + 7;
+ break;
+ }
+ }
+ } else {
+ i20 = i2 + (i15 << 2) + 2686 | 0;
+ i21 = i2 + (i15 << 2) + 2684 | 0;
+ i23 = HEAP32[i4 >> 2] | 0;
+ i26 = HEAP16[i3 >> 1] | 0;
+ do {
+ i24 = HEAPU16[i20 >> 1] | 0;
+ i25 = HEAPU16[i21 >> 1] | 0;
+ i27 = i26 & 65535 | i25 << i23;
+ i26 = i27 & 65535;
+ HEAP16[i3 >> 1] = i26;
+ if ((i23 | 0) > (16 - i24 | 0)) {
+ i26 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i26 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i26 | 0] = i27;
+ i26 = (HEAPU16[i3 >> 1] | 0) >>> 8 & 255;
+ i23 = HEAP32[i14 >> 2] | 0;
+ HEAP32[i14 >> 2] = i23 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i23 | 0] = i26;
+ i23 = HEAP32[i4 >> 2] | 0;
+ i26 = i25 >>> (16 - i23 | 0) & 65535;
+ HEAP16[i3 >> 1] = i26;
+ i23 = i24 + -16 + i23 | 0;
+ } else {
+ i23 = i23 + i24 | 0;
+ }
+ HEAP32[i4 >> 2] = i23;
+ i22 = i22 + -1 | 0;
+ } while ((i22 | 0) != 0);
+ }
+ } while (0);
+ if (i19 << 16 >> 16 == 0) {
+ i24 = i15;
+ i21 = 138;
+ i23 = 3;
+ i15 = i16;
+ continue;
+ }
+ i24 = i15;
+ i21 = i17 ? 6 : 7;
+ i23 = i17 ? 3 : 4;
+ i15 = i16;
+ }
+ STACKTOP = i11;
+ return;
+}
+function __tr_flush_block(i2, i4, i6, i3) {
+ i2 = i2 | 0;
+ i4 = i4 | 0;
+ i6 = i6 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0;
+ i1 = STACKTOP;
+ if ((HEAP32[i2 + 132 >> 2] | 0) > 0) {
+ i5 = (HEAP32[i2 >> 2] | 0) + 44 | 0;
+ if ((HEAP32[i5 >> 2] | 0) == 2) {
+ i8 = -201342849;
+ i9 = 0;
+ while (1) {
+ if ((i8 & 1 | 0) != 0 ? (HEAP16[i2 + (i9 << 2) + 148 >> 1] | 0) != 0 : 0) {
+ i8 = 0;
+ break;
+ }
+ i9 = i9 + 1 | 0;
+ if ((i9 | 0) < 32) {
+ i8 = i8 >>> 1;
+ } else {
+ i7 = 6;
+ break;
+ }
+ }
+ L9 : do {
+ if ((i7 | 0) == 6) {
+ if (((HEAP16[i2 + 184 >> 1] | 0) == 0 ? (HEAP16[i2 + 188 >> 1] | 0) == 0 : 0) ? (HEAP16[i2 + 200 >> 1] | 0) == 0 : 0) {
+ i8 = 32;
+ while (1) {
+ i7 = i8 + 1 | 0;
+ if ((HEAP16[i2 + (i8 << 2) + 148 >> 1] | 0) != 0) {
+ i8 = 1;
+ break L9;
+ }
+ if ((i7 | 0) < 256) {
+ i8 = i7;
+ } else {
+ i8 = 0;
+ break;
+ }
+ }
+ } else {
+ i8 = 1;
+ }
+ }
+ } while (0);
+ HEAP32[i5 >> 2] = i8;
+ }
+ _build_tree(i2, i2 + 2840 | 0);
+ _build_tree(i2, i2 + 2852 | 0);
+ _scan_tree(i2, i2 + 148 | 0, HEAP32[i2 + 2844 >> 2] | 0);
+ _scan_tree(i2, i2 + 2440 | 0, HEAP32[i2 + 2856 >> 2] | 0);
+ _build_tree(i2, i2 + 2864 | 0);
+ i5 = 18;
+ while (1) {
+ i7 = i5 + -1 | 0;
+ if ((HEAP16[i2 + (HEAPU8[2888 + i5 | 0] << 2) + 2686 >> 1] | 0) != 0) {
+ break;
+ }
+ if ((i7 | 0) > 2) {
+ i5 = i7;
+ } else {
+ i5 = i7;
+ break;
+ }
+ }
+ i10 = i2 + 5800 | 0;
+ i7 = (i5 * 3 | 0) + 17 + (HEAP32[i10 >> 2] | 0) | 0;
+ HEAP32[i10 >> 2] = i7;
+ i7 = (i7 + 10 | 0) >>> 3;
+ i10 = ((HEAP32[i2 + 5804 >> 2] | 0) + 10 | 0) >>> 3;
+ i9 = i10 >>> 0 > i7 >>> 0 ? i7 : i10;
+ } else {
+ i10 = i6 + 5 | 0;
+ i5 = 0;
+ i9 = i10;
+ }
+ do {
+ if ((i6 + 4 | 0) >>> 0 > i9 >>> 0 | (i4 | 0) == 0) {
+ i4 = i2 + 5820 | 0;
+ i7 = HEAP32[i4 >> 2] | 0;
+ i8 = (i7 | 0) > 13;
+ if ((HEAP32[i2 + 136 >> 2] | 0) == 4 | (i10 | 0) == (i9 | 0)) {
+ i9 = i3 + 2 & 65535;
+ i6 = i2 + 5816 | 0;
+ i5 = HEAPU16[i6 >> 1] | i9 << i7;
+ HEAP16[i6 >> 1] = i5;
+ if (i8) {
+ i12 = i2 + 20 | 0;
+ i13 = HEAP32[i12 >> 2] | 0;
+ HEAP32[i12 >> 2] = i13 + 1;
+ i14 = i2 + 8 | 0;
+ HEAP8[(HEAP32[i14 >> 2] | 0) + i13 | 0] = i5;
+ i13 = (HEAPU16[i6 >> 1] | 0) >>> 8 & 255;
+ i5 = HEAP32[i12 >> 2] | 0;
+ HEAP32[i12 >> 2] = i5 + 1;
+ HEAP8[(HEAP32[i14 >> 2] | 0) + i5 | 0] = i13;
+ i5 = HEAP32[i4 >> 2] | 0;
+ HEAP16[i6 >> 1] = i9 >>> (16 - i5 | 0);
+ i5 = i5 + -13 | 0;
+ } else {
+ i5 = i7 + 3 | 0;
+ }
+ HEAP32[i4 >> 2] = i5;
+ _compress_block(i2, 1136, 2288);
+ break;
+ }
+ i10 = i3 + 4 & 65535;
+ i6 = i2 + 5816 | 0;
+ i9 = HEAPU16[i6 >> 1] | i10 << i7;
+ HEAP16[i6 >> 1] = i9;
+ if (i8) {
+ i13 = i2 + 20 | 0;
+ i12 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i12 + 1;
+ i14 = i2 + 8 | 0;
+ HEAP8[(HEAP32[i14 >> 2] | 0) + i12 | 0] = i9;
+ i9 = (HEAPU16[i6 >> 1] | 0) >>> 8 & 255;
+ i12 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i12 + 1;
+ HEAP8[(HEAP32[i14 >> 2] | 0) + i12 | 0] = i9;
+ i12 = HEAP32[i4 >> 2] | 0;
+ i9 = i10 >>> (16 - i12 | 0);
+ HEAP16[i6 >> 1] = i9;
+ i12 = i12 + -13 | 0;
+ } else {
+ i12 = i7 + 3 | 0;
+ }
+ HEAP32[i4 >> 2] = i12;
+ i7 = HEAP32[i2 + 2844 >> 2] | 0;
+ i8 = HEAP32[i2 + 2856 >> 2] | 0;
+ i10 = i7 + 65280 & 65535;
+ i11 = i9 & 65535 | i10 << i12;
+ HEAP16[i6 >> 1] = i11;
+ if ((i12 | 0) > 11) {
+ i13 = i2 + 20 | 0;
+ i9 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i9 + 1;
+ i14 = i2 + 8 | 0;
+ HEAP8[(HEAP32[i14 >> 2] | 0) + i9 | 0] = i11;
+ i11 = (HEAPU16[i6 >> 1] | 0) >>> 8 & 255;
+ i9 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i9 + 1;
+ HEAP8[(HEAP32[i14 >> 2] | 0) + i9 | 0] = i11;
+ i9 = HEAP32[i4 >> 2] | 0;
+ i11 = i10 >>> (16 - i9 | 0);
+ HEAP16[i6 >> 1] = i11;
+ i9 = i9 + -11 | 0;
+ } else {
+ i9 = i12 + 5 | 0;
+ }
+ HEAP32[i4 >> 2] = i9;
+ i10 = i8 & 65535;
+ i11 = i10 << i9 | i11 & 65535;
+ HEAP16[i6 >> 1] = i11;
+ if ((i9 | 0) > 11) {
+ i13 = i2 + 20 | 0;
+ i9 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i9 + 1;
+ i14 = i2 + 8 | 0;
+ HEAP8[(HEAP32[i14 >> 2] | 0) + i9 | 0] = i11;
+ i11 = (HEAPU16[i6 >> 1] | 0) >>> 8 & 255;
+ i9 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i13 >> 2] = i9 + 1;
+ HEAP8[(HEAP32[i14 >> 2] | 0) + i9 | 0] = i11;
+ i9 = HEAP32[i4 >> 2] | 0;
+ i11 = i10 >>> (16 - i9 | 0);
+ HEAP16[i6 >> 1] = i11;
+ i9 = i9 + -11 | 0;
+ } else {
+ i9 = i9 + 5 | 0;
+ }
+ HEAP32[i4 >> 2] = i9;
+ i10 = i5 + 65533 & 65535;
+ i14 = i10 << i9 | i11 & 65535;
+ HEAP16[i6 >> 1] = i14;
+ if ((i9 | 0) > 12) {
+ i12 = i2 + 20 | 0;
+ i11 = HEAP32[i12 >> 2] | 0;
+ HEAP32[i12 >> 2] = i11 + 1;
+ i13 = i2 + 8 | 0;
+ HEAP8[(HEAP32[i13 >> 2] | 0) + i11 | 0] = i14;
+ i14 = (HEAPU16[i6 >> 1] | 0) >>> 8 & 255;
+ i11 = HEAP32[i12 >> 2] | 0;
+ HEAP32[i12 >> 2] = i11 + 1;
+ HEAP8[(HEAP32[i13 >> 2] | 0) + i11 | 0] = i14;
+ i11 = HEAP32[i4 >> 2] | 0;
+ i14 = i10 >>> (16 - i11 | 0);
+ HEAP16[i6 >> 1] = i14;
+ i11 = i11 + -12 | 0;
+ } else {
+ i11 = i9 + 4 | 0;
+ }
+ HEAP32[i4 >> 2] = i11;
+ if ((i5 | 0) > -1) {
+ i10 = i2 + 20 | 0;
+ i9 = i2 + 8 | 0;
+ i12 = 0;
+ while (1) {
+ i13 = HEAPU16[i2 + (HEAPU8[2888 + i12 | 0] << 2) + 2686 >> 1] | 0;
+ i14 = i13 << i11 | i14 & 65535;
+ HEAP16[i6 >> 1] = i14;
+ if ((i11 | 0) > 13) {
+ i11 = HEAP32[i10 >> 2] | 0;
+ HEAP32[i10 >> 2] = i11 + 1;
+ HEAP8[(HEAP32[i9 >> 2] | 0) + i11 | 0] = i14;
+ i14 = (HEAPU16[i6 >> 1] | 0) >>> 8 & 255;
+ i11 = HEAP32[i10 >> 2] | 0;
+ HEAP32[i10 >> 2] = i11 + 1;
+ HEAP8[(HEAP32[i9 >> 2] | 0) + i11 | 0] = i14;
+ i11 = HEAP32[i4 >> 2] | 0;
+ i14 = i13 >>> (16 - i11 | 0);
+ HEAP16[i6 >> 1] = i14;
+ i11 = i11 + -13 | 0;
+ } else {
+ i11 = i11 + 3 | 0;
+ }
+ HEAP32[i4 >> 2] = i11;
+ if ((i12 | 0) == (i5 | 0)) {
+ break;
+ } else {
+ i12 = i12 + 1 | 0;
+ }
+ }
+ }
+ i13 = i2 + 148 | 0;
+ _send_tree(i2, i13, i7);
+ i14 = i2 + 2440 | 0;
+ _send_tree(i2, i14, i8);
+ _compress_block(i2, i13, i14);
+ } else {
+ __tr_stored_block(i2, i4, i6, i3);
+ }
+ } while (0);
+ _init_block(i2);
+ if ((i3 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ i3 = i2 + 5820 | 0;
+ i4 = HEAP32[i3 >> 2] | 0;
+ if ((i4 | 0) <= 8) {
+ i5 = i2 + 5816 | 0;
+ if ((i4 | 0) > 0) {
+ i13 = HEAP16[i5 >> 1] & 255;
+ i12 = i2 + 20 | 0;
+ i14 = HEAP32[i12 >> 2] | 0;
+ HEAP32[i12 >> 2] = i14 + 1;
+ HEAP8[(HEAP32[i2 + 8 >> 2] | 0) + i14 | 0] = i13;
+ }
+ } else {
+ i5 = i2 + 5816 | 0;
+ i14 = HEAP16[i5 >> 1] & 255;
+ i11 = i2 + 20 | 0;
+ i12 = HEAP32[i11 >> 2] | 0;
+ HEAP32[i11 >> 2] = i12 + 1;
+ i13 = i2 + 8 | 0;
+ HEAP8[(HEAP32[i13 >> 2] | 0) + i12 | 0] = i14;
+ i12 = (HEAPU16[i5 >> 1] | 0) >>> 8 & 255;
+ i14 = HEAP32[i11 >> 2] | 0;
+ HEAP32[i11 >> 2] = i14 + 1;
+ HEAP8[(HEAP32[i13 >> 2] | 0) + i14 | 0] = i12;
+ }
+ HEAP16[i5 >> 1] = 0;
+ HEAP32[i3 >> 2] = 0;
+ STACKTOP = i1;
+ return;
+}
+function _deflate_fast(i3, i6) {
+ i3 = i3 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0;
+ i1 = STACKTOP;
+ i20 = i3 + 116 | 0;
+ i22 = (i6 | 0) == 0;
+ i23 = i3 + 72 | 0;
+ i24 = i3 + 88 | 0;
+ i5 = i3 + 108 | 0;
+ i7 = i3 + 56 | 0;
+ i9 = i3 + 84 | 0;
+ i10 = i3 + 68 | 0;
+ i11 = i3 + 52 | 0;
+ i12 = i3 + 64 | 0;
+ i19 = i3 + 44 | 0;
+ i21 = i3 + 96 | 0;
+ i16 = i3 + 112 | 0;
+ i13 = i3 + 5792 | 0;
+ i17 = i3 + 5796 | 0;
+ i18 = i3 + 5784 | 0;
+ i14 = i3 + 5788 | 0;
+ i15 = i3 + 128 | 0;
+ i4 = i3 + 92 | 0;
+ while (1) {
+ if ((HEAP32[i20 >> 2] | 0) >>> 0 < 262) {
+ _fill_window(i3);
+ i25 = HEAP32[i20 >> 2] | 0;
+ if (i25 >>> 0 < 262 & i22) {
+ i2 = 0;
+ i25 = 34;
+ break;
+ }
+ if ((i25 | 0) == 0) {
+ i25 = 26;
+ break;
+ }
+ if (!(i25 >>> 0 > 2)) {
+ i25 = 9;
+ } else {
+ i25 = 6;
+ }
+ } else {
+ i25 = 6;
+ }
+ if ((i25 | 0) == 6) {
+ i25 = 0;
+ i26 = HEAP32[i5 >> 2] | 0;
+ i34 = ((HEAPU8[(HEAP32[i7 >> 2] | 0) + (i26 + 2) | 0] | 0) ^ HEAP32[i23 >> 2] << HEAP32[i24 >> 2]) & HEAP32[i9 >> 2];
+ HEAP32[i23 >> 2] = i34;
+ i34 = (HEAP32[i10 >> 2] | 0) + (i34 << 1) | 0;
+ i35 = HEAP16[i34 >> 1] | 0;
+ HEAP16[(HEAP32[i12 >> 2] | 0) + ((HEAP32[i11 >> 2] & i26) << 1) >> 1] = i35;
+ i27 = i35 & 65535;
+ HEAP16[i34 >> 1] = i26;
+ if (!(i35 << 16 >> 16 == 0) ? !((i26 - i27 | 0) >>> 0 > ((HEAP32[i19 >> 2] | 0) + -262 | 0) >>> 0) : 0) {
+ i26 = _longest_match(i3, i27) | 0;
+ HEAP32[i21 >> 2] = i26;
+ } else {
+ i25 = 9;
+ }
+ }
+ if ((i25 | 0) == 9) {
+ i26 = HEAP32[i21 >> 2] | 0;
+ }
+ do {
+ if (i26 >>> 0 > 2) {
+ i35 = i26 + 253 | 0;
+ i25 = (HEAP32[i5 >> 2] | 0) - (HEAP32[i16 >> 2] | 0) | 0;
+ i34 = HEAP32[i13 >> 2] | 0;
+ HEAP16[(HEAP32[i17 >> 2] | 0) + (i34 << 1) >> 1] = i25;
+ HEAP32[i13 >> 2] = i34 + 1;
+ HEAP8[(HEAP32[i18 >> 2] | 0) + i34 | 0] = i35;
+ i35 = i3 + ((HEAPU8[808 + (i35 & 255) | 0] | 0 | 256) + 1 << 2) + 148 | 0;
+ HEAP16[i35 >> 1] = (HEAP16[i35 >> 1] | 0) + 1 << 16 >> 16;
+ i25 = i25 + 65535 & 65535;
+ if (!(i25 >>> 0 < 256)) {
+ i25 = (i25 >>> 7) + 256 | 0;
+ }
+ i25 = i3 + ((HEAPU8[296 + i25 | 0] | 0) << 2) + 2440 | 0;
+ HEAP16[i25 >> 1] = (HEAP16[i25 >> 1] | 0) + 1 << 16 >> 16;
+ i25 = (HEAP32[i13 >> 2] | 0) == ((HEAP32[i14 >> 2] | 0) + -1 | 0) | 0;
+ i26 = HEAP32[i21 >> 2] | 0;
+ i35 = (HEAP32[i20 >> 2] | 0) - i26 | 0;
+ HEAP32[i20 >> 2] = i35;
+ if (!(i26 >>> 0 <= (HEAP32[i15 >> 2] | 0) >>> 0 & i35 >>> 0 > 2)) {
+ i26 = (HEAP32[i5 >> 2] | 0) + i26 | 0;
+ HEAP32[i5 >> 2] = i26;
+ HEAP32[i21 >> 2] = 0;
+ i34 = HEAP32[i7 >> 2] | 0;
+ i35 = HEAPU8[i34 + i26 | 0] | 0;
+ HEAP32[i23 >> 2] = i35;
+ HEAP32[i23 >> 2] = ((HEAPU8[i34 + (i26 + 1) | 0] | 0) ^ i35 << HEAP32[i24 >> 2]) & HEAP32[i9 >> 2];
+ break;
+ }
+ i30 = i26 + -1 | 0;
+ HEAP32[i21 >> 2] = i30;
+ i34 = HEAP32[i24 >> 2] | 0;
+ i33 = HEAP32[i7 >> 2] | 0;
+ i35 = HEAP32[i9 >> 2] | 0;
+ i32 = HEAP32[i10 >> 2] | 0;
+ i27 = HEAP32[i11 >> 2] | 0;
+ i29 = HEAP32[i12 >> 2] | 0;
+ i26 = HEAP32[i5 >> 2] | 0;
+ i31 = HEAP32[i23 >> 2] | 0;
+ while (1) {
+ i28 = i26 + 1 | 0;
+ HEAP32[i5 >> 2] = i28;
+ i31 = ((HEAPU8[i33 + (i26 + 3) | 0] | 0) ^ i31 << i34) & i35;
+ HEAP32[i23 >> 2] = i31;
+ i36 = i32 + (i31 << 1) | 0;
+ HEAP16[i29 + ((i27 & i28) << 1) >> 1] = HEAP16[i36 >> 1] | 0;
+ HEAP16[i36 >> 1] = i28;
+ i30 = i30 + -1 | 0;
+ HEAP32[i21 >> 2] = i30;
+ if ((i30 | 0) == 0) {
+ break;
+ } else {
+ i26 = i28;
+ }
+ }
+ i26 = i26 + 2 | 0;
+ HEAP32[i5 >> 2] = i26;
+ } else {
+ i25 = HEAP8[(HEAP32[i7 >> 2] | 0) + (HEAP32[i5 >> 2] | 0) | 0] | 0;
+ i26 = HEAP32[i13 >> 2] | 0;
+ HEAP16[(HEAP32[i17 >> 2] | 0) + (i26 << 1) >> 1] = 0;
+ HEAP32[i13 >> 2] = i26 + 1;
+ HEAP8[(HEAP32[i18 >> 2] | 0) + i26 | 0] = i25;
+ i25 = i3 + ((i25 & 255) << 2) + 148 | 0;
+ HEAP16[i25 >> 1] = (HEAP16[i25 >> 1] | 0) + 1 << 16 >> 16;
+ i25 = (HEAP32[i13 >> 2] | 0) == ((HEAP32[i14 >> 2] | 0) + -1 | 0) | 0;
+ HEAP32[i20 >> 2] = (HEAP32[i20 >> 2] | 0) + -1;
+ i26 = (HEAP32[i5 >> 2] | 0) + 1 | 0;
+ HEAP32[i5 >> 2] = i26;
+ }
+ } while (0);
+ if ((i25 | 0) == 0) {
+ continue;
+ }
+ i25 = HEAP32[i4 >> 2] | 0;
+ if ((i25 | 0) > -1) {
+ i27 = (HEAP32[i7 >> 2] | 0) + i25 | 0;
+ } else {
+ i27 = 0;
+ }
+ __tr_flush_block(i3, i27, i26 - i25 | 0, 0);
+ HEAP32[i4 >> 2] = HEAP32[i5 >> 2];
+ i27 = HEAP32[i3 >> 2] | 0;
+ i28 = i27 + 28 | 0;
+ i25 = HEAP32[i28 >> 2] | 0;
+ i30 = HEAP32[i25 + 20 >> 2] | 0;
+ i26 = i27 + 16 | 0;
+ i29 = HEAP32[i26 >> 2] | 0;
+ i29 = i30 >>> 0 > i29 >>> 0 ? i29 : i30;
+ if ((i29 | 0) != 0 ? (i8 = i27 + 12 | 0, _memcpy(HEAP32[i8 >> 2] | 0, HEAP32[i25 + 16 >> 2] | 0, i29 | 0) | 0, HEAP32[i8 >> 2] = (HEAP32[i8 >> 2] | 0) + i29, i8 = (HEAP32[i28 >> 2] | 0) + 16 | 0, HEAP32[i8 >> 2] = (HEAP32[i8 >> 2] | 0) + i29, i8 = i27 + 20 | 0, HEAP32[i8 >> 2] = (HEAP32[i8 >> 2] | 0) + i29, HEAP32[i26 >> 2] = (HEAP32[i26 >> 2] | 0) - i29, i8 = HEAP32[i28 >> 2] | 0, i35 = i8 + 20 | 0, i36 = HEAP32[i35 >> 2] | 0, HEAP32[i35 >> 2] = i36 - i29, (i36 | 0) == (i29 | 0)) : 0) {
+ HEAP32[i8 + 16 >> 2] = HEAP32[i8 + 8 >> 2];
+ }
+ if ((HEAP32[(HEAP32[i3 >> 2] | 0) + 16 >> 2] | 0) == 0) {
+ i2 = 0;
+ i25 = 34;
+ break;
+ }
+ }
+ if ((i25 | 0) == 26) {
+ i8 = HEAP32[i4 >> 2] | 0;
+ if ((i8 | 0) > -1) {
+ i7 = (HEAP32[i7 >> 2] | 0) + i8 | 0;
+ } else {
+ i7 = 0;
+ }
+ i6 = (i6 | 0) == 4;
+ __tr_flush_block(i3, i7, (HEAP32[i5 >> 2] | 0) - i8 | 0, i6 & 1);
+ HEAP32[i4 >> 2] = HEAP32[i5 >> 2];
+ i5 = HEAP32[i3 >> 2] | 0;
+ i7 = i5 + 28 | 0;
+ i4 = HEAP32[i7 >> 2] | 0;
+ i10 = HEAP32[i4 + 20 >> 2] | 0;
+ i8 = i5 + 16 | 0;
+ i9 = HEAP32[i8 >> 2] | 0;
+ i9 = i10 >>> 0 > i9 >>> 0 ? i9 : i10;
+ if ((i9 | 0) != 0 ? (i2 = i5 + 12 | 0, _memcpy(HEAP32[i2 >> 2] | 0, HEAP32[i4 + 16 >> 2] | 0, i9 | 0) | 0, HEAP32[i2 >> 2] = (HEAP32[i2 >> 2] | 0) + i9, i2 = (HEAP32[i7 >> 2] | 0) + 16 | 0, HEAP32[i2 >> 2] = (HEAP32[i2 >> 2] | 0) + i9, i2 = i5 + 20 | 0, HEAP32[i2 >> 2] = (HEAP32[i2 >> 2] | 0) + i9, HEAP32[i8 >> 2] = (HEAP32[i8 >> 2] | 0) - i9, i2 = HEAP32[i7 >> 2] | 0, i35 = i2 + 20 | 0, i36 = HEAP32[i35 >> 2] | 0, HEAP32[i35 >> 2] = i36 - i9, (i36 | 0) == (i9 | 0)) : 0) {
+ HEAP32[i2 + 16 >> 2] = HEAP32[i2 + 8 >> 2];
+ }
+ if ((HEAP32[(HEAP32[i3 >> 2] | 0) + 16 >> 2] | 0) == 0) {
+ i36 = i6 ? 2 : 0;
+ STACKTOP = i1;
+ return i36 | 0;
+ } else {
+ i36 = i6 ? 3 : 1;
+ STACKTOP = i1;
+ return i36 | 0;
+ }
+ } else if ((i25 | 0) == 34) {
+ STACKTOP = i1;
+ return i2 | 0;
+ }
+ return 0;
+}
+function _inflate_table(i11, i5, i13, i2, i1, i10) {
+ i11 = i11 | 0;
+ i5 = i5 | 0;
+ i13 = i13 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ i10 = i10 | 0;
+ var i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i12 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0, i33 = 0;
+ i3 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i7 = i3 + 32 | 0;
+ i12 = i3;
+ i4 = i7 + 0 | 0;
+ i9 = i4 + 32 | 0;
+ do {
+ HEAP16[i4 >> 1] = 0;
+ i4 = i4 + 2 | 0;
+ } while ((i4 | 0) < (i9 | 0));
+ i14 = (i13 | 0) == 0;
+ if (!i14) {
+ i4 = 0;
+ do {
+ i32 = i7 + (HEAPU16[i5 + (i4 << 1) >> 1] << 1) | 0;
+ HEAP16[i32 >> 1] = (HEAP16[i32 >> 1] | 0) + 1 << 16 >> 16;
+ i4 = i4 + 1 | 0;
+ } while ((i4 | 0) != (i13 | 0));
+ }
+ i4 = HEAP32[i1 >> 2] | 0;
+ i9 = 15;
+ while (1) {
+ i15 = i9 + -1 | 0;
+ if ((HEAP16[i7 + (i9 << 1) >> 1] | 0) != 0) {
+ break;
+ }
+ if ((i15 | 0) == 0) {
+ i6 = 7;
+ break;
+ } else {
+ i9 = i15;
+ }
+ }
+ if ((i6 | 0) == 7) {
+ i32 = HEAP32[i2 >> 2] | 0;
+ HEAP32[i2 >> 2] = i32 + 4;
+ HEAP8[i32] = 64;
+ HEAP8[i32 + 1 | 0] = 1;
+ HEAP16[i32 + 2 >> 1] = 0;
+ i32 = HEAP32[i2 >> 2] | 0;
+ HEAP32[i2 >> 2] = i32 + 4;
+ HEAP8[i32] = 64;
+ HEAP8[i32 + 1 | 0] = 1;
+ HEAP16[i32 + 2 >> 1] = 0;
+ HEAP32[i1 >> 2] = 1;
+ i32 = 0;
+ STACKTOP = i3;
+ return i32 | 0;
+ }
+ i4 = i4 >>> 0 > i9 >>> 0 ? i9 : i4;
+ L12 : do {
+ if (i9 >>> 0 > 1) {
+ i27 = 1;
+ while (1) {
+ i15 = i27 + 1 | 0;
+ if ((HEAP16[i7 + (i27 << 1) >> 1] | 0) != 0) {
+ break L12;
+ }
+ if (i15 >>> 0 < i9 >>> 0) {
+ i27 = i15;
+ } else {
+ i27 = i15;
+ break;
+ }
+ }
+ } else {
+ i27 = 1;
+ }
+ } while (0);
+ i4 = i4 >>> 0 < i27 >>> 0 ? i27 : i4;
+ i16 = 1;
+ i15 = 1;
+ do {
+ i16 = (i16 << 1) - (HEAPU16[i7 + (i15 << 1) >> 1] | 0) | 0;
+ i15 = i15 + 1 | 0;
+ if ((i16 | 0) < 0) {
+ i8 = -1;
+ i6 = 56;
+ break;
+ }
+ } while (i15 >>> 0 < 16);
+ if ((i6 | 0) == 56) {
+ STACKTOP = i3;
+ return i8 | 0;
+ }
+ if ((i16 | 0) > 0 ? !((i11 | 0) != 0 & (i9 | 0) == 1) : 0) {
+ i32 = -1;
+ STACKTOP = i3;
+ return i32 | 0;
+ }
+ HEAP16[i12 + 2 >> 1] = 0;
+ i16 = 0;
+ i15 = 1;
+ do {
+ i16 = (HEAPU16[i7 + (i15 << 1) >> 1] | 0) + (i16 & 65535) | 0;
+ i15 = i15 + 1 | 0;
+ HEAP16[i12 + (i15 << 1) >> 1] = i16;
+ } while ((i15 | 0) != 15);
+ if (!i14) {
+ i15 = 0;
+ do {
+ i14 = HEAP16[i5 + (i15 << 1) >> 1] | 0;
+ if (!(i14 << 16 >> 16 == 0)) {
+ i31 = i12 + ((i14 & 65535) << 1) | 0;
+ i32 = HEAP16[i31 >> 1] | 0;
+ HEAP16[i31 >> 1] = i32 + 1 << 16 >> 16;
+ HEAP16[i10 + ((i32 & 65535) << 1) >> 1] = i15;
+ }
+ i15 = i15 + 1 | 0;
+ } while ((i15 | 0) != (i13 | 0));
+ }
+ if ((i11 | 0) == 1) {
+ i14 = 1 << i4;
+ if (i14 >>> 0 > 851) {
+ i32 = 1;
+ STACKTOP = i3;
+ return i32 | 0;
+ } else {
+ i16 = 0;
+ i20 = 1;
+ i17 = 14128 + -514 | 0;
+ i19 = 256;
+ i18 = 14192 + -514 | 0;
+ }
+ } else if ((i11 | 0) != 0) {
+ i14 = 1 << i4;
+ i16 = (i11 | 0) == 2;
+ if (i16 & i14 >>> 0 > 591) {
+ i32 = 1;
+ STACKTOP = i3;
+ return i32 | 0;
+ } else {
+ i20 = 0;
+ i17 = 14256;
+ i19 = -1;
+ i18 = 14320;
+ }
+ } else {
+ i16 = 0;
+ i14 = 1 << i4;
+ i20 = 0;
+ i17 = i10;
+ i19 = 19;
+ i18 = i10;
+ }
+ i11 = i14 + -1 | 0;
+ i12 = i4 & 255;
+ i22 = i4;
+ i21 = 0;
+ i25 = 0;
+ i13 = -1;
+ i15 = HEAP32[i2 >> 2] | 0;
+ i24 = 0;
+ L44 : while (1) {
+ i23 = 1 << i22;
+ while (1) {
+ i29 = i27 - i21 | 0;
+ i22 = i29 & 255;
+ i28 = HEAP16[i10 + (i24 << 1) >> 1] | 0;
+ i30 = i28 & 65535;
+ if ((i30 | 0) >= (i19 | 0)) {
+ if ((i30 | 0) > (i19 | 0)) {
+ i26 = HEAP16[i18 + (i30 << 1) >> 1] & 255;
+ i28 = HEAP16[i17 + (i30 << 1) >> 1] | 0;
+ } else {
+ i26 = 96;
+ i28 = 0;
+ }
+ } else {
+ i26 = 0;
+ }
+ i31 = 1 << i29;
+ i30 = i25 >>> i21;
+ i32 = i23;
+ while (1) {
+ i29 = i32 - i31 | 0;
+ i33 = i29 + i30 | 0;
+ HEAP8[i15 + (i33 << 2) | 0] = i26;
+ HEAP8[i15 + (i33 << 2) + 1 | 0] = i22;
+ HEAP16[i15 + (i33 << 2) + 2 >> 1] = i28;
+ if ((i32 | 0) == (i31 | 0)) {
+ break;
+ } else {
+ i32 = i29;
+ }
+ }
+ i26 = 1 << i27 + -1;
+ while (1) {
+ if ((i26 & i25 | 0) == 0) {
+ break;
+ } else {
+ i26 = i26 >>> 1;
+ }
+ }
+ if ((i26 | 0) == 0) {
+ i25 = 0;
+ } else {
+ i25 = (i26 + -1 & i25) + i26 | 0;
+ }
+ i24 = i24 + 1 | 0;
+ i32 = i7 + (i27 << 1) | 0;
+ i33 = (HEAP16[i32 >> 1] | 0) + -1 << 16 >> 16;
+ HEAP16[i32 >> 1] = i33;
+ if (i33 << 16 >> 16 == 0) {
+ if ((i27 | 0) == (i9 | 0)) {
+ break L44;
+ }
+ i27 = HEAPU16[i5 + (HEAPU16[i10 + (i24 << 1) >> 1] << 1) >> 1] | 0;
+ }
+ if (!(i27 >>> 0 > i4 >>> 0)) {
+ continue;
+ }
+ i26 = i25 & i11;
+ if ((i26 | 0) != (i13 | 0)) {
+ break;
+ }
+ }
+ i28 = (i21 | 0) == 0 ? i4 : i21;
+ i23 = i15 + (i23 << 2) | 0;
+ i31 = i27 - i28 | 0;
+ L67 : do {
+ if (i27 >>> 0 < i9 >>> 0) {
+ i29 = i27;
+ i30 = i31;
+ i31 = 1 << i31;
+ while (1) {
+ i31 = i31 - (HEAPU16[i7 + (i29 << 1) >> 1] | 0) | 0;
+ if ((i31 | 0) < 1) {
+ break L67;
+ }
+ i30 = i30 + 1 | 0;
+ i29 = i30 + i28 | 0;
+ if (i29 >>> 0 < i9 >>> 0) {
+ i31 = i31 << 1;
+ } else {
+ break;
+ }
+ }
+ } else {
+ i30 = i31;
+ }
+ } while (0);
+ i29 = (1 << i30) + i14 | 0;
+ if (i20 & i29 >>> 0 > 851 | i16 & i29 >>> 0 > 591) {
+ i8 = 1;
+ i6 = 56;
+ break;
+ }
+ HEAP8[(HEAP32[i2 >> 2] | 0) + (i26 << 2) | 0] = i30;
+ HEAP8[(HEAP32[i2 >> 2] | 0) + (i26 << 2) + 1 | 0] = i12;
+ i22 = HEAP32[i2 >> 2] | 0;
+ HEAP16[i22 + (i26 << 2) + 2 >> 1] = (i23 - i22 | 0) >>> 2;
+ i22 = i30;
+ i21 = i28;
+ i13 = i26;
+ i15 = i23;
+ i14 = i29;
+ }
+ if ((i6 | 0) == 56) {
+ STACKTOP = i3;
+ return i8 | 0;
+ }
+ L77 : do {
+ if ((i25 | 0) != 0) {
+ do {
+ if ((i21 | 0) != 0) {
+ if ((i25 & i11 | 0) != (i13 | 0)) {
+ i21 = 0;
+ i22 = i12;
+ i9 = i4;
+ i15 = HEAP32[i2 >> 2] | 0;
+ }
+ } else {
+ i21 = 0;
+ }
+ i5 = i25 >>> i21;
+ HEAP8[i15 + (i5 << 2) | 0] = 64;
+ HEAP8[i15 + (i5 << 2) + 1 | 0] = i22;
+ HEAP16[i15 + (i5 << 2) + 2 >> 1] = 0;
+ i5 = 1 << i9 + -1;
+ while (1) {
+ if ((i5 & i25 | 0) == 0) {
+ break;
+ } else {
+ i5 = i5 >>> 1;
+ }
+ }
+ if ((i5 | 0) == 0) {
+ break L77;
+ }
+ i25 = (i5 + -1 & i25) + i5 | 0;
+ } while ((i25 | 0) != 0);
+ }
+ } while (0);
+ HEAP32[i2 >> 2] = (HEAP32[i2 >> 2] | 0) + (i14 << 2);
+ HEAP32[i1 >> 2] = i4;
+ i33 = 0;
+ STACKTOP = i3;
+ return i33 | 0;
+}
+function _compress_block(i1, i3, i7) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i7 = i7 | 0;
+ var i2 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0;
+ i2 = STACKTOP;
+ i11 = i1 + 5792 | 0;
+ if ((HEAP32[i11 >> 2] | 0) == 0) {
+ i14 = HEAP32[i1 + 5820 >> 2] | 0;
+ i17 = HEAP16[i1 + 5816 >> 1] | 0;
+ } else {
+ i9 = i1 + 5796 | 0;
+ i10 = i1 + 5784 | 0;
+ i8 = i1 + 5820 | 0;
+ i12 = i1 + 5816 | 0;
+ i5 = i1 + 20 | 0;
+ i6 = i1 + 8 | 0;
+ i14 = 0;
+ while (1) {
+ i20 = HEAP16[(HEAP32[i9 >> 2] | 0) + (i14 << 1) >> 1] | 0;
+ i13 = i20 & 65535;
+ i4 = i14 + 1 | 0;
+ i14 = HEAPU8[(HEAP32[i10 >> 2] | 0) + i14 | 0] | 0;
+ do {
+ if (i20 << 16 >> 16 == 0) {
+ i15 = HEAPU16[i3 + (i14 << 2) + 2 >> 1] | 0;
+ i13 = HEAP32[i8 >> 2] | 0;
+ i14 = HEAPU16[i3 + (i14 << 2) >> 1] | 0;
+ i16 = HEAPU16[i12 >> 1] | 0 | i14 << i13;
+ i17 = i16 & 65535;
+ HEAP16[i12 >> 1] = i17;
+ if ((i13 | 0) > (16 - i15 | 0)) {
+ i17 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i17 + 1;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + i17 | 0] = i16;
+ i17 = (HEAPU16[i12 >> 1] | 0) >>> 8 & 255;
+ i20 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i20 + 1;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + i20 | 0] = i17;
+ i20 = HEAP32[i8 >> 2] | 0;
+ i17 = i14 >>> (16 - i20 | 0) & 65535;
+ HEAP16[i12 >> 1] = i17;
+ i14 = i15 + -16 + i20 | 0;
+ HEAP32[i8 >> 2] = i14;
+ break;
+ } else {
+ i14 = i13 + i15 | 0;
+ HEAP32[i8 >> 2] = i14;
+ break;
+ }
+ } else {
+ i15 = HEAPU8[808 + i14 | 0] | 0;
+ i19 = (i15 | 256) + 1 | 0;
+ i18 = HEAPU16[i3 + (i19 << 2) + 2 >> 1] | 0;
+ i17 = HEAP32[i8 >> 2] | 0;
+ i19 = HEAPU16[i3 + (i19 << 2) >> 1] | 0;
+ i20 = HEAPU16[i12 >> 1] | 0 | i19 << i17;
+ i16 = i20 & 65535;
+ HEAP16[i12 >> 1] = i16;
+ if ((i17 | 0) > (16 - i18 | 0)) {
+ i16 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i16 + 1;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + i16 | 0] = i20;
+ i16 = (HEAPU16[i12 >> 1] | 0) >>> 8 & 255;
+ i20 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i20 + 1;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + i20 | 0] = i16;
+ i20 = HEAP32[i8 >> 2] | 0;
+ i16 = i19 >>> (16 - i20 | 0) & 65535;
+ HEAP16[i12 >> 1] = i16;
+ i18 = i18 + -16 + i20 | 0;
+ } else {
+ i18 = i17 + i18 | 0;
+ }
+ HEAP32[i8 >> 2] = i18;
+ i17 = HEAP32[2408 + (i15 << 2) >> 2] | 0;
+ do {
+ if ((i15 + -8 | 0) >>> 0 < 20) {
+ i14 = i14 - (HEAP32[2528 + (i15 << 2) >> 2] | 0) & 65535;
+ i15 = i14 << i18 | i16 & 65535;
+ i16 = i15 & 65535;
+ HEAP16[i12 >> 1] = i16;
+ if ((i18 | 0) > (16 - i17 | 0)) {
+ i16 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i16 + 1;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + i16 | 0] = i15;
+ i16 = (HEAPU16[i12 >> 1] | 0) >>> 8 & 255;
+ i20 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i20 + 1;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + i20 | 0] = i16;
+ i20 = HEAP32[i8 >> 2] | 0;
+ i16 = i14 >>> (16 - i20 | 0) & 65535;
+ HEAP16[i12 >> 1] = i16;
+ i14 = i17 + -16 + i20 | 0;
+ HEAP32[i8 >> 2] = i14;
+ break;
+ } else {
+ i14 = i18 + i17 | 0;
+ HEAP32[i8 >> 2] = i14;
+ break;
+ }
+ } else {
+ i14 = i18;
+ }
+ } while (0);
+ i13 = i13 + -1 | 0;
+ if (i13 >>> 0 < 256) {
+ i15 = i13;
+ } else {
+ i15 = (i13 >>> 7) + 256 | 0;
+ }
+ i15 = HEAPU8[296 + i15 | 0] | 0;
+ i17 = HEAPU16[i7 + (i15 << 2) + 2 >> 1] | 0;
+ i18 = HEAPU16[i7 + (i15 << 2) >> 1] | 0;
+ i19 = i16 & 65535 | i18 << i14;
+ i16 = i19 & 65535;
+ HEAP16[i12 >> 1] = i16;
+ if ((i14 | 0) > (16 - i17 | 0)) {
+ i20 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i20 + 1;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + i20 | 0] = i19;
+ i20 = (HEAPU16[i12 >> 1] | 0) >>> 8 & 255;
+ i14 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i14 + 1;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + i14 | 0] = i20;
+ i14 = HEAP32[i8 >> 2] | 0;
+ i20 = i18 >>> (16 - i14 | 0) & 65535;
+ HEAP16[i12 >> 1] = i20;
+ i14 = i17 + -16 + i14 | 0;
+ i17 = i20;
+ } else {
+ i14 = i14 + i17 | 0;
+ i17 = i16;
+ }
+ HEAP32[i8 >> 2] = i14;
+ i16 = HEAP32[2648 + (i15 << 2) >> 2] | 0;
+ if ((i15 + -4 | 0) >>> 0 < 26) {
+ i13 = i13 - (HEAP32[2768 + (i15 << 2) >> 2] | 0) & 65535;
+ i15 = i13 << i14 | i17 & 65535;
+ i17 = i15 & 65535;
+ HEAP16[i12 >> 1] = i17;
+ if ((i14 | 0) > (16 - i16 | 0)) {
+ i17 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i17 + 1;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + i17 | 0] = i15;
+ i17 = (HEAPU16[i12 >> 1] | 0) >>> 8 & 255;
+ i14 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i5 >> 2] = i14 + 1;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + i14 | 0] = i17;
+ i14 = HEAP32[i8 >> 2] | 0;
+ i17 = i13 >>> (16 - i14 | 0) & 65535;
+ HEAP16[i12 >> 1] = i17;
+ i14 = i16 + -16 + i14 | 0;
+ HEAP32[i8 >> 2] = i14;
+ break;
+ } else {
+ i14 = i14 + i16 | 0;
+ HEAP32[i8 >> 2] = i14;
+ break;
+ }
+ }
+ }
+ } while (0);
+ if (i4 >>> 0 < (HEAP32[i11 >> 2] | 0) >>> 0) {
+ i14 = i4;
+ } else {
+ break;
+ }
+ }
+ }
+ i5 = i3 + 1026 | 0;
+ i6 = HEAPU16[i5 >> 1] | 0;
+ i4 = i1 + 5820 | 0;
+ i3 = HEAPU16[i3 + 1024 >> 1] | 0;
+ i7 = i1 + 5816 | 0;
+ i8 = i17 & 65535 | i3 << i14;
+ HEAP16[i7 >> 1] = i8;
+ if ((i14 | 0) > (16 - i6 | 0)) {
+ i17 = i1 + 20 | 0;
+ i18 = HEAP32[i17 >> 2] | 0;
+ HEAP32[i17 >> 2] = i18 + 1;
+ i20 = i1 + 8 | 0;
+ HEAP8[(HEAP32[i20 >> 2] | 0) + i18 | 0] = i8;
+ i18 = (HEAPU16[i7 >> 1] | 0) >>> 8 & 255;
+ i19 = HEAP32[i17 >> 2] | 0;
+ HEAP32[i17 >> 2] = i19 + 1;
+ HEAP8[(HEAP32[i20 >> 2] | 0) + i19 | 0] = i18;
+ i19 = HEAP32[i4 >> 2] | 0;
+ HEAP16[i7 >> 1] = i3 >>> (16 - i19 | 0);
+ i19 = i6 + -16 + i19 | 0;
+ HEAP32[i4 >> 2] = i19;
+ i19 = HEAP16[i5 >> 1] | 0;
+ i19 = i19 & 65535;
+ i20 = i1 + 5812 | 0;
+ HEAP32[i20 >> 2] = i19;
+ STACKTOP = i2;
+ return;
+ } else {
+ i19 = i14 + i6 | 0;
+ HEAP32[i4 >> 2] = i19;
+ i19 = HEAP16[i5 >> 1] | 0;
+ i19 = i19 & 65535;
+ i20 = i1 + 5812 | 0;
+ HEAP32[i20 >> 2] = i19;
+ STACKTOP = i2;
+ return;
+ }
+}
+function _deflate_stored(i2, i5) {
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0;
+ i1 = STACKTOP;
+ i4 = (HEAP32[i2 + 12 >> 2] | 0) + -5 | 0;
+ i11 = i4 >>> 0 < 65535 ? i4 : 65535;
+ i12 = i2 + 116 | 0;
+ i4 = i2 + 108 | 0;
+ i6 = i2 + 92 | 0;
+ i10 = i2 + 44 | 0;
+ i7 = i2 + 56 | 0;
+ while (1) {
+ i13 = HEAP32[i12 >> 2] | 0;
+ if (i13 >>> 0 < 2) {
+ _fill_window(i2);
+ i13 = HEAP32[i12 >> 2] | 0;
+ if ((i13 | i5 | 0) == 0) {
+ i2 = 0;
+ i8 = 28;
+ break;
+ }
+ if ((i13 | 0) == 0) {
+ i8 = 20;
+ break;
+ }
+ }
+ i13 = (HEAP32[i4 >> 2] | 0) + i13 | 0;
+ HEAP32[i4 >> 2] = i13;
+ HEAP32[i12 >> 2] = 0;
+ i14 = HEAP32[i6 >> 2] | 0;
+ i15 = i14 + i11 | 0;
+ if (!((i13 | 0) != 0 & i13 >>> 0 < i15 >>> 0)) {
+ HEAP32[i12 >> 2] = i13 - i15;
+ HEAP32[i4 >> 2] = i15;
+ if ((i14 | 0) > -1) {
+ i13 = (HEAP32[i7 >> 2] | 0) + i14 | 0;
+ } else {
+ i13 = 0;
+ }
+ __tr_flush_block(i2, i13, i11, 0);
+ HEAP32[i6 >> 2] = HEAP32[i4 >> 2];
+ i16 = HEAP32[i2 >> 2] | 0;
+ i14 = i16 + 28 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ i17 = HEAP32[i15 + 20 >> 2] | 0;
+ i13 = i16 + 16 | 0;
+ i18 = HEAP32[i13 >> 2] | 0;
+ i17 = i17 >>> 0 > i18 >>> 0 ? i18 : i17;
+ if ((i17 | 0) != 0 ? (i8 = i16 + 12 | 0, _memcpy(HEAP32[i8 >> 2] | 0, HEAP32[i15 + 16 >> 2] | 0, i17 | 0) | 0, HEAP32[i8 >> 2] = (HEAP32[i8 >> 2] | 0) + i17, i8 = (HEAP32[i14 >> 2] | 0) + 16 | 0, HEAP32[i8 >> 2] = (HEAP32[i8 >> 2] | 0) + i17, i8 = i16 + 20 | 0, HEAP32[i8 >> 2] = (HEAP32[i8 >> 2] | 0) + i17, HEAP32[i13 >> 2] = (HEAP32[i13 >> 2] | 0) - i17, i8 = HEAP32[i14 >> 2] | 0, i16 = i8 + 20 | 0, i18 = HEAP32[i16 >> 2] | 0, HEAP32[i16 >> 2] = i18 - i17, (i18 | 0) == (i17 | 0)) : 0) {
+ HEAP32[i8 + 16 >> 2] = HEAP32[i8 + 8 >> 2];
+ }
+ if ((HEAP32[(HEAP32[i2 >> 2] | 0) + 16 >> 2] | 0) == 0) {
+ i2 = 0;
+ i8 = 28;
+ break;
+ }
+ i14 = HEAP32[i6 >> 2] | 0;
+ i13 = HEAP32[i4 >> 2] | 0;
+ }
+ i13 = i13 - i14 | 0;
+ if (i13 >>> 0 < ((HEAP32[i10 >> 2] | 0) + -262 | 0) >>> 0) {
+ continue;
+ }
+ if ((i14 | 0) > -1) {
+ i14 = (HEAP32[i7 >> 2] | 0) + i14 | 0;
+ } else {
+ i14 = 0;
+ }
+ __tr_flush_block(i2, i14, i13, 0);
+ HEAP32[i6 >> 2] = HEAP32[i4 >> 2];
+ i16 = HEAP32[i2 >> 2] | 0;
+ i14 = i16 + 28 | 0;
+ i15 = HEAP32[i14 >> 2] | 0;
+ i17 = HEAP32[i15 + 20 >> 2] | 0;
+ i13 = i16 + 16 | 0;
+ i18 = HEAP32[i13 >> 2] | 0;
+ i17 = i17 >>> 0 > i18 >>> 0 ? i18 : i17;
+ if ((i17 | 0) != 0 ? (i9 = i16 + 12 | 0, _memcpy(HEAP32[i9 >> 2] | 0, HEAP32[i15 + 16 >> 2] | 0, i17 | 0) | 0, HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + i17, i9 = (HEAP32[i14 >> 2] | 0) + 16 | 0, HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + i17, i9 = i16 + 20 | 0, HEAP32[i9 >> 2] = (HEAP32[i9 >> 2] | 0) + i17, HEAP32[i13 >> 2] = (HEAP32[i13 >> 2] | 0) - i17, i9 = HEAP32[i14 >> 2] | 0, i16 = i9 + 20 | 0, i18 = HEAP32[i16 >> 2] | 0, HEAP32[i16 >> 2] = i18 - i17, (i18 | 0) == (i17 | 0)) : 0) {
+ HEAP32[i9 + 16 >> 2] = HEAP32[i9 + 8 >> 2];
+ }
+ if ((HEAP32[(HEAP32[i2 >> 2] | 0) + 16 >> 2] | 0) == 0) {
+ i2 = 0;
+ i8 = 28;
+ break;
+ }
+ }
+ if ((i8 | 0) == 20) {
+ i8 = HEAP32[i6 >> 2] | 0;
+ if ((i8 | 0) > -1) {
+ i7 = (HEAP32[i7 >> 2] | 0) + i8 | 0;
+ } else {
+ i7 = 0;
+ }
+ i5 = (i5 | 0) == 4;
+ __tr_flush_block(i2, i7, (HEAP32[i4 >> 2] | 0) - i8 | 0, i5 & 1);
+ HEAP32[i6 >> 2] = HEAP32[i4 >> 2];
+ i4 = HEAP32[i2 >> 2] | 0;
+ i7 = i4 + 28 | 0;
+ i6 = HEAP32[i7 >> 2] | 0;
+ i9 = HEAP32[i6 + 20 >> 2] | 0;
+ i8 = i4 + 16 | 0;
+ i10 = HEAP32[i8 >> 2] | 0;
+ i9 = i9 >>> 0 > i10 >>> 0 ? i10 : i9;
+ if ((i9 | 0) != 0 ? (i3 = i4 + 12 | 0, _memcpy(HEAP32[i3 >> 2] | 0, HEAP32[i6 + 16 >> 2] | 0, i9 | 0) | 0, HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + i9, i3 = (HEAP32[i7 >> 2] | 0) + 16 | 0, HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + i9, i3 = i4 + 20 | 0, HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + i9, HEAP32[i8 >> 2] = (HEAP32[i8 >> 2] | 0) - i9, i3 = HEAP32[i7 >> 2] | 0, i17 = i3 + 20 | 0, i18 = HEAP32[i17 >> 2] | 0, HEAP32[i17 >> 2] = i18 - i9, (i18 | 0) == (i9 | 0)) : 0) {
+ HEAP32[i3 + 16 >> 2] = HEAP32[i3 + 8 >> 2];
+ }
+ if ((HEAP32[(HEAP32[i2 >> 2] | 0) + 16 >> 2] | 0) == 0) {
+ i18 = i5 ? 2 : 0;
+ STACKTOP = i1;
+ return i18 | 0;
+ } else {
+ i18 = i5 ? 3 : 1;
+ STACKTOP = i1;
+ return i18 | 0;
+ }
+ } else if ((i8 | 0) == 28) {
+ STACKTOP = i1;
+ return i2 | 0;
+ }
+ return 0;
+}
+function _fill_window(i15) {
+ i15 = i15 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0;
+ i2 = STACKTOP;
+ i16 = i15 + 44 | 0;
+ i9 = HEAP32[i16 >> 2] | 0;
+ i4 = i15 + 60 | 0;
+ i8 = i15 + 116 | 0;
+ i3 = i15 + 108 | 0;
+ i5 = i9 + -262 | 0;
+ i1 = i15 + 56 | 0;
+ i17 = i15 + 72 | 0;
+ i6 = i15 + 88 | 0;
+ i7 = i15 + 84 | 0;
+ i11 = i15 + 112 | 0;
+ i12 = i15 + 92 | 0;
+ i13 = i15 + 76 | 0;
+ i14 = i15 + 68 | 0;
+ i10 = i15 + 64 | 0;
+ i19 = HEAP32[i8 >> 2] | 0;
+ i21 = i9;
+ while (1) {
+ i20 = HEAP32[i3 >> 2] | 0;
+ i19 = (HEAP32[i4 >> 2] | 0) - i19 - i20 | 0;
+ if (!(i20 >>> 0 < (i5 + i21 | 0) >>> 0)) {
+ i20 = HEAP32[i1 >> 2] | 0;
+ _memcpy(i20 | 0, i20 + i9 | 0, i9 | 0) | 0;
+ HEAP32[i11 >> 2] = (HEAP32[i11 >> 2] | 0) - i9;
+ i20 = (HEAP32[i3 >> 2] | 0) - i9 | 0;
+ HEAP32[i3 >> 2] = i20;
+ HEAP32[i12 >> 2] = (HEAP32[i12 >> 2] | 0) - i9;
+ i22 = HEAP32[i13 >> 2] | 0;
+ i21 = i22;
+ i22 = (HEAP32[i14 >> 2] | 0) + (i22 << 1) | 0;
+ do {
+ i22 = i22 + -2 | 0;
+ i23 = HEAPU16[i22 >> 1] | 0;
+ if (i23 >>> 0 < i9 >>> 0) {
+ i23 = 0;
+ } else {
+ i23 = i23 - i9 & 65535;
+ }
+ HEAP16[i22 >> 1] = i23;
+ i21 = i21 + -1 | 0;
+ } while ((i21 | 0) != 0);
+ i22 = i9;
+ i21 = (HEAP32[i10 >> 2] | 0) + (i9 << 1) | 0;
+ do {
+ i21 = i21 + -2 | 0;
+ i23 = HEAPU16[i21 >> 1] | 0;
+ if (i23 >>> 0 < i9 >>> 0) {
+ i23 = 0;
+ } else {
+ i23 = i23 - i9 & 65535;
+ }
+ HEAP16[i21 >> 1] = i23;
+ i22 = i22 + -1 | 0;
+ } while ((i22 | 0) != 0);
+ i19 = i19 + i9 | 0;
+ }
+ i21 = HEAP32[i15 >> 2] | 0;
+ i24 = i21 + 4 | 0;
+ i23 = HEAP32[i24 >> 2] | 0;
+ if ((i23 | 0) == 0) {
+ i18 = 28;
+ break;
+ }
+ i22 = HEAP32[i8 >> 2] | 0;
+ i20 = (HEAP32[i1 >> 2] | 0) + (i22 + i20) | 0;
+ i19 = i23 >>> 0 > i19 >>> 0 ? i19 : i23;
+ if ((i19 | 0) == 0) {
+ i19 = 0;
+ } else {
+ HEAP32[i24 >> 2] = i23 - i19;
+ i22 = HEAP32[(HEAP32[i21 + 28 >> 2] | 0) + 24 >> 2] | 0;
+ if ((i22 | 0) == 1) {
+ i22 = i21 + 48 | 0;
+ HEAP32[i22 >> 2] = _adler32(HEAP32[i22 >> 2] | 0, HEAP32[i21 >> 2] | 0, i19) | 0;
+ i22 = i21;
+ } else if ((i22 | 0) == 2) {
+ i22 = i21 + 48 | 0;
+ HEAP32[i22 >> 2] = _crc32(HEAP32[i22 >> 2] | 0, HEAP32[i21 >> 2] | 0, i19) | 0;
+ i22 = i21;
+ } else {
+ i22 = i21;
+ }
+ _memcpy(i20 | 0, HEAP32[i22 >> 2] | 0, i19 | 0) | 0;
+ HEAP32[i22 >> 2] = (HEAP32[i22 >> 2] | 0) + i19;
+ i22 = i21 + 8 | 0;
+ HEAP32[i22 >> 2] = (HEAP32[i22 >> 2] | 0) + i19;
+ i22 = HEAP32[i8 >> 2] | 0;
+ }
+ i19 = i22 + i19 | 0;
+ HEAP32[i8 >> 2] = i19;
+ if (i19 >>> 0 > 2 ? (i23 = HEAP32[i3 >> 2] | 0, i22 = HEAP32[i1 >> 2] | 0, i24 = HEAPU8[i22 + i23 | 0] | 0, HEAP32[i17 >> 2] = i24, HEAP32[i17 >> 2] = ((HEAPU8[i22 + (i23 + 1) | 0] | 0) ^ i24 << HEAP32[i6 >> 2]) & HEAP32[i7 >> 2], !(i19 >>> 0 < 262)) : 0) {
+ break;
+ }
+ if ((HEAP32[(HEAP32[i15 >> 2] | 0) + 4 >> 2] | 0) == 0) {
+ break;
+ }
+ i21 = HEAP32[i16 >> 2] | 0;
+ }
+ if ((i18 | 0) == 28) {
+ STACKTOP = i2;
+ return;
+ }
+ i5 = i15 + 5824 | 0;
+ i6 = HEAP32[i5 >> 2] | 0;
+ i4 = HEAP32[i4 >> 2] | 0;
+ if (!(i6 >>> 0 < i4 >>> 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ i3 = i19 + (HEAP32[i3 >> 2] | 0) | 0;
+ if (i6 >>> 0 < i3 >>> 0) {
+ i4 = i4 - i3 | 0;
+ i24 = i4 >>> 0 > 258 ? 258 : i4;
+ _memset((HEAP32[i1 >> 2] | 0) + i3 | 0, 0, i24 | 0) | 0;
+ HEAP32[i5 >> 2] = i24 + i3;
+ STACKTOP = i2;
+ return;
+ }
+ i3 = i3 + 258 | 0;
+ if (!(i6 >>> 0 < i3 >>> 0)) {
+ STACKTOP = i2;
+ return;
+ }
+ i3 = i3 - i6 | 0;
+ i4 = i4 - i6 | 0;
+ i24 = i3 >>> 0 > i4 >>> 0 ? i4 : i3;
+ _memset((HEAP32[i1 >> 2] | 0) + i6 | 0, 0, i24 | 0) | 0;
+ HEAP32[i5 >> 2] = (HEAP32[i5 >> 2] | 0) + i24;
+ STACKTOP = i2;
+ return;
+}
+function __tr_align(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0;
+ i2 = STACKTOP;
+ i3 = i1 + 5820 | 0;
+ i6 = HEAP32[i3 >> 2] | 0;
+ i4 = i1 + 5816 | 0;
+ i7 = HEAPU16[i4 >> 1] | 0 | 2 << i6;
+ i5 = i7 & 65535;
+ HEAP16[i4 >> 1] = i5;
+ if ((i6 | 0) > 13) {
+ i8 = i1 + 20 | 0;
+ i6 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i6 + 1;
+ i5 = i1 + 8 | 0;
+ HEAP8[(HEAP32[i5 >> 2] | 0) + i6 | 0] = i7;
+ i7 = (HEAPU16[i4 >> 1] | 0) >>> 8 & 255;
+ i6 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i6 + 1;
+ HEAP8[(HEAP32[i5 >> 2] | 0) + i6 | 0] = i7;
+ i6 = HEAP32[i3 >> 2] | 0;
+ i5 = 2 >>> (16 - i6 | 0) & 65535;
+ HEAP16[i4 >> 1] = i5;
+ i6 = i6 + -13 | 0;
+ } else {
+ i6 = i6 + 3 | 0;
+ }
+ HEAP32[i3 >> 2] = i6;
+ if ((i6 | 0) > 9) {
+ i7 = i1 + 20 | 0;
+ i6 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i6 + 1;
+ i8 = i1 + 8 | 0;
+ HEAP8[(HEAP32[i8 >> 2] | 0) + i6 | 0] = i5;
+ i5 = (HEAPU16[i4 >> 1] | 0) >>> 8 & 255;
+ i6 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i6 + 1;
+ HEAP8[(HEAP32[i8 >> 2] | 0) + i6 | 0] = i5;
+ HEAP16[i4 >> 1] = 0;
+ i6 = (HEAP32[i3 >> 2] | 0) + -9 | 0;
+ i5 = 0;
+ } else {
+ i6 = i6 + 7 | 0;
+ }
+ HEAP32[i3 >> 2] = i6;
+ if ((i6 | 0) != 16) {
+ if ((i6 | 0) > 7) {
+ i6 = i1 + 20 | 0;
+ i7 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i7 + 1;
+ HEAP8[(HEAP32[i1 + 8 >> 2] | 0) + i7 | 0] = i5;
+ i7 = (HEAPU16[i4 >> 1] | 0) >>> 8;
+ HEAP16[i4 >> 1] = i7;
+ i6 = (HEAP32[i3 >> 2] | 0) + -8 | 0;
+ HEAP32[i3 >> 2] = i6;
+ } else {
+ i7 = i5;
+ }
+ } else {
+ i9 = i1 + 20 | 0;
+ i8 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = i8 + 1;
+ i7 = i1 + 8 | 0;
+ HEAP8[(HEAP32[i7 >> 2] | 0) + i8 | 0] = i5;
+ i8 = (HEAPU16[i4 >> 1] | 0) >>> 8 & 255;
+ i6 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = i6 + 1;
+ HEAP8[(HEAP32[i7 >> 2] | 0) + i6 | 0] = i8;
+ HEAP16[i4 >> 1] = 0;
+ HEAP32[i3 >> 2] = 0;
+ i6 = 0;
+ i7 = 0;
+ }
+ i5 = i1 + 5812 | 0;
+ if ((11 - i6 + (HEAP32[i5 >> 2] | 0) | 0) >= 9) {
+ HEAP32[i5 >> 2] = 7;
+ STACKTOP = i2;
+ return;
+ }
+ i7 = i7 & 65535 | 2 << i6;
+ HEAP16[i4 >> 1] = i7;
+ if ((i6 | 0) > 13) {
+ i8 = i1 + 20 | 0;
+ i6 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i6 + 1;
+ i9 = i1 + 8 | 0;
+ HEAP8[(HEAP32[i9 >> 2] | 0) + i6 | 0] = i7;
+ i7 = (HEAPU16[i4 >> 1] | 0) >>> 8 & 255;
+ i6 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i6 + 1;
+ HEAP8[(HEAP32[i9 >> 2] | 0) + i6 | 0] = i7;
+ i6 = HEAP32[i3 >> 2] | 0;
+ i7 = 2 >>> (16 - i6 | 0);
+ HEAP16[i4 >> 1] = i7;
+ i6 = i6 + -13 | 0;
+ } else {
+ i6 = i6 + 3 | 0;
+ }
+ i7 = i7 & 255;
+ HEAP32[i3 >> 2] = i6;
+ if ((i6 | 0) > 9) {
+ i8 = i1 + 20 | 0;
+ i9 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i9 + 1;
+ i6 = i1 + 8 | 0;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + i9 | 0] = i7;
+ i9 = (HEAPU16[i4 >> 1] | 0) >>> 8 & 255;
+ i7 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i7 + 1;
+ HEAP8[(HEAP32[i6 >> 2] | 0) + i7 | 0] = i9;
+ HEAP16[i4 >> 1] = 0;
+ i7 = 0;
+ i6 = (HEAP32[i3 >> 2] | 0) + -9 | 0;
+ } else {
+ i6 = i6 + 7 | 0;
+ }
+ HEAP32[i3 >> 2] = i6;
+ if ((i6 | 0) == 16) {
+ i6 = i1 + 20 | 0;
+ i9 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i9 + 1;
+ i8 = i1 + 8 | 0;
+ HEAP8[(HEAP32[i8 >> 2] | 0) + i9 | 0] = i7;
+ i7 = (HEAPU16[i4 >> 1] | 0) >>> 8 & 255;
+ i9 = HEAP32[i6 >> 2] | 0;
+ HEAP32[i6 >> 2] = i9 + 1;
+ HEAP8[(HEAP32[i8 >> 2] | 0) + i9 | 0] = i7;
+ HEAP16[i4 >> 1] = 0;
+ HEAP32[i3 >> 2] = 0;
+ HEAP32[i5 >> 2] = 7;
+ STACKTOP = i2;
+ return;
+ }
+ if ((i6 | 0) <= 7) {
+ HEAP32[i5 >> 2] = 7;
+ STACKTOP = i2;
+ return;
+ }
+ i8 = i1 + 20 | 0;
+ i9 = HEAP32[i8 >> 2] | 0;
+ HEAP32[i8 >> 2] = i9 + 1;
+ HEAP8[(HEAP32[i1 + 8 >> 2] | 0) + i9 | 0] = i7;
+ HEAP16[i4 >> 1] = (HEAPU16[i4 >> 1] | 0) >>> 8;
+ HEAP32[i3 >> 2] = (HEAP32[i3 >> 2] | 0) + -8;
+ HEAP32[i5 >> 2] = 7;
+ STACKTOP = i2;
+ return;
+}
+function _adler32(i6, i4, i5) {
+ i6 = i6 | 0;
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0;
+ i1 = STACKTOP;
+ i3 = i6 >>> 16;
+ i6 = i6 & 65535;
+ if ((i5 | 0) == 1) {
+ i2 = (HEAPU8[i4] | 0) + i6 | 0;
+ i2 = i2 >>> 0 > 65520 ? i2 + -65521 | 0 : i2;
+ i3 = i2 + i3 | 0;
+ i8 = (i3 >>> 0 > 65520 ? i3 + 15 | 0 : i3) << 16 | i2;
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ if ((i4 | 0) == 0) {
+ i8 = 1;
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ if (i5 >>> 0 < 16) {
+ if ((i5 | 0) != 0) {
+ while (1) {
+ i5 = i5 + -1 | 0;
+ i6 = (HEAPU8[i4] | 0) + i6 | 0;
+ i3 = i6 + i3 | 0;
+ if ((i5 | 0) == 0) {
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ }
+ }
+ }
+ i8 = ((i3 >>> 0) % 65521 | 0) << 16 | (i6 >>> 0 > 65520 ? i6 + -65521 | 0 : i6);
+ STACKTOP = i1;
+ return i8 | 0;
+ }
+ if (i5 >>> 0 > 5551) {
+ do {
+ i5 = i5 + -5552 | 0;
+ i7 = i4;
+ i8 = 347;
+ while (1) {
+ i23 = (HEAPU8[i7] | 0) + i6 | 0;
+ i22 = i23 + (HEAPU8[i7 + 1 | 0] | 0) | 0;
+ i21 = i22 + (HEAPU8[i7 + 2 | 0] | 0) | 0;
+ i20 = i21 + (HEAPU8[i7 + 3 | 0] | 0) | 0;
+ i19 = i20 + (HEAPU8[i7 + 4 | 0] | 0) | 0;
+ i18 = i19 + (HEAPU8[i7 + 5 | 0] | 0) | 0;
+ i17 = i18 + (HEAPU8[i7 + 6 | 0] | 0) | 0;
+ i16 = i17 + (HEAPU8[i7 + 7 | 0] | 0) | 0;
+ i15 = i16 + (HEAPU8[i7 + 8 | 0] | 0) | 0;
+ i14 = i15 + (HEAPU8[i7 + 9 | 0] | 0) | 0;
+ i13 = i14 + (HEAPU8[i7 + 10 | 0] | 0) | 0;
+ i12 = i13 + (HEAPU8[i7 + 11 | 0] | 0) | 0;
+ i11 = i12 + (HEAPU8[i7 + 12 | 0] | 0) | 0;
+ i10 = i11 + (HEAPU8[i7 + 13 | 0] | 0) | 0;
+ i9 = i10 + (HEAPU8[i7 + 14 | 0] | 0) | 0;
+ i6 = i9 + (HEAPU8[i7 + 15 | 0] | 0) | 0;
+ i3 = i23 + i3 + i22 + i21 + i20 + i19 + i18 + i17 + i16 + i15 + i14 + i13 + i12 + i11 + i10 + i9 + i6 | 0;
+ i8 = i8 + -1 | 0;
+ if ((i8 | 0) == 0) {
+ break;
+ } else {
+ i7 = i7 + 16 | 0;
+ }
+ }
+ i4 = i4 + 5552 | 0;
+ i6 = (i6 >>> 0) % 65521 | 0;
+ i3 = (i3 >>> 0) % 65521 | 0;
+ } while (i5 >>> 0 > 5551);
+ if ((i5 | 0) != 0) {
+ if (i5 >>> 0 > 15) {
+ i2 = 15;
+ } else {
+ i2 = 16;
+ }
+ }
+ } else {
+ i2 = 15;
+ }
+ if ((i2 | 0) == 15) {
+ while (1) {
+ i5 = i5 + -16 | 0;
+ i9 = (HEAPU8[i4] | 0) + i6 | 0;
+ i10 = i9 + (HEAPU8[i4 + 1 | 0] | 0) | 0;
+ i11 = i10 + (HEAPU8[i4 + 2 | 0] | 0) | 0;
+ i12 = i11 + (HEAPU8[i4 + 3 | 0] | 0) | 0;
+ i13 = i12 + (HEAPU8[i4 + 4 | 0] | 0) | 0;
+ i14 = i13 + (HEAPU8[i4 + 5 | 0] | 0) | 0;
+ i15 = i14 + (HEAPU8[i4 + 6 | 0] | 0) | 0;
+ i16 = i15 + (HEAPU8[i4 + 7 | 0] | 0) | 0;
+ i17 = i16 + (HEAPU8[i4 + 8 | 0] | 0) | 0;
+ i18 = i17 + (HEAPU8[i4 + 9 | 0] | 0) | 0;
+ i19 = i18 + (HEAPU8[i4 + 10 | 0] | 0) | 0;
+ i20 = i19 + (HEAPU8[i4 + 11 | 0] | 0) | 0;
+ i21 = i20 + (HEAPU8[i4 + 12 | 0] | 0) | 0;
+ i22 = i21 + (HEAPU8[i4 + 13 | 0] | 0) | 0;
+ i23 = i22 + (HEAPU8[i4 + 14 | 0] | 0) | 0;
+ i6 = i23 + (HEAPU8[i4 + 15 | 0] | 0) | 0;
+ i3 = i9 + i3 + i10 + i11 + i12 + i13 + i14 + i15 + i16 + i17 + i18 + i19 + i20 + i21 + i22 + i23 + i6 | 0;
+ i4 = i4 + 16 | 0;
+ if (!(i5 >>> 0 > 15)) {
+ break;
+ } else {
+ i2 = 15;
+ }
+ }
+ if ((i5 | 0) == 0) {
+ i2 = 17;
+ } else {
+ i2 = 16;
+ }
+ }
+ if ((i2 | 0) == 16) {
+ while (1) {
+ i5 = i5 + -1 | 0;
+ i6 = (HEAPU8[i4] | 0) + i6 | 0;
+ i3 = i6 + i3 | 0;
+ if ((i5 | 0) == 0) {
+ i2 = 17;
+ break;
+ } else {
+ i4 = i4 + 1 | 0;
+ i2 = 16;
+ }
+ }
+ }
+ if ((i2 | 0) == 17) {
+ i6 = (i6 >>> 0) % 65521 | 0;
+ i3 = (i3 >>> 0) % 65521 | 0;
+ }
+ i23 = i3 << 16 | i6;
+ STACKTOP = i1;
+ return i23 | 0;
+}
+function _crc32(i4, i2, i3) {
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ var i1 = 0, i5 = 0;
+ i1 = STACKTOP;
+ if ((i2 | 0) == 0) {
+ i5 = 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ i4 = ~i4;
+ L4 : do {
+ if ((i3 | 0) != 0) {
+ while (1) {
+ if ((i2 & 3 | 0) == 0) {
+ break;
+ }
+ i4 = HEAP32[3192 + (((HEAPU8[i2] | 0) ^ i4 & 255) << 2) >> 2] ^ i4 >>> 8;
+ i3 = i3 + -1 | 0;
+ if ((i3 | 0) == 0) {
+ break L4;
+ } else {
+ i2 = i2 + 1 | 0;
+ }
+ }
+ if (i3 >>> 0 > 31) {
+ while (1) {
+ i4 = HEAP32[i2 >> 2] ^ i4;
+ i4 = HEAP32[5240 + ((i4 >>> 8 & 255) << 2) >> 2] ^ HEAP32[6264 + ((i4 & 255) << 2) >> 2] ^ HEAP32[4216 + ((i4 >>> 16 & 255) << 2) >> 2] ^ HEAP32[3192 + (i4 >>> 24 << 2) >> 2] ^ HEAP32[i2 + 4 >> 2];
+ i4 = HEAP32[5240 + ((i4 >>> 8 & 255) << 2) >> 2] ^ HEAP32[6264 + ((i4 & 255) << 2) >> 2] ^ HEAP32[4216 + ((i4 >>> 16 & 255) << 2) >> 2] ^ HEAP32[3192 + (i4 >>> 24 << 2) >> 2] ^ HEAP32[i2 + 8 >> 2];
+ i4 = HEAP32[5240 + ((i4 >>> 8 & 255) << 2) >> 2] ^ HEAP32[6264 + ((i4 & 255) << 2) >> 2] ^ HEAP32[4216 + ((i4 >>> 16 & 255) << 2) >> 2] ^ HEAP32[3192 + (i4 >>> 24 << 2) >> 2] ^ HEAP32[i2 + 12 >> 2];
+ i4 = HEAP32[5240 + ((i4 >>> 8 & 255) << 2) >> 2] ^ HEAP32[6264 + ((i4 & 255) << 2) >> 2] ^ HEAP32[4216 + ((i4 >>> 16 & 255) << 2) >> 2] ^ HEAP32[3192 + (i4 >>> 24 << 2) >> 2] ^ HEAP32[i2 + 16 >> 2];
+ i4 = HEAP32[5240 + ((i4 >>> 8 & 255) << 2) >> 2] ^ HEAP32[6264 + ((i4 & 255) << 2) >> 2] ^ HEAP32[4216 + ((i4 >>> 16 & 255) << 2) >> 2] ^ HEAP32[3192 + (i4 >>> 24 << 2) >> 2] ^ HEAP32[i2 + 20 >> 2];
+ i4 = HEAP32[5240 + ((i4 >>> 8 & 255) << 2) >> 2] ^ HEAP32[6264 + ((i4 & 255) << 2) >> 2] ^ HEAP32[4216 + ((i4 >>> 16 & 255) << 2) >> 2] ^ HEAP32[3192 + (i4 >>> 24 << 2) >> 2] ^ HEAP32[i2 + 24 >> 2];
+ i5 = i2 + 32 | 0;
+ i4 = HEAP32[5240 + ((i4 >>> 8 & 255) << 2) >> 2] ^ HEAP32[6264 + ((i4 & 255) << 2) >> 2] ^ HEAP32[4216 + ((i4 >>> 16 & 255) << 2) >> 2] ^ HEAP32[3192 + (i4 >>> 24 << 2) >> 2] ^ HEAP32[i2 + 28 >> 2];
+ i4 = HEAP32[5240 + ((i4 >>> 8 & 255) << 2) >> 2] ^ HEAP32[6264 + ((i4 & 255) << 2) >> 2] ^ HEAP32[4216 + ((i4 >>> 16 & 255) << 2) >> 2] ^ HEAP32[3192 + (i4 >>> 24 << 2) >> 2];
+ i3 = i3 + -32 | 0;
+ if (i3 >>> 0 > 31) {
+ i2 = i5;
+ } else {
+ i2 = i5;
+ break;
+ }
+ }
+ }
+ if (i3 >>> 0 > 3) {
+ while (1) {
+ i5 = i2 + 4 | 0;
+ i4 = HEAP32[i2 >> 2] ^ i4;
+ i4 = HEAP32[5240 + ((i4 >>> 8 & 255) << 2) >> 2] ^ HEAP32[6264 + ((i4 & 255) << 2) >> 2] ^ HEAP32[4216 + ((i4 >>> 16 & 255) << 2) >> 2] ^ HEAP32[3192 + (i4 >>> 24 << 2) >> 2];
+ i3 = i3 + -4 | 0;
+ if (i3 >>> 0 > 3) {
+ i2 = i5;
+ } else {
+ i2 = i5;
+ break;
+ }
+ }
+ }
+ if ((i3 | 0) != 0) {
+ while (1) {
+ i4 = HEAP32[3192 + (((HEAPU8[i2] | 0) ^ i4 & 255) << 2) >> 2] ^ i4 >>> 8;
+ i3 = i3 + -1 | 0;
+ if ((i3 | 0) == 0) {
+ break;
+ } else {
+ i2 = i2 + 1 | 0;
+ }
+ }
+ }
+ }
+ } while (0);
+ i5 = ~i4;
+ STACKTOP = i1;
+ return i5 | 0;
+}
+function _deflateInit2_(i3, i7, i8, i10, i4, i1, i5, i6) {
+ i3 = i3 | 0;
+ i7 = i7 | 0;
+ i8 = i8 | 0;
+ i10 = i10 | 0;
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ var i2 = 0, i9 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0;
+ i2 = STACKTOP;
+ if ((i5 | 0) == 0) {
+ i12 = -6;
+ STACKTOP = i2;
+ return i12 | 0;
+ }
+ if (!((HEAP8[i5] | 0) == 49 & (i6 | 0) == 56)) {
+ i12 = -6;
+ STACKTOP = i2;
+ return i12 | 0;
+ }
+ if ((i3 | 0) == 0) {
+ i12 = -2;
+ STACKTOP = i2;
+ return i12 | 0;
+ }
+ i5 = i3 + 24 | 0;
+ HEAP32[i5 >> 2] = 0;
+ i6 = i3 + 32 | 0;
+ i9 = HEAP32[i6 >> 2] | 0;
+ if ((i9 | 0) == 0) {
+ HEAP32[i6 >> 2] = 1;
+ HEAP32[i3 + 40 >> 2] = 0;
+ i9 = 1;
+ }
+ i11 = i3 + 36 | 0;
+ if ((HEAP32[i11 >> 2] | 0) == 0) {
+ HEAP32[i11 >> 2] = 1;
+ }
+ i7 = (i7 | 0) == -1 ? 6 : i7;
+ if ((i10 | 0) < 0) {
+ i10 = 0 - i10 | 0;
+ i11 = 0;
+ } else {
+ i11 = (i10 | 0) > 15;
+ i10 = i11 ? i10 + -16 | 0 : i10;
+ i11 = i11 ? 2 : 1;
+ }
+ if (!((i4 + -1 | 0) >>> 0 < 9 & (i8 | 0) == 8)) {
+ i12 = -2;
+ STACKTOP = i2;
+ return i12 | 0;
+ }
+ if ((i10 + -8 | 0) >>> 0 > 7 | i7 >>> 0 > 9 | i1 >>> 0 > 4) {
+ i12 = -2;
+ STACKTOP = i2;
+ return i12 | 0;
+ }
+ i12 = (i10 | 0) == 8 ? 9 : i10;
+ i10 = i3 + 40 | 0;
+ i8 = FUNCTION_TABLE_iiii[i9 & 1](HEAP32[i10 >> 2] | 0, 1, 5828) | 0;
+ if ((i8 | 0) == 0) {
+ i12 = -4;
+ STACKTOP = i2;
+ return i12 | 0;
+ }
+ HEAP32[i3 + 28 >> 2] = i8;
+ HEAP32[i8 >> 2] = i3;
+ HEAP32[i8 + 24 >> 2] = i11;
+ HEAP32[i8 + 28 >> 2] = 0;
+ HEAP32[i8 + 48 >> 2] = i12;
+ i14 = 1 << i12;
+ i11 = i8 + 44 | 0;
+ HEAP32[i11 >> 2] = i14;
+ HEAP32[i8 + 52 >> 2] = i14 + -1;
+ i12 = i4 + 7 | 0;
+ HEAP32[i8 + 80 >> 2] = i12;
+ i12 = 1 << i12;
+ i13 = i8 + 76 | 0;
+ HEAP32[i13 >> 2] = i12;
+ HEAP32[i8 + 84 >> 2] = i12 + -1;
+ HEAP32[i8 + 88 >> 2] = ((i4 + 9 | 0) >>> 0) / 3 | 0;
+ i12 = i8 + 56 | 0;
+ HEAP32[i12 >> 2] = FUNCTION_TABLE_iiii[HEAP32[i6 >> 2] & 1](HEAP32[i10 >> 2] | 0, i14, 2) | 0;
+ i14 = FUNCTION_TABLE_iiii[HEAP32[i6 >> 2] & 1](HEAP32[i10 >> 2] | 0, HEAP32[i11 >> 2] | 0, 2) | 0;
+ i9 = i8 + 64 | 0;
+ HEAP32[i9 >> 2] = i14;
+ _memset(i14 | 0, 0, HEAP32[i11 >> 2] << 1 | 0) | 0;
+ i11 = i8 + 68 | 0;
+ HEAP32[i11 >> 2] = FUNCTION_TABLE_iiii[HEAP32[i6 >> 2] & 1](HEAP32[i10 >> 2] | 0, HEAP32[i13 >> 2] | 0, 2) | 0;
+ HEAP32[i8 + 5824 >> 2] = 0;
+ i4 = 1 << i4 + 6;
+ i13 = i8 + 5788 | 0;
+ HEAP32[i13 >> 2] = i4;
+ i4 = FUNCTION_TABLE_iiii[HEAP32[i6 >> 2] & 1](HEAP32[i10 >> 2] | 0, i4, 4) | 0;
+ HEAP32[i8 + 8 >> 2] = i4;
+ i6 = HEAP32[i13 >> 2] | 0;
+ HEAP32[i8 + 12 >> 2] = i6 << 2;
+ if (((HEAP32[i12 >> 2] | 0) != 0 ? (HEAP32[i9 >> 2] | 0) != 0 : 0) ? !((HEAP32[i11 >> 2] | 0) == 0 | (i4 | 0) == 0) : 0) {
+ HEAP32[i8 + 5796 >> 2] = i4 + (i6 >>> 1 << 1);
+ HEAP32[i8 + 5784 >> 2] = i4 + (i6 * 3 | 0);
+ HEAP32[i8 + 132 >> 2] = i7;
+ HEAP32[i8 + 136 >> 2] = i1;
+ HEAP8[i8 + 36 | 0] = 8;
+ i14 = _deflateReset(i3) | 0;
+ STACKTOP = i2;
+ return i14 | 0;
+ }
+ HEAP32[i8 + 4 >> 2] = 666;
+ HEAP32[i5 >> 2] = HEAP32[3176 >> 2];
+ _deflateEnd(i3) | 0;
+ i14 = -4;
+ STACKTOP = i2;
+ return i14 | 0;
+}
+function _longest_match(i19, i16) {
+ i19 = i19 | 0;
+ i16 = i16 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i17 = 0, i18 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0;
+ i1 = STACKTOP;
+ i18 = HEAP32[i19 + 124 >> 2] | 0;
+ i3 = HEAP32[i19 + 56 >> 2] | 0;
+ i5 = HEAP32[i19 + 108 >> 2] | 0;
+ i4 = i3 + i5 | 0;
+ i20 = HEAP32[i19 + 120 >> 2] | 0;
+ i10 = HEAP32[i19 + 144 >> 2] | 0;
+ i2 = (HEAP32[i19 + 44 >> 2] | 0) + -262 | 0;
+ i8 = i5 >>> 0 > i2 >>> 0 ? i5 - i2 | 0 : 0;
+ i6 = HEAP32[i19 + 64 >> 2] | 0;
+ i7 = HEAP32[i19 + 52 >> 2] | 0;
+ i9 = i3 + (i5 + 258) | 0;
+ i2 = HEAP32[i19 + 116 >> 2] | 0;
+ i12 = i10 >>> 0 > i2 >>> 0 ? i2 : i10;
+ i11 = i19 + 112 | 0;
+ i15 = i3 + (i5 + 1) | 0;
+ i14 = i3 + (i5 + 2) | 0;
+ i13 = i9;
+ i10 = i5 + 257 | 0;
+ i17 = i20;
+ i18 = i20 >>> 0 < (HEAP32[i19 + 140 >> 2] | 0) >>> 0 ? i18 : i18 >>> 2;
+ i19 = HEAP8[i3 + (i20 + i5) | 0] | 0;
+ i20 = HEAP8[i3 + (i5 + -1 + i20) | 0] | 0;
+ while (1) {
+ i21 = i3 + i16 | 0;
+ if ((((HEAP8[i3 + (i16 + i17) | 0] | 0) == i19 << 24 >> 24 ? (HEAP8[i3 + (i17 + -1 + i16) | 0] | 0) == i20 << 24 >> 24 : 0) ? (HEAP8[i21] | 0) == (HEAP8[i4] | 0) : 0) ? (HEAP8[i3 + (i16 + 1) | 0] | 0) == (HEAP8[i15] | 0) : 0) {
+ i21 = i3 + (i16 + 2) | 0;
+ i22 = i14;
+ do {
+ i23 = i22 + 1 | 0;
+ if ((HEAP8[i23] | 0) != (HEAP8[i21 + 1 | 0] | 0)) {
+ i22 = i23;
+ break;
+ }
+ i23 = i22 + 2 | 0;
+ if ((HEAP8[i23] | 0) != (HEAP8[i21 + 2 | 0] | 0)) {
+ i22 = i23;
+ break;
+ }
+ i23 = i22 + 3 | 0;
+ if ((HEAP8[i23] | 0) != (HEAP8[i21 + 3 | 0] | 0)) {
+ i22 = i23;
+ break;
+ }
+ i23 = i22 + 4 | 0;
+ if ((HEAP8[i23] | 0) != (HEAP8[i21 + 4 | 0] | 0)) {
+ i22 = i23;
+ break;
+ }
+ i23 = i22 + 5 | 0;
+ if ((HEAP8[i23] | 0) != (HEAP8[i21 + 5 | 0] | 0)) {
+ i22 = i23;
+ break;
+ }
+ i23 = i22 + 6 | 0;
+ if ((HEAP8[i23] | 0) != (HEAP8[i21 + 6 | 0] | 0)) {
+ i22 = i23;
+ break;
+ }
+ i23 = i22 + 7 | 0;
+ if ((HEAP8[i23] | 0) != (HEAP8[i21 + 7 | 0] | 0)) {
+ i22 = i23;
+ break;
+ }
+ i22 = i22 + 8 | 0;
+ i21 = i21 + 8 | 0;
+ } while ((HEAP8[i22] | 0) == (HEAP8[i21] | 0) & i22 >>> 0 < i9 >>> 0);
+ i21 = i22 - i13 | 0;
+ i22 = i21 + 258 | 0;
+ if ((i22 | 0) > (i17 | 0)) {
+ HEAP32[i11 >> 2] = i16;
+ if ((i22 | 0) >= (i12 | 0)) {
+ i17 = i22;
+ i3 = 20;
+ break;
+ }
+ i17 = i22;
+ i19 = HEAP8[i3 + (i22 + i5) | 0] | 0;
+ i20 = HEAP8[i3 + (i10 + i21) | 0] | 0;
+ }
+ }
+ i16 = HEAPU16[i6 + ((i16 & i7) << 1) >> 1] | 0;
+ if (!(i16 >>> 0 > i8 >>> 0)) {
+ i3 = 20;
+ break;
+ }
+ i18 = i18 + -1 | 0;
+ if ((i18 | 0) == 0) {
+ i3 = 20;
+ break;
+ }
+ }
+ if ((i3 | 0) == 20) {
+ STACKTOP = i1;
+ return (i17 >>> 0 > i2 >>> 0 ? i2 : i17) | 0;
+ }
+ return 0;
+}
+function __tr_stored_block(i3, i2, i5, i6) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ var i1 = 0, i4 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0;
+ i1 = STACKTOP;
+ i4 = i3 + 5820 | 0;
+ i7 = HEAP32[i4 >> 2] | 0;
+ i9 = i6 & 65535;
+ i6 = i3 + 5816 | 0;
+ i8 = HEAPU16[i6 >> 1] | 0 | i9 << i7;
+ HEAP16[i6 >> 1] = i8;
+ if ((i7 | 0) > 13) {
+ i11 = i3 + 20 | 0;
+ i7 = HEAP32[i11 >> 2] | 0;
+ HEAP32[i11 >> 2] = i7 + 1;
+ i10 = i3 + 8 | 0;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i7 | 0] = i8;
+ i8 = (HEAPU16[i6 >> 1] | 0) >>> 8 & 255;
+ i7 = HEAP32[i11 >> 2] | 0;
+ HEAP32[i11 >> 2] = i7 + 1;
+ HEAP8[(HEAP32[i10 >> 2] | 0) + i7 | 0] = i8;
+ i7 = HEAP32[i4 >> 2] | 0;
+ i8 = i9 >>> (16 - i7 | 0);
+ HEAP16[i6 >> 1] = i8;
+ i7 = i7 + -13 | 0;
+ } else {
+ i7 = i7 + 3 | 0;
+ }
+ i8 = i8 & 255;
+ HEAP32[i4 >> 2] = i7;
+ do {
+ if ((i7 | 0) <= 8) {
+ i9 = i3 + 20 | 0;
+ if ((i7 | 0) > 0) {
+ i7 = HEAP32[i9 >> 2] | 0;
+ HEAP32[i9 >> 2] = i7 + 1;
+ i11 = i3 + 8 | 0;
+ HEAP8[(HEAP32[i11 >> 2] | 0) + i7 | 0] = i8;
+ i7 = i9;
+ i8 = i11;
+ break;
+ } else {
+ i7 = i9;
+ i8 = i3 + 8 | 0;
+ break;
+ }
+ } else {
+ i7 = i3 + 20 | 0;
+ i10 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i10 + 1;
+ i11 = i3 + 8 | 0;
+ HEAP8[(HEAP32[i11 >> 2] | 0) + i10 | 0] = i8;
+ i10 = (HEAPU16[i6 >> 1] | 0) >>> 8 & 255;
+ i8 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i8 + 1;
+ HEAP8[(HEAP32[i11 >> 2] | 0) + i8 | 0] = i10;
+ i8 = i11;
+ }
+ } while (0);
+ HEAP16[i6 >> 1] = 0;
+ HEAP32[i4 >> 2] = 0;
+ HEAP32[i3 + 5812 >> 2] = 8;
+ i10 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i10 + 1;
+ HEAP8[(HEAP32[i8 >> 2] | 0) + i10 | 0] = i5;
+ i10 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i10 + 1;
+ HEAP8[(HEAP32[i8 >> 2] | 0) + i10 | 0] = i5 >>> 8;
+ i10 = i5 & 65535 ^ 65535;
+ i11 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i11 + 1;
+ HEAP8[(HEAP32[i8 >> 2] | 0) + i11 | 0] = i10;
+ i11 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i11 + 1;
+ HEAP8[(HEAP32[i8 >> 2] | 0) + i11 | 0] = i10 >>> 8;
+ if ((i5 | 0) == 0) {
+ STACKTOP = i1;
+ return;
+ }
+ while (1) {
+ i5 = i5 + -1 | 0;
+ i10 = HEAP8[i2] | 0;
+ i11 = HEAP32[i7 >> 2] | 0;
+ HEAP32[i7 >> 2] = i11 + 1;
+ HEAP8[(HEAP32[i8 >> 2] | 0) + i11 | 0] = i10;
+ if ((i5 | 0) == 0) {
+ break;
+ } else {
+ i2 = i2 + 1 | 0;
+ }
+ }
+ STACKTOP = i1;
+ return;
+}
+function _inflateInit_(i1, i3, i4) {
+ i1 = i1 | 0;
+ i3 = i3 | 0;
+ i4 = i4 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0;
+ i2 = STACKTOP;
+ if ((i3 | 0) == 0) {
+ i11 = -6;
+ STACKTOP = i2;
+ return i11 | 0;
+ }
+ if (!((HEAP8[i3] | 0) == 49 & (i4 | 0) == 56)) {
+ i11 = -6;
+ STACKTOP = i2;
+ return i11 | 0;
+ }
+ if ((i1 | 0) == 0) {
+ i11 = -2;
+ STACKTOP = i2;
+ return i11 | 0;
+ }
+ i3 = i1 + 24 | 0;
+ HEAP32[i3 >> 2] = 0;
+ i4 = i1 + 32 | 0;
+ i6 = HEAP32[i4 >> 2] | 0;
+ if ((i6 | 0) == 0) {
+ HEAP32[i4 >> 2] = 1;
+ HEAP32[i1 + 40 >> 2] = 0;
+ i6 = 1;
+ }
+ i4 = i1 + 36 | 0;
+ if ((HEAP32[i4 >> 2] | 0) == 0) {
+ HEAP32[i4 >> 2] = 1;
+ }
+ i5 = i1 + 40 | 0;
+ i8 = FUNCTION_TABLE_iiii[i6 & 1](HEAP32[i5 >> 2] | 0, 1, 7116) | 0;
+ if ((i8 | 0) == 0) {
+ i11 = -4;
+ STACKTOP = i2;
+ return i11 | 0;
+ }
+ i6 = i1 + 28 | 0;
+ HEAP32[i6 >> 2] = i8;
+ HEAP32[i8 + 52 >> 2] = 0;
+ i9 = HEAP32[i6 >> 2] | 0;
+ do {
+ if ((i9 | 0) != 0) {
+ i10 = i9 + 52 | 0;
+ i11 = HEAP32[i10 >> 2] | 0;
+ i7 = i9 + 36 | 0;
+ if ((i11 | 0) != 0) {
+ if ((HEAP32[i7 >> 2] | 0) == 15) {
+ i10 = i9;
+ } else {
+ FUNCTION_TABLE_vii[HEAP32[i4 >> 2] & 1](HEAP32[i5 >> 2] | 0, i11);
+ HEAP32[i10 >> 2] = 0;
+ i10 = HEAP32[i6 >> 2] | 0;
+ }
+ HEAP32[i9 + 8 >> 2] = 1;
+ HEAP32[i7 >> 2] = 15;
+ if ((i10 | 0) == 0) {
+ break;
+ } else {
+ i9 = i10;
+ }
+ } else {
+ HEAP32[i9 + 8 >> 2] = 1;
+ HEAP32[i7 >> 2] = 15;
+ }
+ HEAP32[i9 + 28 >> 2] = 0;
+ HEAP32[i1 + 20 >> 2] = 0;
+ HEAP32[i1 + 8 >> 2] = 0;
+ HEAP32[i3 >> 2] = 0;
+ HEAP32[i1 + 48 >> 2] = 1;
+ HEAP32[i9 >> 2] = 0;
+ HEAP32[i9 + 4 >> 2] = 0;
+ HEAP32[i9 + 12 >> 2] = 0;
+ HEAP32[i9 + 20 >> 2] = 32768;
+ HEAP32[i9 + 32 >> 2] = 0;
+ HEAP32[i9 + 40 >> 2] = 0;
+ HEAP32[i9 + 44 >> 2] = 0;
+ HEAP32[i9 + 48 >> 2] = 0;
+ HEAP32[i9 + 56 >> 2] = 0;
+ HEAP32[i9 + 60 >> 2] = 0;
+ i11 = i9 + 1328 | 0;
+ HEAP32[i9 + 108 >> 2] = i11;
+ HEAP32[i9 + 80 >> 2] = i11;
+ HEAP32[i9 + 76 >> 2] = i11;
+ HEAP32[i9 + 7104 >> 2] = 1;
+ HEAP32[i9 + 7108 >> 2] = -1;
+ i11 = 0;
+ STACKTOP = i2;
+ return i11 | 0;
+ }
+ } while (0);
+ FUNCTION_TABLE_vii[HEAP32[i4 >> 2] & 1](HEAP32[i5 >> 2] | 0, i8);
+ HEAP32[i6 >> 2] = 0;
+ i11 = -2;
+ STACKTOP = i2;
+ return i11 | 0;
+}
+function _init_block(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ i3 = 0;
+ do {
+ HEAP16[i1 + (i3 << 2) + 148 >> 1] = 0;
+ i3 = i3 + 1 | 0;
+ } while ((i3 | 0) != 286);
+ HEAP16[i1 + 2440 >> 1] = 0;
+ HEAP16[i1 + 2444 >> 1] = 0;
+ HEAP16[i1 + 2448 >> 1] = 0;
+ HEAP16[i1 + 2452 >> 1] = 0;
+ HEAP16[i1 + 2456 >> 1] = 0;
+ HEAP16[i1 + 2460 >> 1] = 0;
+ HEAP16[i1 + 2464 >> 1] = 0;
+ HEAP16[i1 + 2468 >> 1] = 0;
+ HEAP16[i1 + 2472 >> 1] = 0;
+ HEAP16[i1 + 2476 >> 1] = 0;
+ HEAP16[i1 + 2480 >> 1] = 0;
+ HEAP16[i1 + 2484 >> 1] = 0;
+ HEAP16[i1 + 2488 >> 1] = 0;
+ HEAP16[i1 + 2492 >> 1] = 0;
+ HEAP16[i1 + 2496 >> 1] = 0;
+ HEAP16[i1 + 2500 >> 1] = 0;
+ HEAP16[i1 + 2504 >> 1] = 0;
+ HEAP16[i1 + 2508 >> 1] = 0;
+ HEAP16[i1 + 2512 >> 1] = 0;
+ HEAP16[i1 + 2516 >> 1] = 0;
+ HEAP16[i1 + 2520 >> 1] = 0;
+ HEAP16[i1 + 2524 >> 1] = 0;
+ HEAP16[i1 + 2528 >> 1] = 0;
+ HEAP16[i1 + 2532 >> 1] = 0;
+ HEAP16[i1 + 2536 >> 1] = 0;
+ HEAP16[i1 + 2540 >> 1] = 0;
+ HEAP16[i1 + 2544 >> 1] = 0;
+ HEAP16[i1 + 2548 >> 1] = 0;
+ HEAP16[i1 + 2552 >> 1] = 0;
+ HEAP16[i1 + 2556 >> 1] = 0;
+ HEAP16[i1 + 2684 >> 1] = 0;
+ HEAP16[i1 + 2688 >> 1] = 0;
+ HEAP16[i1 + 2692 >> 1] = 0;
+ HEAP16[i1 + 2696 >> 1] = 0;
+ HEAP16[i1 + 2700 >> 1] = 0;
+ HEAP16[i1 + 2704 >> 1] = 0;
+ HEAP16[i1 + 2708 >> 1] = 0;
+ HEAP16[i1 + 2712 >> 1] = 0;
+ HEAP16[i1 + 2716 >> 1] = 0;
+ HEAP16[i1 + 2720 >> 1] = 0;
+ HEAP16[i1 + 2724 >> 1] = 0;
+ HEAP16[i1 + 2728 >> 1] = 0;
+ HEAP16[i1 + 2732 >> 1] = 0;
+ HEAP16[i1 + 2736 >> 1] = 0;
+ HEAP16[i1 + 2740 >> 1] = 0;
+ HEAP16[i1 + 2744 >> 1] = 0;
+ HEAP16[i1 + 2748 >> 1] = 0;
+ HEAP16[i1 + 2752 >> 1] = 0;
+ HEAP16[i1 + 2756 >> 1] = 0;
+ HEAP16[i1 + 1172 >> 1] = 1;
+ HEAP32[i1 + 5804 >> 2] = 0;
+ HEAP32[i1 + 5800 >> 2] = 0;
+ HEAP32[i1 + 5808 >> 2] = 0;
+ HEAP32[i1 + 5792 >> 2] = 0;
+ STACKTOP = i2;
+ return;
+}
+function _deflateReset(i1) {
+ i1 = i1 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0;
+ i2 = STACKTOP;
+ if ((i1 | 0) == 0) {
+ i5 = -2;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ i3 = HEAP32[i1 + 28 >> 2] | 0;
+ if ((i3 | 0) == 0) {
+ i5 = -2;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ if ((HEAP32[i1 + 32 >> 2] | 0) == 0) {
+ i5 = -2;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ if ((HEAP32[i1 + 36 >> 2] | 0) == 0) {
+ i5 = -2;
+ STACKTOP = i2;
+ return i5 | 0;
+ }
+ HEAP32[i1 + 20 >> 2] = 0;
+ HEAP32[i1 + 8 >> 2] = 0;
+ HEAP32[i1 + 24 >> 2] = 0;
+ HEAP32[i1 + 44 >> 2] = 2;
+ HEAP32[i3 + 20 >> 2] = 0;
+ HEAP32[i3 + 16 >> 2] = HEAP32[i3 + 8 >> 2];
+ i4 = i3 + 24 | 0;
+ i5 = HEAP32[i4 >> 2] | 0;
+ if ((i5 | 0) < 0) {
+ i5 = 0 - i5 | 0;
+ HEAP32[i4 >> 2] = i5;
+ }
+ HEAP32[i3 + 4 >> 2] = (i5 | 0) != 0 ? 42 : 113;
+ if ((i5 | 0) == 2) {
+ i4 = _crc32(0, 0, 0) | 0;
+ } else {
+ i4 = _adler32(0, 0, 0) | 0;
+ }
+ HEAP32[i1 + 48 >> 2] = i4;
+ HEAP32[i3 + 40 >> 2] = 0;
+ __tr_init(i3);
+ HEAP32[i3 + 60 >> 2] = HEAP32[i3 + 44 >> 2] << 1;
+ i5 = HEAP32[i3 + 76 >> 2] | 0;
+ i4 = HEAP32[i3 + 68 >> 2] | 0;
+ HEAP16[i4 + (i5 + -1 << 1) >> 1] = 0;
+ _memset(i4 | 0, 0, (i5 << 1) + -2 | 0) | 0;
+ i5 = HEAP32[i3 + 132 >> 2] | 0;
+ HEAP32[i3 + 128 >> 2] = HEAPU16[178 + (i5 * 12 | 0) >> 1] | 0;
+ HEAP32[i3 + 140 >> 2] = HEAPU16[176 + (i5 * 12 | 0) >> 1] | 0;
+ HEAP32[i3 + 144 >> 2] = HEAPU16[180 + (i5 * 12 | 0) >> 1] | 0;
+ HEAP32[i3 + 124 >> 2] = HEAPU16[182 + (i5 * 12 | 0) >> 1] | 0;
+ HEAP32[i3 + 108 >> 2] = 0;
+ HEAP32[i3 + 92 >> 2] = 0;
+ HEAP32[i3 + 116 >> 2] = 0;
+ HEAP32[i3 + 120 >> 2] = 2;
+ HEAP32[i3 + 96 >> 2] = 2;
+ HEAP32[i3 + 112 >> 2] = 0;
+ HEAP32[i3 + 104 >> 2] = 0;
+ HEAP32[i3 + 72 >> 2] = 0;
+ i5 = 0;
+ STACKTOP = i2;
+ return i5 | 0;
+}
+function _updatewindow(i6, i4) {
+ i6 = i6 | 0;
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0;
+ i1 = STACKTOP;
+ i2 = HEAP32[i6 + 28 >> 2] | 0;
+ i3 = i2 + 52 | 0;
+ i8 = HEAP32[i3 >> 2] | 0;
+ if ((i8 | 0) == 0) {
+ i8 = FUNCTION_TABLE_iiii[HEAP32[i6 + 32 >> 2] & 1](HEAP32[i6 + 40 >> 2] | 0, 1 << HEAP32[i2 + 36 >> 2], 1) | 0;
+ HEAP32[i3 >> 2] = i8;
+ if ((i8 | 0) == 0) {
+ i10 = 1;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ }
+ i5 = i2 + 40 | 0;
+ i10 = HEAP32[i5 >> 2] | 0;
+ if ((i10 | 0) == 0) {
+ i10 = 1 << HEAP32[i2 + 36 >> 2];
+ HEAP32[i5 >> 2] = i10;
+ HEAP32[i2 + 48 >> 2] = 0;
+ HEAP32[i2 + 44 >> 2] = 0;
+ }
+ i4 = i4 - (HEAP32[i6 + 16 >> 2] | 0) | 0;
+ if (!(i4 >>> 0 < i10 >>> 0)) {
+ _memcpy(i8 | 0, (HEAP32[i6 + 12 >> 2] | 0) + (0 - i10) | 0, i10 | 0) | 0;
+ HEAP32[i2 + 48 >> 2] = 0;
+ HEAP32[i2 + 44 >> 2] = HEAP32[i5 >> 2];
+ i10 = 0;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ i7 = i2 + 48 | 0;
+ i9 = HEAP32[i7 >> 2] | 0;
+ i10 = i10 - i9 | 0;
+ i10 = i10 >>> 0 > i4 >>> 0 ? i4 : i10;
+ i6 = i6 + 12 | 0;
+ _memcpy(i8 + i9 | 0, (HEAP32[i6 >> 2] | 0) + (0 - i4) | 0, i10 | 0) | 0;
+ i8 = i4 - i10 | 0;
+ if ((i4 | 0) != (i10 | 0)) {
+ _memcpy(HEAP32[i3 >> 2] | 0, (HEAP32[i6 >> 2] | 0) + (0 - i8) | 0, i8 | 0) | 0;
+ HEAP32[i7 >> 2] = i8;
+ HEAP32[i2 + 44 >> 2] = HEAP32[i5 >> 2];
+ i10 = 0;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ i6 = (HEAP32[i7 >> 2] | 0) + i4 | 0;
+ i3 = HEAP32[i5 >> 2] | 0;
+ HEAP32[i7 >> 2] = (i6 | 0) == (i3 | 0) ? 0 : i6;
+ i5 = i2 + 44 | 0;
+ i2 = HEAP32[i5 >> 2] | 0;
+ if (!(i2 >>> 0 < i3 >>> 0)) {
+ i10 = 0;
+ STACKTOP = i1;
+ return i10 | 0;
+ }
+ HEAP32[i5 >> 2] = i2 + i4;
+ i10 = 0;
+ STACKTOP = i1;
+ return i10 | 0;
+}
+function _scan_tree(i1, i5, i6) {
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i6 = i6 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0;
+ i8 = STACKTOP;
+ i10 = HEAP16[i5 + 2 >> 1] | 0;
+ i9 = i10 << 16 >> 16 == 0;
+ HEAP16[i5 + (i6 + 1 << 2) + 2 >> 1] = -1;
+ i2 = i1 + 2752 | 0;
+ i3 = i1 + 2756 | 0;
+ i4 = i1 + 2748 | 0;
+ i7 = i9 ? 138 : 7;
+ i9 = i9 ? 3 : 4;
+ i13 = 0;
+ i11 = i10 & 65535;
+ i12 = -1;
+ L1 : while (1) {
+ i14 = 0;
+ do {
+ if ((i13 | 0) > (i6 | 0)) {
+ break L1;
+ }
+ i13 = i13 + 1 | 0;
+ i16 = HEAP16[i5 + (i13 << 2) + 2 >> 1] | 0;
+ i10 = i16 & 65535;
+ i14 = i14 + 1 | 0;
+ i15 = (i11 | 0) == (i10 | 0);
+ } while ((i14 | 0) < (i7 | 0) & i15);
+ do {
+ if ((i14 | 0) >= (i9 | 0)) {
+ if ((i11 | 0) == 0) {
+ if ((i14 | 0) < 11) {
+ HEAP16[i2 >> 1] = (HEAP16[i2 >> 1] | 0) + 1 << 16 >> 16;
+ break;
+ } else {
+ HEAP16[i3 >> 1] = (HEAP16[i3 >> 1] | 0) + 1 << 16 >> 16;
+ break;
+ }
+ } else {
+ if ((i11 | 0) != (i12 | 0)) {
+ i14 = i1 + (i11 << 2) + 2684 | 0;
+ HEAP16[i14 >> 1] = (HEAP16[i14 >> 1] | 0) + 1 << 16 >> 16;
+ }
+ HEAP16[i4 >> 1] = (HEAP16[i4 >> 1] | 0) + 1 << 16 >> 16;
+ break;
+ }
+ } else {
+ i12 = i1 + (i11 << 2) + 2684 | 0;
+ HEAP16[i12 >> 1] = (HEAPU16[i12 >> 1] | 0) + i14;
+ }
+ } while (0);
+ if (i16 << 16 >> 16 == 0) {
+ i12 = i11;
+ i7 = 138;
+ i9 = 3;
+ i11 = i10;
+ continue;
+ }
+ i12 = i11;
+ i7 = i15 ? 6 : 7;
+ i9 = i15 ? 3 : 4;
+ i11 = i10;
+ }
+ STACKTOP = i8;
+ return;
+}
+function _deflateEnd(i4) {
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i3 = STACKTOP;
+ if ((i4 | 0) == 0) {
+ i7 = -2;
+ STACKTOP = i3;
+ return i7 | 0;
+ }
+ i1 = i4 + 28 | 0;
+ i6 = HEAP32[i1 >> 2] | 0;
+ if ((i6 | 0) == 0) {
+ i7 = -2;
+ STACKTOP = i3;
+ return i7 | 0;
+ }
+ i2 = HEAP32[i6 + 4 >> 2] | 0;
+ switch (i2 | 0) {
+ case 42:
+ case 69:
+ case 73:
+ case 91:
+ case 103:
+ case 113:
+ case 666:
+ {
+ break;
+ }
+ default:
+ {
+ i7 = -2;
+ STACKTOP = i3;
+ return i7 | 0;
+ }
+ }
+ i5 = HEAP32[i6 + 8 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ FUNCTION_TABLE_vii[HEAP32[i4 + 36 >> 2] & 1](HEAP32[i4 + 40 >> 2] | 0, i5);
+ i6 = HEAP32[i1 >> 2] | 0;
+ }
+ i5 = HEAP32[i6 + 68 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ FUNCTION_TABLE_vii[HEAP32[i4 + 36 >> 2] & 1](HEAP32[i4 + 40 >> 2] | 0, i5);
+ i6 = HEAP32[i1 >> 2] | 0;
+ }
+ i5 = HEAP32[i6 + 64 >> 2] | 0;
+ if ((i5 | 0) != 0) {
+ FUNCTION_TABLE_vii[HEAP32[i4 + 36 >> 2] & 1](HEAP32[i4 + 40 >> 2] | 0, i5);
+ i6 = HEAP32[i1 >> 2] | 0;
+ }
+ i7 = HEAP32[i6 + 56 >> 2] | 0;
+ i5 = i4 + 36 | 0;
+ if ((i7 | 0) == 0) {
+ i4 = i4 + 40 | 0;
+ } else {
+ i4 = i4 + 40 | 0;
+ FUNCTION_TABLE_vii[HEAP32[i5 >> 2] & 1](HEAP32[i4 >> 2] | 0, i7);
+ i6 = HEAP32[i1 >> 2] | 0;
+ }
+ FUNCTION_TABLE_vii[HEAP32[i5 >> 2] & 1](HEAP32[i4 >> 2] | 0, i6);
+ HEAP32[i1 >> 2] = 0;
+ i7 = (i2 | 0) == 113 ? -3 : 0;
+ STACKTOP = i3;
+ return i7 | 0;
+}
+function _main(i4, i5) {
+ i4 = i4 | 0;
+ i5 = i5 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i6 = 0;
+ i1 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i2 = i1;
+ L1 : do {
+ if ((i4 | 0) > 1) {
+ i4 = HEAP8[HEAP32[i5 + 4 >> 2] | 0] | 0;
+ switch (i4 | 0) {
+ case 50:
+ {
+ i2 = 250;
+ break L1;
+ }
+ case 51:
+ {
+ i3 = 4;
+ break L1;
+ }
+ case 52:
+ {
+ i2 = 2500;
+ break L1;
+ }
+ case 53:
+ {
+ i2 = 5e3;
+ break L1;
+ }
+ case 48:
+ {
+ i6 = 0;
+ STACKTOP = i1;
+ return i6 | 0;
+ }
+ case 49:
+ {
+ i2 = 60;
+ break L1;
+ }
+ default:
+ {
+ HEAP32[i2 >> 2] = i4 + -48;
+ _printf(144, i2 | 0) | 0;
+ i6 = -1;
+ STACKTOP = i1;
+ return i6 | 0;
+ }
+ }
+ } else {
+ i3 = 4;
+ }
+ } while (0);
+ if ((i3 | 0) == 4) {
+ i2 = 500;
+ }
+ i3 = _malloc(1e5) | 0;
+ i4 = 0;
+ i6 = 0;
+ i5 = 17;
+ while (1) {
+ do {
+ if ((i6 | 0) <= 0) {
+ if ((i4 & 7 | 0) == 0) {
+ i6 = i4 & 31;
+ i5 = 0;
+ break;
+ } else {
+ i5 = (((Math_imul(i4, i4) | 0) >>> 0) % 6714 | 0) & 255;
+ break;
+ }
+ } else {
+ i6 = i6 + -1 | 0;
+ }
+ } while (0);
+ HEAP8[i3 + i4 | 0] = i5;
+ i4 = i4 + 1 | 0;
+ if ((i4 | 0) == 1e5) {
+ i4 = 0;
+ break;
+ }
+ }
+ do {
+ _doit(i3, 1e5, i4);
+ i4 = i4 + 1 | 0;
+ } while ((i4 | 0) < (i2 | 0));
+ _puts(160) | 0;
+ i6 = 0;
+ STACKTOP = i1;
+ return i6 | 0;
+}
+function _doit(i6, i1, i7) {
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ i7 = i7 | 0;
+ var i2 = 0, i3 = 0, i4 = 0, i5 = 0, i8 = 0, i9 = 0;
+ i5 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i4 = i5;
+ i3 = i5 + 12 | 0;
+ i2 = i5 + 8 | 0;
+ i8 = _compressBound(i1) | 0;
+ i9 = HEAP32[2] | 0;
+ if ((i9 | 0) == 0) {
+ i9 = _malloc(i8) | 0;
+ HEAP32[2] = i9;
+ }
+ if ((HEAP32[4] | 0) == 0) {
+ HEAP32[4] = _malloc(i1) | 0;
+ }
+ HEAP32[i3 >> 2] = i8;
+ _compress(i9, i3, i6, i1) | 0;
+ i7 = (i7 | 0) == 0;
+ if (i7) {
+ i9 = HEAP32[i3 >> 2] | 0;
+ HEAP32[i4 >> 2] = i1;
+ HEAP32[i4 + 4 >> 2] = i9;
+ _printf(24, i4 | 0) | 0;
+ }
+ HEAP32[i2 >> 2] = i1;
+ _uncompress(HEAP32[4] | 0, i2, HEAP32[2] | 0, HEAP32[i3 >> 2] | 0) | 0;
+ if ((HEAP32[i2 >> 2] | 0) != (i1 | 0)) {
+ ___assert_fail(40, 72, 24, 104);
+ }
+ if (!i7) {
+ STACKTOP = i5;
+ return;
+ }
+ if ((_strcmp(i6, HEAP32[4] | 0) | 0) == 0) {
+ STACKTOP = i5;
+ return;
+ } else {
+ ___assert_fail(112, 72, 25, 104);
+ }
+}
+function _uncompress(i6, i1, i5, i7) {
+ i6 = i6 | 0;
+ i1 = i1 | 0;
+ i5 = i5 | 0;
+ i7 = i7 | 0;
+ var i2 = 0, i3 = 0, i4 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i3 = i2;
+ HEAP32[i3 >> 2] = i5;
+ i5 = i3 + 4 | 0;
+ HEAP32[i5 >> 2] = i7;
+ HEAP32[i3 + 12 >> 2] = i6;
+ HEAP32[i3 + 16 >> 2] = HEAP32[i1 >> 2];
+ HEAP32[i3 + 32 >> 2] = 0;
+ HEAP32[i3 + 36 >> 2] = 0;
+ i6 = _inflateInit_(i3, 2992, 56) | 0;
+ if ((i6 | 0) != 0) {
+ i7 = i6;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ i6 = _inflate(i3, 4) | 0;
+ if ((i6 | 0) == 1) {
+ HEAP32[i1 >> 2] = HEAP32[i3 + 20 >> 2];
+ i7 = _inflateEnd(i3) | 0;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ _inflateEnd(i3) | 0;
+ if ((i6 | 0) == 2) {
+ i7 = -3;
+ STACKTOP = i2;
+ return i7 | 0;
+ } else if ((i6 | 0) == -5) {
+ i4 = 4;
+ }
+ if ((i4 | 0) == 4 ? (HEAP32[i5 >> 2] | 0) == 0 : 0) {
+ i7 = -3;
+ STACKTOP = i2;
+ return i7 | 0;
+ }
+ i7 = i6;
+ STACKTOP = i2;
+ return i7 | 0;
+}
+function _compress(i4, i1, i6, i5) {
+ i4 = i4 | 0;
+ i1 = i1 | 0;
+ i6 = i6 | 0;
+ i5 = i5 | 0;
+ var i2 = 0, i3 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + 64 | 0;
+ i3 = i2;
+ HEAP32[i3 >> 2] = i6;
+ HEAP32[i3 + 4 >> 2] = i5;
+ HEAP32[i3 + 12 >> 2] = i4;
+ HEAP32[i3 + 16 >> 2] = HEAP32[i1 >> 2];
+ HEAP32[i3 + 32 >> 2] = 0;
+ HEAP32[i3 + 36 >> 2] = 0;
+ HEAP32[i3 + 40 >> 2] = 0;
+ i4 = _deflateInit_(i3, -1, 168, 56) | 0;
+ if ((i4 | 0) != 0) {
+ i6 = i4;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ i4 = _deflate(i3, 4) | 0;
+ if ((i4 | 0) == 1) {
+ HEAP32[i1 >> 2] = HEAP32[i3 + 20 >> 2];
+ i6 = _deflateEnd(i3) | 0;
+ STACKTOP = i2;
+ return i6 | 0;
+ } else {
+ _deflateEnd(i3) | 0;
+ i6 = (i4 | 0) == 0 ? -5 : i4;
+ STACKTOP = i2;
+ return i6 | 0;
+ }
+ return 0;
+}
+function _inflateEnd(i4) {
+ i4 = i4 | 0;
+ var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i1 = STACKTOP;
+ if ((i4 | 0) == 0) {
+ i7 = -2;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ i2 = i4 + 28 | 0;
+ i3 = HEAP32[i2 >> 2] | 0;
+ if ((i3 | 0) == 0) {
+ i7 = -2;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ i6 = i4 + 36 | 0;
+ i5 = HEAP32[i6 >> 2] | 0;
+ if ((i5 | 0) == 0) {
+ i7 = -2;
+ STACKTOP = i1;
+ return i7 | 0;
+ }
+ i7 = HEAP32[i3 + 52 >> 2] | 0;
+ i4 = i4 + 40 | 0;
+ if ((i7 | 0) != 0) {
+ FUNCTION_TABLE_vii[i5 & 1](HEAP32[i4 >> 2] | 0, i7);
+ i5 = HEAP32[i6 >> 2] | 0;
+ i3 = HEAP32[i2 >> 2] | 0;
+ }
+ FUNCTION_TABLE_vii[i5 & 1](HEAP32[i4 >> 2] | 0, i3);
+ HEAP32[i2 >> 2] = 0;
+ i7 = 0;
+ STACKTOP = i1;
+ return i7 | 0;
+}
+function _memcpy(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i4 = 0;
+ if ((i1 | 0) >= 4096) return _emscripten_memcpy_big(i3 | 0, i2 | 0, i1 | 0) | 0;
+ i4 = i3 | 0;
+ if ((i3 & 3) == (i2 & 3)) {
+ while (i3 & 3) {
+ if ((i1 | 0) == 0) return i4 | 0;
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ while ((i1 | 0) >= 4) {
+ HEAP32[i3 >> 2] = HEAP32[i2 >> 2];
+ i3 = i3 + 4 | 0;
+ i2 = i2 + 4 | 0;
+ i1 = i1 - 4 | 0;
+ }
+ }
+ while ((i1 | 0) > 0) {
+ HEAP8[i3] = HEAP8[i2] | 0;
+ i3 = i3 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i1 = i1 - 1 | 0;
+ }
+ return i4 | 0;
+}
+function _strcmp(i4, i2) {
+ i4 = i4 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i3 = 0, i5 = 0;
+ i1 = STACKTOP;
+ i5 = HEAP8[i4] | 0;
+ i3 = HEAP8[i2] | 0;
+ if (i5 << 24 >> 24 != i3 << 24 >> 24 | i5 << 24 >> 24 == 0 | i3 << 24 >> 24 == 0) {
+ i4 = i5;
+ i5 = i3;
+ i4 = i4 & 255;
+ i5 = i5 & 255;
+ i5 = i4 - i5 | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+ }
+ do {
+ i4 = i4 + 1 | 0;
+ i2 = i2 + 1 | 0;
+ i5 = HEAP8[i4] | 0;
+ i3 = HEAP8[i2] | 0;
+ } while (!(i5 << 24 >> 24 != i3 << 24 >> 24 | i5 << 24 >> 24 == 0 | i3 << 24 >> 24 == 0));
+ i4 = i5 & 255;
+ i5 = i3 & 255;
+ i5 = i4 - i5 | 0;
+ STACKTOP = i1;
+ return i5 | 0;
+}
+function _memset(i1, i4, i3) {
+ i1 = i1 | 0;
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ var i2 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i2 = i1 + i3 | 0;
+ if ((i3 | 0) >= 20) {
+ i4 = i4 & 255;
+ i7 = i1 & 3;
+ i6 = i4 | i4 << 8 | i4 << 16 | i4 << 24;
+ i5 = i2 & ~3;
+ if (i7) {
+ i7 = i1 + 4 - i7 | 0;
+ while ((i1 | 0) < (i7 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ }
+ while ((i1 | 0) < (i5 | 0)) {
+ HEAP32[i1 >> 2] = i6;
+ i1 = i1 + 4 | 0;
+ }
+ }
+ while ((i1 | 0) < (i2 | 0)) {
+ HEAP8[i1] = i4;
+ i1 = i1 + 1 | 0;
+ }
+ return i1 - i3 | 0;
+}
+function copyTempDouble(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+ HEAP8[tempDoublePtr + 4 | 0] = HEAP8[i1 + 4 | 0];
+ HEAP8[tempDoublePtr + 5 | 0] = HEAP8[i1 + 5 | 0];
+ HEAP8[tempDoublePtr + 6 | 0] = HEAP8[i1 + 6 | 0];
+ HEAP8[tempDoublePtr + 7 | 0] = HEAP8[i1 + 7 | 0];
+}
+function __tr_init(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ HEAP32[i1 + 2840 >> 2] = i1 + 148;
+ HEAP32[i1 + 2848 >> 2] = 1064;
+ HEAP32[i1 + 2852 >> 2] = i1 + 2440;
+ HEAP32[i1 + 2860 >> 2] = 1088;
+ HEAP32[i1 + 2864 >> 2] = i1 + 2684;
+ HEAP32[i1 + 2872 >> 2] = 1112;
+ HEAP16[i1 + 5816 >> 1] = 0;
+ HEAP32[i1 + 5820 >> 2] = 0;
+ HEAP32[i1 + 5812 >> 2] = 8;
+ _init_block(i1);
+ STACKTOP = i2;
+ return;
+}
+function copyTempFloat(i1) {
+ i1 = i1 | 0;
+ HEAP8[tempDoublePtr] = HEAP8[i1];
+ HEAP8[tempDoublePtr + 1 | 0] = HEAP8[i1 + 1 | 0];
+ HEAP8[tempDoublePtr + 2 | 0] = HEAP8[i1 + 2 | 0];
+ HEAP8[tempDoublePtr + 3 | 0] = HEAP8[i1 + 3 | 0];
+}
+function _deflateInit_(i4, i3, i2, i1) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ var i5 = 0;
+ i5 = STACKTOP;
+ i4 = _deflateInit2_(i4, i3, 8, 15, 8, 0, i2, i1) | 0;
+ STACKTOP = i5;
+ return i4 | 0;
+}
+function _zcalloc(i3, i1, i2) {
+ i3 = i3 | 0;
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ var i4 = 0;
+ i4 = STACKTOP;
+ i3 = _malloc(Math_imul(i2, i1) | 0) | 0;
+ STACKTOP = i4;
+ return i3 | 0;
+}
+function dynCall_iiii(i4, i3, i2, i1) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ return FUNCTION_TABLE_iiii[i4 & 1](i3 | 0, i2 | 0, i1 | 0) | 0;
+}
+function runPostSets() {}
+function _strlen(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = i1;
+ while (HEAP8[i2] | 0) {
+ i2 = i2 + 1 | 0;
+ }
+ return i2 - i1 | 0;
+}
+function stackAlloc(i1) {
+ i1 = i1 | 0;
+ var i2 = 0;
+ i2 = STACKTOP;
+ STACKTOP = STACKTOP + i1 | 0;
+ STACKTOP = STACKTOP + 7 & -8;
+ return i2 | 0;
+}
+function dynCall_iii(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ return FUNCTION_TABLE_iii[i3 & 3](i2 | 0, i1 | 0) | 0;
+}
+function setThrew(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ if ((__THREW__ | 0) == 0) {
+ __THREW__ = i1;
+ threwValue = i2;
+ }
+}
+function dynCall_vii(i3, i2, i1) {
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ FUNCTION_TABLE_vii[i3 & 1](i2 | 0, i1 | 0);
+}
+function _zcfree(i2, i1) {
+ i2 = i2 | 0;
+ i1 = i1 | 0;
+ i2 = STACKTOP;
+ _free(i1);
+ STACKTOP = i2;
+ return;
+}
+function _compressBound(i1) {
+ i1 = i1 | 0;
+ return i1 + 13 + (i1 >>> 12) + (i1 >>> 14) + (i1 >>> 25) | 0;
+}
+function b0(i1, i2, i3) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ i3 = i3 | 0;
+ abort(0);
+ return 0;
+}
+function b2(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ abort(2);
+ return 0;
+}
+function b1(i1, i2) {
+ i1 = i1 | 0;
+ i2 = i2 | 0;
+ abort(1);
+}
+function stackRestore(i1) {
+ i1 = i1 | 0;
+ STACKTOP = i1;
+}
+function setTempRet9(i1) {
+ i1 = i1 | 0;
+ tempRet9 = i1;
+}
+function setTempRet8(i1) {
+ i1 = i1 | 0;
+ tempRet8 = i1;
+}
+function setTempRet7(i1) {
+ i1 = i1 | 0;
+ tempRet7 = i1;
+}
+function setTempRet6(i1) {
+ i1 = i1 | 0;
+ tempRet6 = i1;
+}
+function setTempRet5(i1) {
+ i1 = i1 | 0;
+ tempRet5 = i1;
+}
+function setTempRet4(i1) {
+ i1 = i1 | 0;
+ tempRet4 = i1;
+}
+function setTempRet3(i1) {
+ i1 = i1 | 0;
+ tempRet3 = i1;
+}
+function setTempRet2(i1) {
+ i1 = i1 | 0;
+ tempRet2 = i1;
+}
+function setTempRet1(i1) {
+ i1 = i1 | 0;
+ tempRet1 = i1;
+}
+function setTempRet0(i1) {
+ i1 = i1 | 0;
+ tempRet0 = i1;
+}
+function stackSave() {
+ return STACKTOP | 0;
+}
+
+// EMSCRIPTEN_END_FUNCS
+ var FUNCTION_TABLE_iiii = [b0,_zcalloc];
+ var FUNCTION_TABLE_vii = [b1,_zcfree];
+ var FUNCTION_TABLE_iii = [b2,_deflate_stored,_deflate_fast,_deflate_slow];
+
+ return { _strlen: _strlen, _free: _free, _main: _main, _memset: _memset, _malloc: _malloc, _memcpy: _memcpy, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, setThrew: setThrew, setTempRet0: setTempRet0, setTempRet1: setTempRet1, setTempRet2: setTempRet2, setTempRet3: setTempRet3, setTempRet4: setTempRet4, setTempRet5: setTempRet5, setTempRet6: setTempRet6, setTempRet7: setTempRet7, setTempRet8: setTempRet8, setTempRet9: setTempRet9, dynCall_iiii: dynCall_iiii, dynCall_vii: dynCall_vii, dynCall_iii: dynCall_iii };
+})
+// EMSCRIPTEN_END_ASM
+({ "Math": Math, "Int8Array": Int8Array, "Int16Array": Int16Array, "Int32Array": Int32Array, "Uint8Array": Uint8Array, "Uint16Array": Uint16Array, "Uint32Array": Uint32Array, "Float32Array": Float32Array, "Float64Array": Float64Array }, { "abort": abort, "assert": assert, "asmPrintInt": asmPrintInt, "asmPrintFloat": asmPrintFloat, "min": Math_min, "invoke_iiii": invoke_iiii, "invoke_vii": invoke_vii, "invoke_iii": invoke_iii, "_send": _send, "___setErrNo": ___setErrNo, "___assert_fail": ___assert_fail, "_fflush": _fflush, "_pwrite": _pwrite, "__reallyNegative": __reallyNegative, "_sbrk": _sbrk, "___errno_location": ___errno_location, "_emscripten_memcpy_big": _emscripten_memcpy_big, "_fileno": _fileno, "_sysconf": _sysconf, "_puts": _puts, "_mkport": _mkport, "_write": _write, "_llvm_bswap_i32": _llvm_bswap_i32, "_fputc": _fputc, "_abort": _abort, "_fwrite": _fwrite, "_time": _time, "_fprintf": _fprintf, "__formatString": __formatString, "_fputs": _fputs, "_printf": _printf, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX, "tempDoublePtr": tempDoublePtr, "ABORT": ABORT, "NaN": NaN, "Infinity": Infinity }, buffer);
+var _strlen = Module["_strlen"] = asm["_strlen"];
+var _free = Module["_free"] = asm["_free"];
+var _main = Module["_main"] = asm["_main"];
+var _memset = Module["_memset"] = asm["_memset"];
+var _malloc = Module["_malloc"] = asm["_malloc"];
+var _memcpy = Module["_memcpy"] = asm["_memcpy"];
+var runPostSets = Module["runPostSets"] = asm["runPostSets"];
+var dynCall_iiii = Module["dynCall_iiii"] = asm["dynCall_iiii"];
+var dynCall_vii = Module["dynCall_vii"] = asm["dynCall_vii"];
+var dynCall_iii = Module["dynCall_iii"] = asm["dynCall_iii"];
+
+Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
+Runtime.stackSave = function() { return asm['stackSave']() };
+Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
+
+
+// Warning: printing of i64 values may be slightly rounded! No deep i64 math used, so precise i64 code not included
+var i64Math = null;
+
+// === Auto-generated postamble setup entry stuff ===
+
+if (memoryInitializer) {
+ if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
+ var data = Module['readBinary'](memoryInitializer);
+ HEAPU8.set(data, STATIC_BASE);
+ } else {
+ addRunDependency('memory initializer');
+ Browser.asyncLoad(memoryInitializer, function(data) {
+ HEAPU8.set(data, STATIC_BASE);
+ removeRunDependency('memory initializer');
+ }, function(data) {
+ throw 'could not load memory initializer ' + memoryInitializer;
+ });
+ }
+}
+
+function ExitStatus(status) {
+ this.name = "ExitStatus";
+ this.message = "Program terminated with exit(" + status + ")";
+ this.status = status;
+};
+ExitStatus.prototype = new Error();
+ExitStatus.prototype.constructor = ExitStatus;
+
+var initialStackTop;
+var preloadStartTime = null;
+var calledMain = false;
+
+dependenciesFulfilled = function runCaller() {
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
+ if (!Module['calledRun'] && shouldRunNow) run([].concat(Module["arguments"]));
+ if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
+}
+
+Module['callMain'] = Module.callMain = function callMain(args) {
+ assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');
+ assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
+
+ args = args || [];
+
+ ensureInitRuntime();
+
+ var argc = args.length+1;
+ function pad() {
+ for (var i = 0; i < 4-1; i++) {
+ argv.push(0);
+ }
+ }
+ var argv = [allocate(intArrayFromString("/bin/this.program"), 'i8', ALLOC_NORMAL) ];
+ pad();
+ for (var i = 0; i < argc-1; i = i + 1) {
+ argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL));
+ pad();
+ }
+ argv.push(0);
+ argv = allocate(argv, 'i32', ALLOC_NORMAL);
+
+ initialStackTop = STACKTOP;
+
+ try {
+
+ var ret = Module['_main'](argc, argv, 0);
+
+
+ // if we're not running an evented main loop, it's time to exit
+ if (!Module['noExitRuntime']) {
+ exit(ret);
+ }
+ }
+ catch(e) {
+ if (e instanceof ExitStatus) {
+ // exit() throws this once it's done to make sure execution
+ // has been stopped completely
+ return;
+ } else if (e == 'SimulateInfiniteLoop') {
+ // running an evented main loop, don't immediately exit
+ Module['noExitRuntime'] = true;
+ return;
+ } else {
+ if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
+ throw e;
+ }
+ } finally {
+ calledMain = true;
+ }
+}
+
+
+
+
+function run(args) {
+ args = args || Module['arguments'];
+
+ if (preloadStartTime === null) preloadStartTime = Date.now();
+
+ if (runDependencies > 0) {
+ Module.printErr('run() called, but dependencies remain, so not running');
+ return;
+ }
+
+ preRun();
+
+ if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
+ if (Module['calledRun']) return; // run may have just been called through dependencies being fulfilled just in this very frame
+
+ function doRun() {
+ if (Module['calledRun']) return; // run may have just been called while the async setStatus time below was happening
+ Module['calledRun'] = true;
+
+ ensureInitRuntime();
+
+ preMain();
+
+ if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) {
+ Module.printErr('pre-main prep time: ' + (Date.now() - preloadStartTime) + ' ms');
+ }
+
+ if (Module['_main'] && shouldRunNow) {
+ Module['callMain'](args);
+ }
+
+ postRun();
+ }
+
+ if (Module['setStatus']) {
+ Module['setStatus']('Running...');
+ setTimeout(function() {
+ setTimeout(function() {
+ Module['setStatus']('');
+ }, 1);
+ if (!ABORT) doRun();
+ }, 1);
+ } else {
+ doRun();
+ }
+}
+Module['run'] = Module.run = run;
+
+function exit(status) {
+ ABORT = true;
+ EXITSTATUS = status;
+ STACKTOP = initialStackTop;
+
+ // exit the runtime
+ exitRuntime();
+
+ // TODO We should handle this differently based on environment.
+ // In the browser, the best we can do is throw an exception
+ // to halt execution, but in node we could process.exit and
+ // I'd imagine SM shell would have something equivalent.
+ // This would let us set a proper exit status (which
+ // would be great for checking test exit statuses).
+ // https://github.com/kripken/emscripten/issues/1371
+
+ // throw an exception to halt the current execution
+ throw new ExitStatus(status);
+}
+Module['exit'] = Module.exit = exit;
+
+function abort(text) {
+ if (text) {
+ Module.print(text);
+ Module.printErr(text);
+ }
+
+ ABORT = true;
+ EXITSTATUS = 1;
+
+ var extra = '\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.';
+
+ throw 'abort() at ' + stackTrace() + extra;
+}
+Module['abort'] = Module.abort = abort;
+
+// {{PRE_RUN_ADDITIONS}}
+
+if (Module['preInit']) {
+ if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
+ while (Module['preInit'].length > 0) {
+ Module['preInit'].pop()();
+ }
+}
+
+// shouldRunNow refers to calling main(), not run().
+var shouldRunNow = true;
+if (Module['noInitialRun']) {
+ shouldRunNow = false;
+}
+
+
+run([].concat(Module["arguments"]));
diff --git a/test/mjsunit/asm/float32array-store-div.js b/test/mjsunit/asm/float32array-store-div.js
new file mode 100644
index 000000000..78224f962
--- /dev/null
+++ b/test/mjsunit/asm/float32array-store-div.js
@@ -0,0 +1,16 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function Module(stdlib, foreign, heap) {
+ "use asm";
+ var MEM32 = new stdlib.Float32Array(heap);
+ function foo(i) {
+ MEM32[0] = (i >>> 0) / 2;
+ return MEM32[0];
+ }
+ return { foo: foo };
+}
+
+var foo = Module(this, {}, new ArrayBuffer(64 * 1024)).foo;
+assertEquals(0.5, foo(1));
diff --git a/test/mjsunit/asm/float64array-store-div.js b/test/mjsunit/asm/float64array-store-div.js
new file mode 100644
index 000000000..10b0011fb
--- /dev/null
+++ b/test/mjsunit/asm/float64array-store-div.js
@@ -0,0 +1,16 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function Module(stdlib, foreign, heap) {
+ "use asm";
+ var MEM64 = new stdlib.Float64Array(heap);
+ function foo(i) {
+ MEM64[0] = (i >>> 0) / 2;
+ return MEM64[0];
+ }
+ return { foo: foo };
+}
+
+var foo = Module(this, {}, new ArrayBuffer(64 * 1024)).foo;
+assertEquals(0.5, foo(1));
diff --git a/test/mjsunit/debug-stepframe.js b/test/mjsunit/debug-stepframe.js
new file mode 100644
index 000000000..8f4ee4ca1
--- /dev/null
+++ b/test/mjsunit/debug-stepframe.js
@@ -0,0 +1,111 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --expose-debug-as debug
+
+function f0() {
+ var v00 = 0; // Break 1
+ var v01 = 1;
+ // Normal function call in a catch scope.
+ try {
+ throw 1;
+ } catch (e) {
+ try{
+ f1();
+ } catch (e) {
+ var v02 = 2; // Break 13
+ }
+ }
+ var v03 = 3;
+ var v04 = 4;
+}
+
+function f1() {
+ var v10 = 0; // Break 2
+ var v11 = 1;
+ // Getter call.
+ var v12 = o.get;
+ var v13 = 3 // Break 4
+ // Setter call.
+ o.set = 2;
+ var v14 = 4; // Break 6
+ // Function.prototype.call.
+ f2.call();
+ var v15 = 5; // Break 12
+ var v16 = 6;
+ // Exit function by throw.
+ throw 1;
+ var v17 = 7;
+}
+
+function get() {
+ var g0 = 0; // Break 3
+ var g1 = 1;
+ return 3;
+}
+
+function set() {
+ var s0 = 0; // Break 5
+ return 3;
+}
+
+function f2() {
+ var v20 = 0; // Break 7
+ // Construct call.
+ var v21 = new c0();
+ var v22 = 2; // Break 9
+ // Bound function.
+ b0();
+ return 2; // Break 11
+}
+
+function c0() {
+ this.v0 = 0; // Break 8
+ this.v1 = 1;
+}
+
+function f3() {
+ var v30 = 0; // Break 10
+ var v31 = 1;
+ return 3;
+}
+
+var b0 = f3.bind(o);
+
+var o = {};
+Object.defineProperty(o, "get", { get : get });
+Object.defineProperty(o, "set", { set : set });
+
+Debug = debug.Debug;
+var break_count = 0
+var exception = null;
+var step_size;
+
+function listener(event, exec_state, event_data, data) {
+ if (event != Debug.DebugEvent.Break) return;
+ try {
+ var line = exec_state.frame(0).sourceLineText();
+ print(line);
+ var match = line.match(/\/\/ Break (\d+)$/);
+ assertEquals(2, match.length);
+ assertEquals(break_count, parseInt(match[1]));
+ break_count += step_size;
+ exec_state.prepareStep(Debug.StepAction.StepFrame, step_size);
+ } catch (e) {
+ print(e + e.stack);
+ exception = e;
+ }
+}
+
+for (step_size = 1; step_size < 6; step_size++) {
+ print("step size = " + step_size);
+ break_count = 0;
+ Debug.setListener(listener);
+ debugger; // Break 0
+ f0();
+ Debug.setListener(null); // Break 14
+ assertTrue(break_count > 14);
+}
+
+assertNull(exception);
diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status
index 1185a1198..8bd03e69d 100644
--- a/test/mjsunit/mjsunit.status
+++ b/test/mjsunit/mjsunit.status
@@ -200,6 +200,9 @@
# This test variant makes only sense on arm.
'math-floor-of-div-nosudiv': [PASS, SLOW, ['arch not in [arm, arm64, android_arm, android_arm64]', SKIP]],
+
+ # Too slow for slow variants.
+ 'asm/embenchen/*': [PASS, FAST_VARIANTS],
}], # ALWAYS
##############################################################################
@@ -242,6 +245,9 @@
'math-floor-of-div': [PASS, NO_VARIANTS],
'unicodelctest': [PASS, NO_VARIANTS],
'unicodelctest-no-optimization': [PASS, NO_VARIANTS],
+
+ # Too slow for gc stress.
+ 'asm/embenchen/box2d': [SKIP],
}], # 'gc_stress == True'
##############################################################################
@@ -293,6 +299,8 @@
'array-reduce': [PASS, SLOW],
'array-sort': [PASS, SLOW],
'array-splice': [PASS, SLOW],
+ 'asm/embenchen/box2d': [PASS, TIMEOUT],
+ 'asm/embenchen/lua_binarytrees': [PASS, TIMEOUT],
'bit-not': [PASS, SLOW],
'compiler/alloc-number': [PASS, SLOW],
'compiler/osr-assert': [PASS, SLOW],
diff --git a/test/mjsunit/regress/regress-assignment-in-test-context.js b/test/mjsunit/regress/regress-assignment-in-test-context.js
new file mode 100644
index 000000000..bc4098554
--- /dev/null
+++ b/test/mjsunit/regress/regress-assignment-in-test-context.js
@@ -0,0 +1,20 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax --always-opt
+// Flags: --turbo-filter=* --turbo-deoptimization
+
+function assertEquals() {}
+
+function f(o) {
+ if (o.setterProperty = 0) {
+ return 1;
+ }
+ return 2;
+}
+
+function deopt() { %DeoptimizeFunction(f); }
+
+assertEquals(2,
+ f(Object.defineProperty({}, "setterProperty", { set: deopt })));
diff --git a/test/mjsunit/regress/regress-crbug-137689.js b/test/mjsunit/regress/regress-crbug-137689.js
index ef79d240f..0ff0c4e76 100644
--- a/test/mjsunit/regress/regress-crbug-137689.js
+++ b/test/mjsunit/regress/regress-crbug-137689.js
@@ -44,4 +44,5 @@ assertTrue(%HaveSameMap(o, o2));
Object.defineProperty(o, "foo", { set: setter, configurable: true });
Object.defineProperty(o2, "foo", { set: setter, configurable: true });
-assertTrue(%HaveSameMap(o, o2));
+// TODO(ishell): this should eventually become assertTrue().
+assertFalse(%HaveSameMap(o, o2));
diff --git a/test/unittests/compiler/mips/instruction-selector-mips-unittest.cc b/test/unittests/compiler/mips/instruction-selector-mips-unittest.cc
index f5891d24f..0b3a0f5a4 100644
--- a/test/unittests/compiler/mips/instruction-selector-mips-unittest.cc
+++ b/test/unittests/compiler/mips/instruction-selector-mips-unittest.cc
@@ -161,12 +161,12 @@ const MachInst1 kAddSubOneInstructions[] = {
const IntCmp kCmpInstructions[] = {
{{&RawMachineAssembler::WordEqual, "WordEqual", kMipsCmp, kMachInt16}, 1U},
{{&RawMachineAssembler::WordNotEqual, "WordNotEqual", kMipsCmp, kMachInt16},
- 2U},
+ 1U},
{{&RawMachineAssembler::Word32Equal, "Word32Equal", kMipsCmp, kMachInt32},
1U},
{{&RawMachineAssembler::Word32NotEqual, "Word32NotEqual", kMipsCmp,
kMachInt32},
- 2U},
+ 1U},
{{&RawMachineAssembler::Int32LessThan, "Int32LessThan", kMipsCmp,
kMachInt32},
1U},
@@ -779,10 +779,9 @@ TEST_F(InstructionSelectorTest, Word32EqualWithZero) {
m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(0)));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
- EXPECT_EQ(kMipsTst, s[0]->arch_opcode());
+ EXPECT_EQ(kMipsCmp, s[0]->arch_opcode());
EXPECT_EQ(kMode_None, s[0]->addressing_mode());
ASSERT_EQ(2U, s[0]->InputCount());
- EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1)));
EXPECT_EQ(1U, s[0]->OutputCount());
EXPECT_EQ(kFlags_set, s[0]->flags_mode());
EXPECT_EQ(kEqual, s[0]->flags_condition());
@@ -792,10 +791,9 @@ TEST_F(InstructionSelectorTest, Word32EqualWithZero) {
m.Return(m.Word32Equal(m.Int32Constant(0), m.Parameter(0)));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
- EXPECT_EQ(kMipsTst, s[0]->arch_opcode());
+ EXPECT_EQ(kMipsCmp, s[0]->arch_opcode());
EXPECT_EQ(kMode_None, s[0]->addressing_mode());
ASSERT_EQ(2U, s[0]->InputCount());
- EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1)));
EXPECT_EQ(1U, s[0]->OutputCount());
EXPECT_EQ(kFlags_set, s[0]->flags_mode());
EXPECT_EQ(kEqual, s[0]->flags_condition());
diff --git a/test/unittests/compiler/register-allocator-unittest.cc b/test/unittests/compiler/register-allocator-unittest.cc
index 752999fc5..1c7aeee4f 100644
--- a/test/unittests/compiler/register-allocator-unittest.cc
+++ b/test/unittests/compiler/register-allocator-unittest.cc
@@ -97,7 +97,7 @@ class RegisterAllocatorTest : public TestWithZone {
if (loop_header.IsValid()) {
basic_block->set_loop_depth(1);
basic_block->set_loop_header(basic_blocks_[loop_header.ToSize()]);
- basic_block->set_loop_end(loop_end.ToInt());
+ basic_block->set_loop_end(basic_blocks_[loop_end.ToSize()]);
}
InstructionBlock* instruction_block =
new (zone()) InstructionBlock(zone(), basic_block);
diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp
index 587486533..b675e18d0 100644
--- a/tools/gyp/v8.gyp
+++ b/tools/gyp/v8.gyp
@@ -1146,10 +1146,6 @@
'../../src/x64/macro-assembler-x64.h',
'../../src/x64/regexp-macro-assembler-x64.cc',
'../../src/x64/regexp-macro-assembler-x64.h',
- '../../src/compiler/x64/code-generator-x64.cc',
- '../../src/compiler/x64/instruction-codes-x64.h',
- '../../src/compiler/x64/instruction-selector-x64.cc',
- '../../src/compiler/x64/linkage-x64.cc',
'../../src/ic/x64/access-compiler-x64.cc',
'../../src/ic/x64/handler-compiler-x64.cc',
'../../src/ic/x64/ic-x64.cc',
@@ -1157,6 +1153,14 @@
'../../src/ic/x64/stub-cache-x64.cc',
],
}],
+ ['v8_target_arch=="x64"', {
+ 'sources': [
+ '../../src/compiler/x64/code-generator-x64.cc',
+ '../../src/compiler/x64/instruction-codes-x64.h',
+ '../../src/compiler/x64/instruction-selector-x64.cc',
+ '../../src/compiler/x64/linkage-x64.cc',
+ ],
+ }],
['OS=="linux"', {
'link_settings': {
'conditions': [
diff --git a/tools/gyp/v8_base.host.darwin-x86_64.mk b/tools/gyp/v8_base.host.darwin-x86_64.mk
index bdbcda2ad..3bbd36894 100644
--- a/tools/gyp/v8_base.host.darwin-x86_64.mk
+++ b/tools/gyp/v8_base.host.darwin-x86_64.mk
@@ -274,14 +274,14 @@ LOCAL_SRC_FILES := \
v8/src/x64/lithium-x64.cc \
v8/src/x64/macro-assembler-x64.cc \
v8/src/x64/regexp-macro-assembler-x64.cc \
- v8/src/compiler/x64/code-generator-x64.cc \
- v8/src/compiler/x64/instruction-selector-x64.cc \
- v8/src/compiler/x64/linkage-x64.cc \
v8/src/ic/x64/access-compiler-x64.cc \
v8/src/ic/x64/handler-compiler-x64.cc \
v8/src/ic/x64/ic-x64.cc \
v8/src/ic/x64/ic-compiler-x64.cc \
- v8/src/ic/x64/stub-cache-x64.cc
+ v8/src/ic/x64/stub-cache-x64.cc \
+ v8/src/compiler/x64/code-generator-x64.cc \
+ v8/src/compiler/x64/instruction-selector-x64.cc \
+ v8/src/compiler/x64/linkage-x64.cc
# Flags passed to both C and C++ files.
diff --git a/tools/gyp/v8_base.host.linux-x86_64.mk b/tools/gyp/v8_base.host.linux-x86_64.mk
index bdbcda2ad..3bbd36894 100644
--- a/tools/gyp/v8_base.host.linux-x86_64.mk
+++ b/tools/gyp/v8_base.host.linux-x86_64.mk
@@ -274,14 +274,14 @@ LOCAL_SRC_FILES := \
v8/src/x64/lithium-x64.cc \
v8/src/x64/macro-assembler-x64.cc \
v8/src/x64/regexp-macro-assembler-x64.cc \
- v8/src/compiler/x64/code-generator-x64.cc \
- v8/src/compiler/x64/instruction-selector-x64.cc \
- v8/src/compiler/x64/linkage-x64.cc \
v8/src/ic/x64/access-compiler-x64.cc \
v8/src/ic/x64/handler-compiler-x64.cc \
v8/src/ic/x64/ic-x64.cc \
v8/src/ic/x64/ic-compiler-x64.cc \
- v8/src/ic/x64/stub-cache-x64.cc
+ v8/src/ic/x64/stub-cache-x64.cc \
+ v8/src/compiler/x64/code-generator-x64.cc \
+ v8/src/compiler/x64/instruction-selector-x64.cc \
+ v8/src/compiler/x64/linkage-x64.cc
# Flags passed to both C and C++ files.
diff --git a/tools/gyp/v8_base.target.darwin-x86_64.mk b/tools/gyp/v8_base.target.darwin-x86_64.mk
index 20b42e7bb..59c2022bc 100644
--- a/tools/gyp/v8_base.target.darwin-x86_64.mk
+++ b/tools/gyp/v8_base.target.darwin-x86_64.mk
@@ -274,14 +274,14 @@ LOCAL_SRC_FILES := \
v8/src/x64/lithium-x64.cc \
v8/src/x64/macro-assembler-x64.cc \
v8/src/x64/regexp-macro-assembler-x64.cc \
- v8/src/compiler/x64/code-generator-x64.cc \
- v8/src/compiler/x64/instruction-selector-x64.cc \
- v8/src/compiler/x64/linkage-x64.cc \
v8/src/ic/x64/access-compiler-x64.cc \
v8/src/ic/x64/handler-compiler-x64.cc \
v8/src/ic/x64/ic-x64.cc \
v8/src/ic/x64/ic-compiler-x64.cc \
- v8/src/ic/x64/stub-cache-x64.cc
+ v8/src/ic/x64/stub-cache-x64.cc \
+ v8/src/compiler/x64/code-generator-x64.cc \
+ v8/src/compiler/x64/instruction-selector-x64.cc \
+ v8/src/compiler/x64/linkage-x64.cc
# Flags passed to both C and C++ files.
diff --git a/tools/gyp/v8_base.target.linux-x86_64.mk b/tools/gyp/v8_base.target.linux-x86_64.mk
index 20b42e7bb..59c2022bc 100644
--- a/tools/gyp/v8_base.target.linux-x86_64.mk
+++ b/tools/gyp/v8_base.target.linux-x86_64.mk
@@ -274,14 +274,14 @@ LOCAL_SRC_FILES := \
v8/src/x64/lithium-x64.cc \
v8/src/x64/macro-assembler-x64.cc \
v8/src/x64/regexp-macro-assembler-x64.cc \
- v8/src/compiler/x64/code-generator-x64.cc \
- v8/src/compiler/x64/instruction-selector-x64.cc \
- v8/src/compiler/x64/linkage-x64.cc \
v8/src/ic/x64/access-compiler-x64.cc \
v8/src/ic/x64/handler-compiler-x64.cc \
v8/src/ic/x64/ic-x64.cc \
v8/src/ic/x64/ic-compiler-x64.cc \
- v8/src/ic/x64/stub-cache-x64.cc
+ v8/src/ic/x64/stub-cache-x64.cc \
+ v8/src/compiler/x64/code-generator-x64.cc \
+ v8/src/compiler/x64/instruction-selector-x64.cc \
+ v8/src/compiler/x64/linkage-x64.cc
# Flags passed to both C and C++ files.
diff --git a/tools/push-to-trunk/merge_to_branch.py b/tools/push-to-trunk/merge_to_branch.py
index 927e504f7..da9d3101a 100755
--- a/tools/push-to-trunk/merge_to_branch.py
+++ b/tools/push-to-trunk/merge_to_branch.py
@@ -32,6 +32,9 @@ import sys
from common_includes import *
+def IsSvnNumber(rev):
+ return rev.isdigit() and len(rev) < 8
+
class Preparation(Step):
MESSAGE = "Preparation."
@@ -72,24 +75,21 @@ class SearchArchitecturePorts(Step):
self._options.revisions))
port_revision_list = []
for revision in self["full_revision_list"]:
- # Search for commits which matches the "Port rXXX" pattern.
+ # Search for commits which matches the "Port XXX" pattern.
git_hashes = self.GitLog(reverse=True, format="%H",
- grep="Port r%d" % int(revision),
+ grep="Port %s" % revision,
branch=self.vc.RemoteMasterBranch())
for git_hash in git_hashes.splitlines():
- svn_revision = self.vc.GitSvn(git_hash, self.vc.RemoteMasterBranch())
- if not svn_revision: # pragma: no cover
- self.Die("Cannot determine svn revision for %s" % git_hash)
revision_title = self.GitLog(n=1, format="%s", git_hash=git_hash)
# Is this revision included in the original revision list?
- if svn_revision in self["full_revision_list"]:
- print("Found port of r%s -> r%s (already included): %s"
- % (revision, svn_revision, revision_title))
+ if git_hash in self["full_revision_list"]:
+ print("Found port of %s -> %s (already included): %s"
+ % (revision, git_hash, revision_title))
else:
- print("Found port of r%s -> r%s: %s"
- % (revision, svn_revision, revision_title))
- port_revision_list.append(svn_revision)
+ print("Found port of %s -> %s: %s"
+ % (revision, git_hash, revision_title))
+ port_revision_list.append(git_hash)
# Do we find any port?
if len(port_revision_list) > 0:
@@ -99,16 +99,10 @@ class SearchArchitecturePorts(Step):
self["full_revision_list"].extend(port_revision_list)
-class FindGitRevisions(Step):
- MESSAGE = "Find the git revisions associated with the patches."
+class CreateCommitMessage(Step):
+ MESSAGE = "Create commit message."
def RunStep(self):
- self["patch_commit_hashes"] = []
- for revision in self["full_revision_list"]:
- next_hash = self.vc.SvnGit(revision, self.vc.RemoteMasterBranch())
- if not next_hash: # pragma: no cover
- self.Die("Cannot determine git hash for r%s" % revision)
- self["patch_commit_hashes"].append(next_hash)
# Stringify: [123, 234] -> "r123, r234"
self["revision_list"] = ", ".join(map(lambda s: "r%s" % s,
@@ -117,29 +111,38 @@ class FindGitRevisions(Step):
if not self["revision_list"]: # pragma: no cover
self.Die("Revision list is empty.")
+ if self._options.revert and not self._options.revert_bleeding_edge:
+ action_text = "Rollback of %s"
+ else:
+ action_text = "Merged %s"
+
# The commit message title is added below after the version is specified.
- self["new_commit_msg"] = ""
+ msg_pieces = [
+ "\n".join(action_text % s for s in self["full_revision_list"]),
+ ]
+ msg_pieces.append("\n\n")
- for commit_hash in self["patch_commit_hashes"]:
+ for commit_hash in self["full_revision_list"]:
patch_merge_desc = self.GitLog(n=1, format="%s", git_hash=commit_hash)
- self["new_commit_msg"] += "%s\n\n" % patch_merge_desc
+ msg_pieces.append("%s\n\n" % patch_merge_desc)
bugs = []
- for commit_hash in self["patch_commit_hashes"]:
+ for commit_hash in self["full_revision_list"]:
msg = self.GitLog(n=1, git_hash=commit_hash)
- for bug in re.findall(r"^[ \t]*BUG[ \t]*=[ \t]*(.*?)[ \t]*$", msg,
- re.M):
- bugs.extend(map(lambda s: s.strip(), bug.split(",")))
+ for bug in re.findall(r"^[ \t]*BUG[ \t]*=[ \t]*(.*?)[ \t]*$", msg, re.M):
+ bugs.extend(s.strip() for s in bug.split(","))
bug_aggregate = ",".join(sorted(filter(lambda s: s and s != "none", bugs)))
if bug_aggregate:
- self["new_commit_msg"] += "BUG=%s\nLOG=N\n" % bug_aggregate
+ msg_pieces.append("BUG=%s\nLOG=N\n" % bug_aggregate)
+
+ self["new_commit_msg"] = "".join(msg_pieces)
class ApplyPatches(Step):
MESSAGE = "Apply patches for selected revisions."
def RunStep(self):
- for commit_hash in self["patch_commit_hashes"]:
+ for commit_hash in self["full_revision_list"]:
print("Applying patch for %s to %s..."
% (commit_hash, self["merge_to_branch"]))
patch = self.GitGetPatch(commit_hash)
@@ -189,17 +192,14 @@ class CommitLocal(Step):
def RunStep(self):
# Add a commit message title.
- if self._options.revert:
- if not self._options.revert_bleeding_edge:
- title = ("Version %s (rollback of %s)"
- % (self["version"], self["revision_list"]))
- else:
- title = "Revert %s." % self["revision_list"]
+ if self._options.revert and self._options.revert_bleeding_edge:
+ # TODO(machenbach): Find a better convention if multiple patches are
+ # reverted in one CL.
+ self["commit_title"] = "Revert on master"
else:
- title = ("Version %s (merged %s)"
- % (self["version"], self["revision_list"]))
- self["commit_title"] = title
- self["new_commit_msg"] = "%s\n\n%s" % (title, self["new_commit_msg"])
+ self["commit_title"] = "Version %s (cherry-pick)" % self["version"]
+ self["new_commit_msg"] = "%s\n\n%s" % (self["commit_title"],
+ self["new_commit_msg"])
TextToFile(self["new_commit_msg"], self.Config("COMMITMSG_FILE"))
self.GitCommit(file_name=self.Config("COMMITMSG_FILE"))
@@ -275,6 +275,17 @@ class MergeToBranch(ScriptsBase):
options.bypass_upload_hooks = True
# CC ulan to make sure that fixes are merged to Google3.
options.cc = "ulan@chromium.org"
+
+ # Thd old git-svn workflow is deprecated for this script.
+ assert options.vc_interface != "git_svn"
+
+ # Make sure to use git hashes in the new workflows.
+ for revision in options.revisions:
+ if (IsSvnNumber(revision) or
+ (revision[0:1] == "r" and IsSvnNumber(revision[1:]))):
+ print "Please provide full git hashes of the patches to merge."
+ print "Got: %s" % revision
+ return False
return True
def _Config(self):
@@ -292,7 +303,7 @@ class MergeToBranch(ScriptsBase):
Preparation,
CreateBranch,
SearchArchitecturePorts,
- FindGitRevisions,
+ CreateCommitMessage,
ApplyPatches,
PrepareVersion,
IncrementVersion,
diff --git a/tools/push-to-trunk/releases.py b/tools/push-to-trunk/releases.py
index 53648a618..2090c00fe 100755
--- a/tools/push-to-trunk/releases.py
+++ b/tools/push-to-trunk/releases.py
@@ -33,10 +33,18 @@ PUSH_MSG_GIT_RE = re.compile(r".* \(based on ([a-fA-F0-9]+)\)$")
# (old and new format).
MERGE_MESSAGE_RE = re.compile(r"^.*[M|m]erged (.+)(\)| into).*$", re.M)
+CHERRY_PICK_TITLE_GIT_RE = re.compile(r"^.* \(cherry\-pick\)\.?$")
+
+# New git message for cherry-picked CLs. One message per line.
+MERGE_MESSAGE_GIT_RE = re.compile(r"^Merged ([a-fA-F0-9]+)\.?$")
+
# Expression for retrieving reverted patches from a commit message (old and
# new format).
ROLLBACK_MESSAGE_RE = re.compile(r"^.*[R|r]ollback of (.+)(\)| in).*$", re.M)
+# New git message for reverted CLs. One message per line.
+ROLLBACK_MESSAGE_GIT_RE = re.compile(r"^Rollback of ([a-fA-F0-9]+)\.?$")
+
# Expression for retrieving the code review link.
REVIEW_LINK_RE = re.compile(r"^Review URL: (.+)$", re.M)
@@ -143,6 +151,18 @@ class RetrieveV8Releases(Step):
patches = "-%s" % patches
return patches
+ def GetMergedPatchesGit(self, body):
+ patches = []
+ for line in body.splitlines():
+ patch = MatchSafe(MERGE_MESSAGE_GIT_RE.match(line))
+ if patch:
+ patches.append(patch)
+ patch = MatchSafe(ROLLBACK_MESSAGE_GIT_RE.match(line))
+ if patch:
+ patches.append("-%s" % patch)
+ return ", ".join(patches)
+
+
def GetReleaseDict(
self, git_hash, bleeding_edge_rev, bleeding_edge_git, branch, version,
patches, cl_body):
@@ -185,7 +205,10 @@ class RetrieveV8Releases(Step):
patches = ""
if self["patch"] != "0":
version += ".%s" % self["patch"]
- patches = self.GetMergedPatches(body)
+ if CHERRY_PICK_TITLE_GIT_RE.match(body.splitlines()[0]):
+ patches = self.GetMergedPatchesGit(body)
+ else:
+ patches = self.GetMergedPatches(body)
title = self.GitLog(n=1, format="%s", git_hash=git_hash)
bleeding_edge_revision = self.GetBleedingEdgeFromPush(title)
diff --git a/tools/push-to-trunk/test_scripts.py b/tools/push-to-trunk/test_scripts.py
index f31c491dc..41cc97f77 100644
--- a/tools/push-to-trunk/test_scripts.py
+++ b/tools/push-to-trunk/test_scripts.py
@@ -503,7 +503,7 @@ class ScriptTest(unittest.TestCase):
Cmd("git log -1 --format=%H --grep=\"Title\" origin/candidates", ""),
])
args = ["--branch", "candidates", "--vc-interface", "git_read_svn_write",
- "12345"]
+ "ab12345"]
self._state["version"] = "tag_name"
self._state["commit_title"] = "Title"
self.assertRaises(Exception,
@@ -1225,137 +1225,13 @@ deps = {
return lambda: self.assertEquals(patch,
FileToText(TEST_CONFIG["TEMPORARY_PATCH_FILE"]))
- msg = """Version 3.22.5.1 (merged r12345, r23456, r34567, r45678, r56789)
+ msg = """Version 3.22.5.1 (cherry-pick)
-Title4
-
-Title2
-
-Title3
-
-Title1
-
-Revert "Something"
-
-BUG=123,234,345,456,567,v8:123
-LOG=N
-"""
-
- def VerifySVNCommit():
- commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"])
- self.assertEquals(msg, commit)
- version = FileToText(
- os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE))
- self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
- self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
- self.assertTrue(re.search(r"#define PATCH_LEVEL\s+1", version))
- self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
-
- self.Expect([
- Cmd("git status -s -uno", ""),
- Cmd("git status -s -b -uno", "## some_branch\n"),
- Cmd("git svn fetch", ""),
- Cmd("git branch", " branch1\n* branch2\n"),
- Cmd("git new-branch %s --upstream svn/trunk" % TEST_CONFIG["BRANCHNAME"],
- ""),
- Cmd(("git log --format=%H --grep=\"Port r12345\" "
- "--reverse svn/bleeding_edge"),
- "hash1\nhash2"),
- Cmd("git svn find-rev hash1 svn/bleeding_edge", "45678"),
- Cmd("git log -1 --format=%s hash1", "Title1"),
- Cmd("git svn find-rev hash2 svn/bleeding_edge", "23456"),
- Cmd("git log -1 --format=%s hash2", "Title2"),
- Cmd(("git log --format=%H --grep=\"Port r23456\" "
- "--reverse svn/bleeding_edge"),
- ""),
- Cmd(("git log --format=%H --grep=\"Port r34567\" "
- "--reverse svn/bleeding_edge"),
- "hash3"),
- Cmd("git svn find-rev hash3 svn/bleeding_edge", "56789"),
- Cmd("git log -1 --format=%s hash3", "Title3"),
- RL("Y"), # Automatically add corresponding ports (34567, 56789)?
- Cmd("git svn find-rev r12345 svn/bleeding_edge", "hash4"),
- # Simulate svn being down which stops the script.
- Cmd("git svn find-rev r23456 svn/bleeding_edge", None),
- # Restart script in the failing step.
- Cmd("git svn find-rev r12345 svn/bleeding_edge", "hash4"),
- Cmd("git svn find-rev r23456 svn/bleeding_edge", "hash2"),
- Cmd("git svn find-rev r34567 svn/bleeding_edge", "hash3"),
- Cmd("git svn find-rev r45678 svn/bleeding_edge", "hash1"),
- Cmd("git svn find-rev r56789 svn/bleeding_edge", "hash5"),
- Cmd("git log -1 --format=%s hash4", "Title4"),
- Cmd("git log -1 --format=%s hash2", "Title2"),
- Cmd("git log -1 --format=%s hash3", "Title3"),
- Cmd("git log -1 --format=%s hash1", "Title1"),
- Cmd("git log -1 --format=%s hash5", "Revert \"Something\""),
- Cmd("git log -1 hash4", "Title4\nBUG=123\nBUG=234"),
- Cmd("git log -1 hash2", "Title2\n BUG = v8:123,345"),
- Cmd("git log -1 hash3", "Title3\nLOG=n\nBUG=567, 456"),
- Cmd("git log -1 hash1", "Title1\nBUG="),
- Cmd("git log -1 hash5", "Revert \"Something\"\nBUG=none"),
- Cmd("git log -1 -p hash4", "patch4"),
- Cmd(("git apply --index --reject \"%s\"" %
- TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
- "", cb=VerifyPatch("patch4")),
- Cmd("git log -1 -p hash2", "patch2"),
- Cmd(("git apply --index --reject \"%s\"" %
- TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
- "", cb=VerifyPatch("patch2")),
- Cmd("git log -1 -p hash3", "patch3"),
- Cmd(("git apply --index --reject \"%s\"" %
- TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
- "", cb=VerifyPatch("patch3")),
- Cmd("git log -1 -p hash1", "patch1"),
- Cmd(("git apply --index --reject \"%s\"" %
- TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
- "", cb=VerifyPatch("patch1")),
- Cmd("git log -1 -p hash5", "patch5\n"),
- Cmd(("git apply --index --reject \"%s\"" %
- TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
- "", cb=VerifyPatch("patch5\n")),
- Cmd("git apply --index --reject \"%s\"" % extra_patch, ""),
- RL("Y"), # Automatically increment patch level?
- Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], ""),
- RL("reviewer@chromium.org"), # V8 reviewer.
- Cmd("git cl upload --send-mail -r \"reviewer@chromium.org\" "
- "--bypass-hooks --cc \"ulan@chromium.org\"", ""),
- Cmd("git checkout -f %s" % TEST_CONFIG["BRANCHNAME"], ""),
- RL("LGTM"), # Enter LGTM for V8 CL.
- Cmd("git cl presubmit", "Presubmit successfull\n"),
- Cmd("git cl dcommit -f --bypass-hooks", "Closing issue\n",
- cb=VerifySVNCommit),
- Cmd("git svn fetch", ""),
- Cmd("git rebase svn/trunk", ""),
- Cmd("git svn tag 3.22.5.1 -m \"Tagging version 3.22.5.1\"", ""),
- Cmd("git checkout -f some_branch", ""),
- Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
- ])
-
- # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS
- # ports of r12345. r56789 is the MIPS port of r34567.
- args = ["-f", "-p", extra_patch, "--branch", "trunk",
- "--vc-interface", "git_svn", "12345", "23456", "34567"]
-
- # The first run of the script stops because of the svn being down.
- self.assertRaises(GitFailedException,
- lambda: MergeToBranch(TEST_CONFIG, self).Run(args))
-
- # Test that state recovery after restarting the script works.
- args += ["-s", "4"]
- MergeToBranch(TEST_CONFIG, self).Run(args)
-
- def testMergeToBranchNewGit(self):
- TEST_CONFIG["ALREADY_MERGING_SENTINEL_FILE"] = self.MakeEmptyTempFile()
- TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
- self.WriteFakeVersionFile(build=5)
- os.environ["EDITOR"] = "vi"
- extra_patch = self.MakeEmptyTempFile()
-
- def VerifyPatch(patch):
- return lambda: self.assertEquals(patch,
- FileToText(TEST_CONFIG["TEMPORARY_PATCH_FILE"]))
-
- msg = """Version 3.22.5.1 (merged r12345, r23456, r34567, r45678, r56789)
+Merged ab12345
+Merged ab23456
+Merged ab34567
+Merged ab45678
+Merged ab56789
Title4
@@ -1389,59 +1265,49 @@ LOG=N
Cmd("git branch", " branch1\n* branch2\n"),
Cmd("git new-branch %s --upstream origin/candidates" %
TEST_CONFIG["BRANCHNAME"], ""),
- Cmd(("git log --format=%H --grep=\"Port r12345\" "
+ Cmd(("git log --format=%H --grep=\"Port ab12345\" "
"--reverse origin/master"),
- "hash1\nhash2"),
- Cmd("git svn find-rev hash1 origin/master", "45678"),
- Cmd("git log -1 --format=%s hash1", "Title1"),
- Cmd("git svn find-rev hash2 origin/master", "23456"),
- Cmd("git log -1 --format=%s hash2", "Title2"),
- Cmd(("git log --format=%H --grep=\"Port r23456\" "
+ "ab45678\nab23456"),
+ Cmd("git log -1 --format=%s ab45678", "Title1"),
+ Cmd("git log -1 --format=%s ab23456", "Title2"),
+ Cmd(("git log --format=%H --grep=\"Port ab23456\" "
"--reverse origin/master"),
""),
- Cmd(("git log --format=%H --grep=\"Port r34567\" "
+ Cmd(("git log --format=%H --grep=\"Port ab34567\" "
"--reverse origin/master"),
- "hash3"),
- Cmd("git svn find-rev hash3 origin/master", "56789"),
- Cmd("git log -1 --format=%s hash3", "Title3"),
- RL("Y"), # Automatically add corresponding ports (34567, 56789)?
- Cmd("git svn find-rev r12345 origin/master",
- "Partial-rebuilding bla\nDone rebuilding blub\nhash4"),
- # Simulate svn being down which stops the script.
- Cmd("git svn find-rev r23456 origin/master", None),
+ "ab56789"),
+ Cmd("git log -1 --format=%s ab56789", "Title3"),
+ RL("Y"), # Automatically add corresponding ports (ab34567, ab56789)?
+ # Simulate git being down which stops the script.
+ Cmd("git log -1 --format=%s ab12345", None),
# Restart script in the failing step.
- Cmd("git svn find-rev r12345 origin/master", "hash4"),
- Cmd("git svn find-rev r23456 origin/master", "hash2"),
- Cmd("git svn find-rev r34567 origin/master", "hash3"),
- Cmd("git svn find-rev r45678 origin/master", "hash1"),
- Cmd("git svn find-rev r56789 origin/master", "hash5"),
- Cmd("git log -1 --format=%s hash4", "Title4"),
- Cmd("git log -1 --format=%s hash2", "Title2"),
- Cmd("git log -1 --format=%s hash3", "Title3"),
- Cmd("git log -1 --format=%s hash1", "Title1"),
- Cmd("git log -1 --format=%s hash5", "Revert \"Something\""),
- Cmd("git log -1 hash4", "Title4\nBUG=123\nBUG=234"),
- Cmd("git log -1 hash2", "Title2\n BUG = v8:123,345"),
- Cmd("git log -1 hash3", "Title3\nLOG=n\nBUG=567, 456"),
- Cmd("git log -1 hash1", "Title1\nBUG="),
- Cmd("git log -1 hash5", "Revert \"Something\"\nBUG=none"),
- Cmd("git log -1 -p hash4", "patch4"),
+ Cmd("git log -1 --format=%s ab12345", "Title4"),
+ Cmd("git log -1 --format=%s ab23456", "Title2"),
+ Cmd("git log -1 --format=%s ab34567", "Title3"),
+ Cmd("git log -1 --format=%s ab45678", "Title1"),
+ Cmd("git log -1 --format=%s ab56789", "Revert \"Something\""),
+ Cmd("git log -1 ab12345", "Title4\nBUG=123\nBUG=234"),
+ Cmd("git log -1 ab23456", "Title2\n BUG = v8:123,345"),
+ Cmd("git log -1 ab34567", "Title3\nLOG=n\nBUG=567, 456"),
+ Cmd("git log -1 ab45678", "Title1\nBUG="),
+ Cmd("git log -1 ab56789", "Revert \"Something\"\nBUG=none"),
+ Cmd("git log -1 -p ab12345", "patch4"),
Cmd(("git apply --index --reject \"%s\"" %
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
"", cb=VerifyPatch("patch4")),
- Cmd("git log -1 -p hash2", "patch2"),
+ Cmd("git log -1 -p ab23456", "patch2"),
Cmd(("git apply --index --reject \"%s\"" %
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
"", cb=VerifyPatch("patch2")),
- Cmd("git log -1 -p hash3", "patch3"),
+ Cmd("git log -1 -p ab34567", "patch3"),
Cmd(("git apply --index --reject \"%s\"" %
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
"", cb=VerifyPatch("patch3")),
- Cmd("git log -1 -p hash1", "patch1"),
+ Cmd("git log -1 -p ab45678", "patch1"),
Cmd(("git apply --index --reject \"%s\"" %
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
"", cb=VerifyPatch("patch1")),
- Cmd("git log -1 -p hash5", "patch5\n"),
+ Cmd("git log -1 -p ab56789", "patch5\n"),
Cmd(("git apply --index --reject \"%s\"" %
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
"", cb=VerifyPatch("patch5\n")),
@@ -1458,12 +1324,12 @@ LOG=N
cb=VerifySVNCommit),
Cmd("git fetch", ""),
Cmd("git log -1 --format=%H --grep=\""
- "Version 3.22.5.1 (merged r12345, r23456, r34567, r45678, r56789)"
+ "Version 3.22.5.1 (cherry-pick)"
"\" origin/candidates",
""),
Cmd("git fetch", ""),
Cmd("git log -1 --format=%H --grep=\""
- "Version 3.22.5.1 (merged r12345, r23456, r34567, r45678, r56789)"
+ "Version 3.22.5.1 (cherry-pick)"
"\" origin/candidates",
"hsh_to_tag"),
Cmd("git tag 3.22.5.1 hsh_to_tag", ""),
@@ -1472,12 +1338,12 @@ LOG=N
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
])
- # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS
- # ports of r12345. r56789 is the MIPS port of r34567.
+ # ab12345 and ab34567 are patches. ab23456 (included) and ab45678 are the
+ # MIPS ports of ab12345. ab56789 is the MIPS port of ab34567.
args = ["-f", "-p", extra_patch, "--branch", "candidates",
- "--vc-interface", "git_read_svn_write", "12345", "23456", "34567"]
+ "ab12345", "ab23456", "ab34567"]
- # The first run of the script stops because of the svn being down.
+ # The first run of the script stops because of git being down.
self.assertRaises(GitFailedException,
lambda: MergeToBranch(TEST_CONFIG, self).Run(args))
@@ -1569,7 +1435,9 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
Cmd("git checkout -f hash_234 -- %s" % VERSION_FILE, "",
cb=ResetVersion(3, 1, 1)),
Cmd("git log -1 --format=%B hash_234",
- "Version 3.3.1.1 (merged 12)\n\nReview URL: fake.com\n"),
+ "Version 3.3.1.1 (cherry-pick).\n\n"
+ "Merged abc12.\n\n"
+ "Review URL: fake.com\n"),
Cmd("git log -1 --format=%s hash_234", ""),
Cmd("git svn find-rev hash_234", "234"),
Cmd("git log -1 --format=%ci hash_234", "18:15"),
@@ -1655,7 +1523,7 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
"3.28.40,master,22624,4567,\r\n"
"3.22.3,candidates,345,3456:4566,\r\n"
"3.21.2,3.21,123,,\r\n"
- "3.3.1.1,3.3,234,,12\r\n")
+ "3.3.1.1,3.3,234,,abc12\r\n")
self.assertEquals(csv, FileToText(csv_output))
expected_json = [
@@ -1718,7 +1586,7 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
{
"revision": "234",
"revision_git": "hash_234",
- "patches_merged": "12",
+ "patches_merged": "abc12",
"bleeding_edge": "",
"bleeding_edge_git": "",
"version": "3.3.1.1",
diff --git a/tools/run-tests.py b/tools/run-tests.py
index dc73a4035..20f36798a 100755
--- a/tools/run-tests.py
+++ b/tools/run-tests.py
@@ -44,6 +44,7 @@ import time
from testrunner.local import execution
from testrunner.local import progress
from testrunner.local import testsuite
+from testrunner.local.testsuite import VARIANT_FLAGS
from testrunner.local import utils
from testrunner.local import verbose
from testrunner.network import network_execution
@@ -83,13 +84,6 @@ TIMEOUT_DEFAULT = 60
TIMEOUT_SCALEFACTOR = {"debug" : 4,
"release" : 1 }
-# Use this to run several variants of the tests.
-VARIANT_FLAGS = {
- "default": [],
- "stress": ["--stress-opt", "--always-opt"],
- "turbofan": ["--turbo-asm", "--turbo-filter=*", "--always-opt"],
- "nocrankshaft": ["--nocrankshaft"]}
-
VARIANTS = ["default", "stress", "turbofan", "nocrankshaft"]
MODE_FLAGS = {
diff --git a/tools/testrunner/local/statusfile.py b/tools/testrunner/local/statusfile.py
index 7c3ca7fb5..a313f0509 100644
--- a/tools/testrunner/local/statusfile.py
+++ b/tools/testrunner/local/statusfile.py
@@ -35,6 +35,7 @@ TIMEOUT = "TIMEOUT"
CRASH = "CRASH"
SLOW = "SLOW"
FLAKY = "FLAKY"
+FAST_VARIANTS = "FAST_VARIANTS"
NO_VARIANTS = "NO_VARIANTS"
# These are just for the status files and are mapped below in DEFS:
FAIL_OK = "FAIL_OK"
@@ -44,7 +45,7 @@ ALWAYS = "ALWAYS"
KEYWORDS = {}
for key in [SKIP, FAIL, PASS, OKAY, TIMEOUT, CRASH, SLOW, FLAKY, FAIL_OK,
- NO_VARIANTS, PASS_OR_FAIL, ALWAYS]:
+ FAST_VARIANTS, NO_VARIANTS, PASS_OR_FAIL, ALWAYS]:
KEYWORDS[key] = key
DEFS = {FAIL_OK: [FAIL, OKAY],
@@ -70,6 +71,10 @@ def OnlyStandardVariant(outcomes):
return NO_VARIANTS in outcomes
+def OnlyFastVariants(outcomes):
+ return FAST_VARIANTS in outcomes
+
+
def IsFlaky(outcomes):
return FLAKY in outcomes
diff --git a/tools/testrunner/local/testsuite.py b/tools/testrunner/local/testsuite.py
index 148697bfd..6ff97b34b 100644
--- a/tools/testrunner/local/testsuite.py
+++ b/tools/testrunner/local/testsuite.py
@@ -34,6 +34,17 @@ from . import statusfile
from . import utils
from ..objects import testcase
+# Use this to run several variants of the tests.
+VARIANT_FLAGS = {
+ "default": [],
+ "stress": ["--stress-opt", "--always-opt"],
+ "turbofan": ["--turbo-asm", "--turbo-filter=*", "--always-opt"],
+ "nocrankshaft": ["--nocrankshaft"]}
+
+FAST_VARIANT_FLAGS = [
+ f for v, f in VARIANT_FLAGS.iteritems() if v in ["default", "turbofan"]
+]
+
class TestSuite(object):
@staticmethod
@@ -81,6 +92,8 @@ class TestSuite(object):
def VariantFlags(self, testcase, default_flags):
if testcase.outcomes and statusfile.OnlyStandardVariant(testcase.outcomes):
return [[]]
+ if testcase.outcomes and statusfile.OnlyFastVariants(testcase.outcomes):
+ return filter(lambda flags: flags in FAST_VARIANT_FLAGS, default_flags)
return default_flags
def DownloadData(self):
diff --git a/tools/whitespace.txt b/tools/whitespace.txt
index 19a732534..55592a925 100644
--- a/tools/whitespace.txt
+++ b/tools/whitespace.txt
@@ -5,4 +5,4 @@ Try to write something funny. And please don't add trailing whitespace.
A Smi walks into a bar and says:
"I'm so deoptimized today!"
The doubles heard this and started to unbox.
-The Smi looked at them when a crazy v8-autoroll account showed up.......
+The Smi looked at them when a crazy v8-autoroll account showed up........