file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/97911.c
#include <stdio.h> int main() { while (1); return 0; }
the_stack_data/802378.c
// RUN: %crabllvm --turn-undef-nondet --inline --lower-select --devirt-functions --lower-unsigned-icmp --do-not-print-invariants --crab-dom=boxes --crab-check=assert --externalize-addr-taken-functions %opts "%s" 2>&1 | OutputCheck -l debug %s // CHECK: ^1 Number of total safe checks$ // CHECK: ^0 Number of total error checks$ // CHECK: ^0 Number of total warning checks$ extern void __VERIFIER_error() __attribute__ ((__noreturn__)); extern void *malloc(unsigned long sz ); extern char __VERIFIER_nondet_char(void); extern int __VERIFIER_nondet_int(void); extern long __VERIFIER_nondet_long(void); extern void *__VERIFIER_nondet_pointer(void); /* Generated by CIL v. 1.3.6 */ /* print_CIL_Input is true */ extern int __VERIFIER_nondet_int(); typedef unsigned int size_t; typedef long __time_t; struct buf_mem_st { int length ; char *data ; int max ; }; typedef struct buf_mem_st BUF_MEM; typedef __time_t time_t; struct stack_st { int num ; char **data ; int sorted ; int num_alloc ; int (*comp)(char const * const * , char const * const * ) ; }; typedef struct stack_st STACK; struct bio_st; struct bio_st; struct crypto_ex_data_st { STACK *sk ; int dummy ; }; typedef struct crypto_ex_data_st CRYPTO_EX_DATA; typedef struct bio_st BIO; typedef void bio_info_cb(struct bio_st * , int , char const * , int , long , long ); struct bio_method_st { int type ; char const *name ; int (*bwrite)(BIO * , char const * , int ) ; int (*bread)(BIO * , char * , int ) ; int (*bputs)(BIO * , char const * ) ; int (*bgets)(BIO * , char * , int ) ; long (*ctrl)(BIO * , int , long , void * ) ; int (*create)(BIO * ) ; int (*destroy)(BIO * ) ; long (*callback_ctrl)(BIO * , int , bio_info_cb * ) ; }; typedef struct bio_method_st BIO_METHOD; struct bio_st { BIO_METHOD *method ; long (*callback)(struct bio_st * , int , char const * , int , long , long ) ; char *cb_arg ; int init ; int shutdown ; int flags ; int retry_reason ; int num ; void *ptr ; struct bio_st *next_bio ; struct bio_st *prev_bio ; int references ; unsigned long num_read ; unsigned long num_write ; CRYPTO_EX_DATA ex_data ; }; struct bignum_st { unsigned long *d ; int top ; int dmax ; int neg ; int flags ; }; typedef struct bignum_st BIGNUM; struct bignum_ctx { int tos ; BIGNUM bn[16] ; int flags ; int depth ; int pos[12] ; int too_many ; }; typedef struct bignum_ctx BN_CTX; struct bn_blinding_st { int init ; BIGNUM *A ; BIGNUM *Ai ; BIGNUM *mod ; }; typedef struct bn_blinding_st BN_BLINDING; struct bn_mont_ctx_st { int ri ; BIGNUM RR ; BIGNUM N ; BIGNUM Ni ; unsigned long n0 ; int flags ; }; typedef struct bn_mont_ctx_st BN_MONT_CTX; struct X509_algor_st; struct X509_algor_st; struct X509_algor_st; struct asn1_object_st { char const *sn ; char const *ln ; int nid ; int length ; unsigned char *data ; int flags ; }; typedef struct asn1_object_st ASN1_OBJECT; struct asn1_string_st { int length ; int type ; unsigned char *data ; long flags ; }; typedef struct asn1_string_st ASN1_STRING; typedef struct asn1_string_st ASN1_INTEGER; typedef struct asn1_string_st ASN1_ENUMERATED; typedef struct asn1_string_st ASN1_BIT_STRING; typedef struct asn1_string_st ASN1_OCTET_STRING; typedef struct asn1_string_st ASN1_PRINTABLESTRING; typedef struct asn1_string_st ASN1_T61STRING; typedef struct asn1_string_st ASN1_IA5STRING; typedef struct asn1_string_st ASN1_GENERALSTRING; typedef struct asn1_string_st ASN1_UNIVERSALSTRING; typedef struct asn1_string_st ASN1_BMPSTRING; typedef struct asn1_string_st ASN1_UTCTIME; typedef struct asn1_string_st ASN1_TIME; typedef struct asn1_string_st ASN1_GENERALIZEDTIME; typedef struct asn1_string_st ASN1_VISIBLESTRING; typedef struct asn1_string_st ASN1_UTF8STRING; typedef int ASN1_BOOLEAN; union __anonunion_value_19 { char *ptr ; ASN1_BOOLEAN boolean ; ASN1_STRING *asn1_string ; ASN1_OBJECT *object ; ASN1_INTEGER *integer ; ASN1_ENUMERATED *enumerated ; ASN1_BIT_STRING *bit_string ; ASN1_OCTET_STRING *octet_string ; ASN1_PRINTABLESTRING *printablestring ; ASN1_T61STRING *t61string ; ASN1_IA5STRING *ia5string ; ASN1_GENERALSTRING *generalstring ; ASN1_BMPSTRING *bmpstring ; ASN1_UNIVERSALSTRING *universalstring ; ASN1_UTCTIME *utctime ; ASN1_GENERALIZEDTIME *generalizedtime ; ASN1_VISIBLESTRING *visiblestring ; ASN1_UTF8STRING *utf8string ; ASN1_STRING *set ; ASN1_STRING *sequence ; }; struct asn1_type_st { int type ; union __anonunion_value_19 value ; }; typedef struct asn1_type_st ASN1_TYPE; struct MD5state_st { unsigned int A ; unsigned int B ; unsigned int C ; unsigned int D ; unsigned int Nl ; unsigned int Nh ; unsigned int data[16] ; int num ; }; typedef struct MD5state_st MD5_CTX; struct SHAstate_st { unsigned int h0 ; unsigned int h1 ; unsigned int h2 ; unsigned int h3 ; unsigned int h4 ; unsigned int Nl ; unsigned int Nh ; unsigned int data[16] ; int num ; }; typedef struct SHAstate_st SHA_CTX; struct MD2state_st { int num ; unsigned char data[16] ; unsigned int cksm[16] ; unsigned int state[16] ; }; typedef struct MD2state_st MD2_CTX; struct MD4state_st { unsigned int A ; unsigned int B ; unsigned int C ; unsigned int D ; unsigned int Nl ; unsigned int Nh ; unsigned int data[16] ; int num ; }; typedef struct MD4state_st MD4_CTX; struct RIPEMD160state_st { unsigned int A ; unsigned int B ; unsigned int C ; unsigned int D ; unsigned int E ; unsigned int Nl ; unsigned int Nh ; unsigned int data[16] ; int num ; }; typedef struct RIPEMD160state_st RIPEMD160_CTX; typedef unsigned char des_cblock[8]; union __anonunion_ks_20 { des_cblock cblock ; unsigned long deslong[2] ; }; struct des_ks_struct { union __anonunion_ks_20 ks ; int weak_key ; }; typedef struct des_ks_struct des_key_schedule[16]; struct rc4_key_st { unsigned int x ; unsigned int y ; unsigned int data[256] ; }; typedef struct rc4_key_st RC4_KEY; struct rc2_key_st { unsigned int data[64] ; }; typedef struct rc2_key_st RC2_KEY; struct rc5_key_st { int rounds ; unsigned long data[34] ; }; typedef struct rc5_key_st RC5_32_KEY; struct bf_key_st { unsigned int P[18] ; unsigned int S[1024] ; }; typedef struct bf_key_st BF_KEY; struct cast_key_st { unsigned long data[32] ; int short_key ; }; typedef struct cast_key_st CAST_KEY; struct idea_key_st { unsigned int data[9][6] ; }; typedef struct idea_key_st IDEA_KEY_SCHEDULE; struct mdc2_ctx_st { int num ; unsigned char data[8] ; des_cblock h ; des_cblock hh ; int pad_type ; }; typedef struct mdc2_ctx_st MDC2_CTX; struct rsa_st; struct rsa_st; typedef struct rsa_st RSA; struct rsa_meth_st { char const *name ; int (*rsa_pub_enc)(int flen , unsigned char *from , unsigned char *to , RSA *rsa , int padding ) ; int (*rsa_pub_dec)(int flen , unsigned char *from , unsigned char *to , RSA *rsa , int padding ) ; int (*rsa_priv_enc)(int flen , unsigned char *from , unsigned char *to , RSA *rsa , int padding ) ; int (*rsa_priv_dec)(int flen , unsigned char *from , unsigned char *to , RSA *rsa , int padding ) ; int (*rsa_mod_exp)(BIGNUM *r0 , BIGNUM *I , RSA *rsa ) ; int (*bn_mod_exp)(BIGNUM *r , BIGNUM *a , BIGNUM const *p , BIGNUM const *m , BN_CTX *ctx , BN_MONT_CTX *m_ctx ) ; int (*init)(RSA *rsa ) ; int (*finish)(RSA *rsa ) ; int flags ; char *app_data ; int (*rsa_sign)(int type , unsigned char *m , unsigned int m_len , unsigned char *sigret , unsigned int *siglen , RSA *rsa ) ; int (*rsa_verify)(int dtype , unsigned char *m , unsigned int m_len , unsigned char *sigbuf , unsigned int siglen , RSA *rsa ) ; }; typedef struct rsa_meth_st RSA_METHOD; struct rsa_st { int pad ; int version ; RSA_METHOD *meth ; BIGNUM *n ; BIGNUM *e ; BIGNUM *d ; BIGNUM *p ; BIGNUM *q ; BIGNUM *dmp1 ; BIGNUM *dmq1 ; BIGNUM *iqmp ; CRYPTO_EX_DATA ex_data ; int references ; int flags ; BN_MONT_CTX *_method_mod_n ; BN_MONT_CTX *_method_mod_p ; BN_MONT_CTX *_method_mod_q ; char *bignum_data ; BN_BLINDING *blinding ; }; struct dh_st; struct dh_st; typedef struct dh_st DH; struct dh_method { char const *name ; int (*generate_key)(DH *dh ) ; int (*compute_key)(unsigned char *key , BIGNUM *pub_key , DH *dh ) ; int (*bn_mod_exp)(DH *dh , BIGNUM *r , BIGNUM *a , BIGNUM const *p , BIGNUM const *m , BN_CTX *ctx , BN_MONT_CTX *m_ctx ) ; int (*init)(DH *dh ) ; int (*finish)(DH *dh ) ; int flags ; char *app_data ; }; typedef struct dh_method DH_METHOD; struct dh_st { int pad ; int version ; BIGNUM *p ; BIGNUM *g ; int length ; BIGNUM *pub_key ; BIGNUM *priv_key ; int flags ; char *method_mont_p ; BIGNUM *q ; BIGNUM *j ; unsigned char *seed ; int seedlen ; BIGNUM *counter ; int references ; CRYPTO_EX_DATA ex_data ; DH_METHOD *meth ; }; struct dsa_st; struct dsa_st; typedef struct dsa_st DSA; struct DSA_SIG_st { BIGNUM *r ; BIGNUM *s ; }; typedef struct DSA_SIG_st DSA_SIG; struct dsa_method { char const *name ; DSA_SIG *(*dsa_do_sign)(unsigned char const *dgst , int dlen , DSA *dsa ) ; int (*dsa_sign_setup)(DSA *dsa , BN_CTX *ctx_in , BIGNUM **kinvp , BIGNUM **rp ) ; int (*dsa_do_verify)(unsigned char const *dgst , int dgst_len , DSA_SIG *sig , DSA *dsa ) ; int (*dsa_mod_exp)(DSA *dsa , BIGNUM *rr , BIGNUM *a1 , BIGNUM *p1 , BIGNUM *a2 , BIGNUM *p2 , BIGNUM *m , BN_CTX *ctx , BN_MONT_CTX *in_mont ) ; int (*bn_mod_exp)(DSA *dsa , BIGNUM *r , BIGNUM *a , BIGNUM const *p , BIGNUM const *m , BN_CTX *ctx , BN_MONT_CTX *m_ctx ) ; int (*init)(DSA *dsa ) ; int (*finish)(DSA *dsa ) ; int flags ; char *app_data ; }; typedef struct dsa_method DSA_METHOD; struct dsa_st { int pad ; int version ; int write_params ; BIGNUM *p ; BIGNUM *q ; BIGNUM *g ; BIGNUM *pub_key ; BIGNUM *priv_key ; BIGNUM *kinv ; BIGNUM *r ; int flags ; char *method_mont_p ; int references ; CRYPTO_EX_DATA ex_data ; DSA_METHOD *meth ; }; union __anonunion_pkey_21 { char *ptr ; struct rsa_st *rsa ; struct dsa_st *dsa ; struct dh_st *dh ; }; struct evp_pkey_st { int type ; int save_type ; int references ; union __anonunion_pkey_21 pkey ; int save_parameters ; STACK *attributes ; }; typedef struct evp_pkey_st EVP_PKEY; struct env_md_st { int type ; int pkey_type ; int md_size ; void (*init)() ; void (*update)() ; void (*final)() ; int (*sign)() ; int (*verify)() ; int required_pkey_type[5] ; int block_size ; int ctx_size ; }; typedef struct env_md_st EVP_MD; union __anonunion_md_22 { unsigned char base[4] ; MD2_CTX md2 ; MD5_CTX md5 ; MD4_CTX md4 ; RIPEMD160_CTX ripemd160 ; SHA_CTX sha ; MDC2_CTX mdc2 ; }; struct env_md_ctx_st { EVP_MD const *digest ; union __anonunion_md_22 md ; }; typedef struct env_md_ctx_st EVP_MD_CTX; struct evp_cipher_st; struct evp_cipher_st; typedef struct evp_cipher_st EVP_CIPHER; struct evp_cipher_ctx_st; struct evp_cipher_ctx_st; typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; struct evp_cipher_st { int nid ; int block_size ; int key_len ; int iv_len ; unsigned long flags ; int (*init)(EVP_CIPHER_CTX *ctx , unsigned char const *key , unsigned char const *iv , int enc ) ; int (*do_cipher)(EVP_CIPHER_CTX *ctx , unsigned char *out , unsigned char const *in , unsigned int inl ) ; int (*cleanup)(EVP_CIPHER_CTX * ) ; int ctx_size ; int (*set_asn1_parameters)(EVP_CIPHER_CTX * , ASN1_TYPE * ) ; int (*get_asn1_parameters)(EVP_CIPHER_CTX * , ASN1_TYPE * ) ; int (*ctrl)(EVP_CIPHER_CTX * , int type , int arg , void *ptr ) ; void *app_data ; }; struct __anonstruct_rc4_24 { unsigned char key[16] ; RC4_KEY ks ; }; struct __anonstruct_desx_cbc_25 { des_key_schedule ks ; des_cblock inw ; des_cblock outw ; }; struct __anonstruct_des_ede_26 { des_key_schedule ks1 ; des_key_schedule ks2 ; des_key_schedule ks3 ; }; struct __anonstruct_rc2_27 { int key_bits ; RC2_KEY ks ; }; struct __anonstruct_rc5_28 { int rounds ; RC5_32_KEY ks ; }; union __anonunion_c_23 { struct __anonstruct_rc4_24 rc4 ; des_key_schedule des_ks ; struct __anonstruct_desx_cbc_25 desx_cbc ; struct __anonstruct_des_ede_26 des_ede ; IDEA_KEY_SCHEDULE idea_ks ; struct __anonstruct_rc2_27 rc2 ; struct __anonstruct_rc5_28 rc5 ; BF_KEY bf_ks ; CAST_KEY cast_ks ; }; struct evp_cipher_ctx_st { EVP_CIPHER const *cipher ; int encrypt ; int buf_len ; unsigned char oiv[8] ; unsigned char iv[8] ; unsigned char buf[8] ; int num ; void *app_data ; int key_len ; union __anonunion_c_23 c ; }; struct comp_method_st { int type ; char const *name ; int (*init)() ; void (*finish)() ; int (*compress)() ; int (*expand)() ; long (*ctrl)() ; long (*callback_ctrl)() ; }; typedef struct comp_method_st COMP_METHOD; struct comp_ctx_st { COMP_METHOD *meth ; unsigned long compress_in ; unsigned long compress_out ; unsigned long expand_in ; unsigned long expand_out ; CRYPTO_EX_DATA ex_data ; }; typedef struct comp_ctx_st COMP_CTX; struct X509_algor_st { ASN1_OBJECT *algorithm ; ASN1_TYPE *parameter ; }; typedef struct X509_algor_st X509_ALGOR; struct X509_val_st { ASN1_TIME *notBefore ; ASN1_TIME *notAfter ; }; typedef struct X509_val_st X509_VAL; struct X509_pubkey_st { X509_ALGOR *algor ; ASN1_BIT_STRING *public_key ; EVP_PKEY *pkey ; }; typedef struct X509_pubkey_st X509_PUBKEY; struct X509_name_st { STACK *entries ; int modified ; BUF_MEM *bytes ; unsigned long hash ; }; typedef struct X509_name_st X509_NAME; struct x509_cinf_st { ASN1_INTEGER *version ; ASN1_INTEGER *serialNumber ; X509_ALGOR *signature ; X509_NAME *issuer ; X509_VAL *validity ; X509_NAME *subject ; X509_PUBKEY *key ; ASN1_BIT_STRING *issuerUID ; ASN1_BIT_STRING *subjectUID ; STACK *extensions ; }; typedef struct x509_cinf_st X509_CINF; struct x509_cert_aux_st { STACK *trust ; STACK *reject ; ASN1_UTF8STRING *alias ; ASN1_OCTET_STRING *keyid ; STACK *other ; }; typedef struct x509_cert_aux_st X509_CERT_AUX; struct AUTHORITY_KEYID_st; struct AUTHORITY_KEYID_st; struct x509_st { X509_CINF *cert_info ; X509_ALGOR *sig_alg ; ASN1_BIT_STRING *signature ; int valid ; int references ; char *name ; CRYPTO_EX_DATA ex_data ; long ex_pathlen ; unsigned long ex_flags ; unsigned long ex_kusage ; unsigned long ex_xkusage ; unsigned long ex_nscert ; ASN1_OCTET_STRING *skid ; struct AUTHORITY_KEYID_st *akid ; unsigned char sha1_hash[20] ; X509_CERT_AUX *aux ; }; typedef struct x509_st X509; struct lhash_node_st { void *data ; struct lhash_node_st *next ; unsigned long hash ; }; typedef struct lhash_node_st LHASH_NODE; struct lhash_st { LHASH_NODE **b ; int (*comp)() ; unsigned long (*hash)() ; unsigned int num_nodes ; unsigned int num_alloc_nodes ; unsigned int p ; unsigned int pmax ; unsigned long up_load ; unsigned long down_load ; unsigned long num_items ; unsigned long num_expands ; unsigned long num_expand_reallocs ; unsigned long num_contracts ; unsigned long num_contract_reallocs ; unsigned long num_hash_calls ; unsigned long num_comp_calls ; unsigned long num_insert ; unsigned long num_replace ; unsigned long num_delete ; unsigned long num_no_delete ; unsigned long num_retrieve ; unsigned long num_retrieve_miss ; unsigned long num_hash_comps ; int error ; }; struct x509_store_ctx_st; struct x509_store_ctx_st; typedef struct x509_store_ctx_st X509_STORE_CTX; struct x509_store_st { int cache ; STACK *objs ; STACK *get_cert_methods ; int (*verify)(X509_STORE_CTX *ctx ) ; int (*verify_cb)(int ok , X509_STORE_CTX *ctx ) ; CRYPTO_EX_DATA ex_data ; int references ; int depth ; }; typedef struct x509_store_st X509_STORE; struct x509_store_ctx_st { X509_STORE *ctx ; int current_method ; X509 *cert ; STACK *untrusted ; int purpose ; int trust ; time_t check_time ; unsigned long flags ; void *other_ctx ; int (*verify)(X509_STORE_CTX *ctx ) ; int (*verify_cb)(int ok , X509_STORE_CTX *ctx ) ; int (*get_issuer)(X509 **issuer , X509_STORE_CTX *ctx , X509 *x ) ; int (*check_issued)(X509_STORE_CTX *ctx , X509 *x , X509 *issuer ) ; int (*cleanup)(X509_STORE_CTX *ctx ) ; int depth ; int valid ; int last_untrusted ; STACK *chain ; int error_depth ; int error ; X509 *current_cert ; X509 *current_issuer ; CRYPTO_EX_DATA ex_data ; }; typedef int pem_password_cb(char *buf , int size , int rwflag , void *userdata ); struct ssl_st; struct ssl_st; struct ssl_cipher_st { int valid ; char const *name ; unsigned long id ; unsigned long algorithms ; unsigned long algo_strength ; unsigned long algorithm2 ; int strength_bits ; int alg_bits ; unsigned long mask ; unsigned long mask_strength ; }; typedef struct ssl_cipher_st SSL_CIPHER; typedef struct ssl_st SSL; struct ssl_ctx_st; struct ssl_ctx_st; typedef struct ssl_ctx_st SSL_CTX; struct ssl3_enc_method; struct ssl3_enc_method; struct ssl_method_st { int version ; int (*ssl_new)(SSL *s ) ; void (*ssl_clear)(SSL *s ) ; void (*ssl_free)(SSL *s ) ; int (*ssl_accept)(SSL *s ) ; int (*ssl_connect)(SSL *s ) ; int (*ssl_read)(SSL *s , void *buf , int len ) ; int (*ssl_peek)(SSL *s , void *buf , int len ) ; int (*ssl_write)(SSL *s , void const *buf , int len ) ; int (*ssl_shutdown)(SSL *s ) ; int (*ssl_renegotiate)(SSL *s ) ; int (*ssl_renegotiate_check)(SSL *s ) ; long (*ssl_ctrl)(SSL *s , int cmd , long larg , char *parg ) ; long (*ssl_ctx_ctrl)(SSL_CTX *ctx , int cmd , long larg , char *parg ) ; SSL_CIPHER *(*get_cipher_by_char)(unsigned char const *ptr ) ; int (*put_cipher_by_char)(SSL_CIPHER const *cipher , unsigned char *ptr ) ; int (*ssl_pending)(SSL *s ) ; int (*num_ciphers)(void) ; SSL_CIPHER *(*get_cipher)(unsigned int ncipher ) ; struct ssl_method_st *(*get_ssl_method)(int version ) ; long (*get_timeout)(void) ; struct ssl3_enc_method *ssl3_enc ; int (*ssl_version)() ; long (*ssl_callback_ctrl)(SSL *s , int cb_id , void (*fp)() ) ; long (*ssl_ctx_callback_ctrl)(SSL_CTX *s , int cb_id , void (*fp)() ) ; }; typedef struct ssl_method_st SSL_METHOD; struct sess_cert_st; struct sess_cert_st; struct ssl_session_st { int ssl_version ; unsigned int key_arg_length ; unsigned char key_arg[8] ; int master_key_length ; unsigned char master_key[48] ; unsigned int session_id_length ; unsigned char session_id[32] ; unsigned int sid_ctx_length ; unsigned char sid_ctx[32] ; int not_resumable ; struct sess_cert_st *sess_cert ; X509 *peer ; long verify_result ; int references ; long timeout ; long time ; int compress_meth ; SSL_CIPHER *cipher ; unsigned long cipher_id ; STACK *ciphers ; CRYPTO_EX_DATA ex_data ; struct ssl_session_st *prev ; struct ssl_session_st *next ; }; typedef struct ssl_session_st SSL_SESSION; struct ssl_comp_st { int id ; char *name ; COMP_METHOD *method ; }; typedef struct ssl_comp_st SSL_COMP; struct __anonstruct_stats_37 { int sess_connect ; int sess_connect_renegotiate ; int sess_connect_good ; int sess_accept ; int sess_accept_renegotiate ; int sess_accept_good ; int sess_miss ; int sess_timeout ; int sess_cache_full ; int sess_hit ; int sess_cb_hit ; }; struct cert_st; struct cert_st; struct ssl_ctx_st { SSL_METHOD *method ; unsigned long options ; unsigned long mode ; STACK *cipher_list ; STACK *cipher_list_by_id ; struct x509_store_st *cert_store ; struct lhash_st *sessions ; unsigned long session_cache_size ; struct ssl_session_st *session_cache_head ; struct ssl_session_st *session_cache_tail ; int session_cache_mode ; long session_timeout ; int (*new_session_cb)(struct ssl_st *ssl , SSL_SESSION *sess ) ; void (*remove_session_cb)(struct ssl_ctx_st *ctx , SSL_SESSION *sess ) ; SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl , unsigned char *data , int len , int *copy ) ; struct __anonstruct_stats_37 stats ; int references ; void (*info_callback)() ; int (*app_verify_callback)() ; char *app_verify_arg ; struct cert_st *cert ; int read_ahead ; int verify_mode ; int verify_depth ; unsigned int sid_ctx_length ; unsigned char sid_ctx[32] ; int (*default_verify_callback)(int ok , X509_STORE_CTX *ctx ) ; int purpose ; int trust ; pem_password_cb *default_passwd_callback ; void *default_passwd_callback_userdata ; int (*client_cert_cb)() ; STACK *client_CA ; int quiet_shutdown ; CRYPTO_EX_DATA ex_data ; EVP_MD const *rsa_md5 ; EVP_MD const *md5 ; EVP_MD const *sha1 ; STACK *extra_certs ; STACK *comp_methods ; }; struct ssl2_state_st; struct ssl2_state_st; struct ssl3_state_st; struct ssl3_state_st; struct ssl_st { int version ; int type ; SSL_METHOD *method ; BIO *rbio ; BIO *wbio ; BIO *bbio ; int rwstate ; int in_handshake ; int (*handshake_func)() ; int server ; int new_session ; int quiet_shutdown ; int shutdown ; int state ; int rstate ; BUF_MEM *init_buf ; int init_num ; int init_off ; unsigned char *packet ; unsigned int packet_length ; struct ssl2_state_st *s2 ; struct ssl3_state_st *s3 ; int read_ahead ; int hit ; int purpose ; int trust ; STACK *cipher_list ; STACK *cipher_list_by_id ; EVP_CIPHER_CTX *enc_read_ctx ; EVP_MD const *read_hash ; COMP_CTX *expand ; EVP_CIPHER_CTX *enc_write_ctx ; EVP_MD const *write_hash ; COMP_CTX *compress ; struct cert_st *cert ; unsigned int sid_ctx_length ; unsigned char sid_ctx[32] ; SSL_SESSION *session ; int verify_mode ; int verify_depth ; int (*verify_callback)(int ok , X509_STORE_CTX *ctx ) ; void (*info_callback)() ; int error ; int error_code ; SSL_CTX *ctx ; int debug ; long verify_result ; CRYPTO_EX_DATA ex_data ; STACK *client_CA ; int references ; unsigned long options ; unsigned long mode ; int first_packet ; int client_version ; }; struct __anonstruct_tmp_38 { unsigned int conn_id_length ; unsigned int cert_type ; unsigned int cert_length ; unsigned int csl ; unsigned int clear ; unsigned int enc ; unsigned char ccl[32] ; unsigned int cipher_spec_length ; unsigned int session_id_length ; unsigned int clen ; unsigned int rlen ; }; struct ssl2_state_st { int three_byte_header ; int clear_text ; int escape ; int ssl2_rollback ; unsigned int wnum ; int wpend_tot ; unsigned char const *wpend_buf ; int wpend_off ; int wpend_len ; int wpend_ret ; int rbuf_left ; int rbuf_offs ; unsigned char *rbuf ; unsigned char *wbuf ; unsigned char *write_ptr ; unsigned int padding ; unsigned int rlength ; int ract_data_length ; unsigned int wlength ; int wact_data_length ; unsigned char *ract_data ; unsigned char *wact_data ; unsigned char *mac_data ; unsigned char *pad_data_UNUSED ; unsigned char *read_key ; unsigned char *write_key ; unsigned int challenge_length ; unsigned char challenge[32] ; unsigned int conn_id_length ; unsigned char conn_id[16] ; unsigned int key_material_length ; unsigned char key_material[48] ; unsigned long read_sequence ; unsigned long write_sequence ; struct __anonstruct_tmp_38 tmp ; }; struct ssl3_record_st { int type ; unsigned int length ; unsigned int off ; unsigned char *data ; unsigned char *input ; unsigned char *comp ; }; typedef struct ssl3_record_st SSL3_RECORD; struct ssl3_buffer_st { unsigned char *buf ; int offset ; int left ; }; typedef struct ssl3_buffer_st SSL3_BUFFER; struct __anonstruct_tmp_39 { unsigned char cert_verify_md[72] ; unsigned char finish_md[72] ; int finish_md_len ; unsigned char peer_finish_md[72] ; int peer_finish_md_len ; unsigned long message_size ; int message_type ; SSL_CIPHER *new_cipher ; DH *dh ; int next_state ; int reuse_message ; int cert_req ; int ctype_num ; char ctype[7] ; STACK *ca_names ; int use_rsa_tmp ; int key_block_length ; unsigned char *key_block ; EVP_CIPHER const *new_sym_enc ; EVP_MD const *new_hash ; SSL_COMP const *new_compression ; int cert_request ; }; struct ssl3_state_st { long flags ; int delay_buf_pop_ret ; unsigned char read_sequence[8] ; unsigned char read_mac_secret[36] ; unsigned char write_sequence[8] ; unsigned char write_mac_secret[36] ; unsigned char server_random[32] ; unsigned char client_random[32] ; SSL3_BUFFER rbuf ; SSL3_BUFFER wbuf ; SSL3_RECORD rrec ; SSL3_RECORD wrec ; unsigned char alert_fragment[2] ; unsigned int alert_fragment_len ; unsigned char handshake_fragment[4] ; unsigned int handshake_fragment_len ; unsigned int wnum ; int wpend_tot ; int wpend_type ; int wpend_ret ; unsigned char const *wpend_buf ; EVP_MD_CTX finish_dgst1 ; EVP_MD_CTX finish_dgst2 ; int change_cipher_spec ; int warn_alert ; int fatal_alert ; int alert_dispatch ; unsigned char send_alert[2] ; int renegotiate ; int total_renegotiations ; int num_renegotiations ; int in_read_app_data ; struct __anonstruct_tmp_39 tmp ; }; struct cert_pkey_st { X509 *x509 ; EVP_PKEY *privatekey ; }; typedef struct cert_pkey_st CERT_PKEY; struct cert_st { CERT_PKEY *key ; int valid ; unsigned long mask ; unsigned long export_mask ; RSA *rsa_tmp ; RSA *(*rsa_tmp_cb)(SSL *ssl , int is_export , int keysize ) ; DH *dh_tmp ; DH *(*dh_tmp_cb)(SSL *ssl , int is_export , int keysize ) ; CERT_PKEY pkeys[5] ; int references ; }; struct sess_cert_st { STACK *cert_chain ; int peer_cert_type ; CERT_PKEY *peer_key ; CERT_PKEY peer_pkeys[5] ; RSA *peer_rsa_tmp ; DH *peer_dh_tmp ; int references ; }; struct ssl3_enc_method { int (*enc)(SSL * , int ) ; int (*mac)(SSL * , unsigned char * , int ) ; int (*setup_key_block)(SSL * ) ; int (*generate_master_secret)(SSL * , unsigned char * , unsigned char * , int ) ; int (*change_cipher_state)(SSL * , int ) ; int (*final_finish_mac)(SSL * , EVP_MD_CTX * , EVP_MD_CTX * , char const * , int , unsigned char * ) ; int finish_mac_length ; int (*cert_verify_mac)(SSL * , EVP_MD_CTX * , unsigned char * ) ; char const *client_finished_label ; int client_finished_label_len ; char const *server_finished_label ; int server_finished_label_len ; int (*alert_value)(int ) ; }; extern void *memcpy(void * __restrict __dest , void const * __restrict __src , size_t __n ) ; SSL_METHOD *SSLv3_client_method(void) ; extern SSL_METHOD *sslv3_base_method(void) ; int ssl3_connect(SSL *s ) ; static SSL_METHOD *ssl3_get_client_method(int ver ) ; static SSL_METHOD *ssl3_get_client_method(int ver ) { SSL_METHOD *tmp ; { if (ver == 768) { { tmp = SSLv3_client_method(); } return (tmp); } else { return ((SSL_METHOD *)((void *)0)); } } } static int init = 1; static SSL_METHOD SSLv3_client_data ; SSL_METHOD *SSLv3_client_method(void) { char *tmp ; SSL_METHOD *tmp___0 ; { if (init) { { init = 0; tmp___0 = sslv3_base_method(); tmp = (char *)tmp___0; memcpy((void *)((char *)(& SSLv3_client_data)), (void const *)tmp, sizeof(SSL_METHOD )); SSLv3_client_data.ssl_connect = & ssl3_connect; SSLv3_client_data.get_ssl_method = & ssl3_get_client_method; } } else { } return (& SSLv3_client_data); } } int main(void) { SSL *s = (SSL*)malloc(sizeof(SSL)) ; { { s->s3 = malloc(sizeof(struct ssl3_state_st)); s->ctx = malloc(sizeof(SSL_CTX)); s->session = malloc(sizeof(SSL_SESSION)); s->state = 12292; ssl3_connect(s); } return (0); } } int ssl3_connect(SSL *s ) { BUF_MEM *buf ; unsigned long tmp ; unsigned long l ; long num1 ; void (*cb)() ; int ret ; int new_state ; int state ; int skip ; int *tmp___0 = __VERIFIER_nondet_pointer() ; int tmp___1 = __VERIFIER_nondet_int() ; int tmp___2 = __VERIFIER_nondet_int() ; int tmp___3 = __VERIFIER_nondet_int() ; int tmp___4 = __VERIFIER_nondet_int() ; int tmp___5 = __VERIFIER_nondet_int() ; int tmp___6 = __VERIFIER_nondet_int() ; int tmp___7 = __VERIFIER_nondet_int() ; int tmp___8 = __VERIFIER_nondet_int() ; long tmp___9 = __VERIFIER_nondet_long() ; int blastFlag ; { blastFlag = 0; s->hit=__VERIFIER_nondet_int (); s->state = 12292; tmp = __VERIFIER_nondet_int(); cb = (void (*)())((void *)0); ret = -1; skip = 0; *tmp___0 = 0; if ((unsigned long )s->info_callback != (unsigned long )((void *)0)) { cb = s->info_callback; } else { if ((unsigned long )(s->ctx)->info_callback != (unsigned long )((void *)0)) { cb = (s->ctx)->info_callback; } else { } } s->in_handshake += 1; if (tmp___1 & 12288) { if (tmp___2 & 16384) { } else { } } else { } { while (1) { while_0_continue: /* CIL Label */ ; state = s->state; if (s->state == 12292) { goto switch_1_12292; } else { if (s->state == 16384) { goto switch_1_16384; } else { if (s->state == 4096) { goto switch_1_4096; } else { if (s->state == 20480) { goto switch_1_20480; } else { if (s->state == 4099) { goto switch_1_4099; } else { if (s->state == 4368) { goto switch_1_4368; } else { if (s->state == 4369) { goto switch_1_4369; } else { if (s->state == 4384) { goto switch_1_4384; } else { if (s->state == 4385) { goto switch_1_4385; } else { if (s->state == 4400) { goto switch_1_4400; } else { if (s->state == 4401) { goto switch_1_4401; } else { if (s->state == 4416) { goto switch_1_4416; } else { if (s->state == 4417) { goto switch_1_4417; } else { if (s->state == 4432) { goto switch_1_4432; } else { if (s->state == 4433) { goto switch_1_4433; } else { if (s->state == 4448) { goto switch_1_4448; } else { if (s->state == 4449) { goto switch_1_4449; } else { if (s->state == 4464) { goto switch_1_4464; } else { if (s->state == 4465) { goto switch_1_4465; } else { if (s->state == 4466) { goto switch_1_4466; } else { if (s->state == 4467) { goto switch_1_4467; } else { if (s->state == 4480) { goto switch_1_4480; } else { if (s->state == 4481) { goto switch_1_4481; } else { if (s->state == 4496) { goto switch_1_4496; } else { if (s->state == 4497) { goto switch_1_4497; } else { if (s->state == 4512) { goto switch_1_4512; } else { if (s->state == 4513) { goto switch_1_4513; } else { if (s->state == 4528) { goto switch_1_4528; } else { if (s->state == 4529) { goto switch_1_4529; } else { if (s->state == 4560) { goto switch_1_4560; } else { if (s->state == 4561) { goto switch_1_4561; } else { if (s->state == 4352) { goto switch_1_4352; } else { if (s->state == 3) { goto switch_1_3; } else { { goto switch_1_default; if (0) { switch_1_12292: /* CIL Label */ s->new_session = 1; s->state = 4096; (s->ctx)->stats.sess_connect_renegotiate += 1; switch_1_16384: /* CIL Label */ ; switch_1_4096: /* CIL Label */ ; switch_1_20480: /* CIL Label */ ; switch_1_4099: /* CIL Label */ s->server = 0; if ((unsigned long )cb != (unsigned long )((void *)0)) { } else { } if ((s->version & 65280) != 768) { ret = -1; goto end; } else { } s->type = 4096; if ((unsigned long )s->init_buf == (unsigned long )((void *)0)) { buf = __VERIFIER_nondet_pointer(); if ((unsigned long )buf == (unsigned long )((void *)0)) { ret = -1; goto end; } else { } if (! tmp___3) { ret = -1; goto end; } else { } s->init_buf = buf; } else { } if (! tmp___4) { ret = -1; goto end; } else { } if (! tmp___5) { ret = -1; goto end; } else { } s->state = 4368; (s->ctx)->stats.sess_connect += 1; s->init_num = 0; goto switch_1_break; switch_1_4368: /* CIL Label */ ; switch_1_4369: /* CIL Label */ s->shutdown = 0; ret = __VERIFIER_nondet_int(); if (blastFlag == 0) { blastFlag = 1; } else { } if (ret <= 0) { goto end; } else { } s->state = 4384; s->init_num = 0; if ((unsigned long )s->bbio != (unsigned long )s->wbio) { } else { } goto switch_1_break; switch_1_4384: /* CIL Label */ ; switch_1_4385: /* CIL Label */ ret = __VERIFIER_nondet_int(); if (blastFlag == 1) { blastFlag = 2; } else { if (blastFlag == 4) { blastFlag = 5; } else { } } if (ret <= 0) { goto end; } else { } if (s->hit) { s->state = 4560; } else { s->state = 4400; } s->init_num = 0; goto switch_1_break; switch_1_4400: /* CIL Label */ ; switch_1_4401: /* CIL Label */ ; if (((s->s3)->tmp.new_cipher)->algorithms & 256UL) { skip = 1; } else { ret = __VERIFIER_nondet_int(); if (blastFlag == 2) { blastFlag = 3; } else { } if (ret <= 0) { goto end; } else { } } s->state = 4416; s->init_num = 0; goto switch_1_break; switch_1_4416: /* CIL Label */ ; switch_1_4417: /* CIL Label */ ret = __VERIFIER_nondet_int(); if (blastFlag == 3) { blastFlag = 4; } else { } if (ret <= 0) { goto end; } else { } s->state = 4432; s->init_num = 0; if (! tmp___6) { ret = -1; goto end; } else { } goto switch_1_break; switch_1_4432: /* CIL Label */ ; switch_1_4433: /* CIL Label */ ret = __VERIFIER_nondet_int(); if (blastFlag == 5) { goto ERROR; } else { } if (ret <= 0) { goto end; } else { } s->state = 4448; s->init_num = 0; goto switch_1_break; switch_1_4448: /* CIL Label */ ; switch_1_4449: /* CIL Label */ ret = __VERIFIER_nondet_int(); if (ret <= 0) { goto end; } else { } if ((s->s3)->tmp.cert_req) { s->state = 4464; } else { s->state = 4480; } s->init_num = 0; goto switch_1_break; switch_1_4464: /* CIL Label */ ; switch_1_4465: /* CIL Label */ ; switch_1_4466: /* CIL Label */ ; switch_1_4467: /* CIL Label */ ret = __VERIFIER_nondet_int(); if (ret <= 0) { goto end; } else { } s->state = 4480; s->init_num = 0; goto switch_1_break; switch_1_4480: /* CIL Label */ ; switch_1_4481: /* CIL Label */ ret = __VERIFIER_nondet_int(); if (ret <= 0) { goto end; } else { } l = ((s->s3)->tmp.new_cipher)->algorithms; if ((s->s3)->tmp.cert_req == 1) { s->state = 4496; } else { s->state = 4512; (s->s3)->change_cipher_spec = 0; } s->init_num = 0; goto switch_1_break; switch_1_4496: /* CIL Label */ ; switch_1_4497: /* CIL Label */ ret = __VERIFIER_nondet_int(); if (ret <= 0) { goto end; } else { } s->state = 4512; s->init_num = 0; (s->s3)->change_cipher_spec = 0; goto switch_1_break; switch_1_4512: /* CIL Label */ ; switch_1_4513: /* CIL Label */ ret = __VERIFIER_nondet_int(); if (ret <= 0) { goto end; } else { } s->state = 4528; s->init_num = 0; (s->session)->cipher = (s->s3)->tmp.new_cipher; if ((unsigned long )(s->s3)->tmp.new_compression == (unsigned long )((void *)0)) { (s->session)->compress_meth = 0; } else { (s->session)->compress_meth = ((s->s3)->tmp.new_compression)->id; } if (! tmp___7) { ret = -1; goto end; } else { } if (! tmp___8) { ret = -1; goto end; } else { } goto switch_1_break; switch_1_4528: /* CIL Label */ ; switch_1_4529: /* CIL Label */ ret = __VERIFIER_nondet_int(); if (ret <= 0) { goto end; } else { } s->state = 4352; (s->s3)->flags &= -5L; if (s->hit) { (s->s3)->tmp.next_state = 3; if ((s->s3)->flags & 2L) { s->state = 3; (s->s3)->flags |= 4L; (s->s3)->delay_buf_pop_ret = 0; } else { } } else { (s->s3)->tmp.next_state = 4560; } s->init_num = 0; goto switch_1_break; switch_1_4560: /* CIL Label */ ; switch_1_4561: /* CIL Label */ ret = __VERIFIER_nondet_int(); if (ret <= 0) { goto end; } else { } if (s->hit) { s->state = 4512; } else { s->state = 3; } s->init_num = 0; goto switch_1_break; switch_1_4352: /* CIL Label */ if (num1 > 0L) { s->rwstate = 2; num1 = (long )((int )tmp___9); if (num1 <= 0L) { ret = -1; goto end; } else { } s->rwstate = 1; } else { } s->state = (s->s3)->tmp.next_state; goto switch_1_break; switch_1_3: /* CIL Label */ if ((unsigned long )s->init_buf != (unsigned long )((void *)0)) { s->init_buf = (BUF_MEM *)((void *)0); } else { } if (! ((s->s3)->flags & 4L)) { } else { } s->init_num = 0; s->new_session = 0; if (s->hit) { (s->ctx)->stats.sess_hit += 1; } else { } ret = 1; s->handshake_func = (int (*)())(& ssl3_connect); (s->ctx)->stats.sess_connect_good += 1; if ((unsigned long )cb != (unsigned long )((void *)0)) { } else { } goto end; switch_1_default: /* CIL Label */ ret = -1; goto end; } else { switch_1_break: /* CIL Label */ ; } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } if (! (s->s3)->tmp.reuse_message) { if (! skip) { if (s->debug) { ret = __VERIFIER_nondet_int(); if (ret <= 0) { goto end; } else { } } else { } if ((unsigned long )cb != (unsigned long )((void *)0)) { if (s->state != state) { new_state = s->state; s->state = state; s->state = new_state; } else { } } else { } } else { } } else { } skip = 0; } while_0_break: /* CIL Label */ ; } end: s->in_handshake -= 1; if ((unsigned long )cb != (unsigned long )((void *)0)) { } else { } return (ret); ERROR: __VERIFIER_error(); } }
the_stack_data/23574559.c
#include <stdio.h> // We could // // #include <lib.wasm.h> // // for the externs declared here manually, but including that currently // requires having wasm-rt.h in the include path, which may be annoying for // users - needs to be thought about. extern void wasmbox_init(void); extern int (*Z_do_bad_thingZ_ii)(int); extern int (*Z_twiceZ_ii)(int); int main() { puts("Initializing sandboxed unsafe library"); wasmbox_init(); printf("Calling twice on 21 returns %d\n", Z_twiceZ_ii(21)); puts("Calling something bad now..."); int num = Z_do_bad_thingZ_ii(1); printf("The sandbox should not have been able to print anything.\n" "It claims it printed %d chars but the test proves it didn't!\n", num); }
the_stack_data/167330806.c
/* You are conducting a contest at your college. This contest consists of two problems and participants. You know the problem that a candidate will solve during the contest. You provide a balloon to a participant after he or she solves a problem. There are only green and purple-colored balloons available in a market. Each problem must have a balloon associated with it as a prize for solving that specific problem. You can distribute balloons to each participant by performing the following operation: 1. Use green-colored balloons for the first problem and purple-colored balloons for the second problem 2. Use purple-colored balloons for the first problem and green-colored balloons for the second problem You are given the cost of each balloon and problems that each participant solve. Your task is to print the minimum price that you have to pay while purchasing balloons. Input format First line: T that denotes the number of test cases (1 \le T \le 10) For each test case: First line: Cost of green and purple-colored balloons Second line: that denotes the number of participants (1 \le n \le 10) Next lines: Contain the status of users. For example, if the value of the jth integer in the ith row is 0, then it depicts that the ith participant has not solved the jth problem. Similarly, if the value of the jth integer in the ith row is 1, then it depicts that the ith participant has solved the jth problem. Output format For each test case, print the minimum cost that you have to pay to purchase balloons. */ #include <stdio.h> int main() { int T; scanf("%d", &T); int g, p, n, t1, t2, c1, c2; for (int i = 0; i < T; i++) { scanf("%d %d %d", &g, &p, &n); int s1 = 0, s2 = 0; for (int i = 0; i < n; i++) { scanf("%d %d", &t1, &t2); s1 += t1; s2 += t2; } c1 = s1 * g + s2 * p; c2 = s1 * p + s2 * g; printf("%d\n", c1 < c2 ? c1 : c2); } return 0; }
the_stack_data/551688.c
/* f2c.h -- Standard Fortran to C header file */ /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ #ifndef F2C_INCLUDE #define F2C_INCLUDE #include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimag(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static complex c_b1 = {0.f,0.f}; static complex c_b2 = {1.f,0.f}; static integer c__1 = 1; static integer c__0 = 0; static integer c_n1 = -1; /* > \brief <b> CGGES computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors f or GE matrices</b> */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download CGGES + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgges.f "> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgges.f "> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgges.f "> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE CGGES( JOBVSL, JOBVSR, SORT, SELCTG, N, A, LDA, B, LDB, */ /* SDIM, ALPHA, BETA, VSL, LDVSL, VSR, LDVSR, WORK, */ /* LWORK, RWORK, BWORK, INFO ) */ /* CHARACTER JOBVSL, JOBVSR, SORT */ /* INTEGER INFO, LDA, LDB, LDVSL, LDVSR, LWORK, N, SDIM */ /* LOGICAL BWORK( * ) */ /* REAL RWORK( * ) */ /* COMPLEX A( LDA, * ), ALPHA( * ), B( LDB, * ), */ /* $ BETA( * ), VSL( LDVSL, * ), VSR( LDVSR, * ), */ /* $ WORK( * ) */ /* LOGICAL SELCTG */ /* EXTERNAL SELCTG */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > CGGES computes for a pair of N-by-N complex nonsymmetric matrices */ /* > (A,B), the generalized eigenvalues, the generalized complex Schur */ /* > form (S, T), and optionally left and/or right Schur vectors (VSL */ /* > and VSR). This gives the generalized Schur factorization */ /* > */ /* > (A,B) = ( (VSL)*S*(VSR)**H, (VSL)*T*(VSR)**H ) */ /* > */ /* > where (VSR)**H is the conjugate-transpose of VSR. */ /* > */ /* > Optionally, it also orders the eigenvalues so that a selected cluster */ /* > of eigenvalues appears in the leading diagonal blocks of the upper */ /* > triangular matrix S and the upper triangular matrix T. The leading */ /* > columns of VSL and VSR then form an unitary basis for the */ /* > corresponding left and right eigenspaces (deflating subspaces). */ /* > */ /* > (If only the generalized eigenvalues are needed, use the driver */ /* > CGGEV instead, which is faster.) */ /* > */ /* > A generalized eigenvalue for a pair of matrices (A,B) is a scalar w */ /* > or a ratio alpha/beta = w, such that A - w*B is singular. It is */ /* > usually represented as the pair (alpha,beta), as there is a */ /* > reasonable interpretation for beta=0, and even for both being zero. */ /* > */ /* > A pair of matrices (S,T) is in generalized complex Schur form if S */ /* > and T are upper triangular and, in addition, the diagonal elements */ /* > of T are non-negative real numbers. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] JOBVSL */ /* > \verbatim */ /* > JOBVSL is CHARACTER*1 */ /* > = 'N': do not compute the left Schur vectors; */ /* > = 'V': compute the left Schur vectors. */ /* > \endverbatim */ /* > */ /* > \param[in] JOBVSR */ /* > \verbatim */ /* > JOBVSR is CHARACTER*1 */ /* > = 'N': do not compute the right Schur vectors; */ /* > = 'V': compute the right Schur vectors. */ /* > \endverbatim */ /* > */ /* > \param[in] SORT */ /* > \verbatim */ /* > SORT is CHARACTER*1 */ /* > Specifies whether or not to order the eigenvalues on the */ /* > diagonal of the generalized Schur form. */ /* > = 'N': Eigenvalues are not ordered; */ /* > = 'S': Eigenvalues are ordered (see SELCTG). */ /* > \endverbatim */ /* > */ /* > \param[in] SELCTG */ /* > \verbatim */ /* > SELCTG is a LOGICAL FUNCTION of two COMPLEX arguments */ /* > SELCTG must be declared EXTERNAL in the calling subroutine. */ /* > If SORT = 'N', SELCTG is not referenced. */ /* > If SORT = 'S', SELCTG is used to select eigenvalues to sort */ /* > to the top left of the Schur form. */ /* > An eigenvalue ALPHA(j)/BETA(j) is selected if */ /* > SELCTG(ALPHA(j),BETA(j)) is true. */ /* > */ /* > Note that a selected complex eigenvalue may no longer satisfy */ /* > SELCTG(ALPHA(j),BETA(j)) = .TRUE. after ordering, since */ /* > ordering may change the value of complex eigenvalues */ /* > (especially if the eigenvalue is ill-conditioned), in this */ /* > case INFO is set to N+2 (See INFO below). */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The order of the matrices A, B, VSL, and VSR. N >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in,out] A */ /* > \verbatim */ /* > A is COMPLEX array, dimension (LDA, N) */ /* > On entry, the first of the pair of matrices. */ /* > On exit, A has been overwritten by its generalized Schur */ /* > form S. */ /* > \endverbatim */ /* > */ /* > \param[in] LDA */ /* > \verbatim */ /* > LDA is INTEGER */ /* > The leading dimension of A. LDA >= f2cmax(1,N). */ /* > \endverbatim */ /* > */ /* > \param[in,out] B */ /* > \verbatim */ /* > B is COMPLEX array, dimension (LDB, N) */ /* > On entry, the second of the pair of matrices. */ /* > On exit, B has been overwritten by its generalized Schur */ /* > form T. */ /* > \endverbatim */ /* > */ /* > \param[in] LDB */ /* > \verbatim */ /* > LDB is INTEGER */ /* > The leading dimension of B. LDB >= f2cmax(1,N). */ /* > \endverbatim */ /* > */ /* > \param[out] SDIM */ /* > \verbatim */ /* > SDIM is INTEGER */ /* > If SORT = 'N', SDIM = 0. */ /* > If SORT = 'S', SDIM = number of eigenvalues (after sorting) */ /* > for which SELCTG is true. */ /* > \endverbatim */ /* > */ /* > \param[out] ALPHA */ /* > \verbatim */ /* > ALPHA is COMPLEX array, dimension (N) */ /* > \endverbatim */ /* > */ /* > \param[out] BETA */ /* > \verbatim */ /* > BETA is COMPLEX array, dimension (N) */ /* > On exit, ALPHA(j)/BETA(j), j=1,...,N, will be the */ /* > generalized eigenvalues. ALPHA(j), j=1,...,N and BETA(j), */ /* > j=1,...,N are the diagonals of the complex Schur form (A,B) */ /* > output by CGGES. The BETA(j) will be non-negative real. */ /* > */ /* > Note: the quotients ALPHA(j)/BETA(j) may easily over- or */ /* > underflow, and BETA(j) may even be zero. Thus, the user */ /* > should avoid naively computing the ratio alpha/beta. */ /* > However, ALPHA will be always less than and usually */ /* > comparable with norm(A) in magnitude, and BETA always less */ /* > than and usually comparable with norm(B). */ /* > \endverbatim */ /* > */ /* > \param[out] VSL */ /* > \verbatim */ /* > VSL is COMPLEX array, dimension (LDVSL,N) */ /* > If JOBVSL = 'V', VSL will contain the left Schur vectors. */ /* > Not referenced if JOBVSL = 'N'. */ /* > \endverbatim */ /* > */ /* > \param[in] LDVSL */ /* > \verbatim */ /* > LDVSL is INTEGER */ /* > The leading dimension of the matrix VSL. LDVSL >= 1, and */ /* > if JOBVSL = 'V', LDVSL >= N. */ /* > \endverbatim */ /* > */ /* > \param[out] VSR */ /* > \verbatim */ /* > VSR is COMPLEX array, dimension (LDVSR,N) */ /* > If JOBVSR = 'V', VSR will contain the right Schur vectors. */ /* > Not referenced if JOBVSR = 'N'. */ /* > \endverbatim */ /* > */ /* > \param[in] LDVSR */ /* > \verbatim */ /* > LDVSR is INTEGER */ /* > The leading dimension of the matrix VSR. LDVSR >= 1, and */ /* > if JOBVSR = 'V', LDVSR >= N. */ /* > \endverbatim */ /* > */ /* > \param[out] WORK */ /* > \verbatim */ /* > WORK is COMPLEX array, dimension (MAX(1,LWORK)) */ /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ /* > \endverbatim */ /* > */ /* > \param[in] LWORK */ /* > \verbatim */ /* > LWORK is INTEGER */ /* > The dimension of the array WORK. LWORK >= f2cmax(1,2*N). */ /* > For good performance, LWORK must generally be larger. */ /* > */ /* > If LWORK = -1, then a workspace query is assumed; the routine */ /* > only calculates the optimal size of the WORK array, returns */ /* > this value as the first entry of the WORK array, and no error */ /* > message related to LWORK is issued by XERBLA. */ /* > \endverbatim */ /* > */ /* > \param[out] RWORK */ /* > \verbatim */ /* > RWORK is REAL array, dimension (8*N) */ /* > \endverbatim */ /* > */ /* > \param[out] BWORK */ /* > \verbatim */ /* > BWORK is LOGICAL array, dimension (N) */ /* > Not referenced if SORT = 'N'. */ /* > \endverbatim */ /* > */ /* > \param[out] INFO */ /* > \verbatim */ /* > INFO is INTEGER */ /* > = 0: successful exit */ /* > < 0: if INFO = -i, the i-th argument had an illegal value. */ /* > =1,...,N: */ /* > The QZ iteration failed. (A,B) are not in Schur */ /* > form, but ALPHA(j) and BETA(j) should be correct for */ /* > j=INFO+1,...,N. */ /* > > N: =N+1: other than QZ iteration failed in CHGEQZ */ /* > =N+2: after reordering, roundoff changed values of */ /* > some complex eigenvalues so that leading */ /* > eigenvalues in the Generalized Schur form no */ /* > longer satisfy SELCTG=.TRUE. This could also */ /* > be caused due to scaling. */ /* > =N+3: reordering failed in CTGSEN. */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date December 2016 */ /* > \ingroup complexGEeigen */ /* ===================================================================== */ /* Subroutine */ int cgges_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, integer *n, complex *a, integer *lda, complex *b, integer * ldb, integer *sdim, complex *alpha, complex *beta, complex *vsl, integer *ldvsl, complex *vsr, integer *ldvsr, complex *work, integer * lwork, real *rwork, logical *bwork, integer *info) { /* System generated locals */ integer a_dim1, a_offset, b_dim1, b_offset, vsl_dim1, vsl_offset, vsr_dim1, vsr_offset, i__1, i__2; /* Local variables */ real anrm, bnrm; integer idum[1], ierr, itau, iwrk; real pvsl, pvsr; integer i__; extern logical lsame_(char *, char *); integer ileft, icols; logical cursl, ilvsl, ilvsr; integer irwrk, irows; extern /* Subroutine */ int cggbak_(char *, char *, integer *, integer *, integer *, real *, real *, integer *, complex *, integer *, integer *), cggbal_(char *, integer *, complex *, integer *, complex *, integer *, integer *, integer *, real *, real *, real *, integer *), slabad_(real *, real *); extern real clange_(char *, integer *, integer *, complex *, integer *, real *); extern /* Subroutine */ int cgghrd_(char *, char *, integer *, integer *, integer *, complex *, integer *, complex *, integer *, complex *, integer *, complex *, integer *, integer *), clascl_(char *, integer *, integer *, real *, real *, integer *, integer *, complex *, integer *, integer *); logical ilascl, ilbscl; extern /* Subroutine */ int cgeqrf_(integer *, integer *, complex *, integer *, complex *, complex *, integer *, integer *); extern real slamch_(char *); extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex *, integer *, complex *, integer *), claset_(char *, integer *, integer *, complex *, complex *, complex *, integer *), xerbla_(char *, integer *, ftnlen); extern integer ilaenv_(integer *, char *, char *, integer *, integer *, integer *, integer *, ftnlen, ftnlen); real bignum; extern /* Subroutine */ int chgeqz_(char *, char *, char *, integer *, integer *, integer *, complex *, integer *, complex *, integer *, complex *, complex *, complex *, integer *, complex *, integer *, complex *, integer *, real *, integer *), ctgsen_(integer *, logical *, logical *, logical *, integer *, complex *, integer *, complex *, integer *, complex *, complex *, complex *, integer *, complex *, integer *, integer *, real *, real *, real *, complex *, integer *, integer *, integer *, integer *); integer ijobvl, iright, ijobvr; real anrmto; integer lwkmin; logical lastsl; real bnrmto; extern /* Subroutine */ int cungqr_(integer *, integer *, integer *, complex *, integer *, complex *, complex *, integer *, integer *), cunmqr_(char *, char *, integer *, integer *, integer *, complex *, integer *, complex *, complex *, integer *, complex *, integer *, integer *); real smlnum; logical wantst, lquery; integer lwkopt; real dif[2]; integer ihi, ilo; real eps; /* -- LAPACK driver routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* December 2016 */ /* ===================================================================== */ /* Decode the input arguments */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; b_dim1 = *ldb; b_offset = 1 + b_dim1 * 1; b -= b_offset; --alpha; --beta; vsl_dim1 = *ldvsl; vsl_offset = 1 + vsl_dim1 * 1; vsl -= vsl_offset; vsr_dim1 = *ldvsr; vsr_offset = 1 + vsr_dim1 * 1; vsr -= vsr_offset; --work; --rwork; --bwork; /* Function Body */ if (lsame_(jobvsl, "N")) { ijobvl = 1; ilvsl = FALSE_; } else if (lsame_(jobvsl, "V")) { ijobvl = 2; ilvsl = TRUE_; } else { ijobvl = -1; ilvsl = FALSE_; } if (lsame_(jobvsr, "N")) { ijobvr = 1; ilvsr = FALSE_; } else if (lsame_(jobvsr, "V")) { ijobvr = 2; ilvsr = TRUE_; } else { ijobvr = -1; ilvsr = FALSE_; } wantst = lsame_(sort, "S"); /* Test the input arguments */ *info = 0; lquery = *lwork == -1; if (ijobvl <= 0) { *info = -1; } else if (ijobvr <= 0) { *info = -2; } else if (! wantst && ! lsame_(sort, "N")) { *info = -3; } else if (*n < 0) { *info = -5; } else if (*lda < f2cmax(1,*n)) { *info = -7; } else if (*ldb < f2cmax(1,*n)) { *info = -9; } else if (*ldvsl < 1 || ilvsl && *ldvsl < *n) { *info = -14; } else if (*ldvsr < 1 || ilvsr && *ldvsr < *n) { *info = -16; } /* Compute workspace */ /* (Note: Comments in the code beginning "Workspace:" describe the */ /* minimal amount of workspace needed at that point in the code, */ /* as well as the preferred amount for good performance. */ /* NB refers to the optimal block size for the immediately */ /* following subroutine, as returned by ILAENV.) */ if (*info == 0) { /* Computing MAX */ i__1 = 1, i__2 = *n << 1; lwkmin = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = 1, i__2 = *n + *n * ilaenv_(&c__1, "CGEQRF", " ", n, &c__1, n, &c__0, (ftnlen)6, (ftnlen)1); lwkopt = f2cmax(i__1,i__2); /* Computing MAX */ i__1 = lwkopt, i__2 = *n + *n * ilaenv_(&c__1, "CUNMQR", " ", n, & c__1, n, &c_n1, (ftnlen)6, (ftnlen)1); lwkopt = f2cmax(i__1,i__2); if (ilvsl) { /* Computing MAX */ i__1 = lwkopt, i__2 = *n + *n * ilaenv_(&c__1, "CUNGQR", " ", n, & c__1, n, &c_n1, (ftnlen)6, (ftnlen)1); lwkopt = f2cmax(i__1,i__2); } work[1].r = (real) lwkopt, work[1].i = 0.f; if (*lwork < lwkmin && ! lquery) { *info = -18; } } if (*info != 0) { i__1 = -(*info); xerbla_("CGGES ", &i__1, (ftnlen)6); return 0; } else if (lquery) { return 0; } /* Quick return if possible */ if (*n == 0) { *sdim = 0; return 0; } /* Get machine constants */ eps = slamch_("P"); smlnum = slamch_("S"); bignum = 1.f / smlnum; slabad_(&smlnum, &bignum); smlnum = sqrt(smlnum) / eps; bignum = 1.f / smlnum; /* Scale A if f2cmax element outside range [SMLNUM,BIGNUM] */ anrm = clange_("M", n, n, &a[a_offset], lda, &rwork[1]); ilascl = FALSE_; if (anrm > 0.f && anrm < smlnum) { anrmto = smlnum; ilascl = TRUE_; } else if (anrm > bignum) { anrmto = bignum; ilascl = TRUE_; } if (ilascl) { clascl_("G", &c__0, &c__0, &anrm, &anrmto, n, n, &a[a_offset], lda, & ierr); } /* Scale B if f2cmax element outside range [SMLNUM,BIGNUM] */ bnrm = clange_("M", n, n, &b[b_offset], ldb, &rwork[1]); ilbscl = FALSE_; if (bnrm > 0.f && bnrm < smlnum) { bnrmto = smlnum; ilbscl = TRUE_; } else if (bnrm > bignum) { bnrmto = bignum; ilbscl = TRUE_; } if (ilbscl) { clascl_("G", &c__0, &c__0, &bnrm, &bnrmto, n, n, &b[b_offset], ldb, & ierr); } /* Permute the matrix to make it more nearly triangular */ /* (Real Workspace: need 6*N) */ ileft = 1; iright = *n + 1; irwrk = iright + *n; cggbal_("P", n, &a[a_offset], lda, &b[b_offset], ldb, &ilo, &ihi, &rwork[ ileft], &rwork[iright], &rwork[irwrk], &ierr); /* Reduce B to triangular form (QR decomposition of B) */ /* (Complex Workspace: need N, prefer N*NB) */ irows = ihi + 1 - ilo; icols = *n + 1 - ilo; itau = 1; iwrk = itau + irows; i__1 = *lwork + 1 - iwrk; cgeqrf_(&irows, &icols, &b[ilo + ilo * b_dim1], ldb, &work[itau], &work[ iwrk], &i__1, &ierr); /* Apply the orthogonal transformation to matrix A */ /* (Complex Workspace: need N, prefer N*NB) */ i__1 = *lwork + 1 - iwrk; cunmqr_("L", "C", &irows, &icols, &irows, &b[ilo + ilo * b_dim1], ldb, & work[itau], &a[ilo + ilo * a_dim1], lda, &work[iwrk], &i__1, & ierr); /* Initialize VSL */ /* (Complex Workspace: need N, prefer N*NB) */ if (ilvsl) { claset_("Full", n, n, &c_b1, &c_b2, &vsl[vsl_offset], ldvsl); if (irows > 1) { i__1 = irows - 1; i__2 = irows - 1; clacpy_("L", &i__1, &i__2, &b[ilo + 1 + ilo * b_dim1], ldb, &vsl[ ilo + 1 + ilo * vsl_dim1], ldvsl); } i__1 = *lwork + 1 - iwrk; cungqr_(&irows, &irows, &irows, &vsl[ilo + ilo * vsl_dim1], ldvsl, & work[itau], &work[iwrk], &i__1, &ierr); } /* Initialize VSR */ if (ilvsr) { claset_("Full", n, n, &c_b1, &c_b2, &vsr[vsr_offset], ldvsr); } /* Reduce to generalized Hessenberg form */ /* (Workspace: none needed) */ cgghrd_(jobvsl, jobvsr, n, &ilo, &ihi, &a[a_offset], lda, &b[b_offset], ldb, &vsl[vsl_offset], ldvsl, &vsr[vsr_offset], ldvsr, &ierr); *sdim = 0; /* Perform QZ algorithm, computing Schur vectors if desired */ /* (Complex Workspace: need N) */ /* (Real Workspace: need N) */ iwrk = itau; i__1 = *lwork + 1 - iwrk; chgeqz_("S", jobvsl, jobvsr, n, &ilo, &ihi, &a[a_offset], lda, &b[ b_offset], ldb, &alpha[1], &beta[1], &vsl[vsl_offset], ldvsl, & vsr[vsr_offset], ldvsr, &work[iwrk], &i__1, &rwork[irwrk], &ierr); if (ierr != 0) { if (ierr > 0 && ierr <= *n) { *info = ierr; } else if (ierr > *n && ierr <= *n << 1) { *info = ierr - *n; } else { *info = *n + 1; } goto L30; } /* Sort eigenvalues ALPHA/BETA if desired */ /* (Workspace: none needed) */ if (wantst) { /* Undo scaling on eigenvalues before selecting */ if (ilascl) { clascl_("G", &c__0, &c__0, &anrm, &anrmto, n, &c__1, &alpha[1], n, &ierr); } if (ilbscl) { clascl_("G", &c__0, &c__0, &bnrm, &bnrmto, n, &c__1, &beta[1], n, &ierr); } /* Select eigenvalues */ i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { bwork[i__] = (*selctg)(&alpha[i__], &beta[i__]); /* L10: */ } i__1 = *lwork - iwrk + 1; ctgsen_(&c__0, &ilvsl, &ilvsr, &bwork[1], n, &a[a_offset], lda, &b[ b_offset], ldb, &alpha[1], &beta[1], &vsl[vsl_offset], ldvsl, &vsr[vsr_offset], ldvsr, sdim, &pvsl, &pvsr, dif, &work[iwrk], &i__1, idum, &c__1, &ierr); if (ierr == 1) { *info = *n + 3; } } /* Apply back-permutation to VSL and VSR */ /* (Workspace: none needed) */ if (ilvsl) { cggbak_("P", "L", n, &ilo, &ihi, &rwork[ileft], &rwork[iright], n, & vsl[vsl_offset], ldvsl, &ierr); } if (ilvsr) { cggbak_("P", "R", n, &ilo, &ihi, &rwork[ileft], &rwork[iright], n, & vsr[vsr_offset], ldvsr, &ierr); } /* Undo scaling */ if (ilascl) { clascl_("U", &c__0, &c__0, &anrmto, &anrm, n, n, &a[a_offset], lda, & ierr); clascl_("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alpha[1], n, & ierr); } if (ilbscl) { clascl_("U", &c__0, &c__0, &bnrmto, &bnrm, n, n, &b[b_offset], ldb, & ierr); clascl_("G", &c__0, &c__0, &bnrmto, &bnrm, n, &c__1, &beta[1], n, & ierr); } if (wantst) { /* Check if reordering is correct */ lastsl = TRUE_; *sdim = 0; i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { cursl = (*selctg)(&alpha[i__], &beta[i__]); if (cursl) { ++(*sdim); } if (cursl && ! lastsl) { *info = *n + 2; } lastsl = cursl; /* L20: */ } } L30: work[1].r = (real) lwkopt, work[1].i = 0.f; return 0; /* End of CGGES */ } /* cgges_ */
the_stack_data/109160.c
void _ps2_setvbuf(int fd, char *buf, int mode, int whatever) { }
the_stack_data/26397.c
#include <semaphore.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> static void delay (int); int main (void) { int pid; sem_t exclusion; if (sem_init (&exclusion, 1, 1) < 0) { perror ("sem_init"); exit (1); } setbuf (stdout, NULL); if ((pid = fork ()) != 0) { for (int i = 0; i < 5; i++) { sem_wait (&exclusion); for (int j = 0; j < 26; j++) putchar ('a' + j); putchar ('\n'); sem_post (&exclusion); delay (100000); } } else { for (int i = 0; i < 5; i++) { sem_wait (&exclusion); for (int j = 0; j < 26; j++) putchar ('A' + j); putchar ('\n'); sem_post (&exclusion); delay (100000); } } sem_destroy (&exclusion); return 0; } static void delay (int max) { for (int i = 0; i < max; i++) /* waste time */ ; }
the_stack_data/175143896.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> /* 子线程1入口函数 */ void *thread_routine1(void *arg) { fprintf(stdout, "thread1: hello world!\n"); sleep(1); /* 子线程在此退出 */ return NULL; } /* 子线程2入口函数 */ void *thread_routine2(void *arg) { fprintf(stdout, "thread2: I'm running...\n"); pthread_t main_thread_id = *(pthread_t *)arg; /* 分离自我,不能再被连接 */ pthread_detach(pthread_self()); /* 判断主线程ID与子线程2 ID是否相等 */ if (!pthread_equal(main_thread_id, pthread_self())) { fprintf(stdout, "thread2: main thread id is not equal ethread2!\n"); } /* 等待主线程终止 */ pthread_join(main_thread_id, NULL); fprintf(stdout, "thread2: main thread exit!\n"); fprintf(stdout, "thread2: exit!\n"); fprintf(stdout, "thread2: process exit!\n"); /* 子线程2在此终止,进程退出 */ pthread_exit(NULL); } int main(int argc, char const *argv[]) { /* 创建子线程1 */ pthread_t tid1; if (pthread_create(&tid1, NULL, thread_routine1, NULL) != 0) { fprintf(stderr, "create thread fail.\n"); exit(-1); } /* 等待子线程1终止 */ pthread_join(tid1, NULL); fprintf(stdout, "main thread: thread1 terminated!\n"); /* 创建子线程 2 */ pthread_t tid2; if (pthread_create(&tid2, NULL, thread_routine2, (void*)pthread_self()) != 0) { fprintf(stderr, "create thread fail.\n"); exit(-1); } fprintf(stdout, "main thread: sleeping...\n"); sleep(3); /* 主线程使用 pthread_exit 函数终止,进程继续存在 */ fprintf(stdout, "main thread: exit!\n"); pthread_exit(NULL); fprintf(stdout, "main thread: never reach here!\n"); return 0; }
the_stack_data/875876.c
#include <stdlib.h> #include <string.h> #include <math.h> /* Q[valid] = [-1, 1] Q[invalid] = -inf U = Q + c_put * Policy * (sqrt(sum(N) / (N + 1)) */ double* uct(double* Q, int* N, double cput, unsigned int size) { double* U = (double*) malloc(sizeof(double) * size); memcpy(U, Q, sizeof(double) * size); int i; double logsumN = 0; for (i = 0; i < size; i++) logsumN += N[i]; logsumN = log(logsumN); for (i = 0; i < size; i++) { if (N[i] == 0) U[i] += cput; // to balance exploitation & exploration else U[i] += cput * sqrt(logsumN / (double) N[i]); } return U; }
the_stack_data/237643891.c
/* PGI Fortran wants mymodule_ when calling any mymodule symbol. */ void mymodule_(void) {}
the_stack_data/86074117.c
int test257(){int x = 86;int *y = &x; return (*y) + (*y) + 2;}
the_stack_data/173577644.c
int main() { return 0; }
the_stack_data/25137085.c
#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> #define BUFSIZE 1024 #define FILE_PERMS (S_IRUSR | S_IWUSR| S_IRGRP | S_IROTH) #define FILE_FLAGS (O_WRONLY | O_CREAT | O_TRUNC) int main (int argc, char *argv[]) { char buf[BUFSIZE]; pid_t childpid = 0; int fd; int i, n; if (argc != 3){ /* check for valid number of command-line arguments */ fprintf (stderr, "Usage: %s processes filename\n", argv[0]); return 1; } /* Create a process chain */ n = atoi(argv[1]); for (i = 1; i < n; ++i) if (childpid = fork()) break; if (childpid == -1) { perror("The fork failed"); return 1; } /* Open the log file after the fork */ fd = open(argv[2], FILE_FLAGS, FILE_PERMS); if (fd < 0) { perror("Open failed"); return 1; } /* Write twice to the common log file */ sprintf(buf, "i:%d process:%ld ", i, (long)getpid()); write(fd, buf, strlen(buf)); sprintf(buf,"parent:%ld child:%ld\n", (long)getppid(), (long)childpid); write(fd, buf, strlen(buf)); return 0; }
the_stack_data/321970.c
/* * * Copyright 2015 gRPC authors. * * 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. * */
the_stack_data/933507.c
/* * libc/stdio/snprintf.c */ #include <stdio.h> int snprintf(char * buf, size_t n, const char * fmt, ...) { va_list ap; int rv; va_start(ap, fmt); rv = vsnprintf(buf, n, fmt, ap); va_end(ap); return rv; } EXPORT_SYMBOL(snprintf);
the_stack_data/111078912.c
/* * $ Copyright Broadcom Corporation $ */ #include <stdint.h> const char brcm_patch_version[] = "BCM4343A1_001.002.009.0083.0000_Generic_UART_37_4MHz_wlbga_wiced"; const uint8_t brcm_patchram_format = 0x01; const unsigned char brcm_patchram_buf[] = { /* Configuration Data Records (Write_RAM) */ 0x4C, 0xFC, 0x46, 0x10, 0x18, 0x21, 0x00, 0x42, 0x52, 0x43, 0x4D, 0x63, 0x66, 0x67, 0x53, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x01, 0x01, 0x04, 0x18, 0x92, 0x00, 0x00, 0x00, 0x03, 0x06, 0xAC, 0x1F, 0x12, 0xA1, 0x43, 0x43, 0x00, 0x01, 0x1C, 0x52, 0x18, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x4C, 0xFC, 0xFF, 0x52, 0x18, 0x21, 0x00, 0x42, 0x52, 0x43, 0x4D, 0x63, 0x66, 0x67, 0x44, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x85, 0x00, 0x00, 0x03, 0x03, 0x28, 0x42, 0x43, 0x4D, 0x34, 0x33, 0x34, 0x33, 0x41, 0x31, 0x20, 0x55, 0x41, 0x52, 0x54, 0x20, 0x33, 0x37, 0x2E, 0x34, 0x20, 0x4D, 0x48, 0x7A, 0x20, 0x77, 0x6C, 0x62, 0x67, 0x61, 0x5F, 0x72, 0x65, 0x66, 0x20, 0x77, 0x69, 0x63, 0x65, 0x64, 0x00, 0x16, 0x03, 0x02, 0x53, 0x00, 0x02, 0x01, 0xF8, 0x03, 0x08, 0x01, 0x32, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0xFF, 0x0F, 0x00, 0x00, 0x62, 0x08, 0x00, 0x00, 0x70, 0x00, 0x64, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xAC, 0x00, 0x32, 0x00, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x2F, 0x00, 0x8C, 0x00, 0x32, 0x00, 0x00, 0xF0, 0xFF, 0x0F, 0x00, 0x10, 0x11, 0x01, 0x78, 0x00, 0x32, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xB9, 0xB8, 0xB8, 0xB8, 0x60, 0x2C, 0x20, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x32, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x18, 0x18, 0x6C, 0x01, 0x60, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x0B, 0x00, 0x00, 0x00, 0x70, 0x01, 0x60, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x00, 0x00, 0x00, 0x74, 0x01, 0x60, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x15, 0x00, 0x00, 0x00, 0x78, 0x01, 0x60, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x19, 0x00, 0x00, 0x00, 0x7C, 0x01, 0x60, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x84, 0x01, 0x60, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x21, 0x00, 0x00, 0x00, 0x60, 0x06, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x33, 0x03, 0x00, 0x00, 0x64, 0x06, 0x41, 0x4C, 0xFC, 0xFF, 0x4D, 0x19, 0x21, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x29, 0x3A, 0x00, 0x00, 0x64, 0x06, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x29, 0x3A, 0x00, 0x00, 0x68, 0x06, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x68, 0x05, 0x00, 0x00, 0x6C, 0x06, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xA8, 0x30, 0x00, 0x00, 0x70, 0x06, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xE8, 0x3E, 0x00, 0x00, 0x74, 0x06, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x1C, 0x32, 0x00, 0x00, 0x78, 0x06, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xBB, 0x33, 0x00, 0x00, 0x7C, 0x06, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x30, 0x09, 0x00, 0x00, 0x50, 0x03, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x10, 0x05, 0x00, 0x00, 0x54, 0x03, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x09, 0x09, 0x00, 0x00, 0x5C, 0x03, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x09, 0x08, 0x00, 0x00, 0x60, 0x03, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x0F, 0x07, 0x00, 0x00, 0x64, 0x03, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x05, 0x08, 0x00, 0x00, 0x6C, 0x03, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x0E, 0x09, 0x00, 0x00, 0x74, 0x03, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x05, 0x09, 0x00, 0x00, 0x78, 0x03, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x10, 0x0A, 0x00, 0x00, 0x40, 0x01, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x10, 0x05, 0x00, 0x00, 0x44, 0x01, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x09, 0x09, 0x00, 0x00, 0x4C, 0x01, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x09, 0x08, 0x00, 0x00, 0x50, 0x01, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x0F, 0x07, 0x00, 0x00, 0x54, 0x01, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x05, 0x08, 0x00, 0x00, 0x5C, 0x01, 0x4C, 0xFC, 0xFF, 0x48, 0x1A, 0x21, 0x00, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x0E, 0x09, 0x00, 0x00, 0x60, 0x01, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x05, 0x09, 0x00, 0x00, 0x64, 0x01, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x10, 0x0A, 0x00, 0x00, 0xE0, 0x06, 0x41, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, 0x9C, 0x01, 0x60, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x64, 0x01, 0x60, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x09, 0x01, 0x04, 0x02, 0x01, 0x00, 0x00, 0x22, 0x03, 0x02, 0x01, 0x00, 0xF0, 0x01, 0x28, 0x04, 0x00, 0x00, 0x00, 0x20, 0x15, 0x32, 0x00, 0xFF, 0xFF, 0xFA, 0xFF, 0xD9, 0x03, 0x3E, 0xFE, 0x28, 0x15, 0x32, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x34, 0x10, 0x28, 0x02, 0x2C, 0x09, 0x64, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0xF0, 0x01, 0x28, 0x01, 0x00, 0x00, 0x00, 0x20, 0x15, 0x32, 0x00, 0xFF, 0xFF, 0xFA, 0xFF, 0xDD, 0x03, 0x3E, 0xFE, 0x28, 0x15, 0x32, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x34, 0x10, 0x28, 0x02, 0x2C, 0x09, 0x64, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0xF0, 0x01, 0x28, 0x02, 0x00, 0x00, 0x00, 0x20, 0x15, 0x32, 0x00, 0xFF, 0xFF, 0xFA, 0xFF, 0xD9, 0x03, 0x3E, 0xFE, 0x28, 0x15, 0x32, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x34, 0x10, 0x28, 0x02, 0x2C, 0x09, 0x64, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0xF0, 0x01, 0xA0, 0x01, 0x03, 0x00, 0x00, 0x00, 0x10, 0x15, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0x00, 0x14, 0x15, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0x00, 0x18, 0x15, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0xFC, 0xFF, 0x43, 0x1B, 0x21, 0x00, 0xF0, 0xF0, 0xF0, 0x00, 0x1C, 0x15, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x4C, 0x00, 0x00, 0x20, 0x15, 0x32, 0x00, 0xFF, 0xFF, 0xFA, 0xFF, 0xDD, 0x03, 0x3E, 0xFE, 0x24, 0x15, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x15, 0x32, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x34, 0x10, 0x28, 0x02, 0x34, 0x15, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x38, 0x15, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x15, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCA, 0x06, 0x00, 0x00, 0x2C, 0x09, 0x64, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x64, 0x00, 0x51, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x78, 0x08, 0x64, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0xB5, 0x03, 0x04, 0x06, 0x0A, 0x23, 0x3C, 0x5A, 0x6E, 0x7D, 0x05, 0x38, 0x04, 0x88, 0x04, 0x9C, 0x04, 0x88, 0x04, 0xD8, 0x04, 0x74, 0x04, 0xC4, 0x04, 0xD8, 0x04, 0xC4, 0x04, 0x14, 0x05, 0xB0, 0x04, 0x00, 0x05, 0x14, 0x05, 0x00, 0x05, 0x50, 0x05, 0xF6, 0x04, 0x46, 0x05, 0x5A, 0x05, 0x46, 0x05, 0x96, 0x05, 0x3C, 0x05, 0x8C, 0x05, 0xA0, 0x05, 0x8C, 0x05, 0xDC, 0x05, 0x82, 0x05, 0xD2, 0x05, 0xE6, 0x05, 0xD2, 0x05, 0x22, 0x06, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0xA8, 0x02, 0xA8, 0x02, 0xA8, 0x02, 0xA8, 0x02, 0xA8, 0x02, 0xE4, 0x02, 0xE4, 0x02, 0xE4, 0x02, 0xE4, 0x02, 0xE4, 0x02, 0x20, 0x03, 0x20, 0x03, 0x20, 0x03, 0x20, 0x03, 0x20, 0x03, 0x66, 0x03, 0x66, 0x03, 0x66, 0x03, 0x66, 0x03, 0x66, 0x03, 0xAC, 0x03, 0x4C, 0xFC, 0xFF, 0x3E, 0x1C, 0x21, 0x00, 0xAC, 0x03, 0xAC, 0x03, 0xAC, 0x03, 0xAC, 0x03, 0xF2, 0x03, 0xF2, 0x03, 0xF2, 0x03, 0xF2, 0x03, 0xF2, 0x03, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x05, 0x9C, 0x02, 0xFF, 0xA0, 0x02, 0xFF, 0xA4, 0x02, 0xFF, 0xA8, 0x02, 0xFF, 0xAC, 0x02, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x05, 0xC8, 0x02, 0xFF, 0xCC, 0x02, 0xFF, 0xD0, 0x02, 0xFF, 0xD4, 0x02, 0xFF, 0xD8, 0x02, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x05, 0x88, 0x03, 0xFF, 0x8C, 0x03, 0xFF, 0x90, 0x03, 0xFF, 0x94, 0x03, 0xFF, 0x98, 0x03, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x05, 0x9C, 0x03, 0xFF, 0xA0, 0x03, 0xFF, 0xA4, 0x03, 0xFF, 0xA8, 0x03, 0xFF, 0xAC, 0x03, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x05, 0x80, 0x03, 0xFF, 0x84, 0x03, 0xFF, 0xA0, 0x06, 0xFF, 0xB4, 0x02, 0xFF, 0x38, 0x07, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x03, 0xA4, 0x06, 0xFF, 0x5C, 0x06, 0xFF, 0x98, 0x06, 0xFF, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x41, 0x41, 0x41, 0x41, 0x41, 0x85, 0x85, 0x85, 0x85, 0x84, 0xA6, 0xA5, 0xA5, 0xA5, 0xA5, 0xA4, 0xF4, 0x18, 0x03, 0xFA, 0x65, 0x03, 0xCC, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x84, 0x84, 0x84, 0x84, 0x83, 0xA5, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xF4, 0x1A, 0x03, 0xFA, 0x66, 0x03, 0xCC, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x58, 0x58, 0x58, 0x58, 0x58, 0x84, 0x84, 0x84, 0x84, 0x83, 0xA5, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xF4, 0x1F, 0x03, 0xFA, 0x66, 0x03, 0xCC, 0x85, 0x85, 0x85, 0x85, 0x85, 0x69, 0x69, 0x69, 0x69, 0x69, 0x84, 0x84, 0x84, 0x84, 0x83, 0xA5, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0x4C, 0xFC, 0xFF, 0x39, 0x1D, 0x21, 0x00, 0xF4, 0x1F, 0x03, 0xFA, 0x66, 0x03, 0xCC, 0x99, 0x99, 0x99, 0x99, 0x99, 0x74, 0x74, 0x74, 0x74, 0x74, 0x84, 0x84, 0x84, 0x84, 0x83, 0xA5, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xF4, 0x1F, 0x03, 0xFA, 0x67, 0x03, 0xCC, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0x82, 0x82, 0x82, 0x82, 0x82, 0x84, 0x84, 0x84, 0x84, 0x83, 0xA5, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xF4, 0x1F, 0x03, 0xFA, 0x67, 0x23, 0xFF, 0x01, 0x07, 0xB5, 0x03, 0x00, 0x06, 0x0A, 0x23, 0x3C, 0x5A, 0x6E, 0x7D, 0x05, 0x5C, 0x03, 0x3E, 0x03, 0x48, 0x03, 0x5C, 0x03, 0x48, 0x03, 0x98, 0x03, 0x7A, 0x03, 0x84, 0x03, 0x98, 0x03, 0x84, 0x03, 0xD4, 0x03, 0xB6, 0x03, 0xC0, 0x03, 0xD4, 0x03, 0xC0, 0x03, 0x1A, 0x04, 0xFC, 0x03, 0x06, 0x04, 0x1A, 0x04, 0x06, 0x04, 0x60, 0x04, 0x42, 0x04, 0x4C, 0x04, 0x60, 0x04, 0x4C, 0x04, 0xA6, 0x04, 0x88, 0x04, 0x92, 0x04, 0xA6, 0x04, 0x92, 0x04, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x44, 0x02, 0x30, 0x02, 0x26, 0x02, 0x12, 0x02, 0x1C, 0x02, 0x80, 0x02, 0x6C, 0x02, 0x62, 0x02, 0x4E, 0x02, 0x58, 0x02, 0xBC, 0x02, 0xA8, 0x02, 0x9E, 0x02, 0x8A, 0x02, 0x94, 0x02, 0x02, 0x03, 0xEE, 0x02, 0xE4, 0x02, 0xD0, 0x02, 0xDA, 0x02, 0x48, 0x03, 0x34, 0x03, 0x2A, 0x03, 0x16, 0x03, 0x20, 0x03, 0x8E, 0x03, 0x7A, 0x03, 0x70, 0x03, 0x5C, 0x03, 0x66, 0x03, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x05, 0x9C, 0x02, 0xFF, 0xA0, 0x02, 0xFF, 0xA4, 0x02, 0xFF, 0xA8, 0x02, 0xFF, 0xAC, 0x02, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x05, 0xC8, 0x02, 0xFF, 0xCC, 0x4C, 0xFC, 0xFF, 0x34, 0x1E, 0x21, 0x00, 0x02, 0xFF, 0xD0, 0x02, 0xFF, 0xD4, 0x02, 0xFF, 0xD8, 0x02, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x05, 0x88, 0x03, 0xFF, 0x8C, 0x03, 0xFF, 0x90, 0x03, 0xFF, 0x94, 0x03, 0xFF, 0x98, 0x03, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x05, 0x9C, 0x03, 0xFF, 0xA0, 0x03, 0xFF, 0xA4, 0x03, 0xFF, 0xA8, 0x03, 0xFF, 0xAC, 0x03, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x05, 0x80, 0x03, 0xFF, 0x84, 0x03, 0xFF, 0xA0, 0x06, 0xFF, 0xB4, 0x02, 0xFF, 0x38, 0x07, 0xFF, 0x00, 0x00, 0x60, 0x00, 0x03, 0xA4, 0x06, 0xFF, 0x5C, 0x06, 0xFF, 0x98, 0x06, 0xFF, 0x43, 0x39, 0x37, 0x37, 0x38, 0x38, 0x35, 0x35, 0x36, 0x35, 0x88, 0x86, 0x86, 0x86, 0x85, 0xA8, 0xA6, 0xA6, 0xA6, 0xA4, 0xA4, 0xF4, 0x18, 0x03, 0xFA, 0x65, 0x03, 0xCC, 0x4C, 0x45, 0x41, 0x42, 0x43, 0x40, 0x3C, 0x3B, 0x3B, 0x3C, 0x88, 0x86, 0x86, 0x86, 0x85, 0xA8, 0xA6, 0xA6, 0xA6, 0xA4, 0xA4, 0xF4, 0x1A, 0x03, 0xFA, 0x66, 0x03, 0xCC, 0x5C, 0x52, 0x52, 0x52, 0x52, 0x4B, 0x47, 0x47, 0x47, 0x47, 0x88, 0x86, 0x86, 0x86, 0x85, 0xA8, 0xA6, 0xA6, 0xA6, 0xA4, 0xA4, 0xF4, 0x1F, 0x03, 0xFA, 0x66, 0x03, 0xCC, 0x6A, 0x63, 0x5F, 0x5F, 0x64, 0x57, 0x53, 0x52, 0x52, 0x53, 0x88, 0x86, 0x86, 0x86, 0x85, 0xA8, 0xA6, 0xA6, 0xA6, 0xA4, 0xA4, 0xF4, 0x1F, 0x03, 0xFA, 0x66, 0x03, 0xCC, 0x7C, 0x71, 0x6E, 0x6E, 0x71, 0x61, 0x5D, 0x5C, 0x5C, 0x5D, 0x88, 0x86, 0x86, 0x86, 0x85, 0xA8, 0xA6, 0xA6, 0xA6, 0xA4, 0xA4, 0xF4, 0x1F, 0x03, 0xFA, 0x67, 0x03, 0xCC, 0x8C, 0x81, 0x7F, 0x7F, 0x81, 0x6F, 0x68, 0x67, 0x67, 0x68, 0x88, 0x86, 0x86, 0x86, 0x85, 0xA8, 0xA6, 0xA6, 0xA6, 0xA4, 0xA4, 0xF4, 0x1F, 0x03, 0xFA, 0x67, 0x4C, 0xFC, 0xFF, 0x2F, 0x1F, 0x21, 0x00, 0x23, 0xFF, 0x02, 0x07, 0x7F, 0x04, 0x06, 0x05, 0x38, 0x04, 0x88, 0x04, 0x9C, 0x04, 0x88, 0x04, 0xD8, 0x04, 0x74, 0x04, 0xC4, 0x04, 0xD8, 0x04, 0xC4, 0x04, 0x14, 0x05, 0xB0, 0x04, 0x00, 0x05, 0x14, 0x05, 0x00, 0x05, 0x50, 0x05, 0xF6, 0x04, 0x46, 0x05, 0x5A, 0x05, 0x46, 0x05, 0x96, 0x05, 0x3C, 0x05, 0x8C, 0x05, 0xA0, 0x05, 0x8C, 0x05, 0xDC, 0x05, 0x82, 0x05, 0xD2, 0x05, 0xE6, 0x05, 0xD2, 0x05, 0x22, 0x06, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00, 0x05, 0x9C, 0x02, 0xFF, 0xA0, 0x02, 0xFF, 0xA4, 0x02, 0xFF, 0xA8, 0x02, 0xFF, 0xAC, 0x02, 0xFF, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x85, 0x85, 0x85, 0x85, 0x85, 0x99, 0x99, 0x99, 0x99, 0x99, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0x02, 0x07, 0x7F, 0x00, 0x06, 0x05, 0x5C, 0x03, 0x3E, 0x03, 0x48, 0x03, 0x5C, 0x03, 0x48, 0x03, 0x98, 0x03, 0x7A, 0x03, 0x84, 0x03, 0x98, 0x03, 0x84, 0x03, 0xD4, 0x03, 0xB6, 0x03, 0xC0, 0x03, 0xD4, 0x03, 0xC0, 0x03, 0x1A, 0x04, 0xFC, 0x03, 0x06, 0x04, 0x1A, 0x04, 0x06, 0x04, 0x60, 0x04, 0x42, 0x04, 0x4C, 0x04, 0x60, 0x04, 0x4C, 0x04, 0xA6, 0x04, 0x88, 0x04, 0x92, 0x04, 0xA6, 0x04, 0x92, 0x04, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x14, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00, 0x05, 0x9C, 0x02, 0xFF, 0xA0, 0x02, 0xFF, 0xA4, 0x02, 0xFF, 0xA8, 0x02, 0xFF, 0xAC, 0x02, 0xFF, 0x43, 0x39, 0x37, 0x37, 0x38, 0x4C, 0x45, 0x41, 0x42, 0x43, 0x5C, 0x53, 0x52, 0x52, 0x52, 0x6A, 0x63, 0x5F, 0x5F, 0x4C, 0xFC, 0xFF, 0x2A, 0x20, 0x21, 0x00, 0x64, 0x7C, 0x71, 0x6E, 0x6E, 0x71, 0x8C, 0x81, 0x7F, 0x7F, 0x81, 0x00, 0x07, 0x04, 0x3F, 0x00, 0x00, 0x00, 0x03, 0x01, 0xC4, 0x01, 0x08, 0x0A, 0x20, 0x00, 0x08, 0x08, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x2C, 0x2C, 0x00, 0x00, 0x28, 0x28, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x41, 0x41, 0x00, 0x00, 0x34, 0x34, 0x00, 0x00, 0x49, 0x49, 0x00, 0x00, 0x20, 0x20, 0x01, 0x01, 0x50, 0x50, 0x00, 0x00, 0x24, 0x24, 0x01, 0x01, 0x58, 0x58, 0x00, 0x00, 0x40, 0x40, 0x01, 0x01, 0x8A, 0x8A, 0x00, 0x00, 0x60, 0x60, 0x01, 0x01, 0x8B, 0x8B, 0x00, 0x00, 0x64, 0x64, 0x01, 0x01, 0x8C, 0x8C, 0x00, 0x00, 0x60, 0x60, 0x02, 0x02, 0x8D, 0x8D, 0x00, 0x00, 0x64, 0x64, 0x02, 0x02, 0x8E, 0x8E, 0x00, 0x00, 0x68, 0x68, 0x02, 0x02, 0x8F, 0x8F, 0x00, 0x00, 0x6C, 0x6C, 0x02, 0x02, 0x96, 0x96, 0x00, 0x00, 0x70, 0x70, 0x02, 0x02, 0xA5, 0xA5, 0x00, 0x00, 0x50, 0x50, 0x03, 0x03, 0xA6, 0xA6, 0x00, 0x00, 0x54, 0x54, 0x03, 0x03, 0xDD, 0xDD, 0x00, 0x00, 0x74, 0x74, 0x03, 0x03, 0xE5, 0xE5, 0x00, 0x00, 0x78, 0x78, 0x03, 0x03, 0xED, 0xED, 0x00, 0x00, 0x98, 0x98, 0x03, 0x03, 0xEE, 0xEE, 0x00, 0x00, 0xFC, 0xFC, 0x03, 0x03, 0xEF, 0xEF, 0x00, 0x00, 0xBC, 0xBC, 0x03, 0x03, 0xEF, 0xEF, 0x00, 0x00, 0xBC, 0xBC, 0x03, 0x03, 0x03, 0x01, 0x64, 0xC8, 0x0A, 0x20, 0x00, 0x40, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x01, 0x41, 0x00, 0x04, 0x01, 0x49, 0x00, 0x4C, 0xFC, 0xFF, 0x25, 0x21, 0x21, 0x00, 0x24, 0x01, 0x50, 0x00, 0x40, 0x01, 0x58, 0x00, 0x60, 0x01, 0x52, 0x00, 0x48, 0x01, 0x53, 0x00, 0x4C, 0x01, 0x54, 0x00, 0x50, 0x01, 0x55, 0x00, 0x54, 0x01, 0x56, 0x00, 0x58, 0x01, 0x57, 0x00, 0x5C, 0x01, 0x66, 0x00, 0x98, 0x01, 0x6E, 0x00, 0xB8, 0x01, 0x76, 0x00, 0xD8, 0x01, 0x7E, 0x00, 0xF8, 0x01, 0x7F, 0x00, 0xFC, 0x01, 0x7F, 0x00, 0xFC, 0x01, 0x7F, 0x00, 0xFC, 0x01, 0x7F, 0x00, 0xFC, 0x01, 0x7F, 0x00, 0xFC, 0x01, 0x03, 0x01, 0x3A, 0x28, 0x0B, 0x20, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x7F, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x03, 0x01, 0x05, 0x08, 0x08, 0x20, 0x00, 0x06, 0x03, 0x01, 0x05, 0x0C, 0x08, 0x20, 0x00, 0x05, 0x03, 0x01, 0x05, 0x10, 0x08, 0x20, 0x00, 0x0B, 0x03, 0x01, 0x05, 0x14, 0x08, 0x20, 0x00, 0x0A, 0x04, 0x07, 0x98, 0x01, 0x04, 0x32, 0x1F, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x1C, 0x01, 0x00, 0x1A, 0x02, 0x00, 0x17, 0x02, 0x00, 0x15, 0x12, 0x00, 0x13, 0x55, 0x00, 0x11, 0x64, 0x00, 0x0F, 0x11, 0x00, 0x0E, 0x03, 0x00, 0x0D, 0x14, 0x00, 0x0B, 0x50, 0x00, 0x0A, 0x64, 0x00, 0x09, 0x23, 0x00, 0x08, 0x23, 0x00, 0x07, 0x03, 0x00, 0x07, 0x16, 0x00, 0x06, 0x15, 0x00, 0x05, 0x13, 0x00, 0x05, 0x16, 0x00, 0x04, 0x13, 0x00, 0x04, 0x26, 0x00, 0x04, 0x19, 0x00, 0x03, 0x05, 0x00, 0x03, 0x08, 0x00, 0x03, 0x2A, 0x00, 0x02, 0x03, 0x00, 0x02, 0x4C, 0xFC, 0xFF, 0x20, 0x22, 0x21, 0x00, 0x16, 0x00, 0x02, 0x09, 0x00, 0x02, 0x2B, 0x00, 0x02, 0x3D, 0x00, 0x02, 0x3F, 0x00, 0x01, 0x02, 0x00, 0x01, 0x15, 0x00, 0x01, 0x18, 0x00, 0x01, 0x3A, 0x00, 0x01, 0x1D, 0x00, 0x01, 0x1F, 0x00, 0x01, 0x8F, 0x00, 0x01, 0xEF, 0x00, 0x01, 0x3F, 0x01, 0x01, 0x8F, 0x01, 0x01, 0xCF, 0x01, 0x01, 0x0F, 0x02, 0x01, 0x4F, 0x02, 0x01, 0x7F, 0x02, 0x01, 0xAF, 0x02, 0x01, 0xCF, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x07, 0x98, 0x01, 0x00, 0x32, 0x1F, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x1C, 0x01, 0x00, 0x1A, 0x02, 0x00, 0x17, 0x02, 0x00, 0x15, 0x12, 0x00, 0x13, 0x55, 0x00, 0x11, 0x64, 0x00, 0x0F, 0x11, 0x00, 0x0E, 0x03, 0x00, 0x0D, 0x14, 0x00, 0x0B, 0x50, 0x00, 0x0A, 0x64, 0x00, 0x09, 0x23, 0x00, 0x08, 0x23, 0x00, 0x07, 0x03, 0x00, 0x07, 0x16, 0x00, 0x06, 0x15, 0x00, 0x05, 0x13, 0x00, 0x05, 0x16, 0x00, 0x04, 0x13, 0x00, 0x04, 0x26, 0x00, 0x04, 0x19, 0x00, 0x03, 0x05, 0x00, 0x03, 0x08, 0x00, 0x03, 0x2A, 0x00, 0x02, 0x03, 0x00, 0x02, 0x16, 0x00, 0x02, 0x09, 0x00, 0x02, 0x2B, 0x00, 0x02, 0x3D, 0x00, 0x02, 0x3F, 0x00, 0x01, 0x02, 0x00, 0x01, 0x15, 0x00, 0x01, 0x18, 0x00, 0x01, 0x3A, 0x00, 0x01, 0x1D, 0x00, 0x01, 0x1F, 0x00, 0x01, 0x8F, 0x00, 0x01, 0xEF, 0x00, 0x01, 0x3F, 0x01, 0x01, 0x8F, 0x01, 0x01, 0xCF, 0x01, 0x01, 0x0F, 0x02, 0x01, 0x4F, 0x02, 0x01, 0x7F, 0x02, 0x01, 0xAF, 0x02, 0x01, 0xCF, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x07, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x14, 0x0A, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x02, 0xFE, 0x0B, 0xE4, 0x4C, 0xFC, 0xFF, 0x1B, 0x23, 0x21, 0x00, 0xFE, 0x1C, 0x01, 0xE4, 0xFE, 0x1C, 0x01, 0x0A, 0x02, 0xFE, 0x0B, 0xF1, 0xFF, 0x0F, 0x00, 0xF1, 0xFF, 0x0F, 0x00, 0x05, 0x07, 0x24, 0xFF, 0x01, 0x08, 0x08, 0x0C, 0x00, 0x08, 0x01, 0x04, 0x02, 0x00, 0x03, 0xFC, 0x04, 0xF8, 0x05, 0xF4, 0x06, 0xF0, 0x07, 0x0C, 0x00, 0x08, 0x01, 0x04, 0x02, 0x00, 0x03, 0xFC, 0x04, 0xF8, 0x05, 0xF4, 0x06, 0xF0, 0x07, 0x0F, 0x03, 0x28, 0x02, 0x78, 0x14, 0x7F, 0x5A, 0x00, 0x14, 0x02, 0x14, 0x1E, 0x00, 0x02, 0x03, 0x00, 0x1E, 0xAA, 0x33, 0x19, 0x05, 0xCF, 0x00, 0x80, 0x0A, 0x92, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x05, 0x18, 0x13, 0x21, 0x00, 0x90, 0x03, 0x01, 0x05, 0xC9, 0x22, 0x20, 0x00, 0x00, 0x03, 0x01, 0x0C, 0xDC, 0x1D, 0x20, 0x00, 0x01, 0x01, 0x30, 0x00, 0x02, 0x0A, 0x0A, 0x00, 0x03, 0x01, 0x05, 0x48, 0x2C, 0x20, 0x00, 0x01, 0x03, 0x01, 0x05, 0x24, 0x33, 0x20, 0x00, 0x01, 0x03, 0x01, 0x05, 0x4E, 0x05, 0x20, 0x00, 0x00, 0x03, 0x01, 0x06, 0x08, 0x1E, 0x20, 0x00, 0x00, 0x00, 0x03, 0x01, 0x08, 0xB8, 0x28, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x05, 0xED, 0x25, 0x20, 0x00, 0x00, 0x03, 0x01, 0x06, 0xC6, 0x32, 0x20, 0x00, 0x2A, 0x0E, 0x03, 0x01, 0x06, 0xAC, 0x2C, 0x20, 0x00, 0xF0, 0x00, 0x03, 0x01, 0x06, 0xEC, 0x27, 0x20, 0x00, 0x80, 0x07, 0x03, 0x01, 0x05, 0x98, 0x34, 0x20, 0x00, 0x00, 0x04, 0x03, 0x0C, 0x20, 0x00, 0x20, 0x00, 0x14, 0x14, 0x1A, 0x66, 0x0A, 0x15, 0x00, 0x00, 0x05, 0x03, 0x20, 0x00, 0x1B, 0x28, 0x50, 0xFF, 0xFF, 0x3F, 0x00, 0x05, 0x03, 0x1F, 0x0C, 0xC2, 0x01, 0x4C, 0xFC, 0xFF, 0x16, 0x24, 0x21, 0x00, 0x50, 0x50, 0xAE, 0x38, 0xBA, 0x0A, 0x05, 0x00, 0xFF, 0xFF, 0x07, 0xE3, 0x32, 0x00, 0xB8, 0xA8, 0xC6, 0xFF, 0x11, 0x03, 0x04, 0x40, 0x81, 0x00, 0x00, 0x0A, 0x03, 0x04, 0xD4, 0x30, 0x00, 0x00, 0x03, 0x01, 0x14, 0x60, 0x5D, 0x0D, 0x00, 0x3C, 0x1C, 0x20, 0x00, 0x34, 0x1C, 0x20, 0x00, 0x2C, 0x1C, 0x20, 0x00, 0x00, 0x0A, 0x14, 0x00, 0x03, 0x01, 0x9C, 0x13, 0x70, 0x5D, 0x0D, 0x00, 0x9C, 0x5B, 0x20, 0x00, 0xB8, 0xD8, 0x20, 0x00, 0x18, 0xD7, 0x20, 0x00, 0x4C, 0xD7, 0x20, 0x00, 0x80, 0xD7, 0x20, 0x00, 0xB4, 0xD7, 0x20, 0x00, 0xE8, 0xD7, 0x20, 0x00, 0x1C, 0xD8, 0x20, 0x00, 0x50, 0xD8, 0x20, 0x00, 0x84, 0xD8, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x5B, 0x03, 0x00, 0x47, 0x6A, 0x03, 0x00, 0x67, 0x0F, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x0F, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD9, 0x0F, 0x0D, 0x00, 0xB9, 0x0F, 0x0D, 0x00, 0xEB, 0x61, 0x03, 0x00, 0x8D, 0x62, 0x03, 0x00, 0x3B, 0x56, 0x03, 0x00, 0x5D, 0xD1, 0x07, 0x00, 0xDF, 0xD7, 0x07, 0x00, 0xAB, 0x7C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC9, 0x13, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x13, 0x0D, 0x00, 0xE9, 0x7E, 0x07, 0x00, 0xB5, 0x7D, 0x07, 0x00, 0xA9, 0x7F, 0x07, 0x00, 0x1D, 0xCE, 0x07, 0x00, 0x5D, 0xD1, 0x07, 0x00, 0xDF, 0xD7, 0x07, 0x00, 0xE7, 0xCD, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, 0x14, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFD, 0x13, 0x0D, 0x00, 0xA5, 0xD1, 0x07, 0x00, 0xAB, 0xD2, 0x07, 0x00, 0x67, 0xD7, 0x07, 0x00, 0x1D, 0xCE, 0x07, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x38, 0x0A, 0x21, 0x00, 0x00, 0x00, 0x30, 0x10, 0x4C, 0xFC, 0xFF, 0x11, 0x25, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7B, 0x1E, 0x0D, 0x00, 0x81, 0x1E, 0x0D, 0x00, 0x1D, 0x1F, 0x0D, 0x00, 0x3F, 0x20, 0x0D, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x8F, 0xFB, 0x06, 0x00, 0x85, 0x38, 0x0D, 0x00, 0x77, 0x39, 0x0D, 0x00, 0x1F, 0x02, 0x07, 0x00, 0xC1, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x06, 0x07, 0x00, 0xE7, 0x0A, 0x07, 0x00, 0x65, 0x39, 0x0D, 0x00, 0x8D, 0xFE, 0x06, 0x00, 0x61, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDB, 0xE6, 0x02, 0x00, 0xBD, 0x39, 0x0D, 0x00, 0x0D, 0xE6, 0x02, 0x00, 0xFD, 0xE6, 0x02, 0x00, 0xCB, 0xEC, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFD, 0xE8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8B, 0xE9, 0x02, 0x00, 0x67, 0xEB, 0x02, 0x00, 0xF9, 0xE7, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC2, 0x0B, 0xA3, 0x12, 0x85, 0x17, 0x4E, 0x1B, 0x66, 0x1E, 0x03, 0x21, 0x47, 0x23, 0x46, 0x25, 0x10, 0x27, 0xAE, 0x28, 0x28, 0x2A, 0x83, 0x2B, 0xC5, 0x4C, 0xFC, 0xFF, 0x0C, 0x26, 0x21, 0x00, 0x2C, 0xF1, 0x2D, 0x09, 0x2F, 0x10, 0x30, 0x09, 0x31, 0xF4, 0x31, 0xD2, 0x32, 0xA6, 0x33, 0x70, 0x34, 0x31, 0x35, 0xEA, 0x35, 0x9B, 0x36, 0x46, 0x37, 0xEA, 0x37, 0x88, 0x38, 0x20, 0x39, 0xB3, 0x39, 0x42, 0x3A, 0xCB, 0x3A, 0x51, 0x3B, 0xD3, 0x3B, 0x51, 0x3C, 0xCB, 0x3C, 0x42, 0x3D, 0xB6, 0x3D, 0x27, 0x3E, 0x95, 0x3E, 0x00, 0x3F, 0x68, 0x3F, 0xCF, 0x3F, 0x33, 0x40, 0x94, 0x40, 0xF4, 0x40, 0x51, 0x41, 0xAC, 0x41, 0x06, 0x42, 0x5E, 0x42, 0xB4, 0x42, 0x08, 0x43, 0x5B, 0x43, 0xAC, 0x43, 0xFC, 0x43, 0x4A, 0x44, 0x97, 0x44, 0xE2, 0x44, 0x2D, 0x45, 0x76, 0x45, 0xBD, 0x45, 0x04, 0x46, 0x49, 0x46, 0x8E, 0x46, 0xD1, 0x46, 0x13, 0x47, 0x55, 0x47, 0x95, 0x47, 0xD4, 0x47, 0x13, 0x48, 0x51, 0x48, 0x8D, 0x48, 0xC9, 0x48, 0x04, 0x49, 0x3F, 0x49, 0x78, 0x49, 0xB1, 0x49, 0xE9, 0x49, 0x20, 0x4A, 0x57, 0x4A, 0x8D, 0x4A, 0xC2, 0x4A, 0xF7, 0x4A, 0x2B, 0x4B, 0x5E, 0x4B, 0x91, 0x4B, 0xC3, 0x4B, 0xF5, 0x4B, 0x26, 0x4C, 0x56, 0x4C, 0x86, 0x4C, 0xB6, 0x4C, 0xE5, 0x4C, 0x13, 0x4D, 0x41, 0x4D, 0x6F, 0x4D, 0x9C, 0x4D, 0xC8, 0x4D, 0xF4, 0x4D, 0x20, 0x4E, 0x4B, 0x4E, 0x76, 0x4E, 0xA0, 0x4E, 0xCA, 0x4E, 0xF4, 0x4E, 0x1D, 0x4F, 0x46, 0x4F, 0x6E, 0x4F, 0x96, 0x4F, 0xBE, 0x4F, 0xE5, 0x4F, 0x0C, 0x50, 0x33, 0x50, 0x59, 0x50, 0x7F, 0x50, 0xA5, 0x50, 0xCA, 0x50, 0xEF, 0x50, 0x13, 0x51, 0x38, 0x51, 0x5C, 0x51, 0x80, 0x51, 0xA3, 0x51, 0xC6, 0x51, 0xE9, 0x51, 0x0C, 0x52, 0x2E, 0x52, 0x50, 0x52, 0x72, 0x52, 0x93, 0x52, 0xB5, 0x52, 0xD6, 0x52, 0xF7, 0x52, 0x17, 0x53, 0x37, 0x53, 0x57, 0x53, 0x77, 0x53, 0x97, 0x53, 0xB6, 0x53, 0x4C, 0xFC, 0xFF, 0x07, 0x27, 0x21, 0x00, 0xD5, 0x53, 0xF4, 0x53, 0x13, 0x54, 0x31, 0x54, 0x50, 0x54, 0x6E, 0x54, 0x8C, 0x54, 0xA9, 0x54, 0xC7, 0x54, 0xE4, 0x54, 0x01, 0x55, 0x1E, 0x55, 0x3A, 0x55, 0x57, 0x55, 0x73, 0x55, 0x8F, 0x55, 0xAB, 0x55, 0xC7, 0x55, 0xE3, 0x55, 0xFE, 0x55, 0x19, 0x56, 0x34, 0x56, 0x4F, 0x56, 0x6A, 0x56, 0x84, 0x56, 0x9F, 0x56, 0xB9, 0x56, 0xD3, 0x56, 0xED, 0x56, 0x07, 0x57, 0x20, 0x57, 0x3A, 0x57, 0x53, 0x57, 0x6C, 0x57, 0x85, 0x57, 0x9E, 0x57, 0xB7, 0x57, 0xD0, 0x57, 0xE8, 0x57, 0x01, 0x58, 0x19, 0x58, 0x31, 0x58, 0x49, 0x58, 0x61, 0x58, 0x78, 0x58, 0x90, 0x58, 0xA7, 0x58, 0xBE, 0x58, 0xD6, 0x58, 0xED, 0x58, 0x04, 0x59, 0x1A, 0x59, 0x31, 0x59, 0x48, 0x59, 0x5E, 0x59, 0x74, 0x59, 0x8B, 0x59, 0xA1, 0x59, 0xB7, 0x59, 0xCD, 0x59, 0xE2, 0x59, 0xF8, 0x59, 0x0E, 0x5A, 0x23, 0x5A, 0x38, 0x5A, 0x4E, 0x5A, 0x63, 0x5A, 0x78, 0x5A, 0x8D, 0x5A, 0xA1, 0x5A, 0xB6, 0x5A, 0xCB, 0x5A, 0xDF, 0x5A, 0xF4, 0x5A, 0x08, 0x5B, 0x1C, 0x5B, 0x31, 0x5B, 0x45, 0x5B, 0x59, 0x5B, 0x6C, 0x5B, 0x80, 0x5B, 0x94, 0x5B, 0xA8, 0x5B, 0xBB, 0x5B, 0xCE, 0x5B, 0xE2, 0x5B, 0xF5, 0x5B, 0x08, 0x5C, 0x1B, 0x5C, 0x2E, 0x5C, 0x41, 0x5C, 0x54, 0x5C, 0x67, 0x5C, 0x7A, 0x5C, 0x8C, 0x5C, 0x9F, 0x5C, 0xB1, 0x5C, 0xC3, 0x5C, 0xD6, 0x5C, 0xE8, 0x5C, 0xFA, 0x5C, 0x0C, 0x5D, 0x1E, 0x5D, 0x30, 0x5D, 0x42, 0x5D, 0x54, 0x5D, 0x65, 0x5D, 0x77, 0x5D, 0x89, 0x5D, 0x9A, 0x5D, 0xAB, 0x5D, 0xBD, 0x5D, 0xCE, 0x5D, 0xDF, 0x5D, 0xF0, 0x5D, 0x01, 0x5E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x01, 0x65, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x4C, 0xFC, 0xFF, 0x02, 0x28, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x01, 0x65, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x04, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD5, 0x4E, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0xBC, 0x01, 0x60, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xB6, 0x02, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x60, 0x00, 0x40, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x60, 0x00, 0xF0, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x04, 0x41, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x60, 0x00, 0x30, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x60, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x4F, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0xE8, 0x02, 0x60, 0x00, 0x40, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x04, 0x41, 0x00, 0xBA, 0x40, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x04, 0x41, 0x00, 0x4C, 0xFC, 0xFF, 0xFD, 0x28, 0x21, 0x00, 0xC0, 0x50, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0x4E, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x34, 0x06, 0x41, 0x00, 0x80, 0x18, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x01, 0x60, 0x00, 0x55, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x04, 0x41, 0x00, 0xE9, 0x02, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x06, 0x41, 0x00, 0xF1, 0x82, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x04, 0x41, 0x00, 0x21, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x04, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDB, 0x4F, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x07, 0x50, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x79, 0x4F, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA8, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAC, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0xFC, 0xFF, 0xF8, 0x29, 0x21, 0x00, 0x00, 0xC8, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCC, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD4, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0x4E, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x81, 0xB7, 0x02, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x64, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x00, 0x64, 0x00, 0x0C, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x64, 0x00, 0x30, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x02, 0x60, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBC, 0x01, 0x60, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD5, 0x4E, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x01, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x50, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x4C, 0xFC, 0xFF, 0xF3, 0x2A, 0x21, 0x00, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x60, 0x01, 0x65, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x01, 0x65, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x64, 0x00, 0xDF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8, 0x00, 0x64, 0x00, 0x18, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x60, 0x00, 0xBE, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x60, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x60, 0x00, 0x0F, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x60, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x60, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x60, 0x00, 0x30, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x04, 0x60, 0x00, 0x08, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE8, 0x04, 0x41, 0x00, 0x02, 0xC2, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x04, 0x41, 0x00, 0xBA, 0x40, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x06, 0x41, 0x00, 0x00, 0x48, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE8, 0x02, 0x60, 0x00, 0x45, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDB, 0x4F, 0x0D, 0x00, 0xBC, 0x4C, 0xFC, 0xFF, 0xEE, 0x2B, 0x21, 0x00, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x07, 0x50, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x69, 0x4E, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x91, 0x4E, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x51, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x53, 0x50, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x04, 0x41, 0x00, 0x21, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0x50, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0x99, 0x4F, 0x0D, 0x00, 0xBC, 0xBC, 0xBC, 0xBC, 0x43, 0x43, 0x43, 0x43, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x64, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x00, 0x64, 0x00, 0x0C, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x64, 0x00, 0x30, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xA0, 0x02, 0x00, 0x45, 0x4E, 0x0D, 0x00, 0x39, 0xA0, 0x02, 0x00, 0x57, 0xA0, 0x02, 0x00, 0xD3, 0xA0, 0x02, 0x00, 0x7B, 0xA1, 0x02, 0x00, 0xB5, 0xA1, 0x02, 0x00, 0xC5, 0xA2, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x0A, 0x05, 0x08, 0x06, 0x06, 0x0A, 0x04, 0x0B, 0x02, 0x0D, 0x4C, 0xFC, 0xFF, 0xE9, 0x2C, 0x21, 0x00, 0x00, 0x0F, 0xFE, 0x11, 0xFC, 0x13, 0xFA, 0x15, 0xF8, 0x17, 0xF6, 0x19, 0xF4, 0x1B, 0xF2, 0x1D, 0xF0, 0x1F, 0xEE, 0x21, 0xEC, 0x23, 0xEA, 0x25, 0xE8, 0x27, 0xE6, 0x29, 0x0A, 0x01, 0x08, 0x05, 0x06, 0x07, 0x04, 0x0B, 0x02, 0x0C, 0x00, 0x0E, 0x64, 0x01, 0x60, 0x00, 0x68, 0x01, 0x60, 0x00, 0x6C, 0x01, 0x60, 0x00, 0x70, 0x01, 0x60, 0x00, 0x74, 0x01, 0x60, 0x00, 0x78, 0x01, 0x60, 0x00, 0x7C, 0x01, 0x60, 0x00, 0x84, 0x01, 0x60, 0x00, 0x51, 0x28, 0x0D, 0x00, 0x03, 0x00, 0x00, 0x00, 0xBD, 0x30, 0x0D, 0x00, 0x06, 0x00, 0x09, 0x00, 0x53, 0x31, 0x0D, 0x00, 0x04, 0x00, 0x08, 0x00, 0x53, 0x32, 0x0D, 0x00, 0x04, 0x00, 0x06, 0x00, 0x65, 0x32, 0x0D, 0x00, 0x03, 0x00, 0x07, 0x00, 0x45, 0x29, 0x0D, 0x00, 0x00, 0x00, 0x0E, 0x00, 0xF5, 0x44, 0x0D, 0x00, 0x0A, 0x00, 0x06, 0x00, 0x55, 0x29, 0x0D, 0x00, 0x23, 0x00, 0x00, 0x00, 0x49, 0x56, 0x0D, 0x00, 0x04, 0x00, 0x06, 0x00, 0xCF, 0x28, 0x0D, 0x00, 0x0D, 0x00, 0x06, 0x00, 0xDF, 0x2F, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x30, 0x0D, 0x00, 0x03, 0x00, 0x0E, 0x00, 0x8F, 0xBE, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x8F, 0x29, 0x0D, 0x00, 0x00, 0x00, 0x06, 0x00, 0xB7, 0x29, 0x0D, 0x00, 0x0A, 0x00, 0x06, 0x00, 0x75, 0x32, 0x0D, 0x00, 0x0C, 0x00, 0x06, 0x00, 0x55, 0x2B, 0x0D, 0x00, 0x0A, 0x00, 0x00, 0x00, 0xBB, 0x2B, 0x0D, 0x00, 0x07, 0x00, 0x00, 0x00, 0xDB, 0x29, 0x0D, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x0D, 0x2B, 0x0D, 0x00, 0x03, 0x00, 0x00, 0x00, 0x8F, 0x32, 0x0D, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0xB1, 0x35, 0x0D, 0x4C, 0xFC, 0xFF, 0xE4, 0x2D, 0x21, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x05, 0x2C, 0x0C, 0x21, 0x00, 0x00, 0x03, 0x01, 0x05, 0x2B, 0x0C, 0x21, 0x00, 0x03, 0x03, 0x01, 0x05, 0x2A, 0x0C, 0x21, 0x00, 0x00, 0x03, 0x01, 0x05, 0x28, 0x0C, 0x21, 0x00, 0x01, 0x03, 0x01, 0x05, 0x29, 0x0C, 0x21, 0x00, 0x00, 0x03, 0x01, 0x08, 0x24, 0x0C, 0x21, 0x00, 0xB9, 0xB9, 0xBB, 0xB9, 0x03, 0x01, 0x08, 0x20, 0x0C, 0x21, 0x00, 0xB9, 0xB9, 0xBB, 0xB9, 0x03, 0x01, 0x05, 0x1C, 0x0C, 0x21, 0x00, 0x00, 0x03, 0x01, 0x06, 0x1E, 0x0C, 0x21, 0x00, 0x00, 0x00, 0x03, 0x01, 0x08, 0x14, 0x0C, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x03, 0x01, 0x08, 0x18, 0x0C, 0x21, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x03, 0x01, 0x28, 0xF0, 0x0B, 0x21, 0x00, 0x52, 0x66, 0xFC, 0xFC, 0x3E, 0x52, 0xFD, 0xFD, 0x2A, 0x3E, 0xFE, 0xFE, 0x16, 0x2A, 0xFF, 0xFF, 0x02, 0x16, 0x00, 0x00, 0xEE, 0x02, 0x01, 0x01, 0xDA, 0xEE, 0x02, 0x02, 0xC6, 0xDA, 0x03, 0x03, 0xB2, 0xC6, 0x04, 0x04, 0x03, 0x01, 0x05, 0xEB, 0x0B, 0x21, 0x00, 0x00, 0x03, 0x01, 0x05, 0xEC, 0x0B, 0x21, 0x00, 0x00, 0x03, 0x01, 0x05, 0xED, 0x0B, 0x21, 0x00, 0x00, 0x03, 0x01, 0x05, 0xE9, 0x0B, 0x21, 0x00, 0x00, 0x03, 0x01, 0x05, 0xE8, 0x0B, 0x21, 0x00, 0x00, 0x03, 0x01, 0x05, 0xEA, 0x0B, 0x21, 0x00, 0x00, 0x03, 0x01, 0x06, 0xEE, 0x0B, 0x21, 0x00, 0x90, 0x01, 0x03, 0x01, 0x08, 0xE4, 0x0B, 0x21, 0x00, 0x28, 0x00, 0x00, 0x00, 0x03, 0x01, 0x08, 0xE0, 0x0B, 0x21, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x03, 0x01, 0x05, 0xDE, 0x0B, 0x21, 0x00, 0xB6, 0x03, 0x01, 0x05, 0xDF, 0x0B, 0x21, 0x00, 0xAA, 0x03, 0x01, 0x05, 0x4C, 0xFC, 0xFF, 0xDF, 0x2E, 0x21, 0x00, 0xDD, 0x0B, 0x21, 0x00, 0x01, 0x03, 0x01, 0x05, 0xDC, 0x0B, 0x21, 0x00, 0x28, 0x03, 0x01, 0x05, 0xDB, 0x0B, 0x21, 0x00, 0x01, 0x03, 0x01, 0x05, 0xDA, 0x0B, 0x21, 0x00, 0x00, 0x03, 0x01, 0x05, 0xD8, 0x0B, 0x21, 0x00, 0x00, 0x03, 0x01, 0x05, 0xD9, 0x0B, 0x21, 0x00, 0x00, 0x03, 0x01, 0xA4, 0x03, 0x38, 0x0A, 0x21, 0x00, 0x9C, 0x01, 0x60, 0x00, 0x8C, 0x02, 0x60, 0x00, 0x88, 0x02, 0x60, 0x00, 0x98, 0x02, 0x60, 0x00, 0x94, 0x04, 0x41, 0x00, 0x98, 0x04, 0x41, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x6C, 0x02, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x6C, 0x02, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x6C, 0x02, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x6C, 0x02, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0xF4, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x6C, 0x02, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0xEE, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x6C, 0x02, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0xE8, 0x00, 0x00, 0x00, 0x27, 0x00, 0x4C, 0xFC, 0xFF, 0xDA, 0x2F, 0x21, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x6C, 0x02, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0xE2, 0x00, 0x00, 0x00, 0x2D, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x6C, 0x02, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x6C, 0x02, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0xD6, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x6C, 0x02, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0xD0, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x5C, 0x02, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0xCA, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x4A, 0x02, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0xC4, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x44, 0x02, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0xBE, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x02, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x03, 0x01, 0x05, 0x34, 0x0A, 0x21, 0x00, 0x01, 0x03, 0x01, 0x05, 0x31, 0x0A, 0x21, 0x00, 0x06, 0x03, 0x01, 0x05, 0x32, 0x0A, 0x21, 0x00, 0x04, 0x03, 0x01, 0x05, 0x33, 0x0A, 0x21, 0x00, 0x00, 0x03, 0x4C, 0xFC, 0xFF, 0xD5, 0x30, 0x21, 0x00, 0x01, 0x05, 0x30, 0x0A, 0x21, 0x00, 0x00, 0x03, 0x01, 0x18, 0x00, 0x02, 0x0D, 0x00, 0x91, 0xF8, 0xD8, 0x21, 0x01, 0x68, 0x21, 0xF4, 0x40, 0x01, 0x0A, 0xB1, 0x01, 0xF5, 0x80, 0x01, 0x5C, 0xF7, 0x37, 0xBD, 0x03, 0x01, 0x14, 0x14, 0x02, 0x0D, 0x00, 0x8F, 0xB0, 0x00, 0x24, 0x01, 0x48, 0xC4, 0x61, 0x6D, 0xF7, 0x86, 0xBC, 0x00, 0x3F, 0x20, 0x00, 0x03, 0x01, 0x14, 0x24, 0x02, 0x0D, 0x00, 0x30, 0x46, 0xA1, 0x7B, 0x6A, 0x46, 0x0B, 0xAB, 0x00, 0xF0, 0x3A, 0xFB, 0x6D, 0xF7, 0x1C, 0xBD, 0x03, 0x01, 0x18, 0x34, 0x02, 0x0D, 0x00, 0xA8, 0x69, 0x70, 0xF7, 0x66, 0xFD, 0xB0, 0xF1, 0x80, 0x6F, 0x01, 0xD2, 0x6C, 0xF7, 0x09, 0xBD, 0x6C, 0xF7, 0x10, 0xBD, 0x03, 0x01, 0x14, 0x48, 0x02, 0x0D, 0x00, 0x20, 0x46, 0x00, 0x7D, 0x02, 0x28, 0x01, 0xD1, 0x20, 0x46, 0x90, 0x47, 0x6D, 0xF7, 0x44, 0xB8, 0x03, 0x01, 0x1C, 0x58, 0x02, 0x0D, 0x00, 0x04, 0x48, 0x00, 0x78, 0x08, 0xB1, 0x00, 0xF0, 0x41, 0xFB, 0x03, 0x20, 0x33, 0xF7, 0x20, 0xFD, 0x6C, 0xF7, 0x63, 0xBE, 0x30, 0x0A, 0x21, 0x00, 0x03, 0x01, 0x10, 0x70, 0x02, 0x0D, 0x00, 0x21, 0x00, 0x00, 0xF0, 0x43, 0xFB, 0xA0, 0x75, 0x70, 0xBD, 0x00, 0x00, 0x03, 0x01, 0x20, 0x7C, 0x02, 0x0D, 0x00, 0x02, 0xB4, 0x08, 0x46, 0x05, 0xF0, 0xE9, 0xFB, 0x02, 0xBC, 0x20, 0xB1, 0x3E, 0x20, 0x5B, 0xF7, 0xDB, 0xFC, 0xB1, 0xF7, 0x71, 0xBC, 0xBD, 0xE8, 0xF0, 0x9F, 0x00, 0x00, 0x03, 0x01, 0x0E, 0x98, 0x02, 0x0D, 0x00, 0x10, 0x22, 0xA8, 0xF7, 0x59, 0xFD, 0xA9, 0xF7, 0x0F, 0xB8, 0x03, 0x01, 0x10, 0xA2, 0x02, 0x0D, 0x00, 0x02, 0xD5, 0x20, 0x46, 0x00, 0xF0, 0xED, 0xFB, 0xA8, 0xF7, 0x8B, 0xBB, 0x4C, 0xFC, 0xFF, 0xD0, 0x31, 0x21, 0x00, 0x03, 0x01, 0x16, 0xAE, 0x02, 0x0D, 0x00, 0x68, 0x46, 0x8C, 0xF7, 0xDD, 0xF9, 0x10, 0xB9, 0x20, 0x46, 0x75, 0xF7, 0x79, 0xFA, 0x7C, 0xBD, 0x00, 0x00, 0x03, 0x01, 0x16, 0xC0, 0x02, 0x0D, 0x00, 0xA2, 0xF7, 0xBC, 0xFF, 0x18, 0xB9, 0x60, 0x68, 0x08, 0xB1, 0x75, 0xF7, 0x70, 0xFA, 0xA3, 0xF7, 0x51, 0xBB, 0x03, 0x01, 0x1A, 0xD2, 0x02, 0x0D, 0x00, 0xB1, 0xF7, 0x10, 0xFC, 0x21, 0x78, 0x9B, 0xF8, 0x04, 0x00, 0x81, 0x42, 0x01, 0xD3, 0xA3, 0xF7, 0x36, 0xBF, 0xA3, 0xF7, 0xC8, 0xBE, 0x03, 0x01, 0x18, 0xE8, 0x02, 0x0D, 0x00, 0x31, 0xB9, 0xC1, 0x8F, 0x01, 0x29, 0x03, 0xD1, 0xB0, 0xF8, 0x46, 0x10, 0xA4, 0xF7, 0x4D, 0xB9, 0xA4, 0xF7, 0x5D, 0xB9, 0x03, 0x01, 0x0C, 0xFC, 0x02, 0x0D, 0x00, 0x00, 0xF0, 0x00, 0xFD, 0x7C, 0xBD, 0x00, 0x00, 0x03, 0x01, 0x10, 0x04, 0x03, 0x0D, 0x00, 0x00, 0xB5, 0x00, 0xF0, 0x5E, 0xFF, 0x5D, 0xF8, 0x04, 0xEB, 0x70, 0x47, 0x03, 0x01, 0x0C, 0x10, 0x03, 0x0D, 0x00, 0x73, 0xF7, 0x50, 0xFC, 0x72, 0xF7, 0x36, 0xBA, 0x03, 0x01, 0x12, 0x18, 0x03, 0x0D, 0x00, 0x20, 0x46, 0x6B, 0xF7, 0x09, 0xFF, 0x30, 0x46, 0x75, 0xF7, 0x9F, 0xF8, 0x70, 0xBD, 0x03, 0x01, 0x16, 0x26, 0x03, 0x0D, 0x00, 0x20, 0x46, 0x00, 0xF0, 0x02, 0xFE, 0x18, 0xB1, 0xD4, 0xF8, 0x98, 0x20, 0x64, 0xF7, 0x97, 0xBF, 0x10, 0xBD, 0x03, 0x01, 0x14, 0x38, 0x03, 0x0D, 0x00, 0x20, 0x46, 0x00, 0xF0, 0x07, 0xFE, 0xFF, 0x20, 0x84, 0xF8, 0x1D, 0x01, 0x66, 0xF7, 0x1F, 0xBD, 0x03, 0x01, 0x14, 0x48, 0x03, 0x0D, 0x00, 0x20, 0x46, 0x00, 0xF0, 0xFF, 0xFD, 0xFF, 0x20, 0x84, 0xF8, 0x1D, 0x01, 0x65, 0xF7, 0x7C, 0xBC, 0x03, 0x01, 0x18, 0x58, 0x4C, 0xFC, 0xFF, 0xCB, 0x32, 0x21, 0x00, 0x03, 0x0D, 0x00, 0xD4, 0xF8, 0xD4, 0x00, 0xAE, 0xF7, 0x78, 0xF8, 0x00, 0x21, 0xD4, 0xF8, 0xD8, 0x00, 0x64, 0xF7, 0xBE, 0xBE, 0x00, 0x00, 0x03, 0x01, 0x14, 0x6C, 0x03, 0x0D, 0x00, 0x00, 0xF0, 0x65, 0xFF, 0x08, 0xB1, 0xA5, 0xF7, 0x65, 0xBD, 0xA5, 0xF7, 0x73, 0xBD, 0x00, 0x00, 0x03, 0x01, 0x14, 0x7C, 0x03, 0x0D, 0x00, 0xA3, 0x42, 0x01, 0xD3, 0xA7, 0xF7, 0x0A, 0xBC, 0x44, 0x21, 0xA7, 0xF7, 0x08, 0xBC, 0x00, 0x00, 0x03, 0x01, 0x14, 0x8C, 0x03, 0x0D, 0x00, 0x01, 0xF0, 0x69, 0xF8, 0x20, 0x46, 0xBD, 0xE8, 0x10, 0x40, 0x6A, 0xF7, 0xC4, 0xBE, 0x00, 0x00, 0x03, 0x01, 0x14, 0x9C, 0x03, 0x0D, 0x00, 0x84, 0xF8, 0x30, 0x01, 0x20, 0x46, 0x00, 0xF0, 0xD3, 0xFD, 0xA1, 0xF7, 0x97, 0xB9, 0x00, 0x00, 0x03, 0x01, 0x0C, 0xAC, 0x03, 0x0D, 0x00, 0x01, 0xF0, 0x6A, 0xFF, 0x20, 0x46, 0x70, 0xBD, 0x03, 0x01, 0x0C, 0xB4, 0x03, 0x0D, 0x00, 0xBD, 0xE8, 0xF8, 0x43, 0x02, 0xF0, 0x54, 0xB8, 0x03, 0x01, 0x10, 0xBC, 0x03, 0x0D, 0x00, 0x20, 0x46, 0x02, 0xF0, 0x9D, 0xF9, 0x01, 0x24, 0x8C, 0xF7, 0xCF, 0xBD, 0x03, 0x01, 0x16, 0xC8, 0x03, 0x0D, 0x00, 0x20, 0x46, 0x29, 0x46, 0x02, 0xF0, 0x26, 0xFA, 0x08, 0xB1, 0x4F, 0xF7, 0x93, 0xBE, 0x4F, 0xF7, 0xA5, 0xBE, 0x03, 0x01, 0x1E, 0xDA, 0x03, 0x0D, 0x00, 0x61, 0x88, 0xC1, 0xF3, 0xC9, 0x01, 0x00, 0x29, 0x03, 0xD0, 0x03, 0x28, 0x03, 0xD0, 0x4F, 0xF7, 0xF2, 0xB9, 0x4F, 0xF7, 0x75, 0xBA, 0x4F, 0xF7, 0xF0, 0xB9, 0x03, 0x01, 0x1C, 0xF4, 0x03, 0x0D, 0x00, 0xE1, 0x79, 0x01, 0x29, 0x03, 0xD0, 0x20, 0x28, 0x03, 0xD3, 0x84, 0xF7, 0xEB, 0xBC, 0x84, 0xF7, 0xF0, 0xBC, 0x84, 0xF7, 0xF8, 0xBC, 0x4C, 0xFC, 0xFF, 0xC6, 0x33, 0x21, 0x00, 0x00, 0x00, 0x03, 0x01, 0x14, 0x0C, 0x04, 0x0D, 0x00, 0x20, 0x88, 0x02, 0x21, 0x06, 0x22, 0xE3, 0x1C, 0xBD, 0xE8, 0x10, 0x40, 0x33, 0xF7, 0x56, 0xB9, 0x03, 0x01, 0x1C, 0x1C, 0x04, 0x0D, 0x00, 0x4F, 0xF4, 0xFA, 0x57, 0x4A, 0x46, 0x41, 0x46, 0x20, 0x46, 0x02, 0xF0, 0xE1, 0xFB, 0x08, 0xB9, 0x7F, 0xF7, 0xED, 0xBE, 0x7F, 0xF7, 0xE8, 0xBE, 0x03, 0x01, 0x1C, 0x34, 0x04, 0x0D, 0x00, 0xBB, 0x46, 0x4F, 0xF4, 0xFA, 0x2C, 0x20, 0x46, 0x02, 0xF0, 0xFE, 0xFB, 0x08, 0xB1, 0x7F, 0xF7, 0x6C, 0xBF, 0x7F, 0xF7, 0x84, 0xBF, 0x00, 0x00, 0x03, 0x01, 0x1C, 0x4C, 0x04, 0x0D, 0x00, 0x04, 0x70, 0x7D, 0xF7, 0xAA, 0xFB, 0x5E, 0xF7, 0x5B, 0xFC, 0x5B, 0xF7, 0x15, 0xFC, 0x5B, 0xF7, 0x6B, 0xFC, 0x5B, 0xF7, 0xB4, 0xBB, 0x00, 0x00, 0x03, 0x01, 0x18, 0x64, 0x04, 0x0D, 0x00, 0x02, 0xB4, 0x30, 0xF7, 0x7E, 0xFA, 0x02, 0xBC, 0x20, 0x46, 0x30, 0xF7, 0x76, 0xFE, 0x30, 0xF7, 0x58, 0xBF, 0x00, 0x00, 0x03, 0x01, 0x30, 0x78, 0x04, 0x0D, 0x00, 0x09, 0x4B, 0x1B, 0x78, 0x33, 0xB1, 0x94, 0xF9, 0x1A, 0x10, 0x46, 0x31, 0x5A, 0x29, 0x08, 0xD8, 0x53, 0xF7, 0xF8, 0xBE, 0x94, 0xF9, 0x1A, 0x10, 0x15, 0x31, 0x1E, 0x29, 0x01, 0xD8, 0x53, 0xF7, 0xF1, 0xBE, 0x53, 0xF7, 0xD7, 0xBE, 0x00, 0x00, 0x34, 0x0A, 0x21, 0x00, 0x03, 0x01, 0x1C, 0xA4, 0x04, 0x0D, 0x00, 0x21, 0x7A, 0x01, 0x29, 0x03, 0xD0, 0x20, 0x28, 0x03, 0xD3, 0x53, 0xF7, 0xD9, 0xBE, 0x53, 0xF7, 0xDD, 0xBE, 0x53, 0xF7, 0xC9, 0xBE, 0x00, 0x00, 0x03, 0x01, 0x10, 0xBC, 0x04, 0x0D, 0x00, 0x28, 0x46, 0x02, 0xF0, 0xFD, 0xFE, 0x48, 0xF7, 0xF0, 0xBB, 0x00, 0x00, 0x03, 0x01, 0x34, 0xC8, 0x04, 0x4C, 0xFC, 0xFF, 0xC1, 0x34, 0x21, 0x00, 0x0D, 0x00, 0x47, 0xF2, 0x14, 0x01, 0x88, 0x42, 0x03, 0xD1, 0x08, 0x48, 0x00, 0x78, 0x00, 0xB1, 0x10, 0xBD, 0x08, 0x20, 0x75, 0xF7, 0xAF, 0xF8, 0x01, 0x00, 0xF9, 0xD0, 0x47, 0xF2, 0x14, 0x02, 0x94, 0x42, 0x02, 0xD1, 0x01, 0x22, 0x01, 0x48, 0x02, 0x70, 0x8C, 0xF7, 0x11, 0xB8, 0x4C, 0x5E, 0x0D, 0x00, 0x03, 0x01, 0x0C, 0xF8, 0x04, 0x0D, 0x00, 0x02, 0xF0, 0x2E, 0xFF, 0x10, 0xBD, 0x00, 0x00, 0x03, 0x01, 0x14, 0x00, 0x05, 0x0D, 0x00, 0x15, 0x7F, 0x06, 0x2D, 0x01, 0xD0, 0xC2, 0xF8, 0x1A, 0x40, 0x86, 0xF7, 0x8B, 0xBB, 0x00, 0x00, 0x03, 0x01, 0x14, 0x10, 0x05, 0x0D, 0x00, 0x20, 0xB1, 0x08, 0x20, 0x84, 0xF8, 0xA2, 0x00, 0x96, 0xF7, 0x71, 0xB9, 0x70, 0xBD, 0x00, 0x00, 0x03, 0x01, 0x10, 0x20, 0x05, 0x0D, 0x00, 0x20, 0x46, 0x03, 0xF0, 0x07, 0xF8, 0xBD, 0xE8, 0xF0, 0x81, 0x00, 0x00, 0x03, 0x01, 0x14, 0x2C, 0x05, 0x0D, 0x00, 0xE8, 0x60, 0x01, 0x20, 0xA8, 0x76, 0x00, 0x20, 0x68, 0x76, 0x99, 0xF7, 0xF4, 0xBD, 0x00, 0x00, 0x03, 0x01, 0x10, 0x3C, 0x05, 0x0D, 0x00, 0xC8, 0xF8, 0x08, 0x10, 0x03, 0xF0, 0x72, 0xF8, 0x72, 0xF7, 0x26, 0xBF, 0x03, 0x01, 0x4C, 0x48, 0x05, 0x0D, 0x00, 0x0C, 0x49, 0x09, 0x78, 0x41, 0xB1, 0x0C, 0x49, 0x08, 0x78, 0x28, 0xB1, 0x00, 0x20, 0x08, 0x70, 0x0A, 0x49, 0x4F, 0xF0, 0x01, 0x00, 0x08, 0x70, 0x09, 0x49, 0x0C, 0x20, 0x08, 0x60, 0x09, 0x48, 0x01, 0x69, 0x41, 0xF0, 0x01, 0x01, 0x01, 0x61, 0x01, 0x68, 0x41, 0xF0, 0x01, 0x01, 0x01, 0x60, 0x00, 0x20, 0x70, 0x47, 0xDA, 0x0B, 0x21, 0x00, 0x97, 0x1E, 0x20, 0x00, 0x4E, 0x5E, 0x0D, 0x00, 0x34, 0x09, 0x64, 0x00, 0x60, 0x01, 0x65, 0x00, 0x4C, 0xFC, 0xFF, 0xBC, 0x35, 0x21, 0x00, 0x03, 0x01, 0x18, 0x90, 0x05, 0x0D, 0x00, 0x66, 0xF7, 0x6D, 0xFC, 0x18, 0xB9, 0xE0, 0x69, 0xC0, 0x02, 0x73, 0xF7, 0x7B, 0xB9, 0x73, 0xF7, 0x7A, 0xB9, 0x00, 0x00, 0x03, 0x01, 0x1C, 0xA4, 0x05, 0x0D, 0x00, 0x05, 0xD1, 0x04, 0x48, 0x00, 0x78, 0x10, 0xB9, 0x60, 0x7D, 0x56, 0xF7, 0x0B, 0xB8, 0x00, 0x00, 0x56, 0xF7, 0x12, 0xB8, 0xDB, 0x0B, 0x21, 0x00, 0x03, 0x01, 0x20, 0xBC, 0x05, 0x0D, 0x00, 0x00, 0x28, 0x08, 0xD0, 0x00, 0x29, 0x06, 0xD0, 0x88, 0x42, 0xC8, 0xBF, 0x40, 0x1A, 0xB8, 0xBF, 0x09, 0x1A, 0xF9, 0xD1, 0x70, 0x47, 0x00, 0x20, 0x70, 0x47, 0x00, 0x00, 0x03, 0x01, 0x1C, 0xD8, 0x05, 0x0D, 0x00, 0x94, 0xF8, 0x9D, 0x00, 0x20, 0xF0, 0x01, 0x00, 0x84, 0xF8, 0x9D, 0x00, 0x68, 0x03, 0x01, 0xD5, 0x6F, 0xF7, 0x52, 0xB9, 0x6F, 0xF7, 0x5A, 0xB9, 0x03, 0x01, 0x24, 0xF0, 0x05, 0x0D, 0x00, 0x08, 0xD0, 0x01, 0x06, 0x06, 0xD5, 0x94, 0xF8, 0xA8, 0x00, 0x03, 0xF0, 0xB0, 0xF8, 0xC0, 0x7E, 0xC0, 0x07, 0x03, 0xD0, 0x94, 0xF8, 0x94, 0x00, 0x6F, 0xF7, 0x83, 0xB9, 0x6F, 0xF7, 0x83, 0xB9, 0x03, 0x01, 0x2C, 0x10, 0x06, 0x0D, 0x00, 0x80, 0x7B, 0x70, 0xF7, 0xF0, 0xFB, 0x05, 0x46, 0x30, 0x68, 0xB0, 0xF8, 0xD8, 0x10, 0xA8, 0xB2, 0x70, 0xF7, 0x31, 0xFC, 0xF9, 0x88, 0x88, 0x42, 0x04, 0xDD, 0x30, 0x68, 0x90, 0xF8, 0xA8, 0x00, 0x6E, 0xF7, 0xEE, 0xBD, 0x6E, 0xF7, 0xEE, 0xBD, 0x03, 0x01, 0x16, 0x38, 0x06, 0x0D, 0x00, 0x05, 0xD0, 0x00, 0xB5, 0x6A, 0xF7, 0xF2, 0xFD, 0x6A, 0xF7, 0xFF, 0xFE, 0x00, 0xBD, 0x9E, 0xF7, 0x6E, 0xBF, 0x03, 0x01, 0x16, 0x4A, 0x06, 0x0D, 0x00, 0x08, 0xB9, 0x84, 0xF8, 0x44, 0x60, 0xF8, 0xB2, 0x84, 0x4C, 0xFC, 0xFF, 0xB7, 0x36, 0x21, 0x00, 0xF8, 0x3E, 0x00, 0x9E, 0xF7, 0x3A, 0xBE, 0x00, 0x00, 0x03, 0x01, 0x14, 0x5C, 0x06, 0x0D, 0x00, 0x84, 0xF8, 0x88, 0x00, 0x01, 0x20, 0x84, 0xF8, 0x21, 0x00, 0x7D, 0xF7, 0x1F, 0xBC, 0x00, 0x00, 0x03, 0x01, 0x14, 0x6C, 0x06, 0x0D, 0x00, 0x02, 0x2D, 0xBD, 0xE8, 0x70, 0x40, 0x01, 0xD0, 0x6B, 0xF7, 0xF4, 0xBC, 0x6B, 0xF7, 0x5A, 0xBD, 0x03, 0x01, 0x10, 0x7C, 0x06, 0x0D, 0x00, 0x20, 0x46, 0x03, 0xF0, 0x89, 0xF8, 0x84, 0xF7, 0xC0, 0xB8, 0x00, 0x00, 0x03, 0x01, 0x0A, 0x88, 0x06, 0x0D, 0x00, 0x03, 0xF0, 0x8A, 0xFA, 0x70, 0xBD, 0x03, 0x01, 0x0A, 0x8E, 0x06, 0x0D, 0x00, 0x03, 0xF0, 0xB4, 0xFA, 0x10, 0xBD, 0x03, 0x01, 0x08, 0x94, 0x06, 0x0D, 0x00, 0x10, 0xB5, 0x10, 0xBD, 0x03, 0x01, 0x08, 0x98, 0x06, 0x0D, 0x00, 0x03, 0xF0, 0x1A, 0xBB, 0x03, 0x01, 0x0C, 0x9C, 0x06, 0x0D, 0x00, 0x03, 0xF0, 0x19, 0xFB, 0x10, 0xBD, 0x00, 0x00, 0x03, 0x01, 0x0A, 0xA4, 0x06, 0x0D, 0x00, 0x03, 0xF0, 0xB5, 0xFB, 0x70, 0xBD, 0x03, 0x01, 0x14, 0xAA, 0x06, 0x0D, 0x00, 0x0F, 0xB4, 0x03, 0xF0, 0xDE, 0xFB, 0x0F, 0xBC, 0xBD, 0xE8, 0x10, 0x40, 0x9D, 0xF7, 0x1C, 0xBB, 0x03, 0x01, 0x1A, 0xBA, 0x06, 0x0D, 0x00, 0x00, 0x20, 0x0F, 0xB4, 0x03, 0xF0, 0x55, 0xFC, 0x0F, 0xBC, 0x86, 0xF7, 0x66, 0xFA, 0x20, 0x68, 0x8B, 0xF7, 0x3F, 0xB8, 0x00, 0x00, 0x03, 0x01, 0x0C, 0xD0, 0x06, 0x0D, 0x00, 0x03, 0xF0, 0x36, 0xFF, 0xBD, 0xE8, 0xF0, 0x81, 0x03, 0x01, 0x0C, 0xD8, 0x06, 0x0D, 0x00, 0xBD, 0xE8, 0xF0, 0x4F, 0x04, 0xF0, 0xA9, 0xB8, 0x03, 0x01, 0x10, 0xE0, 0x06, 0x0D, 0x00, 0x62, 0xF7, 0x99, 0xFB, 0xAD, 0xF8, 0x0C, 0x00, 0x64, 0xF7, 0x46, 0xBB, 0x4C, 0xFC, 0xFF, 0xB2, 0x37, 0x21, 0x00, 0x03, 0x01, 0x0C, 0xEC, 0x06, 0x0D, 0x00, 0x04, 0xF0, 0x3D, 0xF9, 0x64, 0xF7, 0x9F, 0xB8, 0x03, 0x01, 0x20, 0xF4, 0x06, 0x0D, 0x00, 0x29, 0x46, 0x32, 0x46, 0x04, 0xF0, 0x2D, 0xFA, 0x06, 0x46, 0x2C, 0xB1, 0x39, 0x46, 0x04, 0xF0, 0x1B, 0xFA, 0x07, 0x46, 0x62, 0xF7, 0x26, 0xBF, 0x62, 0xF7, 0x2C, 0xBF, 0x03, 0x01, 0x14, 0x10, 0x07, 0x0D, 0x00, 0x00, 0x2D, 0x03, 0xD0, 0x05, 0x2D, 0x01, 0xD0, 0x63, 0xF7, 0x42, 0xB8, 0xBD, 0xE8, 0xF0, 0x81, 0x03, 0x01, 0x0A, 0x20, 0x07, 0x0D, 0x00, 0x04, 0xF0, 0x2A, 0xFB, 0x70, 0xBD, 0x03, 0x01, 0x12, 0x26, 0x07, 0x0D, 0x00, 0x02, 0xD1, 0x01, 0x20, 0x4B, 0xF7, 0xED, 0xBF, 0x04, 0xF0, 0x6C, 0xFB, 0x10, 0xBD, 0x03, 0x01, 0x20, 0x34, 0x07, 0x0D, 0x00, 0x01, 0x20, 0x60, 0xF3, 0x0F, 0x24, 0x04, 0xF0, 0xFE, 0x00, 0x5C, 0xF7, 0x88, 0xFD, 0x41, 0xF7, 0xB3, 0xF8, 0x08, 0xB1, 0x04, 0xF0, 0x98, 0xFD, 0x5C, 0xF7, 0xF2, 0xBD, 0x03, 0x01, 0x14, 0x50, 0x07, 0x0D, 0x00, 0x02, 0xF0, 0x12, 0xFE, 0x20, 0x46, 0x29, 0x46, 0x74, 0xF7, 0x92, 0xFC, 0x4F, 0xF7, 0xD8, 0xBF, 0x03, 0x01, 0x0A, 0x60, 0x07, 0x0D, 0x00, 0x05, 0xF0, 0x28, 0xF9, 0x70, 0xBD, 0x03, 0x01, 0x0A, 0x66, 0x07, 0x0D, 0x00, 0x05, 0xF0, 0x59, 0xF9, 0x70, 0xBD, 0x03, 0x01, 0x10, 0x6C, 0x07, 0x0D, 0x00, 0x19, 0xB1, 0x04, 0x46, 0x00, 0x20, 0x82, 0xF7, 0x2D, 0xBB, 0x70, 0xBD, 0x03, 0x01, 0x2C, 0x78, 0x07, 0x0D, 0x00, 0x99, 0xF8, 0x00, 0x30, 0x4B, 0xB9, 0x05, 0xB4, 0x05, 0xF0, 0x80, 0xF9, 0x03, 0x00, 0x05, 0xBC, 0x1B, 0xB1, 0x46, 0xEA, 0x03, 0x06, 0x62, 0xF7, 0xC1, 0xB9, 0x02, 0x4B, 0x02, 0xEB, 0x42, 0x02, 0x62, 0xF7, 0x4C, 0xFC, 0xFF, 0xAD, 0x38, 0x21, 0x00, 0x75, 0xB9, 0x8E, 0x5E, 0x08, 0x00, 0x03, 0x01, 0x0C, 0xA0, 0x07, 0x0D, 0x00, 0x00, 0x88, 0xC0, 0xF5, 0x58, 0x20, 0x10, 0xBD, 0x03, 0x01, 0x0C, 0xA8, 0x07, 0x0D, 0x00, 0x05, 0xF0, 0x7E, 0xF9, 0x70, 0xBD, 0x00, 0x00, 0x03, 0x01, 0x14, 0xB0, 0x07, 0x0D, 0x00, 0x20, 0x46, 0x02, 0x49, 0x32, 0xF7, 0x8F, 0xFC, 0xA6, 0xF7, 0x99, 0xBC, 0x4D, 0x5B, 0x0D, 0x00, 0x03, 0x01, 0x14, 0xC0, 0x07, 0x0D, 0x00, 0x05, 0xF0, 0x8E, 0xF9, 0x01, 0x48, 0x02, 0x24, 0xA5, 0xF7, 0xDE, 0xBF, 0x6C, 0x9F, 0x20, 0x00, 0x03, 0x01, 0x0C, 0xD0, 0x07, 0x0D, 0x00, 0x05, 0xF0, 0xE6, 0xF9, 0x32, 0xF7, 0xC0, 0xBB, 0x03, 0x01, 0x1C, 0xD8, 0x07, 0x0D, 0x00, 0x04, 0x46, 0x0D, 0x46, 0x05, 0xF0, 0xEA, 0xF9, 0x10, 0xB1, 0x02, 0x4A, 0x32, 0xF7, 0xFF, 0xBC, 0x70, 0xBD, 0x00, 0x00, 0xC4, 0x18, 0x20, 0x00, 0x03, 0x01, 0x10, 0xF0, 0x07, 0x0D, 0x00, 0x02, 0x28, 0x01, 0xD9, 0x4A, 0xF7, 0x04, 0xBF, 0x4A, 0xF7, 0x05, 0xBF, 0x03, 0x01, 0x0E, 0xFC, 0x07, 0x0D, 0x00, 0x20, 0x46, 0x05, 0xF0, 0x37, 0xFA, 0x4C, 0xF7, 0x10, 0xB8, 0x03, 0x01, 0x12, 0x06, 0x08, 0x0D, 0x00, 0x20, 0x46, 0x29, 0x46, 0x05, 0xF0, 0x4C, 0xFA, 0xBD, 0xE8, 0xF0, 0x81, 0x00, 0x00, 0x03, 0x01, 0x14, 0x14, 0x08, 0x0D, 0x00, 0x2A, 0x20, 0x20, 0x62, 0x20, 0x46, 0x05, 0xF0, 0x6B, 0xFA, 0x02, 0x28, 0x4A, 0xF7, 0x2D, 0xBE, 0x03, 0x01, 0x84, 0x01, 0x24, 0x08, 0x0D, 0x00, 0x70, 0xB5, 0x04, 0x46, 0x5C, 0xF7, 0x12, 0xF8, 0x17, 0x4D, 0x95, 0xF8, 0xD8, 0x01, 0x38, 0xB3, 0x16, 0x48, 0x17, 0x4A, 0x41, 0x68, 0x41, 0xF3, 0x80, 0x10, 0x40, 0x1C, 0x10, 0x60, 0xC4, 0xEB, 0x04, 0x10, 0x14, 0x4C, 0xFC, 0xFF, 0xA8, 0x39, 0x21, 0x00, 0x4A, 0x00, 0xEB, 0x84, 0x10, 0x02, 0xEB, 0x80, 0x00, 0x90, 0xF8, 0xC0, 0x20, 0x11, 0x48, 0x07, 0x2A, 0x16, 0xD0, 0x11, 0x4A, 0x12, 0x68, 0x52, 0x1E, 0x02, 0x60, 0x20, 0x46, 0xC5, 0xF8, 0x0C, 0x11, 0x5B, 0xF7, 0xA9, 0xFC, 0x74, 0xF7, 0xF5, 0xFD, 0x95, 0xF8, 0xD9, 0x11, 0x41, 0xF0, 0x01, 0x01, 0x85, 0xF8, 0xD9, 0x11, 0x74, 0xF7, 0xF1, 0xFD, 0x00, 0x20, 0x70, 0xBD, 0x03, 0x20, 0x70, 0xBD, 0x01, 0x22, 0xE9, 0xE7, 0x80, 0x01, 0x21, 0x00, 0x70, 0x1D, 0x20, 0x00, 0xA4, 0x35, 0x20, 0x00, 0xAC, 0x75, 0x20, 0x00, 0xA0, 0x31, 0x20, 0x00, 0xA8, 0x31, 0x20, 0x00, 0x03, 0x01, 0x44, 0xA4, 0x08, 0x0D, 0x00, 0x70, 0xB5, 0x0C, 0x46, 0xB0, 0xF9, 0x20, 0x10, 0x40, 0x8C, 0x15, 0x46, 0x1E, 0x46, 0x08, 0x18, 0x0B, 0xD5, 0x40, 0x42, 0x19, 0x46, 0x70, 0xF7, 0x4D, 0xFA, 0x22, 0x46, 0x33, 0x46, 0x29, 0x46, 0xBD, 0xE8, 0x70, 0x40, 0x10, 0x46, 0x70, 0xF7, 0x47, 0xB8, 0x19, 0x46, 0x70, 0xF7, 0x42, 0xFA, 0x22, 0x46, 0x33, 0x46, 0x29, 0x46, 0xBD, 0xE8, 0x70, 0x40, 0x10, 0x46, 0x70, 0xF7, 0x30, 0xB9, 0x03, 0x01, 0x1C, 0xE4, 0x08, 0x0D, 0x00, 0x10, 0xB5, 0x74, 0xF7, 0xB8, 0xFD, 0x04, 0x46, 0x30, 0xF7, 0xE4, 0xFC, 0x20, 0x46, 0xBD, 0xE8, 0x10, 0x40, 0x74, 0xF7, 0xB4, 0xBD, 0x00, 0x00, 0x03, 0x01, 0x28, 0xFC, 0x08, 0x0D, 0x00, 0x10, 0xB5, 0x07, 0x4B, 0x00, 0x22, 0x53, 0xF8, 0x22, 0x40, 0x8C, 0x42, 0x02, 0xD1, 0x40, 0xF0, 0x03, 0x00, 0x10, 0xBD, 0x52, 0x1C, 0x0A, 0x2A, 0xF5, 0xDB, 0x40, 0xF0, 0x01, 0x00, 0x10, 0xBD, 0x70, 0x5D, 0x0D, 0x00, 0x03, 0x01, 0x20, 0x20, 0x09, 0x0D, 0x00, 0x41, 0x7C, 0x02, 0x29, 0x08, 0xD0, 0x4C, 0xFC, 0xFF, 0xA3, 0x3A, 0x21, 0x00, 0x03, 0x29, 0x06, 0xD0, 0x00, 0x7C, 0x16, 0x28, 0x03, 0xD0, 0x17, 0x28, 0x01, 0xD0, 0x00, 0x20, 0x70, 0x47, 0x01, 0x20, 0x70, 0x47, 0x03, 0x01, 0x84, 0x01, 0x3C, 0x09, 0x0D, 0x00, 0x2D, 0xE9, 0xFE, 0x43, 0x1B, 0x4C, 0x66, 0x78, 0xA0, 0x78, 0x08, 0xB1, 0x06, 0x46, 0x22, 0xE0, 0x84, 0xF7, 0xEE, 0xF9, 0x08, 0xB1, 0x26, 0x78, 0x1D, 0xE0, 0x17, 0x48, 0x00, 0x25, 0xA0, 0x46, 0xD0, 0xE9, 0x00, 0x12, 0x80, 0x68, 0x00, 0x91, 0xCD, 0xE9, 0x01, 0x20, 0x6F, 0x46, 0x57, 0xF8, 0x25, 0x00, 0x04, 0x68, 0x07, 0xE0, 0x20, 0x1F, 0xFF, 0xF7, 0xD4, 0xFF, 0x10, 0xB1, 0x98, 0xF8, 0x00, 0x60, 0x04, 0xE0, 0x24, 0x68, 0x57, 0xF8, 0x25, 0x00, 0xA0, 0x42, 0xF3, 0xD1, 0x6D, 0x1C, 0xED, 0xB2, 0x03, 0x2D, 0xEB, 0xD3, 0x09, 0x48, 0x01, 0x78, 0x8E, 0x42, 0x07, 0xD0, 0x06, 0x70, 0x03, 0xB0, 0x31, 0x46, 0xBD, 0xE8, 0xF0, 0x43, 0x02, 0x20, 0x74, 0xF7, 0x68, 0xBC, 0xBD, 0xE8, 0xFE, 0x83, 0x00, 0x00, 0x31, 0x0A, 0x21, 0x00, 0x60, 0x5D, 0x0D, 0x00, 0x98, 0x5D, 0x0D, 0x00, 0x03, 0x01, 0x12, 0xBC, 0x09, 0x0D, 0x00, 0x2F, 0x48, 0x00, 0x21, 0x01, 0x61, 0x41, 0x61, 0x81, 0x61, 0xC1, 0x61, 0x70, 0x47, 0x03, 0x01, 0x1A, 0xCA, 0x09, 0x0D, 0x00, 0x00, 0x20, 0x2B, 0x4B, 0x01, 0x46, 0x10, 0x33, 0x53, 0xF8, 0x21, 0x20, 0x49, 0x1C, 0x10, 0x43, 0x04, 0x29, 0xF9, 0xD3, 0x70, 0x47, 0x03, 0x01, 0x90, 0x01, 0xE0, 0x09, 0x0D, 0x00, 0xFE, 0xB5, 0x26, 0x4E, 0x04, 0x00, 0x1F, 0x46, 0x4F, 0xF0, 0x00, 0x05, 0x06, 0xF1, 0x10, 0x06, 0x04, 0xD0, 0x01, 0x2C, 0x02, 0xD0, 0x02, 0x28, 0x2D, 0xD0, 0x34, 0xE0, 0x10, 0x68, 0x00, 0x90, 0x90, 0x88, 0xAD, 0x4C, 0xFC, 0xFF, 0x9E, 0x3B, 0x21, 0x00, 0xF8, 0x04, 0x00, 0x02, 0xAA, 0x68, 0x46, 0x71, 0xF7, 0x7F, 0xFF, 0x1C, 0x49, 0x09, 0x78, 0x88, 0x42, 0x27, 0xD2, 0x80, 0x28, 0x25, 0xD2, 0x41, 0x09, 0x00, 0xF0, 0x1F, 0x00, 0x01, 0x22, 0x56, 0xF8, 0x21, 0x30, 0x02, 0xFA, 0x00, 0xF2, 0x0C, 0xB1, 0x93, 0x43, 0x0F, 0xE0, 0x13, 0x42, 0x01, 0xD0, 0x17, 0x25, 0x17, 0xE0, 0xDF, 0xF8, 0x40, 0xC0, 0x07, 0xF0, 0x01, 0x07, 0x87, 0x40, 0x5C, 0xF8, 0x21, 0x40, 0x94, 0x43, 0x3C, 0x43, 0x4C, 0xF8, 0x21, 0x40, 0x13, 0x43, 0x46, 0xF8, 0x21, 0x30, 0x08, 0xE0, 0x00, 0x20, 0x01, 0x46, 0x46, 0xF8, 0x20, 0x10, 0x40, 0x1C, 0x04, 0x28, 0xFA, 0xD3, 0x00, 0xE0, 0x12, 0x25, 0x28, 0x46, 0xFE, 0xBD, 0x03, 0x01, 0x1C, 0x6C, 0x0A, 0x0D, 0x00, 0x00, 0x28, 0x04, 0xD0, 0x09, 0x38, 0x20, 0xF0, 0x03, 0x00, 0x74, 0xF7, 0x9A, 0xBE, 0x70, 0x47, 0x08, 0x67, 0x0D, 0x00, 0x4B, 0x29, 0x20, 0x00, 0x03, 0x01, 0xC8, 0x01, 0x84, 0x0A, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x47, 0x04, 0x46, 0x90, 0xF8, 0xD2, 0x00, 0x00, 0xF0, 0x35, 0xFA, 0x06, 0x46, 0xB4, 0xF8, 0x48, 0x00, 0xB4, 0xF8, 0x4A, 0x10, 0x88, 0x42, 0x03, 0xD0, 0x94, 0xF8, 0x20, 0x21, 0xA7, 0xF7, 0x02, 0xFF, 0x45, 0x00, 0x35, 0x80, 0x4A, 0xD0, 0xB4, 0xF8, 0x22, 0x11, 0x20, 0x46, 0x64, 0xF7, 0x3F, 0xFA, 0x82, 0x46, 0x20, 0x6C, 0x00, 0x26, 0x20, 0xF4, 0x80, 0x20, 0x4F, 0xF6, 0xFF, 0x79, 0x20, 0x64, 0x04, 0xEB, 0x46, 0x07, 0xB7, 0xF8, 0x28, 0x01, 0x48, 0x45, 0x37, 0xD0, 0x41, 0x00, 0x50, 0x46, 0x6F, 0xF7, 0x8E, 0xFF, 0xB0, 0xFB, 0xF5, 0xF1, 0x80, 0x46, 0x05, 0xFB, 0x11, 0x80, 0xA7, 0xF8, 0x28, 0x01, 0x5F, 0xEA, 0x48, 0x10, 0x15, 0x4C, 0xFC, 0xFF, 0x99, 0x3C, 0x21, 0x00, 0xD4, 0x94, 0xF8, 0xD2, 0x00, 0x66, 0xF7, 0xAC, 0xF9, 0x40, 0x01, 0x20, 0xD5, 0x4F, 0xF0, 0x80, 0x60, 0xB0, 0xFB, 0xF5, 0xF1, 0x69, 0x43, 0x40, 0x46, 0x70, 0xF7, 0xFD, 0xF8, 0xB0, 0xFB, 0xF5, 0xF1, 0x05, 0xFB, 0x11, 0x01, 0xA7, 0xF8, 0x28, 0x11, 0x40, 0x01, 0x10, 0xD5, 0xB7, 0xF8, 0x28, 0x01, 0x02, 0x23, 0x2A, 0x46, 0x00, 0x21, 0x63, 0xF7, 0x91, 0xFE, 0xA7, 0xF8, 0x28, 0x01, 0x01, 0x20, 0xB0, 0x40, 0x21, 0x6C, 0xC0, 0xF3, 0x00, 0x00, 0x41, 0xEA, 0x80, 0x40, 0x20, 0x64, 0x76, 0x1C, 0x06, 0x2E, 0xC1, 0xD3, 0xBD, 0xE8, 0xF0, 0x87, 0x03, 0x01, 0x96, 0x03, 0x48, 0x0B, 0x0D, 0x00, 0x2D, 0xE9, 0xFC, 0x5F, 0x06, 0x46, 0x80, 0x78, 0xD6, 0xF8, 0x04, 0xA0, 0xF1, 0x78, 0x00, 0xF0, 0x0F, 0x04, 0x0A, 0xEB, 0x01, 0x00, 0x4F, 0xF0, 0x00, 0x08, 0xC7, 0x79, 0xB4, 0x48, 0xDF, 0xF8, 0xD4, 0xB2, 0x01, 0x25, 0x00, 0x78, 0xC1, 0x46, 0x48, 0xB9, 0x04, 0x2C, 0x07, 0xD0, 0xAE, 0xF7, 0x77, 0xFA, 0x20, 0xB1, 0xDB, 0xF8, 0x00, 0x00, 0x00, 0x21, 0x80, 0xF8, 0xFC, 0x11, 0xA7, 0xF7, 0xFF, 0xFA, 0x01, 0x28, 0x01, 0xD1, 0xF8, 0x07, 0x64, 0xD1, 0xAE, 0xF7, 0x69, 0xFA, 0x00, 0x28, 0x60, 0xD0, 0xA7, 0x48, 0x00, 0x78, 0x30, 0xB9, 0x04, 0x2C, 0x04, 0xD1, 0xDB, 0xF8, 0x00, 0x00, 0x90, 0xF8, 0xFC, 0x01, 0x70, 0xBB, 0xF7, 0x78, 0x51, 0x46, 0x04, 0x2C, 0x1A, 0xD1, 0xDB, 0xF8, 0x00, 0x10, 0x3A, 0x46, 0x01, 0xF5, 0x81, 0x70, 0xCD, 0xE9, 0x00, 0x01, 0x51, 0x46, 0x74, 0xF7, 0x2D, 0xFE, 0xDB, 0xF8, 0x00, 0x10, 0x00, 0x98, 0x0A, 0x7A, 0x01, 0x99, 0x38, 0x44, 0x52, 0x1C, 0x09, 0x31, 0x74, 0xF7, 0x23, 0xFE, 0xDB, 0xF8, 0x00, 0x10, 0x4C, 0xFC, 0xFF, 0x94, 0x3D, 0x21, 0x00, 0x08, 0x7A, 0x01, 0xF5, 0x81, 0x71, 0x38, 0x44, 0xC7, 0xB2, 0x92, 0x48, 0x00, 0x78, 0x00, 0x28, 0xB0, 0x78, 0x40, 0xEA, 0x07, 0x20, 0x1D, 0xD0, 0x01, 0xF0, 0x1E, 0xFB, 0xC5, 0xB2, 0x8F, 0x48, 0x24, 0xB1, 0x06, 0x2C, 0x02, 0xD0, 0x04, 0x2C, 0x05, 0xD0, 0x26, 0xE0, 0x05, 0x70, 0x30, 0x46, 0xA2, 0xF7, 0xFA, 0xFF, 0x21, 0xE0, 0x00, 0x78, 0x85, 0x42, 0x1E, 0xD0, 0x25, 0xEA, 0x00, 0x01, 0x11, 0xF0, 0x03, 0x08, 0x45, 0xEA, 0x00, 0x05, 0x17, 0xD0, 0x80, 0x45, 0x15, 0xD0, 0x4F, 0xF0, 0x01, 0x09, 0x12, 0xE0, 0xAE, 0xF7, 0x24, 0xF9, 0xF0, 0xB1, 0x01, 0x20, 0x24, 0xB1, 0x06, 0x2C, 0x02, 0xD0, 0x04, 0x2C, 0x05, 0xD0, 0x06, 0xE0, 0xDB, 0xF8, 0x00, 0x10, 0x81, 0xF8, 0xFC, 0x01, 0x01, 0xE0, 0x4F, 0xF0, 0x01, 0x09, 0x7A, 0x49, 0x08, 0x70, 0x7A, 0x4F, 0x38, 0x68, 0xC0, 0x05, 0x15, 0xD5, 0xBA, 0xF1, 0x00, 0x0F, 0x12, 0xD0, 0x78, 0x48, 0x80, 0x7A, 0xC0, 0x06, 0x0E, 0xD5, 0x30, 0x46, 0xA2, 0xF7, 0xB2, 0xFF, 0x2D, 0xE0, 0xA7, 0xF7, 0x37, 0xFB, 0x01, 0x28, 0x29, 0xD1, 0x0C, 0xB1, 0x06, 0x2C, 0x26, 0xD1, 0x30, 0x46, 0xA2, 0xF7, 0xBE, 0xFF, 0x22, 0xE0, 0x01, 0x2C, 0x03, 0xD1, 0x30, 0x46, 0xA2, 0xF7, 0x89, 0xFF, 0xB0, 0xB1, 0xB9, 0xF1, 0x00, 0x0F, 0x0A, 0xD0, 0x5F, 0xEA, 0xC8, 0x70, 0x07, 0xD0, 0x69, 0x48, 0x00, 0x78, 0x10, 0xB1, 0x68, 0x48, 0xB0, 0xF7, 0x21, 0xFF, 0xA2, 0xF7, 0x60, 0xFF, 0x5F, 0x48, 0x00, 0x78, 0x10, 0xB1, 0x55, 0xB1, 0xE8, 0x07, 0x08, 0xD0, 0x01, 0x20, 0xBD, 0xE8, 0xFC, 0x9F, 0x38, 0x68, 0x40, 0x05, 0x02, 0xD5, 0x30, 0x46, 0xA1, 0xF7, 0xF3, 0xFD, 0x00, 0x20, 0xF5, 0xE7, 0x03, 0x01, 0x2A, 0x4C, 0xFC, 0xFF, 0x8F, 0x3E, 0x21, 0x00, 0xDA, 0x0C, 0x0D, 0x00, 0x10, 0xB5, 0x0A, 0xE0, 0x5D, 0x48, 0x89, 0xF7, 0x3E, 0xFF, 0x04, 0x46, 0x40, 0x68, 0x08, 0xB1, 0x74, 0xF7, 0x60, 0xFD, 0x20, 0x46, 0x74, 0xF7, 0x5D, 0xFD, 0x57, 0x48, 0x89, 0xF7, 0x26, 0xFF, 0x00, 0x28, 0xEF, 0xD0, 0x10, 0xBD, 0x03, 0x01, 0x1C, 0x00, 0x0D, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0x8B, 0xF7, 0xB3, 0xFC, 0x00, 0x28, 0x04, 0xD1, 0x60, 0x68, 0xBD, 0xE8, 0x10, 0x40, 0x74, 0xF7, 0x4C, 0xBD, 0x10, 0xBD, 0x03, 0x01, 0x10, 0x18, 0x0D, 0x0D, 0x00, 0x01, 0x28, 0x01, 0xD0, 0x00, 0xF0, 0xDD, 0xB8, 0x00, 0xF0, 0xA2, 0xB8, 0x03, 0x01, 0xC8, 0x02, 0x24, 0x0D, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x5F, 0x00, 0x26, 0x80, 0x46, 0x0F, 0x46, 0x34, 0x46, 0xAC, 0xF7, 0x30, 0xFA, 0x58, 0xB1, 0x00, 0x25, 0x5F, 0xEA, 0x08, 0x00, 0x09, 0xD0, 0x01, 0x28, 0x0F, 0xD0, 0x10, 0x28, 0x15, 0xD0, 0xB8, 0xF1, 0x11, 0x0F, 0x40, 0xD1, 0x18, 0xE0, 0x01, 0x25, 0xF2, 0xE7, 0xA7, 0xF7, 0xC3, 0xFA, 0x81, 0x46, 0x15, 0x20, 0xA3, 0xF7, 0xF5, 0xFB, 0x06, 0x46, 0x0A, 0xE0, 0xAD, 0xF7, 0x83, 0xFC, 0x81, 0x46, 0x14, 0x20, 0xA3, 0xF7, 0xED, 0xFB, 0x06, 0x46, 0x03, 0xE0, 0xA7, 0xF7, 0xB3, 0xFA, 0x81, 0x46, 0x3C, 0x46, 0xB9, 0xF1, 0x00, 0x0F, 0x26, 0xD0, 0x18, 0xF0, 0xF0, 0x0F, 0xDF, 0xF8, 0xD0, 0xA0, 0xDF, 0xF8, 0xD0, 0xB0, 0xDF, 0xF8, 0xD0, 0x80, 0xDF, 0xF8, 0xD0, 0x90, 0x1D, 0xD0, 0x98, 0xF8, 0x00, 0x00, 0x46, 0x46, 0x01, 0x28, 0x16, 0xD1, 0x14, 0xB1, 0x0D, 0xB1, 0xAB, 0xF7, 0xEA, 0xFF, 0x4F, 0x46, 0xB9, 0xF8, 0x00, 0x00, 0xA7, 0xF7, 0xDB, 0xF9, 0xBA, 0xF8, 0x00, 0x00, 0xA7, 0xF7, 0xDB, 0xF9, 0x34, 0x4C, 0xFC, 0xFF, 0x8A, 0x3F, 0x21, 0x00, 0xB1, 0x38, 0x88, 0xE0, 0x83, 0x1D, 0xB1, 0x9B, 0xF8, 0x0B, 0x00, 0xAC, 0xF7, 0x09, 0xF8, 0x00, 0x20, 0x30, 0x70, 0xBD, 0xE8, 0xF0, 0x9F, 0x00, 0x2E, 0xFB, 0xD0, 0xAD, 0xF7, 0x93, 0xFC, 0x06, 0x46, 0xA7, 0xF7, 0xCC, 0xF9, 0x06, 0xFB, 0x00, 0xF7, 0xA7, 0xF7, 0xCC, 0xF9, 0x06, 0x46, 0xAD, 0xF7, 0x91, 0xFC, 0x46, 0x43, 0xB7, 0x42, 0xEC, 0xD9, 0xA7, 0xF7, 0xC4, 0xF9, 0xAA, 0xF8, 0x00, 0x00, 0xA7, 0xF7, 0xBC, 0xF9, 0xA9, 0xF8, 0x00, 0x00, 0x14, 0xB1, 0x0D, 0xB1, 0xAB, 0xF7, 0xB8, 0xFF, 0xAD, 0xF7, 0x80, 0xFC, 0xA7, 0xF7, 0xAA, 0xF9, 0xAD, 0xF7, 0x74, 0xFC, 0xA7, 0xF7, 0xAA, 0xF9, 0x3C, 0xB1, 0xAD, 0xF7, 0x77, 0xFC, 0xE0, 0x83, 0x1D, 0xB1, 0x9B, 0xF8, 0x0B, 0x00, 0xAB, 0xF7, 0xD7, 0xFF, 0x01, 0x21, 0x88, 0xF8, 0x00, 0x10, 0xCB, 0xE7, 0x00, 0x00, 0x2C, 0x5E, 0x0D, 0x00, 0x00, 0x33, 0x20, 0x00, 0x99, 0x5D, 0x0D, 0x00, 0xF5, 0x32, 0x20, 0x00, 0x9C, 0x29, 0x20, 0x00, 0x58, 0x34, 0x20, 0x00, 0x90, 0x95, 0x20, 0x00, 0xFC, 0x88, 0x20, 0x00, 0x3A, 0x33, 0x20, 0x00, 0xF8, 0x5B, 0x20, 0x00, 0x38, 0x33, 0x20, 0x00, 0x3C, 0x33, 0x20, 0x00, 0x03, 0x01, 0x76, 0x68, 0x0E, 0x0D, 0x00, 0x10, 0xB5, 0xA1, 0xF7, 0x77, 0xFD, 0x1F, 0x48, 0x00, 0x68, 0x80, 0x05, 0x01, 0xD5, 0xA0, 0xF7, 0xB1, 0xFF, 0xA7, 0xF7, 0x85, 0xF9, 0x01, 0x28, 0x01, 0xD1, 0xA9, 0xF7, 0x13, 0xF9, 0x00, 0x21, 0x01, 0x20, 0xFF, 0xF7, 0x4B, 0xFF, 0xAB, 0xF7, 0x4B, 0xFF, 0x17, 0x48, 0x17, 0x49, 0x00, 0x78, 0x00, 0x28, 0x08, 0x68, 0x02, 0xD0, 0x40, 0xF4, 0x00, 0x70, 0x01, 0xE0, 0x20, 0xF4, 0x00, 0x70, 0x08, 0x60, 0x74, 0xF7, 0xD6, 0xFA, 0x04, 0x4C, 0xFC, 0xFF, 0x85, 0x40, 0x21, 0x00, 0x46, 0xAD, 0xF7, 0xDC, 0xFB, 0x60, 0xB1, 0xAD, 0xF7, 0x33, 0xFC, 0x48, 0xB9, 0x14, 0x20, 0xA3, 0xF7, 0x43, 0xFB, 0x28, 0xB1, 0x06, 0x20, 0xAD, 0xF7, 0xD5, 0xFB, 0x0B, 0x49, 0x01, 0x20, 0x08, 0x70, 0x20, 0x46, 0xBD, 0xE8, 0x10, 0x40, 0x74, 0xF7, 0xC4, 0xBA, 0x03, 0x01, 0x26, 0xDA, 0x0E, 0x0D, 0x00, 0x10, 0xB5, 0xA7, 0xF7, 0xB1, 0xF9, 0x00, 0x21, 0xBD, 0xE8, 0x10, 0x40, 0x11, 0x20, 0xFF, 0xF7, 0x1C, 0xBF, 0x9C, 0x29, 0x20, 0x00, 0xF1, 0x32, 0x20, 0x00, 0xFC, 0x32, 0x20, 0x00, 0xF3, 0x32, 0x20, 0x00, 0x03, 0x01, 0x20, 0xFC, 0x0E, 0x0D, 0x00, 0x04, 0x49, 0x09, 0x78, 0x88, 0x42, 0x03, 0xD2, 0x03, 0x49, 0x01, 0xEB, 0x40, 0x00, 0x70, 0x47, 0x00, 0x20, 0x70, 0x47, 0x49, 0x29, 0x20, 0x00, 0x28, 0x67, 0x0D, 0x00, 0x03, 0x01, 0x0C, 0x18, 0x0F, 0x0D, 0x00, 0x38, 0x49, 0x37, 0x48, 0x08, 0x60, 0x70, 0x47, 0x03, 0x01, 0x14, 0x20, 0x0F, 0x0D, 0x00, 0x01, 0x29, 0x03, 0xD1, 0x4F, 0xF4, 0x48, 0x13, 0x10, 0x22, 0xDA, 0x65, 0x65, 0xF7, 0x05, 0xBE, 0x03, 0x01, 0x20, 0x30, 0x0F, 0x0D, 0x00, 0xC1, 0x7B, 0x39, 0xB9, 0x90, 0xF8, 0x8B, 0x10, 0x8A, 0x06, 0x05, 0xD5, 0x21, 0xF0, 0x20, 0x01, 0x80, 0xF8, 0x8B, 0x10, 0x01, 0x20, 0x70, 0x47, 0x00, 0x20, 0x70, 0x47, 0x03, 0x01, 0x1E, 0x4C, 0x0F, 0x0D, 0x00, 0xC1, 0x7B, 0x00, 0x29, 0x08, 0xD1, 0x90, 0xF8, 0x1D, 0x11, 0x01, 0x29, 0x04, 0xD1, 0x10, 0xF8, 0x8B, 0x1F, 0x41, 0xF0, 0x20, 0x01, 0x01, 0x70, 0x70, 0x47, 0x03, 0x01, 0x56, 0x66, 0x0F, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0x64, 0xF7, 0x86, 0xF8, 0xD4, 0xF8, 0xD4, 0x00, 0x01, 0x21, 0xAD, 0xF7, 0x6C, 0xFA, 0xD4, 0x4C, 0xFC, 0xFF, 0x80, 0x41, 0x21, 0x00, 0xF8, 0xD8, 0x00, 0x01, 0x21, 0xAD, 0xF7, 0x67, 0xFA, 0x20, 0x6D, 0x1E, 0x4A, 0x90, 0xF8, 0xD2, 0x10, 0x01, 0x20, 0x13, 0x68, 0x88, 0x40, 0x83, 0x43, 0x13, 0x60, 0x1B, 0x4A, 0x13, 0x68, 0x83, 0x43, 0x13, 0x60, 0x1A, 0x4B, 0x1A, 0x68, 0x82, 0x43, 0x08, 0x46, 0x1A, 0x60, 0x46, 0xF7, 0x2D, 0xFF, 0x20, 0x46, 0xBD, 0xE8, 0x10, 0x40, 0x4F, 0xF4, 0xAC, 0x71, 0x74, 0xF7, 0x1C, 0xBA, 0x03, 0x01, 0x24, 0xB8, 0x0F, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0x65, 0xF7, 0x24, 0xFE, 0xE0, 0x7B, 0x00, 0x28, 0x07, 0xD1, 0x11, 0x48, 0x01, 0x68, 0x11, 0x4A, 0x21, 0xF0, 0xFF, 0x01, 0x12, 0x78, 0x11, 0x43, 0x01, 0x60, 0x10, 0xBD, 0x03, 0x01, 0x40, 0xD8, 0x0F, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0x64, 0xF7, 0xEE, 0xFF, 0xE0, 0x7B, 0x01, 0x28, 0x07, 0xD1, 0x09, 0x48, 0x01, 0x68, 0x09, 0x4A, 0x21, 0xF0, 0xFF, 0x01, 0x12, 0x78, 0x11, 0x43, 0x01, 0x60, 0x10, 0xBD, 0x9C, 0x5D, 0x0D, 0x00, 0x2C, 0x29, 0x20, 0x00, 0x30, 0x29, 0x20, 0x00, 0x34, 0x29, 0x20, 0x00, 0x38, 0x29, 0x20, 0x00, 0x90, 0x8B, 0x31, 0x00, 0x28, 0x25, 0x20, 0x00, 0x03, 0x01, 0x74, 0x14, 0x10, 0x0D, 0x00, 0x70, 0xB5, 0x04, 0x46, 0xAE, 0xF7, 0xA4, 0xFA, 0x08, 0xB1, 0x40, 0x26, 0x00, 0xE0, 0x00, 0x26, 0x6A, 0xF7, 0x25, 0xFF, 0x10, 0xB9, 0x6A, 0xF7, 0x5C, 0xFF, 0x00, 0xB3, 0x00, 0x25, 0x94, 0xF8, 0x27, 0x00, 0x31, 0x46, 0x03, 0x28, 0x1E, 0xD0, 0x0C, 0x20, 0x6E, 0xF7, 0x67, 0xFF, 0x94, 0xF8, 0x27, 0x20, 0xC4, 0x48, 0x01, 0x2A, 0xC2, 0x49, 0x02, 0x68, 0x02, 0xEA, 0x01, 0x02, 0x02, 0x60, 0x01, 0x68, 0x12, 0xD0, 0xC0, 0x4A, 0x11, 0x43, 0x01, 0x60, 0x1D, 0x4C, 0xFC, 0xFF, 0x7B, 0x42, 0x21, 0x00, 0xB1, 0xA0, 0x7B, 0x6F, 0xF7, 0xC8, 0xFE, 0xA0, 0x61, 0x20, 0x46, 0xBD, 0xE8, 0x70, 0x40, 0xA4, 0xF7, 0xA2, 0xBC, 0x6A, 0xF7, 0x80, 0xF9, 0x01, 0x25, 0xDB, 0xE7, 0x0D, 0x20, 0xDF, 0xE7, 0x41, 0xF0, 0x80, 0x71, 0xEB, 0xE7, 0x03, 0x01, 0x10, 0x84, 0x10, 0x0D, 0x00, 0xB6, 0x49, 0x08, 0x70, 0xB6, 0x49, 0x01, 0x20, 0x08, 0x70, 0x70, 0x47, 0x03, 0x01, 0xA0, 0x02, 0x90, 0x10, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0xB4, 0x4D, 0x06, 0x46, 0x0C, 0x46, 0x29, 0x78, 0xFF, 0x20, 0x06, 0xF1, 0x1C, 0x07, 0x01, 0x29, 0x02, 0xD1, 0x38, 0x46, 0x69, 0xF7, 0xD2, 0xFA, 0xAF, 0x49, 0x0A, 0x68, 0x42, 0xF0, 0x00, 0x52, 0x0A, 0x60, 0xAE, 0x49, 0xBC, 0xB1, 0x01, 0x2C, 0x3E, 0xD0, 0x02, 0x2C, 0x4A, 0xD0, 0x03, 0x2C, 0x55, 0xD0, 0x04, 0x2C, 0x5E, 0xD0, 0x05, 0x2C, 0x6C, 0xD1, 0x96, 0xF8, 0x27, 0x00, 0x01, 0x28, 0x68, 0xD0, 0x30, 0x46, 0x6A, 0xF7, 0x17, 0xFD, 0x00, 0x28, 0x63, 0xD0, 0x30, 0x46, 0xBD, 0xE8, 0xF0, 0x41, 0xA4, 0xF7, 0x28, 0xBC, 0x2A, 0x78, 0x01, 0x2A, 0x0E, 0xD1, 0xFF, 0x28, 0x0C, 0xD0, 0x09, 0x78, 0xC1, 0xB1, 0xC0, 0xF3, 0x03, 0x11, 0x08, 0x29, 0x06, 0xD1, 0x00, 0xF0, 0x0F, 0x00, 0x00, 0xF0, 0xA6, 0xFA, 0xC0, 0xB2, 0xFF, 0xF7, 0xBB, 0xFF, 0x6B, 0xF7, 0xAF, 0xF9, 0x78, 0xB1, 0x6F, 0xF7, 0x4D, 0xFA, 0xB0, 0x42, 0x0B, 0xD1, 0x6F, 0xF7, 0x90, 0xFB, 0x40, 0xB1, 0xBD, 0xE8, 0xF0, 0x41, 0x6F, 0xF7, 0x8E, 0xB8, 0x92, 0x49, 0x01, 0xEB, 0x80, 0x00, 0x00, 0x68, 0xE9, 0xE7, 0x30, 0x46, 0xBD, 0xE8, 0xF0, 0x41, 0x6B, 0xE7, 0x09, 0x78, 0x00, 0x29, 0x32, 0xD0, 0x29, 0x78, 0x01, 0x29, 0x2F, 0xD1, 0xC0, 0xF3, 0x03, 0x4C, 0xFC, 0xFF, 0x76, 0x43, 0x21, 0x00, 0x11, 0x08, 0x29, 0x2B, 0xD1, 0x00, 0xF0, 0x0F, 0x00, 0x01, 0x21, 0x23, 0xE0, 0x38, 0x46, 0x69, 0xF7, 0xAB, 0xF9, 0x10, 0xB1, 0x04, 0x20, 0xA8, 0xF7, 0xA3, 0xFF, 0x84, 0x48, 0x00, 0x78, 0xBD, 0xE8, 0xF0, 0x41, 0xA8, 0xF7, 0x2C, 0xBF, 0x29, 0x78, 0x01, 0x29, 0x17, 0xD1, 0xFF, 0x28, 0x15, 0xD0, 0x7F, 0x48, 0x00, 0x68, 0xBD, 0xE8, 0xF0, 0x41, 0xC0, 0xB2, 0x7D, 0xE7, 0x09, 0x78, 0x00, 0x29, 0x0C, 0xD0, 0x29, 0x78, 0x01, 0x29, 0x09, 0xD1, 0xC0, 0xF3, 0x03, 0x10, 0x08, 0x28, 0x05, 0xD1, 0x00, 0x21, 0x08, 0x46, 0xBD, 0xE8, 0xF0, 0x41, 0x00, 0xF0, 0x30, 0xBA, 0xBD, 0xE8, 0xF0, 0x81, 0x03, 0x01, 0x1E, 0xAC, 0x11, 0x0D, 0x00, 0x10, 0xB5, 0x2C, 0x22, 0x73, 0x49, 0x74, 0x48, 0x89, 0xF7, 0xEA, 0xFC, 0xAF, 0xF2, 0x2B, 0x11, 0x71, 0x48, 0x01, 0x61, 0x71, 0x49, 0x08, 0x60, 0x10, 0xBD, 0x03, 0x01, 0x72, 0xC6, 0x11, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x03, 0x46, 0x08, 0x46, 0xFF, 0x29, 0xEA, 0xD0, 0x00, 0x22, 0xFF, 0x26, 0x00, 0xF1, 0x46, 0x01, 0x6C, 0x4D, 0x17, 0x46, 0x03, 0xEB, 0x43, 0x04, 0x5A, 0x29, 0x0B, 0xD8, 0x62, 0x49, 0x09, 0x78, 0x41, 0xB1, 0x00, 0xF0, 0xEA, 0xF9, 0x29, 0x68, 0x40, 0xF0, 0x80, 0x00, 0x01, 0xEB, 0x84, 0x01, 0x88, 0x71, 0xD4, 0xE7, 0xDF, 0xF8, 0x74, 0xE1, 0x6F, 0xF0, 0x18, 0x0C, 0x0E, 0xEB, 0x82, 0x01, 0x09, 0x68, 0x0C, 0xEB, 0x41, 0x01, 0x49, 0xB2, 0x43, 0x1A, 0x00, 0xD5, 0x0B, 0x1A, 0xD9, 0xB2, 0xB1, 0x42, 0x01, 0xD8, 0x17, 0x46, 0x0E, 0x46, 0x52, 0x1C, 0xD2, 0xB2, 0x05, 0x2A, 0xED, 0xD3, 0x28, 0x68, 0x00, 0xEB, 0x84, 0x00, 0x87, 0x71, 0xB9, 0xE7, 0x03, 0x01, 0x0A, 0x34, 0x4C, 0xFC, 0xFF, 0x71, 0x44, 0x21, 0x00, 0x12, 0x0D, 0x00, 0x4A, 0x48, 0x00, 0x78, 0x70, 0x47, 0x03, 0x01, 0xE2, 0x02, 0x3A, 0x12, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x05, 0x46, 0x40, 0x6C, 0x71, 0xF7, 0x74, 0xF9, 0x04, 0x00, 0xAE, 0xD0, 0x94, 0xF8, 0xD0, 0x00, 0x01, 0x21, 0x9F, 0xF7, 0x7C, 0xFE, 0x94, 0xF8, 0xD0, 0x00, 0xA4, 0xF7, 0xE9, 0xFC, 0x05, 0xF1, 0x1C, 0x00, 0x01, 0x21, 0x07, 0x46, 0x69, 0xF7, 0x13, 0xFA, 0x01, 0x21, 0x38, 0x46, 0x69, 0xF7, 0x11, 0xFA, 0x00, 0x21, 0x38, 0x46, 0x69, 0xF7, 0x44, 0xF9, 0x45, 0x48, 0x00, 0x68, 0x20, 0x65, 0x44, 0x48, 0x00, 0x1D, 0x00, 0x68, 0x43, 0x49, 0xA4, 0xF8, 0x54, 0x00, 0x41, 0x48, 0x09, 0x68, 0x0C, 0x30, 0xC1, 0xF3, 0x80, 0x11, 0x84, 0xF8, 0x56, 0x10, 0x95, 0xF8, 0x28, 0x10, 0x84, 0xF8, 0x57, 0x10, 0x00, 0x68, 0x3B, 0x4E, 0x60, 0x63, 0x10, 0x36, 0xAE, 0xF7, 0x6A, 0xF9, 0x60, 0xB1, 0x39, 0x48, 0x14, 0x30, 0x00, 0x68, 0xC0, 0x05, 0x07, 0xD5, 0x30, 0x68, 0xA0, 0x63, 0x36, 0x1D, 0x68, 0x6C, 0x71, 0xF7, 0x35, 0xF9, 0xAE, 0xF7, 0xB9, 0xF9, 0x14, 0x22, 0x31, 0x46, 0x20, 0x46, 0xA3, 0xF7, 0x25, 0xFC, 0xE0, 0x88, 0x00, 0xB3, 0x61, 0x89, 0xF1, 0xB1, 0x40, 0x00, 0xA4, 0xF8, 0xC6, 0x00, 0x94, 0xF8, 0xD0, 0x00, 0x6F, 0xF7, 0x75, 0xFD, 0xA1, 0x88, 0x01, 0x25, 0x89, 0x00, 0x09, 0x1D, 0x6F, 0xF7, 0xDA, 0xFA, 0x4F, 0xEA, 0x50, 0x00, 0xC4, 0xF8, 0xCC, 0x00, 0x41, 0x01, 0x19, 0xD5, 0xB4, 0xF8, 0xC6, 0x10, 0x80, 0xF0, 0x80, 0x60, 0xB0, 0xFB, 0xF1, 0xF2, 0x01, 0xFB, 0x12, 0x00, 0xA4, 0xF8, 0xC4, 0x00, 0x02, 0x20, 0x16, 0xE0, 0x00, 0x21, 0x38, 0x46, 0x69, 0xF7, 0xB7, 0xF9, 0x00, 0x21, 0x38, 0x46, 0x4C, 0xFC, 0xFF, 0x6C, 0x45, 0x21, 0x00, 0x69, 0xF7, 0xB5, 0xF9, 0x01, 0x21, 0x38, 0x46, 0x69, 0xF7, 0xE8, 0xF8, 0x00, 0x20, 0x39, 0xE7, 0xB4, 0xF8, 0xC6, 0x10, 0xB0, 0xFB, 0xF1, 0xF2, 0x01, 0xFB, 0x12, 0x00, 0xA4, 0xF8, 0xC4, 0x00, 0x00, 0x20, 0x84, 0xF8, 0xD4, 0x00, 0xE0, 0x78, 0x00, 0xB9, 0xE5, 0x70, 0x01, 0x20, 0x29, 0xE7, 0xFF, 0xFF, 0x00, 0xFE, 0x94, 0x83, 0x31, 0x00, 0x00, 0x00, 0x01, 0x01, 0xA5, 0x07, 0x20, 0x00, 0x10, 0x61, 0x0D, 0x00, 0x24, 0x33, 0x20, 0x00, 0x00, 0x04, 0x20, 0x00, 0x34, 0x0A, 0x21, 0x00, 0x98, 0x32, 0x20, 0x00, 0x3C, 0x1D, 0x20, 0x00, 0x88, 0x32, 0x20, 0x00, 0xB8, 0xA3, 0x08, 0x00, 0x28, 0x68, 0x0D, 0x00, 0x8C, 0x32, 0x20, 0x00, 0x84, 0x32, 0x20, 0x00, 0x00, 0x0A, 0x37, 0x00, 0x98, 0x8B, 0x31, 0x00, 0x03, 0x01, 0x0E, 0x98, 0x13, 0x0D, 0x00, 0x14, 0x49, 0x13, 0x48, 0x08, 0x60, 0xFF, 0xF7, 0x0D, 0xBB, 0x03, 0x01, 0x2A, 0xA2, 0x13, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0xA6, 0xF7, 0x41, 0xFD, 0xAD, 0xF7, 0xB9, 0xF9, 0x01, 0x28, 0x09, 0xD1, 0xFF, 0xF7, 0x0A, 0xFB, 0x00, 0x28, 0x05, 0xD0, 0xA1, 0x6D, 0x20, 0x46, 0xBD, 0xE8, 0x10, 0x40, 0x00, 0xF0, 0x79, 0xB8, 0x10, 0xBD, 0x03, 0x01, 0x30, 0xC8, 0x13, 0x0D, 0x00, 0x10, 0xB5, 0x0C, 0x46, 0xA6, 0xF7, 0x00, 0xFE, 0x00, 0x2C, 0x08, 0xD1, 0xFF, 0xF7, 0xF9, 0xFA, 0x00, 0x28, 0x04, 0xD0, 0x04, 0x48, 0x01, 0x68, 0x21, 0xF4, 0x80, 0x11, 0x01, 0x60, 0x10, 0xBD, 0xC8, 0x5D, 0x0D, 0x00, 0xB8, 0x32, 0x20, 0x00, 0x6C, 0x8B, 0x31, 0x00, 0x03, 0x01, 0x0C, 0xF4, 0x13, 0x0D, 0x00, 0x2B, 0x49, 0x2A, 0x48, 0x08, 0x60, 0x70, 0x47, 0x03, 0x01, 0x42, 0xFC, 0x13, 0x0D, 0x00, 0x4C, 0xFC, 0xFF, 0x67, 0x46, 0x21, 0x00, 0x10, 0xB5, 0x04, 0x46, 0xAC, 0xF7, 0xC3, 0xF8, 0xB0, 0xF7, 0xB2, 0xF8, 0x68, 0xB1, 0xAD, 0xF7, 0x89, 0xF9, 0x01, 0x28, 0x09, 0xD1, 0xFF, 0xF7, 0xDA, 0xFA, 0x30, 0xB1, 0x23, 0x48, 0x81, 0x6D, 0x20, 0x46, 0xBD, 0xE8, 0x10, 0x40, 0x00, 0xF0, 0x49, 0xB8, 0x94, 0xF8, 0x4A, 0x00, 0x04, 0x28, 0x04, 0xD1, 0x1F, 0x48, 0x01, 0x68, 0x41, 0xF4, 0x80, 0x11, 0x01, 0x60, 0x10, 0xBD, 0x03, 0x01, 0x2C, 0x3A, 0x14, 0x0D, 0x00, 0x10, 0xB5, 0x0C, 0x46, 0xAC, 0xF7, 0xE6, 0xF9, 0x00, 0x2C, 0x0C, 0xD1, 0xB0, 0xF7, 0x91, 0xF8, 0x00, 0x28, 0x08, 0xD0, 0xFF, 0xF7, 0xBC, 0xFA, 0x00, 0x28, 0x04, 0xD0, 0x15, 0x48, 0x01, 0x68, 0x21, 0xF4, 0x80, 0x11, 0x01, 0x60, 0x10, 0xBD, 0x03, 0x01, 0x5A, 0x62, 0x14, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0xC0, 0x8C, 0xB0, 0xF5, 0x00, 0x6F, 0x09, 0xD1, 0xA1, 0xF7, 0x32, 0xF8, 0x38, 0xB1, 0x0E, 0x48, 0xE1, 0x8C, 0x00, 0x68, 0xB0, 0xF8, 0x70, 0x00, 0x07, 0xE0, 0xE0, 0x83, 0x10, 0xBD, 0x9E, 0xF7, 0xA6, 0xF9, 0x40, 0xB1, 0x0A, 0x48, 0xE1, 0x8C, 0x00, 0x8F, 0x08, 0x1A, 0xA1, 0x8C, 0x88, 0x42, 0xF3, 0xDA, 0x08, 0x46, 0xF1, 0xE7, 0xE0, 0x8C, 0xEF, 0xE7, 0xF4, 0x5D, 0x0D, 0x00, 0xCC, 0x32, 0x20, 0x00, 0xFC, 0xEE, 0x20, 0x00, 0x6C, 0x8B, 0x31, 0x00, 0xD4, 0x30, 0x20, 0x00, 0xE4, 0x57, 0x20, 0x00, 0x03, 0x01, 0xD4, 0x01, 0xB8, 0x14, 0x0D, 0x00, 0x10, 0xB5, 0x0B, 0x46, 0x86, 0xB0, 0x04, 0x46, 0x91, 0xF8, 0x56, 0x10, 0x04, 0xAA, 0x03, 0xF1, 0x50, 0x00, 0x71, 0xF7, 0x1F, 0xFA, 0x29, 0x49, 0x09, 0x78, 0x88, 0x42, 0x24, 0xD2, 0x80, 0x28, 0x22, 0xD2, 0x27, 0x4A, 0x41, 0x09, 0x00, 0xF0, 0x1F, 0x4C, 0xFC, 0xFF, 0x62, 0x47, 0x21, 0x00, 0x00, 0x52, 0xF8, 0x21, 0x20, 0x01, 0x23, 0x83, 0x40, 0x1A, 0x42, 0x18, 0xD0, 0x23, 0x4A, 0x52, 0xF8, 0x21, 0x10, 0x22, 0x7C, 0xC1, 0x40, 0x01, 0xF0, 0x01, 0x00, 0x20, 0x49, 0x01, 0x28, 0x26, 0xD0, 0x15, 0x2A, 0x0A, 0x68, 0x2C, 0xD0, 0x22, 0xF4, 0x80, 0x02, 0x0A, 0x60, 0x71, 0xF7, 0x5F, 0xF9, 0x1B, 0x4A, 0x01, 0x68, 0x48, 0x32, 0x11, 0x60, 0x11, 0x1D, 0x80, 0x88, 0x08, 0x60, 0x18, 0x48, 0x01, 0x68, 0x00, 0x91, 0x40, 0x68, 0x01, 0x90, 0xA0, 0x7B, 0x02, 0xA9, 0x6F, 0xF7, 0x57, 0xFC, 0x69, 0x46, 0x02, 0xA8, 0x6F, 0xF7, 0x2E, 0xFC, 0x08, 0x30, 0x8C, 0x28, 0x13, 0xD2, 0x0F, 0x48, 0x00, 0x1D, 0x01, 0x68, 0x41, 0xF4, 0x80, 0x11, 0x01, 0x60, 0x06, 0xB0, 0x10, 0xBD, 0x15, 0x2A, 0x0A, 0x68, 0x02, 0xD0, 0x42, 0xF4, 0x80, 0x02, 0xD7, 0xE7, 0x42, 0xF0, 0x40, 0x02, 0xD4, 0xE7, 0x22, 0xF0, 0x40, 0x02, 0xD1, 0xE7, 0x6E, 0xF7, 0xA5, 0xFE, 0x00, 0x20, 0xAD, 0xF7, 0xDB, 0xF8, 0xEB, 0xE7, 0x4B, 0x29, 0x20, 0x00, 0x18, 0x67, 0x0D, 0x00, 0x08, 0x67, 0x0D, 0x00, 0x68, 0x8B, 0x31, 0x00, 0x70, 0x82, 0x31, 0x00, 0x03, 0x01, 0x40, 0x88, 0x15, 0x0D, 0x00, 0x70, 0xB5, 0x05, 0x46, 0x0C, 0x46, 0x08, 0x0A, 0x00, 0x21, 0x9F, 0xF7, 0xEF, 0xFB, 0x00, 0x21, 0x04, 0x28, 0x04, 0xD9, 0x95, 0xF8, 0xD0, 0x20, 0x92, 0x07, 0x00, 0xD5, 0x00, 0x1F, 0xA2, 0x07, 0x07, 0xD0, 0xE2, 0x43, 0x92, 0x07, 0x05, 0xD1, 0x03, 0x4A, 0x12, 0x78, 0x90, 0x42, 0x00, 0xD2, 0x00, 0xB9, 0x01, 0x21, 0x08, 0x46, 0x70, 0xBD, 0x2C, 0x34, 0x20, 0x00, 0x03, 0x01, 0x48, 0xC4, 0x15, 0x0D, 0x00, 0x2B, 0x4A, 0x00, 0x21, 0x52, 0x68, 0xC1, 0xEB, 0xC1, 0x03, 0x4C, 0xFC, 0xFF, 0x5D, 0x48, 0x21, 0x00, 0x02, 0xEB, 0x83, 0x03, 0x93, 0xF9, 0x18, 0x30, 0x83, 0x42, 0x0E, 0xDC, 0x99, 0xB1, 0xC1, 0xEB, 0xC1, 0x03, 0x02, 0xEB, 0x83, 0x02, 0x92, 0xF9, 0x18, 0x30, 0x12, 0xF9, 0x04, 0x2C, 0xC3, 0x1A, 0x10, 0x1A, 0x83, 0x42, 0x04, 0xDD, 0x49, 0x1E, 0x02, 0xE0, 0x49, 0x1C, 0x0E, 0x29, 0xE5, 0xDB, 0x0E, 0x29, 0x00, 0xD1, 0x0D, 0x21, 0x48, 0xB2, 0x70, 0x47, 0x03, 0x01, 0x50, 0x08, 0x16, 0x0D, 0x00, 0xF0, 0xB5, 0x1A, 0x4F, 0x3A, 0x78, 0x8A, 0x42, 0x1F, 0xD0, 0xFF, 0x2A, 0x01, 0xD1, 0x00, 0x29, 0x1B, 0xD0, 0x17, 0x4C, 0x39, 0x70, 0x00, 0x22, 0xC0, 0xEB, 0xC0, 0x06, 0x78, 0x68, 0x00, 0xEB, 0x82, 0x03, 0x1D, 0x68, 0x75, 0xB1, 0x51, 0xB1, 0x2D, 0x68, 0x44, 0xF8, 0x22, 0x50, 0x00, 0xEB, 0x86, 0x00, 0x00, 0xEB, 0x82, 0x00, 0x1B, 0x68, 0xC0, 0x69, 0x18, 0x60, 0x02, 0xE0, 0x54, 0xF8, 0x22, 0x00, 0x28, 0x60, 0x52, 0x1C, 0x06, 0x2A, 0xE8, 0xDB, 0xF0, 0xBD, 0x03, 0x01, 0x30, 0x54, 0x16, 0x0D, 0x00, 0x07, 0x49, 0x00, 0xF0, 0x0F, 0x00, 0xC0, 0xEB, 0xC0, 0x00, 0x49, 0x68, 0x01, 0xEB, 0x80, 0x00, 0x05, 0x49, 0xC0, 0x69, 0x00, 0xEB, 0x40, 0x00, 0x08, 0x44, 0xD0, 0xF8, 0x02, 0x00, 0x70, 0x47, 0x20, 0x5E, 0x0D, 0x00, 0x54, 0x68, 0x0D, 0x00, 0x70, 0x09, 0x20, 0x00, 0x03, 0x01, 0xFE, 0x02, 0x80, 0x16, 0x0D, 0x00, 0x2D, 0xE9, 0xFF, 0x4F, 0x83, 0xB0, 0xFF, 0x21, 0x00, 0x91, 0x06, 0x99, 0x49, 0xB1, 0xF9, 0x49, 0x4B, 0x78, 0xCA, 0x68, 0x02, 0xEB, 0x03, 0x12, 0x12, 0x68, 0x92, 0x07, 0x1F, 0xD5, 0x0C, 0x69, 0x12, 0xE0, 0xF5, 0x49, 0x0C, 0x68, 0x21, 0x68, 0x89, 0x07, 0x0B, 0xD4, 0x08, 0x2A, 0x16, 0xD2, 0xC2, 0xEB, 0xC2, 0x4C, 0xFC, 0xFF, 0x58, 0x49, 0x21, 0x00, 0x01, 0x01, 0xEB, 0x81, 0x01, 0x04, 0xEB, 0xC1, 0x01, 0xD1, 0xF8, 0x6C, 0x13, 0x89, 0x07, 0x0C, 0xD5, 0x04, 0xF2, 0x2D, 0x14, 0x6F, 0xF0, 0x05, 0x01, 0x01, 0xEB, 0x10, 0x28, 0x04, 0x9E, 0xC0, 0xF3, 0x80, 0x10, 0x00, 0x27, 0x01, 0x90, 0xB6, 0x1D, 0x75, 0xE0, 0xFE, 0x20, 0x07, 0xB0, 0xBD, 0xE8, 0xF0, 0x8F, 0x31, 0x78, 0x00, 0x29, 0x71, 0xD0, 0x48, 0x1C, 0x40, 0x45, 0x6E, 0xDC, 0x70, 0x78, 0x16, 0x28, 0x61, 0xD1, 0xB6, 0xF8, 0x02, 0xB0, 0x00, 0x22, 0x70, 0x1C, 0x4B, 0xF7, 0x2A, 0xFF, 0x81, 0x46, 0x01, 0x98, 0x94, 0xF8, 0x2C, 0x51, 0x40, 0xF0, 0x80, 0x0A, 0x21, 0xE0, 0x00, 0x2D, 0x00, 0xDA, 0x1D, 0x25, 0x05, 0xEB, 0x85, 0x00, 0x14, 0xF8, 0x10, 0x20, 0x52, 0x45, 0x18, 0xD1, 0x06, 0x99, 0x29, 0xB1, 0xD2, 0x49, 0x09, 0x69, 0x01, 0xEB, 0x40, 0x01, 0x49, 0x1C, 0x05, 0xE0, 0xD0, 0x49, 0x09, 0x68, 0x01, 0xEB, 0x40, 0x01, 0x01, 0xF5, 0x97, 0x71, 0x04, 0xEB, 0x40, 0x00, 0xB0, 0xF8, 0x07, 0x20, 0x5A, 0x45, 0x04, 0xD1, 0x06, 0x22, 0x04, 0x98, 0x70, 0xF7, 0xA2, 0xFD, 0xF0, 0xB3, 0x94, 0xF8, 0x2C, 0x01, 0x6D, 0x1E, 0x85, 0x42, 0xD8, 0xD1, 0xC0, 0xB2, 0x00, 0xEB, 0x80, 0x00, 0x04, 0xEB, 0x40, 0x01, 0x04, 0x98, 0x7F, 0x1C, 0x02, 0x68, 0xC1, 0xF8, 0x01, 0x20, 0x80, 0x88, 0xA1, 0xF8, 0x05, 0x00, 0x94, 0xF8, 0x2C, 0x01, 0x00, 0xEB, 0x80, 0x00, 0x04, 0xF8, 0x10, 0xA0, 0x94, 0xF8, 0x2C, 0x01, 0x00, 0xEB, 0x80, 0x00, 0x04, 0xEB, 0x40, 0x00, 0xA0, 0xF8, 0x07, 0xB0, 0x94, 0xF8, 0x2C, 0x01, 0x00, 0xEB, 0x80, 0x00, 0x04, 0xEB, 0x40, 0x00, 0x80, 0xF8, 0x09, 0x90, 0x94, 0xF8, 0x2C, 0x01, 0x40, 0x1C, 0xC0, 0xB2, 0x4C, 0xFC, 0xFF, 0x53, 0x4A, 0x21, 0x00, 0x84, 0xF8, 0x2C, 0x01, 0x1E, 0x28, 0x02, 0xD3, 0x00, 0x20, 0x84, 0xF8, 0x2C, 0x01, 0x16, 0xF8, 0x01, 0x0B, 0xA8, 0xEB, 0x00, 0x01, 0xA1, 0xF1, 0x01, 0x08, 0x06, 0x44, 0xB8, 0xF1, 0x01, 0x0F, 0x8A, 0xDC, 0x8F, 0xB1, 0x00, 0xE0, 0x01, 0xE0, 0xFF, 0x20, 0x82, 0xE7, 0x05, 0xEB, 0x85, 0x00, 0x04, 0xEB, 0x40, 0x00, 0x42, 0x7A, 0x4A, 0x45, 0x02, 0xD1, 0xE8, 0xB2, 0x00, 0x90, 0xE6, 0xE7, 0x80, 0xF8, 0x09, 0x90, 0x7F, 0x1C, 0xE2, 0xE7, 0x00, 0x98, 0x72, 0xE7, 0x03, 0x01, 0x44, 0xFA, 0x17, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x9D, 0x4C, 0xA0, 0x68, 0xB8, 0xB9, 0xA7, 0x78, 0xE6, 0x78, 0xB8, 0x01, 0x9C, 0x4D, 0x00, 0xEB, 0x06, 0x11, 0x01, 0xF2, 0x31, 0x11, 0x28, 0x46, 0x73, 0xF7, 0xEB, 0xFD, 0x05, 0xEB, 0x87, 0x10, 0x01, 0x1D, 0xC4, 0xE9, 0x02, 0x51, 0x00, 0xEB, 0x06, 0x10, 0x01, 0x1D, 0x21, 0x61, 0x94, 0x49, 0x00, 0xF2, 0x31, 0x10, 0x08, 0x60, 0x01, 0x20, 0xBD, 0xE8, 0xF0, 0x81, 0x03, 0x01, 0x5A, 0x3A, 0x18, 0x0D, 0x00, 0x30, 0xB5, 0x8D, 0x4B, 0x42, 0x79, 0xC5, 0x88, 0xDC, 0x68, 0xD1, 0xB2, 0x04, 0xEB, 0x01, 0x11, 0x25, 0xB1, 0x0D, 0x60, 0x05, 0x89, 0x0D, 0x81, 0x85, 0x7A, 0x04, 0xE0, 0x4F, 0xF4, 0x00, 0x45, 0x0D, 0x60, 0x00, 0x25, 0x0D, 0x81, 0x8D, 0x72, 0x04, 0xEB, 0x02, 0x11, 0xC5, 0x7A, 0xCD, 0x72, 0x02, 0x7B, 0x0A, 0x73, 0x02, 0x7B, 0x01, 0x2A, 0x09, 0xD1, 0xB0, 0xF8, 0x0D, 0x20, 0x8A, 0x80, 0xC2, 0x7B, 0x4A, 0x73, 0x02, 0x7C, 0x8A, 0x73, 0xB0, 0xF8, 0x11, 0x00, 0xC8, 0x80, 0x18, 0x78, 0x40, 0x1C, 0x18, 0x70, 0x30, 0xBD, 0x03, 0x01, 0x5A, 0x90, 0x18, 0x0D, 0x00, 0xF0, 0xB5, 0xDF, 0xF8, 0x4C, 0xFC, 0xFF, 0x4E, 0x4B, 0x21, 0x00, 0xE0, 0xE1, 0x44, 0x79, 0x00, 0x26, 0xDE, 0xF8, 0x0C, 0x00, 0x00, 0xEB, 0x04, 0x10, 0x01, 0x68, 0x29, 0xB1, 0x9E, 0xF8, 0x00, 0x10, 0x49, 0x1E, 0x8E, 0xF8, 0x00, 0x10, 0x06, 0x60, 0x00, 0x20, 0x01, 0x25, 0x11, 0xE0, 0xDE, 0xF8, 0x08, 0x10, 0x05, 0xFA, 0x04, 0xF7, 0x01, 0xEB, 0x80, 0x12, 0x13, 0x6C, 0x3B, 0x42, 0x06, 0xD0, 0xBB, 0x43, 0x13, 0x64, 0x03, 0xD1, 0x16, 0x71, 0x0A, 0x78, 0x52, 0x1E, 0x0A, 0x70, 0x40, 0x1C, 0xC0, 0xB2, 0x9E, 0xF8, 0x02, 0x10, 0x88, 0x42, 0xE9, 0xD3, 0xF0, 0xBD, 0x03, 0x01, 0xF0, 0x01, 0xE6, 0x18, 0x0D, 0x00, 0x2D, 0xE9, 0xFF, 0x4F, 0x80, 0x46, 0x00, 0x24, 0x81, 0xB0, 0x91, 0x46, 0x10, 0x06, 0x02, 0xD5, 0x06, 0x20, 0x00, 0x90, 0x01, 0xE0, 0xCD, 0xF8, 0x00, 0x90, 0x5C, 0x49, 0xFE, 0x27, 0x00, 0x26, 0x8D, 0x68, 0xBA, 0x46, 0x2D, 0x1D, 0x01, 0x20, 0x00, 0xFA, 0x03, 0xFB, 0x22, 0xE0, 0x28, 0x78, 0xD0, 0xB1, 0xBA, 0xF1, 0xFD, 0x0F, 0x0B, 0xD0, 0x48, 0x45, 0x09, 0xD1, 0x95, 0xF8, 0x3B, 0x10, 0x41, 0x45, 0x05, 0xD1, 0x68, 0x1C, 0x00, 0x9A, 0x02, 0x99, 0x70, 0xF7, 0xB2, 0xFC, 0x08, 0xB1, 0x40, 0x35, 0x0D, 0xE0, 0xE8, 0x6B, 0x10, 0xEA, 0x0B, 0x0F, 0x02, 0xD0, 0x4F, 0xF0, 0xFD, 0x0A, 0x41, 0xE0, 0x37, 0x46, 0x2C, 0x46, 0x0C, 0xE0, 0x8F, 0x42, 0x01, 0xD3, 0x37, 0x46, 0x2C, 0x46, 0x76, 0x1C, 0xF6, 0xB2, 0x46, 0x48, 0x81, 0x78, 0x8E, 0x42, 0xD8, 0xD3, 0xBA, 0xF1, 0xFD, 0x0F, 0x31, 0xD0, 0x42, 0x48, 0x81, 0x78, 0x8F, 0x42, 0x2D, 0xD2, 0x64, 0xB3, 0x84, 0xF8, 0x00, 0x90, 0x84, 0xF8, 0x3B, 0x80, 0xE1, 0x6B, 0x19, 0xB9, 0x80, 0x68, 0x01, 0x78, 0x49, 0x1C, 0x01, 0x70, 0xE1, 0x4C, 0xFC, 0xFF, 0x49, 0x4C, 0x21, 0x00, 0x6B, 0x60, 0x1C, 0x41, 0xEA, 0x0B, 0x01, 0xE1, 0x63, 0x00, 0x9A, 0x02, 0x99, 0x73, 0xF7, 0x46, 0xFF, 0x02, 0x9A, 0xB8, 0xF1, 0x02, 0x0F, 0x02, 0xEB, 0x09, 0x01, 0x09, 0xD0, 0xB8, 0xF1, 0x03, 0x0F, 0x06, 0xD0, 0xB8, 0xF1, 0x05, 0x0F, 0x07, 0xD0, 0xB8, 0xF1, 0x06, 0x0F, 0x04, 0xD0, 0x08, 0xE0, 0x04, 0xF1, 0x11, 0x00, 0x00, 0x9A, 0x02, 0xE0, 0x04, 0xF1, 0x1E, 0x00, 0x00, 0x9A, 0x73, 0xF7, 0x2D, 0xFF, 0xBA, 0x46, 0x50, 0x46, 0x05, 0xB0, 0x87, 0xE6, 0x03, 0x01, 0x92, 0x01, 0xD2, 0x19, 0x0D, 0x00, 0x2D, 0xE9, 0xFF, 0x5F, 0x00, 0x26, 0x90, 0x46, 0x10, 0x06, 0x02, 0xD5, 0x4F, 0xF0, 0x06, 0x0B, 0x00, 0xE0, 0xC3, 0x46, 0x23, 0x49, 0xFF, 0x27, 0x00, 0x25, 0x8C, 0x68, 0x8A, 0x46, 0x24, 0x1D, 0x01, 0x20, 0x00, 0xFA, 0x03, 0xF9, 0x1A, 0xE0, 0x20, 0x78, 0xA8, 0xB1, 0xFF, 0x2F, 0x13, 0xD1, 0x40, 0x45, 0x11, 0xD1, 0x94, 0xF8, 0x3B, 0x10, 0x00, 0x98, 0x81, 0x42, 0x0C, 0xD1, 0x5A, 0x46, 0x60, 0x1C, 0x01, 0x99, 0x70, 0xF7, 0x3F, 0xFC, 0x30, 0xB9, 0xE0, 0x6B, 0x10, 0xEA, 0x09, 0x0F, 0x02, 0xD0, 0x2F, 0x46, 0x26, 0x46, 0x06, 0xE0, 0x40, 0x34, 0x6D, 0x1C, 0xED, 0xB2, 0x9A, 0xF8, 0x02, 0x00, 0x85, 0x42, 0xE0, 0xD3, 0x9A, 0xF8, 0x02, 0x00, 0x51, 0x46, 0x87, 0x42, 0x0A, 0xD2, 0x4E, 0xB1, 0xF0, 0x6B, 0x30, 0xEA, 0x09, 0x00, 0xF0, 0x63, 0x04, 0xD1, 0x30, 0x70, 0x88, 0x68, 0x01, 0x78, 0x49, 0x1E, 0x01, 0x70, 0x04, 0xB0, 0x38, 0x46, 0xBD, 0xE8, 0xF0, 0x9F, 0x03, 0x01, 0x58, 0x60, 0x1A, 0x0D, 0x00, 0xF0, 0xB5, 0x04, 0x4D, 0x00, 0x23, 0x01, 0x24, 0xAA, 0x68, 0x1F, 0x46, 0x12, 0x1D, 0x8C, 0x40, 0x1C, 0xE0, 0x00, 0x4C, 0xFC, 0xFF, 0x44, 0x4D, 0x21, 0x00, 0x00, 0x28, 0x5E, 0x0D, 0x00, 0x1C, 0x34, 0x20, 0x00, 0x89, 0x68, 0x0D, 0x00, 0x00, 0x33, 0x20, 0x00, 0x92, 0xF8, 0x3B, 0x10, 0x81, 0x42, 0x0C, 0xD1, 0x11, 0x78, 0x51, 0xB1, 0xD1, 0x6B, 0x21, 0x42, 0x07, 0xD0, 0xA1, 0x43, 0xD1, 0x63, 0x04, 0xD1, 0x17, 0x70, 0xA9, 0x68, 0x0E, 0x78, 0x76, 0x1E, 0x0E, 0x70, 0x40, 0x32, 0x5B, 0x1C, 0xDB, 0xB2, 0xA9, 0x78, 0x8B, 0x42, 0xE8, 0xD3, 0xF0, 0xBD, 0x03, 0x01, 0x58, 0xB4, 0x1A, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x47, 0xFA, 0x4F, 0x81, 0x46, 0x41, 0xF0, 0x80, 0x06, 0xBC, 0x68, 0x4F, 0xF0, 0x01, 0x08, 0x24, 0x1D, 0x00, 0x25, 0x15, 0xE0, 0x94, 0xF8, 0x3B, 0x00, 0x80, 0xB9, 0x20, 0x78, 0xB0, 0x42, 0x01, 0xD0, 0x82, 0x28, 0x0B, 0xD1, 0x7A, 0x78, 0xE1, 0x6B, 0x08, 0xFA, 0x02, 0xF0, 0x01, 0x42, 0x05, 0xD0, 0x06, 0x22, 0x61, 0x1C, 0x48, 0x46, 0x70, 0xF7, 0xD3, 0xFB, 0x38, 0xB1, 0x40, 0x34, 0x6D, 0x1C, 0xB8, 0x78, 0x85, 0x42, 0xE6, 0xD3, 0xFF, 0x20, 0xBD, 0xE8, 0xF0, 0x87, 0xE8, 0xB2, 0xFB, 0xE7, 0x03, 0x01, 0xCE, 0x01, 0x08, 0x1B, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x43, 0x92, 0xF8, 0x00, 0x80, 0x89, 0xB0, 0x54, 0x1C, 0x07, 0x46, 0x15, 0x46, 0x0E, 0x46, 0xE9, 0x46, 0x41, 0x45, 0x19, 0xD1, 0x4F, 0xF0, 0x00, 0x00, 0x4A, 0x46, 0x0F, 0xE0, 0x05, 0xEB, 0x00, 0x01, 0x3B, 0x5C, 0x91, 0xF8, 0x11, 0xC0, 0x03, 0xEA, 0x0C, 0x03, 0x13, 0x54, 0x23, 0x5C, 0x49, 0x7C, 0x03, 0xEA, 0x01, 0x03, 0x23, 0x54, 0x00, 0xF1, 0x01, 0x00, 0xC0, 0xB2, 0xB0, 0x42, 0xED, 0xD3, 0x32, 0x46, 0x21, 0x46, 0x48, 0x46, 0x39, 0xE0, 0x18, 0xD2, 0x43, 0x46, 0x4A, 0x46, 0x38, 0x46, 0xAD, 0xF7, 0x96, 0x4C, 0xFC, 0xFF, 0x3F, 0x4E, 0x21, 0x00, 0xFC, 0x00, 0x20, 0x4A, 0x46, 0x0A, 0xE0, 0x29, 0x18, 0x13, 0x5C, 0x4E, 0x7C, 0x33, 0x40, 0x13, 0x54, 0x23, 0x5C, 0x49, 0x7C, 0x0B, 0x40, 0x23, 0x54, 0x40, 0x1C, 0xC0, 0xB2, 0x41, 0x46, 0x40, 0x45, 0xF1, 0xD3, 0x0A, 0x46, 0x21, 0x46, 0x1E, 0xE0, 0x0B, 0x46, 0x4A, 0x46, 0x41, 0x46, 0x20, 0x46, 0xAD, 0xF7, 0x7C, 0xFC, 0x33, 0x46, 0x04, 0xAA, 0x41, 0x46, 0x05, 0xF1, 0x11, 0x00, 0x00, 0xF0, 0xA5, 0xFB, 0x00, 0x20, 0x4C, 0x46, 0x04, 0xAD, 0xBF, 0x4B, 0x08, 0xE0, 0x3A, 0x5C, 0x29, 0x5C, 0x0A, 0x40, 0x1A, 0x54, 0x22, 0x5C, 0x0A, 0x40, 0x22, 0x54, 0x40, 0x1C, 0xC0, 0xB2, 0xB0, 0x42, 0xF4, 0xD3, 0xB9, 0x49, 0x32, 0x46, 0x68, 0x46, 0x70, 0xF7, 0x66, 0xFB, 0x09, 0xB0, 0xBD, 0xE8, 0xF0, 0x83, 0x03, 0x01, 0x9A, 0x02, 0xD2, 0x1B, 0x0D, 0x00, 0x2D, 0xE9, 0xF3, 0x5F, 0x81, 0x46, 0xB2, 0x48, 0x00, 0x26, 0x37, 0x46, 0x84, 0x68, 0x99, 0xF8, 0x00, 0x00, 0x24, 0x1D, 0x03, 0x28, 0x03, 0xD2, 0x00, 0x20, 0x01, 0x46, 0xBD, 0xE8, 0xFC, 0x9F, 0x99, 0xF8, 0x01, 0x00, 0x4F, 0xF0, 0x01, 0x0B, 0x07, 0x28, 0x16, 0xD0, 0x08, 0xDC, 0xA0, 0xF1, 0x02, 0x00, 0x05, 0x28, 0x66, 0xD2, 0xDF, 0xE8, 0x00, 0xF0, 0x0C, 0x0C, 0x0E, 0x0E, 0x10, 0x00, 0x14, 0x28, 0x06, 0xD0, 0x15, 0x28, 0x08, 0xD0, 0x16, 0x28, 0x3B, 0xD0, 0x1F, 0x28, 0x59, 0xD1, 0x01, 0xE0, 0x02, 0x20, 0x02, 0xE0, 0x04, 0x20, 0x00, 0xE0, 0x10, 0x20, 0x82, 0x46, 0x00, 0x20, 0x28, 0xE0, 0x9B, 0x48, 0x84, 0x68, 0x24, 0x1D, 0x00, 0x25, 0x1C, 0xE0, 0x21, 0x78, 0xB9, 0xB1, 0x94, 0xF8, 0x3B, 0x20, 0x01, 0x99, 0x8A, 0x42, 0x12, 0xD1, 0x42, 0x78, 0xE1, 0x6B, 0x0B, 0xFA, 0x4C, 0xFC, 0xFF, 0x3A, 0x4F, 0x21, 0x00, 0x02, 0xF0, 0x01, 0x42, 0x0C, 0xD0, 0x09, 0xEB, 0x08, 0x00, 0x80, 0x1C, 0x22, 0x46, 0x51, 0x46, 0xFF, 0xF7, 0x51, 0xFF, 0x20, 0xB9, 0x0B, 0xFA, 0x05, 0xF0, 0x06, 0x43, 0x47, 0xEA, 0xE0, 0x77, 0x40, 0x34, 0x6D, 0x1C, 0xED, 0xB2, 0x8A, 0x48, 0x81, 0x78, 0x8D, 0x42, 0xDE, 0xD3, 0x08, 0xEB, 0x0A, 0x00, 0xC0, 0xB2, 0x99, 0xF8, 0x00, 0x10, 0x80, 0x46, 0xA1, 0xEB, 0x0A, 0x01, 0x41, 0x45, 0xCF, 0xDC, 0x1F, 0xE0, 0x00, 0x25, 0xDF, 0xF8, 0x08, 0x82, 0x17, 0xE0, 0x21, 0x78, 0x91, 0xB1, 0x94, 0xF8, 0x3B, 0x20, 0x01, 0x99, 0x8A, 0x42, 0x0D, 0xD1, 0x98, 0xF8, 0x01, 0x20, 0xE1, 0x6B, 0x0B, 0xFA, 0x02, 0xF0, 0x01, 0x42, 0x06, 0xD0, 0x22, 0x46, 0x02, 0x21, 0x09, 0xF1, 0x02, 0x00, 0xFF, 0xF7, 0x21, 0xFF, 0x48, 0xB1, 0x40, 0x34, 0x6D, 0x1C, 0xED, 0xB2, 0x98, 0xF8, 0x02, 0x10, 0x8D, 0x42, 0xE3, 0xD3, 0x30, 0x46, 0x39, 0x46, 0x88, 0xE7, 0x0B, 0xFA, 0x05, 0xF0, 0xC1, 0x17, 0x06, 0x43, 0x0F, 0x43, 0xF6, 0xE7, 0x03, 0x01, 0x22, 0xE8, 0x1C, 0x0D, 0x00, 0x0B, 0x46, 0xC0, 0xF3, 0x80, 0x11, 0x6D, 0x48, 0xC2, 0x68, 0x40, 0x78, 0x02, 0xEB, 0x00, 0x10, 0x00, 0x68, 0xC0, 0x07, 0x01, 0xD0, 0x18, 0x46, 0xD8, 0xE6, 0xFE, 0x20, 0x70, 0x47, 0x03, 0x01, 0x4A, 0x06, 0x1D, 0x0D, 0x00, 0xF0, 0xB5, 0x66, 0x4D, 0x84, 0x46, 0x00, 0x20, 0xAA, 0x68, 0x6C, 0x78, 0x12, 0x1D, 0x4F, 0xF0, 0x01, 0x0E, 0x01, 0x46, 0x03, 0x46, 0x0E, 0xFA, 0x04, 0xF6, 0xAF, 0x78, 0x10, 0xE0, 0x14, 0x78, 0x5C, 0xB1, 0x92, 0xF8, 0x3B, 0x40, 0x64, 0x45, 0x07, 0xD1, 0xD5, 0x6B, 0x35, 0x42, 0x04, 0xD0, 0x0E, 0xFA, 0x03, 0xF4, 0x20, 0x43, 0x41, 0xEA, 0xE4, 0x4C, 0xFC, 0xFF, 0x35, 0x50, 0x21, 0x00, 0x71, 0x40, 0x32, 0x5B, 0x1C, 0xDB, 0xB2, 0xBB, 0x42, 0xEC, 0xD3, 0xF0, 0xBD, 0x03, 0x01, 0xAC, 0x02, 0x4C, 0x1D, 0x0D, 0x00, 0x2D, 0xE9, 0xF8, 0x4F, 0x0F, 0x46, 0xFA, 0x21, 0x01, 0xEB, 0x10, 0x20, 0x45, 0xB2, 0x00, 0x20, 0x80, 0x46, 0x82, 0x46, 0x06, 0x46, 0x81, 0x46, 0x4F, 0x48, 0x4F, 0x49, 0x1C, 0x46, 0xC0, 0x68, 0x49, 0x78, 0x02, 0x2B, 0x00, 0xEB, 0x01, 0x10, 0x02, 0xD0, 0xFE, 0x2A, 0x05, 0xD0, 0x08, 0xE0, 0xFE, 0x2A, 0x06, 0xD1, 0x00, 0x68, 0x40, 0x07, 0x01, 0xE0, 0x00, 0x68, 0x00, 0x07, 0x00, 0x28, 0x02, 0xDB, 0xFE, 0x20, 0xBD, 0xE8, 0xF8, 0x8F, 0x18, 0x46, 0xFF, 0xF7, 0xB6, 0xFF, 0x00, 0x90, 0x8B, 0x46, 0x08, 0x43, 0x66, 0xD0, 0xBF, 0x1D, 0x30, 0xE0, 0x38, 0x78, 0x80, 0xB3, 0x40, 0x1C, 0xA8, 0x42, 0x2D, 0xDC, 0x02, 0x2C, 0x04, 0xD0, 0x03, 0x2C, 0x07, 0xD0, 0x02, 0x2C, 0x15, 0xD0, 0x1E, 0xE0, 0x78, 0x78, 0x80, 0x1E, 0x05, 0x28, 0x07, 0xD9, 0x0F, 0xE0, 0x78, 0x78, 0x14, 0x28, 0x03, 0xD0, 0x1F, 0x28, 0x01, 0xD0, 0x15, 0x28, 0x12, 0xD1, 0x21, 0x46, 0x38, 0x46, 0xFF, 0xF7, 0xFA, 0xFE, 0x40, 0xEA, 0x08, 0x08, 0x41, 0xEA, 0x0A, 0x0A, 0x09, 0xE0, 0x78, 0x78, 0x16, 0x28, 0x06, 0xD1, 0x21, 0x46, 0x38, 0x46, 0xFF, 0xF7, 0xEE, 0xFE, 0x06, 0x43, 0x41, 0xEA, 0x09, 0x09, 0x17, 0xF8, 0x01, 0x0B, 0x29, 0x1A, 0x49, 0x1E, 0x4D, 0xB2, 0x07, 0x44, 0x01, 0x2D, 0xCC, 0xDC, 0x02, 0x2C, 0x02, 0xD0, 0x03, 0x2C, 0x08, 0xD0, 0x1E, 0xE0, 0x23, 0x48, 0xC1, 0x68, 0x40, 0x78, 0x01, 0xEB, 0x00, 0x10, 0x00, 0x89, 0x40, 0x07, 0x06, 0xE0, 0x1F, 0x48, 0xC1, 0x68, 0x40, 0x78, 0x01, 0xEB, 0x00, 0x10, 0x00, 0x89, 0x4C, 0xFC, 0xFF, 0x30, 0x51, 0x21, 0x00, 0x00, 0x07, 0x00, 0x28, 0x0D, 0xDA, 0x00, 0x9A, 0x2B, 0xEA, 0x0A, 0x00, 0x22, 0xEA, 0x08, 0x01, 0x01, 0x43, 0x12, 0xD0, 0x22, 0xEA, 0x06, 0x00, 0x2B, 0xEA, 0x09, 0x01, 0x08, 0x43, 0x0C, 0xD0, 0x0D, 0xE0, 0x00, 0x9A, 0x0A, 0xEA, 0x0B, 0x00, 0x08, 0xEA, 0x02, 0x01, 0x01, 0x43, 0x04, 0xD1, 0x16, 0x40, 0x09, 0xEA, 0x0B, 0x00, 0x06, 0x43, 0x01, 0xD0, 0x00, 0x20, 0x8F, 0xE7, 0xFF, 0x20, 0x8D, 0xE7, 0x03, 0x01, 0x0A, 0x74, 0x1E, 0x0D, 0x00, 0x02, 0x23, 0xFE, 0x22, 0x68, 0xE7, 0x03, 0x01, 0x0A, 0x7A, 0x1E, 0x0D, 0x00, 0x03, 0x23, 0xFE, 0x22, 0x65, 0xE7, 0x03, 0x01, 0xA0, 0x01, 0x80, 0x1E, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x07, 0x4E, 0xFA, 0x22, 0x02, 0xEB, 0x10, 0x20, 0xD6, 0xE9, 0x02, 0x52, 0x73, 0x78, 0x40, 0xB2, 0x02, 0xEB, 0x03, 0x12, 0x12, 0x68, 0xD2, 0x06, 0x06, 0xD4, 0xFE, 0x20, 0xC9, 0xE4, 0x00, 0x00, 0x28, 0x5E, 0x0D, 0x00, 0x6C, 0x68, 0x0D, 0x00, 0x8C, 0x1D, 0x0E, 0xE0, 0x21, 0x78, 0x71, 0xB1, 0x4A, 0x1C, 0x82, 0x42, 0x0B, 0xDC, 0x62, 0x78, 0x08, 0x2A, 0x0A, 0xD0, 0x09, 0x2A, 0x08, 0xD0, 0x40, 0x1A, 0x40, 0x1E, 0x64, 0x1C, 0x40, 0xB2, 0x0C, 0x44, 0x01, 0x28, 0xEE, 0xDC, 0xFF, 0x20, 0xAF, 0xE4, 0x2D, 0x1D, 0x00, 0x27, 0x4F, 0xF0, 0x01, 0x08, 0x17, 0xE0, 0x2A, 0x78, 0x92, 0xB1, 0x95, 0xF8, 0x3B, 0x00, 0x04, 0x28, 0x0E, 0xD1, 0x20, 0x78, 0x40, 0x1E, 0x82, 0x42, 0x0A, 0xDC, 0x73, 0x78, 0xE9, 0x6B, 0x08, 0xFA, 0x03, 0xF0, 0x01, 0x42, 0x04, 0xD0, 0xA1, 0x1C, 0x68, 0x1C, 0x70, 0xF7, 0xC8, 0xF9, 0x30, 0xB1, 0x40, 0x35, 0x7F, 0x1C, 0xFF, 0xB2, 0xB0, 0x78, 0x87, 0x42, 0xE4, 0xD3, 0xDC, 0x4C, 0xFC, 0xFF, 0x2B, 0x52, 0x21, 0x00, 0xE7, 0x38, 0x46, 0x8C, 0xE4, 0x03, 0x01, 0xA6, 0x02, 0x1C, 0x1F, 0x0D, 0x00, 0x2D, 0xE9, 0xF8, 0x4F, 0x0D, 0x46, 0xFA, 0x21, 0x01, 0xEB, 0x10, 0x20, 0x4F, 0xFA, 0x80, 0xFA, 0xEA, 0x48, 0x4F, 0xF0, 0x00, 0x07, 0xB9, 0x46, 0xC1, 0x68, 0x40, 0x78, 0x01, 0xEB, 0x00, 0x10, 0x00, 0x68, 0x80, 0x06, 0x01, 0xD4, 0xFE, 0x20, 0x24, 0xE7, 0x05, 0x20, 0xFF, 0xF7, 0xDD, 0xFE, 0x83, 0x46, 0x00, 0x91, 0x08, 0x43, 0x72, 0xD0, 0xAD, 0x1D, 0x54, 0xE0, 0x28, 0x78, 0xE8, 0xB3, 0x40, 0x1C, 0x50, 0x45, 0x52, 0xDC, 0x68, 0x78, 0xFF, 0x28, 0x44, 0xD1, 0xDB, 0x48, 0x84, 0x68, 0x24, 0x1D, 0x00, 0x26, 0x39, 0xE0, 0x20, 0x78, 0x88, 0xB3, 0x94, 0xF8, 0x3B, 0x10, 0x05, 0x29, 0x30, 0xD1, 0x29, 0x78, 0x49, 0x1E, 0x88, 0x42, 0x2C, 0xDC, 0x9C, 0xF8, 0x04, 0x00, 0x90, 0xB1, 0x00, 0x20, 0xDF, 0xF8, 0x4C, 0x83, 0x0B, 0xE0, 0x21, 0x18, 0x4B, 0x78, 0x8A, 0x7F, 0x13, 0x40, 0x4B, 0x70, 0x29, 0x18, 0x89, 0x78, 0x11, 0x40, 0x08, 0xF8, 0x00, 0x10, 0x40, 0x1C, 0xC0, 0xB2, 0x21, 0x78, 0x81, 0x42, 0xF0, 0xD8, 0x9C, 0xF8, 0x01, 0x20, 0xE1, 0x6B, 0x4F, 0xF0, 0x01, 0x08, 0x08, 0xFA, 0x02, 0xF0, 0x01, 0x42, 0x0D, 0xD0, 0x22, 0x78, 0xC5, 0x49, 0x60, 0x1C, 0x70, 0xF7, 0x65, 0xF9, 0x20, 0xB9, 0x08, 0xFA, 0x06, 0xF0, 0x07, 0x43, 0x01, 0xE0, 0x16, 0xE0, 0x01, 0xE0, 0x49, 0xEA, 0xE0, 0x79, 0x40, 0x34, 0x76, 0x1C, 0xF6, 0xB2, 0xDF, 0xF8, 0xF0, 0xC2, 0x9C, 0xF8, 0x02, 0x00, 0x86, 0x42, 0xBF, 0xD3, 0x15, 0xF8, 0x01, 0x0B, 0xAA, 0xEB, 0x00, 0x01, 0x49, 0x1E, 0x4F, 0xFA, 0x81, 0xFA, 0x05, 0x44, 0xBA, 0xF1, 0x01, 0x0F, 0xA7, 0xDC, 0xB3, 0x48, 0x4C, 0xFC, 0xFF, 0x26, 0x53, 0x21, 0x00, 0xC1, 0x68, 0x40, 0x78, 0x01, 0xEB, 0x00, 0x10, 0x00, 0x89, 0x80, 0x06, 0x07, 0xD5, 0x00, 0x9B, 0x2B, 0xEA, 0x07, 0x01, 0x23, 0xEA, 0x09, 0x00, 0x01, 0x43, 0x07, 0xD0, 0x08, 0xE0, 0x00, 0x9A, 0x07, 0xEA, 0x0B, 0x07, 0x09, 0xEA, 0x02, 0x00, 0x07, 0x43, 0x01, 0xD0, 0x00, 0x20, 0xAA, 0xE6, 0xFF, 0x20, 0xA8, 0xE6, 0x03, 0x01, 0x9E, 0x02, 0x3E, 0x20, 0x0D, 0x00, 0x2D, 0xE9, 0xF8, 0x4F, 0x0D, 0x46, 0xFA, 0x21, 0x01, 0xEB, 0x10, 0x20, 0x47, 0xB2, 0x4F, 0xF0, 0x00, 0x01, 0xA1, 0x48, 0x89, 0x46, 0x8A, 0x46, 0xC1, 0x68, 0x40, 0x78, 0x01, 0xEB, 0x00, 0x10, 0x00, 0x68, 0x40, 0x06, 0x01, 0xD4, 0xFE, 0x20, 0x93, 0xE6, 0x06, 0x20, 0xFF, 0xF7, 0x4C, 0xFE, 0x83, 0x46, 0x00, 0x91, 0x08, 0x43, 0x6E, 0xD0, 0xAD, 0x1D, 0x4A, 0xE0, 0x28, 0x78, 0xE8, 0xB3, 0x40, 0x1C, 0xB8, 0x42, 0x47, 0xDC, 0x68, 0x78, 0x16, 0x28, 0x3C, 0xD1, 0x93, 0x48, 0x84, 0x68, 0x24, 0x1D, 0x00, 0x26, 0x2F, 0xE0, 0x20, 0x78, 0x50, 0xB3, 0x94, 0xF8, 0x3B, 0x10, 0x06, 0x29, 0x26, 0xD1, 0x29, 0x78, 0x49, 0x1E, 0x88, 0x42, 0x22, 0xDC, 0x9C, 0xF8, 0x04, 0x00, 0x90, 0xB1, 0x00, 0x20, 0xDF, 0xF8, 0x28, 0x82, 0x0B, 0xE0, 0x21, 0x18, 0x4B, 0x78, 0x8A, 0x7F, 0x13, 0x40, 0x4B, 0x70, 0x29, 0x18, 0x89, 0x78, 0x11, 0x40, 0x08, 0xF8, 0x00, 0x10, 0x40, 0x1C, 0xC0, 0xB2, 0x21, 0x78, 0x81, 0x42, 0xF0, 0xD8, 0x9C, 0xF8, 0x01, 0x20, 0xE1, 0x6B, 0x01, 0x20, 0x90, 0x40, 0x01, 0x42, 0x05, 0xD0, 0x22, 0x78, 0x7D, 0x49, 0x60, 0x1C, 0x70, 0xF7, 0xD6, 0xF8, 0x10, 0xB3, 0x40, 0x34, 0x76, 0x1C, 0xF6, 0xB2, 0xDF, 0xF8, 0xE0, 0xC1, 0x00, 0xE0, 0x0B, 0xE0, 0x9C, 0x4C, 0xFC, 0xFF, 0x21, 0x54, 0x21, 0x00, 0xF8, 0x02, 0x00, 0x86, 0x42, 0xC7, 0xD3, 0x15, 0xF8, 0x01, 0x0B, 0x39, 0x1A, 0x49, 0x1E, 0x4F, 0xB2, 0x05, 0x44, 0x01, 0x2F, 0xB2, 0xDC, 0x70, 0x48, 0xC1, 0x68, 0x40, 0x78, 0x01, 0xEB, 0x00, 0x10, 0x00, 0x89, 0x40, 0x06, 0x0E, 0xD5, 0x00, 0x9B, 0x2B, 0xEA, 0x09, 0x00, 0x23, 0xEA, 0x0A, 0x01, 0x08, 0x43, 0x0E, 0xD0, 0x0F, 0xE0, 0x01, 0x20, 0xB0, 0x40, 0x40, 0xEA, 0x09, 0x09, 0x4A, 0xEA, 0xE0, 0x7A, 0xE0, 0xE7, 0x00, 0x9B, 0x09, 0xEA, 0x0B, 0x01, 0x0A, 0xEA, 0x03, 0x00, 0x01, 0x43, 0x01, 0xD0, 0x00, 0x20, 0x1D, 0xE6, 0xFF, 0x20, 0x1B, 0xE6, 0x03, 0x01, 0xE6, 0x01, 0x58, 0x21, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x5F, 0x93, 0x46, 0x5E, 0x4A, 0xC0, 0xB2, 0x8A, 0x46, 0x01, 0xF0, 0x0F, 0x04, 0x50, 0x70, 0xD1, 0x68, 0x00, 0x25, 0x01, 0xEB, 0x00, 0x10, 0x2E, 0x46, 0x90, 0xF9, 0x0B, 0x30, 0x01, 0x68, 0xE9, 0xB3, 0x00, 0x7B, 0x30, 0xB1, 0x02, 0x28, 0x02, 0xD0, 0x01, 0x28, 0x02, 0xD0, 0x02, 0xE0, 0x02, 0x26, 0x00, 0xE0, 0x01, 0x26, 0x53, 0x48, 0xD0, 0xF8, 0x03, 0x00, 0x90, 0xF9, 0x01, 0x01, 0x98, 0x42, 0x3D, 0xDD, 0x91, 0x46, 0x08, 0x04, 0x3E, 0xD4, 0x59, 0x46, 0x50, 0x46, 0xFF, 0xF7, 0x9E, 0xFD, 0x07, 0x46, 0xFF, 0x28, 0x33, 0xD0, 0x01, 0x2C, 0x33, 0xD0, 0x59, 0x46, 0x50, 0x46, 0xFF, 0xF7, 0x5B, 0xFE, 0xFF, 0x28, 0x2B, 0xD0, 0x01, 0x23, 0x3A, 0x46, 0x59, 0x46, 0x50, 0x46, 0xFF, 0xF7, 0x59, 0xFA, 0xFF, 0x28, 0x23, 0xD0, 0xDF, 0xF8, 0x04, 0x81, 0x00, 0x24, 0x08, 0xF1, 0x14, 0x08, 0x4F, 0x46, 0x58, 0xF8, 0x24, 0x20, 0x59, 0x46, 0x50, 0x46, 0x90, 0x47, 0xFF, 0x28, 0x1C, 0xD0, 0xB9, 0x78, 0x88, 0x42, 0x4C, 0xFC, 0xFF, 0x1C, 0x55, 0x21, 0x00, 0x07, 0xD2, 0x79, 0x78, 0xF8, 0x68, 0x00, 0xE0, 0x0F, 0xE0, 0x00, 0xEB, 0x01, 0x10, 0x80, 0x7A, 0x78, 0xB1, 0x64, 0x1C, 0xE4, 0xB2, 0x04, 0x2C, 0xE9, 0xD3, 0x79, 0x78, 0xF8, 0x68, 0x00, 0xEB, 0x01, 0x10, 0x80, 0x7A, 0x01, 0x28, 0x04, 0xD0, 0x1D, 0xB1, 0x00, 0x20, 0x1E, 0xE4, 0xFE, 0x28, 0xFB, 0xD0, 0x30, 0x46, 0x1A, 0xE4, 0x79, 0x78, 0xF8, 0x68, 0x00, 0xEB, 0x01, 0x10, 0x80, 0x7A, 0x01, 0x28, 0xF2, 0xD0, 0x6D, 0x1C, 0xED, 0xB2, 0xE3, 0xE7, 0x03, 0x01, 0x2E, 0x3A, 0x22, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x00, 0x25, 0x07, 0x46, 0x88, 0x46, 0x2C, 0x46, 0x24, 0x4E, 0x07, 0xE0, 0x42, 0x46, 0x39, 0x46, 0x20, 0x46, 0xFF, 0xF7, 0x82, 0xFF, 0x05, 0x43, 0x64, 0x1C, 0xE4, 0xB2, 0xF0, 0x78, 0x84, 0x42, 0xF4, 0xD3, 0x28, 0x46, 0x1D, 0xE6, 0x03, 0x01, 0x24, 0x64, 0x22, 0x0D, 0x00, 0x1F, 0x48, 0x10, 0xB5, 0x00, 0x68, 0x80, 0x07, 0x01, 0xD5, 0xAC, 0xF7, 0x6F, 0xFA, 0x19, 0x48, 0x00, 0x79, 0x00, 0x28, 0x03, 0xD0, 0xBD, 0xE8, 0x10, 0x40, 0xFF, 0xF7, 0xBC, 0xBA, 0x10, 0xBD, 0x03, 0x01, 0x3A, 0x84, 0x22, 0x0D, 0x00, 0x10, 0xB5, 0x14, 0x4C, 0xA0, 0x68, 0x28, 0xB1, 0xA1, 0x78, 0x04, 0x22, 0x02, 0xEB, 0x81, 0x11, 0x73, 0xF7, 0xAC, 0xF8, 0xE0, 0x68, 0x18, 0xB1, 0xE1, 0x78, 0x09, 0x01, 0x73, 0xF7, 0xA6, 0xF8, 0x20, 0x69, 0x18, 0xB1, 0x40, 0xF2, 0x2D, 0x11, 0x73, 0xF7, 0xA0, 0xF8, 0x00, 0x20, 0x20, 0x70, 0x60, 0x70, 0x20, 0x71, 0x10, 0xBD, 0x03, 0x01, 0x36, 0xBA, 0x22, 0x0D, 0x00, 0x07, 0x48, 0x00, 0x79, 0x38, 0xB9, 0x08, 0x48, 0x00, 0x68, 0x80, 0x07, 0x05, 0xD5, 0x07, 0x48, 0x00, 0x68, 0x00, 0x68, 0x08, 0x4C, 0xFC, 0xFF, 0x17, 0x56, 0x21, 0x00, 0xB1, 0x01, 0x20, 0x70, 0x47, 0x00, 0x20, 0x70, 0x47, 0x28, 0x5E, 0x0D, 0x00, 0x6C, 0x68, 0x0D, 0x00, 0x90, 0x95, 0x20, 0x00, 0x9C, 0x29, 0x20, 0x00, 0x1C, 0x34, 0x20, 0x00, 0x03, 0x01, 0x3E, 0xEC, 0x22, 0x0D, 0x00, 0x70, 0xB5, 0x0E, 0x46, 0x05, 0x46, 0x14, 0x46, 0xB3, 0x42, 0x15, 0xD9, 0x04, 0x2B, 0x0C, 0xD0, 0xFF, 0x22, 0x10, 0x21, 0x20, 0x46, 0xA2, 0xF7, 0xD9, 0xFB, 0x32, 0x46, 0x29, 0x46, 0x04, 0xF1, 0x0C, 0x00, 0xBD, 0xE8, 0x70, 0x40, 0x73, 0xF7, 0x87, 0xBA, 0x28, 0x78, 0x20, 0x70, 0x68, 0x78, 0x60, 0x70, 0xFF, 0x20, 0xE0, 0x70, 0x90, 0x70, 0x70, 0xBD, 0x03, 0x01, 0xC2, 0x02, 0x26, 0x23, 0x0D, 0x00, 0x2D, 0xE9, 0xF7, 0x4F, 0x82, 0xB0, 0x04, 0x00, 0x18, 0xD0, 0xB4, 0xF8, 0x50, 0x10, 0xB4, 0xF8, 0x4E, 0x00, 0x0D, 0x1A, 0x95, 0x42, 0x00, 0xD9, 0x15, 0x46, 0x28, 0x44, 0xA4, 0xF8, 0x4E, 0x00, 0x20, 0x6C, 0xA9, 0x46, 0x28, 0x44, 0x20, 0x64, 0x61, 0x6A, 0x04, 0xF1, 0x10, 0x00, 0x4F, 0xF0, 0x00, 0x0A, 0x00, 0x90, 0x51, 0xB9, 0x81, 0xF7, 0xEC, 0xF9, 0x18, 0xB1, 0x00, 0x20, 0x05, 0xB0, 0xBD, 0xE8, 0xF0, 0x8F, 0x20, 0x69, 0x60, 0x62, 0xC4, 0xF8, 0x2C, 0xA0, 0xD4, 0xF8, 0x24, 0x80, 0x04, 0xF1, 0x55, 0x0B, 0x57, 0xE0, 0xB4, 0xF8, 0x4C, 0x10, 0xE0, 0x6A, 0x0E, 0x1A, 0xAE, 0x42, 0x00, 0xD9, 0x2E, 0x46, 0xA1, 0x69, 0x08, 0xF1, 0x0C, 0x07, 0x38, 0x44, 0x0B, 0x68, 0x32, 0x46, 0x03, 0x99, 0x98, 0x47, 0x03, 0x90, 0x94, 0xF8, 0x54, 0x00, 0x30, 0xB1, 0xE0, 0x6A, 0x32, 0x46, 0xC1, 0x19, 0x58, 0x46, 0x94, 0xF7, 0x42, 0xFE, 0x08, 0xE0, 0x94, 0xF8, 0x55, 0x00, 0x28, 0xB1, 0xE0, 0x6A, 0x32, 0x46, 0xC1, 0x4C, 0xFC, 0xFF, 0x12, 0x57, 0x21, 0x00, 0x19, 0x58, 0x46, 0x94, 0xF7, 0x20, 0xFE, 0xE0, 0x6A, 0xAD, 0x1B, 0x30, 0x44, 0xE0, 0x62, 0xB4, 0xF8, 0x4C, 0x10, 0x88, 0x42, 0x2C, 0xD1, 0x40, 0x46, 0x81, 0xF7, 0xAB, 0xF9, 0x04, 0xF1, 0x08, 0x01, 0x40, 0x46, 0x81, 0xF7, 0xA2, 0xF9, 0xC4, 0xF8, 0x2C, 0xA0, 0x00, 0x98, 0x81, 0xF7, 0xA6, 0xF9, 0xD8, 0xB1, 0xC4, 0xF8, 0x24, 0xA0, 0x5D, 0xB1, 0xB4, 0xF8, 0x4E, 0x00, 0xA9, 0xEB, 0x05, 0x09, 0xA0, 0xEB, 0x05, 0x00, 0xA4, 0xF8, 0x4E, 0x00, 0x20, 0x6C, 0xA0, 0xEB, 0x05, 0x00, 0x20, 0x64, 0xE0, 0x69, 0xB4, 0xF8, 0x4E, 0x20, 0x81, 0x68, 0xD9, 0xB1, 0xC1, 0x8B, 0xCB, 0x06, 0x18, 0xD5, 0xC1, 0xF3, 0x01, 0x03, 0x01, 0x2B, 0x06, 0xD0, 0x08, 0xE0, 0x20, 0x69, 0x60, 0x62, 0x80, 0x46, 0x00, 0x2D, 0xA5, 0xD1, 0xEC, 0xE7, 0x83, 0x8B, 0x93, 0x42, 0x04, 0xD9, 0x8B, 0x07, 0x08, 0xD1, 0x83, 0x8B, 0x93, 0x42, 0x05, 0xD3, 0x21, 0xF0, 0x10, 0x01, 0xC1, 0x83, 0x82, 0x68, 0x81, 0x69, 0x90, 0x47, 0xA0, 0x69, 0xC1, 0x8B, 0x41, 0xF0, 0x10, 0x01, 0xC1, 0x83, 0x20, 0x46, 0x94, 0xF7, 0xAB, 0xFC, 0x48, 0x46, 0x80, 0xE7, 0x00, 0x00, 0x03, 0x01, 0x94, 0x01, 0x64, 0x24, 0x0D, 0x00, 0x2D, 0xE9, 0xF8, 0x43, 0x04, 0x00, 0x88, 0x46, 0x17, 0x46, 0x1D, 0x46, 0x0D, 0xD0, 0x60, 0x69, 0x00, 0x28, 0x0B, 0xD0, 0x72, 0xF7, 0xEF, 0xFF, 0x06, 0x46, 0xE0, 0x8B, 0x80, 0x06, 0x07, 0xD5, 0x60, 0x69, 0x29, 0x46, 0x94, 0xF7, 0x88, 0xFF, 0x03, 0xE0, 0x00, 0x20, 0xBD, 0xE8, 0xF8, 0x83, 0x00, 0x20, 0x38, 0x43, 0xAD, 0xF8, 0x00, 0x00, 0x8D, 0xF8, 0x02, 0x50, 0x23, 0x68, 0x03, 0x22, 0x69, 0x46, 0x40, 0x46, 0x98, 0x47, 0x01, 0x46, 0x60, 0x69, 0x4C, 0xFC, 0xFF, 0x0D, 0x58, 0x21, 0x00, 0x2A, 0x46, 0x94, 0xF7, 0x44, 0xFD, 0x61, 0x69, 0xC8, 0x69, 0xB1, 0xF8, 0x4E, 0x20, 0x81, 0x68, 0xA1, 0xB1, 0xC1, 0x8B, 0xCB, 0x06, 0x11, 0xD5, 0xC1, 0xF3, 0x01, 0x03, 0x01, 0x2B, 0x02, 0xD1, 0x83, 0x8B, 0x93, 0x42, 0x04, 0xD9, 0x8B, 0x07, 0x08, 0xD1, 0x83, 0x8B, 0x93, 0x42, 0x05, 0xD3, 0x21, 0xF0, 0x10, 0x01, 0xC1, 0x83, 0x82, 0x68, 0x81, 0x69, 0x90, 0x47, 0x30, 0x46, 0x72, 0xF7, 0xB9, 0xFF, 0x28, 0x46, 0xCD, 0xE7, 0x03, 0x01, 0x5E, 0xF4, 0x24, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x04, 0x00, 0x0E, 0x46, 0x15, 0x46, 0x20, 0xD0, 0xE0, 0x8B, 0x7A, 0x49, 0xC0, 0xF3, 0x81, 0x00, 0x31, 0xF8, 0x10, 0x00, 0xA0, 0xF5, 0x70, 0x61, 0xFF, 0x39, 0x16, 0xD0, 0x94, 0xF8, 0x24, 0x00, 0x01, 0x28, 0x12, 0xD1, 0x60, 0x69, 0x80, 0xB1, 0x72, 0xF7, 0x9B, 0xFF, 0x07, 0x46, 0x60, 0x69, 0x29, 0x46, 0x94, 0xF7, 0x42, 0xFF, 0x60, 0x69, 0x2A, 0x46, 0x31, 0x46, 0x94, 0xF7, 0x96, 0xFD, 0x38, 0x46, 0xBD, 0xE8, 0xF0, 0x41, 0x72, 0xF7, 0x90, 0xBF, 0x30, 0x46, 0xBD, 0xE8, 0xF0, 0x41, 0x11, 0x46, 0x94, 0xF7, 0xB7, 0xBB, 0x03, 0x01, 0xBA, 0x01, 0x4E, 0x25, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x04, 0x00, 0xC0, 0x8B, 0xC0, 0xF3, 0x81, 0x06, 0x51, 0xD0, 0x60, 0x69, 0x00, 0x28, 0x4E, 0xD0, 0x30, 0x46, 0x79, 0xF7, 0x5E, 0xFB, 0x05, 0x00, 0x02, 0xD1, 0x5A, 0xF7, 0x8B, 0xFB, 0x88, 0xB1, 0x5F, 0x48, 0x00, 0xEB, 0xC6, 0x07, 0x5A, 0xF7, 0x85, 0xFB, 0x38, 0xB3, 0x5D, 0x48, 0x00, 0x68, 0x10, 0xF4, 0x40, 0x0F, 0x60, 0x69, 0xB0, 0xF8, 0x4C, 0x60, 0x0A, 0xD0, 0xF0, 0x2E, 0x13, 0xD9, 0x30, 0x46, 0x12, 0xE0, 0x60, 0x69, 0xB0, 0xF8, 0x4C, 0xFC, 0xFF, 0x08, 0x59, 0x21, 0x00, 0x4E, 0x10, 0xBD, 0xE8, 0xF0, 0x41, 0x94, 0xF7, 0x8C, 0xBC, 0x78, 0x2E, 0x01, 0xD9, 0x30, 0x46, 0x00, 0xE0, 0x78, 0x20, 0xA8, 0x42, 0x0B, 0xD2, 0x78, 0x2E, 0x06, 0xD8, 0x78, 0x25, 0x07, 0xE0, 0xF0, 0x20, 0xA8, 0x42, 0x04, 0xD2, 0xF0, 0x2E, 0x01, 0xD9, 0x35, 0x46, 0x00, 0xE0, 0xF0, 0x25, 0x60, 0x69, 0x0E, 0xE0, 0x60, 0x69, 0xB0, 0xF8, 0x4C, 0x60, 0x3C, 0x2E, 0x01, 0xD9, 0x31, 0x46, 0x00, 0xE0, 0x3C, 0x21, 0xA9, 0x42, 0x04, 0xD2, 0x3C, 0x2E, 0x01, 0xD9, 0x35, 0x46, 0x00, 0xE0, 0x3C, 0x25, 0x29, 0x46, 0x94, 0xF7, 0xEA, 0xFE, 0x60, 0x69, 0x2A, 0x46, 0x39, 0x46, 0xBD, 0xE8, 0xF0, 0x41, 0x94, 0xF7, 0x9E, 0xBC, 0xBD, 0xE8, 0xF0, 0x81, 0x03, 0x01, 0xFC, 0x01, 0x04, 0x26, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x05, 0x00, 0xC0, 0x8B, 0x3A, 0x49, 0xC0, 0xF3, 0x81, 0x06, 0xC6, 0xEB, 0x06, 0x10, 0x00, 0xEB, 0x86, 0x10, 0x01, 0xEB, 0x80, 0x07, 0xEF, 0xD0, 0x68, 0x69, 0x00, 0x28, 0xEC, 0xD0, 0x30, 0x46, 0x79, 0xF7, 0xDD, 0xFA, 0x04, 0x00, 0xE7, 0xD0, 0x2F, 0x48, 0x00, 0x1F, 0x00, 0xEB, 0xC6, 0x06, 0x5A, 0xF7, 0x25, 0xFB, 0x60, 0xB3, 0x2D, 0x48, 0x00, 0x68, 0x10, 0xF4, 0x40, 0x0F, 0x68, 0x69, 0xB0, 0xF8, 0x4C, 0x70, 0x03, 0xD0, 0xF0, 0x2F, 0x0C, 0xD9, 0x38, 0x46, 0x0B, 0xE0, 0x78, 0x2F, 0x01, 0xD9, 0x38, 0x46, 0x00, 0xE0, 0x78, 0x20, 0xA0, 0x42, 0x0B, 0xD2, 0x78, 0x2F, 0x06, 0xD8, 0x78, 0x24, 0x07, 0xE0, 0xF0, 0x20, 0xA0, 0x42, 0x04, 0xD2, 0xF0, 0x2F, 0x01, 0xD9, 0x3C, 0x46, 0x00, 0xE0, 0xF0, 0x24, 0x68, 0x69, 0x21, 0x46, 0x94, 0xF7, 0x97, 0xFE, 0x68, 0x69, 0x22, 0x46, 0x31, 0x46, 0x94, 0xF7, 0xEB, 0x4C, 0xFC, 0xFF, 0x03, 0x5A, 0x21, 0x00, 0xFC, 0x28, 0x46, 0xBD, 0xE8, 0xF0, 0x41, 0x59, 0xF7, 0xAB, 0xBF, 0xD7, 0xF8, 0xE4, 0x10, 0x88, 0x02, 0x0B, 0xD5, 0x00, 0x20, 0x01, 0xE0, 0x32, 0x68, 0x40, 0x1C, 0xB0, 0xEB, 0x54, 0x0F, 0xFA, 0xD3, 0x21, 0xF4, 0x00, 0x10, 0xC7, 0xF8, 0xE4, 0x00, 0xA3, 0xE7, 0x68, 0x69, 0xB0, 0xF8, 0x4C, 0x70, 0x3C, 0x2F, 0x01, 0xD9, 0x39, 0x46, 0x00, 0xE0, 0x3C, 0x21, 0xA1, 0x42, 0x04, 0xD2, 0x3C, 0x2F, 0x01, 0xD9, 0x3C, 0x46, 0x00, 0xE0, 0x3C, 0x24, 0x21, 0x46, 0x94, 0xF7, 0x6B, 0xFE, 0x68, 0x69, 0x22, 0x46, 0x31, 0x46, 0xBD, 0xE8, 0xF0, 0x41, 0x94, 0xF7, 0xBD, 0xBC, 0x00, 0x00, 0xB4, 0x31, 0x20, 0x00, 0x08, 0x10, 0x35, 0x00, 0x58, 0x1E, 0x20, 0x00, 0xAC, 0x75, 0x20, 0x00, 0x03, 0x01, 0x20, 0xFC, 0x26, 0x0D, 0x00, 0x10, 0xB5, 0x6B, 0xF7, 0x2D, 0xFF, 0x00, 0x28, 0x06, 0xD0, 0x01, 0x21, 0x80, 0xF8, 0xED, 0x10, 0xBD, 0xE8, 0x10, 0x40, 0x6B, 0xF7, 0x30, 0xBE, 0x10, 0xBD, 0x00, 0x00, 0x03, 0x01, 0x88, 0x02, 0x18, 0x27, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x5F, 0x45, 0x69, 0xB0, 0xF8, 0x1E, 0xC0, 0x04, 0x46, 0x87, 0x8C, 0xB5, 0xF8, 0x4C, 0x20, 0x00, 0x6A, 0x8B, 0x46, 0xCC, 0xF3, 0x81, 0x08, 0x16, 0x46, 0x00, 0x28, 0x1C, 0xD0, 0x32, 0x49, 0xDF, 0xF8, 0xCC, 0xA0, 0x09, 0x88, 0x8B, 0x06, 0x4F, 0xF0, 0xD2, 0x01, 0x09, 0xD4, 0xDA, 0xF8, 0x00, 0x30, 0x33, 0xB9, 0xBB, 0x07, 0x5B, 0x0F, 0x21, 0xFA, 0x03, 0xF3, 0xDB, 0x43, 0x9B, 0x07, 0x09, 0xD0, 0xBB, 0x07, 0x5B, 0x0F, 0xD9, 0x40, 0x01, 0xF0, 0x03, 0x01, 0x4F, 0xF0, 0x01, 0x09, 0x02, 0x29, 0x03, 0xD0, 0x45, 0xE0, 0x00, 0x20, 0xBD, 0xE8, 0xF0, 0x9F, 0x5F, 0xEA, 0x8C, 0x4C, 0xFC, 0xFF, 0xFE, 0x5A, 0x21, 0x00, 0x61, 0x3F, 0xD4, 0x78, 0xF7, 0x5D, 0xFA, 0x10, 0xB1, 0xBB, 0xF1, 0x00, 0x0F, 0x1D, 0xD0, 0xB8, 0x06, 0x00, 0xD5, 0x76, 0x10, 0x1F, 0x49, 0xC1, 0xF8, 0xB0, 0x92, 0xE1, 0x8B, 0x1E, 0x4A, 0xC1, 0xF3, 0x81, 0x01, 0x51, 0x5C, 0x8E, 0x40, 0x1C, 0x49, 0x0E, 0x60, 0x1B, 0x49, 0x09, 0xFA, 0x08, 0xF0, 0x08, 0x39, 0x08, 0x60, 0x0A, 0x68, 0x02, 0x42, 0xFC, 0xD1, 0x20, 0x6A, 0xB5, 0xF8, 0x4C, 0x20, 0x0C, 0x30, 0x16, 0x49, 0xA2, 0xF7, 0xAD, 0xF9, 0x07, 0xE0, 0x60, 0x69, 0x00, 0x21, 0xB0, 0xF8, 0x4C, 0x20, 0x20, 0x6A, 0x0C, 0x30, 0xA2, 0xF7, 0xC6, 0xF9, 0x21, 0x6A, 0x4F, 0xF4, 0x00, 0x50, 0x88, 0x60, 0xDA, 0xF8, 0x00, 0x00, 0x18, 0xB1, 0x20, 0x6A, 0x4F, 0xF4, 0xC0, 0x41, 0x81, 0x60, 0x84, 0xF8, 0x27, 0x90, 0x69, 0x6C, 0xB5, 0xF8, 0x4C, 0x20, 0x48, 0x46, 0x11, 0x44, 0x69, 0x64, 0xBA, 0xE7, 0x29, 0x6B, 0x0C, 0x30, 0xE6, 0xE7, 0x00, 0x00, 0x08, 0x1E, 0x20, 0x00, 0xA4, 0x35, 0x20, 0x00, 0x00, 0x90, 0x31, 0x00, 0x6C, 0x5D, 0x0D, 0x00, 0x08, 0x8D, 0x31, 0x00, 0x78, 0x8E, 0x31, 0x00, 0x03, 0x01, 0x38, 0x1C, 0x28, 0x0D, 0x00, 0x70, 0xB5, 0x05, 0x46, 0x08, 0x46, 0x01, 0x26, 0x90, 0xF8, 0xA3, 0x00, 0xB5, 0xF8, 0x0B, 0x40, 0xA9, 0x7A, 0x40, 0x09, 0x00, 0x22, 0x46, 0xF7, 0xE1, 0xFC, 0x00, 0x28, 0x09, 0xD0, 0x40, 0x88, 0xA0, 0x42, 0x00, 0xD2, 0x04, 0x46, 0x2A, 0x7A, 0x21, 0x46, 0x30, 0x46, 0x4D, 0xF7, 0x4C, 0xF8, 0x01, 0x20, 0x70, 0xBD, 0x03, 0x01, 0x56, 0x50, 0x28, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0x00, 0x21, 0x13, 0x20, 0x7F, 0xF7, 0xDF, 0xFB, 0xFE, 0xF7, 0xAE, 0xF8, 0x34, 0x48, 0x00, 0x78, 0x01, 0x28, 0x4C, 0xFC, 0xFF, 0xF9, 0x5B, 0x21, 0x00, 0x01, 0xD1, 0x33, 0x49, 0x08, 0x70, 0x33, 0x49, 0x00, 0x20, 0x08, 0x70, 0x33, 0x49, 0xC1, 0xE9, 0x0A, 0x00, 0x8C, 0xF7, 0xC8, 0xF9, 0x71, 0xF7, 0x4B, 0xF9, 0x18, 0xB1, 0xBD, 0xE8, 0x10, 0x40, 0x89, 0xF7, 0x79, 0xBF, 0x01, 0x20, 0x59, 0xF7, 0x79, 0xF9, 0xB4, 0xF8, 0x09, 0x00, 0x00, 0x21, 0x30, 0xF7, 0xD7, 0xFE, 0xBD, 0xE8, 0x10, 0x40, 0x01, 0xF0, 0x3F, 0xBE, 0x03, 0x01, 0x30, 0xA2, 0x28, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0x0A, 0x22, 0x55, 0x21, 0x0C, 0x20, 0x30, 0xF7, 0xE0, 0xFE, 0x01, 0x46, 0x08, 0x30, 0x22, 0x68, 0xC0, 0xF8, 0x02, 0x20, 0x62, 0x68, 0xC0, 0xF8, 0x06, 0x20, 0x22, 0x89, 0x42, 0x81, 0xBD, 0xE8, 0x10, 0x40, 0x08, 0x46, 0x30, 0xF7, 0x60, 0xBE, 0x03, 0x01, 0x7A, 0xCE, 0x28, 0x0D, 0x00, 0x3E, 0xB5, 0x00, 0xF1, 0x09, 0x04, 0x00, 0x20, 0x00, 0x90, 0x01, 0x90, 0x02, 0x90, 0xD4, 0xF8, 0x03, 0x00, 0x00, 0x90, 0xD4, 0xF8, 0x07, 0x00, 0x01, 0x90, 0xB4, 0xF8, 0x0B, 0x00, 0xAD, 0xF8, 0x08, 0x00, 0x15, 0x46, 0x68, 0x46, 0x88, 0xF7, 0x91, 0xFE, 0x21, 0x7B, 0x09, 0x06, 0x17, 0xD4, 0x14, 0x28, 0x15, 0xD3, 0x0F, 0x49, 0x0A, 0x22, 0x09, 0x1D, 0xE0, 0x1C, 0x6F, 0xF7, 0xC5, 0xFC, 0x00, 0x28, 0x0C, 0xD0, 0xE0, 0x1C, 0x70, 0xF7, 0x14, 0xFC, 0x90, 0xF7, 0xF5, 0xFA, 0x20, 0xB1, 0x90, 0xF7, 0x1B, 0xFB, 0xE0, 0x1C, 0xFF, 0xF7, 0xBD, 0xFF, 0x89, 0xF7, 0x4F, 0xF9, 0x3E, 0xBD, 0x12, 0x20, 0x68, 0x71, 0x3E, 0xBD, 0x4E, 0x5E, 0x0D, 0x00, 0x97, 0x1E, 0x20, 0x00, 0x4C, 0x5E, 0x0D, 0x00, 0x18, 0x41, 0x20, 0x00, 0x03, 0x01, 0x14, 0x44, 0x29, 0x0D, 0x00, 0x7C, 0x48, 0x81, 0x68, 0xC2, 0xF8, 0x06, 0x10, 0x4C, 0xFC, 0xFF, 0xF4, 0x5C, 0x21, 0x00, 0xC0, 0x68, 0xC2, 0xF8, 0x0A, 0x00, 0x70, 0x47, 0x03, 0x01, 0x3E, 0x54, 0x29, 0x0D, 0x00, 0x70, 0xB5, 0x79, 0x4C, 0x0E, 0x46, 0x00, 0xF1, 0x09, 0x05, 0xA1, 0x69, 0x31, 0xB1, 0xB0, 0xF8, 0x09, 0x00, 0xBD, 0xE8, 0x70, 0x40, 0x0C, 0x21, 0x30, 0xF7, 0x6C, 0xBE, 0x73, 0x48, 0x71, 0xF7, 0xD9, 0xFA, 0xA9, 0xF7, 0x42, 0xFA, 0x72, 0x48, 0xA5, 0x61, 0xC4, 0xE9, 0x02, 0x04, 0x6F, 0x48, 0x71, 0xF7, 0xD6, 0xFA, 0x00, 0x20, 0x30, 0x70, 0x70, 0xBD, 0x03, 0x01, 0x2C, 0x8E, 0x29, 0x0D, 0x00, 0x70, 0xB5, 0x04, 0x46, 0x0D, 0x46, 0x16, 0x46, 0xA0, 0xF7, 0xC0, 0xFE, 0x28, 0xB9, 0x00, 0x23, 0x1A, 0x46, 0x19, 0x46, 0x02, 0x20, 0xFE, 0xF7, 0x1C, 0xF8, 0x32, 0x46, 0x29, 0x46, 0x20, 0x46, 0xBD, 0xE8, 0x70, 0x40, 0x82, 0xF7, 0x05, 0xBD, 0x03, 0x01, 0x28, 0xB6, 0x29, 0x0D, 0x00, 0x70, 0xB5, 0x00, 0xF1, 0x09, 0x04, 0x15, 0x46, 0x82, 0xF7, 0x36, 0xFD, 0x68, 0x79, 0x00, 0x28, 0x07, 0xD1, 0x22, 0x1D, 0xE1, 0x78, 0xBD, 0xE8, 0x70, 0x40, 0x00, 0x23, 0x01, 0x20, 0xFE, 0xF7, 0x04, 0xB8, 0x70, 0xBD, 0x03, 0x01, 0xB6, 0x02, 0xDA, 0x29, 0x0D, 0x00, 0x2D, 0xE9, 0xFC, 0x41, 0x00, 0xF1, 0x09, 0x04, 0x00, 0x26, 0xAB, 0xF7, 0x42, 0xFE, 0x40, 0xB9, 0x57, 0x48, 0x44, 0xF2, 0x10, 0x01, 0x00, 0x68, 0x08, 0x42, 0x04, 0xD0, 0xAB, 0xF7, 0x77, 0xFE, 0x08, 0xB1, 0x0C, 0x26, 0x7D, 0xE0, 0xB4, 0xF8, 0x05, 0x10, 0xB4, 0xF8, 0x03, 0x00, 0x45, 0xF7, 0x50, 0xFD, 0x20, 0xB3, 0x61, 0x8B, 0x20, 0x8B, 0xCD, 0xE9, 0x00, 0x01, 0xE3, 0x8A, 0xA2, 0x8A, 0x61, 0x8A, 0x20, 0x8A, 0x45, 0xF7, 0x56, 0xFD, 0xC8, 0xB1, 0x61, 0xF7, 0x8F, 0xFF, 0xC0, 0xB1, 0x4C, 0xFC, 0xFF, 0xEF, 0x5D, 0x21, 0x00, 0x00, 0x20, 0x6F, 0xF7, 0xF5, 0xFD, 0x07, 0x46, 0xFF, 0x28, 0x14, 0xD0, 0xA5, 0xF7, 0x10, 0xF9, 0x38, 0x46, 0x6F, 0xF7, 0x77, 0xFD, 0x05, 0x46, 0x3F, 0x48, 0x71, 0xF7, 0x70, 0xFA, 0x62, 0x8B, 0x21, 0x8B, 0x28, 0x46, 0x45, 0xF7, 0x5B, 0xFD, 0xE0, 0x79, 0x30, 0xB1, 0x0F, 0xE0, 0x12, 0x26, 0x4F, 0xE0, 0x0D, 0x26, 0x4D, 0xE0, 0x09, 0x26, 0x4B, 0xE0, 0x20, 0x7A, 0x85, 0xF8, 0x56, 0x00, 0xD4, 0xF8, 0x09, 0x00, 0x28, 0x65, 0xB4, 0xF8, 0x0D, 0x00, 0xA5, 0xF8, 0x54, 0x00, 0xE0, 0x7B, 0x85, 0xF8, 0x57, 0x00, 0x20, 0x8A, 0xA5, 0xF8, 0x48, 0x00, 0x60, 0x8A, 0xA5, 0xF8, 0x4A, 0x00, 0x95, 0xF8, 0xD2, 0x00, 0xA5, 0xF7, 0x8B, 0xFC, 0x21, 0x8A, 0x01, 0x80, 0x61, 0x8A, 0x41, 0x80, 0xA0, 0x8A, 0x28, 0x81, 0xE0, 0x8A, 0x68, 0x81, 0x28, 0x46, 0xA8, 0xF7, 0xF1, 0xFE, 0x25, 0x48, 0x71, 0xF7, 0x43, 0xFA, 0x29, 0x46, 0x20, 0x46, 0x82, 0xF7, 0xE8, 0xFA, 0x00, 0x28, 0x26, 0xD1, 0x01, 0x20, 0xAB, 0xF7, 0xC5, 0xFD, 0x38, 0x46, 0xAB, 0xF7, 0xBE, 0xFD, 0xB4, 0xF8, 0x05, 0x00, 0x20, 0xF0, 0x01, 0x00, 0xAB, 0xF7, 0x1B, 0xFE, 0xB4, 0xF8, 0x03, 0x00, 0x20, 0xF0, 0x01, 0x00, 0xAB, 0xF7, 0x1D, 0xFE, 0xE0, 0x79, 0xAB, 0xF7, 0x0A, 0xFE, 0x19, 0x49, 0x00, 0x20, 0xFE, 0xF7, 0x1C, 0xF9, 0x00, 0x21, 0x08, 0x46, 0xAB, 0xF7, 0x59, 0xFD, 0x6E, 0xF7, 0x68, 0xF9, 0x15, 0x49, 0x08, 0x60, 0x20, 0x88, 0x31, 0x46, 0xBD, 0xE8, 0xFC, 0x41, 0x30, 0xF7, 0xCB, 0xBD, 0xBD, 0xE8, 0xFC, 0x81, 0x03, 0x01, 0x4C, 0x0C, 0x2B, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0xAB, 0xF7, 0xAC, 0xFD, 0x40, 0xB1, 0x00, 0x20, 0xAB, 0xF7, 0x97, 0xFD, 0xBD, 0xE8, 0x4C, 0xFC, 0xFF, 0xEA, 0x5E, 0x21, 0x00, 0x10, 0x40, 0x0A, 0x49, 0x10, 0x20, 0xFE, 0xF7, 0xFE, 0xB8, 0xB4, 0xF8, 0x09, 0x00, 0xBD, 0xE8, 0x10, 0x40, 0x0C, 0x21, 0x30, 0xF7, 0x89, 0xBD, 0x00, 0x00, 0x10, 0x82, 0x20, 0x00, 0xF4, 0xEF, 0x20, 0x00, 0x88, 0x29, 0x20, 0x00, 0x63, 0x85, 0x01, 0x00, 0x9C, 0x29, 0x20, 0x00, 0x5C, 0xEF, 0x20, 0x00, 0x14, 0x34, 0x20, 0x00, 0x03, 0x01, 0x6A, 0x54, 0x2B, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x05, 0x46, 0x00, 0xF1, 0x09, 0x04, 0x0E, 0x46, 0x90, 0x46, 0xE0, 0x1C, 0x70, 0xF7, 0x05, 0xFD, 0xD0, 0xB1, 0xC1, 0x69, 0xC1, 0xF3, 0xC4, 0x01, 0x04, 0x29, 0x15, 0xD0, 0x08, 0x29, 0x13, 0xD2, 0x07, 0x46, 0x00, 0xF1, 0x28, 0x01, 0x70, 0xF7, 0x45, 0xFD, 0xA0, 0xB1, 0xF8, 0x69, 0x80, 0x02, 0x0A, 0xD4, 0x38, 0x68, 0x8C, 0xF7, 0xCB, 0xF9, 0x30, 0xB1, 0x39, 0x68, 0x0B, 0x20, 0x30, 0xF7, 0x70, 0xFE, 0x38, 0x68, 0x71, 0xF7, 0x0A, 0xF8, 0x42, 0x46, 0x31, 0x46, 0x28, 0x46, 0xBD, 0xE8, 0xF0, 0x41, 0x7C, 0xF7, 0x6E, 0xBB, 0x20, 0x88, 0xBD, 0xE8, 0xF0, 0x41, 0x12, 0x21, 0x30, 0xF7, 0x72, 0xBD, 0x03, 0x01, 0x36, 0xBA, 0x2B, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x05, 0x46, 0x0E, 0x46, 0x00, 0xF1, 0x09, 0x04, 0x17, 0x46, 0x80, 0x89, 0x03, 0x21, 0x70, 0xF7, 0x43, 0xFD, 0x30, 0xB1, 0x3A, 0x46, 0x31, 0x46, 0x28, 0x46, 0xBD, 0xE8, 0xF0, 0x41, 0x7C, 0xF7, 0x8E, 0xBC, 0x20, 0x88, 0xBD, 0xE8, 0xF0, 0x41, 0x02, 0x21, 0x30, 0xF7, 0x59, 0xBD, 0x03, 0x01, 0x54, 0xEC, 0x2B, 0x0D, 0x00, 0x00, 0x23, 0xD2, 0x1E, 0xFC, 0x2A, 0x20, 0xD3, 0x04, 0x29, 0x1E, 0xD3, 0x02, 0x68, 0x41, 0x68, 0x8A, 0x42, 0x03, 0xD0, 0x0A, 0xB1, 0xC1, 0xB9, 0x4C, 0xFC, 0xFF, 0xE5, 0x5F, 0x21, 0x00, 0x00, 0xE0, 0xB1, 0xB1, 0x01, 0x7A, 0x42, 0x7B, 0x91, 0x42, 0x12, 0xD1, 0x41, 0x8A, 0x81, 0xB1, 0x81, 0x8A, 0x71, 0xB1, 0xD0, 0xF8, 0x16, 0x20, 0xD0, 0xF8, 0x1A, 0x10, 0x8A, 0x42, 0x03, 0xD0, 0x0A, 0xB1, 0x31, 0xB9, 0x00, 0xE0, 0x21, 0xB1, 0x81, 0x7F, 0x90, 0xF8, 0x23, 0x00, 0x81, 0x42, 0x00, 0xD0, 0x12, 0x23, 0x18, 0x46, 0x70, 0x47, 0x03, 0x01, 0x64, 0x3C, 0x2C, 0x0D, 0x00, 0x01, 0x46, 0x16, 0x4B, 0xD1, 0xF8, 0x16, 0x20, 0x09, 0x8D, 0x00, 0x20, 0xC9, 0x08, 0xB2, 0xFB, 0xF1, 0xF2, 0x19, 0x68, 0xB2, 0xF5, 0xFA, 0x5F, 0x21, 0xF4, 0x40, 0x01, 0x0D, 0xD0, 0xB2, 0xF5, 0x7A, 0x5F, 0x11, 0xD0, 0xB2, 0xF5, 0x7A, 0x6F, 0x06, 0xD1, 0x01, 0xF5, 0x00, 0x01, 0x21, 0xF0, 0x38, 0x00, 0x18, 0x60, 0x4F, 0xF4, 0xFA, 0x30, 0x70, 0x47, 0x21, 0xF0, 0x38, 0x00, 0x08, 0x30, 0x18, 0x60, 0x4F, 0xF4, 0x7A, 0x30, 0x70, 0x47, 0x01, 0xF5, 0x80, 0x01, 0x21, 0xF0, 0x38, 0x00, 0x10, 0x30, 0x18, 0x60, 0x4F, 0xF4, 0xFA, 0x20, 0x70, 0x47, 0x00, 0x00, 0x58, 0x1E, 0x20, 0x00, 0x03, 0x01, 0xAC, 0x01, 0x9C, 0x2C, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x47, 0x04, 0x46, 0x0D, 0x46, 0xFE, 0xF7, 0xA9, 0xFD, 0x4F, 0xF0, 0x07, 0x09, 0x01, 0x28, 0x04, 0xD0, 0x29, 0x68, 0x81, 0xF8, 0x05, 0x90, 0xBD, 0xE8, 0xF0, 0x87, 0x20, 0x79, 0x12, 0x21, 0xF7, 0x4F, 0x02, 0x28, 0x08, 0xD8, 0x03, 0xD2, 0x62, 0x79, 0x3B, 0x78, 0x9A, 0x42, 0x03, 0xD2, 0x28, 0xB9, 0xA2, 0x7A, 0x01, 0x2A, 0x02, 0xD9, 0x28, 0x68, 0x41, 0x71, 0xEC, 0xE7, 0x2E, 0x68, 0xDF, 0xF8, 0xC0, 0x83, 0xF0, 0x71, 0x20, 0x79, 0x38, 0xB1, 0x01, 0x28, 0x19, 0xD0, 0x02, 0x21, 0x00, 0x20, 0x4C, 0xFC, 0xFF, 0xE0, 0x60, 0x21, 0x00, 0xAB, 0xF7, 0x6F, 0xFD, 0x38, 0x78, 0x1A, 0xE0, 0xEA, 0x4A, 0x60, 0x79, 0x12, 0x68, 0x02, 0xEB, 0x00, 0x10, 0x00, 0x68, 0x18, 0xB1, 0x29, 0x68, 0x17, 0x20, 0x48, 0x71, 0xD3, 0xE7, 0x98, 0xF8, 0x00, 0x00, 0x3A, 0x78, 0x90, 0x42, 0xDE, 0xD2, 0x20, 0x46, 0xFE, 0xF7, 0x8E, 0xFD, 0x02, 0xE0, 0x20, 0x46, 0xFE, 0xF7, 0xB5, 0xFD, 0x39, 0x78, 0x98, 0xF8, 0x00, 0x00, 0x08, 0x1A, 0x30, 0x72, 0x28, 0x68, 0x40, 0x79, 0x00, 0x28, 0xBE, 0xD1, 0x20, 0x79, 0xF0, 0x71, 0x29, 0x68, 0x81, 0xF8, 0x01, 0x90, 0xB8, 0xE7, 0x03, 0x01, 0xB0, 0x01, 0x44, 0x2D, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x04, 0x46, 0x0D, 0x46, 0xFE, 0xF7, 0x55, 0xFD, 0x4F, 0xF0, 0x07, 0x08, 0x01, 0x28, 0x47, 0xD1, 0x20, 0x79, 0x12, 0x27, 0x02, 0x28, 0x08, 0xD8, 0x02, 0xD2, 0x21, 0x7B, 0x02, 0x29, 0x04, 0xD8, 0xCC, 0x4A, 0x61, 0x79, 0x12, 0x78, 0x91, 0x42, 0x03, 0xD3, 0x28, 0x68, 0x47, 0x71, 0xBD, 0xE8, 0xF0, 0x81, 0x2E, 0x68, 0x28, 0xB1, 0x01, 0x28, 0x13, 0xD0, 0x02, 0x28, 0x1C, 0xD0, 0x77, 0x71, 0xF5, 0xE7, 0x20, 0x7B, 0x0B, 0x46, 0x40, 0xF0, 0x80, 0x02, 0xA1, 0x1D, 0x00, 0x20, 0xFE, 0xF7, 0xA6, 0xFD, 0xFE, 0x28, 0x24, 0xD0, 0xFD, 0x28, 0x11, 0xD1, 0x29, 0x68, 0x17, 0x20, 0x48, 0x71, 0xE5, 0xE7, 0x20, 0x7B, 0x0B, 0x46, 0x40, 0xF0, 0x80, 0x02, 0xA1, 0x1D, 0x00, 0x20, 0xFE, 0xF7, 0x0C, 0xFE, 0xFF, 0x28, 0xD9, 0xD0, 0x02, 0xE0, 0x00, 0x20, 0xFE, 0xF7, 0x4D, 0xFE, 0x28, 0x68, 0x40, 0x79, 0x00, 0x28, 0xD3, 0xD1, 0x20, 0x79, 0xF0, 0x71, 0x29, 0x68, 0xB4, 0x48, 0x81, 0xF8, 0x01, 0x80, 0x00, 0x68, 0xB3, 0x49, 0x00, 0x78, 0x09, 0x78, 0x08, 0x4C, 0xFC, 0xFF, 0xDB, 0x61, 0x21, 0x00, 0x1A, 0x30, 0x72, 0xC6, 0xE7, 0x29, 0x68, 0x81, 0xF8, 0x05, 0x80, 0xC2, 0xE7, 0x03, 0x01, 0xFE, 0x01, 0xF0, 0x2D, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x47, 0x04, 0x46, 0x0D, 0x46, 0x00, 0x26, 0xFE, 0xF7, 0xFE, 0xFC, 0x4F, 0xF0, 0x07, 0x09, 0x01, 0x28, 0x6D, 0xD1, 0x20, 0x79, 0x02, 0x28, 0x02, 0xD2, 0xA1, 0x78, 0xC9, 0x1E, 0xCE, 0xB2, 0x4F, 0xF0, 0x12, 0x08, 0xC8, 0xB1, 0x02, 0x28, 0x13, 0xD8, 0xA1, 0x78, 0x02, 0x29, 0x10, 0xD3, 0x02, 0x28, 0x16, 0xD8, 0x9D, 0x4A, 0x61, 0x79, 0x12, 0x78, 0x91, 0x42, 0x09, 0xD2, 0x02, 0x28, 0x0F, 0xD2, 0x10, 0x2E, 0x05, 0xD8, 0x02, 0x2E, 0x0B, 0xD0, 0x04, 0x2E, 0x09, 0xD0, 0x10, 0x2E, 0x07, 0xD0, 0x29, 0x68, 0x81, 0xF8, 0x05, 0x80, 0x34, 0xE7, 0xF1, 0x07, 0xF9, 0xD1, 0x76, 0x08, 0xE3, 0xE7, 0x2F, 0x68, 0x30, 0xB1, 0x01, 0x28, 0x19, 0xD0, 0x02, 0x28, 0x26, 0xD0, 0x87, 0xF8, 0x05, 0x80, 0x27, 0xE7, 0xE0, 0x78, 0x63, 0x79, 0x03, 0x28, 0x32, 0x46, 0x04, 0xF1, 0x06, 0x01, 0x07, 0xD0, 0x03, 0x20, 0xFE, 0xF7, 0x36, 0xFD, 0xFE, 0x28, 0x31, 0xD0, 0xFD, 0x28, 0x02, 0xD0, 0x1B, 0xE0, 0x02, 0x20, 0xF6, 0xE7, 0x29, 0x68, 0x17, 0x20, 0x48, 0x71, 0x12, 0xE7, 0xE0, 0x78, 0x63, 0x79, 0x03, 0x28, 0x32, 0x46, 0x04, 0xF1, 0x06, 0x01, 0x05, 0xD0, 0x03, 0x20, 0xFE, 0xF7, 0x97, 0xFD, 0xFF, 0x28, 0xCD, 0xD0, 0x08, 0xE0, 0x02, 0x20, 0xF8, 0xE7, 0xE0, 0x78, 0x61, 0x79, 0x03, 0x28, 0x13, 0xD0, 0x03, 0x20, 0xFE, 0xF7, 0xD2, 0xFD, 0x28, 0x68, 0x40, 0x79, 0x00, 0x28, 0xC2, 0xD1, 0x20, 0x79, 0xF8, 0x71, 0x29, 0x68, 0x77, 0x48, 0x81, 0xF8, 0x01, 0x90, 0x00, 0x68, 0x76, 0x49, 0x00, 0x78, 0x4C, 0xFC, 0xFF, 0xD6, 0x62, 0x21, 0x00, 0x09, 0x78, 0x08, 0x1A, 0x38, 0x72, 0xEB, 0xE6, 0x02, 0x20, 0xEA, 0xE7, 0x29, 0x68, 0x81, 0xF8, 0x05, 0x90, 0xE5, 0xE6, 0x03, 0x01, 0xF8, 0x01, 0xEA, 0x2E, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x04, 0x46, 0x0D, 0x46, 0xFE, 0xF7, 0x82, 0xFC, 0x07, 0x27, 0x01, 0x28, 0x6D, 0xD1, 0x23, 0x79, 0x4F, 0xF0, 0x12, 0x08, 0x02, 0x2B, 0x07, 0xD8, 0xA0, 0x78, 0x03, 0x28, 0x04, 0xD3, 0x63, 0x4A, 0x61, 0x79, 0x12, 0x78, 0x91, 0x42, 0x03, 0xD3, 0x29, 0x68, 0x81, 0xF8, 0x05, 0x80, 0x2B, 0xE7, 0xC0, 0x1E, 0xC2, 0xB2, 0xE0, 0x78, 0x2E, 0x68, 0x06, 0x28, 0x03, 0xD0, 0x07, 0x28, 0x01, 0xD0, 0x63, 0xB1, 0x00, 0xE0, 0x23, 0xB1, 0x01, 0x2B, 0x21, 0xD0, 0x02, 0x2B, 0x32, 0xD0, 0x3C, 0xE0, 0xD3, 0x07, 0x02, 0xD0, 0x86, 0xF8, 0x05, 0x80, 0x16, 0xE7, 0x52, 0x08, 0x05, 0x28, 0x0C, 0xD0, 0x0B, 0x46, 0x06, 0x28, 0x04, 0xF1, 0x06, 0x01, 0x0B, 0xD0, 0x06, 0x20, 0xFE, 0xF7, 0xC4, 0xFC, 0xFE, 0x28, 0x3A, 0xD0, 0xFD, 0x28, 0x06, 0xD0, 0x27, 0xE0, 0x0B, 0x46, 0xA1, 0x1D, 0x04, 0x20, 0xF4, 0xE7, 0x05, 0x20, 0xF2, 0xE7, 0x29, 0x68, 0x17, 0x20, 0x48, 0x71, 0xFC, 0xE6, 0x05, 0x28, 0x0A, 0xD0, 0x0B, 0x46, 0x06, 0x28, 0x04, 0xF1, 0x06, 0x01, 0x09, 0xD0, 0x06, 0x20, 0xFE, 0xF7, 0x21, 0xFD, 0xFF, 0x28, 0xC0, 0xD0, 0x10, 0xE0, 0x0B, 0x46, 0xA1, 0x1D, 0x04, 0x20, 0xF6, 0xE7, 0x05, 0x20, 0xF4, 0xE7, 0x05, 0x28, 0x03, 0xD0, 0x06, 0x28, 0x03, 0xD0, 0x06, 0x20, 0x02, 0xE0, 0x04, 0x20, 0x00, 0xE0, 0x05, 0x20, 0xFE, 0xF7, 0x54, 0xFD, 0x28, 0x68, 0x40, 0x79, 0x00, 0x28, 0xAD, 0xD1, 0x20, 0x79, 0xF0, 0x71, 0x28, 0x68, 0x39, 0x49, 0x47, 0x4C, 0xFC, 0xFF, 0xD1, 0x63, 0x21, 0x00, 0x70, 0x37, 0x48, 0x09, 0x78, 0x00, 0x68, 0x00, 0x78, 0x08, 0x1A, 0x30, 0x72, 0xCE, 0xE6, 0x28, 0x68, 0x47, 0x71, 0xCB, 0xE6, 0x03, 0x01, 0x98, 0x01, 0xDE, 0x2F, 0x0D, 0x00, 0x70, 0xB5, 0x8C, 0xB0, 0x00, 0xF1, 0x09, 0x04, 0xCD, 0xF8, 0x28, 0xD0, 0x00, 0x20, 0x05, 0x26, 0x8D, 0xF8, 0x05, 0x00, 0x8D, 0xF8, 0x01, 0x60, 0xE0, 0x78, 0x6D, 0x46, 0x08, 0x28, 0x22, 0xD2, 0xDF, 0xE8, 0x00, 0xF0, 0x04, 0x0D, 0x12, 0x17, 0x17, 0x1C, 0x1C, 0x1C, 0x29, 0x49, 0x20, 0x79, 0x08, 0x70, 0x8D, 0xF8, 0x07, 0x00, 0x06, 0x20, 0x8D, 0xF8, 0x01, 0x00, 0x16, 0xE0, 0x0A, 0xA9, 0x20, 0x46, 0xFF, 0xF7, 0x3C, 0xFE, 0x11, 0xE0, 0x0A, 0xA9, 0x20, 0x46, 0xFF, 0xF7, 0x8B, 0xFE, 0x0C, 0xE0, 0x0A, 0xA9, 0x20, 0x46, 0xFF, 0xF7, 0xDC, 0xFE, 0x07, 0xE0, 0x0A, 0xA9, 0x20, 0x46, 0xFF, 0xF7, 0x54, 0xFF, 0x02, 0xE0, 0x12, 0x20, 0x8D, 0xF8, 0x05, 0x00, 0x0A, 0x99, 0x00, 0x29, 0x0A, 0xD0, 0x20, 0x46, 0x91, 0xF7, 0x38, 0xFD, 0x0A, 0x98, 0x41, 0x79, 0x01, 0xB1, 0x46, 0x70, 0xA8, 0x42, 0x03, 0xD1, 0x30, 0xF7, 0xDC, 0xFA, 0x0C, 0xB0, 0x70, 0xBD, 0x08, 0x38, 0x30, 0xF7, 0x8F, 0xFA, 0xF9, 0xE7, 0x03, 0x01, 0x4E, 0x72, 0x30, 0x0D, 0x00, 0x10, 0xB5, 0x14, 0x46, 0x50, 0xF7, 0xAD, 0xFF, 0x0E, 0x49, 0x08, 0x78, 0x08, 0xB1, 0x0D, 0x48, 0x00, 0x88, 0x20, 0x81, 0x48, 0x78, 0x01, 0x28, 0x03, 0xD1, 0xE0, 0x72, 0x03, 0x48, 0x00, 0x78, 0x20, 0x73, 0x00, 0x20, 0x60, 0x73, 0x10, 0xBD, 0x00, 0x00, 0x2B, 0x5E, 0x0D, 0x00, 0x28, 0x5E, 0x0D, 0x00, 0x34, 0x5E, 0x0D, 0x00, 0x30, 0x5E, 0x0D, 0x00, 0x2A, 0x5E, 0x0D, 0x00, 0x2C, 0x5E, 0x0D, 0x00, 0xD8, 0x4C, 0xFC, 0xFF, 0xCC, 0x64, 0x21, 0x00, 0x0B, 0x21, 0x00, 0x54, 0x29, 0x20, 0x00, 0x03, 0x01, 0x9A, 0x01, 0xBC, 0x30, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x00, 0xF1, 0x09, 0x01, 0x05, 0x7B, 0x40, 0x7B, 0x4E, 0x79, 0x10, 0x72, 0x95, 0x71, 0xC0, 0xF3, 0x41, 0x01, 0x14, 0x46, 0x00, 0xF0, 0x01, 0x07, 0xD6, 0x71, 0x03, 0x29, 0x05, 0xD0, 0x29, 0x06, 0x05, 0xD5, 0x11, 0x20, 0x50, 0x71, 0xBD, 0xE8, 0xF0, 0x81, 0x12, 0x20, 0xFA, 0xE7, 0x04, 0x2D, 0x01, 0xD2, 0x6C, 0x49, 0x01, 0xE0, 0x6B, 0x49, 0x09, 0x1D, 0xAB, 0x07, 0x4F, 0xEA, 0xD3, 0x6C, 0x0A, 0x68, 0xFF, 0x23, 0x03, 0xFA, 0x0C, 0xF3, 0x9A, 0x43, 0x00, 0xFA, 0x0C, 0xF0, 0x10, 0x43, 0x65, 0x4A, 0x08, 0x60, 0x10, 0x68, 0x4F, 0xEA, 0x85, 0x03, 0x4F, 0xF0, 0x0F, 0x01, 0x01, 0xFA, 0x03, 0xF1, 0x20, 0xEA, 0x01, 0x00, 0x10, 0x60, 0x87, 0xF0, 0x01, 0x02, 0x4F, 0xF0, 0x00, 0x01, 0x28, 0x46, 0x8F, 0xF7, 0xD9, 0xF9, 0x27, 0xB1, 0x28, 0x46, 0x8F, 0xF7, 0xC6, 0xF9, 0xC6, 0xB2, 0x03, 0xE0, 0x31, 0x46, 0x28, 0x46, 0x8F, 0xF7, 0xB2, 0xF9, 0xE6, 0x71, 0x00, 0x20, 0x60, 0x71, 0xC9, 0xE7, 0x03, 0x01, 0x2C, 0x52, 0x31, 0x0D, 0x00, 0x70, 0xB5, 0x00, 0xF1, 0x09, 0x05, 0x00, 0x7B, 0x02, 0x21, 0x14, 0x46, 0xB1, 0xEB, 0xD0, 0x0F, 0x02, 0xD8, 0x30, 0x20, 0x50, 0x71, 0x70, 0xBD, 0x8F, 0xF7, 0xAE, 0xF9, 0xE0, 0x71, 0xE8, 0x78, 0xA0, 0x71, 0x00, 0x20, 0x60, 0x71, 0x70, 0xBD, 0x03, 0x01, 0x2A, 0x7A, 0x31, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0x72, 0xF7, 0x6C, 0xF9, 0x4A, 0x4A, 0xD2, 0xF8, 0x00, 0x11, 0x14, 0xB1, 0x41, 0xF4, 0x00, 0x01, 0x01, 0xE0, 0x21, 0xF4, 0x00, 0x01, 0xC2, 0xF8, 0x00, 0x11, 0xBD, 0xE8, 0x4C, 0xFC, 0xFF, 0xC7, 0x65, 0x21, 0x00, 0x10, 0x40, 0x72, 0xF7, 0x61, 0xB9, 0x03, 0x01, 0x4E, 0xA0, 0x31, 0x0D, 0x00, 0x70, 0xB5, 0x04, 0x46, 0x0D, 0x46, 0x72, 0xF7, 0x58, 0xF9, 0x41, 0x4B, 0x01, 0x46, 0xD3, 0xF8, 0x94, 0x20, 0x24, 0xB1, 0x01, 0x2C, 0x05, 0xD0, 0x02, 0x2C, 0x06, 0xD0, 0x09, 0xE0, 0x22, 0xF0, 0x01, 0x02, 0x06, 0xE0, 0x42, 0xF0, 0x03, 0x02, 0x03, 0xE0, 0x22, 0xF0, 0x02, 0x00, 0x40, 0xF0, 0x80, 0x02, 0x22, 0xF4, 0x70, 0x10, 0x0D, 0xB1, 0x00, 0xF5, 0x80, 0x20, 0xC3, 0xF8, 0x94, 0x00, 0xBD, 0xE8, 0x70, 0x40, 0x08, 0x46, 0x72, 0xF7, 0x3C, 0xB9, 0x03, 0x01, 0x2C, 0xEA, 0x31, 0x0D, 0x00, 0x10, 0xB5, 0x30, 0x4C, 0x38, 0xB1, 0x00, 0x20, 0x5F, 0xF7, 0x2A, 0xFC, 0x20, 0x68, 0x40, 0xF0, 0x04, 0x00, 0x20, 0x60, 0x10, 0xBD, 0x20, 0x68, 0x20, 0xF0, 0x04, 0x00, 0x20, 0x60, 0xBD, 0xE8, 0x10, 0x40, 0x00, 0x20, 0x5F, 0xF7, 0xB7, 0xBC, 0x03, 0x01, 0x44, 0x12, 0x32, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0x27, 0x48, 0x02, 0x78, 0x5A, 0xB1, 0x01, 0x2A, 0x17, 0xD1, 0x21, 0x46, 0x01, 0x20, 0xFF, 0xF7, 0xBC, 0xFF, 0x4F, 0xF0, 0x00, 0x00, 0x54, 0xB1, 0x5D, 0xF7, 0x4B, 0xFA, 0x09, 0xE0, 0x21, 0x46, 0x00, 0x20, 0xFF, 0xF7, 0xB2, 0xFF, 0x20, 0x46, 0xBD, 0xE8, 0x10, 0x40, 0xD2, 0xE7, 0x5D, 0xF7, 0x6B, 0xFA, 0x20, 0x46, 0xBD, 0xE8, 0x10, 0x40, 0x94, 0xE7, 0x10, 0xBD, 0x03, 0x01, 0x16, 0x52, 0x32, 0x0D, 0x00, 0x19, 0x49, 0x02, 0x7B, 0xC8, 0x7C, 0x62, 0xF3, 0x86, 0x10, 0xC8, 0x74, 0xC0, 0xF3, 0x80, 0x10, 0xD6, 0xE7, 0x03, 0x01, 0x14, 0x64, 0x32, 0x0D, 0x00, 0x14, 0x48, 0xC0, 0x7C, 0xC0, 0xF3, 0x80, 0x10, 0x90, 0x71, 0x00, 0x20, 0x50, 0x71, 0x4C, 0xFC, 0xFF, 0xC2, 0x66, 0x21, 0x00, 0x70, 0x47, 0x03, 0x01, 0x1E, 0x74, 0x32, 0x0D, 0x00, 0x70, 0xB5, 0x09, 0x30, 0x14, 0x46, 0xC5, 0x78, 0xC3, 0x7A, 0x01, 0x79, 0x42, 0x1D, 0x28, 0x46, 0xFD, 0xF7, 0xAC, 0xFB, 0x00, 0x20, 0x60, 0x71, 0x70, 0xBD, 0x03, 0x01, 0x32, 0x8E, 0x32, 0x0D, 0x00, 0x10, 0xB5, 0x90, 0xF9, 0x0D, 0x10, 0x14, 0x46, 0x00, 0x7B, 0x02, 0xF0, 0x2C, 0xF8, 0xA0, 0x71, 0x00, 0x20, 0x60, 0x71, 0x10, 0xBD, 0x68, 0x00, 0x32, 0x00, 0x88, 0x00, 0x32, 0x00, 0x00, 0x20, 0x35, 0x00, 0x00, 0x10, 0x35, 0x00, 0x60, 0x2C, 0x20, 0x00, 0x18, 0x41, 0x20, 0x00, 0x03, 0x01, 0xA0, 0x01, 0xBC, 0x32, 0x0D, 0x00, 0x70, 0xB5, 0x23, 0x4C, 0x47, 0xF2, 0x44, 0x03, 0x05, 0x46, 0x01, 0x46, 0xC2, 0x1A, 0x20, 0x68, 0x99, 0x42, 0x30, 0xD0, 0x06, 0xDC, 0xA1, 0xF5, 0xE0, 0x41, 0x3F, 0x39, 0x18, 0xD0, 0x01, 0x29, 0x04, 0xD1, 0x15, 0xE0, 0x3E, 0x2A, 0x1F, 0xD0, 0xBC, 0x2A, 0x17, 0xD0, 0x2D, 0xF7, 0x3D, 0xFB, 0x08, 0x21, 0x03, 0x20, 0x71, 0xF7, 0xC3, 0xFF, 0x20, 0x68, 0x72, 0xF7, 0x5A, 0xFA, 0x28, 0x46, 0x89, 0xF7, 0x6B, 0xF8, 0xBD, 0xE8, 0x70, 0x40, 0x08, 0x21, 0x04, 0x20, 0x71, 0xF7, 0xB7, 0xBF, 0x48, 0xF7, 0x09, 0xFE, 0xBD, 0xE8, 0x70, 0x40, 0x8B, 0xF7, 0x4A, 0xBD, 0x72, 0xF7, 0x49, 0xFA, 0xBD, 0xE8, 0x70, 0x40, 0x41, 0xF7, 0x54, 0xBF, 0x0A, 0x49, 0x09, 0x69, 0x00, 0x29, 0x0D, 0xD0, 0xBD, 0xE8, 0x70, 0x40, 0x08, 0x47, 0x08, 0x49, 0x02, 0x7A, 0x0B, 0x78, 0x9A, 0x1A, 0x0A, 0x70, 0x72, 0xF7, 0x37, 0xFA, 0xBD, 0xE8, 0x70, 0x40, 0x30, 0xF7, 0xF8, 0xB8, 0x70, 0xBD, 0x00, 0x00, 0xF0, 0x27, 0x20, 0x00, 0xC8, 0x9E, 0x20, 0x00, 0xA4, 0x28, 0x20, 0x4C, 0xFC, 0xFF, 0xBD, 0x67, 0x21, 0x00, 0x00, 0x03, 0x01, 0x24, 0x58, 0x33, 0x0D, 0x00, 0x10, 0xB5, 0x01, 0x46, 0x00, 0x24, 0x05, 0x48, 0x83, 0xF7, 0xD7, 0xFA, 0x20, 0xB1, 0x01, 0x24, 0x47, 0xF2, 0x0A, 0x00, 0x89, 0xF7, 0xCC, 0xF8, 0x20, 0x46, 0x10, 0xBD, 0x0C, 0x60, 0x20, 0x00, 0x03, 0x01, 0xA8, 0x01, 0x78, 0x33, 0x0D, 0x00, 0xF0, 0xB5, 0x21, 0x4C, 0x21, 0x4B, 0x21, 0x68, 0x42, 0x18, 0x9A, 0x42, 0x02, 0xD2, 0x08, 0x44, 0x20, 0x60, 0xF0, 0xBD, 0xB2, 0xFB, 0xF3, 0xF1, 0x03, 0xFB, 0x11, 0x20, 0x20, 0x60, 0x05, 0x20, 0xB1, 0xFB, 0xF0, 0xF7, 0x1A, 0x4A, 0x50, 0x68, 0x08, 0x44, 0x50, 0x60, 0x01, 0x20, 0x06, 0x46, 0x13, 0x68, 0x06, 0xFA, 0x00, 0xF4, 0x23, 0x42, 0x03, 0xD0, 0x13, 0x18, 0x1C, 0x7A, 0xE5, 0x19, 0x1D, 0x72, 0x40, 0x1C, 0x11, 0x28, 0xF3, 0xD3, 0x00, 0x20, 0x02, 0xEB, 0x80, 0x03, 0x1C, 0x7F, 0x34, 0xB1, 0x5C, 0x8B, 0x8C, 0x42, 0x01, 0xD8, 0x5E, 0x83, 0x01, 0xE0, 0x64, 0x1A, 0x5C, 0x83, 0x40, 0x1C, 0x08, 0x28, 0xF1, 0xD3, 0x0B, 0x48, 0xC0, 0x7C, 0x40, 0x07, 0xD1, 0xD4, 0x0A, 0x48, 0x00, 0x78, 0x18, 0xB1, 0x09, 0x48, 0x02, 0x88, 0x0A, 0x44, 0x02, 0x80, 0x08, 0x48, 0x02, 0x78, 0x11, 0x44, 0x01, 0x70, 0xF0, 0xBD, 0x00, 0x00, 0xD4, 0x23, 0x20, 0x00, 0x48, 0xE8, 0x01, 0x00, 0xD4, 0x60, 0x20, 0x00, 0x18, 0x41, 0x20, 0x00, 0x92, 0x26, 0x20, 0x00, 0x90, 0x26, 0x20, 0x00, 0x4C, 0x23, 0x20, 0x00, 0x03, 0x01, 0x2A, 0x1C, 0x34, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0x00, 0x6D, 0x48, 0xB1, 0x3E, 0x4A, 0xB4, 0xF8, 0x9C, 0x10, 0x40, 0xF2, 0x71, 0x23, 0x12, 0x78, 0x5A, 0x43, 0x51, 0x43, 0x71, 0xF7, 0xA9, 0xFE, 0x20, 0x46, 0xBD, 0xE8, 0x4C, 0xFC, 0xFF, 0xB8, 0x68, 0x21, 0x00, 0x10, 0x40, 0x4C, 0xF7, 0x75, 0xBA, 0x03, 0x01, 0xA2, 0x01, 0x42, 0x34, 0x0D, 0x00, 0x70, 0xB5, 0x04, 0x46, 0x67, 0xF7, 0xD8, 0xFA, 0x05, 0x46, 0x20, 0x46, 0x92, 0xF7, 0xC3, 0xFF, 0x20, 0x46, 0x70, 0xF7, 0xF6, 0xFB, 0x70, 0xB1, 0x94, 0xF8, 0xA3, 0x00, 0xC0, 0x06, 0x0A, 0xD5, 0xE0, 0x69, 0xC0, 0xF3, 0xC4, 0x00, 0x0A, 0x28, 0x05, 0xD1, 0x20, 0x46, 0x80, 0xF7, 0x6E, 0xFE, 0x20, 0x68, 0x60, 0xF7, 0x48, 0xF9, 0xE0, 0x69, 0xC0, 0xF3, 0xC4, 0x01, 0x08, 0x29, 0x03, 0xD3, 0x20, 0xF0, 0xF8, 0x00, 0x68, 0x30, 0xE0, 0x61, 0x20, 0x46, 0x4B, 0xF7, 0xB3, 0xFF, 0xE1, 0x69, 0x24, 0x48, 0xC1, 0xF3, 0xC0, 0x31, 0x41, 0xF0, 0x0E, 0x01, 0x29, 0x73, 0x94, 0xF8, 0xA1, 0x10, 0x69, 0x73, 0x68, 0x60, 0x20, 0x48, 0xA8, 0x60, 0x29, 0x46, 0x20, 0x46, 0x4B, 0xF7, 0xD3, 0xFF, 0x20, 0x20, 0x72, 0xF7, 0xC2, 0xF8, 0x05, 0x00, 0x0F, 0xD0, 0x22, 0x46, 0x1B, 0x49, 0x71, 0xF7, 0x18, 0xFD, 0x1A, 0x48, 0xB4, 0xF8, 0x9C, 0x10, 0x40, 0xF2, 0x71, 0x22, 0x00, 0x78, 0x50, 0x43, 0x41, 0x43, 0x28, 0x46, 0x71, 0xF7, 0x58, 0xFE, 0x25, 0x65, 0x01, 0x20, 0x70, 0xBD, 0x03, 0x01, 0x58, 0xE0, 0x34, 0x0D, 0x00, 0x70, 0xB5, 0x05, 0x46, 0x0C, 0x46, 0xB1, 0xF8, 0x03, 0x00, 0x02, 0x21, 0x70, 0xF7, 0xB3, 0xF8, 0x78, 0xB1, 0xD0, 0xF8, 0xE4, 0x10, 0xC1, 0xF3, 0x04, 0x21, 0x09, 0x29, 0x09, 0xD0, 0x61, 0x79, 0x05, 0xF8, 0xA1, 0x1F, 0x16, 0x21, 0x69, 0x70, 0xBD, 0xE8, 0x70, 0x40, 0x05, 0x21, 0x73, 0xF7, 0x08, 0xBD, 0x28, 0x46, 0xBD, 0xE8, 0x70, 0x40, 0x07, 0x22, 0x01, 0x21, 0x78, 0xF7, 0xD1, 0xBC, 0x37, 0x31, 0x20, 0x00, 0xAB, 0x64, 0x06, 0x00, 0x4C, 0xFC, 0xFF, 0xB3, 0x69, 0x21, 0x00, 0xA7, 0x64, 0x06, 0x00, 0xD1, 0x63, 0x06, 0x00, 0x4D, 0x5E, 0x0D, 0x00, 0x03, 0x01, 0x48, 0x34, 0x35, 0x0D, 0x00, 0x10, 0xB5, 0xC1, 0x69, 0xC1, 0xF3, 0xC0, 0x31, 0xB1, 0xB1, 0x0C, 0x49, 0x02, 0x8E, 0x09, 0x88, 0x0F, 0x2A, 0x01, 0xD0, 0x0B, 0x04, 0x0F, 0xD5, 0x09, 0x4B, 0x11, 0x24, 0x5B, 0x68, 0x1B, 0x7B, 0xB4, 0xEB, 0x53, 0x0F, 0x03, 0xD0, 0x0F, 0x2A, 0x06, 0xD1, 0x89, 0x04, 0x04, 0xD5, 0x00, 0x68, 0x83, 0xF7, 0x0E, 0xFB, 0x00, 0x20, 0x10, 0xBD, 0x23, 0x20, 0x10, 0xBD, 0x08, 0x1E, 0x20, 0x00, 0xA4, 0x23, 0x20, 0x00, 0x03, 0x01, 0x3C, 0x78, 0x35, 0x0D, 0x00, 0x10, 0xB5, 0x09, 0x4C, 0x20, 0x21, 0x09, 0x48, 0x97, 0xF7, 0xFD, 0xFD, 0x08, 0x48, 0x71, 0xF7, 0x27, 0xFE, 0x20, 0x46, 0x67, 0xF7, 0x2B, 0xFF, 0x08, 0xB1, 0x8C, 0xF7, 0x5D, 0xF8, 0x05, 0x49, 0x8B, 0x20, 0x08, 0x60, 0x10, 0xBD, 0x00, 0x00, 0xC8, 0xD9, 0x20, 0x00, 0x88, 0x60, 0x20, 0x00, 0xA8, 0x60, 0x20, 0x00, 0xEC, 0x8A, 0x31, 0x00, 0x03, 0x01, 0x7C, 0xB0, 0x35, 0x0D, 0x00, 0x70, 0xB5, 0x04, 0x46, 0x06, 0x29, 0x03, 0xD1, 0x94, 0xF8, 0xB5, 0x00, 0xC0, 0x08, 0x01, 0xD0, 0x00, 0x20, 0x70, 0xBD, 0x04, 0x22, 0x80, 0x21, 0x20, 0x46, 0x89, 0xF7, 0xFA, 0xF8, 0x14, 0x4D, 0x03, 0x00, 0x04, 0xD0, 0x68, 0x68, 0x00, 0x7B, 0xC0, 0xF3, 0x00, 0x02, 0x15, 0xE0, 0xE0, 0x69, 0xC0, 0xF3, 0xC4, 0x01, 0x08, 0x29, 0x0B, 0xD1, 0x0E, 0x49, 0x09, 0x88, 0x09, 0x05, 0x11, 0xD5, 0x00, 0x04, 0x0F, 0xD4, 0x20, 0x68, 0x70, 0xF7, 0x71, 0xFB, 0x5E, 0xF7, 0xB0, 0xFC, 0x48, 0xB1, 0x68, 0x68, 0x0C, 0x23, 0x00, 0x7B, 0xC0, 0xF3, 0x00, 0x02, 0x17, 0x21, 0x20, 0x46, 0x4C, 0xFC, 0xFF, 0xAE, 0x6A, 0x21, 0x00, 0x67, 0xF7, 0x41, 0xFA, 0x02, 0xE0, 0x20, 0x46, 0x8A, 0xF7, 0x35, 0xF9, 0x01, 0x20, 0x70, 0xBD, 0x00, 0x00, 0xA4, 0x23, 0x20, 0x00, 0x08, 0x1E, 0x20, 0x00, 0x03, 0x01, 0x0E, 0x28, 0x36, 0x0D, 0x00, 0x11, 0x48, 0x00, 0x21, 0xC0, 0xE9, 0x0C, 0x11, 0x70, 0x47, 0x03, 0x01, 0x4A, 0x32, 0x36, 0x0D, 0x00, 0x70, 0xB5, 0x00, 0x22, 0x0F, 0x4D, 0x10, 0x46, 0x11, 0x46, 0x53, 0x23, 0x4B, 0x43, 0x05, 0xEB, 0x83, 0x03, 0xDC, 0x69, 0xE6, 0x02, 0x0A, 0xD5, 0x93, 0xF8, 0x9B, 0x60, 0x04, 0x2E, 0x06, 0xD0, 0xC4, 0xF3, 0xC4, 0x04, 0x08, 0x2C, 0x02, 0xD1, 0xB3, 0xF8, 0x64, 0x00, 0x52, 0x1C, 0x49, 0x1C, 0x0B, 0x29, 0xEA, 0xDB, 0x01, 0x2A, 0x00, 0xD0, 0x00, 0x20, 0x70, 0xBD, 0x00, 0x00, 0x18, 0x41, 0x20, 0x00, 0x68, 0x42, 0x20, 0x00, 0x03, 0x01, 0x20, 0x78, 0x36, 0x0D, 0x00, 0x05, 0x48, 0x10, 0xB5, 0x80, 0x7B, 0x20, 0xB9, 0x8B, 0xF7, 0xAB, 0xFA, 0x08, 0xB1, 0x02, 0x20, 0x10, 0xBD, 0x00, 0x20, 0x10, 0xBD, 0x00, 0x00, 0xF8, 0x5B, 0x20, 0x00, 0x03, 0x01, 0xCE, 0x01, 0x94, 0x36, 0x0D, 0x00, 0x70, 0xB5, 0x35, 0x4D, 0x28, 0x68, 0x80, 0x7B, 0x6D, 0xF7, 0xAB, 0xFB, 0x29, 0x68, 0xC9, 0x6E, 0x6D, 0xF7, 0x2F, 0xFB, 0x29, 0x68, 0x31, 0x4E, 0x31, 0x4B, 0x91, 0xF8, 0xED, 0x20, 0xC2, 0xB1, 0x91, 0xF8, 0xE5, 0x20, 0x9A, 0xB9, 0x2F, 0x4C, 0xD1, 0xF8, 0xC8, 0x20, 0x24, 0x68, 0x22, 0x42, 0x06, 0xD0, 0x91, 0xF8, 0x94, 0x40, 0x24, 0x06, 0x09, 0xD4, 0x34, 0x78, 0xA0, 0x42, 0x06, 0xD8, 0x29, 0x48, 0x2A, 0x4C, 0x00, 0x68, 0x24, 0x68, 0x20, 0x43, 0x02, 0x42, 0x01, 0xD0, 0x9C, 0x78, 0x00, 0xE0, 0x5C, 0x78, 0x91, 0xF8, 0xE5, 0x00, 0x4C, 0xFC, 0xFF, 0xA9, 0x6B, 0x21, 0x00, 0x18, 0xB1, 0x18, 0x5C, 0xA0, 0x42, 0x00, 0xD9, 0x04, 0x46, 0x23, 0x48, 0x00, 0x68, 0x00, 0x07, 0x00, 0xD5, 0xDC, 0x78, 0xD1, 0xF8, 0xC0, 0x00, 0x40, 0x1C, 0x16, 0xD0, 0x88, 0x7B, 0x6D, 0xF7, 0x74, 0xFB, 0x29, 0x68, 0xD1, 0xF8, 0xC0, 0x10, 0x6D, 0xF7, 0xFF, 0xFA, 0x1B, 0x49, 0x00, 0x28, 0x07, 0xDB, 0x2A, 0x68, 0x4F, 0xF0, 0xFF, 0x30, 0xC2, 0xF8, 0xC0, 0x00, 0x3F, 0x20, 0x08, 0x70, 0x03, 0xE0, 0x08, 0x78, 0x84, 0x42, 0x00, 0xD2, 0x04, 0x46, 0x70, 0x78, 0x40, 0xB1, 0x45, 0x2C, 0x06, 0xD1, 0x28, 0x68, 0x90, 0xF8, 0xA8, 0x00, 0x4C, 0xF7, 0xE5, 0xFB, 0x00, 0xB1, 0x0F, 0x24, 0x21, 0x46, 0x28, 0x68, 0x68, 0xF7, 0x0E, 0xFE, 0x0D, 0x48, 0x00, 0x78, 0x85, 0xF8, 0x34, 0x00, 0x70, 0xBD, 0x03, 0x01, 0x3A, 0x5E, 0x37, 0x0D, 0x00, 0x0C, 0x49, 0x00, 0xEB, 0xC0, 0x00, 0x01, 0xEB, 0x80, 0x00, 0x70, 0x47, 0x00, 0x00, 0xF0, 0x6E, 0x20, 0x00, 0xDC, 0x0B, 0x21, 0x00, 0x30, 0x24, 0x20, 0x00, 0x00, 0x26, 0x20, 0x00, 0xB4, 0x30, 0x20, 0x00, 0x2C, 0x24, 0x20, 0x00, 0x38, 0x1E, 0x20, 0x00, 0x18, 0x24, 0x20, 0x00, 0x20, 0x24, 0x20, 0x00, 0x78, 0x70, 0x20, 0x00, 0x03, 0x01, 0x48, 0x94, 0x37, 0x0D, 0x00, 0x70, 0xB5, 0x04, 0x46, 0x0D, 0x4D, 0x6D, 0xF7, 0x15, 0xFB, 0x80, 0xB2, 0x29, 0x8C, 0x6D, 0xF7, 0x70, 0xFB, 0xE1, 0x8B, 0xB0, 0xEB, 0x41, 0x0F, 0x04, 0xD9, 0xA0, 0x7B, 0x10, 0xB9, 0xA8, 0x7C, 0x2E, 0x28, 0x06, 0xD0, 0x71, 0x20, 0xA0, 0x74, 0x05, 0x48, 0x00, 0x78, 0x84, 0xF8, 0x43, 0x00, 0x70, 0xBD, 0x94, 0xF8, 0x47, 0x00, 0xA0, 0x74, 0x70, 0xBD, 0x00, 0x00, 0x9C, 0x5B, 0x20, 0x00, 0xF8, 0x30, 0x20, 0x00, 0x03, 0x4C, 0xFC, 0xFF, 0xA4, 0x6C, 0x21, 0x00, 0x01, 0x52, 0xD8, 0x37, 0x0D, 0x00, 0x70, 0xB5, 0x27, 0x49, 0x25, 0x4C, 0x09, 0x78, 0x00, 0x29, 0x1D, 0xD0, 0x08, 0x30, 0x01, 0x22, 0xE1, 0x8B, 0x82, 0x40, 0x23, 0x48, 0x11, 0x43, 0xE1, 0x83, 0x90, 0xF8, 0x30, 0x00, 0x2E, 0x25, 0x98, 0xB1, 0x21, 0x49, 0xB4, 0xF9, 0x1C, 0x00, 0x09, 0x78, 0x88, 0x42, 0x06, 0xDC, 0x40, 0x42, 0x88, 0x42, 0x03, 0xDC, 0x94, 0xF8, 0x36, 0x00, 0x00, 0x28, 0x05, 0xD0, 0x20, 0x46, 0x5E, 0xF7, 0xF2, 0xFB, 0x00, 0x28, 0x00, 0xD0, 0xA5, 0x74, 0x70, 0xBD, 0xA0, 0x8B, 0xF4, 0xE7, 0x03, 0x01, 0x62, 0x26, 0x38, 0x0D, 0x00, 0x70, 0xB5, 0x12, 0x4C, 0x01, 0x22, 0x82, 0x40, 0xE1, 0x8B, 0x04, 0xEB, 0x40, 0x00, 0x11, 0x43, 0xE1, 0x83, 0x00, 0x21, 0x41, 0x84, 0x0F, 0x48, 0x2E, 0x25, 0x90, 0xF8, 0x30, 0x00, 0x98, 0xB1, 0x0E, 0x49, 0xB4, 0xF9, 0x1C, 0x00, 0x09, 0x78, 0x88, 0x42, 0x06, 0xDC, 0x40, 0x42, 0x88, 0x42, 0x03, 0xDC, 0x94, 0xF8, 0x36, 0x00, 0x00, 0x28, 0x05, 0xD0, 0x20, 0x46, 0x5E, 0xF7, 0xCC, 0xFB, 0x00, 0x28, 0x00, 0xD0, 0xA5, 0x74, 0x70, 0xBD, 0xA0, 0x8B, 0xF4, 0xE7, 0x00, 0x00, 0x9C, 0x5B, 0x20, 0x00, 0x1F, 0x23, 0x20, 0x00, 0xF8, 0x5B, 0x20, 0x00, 0x20, 0x23, 0x20, 0x00, 0x03, 0x01, 0xE4, 0x01, 0x84, 0x38, 0x0D, 0x00, 0x70, 0xB5, 0x04, 0x46, 0x68, 0xF7, 0x36, 0xF9, 0x00, 0x26, 0x01, 0x25, 0x58, 0xB1, 0x3F, 0x48, 0x00, 0x21, 0x06, 0x70, 0x20, 0x46, 0x9C, 0xF7, 0xD3, 0xFB, 0x20, 0x46, 0x9C, 0xF7, 0x13, 0xFC, 0x84, 0xF8, 0x5B, 0x50, 0x70, 0xBD, 0x20, 0x46, 0x68, 0xF7, 0x01, 0xFB, 0x00, 0x28, 0xF9, 0xD0, 0x20, 0x46, 0xE1, 0x8B, 0x9C, 0xF7, 0xC4, 0xFB, 0xA0, 0x7B, 0x4C, 0xFC, 0xFF, 0x9F, 0x6D, 0x21, 0x00, 0x6D, 0xF7, 0x9A, 0xFA, 0xA1, 0x69, 0x6D, 0xF7, 0x1F, 0xFA, 0xE1, 0x8B, 0x89, 0x1E, 0x88, 0x42, 0x0C, 0xD8, 0x20, 0x46, 0x9C, 0xF7, 0x1F, 0xFA, 0x2F, 0x49, 0x08, 0x60, 0x2F, 0x49, 0x08, 0x60, 0x2F, 0x48, 0x05, 0x60, 0x6D, 0xF7, 0x71, 0xFA, 0x2E, 0x49, 0x08, 0x60, 0x94, 0xF8, 0x5B, 0x00, 0x98, 0xB1, 0x5B, 0xF7, 0xB0, 0xF9, 0x49, 0xF7, 0xDB, 0xFD, 0x01, 0x28, 0x0B, 0xD1, 0x20, 0x46, 0x5A, 0xF7, 0x50, 0xFE, 0x38, 0xB1, 0x94, 0xF8, 0x6F, 0x00, 0x20, 0xB1, 0x84, 0xF8, 0x6E, 0x50, 0x20, 0x46, 0x9B, 0xF7, 0x9A, 0xF9, 0x84, 0xF8, 0x5B, 0x60, 0x94, 0xF8, 0x6B, 0x00, 0xE8, 0xB9, 0x94, 0xF8, 0x28, 0x00, 0x01, 0x28, 0x0D, 0xD0, 0x94, 0xF8, 0x24, 0x00, 0x94, 0xF8, 0x2C, 0x10, 0xC0, 0xF3, 0x02, 0x00, 0xC1, 0xF3, 0x02, 0x01, 0x88, 0x42, 0x03, 0xD1, 0x94, 0xF8, 0x29, 0x00, 0x02, 0x28, 0x0B, 0xD0, 0x20, 0x46, 0x5A, 0xF7, 0x2D, 0xFE, 0x38, 0xB1, 0x94, 0xF8, 0x6F, 0x00, 0x20, 0xB1, 0x84, 0xF8, 0x6E, 0x50, 0x20, 0x46, 0x9B, 0xF7, 0x77, 0xF9, 0x20, 0x46, 0xBD, 0xE8, 0x70, 0x40, 0x9C, 0xF7, 0x33, 0xBB, 0x03, 0x01, 0x16, 0x64, 0x39, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0x9C, 0xF7, 0x93, 0xFF, 0x20, 0x46, 0xBD, 0xE8, 0x10, 0x40, 0x00, 0xF0, 0xBF, 0xB8, 0x03, 0x01, 0x16, 0x76, 0x39, 0x0D, 0x00, 0x10, 0xB5, 0x9C, 0xF7, 0x94, 0xF8, 0x09, 0x49, 0x00, 0x20, 0x08, 0x70, 0x09, 0x49, 0x08, 0x80, 0x10, 0xBD, 0x03, 0x01, 0x30, 0x88, 0x39, 0x0D, 0x00, 0x09, 0x49, 0x08, 0x48, 0x08, 0x60, 0x70, 0x47, 0xFC, 0x26, 0x20, 0x00, 0x08, 0x27, 0x20, 0x00, 0xA0, 0x1C, 0x20, 0x00, 0x9C, 0x1C, 0x20, 0x00, 0xA4, 0x1C, 0x20, 0x00, 0x4C, 0xFC, 0xFF, 0x9A, 0x6E, 0x21, 0x00, 0xAC, 0x5E, 0x0D, 0x00, 0xB0, 0x5E, 0x0D, 0x00, 0x50, 0x5E, 0x0D, 0x00, 0x04, 0x27, 0x20, 0x00, 0x03, 0x01, 0x0C, 0xB4, 0x39, 0x0D, 0x00, 0x31, 0x49, 0x30, 0x48, 0x08, 0x60, 0x70, 0x47, 0x03, 0x01, 0xC8, 0x01, 0xBC, 0x39, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x04, 0x46, 0x2D, 0x49, 0x90, 0xF8, 0x56, 0x00, 0x09, 0x1F, 0x45, 0x18, 0x20, 0x46, 0x68, 0xF7, 0x93, 0xF8, 0x00, 0x26, 0x00, 0x28, 0x20, 0x46, 0x10, 0xD0, 0x68, 0xF7, 0x03, 0xFA, 0x01, 0x27, 0x08, 0xB1, 0x2F, 0x70, 0x00, 0xE0, 0x2E, 0x70, 0xA0, 0x6C, 0x9E, 0xF7, 0xD4, 0xFD, 0xE0, 0x6C, 0x9E, 0xF7, 0xB2, 0xFD, 0x84, 0xF8, 0x5B, 0x70, 0xBD, 0xE8, 0xF0, 0x81, 0x68, 0xF7, 0x59, 0xFA, 0xB0, 0xB1, 0x94, 0xF8, 0x5B, 0x00, 0x18, 0xB9, 0xA0, 0x6C, 0x90, 0xF8, 0x27, 0x00, 0x50, 0xB9, 0x5B, 0xF7, 0x20, 0xF9, 0x49, 0xF7, 0x4B, 0xFD, 0x01, 0x28, 0x02, 0xD1, 0x20, 0x46, 0x5A, 0xF7, 0xC0, 0xFD, 0x84, 0xF8, 0x5B, 0x60, 0x20, 0x46, 0xBD, 0xE8, 0xF0, 0x41, 0x5A, 0xF7, 0xF0, 0xBE, 0x20, 0x46, 0x68, 0xF7, 0x37, 0xFA, 0x00, 0x28, 0xDE, 0xD0, 0x28, 0x78, 0x80, 0xB1, 0x94, 0xF8, 0x5B, 0x00, 0x18, 0xB9, 0xA0, 0x6C, 0x90, 0xF8, 0x27, 0x00, 0x48, 0xB9, 0x5B, 0xF7, 0x02, 0xF9, 0x49, 0xF7, 0x2D, 0xFD, 0x01, 0x28, 0x02, 0xD1, 0x20, 0x46, 0x5A, 0xF7, 0xA2, 0xFD, 0x2E, 0x70, 0x20, 0x46, 0x5A, 0xF7, 0xD5, 0xFE, 0xA0, 0x6C, 0x9E, 0xF7, 0x95, 0xFD, 0xE0, 0x6C, 0xBD, 0xE8, 0xF0, 0x41, 0x9E, 0xF7, 0x71, 0xBD, 0x00, 0x00, 0x80, 0x5E, 0x0D, 0x00, 0x0C, 0x27, 0x20, 0x00, 0x03, 0x01, 0x2C, 0x80, 0x3A, 0x0D, 0x00, 0x10, 0xB5, 0x82, 0xF7, 0x50, 0xFB, 0x3C, 0x48, 0x00, 0x4C, 0xFC, 0xFF, 0x95, 0x6F, 0x21, 0x00, 0x21, 0x01, 0x70, 0x81, 0x80, 0x3B, 0x49, 0x4A, 0x68, 0x09, 0x68, 0xA2, 0xEB, 0x01, 0x01, 0x39, 0x4A, 0xC1, 0xF1, 0xFF, 0x01, 0xD2, 0x79, 0xA1, 0xEB, 0x02, 0x01, 0x81, 0x70, 0x10, 0xBD, 0x03, 0x01, 0x3A, 0xA8, 0x3A, 0x0D, 0x00, 0x02, 0x2A, 0x16, 0xD1, 0x35, 0x48, 0x16, 0x29, 0x06, 0xD0, 0x13, 0x29, 0x0A, 0xD0, 0x14, 0x29, 0x08, 0xD0, 0x15, 0x29, 0x06, 0xD0, 0x0C, 0xE0, 0x01, 0x68, 0x2D, 0x4A, 0x21, 0xF0, 0xFF, 0x01, 0x92, 0x78, 0x04, 0xE0, 0x01, 0x68, 0x2E, 0x4A, 0x21, 0xF0, 0xFF, 0x01, 0x12, 0x78, 0x11, 0x43, 0x01, 0x60, 0x00, 0x20, 0x70, 0x47, 0x03, 0x01, 0x1A, 0xDE, 0x3A, 0x0D, 0x00, 0x2B, 0x48, 0x00, 0x68, 0x10, 0xB1, 0xAF, 0xF2, 0x67, 0x01, 0x01, 0x60, 0xAF, 0xF2, 0x43, 0x00, 0x28, 0x49, 0xC8, 0x64, 0x70, 0x47, 0x03, 0x01, 0xB0, 0x01, 0xF4, 0x3A, 0x0D, 0x00, 0x70, 0xB5, 0x40, 0x6C, 0x00, 0x28, 0x3B, 0xD0, 0x90, 0xF9, 0xDF, 0x00, 0x7F, 0x28, 0x37, 0xD0, 0x1C, 0x4C, 0x23, 0x4B, 0x01, 0x25, 0x61, 0x78, 0x49, 0x1C, 0x01, 0xF0, 0x0F, 0x02, 0x62, 0x70, 0x21, 0x46, 0x93, 0xF9, 0x00, 0x60, 0x89, 0x88, 0xB0, 0x42, 0x03, 0xDA, 0x93, 0xF9, 0x01, 0x30, 0x98, 0x42, 0x04, 0xDA, 0x05, 0xFA, 0x02, 0xF0, 0x81, 0x43, 0xA1, 0x80, 0x03, 0xE0, 0x05, 0xFA, 0x02, 0xF0, 0x08, 0x43, 0xA0, 0x80, 0xA0, 0x88, 0x49, 0xF7, 0xC0, 0xFC, 0x21, 0x78, 0x21, 0xB1, 0x04, 0x28, 0x05, 0xD8, 0x00, 0x20, 0x20, 0x70, 0x02, 0xE0, 0x08, 0x28, 0x00, 0xD3, 0x25, 0x70, 0x10, 0x4A, 0x10, 0x68, 0xC0, 0xF3, 0x05, 0x41, 0x20, 0x29, 0x09, 0xD1, 0x21, 0x78, 0x01, 0x29, 0x06, 0xD1, 0x0D, 0x49, 0x40, 0xF4, 0x80, 0x00, 0x10, 0x60, 0x4C, 0xFC, 0xFF, 0x90, 0x70, 0x21, 0x00, 0x08, 0x60, 0x50, 0x68, 0x48, 0x60, 0x70, 0xBD, 0x00, 0x00, 0xAC, 0x5E, 0x0D, 0x00, 0x90, 0x80, 0x31, 0x00, 0x10, 0x1E, 0x20, 0x00, 0x90, 0x8B, 0x31, 0x00, 0x28, 0x25, 0x20, 0x00, 0x04, 0x1D, 0x20, 0x00, 0x18, 0x52, 0x20, 0x00, 0xDE, 0x0B, 0x21, 0x00, 0xBC, 0x1C, 0x20, 0x00, 0x60, 0x01, 0x65, 0x00, 0x03, 0x01, 0x5E, 0xA0, 0x3B, 0x0D, 0x00, 0x5B, 0x48, 0x4F, 0xF4, 0x80, 0x71, 0x00, 0x68, 0x01, 0x60, 0x01, 0x60, 0x59, 0x48, 0x5A, 0x49, 0x82, 0x68, 0x0A, 0x63, 0x82, 0x6A, 0x8A, 0x63, 0x58, 0x4B, 0xC2, 0x68, 0x1A, 0x60, 0x58, 0x4B, 0x02, 0x69, 0x1A, 0x60, 0x57, 0x4B, 0x42, 0x69, 0x1A, 0x60, 0x57, 0x4B, 0x82, 0x69, 0x1A, 0x60, 0x56, 0x4B, 0xC2, 0x69, 0x1A, 0x60, 0x56, 0x4B, 0x02, 0x6A, 0x1A, 0x60, 0x42, 0x6A, 0x0A, 0x60, 0x54, 0x49, 0x40, 0x68, 0x08, 0x60, 0x54, 0x48, 0x01, 0x69, 0x21, 0xF0, 0x01, 0x01, 0x01, 0x61, 0x01, 0x68, 0x21, 0xF0, 0x01, 0x01, 0x01, 0x60, 0x70, 0x47, 0x03, 0x01, 0xDA, 0x01, 0xFA, 0x3B, 0x0D, 0x00, 0x70, 0xB5, 0x05, 0x46, 0xAE, 0xF7, 0x07, 0xF9, 0x4C, 0x48, 0x00, 0x68, 0x43, 0x4C, 0x00, 0xF0, 0x3F, 0x00, 0x20, 0x63, 0x49, 0x48, 0x38, 0x38, 0x00, 0x68, 0xC0, 0xF3, 0x85, 0x01, 0x4A, 0x11, 0x21, 0xF0, 0x20, 0x00, 0xE0, 0x62, 0x01, 0x2A, 0x04, 0xD1, 0x80, 0xF0, 0x1F, 0x00, 0x40, 0x1C, 0x40, 0x42, 0xE0, 0x62, 0x3E, 0x48, 0x50, 0x30, 0x00, 0x68, 0xC0, 0xF3, 0x03, 0x30, 0xC2, 0x10, 0x20, 0xF0, 0x08, 0x01, 0x61, 0x63, 0x01, 0x2A, 0x04, 0xD1, 0x81, 0xF0, 0x07, 0x00, 0x40, 0x1C, 0x40, 0x42, 0x60, 0x63, 0xAD, 0x1C, 0xE8, 0xB2, 0x40, 0xF0, 0x80, 0x01, 0x31, 0x48, 0xB8, 0x38, 0x4C, 0xFC, 0xFF, 0x8B, 0x71, 0x21, 0x00, 0x95, 0xF7, 0xA7, 0xFF, 0x2F, 0x49, 0x01, 0x20, 0x08, 0x60, 0x2C, 0x48, 0x01, 0x6B, 0x41, 0xF0, 0xCF, 0x01, 0x01, 0x63, 0x4F, 0xF0, 0x0F, 0x01, 0x81, 0x63, 0x4F, 0xF0, 0x1C, 0x01, 0x01, 0x60, 0x2F, 0x48, 0x01, 0x69, 0x41, 0xF0, 0x01, 0x01, 0x01, 0x61, 0x01, 0x68, 0x41, 0xF0, 0x01, 0x01, 0x01, 0x60, 0x24, 0x49, 0x47, 0xF2, 0xC1, 0x00, 0x08, 0x60, 0x23, 0x49, 0x4F, 0xF4, 0xC0, 0x40, 0x08, 0x60, 0x22, 0x48, 0x01, 0x68, 0x4B, 0xF6, 0xFF, 0x72, 0x01, 0xEA, 0x02, 0x01, 0x22, 0x68, 0x41, 0xEA, 0x82, 0x31, 0x01, 0x60, 0x1F, 0x48, 0x01, 0x68, 0x21, 0x4A, 0x21, 0xF0, 0x7F, 0x01, 0x12, 0x68, 0x41, 0xEA, 0x02, 0x01, 0x41, 0xF0, 0x40, 0x01, 0x01, 0x60, 0x19, 0x49, 0x4F, 0xF4, 0xC5, 0x40, 0x08, 0x60, 0x70, 0xBD, 0x03, 0x01, 0x06, 0xD0, 0x3C, 0x0D, 0x00, 0x70, 0x47, 0x03, 0x01, 0x72, 0xD2, 0x3C, 0x0D, 0x00, 0x11, 0x49, 0x0A, 0x6B, 0x0F, 0x48, 0x82, 0x60, 0x10, 0x4A, 0x12, 0x68, 0xC2, 0x60, 0x8A, 0x6B, 0x82, 0x62, 0x0E, 0x4A, 0x12, 0x68, 0x02, 0x61, 0x0E, 0x4A, 0x12, 0x68, 0x42, 0x61, 0x0D, 0x4A, 0x12, 0x68, 0x82, 0x61, 0x0D, 0x4A, 0x12, 0x68, 0xC2, 0x61, 0x0C, 0x4A, 0x12, 0x68, 0x02, 0x62, 0x09, 0x68, 0x41, 0x62, 0x0B, 0x49, 0x09, 0x68, 0x41, 0x60, 0x70, 0x47, 0x00, 0x00, 0xD0, 0x1B, 0x20, 0x00, 0xB8, 0x5E, 0x0D, 0x00, 0xC8, 0x00, 0x64, 0x00, 0xBC, 0x01, 0x60, 0x00, 0x60, 0x04, 0x41, 0x00, 0xFC, 0x04, 0x41, 0x00, 0xE8, 0x06, 0x41, 0x00, 0x58, 0x04, 0x41, 0x00, 0x28, 0x04, 0x41, 0x00, 0xE4, 0x06, 0x41, 0x00, 0x60, 0x01, 0x65, 0x00, 0xE0, 0x0B, 0x21, 0x00, 0x03, 0x01, 0x3A, 0x40, 0x3D, 0x0D, 0x00, 0x4C, 0xFC, 0xFF, 0x86, 0x72, 0x21, 0x00, 0xF8, 0x4A, 0xFF, 0x28, 0x02, 0xDC, 0x32, 0xF8, 0x10, 0x00, 0x70, 0x47, 0xFF, 0x21, 0x90, 0xFB, 0xF1, 0xF1, 0x64, 0x23, 0x58, 0x43, 0xC1, 0xEB, 0x01, 0x23, 0x90, 0xFB, 0xF3, 0xF0, 0xB2, 0xF8, 0xC8, 0x30, 0x32, 0xF8, 0x10, 0x00, 0x32, 0xF8, 0x11, 0x10, 0xC0, 0x1A, 0xB2, 0xF8, 0xFE, 0x31, 0x19, 0x44, 0x08, 0x44, 0x70, 0x47, 0x03, 0x01, 0xA0, 0x01, 0x76, 0x3D, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x00, 0x21, 0xEA, 0x4B, 0x0A, 0x46, 0x08, 0x46, 0x0E, 0x46, 0x4F, 0xF4, 0x00, 0x47, 0xE8, 0x4D, 0x1C, 0x68, 0x08, 0xE0, 0x2F, 0x60, 0x2B, 0x68, 0x2E, 0x60, 0x9B, 0x04, 0x9B, 0x0C, 0x1A, 0x44, 0x00, 0xD1, 0x40, 0x1C, 0x49, 0x1C, 0xA1, 0x42, 0xF4, 0xD3, 0xA0, 0x42, 0x03, 0xD2, 0x20, 0x1A, 0xB2, 0xFB, 0xF0, 0xF0, 0x00, 0xE0, 0x00, 0x20, 0x4F, 0xF4, 0x7A, 0x71, 0x48, 0x43, 0x1B, 0x21, 0xB0, 0xFB, 0xF1, 0xF0, 0x40, 0x1D, 0x0A, 0x21, 0x90, 0xFB, 0xF1, 0xF0, 0xFF, 0xF7, 0xBB, 0xFF, 0xA0, 0xF5, 0x00, 0x40, 0xA0, 0xF5, 0xE2, 0x50, 0x00, 0xEB, 0x80, 0x00, 0x4F, 0xEA, 0x80, 0x00, 0x42, 0xF2, 0x10, 0x71, 0x90, 0xFB, 0xF1, 0xF0, 0xD3, 0x49, 0x09, 0x68, 0xA0, 0xEB, 0x01, 0x01, 0xD2, 0x48, 0x00, 0x68, 0xC0, 0xF1, 0x0B, 0x00, 0x00, 0xEB, 0x40, 0x00, 0x08, 0x44, 0xCF, 0x49, 0x09, 0x68, 0xA0, 0xEB, 0x01, 0x00, 0xCE, 0x49, 0x09, 0x68, 0x40, 0x18, 0x01, 0xD5, 0x40, 0x42, 0x40, 0x42, 0x40, 0xB2, 0xBD, 0xE8, 0xF0, 0x81, 0x03, 0x01, 0x38, 0x12, 0x3E, 0x0D, 0x00, 0x70, 0xB5, 0x04, 0x46, 0x04, 0xF1, 0x28, 0x01, 0x90, 0xF8, 0x34, 0x00, 0x0D, 0x46, 0x99, 0xF7, 0x9B, 0xFF, 0x06, 0x46, 0xFF, 0xF7, 0xA6, 0xFF, 0x01, 0x00, 0x4C, 0xFC, 0xFF, 0x81, 0x73, 0x21, 0x00, 0x09, 0xD0, 0x30, 0x46, 0x99, 0xF7, 0xDB, 0xFF, 0x76, 0x1C, 0x29, 0x46, 0xF0, 0xB2, 0x99, 0xF7, 0x8E, 0xFF, 0x84, 0xF8, 0x34, 0x00, 0x00, 0x20, 0x70, 0xBD, 0x03, 0x01, 0x2A, 0x46, 0x3E, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0xBD, 0x48, 0x00, 0x68, 0x10, 0xF0, 0xFE, 0x0F, 0x09, 0xD0, 0xBB, 0x48, 0x87, 0xF7, 0xE0, 0xFB, 0x18, 0xB1, 0x44, 0x43, 0x4F, 0x20, 0xB4, 0xFB, 0xF0, 0xF4, 0x04, 0xB9, 0x01, 0x24, 0x20, 0x46, 0x10, 0xBD, 0x03, 0x01, 0x1A, 0x6C, 0x3E, 0x0D, 0x00, 0xB6, 0x48, 0x10, 0xB5, 0x40, 0x88, 0xFF, 0xF7, 0xE8, 0xFF, 0xB3, 0x49, 0x80, 0x00, 0x50, 0x39, 0xA1, 0xF8, 0xC0, 0x02, 0x10, 0xBD, 0x03, 0x01, 0x78, 0x82, 0x3E, 0x0D, 0x00, 0x10, 0xB5, 0x6B, 0xF7, 0x58, 0xFF, 0x38, 0xB9, 0x62, 0xF7, 0xF0, 0xFF, 0x20, 0xB9, 0x84, 0xF7, 0x0B, 0xF8, 0x08, 0xB9, 0x87, 0xF7, 0xED, 0xFA, 0xAA, 0x4C, 0x50, 0x3C, 0xB4, 0xF8, 0xC2, 0x02, 0x30, 0xB1, 0xA0, 0xF1, 0x01, 0x00, 0x00, 0x04, 0x00, 0x0C, 0xA4, 0xF8, 0xC2, 0x02, 0x09, 0xD0, 0xA6, 0x48, 0x90, 0xF8, 0x3B, 0x00, 0x40, 0x07, 0x1B, 0xD5, 0xA0, 0x4C, 0x20, 0x68, 0x40, 0x08, 0x0E, 0xD1, 0x09, 0xE0, 0xA0, 0x48, 0x00, 0x78, 0xFF, 0xF7, 0xBC, 0xFF, 0xA4, 0xF8, 0xC2, 0x02, 0xBD, 0xE8, 0x10, 0x40, 0x87, 0xF7, 0x89, 0xBE, 0x9D, 0x48, 0x00, 0x88, 0x40, 0x07, 0x08, 0xD5, 0x01, 0x22, 0x04, 0x21, 0x00, 0x20, 0x82, 0xF7, 0x54, 0xFE, 0x20, 0x68, 0x40, 0xF0, 0x01, 0x00, 0x20, 0x60, 0x10, 0xBD, 0x03, 0x01, 0x7A, 0xF6, 0x3E, 0x0D, 0x00, 0x70, 0xB5, 0x00, 0x25, 0x6B, 0xF7, 0x1D, 0xFF, 0x91, 0x4C, 0x50, 0x3C, 0x68, 0xB1, 0x14, 0x20, 0x99, 0xF7, 0x80, 0xFB, 0x87, 0x4C, 0xFC, 0xFF, 0x7C, 0x74, 0x21, 0x00, 0xF7, 0x99, 0xFB, 0x91, 0x48, 0x21, 0x6D, 0x01, 0x25, 0x01, 0x60, 0x61, 0x6D, 0x41, 0x60, 0xB4, 0xF8, 0x58, 0x10, 0x01, 0x81, 0x62, 0xF7, 0xA5, 0xFF, 0x10, 0xB1, 0x99, 0xF7, 0x50, 0xFD, 0x00, 0xE0, 0x3D, 0xB1, 0x02, 0x20, 0x99, 0xF7, 0x7B, 0xFF, 0x94, 0xF8, 0xEF, 0x00, 0x08, 0xB1, 0x87, 0xF7, 0x73, 0xFA, 0x83, 0x48, 0x90, 0xF8, 0x3B, 0x00, 0x40, 0x07, 0x10, 0xD5, 0x7D, 0x4C, 0x20, 0x68, 0x40, 0x08, 0x03, 0xD1, 0x7F, 0x48, 0x00, 0x88, 0x40, 0x07, 0x08, 0xD5, 0x01, 0x22, 0x04, 0x21, 0x00, 0x20, 0x82, 0xF7, 0x19, 0xFE, 0x20, 0x68, 0x40, 0xF0, 0x01, 0x00, 0x20, 0x60, 0x70, 0xBD, 0x03, 0x01, 0x3A, 0x6C, 0x3F, 0x0D, 0x00, 0x70, 0xB5, 0x78, 0x48, 0x74, 0x4C, 0x75, 0x4D, 0x00, 0x88, 0xA4, 0xF1, 0x50, 0x04, 0x40, 0x07, 0x01, 0xD5, 0x01, 0x20, 0x03, 0xE0, 0x68, 0x88, 0xFF, 0xF7, 0x5F, 0xFF, 0x80, 0x00, 0xA4, 0xF8, 0xC0, 0x02, 0x6C, 0x48, 0x00, 0x68, 0x40, 0x08, 0x02, 0xD0, 0x28, 0x78, 0xFF, 0xF7, 0x55, 0xFF, 0xA4, 0xF8, 0xC2, 0x02, 0x70, 0xBD, 0x03, 0x01, 0x06, 0xA2, 0x3F, 0x0D, 0x00, 0x70, 0x47, 0x03, 0x01, 0xC4, 0x03, 0xA4, 0x3F, 0x0D, 0x00, 0x2D, 0xE9, 0xFF, 0x47, 0x00, 0x27, 0x04, 0x46, 0x3E, 0x46, 0x67, 0xF7, 0x71, 0xFF, 0x00, 0x28, 0x74, 0xD0, 0x6C, 0xF7, 0x43, 0xFC, 0x00, 0x28, 0x70, 0xD1, 0x94, 0xF8, 0x32, 0x00, 0x02, 0x28, 0x6C, 0xD0, 0x64, 0x48, 0x90, 0xF8, 0x30, 0x00, 0x20, 0xB1, 0x97, 0xF7, 0xEB, 0xFC, 0xB0, 0xF5, 0x1C, 0x7F, 0x63, 0xD9, 0xA0, 0x7B, 0x02, 0xA9, 0x6C, 0xF7, 0x00, 0xFF, 0x02, 0x98, 0x5E, 0x4D, 0x10, 0xF0, 0x03, 0x00, 0x06, 0xD0, 0x01, 0x28, 0x07, 0xD0, 0x02, 0x28, 0x4C, 0xFC, 0xFF, 0x77, 0x75, 0x21, 0x00, 0x0E, 0xD0, 0x03, 0x28, 0x17, 0xD1, 0x02, 0xE0, 0x01, 0x21, 0x02, 0x98, 0x0D, 0xE0, 0x28, 0x68, 0x03, 0x99, 0x40, 0x1D, 0x81, 0x42, 0x06, 0xD2, 0x02, 0x99, 0xCD, 0xE9, 0x00, 0x10, 0x0A, 0xE0, 0x02, 0x98, 0x40, 0x1C, 0x03, 0xE0, 0x02, 0x21, 0x02, 0x98, 0x6C, 0xF7, 0x45, 0xFC, 0x00, 0x90, 0x28, 0x68, 0x40, 0x1D, 0x01, 0x90, 0xA0, 0x7B, 0x02, 0xAB, 0x02, 0x46, 0x69, 0x46, 0x6C, 0xF7, 0x89, 0xFD, 0x68, 0x46, 0x6C, 0xF7, 0x88, 0xFE, 0x05, 0x46, 0xDF, 0xF8, 0xE8, 0x90, 0x94, 0xF8, 0x32, 0x00, 0xDF, 0xF8, 0x0C, 0x81, 0xA9, 0xF1, 0x02, 0x09, 0x68, 0xB1, 0x98, 0xF8, 0x02, 0x10, 0x99, 0xF8, 0x00, 0x00, 0x08, 0x44, 0xA8, 0x42, 0x02, 0xD8, 0xB5, 0xFB, 0xF0, 0xF0, 0xC7, 0xB2, 0x00, 0x25, 0x4F, 0xF0, 0x02, 0x09, 0x46, 0xE0, 0x01, 0x20, 0x84, 0xF8, 0x32, 0x00, 0x94, 0xF8, 0x34, 0x00, 0xAD, 0xF7, 0x03, 0xFF, 0xAD, 0xF7, 0x36, 0xFF, 0x98, 0xF8, 0x02, 0x00, 0x98, 0xF8, 0x03, 0x20, 0x99, 0xF8, 0x00, 0x10, 0x83, 0x18, 0x01, 0x26, 0x0B, 0x44, 0xAB, 0x42, 0xE7, 0xD2, 0x2B, 0x1A, 0x0B, 0x44, 0x1A, 0x44, 0x08, 0x44, 0xB2, 0xFB, 0xF0, 0xF0, 0x40, 0x1C, 0xDE, 0xE7, 0x3E, 0xE0, 0x94, 0xF8, 0x34, 0x00, 0x04, 0xF1, 0x28, 0x01, 0x99, 0xF7, 0x56, 0xFE, 0x80, 0x1C, 0xC0, 0xB2, 0x40, 0xF0, 0x80, 0x01, 0x2A, 0x48, 0x95, 0xF7, 0x78, 0xFD, 0x46, 0xB1, 0x98, 0xF8, 0x02, 0x10, 0x98, 0xF8, 0x03, 0x00, 0x08, 0x44, 0x49, 0xF7, 0x21, 0xFA, 0x00, 0x26, 0x03, 0xE0, 0x98, 0xF8, 0x02, 0x00, 0x49, 0xF7, 0x1B, 0xFA, 0x20, 0x46, 0x99, 0xF7, 0x8C, 0xFE, 0x94, 0xF8, 0x34, 0x00, 0x4E, 0x28, 0x05, 0xD9, 0x84, 0xF8, 0x32, 0x90, 0x20, 0x4C, 0xFC, 0xFF, 0x72, 0x76, 0x21, 0x00, 0x46, 0x7F, 0xF7, 0x6E, 0xFD, 0x03, 0xE0, 0x6D, 0x1C, 0xED, 0xB2, 0xBD, 0x42, 0xD3, 0xD3, 0x94, 0xF8, 0x3C, 0x00, 0x40, 0x1C, 0xC0, 0xB2, 0x84, 0xF8, 0x3C, 0x00, 0x4E, 0x28, 0x0A, 0xD9, 0x94, 0xF8, 0x32, 0x00, 0x01, 0x28, 0x06, 0xD1, 0x84, 0xF8, 0x32, 0x90, 0x20, 0x46, 0x7F, 0xF7, 0x58, 0xFD, 0x99, 0xF7, 0x52, 0xFF, 0xBD, 0xE8, 0xFF, 0x87, 0x0A, 0x5F, 0x0D, 0x00, 0xE4, 0x0B, 0x21, 0x00, 0xE8, 0x06, 0x41, 0x00, 0xE4, 0x5E, 0x0D, 0x00, 0xE0, 0x0B, 0x21, 0x00, 0xE8, 0x5E, 0x0D, 0x00, 0xEC, 0x5E, 0x0D, 0x00, 0x90, 0x56, 0x20, 0x00, 0x7C, 0xD4, 0x20, 0x00, 0xA8, 0x1D, 0x20, 0x00, 0x18, 0x41, 0x20, 0x00, 0xB4, 0x1D, 0x20, 0x00, 0xDD, 0x7E, 0x20, 0x00, 0xF8, 0x5B, 0x20, 0x00, 0x44, 0x2B, 0x20, 0x00, 0x04, 0x01, 0x60, 0x00, 0x03, 0x01, 0x50, 0x64, 0x41, 0x0D, 0x00, 0x7C, 0xB5, 0x00, 0x25, 0x04, 0x46, 0x02, 0x29, 0x0F, 0xD0, 0x04, 0x29, 0x1D, 0xD1, 0x94, 0xF8, 0x32, 0x00, 0x00, 0x28, 0x19, 0xD0, 0x59, 0x4E, 0xA0, 0x7B, 0x69, 0x46, 0x6C, 0xF7, 0x2E, 0xFE, 0x00, 0x98, 0xC0, 0x43, 0x80, 0x07, 0x06, 0xD0, 0x09, 0xE0, 0x55, 0x48, 0x00, 0x68, 0xC0, 0xF3, 0x02, 0x10, 0xA0, 0x73, 0x07, 0xE0, 0x01, 0x98, 0x31, 0x68, 0x88, 0x42, 0xEC, 0xD8, 0xAD, 0xF7, 0xCE, 0xFE, 0xAD, 0xF7, 0x01, 0xFF, 0x84, 0xF8, 0x32, 0x50, 0x7C, 0xBD, 0x03, 0x01, 0x98, 0x01, 0xB0, 0x41, 0x0D, 0x00, 0x10, 0xB5, 0x4D, 0x4C, 0x00, 0x20, 0x84, 0xF8, 0x3C, 0x00, 0x94, 0xF8, 0x40, 0x00, 0x08, 0xB9, 0x69, 0xF7, 0x3E, 0xFB, 0xE0, 0x8E, 0x08, 0xB1, 0x40, 0x1E, 0xE0, 0x86, 0x69, 0xF7, 0x47, 0xFF, 0x6A, 0xF7, 0x7D, 0xF8, 0x45, 0x48, 0x7F, 0x4C, 0xFC, 0xFF, 0x6D, 0x77, 0x21, 0x00, 0xF7, 0xAF, 0xFA, 0x20, 0xB9, 0x43, 0x48, 0x00, 0x68, 0x00, 0x1F, 0x6A, 0xF7, 0x07, 0xF8, 0x42, 0x48, 0x7F, 0xF7, 0xA6, 0xFA, 0x38, 0xB9, 0x94, 0xF8, 0x3B, 0x00, 0x01, 0x28, 0x03, 0xD8, 0x69, 0xF7, 0xE4, 0xFD, 0x69, 0xF7, 0x56, 0xFF, 0x82, 0xF7, 0x06, 0xFB, 0x00, 0x20, 0x8E, 0xF7, 0xBD, 0xFB, 0x20, 0x68, 0x50, 0xB1, 0x01, 0x7C, 0x04, 0x29, 0x07, 0xD1, 0x38, 0x49, 0x49, 0x78, 0x21, 0xB9, 0x94, 0xF8, 0x3B, 0x10, 0x09, 0xB9, 0xFF, 0xF7, 0xC1, 0xFE, 0x94, 0xF8, 0x3B, 0x00, 0x01, 0x28, 0x05, 0xD0, 0x68, 0xF7, 0xF9, 0xFD, 0x49, 0xF7, 0xD0, 0xF8, 0x01, 0x20, 0x10, 0xBD, 0x69, 0xF7, 0x80, 0xFF, 0x00, 0x28, 0xF7, 0xD1, 0x49, 0xF7, 0xF0, 0xFB, 0xF4, 0xE7, 0x03, 0x01, 0xC0, 0x01, 0x44, 0x42, 0x0D, 0x00, 0x70, 0xB5, 0x28, 0x4C, 0x01, 0x20, 0x84, 0xF8, 0x3C, 0x00, 0x69, 0xF7, 0xF7, 0xFA, 0x00, 0x25, 0x4F, 0xF6, 0xFF, 0x70, 0x25, 0x61, 0xE0, 0x86, 0xA5, 0x61, 0x69, 0xF7, 0xFE, 0xFE, 0x6A, 0xF7, 0x34, 0xF8, 0x21, 0x48, 0x7F, 0xF7, 0x66, 0xFA, 0x20, 0xB9, 0x1F, 0x48, 0x00, 0x68, 0x00, 0x1F, 0x69, 0xF7, 0xBE, 0xFF, 0x69, 0xF7, 0x89, 0xFF, 0x1E, 0x48, 0xE5, 0x60, 0x7F, 0xF7, 0x5A, 0xFA, 0x08, 0xB9, 0x69, 0xF7, 0x3A, 0xFE, 0x68, 0xF7, 0x83, 0xFE, 0x01, 0x20, 0x8E, 0xF7, 0x77, 0xFB, 0x20, 0x68, 0x38, 0xB1, 0x01, 0x7C, 0x04, 0x29, 0x04, 0xD1, 0x15, 0x49, 0x49, 0x78, 0x09, 0xB9, 0xFF, 0xF7, 0x7E, 0xFE, 0x14, 0x48, 0x00, 0x78, 0x08, 0xB1, 0xFC, 0xF7, 0x45, 0xFB, 0x01, 0x20, 0x68, 0xF7, 0x9E, 0xFA, 0x18, 0xB9, 0x0D, 0x48, 0x7F, 0xF7, 0x3C, 0xFA, 0x28, 0xB1, 0x68, 0xF7, 0xAD, 0xFD, 0x49, 0xF7, 0x84, 0xF8, 0x4C, 0xFC, 0xFF, 0x68, 0x78, 0x21, 0x00, 0x01, 0x20, 0x70, 0xBD, 0x04, 0x48, 0x01, 0x22, 0x11, 0x46, 0x03, 0x68, 0x10, 0x46, 0x5B, 0x1D, 0x68, 0xF7, 0x91, 0xFA, 0xF2, 0xE7, 0x44, 0x2B, 0x20, 0x00, 0x24, 0x86, 0x31, 0x00, 0x00, 0x3F, 0x20, 0x00, 0x44, 0x1C, 0x20, 0x00, 0x3C, 0x1C, 0x20, 0x00, 0xA8, 0x1D, 0x20, 0x00, 0x34, 0x1C, 0x20, 0x00, 0xC9, 0x22, 0x20, 0x00, 0x03, 0x01, 0xF8, 0x03, 0x00, 0x43, 0x0D, 0x00, 0x2D, 0xE9, 0xF8, 0x4F, 0x80, 0x4F, 0x05, 0x46, 0x4F, 0xF0, 0x00, 0x08, 0x38, 0x68, 0x20, 0xB9, 0x28, 0x78, 0x00, 0x28, 0x7E, 0xD1, 0x70, 0xF7, 0xC9, 0xF9, 0x71, 0xF7, 0x9E, 0xF8, 0x00, 0x90, 0x7A, 0x48, 0x22, 0x21, 0x01, 0x60, 0x4F, 0xF4, 0x46, 0x19, 0x00, 0x26, 0xC9, 0xF8, 0x00, 0x62, 0x04, 0x21, 0xC9, 0xF8, 0x04, 0x12, 0x4F, 0xF4, 0x48, 0x14, 0x26, 0x66, 0xC9, 0xF8, 0x00, 0x60, 0x32, 0x20, 0x49, 0xF7, 0xE4, 0xF8, 0x72, 0x48, 0xE0, 0x65, 0x4F, 0xF4, 0x45, 0x11, 0x4F, 0xF0, 0x80, 0x0B, 0xC1, 0xF8, 0x0C, 0xB0, 0xC8, 0x20, 0x49, 0xF7, 0xD9, 0xF8, 0x28, 0x78, 0x4F, 0xF4, 0xCA, 0x0A, 0x4F, 0xF4, 0xC0, 0x04, 0xE0, 0xB1, 0xC4, 0xF8, 0xBC, 0x61, 0x69, 0x48, 0x06, 0x60, 0xD4, 0xF8, 0xFC, 0x02, 0x20, 0xF0, 0x0C, 0x00, 0xC4, 0xF8, 0xFC, 0x02, 0x38, 0x68, 0x48, 0xB1, 0x0A, 0xF5, 0xB0, 0x70, 0x01, 0x69, 0x21, 0xF0, 0x01, 0x01, 0x01, 0x61, 0x01, 0x68, 0x21, 0xF0, 0x01, 0x01, 0x01, 0x60, 0x00, 0x98, 0x71, 0xF7, 0x64, 0xF8, 0x28, 0x78, 0x34, 0x46, 0xD0, 0xB3, 0x9C, 0xE0, 0x00, 0x20, 0x85, 0xF7, 0xF6, 0xFD, 0x01, 0x21, 0x0A, 0xF5, 0xB0, 0x70, 0x39, 0x60, 0x02, 0x69, 0x42, 0xF0, 0x01, 0x02, 0x02, 0x61, 0x02, 0x68, 0x42, 0xF0, 0x01, 0x4C, 0xFC, 0xFF, 0x63, 0x79, 0x21, 0x00, 0x02, 0x02, 0x60, 0x48, 0x46, 0xC9, 0xF8, 0x00, 0x62, 0xC9, 0xF8, 0x04, 0xB2, 0xEA, 0x78, 0x00, 0x2A, 0xD4, 0xF8, 0xFC, 0x22, 0x02, 0xD0, 0x42, 0xF0, 0x0C, 0x02, 0x03, 0xE0, 0x22, 0xF0, 0x0C, 0x02, 0x42, 0xF0, 0x08, 0x02, 0xC4, 0xF8, 0xFC, 0x22, 0x4B, 0x4A, 0x89, 0x46, 0x11, 0x60, 0x69, 0x78, 0x49, 0x4A, 0x89, 0x1E, 0x08, 0x32, 0x11, 0x60, 0x69, 0x78, 0x89, 0x1E, 0x12, 0x1F, 0x11, 0x60, 0x46, 0x49, 0x01, 0x60, 0x00, 0x20, 0x4F, 0xF4, 0x7A, 0x73, 0x4F, 0xF4, 0x45, 0x12, 0x01, 0x46, 0x40, 0x1C, 0x99, 0x42, 0x01, 0xE0, 0x6B, 0xE0, 0x0E, 0xE0, 0x02, 0xD8, 0xD1, 0x68, 0x09, 0x06, 0xF5, 0xD5, 0x4F, 0xF4, 0x48, 0x10, 0x4F, 0xF4, 0x00, 0x31, 0x01, 0x66, 0xC8, 0x20, 0x49, 0xF7, 0x6F, 0xF8, 0xC4, 0xF8, 0xBC, 0x91, 0xAE, 0xE7, 0xE0, 0xB2, 0xA9, 0x78, 0x40, 0xF0, 0x01, 0x00, 0x60, 0xF3, 0x07, 0x04, 0x06, 0x29, 0x19, 0xD2, 0xDF, 0xE8, 0x01, 0xF0, 0x03, 0x07, 0x0E, 0x27, 0x2A, 0x2E, 0x20, 0xF0, 0x1C, 0x00, 0x18, 0x30, 0x0E, 0xE0, 0xC4, 0xF3, 0x07, 0x20, 0x40, 0xF0, 0x01, 0x00, 0x60, 0xF3, 0x0F, 0x24, 0x09, 0xE0, 0xC4, 0xF3, 0x07, 0x21, 0x41, 0xF0, 0x01, 0x01, 0x61, 0xF3, 0x0F, 0x24, 0x40, 0xF0, 0x02, 0x00, 0x60, 0xF3, 0x07, 0x04, 0xE9, 0x78, 0xC4, 0xF3, 0x07, 0x20, 0x61, 0xF3, 0x83, 0x00, 0x60, 0xF3, 0x0F, 0x24, 0x28, 0x79, 0x07, 0x28, 0x0F, 0xD8, 0x00, 0x06, 0x80, 0x0D, 0x40, 0x42, 0x40, 0xB2, 0x11, 0xE0, 0x20, 0xF0, 0xE0, 0x00, 0xEB, 0xE7, 0x20, 0xF0, 0xE0, 0x00, 0x20, 0x30, 0xE7, 0xE7, 0x20, 0xF0, 0xE0, 0x00, 0xA0, 0x30, 0xE3, 0xE7, 0x08, 0x28, 0x02, 0xD0, 0x09, 0x28, 0x05, 0xD0, 0x08, 0xE0, 0x4C, 0xFC, 0xFF, 0x5E, 0x7A, 0x21, 0x00, 0x95, 0xF9, 0x05, 0x00, 0x7E, 0xF7, 0x0A, 0xFA, 0x02, 0xE0, 0xA8, 0x79, 0x7D, 0xF7, 0x9E, 0xFE, 0x80, 0x46, 0x02, 0x21, 0x40, 0x46, 0xA5, 0xF7, 0x45, 0xFD, 0x08, 0xF0, 0xFF, 0x01, 0x11, 0x48, 0x95, 0xF7, 0x68, 0xFB, 0x0B, 0x48, 0x04, 0x60, 0x28, 0x78, 0x20, 0xB1, 0x38, 0x68, 0x10, 0xB1, 0x6F, 0xF7, 0x5B, 0xFF, 0x3E, 0x60, 0x01, 0x20, 0xBD, 0xE8, 0xF8, 0x8F, 0x03, 0x01, 0x30, 0xF4, 0x44, 0x0D, 0x00, 0x10, 0xB5, 0x14, 0x46, 0x0C, 0x30, 0xFF, 0xF7, 0x01, 0xFF, 0x00, 0x28, 0x01, 0xD1, 0x12, 0x20, 0x60, 0x71, 0x10, 0xBD, 0x0C, 0x61, 0x0D, 0x00, 0xC0, 0x04, 0x41, 0x00, 0x00, 0x02, 0x0C, 0x00, 0x10, 0x84, 0x31, 0x00, 0x01, 0x00, 0x80, 0x00, 0x0C, 0x01, 0x60, 0x00, 0x03, 0x01, 0x24, 0x20, 0x45, 0x0D, 0x00, 0x10, 0xB5, 0x85, 0xF7, 0x6E, 0xFD, 0x85, 0xF7, 0x5F, 0xFD, 0x04, 0x48, 0x01, 0x68, 0x41, 0xF0, 0x01, 0x01, 0x01, 0x60, 0xBD, 0xE8, 0x10, 0x40, 0x85, 0xF7, 0x11, 0xBD, 0x04, 0x2C, 0x20, 0x00, 0x03, 0x01, 0xB8, 0x01, 0x40, 0x45, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x0D, 0x46, 0x26, 0x49, 0xDF, 0xF8, 0x98, 0xC0, 0x00, 0x23, 0x89, 0x78, 0x1C, 0xF8, 0x03, 0x40, 0xA1, 0x42, 0x03, 0xD8, 0x5C, 0x1E, 0x06, 0x2B, 0x04, 0xD2, 0x06, 0xE0, 0x5B, 0x1C, 0xDB, 0xB2, 0x06, 0x2B, 0xF3, 0xD3, 0x05, 0x23, 0x04, 0x24, 0x02, 0xE0, 0x0B, 0xB9, 0x01, 0x23, 0x00, 0x24, 0x1C, 0x4E, 0x05, 0xEB, 0x85, 0x05, 0x80, 0xB1, 0x1B, 0x48, 0xC3, 0xEB, 0x03, 0x17, 0x07, 0x44, 0x2F, 0x44, 0x17, 0x44, 0x97, 0xF8, 0xA2, 0x70, 0xF7, 0x60, 0xC4, 0xEB, 0x04, 0x17, 0x38, 0x44, 0x28, 0x44, 0x10, 0x44, 0x90, 0xF8, 0xA2, 0x00, 0x11, 0x4C, 0xFC, 0xFF, 0x59, 0x7B, 0x21, 0x00, 0xE0, 0x14, 0x48, 0x03, 0xEB, 0x83, 0x07, 0x00, 0xEB, 0xC7, 0x07, 0x2F, 0x44, 0x17, 0x44, 0x97, 0xF8, 0x6D, 0x71, 0xF7, 0x60, 0x04, 0xEB, 0x84, 0x07, 0x00, 0xEB, 0xC7, 0x00, 0x28, 0x44, 0x10, 0x44, 0x90, 0xF8, 0x6D, 0x01, 0xB0, 0x60, 0x1C, 0xF8, 0x03, 0x00, 0x70, 0x60, 0x1C, 0xF8, 0x04, 0x00, 0x30, 0x60, 0x05, 0x48, 0x51, 0xF7, 0x36, 0xFD, 0xFF, 0x28, 0x00, 0xD9, 0xFF, 0x20, 0xBD, 0xE8, 0xF0, 0x81, 0xBD, 0x1E, 0x20, 0x00, 0x10, 0x13, 0x20, 0x00, 0x2C, 0x51, 0x20, 0x00, 0xEB, 0x15, 0x20, 0x00, 0x16, 0x13, 0x20, 0x00, 0x03, 0x01, 0xC2, 0x04, 0xF4, 0x45, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x4F, 0x87, 0xB0, 0x00, 0x26, 0x04, 0x46, 0x05, 0x96, 0x90, 0xF8, 0xD2, 0x00, 0xFC, 0xF7, 0x7A, 0xFC, 0x80, 0x46, 0x8A, 0xF7, 0xFF, 0xFA, 0x94, 0xF8, 0xD2, 0x70, 0x04, 0xA9, 0x1E, 0x37, 0x38, 0x46, 0x5F, 0xF7, 0xFC, 0xF9, 0xDF, 0xF8, 0xBC, 0xB4, 0x05, 0x00, 0x0A, 0xD0, 0x04, 0x98, 0x00, 0xEB, 0x40, 0x01, 0xDB, 0xF8, 0x00, 0x00, 0x00, 0xEB, 0x81, 0x00, 0x06, 0x60, 0x46, 0x60, 0x86, 0x60, 0x03, 0xE0, 0x04, 0xA8, 0x5F, 0xF7, 0xD6, 0xF9, 0xF0, 0xB3, 0x08, 0x20, 0x8D, 0xF8, 0x0A, 0x00, 0x4F, 0xF0, 0x01, 0x0A, 0x8D, 0xF8, 0x0B, 0xA0, 0x8D, 0xF8, 0x07, 0x70, 0x94, 0xF8, 0xD0, 0x00, 0xAD, 0xF8, 0x00, 0x60, 0x8D, 0xF8, 0x08, 0x00, 0xAD, 0xF8, 0x02, 0x60, 0x5F, 0xF7, 0xD1, 0xFA, 0x8D, 0xF8, 0x09, 0x00, 0xB4, 0xF8, 0x4C, 0x00, 0x4F, 0xF0, 0x02, 0x09, 0x40, 0x1C, 0x20, 0xF0, 0x01, 0x00, 0x80, 0xB2, 0xAD, 0xF8, 0x04, 0x00, 0x02, 0x28, 0x01, 0xD2, 0xAD, 0xF8, 0x04, 0x90, 0xB4, 0xF8, 0x4E, 0x00, 0xBD, 0xF8, 0x04, 0x10, 0x4C, 0xFC, 0xFF, 0x54, 0x7C, 0x21, 0x00, 0x40, 0x1C, 0x20, 0xF0, 0x01, 0x00, 0x88, 0x42, 0x01, 0xD9, 0x40, 0x1A, 0x05, 0x90, 0x94, 0xF8, 0xD2, 0x00, 0xA5, 0xF7, 0xFE, 0xFA, 0x05, 0x99, 0x6F, 0xF0, 0x01, 0x02, 0x08, 0x44, 0x05, 0x90, 0xB4, 0xF8, 0x48, 0x10, 0x02, 0xEB, 0x41, 0x02, 0x82, 0x42, 0x03, 0xD8, 0x48, 0x00, 0x00, 0xE0, 0x12, 0xE0, 0x80, 0x1E, 0x8D, 0xF8, 0x06, 0x00, 0x94, 0xF8, 0xD1, 0x00, 0xB0, 0xB1, 0x00, 0x2D, 0x7E, 0xD0, 0xB4, 0xF8, 0xC8, 0x00, 0xAD, 0xF8, 0x00, 0x00, 0xB4, 0xF8, 0xCA, 0x00, 0xAD, 0xF8, 0x02, 0x00, 0x94, 0xF8, 0xD5, 0x00, 0x89, 0xE0, 0x00, 0x23, 0x6B, 0x22, 0x40, 0xF2, 0xA1, 0x31, 0xFB, 0x48, 0x70, 0xF7, 0xF4, 0xF8, 0x07, 0xB0, 0xBD, 0xE8, 0xF0, 0x8F, 0x01, 0x27, 0x59, 0xF7, 0x63, 0xFF, 0x18, 0xB1, 0x5E, 0xF7, 0x3C, 0xF8, 0x00, 0xB9, 0x00, 0x27, 0xB4, 0xF8, 0x44, 0x00, 0x40, 0x05, 0x05, 0xD5, 0xB8, 0xF8, 0x00, 0x00, 0x10, 0xB1, 0xAD, 0xF8, 0x02, 0x00, 0x09, 0xE0, 0xB4, 0xF8, 0x4A, 0x00, 0x3B, 0x46, 0x42, 0x00, 0xB4, 0xF8, 0x48, 0x00, 0x41, 0x00, 0x68, 0x46, 0x5F, 0xF7, 0x42, 0xFB, 0xBD, 0xF8, 0x02, 0x00, 0x01, 0x28, 0x0A, 0xD9, 0xE9, 0x49, 0x49, 0x68, 0x40, 0x1E, 0xB1, 0xFB, 0xF0, 0xF2, 0x00, 0xFB, 0x12, 0x10, 0x20, 0xF0, 0x01, 0x00, 0xAD, 0xF8, 0x00, 0x00, 0x94, 0xF8, 0xD2, 0x00, 0x05, 0xAA, 0x69, 0x46, 0xA5, 0xF7, 0xC7, 0xFA, 0x48, 0xBB, 0xB4, 0xF8, 0x44, 0x00, 0x40, 0x05, 0x19, 0xD5, 0xB8, 0xF8, 0x00, 0x00, 0xB0, 0xB1, 0x4A, 0x46, 0x21, 0x46, 0x68, 0x46, 0xCD, 0xF8, 0x0C, 0x90, 0x5F, 0xF7, 0x33, 0xFC, 0xD0, 0xB9, 0x52, 0x46, 0x21, 0x46, 0x68, 0x46, 0xCD, 0xF8, 0x0C, 0xA0, 0x5F, 0xF7, 0x2B, 0x4C, 0xFC, 0xFF, 0x4F, 0x7D, 0x21, 0x00, 0xFC, 0x90, 0xB9, 0x32, 0x46, 0x21, 0x46, 0x68, 0x46, 0x03, 0x96, 0x5F, 0xF7, 0x24, 0xFC, 0x58, 0xB9, 0x03, 0xA9, 0x68, 0x46, 0x5F, 0xF7, 0xEA, 0xFA, 0x30, 0xB9, 0xAD, 0xF8, 0x00, 0x60, 0xB4, 0xF8, 0x4A, 0x00, 0x40, 0x00, 0xAD, 0xF8, 0x02, 0x00, 0xBD, 0xF8, 0x00, 0x00, 0x5D, 0xB1, 0xA4, 0xF8, 0xC8, 0x00, 0xBD, 0xF8, 0x02, 0x00, 0xA4, 0xF8, 0xCA, 0x00, 0x9D, 0xF8, 0x09, 0x00, 0x84, 0xF8, 0xD5, 0x00, 0x17, 0xE0, 0x0A, 0xE0, 0xA4, 0xF8, 0xC4, 0x00, 0xBD, 0xF8, 0x02, 0x00, 0xA4, 0xF8, 0xC6, 0x00, 0x9D, 0xF8, 0x09, 0x00, 0x84, 0xF8, 0xD4, 0x00, 0x0B, 0xE0, 0xB4, 0xF8, 0xC4, 0x00, 0xAD, 0xF8, 0x00, 0x00, 0xB4, 0xF8, 0xC6, 0x00, 0xAD, 0xF8, 0x02, 0x00, 0x94, 0xF8, 0xD4, 0x00, 0x8D, 0xF8, 0x09, 0x00, 0x04, 0x98, 0xDB, 0xF8, 0x00, 0x10, 0x00, 0xEB, 0x40, 0x02, 0x01, 0xEB, 0x82, 0x00, 0x00, 0x9A, 0x02, 0x60, 0x01, 0x9A, 0x42, 0x60, 0x02, 0x9A, 0x82, 0x60, 0x00, 0x2D, 0x7F, 0xF4, 0x6B, 0xAF, 0x04, 0x98, 0x00, 0xEB, 0x40, 0x00, 0x01, 0xEB, 0x80, 0x00, 0x80, 0x79, 0x84, 0xF8, 0xD6, 0x00, 0x61, 0xE7, 0x03, 0x01, 0xBC, 0x02, 0x32, 0x48, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x4F, 0x05, 0x46, 0x90, 0xF8, 0xD2, 0x00, 0x8B, 0xB0, 0x8A, 0x46, 0x90, 0x46, 0x9B, 0x46, 0x1E, 0x30, 0x04, 0xA9, 0x5F, 0xF7, 0xE4, 0xF8, 0x00, 0x28, 0x78, 0xD0, 0x8A, 0xF7, 0xDC, 0xF9, 0x04, 0x98, 0x00, 0xEB, 0x40, 0x01, 0xA0, 0x48, 0x00, 0x68, 0x00, 0xEB, 0x81, 0x01, 0x08, 0x68, 0x00, 0x90, 0x48, 0x68, 0x01, 0x90, 0x88, 0x68, 0x02, 0x90, 0x0C, 0x68, 0x06, 0x94, 0x48, 0x68, 0x07, 0x90, 0x88, 0x68, 0x08, 0x90, 0x00, 0x20, 0x08, 0x60, 0x4C, 0xFC, 0xFF, 0x4A, 0x7E, 0x21, 0x00, 0x48, 0x60, 0x88, 0x60, 0x05, 0xA9, 0x68, 0x46, 0x5F, 0xF7, 0x5E, 0xFE, 0xB5, 0xF8, 0x4E, 0x20, 0xB5, 0xF8, 0x4C, 0x10, 0x68, 0x46, 0x60, 0xF7, 0x7F, 0xF9, 0x02, 0x25, 0x4F, 0xF0, 0x00, 0x09, 0x20, 0x0C, 0x4F, 0x46, 0x09, 0x90, 0xBA, 0xF8, 0x02, 0x00, 0x09, 0x99, 0x40, 0x04, 0x00, 0x0C, 0xAD, 0xF8, 0x02, 0x00, 0x81, 0x42, 0x05, 0xD1, 0x05, 0x98, 0x85, 0x42, 0x02, 0xD2, 0x4F, 0xF0, 0x00, 0x09, 0x40, 0xE0, 0x00, 0x26, 0xB8, 0xF1, 0x00, 0x0F, 0x01, 0xD0, 0x00, 0x24, 0x1E, 0xE0, 0x03, 0xA9, 0x68, 0x46, 0x5F, 0xF7, 0x51, 0xFA, 0x01, 0x28, 0x1A, 0xD1, 0x03, 0x98, 0xA8, 0x42, 0x17, 0xD1, 0x4F, 0xF0, 0x01, 0x09, 0x29, 0xE0, 0x0B, 0xEB, 0x84, 0x00, 0xBD, 0xF8, 0x02, 0x10, 0x00, 0x68, 0xB0, 0xFB, 0xF1, 0xF2, 0x01, 0xFB, 0x12, 0x00, 0xAD, 0xF8, 0x00, 0x00, 0x03, 0xA9, 0x68, 0x46, 0x5F, 0xF7, 0x21, 0xFE, 0x03, 0x98, 0xA8, 0x42, 0xEA, 0xD0, 0x64, 0x1C, 0x44, 0x45, 0xEA, 0xD3, 0xBD, 0xF8, 0x02, 0x00, 0x80, 0x1E, 0x80, 0xB2, 0xAD, 0xF8, 0x02, 0x00, 0xBA, 0xF8, 0x00, 0x10, 0xB0, 0xEB, 0x41, 0x0F, 0x02, 0xD3, 0x76, 0x1C, 0x0C, 0x2E, 0xCB, 0xD3, 0x7F, 0x1C, 0x6D, 0x1E, 0x03, 0x2F, 0xB7, 0xD3, 0xB9, 0xF1, 0x00, 0x0F, 0x04, 0xD0, 0x14, 0x98, 0x03, 0x99, 0x01, 0x60, 0x03, 0xE0, 0x10, 0xE0, 0x14, 0x99, 0x00, 0x20, 0x08, 0x60, 0x04, 0x98, 0x00, 0xEB, 0x40, 0x01, 0x62, 0x48, 0x00, 0x68, 0x00, 0xEB, 0x81, 0x00, 0x06, 0x99, 0x01, 0x60, 0x07, 0x99, 0x41, 0x60, 0x08, 0x99, 0x81, 0x60, 0x48, 0x46, 0x0B, 0xB0, 0xC6, 0xE6, 0x03, 0x01, 0xD6, 0x03, 0x6A, 0x49, 0x0D, 0x00, 0x70, 0xB5, 0x86, 0xB0, 0x04, 0x46, 0x8A, 0x4C, 0xFC, 0xFF, 0x45, 0x7F, 0x21, 0x00, 0xF7, 0x4C, 0xF9, 0x00, 0x25, 0x20, 0x68, 0x03, 0xA9, 0x5F, 0xF7, 0x4B, 0xF8, 0x20, 0xB1, 0xE0, 0x69, 0x00, 0x04, 0x06, 0xD5, 0x01, 0x25, 0x04, 0xE0, 0x03, 0xA8, 0x5F, 0xF7, 0x2E, 0xF8, 0x00, 0x28, 0x7A, 0xD0, 0x54, 0x48, 0x00, 0x78, 0x18, 0xB1, 0xE0, 0x69, 0x00, 0x04, 0x00, 0xD5, 0x01, 0x25, 0x04, 0x20, 0x8D, 0xF8, 0x0A, 0x00, 0x01, 0x20, 0x8D, 0xF8, 0x0B, 0x00, 0x20, 0x68, 0x8D, 0xF8, 0x07, 0x00, 0x20, 0x68, 0x6F, 0xF7, 0x91, 0xF9, 0x8D, 0xF8, 0x08, 0x00, 0xB4, 0xF8, 0xB0, 0x00, 0xAD, 0xF8, 0x00, 0x00, 0xB4, 0xF8, 0xB2, 0x00, 0xAD, 0xF8, 0x02, 0x00, 0x94, 0xF8, 0xB4, 0x00, 0x8D, 0xF8, 0x09, 0x00, 0x21, 0x46, 0x68, 0x46, 0x5E, 0xF7, 0x9B, 0xFD, 0xBD, 0xF8, 0x00, 0x10, 0x42, 0x4E, 0xC8, 0x07, 0x05, 0xD1, 0xBD, 0xF8, 0x02, 0x00, 0x80, 0xB1, 0x80, 0x1E, 0x81, 0x42, 0x08, 0xDD, 0x4F, 0xF0, 0x00, 0x00, 0x00, 0x2D, 0x46, 0xD1, 0xAD, 0xF8, 0x00, 0x00, 0xBD, 0xF8, 0x02, 0x00, 0x20, 0xB1, 0x0D, 0xB9, 0xF0, 0x78, 0xE8, 0xB3, 0x01, 0x25, 0x80, 0xE0, 0x37, 0x48, 0x00, 0x78, 0x28, 0xB9, 0xB4, 0xF8, 0xAA, 0x00, 0xB4, 0xF8, 0xA8, 0x50, 0xA8, 0x42, 0x04, 0xD1, 0xB4, 0xF8, 0xA8, 0x00, 0xAD, 0xF8, 0x02, 0x00, 0x2C, 0xE0, 0x30, 0x78, 0x38, 0xB1, 0xE0, 0x69, 0x00, 0x04, 0x04, 0xD4, 0xAD, 0xF8, 0x02, 0x50, 0xA4, 0xF8, 0xB2, 0x50, 0x27, 0xE0, 0xB4, 0xF8, 0xBC, 0x00, 0x10, 0xB1, 0x85, 0x42, 0x00, 0xD9, 0x05, 0x46, 0x70, 0x78, 0x88, 0xB1, 0xE0, 0x69, 0x00, 0x04, 0x0E, 0xD5, 0xF0, 0x88, 0x85, 0x42, 0x0B, 0xD9, 0x5E, 0xF7, 0xDF, 0xFD, 0x40, 0x42, 0x00, 0xEB, 0x80, 0x00, 0xB4, 0xF8, 0xAA, 0x10, 0x05, 0xEB, 0x4C, 0xFC, 0xFF, 0x40, 0x80, 0x21, 0x00, 0x40, 0x00, 0x81, 0x42, 0x00, 0xD2, 0x05, 0x46, 0xB4, 0xF8, 0xAA, 0x10, 0x01, 0x23, 0x2A, 0x46, 0x68, 0x46, 0x5F, 0xF7, 0x9B, 0xF9, 0xBD, 0xF8, 0x02, 0x00, 0x01, 0xE0, 0x02, 0xE0, 0x55, 0xE0, 0xA4, 0xF8, 0xB2, 0x00, 0x04, 0xA9, 0x68, 0x46, 0x5F, 0xF7, 0x70, 0xF9, 0x05, 0x00, 0x4D, 0xD0, 0xB0, 0x78, 0x02, 0x2D, 0x03, 0xD0, 0xD0, 0xB1, 0x01, 0x2D, 0x25, 0xD0, 0x33, 0xE0, 0x68, 0xB1, 0xE1, 0x69, 0x09, 0x04, 0x0A, 0xD4, 0xB4, 0xF8, 0xAC, 0x10, 0x81, 0x42, 0x06, 0xD2, 0xB4, 0xF8, 0xB2, 0x10, 0xF2, 0x88, 0x91, 0x42, 0x01, 0xD9, 0xA4, 0xF8, 0xAC, 0x00, 0xBD, 0xF8, 0x00, 0x00, 0xA4, 0xF8, 0xB0, 0x00, 0x9D, 0xF8, 0x09, 0x00, 0x84, 0xF8, 0xB4, 0x00, 0x1B, 0xE0, 0x1A, 0xE0, 0x50, 0x31, 0x20, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0xA0, 0x32, 0x00, 0x47, 0x31, 0x20, 0x00, 0xE8, 0x0B, 0x21, 0x00, 0x49, 0x31, 0x20, 0x00, 0xE1, 0x69, 0x09, 0x04, 0x0B, 0xD4, 0xB4, 0xF8, 0xAC, 0x10, 0x81, 0x42, 0x07, 0xD2, 0xB4, 0xF8, 0xB2, 0x10, 0xF2, 0x88, 0x91, 0x42, 0x02, 0xD9, 0xA4, 0xF8, 0xAC, 0x00, 0x02, 0x25, 0x27, 0x49, 0x03, 0x98, 0x00, 0x22, 0x09, 0x68, 0x00, 0xEB, 0x40, 0x00, 0x01, 0xEB, 0x80, 0x00, 0x00, 0x99, 0x01, 0x60, 0x01, 0x99, 0x41, 0x60, 0x02, 0x99, 0x81, 0x60, 0x04, 0x21, 0x20, 0x46, 0x96, 0xF7, 0xD7, 0xF8, 0x28, 0x46, 0x06, 0xB0, 0x70, 0xBD, 0x03, 0x01, 0x1E, 0x3C, 0x4B, 0x0D, 0x00, 0x1D, 0x4A, 0x03, 0x46, 0x08, 0x46, 0x11, 0x79, 0x00, 0x29, 0x05, 0xD0, 0x81, 0x42, 0x03, 0xD9, 0xD2, 0x88, 0x9A, 0x42, 0x00, 0xD2, 0x08, 0x46, 0x70, 0x47, 0x03, 0x01, 0x6A, 0x56, 0x4B, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x4C, 0xFC, 0xFF, 0x3B, 0x81, 0x21, 0x00, 0x46, 0x10, 0x00, 0x01, 0xD1, 0xB4, 0xF8, 0xAA, 0x00, 0x15, 0x4A, 0x12, 0x79, 0x00, 0x2A, 0x21, 0xD0, 0x12, 0x4A, 0x52, 0x79, 0x90, 0x42, 0x1D, 0xD3, 0x62, 0x6B, 0x93, 0x07, 0x01, 0xD5, 0x05, 0x23, 0x04, 0xE0, 0xD2, 0x07, 0x01, 0xD0, 0x03, 0x23, 0x00, 0xE0, 0x01, 0x23, 0xB4, 0xF8, 0x66, 0x20, 0x14, 0x0B, 0x01, 0xD0, 0x5B, 0x1D, 0x05, 0xE0, 0x12, 0xF4, 0x70, 0x6F, 0x01, 0xD0, 0xDB, 0x1C, 0x00, 0xE0, 0x5B, 0x1C, 0x83, 0x42, 0x00, 0xD3, 0x83, 0x1E, 0x8A, 0x88, 0x9A, 0x42, 0x00, 0xD9, 0x13, 0x46, 0x8B, 0x80, 0x10, 0xBD, 0x50, 0x31, 0x20, 0x00, 0xE8, 0x0B, 0x21, 0x00, 0xD4, 0x1D, 0x20, 0x00, 0x03, 0x01, 0x94, 0x03, 0xBC, 0x4B, 0x0D, 0x00, 0x2D, 0xE9, 0xF8, 0x4F, 0x00, 0x24, 0x26, 0x46, 0x4F, 0xF0, 0x01, 0x09, 0x81, 0xF7, 0x54, 0xFE, 0x05, 0x46, 0x4C, 0xF7, 0x7B, 0xFD, 0x5A, 0x4F, 0x38, 0x68, 0x00, 0xF0, 0xE0, 0x01, 0x59, 0x48, 0x02, 0x78, 0x02, 0xF0, 0x1F, 0x02, 0x11, 0x43, 0x39, 0x60, 0x39, 0x1F, 0x0A, 0x68, 0x43, 0x78, 0x02, 0xF0, 0xE0, 0x02, 0x03, 0xF0, 0x1F, 0x03, 0x1A, 0x43, 0x0A, 0x60, 0x3A, 0x1D, 0x13, 0x68, 0x90, 0xF8, 0x02, 0xC0, 0x03, 0xF0, 0xE0, 0x03, 0x0C, 0xF0, 0x1F, 0x0C, 0x43, 0xEA, 0x0C, 0x03, 0x13, 0x60, 0x4D, 0x4A, 0x13, 0x68, 0x90, 0xF8, 0x03, 0xC0, 0x03, 0xF0, 0xE0, 0x03, 0x0C, 0xF0, 0x1F, 0x0C, 0x43, 0xEA, 0x0C, 0x03, 0x13, 0x60, 0xDF, 0xF8, 0x1C, 0xA1, 0x0A, 0xF1, 0x08, 0x0A, 0xDA, 0xF8, 0x00, 0xC0, 0x00, 0x79, 0x0C, 0xF0, 0xE0, 0x0C, 0x00, 0xF0, 0x1F, 0x00, 0x4C, 0xEA, 0x00, 0x0C, 0xCA, 0xF8, 0x00, 0xC0, 0x38, 0x68, 0xDF, 0xF8, 0xF4, 0xC0, 0x00, 0xF0, 0x1F, 0x00, 0x4C, 0xFC, 0xFF, 0x36, 0x82, 0x21, 0x00, 0x0C, 0xF1, 0x54, 0x0C, 0x0C, 0xF1, 0x04, 0x08, 0x03, 0x28, 0x03, 0xD3, 0x80, 0x1E, 0xCC, 0xF8, 0x00, 0x00, 0x04, 0xE0, 0x00, 0x23, 0xCC, 0xF8, 0x00, 0x30, 0x18, 0xB1, 0x40, 0x1E, 0xC8, 0xF8, 0x00, 0x00, 0x01, 0xE0, 0xC8, 0xF8, 0x00, 0x30, 0xED, 0xB3, 0x04, 0x2D, 0x49, 0xD0, 0x10, 0x68, 0x00, 0xF0, 0x1F, 0x00, 0x08, 0x30, 0xDA, 0xF8, 0x00, 0x20, 0x60, 0xF3, 0x04, 0x02, 0xCA, 0xF8, 0x00, 0x20, 0x2D, 0x4B, 0x40, 0x33, 0x1A, 0x68, 0x00, 0xF0, 0x10, 0x00, 0x22, 0xF0, 0x10, 0x02, 0x02, 0x43, 0x1A, 0x60, 0x45, 0xB3, 0x03, 0x2D, 0x37, 0xD0, 0x08, 0x68, 0x04, 0x2D, 0x00, 0xD0, 0x80, 0x1E, 0x38, 0x60, 0x30, 0xF7, 0xD0, 0xFB, 0x00, 0x28, 0x3E, 0xD0, 0x6A, 0x46, 0x02, 0x21, 0x6E, 0x20, 0x30, 0xF7, 0x9B, 0xFB, 0xBD, 0xF8, 0x00, 0x00, 0xC1, 0xB2, 0x41, 0xEA, 0x10, 0x20, 0x01, 0x06, 0x01, 0xD5, 0x4F, 0xF0, 0xFF, 0x39, 0x00, 0xF0, 0x7F, 0x00, 0x00, 0xFB, 0x09, 0xF0, 0x40, 0xB2, 0x00, 0x28, 0x29, 0xD0, 0x19, 0x4A, 0x02, 0xEB, 0x84, 0x01, 0x91, 0xF9, 0x00, 0x30, 0x83, 0x42, 0x1A, 0xDC, 0x01, 0xE0, 0x0C, 0xE0, 0x0F, 0xE0, 0x91, 0xF9, 0x01, 0x10, 0x81, 0x42, 0x13, 0xDD, 0x6D, 0xB1, 0x04, 0x2D, 0x0B, 0xD0, 0x02, 0xEB, 0x84, 0x00, 0x90, 0xF9, 0x02, 0x60, 0x0F, 0xE0, 0x10, 0x68, 0x00, 0xF0, 0x1F, 0x00, 0xB5, 0xE7, 0x08, 0x68, 0x40, 0x1E, 0xC8, 0xE7, 0x02, 0xEB, 0x84, 0x00, 0x90, 0xF9, 0x03, 0x60, 0x03, 0xE0, 0x64, 0x1C, 0xE4, 0xB2, 0x09, 0x2C, 0xDA, 0xD3, 0x38, 0x68, 0x30, 0x44, 0xC0, 0xB2, 0x38, 0x60, 0xBD, 0xE8, 0xF8, 0x8F, 0x00, 0x00, 0x10, 0x04, 0x60, 0x00, 0x9C, 0x07, 0x20, 0x00, 0x00, 0x07, 0x60, 0x4C, 0xFC, 0xFF, 0x31, 0x83, 0x21, 0x00, 0x00, 0xF0, 0x0B, 0x21, 0x00, 0x03, 0x01, 0x1A, 0x4C, 0x4D, 0x0D, 0x00, 0x34, 0x48, 0x01, 0x68, 0x34, 0x48, 0x01, 0x60, 0x34, 0x49, 0x09, 0x68, 0x41, 0x60, 0x34, 0x49, 0x49, 0x68, 0x81, 0x60, 0x70, 0x47, 0x03, 0x01, 0x1A, 0x62, 0x4D, 0x0D, 0x00, 0x33, 0x48, 0x01, 0x68, 0x2F, 0x48, 0x01, 0x60, 0x32, 0x49, 0x09, 0x68, 0x41, 0x60, 0x2E, 0x49, 0x09, 0x68, 0x81, 0x60, 0x70, 0x47, 0x03, 0x01, 0x84, 0x01, 0x78, 0x4D, 0x0D, 0x00, 0x70, 0xB5, 0x2F, 0x48, 0x06, 0x26, 0x00, 0x25, 0x80, 0x68, 0x2E, 0x4C, 0x01, 0x7C, 0x22, 0x29, 0x2E, 0xD0, 0x08, 0xDC, 0x01, 0x29, 0x10, 0xD0, 0x06, 0x29, 0x19, 0xD0, 0x10, 0x29, 0x25, 0xD0, 0x21, 0x29, 0x06, 0xD1, 0x27, 0xE0, 0x28, 0x29, 0x17, 0xD0, 0x2A, 0x29, 0x1B, 0xD0, 0x2B, 0x29, 0x1C, 0xD0, 0x25, 0x60, 0xBD, 0xE8, 0x70, 0x40, 0xD7, 0xE7, 0x90, 0xF8, 0xA9, 0x00, 0x1C, 0xE0, 0xFF, 0xF7, 0xC8, 0xFF, 0x26, 0x60, 0x70, 0xBD, 0xFF, 0xF7, 0xCF, 0xFF, 0x25, 0x60, 0x70, 0xBD, 0x90, 0xF8, 0x39, 0x00, 0x03, 0x28, 0xF7, 0xD1, 0xF2, 0xE7, 0x40, 0x8F, 0x43, 0xF2, 0x06, 0x31, 0x08, 0x42, 0xF1, 0xD0, 0xEC, 0xE7, 0x90, 0xF8, 0x60, 0x00, 0x06, 0xE0, 0x40, 0x6A, 0xE4, 0xE7, 0x90, 0xF8, 0x65, 0x00, 0x01, 0xE0, 0x90, 0xF8, 0x59, 0x00, 0x01, 0x28, 0xE4, 0xD1, 0xDF, 0xE7, 0x03, 0x01, 0x16, 0xF8, 0x4D, 0x0D, 0x00, 0x10, 0xB5, 0x85, 0xF7, 0x71, 0xF9, 0x51, 0xF7, 0xAF, 0xF8, 0xBD, 0xE8, 0x10, 0x40, 0x47, 0xF7, 0xAB, 0xBA, 0x03, 0x01, 0x3E, 0x0A, 0x4E, 0x0D, 0x00, 0x10, 0xB5, 0x0C, 0x4C, 0x20, 0x78, 0x10, 0xB1, 0x01, 0x20, 0x47, 0xF7, 0x4D, 0xFC, 0x00, 0x20, 0x20, 0x70, 0x10, 0xBD, 0x4C, 0xFC, 0xFF, 0x2C, 0x84, 0x21, 0x00, 0x00, 0x00, 0x0C, 0x08, 0x20, 0x00, 0x68, 0x01, 0x60, 0x00, 0x14, 0x08, 0x20, 0x00, 0x14, 0x0C, 0x21, 0x00, 0x08, 0x08, 0x20, 0x00, 0x10, 0x08, 0x20, 0x00, 0x00, 0x3F, 0x20, 0x00, 0x64, 0x08, 0x64, 0x00, 0x10, 0x61, 0x0D, 0x00, 0x03, 0x01, 0x16, 0x44, 0x4E, 0x0D, 0x00, 0x10, 0xB5, 0xC8, 0x4A, 0xC8, 0x49, 0xC9, 0x48, 0x50, 0xF7, 0x6E, 0xFF, 0xC8, 0x49, 0x08, 0x70, 0x10, 0xBD, 0x03, 0x01, 0x16, 0x56, 0x4E, 0x0D, 0x00, 0xC5, 0x49, 0xC7, 0x48, 0xDC, 0x39, 0xC8, 0x60, 0xC7, 0x49, 0x00, 0xF5, 0x98, 0x60, 0x08, 0x60, 0x70, 0x47, 0x03, 0x01, 0x2C, 0x68, 0x4E, 0x0D, 0x00, 0xC5, 0x4A, 0xC6, 0x4B, 0x01, 0x28, 0x03, 0xD0, 0x02, 0x28, 0x09, 0xD1, 0x18, 0x88, 0x06, 0xE0, 0x10, 0x68, 0x18, 0x80, 0x48, 0x78, 0x01, 0x28, 0x03, 0xD0, 0x43, 0xF6, 0x02, 0x10, 0x10, 0x60, 0x70, 0x47, 0x43, 0xF6, 0x0E, 0x10, 0xFA, 0xE7, 0x03, 0x01, 0x48, 0x90, 0x4E, 0x0D, 0x00, 0x10, 0xB5, 0xBB, 0x4A, 0xBC, 0x4C, 0x08, 0x32, 0x40, 0xF6, 0xA2, 0x63, 0x01, 0x28, 0x03, 0xD0, 0x02, 0x28, 0x12, 0xD1, 0x20, 0x88, 0x0F, 0xE0, 0x10, 0x68, 0x80, 0xB2, 0x20, 0x80, 0x49, 0x78, 0x01, 0x29, 0x0B, 0xD0, 0xAD, 0x49, 0xDC, 0x39, 0xC9, 0x88, 0xC1, 0xF5, 0x80, 0x51, 0x89, 0xB2, 0x61, 0xF3, 0x1F, 0x10, 0x40, 0xF0, 0x08, 0x00, 0x10, 0x60, 0x10, 0xBD, 0x10, 0x68, 0x63, 0xF3, 0x1F, 0x10, 0xF7, 0xE7, 0x03, 0x01, 0x70, 0xD4, 0x4E, 0x0D, 0x00, 0x70, 0xB5, 0xA4, 0x4A, 0xA4, 0x4B, 0xA9, 0x4C, 0x12, 0x78, 0xDC, 0x3B, 0x02, 0xEB, 0x82, 0x02, 0x03, 0xEB, 0xC2, 0x02, 0xA8, 0x4D, 0x52, 0x7D, 0x94, 0x3C, 0xA8, 0x4E, 0x4F, 0xF4, 0xC0, 0x03, 0x01, 0x28, 0x4C, 0xFC, 0xFF, 0x27, 0x85, 0x21, 0x00, 0x09, 0xD0, 0x02, 0x28, 0x06, 0xD1, 0x48, 0x78, 0x01, 0x28, 0x1A, 0xD0, 0x30, 0x88, 0x20, 0x60, 0x01, 0x20, 0x58, 0x60, 0x70, 0xBD, 0x20, 0x68, 0x80, 0xB2, 0x30, 0x80, 0xD3, 0xF8, 0x04, 0x61, 0x2E, 0x60, 0x49, 0x78, 0x01, 0x29, 0x09, 0xD0, 0x48, 0xF2, 0xFF, 0x01, 0x08, 0x40, 0x02, 0xF0, 0x7F, 0x01, 0x40, 0xEA, 0x01, 0x20, 0x20, 0x60, 0x00, 0x20, 0x58, 0x60, 0xC3, 0xF8, 0x04, 0x21, 0x70, 0xBD, 0x28, 0x68, 0xC3, 0xF8, 0x04, 0x01, 0x70, 0xBD, 0x03, 0x01, 0x3C, 0x40, 0x4F, 0x0D, 0x00, 0x10, 0xB5, 0x94, 0x49, 0x94, 0x4B, 0x95, 0x4A, 0x95, 0x4C, 0x01, 0x28, 0x06, 0xD0, 0x02, 0x28, 0x03, 0xD1, 0x18, 0x68, 0x08, 0x60, 0x20, 0x68, 0x10, 0x60, 0x10, 0xBD, 0x08, 0x68, 0x18, 0x60, 0x10, 0x68, 0x20, 0x60, 0x08, 0x68, 0x20, 0xF0, 0x3F, 0x00, 0x40, 0xF0, 0x48, 0x00, 0x08, 0x60, 0x10, 0x68, 0x20, 0xF0, 0x02, 0x00, 0xEF, 0xE7, 0x03, 0x01, 0x24, 0x78, 0x4F, 0x0D, 0x00, 0x8A, 0x4A, 0x4F, 0xF4, 0xC0, 0x01, 0x01, 0x28, 0x04, 0xD0, 0x02, 0x28, 0x01, 0xD1, 0x10, 0x68, 0x88, 0x61, 0x70, 0x47, 0x88, 0x69, 0x10, 0x60, 0x88, 0x69, 0x20, 0xF0, 0x02, 0x00, 0xF7, 0xE7, 0x03, 0x01, 0x46, 0x98, 0x4F, 0x0D, 0x00, 0x4F, 0xF4, 0xC0, 0x02, 0x01, 0x28, 0x06, 0xD0, 0x02, 0x28, 0x14, 0xD1, 0xD2, 0xF8, 0xFC, 0x02, 0x20, 0xF0, 0x0C, 0x00, 0x0D, 0xE0, 0x48, 0x78, 0x01, 0x28, 0x0D, 0xD0, 0x00, 0x28, 0x0A, 0xD1, 0x88, 0x78, 0x01, 0x28, 0x08, 0xD0, 0xD2, 0xF8, 0xFC, 0x02, 0x20, 0xF0, 0x0C, 0x00, 0x40, 0xF0, 0x08, 0x00, 0xC2, 0xF8, 0xFC, 0x02, 0x70, 0x47, 0xD2, 0xF8, 0xFC, 0x02, 0x40, 0xF0, 0x0C, 0x00, 0xF7, 0xE7, 0x03, 0x01, 0x4C, 0xFC, 0xFF, 0x22, 0x86, 0x21, 0x00, 0x30, 0xDA, 0x4F, 0x0D, 0x00, 0x69, 0x4A, 0x72, 0x4B, 0x18, 0x32, 0x01, 0x28, 0x03, 0xD0, 0x02, 0x28, 0x0A, 0xD1, 0x18, 0x68, 0x07, 0xE0, 0x10, 0x68, 0x18, 0x60, 0x48, 0x78, 0x01, 0x28, 0x10, 0x68, 0x03, 0xD0, 0x40, 0xF4, 0x80, 0x40, 0x10, 0x60, 0x70, 0x47, 0x20, 0xF4, 0x80, 0x40, 0xFA, 0xE7, 0x03, 0x01, 0x30, 0x06, 0x50, 0x0D, 0x00, 0x69, 0x4B, 0x69, 0x4A, 0x01, 0x28, 0x03, 0xD0, 0x02, 0x28, 0x0A, 0xD1, 0x18, 0x68, 0x07, 0xE0, 0x10, 0x68, 0x18, 0x60, 0x48, 0x78, 0x01, 0x28, 0x10, 0x68, 0x03, 0xD0, 0x40, 0xF4, 0x80, 0x60, 0x10, 0x60, 0x70, 0x47, 0x4F, 0xF6, 0xFF, 0x31, 0x08, 0x40, 0xF9, 0xE7, 0x03, 0x01, 0x24, 0x32, 0x50, 0x0D, 0x00, 0x5A, 0x49, 0x5F, 0x4A, 0x1C, 0x39, 0x01, 0x28, 0x04, 0xD0, 0x02, 0x28, 0x01, 0xD1, 0x10, 0x68, 0x08, 0x60, 0x70, 0x47, 0x08, 0x68, 0x10, 0x60, 0x08, 0x68, 0x00, 0xF0, 0x03, 0x00, 0xF7, 0xE7, 0x03, 0x01, 0x98, 0x01, 0x52, 0x50, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x58, 0x4F, 0x55, 0x4E, 0x01, 0x28, 0x18, 0xD0, 0x02, 0x28, 0x14, 0xD1, 0x30, 0x68, 0x39, 0x68, 0x20, 0xF4, 0x00, 0x70, 0x21, 0xF4, 0x00, 0x51, 0x40, 0xF4, 0x80, 0x74, 0x41, 0xF4, 0x80, 0x45, 0x34, 0x60, 0x3D, 0x60, 0x32, 0x20, 0x6F, 0xF7, 0xBB, 0xFF, 0x24, 0xF4, 0x80, 0x70, 0x25, 0xF4, 0x80, 0x41, 0x30, 0x60, 0x39, 0x60, 0xBD, 0xE8, 0xF0, 0x81, 0x48, 0x78, 0x01, 0x28, 0x16, 0xD0, 0x30, 0x68, 0x39, 0x68, 0x20, 0xF4, 0x00, 0x70, 0x40, 0xF4, 0x80, 0x70, 0x21, 0xF4, 0x00, 0x51, 0x41, 0xF4, 0x80, 0x41, 0x30, 0x60, 0x39, 0x60, 0x40, 0xF4, 0x00, 0x70, 0x41, 0xF4, 0x00, 0x51, 0x30, 0x60, 0x39, 0x60, 0x4C, 0xFC, 0xFF, 0x1D, 0x87, 0x21, 0x00, 0xBD, 0xE8, 0xF0, 0x41, 0xC8, 0x20, 0x6F, 0xF7, 0x99, 0xBF, 0x4F, 0xF4, 0x80, 0x40, 0x38, 0x60, 0x30, 0x68, 0x4F, 0xF6, 0xFF, 0x41, 0x08, 0x40, 0x30, 0x60, 0x4F, 0xF4, 0xC0, 0x40, 0x38, 0x60, 0x30, 0x68, 0x80, 0xB2, 0x40, 0xF4, 0x40, 0x70, 0x30, 0x60, 0xD2, 0xE7, 0x03, 0x01, 0x5C, 0xE6, 0x50, 0x0D, 0x00, 0x30, 0xB5, 0x25, 0x4A, 0x25, 0x4B, 0x33, 0x4D, 0x34, 0x4C, 0x7C, 0x3A, 0x60, 0x33, 0x01, 0x28, 0x09, 0xD0, 0x02, 0x28, 0x06, 0xD1, 0x48, 0x78, 0x01, 0x28, 0x03, 0xD1, 0x28, 0x68, 0x10, 0x60, 0x20, 0x68, 0x18, 0x60, 0x30, 0xBD, 0x10, 0x68, 0x28, 0x60, 0x18, 0x68, 0x20, 0x60, 0x48, 0x78, 0x01, 0x28, 0xF7, 0xD1, 0x13, 0x48, 0x13, 0x4C, 0xC9, 0x78, 0x00, 0x78, 0xDC, 0x3C, 0x00, 0xEB, 0x80, 0x00, 0x04, 0xEB, 0xC0, 0x00, 0x29, 0xB1, 0x01, 0x29, 0x03, 0xD0, 0x80, 0x8C, 0x10, 0x60, 0x00, 0x20, 0xE6, 0xE7, 0xC0, 0x8A, 0xFA, 0xE7, 0x03, 0x01, 0x8E, 0x01, 0x3E, 0x51, 0x0D, 0x00, 0x1E, 0x4A, 0x20, 0x4B, 0x74, 0x3A, 0x01, 0x28, 0x03, 0xD0, 0x02, 0x28, 0x09, 0xD1, 0x18, 0x88, 0x06, 0xE0, 0x10, 0x68, 0x18, 0x80, 0x48, 0x78, 0x01, 0x28, 0x03, 0xD0, 0x4F, 0xF4, 0x00, 0x60, 0x10, 0x60, 0x70, 0x47, 0x25, 0x20, 0xFB, 0xE7, 0x00, 0x00, 0xA0, 0x1E, 0x20, 0x00, 0x2C, 0x11, 0x20, 0x00, 0xC4, 0x63, 0x0D, 0x00, 0xB4, 0x2B, 0x20, 0x00, 0x14, 0x61, 0x0D, 0x00, 0xBC, 0x2B, 0x20, 0x00, 0xAC, 0x06, 0x41, 0x00, 0x28, 0x10, 0x20, 0x00, 0x26, 0x10, 0x20, 0x00, 0x2C, 0x10, 0x20, 0x00, 0x24, 0x10, 0x20, 0x00, 0xDC, 0x04, 0x60, 0x00, 0x44, 0x10, 0x20, 0x00, 0x64, 0x06, 0x60, 0x00, 0x48, 0x10, 0x20, 0x00, 0x30, 0x10, 0x4C, 0xFC, 0xFF, 0x18, 0x88, 0x21, 0x00, 0x20, 0x00, 0x34, 0x10, 0x20, 0x00, 0x38, 0x10, 0x20, 0x00, 0xE8, 0x07, 0x41, 0x00, 0x4C, 0x10, 0x20, 0x00, 0xFC, 0x04, 0x41, 0x00, 0x3C, 0x10, 0x20, 0x00, 0x40, 0x10, 0x20, 0x00, 0x2A, 0x10, 0x20, 0x00, 0x03, 0x01, 0xB8, 0x01, 0xC8, 0x51, 0x0D, 0x00, 0x02, 0x46, 0x30, 0xB4, 0x00, 0x20, 0x11, 0x2A, 0x52, 0xD2, 0xDF, 0xE8, 0x02, 0xF0, 0x09, 0x4A, 0x47, 0x3E, 0x3B, 0x29, 0x0C, 0x45, 0x0F, 0x45, 0x47, 0x3B, 0x4A, 0x4A, 0x29, 0x29, 0x4E, 0x00, 0x30, 0xBC, 0x58, 0xF7, 0x76, 0xB8, 0x30, 0xBC, 0x57, 0xF7, 0xA9, 0xBF, 0x3B, 0x4A, 0x13, 0x68, 0x6F, 0xF3, 0x0F, 0x03, 0x42, 0xF8, 0x90, 0x39, 0x39, 0x4C, 0x3A, 0x4B, 0x05, 0x29, 0x0F, 0xD2, 0xDF, 0xE8, 0x01, 0xF0, 0x10, 0x03, 0x10, 0x16, 0x10, 0x00, 0x02, 0xF1, 0x7C, 0x02, 0x51, 0x69, 0x48, 0xF6, 0x88, 0x03, 0x41, 0xEA, 0x03, 0x01, 0x51, 0x61, 0x4F, 0xF0, 0xBB, 0x31, 0x11, 0x60, 0x30, 0xBC, 0x70, 0x47, 0x19, 0x68, 0x09, 0xB1, 0xD1, 0x67, 0xF9, 0xE7, 0x61, 0x68, 0xFB, 0xE7, 0x52, 0xF8, 0x7C, 0x1F, 0x19, 0x60, 0xA1, 0x68, 0x11, 0x60, 0x51, 0x69, 0x63, 0x88, 0x19, 0x43, 0x51, 0x61, 0xED, 0xE7, 0x30, 0xBC, 0x57, 0xF7, 0x8C, 0xBF, 0x11, 0xB1, 0x30, 0xBC, 0x57, 0xF7, 0xBC, 0xBF, 0x30, 0xBC, 0x57, 0xF7, 0xD9, 0xBF, 0x02, 0x20, 0xE1, 0xE7, 0x30, 0xBC, 0x57, 0xF7, 0x8D, 0xBF, 0x30, 0xBC, 0x08, 0x46, 0x57, 0xF7, 0xF0, 0xBF, 0x30, 0xBC, 0x57, 0xF7, 0x9F, 0xBF, 0x01, 0x20, 0xD5, 0xE7, 0x03, 0x01, 0x7C, 0x7C, 0x52, 0x0D, 0x00, 0x1C, 0x49, 0x45, 0x20, 0x08, 0x60, 0x19, 0x48, 0x01, 0x78, 0x4F, 0xF4, 0x48, 0x10, 0xA9, 0xB1, 0x00, 0xF1, 0x90, 0x00, 0xD0, 0xF8, 0x4C, 0xFC, 0xFF, 0x13, 0x89, 0x21, 0x00, 0xA4, 0x10, 0x21, 0xF4, 0x7C, 0x51, 0x41, 0xF4, 0xF8, 0x51, 0xC0, 0xF8, 0xA4, 0x10, 0x01, 0x68, 0x21, 0xF4, 0x70, 0x21, 0x41, 0xF4, 0x00, 0x21, 0x01, 0x60, 0x41, 0x6D, 0x21, 0xF0, 0x01, 0x01, 0x41, 0x65, 0xA0, 0xF1, 0x90, 0x00, 0x00, 0xF1, 0x90, 0x00, 0xD0, 0xF8, 0xA4, 0x10, 0x21, 0xF0, 0x3F, 0x01, 0x41, 0xF0, 0x1F, 0x01, 0xC0, 0xF8, 0xA4, 0x10, 0x01, 0x68, 0x21, 0xF0, 0x70, 0x61, 0x41, 0xF0, 0x00, 0x61, 0x01, 0x60, 0x41, 0x6D, 0x21, 0xF4, 0x80, 0x31, 0x41, 0x65, 0x70, 0x47, 0x00, 0x00, 0x90, 0x00, 0x32, 0x00, 0x1C, 0x0C, 0x21, 0x00, 0xF4, 0x65, 0x0D, 0x00, 0x00, 0x84, 0x31, 0x00, 0x03, 0x01, 0xA8, 0x02, 0xF4, 0x52, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x03, 0x00, 0x02, 0xD0, 0x3C, 0x4C, 0x06, 0x22, 0x02, 0xE0, 0x3B, 0x4C, 0x28, 0x3C, 0x14, 0x22, 0x94, 0xF9, 0x00, 0x00, 0x00, 0x25, 0x88, 0x42, 0x1D, 0xDD, 0x2B, 0xB9, 0x94, 0xF9, 0x0A, 0x00, 0x88, 0x42, 0x01, 0xDB, 0x05, 0x25, 0x16, 0xE0, 0x04, 0xEB, 0x42, 0x00, 0x10, 0xF9, 0x02, 0x0C, 0x88, 0x42, 0x02, 0xDB, 0x52, 0x1E, 0xD5, 0xB2, 0x0D, 0xE0, 0x01, 0x20, 0x09, 0xE0, 0x04, 0xEB, 0x40, 0x06, 0x96, 0xF9, 0x00, 0x60, 0x8E, 0x42, 0x01, 0xDC, 0x05, 0x46, 0x03, 0xE0, 0x40, 0x1C, 0xC0, 0xB2, 0x90, 0x42, 0xF3, 0xD3, 0x04, 0xEB, 0x45, 0x00, 0x90, 0xF9, 0x00, 0x70, 0x1B, 0xB1, 0x26, 0x49, 0x40, 0x78, 0x08, 0x60, 0x3C, 0xE0, 0x25, 0x49, 0x26, 0x4E, 0x89, 0x79, 0x8F, 0x42, 0x01, 0xDD, 0x01, 0x20, 0x00, 0xE0, 0x00, 0x20, 0x70, 0x70, 0x81, 0xF7, 0x7F, 0xFA, 0x30, 0x70, 0x08, 0x20, 0xF0, 0x70, 0xDF, 0xF8, 0x70, 0xC0, 0xB0, 0x70, 0x00, 0x20, 0x0C, 0x4C, 0xFC, 0xFF, 0x0E, 0x8A, 0x21, 0x00, 0xF1, 0x0C, 0x0C, 0x05, 0xEB, 0x40, 0x01, 0x04, 0xEB, 0x41, 0x03, 0x06, 0xEB, 0x40, 0x01, 0x1A, 0x78, 0x0A, 0x75, 0x0A, 0x71, 0x48, 0x75, 0x48, 0x71, 0x5C, 0xF8, 0x20, 0x20, 0x59, 0x78, 0x11, 0x60, 0x01, 0x28, 0x04, 0xD0, 0x02, 0x28, 0x09, 0xD0, 0x03, 0x28, 0x0E, 0xD1, 0x15, 0xE0, 0xDC, 0xF8, 0x04, 0x10, 0x09, 0x68, 0x11, 0x4A, 0x11, 0x60, 0x11, 0x4A, 0x05, 0xE0, 0xDC, 0xF8, 0x08, 0x10, 0x09, 0x68, 0x0F, 0x4A, 0x11, 0x60, 0x0F, 0x4A, 0x11, 0x60, 0x40, 0x1C, 0xB1, 0x78, 0xC0, 0xB2, 0x81, 0x42, 0xD6, 0xD8, 0x38, 0x46, 0xBD, 0xE8, 0xF0, 0x81, 0xDC, 0xF8, 0x0C, 0x10, 0x09, 0x68, 0x0A, 0x4A, 0x11, 0x60, 0x0A, 0x4A, 0xEF, 0xE7, 0x00, 0x00, 0x20, 0x66, 0x0D, 0x00, 0x9C, 0x01, 0x60, 0x00, 0x4B, 0x1E, 0x20, 0x00, 0x94, 0x17, 0x20, 0x00, 0x0C, 0x08, 0x20, 0x00, 0x08, 0x08, 0x20, 0x00, 0x14, 0x08, 0x20, 0x00, 0x10, 0x08, 0x20, 0x00, 0x18, 0x0C, 0x21, 0x00, 0x14, 0x0C, 0x21, 0x00, 0x03, 0x01, 0x30, 0x18, 0x54, 0x0D, 0x00, 0x70, 0xB5, 0xC1, 0x17, 0x00, 0xEB, 0xD1, 0x61, 0x4C, 0x11, 0x21, 0xF0, 0x1F, 0x01, 0x45, 0x1A, 0x70, 0xF7, 0x17, 0xF8, 0x4F, 0xF0, 0xE0, 0x22, 0x01, 0x21, 0x02, 0xEB, 0x84, 0x02, 0xA9, 0x40, 0xC2, 0xF8, 0x80, 0x11, 0xBD, 0xE8, 0x70, 0x40, 0x70, 0xF7, 0x0F, 0xB8, 0x03, 0x01, 0x5E, 0x44, 0x54, 0x0D, 0x00, 0x64, 0x4B, 0x30, 0xB5, 0x18, 0x44, 0x83, 0x07, 0x0A, 0xD5, 0x50, 0xF8, 0x02, 0x3C, 0x89, 0x1E, 0x1B, 0x0C, 0x80, 0x1C, 0x13, 0x70, 0x1B, 0x0A, 0x53, 0x70, 0x89, 0xB2, 0x02, 0xF1, 0x02, 0x02, 0x4F, 0xEA, 0x91, 0x04, 0x0D, 0xE0, 0x50, 0xF8, 0x04, 0x3B, 0x13, 0x70, 0x4F, 0xEA, 0x4C, 0xFC, 0xFF, 0x09, 0x8B, 0x21, 0x00, 0x13, 0x25, 0x55, 0x70, 0x4F, 0xEA, 0x13, 0x45, 0x95, 0x70, 0x4F, 0xEA, 0x13, 0x63, 0xD3, 0x70, 0x02, 0xF1, 0x04, 0x02, 0x23, 0x00, 0xA4, 0xF1, 0x01, 0x04, 0xA4, 0xB2, 0xEC, 0xD1, 0x89, 0x07, 0x03, 0xD5, 0x00, 0x68, 0x10, 0x70, 0x00, 0x0A, 0x50, 0x70, 0x30, 0xBD, 0x03, 0x01, 0x7E, 0x9E, 0x54, 0x0D, 0x00, 0x0E, 0xB5, 0x4E, 0x48, 0x00, 0x78, 0x01, 0x28, 0x36, 0xD1, 0x4D, 0x48, 0x00, 0x68, 0x4D, 0x49, 0x00, 0xF0, 0x04, 0x00, 0x09, 0x78, 0x08, 0x43, 0x2E, 0xD1, 0x2F, 0xF7, 0xCC, 0xFF, 0x00, 0x28, 0x2A, 0xD0, 0x6A, 0x46, 0x0A, 0x21, 0x00, 0x20, 0xFF, 0xF7, 0xBD, 0xFF, 0x9D, 0xF8, 0x00, 0x00, 0x50, 0x28, 0x21, 0xD1, 0x9D, 0xF8, 0x01, 0x00, 0x4F, 0x28, 0x1D, 0xD1, 0x9D, 0xF8, 0x02, 0x00, 0x00, 0x28, 0x19, 0xD0, 0x9D, 0xF8, 0x03, 0x00, 0x00, 0x28, 0x15, 0xD0, 0x9D, 0xF8, 0x04, 0x00, 0x78, 0xB9, 0x9D, 0xF8, 0x05, 0x00, 0x60, 0xB9, 0x9D, 0xF8, 0x06, 0x00, 0x48, 0xB9, 0x9D, 0xF8, 0x07, 0x00, 0x30, 0xB9, 0x9D, 0xF8, 0x08, 0x00, 0x18, 0xB9, 0x9D, 0xF8, 0x09, 0x00, 0x00, 0x28, 0x02, 0xD0, 0x01, 0xA8, 0x6D, 0xF7, 0x8B, 0xFF, 0x0E, 0xBD, 0x03, 0x01, 0x58, 0x18, 0x55, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x28, 0x24, 0xD1, 0x33, 0x49, 0x31, 0x48, 0x08, 0x60, 0x33, 0x49, 0x32, 0x48, 0x08, 0x60, 0x34, 0x49, 0x32, 0x48, 0x08, 0x60, 0x0F, 0x20, 0xFF, 0xF7, 0x71, 0xFF, 0x33, 0x49, 0x31, 0x48, 0x08, 0x60, 0x32, 0x49, 0x4F, 0xF0, 0xFF, 0x30, 0x88, 0x60, 0x32, 0x49, 0x31, 0x48, 0x48, 0x60, 0xFF, 0xF7, 0xA8, 0xFF, 0xFB, 0xF7, 0x71, 0xFE, 0x30, 0x49, 0x08, 0x60, 0x21, 0x48, 0x40, 0x78, 0x28, 0xB1, 0x2E, 0x49, 0x01, 0x4C, 0xFC, 0xFF, 0x04, 0x8C, 0x21, 0x00, 0x20, 0x88, 0x60, 0x15, 0x20, 0xA6, 0xF7, 0xF7, 0xFF, 0x00, 0x20, 0x10, 0xBD, 0x03, 0x01, 0x0C, 0x6C, 0x55, 0x0D, 0x00, 0x04, 0x21, 0x08, 0x20, 0x57, 0xF7, 0x08, 0xBF, 0x03, 0x01, 0x0C, 0x74, 0x55, 0x0D, 0x00, 0x03, 0x21, 0x08, 0x20, 0x57, 0xF7, 0x04, 0xBF, 0x03, 0x01, 0xD0, 0x01, 0x7C, 0x55, 0x0D, 0x00, 0x10, 0xB5, 0xAF, 0xF2, 0x67, 0x00, 0x26, 0x49, 0x08, 0x60, 0xFF, 0xF7, 0x66, 0xFC, 0x25, 0x49, 0x1D, 0x20, 0x48, 0x70, 0xAF, 0xF2, 0x1F, 0x01, 0x23, 0x48, 0x41, 0x60, 0xAF, 0xF2, 0x2F, 0x01, 0x81, 0x60, 0x46, 0xF7, 0x03, 0xFA, 0x22, 0x49, 0x20, 0x48, 0x50, 0x22, 0x08, 0x60, 0x22, 0x49, 0x20, 0x48, 0x30, 0x23, 0x08, 0x60, 0x22, 0x48, 0x20, 0x49, 0xC1, 0x67, 0x21, 0x49, 0x81, 0x67, 0x21, 0x48, 0x0C, 0x21, 0x41, 0x80, 0x02, 0x71, 0x05, 0x21, 0x41, 0x71, 0xC3, 0x80, 0x02, 0x72, 0x41, 0x72, 0x25, 0x21, 0x01, 0x73, 0x03, 0x21, 0x41, 0x73, 0x10, 0xBD, 0x7E, 0x11, 0x65, 0x00, 0x28, 0x0C, 0x21, 0x00, 0x80, 0x01, 0x32, 0x00, 0x4E, 0x05, 0x20, 0x00, 0xC5, 0x57, 0x0D, 0x00, 0x88, 0x23, 0x20, 0x00, 0x4D, 0x58, 0x0D, 0x00, 0xC4, 0x23, 0x20, 0x00, 0x51, 0x58, 0x0D, 0x00, 0xFC, 0x25, 0x20, 0x00, 0x51, 0x56, 0x0D, 0x00, 0x54, 0x32, 0x20, 0x00, 0x10, 0x82, 0x20, 0x00, 0x79, 0x36, 0x0D, 0x00, 0xE4, 0x5C, 0x20, 0x00, 0x88, 0x32, 0x20, 0x00, 0x00, 0x90, 0x32, 0x00, 0xB4, 0x39, 0x20, 0x00, 0xB3, 0x32, 0x20, 0x00, 0xBC, 0x78, 0x0D, 0x00, 0x65, 0x41, 0x0D, 0x00, 0xBC, 0x30, 0x20, 0x00, 0xA3, 0x3F, 0x0D, 0x00, 0xC0, 0x30, 0x20, 0x00, 0x45, 0x42, 0x0D, 0x00, 0x18, 0x52, 0x20, 0x00, 0xB1, 0x41, 0x0D, 0x00, 0x4C, 0xFC, 0xFF, 0xFF, 0x8C, 0x21, 0x00, 0x9C, 0x18, 0x20, 0x00, 0x03, 0x01, 0x0C, 0x48, 0x56, 0x0D, 0x00, 0x5B, 0x49, 0x00, 0x7B, 0x08, 0x70, 0x70, 0x47, 0x03, 0x01, 0xF8, 0x02, 0x50, 0x56, 0x0D, 0x00, 0xF0, 0xB4, 0x00, 0x24, 0x59, 0x4E, 0x0C, 0x60, 0xA6, 0xF1, 0x80, 0x04, 0x05, 0x2B, 0x71, 0xD0, 0x06, 0xDC, 0x01, 0x2B, 0x0B, 0xD0, 0x02, 0x2B, 0x6C, 0xD0, 0x03, 0x2B, 0x6A, 0xD1, 0x13, 0xE0, 0x06, 0x2B, 0x67, 0xD0, 0x08, 0x2B, 0x1C, 0xD0, 0x3F, 0x2B, 0x63, 0xD1, 0x3F, 0xE0, 0x09, 0x2A, 0x02, 0xD0, 0x0F, 0x2A, 0x5E, 0xD1, 0x03, 0xE0, 0x34, 0x68, 0x0C, 0x60, 0x74, 0x68, 0x89, 0xE0, 0xB4, 0x68, 0x0C, 0x60, 0xF4, 0x68, 0x85, 0xE0, 0x03, 0x2A, 0x02, 0xD0, 0x3F, 0x2A, 0x51, 0xD1, 0x03, 0xE0, 0x25, 0x68, 0x0D, 0x60, 0x64, 0x68, 0x7C, 0xE0, 0xA5, 0x6C, 0x0D, 0x60, 0xE4, 0x6C, 0x78, 0xE0, 0x12, 0x2A, 0x17, 0xD0, 0x06, 0xDC, 0x0D, 0x2A, 0x18, 0xD0, 0x0E, 0x2A, 0x1A, 0xD0, 0x10, 0x2A, 0x73, 0xD1, 0x0B, 0xE0, 0x17, 0x2A, 0x05, 0xD0, 0x1C, 0x2A, 0x6E, 0xD1, 0xA5, 0x6A, 0x0D, 0x60, 0xE4, 0x6A, 0x66, 0xE0, 0xA5, 0x6B, 0x0D, 0x60, 0xE4, 0x6B, 0x62, 0xE0, 0xA5, 0x6E, 0x0D, 0x60, 0xE4, 0x6E, 0x5E, 0xE0, 0x25, 0x6F, 0x0D, 0x60, 0x64, 0x6F, 0x5A, 0xE0, 0x34, 0x69, 0x0C, 0x60, 0x74, 0x69, 0x56, 0xE0, 0xB4, 0x69, 0x0C, 0x60, 0xF4, 0x69, 0x52, 0xE0, 0x40, 0xF2, 0x3F, 0x17, 0xA2, 0xF2, 0x3F, 0x15, 0xBA, 0x42, 0x41, 0xD0, 0x0E, 0xDC, 0x24, 0x2A, 0x22, 0xD0, 0x06, 0xDC, 0x14, 0x2A, 0x27, 0xD0, 0x19, 0x2A, 0x15, 0xD0, 0x1A, 0x2A, 0x46, 0xD1, 0x16, 0xE0, 0x25, 0x2A, 0x1C, 0xD0, 0x85, 0x2A, 0x41, 0xD1, 0x21, 0xE0, 0x14, 0x2D, 0x23, 0xD0, 0x04, 0xDC, 0x4C, 0xFC, 0xFF, 0xFA, 0x8D, 0x21, 0x00, 0x01, 0x2D, 0x30, 0xD0, 0x02, 0x2D, 0x39, 0xD1, 0x2D, 0xE0, 0x18, 0x2D, 0x1F, 0xD0, 0x8A, 0x2D, 0x34, 0xD1, 0x2C, 0xE0, 0x32, 0xE0, 0xA5, 0x68, 0x0D, 0x60, 0xE4, 0x68, 0x2A, 0xE0, 0x25, 0x69, 0x0D, 0x60, 0x64, 0x69, 0x26, 0xE0, 0xA5, 0x69, 0x0D, 0x60, 0xE4, 0x69, 0x22, 0xE0, 0x25, 0x6A, 0x0D, 0x60, 0x64, 0x6A, 0x1E, 0xE0, 0x25, 0x6B, 0x0D, 0x60, 0x64, 0x6B, 0x1A, 0xE0, 0x25, 0x6C, 0x0D, 0x60, 0x64, 0x6C, 0x16, 0xE0, 0xA5, 0x6D, 0x0D, 0x60, 0xE4, 0x6D, 0x12, 0xE0, 0x10, 0x4D, 0x2D, 0x78, 0x01, 0x2D, 0x12, 0xD1, 0x25, 0x6D, 0x0D, 0x60, 0x64, 0x6D, 0x0A, 0xE0, 0xA5, 0x6F, 0x0D, 0x60, 0xE4, 0x6F, 0x06, 0xE0, 0x25, 0x6E, 0x0D, 0x60, 0x64, 0x6E, 0x02, 0xE0, 0x34, 0x6A, 0x0C, 0x60, 0x74, 0x6A, 0x4C, 0x60, 0x0C, 0x68, 0x00, 0x2C, 0x02, 0xD1, 0xF0, 0xBC, 0x46, 0xF7, 0x39, 0xBC, 0xF0, 0xBC, 0x70, 0x47, 0x00, 0x00, 0x2C, 0x0C, 0x21, 0x00, 0xCC, 0x66, 0x0D, 0x00, 0xD9, 0x0B, 0x21, 0x00, 0x03, 0x01, 0x8C, 0x01, 0xC4, 0x57, 0x0D, 0x00, 0x70, 0xB5, 0x04, 0x46, 0x01, 0x29, 0x02, 0xD0, 0x02, 0x29, 0x2F, 0xD0, 0x30, 0xE0, 0xA4, 0xF5, 0xE0, 0x40, 0x0A, 0x38, 0x21, 0xD1, 0x17, 0x48, 0x81, 0xF7, 0xA7, 0xF9, 0x04, 0x46, 0x16, 0x4D, 0x16, 0x4E, 0x0E, 0xE0, 0x14, 0x49, 0x13, 0x48, 0x81, 0xF7, 0xEA, 0xF8, 0x29, 0x88, 0x0B, 0x29, 0x02, 0xD1, 0x28, 0x79, 0x02, 0x28, 0x08, 0xD0, 0x06, 0xEB, 0x81, 0x00, 0x01, 0x68, 0x0E, 0x48, 0x88, 0x47, 0x64, 0x1E, 0xEE, 0xD2, 0x00, 0x24, 0x12, 0xE0, 0x0B, 0x48, 0x9D, 0xF7, 0x46, 0xFA, 0x0B, 0x49, 0x10, 0x20, 0xFB, 0xF7, 0x84, 0xFA, 0xF3, 0xE7, 0xA4, 0xF5, 0xE0, 0x40, 0x06, 0x4C, 0xFC, 0xFF, 0xF5, 0x8E, 0x21, 0x00, 0x38, 0x06, 0xD0, 0x0E, 0x38, 0x04, 0xD1, 0x07, 0x49, 0x08, 0x70, 0xEC, 0xE7, 0x89, 0xF7, 0xBC, 0xFA, 0x20, 0x46, 0x70, 0xBD, 0x0C, 0x60, 0x20, 0x00, 0xA4, 0x23, 0x20, 0x00, 0x3C, 0x92, 0x08, 0x00, 0x5C, 0xEF, 0x20, 0x00, 0x4C, 0x5E, 0x0D, 0x00, 0x03, 0x01, 0x08, 0x4C, 0x58, 0x0D, 0x00, 0x00, 0x20, 0x70, 0x47, 0x03, 0x01, 0x1C, 0x50, 0x58, 0x0D, 0x00, 0x08, 0x7B, 0x42, 0x08, 0x00, 0x20, 0x7F, 0x2A, 0x03, 0xD0, 0x07, 0x2A, 0x01, 0xD1, 0x01, 0x4A, 0x8A, 0x60, 0x70, 0x47, 0x1D, 0x34, 0x0D, 0x00, 0x03, 0x01, 0x50, 0x68, 0x58, 0x0D, 0x00, 0xF0, 0xB5, 0x11, 0x49, 0x0F, 0x48, 0x0F, 0x4E, 0x48, 0x61, 0x00, 0x20, 0x36, 0x1D, 0x01, 0x27, 0x56, 0xF8, 0x30, 0x30, 0x5A, 0x09, 0x03, 0xF0, 0x1F, 0x05, 0x51, 0xF8, 0x22, 0x40, 0x07, 0xFA, 0x05, 0xF3, 0x1C, 0x43, 0x41, 0xF8, 0x22, 0x40, 0x06, 0xEB, 0xC0, 0x02, 0x4B, 0x69, 0x52, 0x68, 0x03, 0xEB, 0x40, 0x03, 0x42, 0xF0, 0x01, 0x02, 0xC2, 0xF5, 0x58, 0x22, 0x1A, 0x80, 0x40, 0x1C, 0xE6, 0xD0, 0xF0, 0xBD, 0xF4, 0x66, 0x0D, 0x00, 0x6C, 0x9F, 0x20, 0x00, 0x03, 0x01, 0x80, 0x01, 0xB4, 0x58, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0x1A, 0x48, 0x00, 0x68, 0xC0, 0x07, 0x2E, 0xD0, 0x19, 0x48, 0x01, 0x68, 0x41, 0xF0, 0x01, 0x01, 0x01, 0x60, 0x17, 0x4F, 0x7C, 0x3F, 0x38, 0x68, 0x40, 0xF0, 0x80, 0x00, 0x38, 0x60, 0x15, 0x4E, 0x01, 0x20, 0x30, 0x60, 0x45, 0xF7, 0x4E, 0xFB, 0x3D, 0x68, 0x25, 0xF0, 0x80, 0x00, 0x38, 0x60, 0x0F, 0x48, 0x74, 0x38, 0x01, 0x68, 0x41, 0xF0, 0x20, 0x01, 0x01, 0x60, 0x01, 0x68, 0x21, 0xF0, 0x20, 0x01, 0x01, 0x60, 0x00, 0x24, 0x04, 0xE0, 0x30, 0x4C, 0xFC, 0xFF, 0xF0, 0x8F, 0x21, 0x00, 0x20, 0x45, 0xF7, 0xA7, 0xFA, 0x04, 0xF1, 0x01, 0x04, 0x30, 0x68, 0x80, 0x07, 0x01, 0xD4, 0x32, 0x2C, 0xF5, 0xD3, 0x45, 0xF0, 0x80, 0x00, 0x38, 0x60, 0x00, 0x20, 0x30, 0x60, 0xBD, 0xE8, 0xF0, 0x81, 0x00, 0x00, 0x60, 0x18, 0x20, 0x00, 0x7C, 0x08, 0x64, 0x00, 0xB4, 0x04, 0x32, 0x00, 0x03, 0x01, 0x88, 0x01, 0x30, 0x59, 0x0D, 0x00, 0x30, 0xB5, 0x1B, 0x4C, 0x24, 0x78, 0x01, 0x2C, 0x07, 0xD1, 0xB0, 0xF5, 0xE1, 0x3F, 0x07, 0xD0, 0x18, 0x4C, 0x25, 0x68, 0x45, 0xF0, 0x01, 0x05, 0x25, 0x60, 0x17, 0x4C, 0xA0, 0x42, 0x01, 0xD8, 0x16, 0x4C, 0x00, 0xE0, 0x16, 0x4C, 0xB4, 0xFB, 0xF0, 0xF0, 0x10, 0x28, 0x0C, 0xDB, 0xC4, 0x17, 0x00, 0xEB, 0x14, 0x74, 0x25, 0x11, 0x24, 0xF0, 0x0F, 0x04, 0x04, 0x1B, 0x18, 0x68, 0x20, 0xF0, 0x08, 0x00, 0x40, 0xF0, 0x80, 0x00, 0x06, 0xE0, 0x05, 0x46, 0x18, 0x68, 0x00, 0x24, 0x20, 0xF0, 0x80, 0x00, 0x40, 0xF0, 0x08, 0x00, 0x18, 0x60, 0xC5, 0xF5, 0x80, 0x70, 0x10, 0x60, 0x04, 0xEB, 0xD4, 0x70, 0x40, 0x10, 0x22, 0x1A, 0x42, 0xEA, 0x00, 0x10, 0x08, 0x60, 0x30, 0xBD, 0x00, 0x00, 0x2A, 0x0C, 0x21, 0x00, 0x1C, 0x04, 0x36, 0x00, 0x60, 0xE3, 0x16, 0x00, 0x00, 0x36, 0x6E, 0x01, 0x00, 0x6C, 0xDC, 0x02, 0x03, 0x01, 0x32, 0xB4, 0x59, 0x0D, 0x00, 0x70, 0xB5, 0x04, 0x46, 0x00, 0x25, 0x6F, 0xF7, 0x4E, 0xFD, 0x06, 0x46, 0x20, 0x46, 0x6F, 0xF7, 0x22, 0xFE, 0x04, 0x00, 0x06, 0xD0, 0x01, 0x21, 0x6F, 0xF7, 0x05, 0xFE, 0x05, 0x46, 0x20, 0x46, 0x6F, 0xF7, 0xFB, 0xFD, 0x30, 0x46, 0x6F, 0xF7, 0x42, 0xFD, 0x28, 0x46, 0x70, 0xBD, 0x03, 0x01, 0x3E, 0xE2, 0x59, 0x0D, 0x00, 0x70, 0xB5, 0x04, 0x46, 0x4C, 0xFC, 0xFF, 0xEB, 0x90, 0x21, 0x00, 0x00, 0x25, 0x6F, 0xF7, 0x37, 0xFD, 0x06, 0x46, 0x20, 0x46, 0x6F, 0xF7, 0x0B, 0xFE, 0x04, 0x00, 0x07, 0xD0, 0x00, 0x21, 0x6F, 0xF7, 0xEE, 0xFD, 0x05, 0x46, 0x20, 0x46, 0x6F, 0xF7, 0xE4, 0xFD, 0x04, 0xE0, 0xCB, 0x21, 0x4F, 0xF4, 0x00, 0x70, 0x6F, 0xF7, 0xCC, 0xF8, 0x30, 0x46, 0x6F, 0xF7, 0x25, 0xFD, 0x28, 0x46, 0x70, 0xBD, 0x03, 0x01, 0x3E, 0x1C, 0x5A, 0x0D, 0x00, 0x70, 0xB5, 0x05, 0x00, 0x16, 0x48, 0x04, 0x68, 0x16, 0xD0, 0x0C, 0xE0, 0x29, 0x46, 0x20, 0x46, 0x6F, 0xF7, 0xB2, 0xFE, 0x30, 0xB1, 0x44, 0xB1, 0x29, 0x46, 0x20, 0x46, 0xBD, 0xE8, 0x70, 0x40, 0x6F, 0xF7, 0x87, 0xBE, 0x24, 0x68, 0x00, 0x2C, 0xF0, 0xD1, 0xBD, 0xE8, 0x70, 0x40, 0xFE, 0x21, 0x4F, 0xF4, 0x00, 0x70, 0x6F, 0xF7, 0xAB, 0xB8, 0x70, 0xBD, 0x03, 0x01, 0x32, 0x56, 0x5A, 0x0D, 0x00, 0x70, 0xB5, 0x09, 0x4D, 0x01, 0x46, 0x01, 0x24, 0x28, 0x78, 0x50, 0xB1, 0x08, 0x46, 0x6F, 0xF7, 0xD1, 0xFD, 0x28, 0xB1, 0x01, 0x7C, 0x40, 0x7C, 0x2A, 0x78, 0x50, 0x43, 0x81, 0x42, 0x00, 0xD2, 0x00, 0x24, 0x20, 0x46, 0x70, 0xBD, 0x84, 0x05, 0x20, 0x00, 0x2B, 0x0C, 0x21, 0x00, 0x03, 0x01, 0x28, 0x84, 0x5A, 0x0D, 0x00, 0x06, 0x49, 0x00, 0x20, 0x09, 0x68, 0xC9, 0x06, 0x06, 0xD5, 0x05, 0x48, 0x01, 0x68, 0x21, 0xF4, 0x70, 0x31, 0x01, 0x60, 0x4F, 0xF4, 0x70, 0x20, 0x70, 0x47, 0x00, 0x00, 0x00, 0x67, 0x0D, 0x00, 0x58, 0x1E, 0x20, 0x00, 0x03, 0x01, 0x3C, 0xA8, 0x5A, 0x0D, 0x00, 0x70, 0xB5, 0x05, 0x46, 0x0C, 0x46, 0x80, 0x6A, 0x08, 0x21, 0x01, 0xEB, 0x80, 0x00, 0x6F, 0xF7, 0xC1, 0xFD, 0x00, 0x28, 0x0F, 0xD0, 0xAA, 0x6A, 0x00, 0xF1, 0x08, 0x01, 0x02, 0x4C, 0xFC, 0xFF, 0xE6, 0x91, 0x21, 0x00, 0x2A, 0x03, 0xD1, 0x54, 0xF8, 0x04, 0x2B, 0x41, 0xF8, 0x04, 0x2B, 0x22, 0x68, 0x0A, 0x60, 0x01, 0x46, 0x28, 0x46, 0x7D, 0xF7, 0x77, 0xF9, 0x01, 0x20, 0x70, 0xBD, 0x03, 0x01, 0x70, 0xE0, 0x5A, 0x0D, 0x00, 0x70, 0xB5, 0x16, 0x4C, 0xA0, 0x78, 0x00, 0x28, 0x26, 0xD0, 0x6F, 0xF7, 0xA1, 0xFA, 0x01, 0x46, 0x13, 0x48, 0x00, 0x68, 0x2D, 0xF7, 0xB4, 0xF9, 0xA1, 0x78, 0x40, 0xF6, 0x35, 0x42, 0x51, 0x43, 0xC0, 0xEB, 0x81, 0x04, 0x6F, 0xF7, 0xA9, 0xFC, 0x0E, 0x4D, 0x06, 0x46, 0x28, 0x78, 0xC0, 0x06, 0x0D, 0xD5, 0x00, 0x2C, 0x0B, 0xDC, 0x2D, 0xF7, 0xE8, 0xF9, 0x20, 0xB9, 0x0A, 0x48, 0x01, 0x68, 0x21, 0xF0, 0x20, 0x01, 0x01, 0x60, 0x28, 0x78, 0x20, 0xF0, 0x10, 0x00, 0x28, 0x70, 0x30, 0x46, 0xBD, 0xE8, 0x70, 0x40, 0x6F, 0xF7, 0x95, 0xBC, 0x70, 0xBD, 0x00, 0x00, 0xC4, 0x18, 0x20, 0x00, 0x04, 0x67, 0x0D, 0x00, 0x16, 0x1D, 0x20, 0x00, 0x20, 0x04, 0x36, 0x00, 0x03, 0x01, 0x58, 0x4C, 0x5B, 0x0D, 0x00, 0xD0, 0xF8, 0xD8, 0x20, 0x04, 0x46, 0x00, 0x21, 0x90, 0x47, 0x42, 0x4E, 0xDF, 0xF8, 0x08, 0x81, 0xDF, 0xF8, 0x08, 0x91, 0x04, 0xF1, 0xB0, 0x0A, 0x50, 0x46, 0x7D, 0xF7, 0x92, 0xF9, 0x05, 0x46, 0x70, 0x79, 0x88, 0xB1, 0xB0, 0x78, 0x78, 0xB1, 0x6F, 0xF7, 0x71, 0xFC, 0x98, 0xF8, 0x00, 0x10, 0x07, 0x46, 0x41, 0xF0, 0x10, 0x01, 0x88, 0xF8, 0x00, 0x10, 0x6F, 0xF7, 0x53, 0xFA, 0xC9, 0xF8, 0x00, 0x00, 0x38, 0x46, 0x6F, 0xF7, 0x67, 0xFC, 0xD4, 0xF8, 0xD8, 0x20, 0x29, 0x46, 0x20, 0x46, 0x90, 0x47, 0xE1, 0xE7, 0x03, 0x01, 0x18, 0xA0, 0x5B, 0x0D, 0x00, 0x2F, 0x48, 0x10, 0xB5, 0x40, 0x79, 0x18, 0xB1, 0x2D, 0xF7, 0x9F, 0x4C, 0xFC, 0xFF, 0xE1, 0x92, 0x21, 0x00, 0xF9, 0x00, 0x28, 0x00, 0xD0, 0x01, 0x20, 0x10, 0xBD, 0x03, 0x01, 0xC0, 0x01, 0xB4, 0x5B, 0x0D, 0x00, 0x2D, 0xE9, 0xF0, 0x41, 0xDF, 0xF8, 0xB0, 0x80, 0x0E, 0x46, 0x98, 0xF8, 0x00, 0x00, 0xE0, 0xB3, 0xE6, 0xB3, 0xC0, 0x07, 0x3D, 0xD0, 0x71, 0x68, 0x06, 0xF1, 0x08, 0x00, 0xA1, 0xF5, 0xE0, 0x42, 0x84, 0x3A, 0x0F, 0xD1, 0x45, 0x88, 0x04, 0x46, 0x05, 0xF1, 0x09, 0x00, 0x6F, 0xF7, 0x2C, 0xFD, 0x07, 0x46, 0x2A, 0x46, 0x21, 0x1D, 0x09, 0x30, 0x6F, 0xF7, 0x1A, 0xFE, 0x3C, 0x46, 0x47, 0xF2, 0x3F, 0x00, 0x1D, 0xE0, 0xA1, 0xF5, 0xE0, 0x42, 0x41, 0x3A, 0x22, 0xD1, 0x05, 0x46, 0xFD, 0xF7, 0x16, 0xFD, 0x07, 0x00, 0x1D, 0xD0, 0x28, 0x78, 0x13, 0x28, 0x1A, 0xD0, 0x68, 0x78, 0x00, 0x1D, 0x3F, 0xF7, 0xAF, 0xFA, 0x69, 0x78, 0xA0, 0xF1, 0x08, 0x04, 0x89, 0x1C, 0x41, 0x80, 0x20, 0xF8, 0x04, 0x7B, 0x6A, 0x78, 0x29, 0x46, 0x92, 0x1C, 0x6F, 0xF7, 0xFA, 0xFD, 0x47, 0xF2, 0x82, 0x00, 0x60, 0x60, 0x55, 0xF7, 0x0D, 0xFE, 0x21, 0x46, 0x01, 0xE0, 0x0C, 0xE0, 0x01, 0xE0, 0x2D, 0xF7, 0x8C, 0xFA, 0x98, 0xF8, 0x00, 0x00, 0x40, 0x07, 0x05, 0xD5, 0x30, 0x46, 0x6F, 0xF7, 0xAD, 0xFD, 0x00, 0x20, 0xBD, 0xE8, 0xF0, 0x81, 0x01, 0x20, 0xFB, 0xE7, 0x00, 0x00, 0xC4, 0x18, 0x20, 0x00, 0x16, 0x1D, 0x20, 0x00, 0x04, 0x67, 0x0D, 0x00, 0x2C, 0x0C, 0x21, 0x00, 0x03, 0x01, 0x3A, 0x70, 0x5C, 0x0D, 0x00, 0x1D, 0x49, 0x30, 0xB4, 0x0A, 0x68, 0x6A, 0xB1, 0x01, 0x46, 0xA1, 0xFB, 0x02, 0x05, 0x00, 0x23, 0x03, 0xFB, 0x02, 0x52, 0x01, 0xFB, 0x03, 0x21, 0x18, 0x4A, 0x19, 0x4B, 0x12, 0x68, 0x1B, 0x78, 0x5A, 0x43, 0x04, 0xE0, 0x40, 0xF6, 0xEB, 0x4C, 0xFC, 0xFF, 0xDC, 0x93, 0x21, 0x00, 0x31, 0xA0, 0xFB, 0x01, 0x01, 0x64, 0x22, 0x30, 0xBC, 0x00, 0x23, 0x55, 0xF7, 0xED, 0xBB, 0x03, 0x01, 0x52, 0xA6, 0x5C, 0x0D, 0x00, 0xF0, 0xB4, 0x0F, 0x4A, 0x12, 0x68, 0x6A, 0xB1, 0x0F, 0x4B, 0x1C, 0x68, 0x0F, 0x4B, 0x1B, 0x78, 0x5C, 0x43, 0x03, 0x46, 0xA4, 0xFB, 0x03, 0x06, 0x00, 0x25, 0x05, 0xFB, 0x03, 0x63, 0x04, 0xFB, 0x01, 0x31, 0x0A, 0xE0, 0x64, 0x22, 0x03, 0x46, 0xA3, 0xFB, 0x02, 0x05, 0x01, 0xFB, 0x02, 0x51, 0x00, 0x24, 0x03, 0xFB, 0x04, 0x11, 0x40, 0xF6, 0xEB, 0x32, 0xF0, 0xBC, 0x00, 0x23, 0x55, 0xF7, 0xCC, 0xBB, 0xE4, 0x18, 0x20, 0x00, 0xE0, 0x18, 0x20, 0x00, 0xD9, 0x18, 0x20, 0x00, 0x03, 0x01, 0x50, 0xF4, 0x5C, 0x0D, 0x00, 0x10, 0xB5, 0x04, 0x46, 0x45, 0xF7, 0xBC, 0xFA, 0x0C, 0x49, 0x02, 0x28, 0x08, 0x70, 0x22, 0x6A, 0x11, 0xD0, 0x4F, 0xF4, 0x80, 0x71, 0x0A, 0x43, 0x22, 0x62, 0x09, 0x49, 0x09, 0x4A, 0x09, 0x68, 0x12, 0x78, 0x51, 0x43, 0x40, 0xF6, 0xEB, 0x32, 0x51, 0x43, 0x64, 0x22, 0xB1, 0xFB, 0xF2, 0xF1, 0x05, 0x4A, 0x11, 0x60, 0x10, 0xBD, 0x80, 0x21, 0xED, 0xE7, 0x00, 0x00, 0x88, 0x19, 0x20, 0x00, 0xE0, 0x18, 0x20, 0x00, 0xD9, 0x18, 0x20, 0x00, 0xE4, 0x18, 0x20, 0x00, 0x10, 0x01, 0x0F, 0x00, 0x24, 0xC6, 0x02, 0x00, 0xA4, 0xF0, 0xFE, 0xB8, 0x00, 0x00, 0x24, 0x08, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x01, 0x78, 0xCC, 0x02, 0x00, 0xA3, 0xF0, 0xC2, 0xBA, 0x00, 0x00, 0x00, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x02, 0x28, 0xDB, 0x03, 0x00, 0x92, 0xF0, 0x74, 0xBB, 0x00, 0x00, 0x14, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x03, 0x54, 0xDC, 0x03, 0x00, 0x92, 0xF0, 0xE6, 0xBA, 0x00, 0x00, 0x4C, 0xFC, 0xFF, 0xD7, 0x94, 0x21, 0x00, 0x24, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x04, 0x50, 0xCC, 0x03, 0x00, 0x93, 0xF0, 0xF0, 0xBA, 0x00, 0x00, 0x34, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x05, 0xDC, 0xD2, 0x03, 0x00, 0x92, 0xF0, 0xB4, 0xBF, 0x00, 0x00, 0x48, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x06, 0x2C, 0xCF, 0x03, 0x00, 0x93, 0xF0, 0x94, 0xB9, 0x00, 0x00, 0x58, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x07, 0x24, 0xB6, 0x03, 0x00, 0x94, 0xF0, 0x24, 0xBE, 0x00, 0x00, 0x70, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x08, 0x70, 0x1B, 0x08, 0x00, 0x4E, 0xF0, 0x84, 0xBB, 0x00, 0x00, 0x7C, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x09, 0x54, 0x85, 0x01, 0x00, 0xB8, 0xF0, 0x8A, 0xBA, 0x00, 0x00, 0x6C, 0x0A, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x0A, 0xBC, 0x92, 0x07, 0x00, 0x56, 0xF0, 0xEC, 0xBF, 0x00, 0x00, 0x98, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x0B, 0x04, 0x89, 0x07, 0x00, 0x57, 0xF0, 0xCD, 0xBC, 0x00, 0x00, 0xA2, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x0C, 0xBC, 0x84, 0x07, 0x00, 0x57, 0xF0, 0xF7, 0xBE, 0x00, 0x00, 0xAE, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x0D, 0xC0, 0x37, 0x08, 0x00, 0x70, 0xBD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x0F, 0x0E, 0xB0, 0x37, 0x08, 0x00, 0x03, 0x29, 0xF8, 0xD2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x0F, 0x0F, 0x68, 0x3C, 0x07, 0x00, 0x5C, 0xF0, 0x6E, 0xBF, 0x00, 0x00, 0x48, 0x0B, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x10, 0x94, 0x29, 0x07, 0x00, 0x5E, 0xF0, 0xA1, 0xB9, 0x00, 0x00, 0xDA, 0x0C, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x11, 0x70, 0x39, 0x07, 0x00, 0x5C, 0xF0, 0xA6, 0xBC, 0x00, 0x4C, 0xFC, 0xFF, 0xD2, 0x95, 0x21, 0x00, 0x00, 0xC0, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x12, 0x74, 0x40, 0x07, 0x00, 0x5C, 0xF0, 0x2D, 0xB9, 0x00, 0x00, 0xD2, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x13, 0x8C, 0x45, 0x07, 0x00, 0x5B, 0xF0, 0xAC, 0xBE, 0x00, 0x00, 0xE8, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x14, 0xC0, 0x33, 0x07, 0x00, 0x5C, 0xF0, 0x9C, 0xBF, 0x00, 0x00, 0xFC, 0x02, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x15, 0x40, 0x34, 0x07, 0x00, 0x5D, 0xF0, 0x6A, 0xBC, 0x00, 0x00, 0x18, 0x0D, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x16, 0xAC, 0xA6, 0x03, 0x00, 0x95, 0xF0, 0x2A, 0xBE, 0x00, 0x00, 0x04, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x17, 0x70, 0x27, 0x04, 0x00, 0x8D, 0xF0, 0xCE, 0xBD, 0x00, 0x00, 0x10, 0x03, 0x0D, 0x00, 0x06, 0x01, 0x04, 0x18, 0x0F, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x18, 0xCC, 0x54, 0x03, 0x00, 0x02, 0x21, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x0F, 0x19, 0xC8, 0x55, 0x03, 0x00, 0x9A, 0xF0, 0xA6, 0xBE, 0x00, 0x00, 0x18, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x1A, 0x60, 0x52, 0x03, 0x00, 0x9B, 0xF0, 0x61, 0xB8, 0x00, 0x00, 0x26, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x1B, 0x80, 0x6D, 0x03, 0x00, 0x99, 0xF0, 0xDA, 0xBA, 0x00, 0x00, 0x38, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x1C, 0x4C, 0x5C, 0x03, 0x00, 0x9A, 0xF0, 0x7C, 0xBB, 0x00, 0x00, 0x48, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x1D, 0xD8, 0x50, 0x03, 0x00, 0x9B, 0xF0, 0x3E, 0xB9, 0x00, 0x00, 0x58, 0x03, 0x0D, 0x00, 0x06, 0x01, 0x04, 0xAC, 0x11, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x1E, 0x3C, 0x5E, 0x07, 0x00, 0x5A, 0xF0, 0x96, 0xBA, 0x00, 0x00, 0x6C, 0x03, 0x4C, 0xFC, 0xFF, 0xCD, 0x96, 0x21, 0x00, 0x0D, 0x00, 0x06, 0x01, 0x04, 0x98, 0x13, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x1F, 0x94, 0x7B, 0x07, 0x00, 0x58, 0xF0, 0xF2, 0xBB, 0x00, 0x00, 0x7C, 0x03, 0x0D, 0x00, 0x06, 0x01, 0x04, 0xF4, 0x13, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x20, 0xD4, 0xCD, 0x07, 0x00, 0x53, 0xF0, 0xDA, 0xBA, 0x00, 0x00, 0x8C, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x21, 0xB8, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x8B, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x0F, 0x22, 0xD4, 0x16, 0x07, 0x00, 0x5E, 0xF0, 0x62, 0xBE, 0x00, 0x00, 0x9C, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x23, 0x2C, 0x9A, 0x07, 0x00, 0x57, 0xF0, 0xAC, 0xBD, 0x00, 0x00, 0x88, 0x15, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x24, 0x90, 0xE7, 0x07, 0x00, 0x53, 0xF0, 0x68, 0xBD, 0x00, 0x00, 0x64, 0x22, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x25, 0x24, 0xE8, 0x07, 0x00, 0x51, 0xF0, 0xC2, 0xBD, 0x00, 0x00, 0xAC, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x26, 0x68, 0xF0, 0x07, 0x00, 0x53, 0xF0, 0x27, 0xB9, 0x00, 0x00, 0xBA, 0x22, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x27, 0x64, 0x70, 0x06, 0x00, 0x6B, 0xF0, 0x5F, 0xB9, 0x00, 0x00, 0x26, 0x23, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x28, 0xFC, 0x6B, 0x06, 0x00, 0x69, 0xF0, 0xDA, 0xBB, 0x00, 0x00, 0xB4, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x29, 0xCC, 0x6C, 0x06, 0x00, 0x6B, 0xF0, 0x12, 0xBC, 0x00, 0x00, 0xF4, 0x24, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x2A, 0xD4, 0x69, 0x06, 0x00, 0x6B, 0xF0, 0xBB, 0xBD, 0x00, 0x00, 0x4E, 0x25, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x2B, 0xDC, 0x68, 0x06, 0x00, 0x6B, 0xF0, 0x92, 0xBE, 0x00, 0x00, 0x04, 0x26, 0x0D, 0x00, 0x10, 0x4C, 0xFC, 0xFF, 0xC8, 0x97, 0x21, 0x00, 0x01, 0x0F, 0x2C, 0x60, 0xCF, 0x05, 0x00, 0x73, 0xF0, 0x2C, 0xBA, 0x00, 0x00, 0xBC, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x2D, 0x44, 0x26, 0x07, 0x00, 0x60, 0xF0, 0x68, 0xB8, 0x00, 0x00, 0x18, 0x27, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x2E, 0xE0, 0x00, 0x02, 0x00, 0xB0, 0xF0, 0x72, 0xB9, 0x00, 0x00, 0xC8, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x2F, 0xCC, 0xF7, 0x01, 0x00, 0xB0, 0xF0, 0x05, 0xBE, 0x00, 0x00, 0xDA, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x30, 0xD4, 0x4D, 0x05, 0x00, 0x7B, 0xF0, 0x0E, 0xBB, 0x00, 0x00, 0xF4, 0x03, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x31, 0x7C, 0xF1, 0x04, 0x00, 0x81, 0xF0, 0x46, 0xB9, 0x00, 0x00, 0x0C, 0x04, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x32, 0xA4, 0x01, 0x05, 0x00, 0x80, 0xF0, 0x3A, 0xB9, 0x00, 0x00, 0x1C, 0x04, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x33, 0xC8, 0x02, 0x05, 0x00, 0x80, 0xF0, 0xB4, 0xB8, 0x00, 0x00, 0x34, 0x04, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x34, 0xB8, 0xBB, 0x02, 0x00, 0xA4, 0xF0, 0x48, 0xBC, 0x00, 0x00, 0x4C, 0x04, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x35, 0x78, 0x3A, 0x00, 0x00, 0x01, 0x20, 0x20, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x0F, 0x36, 0x20, 0x13, 0x00, 0x00, 0xCF, 0xF0, 0xA0, 0xB8, 0x00, 0x00, 0x64, 0x04, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x37, 0x78, 0x42, 0x02, 0x00, 0xAC, 0xF0, 0xFE, 0xB8, 0x00, 0x00, 0x78, 0x04, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x38, 0x60, 0x42, 0x02, 0x00, 0xAC, 0xF0, 0x20, 0xB9, 0x00, 0x00, 0xA4, 0x04, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x39, 0x78, 0x8C, 0x01, 0x00, 0xB7, 0xF0, 0x20, 0xBC, 0x00, 0x00, 0xBC, 0x04, 0x0D, 0x00, 0x4C, 0xFC, 0xFF, 0xC3, 0x98, 0x21, 0x00, 0x10, 0x01, 0x0F, 0x3A, 0x0C, 0xC5, 0x05, 0x00, 0x73, 0xF0, 0xDC, 0xBF, 0x00, 0x00, 0xC8, 0x04, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x3B, 0x70, 0xC6, 0x05, 0x00, 0x73, 0xF0, 0x42, 0xBF, 0x00, 0x00, 0xF8, 0x04, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x3C, 0x20, 0x6C, 0x05, 0x00, 0x79, 0xF0, 0x6E, 0xBC, 0x00, 0x00, 0x00, 0x05, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x3D, 0x10, 0xBE, 0x04, 0x00, 0x98, 0x46, 0x0B, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x0F, 0x3E, 0xB0, 0x64, 0x06, 0x00, 0x6C, 0xF0, 0xC7, 0xBF, 0x00, 0x00, 0x42, 0x34, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x3F, 0xF8, 0x67, 0x06, 0x00, 0x69, 0xF0, 0x8A, 0xBE, 0x00, 0x00, 0x10, 0x05, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x40, 0xFC, 0x61, 0x06, 0x00, 0x6D, 0xF0, 0x70, 0xB9, 0x00, 0x00, 0xE0, 0x34, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x41, 0x14, 0xAC, 0x03, 0x00, 0x95, 0xF0, 0x84, 0xBC, 0x00, 0x00, 0x20, 0x05, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x42, 0xE0, 0x9B, 0x06, 0x00, 0x69, 0xF0, 0xCA, 0xBC, 0x00, 0x00, 0x78, 0x35, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x43, 0x1C, 0xA1, 0x06, 0x00, 0x66, 0xF0, 0x06, 0xBA, 0x00, 0x00, 0x2C, 0x05, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x44, 0x90, 0x33, 0x04, 0x00, 0x8D, 0xF0, 0xD4, 0xB8, 0x00, 0x00, 0x3C, 0x05, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x45, 0x04, 0x3E, 0x04, 0x00, 0x8C, 0xF0, 0xA0, 0xBB, 0x00, 0x00, 0x48, 0x05, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x46, 0x90, 0x38, 0x04, 0x00, 0x8C, 0xF0, 0x7E, 0xBE, 0x00, 0x00, 0x90, 0x05, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x47, 0xC4, 0x65, 0x02, 0x00, 0xA9, 0xF0, 0xEE, 0xBF, 0x00, 0x00, 0xA4, 0x05, 0x0D, 0x4C, 0xFC, 0xFF, 0xBE, 0x99, 0x21, 0x00, 0x00, 0x10, 0x01, 0x0F, 0x48, 0x20, 0x4C, 0x07, 0x00, 0x5B, 0xF0, 0xCC, 0xBC, 0x00, 0x00, 0xBC, 0x05, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x49, 0xCC, 0xEF, 0x03, 0x00, 0x94, 0xF0, 0x62, 0xBB, 0x00, 0x00, 0x94, 0x36, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x4A, 0x8C, 0xF8, 0x03, 0x00, 0x90, 0xF0, 0xA4, 0xBE, 0x00, 0x00, 0xD8, 0x05, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x4B, 0x0C, 0xF9, 0x03, 0x00, 0x90, 0xF0, 0x70, 0xBE, 0x00, 0x00, 0xF0, 0x05, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x4C, 0x0C, 0xF2, 0x03, 0x00, 0x91, 0xF0, 0x00, 0xBA, 0x00, 0x00, 0x10, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x4D, 0x20, 0xF5, 0x06, 0x00, 0x61, 0xF0, 0x8A, 0xB8, 0x00, 0x00, 0x38, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x4E, 0xC8, 0xF2, 0x06, 0x00, 0x61, 0xF0, 0xBF, 0xB9, 0x00, 0x00, 0x4A, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x4F, 0xA4, 0xDE, 0x04, 0x00, 0x82, 0xF0, 0xDA, 0xBB, 0x00, 0x00, 0x5C, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x50, 0x2C, 0x42, 0x05, 0x00, 0x7C, 0xF0, 0x1E, 0xBA, 0x00, 0x00, 0x6C, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x51, 0xFC, 0x47, 0x05, 0x00, 0x7B, 0xF0, 0x3E, 0xBF, 0x00, 0x00, 0x7C, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x52, 0x24, 0x20, 0x03, 0x00, 0xA1, 0xF0, 0xD8, 0xBB, 0x00, 0x00, 0xD8, 0x37, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x53, 0x6C, 0x20, 0x03, 0x00, 0xA1, 0xF0, 0xDB, 0xBB, 0x00, 0x00, 0x26, 0x38, 0x0D, 0x00, 0x06, 0x01, 0x04, 0x88, 0x39, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x54, 0x90, 0xC8, 0x07, 0x00, 0x40, 0x1A, 0x80, 0xB2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x01, 0x04, 0xB4, 0x39, 0x0D, 0x00, 0x06, 0x01, 0x4C, 0xFC, 0xFF, 0xB9, 0x9A, 0x21, 0x00, 0x04, 0xDE, 0x3A, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x55, 0x44, 0x1F, 0x08, 0x00, 0x4E, 0xF0, 0xA0, 0xBB, 0x00, 0x00, 0x88, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x56, 0x80, 0x1E, 0x08, 0x00, 0x4E, 0xF0, 0x05, 0xBC, 0x00, 0x00, 0x8E, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x57, 0xE8, 0x1E, 0x08, 0x00, 0x4E, 0xF0, 0xD4, 0xBB, 0x00, 0x00, 0x94, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x58, 0xB0, 0x1F, 0x08, 0x00, 0x4E, 0xF0, 0x72, 0xBB, 0x00, 0x00, 0x98, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x59, 0x14, 0x1E, 0x08, 0x00, 0x4E, 0xF0, 0x42, 0xBC, 0x00, 0x00, 0x9C, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x5A, 0xF8, 0xDD, 0x06, 0x00, 0x62, 0xF0, 0x54, 0xBC, 0x00, 0x00, 0xA4, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x5B, 0x34, 0xBD, 0x05, 0x00, 0x74, 0xF0, 0xB9, 0xBC, 0x00, 0x00, 0xAA, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x5C, 0x9C, 0xBC, 0x05, 0x00, 0x78, 0xF0, 0xF1, 0xB8, 0x00, 0x00, 0x82, 0x3E, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x5D, 0xEC, 0xBB, 0x05, 0x00, 0x78, 0xF0, 0x83, 0xB9, 0x00, 0x00, 0xF6, 0x3E, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x5E, 0x44, 0xB7, 0x05, 0x00, 0x74, 0xF0, 0xB9, 0xBF, 0x00, 0x00, 0xBA, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x5F, 0x84, 0x1B, 0x02, 0x00, 0xAE, 0xF0, 0xA4, 0xBD, 0x00, 0x00, 0xD0, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x60, 0x4C, 0x40, 0x03, 0x00, 0xA0, 0xF0, 0xD2, 0xBA, 0x00, 0x00, 0xF4, 0x45, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x61, 0xD0, 0x4B, 0x03, 0x00, 0x9B, 0xF0, 0x82, 0xBD, 0x00, 0x00, 0xD8, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x62, 0x74, 0x4D, 0x03, 0x00, 0x9B, 0xF0, 0xB4, 0xBC, 0x4C, 0xFC, 0xFF, 0xB4, 0x9B, 0x21, 0x00, 0x00, 0x00, 0xE0, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x63, 0x1C, 0x47, 0x03, 0x00, 0x9B, 0xF0, 0xE6, 0xBF, 0x00, 0x00, 0xEC, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x64, 0x34, 0x35, 0x03, 0x00, 0x9D, 0xF0, 0xDE, 0xB8, 0x00, 0x00, 0xF4, 0x06, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x65, 0x9C, 0x37, 0x03, 0x00, 0x9C, 0xF0, 0xB8, 0xBF, 0x00, 0x00, 0x10, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x66, 0xEC, 0x17, 0x02, 0x00, 0xB3, 0xF0, 0xE6, 0xB9, 0x00, 0x00, 0xBC, 0x4B, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x67, 0x38, 0xC7, 0x01, 0x00, 0xB3, 0xF0, 0xF2, 0xBF, 0x00, 0x00, 0x20, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x68, 0x10, 0x44, 0x00, 0x00, 0xD0, 0xF0, 0xF2, 0xBC, 0x00, 0x00, 0xF8, 0x4D, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x69, 0x04, 0xC7, 0x01, 0x00, 0xB4, 0xF0, 0x0F, 0xB8, 0x00, 0x00, 0x26, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x6A, 0x84, 0xD3, 0x02, 0x00, 0xA7, 0xF0, 0x20, 0xBF, 0x00, 0x00, 0xC8, 0x51, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x6B, 0xF0, 0xD2, 0x02, 0x00, 0xA3, 0xF0, 0x20, 0xBA, 0x00, 0x00, 0x34, 0x07, 0x0D, 0x00, 0x06, 0x01, 0x04, 0x7C, 0x55, 0x0D, 0x00, 0x06, 0x01, 0x04, 0x68, 0x58, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x6C, 0xF0, 0xAF, 0x01, 0x00, 0xBA, 0xF0, 0x60, 0xBC, 0x00, 0x00, 0xB4, 0x58, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x6D, 0x0C, 0x07, 0x02, 0x00, 0xB0, 0xF0, 0x20, 0xB8, 0x00, 0x00, 0x50, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x6E, 0x64, 0x39, 0x08, 0x00, 0x51, 0xF0, 0xE4, 0xBF, 0x00, 0x00, 0x30, 0x59, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x6F, 0x64, 0x56, 0x04, 0x00, 0x8B, 0xF0, 0x7C, 0xB8, 0x00, 0x00, 0x60, 0x4C, 0xFC, 0xFF, 0xAF, 0x9C, 0x21, 0x00, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x70, 0x3C, 0x56, 0x04, 0x00, 0x90, 0xF0, 0xD1, 0xB9, 0x00, 0x00, 0xE2, 0x59, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x71, 0xB0, 0x57, 0x04, 0x00, 0x8A, 0xF0, 0xD9, 0xBF, 0x00, 0x00, 0x66, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x72, 0xCC, 0x2D, 0x05, 0x00, 0x7D, 0xF0, 0xCE, 0xBC, 0x00, 0x00, 0x6C, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x73, 0x80, 0x2A, 0x03, 0x00, 0x9D, 0xF0, 0x7A, 0xBE, 0x00, 0x00, 0x78, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x74, 0x54, 0xA4, 0x06, 0x00, 0x66, 0xF0, 0xA4, 0xB9, 0x00, 0x00, 0xA0, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x75, 0x14, 0x69, 0x05, 0x00, 0x79, 0xF0, 0x48, 0xBF, 0x00, 0x00, 0xA8, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x76, 0xE8, 0x70, 0x07, 0x00, 0x59, 0xF0, 0x62, 0xBB, 0x00, 0x00, 0xB0, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x77, 0x84, 0x67, 0x07, 0x00, 0x5A, 0xF0, 0x1C, 0xB8, 0x00, 0x00, 0xC0, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x78, 0x54, 0x2F, 0x00, 0x00, 0xCD, 0xF0, 0x3C, 0xBC, 0x00, 0x00, 0xD0, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x79, 0xE0, 0x31, 0x00, 0x00, 0xCD, 0xF0, 0xFA, 0xBA, 0x00, 0x00, 0xD8, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x7A, 0xFC, 0xB5, 0x01, 0x00, 0xB5, 0xF0, 0xF8, 0xB8, 0x00, 0x00, 0xF0, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x7B, 0xFC, 0xC7, 0x01, 0x00, 0xB3, 0xF0, 0xFE, 0xBF, 0x00, 0x00, 0xFC, 0x07, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x7C, 0x64, 0xC8, 0x01, 0x00, 0xB3, 0xF0, 0xCF, 0xBF, 0x00, 0x00, 0x06, 0x08, 0x0D, 0x00, 0x10, 0x01, 0x0F, 0x7D, 0x50, 0xB4, 0x01, 0x00, 0xB5, 0xF0, 0xE0, 0xB9, 0x00, 0x00, 0x4C, 0xFC, 0x0B, 0xAA, 0x9D, 0x21, 0x00, 0x14, 0x08, 0x0D, 0x00, 0xFE, 0x00, 0x00, /* Commit configuration data, reboot firmware (Launch_RAM) */ 0x4E, 0xFC, 0x04, 0xFF, 0xFF, 0xFF, 0xFF }; const int brcm_patch_ram_length = sizeof(brcm_patchram_buf);
the_stack_data/248580760.c
/* { dg-do run } */ #include <assert.h> int A[2][2] = { 1, 2, 3, 4 }; void f (int n, int B[n][n], int C[]) { int D[2][2] = { 1, 2, 3, 4 }; int E[n][n]; assert (n >= 2); E[1][1] = 4; #pragma omp parallel firstprivate(B, C, D, E) { assert (sizeof (B) == sizeof (int (*)[n])); /* { dg-warning "on array function parameter" } */ assert (sizeof (C) == sizeof (int *)); /* { dg-warning "on array function parameter" } */ assert (sizeof (D) == 4 * sizeof (int)); assert (sizeof (E) == n * n * sizeof (int)); /* Private B and C have values of original B and C. */ assert (&B[1][1] == &A[1][1]); assert (&C[3] == &A[1][1]); assert (D[1][1] == 4); assert (E[1][1] == 4); } } int main () { f (2, A, A[0]); return 0; }
the_stack_data/153269217.c
//***************************************************************************** // // startup_codered.c - Startup code for use with code_red tools. // // Copyright (c) 2011-2012 Texas Instruments Incorporated. All rights reserved. // Software License Agreement // // Texas Instruments (TI) is supplying this software for use solely and // exclusively on TI's microcontroller products. The software is owned by // TI and/or its suppliers, and is protected under applicable copyright // laws. You may not combine this software with "viral" open-source // software in order to form a larger program. // // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL // DAMAGES, FOR ANY REASON WHATSOEVER. // // This is part of revision 8555 of the DK-LM3S9B96-EM2-CC2560-BLUETOPIA Firmware Package. // //***************************************************************************** //***************************************************************************** // // Forward declaration of the default fault handlers. // //***************************************************************************** void ResetISR(void); static void NmiSR(void); static void FaultISR(void); static void IntDefaultHandler(void); //***************************************************************************** // // External declarations for the interrupt handlers used by the application. // //***************************************************************************** extern void TouchScreenIntHandler(void); extern void TimerTick(void); extern void HCITR_UARTIntHandler(void); //***************************************************************************** // // The entry point for the application. // //***************************************************************************** #if defined(__REDLIB__) #define __MAIN__ __main #else #define __MAIN__ main #endif extern int __MAIN__(void); //***************************************************************************** // // Reserve space for the system stack. // //***************************************************************************** extern unsigned long _vStackTop; //***************************************************************************** // // The vector table. Note that the proper constructs must be placed on this to // ensure that it ends up at physical address 0x0000.0000. // //***************************************************************************** __attribute__ ((section(".isr_vector"))) void (* const g_pfnVectors[])(void) = { (void (*)(void))((unsigned long)&_vStackTop), // The initial stack pointer ResetISR, // The reset handler NmiSR, // The NMI handler FaultISR, // The hard fault handler IntDefaultHandler, // The MPU fault handler IntDefaultHandler, // The bus fault handler IntDefaultHandler, // The usage fault handler 0, // Reserved 0, // Reserved 0, // Reserved 0, // Reserved IntDefaultHandler, // SVCall handler IntDefaultHandler, // Debug monitor handler 0, // Reserved IntDefaultHandler, // The PendSV handler IntDefaultHandler, // The SysTick handler IntDefaultHandler, // GPIO Port A IntDefaultHandler, // GPIO Port B IntDefaultHandler, // GPIO Port C IntDefaultHandler, // GPIO Port D IntDefaultHandler, // GPIO Port E IntDefaultHandler, // UART0 Rx and Tx HCITR_UARTIntHandler, // UART1 Rx and Tx IntDefaultHandler, // SSI0 Rx and Tx IntDefaultHandler, // I2C0 Master and Slave IntDefaultHandler, // PWM Fault IntDefaultHandler, // PWM Generator 0 IntDefaultHandler, // PWM Generator 1 IntDefaultHandler, // PWM Generator 2 IntDefaultHandler, // Quadrature Encoder 0 IntDefaultHandler, // ADC Sequence 0 IntDefaultHandler, // ADC Sequence 1 IntDefaultHandler, // ADC Sequence 2 TouchScreenIntHandler, // ADC Sequence 3 IntDefaultHandler, // Watchdog timer TimerTick, // Timer 0 subtimer A IntDefaultHandler, // Timer 0 subtimer B IntDefaultHandler, // Timer 1 subtimer A IntDefaultHandler, // Timer 1 subtimer B IntDefaultHandler, // Timer 2 subtimer A IntDefaultHandler, // Timer 2 subtimer B IntDefaultHandler, // Analog Comparator 0 IntDefaultHandler, // Analog Comparator 1 IntDefaultHandler, // Analog Comparator 2 IntDefaultHandler, // System Control (PLL, OSC, BO) IntDefaultHandler, // FLASH Control IntDefaultHandler, // GPIO Port F IntDefaultHandler, // GPIO Port G IntDefaultHandler, // GPIO Port H IntDefaultHandler, // UART2 Rx and Tx IntDefaultHandler, // SSI1 Rx and Tx IntDefaultHandler, // Timer 3 subtimer A IntDefaultHandler, // Timer 3 subtimer B IntDefaultHandler, // I2C1 Master and Slave IntDefaultHandler, // Quadrature Encoder 1 IntDefaultHandler, // CAN0 IntDefaultHandler, // CAN1 IntDefaultHandler, // CAN2 IntDefaultHandler, // Ethernet IntDefaultHandler, // Hibernate IntDefaultHandler, // USB0 IntDefaultHandler, // PWM Generator 3 IntDefaultHandler, // uDMA Software Transfer IntDefaultHandler, // uDMA Error IntDefaultHandler, // ADC1 Sequence 0 IntDefaultHandler, // ADC1 Sequence 1 IntDefaultHandler, // ADC1 Sequence 2 IntDefaultHandler, // ADC1 Sequence 3 IntDefaultHandler, // I2S0 IntDefaultHandler, // External Bus Interface 0 IntDefaultHandler // GPIO Port J }; //***************************************************************************** // // The following are constructs created by the linker, indicating where the // the "data" and "bss" segments reside in memory. The initializers for the // for the "data" segment resides immediately following the "text" segment. // //***************************************************************************** extern unsigned long _etext; extern unsigned long _data; extern unsigned long _edata; extern unsigned long _bss; extern unsigned long _ebss; //***************************************************************************** // // This is the code that gets called when the processor first starts execution // following a reset event. Only the absolutely necessary set is performed, // after which the application supplied entry() routine is called. Any fancy // actions (such as making decisions based on the reset cause register, and // resetting the bits in that register) are left solely in the hands of the // application. // //***************************************************************************** void ResetISR(void) { unsigned long *pulSrc, *pulDest; // // Copy the data segment initializers from flash to SRAM. // pulSrc = &_etext; for(pulDest = &_data; pulDest < &_edata; ) { *pulDest++ = *pulSrc++; } // // Zero fill the bss segment. // __asm(" ldr r0, =_bss\n" " ldr r1, =_ebss\n" " mov r2, #0\n" " .thumb_func\n" "zero_loop:\n" " cmp r0, r1\n" " it lt\n" " strlt r2, [r0], #4\n" " blt zero_loop"); // // Call the application's entry point. // __MAIN__(); } //***************************************************************************** // // This is the code that gets called when the processor receives a NMI. This // simply enters an infinite loop, preserving the system state for examination // by a debugger. // //***************************************************************************** static void NmiSR(void) { // // Enter an infinite loop. // while(1) { } } //***************************************************************************** // // This is the code that gets called when the processor receives a fault // interrupt. This simply enters an infinite loop, preserving the system state // for examination by a debugger. // //***************************************************************************** static void FaultISR(void) { // // Enter an infinite loop. // while(1) { } } //***************************************************************************** // // This is the code that gets called when the processor receives an unexpected // interrupt. This simply enters an infinite loop, preserving the system state // for examination by a debugger. // //***************************************************************************** static void IntDefaultHandler(void) { // // Go into an infinite loop. // while(1) { } }
the_stack_data/111077904.c
/* $OpenBSD: wcsncat.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */ /* $NetBSD: wcsncat.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ /*- * Copyright (c)1999 Citrus Project, * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * citrus Id: wcsncat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp */ #include <wchar.h> wchar_t * wcsncat(wchar_t *s1, const wchar_t *s2, size_t n) { wchar_t *p; wchar_t *q; const wchar_t *r; p = s1; while (*p) p++; q = p; r = s2; while (*r && n) { *q++ = *r++; n--; } *q = '\0'; return s1; } DEF_STRONG(wcsncat);
the_stack_data/28009.c
#include <stdio.h> #include <math.h> int main(){ float triangle[6][3] = { // angles are in radians {137.4, 80.9, 0.78}, {155.2, 92.62, 0.89}, {149.3, 97.93, 1.3}, {160.0, 100.25, 9.00}, {155.6, 68.95, 1.25}, {149.7, 120.0, 1.75} }; float area[6], maxArea; int plotNo, i; // calculating area of each triangle for(i=0;i<6;i++){ area[i] = 0.5 * triangle[i][0] * triangle[i][1] * sin(triangle[i][2]); } // finding greatest area maxArea = area[0]; // used as a reference to compare for(i=0;i<6;i++){ if(area[i] > maxArea){ maxArea = area[i]; plotNo = i+1; } } printf("Plot No. %d has the largest area with area of %.2f\n", plotNo, maxArea); return 0; }
the_stack_data/184519184.c
#include<stdio.h> int max(int a,int b) { if(a>b) { return a; } else { return b; } } int main() { int n,m,i,j; printf("enter the no. of objects\n"); scanf("%d",&n); printf("enter the weight of the sac\n"); scanf("%d",&m); int w[n],p[n]; printf("enter the weight of the objects\n"); for(i=0;i<n;++i) { scanf("%d",&w[i]); } printf("enter the profit of the objects\n"); for(i=0;i<n;++i) { scanf("%d",&p[i]); } int k[n][m]; for(i=0;i<n;++i) { for(j=0;j<=m;++j) { if(i==0 || j==0) { k[i][j]=0; } else if(w[i]<=j) { k[i][j]=max(p[i]+k[i-1][j-w[i]],k[i-1][j]); } else { k[i][j]=k[i-1][j]; } } } printf("the max profit is: %d\n",k[n][m-1]); return 0; }
the_stack_data/76699006.c
// C Program to Calculate Standard Deviation // C programming source code to compute standard deviation by passing elements of an array to function.... #include <stdio.h> #include <math.h> float calculateSD(float data[]); int main() { int i; float data[10]; printf("Enter 10 elements: "); for(i=0; i < 10; ++i) scanf("%f", &data[i]); printf("\nStandard Deviation = %.6f", calculateSD(data)); return 0; } float calculateSD(float data[]) { float sum = 0.0, mean, standardDeviation = 0.0; int i; for(i=0; i<10; ++i) { sum += data[i]; } mean = sum/10; for(i=0; i<10; ++i) standardDeviation += pow(data[i] - mean, 2); return sqrt(standardDeviation/10); } // https://www.programiz.com/c-programming/examples/standard-deviation
the_stack_data/173578652.c
/***************************************************************************** Example : omp-matrix-transpose.c Objective : Write an OpenMP Program for Transpose of a Matrix and measure the performance. This example demonstrates the use of PARALLEL Directive and Private clause Input : a) Number of threads b) Size of matrices (numofrows and noofcols ) Output : Each thread transposes assaigned Row and finally master prints the result of the matrix transpose, the status of execution i.e. compare the result of the serial and parallel execution and time taken for this. Created :Aug 2011 . Author : RarchK *********************************************************************************/ #include <stdio.h> #include <sys/time.h> #include <omp.h> #include <stdlib.h> /* Main Program */ main(int argc,char **argv) { int NoofRows, NoofCols, i, j,Total_threads,Noofthreads; float **Matrix, **Trans, **Checkoutput, flops; struct timeval TimeValue_Start; struct timezone TimeZone_Start; struct timeval TimeValue_Final; struct timezone TimeZone_Final; long time_start, time_end; double time_overhead; printf("\n\t\t---------------------------------------------------------------------------"); printf("\n\t\t Email : RarchK"); printf("\n\t\t---------------------------------------------------------------------------"); printf("\n\t\t Objective : Implementation of the transpose of matrix ."); printf("\n\t\t using OpenMP Parallel for directive,Private Clause. "); printf("\n\t\t..........................................................................\n"); /* Checking for command line arguments */ if( argc != 4 ){ printf("\t\t Very Few Arguments\n "); printf("\t\t Syntax : exec <Threads> <NoOfRows> <NoOfColumns>\n"); exit(-1); } Noofthreads=atoi(argv[1]); if ((Noofthreads!=1) && (Noofthreads!=2) && (Noofthreads!=4) && (Noofthreads!=8) && (Noofthreads!= 16) ) { printf("\n Number of threads should be 1,2,4,8 or 16 for the execution of program. \n\n"); exit(-1); } NoofRows=atoi(argv[2]); NoofCols=atoi(argv[3]); /* printf("\n\t\t Read The Matrix Size Noofrows And Colums Of Matrix \n"); scanf("%d%d",&NoofRows,&NoofCols);*/ printf("\n\t\t Threads : %d ",Noofthreads); printf("\n\t\t Matrix Size : %d X %d \n ",NoofRows,NoofCols); if (NoofRows <= 0 || NoofCols <= 0) { printf("\n\t\t The NoofRows And NoofCols Should Be Of Positive Sign\n"); exit(1); } /* Matrix Elements */ Matrix = (float **) malloc(sizeof(float *) * NoofRows); for (i = 0; i < NoofRows; i++) { Matrix[i] = (float *) malloc(sizeof(float) * NoofCols); for (j = 0; j < NoofCols; j++) Matrix[i][j] = (i * j) * 5 + i; } /* Dynamic Memory Allocation */ Trans = (float **) malloc(sizeof(float *) * NoofCols); Checkoutput = (float **) malloc(sizeof(float *) * NoofCols); /* Initializing The Output Matrices Elements As Zero */ for (i = 0; i < NoofCols; i++) { Checkoutput[i] = (float *) malloc(sizeof(float) * NoofRows); Trans[i] = (float *) malloc(sizeof(float) * NoofRows); for (j = 0; j < NoofRows; j++) { Checkoutput[i][j] = 0; Trans[i][j] = 0; } } gettimeofday(&TimeValue_Start, &TimeZone_Start); omp_set_num_threads(Noofthreads); /* OpenMP Parallel For Directive */ #pragma omp parallel for private(j) for (i = 0; i < NoofRows; i = i + 1) { Total_threads=omp_get_num_threads(); for (j = 0; j < NoofCols; j = j + 1) { Trans[j][i] = Matrix[i][j]; } } /* All thread join Master thread */ gettimeofday(&TimeValue_Final, &TimeZone_Final); time_start = TimeValue_Start.tv_sec * 1000000 + TimeValue_Start.tv_usec; time_end = TimeValue_Final.tv_sec * 1000000 + TimeValue_Final.tv_usec; time_overhead = (time_end - time_start)/1000000.0; /* Serial Computation */ for (i = 0; i < NoofRows; i = i + 1) for (j = 0; j < NoofCols; j = j + 1) Checkoutput[j][i] = Matrix[i][j]; for (i = 0; i < NoofCols; i = i + 1) for (j = 0; j < NoofRows; j = j + 1) if (Checkoutput[i][j] == Trans[i][j]) continue; else { printf("There Is A Difference From Serial And Parallel Calculation \n"); exit(-1); } /* printf("The Input Matrix Is \n"); for (i = 0; i < NoofRows; i++) { for (j = 0; j < NoofCols; j++) printf("%f \t", Matrix[i][j]); printf("\n"); } printf("\nThe Transpose Matrix Is \n"); for (i = 0; i < NoofCols; i = i + 1) { for (j = 0; j < NoofRows; j = j + 1) printf("%f \t", Trans[i][j]); printf("\n"); }*/ /* Calculation Of Flops */ /* flops = (float) 2 *NoofRows * NoofCols / (float) time_overhead; */ /*printf("Time Taken :%lf \n Flops= %f Flops\n", time_overhead, flops); */ printf("\n\n\t\t Transpose of the matrix is ................ Done"); printf("\n\n\t\t Time in Seconds (T) : %lf",time_overhead); printf("\n\n\t\t ( T represents the Time taken for computation )"); printf("\n\t\t..........................................................................\n"); /* Freeing Allocated Memory */ free(Matrix); free(Checkoutput); free(Trans); }
the_stack_data/25138093.c
/* PR c/6677 */ /* Verify that GCC doesn't perform illegal simplifications when folding constants. */ #include <limits.h> extern void abort (void); extern void exit (int); int main (void) { int i; signed char j; unsigned char k; i = SCHAR_MAX; j = ((signed char) (i << 1)) / 2; if (j != -1) abort(); j = ((signed char) (i * 2)) / 2; if (j != -1) abort(); i = UCHAR_MAX; k = ((unsigned char) (i << 1)) / 2; if (k != UCHAR_MAX/2) abort(); k = ((unsigned char) (i * 2)) / 2; if (k != UCHAR_MAX/2) abort(); exit(0); }
the_stack_data/1056594.c
#include <stdio.h> int Callback_1(int x) { printf("Hello, this is Callback_1:x = %d \n", x); return 0; } int Callback_2(int x) { printf("Hello, this is Callback_2:x = %d \n", x); return 0; } int Callback_3(int x) { printf("Hello, this is Callback_3:x = %d \n", x); return 0; } int Handle(int y, int (*Callback)(int)) { printf("Entering Handle Function. \n"); Callback(y); printf("Leaving Handle Function. \n"); } int main() { int a = 2; int b = 3; int c = 4; printf("Enter main function. \n"); Handle(a, Callback_1); Handle(b, Callback_2); Handle(c, Callback_3); printf("Leaving main function! \n"); return 0; }
the_stack_data/82950777.c
/* * Happyblog -- A Blog in the imperative programming Language C * (C) 2012 Martin Wolters * * This program is free software. It comes without any warranty, to * the extent permitted by applicable law. You can redistribute it * and/or modify it under the terms of the Do What The Fuck You Want * To Public License, Version 2, as published by Sam Hocevar. See * http://sam.zoy.org/wtfpl/COPYING for more details. */ #include <getopt.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sqlite3.h> #define MAXBUF 512 static void filltable(sqlite3 *db, char *desc, char *url, char *title, char *head, char *tail) { sqlite3_stmt *statement; if(sqlite3_prepare(db, "INSERT INTO config (title, head, tail) " "VALUES (:ttl, :hed, :tai);", MAXBUF, &statement, NULL) != SQLITE_OK) { fprintf(stderr, "SQLite error: %s\n", sqlite3_errmsg(db)); return; } sqlite3_bind_text(statement, 1, title, strlen(title), SQLITE_STATIC); sqlite3_bind_text(statement, 2, head, strlen(head), SQLITE_STATIC); sqlite3_bind_text(statement, 3, tail, strlen(tail), SQLITE_STATIC); sqlite3_step(statement); sqlite3_finalize(statement); if(sqlite3_prepare(db, "INSERT INTO rssconfig (desc, baseurl) " "VALUES (:dsc, :url);", MAXBUF, &statement, NULL) != SQLITE_OK) { fprintf(stderr, "SQLite error: %s\n", sqlite3_errmsg(db)); return; } sqlite3_bind_text(statement, 1, desc, strlen(desc), SQLITE_STATIC); sqlite3_bind_text(statement, 2, url, strlen(url), SQLITE_STATIC); sqlite3_step(statement); sqlite3_finalize(statement); } static void mktables(sqlite3 *db) { char *errmsg = NULL; if(sqlite3_exec(db, "CREATE TABLE entries (id INTEGER PRIMARY KEY, hash " "INTEGER, time INTEGER, entry TEXT);", NULL, 0, &errmsg) != SQLITE_OK) { fprintf(stderr, "SQLite error: %s\n", errmsg); sqlite3_free(errmsg); return; } if(sqlite3_exec(db, "CREATE TABLE updates (id INTEGER PRIMARY KEY, hash " "INTEGER, time INTEGER, entry TEXT);", NULL, 0, &errmsg) != SQLITE_OK) { fprintf(stderr, "SQLite error: %s\n", errmsg); sqlite3_free(errmsg); return; } if(sqlite3_exec(db, "CREATE TABLE config (title TEXT, head TEXT, " "tail TEXT);", NULL, 0, &errmsg) != SQLITE_OK) { fprintf(stderr, "SQLite error: %s\n", errmsg); sqlite3_free(errmsg); return; } if(sqlite3_exec(db, "CREATE TABLE rssconfig (desc TEXT, baseurl TEXT);", NULL, 0, &errmsg) != SQLITE_OK) { fprintf(stderr, "SQLite error: %s\n", errmsg); sqlite3_free(errmsg); return; } } static int delifexists(char *filename) { FILE *fp; if((fp = fopen(filename, "r")) == NULL) return 1; fclose(fp); printf("Deleting '%s'...\n", filename); if(remove(filename) == -1) { fprintf(stderr, "ERROR: Could not delete '%s'.\n", filename); return 0; } return 1; } static void usage(char *argv) { printf("USAGE: %s [-b] [-d] [-e] [-f] [-h] [-o] [-t] ...\n", argv); printf("Options:\n"); printf("\t-b Base URL\n"); printf("\t-d Deacription\n"); printf("\t-e Head\n"); printf("\t-f Foot\n"); printf("\t-h This help\n"); printf("\t-o Output filename\n"); printf("\t-t Title\n"); } int main(int argc, char **argv) { char *filename = "blog.db"; char *title = "Blog"; char *head = ""; char *tail = ""; char *desc = ""; char *url = ""; int opt; sqlite3 *db; while((opt = getopt(argc, argv, "hb:d:e:f:o:t:")) != -1) { switch(opt) { case 'h': usage(argv[0]); return EXIT_SUCCESS; case 'b': url = optarg; break; case 'd': desc = optarg; break; case 'e': head = optarg; break; case 'f': tail = optarg; break; case 'o': filename = optarg; break; case 't': title = optarg; break; default: usage(argv[0]); return EXIT_FAILURE; } } if(!delifexists(filename)) return EXIT_FAILURE; if(sqlite3_open(filename, &db)) { fprintf(stderr, "ERROR: Could not open '%s': %s\n", filename, sqlite3_errmsg(db)); return EXIT_FAILURE; } mktables(db); filltable(db, desc, url, title, head, tail); sqlite3_close(db); return EXIT_SUCCESS; }
the_stack_data/14199006.c
 #include "math.h" // _sum int sum(int v1, int v2) { return v1 + v2; } // _delta int delta(int v1, int v2) { return v1 - v2; } int divide(int v1, int v2) { return v1 / v2; }
the_stack_data/361462.c
/* * Copyright (c) 2017, 2018, Oracle and/or its affiliates. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials provided * with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors may be used to * endorse or promote products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdio.h> #include <stdint.h> #include "syscall.h" #define ABORT_STATUS 134 #ifndef __linux__ #define SYS_exit_group 231 #endif void __sulong_print_stacktrace(); int __sulong_should_print_stacktrace_on_abort(); void abort() { int64_t result; if (__sulong_should_print_stacktrace_on_abort()) { fprintf(stderr, "abort()\n\n"); __sulong_print_stacktrace(); } __SYSCALL_1(result, SYS_exit_group, ABORT_STATUS); for (;;) { __SYSCALL_1(result, SYS_exit_group, ABORT_STATUS); } }
the_stack_data/121630.c
/* f2c.h -- Standard Fortran to C header file */ /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ #ifndef F2C_INCLUDE #define F2C_INCLUDE #include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimag(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static integer c__1 = 1; /* > \brief \b CHPTRF */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download CHPTRF + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chptrf. f"> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chptrf. f"> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chptrf. f"> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE CHPTRF( UPLO, N, AP, IPIV, INFO ) */ /* CHARACTER UPLO */ /* INTEGER INFO, N */ /* INTEGER IPIV( * ) */ /* COMPLEX AP( * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > CHPTRF computes the factorization of a complex Hermitian packed */ /* > matrix A using the Bunch-Kaufman diagonal pivoting method: */ /* > */ /* > A = U*D*U**H or A = L*D*L**H */ /* > */ /* > where U (or L) is a product of permutation and unit upper (lower) */ /* > triangular matrices, and D is Hermitian and block diagonal with */ /* > 1-by-1 and 2-by-2 diagonal blocks. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] UPLO */ /* > \verbatim */ /* > UPLO is CHARACTER*1 */ /* > = 'U': Upper triangle of A is stored; */ /* > = 'L': Lower triangle of A is stored. */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The order of the matrix A. N >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in,out] AP */ /* > \verbatim */ /* > AP is COMPLEX array, dimension (N*(N+1)/2) */ /* > On entry, the upper or lower triangle of the Hermitian matrix */ /* > A, packed columnwise in a linear array. The j-th column of A */ /* > is stored in the array AP as follows: */ /* > if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ /* > if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ /* > */ /* > On exit, the block diagonal matrix D and the multipliers used */ /* > to obtain the factor U or L, stored as a packed triangular */ /* > matrix overwriting A (see below for further details). */ /* > \endverbatim */ /* > */ /* > \param[out] IPIV */ /* > \verbatim */ /* > IPIV is INTEGER array, dimension (N) */ /* > Details of the interchanges and the block structure of D. */ /* > If IPIV(k) > 0, then rows and columns k and IPIV(k) were */ /* > interchanged and D(k,k) is a 1-by-1 diagonal block. */ /* > If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and */ /* > columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) */ /* > is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) = */ /* > IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were */ /* > interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */ /* > \endverbatim */ /* > */ /* > \param[out] INFO */ /* > \verbatim */ /* > INFO is INTEGER */ /* > = 0: successful exit */ /* > < 0: if INFO = -i, the i-th argument had an illegal value */ /* > > 0: if INFO = i, D(i,i) is exactly zero. The factorization */ /* > has been completed, but the block diagonal matrix D is */ /* > exactly singular, and division by zero will occur if it */ /* > is used to solve a system of equations. */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date December 2016 */ /* > \ingroup complexOTHERcomputational */ /* > \par Further Details: */ /* ===================== */ /* > */ /* > \verbatim */ /* > */ /* > If UPLO = 'U', then A = U*D*U**H, where */ /* > U = P(n)*U(n)* ... *P(k)U(k)* ..., */ /* > i.e., U is a product of terms P(k)*U(k), where k decreases from n to */ /* > 1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1 */ /* > and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as */ /* > defined by IPIV(k), and U(k) is a unit upper triangular matrix, such */ /* > that if the diagonal block D(k) is of order s (s = 1 or 2), then */ /* > */ /* > ( I v 0 ) k-s */ /* > U(k) = ( 0 I 0 ) s */ /* > ( 0 0 I ) n-k */ /* > k-s s n-k */ /* > */ /* > If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k). */ /* > If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k), */ /* > and A(k,k), and v overwrites A(1:k-2,k-1:k). */ /* > */ /* > If UPLO = 'L', then A = L*D*L**H, where */ /* > L = P(1)*L(1)* ... *P(k)*L(k)* ..., */ /* > i.e., L is a product of terms P(k)*L(k), where k increases from 1 to */ /* > n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1 */ /* > and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as */ /* > defined by IPIV(k), and L(k) is a unit lower triangular matrix, such */ /* > that if the diagonal block D(k) is of order s (s = 1 or 2), then */ /* > */ /* > ( I 0 0 ) k-1 */ /* > L(k) = ( 0 I 0 ) s */ /* > ( 0 v I ) n-k-s+1 */ /* > k-1 s n-k-s+1 */ /* > */ /* > If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k). */ /* > If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k), */ /* > and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1). */ /* > \endverbatim */ /* > \par Contributors: */ /* ================== */ /* > */ /* > J. Lewis, Boeing Computer Services Company */ /* > */ /* ===================================================================== */ /* Subroutine */ int chptrf_(char *uplo, integer *n, complex *ap, integer * ipiv, integer *info) { /* System generated locals */ integer i__1, i__2, i__3, i__4, i__5, i__6; real r__1, r__2, r__3, r__4; complex q__1, q__2, q__3, q__4, q__5, q__6; /* Local variables */ extern /* Subroutine */ int chpr_(char *, integer *, real *, complex *, integer *, complex *); integer imax, jmax; real d__; integer i__, j, k; complex t; real alpha; extern logical lsame_(char *, char *); extern /* Subroutine */ int cswap_(integer *, complex *, integer *, complex *, integer *); integer kstep; logical upper; real r1, d11; complex d12; real d22; complex d21; extern real slapy2_(real *, real *); integer kc, kk, kp; real absakk; complex wk; integer kx; extern integer icamax_(integer *, complex *, integer *); real tt; extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer *), xerbla_(char *, integer *, ftnlen); real colmax, rowmax; integer knc, kpc, npp; complex wkm1, wkp1; /* -- LAPACK computational routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* December 2016 */ /* ===================================================================== */ /* Test the input parameters. */ /* Parameter adjustments */ --ipiv; --ap; /* Function Body */ *info = 0; upper = lsame_(uplo, "U"); if (! upper && ! lsame_(uplo, "L")) { *info = -1; } else if (*n < 0) { *info = -2; } if (*info != 0) { i__1 = -(*info); xerbla_("CHPTRF", &i__1, (ftnlen)6); return 0; } /* Initialize ALPHA for use in choosing pivot block size. */ alpha = (sqrt(17.f) + 1.f) / 8.f; if (upper) { /* Factorize A as U*D*U**H using the upper triangle of A */ /* K is the main loop index, decreasing from N to 1 in steps of */ /* 1 or 2 */ k = *n; kc = (*n - 1) * *n / 2 + 1; L10: knc = kc; /* If K < 1, exit from loop */ if (k < 1) { goto L110; } kstep = 1; /* Determine rows and columns to be interchanged and whether */ /* a 1-by-1 or 2-by-2 pivot block will be used */ i__1 = kc + k - 1; absakk = (r__1 = ap[i__1].r, abs(r__1)); /* IMAX is the row-index of the largest off-diagonal element in */ /* column K, and COLMAX is its absolute value */ if (k > 1) { i__1 = k - 1; imax = icamax_(&i__1, &ap[kc], &c__1); i__1 = kc + imax - 1; colmax = (r__1 = ap[i__1].r, abs(r__1)) + (r__2 = r_imag(&ap[kc + imax - 1]), abs(r__2)); } else { colmax = 0.f; } if (f2cmax(absakk,colmax) == 0.f) { /* Column K is zero: set INFO and continue */ if (*info == 0) { *info = k; } kp = k; i__1 = kc + k - 1; i__2 = kc + k - 1; r__1 = ap[i__2].r; ap[i__1].r = r__1, ap[i__1].i = 0.f; } else { if (absakk >= alpha * colmax) { /* no interchange, use 1-by-1 pivot block */ kp = k; } else { /* JMAX is the column-index of the largest off-diagonal */ /* element in row IMAX, and ROWMAX is its absolute value */ rowmax = 0.f; jmax = imax; kx = imax * (imax + 1) / 2 + imax; i__1 = k; for (j = imax + 1; j <= i__1; ++j) { i__2 = kx; if ((r__1 = ap[i__2].r, abs(r__1)) + (r__2 = r_imag(&ap[ kx]), abs(r__2)) > rowmax) { i__2 = kx; rowmax = (r__1 = ap[i__2].r, abs(r__1)) + (r__2 = r_imag(&ap[kx]), abs(r__2)); jmax = j; } kx += j; /* L20: */ } kpc = (imax - 1) * imax / 2 + 1; if (imax > 1) { i__1 = imax - 1; jmax = icamax_(&i__1, &ap[kpc], &c__1); /* Computing MAX */ i__1 = kpc + jmax - 1; r__3 = rowmax, r__4 = (r__1 = ap[i__1].r, abs(r__1)) + ( r__2 = r_imag(&ap[kpc + jmax - 1]), abs(r__2)); rowmax = f2cmax(r__3,r__4); } if (absakk >= alpha * colmax * (colmax / rowmax)) { /* no interchange, use 1-by-1 pivot block */ kp = k; } else /* if(complicated condition) */ { i__1 = kpc + imax - 1; if ((r__1 = ap[i__1].r, abs(r__1)) >= alpha * rowmax) { /* interchange rows and columns K and IMAX, use 1-by-1 */ /* pivot block */ kp = imax; } else { /* interchange rows and columns K-1 and IMAX, use 2-by-2 */ /* pivot block */ kp = imax; kstep = 2; } } } kk = k - kstep + 1; if (kstep == 2) { knc = knc - k + 1; } if (kp != kk) { /* Interchange rows and columns KK and KP in the leading */ /* submatrix A(1:k,1:k) */ i__1 = kp - 1; cswap_(&i__1, &ap[knc], &c__1, &ap[kpc], &c__1); kx = kpc + kp - 1; i__1 = kk - 1; for (j = kp + 1; j <= i__1; ++j) { kx = kx + j - 1; r_cnjg(&q__1, &ap[knc + j - 1]); t.r = q__1.r, t.i = q__1.i; i__2 = knc + j - 1; r_cnjg(&q__1, &ap[kx]); ap[i__2].r = q__1.r, ap[i__2].i = q__1.i; i__2 = kx; ap[i__2].r = t.r, ap[i__2].i = t.i; /* L30: */ } i__1 = kx + kk - 1; r_cnjg(&q__1, &ap[kx + kk - 1]); ap[i__1].r = q__1.r, ap[i__1].i = q__1.i; i__1 = knc + kk - 1; r1 = ap[i__1].r; i__1 = knc + kk - 1; i__2 = kpc + kp - 1; r__1 = ap[i__2].r; ap[i__1].r = r__1, ap[i__1].i = 0.f; i__1 = kpc + kp - 1; ap[i__1].r = r1, ap[i__1].i = 0.f; if (kstep == 2) { i__1 = kc + k - 1; i__2 = kc + k - 1; r__1 = ap[i__2].r; ap[i__1].r = r__1, ap[i__1].i = 0.f; i__1 = kc + k - 2; t.r = ap[i__1].r, t.i = ap[i__1].i; i__1 = kc + k - 2; i__2 = kc + kp - 1; ap[i__1].r = ap[i__2].r, ap[i__1].i = ap[i__2].i; i__1 = kc + kp - 1; ap[i__1].r = t.r, ap[i__1].i = t.i; } } else { i__1 = kc + k - 1; i__2 = kc + k - 1; r__1 = ap[i__2].r; ap[i__1].r = r__1, ap[i__1].i = 0.f; if (kstep == 2) { i__1 = kc - 1; i__2 = kc - 1; r__1 = ap[i__2].r; ap[i__1].r = r__1, ap[i__1].i = 0.f; } } /* Update the leading submatrix */ if (kstep == 1) { /* 1-by-1 pivot block D(k): column k now holds */ /* W(k) = U(k)*D(k) */ /* where U(k) is the k-th column of U */ /* Perform a rank-1 update of A(1:k-1,1:k-1) as */ /* A := A - U(k)*D(k)*U(k)**H = A - W(k)*1/D(k)*W(k)**H */ i__1 = kc + k - 1; r1 = 1.f / ap[i__1].r; i__1 = k - 1; r__1 = -r1; chpr_(uplo, &i__1, &r__1, &ap[kc], &c__1, &ap[1]); /* Store U(k) in column k */ i__1 = k - 1; csscal_(&i__1, &r1, &ap[kc], &c__1); } else { /* 2-by-2 pivot block D(k): columns k and k-1 now hold */ /* ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k) */ /* where U(k) and U(k-1) are the k-th and (k-1)-th columns */ /* of U */ /* Perform a rank-2 update of A(1:k-2,1:k-2) as */ /* A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**H */ /* = A - ( W(k-1) W(k) )*inv(D(k))*( W(k-1) W(k) )**H */ if (k > 2) { i__1 = k - 1 + (k - 1) * k / 2; r__1 = ap[i__1].r; r__2 = r_imag(&ap[k - 1 + (k - 1) * k / 2]); d__ = slapy2_(&r__1, &r__2); i__1 = k - 1 + (k - 2) * (k - 1) / 2; d22 = ap[i__1].r / d__; i__1 = k + (k - 1) * k / 2; d11 = ap[i__1].r / d__; tt = 1.f / (d11 * d22 - 1.f); i__1 = k - 1 + (k - 1) * k / 2; q__1.r = ap[i__1].r / d__, q__1.i = ap[i__1].i / d__; d12.r = q__1.r, d12.i = q__1.i; d__ = tt / d__; for (j = k - 2; j >= 1; --j) { i__1 = j + (k - 2) * (k - 1) / 2; q__3.r = d11 * ap[i__1].r, q__3.i = d11 * ap[i__1].i; r_cnjg(&q__5, &d12); i__2 = j + (k - 1) * k / 2; q__4.r = q__5.r * ap[i__2].r - q__5.i * ap[i__2].i, q__4.i = q__5.r * ap[i__2].i + q__5.i * ap[ i__2].r; q__2.r = q__3.r - q__4.r, q__2.i = q__3.i - q__4.i; q__1.r = d__ * q__2.r, q__1.i = d__ * q__2.i; wkm1.r = q__1.r, wkm1.i = q__1.i; i__1 = j + (k - 1) * k / 2; q__3.r = d22 * ap[i__1].r, q__3.i = d22 * ap[i__1].i; i__2 = j + (k - 2) * (k - 1) / 2; q__4.r = d12.r * ap[i__2].r - d12.i * ap[i__2].i, q__4.i = d12.r * ap[i__2].i + d12.i * ap[i__2] .r; q__2.r = q__3.r - q__4.r, q__2.i = q__3.i - q__4.i; q__1.r = d__ * q__2.r, q__1.i = d__ * q__2.i; wk.r = q__1.r, wk.i = q__1.i; for (i__ = j; i__ >= 1; --i__) { i__1 = i__ + (j - 1) * j / 2; i__2 = i__ + (j - 1) * j / 2; i__3 = i__ + (k - 1) * k / 2; r_cnjg(&q__4, &wk); q__3.r = ap[i__3].r * q__4.r - ap[i__3].i * q__4.i, q__3.i = ap[i__3].r * q__4.i + ap[ i__3].i * q__4.r; q__2.r = ap[i__2].r - q__3.r, q__2.i = ap[i__2].i - q__3.i; i__4 = i__ + (k - 2) * (k - 1) / 2; r_cnjg(&q__6, &wkm1); q__5.r = ap[i__4].r * q__6.r - ap[i__4].i * q__6.i, q__5.i = ap[i__4].r * q__6.i + ap[ i__4].i * q__6.r; q__1.r = q__2.r - q__5.r, q__1.i = q__2.i - q__5.i; ap[i__1].r = q__1.r, ap[i__1].i = q__1.i; /* L40: */ } i__1 = j + (k - 1) * k / 2; ap[i__1].r = wk.r, ap[i__1].i = wk.i; i__1 = j + (k - 2) * (k - 1) / 2; ap[i__1].r = wkm1.r, ap[i__1].i = wkm1.i; i__1 = j + (j - 1) * j / 2; i__2 = j + (j - 1) * j / 2; r__1 = ap[i__2].r; q__1.r = r__1, q__1.i = 0.f; ap[i__1].r = q__1.r, ap[i__1].i = q__1.i; /* L50: */ } } } } /* Store details of the interchanges in IPIV */ if (kstep == 1) { ipiv[k] = kp; } else { ipiv[k] = -kp; ipiv[k - 1] = -kp; } /* Decrease K and return to the start of the main loop */ k -= kstep; kc = knc - k; goto L10; } else { /* Factorize A as L*D*L**H using the lower triangle of A */ /* K is the main loop index, increasing from 1 to N in steps of */ /* 1 or 2 */ k = 1; kc = 1; npp = *n * (*n + 1) / 2; L60: knc = kc; /* If K > N, exit from loop */ if (k > *n) { goto L110; } kstep = 1; /* Determine rows and columns to be interchanged and whether */ /* a 1-by-1 or 2-by-2 pivot block will be used */ i__1 = kc; absakk = (r__1 = ap[i__1].r, abs(r__1)); /* IMAX is the row-index of the largest off-diagonal element in */ /* column K, and COLMAX is its absolute value */ if (k < *n) { i__1 = *n - k; imax = k + icamax_(&i__1, &ap[kc + 1], &c__1); i__1 = kc + imax - k; colmax = (r__1 = ap[i__1].r, abs(r__1)) + (r__2 = r_imag(&ap[kc + imax - k]), abs(r__2)); } else { colmax = 0.f; } if (f2cmax(absakk,colmax) == 0.f) { /* Column K is zero: set INFO and continue */ if (*info == 0) { *info = k; } kp = k; i__1 = kc; i__2 = kc; r__1 = ap[i__2].r; ap[i__1].r = r__1, ap[i__1].i = 0.f; } else { if (absakk >= alpha * colmax) { /* no interchange, use 1-by-1 pivot block */ kp = k; } else { /* JMAX is the column-index of the largest off-diagonal */ /* element in row IMAX, and ROWMAX is its absolute value */ rowmax = 0.f; kx = kc + imax - k; i__1 = imax - 1; for (j = k; j <= i__1; ++j) { i__2 = kx; if ((r__1 = ap[i__2].r, abs(r__1)) + (r__2 = r_imag(&ap[ kx]), abs(r__2)) > rowmax) { i__2 = kx; rowmax = (r__1 = ap[i__2].r, abs(r__1)) + (r__2 = r_imag(&ap[kx]), abs(r__2)); jmax = j; } kx = kx + *n - j; /* L70: */ } kpc = npp - (*n - imax + 1) * (*n - imax + 2) / 2 + 1; if (imax < *n) { i__1 = *n - imax; jmax = imax + icamax_(&i__1, &ap[kpc + 1], &c__1); /* Computing MAX */ i__1 = kpc + jmax - imax; r__3 = rowmax, r__4 = (r__1 = ap[i__1].r, abs(r__1)) + ( r__2 = r_imag(&ap[kpc + jmax - imax]), abs(r__2)); rowmax = f2cmax(r__3,r__4); } if (absakk >= alpha * colmax * (colmax / rowmax)) { /* no interchange, use 1-by-1 pivot block */ kp = k; } else /* if(complicated condition) */ { i__1 = kpc; if ((r__1 = ap[i__1].r, abs(r__1)) >= alpha * rowmax) { /* interchange rows and columns K and IMAX, use 1-by-1 */ /* pivot block */ kp = imax; } else { /* interchange rows and columns K+1 and IMAX, use 2-by-2 */ /* pivot block */ kp = imax; kstep = 2; } } } kk = k + kstep - 1; if (kstep == 2) { knc = knc + *n - k + 1; } if (kp != kk) { /* Interchange rows and columns KK and KP in the trailing */ /* submatrix A(k:n,k:n) */ if (kp < *n) { i__1 = *n - kp; cswap_(&i__1, &ap[knc + kp - kk + 1], &c__1, &ap[kpc + 1], &c__1); } kx = knc + kp - kk; i__1 = kp - 1; for (j = kk + 1; j <= i__1; ++j) { kx = kx + *n - j + 1; r_cnjg(&q__1, &ap[knc + j - kk]); t.r = q__1.r, t.i = q__1.i; i__2 = knc + j - kk; r_cnjg(&q__1, &ap[kx]); ap[i__2].r = q__1.r, ap[i__2].i = q__1.i; i__2 = kx; ap[i__2].r = t.r, ap[i__2].i = t.i; /* L80: */ } i__1 = knc + kp - kk; r_cnjg(&q__1, &ap[knc + kp - kk]); ap[i__1].r = q__1.r, ap[i__1].i = q__1.i; i__1 = knc; r1 = ap[i__1].r; i__1 = knc; i__2 = kpc; r__1 = ap[i__2].r; ap[i__1].r = r__1, ap[i__1].i = 0.f; i__1 = kpc; ap[i__1].r = r1, ap[i__1].i = 0.f; if (kstep == 2) { i__1 = kc; i__2 = kc; r__1 = ap[i__2].r; ap[i__1].r = r__1, ap[i__1].i = 0.f; i__1 = kc + 1; t.r = ap[i__1].r, t.i = ap[i__1].i; i__1 = kc + 1; i__2 = kc + kp - k; ap[i__1].r = ap[i__2].r, ap[i__1].i = ap[i__2].i; i__1 = kc + kp - k; ap[i__1].r = t.r, ap[i__1].i = t.i; } } else { i__1 = kc; i__2 = kc; r__1 = ap[i__2].r; ap[i__1].r = r__1, ap[i__1].i = 0.f; if (kstep == 2) { i__1 = knc; i__2 = knc; r__1 = ap[i__2].r; ap[i__1].r = r__1, ap[i__1].i = 0.f; } } /* Update the trailing submatrix */ if (kstep == 1) { /* 1-by-1 pivot block D(k): column k now holds */ /* W(k) = L(k)*D(k) */ /* where L(k) is the k-th column of L */ if (k < *n) { /* Perform a rank-1 update of A(k+1:n,k+1:n) as */ /* A := A - L(k)*D(k)*L(k)**H = A - W(k)*(1/D(k))*W(k)**H */ i__1 = kc; r1 = 1.f / ap[i__1].r; i__1 = *n - k; r__1 = -r1; chpr_(uplo, &i__1, &r__1, &ap[kc + 1], &c__1, &ap[kc + *n - k + 1]); /* Store L(k) in column K */ i__1 = *n - k; csscal_(&i__1, &r1, &ap[kc + 1], &c__1); } } else { /* 2-by-2 pivot block D(k): columns K and K+1 now hold */ /* ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k) */ /* where L(k) and L(k+1) are the k-th and (k+1)-th columns */ /* of L */ if (k < *n - 1) { /* Perform a rank-2 update of A(k+2:n,k+2:n) as */ /* A := A - ( L(k) L(k+1) )*D(k)*( L(k) L(k+1) )**H */ /* = A - ( W(k) W(k+1) )*inv(D(k))*( W(k) W(k+1) )**H */ /* where L(k) and L(k+1) are the k-th and (k+1)-th */ /* columns of L */ i__1 = k + 1 + (k - 1) * ((*n << 1) - k) / 2; r__1 = ap[i__1].r; r__2 = r_imag(&ap[k + 1 + (k - 1) * ((*n << 1) - k) / 2]); d__ = slapy2_(&r__1, &r__2); i__1 = k + 1 + k * ((*n << 1) - k - 1) / 2; d11 = ap[i__1].r / d__; i__1 = k + (k - 1) * ((*n << 1) - k) / 2; d22 = ap[i__1].r / d__; tt = 1.f / (d11 * d22 - 1.f); i__1 = k + 1 + (k - 1) * ((*n << 1) - k) / 2; q__1.r = ap[i__1].r / d__, q__1.i = ap[i__1].i / d__; d21.r = q__1.r, d21.i = q__1.i; d__ = tt / d__; i__1 = *n; for (j = k + 2; j <= i__1; ++j) { i__2 = j + (k - 1) * ((*n << 1) - k) / 2; q__3.r = d11 * ap[i__2].r, q__3.i = d11 * ap[i__2].i; i__3 = j + k * ((*n << 1) - k - 1) / 2; q__4.r = d21.r * ap[i__3].r - d21.i * ap[i__3].i, q__4.i = d21.r * ap[i__3].i + d21.i * ap[i__3] .r; q__2.r = q__3.r - q__4.r, q__2.i = q__3.i - q__4.i; q__1.r = d__ * q__2.r, q__1.i = d__ * q__2.i; wk.r = q__1.r, wk.i = q__1.i; i__2 = j + k * ((*n << 1) - k - 1) / 2; q__3.r = d22 * ap[i__2].r, q__3.i = d22 * ap[i__2].i; r_cnjg(&q__5, &d21); i__3 = j + (k - 1) * ((*n << 1) - k) / 2; q__4.r = q__5.r * ap[i__3].r - q__5.i * ap[i__3].i, q__4.i = q__5.r * ap[i__3].i + q__5.i * ap[ i__3].r; q__2.r = q__3.r - q__4.r, q__2.i = q__3.i - q__4.i; q__1.r = d__ * q__2.r, q__1.i = d__ * q__2.i; wkp1.r = q__1.r, wkp1.i = q__1.i; i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { i__3 = i__ + (j - 1) * ((*n << 1) - j) / 2; i__4 = i__ + (j - 1) * ((*n << 1) - j) / 2; i__5 = i__ + (k - 1) * ((*n << 1) - k) / 2; r_cnjg(&q__4, &wk); q__3.r = ap[i__5].r * q__4.r - ap[i__5].i * q__4.i, q__3.i = ap[i__5].r * q__4.i + ap[ i__5].i * q__4.r; q__2.r = ap[i__4].r - q__3.r, q__2.i = ap[i__4].i - q__3.i; i__6 = i__ + k * ((*n << 1) - k - 1) / 2; r_cnjg(&q__6, &wkp1); q__5.r = ap[i__6].r * q__6.r - ap[i__6].i * q__6.i, q__5.i = ap[i__6].r * q__6.i + ap[ i__6].i * q__6.r; q__1.r = q__2.r - q__5.r, q__1.i = q__2.i - q__5.i; ap[i__3].r = q__1.r, ap[i__3].i = q__1.i; /* L90: */ } i__2 = j + (k - 1) * ((*n << 1) - k) / 2; ap[i__2].r = wk.r, ap[i__2].i = wk.i; i__2 = j + k * ((*n << 1) - k - 1) / 2; ap[i__2].r = wkp1.r, ap[i__2].i = wkp1.i; i__2 = j + (j - 1) * ((*n << 1) - j) / 2; i__3 = j + (j - 1) * ((*n << 1) - j) / 2; r__1 = ap[i__3].r; q__1.r = r__1, q__1.i = 0.f; ap[i__2].r = q__1.r, ap[i__2].i = q__1.i; /* L100: */ } } } } /* Store details of the interchanges in IPIV */ if (kstep == 1) { ipiv[k] = kp; } else { ipiv[k] = -kp; ipiv[k + 1] = -kp; } /* Increase K and return to the start of the main loop */ k += kstep; kc = knc + *n - k + 2; goto L60; } L110: return 0; /* End of CHPTRF */ } /* chptrf_ */
the_stack_data/29381.c
#if defined(SUPPORT_NP2_TICKCOUNT) #include <np2_tickcount.h> #include <time.h> #if defined(NP2_WIN) #include <windows.h> #elif defined(NP2_SDL) #include <SDL.h> #elif defined(__LIBRETRO__) #include <features/features_cpu.h> #endif static int64_t initcount; #if defined(__LIBRETRO__) static int64_t inittime; static int64_t lastcount; static int64_t lasttime; #endif int64_t NP2_TickCount_GetCount(void) { #if defined(NP2_WIN) LARGE_INTEGER count; QueryPerformanceCounter(&count); return count.QuadPart; #elif defined(NP2_SDL) #if SDL_MAJOR_VERSION == 1 return SDL_GetTicks(); #else return SDL_GetPerformanceCounter(); #endif #elif defined(__LIBRETRO__) lastcount = cpu_features_get_perf_counter(); lasttime = cpu_features_get_time_usec(); return lastcount; #else struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return ts.tv_sec * 1000000000 + ts.tv_nsec; #endif } int64_t NP2_TickCount_GetFrequency(void) { #if defined(NP2_WIN) LARGE_INTEGER freq; QueryPerformanceFrequency(&freq); return freq.QuadPart; #elif defined(NP2_SDL) #if SDL_MAJOR_VERSION == 1 return 100000000; #else return SDL_GetPerformanceFrequency(); #endif #elif defined(__LIBRETRO__) int64_t nowcount = cpu_features_get_perf_counter(); int64_t nowtime = cpu_features_get_time_usec(); int64_t ret; if(nowtime > lasttime) { ret = ((nowcount - lastcount) / (nowtime - lasttime)) * 1000000; } else { ret = 0; } lastcount = nowtime; lasttime = nowtime; return ret; #else struct timespec res; clock_getres(CLOCK_MONOTONIC, &res); return 1000000000 / (res.tv_sec * 1000000000 + res.tv_nsec); #endif } void NP2_TickCount_Initialize(void) { initcount = NP2_TickCount_GetCount(); #if defined(__LIBRETRO__) inittime = cpu_features_get_time_usec(); lastcount = initcount; lasttime = inittime; #endif } int64_t NP2_TickCount_GetCountFromInit(void) { return NP2_TickCount_GetCount() - initcount; } #if !defined(_WINDOWS) && defined(SUPPORT_NP2_TICKCOUNT) BOOL QueryPerformanceCounter(LARGE_INTEGER* count) { int64_t icount = NP2_TickCount_GetCount(); COPY64(count, &icount); return TRUE; } BOOL QueryPerformanceFrequency(LARGE_INTEGER* freq) { int64_t ifreq = NP2_TickCount_GetFrequency(); COPY64(freq, &ifreq); return TRUE; } #endif #endif // SUPPORT_NP2_TICKCOUNT
the_stack_data/106176.c
#include <stdio.h> #include <string.h> #include <stdlib.h> /* * Strips spaces from both the front and back of a string, * leaving any internal spaces alone. */ char* strip(char* str) { int size; int num_spaces; int first_non_space, last_non_space, i; char* result; size = strlen(str); // This counts the number of leading and trailing spaces // so we can figure out how big the result array should be. num_spaces = 0; first_non_space = 0; while (first_non_space<size && str[first_non_space] == ' ') { ++num_spaces; ++first_non_space; } last_non_space = size-1; while (last_non_space>=0 && str[last_non_space] == ' ') { ++num_spaces; --last_non_space; } // If num_spaces >= size then that means that the string // consisted of nothing but spaces, so we'll return the // empty string. if (num_spaces >= size) { return ""; } // Allocate a slot for all the "saved" characters // plus one extra for the null terminator. result = calloc(size-num_spaces+1, sizeof(char)); // Copy in the "saved" characters. for (i=first_non_space; i<=last_non_space; ++i) { result[i-first_non_space] = str[i]; } free(result); // Place the null terminator at the end of the result string. result[i-first_non_space] = '\0'; return result; } /* * Return true (1) if the given string is "clean", i.e., has * no spaces at the front or the back of the string. */ int is_clean(char* str) { char* cleaned; int result; // We check if it's clean by calling strip and seeing if the // result is the same as the original string. cleaned = strip(str); // strcmp compares two strings, returning a negative value if // the first is less than the second (in alphabetical order), // 0 if they're equal, and a positive value if the first is // greater than the second. result = strcmp(str, cleaned); return result == 0; } int main() { int i; int NUM_STRINGS = 7; // Makes an array of 7 string constants for testing. char* strings[] = { "Morris", " stuff", "Minnesota", "nonsense ", "USA", " ", " silliness " }; for (i=0; i<NUM_STRINGS; ++i) { if (is_clean(strings[i])) { printf("The string '%s' is clean.\n", strings[i]); } else { printf("The string '%s' is NOT clean.\n", strings[i]); } } return 0; }
the_stack_data/153267189.c
#include <stdio.h> int main() { return(0); }
the_stack_data/700608.c
#include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> #include <time.h> #define MAXN 21 #define NUM_BUFS 5 typedef unsigned char bool; #define true 1 #define false 0 #define MAX_MASK_COUNT 5 #define MAX_MASKS 5009 int masksByBitCount[MAX_MASK_COUNT][MAX_MASKS]; int maskCountByBitCount[MAXN]; #define isBitOn(mask, i) ((mask) & (1<<(i))) #define flipBit(mask, i) (mask ^= (1<<(i))) #define turnBitOn(mask, i) (mask |= (1<<(i))) #define turnBitOff(mask, i) (mask &= ~(1<<(i))) #define bitCount(mask) __builtin_popcount(mask) #define lastBitPos(mask) __builtin_ctz(mask) #define lastBitOnly(mask) ((mask) & -(mask)) #define turnLastBitOff(mask) (mask &= ~lastBitOnly(mask)) clock_t startTime; FILE *inputFile, *outputFile, *instructionFile; void cleanUp() { if (inputFile != stdin) { fclose(inputFile); } if (outputFile != stdout) { fclose(outputFile); } if (instructionFile != stdout && instructionFile != outputFile) { fclose(instructionFile); } } bool debug, verbose, instructions, noGuessing, help; char fmtBufs[NUM_BUFS][1009]; int fmtBufIndex = 0; const char* fmt(const char* template, ...) { if (!debug && !verbose && !instructions) { return ""; } va_list args; va_start(args, template); int i = fmtBufIndex; fmtBufIndex = (fmtBufIndex + 1) % NUM_BUFS; vsprintf(fmtBufs[i], template, args); va_end(args); return fmtBufs[i]; } void levelLog(const char* level, const char* msg) { clock_t curTime = clock(); clock_t elapsedTime = curTime - startTime; int timeMs = elapsedTime * 1000 / CLOCKS_PER_SEC; printf("[%dms][%s]: %s\n", timeMs, level, msg); } void debugf(const char* msg) { if (debug) { levelLog("DEBUG", msg); } } void infof(const char* msg) { if (verbose) { levelLog("INFO", msg); } } void fatalf(const char* msg) { levelLog("FATAL", msg); cleanUp(); exit(1); } int numberList[NUM_BUFS][MAXN]; int numberListIndex = 0; const int* maskToList(int mask) { int sz = 0, u; int i = numberListIndex; numberListIndex = (numberListIndex + 1) % NUM_BUFS; while (mask > 0) { u = lastBitPos(mask); numberList[i][sz++] = u; turnBitOff(mask, u); } return numberList[i]; } char numbersBuf[NUM_BUFS][1009]; char numbersBufIndex = 0; const char* prettyBufNumbers(const int *arr, int n) { int i = numbersBufIndex; numbersBufIndex = (numbersBufIndex + 1) % NUM_BUFS; char numberBuf[5]; strcpy(numbersBuf[i], "["); int sz = strlen(numbersBuf[i]); for (int j = 0; j < n; j++) { sprintf(numberBuf, "%d ", arr[j]); strcpy(numbersBuf[i] + sz, numberBuf); sz += strlen(numberBuf); } numbersBuf[i][sz-1] = ']'; return numbersBuf[i]; } char sudokuBuf[1009]; const char* prettyBufSudoku(int sudoku[MAXN][MAXN], int nm) { sudokuBuf[0] = '\0'; char numberBuf[5]; char template[10]; if (nm < 10) { sprintf(template, "%%d "); } else { sprintf(template, "%%2d "); } int sz = 0; for (int i = 0; i < nm; i++) { for (int j = 0; j < nm; j++) { sprintf(numberBuf, template, sudoku[i][j]); strcpy(sudokuBuf + sz, numberBuf); sz += strlen(numberBuf); } sudokuBuf[sz-1] = '\n'; } return sudokuBuf; } int n, m, nm; int sudoku[MAXN][MAXN], initialDiscoveries; bool restricted, impossible, done; #define DISCOVER 1 #define CANNOT_BE 2 #define REASON_BUF 209 #define MAXEVENTS 10009 typedef struct event { int type; int i, j, u; char reason[REASON_BUF]; } event; event events[MAXEVENTS]; int eventCount = 0; #define ROW 0 #define COL 1 #define QUA 2 typedef struct block { int index; int dimensionId; const char *dimensionName; int canBePosMask[MAXN]; int it[MAXN]; int jt[MAXN]; } block; block blocks[3][MAXN]; block *blocksByPos[MAXN][MAXN][3]; int discoveries, guesses, steps; int canBeMask[MAXN][MAXN]; #define canBe(i, j, u) isBitOn(canBeMask[i][j], u) #define canBeCount(i, j) bitCount(canBeMask[i][j]) #define canBeLast(i, j) lastBitPos(canBeMask[i][j]) void rollbackEvents(const int eventIndex) { while (eventCount > eventIndex) { event e = events[--eventCount]; if (e.type == DISCOVER) { sudoku[e.i][e.j] = 0; discoveries--; } else if (e.type == CANNOT_BE) { turnBitOn(canBeMask[e.i][e.j], e.u); for (int d = 0; d < 3; d++) { block *b = blocksByPos[e.i][e.j][d]; for (int t = 0; t < nm; t++) { int ni = b->it[t], nj = b->jt[t]; if (ni == e.i && nj == e.j) { turnBitOn(b->canBePosMask[e.u], t); break; } } } } else { fatalf(fmt("Found event of unknown type %d.", e.type)); } } } void applyEvent(const event e) { events[eventCount++] = e; steps++; if (e.type == DISCOVER) { sudoku[e.i][e.j] = e.u; discoveries++; debugf(fmt("Discovered number %d at position (%d,%d); reason: %s; discoveries: %d.", e.u, e.i, e.j, e.reason, discoveries)); if (discoveries == nm*nm) { done = true; } } else if (e.type == CANNOT_BE) { turnBitOff(canBeMask[e.i][e.j], e.u); for (int d = 0; d < 3; d++) { block *b = blocksByPos[e.i][e.j][d]; for (int t = 0; t < nm; t++) { int ni = b->it[t], nj = b->jt[t]; if (ni == e.i && nj == e.j) { turnBitOff(b->canBePosMask[e.u], t); break; } } } int cnt = canBeCount(e.i, e.j); const int *canBeList = maskToList(canBeMask[e.i][e.j]); debugf(fmt("Number %d cannot be at (%d,%d); reason: %s; possiblities left: %s.", e.u, e.i, e.j, e.reason, prettyBufNumbers(canBeList, cnt))); } else { fatalf(fmt("Found event of unknown type %d.", e.type)); } // signal that we made progress this round restricted = true; } void discover(int i, int j, int u, const char *reason) { if (impossible) { return; } if (sudoku[i][j] != 0) { if (sudoku[i][j] != u) { debugf(fmt("Inconsistency in discovery; found %d and %d at (%d,%d); reason for latest: %s.", sudoku[i][j], u, i, j, reason)); impossible = true; } return; } // create event event e; e.type = DISCOVER; e.i = i; e.j = j; e.u = u; if (reason != NULL) { strcpy(e.reason, reason); } // change state of the world applyEvent(e); } void cannotBe(int i, int j, int u, const char *reason) { if (impossible || !canBe(i, j, u)) { return; } // create event event e; e.type = CANNOT_BE; e.i = i; e.j = j; e.u = u; if (reason != NULL) { strcpy(e.reason, reason); } // change state of the world applyEvent(e); // hidden single for (int d = 0; d < 3; d++) { block *b = blocksByPos[i][j][d]; int left = bitCount(b->canBePosMask[u]); if (left == 0) { debugf(fmt("Inconsistency in restriction of (%d,%d) to %d; no remaining possibilities for the number in %s %d; reason for latest: %s.", i, j, u, b->dimensionName, b->index, reason)); impossible = true; return; } else if (left == 1) { int t = lastBitPos(b->canBePosMask[u]); int ni = b->it[t], nj = b->jt[t]; if (canBe(ni, nj, u)) { discover(ni, nj, u, fmt("it is the last possibility for the %s; discoveries: %d", b->dimensionName, discoveries+1)); } } } // naked single if (canBeCount(i, j) == 1) { discover(i, j, canBeLast(i, j), fmt("it is the last possibility for the cell; discoveries: %d", discoveries+1)); } } void init() { // reset global control variables done = impossible = false; // reset global statistics variables guesses = steps = 0; // reset events eventCount = 0; // reset discoveries to identify when the game is done discoveries = initialDiscoveries; // set canBeMask to 111..1110 (nm 1's) for (int i = 0; i < nm; i++) { for (int j = 0; j < nm; j++) { canBeMask[i][j] = ((1<<nm)-1)<<1; } } // build row blocks for(int r = 0; r < nm; r++) { blocks[ROW][r].index = r; blocks[ROW][r].dimensionId = ROW; blocks[ROW][r].dimensionName = "row"; for (int u = 1; u <= nm; u++) { blocks[ROW][r].canBePosMask[u] = (1<<nm)-1; } for (int t = 0; t < nm; t++) { blocks[ROW][r].it[t] = r; blocks[ROW][r].jt[t] = t; } } // build columns blocks for(int c = 0; c < nm; c++) { blocks[COL][c].index = c; blocks[COL][c].dimensionId = COL; blocks[COL][c].dimensionName = "column"; for (int u = 1; u <= nm; u++) { blocks[COL][c].canBePosMask[u] = (1<<nm)-1; } for (int t = 0; t < nm; t++) { blocks[COL][c].it[t] = t; blocks[COL][c].jt[t] = c; } } // build quadrant blocks for(int q = 0; q < nm; q++) { blocks[ROW][q].index = q; blocks[QUA][q].dimensionId = QUA; blocks[QUA][q].dimensionName = "quadrant"; for (int u = 1; u <= nm; u++) { blocks[QUA][q].canBePosMask[u] = (1<<nm)-1; } int bi = (q/n)*n, bj = (q%n)*m; for (int t = 0; t < nm; t++) { blocks[QUA][q].it[t] = bi + (t/m); blocks[QUA][q].jt[t] = bj + (t%m); } } // set blocksByPos for (int d = 0; d < 3; d++) { for (int bt = 0; bt < nm; bt++) { block *b = &blocks[d][bt]; for (int t = 0; t < nm; t++) { int i = b->it[t], j = b->jt[t]; blocksByPos[i][j][d] = b; } } } // set masksByBitCount memset(maskCountByBitCount, 0, sizeof maskCountByBitCount); for (int mask = 0; mask < (1<<nm); mask++) { int cnt = bitCount(mask); if (cnt >= MAX_MASK_COUNT) { continue; } if (maskCountByBitCount[cnt] == MAX_MASKS) { fatalf("Overflow while computing number of masks"); } masksByBitCount[cnt][maskCountByBitCount[cnt]++] = mask; } debugf("Initialized solver variables."); } void restrictDiscoveries() { for (int i = 0; i < nm; i++) { for (int j = 0; j < nm; j++) { int u = sudoku[i][j]; if (u == 0) { continue; } for (int canBeMaskIt = canBeMask[i][j]; canBeMaskIt; turnLastBitOff(canBeMaskIt)) { int v = lastBitPos(canBeMaskIt); if (v == u) { continue; } cannotBe(i, j, v, fmt("discovered number %d in its place", u)); } for (int d = 0; d < 3; d++) { block *b = blocksByPos[i][j][d]; for (int posMaskIt = b->canBePosMask[u]; posMaskIt; turnLastBitOff(posMaskIt)) { int t = lastBitPos(posMaskIt); int ni = b->it[t], nj = b->jt[t]; if (ni == i && nj == j) { continue; } cannotBe(ni, nj, u, fmt("discovered the number %d at the same %s at position (%d,%d)", u, b->dimensionName, i, j)); } } } } } bool restrictedPointers[3][MAXN][3][MAXN]; void restrictPointer(block *b1, int d2, int u) { if (restrictedPointers[b1->dimensionId][b1->index][d2][u]) { return; } block *b2 = NULL; for (int posMaskIt = b1->canBePosMask[u]; posMaskIt; turnLastBitOff(posMaskIt)) { int t = lastBitPos(posMaskIt); int i = b1->it[t], j = b1->jt[t]; block *cand = blocksByPos[i][j][d2]; if (b2 == NULL || cand == b2) { b2 = cand; } else { return; } } if (b2 == NULL) { impossible = true; return; } debugf(fmt("At %s %d, number %d can only be at %s %d; removing possibilites for this %s in other %ss.", b1->dimensionName, b1->index, u, b2->dimensionName, b2->index, b2->dimensionName, b1->dimensionName)); restrictedPointers[b1->dimensionId][b1->index][d2][u] = true; for (int posMaskIt = b2->canBePosMask[u]; posMaskIt; turnLastBitOff(posMaskIt)) { int t = lastBitPos(posMaskIt); int i = b2->it[t], j = b2->jt[t]; if (blocksByPos[i][j][b1->dimensionId] == b1) { continue; } cannotBe(i, j, u, fmt("%s %d definitely has this number in this %s", b1->dimensionName, b1->index, b2->dimensionName)); } } void restrictNaked(block *b, int posMask) { int valueMask = 0; for (int posMaskIt = posMask; posMaskIt; turnLastBitOff(posMaskIt)) { int t = lastBitPos(posMaskIt); int i = b->it[t], j = b->jt[t]; valueMask |= canBeMask[i][j]; } if (bitCount(posMask) != bitCount(valueMask)) { return; } const int *valueMaskList = maskToList(valueMask); const char *valueMaskBuf = prettyBufNumbers(valueMaskList, bitCount(valueMask)); const int *posMaskList = maskToList(posMask); const char *posMaskBuf = prettyBufNumbers(posMaskList, bitCount(posMask)); for (int posMaskIt = (((1<<nm)-1)^posMask); posMaskIt; turnLastBitOff(posMaskIt)) { int t = lastBitPos(posMaskIt); int i = b->it[t], j = b->jt[t]; for (int valueMaskIt = valueMask; valueMaskIt; turnLastBitOff(valueMaskIt)) { int u = lastBitPos(valueMaskIt); cannotBe(i, j, u, fmt("naked combination along %s %d of numbers %s at indexes %s found at cell", b->dimensionName, b->index, valueMaskBuf, posMaskBuf)); } } } void restrictHidden(block *b, int valueMask) { int posMask = 0; for (int valueMaskIt = valueMask; valueMaskIt; turnLastBitOff(valueMaskIt)) { int u = lastBitPos(valueMaskIt); posMask |= b->canBePosMask[u]; } if (bitCount(posMask) != bitCount(valueMask)) { return; } const int *valueMaskList = maskToList(valueMask); const char *valueMaskBuf = prettyBufNumbers(valueMaskList, bitCount(valueMask)); const int *posMaskList = maskToList(posMask); const char *posMaskBuf = prettyBufNumbers(posMaskList, bitCount(posMask)); for (int posMaskIt = posMask; posMaskIt; turnLastBitOff(posMaskIt)) { int t = lastBitPos(posMaskIt); int i = b->it[t], j = b->jt[t]; for (int valueMaskIt = ((((1<<nm)-1)<<1)^valueMask)&canBeMask[i][j]; valueMaskIt; turnLastBitOff(valueMaskIt)) { int u = lastBitPos(valueMaskIt); cannotBe(i, j, u, fmt("hidden combination along %s %d of numbers %s at indexes %s found at cell", b->dimensionName, b->index, valueMaskBuf, posMaskBuf)); } } } void restrictXWing(int d, int u) { int btMask = 0; for (int b1t = 0; b1t < nm; b1t++) { block *b1 = &blocks[d][b1t]; if (bitCount(b1->canBePosMask[u]) != 2) { continue; } for (int btMaskIt = btMask; btMaskIt; turnLastBitOff(btMaskIt)) { int b2t = lastBitPos(btMaskIt); block *b2 = &blocks[d][b2t]; if (b1->canBePosMask[u] != b2->canBePosMask[u]) { continue; } const int *posMaskList = maskToList(b1->canBePosMask[u]); const char *posMaskBuf = prettyBufNumbers(posMaskList, bitCount(b1->canBePosMask[u])); for (int bt = 0; bt < nm; bt++) { if (bt == b1t || bt == b2t) { continue; } block *b = &blocks[d][bt]; for (int posMaskIt = (b1->canBePosMask[u])&(b->canBePosMask[u]); posMaskIt; turnLastBitOff(posMaskIt)) { int t = lastBitPos(posMaskIt); int i = b->it[t], j = b->jt[t]; cannotBe(i, j, u, fmt("X wing of number %d found in %ss %d and %d at indexes %s", u, b->dimensionName, b2t, b1t, posMaskBuf)); } } } turnBitOn(btMask, b1t); } } void restrictAll() { restrictDiscoveries(); for (int bt = 0; bt < nm; bt++) { for (int u = 1; u <= nm; u++) { restrictPointer(&blocks[ROW][bt], QUA, u); restrictPointer(&blocks[COL][bt], QUA, u); restrictPointer(&blocks[QUA][bt], ROW, u); restrictPointer(&blocks[QUA][bt], COL, u); } } if (restricted || impossible) { return; } for (int cnt = 2; cnt < 4; cnt++) { for (int maskt = 0; maskt < maskCountByBitCount[cnt]; maskt++) { int mask = masksByBitCount[cnt][maskt]; for (int d = 0; d < 3; d++) { for (int t = 0; t < nm; t++) { if (restrictNaked(&blocks[d][t], mask), restricted || impossible) { return; } if (restrictHidden(&blocks[d][t], mask<<1), restricted || impossible) { return; } } } } } for (int u = 1; u <= nm; u++) { if (restrictXWing(ROW, u), restricted || impossible) { return; } if (restrictXWing(COL, u), restricted || impossible) { return; } } for (int maskt = 0; maskt < maskCountByBitCount[4]; maskt++) { int mask = masksByBitCount[4][maskt]; for (int d = 0; d < 3; d++) { for (int t = 0; t < nm; t++) { if (restrictNaked(&blocks[d][t], mask), restricted || impossible) { return; } if (restrictHidden(&blocks[d][t], mask<<1), restricted || impossible) { return; } } } } } void searchBestGuess(int *ri, int *rj, int *ru, char *reason) { int minPossibilities = nm+1; debugf(fmt("Searching for best guess. discoveries: %d.", discoveries)); for (int i = 0; i < nm && minPossibilities > 2; i++) { for (int j = 0; j < nm && minPossibilities > 2; j++) { if (sudoku[i][j] != 0) { continue; } int possibilities = canBeCount(i, j); int u = canBeLast(i, j); if (minPossibilities > possibilities) { minPossibilities = possibilities; *ri = i; *rj = j; *ru = u; strcpy(reason, fmt("%d possibilities at cell; discoveries: %d", possibilities, discoveries+1)); debugf(fmt("Candidate %d at (%d,%d); %d possibilities at %s.", u, i, j, possibilities, "cell")); } } } for (int d = 0; d < 3 && minPossibilities > 2; d++) { for (int bt = 0; bt < nm && minPossibilities > 2; bt++) { block *b = &blocks[d][bt]; for (int u = 1; u <= nm && minPossibilities > 2; u++) { int t = lastBitPos(b->canBePosMask[u]); int i = b->it[t], j = b->jt[t]; if (sudoku[i][j] != 0) { continue; } int possibilities = bitCount(b->canBePosMask[u]); if (minPossibilities > possibilities) { minPossibilities = possibilities; *ri = i; *rj = j; *ru = u; strcpy(reason, fmt("%d possibilities at %s %d; discoveries: %d", possibilities, b->dimensionName, b->index, discoveries+1)); debugf(fmt("Candidate %d at (%d,%d); %d possibilities at %s.", u, i, j, possibilities, b->dimensionName)); } } } } if (minPossibilities == 1) { fatalf("Attempted guess when there is a single opportunity forward."); } if (minPossibilities == nm+1) { fatalf("Attempted guess when Sudoku is already full."); } debugf(fmt("Guessing %d at (%d,%d); %d possibilities; %d discoveries.", *ru, *ri, *rj, minPossibilities, discoveries)); } bool solve() { // reset pointer restriction cache memset(restrictedPointers, false, sizeof restrictedPointers); do { restricted = false; restrictAll(); } while(restricted && !impossible && !done); if (impossible) { return false; } if (done || noGuessing) { return true; } int ri, rj, ru; char reason[109]; searchBestGuess(&ri, &rj, &ru, reason); guesses++; // save state in case we need to rollback int tmpEventCount = eventCount; discover(ri, rj, ru, fmt("guess with reason: %s", reason)); if (solve()) { return true; } // guess failed, rollback and try the opposite guess rollbackEvents(tmpEventCount); impossible = false; cannotBe(ri, rj, ru, fmt("failed guess with reason: %s", reason)); if (solve()) { return true; } // if it can and cannot be, we failed an upstream guess return false; } bool validate() { for (int i = 0; i < nm; i++) { for (int j = 0; j < nm; j++) { if (sudoku[i][j] == 0) { return false; } for (int d = 0; d < 3; d++) { block *b = blocksByPos[i][j][d]; for (int t = 0; t < nm; t++) { int ni = b->it[t], nj = b->jt[t]; if (ni == i && nj == j) { continue; } if (sudoku[i][j] == sudoku[ni][nj]) { return false; } } } } } return true; } bool read() { if (feof(inputFile)) { return false; } if (fscanf(inputFile, "%d %d ", &n, &m) == EOF) { return false; } nm = n * m; if (n >= MAXN || m >= MAXN || nm >= MAXN) { fatalf(fmt("n, m and n*m cannot be over %d", MAXN-1)); } infof(fmt("Read input header; n = %d and m = %d", n, m)); initialDiscoveries = 0; for (int i = 0; i < nm; i++) { for (int j = 0; j < nm; j++) { fscanf(inputFile, " %d ", &sudoku[i][j]); if (sudoku[i][j] != 0) { initialDiscoveries++; } } } infof(fmt("Read input with sudoku:\n%s", prettyBufSudoku(sudoku, nm))); return true; } bool write() { const char *out = prettyBufSudoku(sudoku, nm); fprintf(outputFile, "%d %d\n%s", n, m, out); infof(fmt("Wrote output with sudoku:\n%s", out)); return true; } void processArgs(int argc, char *argv[]) { for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { help = true; } else if (strcmp(argv[i], "--debug") == 0 || strcmp(argv[i], "-d") == 0) { debug = verbose = true; } else if (strcmp(argv[i], "--verbose") == 0 || strcmp(argv[i], "-v") == 0) { verbose = true; } else if (strcmp(argv[i], "--instructions") == 0 || strcmp(argv[i], "-s") == 0) { instructions = true; } else if (strcmp(argv[i], "--no-guessing") == 0 || strcmp(argv[i], "-g") == 0) { noGuessing = true; } else if (strcmp(argv[i], "--input") == 0 || strcmp(argv[i], "-i") == 0) { i++; inputFile = fopen(argv[i], "r"); } else if (strcmp(argv[i], "--output") == 0 || strcmp(argv[i], "-o") == 0) { i++; outputFile = fopen(argv[i], "w"); } else if (strcmp(argv[i], "--instructions-output") == 0 || strcmp(argv[i], "-O") == 0) { i++; instructionFile = fopen(argv[i], "w"); } else { printf("Unknown flag %s.", argv[i]); exit(1); } } if (instructionFile == NULL) { instructionFile = outputFile; } char argsBuf[1009]; for (int i = 0, argsBufEnd = 0; i < argc; i++) { sprintf(argsBuf + argsBufEnd, "%s ", argv[i]); argsBufEnd += strlen(argv[i]); } debugf(fmt("Processed %d args: %s.", argc, argsBuf)); } void printHelpMessage() { printf("This CLI solves Sudoku puzzles of sizes with n*m <= %d.\n\n", MAXN-1); printf("usage: [--input $PATH] [--output $PATH] [--instructions-output $PATH] [--debug] [--instructions] [--verbose]\n\n"); printf("Flags:\n"); printf("--help/-h Prints the help message.\n"); printf("--debug/-d Enables DEBUG logging.\n"); printf("--verbose/-v Enables INFO logging.\n"); printf("--instructions/-s When set, prints instructions on how to solve.\n"); printf("--no-guessing/-g When set, makes as much progress as possible without making a guess.\n"); printf("--input/-i Sets the input file to read puzzles from. Defaults to stdin.\n"); printf("--output/-o Sets the output file to write solutions to. Defaults to stdout.\n"); printf("--instruction-output/-O Sets the output file to write instructions to. Defaults to the output file.\n"); } void printInstructions(int caseNum) { fprintf(instructionFile, "Instructions for case number %d:\n", caseNum); for (int i = 0; i < eventCount; i++) { event e = events[i]; if (e.type == DISCOVER) { fprintf(instructionFile, "%d: Discovered number %d at position (%d,%d); reason: %s.\n", i+1, e.u, e.i, e.j, e.reason); } else if (e.type == CANNOT_BE) { int cnt = canBeCount(e.i, e.j); const int *canBeList = maskToList(canBeMask[e.i][e.j]); fprintf(instructionFile, "%d: Number %d cannot be at (%d,%d); reason: %s; possiblities left: %s.\n", i+1, e.u, e.i, e.j, e.reason, prettyBufNumbers(canBeList, cnt)); } else { fatalf(fmt("Found event of unknown type %d.", e.type)); } } } int main(int argc, char *argv[]) { inputFile = stdin; outputFile = stdout; startTime = clock(); processArgs(argc, argv); if (help) { printHelpMessage(); return 0; } for(int caseNum = 1; read(); caseNum++) { init(); infof(fmt("Solving case num %d...", caseNum)); if (!solve()) { infof(fmt("Could not solve Sudoku case %d.", caseNum)); continue; } if (!validate()) { infof(fmt("Sudoku case %d failed validation.", caseNum)); continue; } if (instructions) { printInstructions(caseNum); } infof(fmt("Case num %d solved. Steps: %d Guesses: %d.", caseNum, steps, guesses)); write(); } cleanUp(); return 0; }
the_stack_data/98907.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/mman.h> #include <signal.h> //#include <ucontext.h> #include <errno.h> #include <string.h> #include <fcntl.h> #define stack_size 100000 #define heap_size 100000 #ifdef __APPLE__ #define SCHEME_ENTRY scheme_entry #endif #ifdef __linux__ #define SCHEME_ENTRY _scheme_entry #endif extern long SCHEME_ENTRY(char *, char *); /* locally defined functions */ static char *guarded_area(long n); #ifdef __APPLE__ static void segv_handler(int signo, siginfo_t *info, void *ignore); #endif #ifdef __linux__ static void segv_handler(int signo, struct sigcontext sc); #endif static void bus_handler(int signo); static void usage_error(char *who); static void print(long x); /* local stack/heap management variables */ static long pagesize; static char *heap; static char *stack; static long heapsize; static long stacksize; int main(int argc, char *argv[]) { struct sigaction action; sigset_t s_set; int n; pagesize = sysconf(_SC_PAGESIZE); stacksize = stack_size * sizeof(void *); heapsize = heap_size * sizeof(void *); for (n = 1; n < argc; n++) if ((*argv[n] == '-') && (*(argv[n]+2) == 0)) switch (*(argv[n]+1)) { case 'h': /* heap size option */ argv[n] = (char *)NULL; if (++n == argc) usage_error(argv[0]); heapsize = atoi(argv[n]); if (heapsize <= 0) usage_error(argv[0]); break; case 's': /* stack size option */ argv[n] = (char *)NULL; if (++n == argc) usage_error(argv[0]); stacksize = atoi(argv[n]); if (stacksize <= 0) usage_error(argv[0]); break; default: usage_error(argv[0]); } else usage_error(argv[0]); /* round stack and heap sizes to even pages */ stacksize = ((stacksize + pagesize - 1) / pagesize) * pagesize; heapsize = ((heapsize + pagesize - 1) / pagesize) * pagesize; stack = guarded_area(stacksize); heap = guarded_area(heapsize); /* Set up segmentation fault signal handler to catch stack and heap * overflow and some memory faults */ sigemptyset(&s_set); #ifdef __linux__ action.sa_handler = (void *)segv_handler; action.sa_flags = SA_RESETHAND; #else action.sa_sigaction = segv_handler; action.sa_flags = SA_SIGINFO | SA_RESETHAND; #endif action.sa_mask = s_set; if (sigaction(SIGSEGV, &action, NULL)) { fprintf(stderr, "sigaction failed: %s\n", strerror(errno)); fprintf(stderr, " overflow checking may not work\n"); } /* Set up bus error signal handler to catch remaining memory faults */ sigemptyset(&s_set); action.sa_handler = bus_handler; action.sa_mask = s_set; action.sa_flags = SA_RESETHAND; if (sigaction(SIGBUS, &action, NULL)) { fprintf(stderr, "sigaction failed: %s\n", strerror(errno)); } /* run the Scheme program and print the result */ print(SCHEME_ENTRY(stack, heap)); printf("\n"); return 0; } /* allocate a chunk of memory with a guard page on either end */ static char *guarded_area(long n) { /* n must be page aligned */ char *addr; /* allocate, leaving room for guard pages */ addr = (char *)mmap(NULL, (size_t)(n + 2 * pagesize), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); if (addr == (char *)-1) { fprintf(stderr, "mmap failed: %s\n", strerror(errno)); exit(2); } /* remove access rights from the guard pages */ if (mprotect(addr, (size_t)pagesize, PROT_NONE) || mprotect(addr + pagesize + n, (size_t)pagesize, PROT_NONE)) { fprintf(stderr, "mprotect failed: %s\n", strerror(errno)); exit(3); } return addr + pagesize; } /* Signal handler that traps SIGSEGV and checks if the violation * might have been caused by stack or heap overflow */ #ifdef __APPLE__ static void segv_handler(int signo, siginfo_t *info, void *ingore) { #endif #ifdef __linux__ static void segv_handler(int signo, struct sigcontext sc) { #endif char *addr; #ifdef __APPLE__ addr = (char *)info->si_addr; #endif #ifdef __linux__ addr = (char *)(sc.cr2); #endif if (heap-pagesize <= addr && addr < heap) { fprintf(stderr,"invalid access just below the heap\n"); } else if (heap+heapsize <= addr && addr <= heap+heapsize+pagesize) { fprintf(stderr,"invalid access just above the heap\n"); } else if (stack-pagesize <= addr && addr < stack) { fprintf(stderr,"invalid access just below the stack\n"); } else if (stack+stacksize <= addr && addr < stack+stacksize+pagesize) { fprintf(stderr,"invalid access just above the stack\n"); } else { fprintf(stderr, "Segmentation violation\n"); } exit(-1); } /* Signal handler for bus errors */ static void bus_handler(int signo) { fprintf(stderr, "Bus error\n"); exit(-1); } static void usage_error(char *who) { fprintf(stderr, "usage: %s [-h <heap size>] [-s <stack size>]\n", who); fprintf(stderr, " specify sizes in pages (base 10)\n"); fprintf(stderr, " page size is %ld bytes\n",pagesize); exit(1); } #define SCHEME_PRINTER #ifdef SCHEME_PRINTER /* generated from Scheme definitions */ #define word_size 8 #define object_alignment 8 #define shift_fixnum 3 #define mask_fixnum 7 #define tag_fixnum 0 #define mask_pair 7 #define tag_pair 1 #define size_pair 16 #define disp_car 0 #define disp_cdr 8 #define mask_vector 7 #define tag_vector 3 #define disp_vector_length 0 #define disp_vector_data 8 #define mask_procedure 7 #define tag_procedure 2 #define disp_procedure_code 0 #define disp_procedure_data 8 #define mask_boolean 247 #define tag_boolean 6 #define _false 6 #define _true 14 #define _nil 22 #define _void 30 typedef long ptr; #define UNFIX(x) (x >> shift_fixnum) #define TAG(x,mask) (x & mask) #define UNTAG(x,tag) ((x)-tag) #define CAR(x) (*(ptr *)(UNTAG(x,tag_pair) + disp_car)) #define CDR(x) (*(ptr *)(UNTAG(x,tag_pair) + disp_cdr)) #define VECTORLENGTH(x) (*(ptr *)(UNTAG(x,tag_vector) + disp_vector_length)) #define VECTORDATA(x) ((ptr *)(UNTAG(x,tag_vector) + disp_vector_data)) #define MAXDEPTH 100 #define MAXLENGTH 1000 static void print1(ptr x, int d) { if (TAG(x, mask_fixnum) == tag_fixnum) { printf("%ld", (long)UNFIX(x)); } else if (TAG(x, mask_pair) == tag_pair) { int len = 0; ptr y; if (d > MAXDEPTH) { printf("(...)"); return; } printf("("); print1(CAR(x), d+1); y = CDR(x); while (TAG(y, mask_pair) == tag_pair && (len < MAXLENGTH-1)) { printf(" "); print1(CAR(y), d+1); y = CDR(y); len++; } if (y != _nil) if (len == MAXLENGTH-1) printf(" ..."); else { printf(" . "); print1(y, d+1); } printf(")"); } else if (TAG(x, mask_vector) == tag_vector) { long i, n; ptr *p; if (d > MAXDEPTH) { printf("#(...)"); return; } printf("#("); n = UNFIX(VECTORLENGTH(x)); p = VECTORDATA(x); i = n > MAXLENGTH ? MAXLENGTH : n; if (i != 0) { print1(*p, d+1); while (--i) { printf(" "); print1(*++p, d+1); } } if (n > MAXLENGTH) printf(" ..."); printf(")"); } else if (TAG(x, mask_procedure) == tag_procedure) { printf("#<procedure>"); } else if (x == _false) { printf("#f"); } else if (x == _true) { printf("#t"); } else if (x == _nil) { printf("()"); } else if (x == _void) { printf("#<void>"); } } static void print(ptr x) { print1(x, 0); } #else /* SCHEME_PRINTER */ static void print(long x) { printf("%ld", x); } #endif /* SCHEME_PRINTER */
the_stack_data/6988.c
#include<stdio.h> int main() { int n,m; scanf("%d %d",&n,&m); int a[n],b[m]; for(int i = 0;i<n;i++) { scanf("%d",&a[i]); } for(int i = 0;i<m;i++) { scanf("%d",&b[i]); } int count = 0; for(int i = 1;i<1000;i++) { int c = 0,d = 0; for(int j = 0;j<n;j++) { if(i%a[j] == 0) { c++; } } for(int k = 0;k<m;k++) { if(b[k]%i == 0) { d++; } } if(c == n && d == m) { count++; } } printf("%d",count); }
the_stack_data/37145.c
/* * com2.c *reciver * Program to interprocess communcation using flag * Author : Adhithyan t pillai * License: MIT */ #include <signal.h> #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <string.h> #include <stdlib.h> void handler(int signo,siginfo_t *si,void *ucontext) { printf("recives value is %d\n",si->si_int); } int main() { static int x; struct sigaction sa; sa.sa_handler=handler; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_NODEFER|SA_SIGINFO; if (sigaction(SIGUSR2, &sa, NULL) == -1) { perror("sigaction failed "); exit(EXIT_FAILURE);} printf("pid is %d\n",getpid()); while(1); return 0; }
the_stack_data/97012208.c
#include <stdio.h> #include <stdlib.h> #include <string.h> struct pessoa{ int id; char descricao[50]; }; void ordenar(struct pessoa *dados, int tam){ int j,k; struct pessoa aux; for(j=1; j<= tam; j++){ for(k=0; k<tam-1; k++){ if(strcmp(dados[k].descricao , dados[k+1].descricao) > 0){ aux= dados[k]; dados[k]= dados[k+1]; dados[k+1]= aux; } } } } int pesquisar(struct pessoa *item, char *chave, int tam){ int high, low, mid; low= 0; high= tam-1; while(low <= high){ mid= (low + high)/2; if(strcmp(chave, item[mid].descricao) < 0){ high= mid-1; } else if(strcmp(chave, item[mid].descricao) > 0){ low= mid+1; } else{ return mid; } } return -1; } int main(){ int vezes,i,posic=-1; char chave[50]; scanf("%d", &vezes); scanf("%s", chave); struct pessoa *vetor= (struct pessoa *)malloc(vezes * sizeof(struct pessoa)); for(i=0; i<vezes; i++){ scanf("%d", &vetor[i].id); scanf("%s", vetor[i].descricao); } ordenar(vetor, vezes); /*for(i=0; i<vezes; i++){ printf("%d \n", vetor[i].id); printf("%s \n", vetor[i].descricao); } */ posic=pesquisar(vetor, chave, vezes); printf("%d", vetor[posic].id); }
the_stack_data/10603.c
/* * Author: Moisés Fernández * ID: A01197049 * Date: 27/03/2020 * P10. Malloc */ #include <stdio.h> #include <stdlib.h> // Function that will manage the string received from the keyboard. void extremelyLargeString(int size, char *ptr) { int index = 0; char aux; while ((aux = getchar()) && aux != '\n') { if (index < size) { ptr[index] = aux; } else { ptr = realloc(ptr, (size + 3) * sizeof(char)); size += 3; ptr[index] = aux; } index++; } if(ptr[index - 1] != '$') { printf("Error: Escape character not introduced \n"); } else { printf("String: %s\n", ptr); } } // Main function. int main(void) { int size = 3; char *ptr = NULL; ptr = malloc(sizeof(char) * size); printf("Escape character: $\n"); printf("Introduce a extremely large string: "); extremelyLargeString(size, ptr); // To free any allocated memory. free(ptr); return 0; }
the_stack_data/242330564.c
#include <stdio.h> main() { int a,b,c; int count = 1; for (b=c=10;a="- FIGURE?, UMKC,XYZHello Folks,\ TFy!QJu ROo TNn(ROo)SLq SLq ULo+\ UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\ NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\ HCStHAUFAgcEAelclcn^r^r\\tZvYxXy\ T|S~Pn SPm SOn TNn ULo0ULo#ULo-W\ Hq!WFs XDt!" [b+++21]; ) for(; a-- > 64 ; ) putchar ( ++c=='Z' ? c = c/ 9:33^b&1); return 0; }
the_stack_data/1247806.c
/* ** This file contains all sources (including headers) to the LEMON ** LALR(1) parser generator. The sources have been combined into a ** single file to make it easy to include LEMON in the source tree ** and Makefile of another program. ** ** The author of this program disclaims copyright. */ #include <stdio.h> #include <stdarg.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #ifndef __WIN32__ # if defined(_WIN32) || defined(WIN32) # define __WIN32__ # endif #endif /* #define PRIVATE static */ #define PRIVATE #ifdef TEST #define MAXRHS 5 /* Set low to exercise exception code */ #else #define MAXRHS 1000 #endif char *msort(); extern void *malloc(); /******** From the file "action.h" *************************************/ struct action *Action_new(); struct action *Action_sort(); /********* From the file "assert.h" ************************************/ void myassert(); #ifndef NDEBUG # define assert(X) if(!(X))myassert(__FILE__,__LINE__) #else # define assert(X) #endif /********** From the file "build.h" ************************************/ void FindRulePrecedences(); void FindFirstSets(); void FindStates(); void FindLinks(); void FindFollowSets(); void FindActions(); /********* From the file "configlist.h" *********************************/ void Configlist_init(/* void */); struct config *Configlist_add(/* struct rule *, int */); struct config *Configlist_addbasis(/* struct rule *, int */); void Configlist_closure(/* void */); void Configlist_sort(/* void */); void Configlist_sortbasis(/* void */); struct config *Configlist_return(/* void */); struct config *Configlist_basis(/* void */); void Configlist_eat(/* struct config * */); void Configlist_reset(/* void */); /********* From the file "error.h" ***************************************/ void ErrorMsg(const char *, int,const char *, ...); /****** From the file "option.h" ******************************************/ struct s_options { enum { OPT_FLAG=1, OPT_INT, OPT_DBL, OPT_STR, OPT_FFLAG, OPT_FINT, OPT_FDBL, OPT_FSTR} type; char *label; char *arg; char *message; }; int OptInit(/* char**,struct s_options*,FILE* */); int OptNArgs(/* void */); char *OptArg(/* int */); void OptErr(/* int */); void OptPrint(/* void */); /******** From the file "parse.h" *****************************************/ void Parse(/* struct lemon *lemp */); /********* From the file "plink.h" ***************************************/ struct plink *Plink_new(/* void */); void Plink_add(/* struct plink **, struct config * */); void Plink_copy(/* struct plink **, struct plink * */); void Plink_delete(/* struct plink * */); /********** From the file "report.h" *************************************/ void Reprint(/* struct lemon * */); void ReportOutput(/* struct lemon * */); void ReportTable(/* struct lemon * */); void ReportHeader(/* struct lemon * */); void CompressTables(/* struct lemon * */); /********** From the file "set.h" ****************************************/ void SetSize(/* int N */); /* All sets will be of size N */ char *SetNew(/* void */); /* A new set for element 0..N */ void SetFree(/* char* */); /* Deallocate a set */ int SetAdd(/* char*,int */); /* Add element to a set */ int SetUnion(/* char *A,char *B */); /* A <- A U B, thru element N */ #define SetFind(X,Y) (X[Y]) /* True if Y is in set X */ /********** From the file "struct.h" *************************************/ /* ** Principal data structures for the LEMON parser generator. */ typedef enum {B_FALSE=0, B_TRUE} Boolean; /* Symbols (terminals and nonterminals) of the grammar are stored ** in the following: */ struct symbol { char *name; /* Name of the symbol */ int index; /* Index number for this symbol */ enum { TERMINAL, NONTERMINAL } type; /* Symbols are all either TERMINALS or NTs */ struct rule *rule; /* Linked list of rules of this (if an NT) */ struct symbol *fallback; /* fallback token in case this token doesn't parse */ int prec; /* Precedence if defined (-1 otherwise) */ enum e_assoc { LEFT, RIGHT, NONE, UNK } assoc; /* Associativity if predecence is defined */ char *firstset; /* First-set for all rules of this symbol */ Boolean lambda; /* True if NT and can generate an empty string */ char *destructor; /* Code which executes whenever this symbol is ** popped from the stack during error processing */ int destructorln; /* Line number of destructor code */ char *datatype; /* The data type of information held by this ** object. Only used if type==NONTERMINAL */ int dtnum; /* The data type number. In the parser, the value ** stack is a union. The .yy%d element of this ** union is the correct data type for this object */ }; /* Each production rule in the grammar is stored in the following ** structure. */ struct rule { struct symbol *lhs; /* Left-hand side of the rule */ char *lhsalias; /* Alias for the LHS (NULL if none) */ int ruleline; /* Line number for the rule */ int nrhs; /* Number of RHS symbols */ struct symbol **rhs; /* The RHS symbols */ char **rhsalias; /* An alias for each RHS symbol (NULL if none) */ int line; /* Line number at which code begins */ char *code; /* The code executed when this rule is reduced */ struct symbol *precsym; /* Precedence symbol for this rule */ int index; /* An index number for this rule */ Boolean canReduce; /* True if this rule is ever reduced */ struct rule *nextlhs; /* Next rule with the same LHS */ struct rule *next; /* Next rule in the global list */ }; /* A configuration is a production rule of the grammar together with ** a mark (dot) showing how much of that rule has been processed so far. ** Configurations also contain a follow-set which is a list of terminal ** symbols which are allowed to immediately follow the end of the rule. ** Every configuration is recorded as an instance of the following: */ struct config { struct rule *rp; /* The rule upon which the configuration is based */ int dot; /* The parse point */ char *fws; /* Follow-set for this configuration only */ struct plink *fplp; /* Follow-set forward propagation links */ struct plink *bplp; /* Follow-set backwards propagation links */ struct state *stp; /* Pointer to state which contains this */ enum { COMPLETE, /* The status is used during followset and */ INCOMPLETE /* shift computations */ } status; struct config *next; /* Next configuration in the state */ struct config *bp; /* The next basis configuration */ }; /* Every shift or reduce operation is stored as one of the following */ struct action { struct symbol *sp; /* The look-ahead symbol */ enum e_action { SHIFT, ACCEPT, REDUCE, ERROR, CONFLICT, /* Was a reduce, but part of a conflict */ SH_RESOLVED, /* Was a shift. Precedence resolved conflict */ RD_RESOLVED, /* Was reduce. Precedence resolved conflict */ NOT_USED /* Deleted by compression */ } type; union { struct state *stp; /* The new state, if a shift */ struct rule *rp; /* The rule, if a reduce */ } x; struct action *next; /* Next action for this state */ struct action *collide; /* Next action with the same hash */ }; /* Each state of the generated parser's finite state machine ** is encoded as an instance of the following structure. */ struct state { struct config *bp; /* The basis configurations for this state */ struct config *cfp; /* All configurations in this set */ int index; /* Sequencial number for this state */ struct action *ap; /* Array of actions for this state */ int nTknAct, nNtAct; /* Number of actions on terminals and nonterminals */ int iTknOfst, iNtOfst; /* yy_action[] offset for terminals and nonterms */ int iDflt; /* Default action */ }; #define NO_OFFSET (-2147483647) /* A followset propagation link indicates that the contents of one ** configuration followset should be propagated to another whenever ** the first changes. */ struct plink { struct config *cfp; /* The configuration to which linked */ struct plink *next; /* The next propagate link */ }; /* The state vector for the entire parser generator is recorded as ** follows. (LEMON uses no global variables and makes little use of ** static variables. Fields in the following structure can be thought ** of as begin global variables in the program.) */ struct lemon { struct state **sorted; /* Table of states sorted by state number */ struct rule *rule; /* List of all rules */ int nstate; /* Number of states */ int nrule; /* Number of rules */ int nsymbol; /* Number of terminal and nonterminal symbols */ int nterminal; /* Number of terminal symbols */ struct symbol **symbols; /* Sorted array of pointers to symbols */ int errorcnt; /* Number of errors */ struct symbol *errsym; /* The error symbol */ char *name; /* Name of the generated parser */ char *arg; /* Declaration of the 3th argument to parser */ char *tokentype; /* Type of terminal symbols in the parser stack */ char *vartype; /* The default type of non-terminal symbols */ char *start; /* Name of the start symbol for the grammar */ char *stacksize; /* Size of the parser stack */ char *include; /* Code to put at the start of the C file */ int includeln; /* Line number for start of include code */ char *error; /* Code to execute when an error is seen */ int errorln; /* Line number for start of error code */ char *overflow; /* Code to execute on a stack overflow */ int overflowln; /* Line number for start of overflow code */ char *failure; /* Code to execute on parser failure */ int failureln; /* Line number for start of failure code */ char *accept; /* Code to execute when the parser excepts */ int acceptln; /* Line number for the start of accept code */ char *extracode; /* Code appended to the generated file */ int extracodeln; /* Line number for the start of the extra code */ char *tokendest; /* Code to execute to destroy token data */ int tokendestln; /* Line number for token destroyer code */ char *vardest; /* Code for the default non-terminal destructor */ int vardestln; /* Line number for default non-term destructor code*/ char *filename; /* Name of the input file */ char *outname; /* Name of the current output file */ char *tokenprefix; /* A prefix added to token names in the .h file */ int nconflict; /* Number of parsing conflicts */ int tablesize; /* Size of the parse tables */ int basisflag; /* Print only basis configurations */ int has_fallback; /* True if any %fallback is seen in the grammer */ char *argv0; /* Name of the program */ }; #define MemoryCheck(X) if((X)==0){ \ extern void memory_error(); \ memory_error(); \ } /**************** From the file "table.h" *********************************/ /* ** All code in this file has been automatically generated ** from a specification in the file ** "table.q" ** by the associative array code building program "aagen". ** Do not edit this file! Instead, edit the specification ** file, then rerun aagen. */ /* ** Code for processing tables in the LEMON parser generator. */ /* Routines for handling a strings */ char *Strsafe(); void Strsafe_init(/* void */); int Strsafe_insert(/* char * */); char *Strsafe_find(/* char * */); /* Routines for handling symbols of the grammar */ struct symbol *Symbol_new(); int Symbolcmpp(/* struct symbol **, struct symbol ** */); void Symbol_init(/* void */); int Symbol_insert(/* struct symbol *, char * */); struct symbol *Symbol_find(/* char * */); struct symbol *Symbol_Nth(/* int */); int Symbol_count(/* */); struct symbol **Symbol_arrayof(/* */); /* Routines to manage the state table */ int Configcmp(/* struct config *, struct config * */); struct state *State_new(); void State_init(/* void */); int State_insert(/* struct state *, struct config * */); struct state *State_find(/* struct config * */); struct state **State_arrayof(/* */); /* Routines used for efficiency in Configlist_add */ void Configtable_init(/* void */); int Configtable_insert(/* struct config * */); struct config *Configtable_find(/* struct config * */); void Configtable_clear(/* int(*)(struct config *) */); /****************** From the file "action.c" *******************************/ /* ** Routines processing parser actions in the LEMON parser generator. */ /* Allocate a new parser action */ struct action *Action_new(){ static struct action *freelist = 0; struct action *new; if( freelist==0 ){ int i; int amt = 100; freelist = (struct action *)malloc( sizeof(struct action)*amt ); if( freelist==0 ){ fprintf(stderr,"Unable to allocate memory for a new parser action."); exit(1); } for(i=0; i<amt-1; i++) freelist[i].next = &freelist[i+1]; freelist[amt-1].next = 0; } new = freelist; freelist = freelist->next; return new; } /* Compare two actions */ static int actioncmp(ap1,ap2) struct action *ap1; struct action *ap2; { int rc; rc = ap1->sp->index - ap2->sp->index; if( rc==0 ) rc = (int)ap1->type - (int)ap2->type; if( rc==0 ){ assert( ap1->type==REDUCE || ap1->type==RD_RESOLVED || ap1->type==CONFLICT); assert( ap2->type==REDUCE || ap2->type==RD_RESOLVED || ap2->type==CONFLICT); rc = ap1->x.rp->index - ap2->x.rp->index; } return rc; } /* Sort parser actions */ struct action *Action_sort(ap) struct action *ap; { ap = (struct action *)msort((char *)ap,(char **)&ap->next,actioncmp); return ap; } void Action_add(app,type,sp,arg) struct action **app; enum e_action type; struct symbol *sp; char *arg; { struct action *new; new = Action_new(); new->next = *app; *app = new; new->type = type; new->sp = sp; if( type==SHIFT ){ new->x.stp = (struct state *)arg; }else{ new->x.rp = (struct rule *)arg; } } /********************** New code to implement the "acttab" module ***********/ /* ** This module implements routines use to construct the yy_action[] table. */ /* ** The state of the yy_action table under construction is an instance of ** the following structure */ typedef struct acttab acttab; struct acttab { int nAction; /* Number of used slots in aAction[] */ int nActionAlloc; /* Slots allocated for aAction[] */ struct { int lookahead; /* Value of the lookahead token */ int action; /* Action to take on the given lookahead */ } *aAction, /* The yy_action[] table under construction */ *aLookahead; /* A single new transaction set */ int mnLookahead; /* Minimum aLookahead[].lookahead */ int mnAction; /* Action associated with mnLookahead */ int mxLookahead; /* Maximum aLookahead[].lookahead */ int nLookahead; /* Used slots in aLookahead[] */ int nLookaheadAlloc; /* Slots allocated in aLookahead[] */ }; /* Return the number of entries in the yy_action table */ #define acttab_size(X) ((X)->nAction) /* The value for the N-th entry in yy_action */ #define acttab_yyaction(X,N) ((X)->aAction[N].action) /* The value for the N-th entry in yy_lookahead */ #define acttab_yylookahead(X,N) ((X)->aAction[N].lookahead) /* Free all memory associated with the given acttab */ void acttab_free(acttab *p){ free( p->aAction ); free( p->aLookahead ); free( p ); } /* Allocate a new acttab structure */ acttab *acttab_alloc(void){ acttab *p = malloc( sizeof(*p) ); if( p==0 ){ fprintf(stderr,"Unable to allocate memory for a new acttab."); exit(1); } memset(p, 0, sizeof(*p)); return p; } /* Add a new action to the current transaction set */ void acttab_action(acttab *p, int lookahead, int action){ if( p->nLookahead>=p->nLookaheadAlloc ){ p->nLookaheadAlloc += 25; p->aLookahead = realloc( p->aLookahead, sizeof(p->aLookahead[0])*p->nLookaheadAlloc ); if( p->aLookahead==0 ){ fprintf(stderr,"malloc failed\n"); exit(1); } } if( p->nLookahead==0 ){ p->mxLookahead = lookahead; p->mnLookahead = lookahead; p->mnAction = action; }else{ if( p->mxLookahead<lookahead ) p->mxLookahead = lookahead; if( p->mnLookahead>lookahead ){ p->mnLookahead = lookahead; p->mnAction = action; } } p->aLookahead[p->nLookahead].lookahead = lookahead; p->aLookahead[p->nLookahead].action = action; p->nLookahead++; } /* ** Add the transaction set built up with prior calls to acttab_action() ** into the current action table. Then reset the transaction set back ** to an empty set in preparation for a new round of acttab_action() calls. ** ** Return the offset into the action table of the new transaction. */ int acttab_insert(acttab *p){ int i, j, k, n; assert( p->nLookahead>0 ); /* Make sure we have enough space to hold the expanded action table ** in the worst case. The worst case occurs if the transaction set ** must be appended to the current action table */ n = p->mxLookahead + 1; if( p->nAction + n >= p->nActionAlloc ){ int oldAlloc = p->nActionAlloc; p->nActionAlloc = p->nAction + n + p->nActionAlloc + 20; p->aAction = realloc( p->aAction, sizeof(p->aAction[0])*p->nActionAlloc); if( p->aAction==0 ){ fprintf(stderr,"malloc failed\n"); exit(1); } for(i=oldAlloc; i<p->nActionAlloc; i++){ p->aAction[i].lookahead = -1; p->aAction[i].action = -1; } } /* Scan the existing action table looking for an offset where we can ** insert the current transaction set. Fall out of the loop when that ** offset is found. In the worst case, we fall out of the loop when ** i reaches p->nAction, which means we append the new transaction set. ** ** i is the index in p->aAction[] where p->mnLookahead is inserted. */ for(i=0; i<p->nAction+p->mnLookahead; i++){ if( p->aAction[i].lookahead<0 ){ for(j=0; j<p->nLookahead; j++){ k = p->aLookahead[j].lookahead - p->mnLookahead + i; if( k<0 ) break; if( p->aAction[k].lookahead>=0 ) break; } if( j<p->nLookahead ) continue; for(j=0; j<p->nAction; j++){ if( p->aAction[j].lookahead==j+p->mnLookahead-i ) break; } if( j==p->nAction ){ break; /* Fits in empty slots */ } }else if( p->aAction[i].lookahead==p->mnLookahead ){ if( p->aAction[i].action!=p->mnAction ) continue; for(j=0; j<p->nLookahead; j++){ k = p->aLookahead[j].lookahead - p->mnLookahead + i; if( k<0 || k>=p->nAction ) break; if( p->aLookahead[j].lookahead!=p->aAction[k].lookahead ) break; if( p->aLookahead[j].action!=p->aAction[k].action ) break; } if( j<p->nLookahead ) continue; n = 0; for(j=0; j<p->nAction; j++){ if( p->aAction[j].lookahead<0 ) continue; if( p->aAction[j].lookahead==j+p->mnLookahead-i ) n++; } if( n==p->nLookahead ){ break; /* Same as a prior transaction set */ } } } /* Insert transaction set at index i. */ for(j=0; j<p->nLookahead; j++){ k = p->aLookahead[j].lookahead - p->mnLookahead + i; p->aAction[k] = p->aLookahead[j]; if( k>=p->nAction ) p->nAction = k+1; } p->nLookahead = 0; /* Return the offset that is added to the lookahead in order to get the ** index into yy_action of the action */ return i - p->mnLookahead; } /********************** From the file "assert.c" ****************************/ /* ** A more efficient way of handling assertions. */ void myassert(file,line) char *file; int line; { fprintf(stderr,"Assertion failed on line %d of file \"%s\"\n",line,file); exit(1); } /********************** From the file "build.c" *****************************/ /* ** Routines to construction the finite state machine for the LEMON ** parser generator. */ /* Find a precedence symbol of every rule in the grammar. ** ** Those rules which have a precedence symbol coded in the input ** grammar using the "[symbol]" construct will already have the ** rp->precsym field filled. Other rules take as their precedence ** symbol the first RHS symbol with a defined precedence. If there ** are not RHS symbols with a defined precedence, the precedence ** symbol field is left blank. */ void FindRulePrecedences(xp) struct lemon *xp; { struct rule *rp; for(rp=xp->rule; rp; rp=rp->next){ if( rp->precsym==0 ){ int i; for(i=0; i<rp->nrhs; i++){ if( rp->rhs[i]->prec>=0 ){ rp->precsym = rp->rhs[i]; break; } } } } return; } /* Find all nonterminals which will generate the empty string. ** Then go back and compute the first sets of every nonterminal. ** The first set is the set of all terminal symbols which can begin ** a string generated by that nonterminal. */ void FindFirstSets(lemp) struct lemon *lemp; { int i; struct rule *rp; int progress; for(i=0; i<lemp->nsymbol; i++){ lemp->symbols[i]->lambda = B_FALSE; } for(i=lemp->nterminal; i<lemp->nsymbol; i++){ lemp->symbols[i]->firstset = SetNew(); } /* First compute all lambdas */ do{ progress = 0; for(rp=lemp->rule; rp; rp=rp->next){ if( rp->lhs->lambda ) continue; for(i=0; i<rp->nrhs; i++){ if( rp->rhs[i]->lambda==B_FALSE ) break; } if( i==rp->nrhs ){ rp->lhs->lambda = B_TRUE; progress = 1; } } }while( progress ); /* Now compute all first sets */ do{ struct symbol *s1, *s2; progress = 0; for(rp=lemp->rule; rp; rp=rp->next){ s1 = rp->lhs; for(i=0; i<rp->nrhs; i++){ s2 = rp->rhs[i]; if( s2->type==TERMINAL ){ progress += SetAdd(s1->firstset,s2->index); break; }else if( s1==s2 ){ if( s1->lambda==B_FALSE ) break; }else{ progress += SetUnion(s1->firstset,s2->firstset); if( s2->lambda==B_FALSE ) break; } } } }while( progress ); return; } /* Compute all LR(0) states for the grammar. Links ** are added to between some states so that the LR(1) follow sets ** can be computed later. */ PRIVATE struct state *getstate(/* struct lemon * */); /* forward reference */ void FindStates(lemp) struct lemon *lemp; { struct symbol *sp; struct rule *rp; Configlist_init(); /* Find the start symbol */ if( lemp->start ){ sp = Symbol_find(lemp->start); if( sp==0 ){ ErrorMsg(lemp->filename,0, "The specified start symbol \"%s\" is not \ in a nonterminal of the grammar. \"%s\" will be used as the start \ symbol instead.",lemp->start,lemp->rule->lhs->name); lemp->errorcnt++; sp = lemp->rule->lhs; } }else{ sp = lemp->rule->lhs; } /* Make sure the start symbol doesn't occur on the right-hand side of ** any rule. Report an error if it does. (YACC would generate a new ** start symbol in this case.) */ for(rp=lemp->rule; rp; rp=rp->next){ int i; for(i=0; i<rp->nrhs; i++){ if( rp->rhs[i]==sp ){ ErrorMsg(lemp->filename,0, "The start symbol \"%s\" occurs on the \ right-hand side of a rule. This will result in a parser which \ does not work properly.",sp->name); lemp->errorcnt++; } } } /* The basis configuration set for the first state ** is all rules which have the start symbol as their ** left-hand side */ for(rp=sp->rule; rp; rp=rp->nextlhs){ struct config *newcfp; newcfp = Configlist_addbasis(rp,0); SetAdd(newcfp->fws,0); } /* Compute the first state. All other states will be ** computed automatically during the computation of the first one. ** The returned pointer to the first state is not used. */ (void)getstate(lemp); return; } /* Return a pointer to a state which is described by the configuration ** list which has been built from calls to Configlist_add. */ PRIVATE void buildshifts(/* struct lemon *, struct state * */); /* Forwd ref */ PRIVATE struct state *getstate(lemp) struct lemon *lemp; { struct config *cfp, *bp; struct state *stp; /* Extract the sorted basis of the new state. The basis was constructed ** by prior calls to "Configlist_addbasis()". */ Configlist_sortbasis(); bp = Configlist_basis(); /* Get a state with the same basis */ stp = State_find(bp); if( stp ){ /* A state with the same basis already exists! Copy all the follow-set ** propagation links from the state under construction into the ** preexisting state, then return a pointer to the preexisting state */ struct config *x, *y; for(x=bp, y=stp->bp; x && y; x=x->bp, y=y->bp){ Plink_copy(&y->bplp,x->bplp); Plink_delete(x->fplp); x->fplp = x->bplp = 0; } cfp = Configlist_return(); Configlist_eat(cfp); }else{ /* This really is a new state. Construct all the details */ Configlist_closure(lemp); /* Compute the configuration closure */ Configlist_sort(); /* Sort the configuration closure */ cfp = Configlist_return(); /* Get a pointer to the config list */ stp = State_new(); /* A new state structure */ MemoryCheck(stp); stp->bp = bp; /* Remember the configuration basis */ stp->cfp = cfp; /* Remember the configuration closure */ stp->index = lemp->nstate++; /* Every state gets a sequence number */ stp->ap = 0; /* No actions, yet. */ State_insert(stp,stp->bp); /* Add to the state table */ buildshifts(lemp,stp); /* Recursively compute successor states */ } return stp; } /* Construct all successor states to the given state. A "successor" ** state is any state which can be reached by a shift action. */ PRIVATE void buildshifts(lemp,stp) struct lemon *lemp; struct state *stp; /* The state from which successors are computed */ { struct config *cfp; /* For looping thru the config closure of "stp" */ struct config *bcfp; /* For the inner loop on config closure of "stp" */ struct config *new; /* */ struct symbol *sp; /* Symbol following the dot in configuration "cfp" */ struct symbol *bsp; /* Symbol following the dot in configuration "bcfp" */ struct state *newstp; /* A pointer to a successor state */ /* Each configuration becomes complete after it contibutes to a successor ** state. Initially, all configurations are incomplete */ for(cfp=stp->cfp; cfp; cfp=cfp->next) cfp->status = INCOMPLETE; /* Loop through all configurations of the state "stp" */ for(cfp=stp->cfp; cfp; cfp=cfp->next){ if( cfp->status==COMPLETE ) continue; /* Already used by inner loop */ if( cfp->dot>=cfp->rp->nrhs ) continue; /* Can't shift this config */ Configlist_reset(); /* Reset the new config set */ sp = cfp->rp->rhs[cfp->dot]; /* Symbol after the dot */ /* For every configuration in the state "stp" which has the symbol "sp" ** following its dot, add the same configuration to the basis set under ** construction but with the dot shifted one symbol to the right. */ for(bcfp=cfp; bcfp; bcfp=bcfp->next){ if( bcfp->status==COMPLETE ) continue; /* Already used */ if( bcfp->dot>=bcfp->rp->nrhs ) continue; /* Can't shift this one */ bsp = bcfp->rp->rhs[bcfp->dot]; /* Get symbol after dot */ if( bsp!=sp ) continue; /* Must be same as for "cfp" */ bcfp->status = COMPLETE; /* Mark this config as used */ new = Configlist_addbasis(bcfp->rp,bcfp->dot+1); Plink_add(&new->bplp,bcfp); } /* Get a pointer to the state described by the basis configuration set ** constructed in the preceding loop */ newstp = getstate(lemp); /* The state "newstp" is reached from the state "stp" by a shift action ** on the symbol "sp" */ Action_add(&stp->ap,SHIFT,sp,(char *)newstp); } } /* ** Construct the propagation links */ void FindLinks(lemp) struct lemon *lemp; { int i; struct config *cfp, *other; struct state *stp; struct plink *plp; /* Housekeeping detail: ** Add to every propagate link a pointer back to the state to ** which the link is attached. */ for(i=0; i<lemp->nstate; i++){ stp = lemp->sorted[i]; for(cfp=stp->cfp; cfp; cfp=cfp->next){ cfp->stp = stp; } } /* Convert all backlinks into forward links. Only the forward ** links are used in the follow-set computation. */ for(i=0; i<lemp->nstate; i++){ stp = lemp->sorted[i]; for(cfp=stp->cfp; cfp; cfp=cfp->next){ for(plp=cfp->bplp; plp; plp=plp->next){ other = plp->cfp; Plink_add(&other->fplp,cfp); } } } } /* Compute all followsets. ** ** A followset is the set of all symbols which can come immediately ** after a configuration. */ void FindFollowSets(lemp) struct lemon *lemp; { int i; struct config *cfp; struct plink *plp; int progress; int change; for(i=0; i<lemp->nstate; i++){ for(cfp=lemp->sorted[i]->cfp; cfp; cfp=cfp->next){ cfp->status = INCOMPLETE; } } do{ progress = 0; for(i=0; i<lemp->nstate; i++){ for(cfp=lemp->sorted[i]->cfp; cfp; cfp=cfp->next){ if( cfp->status==COMPLETE ) continue; for(plp=cfp->fplp; plp; plp=plp->next){ change = SetUnion(plp->cfp->fws,cfp->fws); if( change ){ plp->cfp->status = INCOMPLETE; progress = 1; } } cfp->status = COMPLETE; } } }while( progress ); } static int resolve_conflict(); /* Compute the reduce actions, and resolve conflicts. */ void FindActions(lemp) struct lemon *lemp; { int i,j; struct config *cfp; struct state *stp; struct symbol *sp; struct rule *rp; /* Add all of the reduce actions ** A reduce action is added for each element of the followset of ** a configuration which has its dot at the extreme right. */ for(i=0; i<lemp->nstate; i++){ /* Loop over all states */ stp = lemp->sorted[i]; for(cfp=stp->cfp; cfp; cfp=cfp->next){ /* Loop over all configurations */ if( cfp->rp->nrhs==cfp->dot ){ /* Is dot at extreme right? */ for(j=0; j<lemp->nterminal; j++){ if( SetFind(cfp->fws,j) ){ /* Add a reduce action to the state "stp" which will reduce by the ** rule "cfp->rp" if the lookahead symbol is "lemp->symbols[j]" */ Action_add(&stp->ap,REDUCE,lemp->symbols[j],(char *)cfp->rp); } } } } } /* Add the accepting token */ if( lemp->start ){ sp = Symbol_find(lemp->start); if( sp==0 ) sp = lemp->rule->lhs; }else{ sp = lemp->rule->lhs; } /* Add to the first state (which is always the starting state of the ** finite state machine) an action to ACCEPT if the lookahead is the ** start nonterminal. */ Action_add(&lemp->sorted[0]->ap,ACCEPT,sp,0); /* Resolve conflicts */ for(i=0; i<lemp->nstate; i++){ struct action *ap, *nap; struct state *stp; stp = lemp->sorted[i]; assert( stp->ap ); stp->ap = Action_sort(stp->ap); for(ap=stp->ap; ap && ap->next; ap=ap->next){ for(nap=ap->next; nap && nap->sp==ap->sp; nap=nap->next){ /* The two actions "ap" and "nap" have the same lookahead. ** Figure out which one should be used */ lemp->nconflict += resolve_conflict(ap,nap,lemp->errsym); } } } /* Report an error for each rule that can never be reduced. */ for(rp=lemp->rule; rp; rp=rp->next) rp->canReduce = B_FALSE; for(i=0; i<lemp->nstate; i++){ struct action *ap; for(ap=lemp->sorted[i]->ap; ap; ap=ap->next){ if( ap->type==REDUCE ) ap->x.rp->canReduce = B_TRUE; } } for(rp=lemp->rule; rp; rp=rp->next){ if( rp->canReduce ) continue; ErrorMsg(lemp->filename,rp->ruleline,"This rule can not be reduced.\n"); lemp->errorcnt++; } } /* Resolve a conflict between the two given actions. If the ** conflict can't be resolve, return non-zero. ** ** NO LONGER TRUE: ** To resolve a conflict, first look to see if either action ** is on an error rule. In that case, take the action which ** is not associated with the error rule. If neither or both ** actions are associated with an error rule, then try to ** use precedence to resolve the conflict. ** ** If either action is a SHIFT, then it must be apx. This ** function won't work if apx->type==REDUCE and apy->type==SHIFT. */ static int resolve_conflict(apx,apy,errsym) struct action *apx; struct action *apy; struct symbol *errsym; /* The error symbol (if defined. NULL otherwise) */ { struct symbol *spx, *spy; int errcnt = 0; assert( apx->sp==apy->sp ); /* Otherwise there would be no conflict */ if( apx->type==SHIFT && apy->type==REDUCE ){ spx = apx->sp; spy = apy->x.rp->precsym; if( spy==0 || spx->prec<0 || spy->prec<0 ){ /* Not enough precedence information. */ apy->type = CONFLICT; errcnt++; }else if( spx->prec>spy->prec ){ /* Lower precedence wins */ apy->type = RD_RESOLVED; }else if( spx->prec<spy->prec ){ apx->type = SH_RESOLVED; }else if( spx->prec==spy->prec && spx->assoc==RIGHT ){ /* Use operator */ apy->type = RD_RESOLVED; /* associativity */ }else if( spx->prec==spy->prec && spx->assoc==LEFT ){ /* to break tie */ apx->type = SH_RESOLVED; }else{ assert( spx->prec==spy->prec && spx->assoc==NONE ); apy->type = CONFLICT; errcnt++; } }else if( apx->type==REDUCE && apy->type==REDUCE ){ spx = apx->x.rp->precsym; spy = apy->x.rp->precsym; if( spx==0 || spy==0 || spx->prec<0 || spy->prec<0 || spx->prec==spy->prec ){ apy->type = CONFLICT; errcnt++; }else if( spx->prec>spy->prec ){ apy->type = RD_RESOLVED; }else if( spx->prec<spy->prec ){ apx->type = RD_RESOLVED; } }else{ assert( apx->type==SH_RESOLVED || apx->type==RD_RESOLVED || apx->type==CONFLICT || apy->type==SH_RESOLVED || apy->type==RD_RESOLVED || apy->type==CONFLICT ); /* The REDUCE/SHIFT case cannot happen because SHIFTs come before ** REDUCEs on the list. If we reach this point it must be because ** the parser conflict had already been resolved. */ } return errcnt; } /********************* From the file "configlist.c" *************************/ /* ** Routines to processing a configuration list and building a state ** in the LEMON parser generator. */ static struct config *freelist = 0; /* List of free configurations */ static struct config *current = 0; /* Top of list of configurations */ static struct config **currentend = 0; /* Last on list of configs */ static struct config *basis = 0; /* Top of list of basis configs */ static struct config **basisend = 0; /* End of list of basis configs */ /* Return a pointer to a new configuration */ PRIVATE struct config *newconfig(){ struct config *new; if( freelist==0 ){ int i; int amt = 3; freelist = (struct config *)malloc( sizeof(struct config)*amt ); if( freelist==0 ){ fprintf(stderr,"Unable to allocate memory for a new configuration."); exit(1); } for(i=0; i<amt-1; i++) freelist[i].next = &freelist[i+1]; freelist[amt-1].next = 0; } new = freelist; freelist = freelist->next; return new; } /* The configuration "old" is no longer used */ PRIVATE void deleteconfig(old) struct config *old; { old->next = freelist; freelist = old; } /* Initialized the configuration list builder */ void Configlist_init(){ current = 0; currentend = &current; basis = 0; basisend = &basis; Configtable_init(); return; } /* Initialized the configuration list builder */ void Configlist_reset(){ current = 0; currentend = &current; basis = 0; basisend = &basis; Configtable_clear(0); return; } /* Add another configuration to the configuration list */ struct config *Configlist_add(rp,dot) struct rule *rp; /* The rule */ int dot; /* Index into the RHS of the rule where the dot goes */ { struct config *cfp, model; assert( currentend!=0 ); model.rp = rp; model.dot = dot; cfp = Configtable_find(&model); if( cfp==0 ){ cfp = newconfig(); cfp->rp = rp; cfp->dot = dot; cfp->fws = SetNew(); cfp->stp = 0; cfp->fplp = cfp->bplp = 0; cfp->next = 0; cfp->bp = 0; *currentend = cfp; currentend = &cfp->next; Configtable_insert(cfp); } return cfp; } /* Add a basis configuration to the configuration list */ struct config *Configlist_addbasis(rp,dot) struct rule *rp; int dot; { struct config *cfp, model; assert( basisend!=0 ); assert( currentend!=0 ); model.rp = rp; model.dot = dot; cfp = Configtable_find(&model); if( cfp==0 ){ cfp = newconfig(); cfp->rp = rp; cfp->dot = dot; cfp->fws = SetNew(); cfp->stp = 0; cfp->fplp = cfp->bplp = 0; cfp->next = 0; cfp->bp = 0; *currentend = cfp; currentend = &cfp->next; *basisend = cfp; basisend = &cfp->bp; Configtable_insert(cfp); } return cfp; } /* Compute the closure of the configuration list */ void Configlist_closure(lemp) struct lemon *lemp; { struct config *cfp, *newcfp; struct rule *rp, *newrp; struct symbol *sp, *xsp; int i, dot; assert( currentend!=0 ); for(cfp=current; cfp; cfp=cfp->next){ rp = cfp->rp; dot = cfp->dot; if( dot>=rp->nrhs ) continue; sp = rp->rhs[dot]; if( sp->type==NONTERMINAL ){ if( sp->rule==0 && sp!=lemp->errsym ){ ErrorMsg(lemp->filename,rp->line,"Nonterminal \"%s\" has no rules.", sp->name); lemp->errorcnt++; } for(newrp=sp->rule; newrp; newrp=newrp->nextlhs){ newcfp = Configlist_add(newrp,0); for(i=dot+1; i<rp->nrhs; i++){ xsp = rp->rhs[i]; if( xsp->type==TERMINAL ){ SetAdd(newcfp->fws,xsp->index); break; }else{ SetUnion(newcfp->fws,xsp->firstset); if( xsp->lambda==B_FALSE ) break; } } if( i==rp->nrhs ) Plink_add(&cfp->fplp,newcfp); } } } return; } /* Sort the configuration list */ void Configlist_sort(){ current = (struct config *)msort((char *)current,(char **)&(current->next),Configcmp); currentend = 0; return; } /* Sort the basis configuration list */ void Configlist_sortbasis(){ basis = (struct config *)msort((char *)current,(char **)&(current->bp),Configcmp); basisend = 0; return; } /* Return a pointer to the head of the configuration list and ** reset the list */ struct config *Configlist_return(){ struct config *old; old = current; current = 0; currentend = 0; return old; } /* Return a pointer to the head of the configuration list and ** reset the list */ struct config *Configlist_basis(){ struct config *old; old = basis; basis = 0; basisend = 0; return old; } /* Free all elements of the given configuration list */ void Configlist_eat(cfp) struct config *cfp; { struct config *nextcfp; for(; cfp; cfp=nextcfp){ nextcfp = cfp->next; assert( cfp->fplp==0 ); assert( cfp->bplp==0 ); if( cfp->fws ) SetFree(cfp->fws); deleteconfig(cfp); } return; } /***************** From the file "error.c" *********************************/ /* ** Code for printing error message. */ /* Find a good place to break "msg" so that its length is at least "min" ** but no more than "max". Make the point as close to max as possible. */ static int findbreak(msg,min,max) char *msg; int min; int max; { int i,spot; char c; for(i=spot=min; i<=max; i++){ c = msg[i]; if( c=='\t' ) msg[i] = ' '; if( c=='\n' ){ msg[i] = ' '; spot = i; break; } if( c==0 ){ spot = i; break; } if( c=='-' && i<max-1 ) spot = i+1; if( c==' ' ) spot = i; } return spot; } /* ** The error message is split across multiple lines if necessary. The ** splits occur at a space, if there is a space available near the end ** of the line. */ #define ERRMSGSIZE 10000 /* Hope this is big enough. No way to error check */ #define LINEWIDTH 79 /* Max width of any output line */ #define PREFIXLIMIT 30 /* Max width of the prefix on each line */ void ErrorMsg(const char *filename, int lineno, const char *format, ...){ char errmsg[ERRMSGSIZE]; char prefix[PREFIXLIMIT+10]; int errmsgsize; int prefixsize; int availablewidth; va_list ap; int end, restart, base; va_start(ap, format); /* Prepare a prefix to be prepended to every output line */ if( lineno>0 ){ sprintf(prefix,"%.*s:%d: ",PREFIXLIMIT-10,filename,lineno); }else{ sprintf(prefix,"%.*s: ",PREFIXLIMIT-10,filename); } prefixsize = strlen(prefix); availablewidth = LINEWIDTH - prefixsize; /* Generate the error message */ vsprintf(errmsg,format,ap); va_end(ap); errmsgsize = strlen(errmsg); /* Remove trailing '\n's from the error message. */ while( errmsgsize>0 && errmsg[errmsgsize-1]=='\n' ){ errmsg[--errmsgsize] = 0; } /* Print the error message */ base = 0; while( errmsg[base]!=0 ){ end = restart = findbreak(&errmsg[base],0,availablewidth); restart += base; while( errmsg[restart]==' ' ) restart++; fprintf(stdout,"%s%.*s\n",prefix,end,&errmsg[base]); base = restart; } } /**************** From the file "main.c" ************************************/ /* ** Main program file for the LEMON parser generator. */ /* Report an out-of-memory condition and abort. This function ** is used mostly by the "MemoryCheck" macro in struct.h */ void memory_error(){ fprintf(stderr,"Out of memory. Aborting...\n"); exit(1); } static int nDefine = 0; /* Number of -D options on the command line */ static char **azDefine = 0; /* Name of the -D macros */ /* This routine is called with the argument to each -D command-line option. ** Add the macro defined to the azDefine array. */ static void handle_D_option(char *z){ char **paz; nDefine++; azDefine = realloc(azDefine, sizeof(azDefine[0])*nDefine); if( azDefine==0 ){ fprintf(stderr,"out of memory\n"); exit(1); } paz = &azDefine[nDefine-1]; *paz = malloc( strlen(z)+1 ); if( *paz==0 ){ fprintf(stderr,"out of memory\n"); exit(1); } strcpy(*paz, z); for(z=*paz; *z && *z!='='; z++){} *z = 0; } /* The main program. Parse the command line and do it... */ int main(argc,argv) int argc; char **argv; { static int version = 0; static int rpflag = 0; static int basisflag = 0; static int compress = 0; static int quiet = 0; static int statistics = 0; static int mhflag = 0; static struct s_options options[] = { {OPT_FLAG, "b", (char*)&basisflag, "Print only the basis in report."}, {OPT_FLAG, "c", (char*)&compress, "Don't compress the action table."}, {OPT_FSTR, "D", (char*)handle_D_option, "Define an %ifdef macro."}, {OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."}, {OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file"}, {OPT_FLAG, "q", (char*)&quiet, "(Quiet) Don't print the report file."}, {OPT_FLAG, "s", (char*)&statistics, "Print parser stats to standard output."}, {OPT_FLAG, "x", (char*)&version, "Print the version number."}, {OPT_FLAG,0,0,0} }; int i; struct lemon lem; OptInit(argv,options,stderr); if( version ){ printf("Lemon version 1.0\n"); exit(0); } if( OptNArgs()!=1 ){ fprintf(stderr,"Exactly one filename argument is required.\n"); exit(1); } lem.errorcnt = 0; /* Initialize the machine */ Strsafe_init(); Symbol_init(); State_init(); lem.argv0 = argv[0]; lem.filename = OptArg(0); lem.basisflag = basisflag; lem.has_fallback = 0; lem.nconflict = 0; lem.name = lem.include = lem.arg = lem.tokentype = lem.start = 0; lem.vartype = 0; lem.stacksize = 0; lem.error = lem.overflow = lem.failure = lem.accept = lem.tokendest = lem.tokenprefix = lem.outname = lem.extracode = 0; lem.vardest = 0; lem.tablesize = 0; Symbol_new("$"); lem.errsym = Symbol_new("error"); /* Parse the input file */ Parse(&lem); if( lem.errorcnt ) exit(lem.errorcnt); if( lem.rule==0 ){ fprintf(stderr,"Empty grammar.\n"); exit(1); } /* Count and index the symbols of the grammar */ lem.nsymbol = Symbol_count(); Symbol_new("{default}"); lem.symbols = Symbol_arrayof(); for(i=0; i<=lem.nsymbol; i++) lem.symbols[i]->index = i; qsort(lem.symbols,lem.nsymbol+1,sizeof(struct symbol*), (int(*)())Symbolcmpp); for(i=0; i<=lem.nsymbol; i++) lem.symbols[i]->index = i; for(i=1; isupper(lem.symbols[i]->name[0]); i++); lem.nterminal = i; /* Generate a reprint of the grammar, if requested on the command line */ if( rpflag ){ Reprint(&lem); }else{ /* Initialize the size for all follow and first sets */ SetSize(lem.nterminal); /* Find the precedence for every production rule (that has one) */ FindRulePrecedences(&lem); /* Compute the lambda-nonterminals and the first-sets for every ** nonterminal */ FindFirstSets(&lem); /* Compute all LR(0) states. Also record follow-set propagation ** links so that the follow-set can be computed later */ lem.nstate = 0; FindStates(&lem); lem.sorted = State_arrayof(); /* Tie up loose ends on the propagation links */ FindLinks(&lem); /* Compute the follow set of every reducible configuration */ FindFollowSets(&lem); /* Compute the action tables */ FindActions(&lem); /* Compress the action tables */ if( compress==0 ) CompressTables(&lem); /* Generate a report of the parser generated. (the "y.output" file) */ if( !quiet ) ReportOutput(&lem); /* Generate the source code for the parser */ ReportTable(&lem, mhflag); /* Produce a header file for use by the scanner. (This step is ** omitted if the "-m" option is used because makeheaders will ** generate the file for us.) */ if( !mhflag ) ReportHeader(&lem); } if( statistics ){ printf("Parser statistics: %d terminals, %d nonterminals, %d rules\n", lem.nterminal, lem.nsymbol - lem.nterminal, lem.nrule); printf(" %d states, %d parser table entries, %d conflicts\n", lem.nstate, lem.tablesize, lem.nconflict); } if( lem.nconflict ){ fprintf(stderr,"%d parsing conflicts.\n",lem.nconflict); } exit(lem.errorcnt + lem.nconflict); return (lem.errorcnt + lem.nconflict); } /******************** From the file "msort.c" *******************************/ /* ** A generic merge-sort program. ** ** USAGE: ** Let "ptr" be a pointer to some structure which is at the head of ** a null-terminated list. Then to sort the list call: ** ** ptr = msort(ptr,&(ptr->next),cmpfnc); ** ** In the above, "cmpfnc" is a pointer to a function which compares ** two instances of the structure and returns an integer, as in ** strcmp. The second argument is a pointer to the pointer to the ** second element of the linked list. This address is used to compute ** the offset to the "next" field within the structure. The offset to ** the "next" field must be constant for all structures in the list. ** ** The function returns a new pointer which is the head of the list ** after sorting. ** ** ALGORITHM: ** Merge-sort. */ /* ** Return a pointer to the next structure in the linked list. */ #define NEXT(A) (*(char**)(((unsigned long)A)+offset)) /* ** Inputs: ** a: A sorted, null-terminated linked list. (May be null). ** b: A sorted, null-terminated linked list. (May be null). ** cmp: A pointer to the comparison function. ** offset: Offset in the structure to the "next" field. ** ** Return Value: ** A pointer to the head of a sorted list containing the elements ** of both a and b. ** ** Side effects: ** The "next" pointers for elements in the lists a and b are ** changed. */ static char *merge(a,b,cmp,offset) char *a; char *b; int (*cmp)(); int offset; { char *ptr, *head; if( a==0 ){ head = b; }else if( b==0 ){ head = a; }else{ if( (*cmp)(a,b)<0 ){ ptr = a; a = NEXT(a); }else{ ptr = b; b = NEXT(b); } head = ptr; while( a && b ){ if( (*cmp)(a,b)<0 ){ NEXT(ptr) = a; ptr = a; a = NEXT(a); }else{ NEXT(ptr) = b; ptr = b; b = NEXT(b); } } if( a ) NEXT(ptr) = a; else NEXT(ptr) = b; } return head; } /* ** Inputs: ** list: Pointer to a singly-linked list of structures. ** next: Pointer to pointer to the second element of the list. ** cmp: A comparison function. ** ** Return Value: ** A pointer to the head of a sorted list containing the elements ** orginally in list. ** ** Side effects: ** The "next" pointers for elements in list are changed. */ #define LISTSIZE 30 char *msort(list,next,cmp) char *list; char **next; int (*cmp)(); { unsigned long offset; char *ep; char *set[LISTSIZE]; int i; offset = (unsigned long)next - (unsigned long)list; for(i=0; i<LISTSIZE; i++) set[i] = 0; while( list ){ ep = list; list = NEXT(list); NEXT(ep) = 0; for(i=0; i<LISTSIZE-1 && set[i]!=0; i++){ ep = merge(ep,set[i],cmp,offset); set[i] = 0; } set[i] = ep; } ep = 0; for(i=0; i<LISTSIZE; i++) if( set[i] ) ep = merge(ep,set[i],cmp,offset); return ep; } /************************ From the file "option.c" **************************/ static char **argv; static struct s_options *op; static FILE *errstream; #define ISOPT(X) ((X)[0]=='-'||(X)[0]=='+'||strchr((X),'=')!=0) /* ** Print the command line with a carrot pointing to the k-th character ** of the n-th field. */ static void errline(n,k,err) int n; int k; FILE *err; { int spcnt, i; spcnt = 0; if( argv[0] ) fprintf(err,"%s",argv[0]); spcnt = strlen(argv[0]) + 1; for(i=1; i<n && argv[i]; i++){ fprintf(err," %s",argv[i]); spcnt += strlen(argv[i]+1); } spcnt += k; for(; argv[i]; i++) fprintf(err," %s",argv[i]); if( spcnt<20 ){ fprintf(err,"\n%*s^-- here\n",spcnt,""); }else{ fprintf(err,"\n%*shere --^\n",spcnt-7,""); } } /* ** Return the index of the N-th non-switch argument. Return -1 ** if N is out of range. */ static int argindex(n) int n; { int i; int dashdash = 0; if( argv!=0 && *argv!=0 ){ for(i=1; argv[i]; i++){ if( dashdash || !ISOPT(argv[i]) ){ if( n==0 ) return i; n--; } if( strcmp(argv[i],"--")==0 ) dashdash = 1; } } return -1; } static char emsg[] = "Command line syntax error: "; /* ** Process a flag command line argument. */ static int handleflags(i,err) int i; FILE *err; { int v; int errcnt = 0; int j; for(j=0; op[j].label; j++){ if( strncmp(&argv[i][1],op[j].label,strlen(op[j].label))==0 ) break; } v = argv[i][0]=='-' ? 1 : 0; if( op[j].label==0 ){ if( err ){ fprintf(err,"%sundefined option.\n",emsg); errline(i,1,err); } errcnt++; }else if( op[j].type==OPT_FLAG ){ *((int*)op[j].arg) = v; }else if( op[j].type==OPT_FFLAG ){ (*(void(*)())(op[j].arg))(v); }else if( op[j].type==OPT_FSTR ){ (*(void(*)())(op[j].arg))(&argv[i][2]); }else{ if( err ){ fprintf(err,"%smissing argument on switch.\n",emsg); errline(i,1,err); } errcnt++; } return errcnt; } /* ** Process a command line switch which has an argument. */ static int handleswitch(i,err) int i; FILE *err; { int lv = 0; double dv = 0.0; char *sv = 0, *end; char *cp; int j; int errcnt = 0; cp = strchr(argv[i],'='); *cp = 0; for(j=0; op[j].label; j++){ if( strcmp(argv[i],op[j].label)==0 ) break; } *cp = '='; if( op[j].label==0 ){ if( err ){ fprintf(err,"%sundefined option.\n",emsg); errline(i,0,err); } errcnt++; }else{ cp++; switch( op[j].type ){ case OPT_FLAG: case OPT_FFLAG: if( err ){ fprintf(err,"%soption requires an argument.\n",emsg); errline(i,0,err); } errcnt++; break; case OPT_DBL: case OPT_FDBL: dv = strtod(cp,&end); if( *end ){ if( err ){ fprintf(err,"%sillegal character in floating-point argument.\n",emsg); errline(i,((unsigned long)end)-(unsigned long)argv[i],err); } errcnt++; } break; case OPT_INT: case OPT_FINT: lv = strtol(cp,&end,0); if( *end ){ if( err ){ fprintf(err,"%sillegal character in integer argument.\n",emsg); errline(i,((unsigned long)end)-(unsigned long)argv[i],err); } errcnt++; } break; case OPT_STR: case OPT_FSTR: sv = cp; break; } switch( op[j].type ){ case OPT_FLAG: case OPT_FFLAG: break; case OPT_DBL: *(double*)(op[j].arg) = dv; break; case OPT_FDBL: (*(void(*)())(op[j].arg))(dv); break; case OPT_INT: *(int*)(op[j].arg) = lv; break; case OPT_FINT: (*(void(*)())(op[j].arg))((int)lv); break; case OPT_STR: *(char**)(op[j].arg) = sv; break; case OPT_FSTR: (*(void(*)())(op[j].arg))(sv); break; } } return errcnt; } int OptInit(a,o,err) char **a; struct s_options *o; FILE *err; { int errcnt = 0; argv = a; op = o; errstream = err; if( argv && *argv && op ){ int i; for(i=1; argv[i]; i++){ if( argv[i][0]=='+' || argv[i][0]=='-' ){ errcnt += handleflags(i,err); }else if( strchr(argv[i],'=') ){ errcnt += handleswitch(i,err); } } } if( errcnt>0 ){ fprintf(err,"Valid command line options for \"%s\" are:\n",*a); OptPrint(); exit(1); } return 0; } int OptNArgs(){ int cnt = 0; int dashdash = 0; int i; if( argv!=0 && argv[0]!=0 ){ for(i=1; argv[i]; i++){ if( dashdash || !ISOPT(argv[i]) ) cnt++; if( strcmp(argv[i],"--")==0 ) dashdash = 1; } } return cnt; } char *OptArg(n) int n; { int i; i = argindex(n); return i>=0 ? argv[i] : 0; } void OptErr(n) int n; { int i; i = argindex(n); if( i>=0 ) errline(i,0,errstream); } void OptPrint(){ int i; int max, len; max = 0; for(i=0; op[i].label; i++){ len = strlen(op[i].label) + 1; switch( op[i].type ){ case OPT_FLAG: case OPT_FFLAG: break; case OPT_INT: case OPT_FINT: len += 9; /* length of "<integer>" */ break; case OPT_DBL: case OPT_FDBL: len += 6; /* length of "<real>" */ break; case OPT_STR: case OPT_FSTR: len += 8; /* length of "<string>" */ break; } if( len>max ) max = len; } for(i=0; op[i].label; i++){ switch( op[i].type ){ case OPT_FLAG: case OPT_FFLAG: fprintf(errstream," -%-*s %s\n",max,op[i].label,op[i].message); break; case OPT_INT: case OPT_FINT: fprintf(errstream," %s=<integer>%*s %s\n",op[i].label, (int)(max-strlen(op[i].label)-9),"",op[i].message); break; case OPT_DBL: case OPT_FDBL: fprintf(errstream," %s=<real>%*s %s\n",op[i].label, (int)(max-strlen(op[i].label)-6),"",op[i].message); break; case OPT_STR: case OPT_FSTR: fprintf(errstream," %s=<string>%*s %s\n",op[i].label, (int)(max-strlen(op[i].label)-8),"",op[i].message); break; } } } /*********************** From the file "parse.c" ****************************/ /* ** Input file parser for the LEMON parser generator. */ /* The state of the parser */ struct pstate { char *filename; /* Name of the input file */ int tokenlineno; /* Linenumber at which current token starts */ int errorcnt; /* Number of errors so far */ char *tokenstart; /* Text of current token */ struct lemon *gp; /* Global state vector */ enum e_state { INITIALIZE, WAITING_FOR_DECL_OR_RULE, WAITING_FOR_DECL_KEYWORD, WAITING_FOR_DECL_ARG, WAITING_FOR_PRECEDENCE_SYMBOL, WAITING_FOR_ARROW, IN_RHS, LHS_ALIAS_1, LHS_ALIAS_2, LHS_ALIAS_3, RHS_ALIAS_1, RHS_ALIAS_2, PRECEDENCE_MARK_1, PRECEDENCE_MARK_2, RESYNC_AFTER_RULE_ERROR, RESYNC_AFTER_DECL_ERROR, WAITING_FOR_DESTRUCTOR_SYMBOL, WAITING_FOR_DATATYPE_SYMBOL, WAITING_FOR_FALLBACK_ID } state; /* The state of the parser */ struct symbol *fallback; /* The fallback token */ struct symbol *lhs; /* Left-hand side of current rule */ char *lhsalias; /* Alias for the LHS */ int nrhs; /* Number of right-hand side symbols seen */ struct symbol *rhs[MAXRHS]; /* RHS symbols */ char *alias[MAXRHS]; /* Aliases for each RHS symbol (or NULL) */ struct rule *prevrule; /* Previous rule parsed */ char *declkeyword; /* Keyword of a declaration */ char **declargslot; /* Where the declaration argument should be put */ int *decllnslot; /* Where the declaration linenumber is put */ enum e_assoc declassoc; /* Assign this association to decl arguments */ int preccounter; /* Assign this precedence to decl arguments */ struct rule *firstrule; /* Pointer to first rule in the grammar */ struct rule *lastrule; /* Pointer to the most recently parsed rule */ }; /* Parse a single token */ static void parseonetoken(psp) struct pstate *psp; { char *x; x = Strsafe(psp->tokenstart); /* Save the token permanently */ #if 0 printf("%s:%d: Token=[%s] state=%d\n",psp->filename,psp->tokenlineno, x,psp->state); #endif switch( psp->state ){ case INITIALIZE: psp->prevrule = 0; psp->preccounter = 0; psp->firstrule = psp->lastrule = 0; psp->gp->nrule = 0; /* Fall thru to next case */ case WAITING_FOR_DECL_OR_RULE: if( x[0]=='%' ){ psp->state = WAITING_FOR_DECL_KEYWORD; }else if( islower(x[0]) ){ psp->lhs = Symbol_new(x); psp->nrhs = 0; psp->lhsalias = 0; psp->state = WAITING_FOR_ARROW; }else if( x[0]=='{' ){ if( psp->prevrule==0 ){ ErrorMsg(psp->filename,psp->tokenlineno, "There is not prior rule opon which to attach the code \ fragment which begins on this line."); psp->errorcnt++; }else if( psp->prevrule->code!=0 ){ ErrorMsg(psp->filename,psp->tokenlineno, "Code fragment beginning on this line is not the first \ to follow the previous rule."); psp->errorcnt++; }else{ psp->prevrule->line = psp->tokenlineno; psp->prevrule->code = &x[1]; } }else if( x[0]=='[' ){ psp->state = PRECEDENCE_MARK_1; }else{ ErrorMsg(psp->filename,psp->tokenlineno, "Token \"%s\" should be either \"%%\" or a nonterminal name.", x); psp->errorcnt++; } break; case PRECEDENCE_MARK_1: if( !isupper(x[0]) ){ ErrorMsg(psp->filename,psp->tokenlineno, "The precedence symbol must be a terminal."); psp->errorcnt++; }else if( psp->prevrule==0 ){ ErrorMsg(psp->filename,psp->tokenlineno, "There is no prior rule to assign precedence \"[%s]\".",x); psp->errorcnt++; }else if( psp->prevrule->precsym!=0 ){ ErrorMsg(psp->filename,psp->tokenlineno, "Precedence mark on this line is not the first \ to follow the previous rule."); psp->errorcnt++; }else{ psp->prevrule->precsym = Symbol_new(x); } psp->state = PRECEDENCE_MARK_2; break; case PRECEDENCE_MARK_2: if( x[0]!=']' ){ ErrorMsg(psp->filename,psp->tokenlineno, "Missing \"]\" on precedence mark."); psp->errorcnt++; } psp->state = WAITING_FOR_DECL_OR_RULE; break; case WAITING_FOR_ARROW: if( x[0]==':' && x[1]==':' && x[2]=='=' ){ psp->state = IN_RHS; }else if( x[0]=='(' ){ psp->state = LHS_ALIAS_1; }else{ ErrorMsg(psp->filename,psp->tokenlineno, "Expected to see a \":\" following the LHS symbol \"%s\".", psp->lhs->name); psp->errorcnt++; psp->state = RESYNC_AFTER_RULE_ERROR; } break; case LHS_ALIAS_1: if( isalpha(x[0]) ){ psp->lhsalias = x; psp->state = LHS_ALIAS_2; }else{ ErrorMsg(psp->filename,psp->tokenlineno, "\"%s\" is not a valid alias for the LHS \"%s\"\n", x,psp->lhs->name); psp->errorcnt++; psp->state = RESYNC_AFTER_RULE_ERROR; } break; case LHS_ALIAS_2: if( x[0]==')' ){ psp->state = LHS_ALIAS_3; }else{ ErrorMsg(psp->filename,psp->tokenlineno, "Missing \")\" following LHS alias name \"%s\".",psp->lhsalias); psp->errorcnt++; psp->state = RESYNC_AFTER_RULE_ERROR; } break; case LHS_ALIAS_3: if( x[0]==':' && x[1]==':' && x[2]=='=' ){ psp->state = IN_RHS; }else{ ErrorMsg(psp->filename,psp->tokenlineno, "Missing \"->\" following: \"%s(%s)\".", psp->lhs->name,psp->lhsalias); psp->errorcnt++; psp->state = RESYNC_AFTER_RULE_ERROR; } break; case IN_RHS: if( x[0]=='.' ){ struct rule *rp; rp = (struct rule *)malloc( sizeof(struct rule) + sizeof(struct symbol*)*psp->nrhs + sizeof(char*)*psp->nrhs ); if( rp==0 ){ ErrorMsg(psp->filename,psp->tokenlineno, "Can't allocate enough memory for this rule."); psp->errorcnt++; psp->prevrule = 0; }else{ int i; rp->ruleline = psp->tokenlineno; rp->rhs = (struct symbol**)&rp[1]; rp->rhsalias = (char**)&(rp->rhs[psp->nrhs]); for(i=0; i<psp->nrhs; i++){ rp->rhs[i] = psp->rhs[i]; rp->rhsalias[i] = psp->alias[i]; } rp->lhs = psp->lhs; rp->lhsalias = psp->lhsalias; rp->nrhs = psp->nrhs; rp->code = 0; rp->precsym = 0; rp->index = psp->gp->nrule++; rp->nextlhs = rp->lhs->rule; rp->lhs->rule = rp; rp->next = 0; if( psp->firstrule==0 ){ psp->firstrule = psp->lastrule = rp; }else{ psp->lastrule->next = rp; psp->lastrule = rp; } psp->prevrule = rp; } psp->state = WAITING_FOR_DECL_OR_RULE; }else if( isalpha(x[0]) ){ if( psp->nrhs>=MAXRHS ){ ErrorMsg(psp->filename,psp->tokenlineno, "Too many symbol on RHS or rule beginning at \"%s\".", x); psp->errorcnt++; psp->state = RESYNC_AFTER_RULE_ERROR; }else{ psp->rhs[psp->nrhs] = Symbol_new(x); psp->alias[psp->nrhs] = 0; psp->nrhs++; } }else if( x[0]=='(' && psp->nrhs>0 ){ psp->state = RHS_ALIAS_1; }else{ ErrorMsg(psp->filename,psp->tokenlineno, "Illegal character on RHS of rule: \"%s\".",x); psp->errorcnt++; psp->state = RESYNC_AFTER_RULE_ERROR; } break; case RHS_ALIAS_1: if( isalpha(x[0]) ){ psp->alias[psp->nrhs-1] = x; psp->state = RHS_ALIAS_2; }else{ ErrorMsg(psp->filename,psp->tokenlineno, "\"%s\" is not a valid alias for the RHS symbol \"%s\"\n", x,psp->rhs[psp->nrhs-1]->name); psp->errorcnt++; psp->state = RESYNC_AFTER_RULE_ERROR; } break; case RHS_ALIAS_2: if( x[0]==')' ){ psp->state = IN_RHS; }else{ ErrorMsg(psp->filename,psp->tokenlineno, "Missing \")\" following LHS alias name \"%s\".",psp->lhsalias); psp->errorcnt++; psp->state = RESYNC_AFTER_RULE_ERROR; } break; case WAITING_FOR_DECL_KEYWORD: if( isalpha(x[0]) ){ psp->declkeyword = x; psp->declargslot = 0; psp->decllnslot = 0; psp->state = WAITING_FOR_DECL_ARG; if( strcmp(x,"name")==0 ){ psp->declargslot = &(psp->gp->name); }else if( strcmp(x,"include")==0 ){ psp->declargslot = &(psp->gp->include); psp->decllnslot = &psp->gp->includeln; }else if( strcmp(x,"code")==0 ){ psp->declargslot = &(psp->gp->extracode); psp->decllnslot = &psp->gp->extracodeln; }else if( strcmp(x,"token_destructor")==0 ){ psp->declargslot = &psp->gp->tokendest; psp->decllnslot = &psp->gp->tokendestln; }else if( strcmp(x,"default_destructor")==0 ){ psp->declargslot = &psp->gp->vardest; psp->decllnslot = &psp->gp->vardestln; }else if( strcmp(x,"token_prefix")==0 ){ psp->declargslot = &psp->gp->tokenprefix; }else if( strcmp(x,"syntax_error")==0 ){ psp->declargslot = &(psp->gp->error); psp->decllnslot = &psp->gp->errorln; }else if( strcmp(x,"parse_accept")==0 ){ psp->declargslot = &(psp->gp->accept); psp->decllnslot = &psp->gp->acceptln; }else if( strcmp(x,"parse_failure")==0 ){ psp->declargslot = &(psp->gp->failure); psp->decllnslot = &psp->gp->failureln; }else if( strcmp(x,"stack_overflow")==0 ){ psp->declargslot = &(psp->gp->overflow); psp->decllnslot = &psp->gp->overflowln; }else if( strcmp(x,"extra_argument")==0 ){ psp->declargslot = &(psp->gp->arg); }else if( strcmp(x,"token_type")==0 ){ psp->declargslot = &(psp->gp->tokentype); }else if( strcmp(x,"default_type")==0 ){ psp->declargslot = &(psp->gp->vartype); }else if( strcmp(x,"stack_size")==0 ){ psp->declargslot = &(psp->gp->stacksize); }else if( strcmp(x,"start_symbol")==0 ){ psp->declargslot = &(psp->gp->start); }else if( strcmp(x,"left")==0 ){ psp->preccounter++; psp->declassoc = LEFT; psp->state = WAITING_FOR_PRECEDENCE_SYMBOL; }else if( strcmp(x,"right")==0 ){ psp->preccounter++; psp->declassoc = RIGHT; psp->state = WAITING_FOR_PRECEDENCE_SYMBOL; }else if( strcmp(x,"nonassoc")==0 ){ psp->preccounter++; psp->declassoc = NONE; psp->state = WAITING_FOR_PRECEDENCE_SYMBOL; }else if( strcmp(x,"destructor")==0 ){ psp->state = WAITING_FOR_DESTRUCTOR_SYMBOL; }else if( strcmp(x,"type")==0 ){ psp->state = WAITING_FOR_DATATYPE_SYMBOL; }else if( strcmp(x,"fallback")==0 ){ psp->fallback = 0; psp->state = WAITING_FOR_FALLBACK_ID; }else{ ErrorMsg(psp->filename,psp->tokenlineno, "Unknown declaration keyword: \"%%%s\".",x); psp->errorcnt++; psp->state = RESYNC_AFTER_DECL_ERROR; } }else{ ErrorMsg(psp->filename,psp->tokenlineno, "Illegal declaration keyword: \"%s\".",x); psp->errorcnt++; psp->state = RESYNC_AFTER_DECL_ERROR; } break; case WAITING_FOR_DESTRUCTOR_SYMBOL: if( !isalpha(x[0]) ){ ErrorMsg(psp->filename,psp->tokenlineno, "Symbol name missing after %destructor keyword"); psp->errorcnt++; psp->state = RESYNC_AFTER_DECL_ERROR; }else{ struct symbol *sp = Symbol_new(x); psp->declargslot = &sp->destructor; psp->decllnslot = &sp->destructorln; psp->state = WAITING_FOR_DECL_ARG; } break; case WAITING_FOR_DATATYPE_SYMBOL: if( !isalpha(x[0]) ){ ErrorMsg(psp->filename,psp->tokenlineno, "Symbol name missing after %destructor keyword"); psp->errorcnt++; psp->state = RESYNC_AFTER_DECL_ERROR; }else{ struct symbol *sp = Symbol_new(x); psp->declargslot = &sp->datatype; psp->decllnslot = 0; psp->state = WAITING_FOR_DECL_ARG; } break; case WAITING_FOR_PRECEDENCE_SYMBOL: if( x[0]=='.' ){ psp->state = WAITING_FOR_DECL_OR_RULE; }else if( isupper(x[0]) ){ struct symbol *sp; sp = Symbol_new(x); if( sp->prec>=0 ){ ErrorMsg(psp->filename,psp->tokenlineno, "Symbol \"%s\" has already be given a precedence.",x); psp->errorcnt++; }else{ sp->prec = psp->preccounter; sp->assoc = psp->declassoc; } }else{ ErrorMsg(psp->filename,psp->tokenlineno, "Can't assign a precedence to \"%s\".",x); psp->errorcnt++; } break; case WAITING_FOR_DECL_ARG: if( (x[0]=='{' || x[0]=='\"' || isalnum(x[0])) ){ if( *(psp->declargslot)!=0 ){ ErrorMsg(psp->filename,psp->tokenlineno, "The argument \"%s\" to declaration \"%%%s\" is not the first.", x[0]=='\"' ? &x[1] : x,psp->declkeyword); psp->errorcnt++; psp->state = RESYNC_AFTER_DECL_ERROR; }else{ *(psp->declargslot) = (x[0]=='\"' || x[0]=='{') ? &x[1] : x; if( psp->decllnslot ) *psp->decllnslot = psp->tokenlineno; psp->state = WAITING_FOR_DECL_OR_RULE; } }else{ ErrorMsg(psp->filename,psp->tokenlineno, "Illegal argument to %%%s: %s",psp->declkeyword,x); psp->errorcnt++; psp->state = RESYNC_AFTER_DECL_ERROR; } break; case WAITING_FOR_FALLBACK_ID: if( x[0]=='.' ){ psp->state = WAITING_FOR_DECL_OR_RULE; }else if( !isupper(x[0]) ){ ErrorMsg(psp->filename, psp->tokenlineno, "%%fallback argument \"%s\" should be a token", x); psp->errorcnt++; }else{ struct symbol *sp = Symbol_new(x); if( psp->fallback==0 ){ psp->fallback = sp; }else if( sp->fallback ){ ErrorMsg(psp->filename, psp->tokenlineno, "More than one fallback assigned to token %s", x); psp->errorcnt++; }else{ sp->fallback = psp->fallback; psp->gp->has_fallback = 1; } } break; case RESYNC_AFTER_RULE_ERROR: /* if( x[0]=='.' ) psp->state = WAITING_FOR_DECL_OR_RULE; ** break; */ case RESYNC_AFTER_DECL_ERROR: if( x[0]=='.' ) psp->state = WAITING_FOR_DECL_OR_RULE; if( x[0]=='%' ) psp->state = WAITING_FOR_DECL_KEYWORD; break; } } /* Run the proprocessor over the input file text. The global variables ** azDefine[0] through azDefine[nDefine-1] contains the names of all defined ** macros. This routine looks for "%ifdef" and "%ifndef" and "%endif" and ** comments them out. Text in between is also commented out as appropriate. */ static preprocess_input(char *z){ int i, j, k, n; int exclude = 0; int start; int lineno = 1; int start_lineno; for(i=0; z[i]; i++){ if( z[i]=='\n' ) lineno++; if( z[i]!='%' || (i>0 && z[i-1]!='\n') ) continue; if( strncmp(&z[i],"%endif",6)==0 && isspace(z[i+6]) ){ if( exclude ){ exclude--; if( exclude==0 ){ for(j=start; j<i; j++) if( z[j]!='\n' ) z[j] = ' '; } } for(j=i; z[j] && z[j]!='\n'; j++) z[j] = ' '; }else if( (strncmp(&z[i],"%ifdef",6)==0 && isspace(z[i+6])) || (strncmp(&z[i],"%ifndef",7)==0 && isspace(z[i+7])) ){ if( exclude ){ exclude++; }else{ for(j=i+7; isspace(z[j]); j++){} for(n=0; z[j+n] && !isspace(z[j+n]); n++){} exclude = 1; for(k=0; k<nDefine; k++){ if( strncmp(azDefine[k],&z[j],n)==0 && strlen(azDefine[k])==n ){ exclude = 0; break; } } if( z[i+3]=='n' ) exclude = !exclude; if( exclude ){ start = i; start_lineno = lineno; } } for(j=i; z[j] && z[j]!='\n'; j++) z[j] = ' '; } } if( exclude ){ fprintf(stderr,"unterminated %%ifdef starting on line %d\n", start_lineno); exit(1); } } /* In spite of its name, this function is really a scanner. It read ** in the entire input file (all at once) then tokenizes it. Each ** token is passed to the function "parseonetoken" which builds all ** the appropriate data structures in the global state vector "gp". */ void Parse(gp) struct lemon *gp; { struct pstate ps; FILE *fp; char *filebuf; int filesize; int lineno; int c; char *cp, *nextcp; int startline = 0; ps.gp = gp; ps.filename = gp->filename; ps.errorcnt = 0; ps.state = INITIALIZE; /* Begin by reading the input file */ fp = fopen(ps.filename,"rb"); if( fp==0 ){ ErrorMsg(ps.filename,0,"Can't open this file for reading."); gp->errorcnt++; return; } fseek(fp,0,2); filesize = ftell(fp); rewind(fp); filebuf = (char *)malloc( filesize+1 ); if( filebuf==0 ){ ErrorMsg(ps.filename,0,"Can't allocate %d of memory to hold this file.", filesize+1); gp->errorcnt++; return; } if( fread(filebuf,1,filesize,fp)!=filesize ){ ErrorMsg(ps.filename,0,"Can't read in all %d bytes of this file.", filesize); free(filebuf); gp->errorcnt++; return; } fclose(fp); filebuf[filesize] = 0; /* Make an initial pass through the file to handle %ifdef and %ifndef */ preprocess_input(filebuf); /* Now scan the text of the input file */ lineno = 1; for(cp=filebuf; (c= *cp)!=0; ){ if( c=='\n' ) lineno++; /* Keep track of the line number */ if( isspace(c) ){ cp++; continue; } /* Skip all white space */ if( c=='/' && cp[1]=='/' ){ /* Skip C++ style comments */ cp+=2; while( (c= *cp)!=0 && c!='\n' ) cp++; continue; } if( c=='/' && cp[1]=='*' ){ /* Skip C style comments */ cp+=2; while( (c= *cp)!=0 && (c!='/' || cp[-1]!='*') ){ if( c=='\n' ) lineno++; cp++; } if( c ) cp++; continue; } ps.tokenstart = cp; /* Mark the beginning of the token */ ps.tokenlineno = lineno; /* Linenumber on which token begins */ if( c=='\"' ){ /* String literals */ cp++; while( (c= *cp)!=0 && c!='\"' ){ if( c=='\n' ) lineno++; cp++; } if( c==0 ){ ErrorMsg(ps.filename,startline, "String starting on this line is not terminated before the end of the file."); ps.errorcnt++; nextcp = cp; }else{ nextcp = cp+1; } }else if( c=='{' ){ /* A block of C code */ int level; cp++; for(level=1; (c= *cp)!=0 && (level>1 || c!='}'); cp++){ if( c=='\n' ) lineno++; else if( c=='{' ) level++; else if( c=='}' ) level--; else if( c=='/' && cp[1]=='*' ){ /* Skip comments */ int prevc; cp = &cp[2]; prevc = 0; while( (c= *cp)!=0 && (c!='/' || prevc!='*') ){ if( c=='\n' ) lineno++; prevc = c; cp++; } }else if( c=='/' && cp[1]=='/' ){ /* Skip C++ style comments too */ cp = &cp[2]; while( (c= *cp)!=0 && c!='\n' ) cp++; if( c ) lineno++; }else if( c=='\'' || c=='\"' ){ /* String a character literals */ int startchar, prevc; startchar = c; prevc = 0; for(cp++; (c= *cp)!=0 && (c!=startchar || prevc=='\\'); cp++){ if( c=='\n' ) lineno++; if( prevc=='\\' ) prevc = 0; else prevc = c; } } } if( c==0 ){ ErrorMsg(ps.filename,ps.tokenlineno, "C code starting on this line is not terminated before the end of the file."); ps.errorcnt++; nextcp = cp; }else{ nextcp = cp+1; } }else if( isalnum(c) ){ /* Identifiers */ while( (c= *cp)!=0 && (isalnum(c) || c=='_') ) cp++; nextcp = cp; }else if( c==':' && cp[1]==':' && cp[2]=='=' ){ /* The operator "::=" */ cp += 3; nextcp = cp; }else{ /* All other (one character) operators */ cp++; nextcp = cp; } c = *cp; *cp = 0; /* Null terminate the token */ parseonetoken(&ps); /* Parse the token */ *cp = c; /* Restore the buffer */ cp = nextcp; } free(filebuf); /* Release the buffer after parsing */ gp->rule = ps.firstrule; gp->errorcnt = ps.errorcnt; } /*************************** From the file "plink.c" *********************/ /* ** Routines processing configuration follow-set propagation links ** in the LEMON parser generator. */ static struct plink *plink_freelist = 0; /* Allocate a new plink */ struct plink *Plink_new(){ struct plink *new; if( plink_freelist==0 ){ int i; int amt = 100; plink_freelist = (struct plink *)malloc( sizeof(struct plink)*amt ); if( plink_freelist==0 ){ fprintf(stderr, "Unable to allocate memory for a new follow-set propagation link.\n"); exit(1); } for(i=0; i<amt-1; i++) plink_freelist[i].next = &plink_freelist[i+1]; plink_freelist[amt-1].next = 0; } new = plink_freelist; plink_freelist = plink_freelist->next; return new; } /* Add a plink to a plink list */ void Plink_add(plpp,cfp) struct plink **plpp; struct config *cfp; { struct plink *new; new = Plink_new(); new->next = *plpp; *plpp = new; new->cfp = cfp; } /* Transfer every plink on the list "from" to the list "to" */ void Plink_copy(to,from) struct plink **to; struct plink *from; { struct plink *nextpl; while( from ){ nextpl = from->next; from->next = *to; *to = from; from = nextpl; } } /* Delete every plink on the list */ void Plink_delete(plp) struct plink *plp; { struct plink *nextpl; while( plp ){ nextpl = plp->next; plp->next = plink_freelist; plink_freelist = plp; plp = nextpl; } } /*********************** From the file "report.c" **************************/ /* ** Procedures for generating reports and tables in the LEMON parser generator. */ /* Generate a filename with the given suffix. Space to hold the ** name comes from malloc() and must be freed by the calling ** function. */ PRIVATE char *file_makename(lemp,suffix) struct lemon *lemp; char *suffix; { char *name; char *cp; name = malloc( strlen(lemp->filename) + strlen(suffix) + 5 ); if( name==0 ){ fprintf(stderr,"Can't allocate space for a filename.\n"); exit(1); } strcpy(name,lemp->filename); cp = strrchr(name,'.'); if( cp ) *cp = 0; strcat(name,suffix); return name; } /* Open a file with a name based on the name of the input file, ** but with a different (specified) suffix, and return a pointer ** to the stream */ PRIVATE FILE *file_open(lemp,suffix,mode) struct lemon *lemp; char *suffix; char *mode; { FILE *fp; if( lemp->outname ) free(lemp->outname); lemp->outname = file_makename(lemp, suffix); fp = fopen(lemp->outname,mode); if( fp==0 && *mode=='w' ){ fprintf(stderr,"Can't open file \"%s\".\n",lemp->outname); lemp->errorcnt++; return 0; } return fp; } /* Duplicate the input file without comments and without actions ** on rules */ void Reprint(lemp) struct lemon *lemp; { struct rule *rp; struct symbol *sp; int i, j, maxlen, len, ncolumns, skip; printf("// Reprint of input file \"%s\".\n// Symbols:\n",lemp->filename); maxlen = 10; for(i=0; i<lemp->nsymbol; i++){ sp = lemp->symbols[i]; len = strlen(sp->name); if( len>maxlen ) maxlen = len; } ncolumns = 76/(maxlen+5); if( ncolumns<1 ) ncolumns = 1; skip = (lemp->nsymbol + ncolumns - 1)/ncolumns; for(i=0; i<skip; i++){ printf("//"); for(j=i; j<lemp->nsymbol; j+=skip){ sp = lemp->symbols[j]; assert( sp->index==j ); printf(" %3d %-*.*s",j,maxlen,maxlen,sp->name); } printf("\n"); } for(rp=lemp->rule; rp; rp=rp->next){ printf("%s",rp->lhs->name); /* if( rp->lhsalias ) printf("(%s)",rp->lhsalias); */ printf(" ::="); for(i=0; i<rp->nrhs; i++){ printf(" %s",rp->rhs[i]->name); /* if( rp->rhsalias[i] ) printf("(%s)",rp->rhsalias[i]); */ } printf("."); if( rp->precsym ) printf(" [%s]",rp->precsym->name); /* if( rp->code ) printf("\n %s",rp->code); */ printf("\n"); } } void ConfigPrint(fp,cfp) FILE *fp; struct config *cfp; { struct rule *rp; int i; rp = cfp->rp; fprintf(fp,"%s ::=",rp->lhs->name); for(i=0; i<=rp->nrhs; i++){ if( i==cfp->dot ) fprintf(fp," *"); if( i==rp->nrhs ) break; fprintf(fp," %s",rp->rhs[i]->name); } } /* #define TEST */ #ifdef TEST /* Print a set */ PRIVATE void SetPrint(out,set,lemp) FILE *out; char *set; struct lemon *lemp; { int i; char *spacer; spacer = ""; fprintf(out,"%12s[",""); for(i=0; i<lemp->nterminal; i++){ if( SetFind(set,i) ){ fprintf(out,"%s%s",spacer,lemp->symbols[i]->name); spacer = " "; } } fprintf(out,"]\n"); } /* Print a plink chain */ PRIVATE void PlinkPrint(out,plp,tag) FILE *out; struct plink *plp; char *tag; { while( plp ){ fprintf(out,"%12s%s (state %2d) ","",tag,plp->cfp->stp->index); ConfigPrint(out,plp->cfp); fprintf(out,"\n"); plp = plp->next; } } #endif /* Print an action to the given file descriptor. Return FALSE if ** nothing was actually printed. */ int PrintAction(struct action *ap, FILE *fp, int indent){ int result = 1; switch( ap->type ){ case SHIFT: fprintf(fp,"%*s shift %d",indent,ap->sp->name,ap->x.stp->index); break; case REDUCE: fprintf(fp,"%*s reduce %d",indent,ap->sp->name,ap->x.rp->index); break; case ACCEPT: fprintf(fp,"%*s accept",indent,ap->sp->name); break; case ERROR: fprintf(fp,"%*s error",indent,ap->sp->name); break; case CONFLICT: fprintf(fp,"%*s reduce %-3d ** Parsing conflict **", indent,ap->sp->name,ap->x.rp->index); break; case SH_RESOLVED: case RD_RESOLVED: case NOT_USED: result = 0; break; } return result; } /* Generate the "y.output" log file */ void ReportOutput(lemp) struct lemon *lemp; { int i; struct state *stp; struct config *cfp; struct action *ap; FILE *fp; fp = file_open(lemp,".out","wb"); if( fp==0 ) return; fprintf(fp," \b"); for(i=0; i<lemp->nstate; i++){ stp = lemp->sorted[i]; fprintf(fp,"State %d:\n",stp->index); if( lemp->basisflag ) cfp=stp->bp; else cfp=stp->cfp; while( cfp ){ char buf[20]; if( cfp->dot==cfp->rp->nrhs ){ sprintf(buf,"(%d)",cfp->rp->index); fprintf(fp," %5s ",buf); }else{ fprintf(fp," "); } ConfigPrint(fp,cfp); fprintf(fp,"\n"); #ifdef TEST SetPrint(fp,cfp->fws,lemp); PlinkPrint(fp,cfp->fplp,"To "); PlinkPrint(fp,cfp->bplp,"From"); #endif if( lemp->basisflag ) cfp=cfp->bp; else cfp=cfp->next; } fprintf(fp,"\n"); for(ap=stp->ap; ap; ap=ap->next){ if( PrintAction(ap,fp,30) ) fprintf(fp,"\n"); } fprintf(fp,"\n"); } fclose(fp); return; } /* Search for the file "name" which is in the same directory as ** the exacutable */ PRIVATE char *pathsearch(argv0,name,modemask) char *argv0; char *name; int modemask; { char *pathlist; char *path,*cp; char c; extern int access(); #ifdef __WIN32__ cp = strrchr(argv0,'\\'); #else cp = strrchr(argv0,'/'); #endif if( cp ){ c = *cp; *cp = 0; path = (char *)malloc( strlen(argv0) + strlen(name) + 2 ); if( path ) sprintf(path,"%s/%s",argv0,name); *cp = c; }else{ extern char *getenv(); pathlist = getenv("PATH"); if( pathlist==0 ) pathlist = ".:/bin:/usr/bin"; path = (char *)malloc( strlen(pathlist)+strlen(name)+2 ); if( path!=0 ){ while( *pathlist ){ cp = strchr(pathlist,':'); if( cp==0 ) cp = &pathlist[strlen(pathlist)]; c = *cp; *cp = 0; sprintf(path,"%s/%s",pathlist,name); *cp = c; if( c==0 ) pathlist = ""; else pathlist = &cp[1]; if( access(path,modemask)==0 ) break; } } } return path; } /* Given an action, compute the integer value for that action ** which is to be put in the action table of the generated machine. ** Return negative if no action should be generated. */ PRIVATE int compute_action(lemp,ap) struct lemon *lemp; struct action *ap; { int act; switch( ap->type ){ case SHIFT: act = ap->x.stp->index; break; case REDUCE: act = ap->x.rp->index + lemp->nstate; break; case ERROR: act = lemp->nstate + lemp->nrule; break; case ACCEPT: act = lemp->nstate + lemp->nrule + 1; break; default: act = -1; break; } return act; } #define LINESIZE 1000 /* The next cluster of routines are for reading the template file ** and writing the results to the generated parser */ /* The first function transfers data from "in" to "out" until ** a line is seen which begins with "%%". The line number is ** tracked. ** ** if name!=0, then any word that begin with "Parse" is changed to ** begin with *name instead. */ PRIVATE void tplt_xfer(name,in,out,lineno) char *name; FILE *in; FILE *out; int *lineno; { int i, iStart; char line[LINESIZE]; while( fgets(line,LINESIZE,in) && (line[0]!='%' || line[1]!='%') ){ (*lineno)++; iStart = 0; if( name ){ for(i=0; line[i]; i++){ if( line[i]=='P' && strncmp(&line[i],"Parse",5)==0 && (i==0 || !isalpha(line[i-1])) ){ if( i>iStart ) fprintf(out,"%.*s",i-iStart,&line[iStart]); fprintf(out,"%s",name); i += 4; iStart = i+1; } } } fprintf(out,"%s",&line[iStart]); } } /* The next function finds the template file and opens it, returning ** a pointer to the opened file. */ PRIVATE FILE *tplt_open(lemp) struct lemon *lemp; { static char templatename[] = "lempar.c"; char buf[1000]; FILE *in; char *tpltname; char *cp; cp = strrchr(lemp->filename,'.'); if( cp ){ sprintf(buf,"%.*s.lt",(int)(cp-lemp->filename),lemp->filename); }else{ sprintf(buf,"%s.lt",lemp->filename); } if( access(buf,004)==0 ){ tpltname = buf; }else if( access(templatename,004)==0 ){ tpltname = templatename; }else{ tpltname = pathsearch(lemp->argv0,templatename,0); } if( tpltname==0 ){ fprintf(stderr,"Can't find the parser driver template file \"%s\".\n", templatename); lemp->errorcnt++; return 0; } in = fopen(tpltname,"rb"); if( in==0 ){ fprintf(stderr,"Can't open the template file \"%s\".\n",templatename); lemp->errorcnt++; return 0; } return in; } /* Print a #line directive line to the output file. */ PRIVATE void tplt_linedir(out,lineno,filename) FILE *out; int lineno; char *filename; { fprintf(out,"#line %d \"",lineno); while( *filename ){ if( *filename == '\\' ) putc('\\',out); putc(*filename,out); filename++; } fprintf(out,"\"\n"); } /* Print a string to the file and keep the linenumber up to date */ PRIVATE void tplt_print(out,lemp,str,strln,lineno) FILE *out; struct lemon *lemp; char *str; int strln; int *lineno; { if( str==0 ) return; tplt_linedir(out,strln,lemp->filename); (*lineno)++; while( *str ){ if( *str=='\n' ) (*lineno)++; putc(*str,out); str++; } if( str[-1]!='\n' ){ putc('\n',out); (*lineno)++; } tplt_linedir(out,*lineno+2,lemp->outname); (*lineno)+=2; return; } /* ** The following routine emits code for the destructor for the ** symbol sp */ void emit_destructor_code(out,sp,lemp,lineno) FILE *out; struct symbol *sp; struct lemon *lemp; int *lineno; { char *cp = 0; int linecnt = 0; if( sp->type==TERMINAL ){ cp = lemp->tokendest; if( cp==0 ) return; tplt_linedir(out,lemp->tokendestln,lemp->filename); fprintf(out,"{"); }else if( sp->destructor ){ cp = sp->destructor; tplt_linedir(out,sp->destructorln,lemp->filename); fprintf(out,"{"); }else if( lemp->vardest ){ cp = lemp->vardest; if( cp==0 ) return; tplt_linedir(out,lemp->vardestln,lemp->filename); fprintf(out,"{"); }else{ assert( 0 ); /* Cannot happen */ } for(; *cp; cp++){ if( *cp=='$' && cp[1]=='$' ){ fprintf(out,"(yypminor->yy%d)",sp->dtnum); cp++; continue; } if( *cp=='\n' ) linecnt++; fputc(*cp,out); } (*lineno) += 3 + linecnt; fprintf(out,"}\n"); tplt_linedir(out,*lineno,lemp->outname); return; } /* ** Return TRUE (non-zero) if the given symbol has a destructor. */ int has_destructor(sp, lemp) struct symbol *sp; struct lemon *lemp; { int ret; if( sp->type==TERMINAL ){ ret = lemp->tokendest!=0; }else{ ret = lemp->vardest!=0 || sp->destructor!=0; } return ret; } /* ** Append text to a dynamically allocated string. If zText is 0 then ** reset the string to be empty again. Always return the complete text ** of the string (which is overwritten with each call). ** ** n bytes of zText are stored. If n==0 then all of zText up to the first ** \000 terminator is stored. zText can contain up to two instances of ** %d. The values of p1 and p2 are written into the first and second ** %d. ** ** If n==-1, then the previous character is overwritten. */ PRIVATE char *append_str(char *zText, int n, int p1, int p2){ static char *z = 0; static int alloced = 0; static int used = 0; int c; char zInt[40]; if( zText==0 ){ used = 0; return z; } if( n<=0 ){ if( n<0 ){ used += n; assert( used>=0 ); } n = strlen(zText); } if( n+sizeof(zInt)*2+used >= alloced ){ alloced = n + sizeof(zInt)*2 + used + 200; z = realloc(z, alloced); } if( z==0 ) return ""; while( n-- > 0 ){ c = *(zText++); if( c=='%' && zText[0]=='d' ){ sprintf(zInt, "%d", p1); p1 = p2; strcpy(&z[used], zInt); used += strlen(&z[used]); zText++; n--; }else{ z[used++] = c; } } z[used] = 0; return z; } /* ** zCode is a string that is the action associated with a rule. Expand ** the symbols in this string so that the refer to elements of the parser ** stack. */ PRIVATE void translate_code(struct lemon *lemp, struct rule *rp){ char *cp, *xp; int i; char lhsused = 0; /* True if the LHS element has been used */ char used[MAXRHS]; /* True for each RHS element which is used */ for(i=0; i<rp->nrhs; i++) used[i] = 0; lhsused = 0; append_str(0,0,0,0); for(cp=rp->code; *cp; cp++){ if( isalpha(*cp) && (cp==rp->code || (!isalnum(cp[-1]) && cp[-1]!='_')) ){ char saved; for(xp= &cp[1]; isalnum(*xp) || *xp=='_'; xp++); saved = *xp; *xp = 0; if( rp->lhsalias && strcmp(cp,rp->lhsalias)==0 ){ append_str("yygotominor.yy%d",0,rp->lhs->dtnum,0); cp = xp; lhsused = 1; }else{ for(i=0; i<rp->nrhs; i++){ if( rp->rhsalias[i] && strcmp(cp,rp->rhsalias[i])==0 ){ if( cp!=rp->code && cp[-1]=='@' ){ /* If the argument is of the form @X then substituted ** the token number of X, not the value of X */ append_str("yymsp[%d].major",-1,i-rp->nrhs+1,0); }else{ append_str("yymsp[%d].minor.yy%d",0, i-rp->nrhs+1,rp->rhs[i]->dtnum); } cp = xp; used[i] = 1; break; } } } *xp = saved; } append_str(cp, 1, 0, 0); } /* End loop */ /* Check to make sure the LHS has been used */ if( rp->lhsalias && !lhsused ){ ErrorMsg(lemp->filename,rp->ruleline, "Label \"%s\" for \"%s(%s)\" is never used.", rp->lhsalias,rp->lhs->name,rp->lhsalias); lemp->errorcnt++; } /* Generate destructor code for RHS symbols which are not used in the ** reduce code */ for(i=0; i<rp->nrhs; i++){ if( rp->rhsalias[i] && !used[i] ){ ErrorMsg(lemp->filename,rp->ruleline, "Label %s for \"%s(%s)\" is never used.", rp->rhsalias[i],rp->rhs[i]->name,rp->rhsalias[i]); lemp->errorcnt++; }else if( rp->rhsalias[i]==0 ){ if( has_destructor(rp->rhs[i],lemp) ){ append_str(" yy_destructor(%d,&yymsp[%d].minor);\n", 0, rp->rhs[i]->index,i-rp->nrhs+1); }else{ /* No destructor defined for this term */ } } } cp = append_str(0,0,0,0); rp->code = Strsafe(cp); } /* ** Generate code which executes when the rule "rp" is reduced. Write ** the code to "out". Make sure lineno stays up-to-date. */ PRIVATE void emit_code(out,rp,lemp,lineno) FILE *out; struct rule *rp; struct lemon *lemp; int *lineno; { char *cp; int linecnt = 0; /* Generate code to do the reduce action */ if( rp->code ){ tplt_linedir(out,rp->line,lemp->filename); fprintf(out,"{%s",rp->code); for(cp=rp->code; *cp; cp++){ if( *cp=='\n' ) linecnt++; } /* End loop */ (*lineno) += 3 + linecnt; fprintf(out,"}\n"); tplt_linedir(out,*lineno,lemp->outname); } /* End if( rp->code ) */ return; } /* ** Print the definition of the union used for the parser's data stack. ** This union contains fields for every possible data type for tokens ** and nonterminals. In the process of computing and printing this ** union, also set the ".dtnum" field of every terminal and nonterminal ** symbol. */ void print_stack_union(out,lemp,plineno,mhflag) FILE *out; /* The output stream */ struct lemon *lemp; /* The main info structure for this parser */ int *plineno; /* Pointer to the line number */ int mhflag; /* True if generating makeheaders output */ { int lineno = *plineno; /* The line number of the output */ char **types; /* A hash table of datatypes */ int arraysize; /* Size of the "types" array */ int maxdtlength; /* Maximum length of any ".datatype" field. */ char *stddt; /* Standardized name for a datatype */ int i,j; /* Loop counters */ int hash; /* For hashing the name of a type */ char *name; /* Name of the parser */ /* Allocate and initialize types[] and allocate stddt[] */ arraysize = lemp->nsymbol * 2; types = (char**)malloc( arraysize * sizeof(char*) ); for(i=0; i<arraysize; i++) types[i] = 0; maxdtlength = 0; if( lemp->vartype ){ maxdtlength = strlen(lemp->vartype); } for(i=0; i<lemp->nsymbol; i++){ int len; struct symbol *sp = lemp->symbols[i]; if( sp->datatype==0 ) continue; len = strlen(sp->datatype); if( len>maxdtlength ) maxdtlength = len; } stddt = (char*)malloc( maxdtlength*2 + 1 ); if( types==0 || stddt==0 ){ fprintf(stderr,"Out of memory.\n"); exit(1); } /* Build a hash table of datatypes. The ".dtnum" field of each symbol ** is filled in with the hash index plus 1. A ".dtnum" value of 0 is ** used for terminal symbols. If there is no %default_type defined then ** 0 is also used as the .dtnum value for nonterminals which do not specify ** a datatype using the %type directive. */ for(i=0; i<lemp->nsymbol; i++){ struct symbol *sp = lemp->symbols[i]; char *cp; if( sp==lemp->errsym ){ sp->dtnum = arraysize+1; continue; } if( sp->type!=NONTERMINAL || (sp->datatype==0 && lemp->vartype==0) ){ sp->dtnum = 0; continue; } cp = sp->datatype; if( cp==0 ) cp = lemp->vartype; j = 0; while( isspace(*cp) ) cp++; while( *cp ) stddt[j++] = *cp++; while( j>0 && isspace(stddt[j-1]) ) j--; stddt[j] = 0; hash = 0; for(j=0; stddt[j]; j++){ hash = hash*53 + stddt[j]; } hash = (hash & 0x7fffffff)%arraysize; while( types[hash] ){ if( strcmp(types[hash],stddt)==0 ){ sp->dtnum = hash + 1; break; } hash++; if( hash>=arraysize ) hash = 0; } if( types[hash]==0 ){ sp->dtnum = hash + 1; types[hash] = (char*)malloc( strlen(stddt)+1 ); if( types[hash]==0 ){ fprintf(stderr,"Out of memory.\n"); exit(1); } strcpy(types[hash],stddt); } } /* Print out the definition of YYTOKENTYPE and YYMINORTYPE */ name = lemp->name ? lemp->name : "Parse"; lineno = *plineno; if( mhflag ){ fprintf(out,"#if INTERFACE\n"); lineno++; } fprintf(out,"#define %sTOKENTYPE %s\n",name, lemp->tokentype?lemp->tokentype:"void*"); lineno++; if( mhflag ){ fprintf(out,"#endif\n"); lineno++; } fprintf(out,"typedef union {\n"); lineno++; fprintf(out," %sTOKENTYPE yy0;\n",name); lineno++; for(i=0; i<arraysize; i++){ if( types[i]==0 ) continue; fprintf(out," %s yy%d;\n",types[i],i+1); lineno++; free(types[i]); } fprintf(out," int yy%d;\n",lemp->errsym->dtnum); lineno++; free(stddt); free(types); fprintf(out,"} YYMINORTYPE;\n"); lineno++; *plineno = lineno; } /* ** Return the name of a C datatype able to represent values between ** lwr and upr, inclusive. */ static const char *minimum_size_type(int lwr, int upr){ if( lwr>=0 ){ if( upr<=255 ){ return "unsigned char"; }else if( upr<65535 ){ return "unsigned short int"; }else{ return "unsigned int"; } }else if( lwr>=-127 && upr<=127 ){ return "signed char"; }else if( lwr>=-32767 && upr<32767 ){ return "short"; }else{ return "int"; } } /* ** Each state contains a set of token transaction and a set of ** nonterminal transactions. Each of these sets makes an instance ** of the following structure. An array of these structures is used ** to order the creation of entries in the yy_action[] table. */ struct axset { struct state *stp; /* A pointer to a state */ int isTkn; /* True to use tokens. False for non-terminals */ int nAction; /* Number of actions */ }; /* ** Compare to axset structures for sorting purposes */ static int axset_compare(const void *a, const void *b){ struct axset *p1 = (struct axset*)a; struct axset *p2 = (struct axset*)b; return p2->nAction - p1->nAction; } /* Generate C source code for the parser */ void ReportTable(lemp, mhflag) struct lemon *lemp; int mhflag; /* Output in makeheaders format if true */ { FILE *out, *in; char line[LINESIZE]; int lineno; struct state *stp; struct action *ap; struct rule *rp; struct acttab *pActtab; int i, j, n; char *name; int mnTknOfst, mxTknOfst; int mnNtOfst, mxNtOfst; struct axset *ax; in = tplt_open(lemp); if( in==0 ) return; out = file_open(lemp,".c","wb"); if( out==0 ){ fclose(in); return; } lineno = 1; tplt_xfer(lemp->name,in,out,&lineno); /* Generate the include code, if any */ tplt_print(out,lemp,lemp->include,lemp->includeln,&lineno); if( mhflag ){ char *name = file_makename(lemp, ".h"); fprintf(out,"#include \"%s\"\n", name); lineno++; free(name); } tplt_xfer(lemp->name,in,out,&lineno); /* Generate #defines for all tokens */ if( mhflag ){ char *prefix; fprintf(out,"#if INTERFACE\n"); lineno++; if( lemp->tokenprefix ) prefix = lemp->tokenprefix; else prefix = ""; for(i=1; i<lemp->nterminal; i++){ fprintf(out,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i); lineno++; } fprintf(out,"#endif\n"); lineno++; } tplt_xfer(lemp->name,in,out,&lineno); /* Generate the defines */ fprintf(out,"#define YYCODETYPE %s\n", minimum_size_type(0, lemp->nsymbol+5)); lineno++; fprintf(out,"#define YYNOCODE %d\n",lemp->nsymbol+1); lineno++; fprintf(out,"#define YYACTIONTYPE %s\n", minimum_size_type(0, lemp->nstate+lemp->nrule+5)); lineno++; print_stack_union(out,lemp,&lineno,mhflag); if( lemp->stacksize ){ if( atoi(lemp->stacksize)<=0 ){ ErrorMsg(lemp->filename,0, "Illegal stack size: [%s]. The stack size should be an integer constant.", lemp->stacksize); lemp->errorcnt++; lemp->stacksize = "100"; } fprintf(out,"#define YYSTACKDEPTH %s\n",lemp->stacksize); lineno++; }else{ fprintf(out,"#define YYSTACKDEPTH 100\n"); lineno++; } if( mhflag ){ fprintf(out,"#if INTERFACE\n"); lineno++; } name = lemp->name ? lemp->name : "Parse"; if( lemp->arg && lemp->arg[0] ){ int i; i = strlen(lemp->arg); while( i>=1 && isspace(lemp->arg[i-1]) ) i--; while( i>=1 && (isalnum(lemp->arg[i-1]) || lemp->arg[i-1]=='_') ) i--; fprintf(out,"#define %sARG_SDECL %s;\n",name,lemp->arg); lineno++; fprintf(out,"#define %sARG_PDECL ,%s\n",name,lemp->arg); lineno++; fprintf(out,"#define %sARG_FETCH %s = yypParser->%s\n", name,lemp->arg,&lemp->arg[i]); lineno++; fprintf(out,"#define %sARG_STORE yypParser->%s = %s\n", name,&lemp->arg[i],&lemp->arg[i]); lineno++; }else{ fprintf(out,"#define %sARG_SDECL\n",name); lineno++; fprintf(out,"#define %sARG_PDECL\n",name); lineno++; fprintf(out,"#define %sARG_FETCH\n",name); lineno++; fprintf(out,"#define %sARG_STORE\n",name); lineno++; } if( mhflag ){ fprintf(out,"#endif\n"); lineno++; } fprintf(out,"#define YYNSTATE %d\n",lemp->nstate); lineno++; fprintf(out,"#define YYNRULE %d\n",lemp->nrule); lineno++; fprintf(out,"#define YYERRORSYMBOL %d\n",lemp->errsym->index); lineno++; fprintf(out,"#define YYERRSYMDT yy%d\n",lemp->errsym->dtnum); lineno++; if( lemp->has_fallback ){ fprintf(out,"#define YYFALLBACK 1\n"); lineno++; } tplt_xfer(lemp->name,in,out,&lineno); /* Generate the action table and its associates: ** ** yy_action[] A single table containing all actions. ** yy_lookahead[] A table containing the lookahead for each entry in ** yy_action. Used to detect hash collisions. ** yy_shift_ofst[] For each state, the offset into yy_action for ** shifting terminals. ** yy_reduce_ofst[] For each state, the offset into yy_action for ** shifting non-terminals after a reduce. ** yy_default[] Default action for each state. */ /* Compute the actions on all states and count them up */ ax = malloc( sizeof(ax[0])*lemp->nstate*2 ); if( ax==0 ){ fprintf(stderr,"malloc failed\n"); exit(1); } for(i=0; i<lemp->nstate; i++){ stp = lemp->sorted[i]; stp->nTknAct = stp->nNtAct = 0; stp->iDflt = lemp->nstate + lemp->nrule; stp->iTknOfst = NO_OFFSET; stp->iNtOfst = NO_OFFSET; for(ap=stp->ap; ap; ap=ap->next){ if( compute_action(lemp,ap)>=0 ){ if( ap->sp->index<lemp->nterminal ){ stp->nTknAct++; }else if( ap->sp->index<lemp->nsymbol ){ stp->nNtAct++; }else{ stp->iDflt = compute_action(lemp, ap); } } } ax[i*2].stp = stp; ax[i*2].isTkn = 1; ax[i*2].nAction = stp->nTknAct; ax[i*2+1].stp = stp; ax[i*2+1].isTkn = 0; ax[i*2+1].nAction = stp->nNtAct; } mxTknOfst = mnTknOfst = 0; mxNtOfst = mnNtOfst = 0; /* Compute the action table. In order to try to keep the size of the ** action table to a minimum, the heuristic of placing the largest action ** sets first is used. */ qsort(ax, lemp->nstate*2, sizeof(ax[0]), axset_compare); pActtab = acttab_alloc(); for(i=0; i<lemp->nstate*2 && ax[i].nAction>0; i++){ stp = ax[i].stp; if( ax[i].isTkn ){ for(ap=stp->ap; ap; ap=ap->next){ int action; if( ap->sp->index>=lemp->nterminal ) continue; action = compute_action(lemp, ap); if( action<0 ) continue; acttab_action(pActtab, ap->sp->index, action); } stp->iTknOfst = acttab_insert(pActtab); if( stp->iTknOfst<mnTknOfst ) mnTknOfst = stp->iTknOfst; if( stp->iTknOfst>mxTknOfst ) mxTknOfst = stp->iTknOfst; }else{ for(ap=stp->ap; ap; ap=ap->next){ int action; if( ap->sp->index<lemp->nterminal ) continue; if( ap->sp->index==lemp->nsymbol ) continue; action = compute_action(lemp, ap); if( action<0 ) continue; acttab_action(pActtab, ap->sp->index, action); } stp->iNtOfst = acttab_insert(pActtab); if( stp->iNtOfst<mnNtOfst ) mnNtOfst = stp->iNtOfst; if( stp->iNtOfst>mxNtOfst ) mxNtOfst = stp->iNtOfst; } } free(ax); /* Output the yy_action table */ fprintf(out,"static const YYACTIONTYPE yy_action[] = {\n"); lineno++; n = acttab_size(pActtab); for(i=j=0; i<n; i++){ int action = acttab_yyaction(pActtab, i); if( action<0 ) action = lemp->nsymbol + lemp->nrule + 2; if( j==0 ) fprintf(out," /* %5d */ ", i); fprintf(out, " %4d,", action); if( j==9 || i==n-1 ){ fprintf(out, "\n"); lineno++; j = 0; }else{ j++; } } fprintf(out, "};\n"); lineno++; /* Output the yy_lookahead table */ fprintf(out,"static const YYCODETYPE yy_lookahead[] = {\n"); lineno++; for(i=j=0; i<n; i++){ int la = acttab_yylookahead(pActtab, i); if( la<0 ) la = lemp->nsymbol; if( j==0 ) fprintf(out," /* %5d */ ", i); fprintf(out, " %4d,", la); if( j==9 || i==n-1 ){ fprintf(out, "\n"); lineno++; j = 0; }else{ j++; } } fprintf(out, "};\n"); lineno++; /* Output the yy_shift_ofst[] table */ fprintf(out, "#define YY_SHIFT_USE_DFLT (%d)\n", mnTknOfst-1); lineno++; fprintf(out, "static const %s yy_shift_ofst[] = {\n", minimum_size_type(mnTknOfst-1, mxTknOfst)); lineno++; n = lemp->nstate; for(i=j=0; i<n; i++){ int ofst; stp = lemp->sorted[i]; ofst = stp->iTknOfst; if( ofst==NO_OFFSET ) ofst = mnTknOfst - 1; if( j==0 ) fprintf(out," /* %5d */ ", i); fprintf(out, " %4d,", ofst); if( j==9 || i==n-1 ){ fprintf(out, "\n"); lineno++; j = 0; }else{ j++; } } fprintf(out, "};\n"); lineno++; /* Output the yy_reduce_ofst[] table */ fprintf(out, "#define YY_REDUCE_USE_DFLT (%d)\n", mnNtOfst-1); lineno++; fprintf(out, "static const %s yy_reduce_ofst[] = {\n", minimum_size_type(mnNtOfst-1, mxNtOfst)); lineno++; n = lemp->nstate; for(i=j=0; i<n; i++){ int ofst; stp = lemp->sorted[i]; ofst = stp->iNtOfst; if( ofst==NO_OFFSET ) ofst = mnNtOfst - 1; if( j==0 ) fprintf(out," /* %5d */ ", i); fprintf(out, " %4d,", ofst); if( j==9 || i==n-1 ){ fprintf(out, "\n"); lineno++; j = 0; }else{ j++; } } fprintf(out, "};\n"); lineno++; /* Output the default action table */ fprintf(out, "static const YYACTIONTYPE yy_default[] = {\n"); lineno++; n = lemp->nstate; for(i=j=0; i<n; i++){ stp = lemp->sorted[i]; if( j==0 ) fprintf(out," /* %5d */ ", i); fprintf(out, " %4d,", stp->iDflt); if( j==9 || i==n-1 ){ fprintf(out, "\n"); lineno++; j = 0; }else{ j++; } } fprintf(out, "};\n"); lineno++; tplt_xfer(lemp->name,in,out,&lineno); /* Generate the table of fallback tokens. */ if( lemp->has_fallback ){ for(i=0; i<lemp->nterminal; i++){ struct symbol *p = lemp->symbols[i]; if( p->fallback==0 ){ fprintf(out, " 0, /* %10s => nothing */\n", p->name); }else{ fprintf(out, " %3d, /* %10s => %s */\n", p->fallback->index, p->name, p->fallback->name); } lineno++; } } tplt_xfer(lemp->name, in, out, &lineno); /* Generate a table containing the symbolic name of every symbol */ for(i=0; i<lemp->nsymbol; i++){ sprintf(line,"\"%s\",",lemp->symbols[i]->name); fprintf(out," %-15s",line); if( (i&3)==3 ){ fprintf(out,"\n"); lineno++; } } if( (i&3)!=0 ){ fprintf(out,"\n"); lineno++; } tplt_xfer(lemp->name,in,out,&lineno); /* Generate a table containing a text string that describes every ** rule in the rule set of the grammer. This information is used ** when tracing REDUCE actions. */ for(i=0, rp=lemp->rule; rp; rp=rp->next, i++){ assert( rp->index==i ); fprintf(out," /* %3d */ \"%s ::=", i, rp->lhs->name); for(j=0; j<rp->nrhs; j++) fprintf(out," %s",rp->rhs[j]->name); fprintf(out,"\",\n"); lineno++; } tplt_xfer(lemp->name,in,out,&lineno); /* Generate code which executes every time a symbol is popped from ** the stack while processing errors or while destroying the parser. ** (In other words, generate the %destructor actions) */ if( lemp->tokendest ){ for(i=0; i<lemp->nsymbol; i++){ struct symbol *sp = lemp->symbols[i]; if( sp==0 || sp->type!=TERMINAL ) continue; fprintf(out," case %d:\n",sp->index); lineno++; } for(i=0; i<lemp->nsymbol && lemp->symbols[i]->type!=TERMINAL; i++); if( i<lemp->nsymbol ){ emit_destructor_code(out,lemp->symbols[i],lemp,&lineno); fprintf(out," break;\n"); lineno++; } } for(i=0; i<lemp->nsymbol; i++){ struct symbol *sp = lemp->symbols[i]; if( sp==0 || sp->type==TERMINAL || sp->destructor==0 ) continue; fprintf(out," case %d:\n",sp->index); lineno++; /* Combine duplicate destructors into a single case */ for(j=i+1; j<lemp->nsymbol; j++){ struct symbol *sp2 = lemp->symbols[j]; if( sp2 && sp2->type!=TERMINAL && sp2->destructor && sp2->dtnum==sp->dtnum && strcmp(sp->destructor,sp2->destructor)==0 ){ fprintf(out," case %d:\n",sp2->index); lineno++; sp2->destructor = 0; } } emit_destructor_code(out,lemp->symbols[i],lemp,&lineno); fprintf(out," break;\n"); lineno++; } if( lemp->vardest ){ struct symbol *dflt_sp = 0; for(i=0; i<lemp->nsymbol; i++){ struct symbol *sp = lemp->symbols[i]; if( sp==0 || sp->type==TERMINAL || sp->index<=0 || sp->destructor!=0 ) continue; fprintf(out," case %d:\n",sp->index); lineno++; dflt_sp = sp; } if( dflt_sp!=0 ){ emit_destructor_code(out,dflt_sp,lemp,&lineno); fprintf(out," break;\n"); lineno++; } } tplt_xfer(lemp->name,in,out,&lineno); /* Generate code which executes whenever the parser stack overflows */ tplt_print(out,lemp,lemp->overflow,lemp->overflowln,&lineno); tplt_xfer(lemp->name,in,out,&lineno); /* Generate the table of rule information ** ** Note: This code depends on the fact that rules are number ** sequentually beginning with 0. */ for(rp=lemp->rule; rp; rp=rp->next){ fprintf(out," { %d, %d },\n",rp->lhs->index,rp->nrhs); lineno++; } tplt_xfer(lemp->name,in,out,&lineno); /* Generate code which execution during each REDUCE action */ for(rp=lemp->rule; rp; rp=rp->next){ if( rp->code ) translate_code(lemp, rp); } for(rp=lemp->rule; rp; rp=rp->next){ struct rule *rp2; if( rp->code==0 ) continue; fprintf(out," case %d:\n",rp->index); lineno++; for(rp2=rp->next; rp2; rp2=rp2->next){ if( rp2->code==rp->code ){ fprintf(out," case %d:\n",rp2->index); lineno++; rp2->code = 0; } } emit_code(out,rp,lemp,&lineno); fprintf(out," break;\n"); lineno++; } tplt_xfer(lemp->name,in,out,&lineno); /* Generate code which executes if a parse fails */ tplt_print(out,lemp,lemp->failure,lemp->failureln,&lineno); tplt_xfer(lemp->name,in,out,&lineno); /* Generate code which executes when a syntax error occurs */ tplt_print(out,lemp,lemp->error,lemp->errorln,&lineno); tplt_xfer(lemp->name,in,out,&lineno); /* Generate code which executes when the parser accepts its input */ tplt_print(out,lemp,lemp->accept,lemp->acceptln,&lineno); tplt_xfer(lemp->name,in,out,&lineno); /* Append any addition code the user desires */ tplt_print(out,lemp,lemp->extracode,lemp->extracodeln,&lineno); fclose(in); fclose(out); return; } /* Generate a header file for the parser */ void ReportHeader(lemp) struct lemon *lemp; { FILE *out, *in; char *prefix; char line[LINESIZE]; char pattern[LINESIZE]; int i; if( lemp->tokenprefix ) prefix = lemp->tokenprefix; else prefix = ""; in = file_open(lemp,".h","rb"); if( in ){ for(i=1; i<lemp->nterminal && fgets(line,LINESIZE,in); i++){ sprintf(pattern,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i); if( strcmp(line,pattern) ) break; } fclose(in); if( i==lemp->nterminal ){ /* No change in the file. Don't rewrite it. */ return; } } out = file_open(lemp,".h","wb"); if( out ){ for(i=1; i<lemp->nterminal; i++){ fprintf(out,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i); } fclose(out); } return; } /* Reduce the size of the action tables, if possible, by making use ** of defaults. ** ** In this version, we take the most frequent REDUCE action and make ** it the default. Only default a reduce if there are more than one. */ void CompressTables(lemp) struct lemon *lemp; { struct state *stp; struct action *ap, *ap2; struct rule *rp, *rp2, *rbest; int nbest, n; int i; for(i=0; i<lemp->nstate; i++){ stp = lemp->sorted[i]; nbest = 0; rbest = 0; for(ap=stp->ap; ap; ap=ap->next){ if( ap->type!=REDUCE ) continue; rp = ap->x.rp; if( rp==rbest ) continue; n = 1; for(ap2=ap->next; ap2; ap2=ap2->next){ if( ap2->type!=REDUCE ) continue; rp2 = ap2->x.rp; if( rp2==rbest ) continue; if( rp2==rp ) n++; } if( n>nbest ){ nbest = n; rbest = rp; } } /* Do not make a default if the number of rules to default ** is not at least 2 */ if( nbest<2 ) continue; /* Combine matching REDUCE actions into a single default */ for(ap=stp->ap; ap; ap=ap->next){ if( ap->type==REDUCE && ap->x.rp==rbest ) break; } assert( ap ); ap->sp = Symbol_new("{default}"); for(ap=ap->next; ap; ap=ap->next){ if( ap->type==REDUCE && ap->x.rp==rbest ) ap->type = NOT_USED; } stp->ap = Action_sort(stp->ap); } } /***************** From the file "set.c" ************************************/ /* ** Set manipulation routines for the LEMON parser generator. */ static int size = 0; /* Set the set size */ void SetSize(n) int n; { size = n+1; } /* Allocate a new set */ char *SetNew(){ char *s; int i; s = (char*)malloc( size ); if( s==0 ){ extern void memory_error(); memory_error(); } for(i=0; i<size; i++) s[i] = 0; return s; } /* Deallocate a set */ void SetFree(s) char *s; { free(s); } /* Add a new element to the set. Return TRUE if the element was added ** and FALSE if it was already there. */ int SetAdd(s,e) char *s; int e; { int rv; rv = s[e]; s[e] = 1; return !rv; } /* Add every element of s2 to s1. Return TRUE if s1 changes. */ int SetUnion(s1,s2) char *s1; char *s2; { int i, progress; progress = 0; for(i=0; i<size; i++){ if( s2[i]==0 ) continue; if( s1[i]==0 ){ progress = 1; s1[i] = 1; } } return progress; } /********************** From the file "table.c" ****************************/ /* ** All code in this file has been automatically generated ** from a specification in the file ** "table.q" ** by the associative array code building program "aagen". ** Do not edit this file! Instead, edit the specification ** file, then rerun aagen. */ /* ** Code for processing tables in the LEMON parser generator. */ PRIVATE int strhash(x) char *x; { int h = 0; while( *x) h = h*13 + *(x++); return h; } /* Works like strdup, sort of. Save a string in malloced memory, but ** keep strings in a table so that the same string is not in more ** than one place. */ char *Strsafe(y) char *y; { char *z; z = Strsafe_find(y); if( z==0 && (z=malloc( strlen(y)+1 ))!=0 ){ strcpy(z,y); Strsafe_insert(z); } MemoryCheck(z); return z; } /* There is one instance of the following structure for each ** associative array of type "x1". */ struct s_x1 { int size; /* The number of available slots. */ /* Must be a power of 2 greater than or */ /* equal to 1 */ int count; /* Number of currently slots filled */ struct s_x1node *tbl; /* The data stored here */ struct s_x1node **ht; /* Hash table for lookups */ }; /* There is one instance of this structure for every data element ** in an associative array of type "x1". */ typedef struct s_x1node { char *data; /* The data */ struct s_x1node *next; /* Next entry with the same hash */ struct s_x1node **from; /* Previous link */ } x1node; /* There is only one instance of the array, which is the following */ static struct s_x1 *x1a; /* Allocate a new associative array */ void Strsafe_init(){ if( x1a ) return; x1a = (struct s_x1*)malloc( sizeof(struct s_x1) ); if( x1a ){ x1a->size = 1024; x1a->count = 0; x1a->tbl = (x1node*)malloc( (sizeof(x1node) + sizeof(x1node*))*1024 ); if( x1a->tbl==0 ){ free(x1a); x1a = 0; }else{ int i; x1a->ht = (x1node**)&(x1a->tbl[1024]); for(i=0; i<1024; i++) x1a->ht[i] = 0; } } } /* Insert a new record into the array. Return TRUE if successful. ** Prior data with the same key is NOT overwritten */ int Strsafe_insert(data) char *data; { x1node *np; int h; int ph; if( x1a==0 ) return 0; ph = strhash(data); h = ph & (x1a->size-1); np = x1a->ht[h]; while( np ){ if( strcmp(np->data,data)==0 ){ /* An existing entry with the same key is found. */ /* Fail because overwrite is not allows. */ return 0; } np = np->next; } if( x1a->count>=x1a->size ){ /* Need to make the hash table bigger */ int i,size; struct s_x1 array; array.size = size = x1a->size*2; array.count = x1a->count; array.tbl = (x1node*)malloc( (sizeof(x1node) + sizeof(x1node*))*size ); if( array.tbl==0 ) return 0; /* Fail due to malloc failure */ array.ht = (x1node**)&(array.tbl[size]); for(i=0; i<size; i++) array.ht[i] = 0; for(i=0; i<x1a->count; i++){ x1node *oldnp, *newnp; oldnp = &(x1a->tbl[i]); h = strhash(oldnp->data) & (size-1); newnp = &(array.tbl[i]); if( array.ht[h] ) array.ht[h]->from = &(newnp->next); newnp->next = array.ht[h]; newnp->data = oldnp->data; newnp->from = &(array.ht[h]); array.ht[h] = newnp; } free(x1a->tbl); *x1a = array; } /* Insert the new data */ h = ph & (x1a->size-1); np = &(x1a->tbl[x1a->count++]); np->data = data; if( x1a->ht[h] ) x1a->ht[h]->from = &(np->next); np->next = x1a->ht[h]; x1a->ht[h] = np; np->from = &(x1a->ht[h]); return 1; } /* Return a pointer to data assigned to the given key. Return NULL ** if no such key. */ char *Strsafe_find(key) char *key; { int h; x1node *np; if( x1a==0 ) return 0; h = strhash(key) & (x1a->size-1); np = x1a->ht[h]; while( np ){ if( strcmp(np->data,key)==0 ) break; np = np->next; } return np ? np->data : 0; } /* Return a pointer to the (terminal or nonterminal) symbol "x". ** Create a new symbol if this is the first time "x" has been seen. */ struct symbol *Symbol_new(x) char *x; { struct symbol *sp; sp = Symbol_find(x); if( sp==0 ){ sp = (struct symbol *)malloc( sizeof(struct symbol) ); MemoryCheck(sp); sp->name = Strsafe(x); sp->type = isupper(*x) ? TERMINAL : NONTERMINAL; sp->rule = 0; sp->fallback = 0; sp->prec = -1; sp->assoc = UNK; sp->firstset = 0; sp->lambda = B_FALSE; sp->destructor = 0; sp->datatype = 0; Symbol_insert(sp,sp->name); } return sp; } /* Compare two symbols for working purposes ** ** Symbols that begin with upper case letters (terminals or tokens) ** must sort before symbols that begin with lower case letters ** (non-terminals). Other than that, the order does not matter. ** ** We find experimentally that leaving the symbols in their original ** order (the order they appeared in the grammar file) gives the ** smallest parser tables in SQLite. */ int Symbolcmpp(struct symbol **a, struct symbol **b){ int i1 = (**a).index + 10000000*((**a).name[0]>'Z'); int i2 = (**b).index + 10000000*((**b).name[0]>'Z'); return i1-i2; } /* There is one instance of the following structure for each ** associative array of type "x2". */ struct s_x2 { int size; /* The number of available slots. */ /* Must be a power of 2 greater than or */ /* equal to 1 */ int count; /* Number of currently slots filled */ struct s_x2node *tbl; /* The data stored here */ struct s_x2node **ht; /* Hash table for lookups */ }; /* There is one instance of this structure for every data element ** in an associative array of type "x2". */ typedef struct s_x2node { struct symbol *data; /* The data */ char *key; /* The key */ struct s_x2node *next; /* Next entry with the same hash */ struct s_x2node **from; /* Previous link */ } x2node; /* There is only one instance of the array, which is the following */ static struct s_x2 *x2a; /* Allocate a new associative array */ void Symbol_init(){ if( x2a ) return; x2a = (struct s_x2*)malloc( sizeof(struct s_x2) ); if( x2a ){ x2a->size = 128; x2a->count = 0; x2a->tbl = (x2node*)malloc( (sizeof(x2node) + sizeof(x2node*))*128 ); if( x2a->tbl==0 ){ free(x2a); x2a = 0; }else{ int i; x2a->ht = (x2node**)&(x2a->tbl[128]); for(i=0; i<128; i++) x2a->ht[i] = 0; } } } /* Insert a new record into the array. Return TRUE if successful. ** Prior data with the same key is NOT overwritten */ int Symbol_insert(data,key) struct symbol *data; char *key; { x2node *np; int h; int ph; if( x2a==0 ) return 0; ph = strhash(key); h = ph & (x2a->size-1); np = x2a->ht[h]; while( np ){ if( strcmp(np->key,key)==0 ){ /* An existing entry with the same key is found. */ /* Fail because overwrite is not allows. */ return 0; } np = np->next; } if( x2a->count>=x2a->size ){ /* Need to make the hash table bigger */ int i,size; struct s_x2 array; array.size = size = x2a->size*2; array.count = x2a->count; array.tbl = (x2node*)malloc( (sizeof(x2node) + sizeof(x2node*))*size ); if( array.tbl==0 ) return 0; /* Fail due to malloc failure */ array.ht = (x2node**)&(array.tbl[size]); for(i=0; i<size; i++) array.ht[i] = 0; for(i=0; i<x2a->count; i++){ x2node *oldnp, *newnp; oldnp = &(x2a->tbl[i]); h = strhash(oldnp->key) & (size-1); newnp = &(array.tbl[i]); if( array.ht[h] ) array.ht[h]->from = &(newnp->next); newnp->next = array.ht[h]; newnp->key = oldnp->key; newnp->data = oldnp->data; newnp->from = &(array.ht[h]); array.ht[h] = newnp; } free(x2a->tbl); *x2a = array; } /* Insert the new data */ h = ph & (x2a->size-1); np = &(x2a->tbl[x2a->count++]); np->key = key; np->data = data; if( x2a->ht[h] ) x2a->ht[h]->from = &(np->next); np->next = x2a->ht[h]; x2a->ht[h] = np; np->from = &(x2a->ht[h]); return 1; } /* Return a pointer to data assigned to the given key. Return NULL ** if no such key. */ struct symbol *Symbol_find(key) char *key; { int h; x2node *np; if( x2a==0 ) return 0; h = strhash(key) & (x2a->size-1); np = x2a->ht[h]; while( np ){ if( strcmp(np->key,key)==0 ) break; np = np->next; } return np ? np->data : 0; } /* Return the n-th data. Return NULL if n is out of range. */ struct symbol *Symbol_Nth(n) int n; { struct symbol *data; if( x2a && n>0 && n<=x2a->count ){ data = x2a->tbl[n-1].data; }else{ data = 0; } return data; } /* Return the size of the array */ int Symbol_count() { return x2a ? x2a->count : 0; } /* Return an array of pointers to all data in the table. ** The array is obtained from malloc. Return NULL if memory allocation ** problems, or if the array is empty. */ struct symbol **Symbol_arrayof() { struct symbol **array; int i,size; if( x2a==0 ) return 0; size = x2a->count; array = (struct symbol **)malloc( sizeof(struct symbol *)*size ); if( array ){ for(i=0; i<size; i++) array[i] = x2a->tbl[i].data; } return array; } /* Compare two configurations */ int Configcmp(a,b) struct config *a; struct config *b; { int x; x = a->rp->index - b->rp->index; if( x==0 ) x = a->dot - b->dot; return x; } /* Compare two states */ PRIVATE int statecmp(a,b) struct config *a; struct config *b; { int rc; for(rc=0; rc==0 && a && b; a=a->bp, b=b->bp){ rc = a->rp->index - b->rp->index; if( rc==0 ) rc = a->dot - b->dot; } if( rc==0 ){ if( a ) rc = 1; if( b ) rc = -1; } return rc; } /* Hash a state */ PRIVATE int statehash(a) struct config *a; { int h=0; while( a ){ h = h*571 + a->rp->index*37 + a->dot; a = a->bp; } return h; } /* Allocate a new state structure */ struct state *State_new() { struct state *new; new = (struct state *)malloc( sizeof(struct state) ); MemoryCheck(new); return new; } /* There is one instance of the following structure for each ** associative array of type "x3". */ struct s_x3 { int size; /* The number of available slots. */ /* Must be a power of 2 greater than or */ /* equal to 1 */ int count; /* Number of currently slots filled */ struct s_x3node *tbl; /* The data stored here */ struct s_x3node **ht; /* Hash table for lookups */ }; /* There is one instance of this structure for every data element ** in an associative array of type "x3". */ typedef struct s_x3node { struct state *data; /* The data */ struct config *key; /* The key */ struct s_x3node *next; /* Next entry with the same hash */ struct s_x3node **from; /* Previous link */ } x3node; /* There is only one instance of the array, which is the following */ static struct s_x3 *x3a; /* Allocate a new associative array */ void State_init(){ if( x3a ) return; x3a = (struct s_x3*)malloc( sizeof(struct s_x3) ); if( x3a ){ x3a->size = 128; x3a->count = 0; x3a->tbl = (x3node*)malloc( (sizeof(x3node) + sizeof(x3node*))*128 ); if( x3a->tbl==0 ){ free(x3a); x3a = 0; }else{ int i; x3a->ht = (x3node**)&(x3a->tbl[128]); for(i=0; i<128; i++) x3a->ht[i] = 0; } } } /* Insert a new record into the array. Return TRUE if successful. ** Prior data with the same key is NOT overwritten */ int State_insert(data,key) struct state *data; struct config *key; { x3node *np; int h; int ph; if( x3a==0 ) return 0; ph = statehash(key); h = ph & (x3a->size-1); np = x3a->ht[h]; while( np ){ if( statecmp(np->key,key)==0 ){ /* An existing entry with the same key is found. */ /* Fail because overwrite is not allows. */ return 0; } np = np->next; } if( x3a->count>=x3a->size ){ /* Need to make the hash table bigger */ int i,size; struct s_x3 array; array.size = size = x3a->size*2; array.count = x3a->count; array.tbl = (x3node*)malloc( (sizeof(x3node) + sizeof(x3node*))*size ); if( array.tbl==0 ) return 0; /* Fail due to malloc failure */ array.ht = (x3node**)&(array.tbl[size]); for(i=0; i<size; i++) array.ht[i] = 0; for(i=0; i<x3a->count; i++){ x3node *oldnp, *newnp; oldnp = &(x3a->tbl[i]); h = statehash(oldnp->key) & (size-1); newnp = &(array.tbl[i]); if( array.ht[h] ) array.ht[h]->from = &(newnp->next); newnp->next = array.ht[h]; newnp->key = oldnp->key; newnp->data = oldnp->data; newnp->from = &(array.ht[h]); array.ht[h] = newnp; } free(x3a->tbl); *x3a = array; } /* Insert the new data */ h = ph & (x3a->size-1); np = &(x3a->tbl[x3a->count++]); np->key = key; np->data = data; if( x3a->ht[h] ) x3a->ht[h]->from = &(np->next); np->next = x3a->ht[h]; x3a->ht[h] = np; np->from = &(x3a->ht[h]); return 1; } /* Return a pointer to data assigned to the given key. Return NULL ** if no such key. */ struct state *State_find(key) struct config *key; { int h; x3node *np; if( x3a==0 ) return 0; h = statehash(key) & (x3a->size-1); np = x3a->ht[h]; while( np ){ if( statecmp(np->key,key)==0 ) break; np = np->next; } return np ? np->data : 0; } /* Return an array of pointers to all data in the table. ** The array is obtained from malloc. Return NULL if memory allocation ** problems, or if the array is empty. */ struct state **State_arrayof() { struct state **array; int i,size; if( x3a==0 ) return 0; size = x3a->count; array = (struct state **)malloc( sizeof(struct state *)*size ); if( array ){ for(i=0; i<size; i++) array[i] = x3a->tbl[i].data; } return array; } /* Hash a configuration */ PRIVATE int confighash(a) struct config *a; { int h=0; h = h*571 + a->rp->index*37 + a->dot; return h; } /* There is one instance of the following structure for each ** associative array of type "x4". */ struct s_x4 { int size; /* The number of available slots. */ /* Must be a power of 2 greater than or */ /* equal to 1 */ int count; /* Number of currently slots filled */ struct s_x4node *tbl; /* The data stored here */ struct s_x4node **ht; /* Hash table for lookups */ }; /* There is one instance of this structure for every data element ** in an associative array of type "x4". */ typedef struct s_x4node { struct config *data; /* The data */ struct s_x4node *next; /* Next entry with the same hash */ struct s_x4node **from; /* Previous link */ } x4node; /* There is only one instance of the array, which is the following */ static struct s_x4 *x4a; /* Allocate a new associative array */ void Configtable_init(){ if( x4a ) return; x4a = (struct s_x4*)malloc( sizeof(struct s_x4) ); if( x4a ){ x4a->size = 64; x4a->count = 0; x4a->tbl = (x4node*)malloc( (sizeof(x4node) + sizeof(x4node*))*64 ); if( x4a->tbl==0 ){ free(x4a); x4a = 0; }else{ int i; x4a->ht = (x4node**)&(x4a->tbl[64]); for(i=0; i<64; i++) x4a->ht[i] = 0; } } } /* Insert a new record into the array. Return TRUE if successful. ** Prior data with the same key is NOT overwritten */ int Configtable_insert(data) struct config *data; { x4node *np; int h; int ph; if( x4a==0 ) return 0; ph = confighash(data); h = ph & (x4a->size-1); np = x4a->ht[h]; while( np ){ if( Configcmp(np->data,data)==0 ){ /* An existing entry with the same key is found. */ /* Fail because overwrite is not allows. */ return 0; } np = np->next; } if( x4a->count>=x4a->size ){ /* Need to make the hash table bigger */ int i,size; struct s_x4 array; array.size = size = x4a->size*2; array.count = x4a->count; array.tbl = (x4node*)malloc( (sizeof(x4node) + sizeof(x4node*))*size ); if( array.tbl==0 ) return 0; /* Fail due to malloc failure */ array.ht = (x4node**)&(array.tbl[size]); for(i=0; i<size; i++) array.ht[i] = 0; for(i=0; i<x4a->count; i++){ x4node *oldnp, *newnp; oldnp = &(x4a->tbl[i]); h = confighash(oldnp->data) & (size-1); newnp = &(array.tbl[i]); if( array.ht[h] ) array.ht[h]->from = &(newnp->next); newnp->next = array.ht[h]; newnp->data = oldnp->data; newnp->from = &(array.ht[h]); array.ht[h] = newnp; } free(x4a->tbl); *x4a = array; } /* Insert the new data */ h = ph & (x4a->size-1); np = &(x4a->tbl[x4a->count++]); np->data = data; if( x4a->ht[h] ) x4a->ht[h]->from = &(np->next); np->next = x4a->ht[h]; x4a->ht[h] = np; np->from = &(x4a->ht[h]); return 1; } /* Return a pointer to data assigned to the given key. Return NULL ** if no such key. */ struct config *Configtable_find(key) struct config *key; { int h; x4node *np; if( x4a==0 ) return 0; h = confighash(key) & (x4a->size-1); np = x4a->ht[h]; while( np ){ if( Configcmp(np->data,key)==0 ) break; np = np->next; } return np ? np->data : 0; } /* Remove all data from the table. Pass each data to the function "f" ** as it is removed. ("f" may be null to avoid this step.) */ void Configtable_clear(f) int(*f)(/* struct config * */); { int i; if( x4a==0 || x4a->count==0 ) return; if( f ) for(i=0; i<x4a->count; i++) (*f)(x4a->tbl[i].data); for(i=0; i<x4a->size; i++) x4a->ht[i] = 0; x4a->count = 0; return; }
the_stack_data/140764347.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <stdbool.h> int main(int ac, char **av) { int i, j, prime, opt, num; int from = 2, to = 1000, count = 0; char *trailer = "\n"; while ((opt = getopt(ac, av, "nf:t:c:")) != EOF) { switch (opt) { case 'f': from = atoi(optarg); break; case 't': to = atoi(optarg); break; case 'c': count = atoi(optarg); break; case 'n': trailer = " "; break; default: /* '?' */ fprintf(stderr, "Usage: %s [-f from][[-t to]|[-c count]][-n]\n", av[0]); exit(EXIT_FAILURE); } } if (count > 0) { to = 0x7FFFFFFF; } num = 0; for(i = 2; i <= to; i++) { prime = 1; for(j = 2; j < i; j++){ if((i % j) == 0) { prime = 0; break; } } if(prime && i >= from) { num++; if (count == 0 || num <= count) { printf("%d%s", i, trailer); if (num == count) break; } } } return 0; }
the_stack_data/456563.c
#include <stdio.h> #include <stdlib.h> #include <string.h> /*Funciones*/ int estaContenido(char *subTexto, char *texto){ char *seEncuentra; seEncuentra = strstr(texto, subTexto); //Devolverá NULL si no se encuentra la ocurrencia if(seEncuentra == NULL) return 0; return 1; } int main(){ //strstr(stringPrincipal, stringABuscar); printf("\nEjercicio 4\n"); char *texto, *palabra; texto = (char *)malloc(sizeof(char) * 100); palabra = (char*)malloc(sizeof(char) * 50); printf("\nIngrese el la cadena principal: "); scanf("%s", texto); printf("Ingrese la subcadena a buscar: "); scanf("%s", palabra); int contenido = estaContenido(palabra, texto); if (contenido == 0) printf("la cadena '%s' NO se encuentra dentro de la cadena principal.", palabra); if (contenido == 1) printf("la cadena '%s' SI se encuentra dentro de la cadena principal.", palabra); }
the_stack_data/97013180.c
#include<string.h> #include<unistd.h> #include<sys/socket.h> #include<sys/types.h> #include<netinet/in.h> #include<stdlib.h> #include<stdio.h> int main() { int s,r,recb,sntb,x,ns,a=0; socklen_t len; struct sockaddr_in server,client; char buff[50]; s=socket(AF_INET,SOCK_STREAM,0); if(s==-1) { printf("\nSocket creation error."); exit(0); } printf("\nSocket created."); server.sin_family=AF_INET; server.sin_port=htons(3212); server.sin_addr.s_addr=htonl(INADDR_ANY); r=bind(s,(struct sockaddr*)&server,sizeof(server)); if(r==-1) { printf("\nBinding error."); exit(0); } printf("\nSocket binded."); r=listen(s,2); if(r==-1) { close(s); exit(0); } printf("\nSocket listening."); len=sizeof(client); ns=accept(s,(struct sockaddr*)&client, &len); if(ns==-1) { close(s); exit(0); } printf("\nSocket accepting."); int f; recb = recv(ns, buff, sizeof(buff), 0); if(recb == -1){ printf("Receive Error\n"); close(s); exit(0); } printf("%lu\n", sizeof(buff)); char arr[50]; int ch = 1; while(ch != 4){ recb = recv(ns, arr, sizeof(arr), 0); if(recb == -1){ printf("Receive error inside while!\n"); close(s); exit(0); } ch = arr[0]; int n = arr[1]; int search; int j, k, l, temp; switch(ch){ case 1: search = arr[2]; for( j = 0; j < n; j++){ if(buff[j] == search){ printf("Element found at %d\n", j+1); break; } } if(j >= n){ printf("Element not found\n"); } break; case 2: for(k = 0; k < (n-1); k++){ for(l = k+1; l < n; l++){ if(buff[k] > buff[l]){ temp = buff[k]; buff[k] = buff[l]; buff[l] = temp; } } } for(k = 0; k < n; k++){ printf("%d\n", buff[k]); } break; case 3: break; case 4: break; default: printf("Wrong Command\n"); } } close(s); exit(0); }
the_stack_data/905093.c
/* * Benchmarks contributed by Divyesh Unadkat[1,2], Supratik Chakraborty[1], Ashutosh Gupta[1] * [1] Indian Institute of Technology Bombay, Mumbai * [2] TCS Innovation labs, Pune * */ extern void __VERIFIER_error() __attribute__ ((__noreturn__)); extern void __VERIFIER_assume(int); void __VERIFIER_assert(int cond) { if(!(cond)) { ERROR: __VERIFIER_error(); } } extern int __VERIFIER_nondet_int(void); int N; int main() { N = __VERIFIER_nondet_int(); if(N <= 0) return 1; __VERIFIER_assume(N <= 2147483647/sizeof(int)); int i, j; int sum[1]; int a[N]; int b[N]; for (i = 0; i < N; i++) { a[i] = 1; } for (i = 0; i < N; i++) { b[i] = 1; } sum[0] = 0; for (i = 0; i < N; i++) { sum[0] = sum[0] + a[i]; } for (i = 0; i < N; i++) { sum[0] = sum[0] + b[i]; } for (i = 0; i < N; i++) { for (j = i; j < N; j++) { b[i] = b[i] + 1; } b[i] = b[i] + sum[0]; } for (i = 0; i < N; i++) { __VERIFIER_assert(b[i] == 3*N); } }
the_stack_data/616731.c
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <limits.h> #include <string.h> #include <memory.h> #include <errno.h> typedef struct node { int info; struct node* left; struct node* right; } Node; void* alloc(const size_t count, const size_t blockSize){ void* ptr = calloc(count, blockSize); if(! ptr){ fprintf(stderr, "%s\n", strerror(errno)); abort(); } return ptr; } Node* inserir(Node* root, int info){ if(!root){ root = (Node*) alloc(1, sizeof(Node)); root->info = info; return root; } if(info > root->info) root->right = inserir(root->right, info); else if(info < root->info) root->left = inserir(root->left, info); else puts("Valor repetido"); } void print(Node* root){ if(root){ print(root->left); printf("%d ", root->info); print(root->right); } } bool max(int a, int b){ return (a>=b)?1:0; } int height(Node* root){ if(!root) return 0; return 1 + max(height(root->left), height(root->right)); } bool isBalanced(Node* root){ if(!root) return 1; int lh = height(root->left); int rh = height(root->right); if(abs(lh-rh) <= 1 && isBalanced(root->left) && isBalanced(root->right)) return true; return false; } bool isMirror(Node* root1, Node* root2){ if(root1 == NULL && root2 == NULL) return true; if(root1 && root2) return isMirror(root1->left, root2->right) && isMirror(root1->right, root2->left); return false; } bool isSymmetric(Node* root){ return isMirror(root, root); } Node* minValueNode(Node* root){ Node* aux = root; while(aux->left) aux = aux->left; return aux; } Node* deleteNode(Node* root, int info){ if(!root) return NULL; if(info < root->info) root->left = deleteNode(root->left, info); else if(info > root->info) root->right = deleteNode(root->right, info); else{ if(!(root->left)){ Node* aux = root->right; free(root); return aux; } else if(!(root->right)){ Node* aux = root->left; free(root); return aux; } Node* temp = minValueNode(root->right); root->info = temp->info; root->right = deleteNode(root->right, temp->info); } return root; } int isBSTUtil(Node* root, int min, int max){ if(!root) return 1; if(root->info < min || root->info > max) return 0; return isBSTUtil(root->left, min, root->info-1) && isBSTUtil(root->right, root->info+1, max); } int isBST(Node* root){ return isBSTUtil(root, INT_MIN, INT_MAX); } int treeDistance (Node* root, int info) { if (!root) return -1; int distance = -1; if (root->info == info || (distance = treeDistance(root->left, info)) >=0 || (distance = treeDistance(root->right, info) >= 0)) return distance + 1; return distance; } int main(){ Node* raiz = NULL; int input[] = {32, 33, 34, 5, 35, 2, -1, 321}; int inputSize = sizeof(input)/sizeof(*input); printf("Entrada: "); for(int i=0; i < inputSize; i++){ raiz = inserir(raiz, input[i]); printf("%d ", input[i]); } putchar('\n'); printf("BST: "); print(raiz); putchar('\n'); printf("Altura = %d\n", height(raiz)); puts("\nCaracteristicas da BST: "); if(isBalanced(raiz)) puts("Arvore balanceada!"); else puts("Não balanceada!"); //deleteNode(raiz, 321); if(isSymmetric(raiz)) puts("Arvore simétrica!"); else puts("Não simétrica!"); return 0; }
the_stack_data/296395.c
#include <stdio.h> #include <stdlib.h> #include <locale.h> int somaCalc(number) { int acumulator; acumulator = 1; for(int i=number; i>0; i--){ acumulator = acumulator + i; } printf("A soma é igual a %i", number); return 0; } int main(void) { int number; printf("Digite aqui o número: \n"); scanf("%i", &number); somaCalc(number); }
the_stack_data/1005707.c
/* @author: david942j Getting libc's information, such as: - main_arena offset - is tcache enabled? Sample Usage > ./libc_info > LD_LIBRARY_PATH=. ./libc_info > ./ld-linux.so.2 --library-path . ./libc_info */ #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define SZ sizeof(size_t) #define PAGE_SIZE 0x1000 void *search_head(size_t e) { e = (e >> 12) << 12; while(strncmp((void*)e, "\177ELF", 4)) e -= PAGE_SIZE; return (void*) e; } void* main_arena_offset() { void **p = (void**)malloc(SZ * 128 * 2); // a large chunk void *z = malloc(SZ); // prevent p merge with top chunk *p = z; // prevent compiler optimize free(p); // now *p must be the pointer of the (chunk_ptr) unsorted bin z = (void*)((*p) - (4 + 4 + SZ * 10)); // mutex+flags+fastbin[] 2.23-2.26, 2.27+ need to -8 void* a = search_head((size_t)__builtin_return_address(1)); return (void*)(z - a); } int tcache_enable() { void **p = malloc(SZ * 32); // smallbin size *p = (void*) 0xdeadbeefu; // if tcache is enabled, this free will put p into tcache_entry; // otherwise, either merge with top_chunk or put into unsorted_bin free(p); if(*p == 0) return 1; // tcache_entry, fd set as zero return 0; } int main(int argc, char **argv) { printf("{" \ "\"main_arena_offset\": %u," \ "\"tcache_enable\": %s" \ "}\n", main_arena_offset(), tcache_enable() ? "true" : "false"); return 0; }
the_stack_data/887139.c
#include <stdio.h> #include <stdlib.h> #ifdef _OPENMP #include <omp.h> #else #define omp_get_thread_num() 0 #endif main(int argc, char **argv) { int i, n=20, a[n],suma=0; if(argc < 2) { fprintf(stderr,"Falta iteraciones\n"); exit(-1); } n = atoi(argv[1]); if (n>20) { n=20; printf("n=%d",n); } for (i=0; i<n; i++) a[i] = i; #pragma omp parallel for reduction(+:suma) for (i=0; i<n; i++) suma += a[i]; printf("Tras 'parallel' suma=%d\n",suma); }
the_stack_data/51699262.c
/* f2c.h -- Standard Fortran to C header file */ /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ #ifndef F2C_INCLUDE #define F2C_INCLUDE #include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimag(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static doublereal c_b23 = -1.; static doublereal c_b27 = 1.; /* > \brief \b DTFSM solves a matrix equation (one operand is a triangular matrix in RFP format). */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download DTFSM + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtfsm.f "> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtfsm.f "> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtfsm.f "> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE DTFSM( TRANSR, SIDE, UPLO, TRANS, DIAG, M, N, ALPHA, A, */ /* B, LDB ) */ /* CHARACTER TRANSR, DIAG, SIDE, TRANS, UPLO */ /* INTEGER LDB, M, N */ /* DOUBLE PRECISION ALPHA */ /* DOUBLE PRECISION A( 0: * ), B( 0: LDB-1, 0: * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > Level 3 BLAS like routine for A in RFP Format. */ /* > */ /* > DTFSM solves the matrix equation */ /* > */ /* > op( A )*X = alpha*B or X*op( A ) = alpha*B */ /* > */ /* > where alpha is a scalar, X and B are m by n matrices, A is a unit, or */ /* > non-unit, upper or lower triangular matrix and op( A ) is one of */ /* > */ /* > op( A ) = A or op( A ) = A**T. */ /* > */ /* > A is in Rectangular Full Packed (RFP) Format. */ /* > */ /* > The matrix X is overwritten on B. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] TRANSR */ /* > \verbatim */ /* > TRANSR is CHARACTER*1 */ /* > = 'N': The Normal Form of RFP A is stored; */ /* > = 'T': The Transpose Form of RFP A is stored. */ /* > \endverbatim */ /* > */ /* > \param[in] SIDE */ /* > \verbatim */ /* > SIDE is CHARACTER*1 */ /* > On entry, SIDE specifies whether op( A ) appears on the left */ /* > or right of X as follows: */ /* > */ /* > SIDE = 'L' or 'l' op( A )*X = alpha*B. */ /* > */ /* > SIDE = 'R' or 'r' X*op( A ) = alpha*B. */ /* > */ /* > Unchanged on exit. */ /* > \endverbatim */ /* > */ /* > \param[in] UPLO */ /* > \verbatim */ /* > UPLO is CHARACTER*1 */ /* > On entry, UPLO specifies whether the RFP matrix A came from */ /* > an upper or lower triangular matrix as follows: */ /* > UPLO = 'U' or 'u' RFP A came from an upper triangular matrix */ /* > UPLO = 'L' or 'l' RFP A came from a lower triangular matrix */ /* > */ /* > Unchanged on exit. */ /* > \endverbatim */ /* > */ /* > \param[in] TRANS */ /* > \verbatim */ /* > TRANS is CHARACTER*1 */ /* > On entry, TRANS specifies the form of op( A ) to be used */ /* > in the matrix multiplication as follows: */ /* > */ /* > TRANS = 'N' or 'n' op( A ) = A. */ /* > */ /* > TRANS = 'T' or 't' op( A ) = A'. */ /* > */ /* > Unchanged on exit. */ /* > \endverbatim */ /* > */ /* > \param[in] DIAG */ /* > \verbatim */ /* > DIAG is CHARACTER*1 */ /* > On entry, DIAG specifies whether or not RFP A is unit */ /* > triangular as follows: */ /* > */ /* > DIAG = 'U' or 'u' A is assumed to be unit triangular. */ /* > */ /* > DIAG = 'N' or 'n' A is not assumed to be unit */ /* > triangular. */ /* > */ /* > Unchanged on exit. */ /* > \endverbatim */ /* > */ /* > \param[in] M */ /* > \verbatim */ /* > M is INTEGER */ /* > On entry, M specifies the number of rows of B. M must be at */ /* > least zero. */ /* > Unchanged on exit. */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > On entry, N specifies the number of columns of B. N must be */ /* > at least zero. */ /* > Unchanged on exit. */ /* > \endverbatim */ /* > */ /* > \param[in] ALPHA */ /* > \verbatim */ /* > ALPHA is DOUBLE PRECISION */ /* > On entry, ALPHA specifies the scalar alpha. When alpha is */ /* > zero then A is not referenced and B need not be set before */ /* > entry. */ /* > Unchanged on exit. */ /* > \endverbatim */ /* > */ /* > \param[in] A */ /* > \verbatim */ /* > A is DOUBLE PRECISION array, dimension (NT) */ /* > NT = N*(N+1)/2. On entry, the matrix A in RFP Format. */ /* > RFP Format is described by TRANSR, UPLO and N as follows: */ /* > If TRANSR='N' then RFP A is (0:N,0:K-1) when N is even; */ /* > K=N/2. RFP A is (0:N-1,0:K) when N is odd; K=N/2. If */ /* > TRANSR = 'T' then RFP is the transpose of RFP A as */ /* > defined when TRANSR = 'N'. The contents of RFP A are defined */ /* > by UPLO as follows: If UPLO = 'U' the RFP A contains the NT */ /* > elements of upper packed A either in normal or */ /* > transpose Format. If UPLO = 'L' the RFP A contains */ /* > the NT elements of lower packed A either in normal or */ /* > transpose Format. The LDA of RFP A is (N+1)/2 when */ /* > TRANSR = 'T'. When TRANSR is 'N' the LDA is N+1 when N is */ /* > even and is N when is odd. */ /* > See the Note below for more details. Unchanged on exit. */ /* > \endverbatim */ /* > */ /* > \param[in,out] B */ /* > \verbatim */ /* > B is DOUBLE PRECISION array, dimension (LDB,N) */ /* > Before entry, the leading m by n part of the array B must */ /* > contain the right-hand side matrix B, and on exit is */ /* > overwritten by the solution matrix X. */ /* > \endverbatim */ /* > */ /* > \param[in] LDB */ /* > \verbatim */ /* > LDB is INTEGER */ /* > On entry, LDB specifies the first dimension of B as declared */ /* > in the calling (sub) program. LDB must be at least */ /* > f2cmax( 1, m ). */ /* > Unchanged on exit. */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date December 2016 */ /* > \ingroup doubleOTHERcomputational */ /* > \par Further Details: */ /* ===================== */ /* > */ /* > \verbatim */ /* > */ /* > We first consider Rectangular Full Packed (RFP) Format when N is */ /* > even. We give an example where N = 6. */ /* > */ /* > AP is Upper AP is Lower */ /* > */ /* > 00 01 02 03 04 05 00 */ /* > 11 12 13 14 15 10 11 */ /* > 22 23 24 25 20 21 22 */ /* > 33 34 35 30 31 32 33 */ /* > 44 45 40 41 42 43 44 */ /* > 55 50 51 52 53 54 55 */ /* > */ /* > */ /* > Let TRANSR = 'N'. RFP holds AP as follows: */ /* > For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last */ /* > three columns of AP upper. The lower triangle A(4:6,0:2) consists of */ /* > the transpose of the first three columns of AP upper. */ /* > For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first */ /* > three columns of AP lower. The upper triangle A(0:2,0:2) consists of */ /* > the transpose of the last three columns of AP lower. */ /* > This covers the case N even and TRANSR = 'N'. */ /* > */ /* > RFP A RFP A */ /* > */ /* > 03 04 05 33 43 53 */ /* > 13 14 15 00 44 54 */ /* > 23 24 25 10 11 55 */ /* > 33 34 35 20 21 22 */ /* > 00 44 45 30 31 32 */ /* > 01 11 55 40 41 42 */ /* > 02 12 22 50 51 52 */ /* > */ /* > Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */ /* > transpose of RFP A above. One therefore gets: */ /* > */ /* > */ /* > RFP A RFP A */ /* > */ /* > 03 13 23 33 00 01 02 33 00 10 20 30 40 50 */ /* > 04 14 24 34 44 11 12 43 44 11 21 31 41 51 */ /* > 05 15 25 35 45 55 22 53 54 55 22 32 42 52 */ /* > */ /* > */ /* > We then consider Rectangular Full Packed (RFP) Format when N is */ /* > odd. We give an example where N = 5. */ /* > */ /* > AP is Upper AP is Lower */ /* > */ /* > 00 01 02 03 04 00 */ /* > 11 12 13 14 10 11 */ /* > 22 23 24 20 21 22 */ /* > 33 34 30 31 32 33 */ /* > 44 40 41 42 43 44 */ /* > */ /* > */ /* > Let TRANSR = 'N'. RFP holds AP as follows: */ /* > For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last */ /* > three columns of AP upper. The lower triangle A(3:4,0:1) consists of */ /* > the transpose of the first two columns of AP upper. */ /* > For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first */ /* > three columns of AP lower. The upper triangle A(0:1,1:2) consists of */ /* > the transpose of the last two columns of AP lower. */ /* > This covers the case N odd and TRANSR = 'N'. */ /* > */ /* > RFP A RFP A */ /* > */ /* > 02 03 04 00 33 43 */ /* > 12 13 14 10 11 44 */ /* > 22 23 24 20 21 22 */ /* > 00 33 34 30 31 32 */ /* > 01 11 44 40 41 42 */ /* > */ /* > Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */ /* > transpose of RFP A above. One therefore gets: */ /* > */ /* > RFP A RFP A */ /* > */ /* > 02 12 22 00 01 00 10 20 30 40 50 */ /* > 03 13 23 33 11 33 11 21 31 41 51 */ /* > 04 14 24 34 44 43 44 22 32 42 52 */ /* > \endverbatim */ /* ===================================================================== */ /* Subroutine */ int dtfsm_(char *transr, char *side, char *uplo, char *trans, char *diag, integer *m, integer *n, doublereal *alpha, doublereal *a, doublereal *b, integer *ldb) { /* System generated locals */ integer b_dim1, b_offset, i__1, i__2; /* Local variables */ integer info, i__, j, k; logical normaltransr; extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, integer *, doublereal *, doublereal *, integer *, doublereal *, integer *, doublereal *, doublereal *, integer *); logical lside; extern logical lsame_(char *, char *); logical lower; extern /* Subroutine */ int dtrsm_(char *, char *, char *, char *, integer *, integer *, doublereal *, doublereal *, integer *, doublereal *, integer *); integer m1, m2, n1, n2; extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); logical misodd, nisodd, notrans; /* -- LAPACK computational routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* December 2016 */ /* ===================================================================== */ /* Test the input parameters. */ /* Parameter adjustments */ b_dim1 = *ldb - 1 - 0 + 1; b_offset = 0 + b_dim1 * 0; b -= b_offset; /* Function Body */ info = 0; normaltransr = lsame_(transr, "N"); lside = lsame_(side, "L"); lower = lsame_(uplo, "L"); notrans = lsame_(trans, "N"); if (! normaltransr && ! lsame_(transr, "T")) { info = -1; } else if (! lside && ! lsame_(side, "R")) { info = -2; } else if (! lower && ! lsame_(uplo, "U")) { info = -3; } else if (! notrans && ! lsame_(trans, "T")) { info = -4; } else if (! lsame_(diag, "N") && ! lsame_(diag, "U")) { info = -5; } else if (*m < 0) { info = -6; } else if (*n < 0) { info = -7; } else if (*ldb < f2cmax(1,*m)) { info = -11; } if (info != 0) { i__1 = -info; xerbla_("DTFSM ", &i__1, (ftnlen)6); return 0; } /* Quick return when ( (N.EQ.0).OR.(M.EQ.0) ) */ if (*m == 0 || *n == 0) { return 0; } /* Quick return when ALPHA.EQ.(0D+0) */ if (*alpha == 0.) { i__1 = *n - 1; for (j = 0; j <= i__1; ++j) { i__2 = *m - 1; for (i__ = 0; i__ <= i__2; ++i__) { b[i__ + j * b_dim1] = 0.; /* L10: */ } /* L20: */ } return 0; } if (lside) { /* SIDE = 'L' */ /* A is M-by-M. */ /* If M is odd, set NISODD = .TRUE., and M1 and M2. */ /* If M is even, NISODD = .FALSE., and M. */ if (*m % 2 == 0) { misodd = FALSE_; k = *m / 2; } else { misodd = TRUE_; if (lower) { m2 = *m / 2; m1 = *m - m2; } else { m1 = *m / 2; m2 = *m - m1; } } if (misodd) { /* SIDE = 'L' and N is odd */ if (normaltransr) { /* SIDE = 'L', N is odd, and TRANSR = 'N' */ if (lower) { /* SIDE ='L', N is odd, TRANSR = 'N', and UPLO = 'L' */ if (notrans) { /* SIDE ='L', N is odd, TRANSR = 'N', UPLO = 'L', and */ /* TRANS = 'N' */ if (*m == 1) { dtrsm_("L", "L", "N", diag, &m1, n, alpha, a, m, & b[b_offset], ldb); } else { dtrsm_("L", "L", "N", diag, &m1, n, alpha, a, m, & b[b_offset], ldb); dgemm_("N", "N", &m2, n, &m1, &c_b23, &a[m1], m, & b[b_offset], ldb, alpha, &b[m1], ldb); dtrsm_("L", "U", "T", diag, &m2, n, &c_b27, &a[*m] , m, &b[m1], ldb); } } else { /* SIDE ='L', N is odd, TRANSR = 'N', UPLO = 'L', and */ /* TRANS = 'T' */ if (*m == 1) { dtrsm_("L", "L", "T", diag, &m1, n, alpha, a, m, & b[b_offset], ldb); } else { dtrsm_("L", "U", "N", diag, &m2, n, alpha, &a[*m], m, &b[m1], ldb); dgemm_("T", "N", &m1, n, &m2, &c_b23, &a[m1], m, & b[m1], ldb, alpha, &b[b_offset], ldb); dtrsm_("L", "L", "T", diag, &m1, n, &c_b27, a, m, &b[b_offset], ldb); } } } else { /* SIDE ='L', N is odd, TRANSR = 'N', and UPLO = 'U' */ if (! notrans) { /* SIDE ='L', N is odd, TRANSR = 'N', UPLO = 'U', and */ /* TRANS = 'N' */ dtrsm_("L", "L", "N", diag, &m1, n, alpha, &a[m2], m, &b[b_offset], ldb); dgemm_("T", "N", &m2, n, &m1, &c_b23, a, m, &b[ b_offset], ldb, alpha, &b[m1], ldb); dtrsm_("L", "U", "T", diag, &m2, n, &c_b27, &a[m1], m, &b[m1], ldb); } else { /* SIDE ='L', N is odd, TRANSR = 'N', UPLO = 'U', and */ /* TRANS = 'T' */ dtrsm_("L", "U", "N", diag, &m2, n, alpha, &a[m1], m, &b[m1], ldb); dgemm_("N", "N", &m1, n, &m2, &c_b23, a, m, &b[m1], ldb, alpha, &b[b_offset], ldb); dtrsm_("L", "L", "T", diag, &m1, n, &c_b27, &a[m2], m, &b[b_offset], ldb); } } } else { /* SIDE = 'L', N is odd, and TRANSR = 'T' */ if (lower) { /* SIDE ='L', N is odd, TRANSR = 'T', and UPLO = 'L' */ if (notrans) { /* SIDE ='L', N is odd, TRANSR = 'T', UPLO = 'L', and */ /* TRANS = 'N' */ if (*m == 1) { dtrsm_("L", "U", "T", diag, &m1, n, alpha, a, &m1, &b[b_offset], ldb); } else { dtrsm_("L", "U", "T", diag, &m1, n, alpha, a, &m1, &b[b_offset], ldb); dgemm_("T", "N", &m2, n, &m1, &c_b23, &a[m1 * m1], &m1, &b[b_offset], ldb, alpha, &b[m1], ldb); dtrsm_("L", "L", "N", diag, &m2, n, &c_b27, &a[1], &m1, &b[m1], ldb); } } else { /* SIDE ='L', N is odd, TRANSR = 'T', UPLO = 'L', and */ /* TRANS = 'T' */ if (*m == 1) { dtrsm_("L", "U", "N", diag, &m1, n, alpha, a, &m1, &b[b_offset], ldb); } else { dtrsm_("L", "L", "T", diag, &m2, n, alpha, &a[1], &m1, &b[m1], ldb); dgemm_("N", "N", &m1, n, &m2, &c_b23, &a[m1 * m1], &m1, &b[m1], ldb, alpha, &b[b_offset], ldb); dtrsm_("L", "U", "N", diag, &m1, n, &c_b27, a, & m1, &b[b_offset], ldb); } } } else { /* SIDE ='L', N is odd, TRANSR = 'T', and UPLO = 'U' */ if (! notrans) { /* SIDE ='L', N is odd, TRANSR = 'T', UPLO = 'U', and */ /* TRANS = 'N' */ dtrsm_("L", "U", "T", diag, &m1, n, alpha, &a[m2 * m2] , &m2, &b[b_offset], ldb); dgemm_("N", "N", &m2, n, &m1, &c_b23, a, &m2, &b[ b_offset], ldb, alpha, &b[m1], ldb); dtrsm_("L", "L", "N", diag, &m2, n, &c_b27, &a[m1 * m2], &m2, &b[m1], ldb); } else { /* SIDE ='L', N is odd, TRANSR = 'T', UPLO = 'U', and */ /* TRANS = 'T' */ dtrsm_("L", "L", "T", diag, &m2, n, alpha, &a[m1 * m2] , &m2, &b[m1], ldb); dgemm_("T", "N", &m1, n, &m2, &c_b23, a, &m2, &b[m1], ldb, alpha, &b[b_offset], ldb); dtrsm_("L", "U", "N", diag, &m1, n, &c_b27, &a[m2 * m2], &m2, &b[b_offset], ldb); } } } } else { /* SIDE = 'L' and N is even */ if (normaltransr) { /* SIDE = 'L', N is even, and TRANSR = 'N' */ if (lower) { /* SIDE ='L', N is even, TRANSR = 'N', and UPLO = 'L' */ if (notrans) { /* SIDE ='L', N is even, TRANSR = 'N', UPLO = 'L', */ /* and TRANS = 'N' */ i__1 = *m + 1; dtrsm_("L", "L", "N", diag, &k, n, alpha, &a[1], & i__1, &b[b_offset], ldb); i__1 = *m + 1; dgemm_("N", "N", &k, n, &k, &c_b23, &a[k + 1], &i__1, &b[b_offset], ldb, alpha, &b[k], ldb); i__1 = *m + 1; dtrsm_("L", "U", "T", diag, &k, n, &c_b27, a, &i__1, & b[k], ldb); } else { /* SIDE ='L', N is even, TRANSR = 'N', UPLO = 'L', */ /* and TRANS = 'T' */ i__1 = *m + 1; dtrsm_("L", "U", "N", diag, &k, n, alpha, a, &i__1, & b[k], ldb); i__1 = *m + 1; dgemm_("T", "N", &k, n, &k, &c_b23, &a[k + 1], &i__1, &b[k], ldb, alpha, &b[b_offset], ldb); i__1 = *m + 1; dtrsm_("L", "L", "T", diag, &k, n, &c_b27, &a[1], & i__1, &b[b_offset], ldb); } } else { /* SIDE ='L', N is even, TRANSR = 'N', and UPLO = 'U' */ if (! notrans) { /* SIDE ='L', N is even, TRANSR = 'N', UPLO = 'U', */ /* and TRANS = 'N' */ i__1 = *m + 1; dtrsm_("L", "L", "N", diag, &k, n, alpha, &a[k + 1], & i__1, &b[b_offset], ldb); i__1 = *m + 1; dgemm_("T", "N", &k, n, &k, &c_b23, a, &i__1, &b[ b_offset], ldb, alpha, &b[k], ldb); i__1 = *m + 1; dtrsm_("L", "U", "T", diag, &k, n, &c_b27, &a[k], & i__1, &b[k], ldb); } else { /* SIDE ='L', N is even, TRANSR = 'N', UPLO = 'U', */ /* and TRANS = 'T' */ i__1 = *m + 1; dtrsm_("L", "U", "N", diag, &k, n, alpha, &a[k], & i__1, &b[k], ldb); i__1 = *m + 1; dgemm_("N", "N", &k, n, &k, &c_b23, a, &i__1, &b[k], ldb, alpha, &b[b_offset], ldb); i__1 = *m + 1; dtrsm_("L", "L", "T", diag, &k, n, &c_b27, &a[k + 1], &i__1, &b[b_offset], ldb); } } } else { /* SIDE = 'L', N is even, and TRANSR = 'T' */ if (lower) { /* SIDE ='L', N is even, TRANSR = 'T', and UPLO = 'L' */ if (notrans) { /* SIDE ='L', N is even, TRANSR = 'T', UPLO = 'L', */ /* and TRANS = 'N' */ dtrsm_("L", "U", "T", diag, &k, n, alpha, &a[k], &k, & b[b_offset], ldb); dgemm_("T", "N", &k, n, &k, &c_b23, &a[k * (k + 1)], & k, &b[b_offset], ldb, alpha, &b[k], ldb); dtrsm_("L", "L", "N", diag, &k, n, &c_b27, a, &k, &b[ k], ldb); } else { /* SIDE ='L', N is even, TRANSR = 'T', UPLO = 'L', */ /* and TRANS = 'T' */ dtrsm_("L", "L", "T", diag, &k, n, alpha, a, &k, &b[k] , ldb); dgemm_("N", "N", &k, n, &k, &c_b23, &a[k * (k + 1)], & k, &b[k], ldb, alpha, &b[b_offset], ldb); dtrsm_("L", "U", "N", diag, &k, n, &c_b27, &a[k], &k, &b[b_offset], ldb); } } else { /* SIDE ='L', N is even, TRANSR = 'T', and UPLO = 'U' */ if (! notrans) { /* SIDE ='L', N is even, TRANSR = 'T', UPLO = 'U', */ /* and TRANS = 'N' */ dtrsm_("L", "U", "T", diag, &k, n, alpha, &a[k * (k + 1)], &k, &b[b_offset], ldb); dgemm_("N", "N", &k, n, &k, &c_b23, a, &k, &b[ b_offset], ldb, alpha, &b[k], ldb); dtrsm_("L", "L", "N", diag, &k, n, &c_b27, &a[k * k], &k, &b[k], ldb); } else { /* SIDE ='L', N is even, TRANSR = 'T', UPLO = 'U', */ /* and TRANS = 'T' */ dtrsm_("L", "L", "T", diag, &k, n, alpha, &a[k * k], & k, &b[k], ldb); dgemm_("T", "N", &k, n, &k, &c_b23, a, &k, &b[k], ldb, alpha, &b[b_offset], ldb); dtrsm_("L", "U", "N", diag, &k, n, &c_b27, &a[k * (k + 1)], &k, &b[b_offset], ldb); } } } } } else { /* SIDE = 'R' */ /* A is N-by-N. */ /* If N is odd, set NISODD = .TRUE., and N1 and N2. */ /* If N is even, NISODD = .FALSE., and K. */ if (*n % 2 == 0) { nisodd = FALSE_; k = *n / 2; } else { nisodd = TRUE_; if (lower) { n2 = *n / 2; n1 = *n - n2; } else { n1 = *n / 2; n2 = *n - n1; } } if (nisodd) { /* SIDE = 'R' and N is odd */ if (normaltransr) { /* SIDE = 'R', N is odd, and TRANSR = 'N' */ if (lower) { /* SIDE ='R', N is odd, TRANSR = 'N', and UPLO = 'L' */ if (notrans) { /* SIDE ='R', N is odd, TRANSR = 'N', UPLO = 'L', and */ /* TRANS = 'N' */ dtrsm_("R", "U", "T", diag, m, &n2, alpha, &a[*n], n, &b[n1 * b_dim1], ldb); dgemm_("N", "N", m, &n1, &n2, &c_b23, &b[n1 * b_dim1], ldb, &a[n1], n, alpha, b, ldb); dtrsm_("R", "L", "N", diag, m, &n1, &c_b27, a, n, b, ldb); } else { /* SIDE ='R', N is odd, TRANSR = 'N', UPLO = 'L', and */ /* TRANS = 'T' */ dtrsm_("R", "L", "T", diag, m, &n1, alpha, a, n, b, ldb); dgemm_("N", "T", m, &n2, &n1, &c_b23, b, ldb, &a[n1], n, alpha, &b[n1 * b_dim1], ldb); dtrsm_("R", "U", "N", diag, m, &n2, &c_b27, &a[*n], n, &b[n1 * b_dim1], ldb); } } else { /* SIDE ='R', N is odd, TRANSR = 'N', and UPLO = 'U' */ if (notrans) { /* SIDE ='R', N is odd, TRANSR = 'N', UPLO = 'U', and */ /* TRANS = 'N' */ dtrsm_("R", "L", "T", diag, m, &n1, alpha, &a[n2], n, b, ldb); dgemm_("N", "N", m, &n2, &n1, &c_b23, b, ldb, a, n, alpha, &b[n1 * b_dim1], ldb); dtrsm_("R", "U", "N", diag, m, &n2, &c_b27, &a[n1], n, &b[n1 * b_dim1], ldb); } else { /* SIDE ='R', N is odd, TRANSR = 'N', UPLO = 'U', and */ /* TRANS = 'T' */ dtrsm_("R", "U", "T", diag, m, &n2, alpha, &a[n1], n, &b[n1 * b_dim1], ldb); dgemm_("N", "T", m, &n1, &n2, &c_b23, &b[n1 * b_dim1], ldb, a, n, alpha, b, ldb); dtrsm_("R", "L", "N", diag, m, &n1, &c_b27, &a[n2], n, b, ldb); } } } else { /* SIDE = 'R', N is odd, and TRANSR = 'T' */ if (lower) { /* SIDE ='R', N is odd, TRANSR = 'T', and UPLO = 'L' */ if (notrans) { /* SIDE ='R', N is odd, TRANSR = 'T', UPLO = 'L', and */ /* TRANS = 'N' */ dtrsm_("R", "L", "N", diag, m, &n2, alpha, &a[1], &n1, &b[n1 * b_dim1], ldb); dgemm_("N", "T", m, &n1, &n2, &c_b23, &b[n1 * b_dim1], ldb, &a[n1 * n1], &n1, alpha, b, ldb); dtrsm_("R", "U", "T", diag, m, &n1, &c_b27, a, &n1, b, ldb); } else { /* SIDE ='R', N is odd, TRANSR = 'T', UPLO = 'L', and */ /* TRANS = 'T' */ dtrsm_("R", "U", "N", diag, m, &n1, alpha, a, &n1, b, ldb); dgemm_("N", "N", m, &n2, &n1, &c_b23, b, ldb, &a[n1 * n1], &n1, alpha, &b[n1 * b_dim1], ldb); dtrsm_("R", "L", "T", diag, m, &n2, &c_b27, &a[1], & n1, &b[n1 * b_dim1], ldb); } } else { /* SIDE ='R', N is odd, TRANSR = 'T', and UPLO = 'U' */ if (notrans) { /* SIDE ='R', N is odd, TRANSR = 'T', UPLO = 'U', and */ /* TRANS = 'N' */ dtrsm_("R", "U", "N", diag, m, &n1, alpha, &a[n2 * n2] , &n2, b, ldb); dgemm_("N", "T", m, &n2, &n1, &c_b23, b, ldb, a, &n2, alpha, &b[n1 * b_dim1], ldb); dtrsm_("R", "L", "T", diag, m, &n2, &c_b27, &a[n1 * n2], &n2, &b[n1 * b_dim1], ldb); } else { /* SIDE ='R', N is odd, TRANSR = 'T', UPLO = 'U', and */ /* TRANS = 'T' */ dtrsm_("R", "L", "N", diag, m, &n2, alpha, &a[n1 * n2] , &n2, &b[n1 * b_dim1], ldb); dgemm_("N", "N", m, &n1, &n2, &c_b23, &b[n1 * b_dim1], ldb, a, &n2, alpha, b, ldb); dtrsm_("R", "U", "T", diag, m, &n1, &c_b27, &a[n2 * n2], &n2, b, ldb); } } } } else { /* SIDE = 'R' and N is even */ if (normaltransr) { /* SIDE = 'R', N is even, and TRANSR = 'N' */ if (lower) { /* SIDE ='R', N is even, TRANSR = 'N', and UPLO = 'L' */ if (notrans) { /* SIDE ='R', N is even, TRANSR = 'N', UPLO = 'L', */ /* and TRANS = 'N' */ i__1 = *n + 1; dtrsm_("R", "U", "T", diag, m, &k, alpha, a, &i__1, & b[k * b_dim1], ldb); i__1 = *n + 1; dgemm_("N", "N", m, &k, &k, &c_b23, &b[k * b_dim1], ldb, &a[k + 1], &i__1, alpha, b, ldb); i__1 = *n + 1; dtrsm_("R", "L", "N", diag, m, &k, &c_b27, &a[1], & i__1, b, ldb); } else { /* SIDE ='R', N is even, TRANSR = 'N', UPLO = 'L', */ /* and TRANS = 'T' */ i__1 = *n + 1; dtrsm_("R", "L", "T", diag, m, &k, alpha, &a[1], & i__1, b, ldb); i__1 = *n + 1; dgemm_("N", "T", m, &k, &k, &c_b23, b, ldb, &a[k + 1], &i__1, alpha, &b[k * b_dim1], ldb); i__1 = *n + 1; dtrsm_("R", "U", "N", diag, m, &k, &c_b27, a, &i__1, & b[k * b_dim1], ldb); } } else { /* SIDE ='R', N is even, TRANSR = 'N', and UPLO = 'U' */ if (notrans) { /* SIDE ='R', N is even, TRANSR = 'N', UPLO = 'U', */ /* and TRANS = 'N' */ i__1 = *n + 1; dtrsm_("R", "L", "T", diag, m, &k, alpha, &a[k + 1], & i__1, b, ldb); i__1 = *n + 1; dgemm_("N", "N", m, &k, &k, &c_b23, b, ldb, a, &i__1, alpha, &b[k * b_dim1], ldb); i__1 = *n + 1; dtrsm_("R", "U", "N", diag, m, &k, &c_b27, &a[k], & i__1, &b[k * b_dim1], ldb); } else { /* SIDE ='R', N is even, TRANSR = 'N', UPLO = 'U', */ /* and TRANS = 'T' */ i__1 = *n + 1; dtrsm_("R", "U", "T", diag, m, &k, alpha, &a[k], & i__1, &b[k * b_dim1], ldb); i__1 = *n + 1; dgemm_("N", "T", m, &k, &k, &c_b23, &b[k * b_dim1], ldb, a, &i__1, alpha, b, ldb); i__1 = *n + 1; dtrsm_("R", "L", "N", diag, m, &k, &c_b27, &a[k + 1], &i__1, b, ldb); } } } else { /* SIDE = 'R', N is even, and TRANSR = 'T' */ if (lower) { /* SIDE ='R', N is even, TRANSR = 'T', and UPLO = 'L' */ if (notrans) { /* SIDE ='R', N is even, TRANSR = 'T', UPLO = 'L', */ /* and TRANS = 'N' */ dtrsm_("R", "L", "N", diag, m, &k, alpha, a, &k, &b[k * b_dim1], ldb); dgemm_("N", "T", m, &k, &k, &c_b23, &b[k * b_dim1], ldb, &a[(k + 1) * k], &k, alpha, b, ldb); dtrsm_("R", "U", "T", diag, m, &k, &c_b27, &a[k], &k, b, ldb); } else { /* SIDE ='R', N is even, TRANSR = 'T', UPLO = 'L', */ /* and TRANS = 'T' */ dtrsm_("R", "U", "N", diag, m, &k, alpha, &a[k], &k, b, ldb); dgemm_("N", "N", m, &k, &k, &c_b23, b, ldb, &a[(k + 1) * k], &k, alpha, &b[k * b_dim1], ldb); dtrsm_("R", "L", "T", diag, m, &k, &c_b27, a, &k, &b[ k * b_dim1], ldb); } } else { /* SIDE ='R', N is even, TRANSR = 'T', and UPLO = 'U' */ if (notrans) { /* SIDE ='R', N is even, TRANSR = 'T', UPLO = 'U', */ /* and TRANS = 'N' */ dtrsm_("R", "U", "N", diag, m, &k, alpha, &a[(k + 1) * k], &k, b, ldb); dgemm_("N", "T", m, &k, &k, &c_b23, b, ldb, a, &k, alpha, &b[k * b_dim1], ldb); dtrsm_("R", "L", "T", diag, m, &k, &c_b27, &a[k * k], &k, &b[k * b_dim1], ldb); } else { /* SIDE ='R', N is even, TRANSR = 'T', UPLO = 'U', */ /* and TRANS = 'T' */ dtrsm_("R", "L", "N", diag, m, &k, alpha, &a[k * k], & k, &b[k * b_dim1], ldb); dgemm_("N", "N", m, &k, &k, &c_b23, &b[k * b_dim1], ldb, a, &k, alpha, b, ldb); dtrsm_("R", "U", "T", diag, m, &k, &c_b27, &a[(k + 1) * k], &k, b, ldb); } } } } } return 0; /* End of DTFSM */ } /* dtfsm_ */
the_stack_data/68887150.c
/* * Copyright (C) 2009, 2010 Nick Johnson <nickbjohnson4224 at gmail.com> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <stdint.h> #include <string.h> size_t strlen(const char *s) { size_t i; for (i = 0; s[i]; i++); return i; }
the_stack_data/752713.c
#include <stdio.h> int main(int argc, char *argv[]) { char *aa = argv[1]; printf("%s\n", aa); int a = 4; int b = 6; int array[3]; array[0] = 1; array[1] = 10; array[2] = 100; int *p; p = &a; int i = 0; while (i < 6) { printf("*p = %d\n", *p); p++; i++; } return 0; }
the_stack_data/72012607.c
/* ** EPITECH PROJECT, 2020 ** concat_params.c ** File description: ** concatenate parameters */ #include <stdlib.h> char *my_strcat(char *dest, char const *src); int my_len_array(int argc, char **argv); char *concat_params(int argc, char **argv) { char *concat = malloc(sizeof(char) * (my_len_array(argc, argv) + argc - 1)); for (int i = 0; argv[i]; i++) { my_strcat(concat, argv[i]); if (argv[i + 1]) my_strcat(concat, "\n"); } return (concat); }
the_stack_data/87638873.c
/* A Bison parser, made by GNU Bison 3.3.2. */ /* Bison implementation for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Undocumented macros, especially those whose name start with YY_, are private implementation details. Do not rely on them. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "3.3.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* First part of user prologue. */ #line 1 "calc.yacc" /* yacc.c:337 */ #include <stdio.h> int regs[26]; int base; #line 76 "y.tab.c" /* yacc.c:337 */ # ifndef YY_NULLPTR # if defined __cplusplus # if 201103L <= __cplusplus # define YY_NULLPTR nullptr # else # define YY_NULLPTR 0 # endif # else # define YY_NULLPTR ((void*)0) # endif # endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* In a future release of Bison, this section will be replaced by #include "y.tab.h". */ #ifndef YY_YY_Y_TAB_H_INCLUDED # define YY_YY_Y_TAB_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif #if YYDEBUG extern int yydebug; #endif /* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { DIGIT = 258, LETTER = 259, UMINUS = 260 }; #endif /* Tokens. */ #define DIGIT 258 #define LETTER 259 #define UMINUS 260 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif extern YYSTYPE yylval; int yyparse (void); #endif /* !YY_YY_Y_TAB_H_INCLUDED */ #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #else typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ # define YY_(Msgid) Msgid # endif #endif #ifndef YY_ATTRIBUTE # if (defined __GNUC__ \ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C # define YY_ATTRIBUTE(Spec) __attribute__(Spec) # else # define YY_ATTRIBUTE(Spec) /* empty */ # endif #endif #ifndef YY_ATTRIBUTE_PURE # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) #endif #ifndef YY_ATTRIBUTE_UNUSED # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) #else # define YYUSE(E) /* empty */ #endif #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value #endif #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_END #endif #ifndef YY_INITIAL_VALUE # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's 'empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ while (0) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 65 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 17 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 5 /* YYNRULES -- Number of rules. */ #define YYNRULES 19 /* YYNSTATES -- Number of states. */ #define YYNSTATES 34 #define YYUNDEFTOK 2 #define YYMAXUTOK 260 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 13, 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, 11, 6, 2, 15, 16, 9, 7, 2, 8, 2, 10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 14, 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, 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, 5, 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, 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, 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, 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, 2, 2, 2, 1, 2, 3, 4, 12 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { 0, 14, 14, 16, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73, 78, 83, 85, 90 }; #endif #if YYDEBUG || YYERROR_VERBOSE || 0 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "DIGIT", "LETTER", "'|'", "'&'", "'+'", "'-'", "'*'", "'/'", "'%'", "UMINUS", "'\\n'", "'='", "'('", "')'", "$accept", "list", "stat", "expr", "number", YY_NULLPTR }; #endif # ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 124, 38, 43, 45, 42, 47, 37, 260, 10, 61, 40, 41 }; # endif #define YYPACT_NINF -9 #define yypact_value_is_default(Yystate) \ (!!((Yystate) == (-9))) #define YYTABLE_NINF -1 #define yytable_value_is_error(Yytable_value) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int8 yypact[] = { -9, 18, -9, -8, -9, -5, 20, 20, -3, 43, 4, -9, 20, -9, -9, 31, -9, 20, 20, 20, 20, 20, 20, 20, -9, 43, -9, 49, 54, -7, -7, -9, -9, -9 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 2, 0, 1, 0, 18, 16, 0, 0, 0, 5, 17, 4, 0, 16, 15, 0, 3, 0, 0, 0, 0, 0, 0, 0, 19, 6, 7, 14, 13, 11, 12, 8, 9, 10 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -9, -9, -9, -6, -9 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { -1, 1, 8, 9, 10 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_uint8 yytable[] = { 14, 15, 21, 22, 23, 11, 25, 24, 0, 12, 16, 27, 28, 29, 30, 31, 32, 33, 2, 3, 0, 4, 5, 4, 13, 0, 6, 0, 6, 0, 0, 0, 0, 7, 0, 7, 17, 18, 19, 20, 21, 22, 23, 0, 0, 0, 0, 26, 17, 18, 19, 20, 21, 22, 23, 18, 19, 20, 21, 22, 23, 19, 20, 21, 22, 23 }; static const yytype_int8 yycheck[] = { 6, 7, 9, 10, 11, 13, 12, 3, -1, 14, 13, 17, 18, 19, 20, 21, 22, 23, 0, 1, -1, 3, 4, 3, 4, -1, 8, -1, 8, -1, -1, -1, -1, 15, -1, 15, 5, 6, 7, 8, 9, 10, 11, -1, -1, -1, -1, 16, 5, 6, 7, 8, 9, 10, 11, 6, 7, 8, 9, 10, 11, 7, 8, 9, 10, 11 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 18, 0, 1, 3, 4, 8, 15, 19, 20, 21, 13, 14, 4, 20, 20, 13, 5, 6, 7, 8, 9, 10, 11, 3, 20, 16, 20, 20, 20, 20, 20, 20, 20 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 17, 18, 18, 18, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 0, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 2 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY) \ { \ yychar = (Token); \ yylval = (Value); \ YYPOPSTACK (yylen); \ yystate = *yyssp; \ goto yybackup; \ } \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (0) /* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) /* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) /*-----------------------------------. | Print this symbol's value on YYO. | `-----------------------------------*/ static void yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { FILE *yyoutput = yyo; YYUSE (yyoutput); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } /*---------------------------. | Print this symbol on YYO. | `---------------------------*/ static void yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { YYFPRINTF (yyo, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); yy_symbol_value_print (yyo, yytype, yyvaluep); YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { unsigned long yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], &yyvsp[(yyi + 1) - (yynrhs)] ); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyssp, yyvsp, Rule); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T yystrlen (const char *yystr) { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * yystpcpy (char *yydest, const char *yysrc) { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; else goto append; append: default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); } # endif /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message about the unexpected token YYTOKEN for the state stack whose top is YYSSP. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is not large enough to hold the message. In that case, also set *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per "expected"). */ int yycount = 0; /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". - Don't assume there isn't a lookahead just because this state is a consistent state with a default action. There might have been a previous inconsistent state, consistent state with a non-default action, or user semantic action that manipulated yychar. - Of course, the expected token list depends on states to have correct lookahead information, and it depends on the parser not to perform extra reductions after fetching a lookahead from the scanner and before detecting a syntax error. Thus, state merging (from LALR or IELR) and default reductions corrupt the expected token list. However, the list is correct for canonical LR with one exception: it will still contain any token that will not be accepted due to an error action in a later state. */ if (yytoken != YYEMPTY) { int yyn = yypact[*yyssp]; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. In other words, skip the first -YYN actions for this state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyx; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; break; } yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) yysize = yysize1; else return 2; } } } } switch (yycount) { # define YYCASE_(N, S) \ case N: \ yyformat = S; \ break default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); # undef YYCASE_ } { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) yysize = yysize1; else return 2; } if (*yymsg_alloc < yysize) { *yymsg_alloc = 2 * yysize; if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; return 1; } /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ { char *yyp = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyformat += 2; } else { yyp++; yyformat++; } } return 0; } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) { YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; /*----------. | yyparse. | `----------*/ int yyparse (void) { int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: 'yyss': related to states. 'yyvs': related to semantic values. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yyssp = yyss = yyssa; yyvsp = yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; /*------------------------------------------------------------. | yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; /*--------------------------------------------------------------------. | yynewstate -- set current state (the top of the stack) to yystate. | `--------------------------------------------------------------------*/ yysetstate: *yyssp = (yytype_int16) yystate; if (yyss + yystacksize - 1 <= yyssp) #if !defined yyoverflow && !defined YYSTACK_RELOCATE goto yyexhaustedlab; #else { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); # if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } # else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = yylex (); } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 4: #line 19 "calc.yacc" /* yacc.c:1652 */ { yyerrok; } #line 1232 "y.tab.c" /* yacc.c:1652 */ break; case 5: #line 24 "calc.yacc" /* yacc.c:1652 */ { printf("%d\n",yyvsp[0]); } #line 1240 "y.tab.c" /* yacc.c:1652 */ break; case 6: #line 29 "calc.yacc" /* yacc.c:1652 */ { regs[yyvsp[-2]] = yyvsp[0]; } #line 1248 "y.tab.c" /* yacc.c:1652 */ break; case 7: #line 34 "calc.yacc" /* yacc.c:1652 */ { yyval = yyvsp[-1]; } #line 1256 "y.tab.c" /* yacc.c:1652 */ break; case 8: #line 39 "calc.yacc" /* yacc.c:1652 */ { yyval = yyvsp[-2] * yyvsp[0]; } #line 1264 "y.tab.c" /* yacc.c:1652 */ break; case 9: #line 44 "calc.yacc" /* yacc.c:1652 */ { yyval = yyvsp[-2] / yyvsp[0]; } #line 1272 "y.tab.c" /* yacc.c:1652 */ break; case 10: #line 49 "calc.yacc" /* yacc.c:1652 */ { yyval = yyvsp[-2] % yyvsp[0]; } #line 1280 "y.tab.c" /* yacc.c:1652 */ break; case 11: #line 54 "calc.yacc" /* yacc.c:1652 */ { yyval = yyvsp[-2] + yyvsp[0]; } #line 1288 "y.tab.c" /* yacc.c:1652 */ break; case 12: #line 59 "calc.yacc" /* yacc.c:1652 */ { yyval = yyvsp[-2] - yyvsp[0]; } #line 1296 "y.tab.c" /* yacc.c:1652 */ break; case 13: #line 64 "calc.yacc" /* yacc.c:1652 */ { yyval = yyvsp[-2] & yyvsp[0]; } #line 1304 "y.tab.c" /* yacc.c:1652 */ break; case 14: #line 69 "calc.yacc" /* yacc.c:1652 */ { yyval = yyvsp[-2] | yyvsp[0]; } #line 1312 "y.tab.c" /* yacc.c:1652 */ break; case 15: #line 74 "calc.yacc" /* yacc.c:1652 */ { yyval = -yyvsp[0]; } #line 1320 "y.tab.c" /* yacc.c:1652 */ break; case 16: #line 79 "calc.yacc" /* yacc.c:1652 */ { yyval = regs[yyvsp[0]]; } #line 1328 "y.tab.c" /* yacc.c:1652 */ break; case 18: #line 86 "calc.yacc" /* yacc.c:1652 */ { yyval = yyvsp[0]; base = (yyvsp[0]==0) ? 8 : 10; } #line 1337 "y.tab.c" /* yacc.c:1652 */ break; case 19: #line 91 "calc.yacc" /* yacc.c:1652 */ { yyval = base * yyvsp[-1] + yyvsp[0]; } #line 1345 "y.tab.c" /* yacc.c:1652 */ break; #line 1349 "y.tab.c" /* yacc.c:1652 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ { const int yylhs = yyr1[yyn] - YYNTOKENS; const int yyi = yypgoto[yylhs] + *yyssp; yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp ? yytable[yyi] : yydefgoto[yylhs]); } goto yynewstate; /*--------------------------------------. | yyerrlab -- here on detecting error. | `--------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) { char const *yymsgp = YY_("syntax error"); int yysyntax_error_status; yysyntax_error_status = YYSYNTAX_ERROR; if (yysyntax_error_status == 0) yymsgp = yymsg; else if (yysyntax_error_status == 1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; yysyntax_error_status = 2; } else { yysyntax_error_status = YYSYNTAX_ERROR; yymsgp = yymsg; } } yyerror (yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } # undef YYSYNTAX_ERROR #endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (0) YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yydestruct ("Error: popping", yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif /*-----------------------------------------------------. | yyreturn -- parsing is finished, return the result. | `-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); } /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif return yyresult; } #line 95 "calc.yacc" /* yacc.c:1918 */ main() { return(yyparse()); } yyerror(s) char *s; { fprintf(stderr, "%s\n",s); } yywrap() { return(1); }
the_stack_data/5753.c
// pointer arithmetic on arrays int main() { int a[2], b, *p; a[0] = 0; a[1] = 1; if (a[0] > a[1]) { p = a; b = 0; } else { p = a + 1; b = 1; } b = p[0]; return b; }
the_stack_data/225440.c
#include <stdio.h> #include <stdbool.h> #include <pthread.h> typedef struct { pthread_mutex_t mutex; pthread_cond_t cond_producer; pthread_cond_t cond_consumer; bool can_produce; bool can_consume; int counter; } ctx_t; void init_ctx(ctx_t *ctx) { pthread_mutex_init(&ctx->mutex, NULL); pthread_cond_init(&ctx->cond_producer, NULL); pthread_cond_init(&ctx->cond_consumer, NULL); ctx->can_produce = true; ctx->can_consume = false; ctx->counter = 0; } void * producer(void *arg) { ctx_t *ctx = arg; for (;;) { pthread_mutex_lock(&ctx->mutex); while (!ctx->can_produce) pthread_cond_wait(&ctx->cond_producer, &ctx->mutex); ctx->counter++; ctx->can_consume = true; ctx->can_produce = false; pthread_cond_signal(&ctx->cond_consumer); pthread_mutex_unlock(&ctx->mutex); } return NULL; } void * consumer(void *arg) { ctx_t *ctx = arg; for (;;) { pthread_mutex_lock(&ctx->mutex); while (!ctx->can_consume) pthread_cond_wait(&ctx->cond_consumer, &ctx->mutex); printf("%d\n", ctx->counter); ctx->can_consume = false; ctx->can_produce = true; pthread_cond_signal(&ctx->cond_producer); pthread_mutex_unlock(&ctx->mutex); } return NULL; } int main(void) { pthread_t thread[2]; ctx_t ctx; init_ctx(&ctx); pthread_create(&thread[0], NULL, producer, &ctx); pthread_create(&thread[1], NULL, consumer, &ctx); pthread_join(thread[0], NULL); pthread_join(thread[1], NULL); return 0; }
the_stack_data/150139232.c
extern int foo(int *); void f(int *p) { if(foo(p)) *p = 1; }
the_stack_data/43490.c
// { dg-do run } // { dg-require-weak "" } // { dg-require-alias "" } // { dg-options "-O2 -fno-common" } // Copyright 2005 Free Software Foundation, Inc. // Contributed by Alexandre Oliva <[email protected]> // PR middle-end/24295 // The unit-at-a-time call graph code used to fail to emit variables // without external linkage that were only used indirectly, through // aliases. We might then get linker failures because the static // variable was not defined, or run-time errors because the weak alias // ended up pointing somewhere random. #include <stdlib.h> static unsigned long lv1 = 0xdeadbeefUL; #pragma weak Av1a = lv1 extern unsigned long Av1a; static unsigned long lf1(void) { return 0x510bea7UL; } #pragma weak Af1a = lf1 extern unsigned long Af1a(void); int main (void) { if (! &Av1a || ! &Af1a || Av1a != 0xdeadbeefUL || Af1a() != 0x510bea7UL) abort (); exit (0); }
the_stack_data/85518.c
#include <stdio.h> #include <unistd.h> // C/C++语言中提供对POSIX操作系统API的访问功能的头文件的名称 #include <fcntl.h> // 操作文件描述符, 使用man fcntl 查看手册用法: http://man7.org/linux/man-pages/man2/fcntl.2.html int main(int argc, char* argv[]) { int fd, wr_ret, rd_ret; char buf[] = "linux"; char read_buf[120] = {0}; fd = open("./a.c", O_RDWR | O_TRUNC); // 打开文件,如果有内容时删除 if (fd < 0) { printf("open file ./a.c failure\n"); return -1; } printf("open file ./a.c success, fd=%d\n", fd); wr_ret = write(fd, buf, sizeof(buf)); printf("wr_ret=%d\n", wr_ret); // 开始读 rd_ret = read(fd, read_buf, 128); // 此时是从写入的文件末尾开始读,所以没有内容,需要重新定位 printf("read_buf=%d\n", rd_ret); close(fd); return 0; }
the_stack_data/878533.c
/* explode a raw gif file already in any array of char. * return 0 if ok, else -1. * code from fit2gif.tar.gz, author unknown but thanks! */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #define RDSZ 4096 /* bytes per read attempt */ #define True 1 #define False 0 typedef unsigned char byte; typedef struct { byte *pic; /* image data */ int w, h; /* size */ byte r[256],g[256],b[256]; /* colormap */ } PICINFO; typedef int boolean; #define EXTENSION 0x21 #define IMAGESEP 0x2c #define TRAILER 0x3b #define INTERLACEMASK 0x40 #define COLORMAPMASK 0x80 static int BitOffset = 0, /* Bit Offset of next code */ XC = 0, YC = 0, /* Output X and Y coords of current pixel */ Pass = 0, /* Used by output routine if interlaced pic */ OutCount = 0, /* Decompressor output 'stack count' */ RWidth, RHeight, /* screen dimensions */ Width, Height, /* image dimensions */ LeftOfs, TopOfs, /* image offset */ BitsPerPixel, /* Bits per pixel, read from GIF header */ ColorMapSize, /* number of colors */ Background, /* background color */ CodeSize, /* Code size, read from GIF header */ InitCodeSize, /* Starting code size, used during Clear */ Code, /* Value returned by ReadCode */ MaxCode, /* limiting value for current code size */ ClearCode, /* GIF clear code */ EOFCode, /* GIF end-of-information code */ CurCode, OldCode, InCode, /* Decompressor variables */ FirstFree, /* First free code, generated per GIF spec */ FreeCode, /* Decompressor,next free slot in hash table */ FinChar, /* Decompressor variable */ BitMask, /* AND mask for data size */ ReadMask, /* Code AND mask for current code size */ Misc; /* miscellaneous bits (interlace, local cmap)*/ static boolean Interlace, HasColormap; static byte *RawGIF; /* The heap array to hold it, raw */ static byte *Raster; /* The raster data stream, unblocked */ static byte *pic8; /* The hash table used by the decompressor */ static int Prefix[4096]; static int Suffix[4096]; /* An output array used by the decompressor */ static int OutCode[4097]; static int gif89 = 0; static char *id87 = "GIF87a"; static char *id89 = "GIF89a"; static int EGApalette[16][3] = { {0,0,0}, {0,0,128}, {0,128,0}, {0,128,128}, {128,0,0}, {128,0,128}, {128,128,0}, {200,200,200}, {100,100,100}, {100,100,255}, {100,255,100}, {100,255,255}, {255,100,100}, {255,100,255}, {255,255,100}, {255,255,255} }; static int readImage(); static int ReadCode(); static void DoInterlace(); static int gifError(); static int filesize; static int numcols; static float normaspect; static byte dummy; static byte *dataptr; #define NEXTBYTE (dummy = *dataptr++) static char *g_errmsg; static int LoadGIF(); int explodeGIF (raw, nraw, wp, hp, pixap, ra, ga, ba, errmsg) unsigned char *raw; /* raw gif file */ int nraw; /* bytes ingif file */ int *wp, *hp; /* RETURN: image width/height */ unsigned char *pixap[]; /* RETURN: malloced w*h pixels, rgba indices */ unsigned char ra[], ga[], ba[]; /* RETURN: color map, 256 each */ char errmsg[]; /* excuse, if return -1 */ { PICINFO pi; dataptr = raw; filesize = nraw; g_errmsg = errmsg; if (LoadGIF (&pi) != 1) return (-1); *wp = pi.w; *hp = pi.h; *pixap = pi.pic; memcpy (ra, pi.r, 256); memcpy (ga, pi.g, 256); memcpy (ba, pi.b, 256); return (0); } /*****************************/ static int LoadGIF(pinfo) PICINFO *pinfo; /*****************************/ { /* returns '1' if successful */ register byte ch, *origptr; register int i, block; int aspect, gotimage; /* initialize variables */ BitOffset = XC = YC = Pass = OutCount = gotimage = 0; Raster = pic8 = NULL; gif89 = 0; pinfo->pic = (byte *) NULL; RawGIF = dataptr; /* the +256's are so we can read truncated GIF files without fear of segmentation violation */ if (!(Raster = (byte *) calloc(filesize+256,1))) return( gifError(pinfo, "not enough memory to read gif file") ); origptr = dataptr; if (strncmp((char *) dataptr, id87, 6)==0) gif89 = 0; else if (strncmp((char *) dataptr, id89, 6)==0) gif89 = 1; else return( gifError(pinfo, "not a GIF file")); dataptr += 6; /* Get variables from the GIF screen descriptor */ ch = NEXTBYTE; RWidth = ch + 0x100 * NEXTBYTE; /* screen dimensions... not used. */ ch = NEXTBYTE; RHeight = ch + 0x100 * NEXTBYTE; ch = NEXTBYTE; HasColormap = ((ch & COLORMAPMASK) ? True : False); BitsPerPixel = (ch & 7) + 1; numcols = ColorMapSize = 1 << BitsPerPixel; BitMask = ColorMapSize - 1; Background = NEXTBYTE; /* background color... not used. */ aspect = NEXTBYTE; if (aspect) { if (!gif89) return(gifError(pinfo,"corrupt GIF file (screen descriptor)")); else normaspect = (float)((aspect + 15) / 64.0); /* gif89 aspect ratio */ } /* Read in global colormap. */ if (HasColormap) { for (i=0; i<ColorMapSize; i++) { pinfo->r[i] = NEXTBYTE; pinfo->g[i] = NEXTBYTE; pinfo->b[i] = NEXTBYTE; } /* fill out with last color to avoid garbage clobbering xephem colormap. * from [email protected] */ for( ; i < 256; i++ ) { pinfo->r[i] = pinfo->r[ColorMapSize-1]; pinfo->g[i] = pinfo->g[ColorMapSize-1]; pinfo->b[i] = pinfo->b[ColorMapSize-1]; } } else { /* no colormap in GIF file */ /* put std EGA palette (repeated 16 times) into colormap, for lack of anything better to do */ for (i=0; i<256; i++) { pinfo->r[i] = EGApalette[i&15][0]; pinfo->g[i] = EGApalette[i&15][1]; pinfo->b[i] = EGApalette[i&15][2]; } } /* possible things at this point are: * an application extension block * a comment extension block * an (optional) graphic control extension block * followed by either an image * or a plaintext extension */ while (1) { block = NEXTBYTE; if (block == EXTENSION) { /* parse extension blocks */ int i, fn, blocksize, aspnum, aspden; /* read extension block */ fn = NEXTBYTE; if (fn == 'R') { /* GIF87 aspect extension */ int sbsize; blocksize = NEXTBYTE; if (blocksize == 2) { aspnum = NEXTBYTE; aspden = NEXTBYTE; if (aspden>0 && aspnum>0) normaspect = (float) aspnum / (float) aspden; else { normaspect = 1.0; aspnum = aspden = 1; } } else { for (i=0; i<blocksize; i++) NEXTBYTE; } while ((sbsize=NEXTBYTE)>0) { /* eat any following data subblocks */ for (i=0; i<sbsize; i++) NEXTBYTE; } } else if (fn == 0xFE) { /* Comment Extension */ int ch, j, sbsize, cmtlen; byte *ptr1; cmtlen = 0; ptr1 = dataptr; /* remember start of comments */ /* figure out length of comment */ do { sbsize = NEXTBYTE; cmtlen += sbsize; for (j=0; j<sbsize; j++) ch = NEXTBYTE; } while (sbsize); if (cmtlen>0) { do { sbsize = (*ptr1++); for (j=0; j<sbsize; j++, ptr1++) continue; } while (sbsize); } /* if cmtlen>0 */ } else if (fn == 0x01) { /* PlainText Extension */ int j,sbsize,ch; int tgLeft, tgTop, tgWidth, tgHeight, cWidth, cHeight, fg, bg; sbsize = NEXTBYTE; tgLeft = NEXTBYTE; tgLeft += (NEXTBYTE)<<8; tgTop = NEXTBYTE; tgTop += (NEXTBYTE)<<8; tgWidth = NEXTBYTE; tgWidth += (NEXTBYTE)<<8; tgHeight = NEXTBYTE; tgHeight += (NEXTBYTE)<<8; cWidth = NEXTBYTE; cHeight = NEXTBYTE; fg = NEXTBYTE; bg = NEXTBYTE; i=12; for ( ; i<sbsize; i++) NEXTBYTE; /* read rest of first subblock*/ /* read (and ignore) data sub-blocks */ do { j = 0; sbsize = NEXTBYTE; while (j<sbsize) { ch = NEXTBYTE; j++; } } while (sbsize); } else if (fn == 0xF9) { /* Graphic Control Extension */ int j, sbsize; /* read (and ignore) data sub-blocks */ do { j = 0; sbsize = NEXTBYTE; while (j<sbsize) { NEXTBYTE; j++; } } while (sbsize); } else if (fn == 0xFF) { /* Application Extension */ int j, sbsize; /* read (and ignore) data sub-blocks */ do { j = 0; sbsize = NEXTBYTE; while (j<sbsize) { NEXTBYTE; j++; } } while (sbsize); } else { /* unknown extension */ int j, sbsize; /* read (and ignore) data sub-blocks */ do { j = 0; sbsize = NEXTBYTE; while (j<sbsize) { NEXTBYTE; j++; } } while (sbsize); } } else if (block == IMAGESEP) { if (gotimage) { /* just skip over remaining images */ int i,misc,ch,ch1; /* skip image header */ NEXTBYTE; NEXTBYTE; /* left position */ NEXTBYTE; NEXTBYTE; /* top position */ NEXTBYTE; NEXTBYTE; /* width */ NEXTBYTE; NEXTBYTE; /* height */ misc = NEXTBYTE; /* misc. bits */ if (misc & 0x80) { /* image has local colormap. skip it */ for (i=0; i< 1 << ((misc&7)+1); i++) { NEXTBYTE; NEXTBYTE; NEXTBYTE; } } NEXTBYTE; /* minimum code size */ /* skip image data sub-blocks */ do { ch = ch1 = NEXTBYTE; while (ch--) NEXTBYTE; if ((dataptr - RawGIF) > filesize) break; /* EOF */ } while(ch1); } else if (readImage(pinfo)) gotimage = 1; } else if (block == TRAILER) { /* stop reading blocks */ break; } else { /* unknown block type */ char str[128]; /* don't mention bad block if file was trunc'd, as it's all bogus */ if ((dataptr - origptr) < filesize) { sprintf(str, "Unknown block type (0x%02x) at offset 0x%x", block, (unsigned int)(dataptr - origptr) - 1); if (!gotimage) return gifError(pinfo, str); else return( gifError(pinfo, str)); } break; } } free(Raster); Raster = NULL; if (!gotimage) return( gifError(pinfo, "no image data found in GIF file") ); return 1; } /********************************************/ static int readImage(pinfo) PICINFO *pinfo; { register byte ch, ch1, *ptr1, *picptr; int i, npixels, maxpixels; npixels = maxpixels = 0; /* read in values from the image descriptor */ ch = NEXTBYTE; LeftOfs = ch + 0x100 * NEXTBYTE; ch = NEXTBYTE; TopOfs = ch + 0x100 * NEXTBYTE; ch = NEXTBYTE; Width = ch + 0x100 * NEXTBYTE; ch = NEXTBYTE; Height = ch + 0x100 * NEXTBYTE; Misc = NEXTBYTE; Interlace = ((Misc & INTERLACEMASK) ? True : False); if (Misc & 0x80) { for (i=0; i< 1 << ((Misc&7)+1); i++) { pinfo->r[i] = NEXTBYTE; pinfo->g[i] = NEXTBYTE; pinfo->b[i] = NEXTBYTE; } } if (!HasColormap && !(Misc&0x80)) { /* no global or local colormap */ return (gifError (pinfo, "No colormap in this GIF file.")); } /* Start reading the raster data. First we get the intial code size * and compute decompressor constant values, based on this code size. */ CodeSize = NEXTBYTE; ClearCode = (1 << CodeSize); EOFCode = ClearCode + 1; FreeCode = FirstFree = ClearCode + 2; /* The GIF spec has it that the code size is the code size used to * compute the above values is the code size given in the file, but the * code size used in compression/decompression is the code size given in * the file plus one. (thus the ++). */ CodeSize++; InitCodeSize = CodeSize; MaxCode = (1 << CodeSize); ReadMask = MaxCode - 1; /* UNBLOCK: * Read the raster data. Here we just transpose it from the GIF array * to the Raster array, turning it from a series of blocks into one long * data stream, which makes life much easier for ReadCode(). */ ptr1 = Raster; do { ch = ch1 = NEXTBYTE; while (ch--) { *ptr1 = NEXTBYTE; ptr1++; } if ((dataptr - RawGIF) > filesize) { break; } } while(ch1); /* Allocate the 'pic' */ maxpixels = Width*Height; picptr = pic8 = (byte *) malloc(maxpixels); if (!pic8) return( gifError(pinfo, "couldn't malloc 'pic8'") ); /* Decompress the file, continuing until you see the GIF EOF code. * One obvious enhancement is to add checking for corrupt files here. */ Code = ReadCode(); while (Code != EOFCode) { /* Clear code sets everything back to its initial value, then reads the * immediately subsequent code as uncompressed data. */ if (Code == ClearCode) { CodeSize = InitCodeSize; MaxCode = (1 << CodeSize); ReadMask = MaxCode - 1; FreeCode = FirstFree; Code = ReadCode(); CurCode = OldCode = Code; FinChar = CurCode & BitMask; if (!Interlace) *picptr++ = FinChar; else DoInterlace(FinChar); npixels++; } else { /* If not a clear code, must be data: save same as CurCode and InCode */ /* if we're at maxcode and didn't get a clear, stop loading */ if (FreeCode>=4096) { /* printf("freecode blew up\n"); */ break; } CurCode = InCode = Code; /* If greater or equal to FreeCode, not in the hash table yet; * repeat the last character decoded */ if (CurCode >= FreeCode) { CurCode = OldCode; if (OutCount > 4096) { /* printf("outcount1 blew up\n"); */ break; } OutCode[OutCount++] = FinChar; } /* Unless this code is raw data, pursue the chain pointed to by CurCode * through the hash table to its end; each code in the chain puts its * associated output code on the output queue. */ while (CurCode > BitMask) { if (OutCount > 4096) break; /* corrupt file */ OutCode[OutCount++] = Suffix[CurCode]; CurCode = Prefix[CurCode]; } if (OutCount > 4096) { /* printf("outcount blew up\n"); */ break; } /* The last code in the chain is treated as raw data. */ FinChar = CurCode & BitMask; OutCode[OutCount++] = FinChar; /* Now we put the data out to the Output routine. * It's been stacked LIFO, so deal with it that way... */ /* safety thing: prevent exceeding range of 'pic8' */ if (npixels + OutCount > maxpixels) OutCount = maxpixels-npixels; npixels += OutCount; if (!Interlace) for (i=OutCount-1; i>=0; i--) *picptr++ = OutCode[i]; else for (i=OutCount-1; i>=0; i--) DoInterlace(OutCode[i]); OutCount = 0; /* Build the hash table on-the-fly. No table is stored in the file. */ Prefix[FreeCode] = OldCode; Suffix[FreeCode] = FinChar; OldCode = InCode; /* Point to the next slot in the table. If we exceed the current * MaxCode value, increment the code size unless it's already 12. If it * is, do nothing: the next code decompressed better be CLEAR */ FreeCode++; if (FreeCode >= MaxCode) { if (CodeSize < 12) { CodeSize++; MaxCode *= 2; ReadMask = (1 << CodeSize) - 1; } } } Code = ReadCode(); if (npixels >= maxpixels) break; } if (npixels != maxpixels) { if (!Interlace) memset(pic8+npixels, 0, maxpixels-npixels); /* clear to EOBuffer */ } /* fill in the PICINFO structure */ pinfo->pic = pic8; pinfo->w = Width; pinfo->h = Height; return 1; } /* Fetch the next code from the raster data stream. The codes can be * any length from 3 to 12 bits, packed into 8-bit bytes, so we have to * maintain our location in the Raster array as a BIT Offset. We compute * the byte Offset into the raster array by dividing this by 8, pick up * three bytes, compute the bit Offset into our 24-bit chunk, shift to * bring the desired code to the bottom, then mask it off and return it. */ static int ReadCode() { int RawCode, ByteOffset; ByteOffset = BitOffset / 8; RawCode = Raster[ByteOffset] + (Raster[ByteOffset + 1] << 8); if (CodeSize >= 8) RawCode += ( ((int) Raster[ByteOffset + 2]) << 16); RawCode >>= (BitOffset % 8); BitOffset += CodeSize; return(RawCode & ReadMask); } /***************************/ static void DoInterlace(Index) byte Index; { static byte *ptr = NULL; static int oldYC = -1; if (oldYC != YC) { ptr = pic8 + YC * Width; oldYC = YC; } if (YC<Height) *ptr++ = Index; /* Update the X-coordinate, and if it overflows, update the Y-coordinate */ if (++XC == Width) { /* deal with the interlace as described in the GIF * spec. Put the decoded scan line out to the screen if we haven't gone * past the bottom of it */ XC = 0; switch (Pass) { case 0: YC += 8; if (YC >= Height) { Pass++; YC = 4; } break; case 1: YC += 8; if (YC >= Height) { Pass++; YC = 2; } break; case 2: YC += 4; if (YC >= Height) { Pass++; YC = 1; } break; case 3: YC += 2; break; default: break; } } } /*****************************/ static int gifError(pinfo, st) PICINFO *pinfo; char *st; { strcpy (g_errmsg, st); if (Raster != NULL) free(Raster); if (pinfo->pic) free(pinfo->pic); if (pic8 && pic8 != pinfo->pic) free(pic8); pinfo->pic = (byte *) NULL; return 0; } /* For RCS Only -- Do Not Edit */ static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: explodegif.c,v $ $Date: 2009/01/05 20:55:16 $ $Revision: 1.3 $ $Name: $"};
the_stack_data/165767173.c
#include <stdio.h> #include <math.h> void start_slice(){ __asm__ __volatile__ (""); } void end_slice(){ __asm__ __volatile__ (""); } int main() { start_slice(); volatile double x,y; x = 1e16; y = sqrt(x + 1) - sqrt(x); printf("%e\n", y); end_slice(); return 0; }
the_stack_data/117327444.c
#include <stdio.h> #include <stdlib.h> // sert pour les fonctions srand et rand #include <time.h> int main() { int nb, x; srand (time (NULL)); nb = rand() % 100; printf("Entrez un nombre : "); scanf("%d", &x); while(x != nb) { if(x > nb) { printf("<"); scanf("%d", &x); } else if(x < nb) { printf(">"); scanf("%d", &x); } else { break; } } return 0; }
the_stack_data/84690.c
#include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> int main(int ac, char** av) { for (int i = 0; i < 100000; i++) { int fd = open(av[1], O_RDONLY); char buf[4096]; if (fd >= 0) read(fd, buf, sizeof(buf)); if (fd >= 0) close(fd); } }
the_stack_data/42718.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <termios.h> #include <stdbool.h> #include <time.h> #include <termios.h> #include <unistd.h> #include <fcntl.h> #define MAX_TIME 3 * 1000 static struct termios initial_settings, new_settings; static int peek_character = -1; void init_keyboard() { tcgetattr(0,&initial_settings); new_settings = initial_settings; new_settings.c_lflag &= ~ICANON; new_settings.c_lflag &= ~ECHO; new_settings.c_cc[VMIN] = 1; new_settings.c_cc[VTIME] = 0; tcsetattr(0, TCSANOW, &new_settings); } void close_keyboard(){ tcsetattr(0, TCSANOW, &initial_settings); } int _kbhit() { unsigned char ch; int nread; if (peek_character != -1) return 1; new_settings.c_cc[VMIN]=0; tcsetattr(0, TCSANOW, &new_settings); nread = read(0,&ch,1); new_settings.c_cc[VMIN]=1; tcsetattr(0, TCSANOW, &new_settings); if(nread == 1) { peek_character = ch; return 1; } return 0; } int _getch() { char ch; if(peek_character != -1) { ch = peek_character; peek_character = -1; return ch; } read(0,&ch,1); return ch; } void setBufferedInput(bool enable) { static bool enabled = true; static struct termios old; struct termios new; if (enable && !enabled) { // restore the former settings tcsetattr(STDIN_FILENO,TCSANOW,&old); // set the new state enabled = true; } else if (!enable && enabled) { // get the terminal settings for standard input tcgetattr(STDIN_FILENO,&new); // we want to keep the old setting to restore them at the end old = new; // disable canonical mode (buffered i/o) and local echo new.c_lflag &=(~ICANON & ~ECHO); // set the new settings immediately tcsetattr(STDIN_FILENO,TCSANOW,&new); // set the new state enabled = false; } } //보드 그리기 - 2차원 배열 int drawBoard(int board[5][5], double msec){ int x,y; int score = 0; for (x=0; x<5; x++) { for (y=0; y<5; y++) { score += board[x][y]; } } printf("\033[H"); int t_min = msec / (60 * 1000); int t_sec = (msec - t_min*60*1000) / 1000; printf("[REMAIN TIME] %02d:%02d \n", t_min, t_sec); printf("[SCORE] %d\n\n", score); for (x=0;x<5;x++) { for (y=0;y<5;y++) { printf("%5d", board[x][y]); } printf("\n"); printf("\n"); } printf("\033[A"); return score; } //버튼 누를 때마다 랜덤으로 2만들어주기 위해서 void add2Randomly(int board[5][5]){ int x,y; int r,num=0; // uint8_t n; int candilist[25][2]; //2 또는 4가 들어갈 수 있는 칸(현재 0인) 의 후보 리스트. srand(time(NULL)); for (x=0;x<5;x++) { for (y=0;y<5;y++) { if (board[x][y]==0) { candilist[num][0] = x; candilist[num][1] = y; num++; } } } if (num>0) { r = rand()%num; x = candilist[r][0]; y = candilist[r][1]; //랜덤으로 뽑기 // 빈칸에 랜덤으로 2, 4 나오게 하기 int random = rand() % 2; if (random == 0){ board[x][y] = 2; //2 넣어주기 } else{ board[x][y] = 4; //4 넣어주기 } } } void initBoard(int board[5][5], double msec) { int x,y; for (x=0;x<5;x++) { for (y=0;y<5;y++) { board[x][y] = 0; } } //보드 초기화 - 모두 0넣기 add2Randomly(board); // 게임 시작이니까 2 또는 4 두개 랜덤으로 들어감 add2Randomly(board); drawBoard(board, msec); } bool gameOver(int board[5][5]) { bool over = true; int x,y; //0인 칸이 남아있으면 not over for (x=0;x<5;x++) { for (y=0;y<5;y++) { if (board[x][y]==0){ over = false; break; break; } } } //좌우 같은 애 있으면 꽉 차 있어도 not over for (x=0;x<4;x++) { for (y=0;y<5;y++) { if (board[x][y]==board[x+1][y]){ over = false; break; break; } } } //상하 같은 애 있으면 꽉 차 있어도 not over for (x=0;x<5;x++) { for (y=0;y<4;y++) { if (board[x][y]==board[x][y+1]){ over = false; break; break; } } } return over; } bool gameClear(int board[5][5]) { int x, y; for (x=0; x<5; x++) { for (y=0; y<5; y++) { if (board[x][y] >= 2048) { return true; } } } return false; } void ranking(bool clear, int score, double msec, int move_count, int max_combo) { setBufferedInput(true); char name[100] = {0,}; char c; printf("Enter Your Name : "); fflush(stdin); for (int i=0; i<100; i++) { c = getchar(); putchar(c); if (c == '\n') { break; } name[i] = c; } char result[20]; if (clear) { strcpy(result, "Success"); } else { strcpy(result, "Failure"); } int elapsed_time = MAX_TIME - (int) msec; int t_min = elapsed_time / (60 * 1000); int t_sec = (elapsed_time - t_min*60*1000) / 1000; FILE *fp; fp = fopen("game_result.txt", "a"); fseek(fp, 0L, SEEK_END); long size = ftell(fp); fseek(fp, 0L, SEEK_SET); if (size == 0) { fprintf(fp, "Name,Result,SCORE,Elapsed_Time,Move_Count,Max_Combo\n"); } fclose(fp); fp = fopen("game_result.txt", "a"); fprintf(fp, "%s,%s,%d,%d,%d,%d\n", name, result, score, elapsed_time, move_count, max_combo); fclose(fp); } void rotate(int board[5][5]) { //시계 방향으로 돌리기 int tmp[5][5]; int x,y; for (x=0;x<5;x++) { for (y=0;y<5;y++) { tmp[x][y] = board[4-y][x]; //임시 어레이에 넣어놓고 } } for (x=0;x<5;x++) { for (y=0;y<5;y++) { board[x][y] = tmp[x][y]; //다시 board에 붙여넣기 } } } int moveUp(int board[5][5]) { int tmp[5][5]; //임시보드 만들어서 값 옮겨넣기 int x,y; int target = 0; int done=0; int merge = 0; for (y=0;y<5;y++) { int target = -1; //임시보드의 0 index부터 채워넣기 int done=0; //매번 초기화 for (x=0;x<5;x++) { if (board[x][y] == 0) { continue; //0이면 임시보드에 넣지 않음 } else if (done==1 && (board[x][y] == tmp[target][y])) { // 새로 넣으려는 수가 아까 넣은 수랑 같으면 그 칸 두배 // done 초기화(또 2배되지 않게 하려고) tmp[target][y] *= 2; done=0; merge = 1; } else { tmp[++target][y]=board[x][y]; done = 1; //어떤 수 있으면 target +1 해서 그 자리에 넣기 } for (int i=target+1; i<5; i++){ tmp[i][y] = 0; //나머지 칸들은 0으로 채워 } } } for (x=0; x<5; x++) { for (y=0; y<5; y++) { board[x][y] = tmp[x][y]; //board에 붙여넣기 } } return merge; } int moveLeft(int board[5][5]) { int merge; rotate(board); merge = moveUp(board); rotate(board); rotate(board); rotate(board); //rotate 이용해서 moveUp함수 그대로 쓰기 return merge; } int moveRight(int board[5][5]) { int merge; rotate(board); rotate(board); rotate(board); merge = moveUp(board); rotate(board); return merge; } int moveDown(int board[5][5]) { int merge; rotate(board); rotate(board); merge = moveUp(board); rotate(board); rotate(board); return merge; } int moveup(int board[5][5]) { int merge; rotate(board); rotate(board); merge = moveDown(board); rotate(board); rotate(board); return merge; } //moveUp함수 그대로 쓰면 에러가 나서 moveDown써서 "moveup"으로 새로 만들었습니다. int main( ) { int choice; int board[5][5]; char c; bool moved; int score; int move_count = 0; int merge = 0; int sum_combo = 0; int max_combo = 0; double msec; while (true) { printf("\nMain Menu\n1. Game Start 2. How to 3. Ranking 4. Exit\nPlease Enter an integer : "); scanf("%d", &choice); if (choice < 1 || choice > 4) { printf("Wrong Input.\n"); } else if (choice == 1) { init_keyboard(); msec = MAX_TIME; printf("\033[?25l\033[2J"); // signal(SIGINT, signal_callback_handler); initBoard(board, msec); //제일 처음에 보드초기화 setBufferedInput(false); while (true) { if (_kbhit()) { // 어떠한 키가 눌리면 진입 int c = _getch(); switch(c) { case 97: // 'a' key moved = true; merge = moveLeft(board); break; case 100: // 'd' key moved = true; merge = moveRight(board); break; case 119: // 'w' key moved = true; merge = moveup(board); break; case 115: // 's' key moved = true; merge = moveDown(board); break; default: moved = false; } if (moved == true) { move_count += 1; if (merge) { sum_combo += 1; if (max_combo < sum_combo) { max_combo = sum_combo; } } else { sum_combo = 1; } score = drawBoard(board, msec); add2Randomly(board); score = drawBoard(board, msec); if (gameOver(board)) { printf("\nGAME OVER\n\n"); ranking(false, score, msec, move_count, max_combo); break; } if (gameClear(board)) { printf("\nGAME CLEAR\n\n"); ranking(true, score, msec, move_count, max_combo); break; } } } usleep(10000); // sleep 10 ms score = drawBoard(board, msec); msec = msec - 10; // 10 ms 차감 // Time OUT if (msec < 0) { printf("\nGAME OVER\n\n"); ranking(false, score, msec, move_count, max_combo); break; } } setBufferedInput(true); printf("\033[?25h\033[m"); close_keyboard(); } else if (choice == 2) { // how to printf("\n< How to Play >\n"); printf("1. Use your ‘a’, ‘w’, ‘d’, ’s’ to move the tiles. \n2. If the number is same as the one touched, they merge into one. \n3. Add them up to reach 2048 within time limit! \n"); } else if (choice == 3) { // If the result file exists if (access("game_result.txt", F_OK) == 0) { struct data { char name[100]; char result[20]; int score; int elapsed_time; int move_count; int max_combo; }; struct data data_list[1000]; struct data data_temp; int first = 1; int i = 0; char temp[1000] = {0,}; char *elt; FILE *fp = fopen("game_result.txt", "r"); while (fscanf(fp, "%s", temp) != EOF) { if (!first) { elt = strtok(temp, ","); strcpy(data_list[i].name, elt); elt = strtok(NULL, ","); strcpy(data_list[i].result, elt); elt = strtok(NULL, ","); data_list[i].score = atoi(elt); elt = strtok(NULL, ","); data_list[i].elapsed_time = atoi(elt); elt = strtok(NULL, ","); data_list[i].move_count = atoi(elt); elt = strtok(NULL, ","); data_list[i].max_combo = atoi(elt); i += 1; } first = 0; } int num_row = i; fclose(fp); for (i=0; i<num_row-1; i++) { for (int j = i+1; j<num_row; j++){ if (data_list[i].score < data_list[j].score){ data_temp = data_list[i]; data_list[i] = data_list[j]; data_list[j] = data_temp; } } } printf("\n<Ranking> (Sorted by SCORE)\n"); for (i=0; i<num_row; i++) { printf("Name : %s, Result : %s, Score : %d, ", data_list[i].name, data_list[i].result, data_list[i].score); printf("Elapsed Time : %d, Move Count : %d, Max Combo : %d\n", data_list[i].elapsed_time, data_list[i].move_count, data_list[i].max_combo); } } // If the result file does not exist else { printf("No Data\n"); } } else { printf("Bye~\n"); break; } } }
the_stack_data/103265284.c
#include <stdlib.h> #include <string.h> void reverse(char *arr, int first, int last) { for (; first < last; ++first, --last) { char tmp = arr[first]; arr[first] = arr[last]; arr[last] = tmp; } } char *shortestPalindrome(char *s) { int N = strlen(s); char pattern[2 * N + 2]; strcpy(pattern, s); pattern[N] = '#'; strcpy(&pattern[N + 1], s); reverse(pattern, N + 1, 2 * N); int next[2 * N + 1]; next[0] = 0; for (int i = 1, j = 0; i <= 2 * N; ++i) { while (j > 0 && pattern[i] != pattern[j]) j = next[j - 1]; if (pattern[i] == pattern[j]) ++j; next[i] = j; } strncpy(pattern, &pattern[N + 1], N - next[2 * N]); strcpy(&pattern[N - next[2 * N]], s); return strdup(pattern); }
the_stack_data/247017120.c
/** * @file main.c * @brief クロスコンパイル動作確認用のサンプルコード */ #include <stdio.h> /** * @brief メイン関数 * @param[in] argc 引数の数 * @param[in] argv 引数 * @return int 0固定 * @details クロスコンパイル動作確認用のサンプル */ int main(int argc, char* argv[]) { printf("Cross Compile has been succeeded!!\n"); return 0; }
the_stack_data/19751.c
#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *link; }*head = NULL; struct node* createNode() { struct node *temp; temp = malloc(sizeof(struct node)); if(temp != NULL) { int item; printf("Enter item: "); scanf("%d", &item); temp->data = item; temp->link = NULL; } return temp; } void insertAtBeginning() { struct node *temp; temp = createNode(); if(temp == NULL) { printf("Memory Undeflow - No insertion"); exit(1); } else { if(head == NULL) head = temp; else { temp->link = head; head = temp; } } } void insertAtEnd() { struct node *temp; temp = createNode(); if(temp == NULL) { printf("Memory Undeflow - No insertion"); exit(1); } else { if(head == NULL) head = temp; else { struct node *p; p = head; while(p->link != NULL) p = p->link; p->link = temp; } } } void insertAtSpecific() { struct node *temp; temp = createNode(); if(temp == NULL) { printf("Memory Undeflow - No insertion\n"); exit(1); } else { int key; printf("Enter key: "); scanf("%d", &key); if(head == NULL) printf("Key not found - No insertion\n"); else { struct node *p; p = head; while(p->data != key && p->link != NULL) p = p->link; if(p->data == key) { temp->link = p->link; p->link = temp; } else printf("Key not found - No insertion"); } } } void deleteAtBeginning() { if(head == NULL) printf("Empty list.\n"); else { struct node *p; head = head->link; free(p); } } void deleteAtEnd() { if(head == NULL) printf("Empty list.\n"); else if (head->link == NULL) { struct node *ptr; ptr = head; head = NULL; free(ptr); } else { struct node *ptr, *prev; prev = head; ptr = head->link; while(ptr->link != NULL) { prev = prev->link; ptr = ptr->link; } prev->link = NULL; free(ptr); } } void deleteAtSpecific() { int key; printf("Enter key: "); scanf("%d", &key); if(head == NULL) printf("Empty list.\n"); else if (head->data == key) { struct node *ptr; ptr = head; head = head->link; free(ptr); } else { struct node *ptr, *prev; prev = head; ptr = head->link; while(ptr->link != NULL && ptr->data != key) { prev = prev->link; ptr = ptr->link; } if(ptr->data != key) { printf("Key not found.\n"); } else { prev->link = ptr->link; free(ptr); } } } void displayList() { if(head == NULL) printf("Empty List.\n"); else { struct node* p; p = head; printf("List: \n"); while(p!= NULL) { printf("%d\n", p->data); p = p->link; } } } void main() { int opt; while(1) { printf("Menu\n1. Insertion at Beginning\n2. Insertion at End\n3. Insertion at Specific\n"); printf("4. Deletion at Beginning\n5. Deletion at End\n6. Deletion at Specific\n"); printf("Enter your choice: "); scanf("%d", &opt); switch(opt) { case 1: insertAtBeginning(); break; case 2: insertAtEnd(); break; case 3: insertAtSpecific(); break; case 4: deleteAtBeginning(); break; case 5: deleteAtEnd(); break; case 6: deleteAtSpecific(); break; default: exit(1); } displayList(); } }
the_stack_data/91855.c
#include <stdio.h> void funzione_1(); char funzione_2(); int somma(int a, int b); void stampa_array(int array[], int dim); int G; //varaibile globale int i; int main () { int A, R, i; char C; int *p; funzione_1(); C = funzione_2(); R = somma(5, 6); printf(" %d ",R); int numeri[] = {1,2,3}; //stampa vettore stampa_array(numeri, 3); printf("\n\n"); return 0; } void funzione_1() { printf("A"); } char funzione_2() { char K = 'p'; funzione_1(); printf("B"); return K; } int somma (int a, int b) { int sum; sum = a + b; return sum; } void stampa_array(int array[], int dim) { int i = 0; for (i=0; i<dim; i++) { printf(" %d ", array[i]); } }
the_stack_data/110168.c
/*! * @file main.c * @brief 06. Funciones - Argumentos por Valor - 04. Variables globales (al módulo) * @author Javier Balloffet <[email protected]> * @date Sep 7, 2018 */ #include <stdio.h> // Declaro la variable "number" como global (al módulo main.c). static int number = 1; void increment(); int main() { // Invoco a "increment" y muestro el valor de "number" antes y después de llamar a la función. printf("Valor de \"number\" en main() antes de incrementar = %d\n", number); increment(); printf("Valor de \"number\" en main() despues de incrementar = %d\n", number); return 0; } void increment() { // Muestro el valor de "number" antes y después de incrementar. printf("Valor de \"number\" en increment() antes de incrementar = %d\n", number); number++; printf("Valor de \"number\" en increment() despues de incrementar = %d\n", number); }
the_stack_data/697967.c
/* * Copyright (c) 2013 Jan-Piet Mens <[email protected]> wendal * <wendal1985()gmai.com> All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. 2. Redistributions * in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. 3. Neither the name of mosquitto * nor the names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifdef BE_JWT #include "backends.h" #include "be-jwt.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include "hash.h" #include "log.h" #include "envs.h" #include <curl/curl.h> static int get_string_envs(CURL * curl, const char *required_env, char *querystring) { char *data = NULL; char *escaped_key = NULL; char *escaped_val = NULL; char *env_string = NULL; char *params_key[MAXPARAMSNUM]; char *env_names[MAXPARAMSNUM]; char *env_value[MAXPARAMSNUM]; int i, num = 0; //_log(LOG_DEBUG, "sys_envs=%s", sys_envs); env_string = (char *)malloc(strlen(required_env) + 20); if (env_string == NULL) { _fatal("ENOMEM"); return (-1); } sprintf(env_string, "%s", required_env); //_log(LOG_DEBUG, "env_string=%s", env_string); num = get_sys_envs(env_string, ",", "=", params_key, env_names, env_value); //sprintf(querystring, ""); for (i = 0; i < num; i++) { escaped_key = curl_easy_escape(curl, params_key[i], 0); escaped_val = curl_easy_escape(curl, env_value[i], 0); //_log(LOG_DEBUG, "key=%s", params_key[i]); //_log(LOG_DEBUG, "escaped_key=%s", escaped_key); //_log(LOG_DEBUG, "escaped_val=%s", escaped_envvalue); data = (char *)malloc(strlen(escaped_key) + strlen(escaped_val) + 1); if (data == NULL) { _fatal("ENOMEM"); return (-1); } sprintf(data, "%s=%s&", escaped_key, escaped_val); if (i == 0) { sprintf(querystring, "%s", data); } else { strcat(querystring, data); } } if (data) free(data); if (escaped_key) free(escaped_key); if (escaped_val) free(escaped_val); free(env_string); return (num); } static int http_post(void *handle, char *uri, const char *clientid, const char *token, const char *topic, int acc, int method) { struct jwt_backend *conf = (struct jwt_backend *)handle; CURL *curl; struct curl_slist *headerlist = NULL; int re; int respCode = 0; int ok = BACKEND_DEFER; char url[BUFSIZ]; char *data; if (token == NULL) { return BACKEND_DEFER; } clientid = (clientid && *clientid) ? clientid : ""; topic = (topic && *topic) ? topic : ""; if ((curl = curl_easy_init()) == NULL) { _fatal("create curl_easy_handle fails"); return BACKEND_ERROR; } if (conf->hostheader != NULL) headerlist = curl_slist_append(headerlist, conf->hostheader); headerlist = curl_slist_append(headerlist, "Expect:"); //_log(LOG_NOTICE, "u=%s p=%s t=%s acc=%d", username, password, topic, acc); // uri begins with a slash snprintf(url, sizeof(url), "%s://%s:%d%s", strcmp(conf->with_tls, "true") == 0 ? "https" : "http", conf->hostname ? conf->hostname : conf->ip, conf->port, uri); char *escaped_token = curl_easy_escape(curl, token, 0); char *escaped_topic = curl_easy_escape(curl, topic, 0); char *escaped_clientid = curl_easy_escape(curl, clientid, 0); char string_acc[20]; snprintf(string_acc, 20, "%d", acc); char *string_envs = (char *)malloc(MAXPARAMSLEN); if (string_envs == NULL) { _fatal("ENOMEM"); return BACKEND_ERROR; } memset(string_envs, 0, MAXPARAMSLEN); //get the sys_env from here int env_num = 0; if (method == METHOD_GETUSER && conf->getuser_envs != NULL) { env_num = get_string_envs(curl, conf->getuser_envs, string_envs); } else if (method == METHOD_SUPERUSER && conf->superuser_envs != NULL) { env_num = get_string_envs(curl, conf->superuser_envs, string_envs); } else if (method == METHOD_ACLCHECK && conf->aclcheck_envs != NULL) { env_num = get_string_envs(curl, conf->aclcheck_envs, string_envs); } if (env_num == -1) { return BACKEND_ERROR; } //----over-- -- data = (char *)malloc(strlen(string_envs) + strlen(escaped_topic) + strlen(string_acc) + strlen(escaped_clientid) + 30); if (data == NULL) { _fatal("ENOMEM"); return BACKEND_ERROR; } sprintf(data, "%stopic=%s&acc=%s&clientid=%s", string_envs, escaped_topic, string_acc, clientid); _log(LOG_DEBUG, "url=%s", url); _log(LOG_DEBUG, "data=%s", data); //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); char *token_header = (char *)malloc(strlen(escaped_token) + strlen("Authorization: Bearer ") + 1); if (token_header == NULL) { _fatal("ENOMEM"); return BACKEND_ERROR; } sprintf(token_header, "Authorization: Bearer %s", escaped_token); headerlist = curl_slist_append(headerlist, token_header); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_POST, 1L); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); re = curl_easy_perform(curl); if (re == CURLE_OK) { re = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &respCode); if (re == CURLE_OK && respCode >= 200 && respCode < 300) { ok = BACKEND_ALLOW; } else if (re == CURLE_OK && respCode >= 500) { ok = BACKEND_ERROR; } else { //_log(LOG_NOTICE, "http auth fail re=%d respCode=%d", re, respCode); } } else { _log(LOG_DEBUG, "http req fail url=%s re=%s", url, curl_easy_strerror(re)); ok = BACKEND_ERROR; } curl_easy_cleanup(curl); curl_slist_free_all(headerlist); free(data); free(string_envs); free(escaped_token); free(token_header); free(escaped_topic); free(escaped_clientid); return (ok); } void *be_jwt_init() { struct jwt_backend *conf; char *ip; char *getuser_uri; char *superuser_uri; char *aclcheck_uri; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { _fatal("init curl fail"); return (NULL); } if ((ip = p_stab("http_ip")) == NULL) { _fatal("Mandatory parameter `http_ip' missing"); return (NULL); } if ((getuser_uri = p_stab("http_getuser_uri")) == NULL) { _fatal("Mandatory parameter `http_getuser_uri' missing"); return (NULL); } if ((superuser_uri = p_stab("http_superuser_uri")) == NULL) { _fatal("Mandatory parameter `http_superuser_uri' missing"); return (NULL); } if ((aclcheck_uri = p_stab("http_aclcheck_uri")) == NULL) { _fatal("Mandatory parameter `http_aclcheck_uri' missing"); return (NULL); } conf = (struct jwt_backend *)malloc(sizeof(struct jwt_backend)); conf->ip = ip; conf->hostname = NULL; conf->hostheader = NULL; conf->port = p_stab("http_port") == NULL ? 80 : atoi(p_stab("http_port")); if (p_stab("http_hostname") != NULL) { conf->hostheader = (char *)malloc(128); conf->hostname = p_stab("http_hostname"); sprintf(conf->hostheader, "Host: %s", p_stab("http_hostname")); } conf->getuser_uri = getuser_uri; conf->superuser_uri = superuser_uri; conf->aclcheck_uri = aclcheck_uri; conf->getuser_envs = p_stab("http_getuser_params"); conf->superuser_envs = p_stab("http_superuser_params"); conf->aclcheck_envs = p_stab("http_aclcheck_params"); if (p_stab("http_with_tls") != NULL) { conf->with_tls = p_stab("http_with_tls"); } else { conf->with_tls = "false"; } _log(LOG_DEBUG, "with_tls=%s", conf->with_tls); _log(LOG_DEBUG, "getuser_uri=%s", getuser_uri); _log(LOG_DEBUG, "superuser_uri=%s", superuser_uri); _log(LOG_DEBUG, "aclcheck_uri=%s", aclcheck_uri); _log(LOG_DEBUG, "getuser_params=%s", conf->getuser_envs); _log(LOG_DEBUG, "superuser_params=%s", conf->superuser_envs); _log(LOG_DEBUG, "aclcheck_paramsi=%s", conf->aclcheck_envs); return (conf); }; void be_jwt_destroy(void *handle) { struct jwt_backend *conf = (struct jwt_backend *)handle; if (conf) { if (conf->hostname) free(conf->hostname); if (conf->hostheader) free(conf->hostheader); curl_global_cleanup(); free(conf); } }; int be_jwt_getuser(void *handle, const char *token, const char *pass, char **phash, const char *clientid) { struct jwt_backend *conf = (struct jwt_backend *)handle; int re; if (token == NULL) { return BACKEND_DEFER; } re = http_post(handle, conf->getuser_uri, NULL, token, NULL, -1, METHOD_GETUSER); return re; }; int be_jwt_superuser(void *handle, const char *token) { struct jwt_backend *conf = (struct jwt_backend *)handle; return http_post(handle, conf->superuser_uri, NULL, token, NULL, -1, METHOD_SUPERUSER); }; int be_jwt_aclcheck(void *handle, const char *clientid, const char *token, const char *topic, int acc) { struct jwt_backend *conf = (struct jwt_backend *)handle; return http_post(conf, conf->aclcheck_uri, clientid, token, topic, acc, METHOD_ACLCHECK); }; #endif /* BE_JWT */
the_stack_data/36074623.c
struct B; struct A { long a; struct B *foo; }; static struct A *foo __attribute__((used));
the_stack_data/98575054.c
// Queue Operations #include<stdio.h> float ar[10]; int f = -1; int r = -1; int isempty() { if(f==r) return 1; else return 0; } int isfull() { if(r==9) return 1; else return 0; } void enqueue() { if(isfull()) printf("Queue Overflow\n"); else { printf("Enter the element: "); scanf("%f",&ar[r]); r=r+1; printf("\n"); } } void dequeue() { if(isempty()) printf("Queue Underflow\n"); else { printf("%f",ar[f]); f=f+1; printf("\n"); } } void display() { int i; for(i=f;i<r;i++) printf("%f \n",ar[i]); } void main() { int c,ch=1,a=0; printf("1. isEmpty\n2. isFull\n3. Enqueue\n4. Dequeue\n5. Display\nDefault: exit"); while(ch==1) { printf("\nEnter your choice: "); scanf("%d",&c); switch (c) { case 1: a=isempty(); if(a==1) printf("Queue Underflow\n"); else printf("Queue is not empty\n"); break; case 2: a=isfull(); if(a==1) printf("Queue Overflow\n"); else printf("Queue is not full\n"); break; case 3: enqueue(); break; case 4: dequeue(); break; case 5: display(); break; default: ch = 0; } } }
the_stack_data/28263063.c
/* gcc -std=c17 -lc -lm -pthread -o ../_build/c/language_operator_logical_1.exe ./c/language_operator_logical_1.c && (cd ../_build/c/;./language_operator_logical_1.exe) https://en.cppreference.com/w/c/language/operator_logical */ #include <stdbool.h> #include <stdio.h> int main(void) { bool b = 2+2==4 && 2*2==4; // b == true 1 > 2 && puts("this won't print"); char *p = "abc"; if(p && *p) // common C idiom: if p is not null // AND if p does not point at the end of the string { // (note that thanks to short-circuit evaluation, this // will not attempt to dereference a null pointer) // ... // ... then do some string processing } }
the_stack_data/48891.c
#include <stdlib.h> #include <sys/errno.h> #include <string.h> #include <stdio.h> #include <unistd.h> #include <signal.h> #define MAX 1024 static char line[MAX]; char *var; char *val; void affiche_cmd(char *argv[]); int parse_line(char *s, char **argv[]); void print_dir(); int takeInput(char* str); void simple_cmd(char *str); int parse_line_redir (char * s, char **argv[], char **in, char **out); int redir_cmd(char*argv[],char*in,char*out); int parse_line_pipes(char*s,char***argv[],char**in,char**out); void sighandler(int sig_num); int main(int argc, char *argv[]) { char *in,*out; char option; while(1) { signal(SIGTSTP, sighandler); print_dir(); fflush(NULL); if (!fgets(line, MAX, stdin)) return 0; char *cmd = line; parse_line(cmd,&argv); if (var!=NULL && val!= NULL && strstr(cmd,var)!=NULL) printf("%s",val); redir_cmd(&cmd,in,out); } //parse_line_pipes("cmd1 toto|cmd2 tata titi|cmd3",&argv,&in,&out); //parse_line("chaine=valeur",&argv); //parse_line_redir("command -v <input >output",&argv,&in,&out); return 0; } void affiche_cmd(char *argv[]){ int i = 0; printf("\n"); while(argv[i]!=NULL){ printf(" %s ",argv[i++]); } printf("\n"); } void print_dir(){ char cwd[1024]; getcwd(cwd, sizeof(cwd)); printf("\n%s$ ", cwd); } void simple_cmd(char *str){ if (strstr(str, "exit") != NULL) { exit(0); } else if (strstr(str, "cd") != NULL){ chdir(".."); } else if (strstr(str, "./" )!= NULL){ system(str); } else if (strstr(str, "ls")!=NULL){ system(str); } else if (strstr(str,"$"!=NULL && var!=NULL && val!=NULL)){ system(*val); } } int parse_line(char *s, char **argv[]){ if(strstr(s,"=")!=NULL){ char key[] = "="; char *temp = strdup(s); char *token = strtok(temp,key); int i = 0; while(token != NULL){ if(i == 0){ var =(char*)malloc(sizeof(char)*strlen(token)+1); var = token; i++; } else if(i == 1){ val = (char*)malloc(sizeof(char)*strlen(token)+1); val = token; } token = strtok(NULL,key); } (*argv)[i] = NULL; //affiche_cmd(*argv); } else{ char key[] = " "; char *temp = strdup(s); char *token = strtok(temp,key); int i = 0; while(token != NULL){ (*argv)[i] = malloc(sizeof(char*)*(strlen(temp)+1)); (*argv)[i++] = token; token = strtok(NULL,key); } (*argv)[i] = NULL; //affiche_cmd(*argv); } return 0; } int parse_line_redir (char *s, char **argv[], char **in, char **out){ char key[] = " "; char *temp = strdup(s); char *token = strtok(temp,key); int i = 0; while(token != NULL){ if(strstr(token,"<") != NULL){ *in =(char*)malloc(sizeof(char)*(strlen(token)+1)); char *temp1 = token; temp1++; *in=temp1; } else if(strstr(token,">") != NULL){ *out =(char*)malloc(sizeof(char)*(strlen(token)+1)); char *temp1 = token; temp1++; *out = temp1; } (*argv)[i] = malloc(sizeof(char*)*(strlen(token)+1)); (*argv)[i++] = token; token = strtok(NULL,key); } (*argv)[i] = NULL; affiche_cmd(*argv); return 0; } int redir_cmd(char*argv[],char*in,char*out){ simple_cmd(*argv); } int parse_line_pipes(char*s,char***argv[],char**in,char**out){ char key[] = "|"; char *temp = strdup(s); char *token = strtok(temp,key); int count = 0; int i = 0; while(s[i]!=NULL){ if (s[i]=='|') count++; i++; } i = 0; char **tempPipe = (char**)malloc(sizeof(char*)*(count+1)); while(token != NULL){ tempPipe[i] = (char*)malloc(sizeof(char)*(strlen(token)+1)); tempPipe[i++] = token; token = strtok(NULL,key); } tempPipe[i]=NULL; **argv=malloc(sizeof(char**)*(count+1)); key[0] = ' '; for(int j = 0;j<=count;j++){ char *temp1 = strdup(tempPipe[j]); token = strtok(temp1,key); int k = 0; count = 0; int it = 0; while(tempPipe[j][it]!=NULL){ if (tempPipe[j][it++]==' ') count++; } **argv[j]=malloc(sizeof(char**)*(count + 1)); while(token != NULL){ **argv[k] = malloc(sizeof(char*)*(strlen(temp1)+1)); **argv[k++] = token; token = strtok(NULL,key); } } (**argv)[i] = NULL; return 0; } void sighandler(int sig_num) { signal(SIGTSTP, sighandler); printf("Cannot execute Ctrl+Z\n"); }
the_stack_data/151705294.c
// RUN: %clang -fsanitize=cver %s -O3 -o %t // RUN: CVER_OPTIONS=die_on_error=1 %run %t 2>&1 // This test does nothing but check whether cast_sanitizer can build plain c programs. #include <stdio.h> int main(int argc) { return 0; }
the_stack_data/281003.c
#include <stdio.h> #include <omp.h> void funcA() { printf("En funcA: esta sección la ejecuta el thread %d\n", omp_get_thread_num()); } void funcB() { printf("En funcB: esta sección la ejecuta el thread %d\n", omp_get_thread_num()); } int main(int argc, char ** argv) { #pragma omp parallel sections { #pragma omp section (void) funcA(); #pragma omp section (void) funcB(); } return(0); }
the_stack_data/128762.c
#include <unistd.h> #include <stdlib.h> #include <stdio.h> int main(int argc, char* argv[]) { FILE *fp; char id[10]; int grade1, grade2, grade3; float avg; if (argc != 2) { printf("< Usage: ./high4 filename >\n"); return 1; } fp = fopen(argv[1], "r"); if (fp == NULL) { perror("Open"); exit(1); } fscanf(fp, "%s %d %d %d %f\n", id, &grade1, &grade2, &grade3, &avg); fprintf(stdout, "%s %d %d %d %.3f\n", id, grade1, grade2, grade3, avg); fscanf(fp, "%s %d %d %d %f\n", id, &grade1, &grade2, &grade3, &avg); fprintf(stdout, "%s %d %d %d %.3f\n", id, grade1, grade2, grade3, avg); fscanf(fp, "%s %d %d %d %f\n", id, &grade1, &grade2, &grade3, &avg); fprintf(stdout, "%s %d %d %d %.3f\n", id, grade1, grade2, grade3, avg); fclose(fp); return 0; }
the_stack_data/182951767.c
/* mbed Microcontroller Library * Copyright (c) 2017 ARM Limited * Copyright (c) 2017 STMicroelectronics * SPDX-License-Identifier: Apache-2.0 * * 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. */ #if DEVICE_FLASH #include "flash_api.h" #include "flash_data.h" #include "platform/mbed_critical.h" // This file is automatically generated static uint32_t GetSector(uint32_t Address); static uint32_t GetSectorSize(uint32_t Sector); int32_t flash_init(flash_t *obj) { return 0; } int32_t flash_free(flash_t *obj) { return 0; } static int32_t flash_unlock(void) { /* Allow Access to Flash control registers and user Falsh */ if (HAL_FLASH_Unlock()) { return -1; } else { return 0; } } static int32_t flash_lock(void) { /* Disable the Flash option control register access (recommended to protect the option Bytes against possible unwanted operations) */ if (HAL_FLASH_Lock()) { return -1; } else { return 0; } } int32_t flash_erase_sector(flash_t *obj, uint32_t address) { /*Variable used for Erase procedure*/ static FLASH_EraseInitTypeDef EraseInitStruct; uint32_t FirstSector; uint32_t SectorError = 0; int32_t status = 0; if ((address >= (FLASH_BASE + FLASH_SIZE)) || (address < FLASH_BASE)) { return -1; } if (flash_unlock() != HAL_OK) { return -1; } /* Get the 1st sector to erase */ FirstSector = GetSector(address); /* Fill EraseInit structure*/ EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS; EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3; EraseInitStruct.Sector = FirstSector; EraseInitStruct.NbSectors = 1; if (HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError) != HAL_OK) { status = -1; } flash_lock(); return status; } int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size) { int32_t status = 0; if ((address >= (FLASH_BASE + FLASH_SIZE)) || (address < FLASH_BASE)) { return -1; } if (flash_unlock() != HAL_OK) { return -1; } /* Note: If an erase operation in Flash memory also concerns data in the data or instruction cache, you have to make sure that these data are rewritten before they are accessed during code execution. If this cannot be done safely, it is recommended to flush the caches by setting the DCRST and ICRST bits in the FLASH_CR register. */ __HAL_FLASH_DATA_CACHE_DISABLE(); __HAL_FLASH_INSTRUCTION_CACHE_DISABLE(); __HAL_FLASH_DATA_CACHE_RESET(); __HAL_FLASH_INSTRUCTION_CACHE_RESET(); __HAL_FLASH_INSTRUCTION_CACHE_ENABLE(); __HAL_FLASH_DATA_CACHE_ENABLE(); while ((size > 0) && (status == 0)) { if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, address, (uint64_t)*data) != HAL_OK) { status = -1; } else { size--; address++; data++; } } flash_lock(); return status; } uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address) { if ((address >= (FLASH_BASE + FLASH_SIZE)) || (address < FLASH_BASE)) { return MBED_FLASH_INVALID_SIZE; } return (GetSectorSize(GetSector(address))); } uint32_t flash_get_page_size(const flash_t *obj) { // Flash of STM32F4 devices can be programed 1 byte at a time return (1); } uint32_t flash_get_start_address(const flash_t *obj) { return FLASH_BASE; } uint32_t flash_get_size(const flash_t *obj) { return FLASH_SIZE; } /** * @brief Gets the sector of a given address * @param None * @retval The sector of a given address */ static uint32_t GetSector(uint32_t address) { uint32_t sector = 0; uint32_t tmp = address - ADDR_FLASH_SECTOR_0; /* This function supports 1Mb and 2Mb flash sizes */ #if defined(ADDR_FLASH_SECTOR_16) if (address & 0x100000) { // handle 2nd bank /* Sector will be at least 12 */ sector = FLASH_SECTOR_12; tmp -= 0x100000; address -= 0x100000; } #endif if (address < ADDR_FLASH_SECTOR_4) { // 16k sectorsize sector += tmp >> 14; } #if defined(ADDR_FLASH_SECTOR_5) else if (address < ADDR_FLASH_SECTOR_5) { //64k sector size sector += FLASH_SECTOR_4; } else { sector += 4 + (tmp >> 17); } #else // In case ADDR_FLASH_SECTOR_5 is not defined, sector 4 is the last one. else { //64k sector size sector += FLASH_SECTOR_4; } #endif return sector; } /** * @brief Gets sector Size * @param None * @retval The size of a given sector */ static uint32_t GetSectorSize(uint32_t Sector) { uint32_t sectorsize = 0x00; #if defined(FLASH_SECTOR_16) if ((Sector == FLASH_SECTOR_0) || (Sector == FLASH_SECTOR_1) || (Sector == FLASH_SECTOR_2) || \ (Sector == FLASH_SECTOR_3) || (Sector == FLASH_SECTOR_12) || (Sector == FLASH_SECTOR_13) || \ (Sector == FLASH_SECTOR_14) || (Sector == FLASH_SECTOR_15)) { sectorsize = 16 * 1024; } else if ((Sector == FLASH_SECTOR_4) || (Sector == FLASH_SECTOR_16)) { #else if ((Sector == FLASH_SECTOR_0) || (Sector == FLASH_SECTOR_1) || (Sector == FLASH_SECTOR_2) || \ (Sector == FLASH_SECTOR_3)) { sectorsize = 16 * 1024; } else if (Sector == FLASH_SECTOR_4) { #endif sectorsize = 64 * 1024; } else { sectorsize = 128 * 1024; } return sectorsize; } uint8_t flash_get_erase_value(const flash_t *obj) { (void)obj; return 0xFF; } #endif
the_stack_data/873932.c
// Protocoale de comunicatii // Laborator 9 - DNS // dns.c #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <string.h> #include <sys/socket.h> #include <netdb.h> #include <arpa/inet.h> int usage(char* name) { printf("Usage:\n\t%s -n <NAME>\n\t%s -a <IP>\n", name, name); return 1; } // Receives a name and prints IP addresses void get_ip(char* name) { int ret; struct addrinfo hints, *result, *p; // TODO: set hints hints.ai_flags = 0; hints.ai_family = AF_INET; hints.ai_socktype = 0; hints.ai_protocol = 0; hints.ai_addrlen = 0; hints.ai_addr = NULL; hints.ai_canonname = NULL; hints.ai_next = NULL; // TODO: get addresses ret = getaddrinfo(name, NULL, &hints, &result); if(ret < 0) { gai_strerror(ret); return; } // TODO: iterate through addresses and print them for(p = result; p != NULL; p = p->ai_next) { char temp[INET_ADDRSTRLEN]; struct sockaddr_in *temp_struct = (struct sockaddr_in*)p->ai_addr; if(inet_ntop(AF_INET, &(temp_struct->sin_addr), temp, sizeof(temp)) == NULL) { perror("inet_ntop"); return; } printf("%s\n", temp); } // TODO: free allocated data free(result); } // Receives an address and prints the associated name and service void get_name(char* ip) { int ret; struct sockaddr_in addr; char host[1024]; char service[20]; // TODO: fill in address data addr.sin_family = AF_INET; addr.sin_port = 53; if(inet_pton(AF_INET, ip, &(addr.sin_addr)) == NULL) { perror("inet_pton"); return; } // TODO: get name and service ret = getnameinfo(((struct sockaddr*)&addr), sizeof(addr), host, sizeof(host), service, sizeof(service), 0); if(ret < 0) { gai_strerror(ret); return; } // TODO: print name and service printf("host: %s\tservice: %s\n", host, service); } int main(int argc, char **argv) { if (argc < 3) { return usage(argv[0]); } if (strncmp(argv[1], "-n", 2) == 0) { get_ip(argv[2]); } else if (strncmp(argv[1], "-a", 2) == 0) { get_name(argv[2]); } else { return usage(argv[0]); } return 0; }
the_stack_data/549508.c
#ifdef CONFIG_WAPI_SUPPORT #include <linux/unistd.h> #include <linux/etherdevice.h> #include <drv_types.h> #include <rtw_wapi.h> u32 wapi_debug_component = /* WAPI_INIT | * WAPI_API | * WAPI_TX | * WAPI_RX | */ WAPI_ERR ; /* always open err flags on */ void WapiFreeAllStaInfo(_adapter *padapter) { PRT_WAPI_T pWapiInfo; PRT_WAPI_STA_INFO pWapiStaInfo; PRT_WAPI_BKID pWapiBkid; WAPI_TRACE(WAPI_INIT, "===========> %s\n", __FUNCTION__); pWapiInfo = &padapter->wapiInfo; /* Pust to Idle List */ rtw_wapi_return_all_sta_info(padapter); /* Sta Info List */ while (!list_empty(&(pWapiInfo->wapiSTAIdleList))) { pWapiStaInfo = (PRT_WAPI_STA_INFO)list_entry(pWapiInfo->wapiSTAIdleList.next, RT_WAPI_STA_INFO, list); list_del_init(&pWapiStaInfo->list); } /* BKID List */ while (!list_empty(&(pWapiInfo->wapiBKIDIdleList))) { pWapiBkid = (PRT_WAPI_BKID)list_entry(pWapiInfo->wapiBKIDIdleList.next, RT_WAPI_BKID, list); list_del_init(&pWapiBkid->list); } WAPI_TRACE(WAPI_INIT, "<=========== %s\n", __FUNCTION__); return; } void WapiSetIE(_adapter *padapter) { PRT_WAPI_T pWapiInfo = &(padapter->wapiInfo); /* PRT_WAPI_BKID pWapiBkid; */ u16 protocolVer = 1; u16 akmCnt = 1; u16 suiteCnt = 1; u16 capability = 0; u8 OUI[3]; OUI[0] = 0x00; OUI[1] = 0x14; OUI[2] = 0x72; pWapiInfo->wapiIELength = 0; /* protocol version */ memcpy(pWapiInfo->wapiIE + pWapiInfo->wapiIELength, &protocolVer, 2); pWapiInfo->wapiIELength += 2; /* akm */ memcpy(pWapiInfo->wapiIE + pWapiInfo->wapiIELength, &akmCnt, 2); pWapiInfo->wapiIELength += 2; if (pWapiInfo->bWapiPSK) { memcpy(pWapiInfo->wapiIE + pWapiInfo->wapiIELength, OUI, 3); pWapiInfo->wapiIELength += 3; pWapiInfo->wapiIE[pWapiInfo->wapiIELength] = 0x2; pWapiInfo->wapiIELength += 1; } else { memcpy(pWapiInfo->wapiIE + pWapiInfo->wapiIELength, OUI, 3); pWapiInfo->wapiIELength += 3; pWapiInfo->wapiIE[pWapiInfo->wapiIELength] = 0x1; pWapiInfo->wapiIELength += 1; } /* usk */ memcpy(pWapiInfo->wapiIE + pWapiInfo->wapiIELength, &suiteCnt, 2); pWapiInfo->wapiIELength += 2; memcpy(pWapiInfo->wapiIE + pWapiInfo->wapiIELength, OUI, 3); pWapiInfo->wapiIELength += 3; pWapiInfo->wapiIE[pWapiInfo->wapiIELength] = 0x1; pWapiInfo->wapiIELength += 1; /* msk */ memcpy(pWapiInfo->wapiIE + pWapiInfo->wapiIELength, OUI, 3); pWapiInfo->wapiIELength += 3; pWapiInfo->wapiIE[pWapiInfo->wapiIELength] = 0x1; pWapiInfo->wapiIELength += 1; /* Capbility */ memcpy(pWapiInfo->wapiIE + pWapiInfo->wapiIELength, &capability, 2); pWapiInfo->wapiIELength += 2; } /* PN1 > PN2, return 1, * else return 0. */ u32 WapiComparePN(u8 *PN1, u8 *PN2) { char i; if ((NULL == PN1) || (NULL == PN2)) return 1; /* overflow case */ if ((PN2[15] - PN1[15]) & 0x80) return 1; for (i = 16; i > 0; i--) { if (PN1[i - 1] == PN2[i - 1]) continue; else if (PN1[i - 1] > PN2[i - 1]) return 1; else return 0; } return 0; } u8 WapiGetEntryForCamWrite(_adapter *padapter, u8 *pMacAddr, u8 KID, BOOLEAN IsMsk) { PRT_WAPI_T pWapiInfo = NULL; /* PRT_WAPI_CAM_ENTRY pEntry=NULL; */ u8 i = 0; u8 ret = 0xff; WAPI_TRACE(WAPI_API, "===========> %s\n", __FUNCTION__); pWapiInfo = &padapter->wapiInfo; /* exist? */ for (i = 0; i < WAPI_CAM_ENTRY_NUM; i++) { if (pWapiInfo->wapiCamEntry[i].IsUsed && (_rtw_memcmp(pMacAddr, pWapiInfo->wapiCamEntry[i].PeerMacAddr, ETH_ALEN) == _TRUE) && pWapiInfo->wapiCamEntry[i].keyidx == KID && pWapiInfo->wapiCamEntry[i].type == IsMsk) { ret = pWapiInfo->wapiCamEntry[i].entry_idx; /* cover it */ break; } } if (i == WAPI_CAM_ENTRY_NUM) { /* not found */ for (i = 0; i < WAPI_CAM_ENTRY_NUM; i++) { if (pWapiInfo->wapiCamEntry[i].IsUsed == 0) { pWapiInfo->wapiCamEntry[i].IsUsed = 1; pWapiInfo->wapiCamEntry[i].type = IsMsk; pWapiInfo->wapiCamEntry[i].keyidx = KID; _rtw_memcpy(pWapiInfo->wapiCamEntry[i].PeerMacAddr, pMacAddr, ETH_ALEN); ret = pWapiInfo->wapiCamEntry[i].entry_idx; break; } } } WAPI_TRACE(WAPI_API, "<========== %s\n", __FUNCTION__); return ret; /* if(RTIsListEmpty(&pWapiInfo->wapiCamIdleList)) { return 0; } pEntry = (PRT_WAPI_CAM_ENTRY)RTRemoveHeadList(&pWapiInfo->wapiCamIdleList); RTInsertTailList(&pWapiInfo->wapiCamUsedList, &pEntry->list); return pEntry->entry_idx;*/ } u8 WapiGetEntryForCamClear(_adapter *padapter, u8 *pPeerMac, u8 keyid, u8 IsMsk) { PRT_WAPI_T pWapiInfo = NULL; u8 i = 0; WAPI_TRACE(WAPI_API, "===========> %s\n", __FUNCTION__); pWapiInfo = &padapter->wapiInfo; for (i = 0; i < WAPI_CAM_ENTRY_NUM; i++) { if (pWapiInfo->wapiCamEntry[i].IsUsed && (_rtw_memcmp(pPeerMac, pWapiInfo->wapiCamEntry[i].PeerMacAddr, ETH_ALEN) == _TRUE) && pWapiInfo->wapiCamEntry[i].keyidx == keyid && pWapiInfo->wapiCamEntry[i].type == IsMsk) { pWapiInfo->wapiCamEntry[i].IsUsed = 0; pWapiInfo->wapiCamEntry[i].keyidx = 2; _rtw_memset(pWapiInfo->wapiCamEntry[i].PeerMacAddr, 0, ETH_ALEN); WAPI_TRACE(WAPI_API, "<========== %s\n", __FUNCTION__); return pWapiInfo->wapiCamEntry[i].entry_idx; } } WAPI_TRACE(WAPI_API, "<====WapiGetReturnCamEntry(), No this cam entry.\n"); return 0xff; /* if(RTIsListEmpty(&pWapiInfo->wapiCamUsedList)) { return FALSE; } pList = &pWapiInfo->wapiCamUsedList; while(pList->Flink != &pWapiInfo->wapiCamUsedList) { pEntry = (PRT_WAPI_CAM_ENTRY)pList->Flink; if(PlatformCompareMemory(pPeerMac,pEntry->PeerMacAddr, ETHER_ADDRLEN)== 0 && keyid == pEntry->keyidx) { RTRemoveEntryList(pList); RTInsertHeadList(&pWapiInfo->wapiCamIdleList, pList); return pEntry->entry_idx; } pList = pList->Flink; } return 0; */ } void WapiResetAllCamEntry(_adapter *padapter) { PRT_WAPI_T pWapiInfo; int i; WAPI_TRACE(WAPI_API, "===========> %s\n", __FUNCTION__); pWapiInfo = &padapter->wapiInfo; for (i = 0; i < WAPI_CAM_ENTRY_NUM; i++) { _rtw_memset(pWapiInfo->wapiCamEntry[i].PeerMacAddr, 0, ETH_ALEN); pWapiInfo->wapiCamEntry[i].IsUsed = 0; pWapiInfo->wapiCamEntry[i].keyidx = 2; /* invalid */ pWapiInfo->wapiCamEntry[i].entry_idx = 4 + i * 2; } WAPI_TRACE(WAPI_API, "<========== %s\n", __FUNCTION__); return; } u8 WapiWriteOneCamEntry( _adapter *padapter, u8 *pMacAddr, u8 KeyId, u8 EntryId, u8 EncAlg, u8 bGroupKey, u8 *pKey ) { u8 retVal = 0; u16 usConfig = 0; WAPI_TRACE(WAPI_API, "===========> %s\n", __FUNCTION__); if (EntryId >= 32) { WAPI_TRACE(WAPI_ERR, "<=== CamAddOneEntry(): ulKeyId exceed!\n"); return retVal; } usConfig = usConfig | (0x01 << 15) | ((u16)(EncAlg) << 2) | (KeyId); if (EncAlg == _SMS4_) { if (bGroupKey == 1) usConfig |= (0x01 << 6); if ((EntryId % 2) == 1) /* ==0 sec key; == 1mic key */ usConfig |= (0x01 << 5); } write_cam(padapter, EntryId, usConfig, pMacAddr, pKey); WAPI_TRACE(WAPI_API, "===========> %s\n", __FUNCTION__); return 1; } void rtw_wapi_init(_adapter *padapter) { PRT_WAPI_T pWapiInfo; int i; WAPI_TRACE(WAPI_INIT, "===========> %s\n", __FUNCTION__); RT_ASSERT_RET(padapter); if (!padapter->WapiSupport) { WAPI_TRACE(WAPI_INIT, "<========== %s, WAPI not supported!\n", __FUNCTION__); return; } pWapiInfo = &padapter->wapiInfo; pWapiInfo->bWapiEnable = false; /* Init BKID List */ INIT_LIST_HEAD(&pWapiInfo->wapiBKIDIdleList); INIT_LIST_HEAD(&pWapiInfo->wapiBKIDStoreList); for (i = 0; i < WAPI_MAX_BKID_NUM; i++) list_add_tail(&pWapiInfo->wapiBKID[i].list, &pWapiInfo->wapiBKIDIdleList); /* Init STA List */ INIT_LIST_HEAD(&pWapiInfo->wapiSTAIdleList); INIT_LIST_HEAD(&pWapiInfo->wapiSTAUsedList); for (i = 0; i < WAPI_MAX_STAINFO_NUM; i++) list_add_tail(&pWapiInfo->wapiSta[i].list, &pWapiInfo->wapiSTAIdleList); for (i = 0; i < WAPI_CAM_ENTRY_NUM; i++) { pWapiInfo->wapiCamEntry[i].IsUsed = 0; pWapiInfo->wapiCamEntry[i].keyidx = 2; /* invalid */ pWapiInfo->wapiCamEntry[i].entry_idx = 4 + i * 2; } WAPI_TRACE(WAPI_INIT, "<========== %s\n", __FUNCTION__); } void rtw_wapi_free(_adapter *padapter) { WAPI_TRACE(WAPI_INIT, "===========> %s\n", __FUNCTION__); RT_ASSERT_RET(padapter); if (!padapter->WapiSupport) { WAPI_TRACE(WAPI_INIT, "<========== %s, WAPI not supported!\n", __FUNCTION__); return; } WapiFreeAllStaInfo(padapter); WAPI_TRACE(WAPI_INIT, "<========== %s\n", __FUNCTION__); } void rtw_wapi_disable_tx(_adapter *padapter) { WAPI_TRACE(WAPI_INIT, "===========> %s\n", __FUNCTION__); RT_ASSERT_RET(padapter); if (!padapter->WapiSupport) { WAPI_TRACE(WAPI_INIT, "<========== %s, WAPI not supported!\n", __FUNCTION__); return; } padapter->wapiInfo.wapiTxMsk.bTxEnable = false; padapter->wapiInfo.wapiTxMsk.bSet = false; WAPI_TRACE(WAPI_INIT, "<========== %s\n", __FUNCTION__); } u8 rtw_wapi_is_wai_packet(_adapter *padapter, u8 *pkt_data) { PRT_WAPI_T pWapiInfo = &(padapter->wapiInfo); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; PRT_WAPI_STA_INFO pWapiSta = NULL; u8 WaiPkt = 0, *pTaddr, bFind = false; u8 Offset_TypeWAI = 0 ; /* (mac header len + llc length) */ WAPI_TRACE(WAPI_TX | WAPI_RX, "===========> %s\n", __FUNCTION__); if ((!padapter->WapiSupport) || (!pWapiInfo->bWapiEnable)) { WAPI_TRACE(WAPI_MLME, "<========== %s, WAPI not supported or not enabled!\n", __FUNCTION__); return 0; } Offset_TypeWAI = 24 + 6 ; /* YJ,add,091103. Data frame may also have skb->data[30]=0x88 and skb->data[31]=0xb4. */ if ((pkt_data[1] & 0x40) != 0) { /* RTW_INFO("data is privacy\n"); */ return 0; } pTaddr = get_addr2_ptr(pkt_data); if (list_empty(&pWapiInfo->wapiSTAUsedList)) bFind = false; else { list_for_each_entry(pWapiSta, &pWapiInfo->wapiSTAUsedList, list) { if (_rtw_memcmp(pTaddr, pWapiSta->PeerMacAddr, 6) == _TRUE) { bFind = true; break; } } } WAPI_TRACE(WAPI_TX | WAPI_RX, "%s: bFind=%d pTaddr="MAC_FMT"\n", __FUNCTION__, bFind, MAC_ARG(pTaddr)); if (pkt_data[0] == WIFI_QOS_DATA_TYPE) Offset_TypeWAI += 2; /* 88b4? */ if ((pkt_data[Offset_TypeWAI] == 0x88) && (pkt_data[Offset_TypeWAI + 1] == 0xb4)) { WaiPkt = pkt_data[Offset_TypeWAI + 5]; psecuritypriv->hw_decrypted = _TRUE; } else WAPI_TRACE(WAPI_TX | WAPI_RX, "%s(): non wai packet\n", __FUNCTION__); WAPI_TRACE(WAPI_TX | WAPI_RX, "%s(): Recvd WAI frame. IsWAIPkt(%d)\n", __FUNCTION__, WaiPkt); return WaiPkt; } void rtw_wapi_update_info(_adapter *padapter, union recv_frame *precv_frame) { PRT_WAPI_T pWapiInfo = &(padapter->wapiInfo); struct recv_frame_hdr *precv_hdr; u8 *ptr; u8 *pTA; u8 *pRecvPN; WAPI_TRACE(WAPI_RX, "===========> %s\n", __FUNCTION__); if ((!padapter->WapiSupport) || (!pWapiInfo->bWapiEnable)) { WAPI_TRACE(WAPI_RX, "<========== %s, WAPI not supported or not enabled!\n", __FUNCTION__); return; } precv_hdr = &precv_frame->u.hdr; ptr = precv_hdr->rx_data; if (precv_hdr->attrib.qos == 1) precv_hdr->UserPriority = GetTid(ptr); else precv_hdr->UserPriority = 0; pTA = get_addr2_ptr(ptr); _rtw_memcpy((u8 *)precv_hdr->WapiSrcAddr, pTA, 6); pRecvPN = ptr + precv_hdr->attrib.hdrlen + 2; _rtw_memcpy((u8 *)precv_hdr->WapiTempPN, pRecvPN, 16); WAPI_TRACE(WAPI_RX, "<========== %s\n", __FUNCTION__); } /**************************************************************************** TRUE-----------------Drop FALSE---------------- handle add to support WAPI to N-mode *****************************************************************************/ u8 rtw_wapi_check_for_drop( _adapter *padapter, union recv_frame *precv_frame ) { PRT_WAPI_T pWapiInfo = &(padapter->wapiInfo); u8 *pLastRecvPN = NULL; u8 bFind = false; PRT_WAPI_STA_INFO pWapiSta = NULL; u8 bDrop = false; struct recv_frame_hdr *precv_hdr = &precv_frame->u.hdr; u8 WapiAEPNInitialValueSrc[16] = {0x37, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C} ; u8 WapiAEMultiCastPNInitialValueSrc[16] = {0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C} ; u8 *ptr = precv_frame->u.hdr.rx_data; int i; WAPI_TRACE(WAPI_RX, "===========> %s\n", __FUNCTION__); if ((!padapter->WapiSupport) || (!pWapiInfo->bWapiEnable)) { WAPI_TRACE(WAPI_RX, "<========== %s, WAPI not supported or not enabled!\n", __FUNCTION__); return false; } if (precv_hdr->bIsWaiPacket != 0) { if (precv_hdr->bIsWaiPacket == 0x8) { RTW_INFO("rtw_wapi_check_for_drop: dump packet\n"); for (i = 0; i < 50; i++) { RTW_INFO("%02X ", ptr[i]); if ((i + 1) % 8 == 0) RTW_INFO("\n"); } RTW_INFO("\n rtw_wapi_check_for_drop: dump packet\n"); for (i = 0; i < 16; i++) { if (ptr[i + 27] != 0) break; } if (i == 16) { WAPI_TRACE(WAPI_RX, "rtw_wapi_check_for_drop: drop with zero BKID\n"); return true; } else return false; } else return false; } if (list_empty(&pWapiInfo->wapiSTAUsedList)) bFind = false; else { list_for_each_entry(pWapiSta, &pWapiInfo->wapiSTAUsedList, list) { if (_rtw_memcmp(precv_hdr->WapiSrcAddr, pWapiSta->PeerMacAddr, ETH_ALEN) == _TRUE) { bFind = true; break; } } } WAPI_TRACE(WAPI_RX, "%s: bFind=%d prxb->WapiSrcAddr="MAC_FMT"\n", __FUNCTION__, bFind, MAC_ARG(precv_hdr->WapiSrcAddr)); if (bFind) { if (IS_MCAST(precv_hdr->attrib.ra)) { WAPI_TRACE(WAPI_RX, "rtw_wapi_check_for_drop: multicast case\n"); pLastRecvPN = pWapiSta->lastRxMulticastPN; } else { WAPI_TRACE(WAPI_RX, "rtw_wapi_check_for_drop: unicast case\n"); switch (precv_hdr->UserPriority) { case 0: case 3: pLastRecvPN = pWapiSta->lastRxUnicastPNBEQueue; break; case 1: case 2: pLastRecvPN = pWapiSta->lastRxUnicastPNBKQueue; break; case 4: case 5: pLastRecvPN = pWapiSta->lastRxUnicastPNVIQueue; break; case 6: case 7: pLastRecvPN = pWapiSta->lastRxUnicastPNVOQueue; break; default: WAPI_TRACE(WAPI_ERR, "%s: Unknown TID\n", __FUNCTION__); break; } } if (!WapiComparePN(precv_hdr->WapiTempPN, pLastRecvPN)) { WAPI_TRACE(WAPI_RX, "%s: Equal PN!!\n", __FUNCTION__); if (IS_MCAST(precv_hdr->attrib.ra)) _rtw_memcpy(pLastRecvPN, WapiAEMultiCastPNInitialValueSrc, 16); else _rtw_memcpy(pLastRecvPN, WapiAEPNInitialValueSrc, 16); bDrop = true; } else _rtw_memcpy(pLastRecvPN, precv_hdr->WapiTempPN, 16); } WAPI_TRACE(WAPI_RX, "<========== %s\n", __FUNCTION__); return bDrop; } void rtw_build_probe_resp_wapi_ie(_adapter *padapter, unsigned char *pframe, struct pkt_attrib *pattrib) { PRT_WAPI_T pWapiInfo = &(padapter->wapiInfo); u8 WapiIELength = 0; WAPI_TRACE(WAPI_MLME, "===========> %s\n", __FUNCTION__); if ((!padapter->WapiSupport) || (!pWapiInfo->bWapiEnable)) { WAPI_TRACE(WAPI_MLME, "<========== %s, WAPI not supported!\n", __FUNCTION__); return; } WapiSetIE(padapter); WapiIELength = pWapiInfo->wapiIELength; pframe[0] = _WAPI_IE_; pframe[1] = WapiIELength; _rtw_memcpy(pframe + 2, pWapiInfo->wapiIE, WapiIELength); pframe += WapiIELength + 2; pattrib->pktlen += WapiIELength + 2; WAPI_TRACE(WAPI_MLME, "<========== %s\n", __FUNCTION__); } void rtw_build_beacon_wapi_ie(_adapter *padapter, unsigned char *pframe, struct pkt_attrib *pattrib) { PRT_WAPI_T pWapiInfo = &(padapter->wapiInfo); u8 WapiIELength = 0; WAPI_TRACE(WAPI_MLME, "===========> %s\n", __FUNCTION__); if ((!padapter->WapiSupport) || (!pWapiInfo->bWapiEnable)) { WAPI_TRACE(WAPI_MLME, "<========== %s, WAPI not supported!\n", __FUNCTION__); return; } WapiSetIE(padapter); WapiIELength = pWapiInfo->wapiIELength; pframe[0] = _WAPI_IE_; pframe[1] = WapiIELength; _rtw_memcpy(pframe + 2, pWapiInfo->wapiIE, WapiIELength); pframe += WapiIELength + 2; pattrib->pktlen += WapiIELength + 2; WAPI_TRACE(WAPI_MLME, "<========== %s\n", __FUNCTION__); } void rtw_build_assoc_req_wapi_ie(_adapter *padapter, unsigned char *pframe, struct pkt_attrib *pattrib) { PRT_WAPI_BKID pWapiBKID; u16 bkidNum; PRT_WAPI_T pWapiInfo = &(padapter->wapiInfo); u8 WapiIELength = 0; WAPI_TRACE(WAPI_MLME, "===========> %s\n", __FUNCTION__); if ((!padapter->WapiSupport) || (!pWapiInfo->bWapiEnable)) { WAPI_TRACE(WAPI_MLME, "<========== %s, WAPI not supported!\n", __FUNCTION__); return; } WapiSetIE(padapter); WapiIELength = pWapiInfo->wapiIELength; bkidNum = 0; if (!list_empty(&(pWapiInfo->wapiBKIDStoreList))) { list_for_each_entry(pWapiBKID, &pWapiInfo->wapiBKIDStoreList, list) { bkidNum++; _rtw_memcpy(pWapiInfo->wapiIE + WapiIELength + 2, pWapiBKID->bkid, 16); WapiIELength += 16; } } _rtw_memcpy(pWapiInfo->wapiIE + WapiIELength, &bkidNum, 2); WapiIELength += 2; pframe[0] = _WAPI_IE_; pframe[1] = WapiIELength; _rtw_memcpy(pframe + 2, pWapiInfo->wapiIE, WapiIELength); pframe += WapiIELength + 2; pattrib->pktlen += WapiIELength + 2; WAPI_TRACE(WAPI_MLME, "<========== %s\n", __FUNCTION__); } void rtw_wapi_on_assoc_ok(_adapter *padapter, PNDIS_802_11_VARIABLE_IEs pIE) { PRT_WAPI_T pWapiInfo = &(padapter->wapiInfo); PRT_WAPI_STA_INFO pWapiSta; u8 WapiAEPNInitialValueSrc[16] = {0x37, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C} ; /* u8 WapiASUEPNInitialValueSrc[16] = {0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C} ; */ u8 WapiAEMultiCastPNInitialValueSrc[16] = {0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C} ; WAPI_TRACE(WAPI_MLME, "===========> %s\n", __FUNCTION__); if ((!padapter->WapiSupport) || (!pWapiInfo->bWapiEnable)) { WAPI_TRACE(WAPI_MLME, "<========== %s, WAPI not supported or not enabled!\n", __FUNCTION__); return; } pWapiSta = (PRT_WAPI_STA_INFO)list_entry(pWapiInfo->wapiSTAIdleList.next, RT_WAPI_STA_INFO, list); list_del_init(&pWapiSta->list); list_add_tail(&pWapiSta->list, &pWapiInfo->wapiSTAUsedList); _rtw_memcpy(pWapiSta->PeerMacAddr, padapter->mlmeextpriv.mlmext_info.network.MacAddress, 6); _rtw_memcpy(pWapiSta->lastRxMulticastPN, WapiAEMultiCastPNInitialValueSrc, 16); _rtw_memcpy(pWapiSta->lastRxUnicastPN, WapiAEPNInitialValueSrc, 16); /* For chenk PN error with Qos Data after s3: add by ylb 20111114 */ _rtw_memcpy(pWapiSta->lastRxUnicastPNBEQueue, WapiAEPNInitialValueSrc, 16); _rtw_memcpy(pWapiSta->lastRxUnicastPNBKQueue, WapiAEPNInitialValueSrc, 16); _rtw_memcpy(pWapiSta->lastRxUnicastPNVIQueue, WapiAEPNInitialValueSrc, 16); _rtw_memcpy(pWapiSta->lastRxUnicastPNVOQueue, WapiAEPNInitialValueSrc, 16); WAPI_TRACE(WAPI_MLME, "<========== %s\n", __FUNCTION__); } void rtw_wapi_return_one_sta_info(_adapter *padapter, u8 *MacAddr) { PRT_WAPI_T pWapiInfo; PRT_WAPI_STA_INFO pWapiStaInfo = NULL; PRT_WAPI_BKID pWapiBkid = NULL; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; pWapiInfo = &padapter->wapiInfo; WAPI_TRACE(WAPI_API, "==========> %s\n", __FUNCTION__); if ((!padapter->WapiSupport) || (!pWapiInfo->bWapiEnable)) { WAPI_TRACE(WAPI_MLME, "<========== %s, WAPI not supported or not enabled!\n", __FUNCTION__); return; } if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { while (!list_empty(&(pWapiInfo->wapiBKIDStoreList))) { pWapiBkid = (PRT_WAPI_BKID)list_entry(pWapiInfo->wapiBKIDStoreList.next, RT_WAPI_BKID, list); list_del_init(&pWapiBkid->list); _rtw_memset(pWapiBkid->bkid, 0, 16); list_add_tail(&pWapiBkid->list, &pWapiInfo->wapiBKIDIdleList); } } WAPI_TRACE(WAPI_API, " %s: after clear bkid\n", __FUNCTION__); /* Remove STA info */ if (list_empty(&(pWapiInfo->wapiSTAUsedList))) { WAPI_TRACE(WAPI_API, " %s: wapiSTAUsedList is null\n", __FUNCTION__); return; } else { WAPI_TRACE(WAPI_API, " %s: wapiSTAUsedList is not null\n", __FUNCTION__); #if 0 pWapiStaInfo = (PRT_WAPI_STA_INFO)list_entry((pWapiInfo->wapiSTAUsedList.next), RT_WAPI_STA_INFO, list); list_for_each_entry(pWapiStaInfo, &(pWapiInfo->wapiSTAUsedList), list) { RTW_INFO("MAC Addr %02x-%02x-%02x-%02x-%02x-%02x\n", MacAddr[0], MacAddr[1], MacAddr[2], MacAddr[3], MacAddr[4], MacAddr[5]); RTW_INFO("peer Addr %02x-%02x-%02x-%02x-%02x-%02x\n", pWapiStaInfo->PeerMacAddr[0], pWapiStaInfo->PeerMacAddr[1], pWapiStaInfo->PeerMacAddr[2], pWapiStaInfo->PeerMacAddr[3], pWapiStaInfo->PeerMacAddr[4], pWapiStaInfo->PeerMacAddr[5]); if (pWapiStaInfo == NULL) { WAPI_TRACE(WAPI_API, " %s: pWapiStaInfo == NULL Case\n", __FUNCTION__); return; } if (pWapiStaInfo->PeerMacAddr == NULL) { WAPI_TRACE(WAPI_API, " %s: pWapiStaInfo->PeerMacAddr == NULL Case\n", __FUNCTION__); return; } if (MacAddr == NULL) { WAPI_TRACE(WAPI_API, " %s: MacAddr == NULL Case\n", __FUNCTION__); return; } if (_rtw_memcmp(pWapiStaInfo->PeerMacAddr, MacAddr, ETH_ALEN) == _TRUE) { pWapiStaInfo->bAuthenticateInProgress = false; pWapiStaInfo->bSetkeyOk = false; _rtw_memset(pWapiStaInfo->PeerMacAddr, 0, ETH_ALEN); list_del_init(&pWapiStaInfo->list); list_add_tail(&pWapiStaInfo->list, &pWapiInfo->wapiSTAIdleList); break; } } #endif while (!list_empty(&(pWapiInfo->wapiSTAUsedList))) { pWapiStaInfo = (PRT_WAPI_STA_INFO)list_entry(pWapiInfo->wapiSTAUsedList.next, RT_WAPI_STA_INFO, list); RTW_INFO("peer Addr %02x-%02x-%02x-%02x-%02x-%02x\n", pWapiStaInfo->PeerMacAddr[0], pWapiStaInfo->PeerMacAddr[1], pWapiStaInfo->PeerMacAddr[2], pWapiStaInfo->PeerMacAddr[3], pWapiStaInfo->PeerMacAddr[4], pWapiStaInfo->PeerMacAddr[5]); list_del_init(&pWapiStaInfo->list); memset(pWapiStaInfo->PeerMacAddr, 0, ETH_ALEN); pWapiStaInfo->bSetkeyOk = 0; list_add_tail(&pWapiStaInfo->list, &pWapiInfo->wapiSTAIdleList); } } WAPI_TRACE(WAPI_API, "<========== %s\n", __FUNCTION__); return; } void rtw_wapi_return_all_sta_info(_adapter *padapter) { PRT_WAPI_T pWapiInfo; PRT_WAPI_STA_INFO pWapiStaInfo; PRT_WAPI_BKID pWapiBkid; WAPI_TRACE(WAPI_API, "===========> %s\n", __FUNCTION__); pWapiInfo = &padapter->wapiInfo; if ((!padapter->WapiSupport) || (!pWapiInfo->bWapiEnable)) { WAPI_TRACE(WAPI_MLME, "<========== %s, WAPI not supported or not enabled!\n", __FUNCTION__); return; } /* Sta Info List */ while (!list_empty(&(pWapiInfo->wapiSTAUsedList))) { pWapiStaInfo = (PRT_WAPI_STA_INFO)list_entry(pWapiInfo->wapiSTAUsedList.next, RT_WAPI_STA_INFO, list); list_del_init(&pWapiStaInfo->list); memset(pWapiStaInfo->PeerMacAddr, 0, ETH_ALEN); pWapiStaInfo->bSetkeyOk = 0; list_add_tail(&pWapiStaInfo->list, &pWapiInfo->wapiSTAIdleList); } /* BKID List */ while (!list_empty(&(pWapiInfo->wapiBKIDStoreList))) { pWapiBkid = (PRT_WAPI_BKID)list_entry(pWapiInfo->wapiBKIDStoreList.next, RT_WAPI_BKID, list); list_del_init(&pWapiBkid->list); memset(pWapiBkid->bkid, 0, 16); list_add_tail(&pWapiBkid->list, &pWapiInfo->wapiBKIDIdleList); } WAPI_TRACE(WAPI_API, "<========== %s\n", __FUNCTION__); } void rtw_wapi_clear_cam_entry(_adapter *padapter, u8 *pMacAddr) { u8 UcIndex = 0; WAPI_TRACE(WAPI_API, "===========> %s\n", __FUNCTION__); if ((!padapter->WapiSupport) || (!padapter->wapiInfo.bWapiEnable)) { WAPI_TRACE(WAPI_MLME, "<========== %s, WAPI not supported or not enabled!\n", __FUNCTION__); return; } UcIndex = WapiGetEntryForCamClear(padapter, pMacAddr, 0, 0); if (UcIndex != 0xff) { /* CAM_mark_invalid(Adapter, UcIndex); */ CAM_empty_entry(padapter, UcIndex); } UcIndex = WapiGetEntryForCamClear(padapter, pMacAddr, 1, 0); if (UcIndex != 0xff) { /* CAM_mark_invalid(Adapter, UcIndex); */ CAM_empty_entry(padapter, UcIndex); } UcIndex = WapiGetEntryForCamClear(padapter, pMacAddr, 0, 1); if (UcIndex != 0xff) { /* CAM_mark_invalid(Adapter, UcIndex); */ CAM_empty_entry(padapter, UcIndex); } UcIndex = WapiGetEntryForCamClear(padapter, pMacAddr, 1, 1); if (UcIndex != 0xff) { /* CAM_mark_invalid(padapter, UcIndex); */ CAM_empty_entry(padapter, UcIndex); } WAPI_TRACE(WAPI_API, "<========== %s\n", __FUNCTION__); } void rtw_wapi_clear_all_cam_entry(_adapter *padapter) { WAPI_TRACE(WAPI_API, "===========> %s\n", __FUNCTION__); if ((!padapter->WapiSupport) || (!padapter->wapiInfo.bWapiEnable)) { WAPI_TRACE(WAPI_MLME, "<========== %s, WAPI not supported or not enabled!\n", __FUNCTION__); return; } invalidate_cam_all(padapter); /* is this ok? */ WapiResetAllCamEntry(padapter); WAPI_TRACE(WAPI_API, "===========> %s\n", __FUNCTION__); } void rtw_wapi_set_key(_adapter *padapter, RT_WAPI_KEY *pWapiKey, RT_WAPI_STA_INFO *pWapiSta, u8 bGroupKey, u8 bUseDefaultKey) { PRT_WAPI_T pWapiInfo = &padapter->wapiInfo; u8 *pMacAddr = pWapiSta->PeerMacAddr; u32 EntryId = 0; BOOLEAN IsPairWise = false ; u8 EncAlgo; WAPI_TRACE(WAPI_API, "===========> %s\n", __FUNCTION__); if ((!padapter->WapiSupport) || (!padapter->wapiInfo.bWapiEnable)) { WAPI_TRACE(WAPI_API, "<========== %s, WAPI not supported or not enabled!\n", __FUNCTION__); return; } EncAlgo = _SMS4_; /* For Tx bc/mc pkt,use defualt key entry */ if (bUseDefaultKey) { /* when WAPI update key, keyid will be 0 or 1 by turns. */ if (pWapiKey->keyId == 0) EntryId = 0; else EntryId = 2; } else { /* tx/rx unicast pkt, or rx broadcast, find the key entry by peer's MacAddr */ EntryId = WapiGetEntryForCamWrite(padapter, pMacAddr, pWapiKey->keyId, bGroupKey); } if (EntryId == 0xff) { WAPI_TRACE(WAPI_API, "===>No entry for WAPI setkey! !!\n"); return; } /* EntryId is also used to diff Sec key and Mic key */ /* Sec Key */ WapiWriteOneCamEntry(padapter, pMacAddr, pWapiKey->keyId, /* keyid */ EntryId, /* entry */ EncAlgo, /* type */ bGroupKey, /* pairwise or group key */ pWapiKey->dataKey); /* MIC key */ WapiWriteOneCamEntry(padapter, pMacAddr, pWapiKey->keyId, /* keyid */ EntryId + 1, /* entry */ EncAlgo, /* type */ bGroupKey, /* pairwise or group key */ pWapiKey->micKey); WAPI_TRACE(WAPI_API, "Set Wapi Key :KeyId:%d,EntryId:%d,PairwiseKey:%d.\n", pWapiKey->keyId, EntryId, !bGroupKey); WAPI_TRACE(WAPI_API, "===========> %s\n", __FUNCTION__); } #if 0 /* YJ,test,091013 */ void wapi_test_set_key(struct _adapter *padapter, u8 *buf) { /*Data: keyType(1) + bTxEnable(1) + bAuthenticator(1) + bUpdate(1) + PeerAddr(6) + DataKey(16) + MicKey(16) + KeyId(1)*/ PRT_WAPI_T pWapiInfo = &padapter->wapiInfo; PRT_WAPI_BKID pWapiBkid; PRT_WAPI_STA_INFO pWapiSta; u8 data[43]; bool bTxEnable; bool bUpdate; bool bAuthenticator; u8 PeerAddr[6]; u8 WapiAEPNInitialValueSrc[16] = {0x37, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C} ; u8 WapiASUEPNInitialValueSrc[16] = {0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C} ; u8 WapiAEMultiCastPNInitialValueSrc[16] = {0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C, 0x36, 0x5C} ; WAPI_TRACE(WAPI_INIT, "===========>%s\n", __FUNCTION__); if (!padapter->WapiSupport) return; copy_from_user(data, buf, 43); bTxEnable = data[1]; bAuthenticator = data[2]; bUpdate = data[3]; memcpy(PeerAddr, data + 4, 6); if (data[0] == 0x3) { if (!list_empty(&(pWapiInfo->wapiBKIDIdleList))) { pWapiBkid = (PRT_WAPI_BKID)list_entry(pWapiInfo->wapiBKIDIdleList.next, RT_WAPI_BKID, list); list_del_init(&pWapiBkid->list); memcpy(pWapiBkid->bkid, data + 10, 16); WAPI_DATA(WAPI_INIT, "SetKey - BKID", pWapiBkid->bkid, 16); list_add_tail(&pWapiBkid->list, &pWapiInfo->wapiBKIDStoreList); } } else { list_for_each_entry(pWapiSta, &pWapiInfo->wapiSTAUsedList, list) { if (!memcmp(pWapiSta->PeerMacAddr, PeerAddr, 6)) { pWapiSta->bAuthenticatorInUpdata = false; switch (data[0]) { case 1: /* usk */ if (bAuthenticator) { /* authenticator */ memcpy(pWapiSta->lastTxUnicastPN, WapiAEPNInitialValueSrc, 16); if (!bUpdate) { /* first */ WAPI_TRACE(WAPI_INIT, "AE fisrt set usk\n"); pWapiSta->wapiUsk.bSet = true; memcpy(pWapiSta->wapiUsk.dataKey, data + 10, 16); memcpy(pWapiSta->wapiUsk.micKey, data + 26, 16); pWapiSta->wapiUsk.keyId = *(data + 42); pWapiSta->wapiUsk.bTxEnable = true; WAPI_DATA(WAPI_INIT, "SetKey - AE USK Data Key", pWapiSta->wapiUsk.dataKey, 16); WAPI_DATA(WAPI_INIT, "SetKey - AE USK Mic Key", pWapiSta->wapiUsk.micKey, 16); } else { /* update */ WAPI_TRACE(WAPI_INIT, "AE update usk\n"); pWapiSta->wapiUskUpdate.bSet = true; pWapiSta->bAuthenticatorInUpdata = true; memcpy(pWapiSta->wapiUskUpdate.dataKey, data + 10, 16); memcpy(pWapiSta->wapiUskUpdate.micKey, data + 26, 16); memcpy(pWapiSta->lastRxUnicastPNBEQueue, WapiASUEPNInitialValueSrc, 16); memcpy(pWapiSta->lastRxUnicastPNBKQueue, WapiASUEPNInitialValueSrc, 16); memcpy(pWapiSta->lastRxUnicastPNVIQueue, WapiASUEPNInitialValueSrc, 16); memcpy(pWapiSta->lastRxUnicastPNVOQueue, WapiASUEPNInitialValueSrc, 16); memcpy(pWapiSta->lastRxUnicastPN, WapiASUEPNInitialValueSrc, 16); pWapiSta->wapiUskUpdate.keyId = *(data + 42); pWapiSta->wapiUskUpdate.bTxEnable = true; } } else { if (!bUpdate) { WAPI_TRACE(WAPI_INIT, "ASUE fisrt set usk\n"); if (bTxEnable) { pWapiSta->wapiUsk.bTxEnable = true; memcpy(pWapiSta->lastTxUnicastPN, WapiASUEPNInitialValueSrc, 16); } else { pWapiSta->wapiUsk.bSet = true; memcpy(pWapiSta->wapiUsk.dataKey, data + 10, 16); memcpy(pWapiSta->wapiUsk.micKey, data + 26, 16); pWapiSta->wapiUsk.keyId = *(data + 42); pWapiSta->wapiUsk.bTxEnable = false; } } else { WAPI_TRACE(WAPI_INIT, "ASUE update usk\n"); if (bTxEnable) { pWapiSta->wapiUskUpdate.bTxEnable = true; if (pWapiSta->wapiUskUpdate.bSet) { memcpy(pWapiSta->wapiUsk.dataKey, pWapiSta->wapiUskUpdate.dataKey, 16); memcpy(pWapiSta->wapiUsk.micKey, pWapiSta->wapiUskUpdate.micKey, 16); pWapiSta->wapiUsk.keyId = pWapiSta->wapiUskUpdate.keyId; memcpy(pWapiSta->lastRxUnicastPNBEQueue, WapiASUEPNInitialValueSrc, 16); memcpy(pWapiSta->lastRxUnicastPNBKQueue, WapiASUEPNInitialValueSrc, 16); memcpy(pWapiSta->lastRxUnicastPNVIQueue, WapiASUEPNInitialValueSrc, 16); memcpy(pWapiSta->lastRxUnicastPNVOQueue, WapiASUEPNInitialValueSrc, 16); memcpy(pWapiSta->lastRxUnicastPN, WapiASUEPNInitialValueSrc, 16); pWapiSta->wapiUskUpdate.bTxEnable = false; pWapiSta->wapiUskUpdate.bSet = false; } memcpy(pWapiSta->lastTxUnicastPN, WapiASUEPNInitialValueSrc, 16); } else { pWapiSta->wapiUskUpdate.bSet = true; memcpy(pWapiSta->wapiUskUpdate.dataKey, data + 10, 16); memcpy(pWapiSta->wapiUskUpdate.micKey, data + 26, 16); pWapiSta->wapiUskUpdate.keyId = *(data + 42); pWapiSta->wapiUskUpdate.bTxEnable = false; } } } break; case 2: /* msk */ if (bAuthenticator) { /* authenticator */ pWapiInfo->wapiTxMsk.bSet = true; memcpy(pWapiInfo->wapiTxMsk.dataKey, data + 10, 16); memcpy(pWapiInfo->wapiTxMsk.micKey, data + 26, 16); pWapiInfo->wapiTxMsk.keyId = *(data + 42); pWapiInfo->wapiTxMsk.bTxEnable = true; memcpy(pWapiInfo->lastTxMulticastPN, WapiAEMultiCastPNInitialValueSrc, 16); if (!bUpdate) { /* first */ WAPI_TRACE(WAPI_INIT, "AE fisrt set msk\n"); if (!pWapiSta->bSetkeyOk) pWapiSta->bSetkeyOk = true; pWapiInfo->bFirstAuthentiateInProgress = false; } else /* update */ WAPI_TRACE(WAPI_INIT, "AE update msk\n"); WAPI_DATA(WAPI_INIT, "SetKey - AE MSK Data Key", pWapiInfo->wapiTxMsk.dataKey, 16); WAPI_DATA(WAPI_INIT, "SetKey - AE MSK Mic Key", pWapiInfo->wapiTxMsk.micKey, 16); } else { if (!bUpdate) { WAPI_TRACE(WAPI_INIT, "ASUE fisrt set msk\n"); pWapiSta->wapiMsk.bSet = true; memcpy(pWapiSta->wapiMsk.dataKey, data + 10, 16); memcpy(pWapiSta->wapiMsk.micKey, data + 26, 16); pWapiSta->wapiMsk.keyId = *(data + 42); pWapiSta->wapiMsk.bTxEnable = false; if (!pWapiSta->bSetkeyOk) pWapiSta->bSetkeyOk = true; pWapiInfo->bFirstAuthentiateInProgress = false; WAPI_DATA(WAPI_INIT, "SetKey - ASUE MSK Data Key", pWapiSta->wapiMsk.dataKey, 16); WAPI_DATA(WAPI_INIT, "SetKey - ASUE MSK Mic Key", pWapiSta->wapiMsk.micKey, 16); } else { WAPI_TRACE(WAPI_INIT, "ASUE update msk\n"); pWapiSta->wapiMskUpdate.bSet = true; memcpy(pWapiSta->wapiMskUpdate.dataKey, data + 10, 16); memcpy(pWapiSta->wapiMskUpdate.micKey, data + 26, 16); pWapiSta->wapiMskUpdate.keyId = *(data + 42); pWapiSta->wapiMskUpdate.bTxEnable = false; } } break; default: WAPI_TRACE(WAPI_ERR, "Unknown Flag\n"); break; } } } } WAPI_TRACE(WAPI_INIT, "<===========%s\n", __FUNCTION__); } void wapi_test_init(struct _adapter *padapter) { u8 keybuf[100]; u8 mac_addr[6] = {0x00, 0xe0, 0x4c, 0x72, 0x04, 0x70}; u8 UskDataKey[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; u8 UskMicKey[16] = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}; u8 UskId = 0; u8 MskDataKey[16] = {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f}; u8 MskMicKey[16] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}; u8 MskId = 0; WAPI_TRACE(WAPI_INIT, "===========>%s\n", __FUNCTION__); /* Enable Wapi */ WAPI_TRACE(WAPI_INIT, "%s: Enable wapi!!!!\n", __FUNCTION__); padapter->wapiInfo.bWapiEnable = true; padapter->pairwise_key_type = KEY_TYPE_SMS4; ieee->group_key_type = KEY_TYPE_SMS4; padapter->wapiInfo.extra_prefix_len = WAPI_EXT_LEN; padapter->wapiInfo.extra_postfix_len = SMS4_MIC_LEN; /* set usk */ WAPI_TRACE(WAPI_INIT, "%s: Set USK!!!!\n", __FUNCTION__); memset(keybuf, 0, 100); keybuf[0] = 1; /* set usk */ keybuf[1] = 1; /* enable tx */ keybuf[2] = 1; /* AE */ keybuf[3] = 0; /* not update */ memcpy(keybuf + 4, mac_addr, 6); memcpy(keybuf + 10, UskDataKey, 16); memcpy(keybuf + 26, UskMicKey, 16); keybuf[42] = UskId; wapi_test_set_key(padapter, keybuf); memset(keybuf, 0, 100); keybuf[0] = 1; /* set usk */ keybuf[1] = 1; /* enable tx */ keybuf[2] = 0; /* AE */ keybuf[3] = 0; /* not update */ memcpy(keybuf + 4, mac_addr, 6); memcpy(keybuf + 10, UskDataKey, 16); memcpy(keybuf + 26, UskMicKey, 16); keybuf[42] = UskId; wapi_test_set_key(padapter, keybuf); /* set msk */ WAPI_TRACE(WAPI_INIT, "%s: Set MSK!!!!\n", __FUNCTION__); memset(keybuf, 0, 100); keybuf[0] = 2; /* set msk */ keybuf[1] = 1; /* Enable TX */ keybuf[2] = 1; /* AE */ keybuf[3] = 0; /* not update */ memcpy(keybuf + 4, mac_addr, 6); memcpy(keybuf + 10, MskDataKey, 16); memcpy(keybuf + 26, MskMicKey, 16); keybuf[42] = MskId; wapi_test_set_key(padapter, keybuf); memset(keybuf, 0, 100); keybuf[0] = 2; /* set msk */ keybuf[1] = 1; /* Enable TX */ keybuf[2] = 0; /* AE */ keybuf[3] = 0; /* not update */ memcpy(keybuf + 4, mac_addr, 6); memcpy(keybuf + 10, MskDataKey, 16); memcpy(keybuf + 26, MskMicKey, 16); keybuf[42] = MskId; wapi_test_set_key(padapter, keybuf); WAPI_TRACE(WAPI_INIT, "<===========%s\n", __FUNCTION__); } #endif void rtw_wapi_get_iv(_adapter *padapter, u8 *pRA, u8 *IV) { PWLAN_HEADER_WAPI_EXTENSION pWapiExt = NULL; PRT_WAPI_T pWapiInfo = &padapter->wapiInfo; bool bPNOverflow = false; bool bFindMatchPeer = false; PRT_WAPI_STA_INFO pWapiSta = NULL; pWapiExt = (PWLAN_HEADER_WAPI_EXTENSION)IV; WAPI_DATA(WAPI_RX, "wapi_get_iv: pra", pRA, 6); if (IS_MCAST(pRA)) { if (!pWapiInfo->wapiTxMsk.bTxEnable) { WAPI_TRACE(WAPI_ERR, "%s: bTxEnable = 0!!\n", __FUNCTION__); return; } if (pWapiInfo->wapiTxMsk.keyId <= 1) { pWapiExt->KeyIdx = pWapiInfo->wapiTxMsk.keyId; pWapiExt->Reserved = 0; bPNOverflow = WapiIncreasePN(pWapiInfo->lastTxMulticastPN, 1); memcpy(pWapiExt->PN, pWapiInfo->lastTxMulticastPN, 16); } } else { if (list_empty(&pWapiInfo->wapiSTAUsedList)) { WAPI_TRACE(WAPI_RX, "rtw_wapi_get_iv: list is empty\n"); _rtw_memset(IV, 10, 18); return; } else { list_for_each_entry(pWapiSta, &pWapiInfo->wapiSTAUsedList, list) { WAPI_DATA(WAPI_RX, "rtw_wapi_get_iv: peermacaddr ", pWapiSta->PeerMacAddr, 6); if (_rtw_memcmp((u8 *)pWapiSta->PeerMacAddr, pRA, 6) == _TRUE) { bFindMatchPeer = true; break; } } WAPI_TRACE(WAPI_RX, "bFindMatchPeer: %d\n", bFindMatchPeer); WAPI_DATA(WAPI_RX, "Addr", pRA, 6); if (bFindMatchPeer) { if ((!pWapiSta->wapiUskUpdate.bTxEnable) && (!pWapiSta->wapiUsk.bTxEnable)) return; if (pWapiSta->wapiUsk.keyId <= 1) { if (pWapiSta->wapiUskUpdate.bTxEnable) pWapiExt->KeyIdx = pWapiSta->wapiUskUpdate.keyId; else pWapiExt->KeyIdx = pWapiSta->wapiUsk.keyId; pWapiExt->Reserved = 0; bPNOverflow = WapiIncreasePN(pWapiSta->lastTxUnicastPN, 2); _rtw_memcpy(pWapiExt->PN, pWapiSta->lastTxUnicastPN, 16); } } } } } bool rtw_wapi_drop_for_key_absent(_adapter *padapter, u8 *pRA) { PRT_WAPI_T pWapiInfo = &padapter->wapiInfo; bool bFindMatchPeer = false; bool bDrop = false; PRT_WAPI_STA_INFO pWapiSta = NULL; struct security_priv *psecuritypriv = &padapter->securitypriv; WAPI_DATA(WAPI_RX, "rtw_wapi_drop_for_key_absent: ra ", pRA, 6); if (psecuritypriv->dot11PrivacyAlgrthm == _SMS4_) { if ((!padapter->WapiSupport) || (!pWapiInfo->bWapiEnable)) return true; if (IS_MCAST(pRA)) { if (!pWapiInfo->wapiTxMsk.bTxEnable) { bDrop = true; WAPI_TRACE(WAPI_RX, "rtw_wapi_drop_for_key_absent: multicast key is absent\n"); return bDrop; } } else { if (!list_empty(&pWapiInfo->wapiSTAUsedList)) { list_for_each_entry(pWapiSta, &pWapiInfo->wapiSTAUsedList, list) { WAPI_DATA(WAPI_RX, "rtw_wapi_drop_for_key_absent: pWapiSta->PeerMacAddr ", pWapiSta->PeerMacAddr, 6); if (_rtw_memcmp(pRA, pWapiSta->PeerMacAddr, 6) == _TRUE) { bFindMatchPeer = true; break; } } if (bFindMatchPeer) { if (!pWapiSta->wapiUsk.bTxEnable) { bDrop = true; WAPI_TRACE(WAPI_RX, "rtw_wapi_drop_for_key_absent: unicast key is absent\n"); return bDrop; } } else { bDrop = true; WAPI_TRACE(WAPI_RX, "rtw_wapi_drop_for_key_absent: no peer find\n"); return bDrop; } } else { bDrop = true; WAPI_TRACE(WAPI_RX, "rtw_wapi_drop_for_key_absent: no sta exist\n"); return bDrop; } } } else return bDrop; return bDrop; } #endif
the_stack_data/22012859.c
#include <stdio.h> #include <math.h> float function(float xi){ return pow (xi,2) + 2*xi - 4; } float bisection (float a, float b, int i){ static float x; float f; float f_a; while (i != 0){ x = (a+b)/2; i--; f = function(x); f_a = function(a); if (f*f_a < 0){ b = x; a = a; }else if (f*f_a > 0){ a = x; b = b; } else return x; } return x; } int main() { float a = 0; /* Low Interval */ float b = 5; /* High Interval */ int i = 50; /* Iterations */ float res; res = bisection(a, b, i); printf ("\nRoot of x^2+2*x-4: %5f\n", res); return 0; }
the_stack_data/225143745.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { char *p = getenv("HOSTNAME"); printf("*p = %s\n", p); return 0; }
the_stack_data/22011682.c
// c) Create a structure Date with day, month, and year as data members. Include functions // getDate() and showDate() to read and print the date respectively. Write a program to // demonstrate the Date structure. #include <stdio.h> typedef struct date { int day, month, year; }date; void showdate(date d) { printf("Date:%d/%d/%d", d.day, d.month, d.year); } void getdate(date *d) { printf("Enter day,month,year:"); scanf("%d %d %d",&d->day,&d->month,&d->year); } int main() { date d; getdate(&d); showdate(d); }
the_stack_data/142073.c
/* Date: 24/05/2018 Description: Project 4 - Compare search algorithms Version 5.3 */ #include<stdio.h> #include<stdlib.h> #include<time.h> #define N 50000 #define hashSIZE 100003 void createFirstMatrix(); void createSecondMatrix(); int linearsearch(int firstMatrix[N], int secondMatrix[N]); int sortbinary(int firstMatrix[N], int secondMatrix[N]); int bubblesort(int *array); int binarysearch(int array[], int search); int openAddressing(int firstMatrix[N], int secondMatrix[N]); void fillHashTable(int *table, int num, int index); int searchHash(int *table, int num, int index); int firstMatrix[N], secondMatrix[N]; struct hash *hashTable = NULL; struct node { int key; struct node *next; }; struct hash { struct node *head; int count; }; struct node * createNode(int key); void insertToHash(int key); int searchInHash(int key); void chaining(); ///////////////////////////////////////////////////////////////////// int main(){ if (hashSIZE < N) { puts("HashSIZE < N"); system("PAUSE"); return -5; } printf_s("N = %d, Hash Size = %d\n", N, hashSIZE); srand(1047028); createFirstMatrix(); createSecondMatrix(); if (linearsearch(firstMatrix, secondMatrix)) return -1; if (sortbinary(firstMatrix, secondMatrix)) return -2; if (openAddressing(firstMatrix, secondMatrix)) return -3; chaining(); system("PAUSE"); return 0; } void createFirstMatrix() { unsigned int i; srand(1047028); for (i = 0; i<N; i++) { firstMatrix[i] = rand() % (10 * N); } return; } void createSecondMatrix() { unsigned int i, num1, num2; for (i = 0; i < N; i++) secondMatrix[i] = -1.0; for (i = 0; i < N / 2; i++) { num1 = rand() % N; num2 = rand() % N; secondMatrix[num1] = firstMatrix[num2]; } for (i = 0; i < N; i++) { if (secondMatrix[i] == -1) secondMatrix[i] = rand() % (10 * N); } return; } ///////////////////////////////////////////////////////////////////// int linearsearch(int firstMatrix[N], int secondMatrix[N]) { unsigned int i, j, counter = 0; clock_t start = clock(); for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { if (firstMatrix[i] == secondMatrix[j]) { counter++; break; } } } clock_t end = clock(); puts("1: Linear Search:"); printf_s(" Common numbers: %d, Time: %f\n", counter, (float)(end - start) / CLOCKS_PER_SEC); return 0; } ///////////////////////////////////////////////////////////////////// int sortbinary(int firstMatrix[N], int secondMatrix[N]) { unsigned int i, counter = 0; bubblesort(secondMatrix); clock_t start = clock(); for (i = 0; i < N; i++) { if (binarysearch(secondMatrix, firstMatrix[i]) == 1) counter++; } clock_t end = clock(); puts("2: Sort and Binary Search:"); printf_s(" Common numbers: %d, Time: %f\n", counter, (float)(end - start) / CLOCKS_PER_SEC); return 0; } int bubblesort(int *array) { int swap; for (int i = 0; i < N - 1; i++){ for (int j = 0; j < N - i - 1; j++){ if (array[j] > array[j + 1]){ swap = array[j]; array[j] = array[j + 1]; array[j + 1] = swap; } } } return; } int binarysearch(int array[], int search) { int first = 0, last = N - 1, middle = (first + last) / 2; while (first <= last) { if (array[middle] < search) first = middle + 1; else if (array[middle] == search) { return 1; } else last = middle - 1; middle = (first + last) / 2; } if (first > last) return 0; } ///////////////////////////////////////////////////////////////////// int openAddressing(int firstMatrix[N], int secondMatrix[N]) { unsigned int i, counter = 0, hashIndex; int hashTable[hashSIZE]; for (i = 0; i < hashSIZE; i++) hashTable[i] = -1.0; for (i = 0; i < N; i++) { hashIndex = (secondMatrix[i] % hashSIZE); fillHashTable(hashTable, secondMatrix[i], hashIndex); } clock_t start = clock(); for (i = 0; i < N; i++) { hashIndex = (firstMatrix[i] % hashSIZE); if (searchHash(hashTable, firstMatrix[i], hashIndex) == 1) counter++; } clock_t end = clock(); puts("3: Open Addressing Search:"); printf_s(" Common numbers: %d, Time: %f\n", counter, (float)(end - start) / CLOCKS_PER_SEC); return 0; } void fillHashTable(int *table, int num, int index) { if (table[index] == -1 || table[index] == num) table[index] = num; else { index++; while (index < hashSIZE) { if (table[index] == -1 || table[index] == num) { table[index] = num; break; } else { index++; if (index > hashSIZE) index = 0; // dont get out of array limits } } } } int searchHash(int *table, int num, int index) { while (1) { if (table[index] == num) return 1; else if (table[index] == -1) return 0; else { index++; if (index > hashSIZE) index = 0; } } } ///////////////////////////////////////////////////////////////////// void chaining() { unsigned int i, counter = 0; hashTable = (struct hash *)calloc(N, sizeof(struct hash)); for (i = 0; i < N; i++) { insertToHash(secondMatrix[i]); } clock_t start = clock(); for (i = 0; i < N; i++) { if (searchInHash(firstMatrix[i]) == 1) counter++; } clock_t end = clock(); puts("4: Chaining Search:"); printf_s(" Common numbers: %d, Time: %f\n", counter, (float)(end - start) / CLOCKS_PER_SEC); } struct node * createNode(int key) { struct node *newnode; newnode = (struct node *)malloc(sizeof(struct node)); newnode->key = key; newnode->next = NULL; return newnode; } void insertToHash(int key) { int hashIndex = key % N; struct node *newnode = createNode(key); /* head of list for the bucket with index "hashIndex" */ if (!hashTable[hashIndex].head) { hashTable[hashIndex].head = newnode; hashTable[hashIndex].count = 1; return; } /* adding new node to the list */ newnode->next = (hashTable[hashIndex].head); /* * update the head of the list and no of * nodes in the current bucket */ hashTable[hashIndex].head = newnode; hashTable[hashIndex].count++; return; } int searchInHash(int key) { int hashIndex = key % N, flag = 0; struct node *myNode; myNode = hashTable[hashIndex].head; if (!myNode) return 0;//Search element unavailable in hash table while (myNode != NULL) { if (myNode->key == key) { flag = 1; return 1;/////////////////// break; } myNode = myNode->next; } if (!flag) return 0;//Search element unavailable in hash table }
the_stack_data/104828143.c
#include <stdio.h> #pragma warning(disable : 4996) #define SIZE 15 #define B_SIZE 30 typedef struct car { char brand[SIZE]; char model[SIZE]; int price; float co2_emission; } car; int main(void) { car cars[SIZE] = { {"Fiat", "Panda", 16000, 91}, {"Seat", "Ibiza", 15000, 100}, {"Volkswagen", "Polo", 10000, 120}, {"Dacia", "Logan", 22000, 80}, {"Aston Martin", "Vanquish", 11500, 70}, {"Fiat", "Punto", 30000, 50}, {"Nissan", "Micra", 26000, 120}, {"Porsche", "918", 25000, 100}, {"Ford", "Focus", 21000, 96}, {"Ford", "Fiesta", 13000, 250}, {"Audi", "A4", 23500, 150}, {"Honda", "Accord", 18000, 80}, {"Skoda", "Octavia", 23000, 50}, {"Toyota", "Yaris", 21750, 66}, {"Chevrolet", "Spark", 35000, 99} }; int input = 0; char buffer[B_SIZE]; FILE* write; write = fopen("text17.txt", "wb"); fwrite(cars, sizeof(car), SIZE, write); fclose(write); while (input != 3) { printf("1. print all cars in the file\n"); printf("2. add new car to the end of the file (ask user to enter information\n3. quit the program.\n"); fgets(buffer, B_SIZE, stdin); sscanf(buffer, "%d", &input); if (input == 1) { car temp; FILE *read; read = fopen("text17.txt", "rb"); while (fread(&temp, sizeof(car), 1, read)) { printf("%s: %s: %d: %.2f\n", temp.brand, temp.model, temp.price, temp.co2_emission); } fclose(read); } else if (input == 2) { FILE* append; car extra; car temp[SIZE + 1]; printf("Enter the brand of the car: "); fgets(buffer, B_SIZE, stdin); sscanf(buffer, "%[^\n]", extra.brand); printf("Enter the model of the car: "); fgets(buffer, B_SIZE, stdin); sscanf(buffer, "%[^\n]", extra.model); printf("Enter the price of the car: "); fgets(buffer, B_SIZE, stdin); sscanf(buffer, "%d", &extra.price); printf("Enter the co2 emissions of the car: "); fgets(buffer, B_SIZE, stdin); sscanf(buffer, "%f", &extra.co2_emission); append = fopen("text17.txt", "ab"); fwrite(&extra, sizeof(car), 1, append); fclose(append); } else if (input == 3) { puts("Quitting the program.."); } else { puts("Invalid input!"); } } return 0; }
the_stack_data/15763128.c
#include <stdio.h> #include <math.h> void merge_sort(int arr[], int start, int end); void display_arr(int items[], int size); int main(int argc, char *argv[]) { int arr[] = {1, 5, 8, 0, -1}; int len = sizeof(arr) / sizeof(arr[0]); merge_sort(arr, 0, len - 1); display_arr(arr, len); } void merge(int arr[], int start, int m, int end) { int l = m - start + 1; int r = end - m; int r_arr[l], l_arr[r]; int lp = 0; int rp = 0; int kp = start; while (lp < l) { l_arr[lp] = arr[start + lp]; lp++; } while (rp < r) { r_arr[rp] = arr[m + 1 + rp]; rp++; } lp = 0; rp = 0; while (lp < l && rp < r) { if (l_arr[lp] <= r_arr[rp]) { arr[kp] = l_arr[lp]; lp++; } else { arr[kp] = r_arr[rp]; rp++; } kp++; } while (lp < l) { arr[kp] = l_arr[lp]; kp++; lp++; } while (rp < r) { arr[kp] = r_arr[rp]; kp++; rp++; } } // Time Complexity: Ω(n log(n)) Θ(n log(n)) O(n log(n)) // Space complexity: O(n) void merge_sort(int arr[], int start, int end) { if (start < end) { int m = round((start + end) / 2); merge_sort(arr, start, m); merge_sort(arr, m + 1, end); merge(arr, start, m, end); } } void display_arr(int items[], int size) { for (int i = 0; i < size; i++) { printf("%d\t", items[i]); } printf("\n"); }
the_stack_data/50138222.c
#if defined(__SAM3X8E__) || defined(__SAM3X8H__) #include "../hal/osal.h" #if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC #if OSAL_ST_FREQUENCY != 1000 #error "Due only supports CH_CFG_ST_FREQUENCY == 1000" #endif static int sysTickEnabled = 0; int sysTickHook(void) { if (sysTickEnabled) { CH_IRQ_PROLOGUE(); chSysLockFromISR(); chSysTimerHandlerI(); chSysUnlockFromISR(); CH_IRQ_EPILOGUE(); } return 0; } void st_lld_init(void) { sysTickEnabled = 1; } #endif // OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC #endif // defined(__SAM3X8E__) || defined(__SAM3X8H__)
the_stack_data/11074447.c
// MIT License // // Copyright (c) 2013-2020 Robert Nystrom and Wren Contributors // // 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", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // Begin file "wren.h" #ifndef wren_h #define wren_h #include <stdarg.h> #include <stdlib.h> #include <stdbool.h> // The Wren semantic version number components. #define WREN_VERSION_MAJOR 0 #define WREN_VERSION_MINOR 3 #define WREN_VERSION_PATCH 0 // A human-friendly string representation of the version. #define WREN_VERSION_STRING "0.3.0" // A monotonically increasing numeric representation of the version number. Use // this if you want to do range checks over versions. #define WREN_VERSION_NUMBER (WREN_VERSION_MAJOR * 1000000 + \ WREN_VERSION_MINOR * 1000 + \ WREN_VERSION_PATCH) // A single virtual machine for executing Wren code. // // Wren has no global state, so all state stored by a running interpreter lives // here. typedef struct WrenVM WrenVM; // A handle to a Wren object. // // This lets code outside of the VM hold a persistent reference to an object. // After a handle is acquired, and until it is released, this ensures the // garbage collector will not reclaim the object it references. typedef struct WrenHandle WrenHandle; // A generic allocation function that handles all explicit memory management // used by Wren. It's used like so: // // - To allocate new memory, [memory] is NULL and [newSize] is the desired // size. It should return the allocated memory or NULL on failure. // // - To attempt to grow an existing allocation, [memory] is the memory, and // [newSize] is the desired size. It should return [memory] if it was able to // grow it in place, or a new pointer if it had to move it. // // - To shrink memory, [memory] and [newSize] are the same as above but it will // always return [memory]. // // - To free memory, [memory] will be the memory to free and [newSize] will be // zero. It should return NULL. typedef void* (*WrenReallocateFn)(void* memory, size_t newSize); // A function callable from Wren code, but implemented in C. typedef void (*WrenForeignMethodFn)(WrenVM* vm); // A finalizer function for freeing resources owned by an instance of a foreign // class. Unlike most foreign methods, finalizers do not have access to the VM // and should not interact with it since it's in the middle of a garbage // collection. typedef void (*WrenFinalizerFn)(void* data); // Gives the host a chance to canonicalize the imported module name, // potentially taking into account the (previously resolved) name of the module // that contains the import. Typically, this is used to implement relative // imports. typedef const char* (*WrenResolveModuleFn)(WrenVM* vm, const char* importer, const char* name); // Loads and returns the source code for the module [name]. typedef char* (*WrenLoadModuleFn)(WrenVM* vm, const char* name); // Returns a pointer to a foreign method on [className] in [module] with // [signature]. typedef WrenForeignMethodFn (*WrenBindForeignMethodFn)(WrenVM* vm, const char* module, const char* className, bool isStatic, const char* signature); // Displays a string of text to the user. typedef void (*WrenWriteFn)(WrenVM* vm, const char* text); typedef enum { // A syntax or resolution error detected at compile time. WREN_ERROR_COMPILE, // The error message for a runtime error. WREN_ERROR_RUNTIME, // One entry of a runtime error's stack trace. WREN_ERROR_STACK_TRACE } WrenErrorType; // Reports an error to the user. // // An error detected during compile time is reported by calling this once with // [type] `WREN_ERROR_COMPILE`, the resolved name of the [module] and [line] // where the error occurs, and the compiler's error [message]. // // A runtime error is reported by calling this once with [type] // `WREN_ERROR_RUNTIME`, no [module] or [line], and the runtime error's // [message]. After that, a series of [type] `WREN_ERROR_STACK_TRACE` calls are // made for each line in the stack trace. Each of those has the resolved // [module] and [line] where the method or function is defined and [message] is // the name of the method or function. typedef void (*WrenErrorFn)( WrenVM* vm, WrenErrorType type, const char* module, int line, const char* message); typedef struct { // The callback invoked when the foreign object is created. // // This must be provided. Inside the body of this, it must call // [wrenSetSlotNewForeign()] exactly once. WrenForeignMethodFn allocate; // The callback invoked when the garbage collector is about to collect a // foreign object's memory. // // This may be `NULL` if the foreign class does not need to finalize. WrenFinalizerFn finalize; } WrenForeignClassMethods; // Returns a pair of pointers to the foreign methods used to allocate and // finalize the data for instances of [className] in resolved [module]. typedef WrenForeignClassMethods (*WrenBindForeignClassFn)( WrenVM* vm, const char* module, const char* className); typedef struct { // The callback Wren will use to allocate, reallocate, and deallocate memory. // // If `NULL`, defaults to a built-in function that uses `realloc` and `free`. WrenReallocateFn reallocateFn; // The callback Wren uses to resolve a module name. // // Some host applications may wish to support "relative" imports, where the // meaning of an import string depends on the module that contains it. To // support that without baking any policy into Wren itself, the VM gives the // host a chance to resolve an import string. // // Before an import is loaded, it calls this, passing in the name of the // module that contains the import and the import string. The host app can // look at both of those and produce a new "canonical" string that uniquely // identifies the module. This string is then used as the name of the module // going forward. It is what is passed to [loadModuleFn], how duplicate // imports of the same module are detected, and how the module is reported in // stack traces. // // If you leave this function NULL, then the original import string is // treated as the resolved string. // // If an import cannot be resolved by the embedder, it should return NULL and // Wren will report that as a runtime error. // // Wren will take ownership of the string you return and free it for you, so // it should be allocated using the same allocation function you provide // above. WrenResolveModuleFn resolveModuleFn; // The callback Wren uses to load a module. // // Since Wren does not talk directly to the file system, it relies on the // embedder to physically locate and read the source code for a module. The // first time an import appears, Wren will call this and pass in the name of // the module being imported. The VM should return the soure code for that // module. Memory for the source should be allocated using [reallocateFn] and // Wren will take ownership over it. // // This will only be called once for any given module name. Wren caches the // result internally so subsequent imports of the same module will use the // previous source and not call this. // // If a module with the given name could not be found by the embedder, it // should return NULL and Wren will report that as a runtime error. WrenLoadModuleFn loadModuleFn; // The callback Wren uses to find a foreign method and bind it to a class. // // When a foreign method is declared in a class, this will be called with the // foreign method's module, class, and signature when the class body is // executed. It should return a pointer to the foreign function that will be // bound to that method. // // If the foreign function could not be found, this should return NULL and // Wren will report it as runtime error. WrenBindForeignMethodFn bindForeignMethodFn; // The callback Wren uses to find a foreign class and get its foreign methods. // // When a foreign class is declared, this will be called with the class's // module and name when the class body is executed. It should return the // foreign functions uses to allocate and (optionally) finalize the bytes // stored in the foreign object when an instance is created. WrenBindForeignClassFn bindForeignClassFn; // The callback Wren uses to display text when `System.print()` or the other // related functions are called. // // If this is `NULL`, Wren discards any printed text. WrenWriteFn writeFn; // The callback Wren uses to report errors. // // When an error occurs, this will be called with the module name, line // number, and an error message. If this is `NULL`, Wren doesn't report any // errors. WrenErrorFn errorFn; // The number of bytes Wren will allocate before triggering the first garbage // collection. // // If zero, defaults to 10MB. size_t initialHeapSize; // After a collection occurs, the threshold for the next collection is // determined based on the number of bytes remaining in use. This allows Wren // to shrink its memory usage automatically after reclaiming a large amount // of memory. // // This can be used to ensure that the heap does not get too small, which can // in turn lead to a large number of collections afterwards as the heap grows // back to a usable size. // // If zero, defaults to 1MB. size_t minHeapSize; // Wren will resize the heap automatically as the number of bytes // remaining in use after a collection changes. This number determines the // amount of additional memory Wren will use after a collection, as a // percentage of the current heap size. // // For example, say that this is 50. After a garbage collection, when there // are 400 bytes of memory still in use, the next collection will be triggered // after a total of 600 bytes are allocated (including the 400 already in // use.) // // Setting this to a smaller number wastes less memory, but triggers more // frequent garbage collections. // // If zero, defaults to 50. int heapGrowthPercent; // User-defined data associated with the VM. void* userData; } WrenConfiguration; typedef enum { WREN_RESULT_SUCCESS, WREN_RESULT_COMPILE_ERROR, WREN_RESULT_RUNTIME_ERROR } WrenInterpretResult; // The type of an object stored in a slot. // // This is not necessarily the object's *class*, but instead its low level // representation type. typedef enum { WREN_TYPE_BOOL, WREN_TYPE_NUM, WREN_TYPE_FOREIGN, WREN_TYPE_LIST, WREN_TYPE_MAP, WREN_TYPE_NULL, WREN_TYPE_STRING, // The object is of a type that isn't accessible by the C API. WREN_TYPE_UNKNOWN } WrenType; // Initializes [configuration] with all of its default values. // // Call this before setting the particular fields you care about. void wrenInitConfiguration(WrenConfiguration* configuration); // Creates a new Wren virtual machine using the given [configuration]. Wren // will copy the configuration data, so the argument passed to this can be // freed after calling this. If [configuration] is `NULL`, uses a default // configuration. WrenVM* wrenNewVM(WrenConfiguration* configuration); // Disposes of all resources is use by [vm], which was previously created by a // call to [wrenNewVM]. void wrenFreeVM(WrenVM* vm); // Immediately run the garbage collector to free unused memory. void wrenCollectGarbage(WrenVM* vm); // Runs [source], a string of Wren source code in a new fiber in [vm] in the // context of resolved [module]. WrenInterpretResult wrenInterpret(WrenVM* vm, const char* module, const char* source); // Creates a handle that can be used to invoke a method with [signature] on // using a receiver and arguments that are set up on the stack. // // This handle can be used repeatedly to directly invoke that method from C // code using [wrenCall]. // // When you are done with this handle, it must be released using // [wrenReleaseHandle]. WrenHandle* wrenMakeCallHandle(WrenVM* vm, const char* signature); // Calls [method], using the receiver and arguments previously set up on the // stack. // // [method] must have been created by a call to [wrenMakeCallHandle]. The // arguments to the method must be already on the stack. The receiver should be // in slot 0 with the remaining arguments following it, in order. It is an // error if the number of arguments provided does not match the method's // signature. // // After this returns, you can access the return value from slot 0 on the stack. WrenInterpretResult wrenCall(WrenVM* vm, WrenHandle* method); // Releases the reference stored in [handle]. After calling this, [handle] can // no longer be used. void wrenReleaseHandle(WrenVM* vm, WrenHandle* handle); // The following functions are intended to be called from foreign methods or // finalizers. The interface Wren provides to a foreign method is like a // register machine: you are given a numbered array of slots that values can be // read from and written to. Values always live in a slot (unless explicitly // captured using wrenGetSlotHandle(), which ensures the garbage collector can // find them. // // When your foreign function is called, you are given one slot for the receiver // and each argument to the method. The receiver is in slot 0 and the arguments // are in increasingly numbered slots after that. You are free to read and // write to those slots as you want. If you want more slots to use as scratch // space, you can call wrenEnsureSlots() to add more. // // When your function returns, every slot except slot zero is discarded and the // value in slot zero is used as the return value of the method. If you don't // store a return value in that slot yourself, it will retain its previous // value, the receiver. // // While Wren is dynamically typed, C is not. This means the C interface has to // support the various types of primitive values a Wren variable can hold: bool, // double, string, etc. If we supported this for every operation in the C API, // there would be a combinatorial explosion of functions, like "get a // double-valued element from a list", "insert a string key and double value // into a map", etc. // // To avoid that, the only way to convert to and from a raw C value is by going // into and out of a slot. All other functions work with values already in a // slot. So, to add an element to a list, you put the list in one slot, and the // element in another. Then there is a single API function wrenInsertInList() // that takes the element out of that slot and puts it into the list. // // The goal of this API is to be easy to use while not compromising performance. // The latter means it does not do type or bounds checking at runtime except // using assertions which are generally removed from release builds. C is an // unsafe language, so it's up to you to be careful to use it correctly. In // return, you get a very fast FFI. // Returns the number of slots available to the current foreign method. int wrenGetSlotCount(WrenVM* vm); // Ensures that the foreign method stack has at least [numSlots] available for // use, growing the stack if needed. // // Does not shrink the stack if it has more than enough slots. // // It is an error to call this from a finalizer. void wrenEnsureSlots(WrenVM* vm, int numSlots); // Gets the type of the object in [slot]. WrenType wrenGetSlotType(WrenVM* vm, int slot); // Reads a boolean value from [slot]. // // It is an error to call this if the slot does not contain a boolean value. bool wrenGetSlotBool(WrenVM* vm, int slot); // Reads a byte array from [slot]. // // The memory for the returned string is owned by Wren. You can inspect it // while in your foreign method, but cannot keep a pointer to it after the // function returns, since the garbage collector may reclaim it. // // Returns a pointer to the first byte of the array and fill [length] with the // number of bytes in the array. // // It is an error to call this if the slot does not contain a string. const char* wrenGetSlotBytes(WrenVM* vm, int slot, int* length); // Reads a number from [slot]. // // It is an error to call this if the slot does not contain a number. double wrenGetSlotDouble(WrenVM* vm, int slot); // Reads a foreign object from [slot] and returns a pointer to the foreign data // stored with it. // // It is an error to call this if the slot does not contain an instance of a // foreign class. void* wrenGetSlotForeign(WrenVM* vm, int slot); // Reads a string from [slot]. // // The memory for the returned string is owned by Wren. You can inspect it // while in your foreign method, but cannot keep a pointer to it after the // function returns, since the garbage collector may reclaim it. // // It is an error to call this if the slot does not contain a string. const char* wrenGetSlotString(WrenVM* vm, int slot); // Creates a handle for the value stored in [slot]. // // This will prevent the object that is referred to from being garbage collected // until the handle is released by calling [wrenReleaseHandle()]. WrenHandle* wrenGetSlotHandle(WrenVM* vm, int slot); // Stores the boolean [value] in [slot]. void wrenSetSlotBool(WrenVM* vm, int slot, bool value); // Stores the array [length] of [bytes] in [slot]. // // The bytes are copied to a new string within Wren's heap, so you can free // memory used by them after this is called. void wrenSetSlotBytes(WrenVM* vm, int slot, const char* bytes, size_t length); // Stores the numeric [value] in [slot]. void wrenSetSlotDouble(WrenVM* vm, int slot, double value); // Creates a new instance of the foreign class stored in [classSlot] with [size] // bytes of raw storage and places the resulting object in [slot]. // // This does not invoke the foreign class's constructor on the new instance. If // you need that to happen, call the constructor from Wren, which will then // call the allocator foreign method. In there, call this to create the object // and then the constructor will be invoked when the allocator returns. // // Returns a pointer to the foreign object's data. void* wrenSetSlotNewForeign(WrenVM* vm, int slot, int classSlot, size_t size); // Stores a new empty list in [slot]. void wrenSetSlotNewList(WrenVM* vm, int slot); // Stores a new empty map in [slot]. void wrenSetSlotNewMap(WrenVM* vm, int slot); // Stores null in [slot]. void wrenSetSlotNull(WrenVM* vm, int slot); // Stores the string [text] in [slot]. // // The [text] is copied to a new string within Wren's heap, so you can free // memory used by it after this is called. The length is calculated using // [strlen()]. If the string may contain any null bytes in the middle, then you // should use [wrenSetSlotBytes()] instead. void wrenSetSlotString(WrenVM* vm, int slot, const char* text); // Stores the value captured in [handle] in [slot]. // // This does not release the handle for the value. void wrenSetSlotHandle(WrenVM* vm, int slot, WrenHandle* handle); // Returns the number of elements in the list stored in [slot]. int wrenGetListCount(WrenVM* vm, int slot); // Reads element [index] from the list in [listSlot] and stores it in // [elementSlot]. void wrenGetListElement(WrenVM* vm, int listSlot, int index, int elementSlot); // Takes the value stored at [elementSlot] and inserts it into the list stored // at [listSlot] at [index]. // // As in Wren, negative indexes can be used to insert from the end. To append // an element, use `-1` for the index. void wrenInsertInList(WrenVM* vm, int listSlot, int index, int elementSlot); // Returns the number of entries in the map stored in [slot]. int wrenGetMapCount(WrenVM* vm, int slot); // Returns true if the key in [keySlot] is found in the map placed in [mapSlot]. bool wrenGetMapContainsKey(WrenVM* vm, int mapSlot, int keySlot); // Retrieves a value with the key in [keySlot] from the map in [mapSlot] and // stores it in [valueSlot]. void wrenGetMapValue(WrenVM* vm, int mapSlot, int keySlot, int valueSlot); // Takes the value stored at [valueSlot] and inserts it into the map stored // at [mapSlot] with key [keySlot]. void wrenSetMapValue(WrenVM* vm, int mapSlot, int keySlot, int valueSlot); // Removes a value from the map in [mapSlot], with the key from [keySlot], // and place it in [removedValueSlot]. If not found, [removedValueSlot] is // set to null, the same behaviour as the Wren Map API. void wrenRemoveMapValue(WrenVM* vm, int mapSlot, int keySlot, int removedValueSlot); // Looks up the top level variable with [name] in resolved [module] and stores // it in [slot]. void wrenGetVariable(WrenVM* vm, const char* module, const char* name, int slot); // Sets the current fiber to be aborted, and uses the value in [slot] as the // runtime error object. void wrenAbortFiber(WrenVM* vm, int slot); // Returns the user data associated with the WrenVM. void* wrenGetUserData(WrenVM* vm); // Sets user data associated with the WrenVM. void wrenSetUserData(WrenVM* vm, void* userData); #endif // End file "wren.h" // Begin file "wren_debug.h" #ifndef wren_debug_h #define wren_debug_h // Begin file "wren_value.h" #ifndef wren_value_h #define wren_value_h #include <stdbool.h> #include <string.h> // Begin file "wren_common.h" #ifndef wren_common_h #define wren_common_h // This header contains macros and defines used across the entire Wren // implementation. In particular, it contains "configuration" defines that // control how Wren works. Some of these are only used while hacking on Wren // itself. // // This header is *not* intended to be included by code outside of Wren itself. // Wren pervasively uses the C99 integer types (uint16_t, etc.) along with some // of the associated limit constants (UINT32_MAX, etc.). The constants are not // part of standard C++, so aren't included by default by C++ compilers when you // include <stdint> unless __STDC_LIMIT_MACROS is defined. #define __STDC_LIMIT_MACROS #include <stdint.h> // These flags let you control some details of the interpreter's implementation. // Usually they trade-off a bit of portability for speed. They default to the // most efficient behavior. // If true, then Wren uses a NaN-tagged double for its core value // representation. Otherwise, it uses a larger more conventional struct. The // former is significantly faster and more compact. The latter is useful for // debugging and may be more portable. // // Defaults to on. #ifndef WREN_NAN_TAGGING #define WREN_NAN_TAGGING 1 #endif // If true, the VM's interpreter loop uses computed gotos. See this for more: // http://gcc.gnu.org/onlinedocs/gcc-3.1.1/gcc/Labels-as-Values.html // Enabling this speeds up the main dispatch loop a bit, but requires compiler // support. // see https://bullno1.com/blog/switched-goto for alternative // Defaults to true on supported compilers. #ifndef WREN_COMPUTED_GOTO #if defined(_MSC_VER) && !defined(__clang__) // No computed gotos in Visual Studio. #define WREN_COMPUTED_GOTO 0 #else #define WREN_COMPUTED_GOTO 1 #endif #endif // The VM includes a number of optional modules. You can choose to include // these or not. By default, they are all available. To disable one, set the // corresponding `WREN_OPT_<name>` define to `0`. #ifndef WREN_OPT_META #define WREN_OPT_META 1 #endif #ifndef WREN_OPT_RANDOM #define WREN_OPT_RANDOM 1 #endif // These flags are useful for debugging and hacking on Wren itself. They are not // intended to be used for production code. They default to off. // Set this to true to stress test the GC. It will perform a collection before // every allocation. This is useful to ensure that memory is always correctly // reachable. #define WREN_DEBUG_GC_STRESS 0 // Set this to true to log memory operations as they occur. #define WREN_DEBUG_TRACE_MEMORY 0 // Set this to true to log garbage collections as they occur. #define WREN_DEBUG_TRACE_GC 0 // Set this to true to print out the compiled bytecode of each function. #define WREN_DEBUG_DUMP_COMPILED_CODE 0 // Set this to trace each instruction as it's executed. #define WREN_DEBUG_TRACE_INSTRUCTIONS 0 // The maximum number of module-level variables that may be defined at one time. // This limitation comes from the 16 bits used for the arguments to // `CODE_LOAD_MODULE_VAR` and `CODE_STORE_MODULE_VAR`. #define MAX_MODULE_VARS 65536 // The maximum number of arguments that can be passed to a method. Note that // this limitation is hardcoded in other places in the VM, in particular, the // `CODE_CALL_XX` instructions assume a certain maximum number. #define MAX_PARAMETERS 16 // The maximum name of a method, not including the signature. This is an // arbitrary but enforced maximum just so we know how long the method name // strings need to be in the parser. #define MAX_METHOD_NAME 64 // The maximum length of a method signature. Signatures look like: // // foo // Getter. // foo() // No-argument method. // foo(_) // One-argument method. // foo(_,_) // Two-argument method. // init foo() // Constructor initializer. // // The maximum signature length takes into account the longest method name, the // maximum number of parameters with separators between them, "init ", and "()". #define MAX_METHOD_SIGNATURE (MAX_METHOD_NAME + (MAX_PARAMETERS * 2) + 6) // The maximum length of an identifier. The only real reason for this limitation // is so that error messages mentioning variables can be stack allocated. #define MAX_VARIABLE_NAME 64 // The maximum number of fields a class can have, including inherited fields. // This is explicit in the bytecode since `CODE_CLASS` and `CODE_SUBCLASS` take // a single byte for the number of fields. Note that it's 255 and not 256 // because creating a class takes the *number* of fields, not the *highest // field index*. #define MAX_FIELDS 255 // Use the VM's allocator to allocate an object of [type]. #define ALLOCATE(vm, type) \ ((type*)wrenReallocate(vm, NULL, 0, sizeof(type))) // Use the VM's allocator to allocate an object of [mainType] containing a // flexible array of [count] objects of [arrayType]. #define ALLOCATE_FLEX(vm, mainType, arrayType, count) \ ((mainType*)wrenReallocate(vm, NULL, 0, \ sizeof(mainType) + sizeof(arrayType) * (count))) // Use the VM's allocator to allocate an array of [count] elements of [type]. #define ALLOCATE_ARRAY(vm, type, count) \ ((type*)wrenReallocate(vm, NULL, 0, sizeof(type) * (count))) // Use the VM's allocator to free the previously allocated memory at [pointer]. #define DEALLOCATE(vm, pointer) wrenReallocate(vm, pointer, 0, 0) // The Microsoft compiler does not support the "inline" modifier when compiling // as plain C. #if defined( _MSC_VER ) && !defined(__cplusplus) #define inline _inline #endif // This is used to clearly mark flexible-sized arrays that appear at the end of // some dynamically-allocated structs, known as the "struct hack". #if __STDC_VERSION__ >= 199901L // In C99, a flexible array member is just "[]". #define FLEXIBLE_ARRAY #else // Elsewhere, use a zero-sized array. It's technically undefined behavior, // but works reliably in most known compilers. #define FLEXIBLE_ARRAY 0 #endif // Assertions are used to validate program invariants. They indicate things the // program expects to be true about its internal state during execution. If an // assertion fails, there is a bug in Wren. // // Assertions add significant overhead, so are only enabled in debug builds. #ifdef DEBUG #include <stdio.h> #define ASSERT(condition, message) \ do \ { \ if (!(condition)) \ { \ fprintf(stderr, "[%s:%d] Assert failed in %s(): %s\n", \ __FILE__, __LINE__, __func__, message); \ abort(); \ } \ } while (false) // Indicates that we know execution should never reach this point in the // program. In debug mode, we assert this fact because it's a bug to get here. // // In release mode, we use compiler-specific built in functions to tell the // compiler the code can't be reached. This avoids "missing return" warnings // in some cases and also lets it perform some optimizations by assuming the // code is never reached. #define UNREACHABLE() \ do \ { \ fprintf(stderr, "[%s:%d] This code should not be reached in %s()\n", \ __FILE__, __LINE__, __func__); \ abort(); \ } while (false) #else #define ASSERT(condition, message) do { } while (false) // Tell the compiler that this part of the code will never be reached. #if defined( _MSC_VER ) #define UNREACHABLE() __assume(0) #elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) #define UNREACHABLE() __builtin_unreachable() #else #define UNREACHABLE() #endif #endif #endif // End file "wren_common.h" // Begin file "wren_utils.h" #ifndef wren_utils_h #define wren_utils_h // Reusable data structures and other utility functions. // Forward declare this here to break a cycle between wren_utils.h and // wren_value.h. typedef struct sObjString ObjString; // We need buffers of a few different types. To avoid lots of casting between // void* and back, we'll use the preprocessor as a poor man's generics and let // it generate a few type-specific ones. #define DECLARE_BUFFER(name, type) \ typedef struct \ { \ type* data; \ int count; \ int capacity; \ } name##Buffer; \ void wren##name##BufferInit(name##Buffer* buffer); \ void wren##name##BufferClear(WrenVM* vm, name##Buffer* buffer); \ void wren##name##BufferFill(WrenVM* vm, name##Buffer* buffer, type data, \ int count); \ void wren##name##BufferWrite(WrenVM* vm, name##Buffer* buffer, type data) // This should be used once for each type instantiation, somewhere in a .c file. #define DEFINE_BUFFER(name, type) \ void wren##name##BufferInit(name##Buffer* buffer) \ { \ buffer->data = NULL; \ buffer->capacity = 0; \ buffer->count = 0; \ } \ \ void wren##name##BufferClear(WrenVM* vm, name##Buffer* buffer) \ { \ wrenReallocate(vm, buffer->data, 0, 0); \ wren##name##BufferInit(buffer); \ } \ \ void wren##name##BufferFill(WrenVM* vm, name##Buffer* buffer, type data, \ int count) \ { \ if (buffer->capacity < buffer->count + count) \ { \ int capacity = wrenPowerOf2Ceil(buffer->count + count); \ buffer->data = (type*)wrenReallocate(vm, buffer->data, \ buffer->capacity * sizeof(type), capacity * sizeof(type)); \ buffer->capacity = capacity; \ } \ \ for (int i = 0; i < count; i++) \ { \ buffer->data[buffer->count++] = data; \ } \ } \ \ void wren##name##BufferWrite(WrenVM* vm, name##Buffer* buffer, type data) \ { \ wren##name##BufferFill(vm, buffer, data, 1); \ } DECLARE_BUFFER(Byte, uint8_t); DECLARE_BUFFER(Int, int); DECLARE_BUFFER(String, ObjString*); // TODO: Change this to use a map. typedef StringBuffer SymbolTable; // Initializes the symbol table. void wrenSymbolTableInit(SymbolTable* symbols); // Frees all dynamically allocated memory used by the symbol table, but not the // SymbolTable itself. void wrenSymbolTableClear(WrenVM* vm, SymbolTable* symbols); // Adds name to the symbol table. Returns the index of it in the table. int wrenSymbolTableAdd(WrenVM* vm, SymbolTable* symbols, const char* name, size_t length); // Adds name to the symbol table. Returns the index of it in the table. Will // use an existing symbol if already present. int wrenSymbolTableEnsure(WrenVM* vm, SymbolTable* symbols, const char* name, size_t length); // Looks up name in the symbol table. Returns its index if found or -1 if not. int wrenSymbolTableFind(const SymbolTable* symbols, const char* name, size_t length); void wrenBlackenSymbolTable(WrenVM* vm, SymbolTable* symbolTable); // Returns the number of bytes needed to encode [value] in UTF-8. // // Returns 0 if [value] is too large to encode. int wrenUtf8EncodeNumBytes(int value); // Encodes value as a series of bytes in [bytes], which is assumed to be large // enough to hold the encoded result. // // Returns the number of written bytes. int wrenUtf8Encode(int value, uint8_t* bytes); // Decodes the UTF-8 sequence starting at [bytes] (which has max [length]), // returning the code point. // // Returns -1 if the bytes are not a valid UTF-8 sequence. int wrenUtf8Decode(const uint8_t* bytes, uint32_t length); // Returns the number of bytes in the UTF-8 sequence starting with [byte]. // // If the character at that index is not the beginning of a UTF-8 sequence, // returns 0. int wrenUtf8DecodeNumBytes(uint8_t byte); // Returns the smallest power of two that is equal to or greater than [n]. int wrenPowerOf2Ceil(int n); #endif // End file "wren_utils.h" // This defines the built-in types and their core representations in memory. // Since Wren is dynamically typed, any variable can hold a value of any type, // and the type can change at runtime. Implementing this efficiently is // critical for performance. // // The main type exposed by this is [Value]. A C variable of that type is a // storage location that can hold any Wren value. The stack, module variables, // and instance fields are all implemented in C as variables of type Value. // // The built-in types for booleans, numbers, and null are unboxed: their value // is stored directly in the Value, and copying a Value copies the value. Other // types--classes, instances of classes, functions, lists, and strings--are all // reference types. They are stored on the heap and the Value just stores a // pointer to it. Copying the Value copies a reference to the same object. The // Wren implementation calls these "Obj", or objects, though to a user, all // values are objects. // // There is also a special singleton value "undefined". It is used internally // but never appears as a real value to a user. It has two uses: // // - It is used to identify module variables that have been implicitly declared // by use in a forward reference but not yet explicitly declared. These only // exist during compilation and do not appear at runtime. // // - It is used to represent unused map entries in an ObjMap. // // There are two supported Value representations. The main one uses a technique // called "NaN tagging" (explained in detail below) to store a number, any of // the value types, or a pointer, all inside one double-precision floating // point number. A larger, slower, Value type that uses a struct to store these // is also supported, and is useful for debugging the VM. // // The representation is controlled by the `WREN_NAN_TAGGING` define. If that's // defined, Nan tagging is used. // These macros cast a Value to one of the specific object types. These do *not* // perform any validation, so must only be used after the Value has been // ensured to be the right type. #define AS_CLASS(value) ((ObjClass*)AS_OBJ(value)) // ObjClass* #define AS_CLOSURE(value) ((ObjClosure*)AS_OBJ(value)) // ObjClosure* #define AS_FIBER(v) ((ObjFiber*)AS_OBJ(v)) // ObjFiber* #define AS_FN(value) ((ObjFn*)AS_OBJ(value)) // ObjFn* #define AS_FOREIGN(v) ((ObjForeign*)AS_OBJ(v)) // ObjForeign* #define AS_INSTANCE(value) ((ObjInstance*)AS_OBJ(value)) // ObjInstance* #define AS_LIST(value) ((ObjList*)AS_OBJ(value)) // ObjList* #define AS_MAP(value) ((ObjMap*)AS_OBJ(value)) // ObjMap* #define AS_MODULE(value) ((ObjModule*)AS_OBJ(value)) // ObjModule* #define AS_NUM(value) (wrenValueToNum(value)) // double #define AS_RANGE(v) ((ObjRange*)AS_OBJ(v)) // ObjRange* #define AS_STRING(v) ((ObjString*)AS_OBJ(v)) // ObjString* #define AS_CSTRING(v) (AS_STRING(v)->value) // const char* // These macros promote a primitive C value to a full Wren Value. There are // more defined below that are specific to the Nan tagged or other // representation. #define BOOL_VAL(boolean) ((boolean) ? TRUE_VAL : FALSE_VAL) // boolean #define NUM_VAL(num) (wrenNumToValue(num)) // double #define OBJ_VAL(obj) (wrenObjectToValue((Obj*)(obj))) // Any Obj___* // These perform type tests on a Value, returning `true` if the Value is of the // given type. #define IS_BOOL(value) (wrenIsBool(value)) // Bool #define IS_CLASS(value) (wrenIsObjType(value, OBJ_CLASS)) // ObjClass #define IS_CLOSURE(value) (wrenIsObjType(value, OBJ_CLOSURE)) // ObjClosure #define IS_FIBER(value) (wrenIsObjType(value, OBJ_FIBER)) // ObjFiber #define IS_FN(value) (wrenIsObjType(value, OBJ_FN)) // ObjFn #define IS_FOREIGN(value) (wrenIsObjType(value, OBJ_FOREIGN)) // ObjForeign #define IS_INSTANCE(value) (wrenIsObjType(value, OBJ_INSTANCE)) // ObjInstance #define IS_LIST(value) (wrenIsObjType(value, OBJ_LIST)) // ObjList #define IS_MAP(value) (wrenIsObjType(value, OBJ_MAP)) // ObjMap #define IS_RANGE(value) (wrenIsObjType(value, OBJ_RANGE)) // ObjRange #define IS_STRING(value) (wrenIsObjType(value, OBJ_STRING)) // ObjString // Creates a new string object from [text], which should be a bare C string // literal. This determines the length of the string automatically at compile // time based on the size of the character array (-1 for the terminating '\0'). #define CONST_STRING(vm, text) wrenNewStringLength((vm), (text), sizeof(text) - 1) // Identifies which specific type a heap-allocated object is. typedef enum { OBJ_CLASS, OBJ_CLOSURE, OBJ_FIBER, OBJ_FN, OBJ_FOREIGN, OBJ_INSTANCE, OBJ_LIST, OBJ_MAP, OBJ_MODULE, OBJ_RANGE, OBJ_STRING, OBJ_UPVALUE } ObjType; typedef struct sObjClass ObjClass; // Base struct for all heap-allocated objects. typedef struct sObj Obj; struct sObj { ObjType type; bool isDark; // The object's class. ObjClass* classObj; // The next object in the linked list of all currently allocated objects. struct sObj* next; }; #if WREN_NAN_TAGGING typedef uint64_t Value; #else typedef enum { VAL_FALSE, VAL_NULL, VAL_NUM, VAL_TRUE, VAL_UNDEFINED, VAL_OBJ } ValueType; typedef struct { ValueType type; union { double num; Obj* obj; } as; } Value; #endif DECLARE_BUFFER(Value, Value); // A heap-allocated string object. struct sObjString { Obj obj; // Number of bytes in the string, not including the null terminator. uint32_t length; // The hash value of the string's contents. uint32_t hash; // Inline array of the string's bytes followed by a null terminator. char value[FLEXIBLE_ARRAY]; }; // The dynamically allocated data structure for a variable that has been used // by a closure. Whenever a function accesses a variable declared in an // enclosing function, it will get to it through this. // // An upvalue can be either "closed" or "open". An open upvalue points directly // to a [Value] that is still stored on the fiber's stack because the local // variable is still in scope in the function where it's declared. // // When that local variable goes out of scope, the upvalue pointing to it will // be closed. When that happens, the value gets copied off the stack into the // upvalue itself. That way, it can have a longer lifetime than the stack // variable. typedef struct sObjUpvalue { // The object header. Note that upvalues have this because they are garbage // collected, but they are not first class Wren objects. Obj obj; // Pointer to the variable this upvalue is referencing. Value* value; // If the upvalue is closed (i.e. the local variable it was pointing to has // been popped off the stack) then the closed-over value will be hoisted out // of the stack into here. [value] will then be changed to point to this. Value closed; // Open upvalues are stored in a linked list by the fiber. This points to the // next upvalue in that list. struct sObjUpvalue* next; } ObjUpvalue; // The type of a primitive function. // // Primitives are similiar to foreign functions, but have more direct access to // VM internals. It is passed the arguments in [args]. If it returns a value, // it places it in `args[0]` and returns `true`. If it causes a runtime error // or modifies the running fiber, it returns `false`. typedef bool (*Primitive)(WrenVM* vm, Value* args); // TODO: See if it's actually a perf improvement to have this in a separate // struct instead of in ObjFn. // Stores debugging information for a function used for things like stack // traces. typedef struct { // The name of the function. Heap allocated and owned by the FnDebug. char* name; // An array of line numbers. There is one element in this array for each // bytecode in the function's bytecode array. The value of that element is // the line in the source code that generated that instruction. IntBuffer sourceLines; } FnDebug; // A loaded module and the top-level variables it defines. // // While this is an Obj and is managed by the GC, it never appears as a // first-class object in Wren. typedef struct { Obj obj; // The currently defined top-level variables. ValueBuffer variables; // Symbol table for the names of all module variables. Indexes here directly // correspond to entries in [variables]. SymbolTable variableNames; // The name of the module. ObjString* name; } ObjModule; // A function object. It wraps and owns the bytecode and other debug information // for a callable chunk of code. // // Function objects are not passed around and invoked directly. Instead, they // are always referenced by an [ObjClosure] which is the real first-class // representation of a function. This isn't strictly necessary if they function // has no upvalues, but lets the rest of the VM assume all called objects will // be closures. typedef struct { Obj obj; ByteBuffer code; ValueBuffer constants; // The module where this function was defined. ObjModule* module; // The maximum number of stack slots this function may use. int maxSlots; // The number of upvalues this function closes over. int numUpvalues; // The number of parameters this function expects. Used to ensure that .call // handles a mismatch between number of parameters and arguments. This will // only be set for fns, and not ObjFns that represent methods or scripts. int arity; FnDebug* debug; } ObjFn; // An instance of a first-class function and the environment it has closed over. // Unlike [ObjFn], this has captured the upvalues that the function accesses. typedef struct { Obj obj; // The function that this closure is an instance of. ObjFn* fn; // The upvalues this function has closed over. ObjUpvalue* upvalues[FLEXIBLE_ARRAY]; } ObjClosure; typedef struct { // Pointer to the current (really next-to-be-executed) instruction in the // function's bytecode. uint8_t* ip; // The closure being executed. ObjClosure* closure; // Pointer to the first stack slot used by this call frame. This will contain // the receiver, followed by the function's parameters, then local variables // and temporaries. Value* stackStart; } CallFrame; // Tracks how this fiber has been invoked, aside from the ways that can be // detected from the state of other fields in the fiber. typedef enum { // The fiber is being run from another fiber using a call to `try()`. FIBER_TRY, // The fiber was directly invoked by `runInterpreter()`. This means it's the // initial fiber used by a call to `wrenCall()` or `wrenInterpret()`. FIBER_ROOT, // The fiber is invoked some other way. If [caller] is `NULL` then the fiber // was invoked using `call()`. If [numFrames] is zero, then the fiber has // finished running and is done. If [numFrames] is one and that frame's `ip` // points to the first byte of code, the fiber has not been started yet. FIBER_OTHER, } FiberState; typedef struct sObjFiber { Obj obj; // The stack of value slots. This is used for holding local variables and // temporaries while the fiber is executing. It is heap-allocated and grown // as needed. Value* stack; // A pointer to one past the top-most value on the stack. Value* stackTop; // The number of allocated slots in the stack array. int stackCapacity; // The stack of call frames. This is a dynamic array that grows as needed but // never shrinks. CallFrame* frames; // The number of frames currently in use in [frames]. int numFrames; // The number of [frames] allocated. int frameCapacity; // Pointer to the first node in the linked list of open upvalues that are // pointing to values still on the stack. The head of the list will be the // upvalue closest to the top of the stack, and then the list works downwards. ObjUpvalue* openUpvalues; // The fiber that ran this one. If this fiber is yielded, control will resume // to this one. May be `NULL`. struct sObjFiber* caller; // If the fiber failed because of a runtime error, this will contain the // error object. Otherwise, it will be null. Value error; FiberState state; } ObjFiber; typedef enum { // A primitive method implemented in C in the VM. Unlike foreign methods, // this can directly manipulate the fiber's stack. METHOD_PRIMITIVE, // A primitive that handles .call on Fn. METHOD_FUNCTION_CALL, // A externally-defined C method. METHOD_FOREIGN, // A normal user-defined method. METHOD_BLOCK, // No method for the given symbol. METHOD_NONE } MethodType; typedef struct { MethodType type; // The method function itself. The [type] determines which field of the union // is used. union { Primitive primitive; WrenForeignMethodFn foreign; ObjClosure* closure; } as; } Method; DECLARE_BUFFER(Method, Method); struct sObjClass { Obj obj; ObjClass* superclass; // The number of fields needed for an instance of this class, including all // of its superclass fields. int numFields; // The table of methods that are defined in or inherited by this class. // Methods are called by symbol, and the symbol directly maps to an index in // this table. This makes method calls fast at the expense of empty cells in // the list for methods the class doesn't support. // // You can think of it as a hash table that never has collisions but has a // really low load factor. Since methods are pretty small (just a type and a // pointer), this should be a worthwhile trade-off. MethodBuffer methods; // The name of the class. ObjString* name; }; typedef struct { Obj obj; uint8_t data[FLEXIBLE_ARRAY]; } ObjForeign; typedef struct { Obj obj; Value fields[FLEXIBLE_ARRAY]; } ObjInstance; typedef struct { Obj obj; // The elements in the list. ValueBuffer elements; } ObjList; typedef struct { // The entry's key, or UNDEFINED_VAL if the entry is not in use. Value key; // The value associated with the key. If the key is UNDEFINED_VAL, this will // be false to indicate an open available entry or true to indicate a // tombstone -- an entry that was previously in use but was then deleted. Value value; } MapEntry; // A hash table mapping keys to values. // // We use something very simple: open addressing with linear probing. The hash // table is an array of entries. Each entry is a key-value pair. If the key is // the special UNDEFINED_VAL, it indicates no value is currently in that slot. // Otherwise, it's a valid key, and the value is the value associated with it. // // When entries are added, the array is dynamically scaled by GROW_FACTOR to // keep the number of filled slots under MAP_LOAD_PERCENT. Likewise, if the map // gets empty enough, it will be resized to a smaller array. When this happens, // all existing entries are rehashed and re-added to the new array. // // When an entry is removed, its slot is replaced with a "tombstone". This is an // entry whose key is UNDEFINED_VAL and whose value is TRUE_VAL. When probing // for a key, we will continue past tombstones, because the desired key may be // found after them if the key that was removed was part of a prior collision. // When the array gets resized, all tombstones are discarded. typedef struct { Obj obj; // The number of entries allocated. uint32_t capacity; // The number of entries in the map. uint32_t count; // Pointer to a contiguous array of [capacity] entries. MapEntry* entries; } ObjMap; typedef struct { Obj obj; // The beginning of the range. double from; // The end of the range. May be greater or less than [from]. double to; // True if [to] is included in the range. bool isInclusive; } ObjRange; // An IEEE 754 double-precision float is a 64-bit value with bits laid out like: // // 1 Sign bit // | 11 Exponent bits // | | 52 Mantissa (i.e. fraction) bits // | | | // S[Exponent-][Mantissa------------------------------------------] // // The details of how these are used to represent numbers aren't really // relevant here as long we don't interfere with them. The important bit is NaN. // // An IEEE double can represent a few magical values like NaN ("not a number"), // Infinity, and -Infinity. A NaN is any value where all exponent bits are set: // // v--NaN bits // -11111111111---------------------------------------------------- // // Here, "-" means "doesn't matter". Any bit sequence that matches the above is // a NaN. With all of those "-", it obvious there are a *lot* of different // bit patterns that all mean the same thing. NaN tagging takes advantage of // this. We'll use those available bit patterns to represent things other than // numbers without giving up any valid numeric values. // // NaN values come in two flavors: "signalling" and "quiet". The former are // intended to halt execution, while the latter just flow through arithmetic // operations silently. We want the latter. Quiet NaNs are indicated by setting // the highest mantissa bit: // // v--Highest mantissa bit // -[NaN ]1--------------------------------------------------- // // If all of the NaN bits are set, it's not a number. Otherwise, it is. // That leaves all of the remaining bits as available for us to play with. We // stuff a few different kinds of things here: special singleton values like // "true", "false", and "null", and pointers to objects allocated on the heap. // We'll use the sign bit to distinguish singleton values from pointers. If // it's set, it's a pointer. // // v--Pointer or singleton? // S[NaN ]1--------------------------------------------------- // // For singleton values, we just enumerate the different values. We'll use the // low bits of the mantissa for that, and only need a few: // // 3 Type bits--v // 0[NaN ]1------------------------------------------------[T] // // For pointers, we are left with 51 bits of mantissa to store an address. // That's more than enough room for a 32-bit address. Even 64-bit machines // only actually use 48 bits for addresses, so we've got plenty. We just stuff // the address right into the mantissa. // // Ta-da, double precision numbers, pointers, and a bunch of singleton values, // all stuffed into a single 64-bit sequence. Even better, we don't have to // do any masking or work to extract number values: they are unmodified. This // means math on numbers is fast. #if WREN_NAN_TAGGING // A mask that selects the sign bit. #define SIGN_BIT ((uint64_t)1 << 63) // The bits that must be set to indicate a quiet NaN. #define QNAN ((uint64_t)0x7ffc000000000000) // If the NaN bits are set, it's not a number. #define IS_NUM(value) (((value) & QNAN) != QNAN) // An object pointer is a NaN with a set sign bit. #define IS_OBJ(value) (((value) & (QNAN | SIGN_BIT)) == (QNAN | SIGN_BIT)) #define IS_FALSE(value) ((value) == FALSE_VAL) #define IS_NULL(value) ((value) == NULL_VAL) #define IS_UNDEFINED(value) ((value) == UNDEFINED_VAL) // Masks out the tag bits used to identify the singleton value. #define MASK_TAG (7) // Tag values for the different singleton values. #define TAG_NAN (0) #define TAG_NULL (1) #define TAG_FALSE (2) #define TAG_TRUE (3) #define TAG_UNDEFINED (4) #define TAG_UNUSED2 (5) #define TAG_UNUSED3 (6) #define TAG_UNUSED4 (7) // Value -> 0 or 1. #define AS_BOOL(value) ((value) == TRUE_VAL) // Value -> Obj*. #define AS_OBJ(value) ((Obj*)(uintptr_t)((value) & ~(SIGN_BIT | QNAN))) // Singleton values. #define NULL_VAL ((Value)(uint64_t)(QNAN | TAG_NULL)) #define FALSE_VAL ((Value)(uint64_t)(QNAN | TAG_FALSE)) #define TRUE_VAL ((Value)(uint64_t)(QNAN | TAG_TRUE)) #define UNDEFINED_VAL ((Value)(uint64_t)(QNAN | TAG_UNDEFINED)) // Gets the singleton type tag for a Value (which must be a singleton). #define GET_TAG(value) ((int)((value) & MASK_TAG)) #else // Value -> 0 or 1. #define AS_BOOL(value) ((value).type == VAL_TRUE) // Value -> Obj*. #define AS_OBJ(v) ((v).as.obj) // Determines if [value] is a garbage-collected object or not. #define IS_OBJ(value) ((value).type == VAL_OBJ) #define IS_FALSE(value) ((value).type == VAL_FALSE) #define IS_NULL(value) ((value).type == VAL_NULL) #define IS_NUM(value) ((value).type == VAL_NUM) #define IS_UNDEFINED(value) ((value).type == VAL_UNDEFINED) // Singleton values. #define FALSE_VAL ((Value){ VAL_FALSE, { 0 } }) #define NULL_VAL ((Value){ VAL_NULL, { 0 } }) #define TRUE_VAL ((Value){ VAL_TRUE, { 0 } }) #define UNDEFINED_VAL ((Value){ VAL_UNDEFINED, { 0 } }) #endif // A union to let us reinterpret a double as raw bits and back. typedef union { uint64_t bits64; uint32_t bits32[2]; double num; } DoubleBits; // Creates a new "raw" class. It has no metaclass or superclass whatsoever. // This is only used for bootstrapping the initial Object and Class classes, // which are a little special. ObjClass* wrenNewSingleClass(WrenVM* vm, int numFields, ObjString* name); // Makes [superclass] the superclass of [subclass], and causes subclass to // inherit its methods. This should be called before any methods are defined // on subclass. void wrenBindSuperclass(WrenVM* vm, ObjClass* subclass, ObjClass* superclass); // Creates a new class object as well as its associated metaclass. ObjClass* wrenNewClass(WrenVM* vm, ObjClass* superclass, int numFields, ObjString* name); void wrenBindMethod(WrenVM* vm, ObjClass* classObj, int symbol, Method method); // Creates a new closure object that invokes [fn]. Allocates room for its // upvalues, but assumes outside code will populate it. ObjClosure* wrenNewClosure(WrenVM* vm, ObjFn* fn); // Creates a new fiber object that will invoke [closure]. ObjFiber* wrenNewFiber(WrenVM* vm, ObjClosure* closure); // Adds a new [CallFrame] to [fiber] invoking [closure] whose stack starts at // [stackStart]. static inline void wrenAppendCallFrame(WrenVM* vm, ObjFiber* fiber, ObjClosure* closure, Value* stackStart) { // The caller should have ensured we already have enough capacity. ASSERT(fiber->frameCapacity > fiber->numFrames, "No memory for call frame."); CallFrame* frame = &fiber->frames[fiber->numFrames++]; frame->stackStart = stackStart; frame->closure = closure; frame->ip = closure->fn->code.data; } // Ensures [fiber]'s stack has at least [needed] slots. void wrenEnsureStack(WrenVM* vm, ObjFiber* fiber, int needed); static inline bool wrenHasError(const ObjFiber* fiber) { return !IS_NULL(fiber->error); } ObjForeign* wrenNewForeign(WrenVM* vm, ObjClass* classObj, size_t size); // Creates a new empty function. Before being used, it must have code, // constants, etc. added to it. ObjFn* wrenNewFunction(WrenVM* vm, ObjModule* module, int maxSlots); void wrenFunctionBindName(WrenVM* vm, ObjFn* fn, const char* name, int length); // Creates a new instance of the given [classObj]. Value wrenNewInstance(WrenVM* vm, ObjClass* classObj); // Creates a new list with [numElements] elements (which are left // uninitialized.) ObjList* wrenNewList(WrenVM* vm, uint32_t numElements); // Inserts [value] in [list] at [index], shifting down the other elements. void wrenListInsert(WrenVM* vm, ObjList* list, Value value, uint32_t index); // Removes and returns the item at [index] from [list]. Value wrenListRemoveAt(WrenVM* vm, ObjList* list, uint32_t index); // Creates a new empty map. ObjMap* wrenNewMap(WrenVM* vm); // Looks up [key] in [map]. If found, returns the value. Otherwise, returns // `UNDEFINED_VAL`. Value wrenMapGet(ObjMap* map, Value key); // Associates [key] with [value] in [map]. void wrenMapSet(WrenVM* vm, ObjMap* map, Value key, Value value); void wrenMapClear(WrenVM* vm, ObjMap* map); // Removes [key] from [map], if present. Returns the value for the key if found // or `NULL_VAL` otherwise. Value wrenMapRemoveKey(WrenVM* vm, ObjMap* map, Value key); // Creates a new module. ObjModule* wrenNewModule(WrenVM* vm, ObjString* name); // Creates a new range from [from] to [to]. Value wrenNewRange(WrenVM* vm, double from, double to, bool isInclusive); // Creates a new string object and copies [text] into it. // // [text] must be non-NULL. Value wrenNewString(WrenVM* vm, const char* text); // Creates a new string object of [length] and copies [text] into it. // // [text] may be NULL if [length] is zero. Value wrenNewStringLength(WrenVM* vm, const char* text, size_t length); // Creates a new string object by taking a range of characters from [source]. // The range starts at [start], contains [count] bytes, and increments by // [step]. Value wrenNewStringFromRange(WrenVM* vm, ObjString* source, int start, uint32_t count, int step); // Produces a string representation of [value]. Value wrenNumToString(WrenVM* vm, double value); // Creates a new formatted string from [format] and any additional arguments // used in the format string. // // This is a very restricted flavor of formatting, intended only for internal // use by the VM. Two formatting characters are supported, each of which reads // the next argument as a certain type: // // $ - A C string. // @ - A Wren string object. Value wrenStringFormat(WrenVM* vm, const char* format, ...); // Creates a new string containing the UTF-8 encoding of [value]. Value wrenStringFromCodePoint(WrenVM* vm, int value); // Creates a new string from the integer representation of a byte Value wrenStringFromByte(WrenVM* vm, uint8_t value); // Creates a new string containing the code point in [string] starting at byte // [index]. If [index] points into the middle of a UTF-8 sequence, returns an // empty string. Value wrenStringCodePointAt(WrenVM* vm, ObjString* string, uint32_t index); // Search for the first occurence of [needle] within [haystack] and returns its // zero-based offset. Returns `UINT32_MAX` if [haystack] does not contain // [needle]. uint32_t wrenStringFind(ObjString* haystack, ObjString* needle, uint32_t startIndex); // Returns true if [a] and [b] represent the same string. static inline bool wrenStringEqualsCString(const ObjString* a, const char* b, size_t length) { return a->length == length && memcmp(a->value, b, length) == 0; } // Creates a new open upvalue pointing to [value] on the stack. ObjUpvalue* wrenNewUpvalue(WrenVM* vm, Value* value); // Mark [obj] as reachable and still in use. This should only be called // during the sweep phase of a garbage collection. void wrenGrayObj(WrenVM* vm, Obj* obj); // Mark [value] as reachable and still in use. This should only be called // during the sweep phase of a garbage collection. void wrenGrayValue(WrenVM* vm, Value value); // Mark the values in [buffer] as reachable and still in use. This should only // be called during the sweep phase of a garbage collection. void wrenGrayBuffer(WrenVM* vm, ValueBuffer* buffer); // Processes every object in the gray stack until all reachable objects have // been marked. After that, all objects are either white (freeable) or black // (in use and fully traversed). void wrenBlackenObjects(WrenVM* vm); // Releases all memory owned by [obj], including [obj] itself. void wrenFreeObj(WrenVM* vm, Obj* obj); // Returns the class of [value]. // // Unlike wrenGetClassInline in wren_vm.h, this is not inlined. Inlining helps // performance (significantly) in some cases, but degrades it in others. The // ones used by the implementation were chosen to give the best results in the // benchmarks. ObjClass* wrenGetClass(WrenVM* vm, Value value); // Returns true if [a] and [b] are strictly the same value. This is identity // for object values, and value equality for unboxed values. static inline bool wrenValuesSame(Value a, Value b) { #if WREN_NAN_TAGGING // Value types have unique bit representations and we compare object types // by identity (i.e. pointer), so all we need to do is compare the bits. return a == b; #else if (a.type != b.type) return false; if (a.type == VAL_NUM) return a.as.num == b.as.num; return a.as.obj == b.as.obj; #endif } // Returns true if [a] and [b] are equivalent. Immutable values (null, bools, // numbers, ranges, and strings) are equal if they have the same data. All // other values are equal if they are identical objects. bool wrenValuesEqual(Value a, Value b); // Returns true if [value] is a bool. Do not call this directly, instead use // [IS_BOOL]. static inline bool wrenIsBool(Value value) { #if WREN_NAN_TAGGING return value == TRUE_VAL || value == FALSE_VAL; #else return value.type == VAL_FALSE || value.type == VAL_TRUE; #endif } // Returns true if [value] is an object of type [type]. Do not call this // directly, instead use the [IS___] macro for the type in question. static inline bool wrenIsObjType(Value value, ObjType type) { return IS_OBJ(value) && AS_OBJ(value)->type == type; } // Converts the raw object pointer [obj] to a [Value]. static inline Value wrenObjectToValue(Obj* obj) { #if WREN_NAN_TAGGING // The triple casting is necessary here to satisfy some compilers: // 1. (uintptr_t) Convert the pointer to a number of the right size. // 2. (uint64_t) Pad it up to 64 bits in 32-bit builds. // 3. Or in the bits to make a tagged Nan. // 4. Cast to a typedef'd value. return (Value)(SIGN_BIT | QNAN | (uint64_t)(uintptr_t)(obj)); #else Value value; value.type = VAL_OBJ; value.as.obj = obj; return value; #endif } // Interprets [value] as a [double]. static inline double wrenValueToNum(Value value) { #if WREN_NAN_TAGGING DoubleBits data; data.bits64 = value; return data.num; #else return value.as.num; #endif } // Converts [num] to a [Value]. static inline Value wrenNumToValue(double num) { #if WREN_NAN_TAGGING DoubleBits data; data.num = num; return data.bits64; #else Value value; value.type = VAL_NUM; value.as.num = num; return value; #endif } #endif // End file "wren_value.h" // Begin file "wren_vm.h" #ifndef wren_vm_h #define wren_vm_h // Begin file "wren_compiler.h" #ifndef wren_compiler_h #define wren_compiler_h typedef struct sCompiler Compiler; // This module defines the compiler for Wren. It takes a string of source code // and lexes, parses, and compiles it. Wren uses a single-pass compiler. It // does not build an actual AST during parsing and then consume that to // generate code. Instead, the parser directly emits bytecode. // // This forces a few restrictions on the grammar and semantics of the language. // Things like forward references and arbitrary lookahead are much harder. We // get a lot in return for that, though. // // The implementation is much simpler since we don't need to define a bunch of // AST data structures. More so, we don't have to deal with managing memory for // AST objects. The compiler does almost no dynamic allocation while running. // // Compilation is also faster since we don't create a bunch of temporary data // structures and destroy them after generating code. // Compiles [source], a string of Wren source code located in [module], to an // [ObjFn] that will execute that code when invoked. Returns `NULL` if the // source contains any syntax errors. // // If [isExpression] is `true`, [source] should be a single expression, and // this compiles it to a function that evaluates and returns that expression. // Otherwise, [source] should be a series of top level statements. // // If [printErrors] is `true`, any compile errors are output to stderr. // Otherwise, they are silently discarded. ObjFn* wrenCompile(WrenVM* vm, ObjModule* module, const char* source, bool isExpression, bool printErrors); // When a class is defined, its superclass is not known until runtime since // class definitions are just imperative statements. Most of the bytecode for a // a method doesn't care, but there are two places where it matters: // // - To load or store a field, we need to know the index of the field in the // instance's field array. We need to adjust this so that subclass fields // are positioned after superclass fields, and we don't know this until the // superclass is known. // // - Superclass calls need to know which superclass to dispatch to. // // We could handle this dynamically, but that adds overhead. Instead, when a // method is bound, we walk the bytecode for the function and patch it up. void wrenBindMethodCode(ObjClass* classObj, ObjFn* fn); // Reaches all of the heap-allocated objects in use by [compiler] (and all of // its parents) so that they are not collected by the GC. void wrenMarkCompiler(WrenVM* vm, Compiler* compiler); #endif // End file "wren_compiler.h" // The maximum number of temporary objects that can be made visible to the GC // at one time. #define WREN_MAX_TEMP_ROOTS 8 typedef enum { #define OPCODE(name, _) CODE_##name, // Begin file "wren_opcodes.h" // This defines the bytecode instructions used by the VM. It does so by invoking // an OPCODE() macro which is expected to be defined at the point that this is // included. (See: http://en.wikipedia.org/wiki/X_Macro for more.) // // The first argument is the name of the opcode. The second is its "stack // effect" -- the amount that the op code changes the size of the stack. A // stack effect of 1 means it pushes a value and the stack grows one larger. // -2 means it pops two values, etc. // // Note that the order of instructions here affects the order of the dispatch // table in the VM's interpreter loop. That in turn affects caching which // affects overall performance. Take care to run benchmarks if you change the // order here. // Load the constant at index [arg]. OPCODE(CONSTANT, 1) // Push null onto the stack. OPCODE(NULL, 1) // Push false onto the stack. OPCODE(FALSE, 1) // Push true onto the stack. OPCODE(TRUE, 1) // Pushes the value in the given local slot. OPCODE(LOAD_LOCAL_0, 1) OPCODE(LOAD_LOCAL_1, 1) OPCODE(LOAD_LOCAL_2, 1) OPCODE(LOAD_LOCAL_3, 1) OPCODE(LOAD_LOCAL_4, 1) OPCODE(LOAD_LOCAL_5, 1) OPCODE(LOAD_LOCAL_6, 1) OPCODE(LOAD_LOCAL_7, 1) OPCODE(LOAD_LOCAL_8, 1) // Note: The compiler assumes the following _STORE instructions always // immediately follow their corresponding _LOAD ones. // Pushes the value in local slot [arg]. OPCODE(LOAD_LOCAL, 1) // Stores the top of stack in local slot [arg]. Does not pop it. OPCODE(STORE_LOCAL, 0) // Pushes the value in upvalue [arg]. OPCODE(LOAD_UPVALUE, 1) // Stores the top of stack in upvalue [arg]. Does not pop it. OPCODE(STORE_UPVALUE, 0) // Pushes the value of the top-level variable in slot [arg]. OPCODE(LOAD_MODULE_VAR, 1) // Stores the top of stack in top-level variable slot [arg]. Does not pop it. OPCODE(STORE_MODULE_VAR, 0) // Pushes the value of the field in slot [arg] of the receiver of the current // function. This is used for regular field accesses on "this" directly in // methods. This instruction is faster than the more general CODE_LOAD_FIELD // instruction. OPCODE(LOAD_FIELD_THIS, 1) // Stores the top of the stack in field slot [arg] in the receiver of the // current value. Does not pop the value. This instruction is faster than the // more general CODE_LOAD_FIELD instruction. OPCODE(STORE_FIELD_THIS, 0) // Pops an instance and pushes the value of the field in slot [arg] of it. OPCODE(LOAD_FIELD, 0) // Pops an instance and stores the subsequent top of stack in field slot // [arg] in it. Does not pop the value. OPCODE(STORE_FIELD, -1) // Pop and discard the top of stack. OPCODE(POP, -1) // Invoke the method with symbol [arg]. The number indicates the number of // arguments (not including the receiver). OPCODE(CALL_0, 0) OPCODE(CALL_1, -1) OPCODE(CALL_2, -2) OPCODE(CALL_3, -3) OPCODE(CALL_4, -4) OPCODE(CALL_5, -5) OPCODE(CALL_6, -6) OPCODE(CALL_7, -7) OPCODE(CALL_8, -8) OPCODE(CALL_9, -9) OPCODE(CALL_10, -10) OPCODE(CALL_11, -11) OPCODE(CALL_12, -12) OPCODE(CALL_13, -13) OPCODE(CALL_14, -14) OPCODE(CALL_15, -15) OPCODE(CALL_16, -16) // Invoke a superclass method with symbol [arg]. The number indicates the // number of arguments (not including the receiver). OPCODE(SUPER_0, 0) OPCODE(SUPER_1, -1) OPCODE(SUPER_2, -2) OPCODE(SUPER_3, -3) OPCODE(SUPER_4, -4) OPCODE(SUPER_5, -5) OPCODE(SUPER_6, -6) OPCODE(SUPER_7, -7) OPCODE(SUPER_8, -8) OPCODE(SUPER_9, -9) OPCODE(SUPER_10, -10) OPCODE(SUPER_11, -11) OPCODE(SUPER_12, -12) OPCODE(SUPER_13, -13) OPCODE(SUPER_14, -14) OPCODE(SUPER_15, -15) OPCODE(SUPER_16, -16) // Jump the instruction pointer [arg] forward. OPCODE(JUMP, 0) // Jump the instruction pointer [arg] backward. OPCODE(LOOP, 0) // Pop and if not truthy then jump the instruction pointer [arg] forward. OPCODE(JUMP_IF, -1) // If the top of the stack is false, jump [arg] forward. Otherwise, pop and // continue. OPCODE(AND, -1) // If the top of the stack is non-false, jump [arg] forward. Otherwise, pop // and continue. OPCODE(OR, -1) // Close the upvalue for the local on the top of the stack, then pop it. OPCODE(CLOSE_UPVALUE, -1) // Exit from the current function and return the value on the top of the // stack. OPCODE(RETURN, 0) // Creates a closure for the function stored at [arg] in the constant table. // // Following the function argument is a number of arguments, two for each // upvalue. The first is true if the variable being captured is a local (as // opposed to an upvalue), and the second is the index of the local or // upvalue being captured. // // Pushes the created closure. OPCODE(CLOSURE, 1) // Creates a new instance of a class. // // Assumes the class object is in slot zero, and replaces it with the new // uninitialized instance of that class. This opcode is only emitted by the // compiler-generated constructor metaclass methods. OPCODE(CONSTRUCT, 0) // Creates a new instance of a foreign class. // // Assumes the class object is in slot zero, and replaces it with the new // uninitialized instance of that class. This opcode is only emitted by the // compiler-generated constructor metaclass methods. OPCODE(FOREIGN_CONSTRUCT, 0) // Creates a class. Top of stack is the superclass. Below that is a string for // the name of the class. Byte [arg] is the number of fields in the class. OPCODE(CLASS, -1) // Creates a foreign class. Top of stack is the superclass. Below that is a // string for the name of the class. OPCODE(FOREIGN_CLASS, -1) // Define a method for symbol [arg]. The class receiving the method is popped // off the stack, then the function defining the body is popped. // // If a foreign method is being defined, the "function" will be a string // identifying the foreign method. Otherwise, it will be a function or // closure. OPCODE(METHOD_INSTANCE, -2) // Define a method for symbol [arg]. The class whose metaclass will receive // the method is popped off the stack, then the function defining the body is // popped. // // If a foreign method is being defined, the "function" will be a string // identifying the foreign method. Otherwise, it will be a function or // closure. OPCODE(METHOD_STATIC, -2) // This is executed at the end of the module's body. Pushes NULL onto the stack // as the "return value" of the import statement and stores the module as the // most recently imported one. OPCODE(END_MODULE, 1) // Import a module whose name is the string stored at [arg] in the constant // table. // // Pushes null onto the stack so that the fiber for the imported module can // replace that with a dummy value when it returns. (Fibers always return a // value when resuming a caller.) OPCODE(IMPORT_MODULE, 1) // Import a variable from the most recently imported module. The name of the // variable to import is at [arg] in the constant table. Pushes the loaded // variable's value. OPCODE(IMPORT_VARIABLE, 1) // This pseudo-instruction indicates the end of the bytecode. It should // always be preceded by a `CODE_RETURN`, so is never actually executed. OPCODE(END, 0) // End file "wren_opcodes.h" #undef OPCODE } Code; // A handle to a value, basically just a linked list of extra GC roots. // // Note that even non-heap-allocated values can be stored here. struct WrenHandle { Value value; WrenHandle* prev; WrenHandle* next; }; struct WrenVM { ObjClass* boolClass; ObjClass* classClass; ObjClass* fiberClass; ObjClass* fnClass; ObjClass* listClass; ObjClass* mapClass; ObjClass* nullClass; ObjClass* numClass; ObjClass* objectClass; ObjClass* rangeClass; ObjClass* stringClass; // The fiber that is currently running. ObjFiber* fiber; // The loaded modules. Each key is an ObjString (except for the main module, // whose key is null) for the module's name and the value is the ObjModule // for the module. ObjMap* modules; // The most recently imported module. More specifically, the module whose // code has most recently finished executing. // // Not treated like a GC root since the module is already in [modules]. ObjModule* lastModule; // Memory management data: // The number of bytes that are known to be currently allocated. Includes all // memory that was proven live after the last GC, as well as any new bytes // that were allocated since then. Does *not* include bytes for objects that // were freed since the last GC. size_t bytesAllocated; // The number of total allocated bytes that will trigger the next GC. size_t nextGC; // The first object in the linked list of all currently allocated objects. Obj* first; // The "gray" set for the garbage collector. This is the stack of unprocessed // objects while a garbage collection pass is in process. Obj** gray; int grayCount; int grayCapacity; // The list of temporary roots. This is for temporary or new objects that are // not otherwise reachable but should not be collected. // // They are organized as a stack of pointers stored in this array. This // implies that temporary roots need to have stack semantics: only the most // recently pushed object can be released. Obj* tempRoots[WREN_MAX_TEMP_ROOTS]; int numTempRoots; // Pointer to the first node in the linked list of active handles or NULL if // there are none. WrenHandle* handles; // Pointer to the bottom of the range of stack slots available for use from // the C API. During a foreign method, this will be in the stack of the fiber // that is executing a method. // // If not in a foreign method, this is initially NULL. If the user requests // slots by calling wrenEnsureSlots(), a stack is created and this is // initialized. Value* apiStack; WrenConfiguration config; // Compiler and debugger data: // The compiler that is currently compiling code. This is used so that heap // allocated objects used by the compiler can be found if a GC is kicked off // in the middle of a compile. Compiler* compiler; // There is a single global symbol table for all method names on all classes. // Method calls are dispatched directly by index in this table. SymbolTable methodNames; }; // A generic allocation function that handles all explicit memory management. // It's used like so: // // - To allocate new memory, [memory] is NULL and [oldSize] is zero. It should // return the allocated memory or NULL on failure. // // - To attempt to grow an existing allocation, [memory] is the memory, // [oldSize] is its previous size, and [newSize] is the desired size. // It should return [memory] if it was able to grow it in place, or a new // pointer if it had to move it. // // - To shrink memory, [memory], [oldSize], and [newSize] are the same as above // but it will always return [memory]. // // - To free memory, [memory] will be the memory to free and [newSize] and // [oldSize] will be zero. It should return NULL. void* wrenReallocate(WrenVM* vm, void* memory, size_t oldSize, size_t newSize); // Invoke the finalizer for the foreign object referenced by [foreign]. void wrenFinalizeForeign(WrenVM* vm, ObjForeign* foreign); // Creates a new [WrenHandle] for [value]. WrenHandle* wrenMakeHandle(WrenVM* vm, Value value); // Compile [source] in the context of [module] and wrap in a fiber that can // execute it. // // Returns NULL if a compile error occurred. ObjClosure* wrenCompileSource(WrenVM* vm, const char* module, const char* source, bool isExpression, bool printErrors); // Looks up a variable from a previously-loaded module. // // Aborts the current fiber if the module or variable could not be found. Value wrenGetModuleVariable(WrenVM* vm, Value moduleName, Value variableName); // Returns the value of the module-level variable named [name] in the main // module. Value wrenFindVariable(WrenVM* vm, ObjModule* module, const char* name); // Adds a new implicitly declared top-level variable named [name] to [module] // based on a use site occurring on [line]. // // Does not check to see if a variable with that name is already declared or // defined. Returns the symbol for the new variable or -2 if there are too many // variables defined. int wrenDeclareVariable(WrenVM* vm, ObjModule* module, const char* name, size_t length, int line); // Adds a new top-level variable named [name] to [module], and optionally // populates line with the line of the implicit first use (line can be NULL). // // Returns the symbol for the new variable, -1 if a variable with the given name // is already defined, or -2 if there are too many variables defined. // Returns -3 if this is a top-level lowercase variable (localname) that was // used before being defined. int wrenDefineVariable(WrenVM* vm, ObjModule* module, const char* name, size_t length, Value value, int* line); // Pushes [closure] onto [fiber]'s callstack to invoke it. Expects [numArgs] // arguments (including the receiver) to be on the top of the stack already. static inline void wrenCallFunction(WrenVM* vm, ObjFiber* fiber, ObjClosure* closure, int numArgs) { // Grow the call frame array if needed. if (fiber->numFrames + 1 > fiber->frameCapacity) { int max = fiber->frameCapacity * 2; fiber->frames = (CallFrame*)wrenReallocate(vm, fiber->frames, sizeof(CallFrame) * fiber->frameCapacity, sizeof(CallFrame) * max); fiber->frameCapacity = max; } // Grow the stack if needed. int stackSize = (int)(fiber->stackTop - fiber->stack); int needed = stackSize + closure->fn->maxSlots; wrenEnsureStack(vm, fiber, needed); wrenAppendCallFrame(vm, fiber, closure, fiber->stackTop - numArgs); } // Marks [obj] as a GC root so that it doesn't get collected. void wrenPushRoot(WrenVM* vm, Obj* obj); // Removes the most recently pushed temporary root. void wrenPopRoot(WrenVM* vm); // Returns the class of [value]. // // Defined here instead of in wren_value.h because it's critical that this be // inlined. That means it must be defined in the header, but the wren_value.h // header doesn't have a full definitely of WrenVM yet. static inline ObjClass* wrenGetClassInline(WrenVM* vm, Value value) { if (IS_NUM(value)) return vm->numClass; if (IS_OBJ(value)) return AS_OBJ(value)->classObj; #if WREN_NAN_TAGGING switch (GET_TAG(value)) { case TAG_FALSE: return vm->boolClass; break; case TAG_NAN: return vm->numClass; break; case TAG_NULL: return vm->nullClass; break; case TAG_TRUE: return vm->boolClass; break; case TAG_UNDEFINED: UNREACHABLE(); } #else switch (value.type) { case VAL_FALSE: return vm->boolClass; case VAL_NULL: return vm->nullClass; case VAL_NUM: return vm->numClass; case VAL_TRUE: return vm->boolClass; case VAL_OBJ: return AS_OBJ(value)->classObj; case VAL_UNDEFINED: UNREACHABLE(); } #endif UNREACHABLE(); return NULL; } // Returns `true` if [name] is a local variable name (starts with a lowercase // letter). static inline bool wrenIsLocalName(const char* name) { return name[0] >= 'a' && name[0] <= 'z'; } #endif // End file "wren_vm.h" // Prints the stack trace for the current fiber. // // Used when a fiber throws a runtime error which is not caught. void wrenDebugPrintStackTrace(WrenVM* vm); // The "dump" functions are used for debugging Wren itself. Normal code paths // will not call them unless one of the various DEBUG_ flags is enabled. // Prints a representation of [value] to stdout. void wrenDumpValue(Value value); // Prints a representation of the bytecode for [fn] at instruction [i]. int wrenDumpInstruction(WrenVM* vm, ObjFn* fn, int i); // Prints the disassembled code for [fn] to stdout. void wrenDumpCode(WrenVM* vm, ObjFn* fn); // Prints the contents of the current stack for [fiber] to stdout. void wrenDumpStack(ObjFiber* fiber); #endif // End file "wren_debug.h" // Begin file "wren_debug.c" #include <stdio.h> void wrenDebugPrintStackTrace(WrenVM* vm) { // Bail if the host doesn't enable printing errors. if (vm->config.errorFn == NULL) return; ObjFiber* fiber = vm->fiber; if (IS_STRING(fiber->error)) { vm->config.errorFn(vm, WREN_ERROR_RUNTIME, NULL, -1, AS_CSTRING(fiber->error)); } else { // TODO: Print something a little useful here. Maybe the name of the error's // class? vm->config.errorFn(vm, WREN_ERROR_RUNTIME, NULL, -1, "[error object]"); } for (int i = fiber->numFrames - 1; i >= 0; i--) { CallFrame* frame = &fiber->frames[i]; ObjFn* fn = frame->closure->fn; // Skip over stub functions for calling methods from the C API. if (fn->module == NULL) continue; // The built-in core module has no name. We explicitly omit it from stack // traces since we don't want to highlight to a user the implementation // detail of what part of the core module is written in C and what is Wren. if (fn->module->name == NULL) continue; // -1 because IP has advanced past the instruction that it just executed. int line = fn->debug->sourceLines.data[frame->ip - fn->code.data - 1]; vm->config.errorFn(vm, WREN_ERROR_STACK_TRACE, fn->module->name->value, line, fn->debug->name); } } static void dumpObject(Obj* obj) { switch (obj->type) { case OBJ_CLASS: printf("[class %s %p]", ((ObjClass*)obj)->name->value, obj); break; case OBJ_CLOSURE: printf("[closure %p]", obj); break; case OBJ_FIBER: printf("[fiber %p]", obj); break; case OBJ_FN: printf("[fn %p]", obj); break; case OBJ_FOREIGN: printf("[foreign %p]", obj); break; case OBJ_INSTANCE: printf("[instance %p]", obj); break; case OBJ_LIST: printf("[list %p]", obj); break; case OBJ_MAP: printf("[map %p]", obj); break; case OBJ_MODULE: printf("[module %p]", obj); break; case OBJ_RANGE: printf("[range %p]", obj); break; case OBJ_STRING: printf("%s", ((ObjString*)obj)->value); break; case OBJ_UPVALUE: printf("[upvalue %p]", obj); break; default: printf("[unknown object %d]", obj->type); break; } } void wrenDumpValue(Value value) { #if WREN_NAN_TAGGING if (IS_NUM(value)) { printf("%.14g", AS_NUM(value)); } else if (IS_OBJ(value)) { dumpObject(AS_OBJ(value)); } else { switch (GET_TAG(value)) { case TAG_FALSE: printf("false"); break; case TAG_NAN: printf("NaN"); break; case TAG_NULL: printf("null"); break; case TAG_TRUE: printf("true"); break; case TAG_UNDEFINED: UNREACHABLE(); } } #else switch (value.type) { case VAL_FALSE: printf("false"); break; case VAL_NULL: printf("null"); break; case VAL_NUM: printf("%.14g", AS_NUM(value)); break; case VAL_TRUE: printf("true"); break; case VAL_OBJ: dumpObject(AS_OBJ(value)); break; case VAL_UNDEFINED: UNREACHABLE(); } #endif } static int dumpInstruction(WrenVM* vm, ObjFn* fn, int i, int* lastLine) { int start = i; uint8_t* bytecode = fn->code.data; Code code = (Code)bytecode[i]; int line = fn->debug->sourceLines.data[i]; if (lastLine == NULL || *lastLine != line) { printf("%4d:", line); if (lastLine != NULL) *lastLine = line; } else { printf(" "); } printf(" %04d ", i++); #define READ_BYTE() (bytecode[i++]) #define READ_SHORT() (i += 2, (bytecode[i - 2] << 8) | bytecode[i - 1]) #define BYTE_INSTRUCTION(name) \ printf("%-16s %5d\n", name, READ_BYTE()); \ break switch (code) { case CODE_CONSTANT: { int constant = READ_SHORT(); printf("%-16s %5d '", "CONSTANT", constant); wrenDumpValue(fn->constants.data[constant]); printf("'\n"); break; } case CODE_NULL: printf("NULL\n"); break; case CODE_FALSE: printf("FALSE\n"); break; case CODE_TRUE: printf("TRUE\n"); break; case CODE_LOAD_LOCAL_0: printf("LOAD_LOCAL_0\n"); break; case CODE_LOAD_LOCAL_1: printf("LOAD_LOCAL_1\n"); break; case CODE_LOAD_LOCAL_2: printf("LOAD_LOCAL_2\n"); break; case CODE_LOAD_LOCAL_3: printf("LOAD_LOCAL_3\n"); break; case CODE_LOAD_LOCAL_4: printf("LOAD_LOCAL_4\n"); break; case CODE_LOAD_LOCAL_5: printf("LOAD_LOCAL_5\n"); break; case CODE_LOAD_LOCAL_6: printf("LOAD_LOCAL_6\n"); break; case CODE_LOAD_LOCAL_7: printf("LOAD_LOCAL_7\n"); break; case CODE_LOAD_LOCAL_8: printf("LOAD_LOCAL_8\n"); break; case CODE_LOAD_LOCAL: BYTE_INSTRUCTION("LOAD_LOCAL"); case CODE_STORE_LOCAL: BYTE_INSTRUCTION("STORE_LOCAL"); case CODE_LOAD_UPVALUE: BYTE_INSTRUCTION("LOAD_UPVALUE"); case CODE_STORE_UPVALUE: BYTE_INSTRUCTION("STORE_UPVALUE"); case CODE_LOAD_MODULE_VAR: { int slot = READ_SHORT(); printf("%-16s %5d '%s'\n", "LOAD_MODULE_VAR", slot, fn->module->variableNames.data[slot]->value); break; } case CODE_STORE_MODULE_VAR: { int slot = READ_SHORT(); printf("%-16s %5d '%s'\n", "STORE_MODULE_VAR", slot, fn->module->variableNames.data[slot]->value); break; } case CODE_LOAD_FIELD_THIS: BYTE_INSTRUCTION("LOAD_FIELD_THIS"); case CODE_STORE_FIELD_THIS: BYTE_INSTRUCTION("STORE_FIELD_THIS"); case CODE_LOAD_FIELD: BYTE_INSTRUCTION("LOAD_FIELD"); case CODE_STORE_FIELD: BYTE_INSTRUCTION("STORE_FIELD"); case CODE_POP: printf("POP\n"); break; case CODE_CALL_0: case CODE_CALL_1: case CODE_CALL_2: case CODE_CALL_3: case CODE_CALL_4: case CODE_CALL_5: case CODE_CALL_6: case CODE_CALL_7: case CODE_CALL_8: case CODE_CALL_9: case CODE_CALL_10: case CODE_CALL_11: case CODE_CALL_12: case CODE_CALL_13: case CODE_CALL_14: case CODE_CALL_15: case CODE_CALL_16: { int numArgs = bytecode[i - 1] - CODE_CALL_0; int symbol = READ_SHORT(); printf("CALL_%-11d %5d '%s'\n", numArgs, symbol, vm->methodNames.data[symbol]->value); break; } case CODE_SUPER_0: case CODE_SUPER_1: case CODE_SUPER_2: case CODE_SUPER_3: case CODE_SUPER_4: case CODE_SUPER_5: case CODE_SUPER_6: case CODE_SUPER_7: case CODE_SUPER_8: case CODE_SUPER_9: case CODE_SUPER_10: case CODE_SUPER_11: case CODE_SUPER_12: case CODE_SUPER_13: case CODE_SUPER_14: case CODE_SUPER_15: case CODE_SUPER_16: { int numArgs = bytecode[i - 1] - CODE_SUPER_0; int symbol = READ_SHORT(); int superclass = READ_SHORT(); printf("SUPER_%-10d %5d '%s' %5d\n", numArgs, symbol, vm->methodNames.data[symbol]->value, superclass); break; } case CODE_JUMP: { int offset = READ_SHORT(); printf("%-16s %5d to %d\n", "JUMP", offset, i + offset); break; } case CODE_LOOP: { int offset = READ_SHORT(); printf("%-16s %5d to %d\n", "LOOP", offset, i - offset); break; } case CODE_JUMP_IF: { int offset = READ_SHORT(); printf("%-16s %5d to %d\n", "JUMP_IF", offset, i + offset); break; } case CODE_AND: { int offset = READ_SHORT(); printf("%-16s %5d to %d\n", "AND", offset, i + offset); break; } case CODE_OR: { int offset = READ_SHORT(); printf("%-16s %5d to %d\n", "OR", offset, i + offset); break; } case CODE_CLOSE_UPVALUE: printf("CLOSE_UPVALUE\n"); break; case CODE_RETURN: printf("RETURN\n"); break; case CODE_CLOSURE: { int constant = READ_SHORT(); printf("%-16s %5d ", "CLOSURE", constant); wrenDumpValue(fn->constants.data[constant]); printf(" "); ObjFn* loadedFn = AS_FN(fn->constants.data[constant]); for (int j = 0; j < loadedFn->numUpvalues; j++) { int isLocal = READ_BYTE(); int index = READ_BYTE(); if (j > 0) printf(", "); printf("%s %d", isLocal ? "local" : "upvalue", index); } printf("\n"); break; } case CODE_CONSTRUCT: printf("CONSTRUCT\n"); break; case CODE_FOREIGN_CONSTRUCT: printf("FOREIGN_CONSTRUCT\n"); break; case CODE_CLASS: { int numFields = READ_BYTE(); printf("%-16s %5d fields\n", "CLASS", numFields); break; } case CODE_FOREIGN_CLASS: printf("FOREIGN_CLASS\n"); break; case CODE_METHOD_INSTANCE: { int symbol = READ_SHORT(); printf("%-16s %5d '%s'\n", "METHOD_INSTANCE", symbol, vm->methodNames.data[symbol]->value); break; } case CODE_METHOD_STATIC: { int symbol = READ_SHORT(); printf("%-16s %5d '%s'\n", "METHOD_STATIC", symbol, vm->methodNames.data[symbol]->value); break; } case CODE_END_MODULE: printf("END_MODULE\n"); break; case CODE_IMPORT_MODULE: { int name = READ_SHORT(); printf("%-16s %5d '", "IMPORT_MODULE", name); wrenDumpValue(fn->constants.data[name]); printf("'\n"); break; } case CODE_IMPORT_VARIABLE: { int variable = READ_SHORT(); printf("%-16s %5d '", "IMPORT_VARIABLE", variable); wrenDumpValue(fn->constants.data[variable]); printf("'\n"); break; } case CODE_END: printf("END\n"); break; default: printf("UKNOWN! [%d]\n", bytecode[i - 1]); break; } // Return how many bytes this instruction takes, or -1 if it's an END. if (code == CODE_END) return -1; return i - start; #undef READ_BYTE #undef READ_SHORT } int wrenDumpInstruction(WrenVM* vm, ObjFn* fn, int i) { return dumpInstruction(vm, fn, i, NULL); } void wrenDumpCode(WrenVM* vm, ObjFn* fn) { printf("%s: %s\n", fn->module->name == NULL ? "<core>" : fn->module->name->value, fn->debug->name); int i = 0; int lastLine = -1; for (;;) { int offset = dumpInstruction(vm, fn, i, &lastLine); if (offset == -1) break; i += offset; } printf("\n"); } void wrenDumpStack(ObjFiber* fiber) { printf("(fiber %p) ", fiber); for (Value* slot = fiber->stack; slot < fiber->stackTop; slot++) { wrenDumpValue(*slot); printf(" | "); } printf("\n"); } // End file "wren_debug.c" // Begin file "wren_utils.c" #include <string.h> DEFINE_BUFFER(Byte, uint8_t); DEFINE_BUFFER(Int, int); DEFINE_BUFFER(String, ObjString*); void wrenSymbolTableInit(SymbolTable* symbols) { wrenStringBufferInit(symbols); } void wrenSymbolTableClear(WrenVM* vm, SymbolTable* symbols) { wrenStringBufferClear(vm, symbols); } int wrenSymbolTableAdd(WrenVM* vm, SymbolTable* symbols, const char* name, size_t length) { ObjString* symbol = AS_STRING(wrenNewStringLength(vm, name, length)); wrenPushRoot(vm, &symbol->obj); wrenStringBufferWrite(vm, symbols, symbol); wrenPopRoot(vm); return symbols->count - 1; } int wrenSymbolTableEnsure(WrenVM* vm, SymbolTable* symbols, const char* name, size_t length) { // See if the symbol is already defined. int existing = wrenSymbolTableFind(symbols, name, length); if (existing != -1) return existing; // New symbol, so add it. return wrenSymbolTableAdd(vm, symbols, name, length); } int wrenSymbolTableFind(const SymbolTable* symbols, const char* name, size_t length) { // See if the symbol is already defined. // TODO: O(n). Do something better. for (int i = 0; i < symbols->count; i++) { if (wrenStringEqualsCString(symbols->data[i], name, length)) return i; } return -1; } void wrenBlackenSymbolTable(WrenVM* vm, SymbolTable* symbolTable) { for (int i = 0; i < symbolTable->count; i++) { wrenGrayObj(vm, &symbolTable->data[i]->obj); } // Keep track of how much memory is still in use. vm->bytesAllocated += symbolTable->capacity * sizeof(*symbolTable->data); } int wrenUtf8EncodeNumBytes(int value) { ASSERT(value >= 0, "Cannot encode a negative value."); if (value <= 0x7f) return 1; if (value <= 0x7ff) return 2; if (value <= 0xffff) return 3; if (value <= 0x10ffff) return 4; return 0; } int wrenUtf8Encode(int value, uint8_t* bytes) { if (value <= 0x7f) { // Single byte (i.e. fits in ASCII). *bytes = value & 0x7f; return 1; } else if (value <= 0x7ff) { // Two byte sequence: 110xxxxx 10xxxxxx. *bytes = 0xc0 | ((value & 0x7c0) >> 6); bytes++; *bytes = 0x80 | (value & 0x3f); return 2; } else if (value <= 0xffff) { // Three byte sequence: 1110xxxx 10xxxxxx 10xxxxxx. *bytes = 0xe0 | ((value & 0xf000) >> 12); bytes++; *bytes = 0x80 | ((value & 0xfc0) >> 6); bytes++; *bytes = 0x80 | (value & 0x3f); return 3; } else if (value <= 0x10ffff) { // Four byte sequence: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx. *bytes = 0xf0 | ((value & 0x1c0000) >> 18); bytes++; *bytes = 0x80 | ((value & 0x3f000) >> 12); bytes++; *bytes = 0x80 | ((value & 0xfc0) >> 6); bytes++; *bytes = 0x80 | (value & 0x3f); return 4; } // Invalid Unicode value. See: http://tools.ietf.org/html/rfc3629 UNREACHABLE(); return 0; } int wrenUtf8Decode(const uint8_t* bytes, uint32_t length) { // Single byte (i.e. fits in ASCII). if (*bytes <= 0x7f) return *bytes; int value; uint32_t remainingBytes; if ((*bytes & 0xe0) == 0xc0) { // Two byte sequence: 110xxxxx 10xxxxxx. value = *bytes & 0x1f; remainingBytes = 1; } else if ((*bytes & 0xf0) == 0xe0) { // Three byte sequence: 1110xxxx 10xxxxxx 10xxxxxx. value = *bytes & 0x0f; remainingBytes = 2; } else if ((*bytes & 0xf8) == 0xf0) { // Four byte sequence: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx. value = *bytes & 0x07; remainingBytes = 3; } else { // Invalid UTF-8 sequence. return -1; } // Don't read past the end of the buffer on truncated UTF-8. if (remainingBytes > length - 1) return -1; while (remainingBytes > 0) { bytes++; remainingBytes--; // Remaining bytes must be of form 10xxxxxx. if ((*bytes & 0xc0) != 0x80) return -1; value = value << 6 | (*bytes & 0x3f); } return value; } int wrenUtf8DecodeNumBytes(uint8_t byte) { // If the byte starts with 10xxxxx, it's the middle of a UTF-8 sequence, so // don't count it at all. if ((byte & 0xc0) == 0x80) return 0; // The first byte's high bits tell us how many bytes are in the UTF-8 // sequence. if ((byte & 0xf8) == 0xf0) return 4; if ((byte & 0xf0) == 0xe0) return 3; if ((byte & 0xe0) == 0xc0) return 2; return 1; } // From: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2Float int wrenPowerOf2Ceil(int n) { n--; n |= n >> 1; n |= n >> 2; n |= n >> 4; n |= n >> 8; n |= n >> 16; n++; return n; } // End file "wren_utils.c" // Begin file "wren_primitive.c" // Begin file "wren_primitive.h" #ifndef wren_primitive_h #define wren_primitive_h // Binds a primitive method named [name] (in Wren) implemented using C function // [fn] to `ObjClass` [cls]. #define PRIMITIVE(cls, name, function) \ do \ { \ int symbol = wrenSymbolTableEnsure(vm, \ &vm->methodNames, name, strlen(name)); \ Method method; \ method.type = METHOD_PRIMITIVE; \ method.as.primitive = prim_##function; \ wrenBindMethod(vm, cls, symbol, method); \ } while (false) // Binds a primitive method named [name] (in Wren) implemented using C function // [fn] to `ObjClass` [cls], but as a FN call. #define FUNCTION_CALL(cls, name, function) \ do \ { \ int symbol = wrenSymbolTableEnsure(vm, \ &vm->methodNames, name, strlen(name)); \ Method method; \ method.type = METHOD_FUNCTION_CALL; \ method.as.primitive = prim_##function; \ wrenBindMethod(vm, cls, symbol, method); \ } while (false) // Defines a primitive method whose C function name is [name]. This abstracts // the actual type signature of a primitive function and makes it clear which C // functions are invoked as primitives. #define DEF_PRIMITIVE(name) \ static bool prim_##name(WrenVM* vm, Value* args) #define RETURN_VAL(value) \ do \ { \ args[0] = value; \ return true; \ } while (false) #define RETURN_OBJ(obj) RETURN_VAL(OBJ_VAL(obj)) #define RETURN_BOOL(value) RETURN_VAL(BOOL_VAL(value)) #define RETURN_FALSE RETURN_VAL(FALSE_VAL) #define RETURN_NULL RETURN_VAL(NULL_VAL) #define RETURN_NUM(value) RETURN_VAL(NUM_VAL(value)) #define RETURN_TRUE RETURN_VAL(TRUE_VAL) #define RETURN_ERROR(msg) \ do \ { \ vm->fiber->error = wrenNewStringLength(vm, msg, sizeof(msg) - 1); \ return false; \ } while (false) #define RETURN_ERROR_FMT(...) \ do \ { \ vm->fiber->error = wrenStringFormat(vm, __VA_ARGS__); \ return false; \ } while (false) // Validates that the given [arg] is a function. Returns true if it is. If not, // reports an error and returns false. bool validateFn(WrenVM* vm, Value arg, const char* argName); // Validates that the given [arg] is a Num. Returns true if it is. If not, // reports an error and returns false. bool validateNum(WrenVM* vm, Value arg, const char* argName); // Validates that [value] is an integer. Returns true if it is. If not, reports // an error and returns false. bool validateIntValue(WrenVM* vm, double value, const char* argName); // Validates that the given [arg] is an integer. Returns true if it is. If not, // reports an error and returns false. bool validateInt(WrenVM* vm, Value arg, const char* argName); // Validates that [arg] is a valid object for use as a map key. Returns true if // it is. If not, reports an error and returns false. bool validateKey(WrenVM* vm, Value arg); // Validates that the argument at [argIndex] is an integer within `[0, count)`. // Also allows negative indices which map backwards from the end. Returns the // valid positive index value. If invalid, reports an error and returns // `UINT32_MAX`. uint32_t validateIndex(WrenVM* vm, Value arg, uint32_t count, const char* argName); // Validates that the given [arg] is a String. Returns true if it is. If not, // reports an error and returns false. bool validateString(WrenVM* vm, Value arg, const char* argName); // Given a [range] and the [length] of the object being operated on, determines // the series of elements that should be chosen from the underlying object. // Handles ranges that count backwards from the end as well as negative ranges. // // Returns the index from which the range should start or `UINT32_MAX` if the // range is invalid. After calling, [length] will be updated with the number of // elements in the resulting sequence. [step] will be direction that the range // is going: `1` if the range is increasing from the start index or `-1` if the // range is decreasing. uint32_t calculateRange(WrenVM* vm, ObjRange* range, uint32_t* length, int* step); #endif // End file "wren_primitive.h" #include <math.h> // Validates that [value] is an integer within `[0, count)`. Also allows // negative indices which map backwards from the end. Returns the valid positive // index value. If invalid, reports an error and returns `UINT32_MAX`. static uint32_t validateIndexValue(WrenVM* vm, uint32_t count, double value, const char* argName) { if (!validateIntValue(vm, value, argName)) return UINT32_MAX; // Negative indices count from the end. if (value < 0) value = count + value; // Check bounds. if (value >= 0 && value < count) return (uint32_t)value; vm->fiber->error = wrenStringFormat(vm, "$ out of bounds.", argName); return UINT32_MAX; } bool validateFn(WrenVM* vm, Value arg, const char* argName) { if (IS_CLOSURE(arg)) return true; RETURN_ERROR_FMT("$ must be a function.", argName); } bool validateNum(WrenVM* vm, Value arg, const char* argName) { if (IS_NUM(arg)) return true; RETURN_ERROR_FMT("$ must be a number.", argName); } bool validateIntValue(WrenVM* vm, double value, const char* argName) { if (trunc(value) == value) return true; RETURN_ERROR_FMT("$ must be an integer.", argName); } bool validateInt(WrenVM* vm, Value arg, const char* argName) { // Make sure it's a number first. if (!validateNum(vm, arg, argName)) return false; return validateIntValue(vm, AS_NUM(arg), argName); } bool validateKey(WrenVM* vm, Value arg) { if (IS_BOOL(arg) || IS_CLASS(arg) || IS_NULL(arg) || IS_NUM(arg) || IS_RANGE(arg) || IS_STRING(arg)) { return true; } RETURN_ERROR("Key must be a value type."); } uint32_t validateIndex(WrenVM* vm, Value arg, uint32_t count, const char* argName) { if (!validateNum(vm, arg, argName)) return UINT32_MAX; return validateIndexValue(vm, count, AS_NUM(arg), argName); } bool validateString(WrenVM* vm, Value arg, const char* argName) { if (IS_STRING(arg)) return true; RETURN_ERROR_FMT("$ must be a string.", argName); } uint32_t calculateRange(WrenVM* vm, ObjRange* range, uint32_t* length, int* step) { *step = 0; // Edge case: an empty range is allowed at the end of a sequence. This way, // list[0..-1] and list[0...list.count] can be used to copy a list even when // empty. if (range->from == *length && range->to == (range->isInclusive ? -1.0 : (double)*length)) { *length = 0; return 0; } uint32_t from = validateIndexValue(vm, *length, range->from, "Range start"); if (from == UINT32_MAX) return UINT32_MAX; // Bounds check the end manually to handle exclusive ranges. double value = range->to; if (!validateIntValue(vm, value, "Range end")) return UINT32_MAX; // Negative indices count from the end. if (value < 0) value = *length + value; // Convert the exclusive range to an inclusive one. if (!range->isInclusive) { // An exclusive range with the same start and end points is empty. if (value == from) { *length = 0; return from; } // Shift the endpoint to make it inclusive, handling both increasing and // decreasing ranges. value += value >= from ? -1 : 1; } // Check bounds. if (value < 0 || value >= *length) { vm->fiber->error = CONST_STRING(vm, "Range end out of bounds."); return UINT32_MAX; } uint32_t to = (uint32_t)value; *length = abs((int)(from - to)) + 1; *step = from < to ? 1 : -1; return from; } // End file "wren_primitive.c" // Begin file "wren_core.c" #include <ctype.h> #include <errno.h> #include <float.h> #include <math.h> #include <string.h> #include <time.h> // Begin file "wren_core.h" #ifndef wren_core_h #define wren_core_h // This module defines the built-in classes and their primitives methods that // are implemented directly in C code. Some languages try to implement as much // of the core module itself in the primary language instead of in the host // language. // // With Wren, we try to do as much of it in C as possible. Primitive methods // are always faster than code written in Wren, and it minimizes startup time // since we don't have to parse, compile, and execute Wren code. // // There is one limitation, though. Methods written in C cannot call Wren ones. // They can only be the top of the callstack, and immediately return. This // makes it difficult to have primitive methods that rely on polymorphic // behavior. For example, `IO.write` should call `toString` on its argument, // including user-defined `toString` methods on user-defined classes. void wrenInitializeCore(WrenVM* vm); #endif // End file "wren_core.h" // Begin file "wren_core.wren.inc" // Generated automatically from src/vm/wren_core.wren. Do not edit. static const char* coreModuleSource = "class Bool {}\n" "class Fiber {}\n" "class Fn {}\n" "class Null {}\n" "class Num {}\n" "\n" "class Sequence {\n" " all(f) {\n" " var result = true\n" " for (element in this) {\n" " result = f.call(element)\n" " if (!result) return result\n" " }\n" " return result\n" " }\n" "\n" " any(f) {\n" " var result = false\n" " for (element in this) {\n" " result = f.call(element)\n" " if (result) return result\n" " }\n" " return result\n" " }\n" "\n" " contains(element) {\n" " for (item in this) {\n" " if (element == item) return true\n" " }\n" " return false\n" " }\n" "\n" " count {\n" " var result = 0\n" " for (element in this) {\n" " result = result + 1\n" " }\n" " return result\n" " }\n" "\n" " count(f) {\n" " var result = 0\n" " for (element in this) {\n" " if (f.call(element)) result = result + 1\n" " }\n" " return result\n" " }\n" "\n" " each(f) {\n" " for (element in this) {\n" " f.call(element)\n" " }\n" " }\n" "\n" " isEmpty { iterate(null) ? false : true }\n" "\n" " map(transformation) { MapSequence.new(this, transformation) }\n" "\n" " skip(count) {\n" " if (!(count is Num) || !count.isInteger || count < 0) {\n" " Fiber.abort(\"Count must be a non-negative integer.\")\n" " }\n" "\n" " return SkipSequence.new(this, count)\n" " }\n" "\n" " take(count) {\n" " if (!(count is Num) || !count.isInteger || count < 0) {\n" " Fiber.abort(\"Count must be a non-negative integer.\")\n" " }\n" "\n" " return TakeSequence.new(this, count)\n" " }\n" "\n" " where(predicate) { WhereSequence.new(this, predicate) }\n" "\n" " reduce(acc, f) {\n" " for (element in this) {\n" " acc = f.call(acc, element)\n" " }\n" " return acc\n" " }\n" "\n" " reduce(f) {\n" " var iter = iterate(null)\n" " if (!iter) Fiber.abort(\"Can't reduce an empty sequence.\")\n" "\n" " // Seed with the first element.\n" " var result = iteratorValue(iter)\n" " while (iter = iterate(iter)) {\n" " result = f.call(result, iteratorValue(iter))\n" " }\n" "\n" " return result\n" " }\n" "\n" " join() { join(\"\") }\n" "\n" " join(sep) {\n" " var first = true\n" " var result = \"\"\n" "\n" " for (element in this) {\n" " if (!first) result = result + sep\n" " first = false\n" " result = result + element.toString\n" " }\n" "\n" " return result\n" " }\n" "\n" " toList {\n" " var result = List.new()\n" " for (element in this) {\n" " result.add(element)\n" " }\n" " return result\n" " }\n" "}\n" "\n" "class MapSequence is Sequence {\n" " construct new(sequence, fn) {\n" " _sequence = sequence\n" " _fn = fn\n" " }\n" "\n" " iterate(iterator) { _sequence.iterate(iterator) }\n" " iteratorValue(iterator) { _fn.call(_sequence.iteratorValue(iterator)) }\n" "}\n" "\n" "class SkipSequence is Sequence {\n" " construct new(sequence, count) {\n" " _sequence = sequence\n" " _count = count\n" " }\n" "\n" " iterate(iterator) {\n" " if (iterator) {\n" " return _sequence.iterate(iterator)\n" " } else {\n" " iterator = _sequence.iterate(iterator)\n" " var count = _count\n" " while (count > 0 && iterator) {\n" " iterator = _sequence.iterate(iterator)\n" " count = count - 1\n" " }\n" " return iterator\n" " }\n" " }\n" "\n" " iteratorValue(iterator) { _sequence.iteratorValue(iterator) }\n" "}\n" "\n" "class TakeSequence is Sequence {\n" " construct new(sequence, count) {\n" " _sequence = sequence\n" " _count = count\n" " }\n" "\n" " iterate(iterator) {\n" " if (!iterator) _taken = 1 else _taken = _taken + 1\n" " return _taken > _count ? null : _sequence.iterate(iterator)\n" " }\n" "\n" " iteratorValue(iterator) { _sequence.iteratorValue(iterator) }\n" "}\n" "\n" "class WhereSequence is Sequence {\n" " construct new(sequence, fn) {\n" " _sequence = sequence\n" " _fn = fn\n" " }\n" "\n" " iterate(iterator) {\n" " while (iterator = _sequence.iterate(iterator)) {\n" " if (_fn.call(_sequence.iteratorValue(iterator))) break\n" " }\n" " return iterator\n" " }\n" "\n" " iteratorValue(iterator) { _sequence.iteratorValue(iterator) }\n" "}\n" "\n" "class String is Sequence {\n" " bytes { StringByteSequence.new(this) }\n" " codePoints { StringCodePointSequence.new(this) }\n" "\n" " split(delimiter) {\n" " if (!(delimiter is String) || delimiter.isEmpty) {\n" " Fiber.abort(\"Delimiter must be a non-empty string.\")\n" " }\n" "\n" " var result = []\n" "\n" " var last = 0\n" " var index = 0\n" "\n" " var delimSize = delimiter.byteCount_\n" " var size = byteCount_\n" "\n" " while (last < size && (index = indexOf(delimiter, last)) != -1) {\n" " result.add(this[last...index])\n" " last = index + delimSize\n" " }\n" "\n" " if (last < size) {\n" " result.add(this[last..-1])\n" " } else {\n" " result.add(\"\")\n" " }\n" " return result\n" " }\n" "\n" " replace(from, to) {\n" " if (!(from is String) || from.isEmpty) {\n" " Fiber.abort(\"From must be a non-empty string.\")\n" " } else if (!(to is String)) {\n" " Fiber.abort(\"To must be a string.\")\n" " }\n" "\n" " var result = \"\"\n" "\n" " var last = 0\n" " var index = 0\n" "\n" " var fromSize = from.byteCount_\n" " var size = byteCount_\n" "\n" " while (last < size && (index = indexOf(from, last)) != -1) {\n" " result = result + this[last...index] + to\n" " last = index + fromSize\n" " }\n" "\n" " if (last < size) result = result + this[last..-1]\n" "\n" " return result\n" " }\n" "\n" " trim() { trim_(\"\t\r\n \", true, true) }\n" " trim(chars) { trim_(chars, true, true) }\n" " trimEnd() { trim_(\"\t\r\n \", false, true) }\n" " trimEnd(chars) { trim_(chars, false, true) }\n" " trimStart() { trim_(\"\t\r\n \", true, false) }\n" " trimStart(chars) { trim_(chars, true, false) }\n" "\n" " trim_(chars, trimStart, trimEnd) {\n" " if (!(chars is String)) {\n" " Fiber.abort(\"Characters must be a string.\")\n" " }\n" "\n" " var codePoints = chars.codePoints.toList\n" "\n" " var start\n" " if (trimStart) {\n" " while (start = iterate(start)) {\n" " if (!codePoints.contains(codePointAt_(start))) break\n" " }\n" "\n" " if (start == false) return \"\"\n" " } else {\n" " start = 0\n" " }\n" "\n" " var end\n" " if (trimEnd) {\n" " end = byteCount_ - 1\n" " while (end >= start) {\n" " var codePoint = codePointAt_(end)\n" " if (codePoint != -1 && !codePoints.contains(codePoint)) break\n" " end = end - 1\n" " }\n" "\n" " if (end < start) return \"\"\n" " } else {\n" " end = -1\n" " }\n" "\n" " return this[start..end]\n" " }\n" "\n" " *(count) {\n" " if (!(count is Num) || !count.isInteger || count < 0) {\n" " Fiber.abort(\"Count must be a non-negative integer.\")\n" " }\n" "\n" " var result = \"\"\n" " for (i in 0...count) {\n" " result = result + this\n" " }\n" " return result\n" " }\n" "}\n" "\n" "class StringByteSequence is Sequence {\n" " construct new(string) {\n" " _string = string\n" " }\n" "\n" " [index] { _string.byteAt_(index) }\n" " iterate(iterator) { _string.iterateByte_(iterator) }\n" " iteratorValue(iterator) { _string.byteAt_(iterator) }\n" "\n" " count { _string.byteCount_ }\n" "}\n" "\n" "class StringCodePointSequence is Sequence {\n" " construct new(string) {\n" " _string = string\n" " }\n" "\n" " [index] { _string.codePointAt_(index) }\n" " iterate(iterator) { _string.iterate(iterator) }\n" " iteratorValue(iterator) { _string.codePointAt_(iterator) }\n" "\n" " count { _string.count }\n" "}\n" "\n" "class List is Sequence {\n" " addAll(other) {\n" " for (element in other) {\n" " add(element)\n" " }\n" " return other\n" " }\n" "\n" " toString { \"[%(join(\", \"))]\" }\n" "\n" " +(other) {\n" " var result = this[0..-1]\n" " for (element in other) {\n" " result.add(element)\n" " }\n" " return result\n" " }\n" "\n" " *(count) {\n" " if (!(count is Num) || !count.isInteger || count < 0) {\n" " Fiber.abort(\"Count must be a non-negative integer.\")\n" " }\n" "\n" " var result = []\n" " for (i in 0...count) {\n" " result.addAll(this)\n" " }\n" " return result\n" " }\n" "}\n" "\n" "class Map is Sequence {\n" " keys { MapKeySequence.new(this) }\n" " values { MapValueSequence.new(this) }\n" "\n" " toString {\n" " var first = true\n" " var result = \"{\"\n" "\n" " for (key in keys) {\n" " if (!first) result = result + \", \"\n" " first = false\n" " result = result + \"%(key): %(this[key])\"\n" " }\n" "\n" " return result + \"}\"\n" " }\n" "\n" " iteratorValue(iterator) {\n" " return MapEntry.new(\n" " keyIteratorValue_(iterator),\n" " valueIteratorValue_(iterator))\n" " }\n" "}\n" "\n" "class MapEntry {\n" " construct new(key, value) {\n" " _key = key\n" " _value = value\n" " }\n" "\n" " key { _key }\n" " value { _value }\n" "\n" " toString { \"%(_key):%(_value)\" }\n" "}\n" "\n" "class MapKeySequence is Sequence {\n" " construct new(map) {\n" " _map = map\n" " }\n" "\n" " iterate(n) { _map.iterate(n) }\n" " iteratorValue(iterator) { _map.keyIteratorValue_(iterator) }\n" "}\n" "\n" "class MapValueSequence is Sequence {\n" " construct new(map) {\n" " _map = map\n" " }\n" "\n" " iterate(n) { _map.iterate(n) }\n" " iteratorValue(iterator) { _map.valueIteratorValue_(iterator) }\n" "}\n" "\n" "class Range is Sequence {}\n" "\n" "class System {\n" " static print() {\n" " writeString_(\"\n\")\n" " }\n" "\n" " static print(obj) {\n" " writeObject_(obj)\n" " writeString_(\"\n\")\n" " return obj\n" " }\n" "\n" " static printAll(sequence) {\n" " for (object in sequence) writeObject_(object)\n" " writeString_(\"\n\")\n" " }\n" "\n" " static write(obj) {\n" " writeObject_(obj)\n" " return obj\n" " }\n" "\n" " static writeAll(sequence) {\n" " for (object in sequence) writeObject_(object)\n" " }\n" "\n" " static writeObject_(obj) {\n" " var string = obj.toString\n" " if (string is String) {\n" " writeString_(string)\n" " } else {\n" " writeString_(\"[invalid toString]\")\n" " }\n" " }\n" "}\n"; // End file "wren_core.wren.inc" DEF_PRIMITIVE(bool_not) { RETURN_BOOL(!AS_BOOL(args[0])); } DEF_PRIMITIVE(bool_toString) { if (AS_BOOL(args[0])) { RETURN_VAL(CONST_STRING(vm, "true")); } else { RETURN_VAL(CONST_STRING(vm, "false")); } } DEF_PRIMITIVE(class_name) { RETURN_OBJ(AS_CLASS(args[0])->name); } DEF_PRIMITIVE(class_supertype) { ObjClass* classObj = AS_CLASS(args[0]); // Object has no superclass. if (classObj->superclass == NULL) RETURN_NULL; RETURN_OBJ(classObj->superclass); } DEF_PRIMITIVE(class_toString) { RETURN_OBJ(AS_CLASS(args[0])->name); } DEF_PRIMITIVE(fiber_new) { if (!validateFn(vm, args[1], "Argument")) return false; ObjClosure* closure = AS_CLOSURE(args[1]); if (closure->fn->arity > 1) { RETURN_ERROR("Function cannot take more than one parameter."); } RETURN_OBJ(wrenNewFiber(vm, closure)); } DEF_PRIMITIVE(fiber_abort) { vm->fiber->error = args[1]; // If the error is explicitly null, it's not really an abort. return IS_NULL(args[1]); } // Transfer execution to [fiber] coming from the current fiber whose stack has // [args]. // // [isCall] is true if [fiber] is being called and not transferred. // // [hasValue] is true if a value in [args] is being passed to the new fiber. // Otherwise, `null` is implicitly being passed. static bool runFiber(WrenVM* vm, ObjFiber* fiber, Value* args, bool isCall, bool hasValue, const char* verb) { if (wrenHasError(fiber)) { RETURN_ERROR_FMT("Cannot $ an aborted fiber.", verb); } if (isCall) { // You can't call a called fiber, but you can transfer directly to it, // which is why this check is gated on `isCall`. This way, after resuming a // suspended fiber, it will run and then return to the fiber that called it // and so on. if (fiber->caller != NULL) RETURN_ERROR("Fiber has already been called."); if (fiber->state == FIBER_ROOT) RETURN_ERROR("Cannot call root fiber."); // Remember who ran it. fiber->caller = vm->fiber; } if (fiber->numFrames == 0) { RETURN_ERROR_FMT("Cannot $ a finished fiber.", verb); } // When the calling fiber resumes, we'll store the result of the call in its // stack. If the call has two arguments (the fiber and the value), we only // need one slot for the result, so discard the other slot now. if (hasValue) vm->fiber->stackTop--; if (fiber->numFrames == 1 && fiber->frames[0].ip == fiber->frames[0].closure->fn->code.data) { // The fiber is being started for the first time. If its function takes a // parameter, bind an argument to it. if (fiber->frames[0].closure->fn->arity == 1) { fiber->stackTop[0] = hasValue ? args[1] : NULL_VAL; fiber->stackTop++; } } else { // The fiber is being resumed, make yield() or transfer() return the result. fiber->stackTop[-1] = hasValue ? args[1] : NULL_VAL; } vm->fiber = fiber; return false; } DEF_PRIMITIVE(fiber_call) { return runFiber(vm, AS_FIBER(args[0]), args, true, false, "call"); } DEF_PRIMITIVE(fiber_call1) { return runFiber(vm, AS_FIBER(args[0]), args, true, true, "call"); } DEF_PRIMITIVE(fiber_current) { RETURN_OBJ(vm->fiber); } DEF_PRIMITIVE(fiber_error) { RETURN_VAL(AS_FIBER(args[0])->error); } DEF_PRIMITIVE(fiber_isDone) { ObjFiber* runFiber = AS_FIBER(args[0]); RETURN_BOOL(runFiber->numFrames == 0 || wrenHasError(runFiber)); } DEF_PRIMITIVE(fiber_suspend) { // Switching to a null fiber tells the interpreter to stop and exit. vm->fiber = NULL; vm->apiStack = NULL; return false; } DEF_PRIMITIVE(fiber_transfer) { return runFiber(vm, AS_FIBER(args[0]), args, false, false, "transfer to"); } DEF_PRIMITIVE(fiber_transfer1) { return runFiber(vm, AS_FIBER(args[0]), args, false, true, "transfer to"); } DEF_PRIMITIVE(fiber_transferError) { runFiber(vm, AS_FIBER(args[0]), args, false, true, "transfer to"); vm->fiber->error = args[1]; return false; } DEF_PRIMITIVE(fiber_try) { runFiber(vm, AS_FIBER(args[0]), args, true, false, "try"); // If we're switching to a valid fiber to try, remember that we're trying it. if (!wrenHasError(vm->fiber)) vm->fiber->state = FIBER_TRY; return false; } DEF_PRIMITIVE(fiber_yield) { ObjFiber* current = vm->fiber; vm->fiber = current->caller; // Unhook this fiber from the one that called it. current->caller = NULL; current->state = FIBER_OTHER; if (vm->fiber != NULL) { // Make the caller's run method return null. vm->fiber->stackTop[-1] = NULL_VAL; } return false; } DEF_PRIMITIVE(fiber_yield1) { ObjFiber* current = vm->fiber; vm->fiber = current->caller; // Unhook this fiber from the one that called it. current->caller = NULL; current->state = FIBER_OTHER; if (vm->fiber != NULL) { // Make the caller's run method return the argument passed to yield. vm->fiber->stackTop[-1] = args[1]; // When the yielding fiber resumes, we'll store the result of the yield // call in its stack. Since Fiber.yield(value) has two arguments (the Fiber // class and the value) and we only need one slot for the result, discard // the other slot now. current->stackTop--; } return false; } DEF_PRIMITIVE(fn_new) { if (!validateFn(vm, args[1], "Argument")) return false; // The block argument is already a function, so just return it. RETURN_VAL(args[1]); } DEF_PRIMITIVE(fn_arity) { RETURN_NUM(AS_CLOSURE(args[0])->fn->arity); } static void call_fn(WrenVM* vm, Value* args, int numArgs) { // +1 to include the function itself. wrenCallFunction(vm, vm->fiber, AS_CLOSURE(args[0]), numArgs + 1); } #define DEF_FN_CALL(numArgs) \ DEF_PRIMITIVE(fn_call##numArgs) \ { \ call_fn(vm, args, numArgs); \ return false; \ } DEF_FN_CALL(0) DEF_FN_CALL(1) DEF_FN_CALL(2) DEF_FN_CALL(3) DEF_FN_CALL(4) DEF_FN_CALL(5) DEF_FN_CALL(6) DEF_FN_CALL(7) DEF_FN_CALL(8) DEF_FN_CALL(9) DEF_FN_CALL(10) DEF_FN_CALL(11) DEF_FN_CALL(12) DEF_FN_CALL(13) DEF_FN_CALL(14) DEF_FN_CALL(15) DEF_FN_CALL(16) DEF_PRIMITIVE(fn_toString) { RETURN_VAL(CONST_STRING(vm, "<fn>")); } // Creates a new list of size args[1], with all elements initialized to args[2]. DEF_PRIMITIVE(list_filled) { if (!validateInt(vm, args[1], "Size")) return false; if (AS_NUM(args[1]) < 0) RETURN_ERROR("Size cannot be negative."); uint32_t size = (uint32_t)AS_NUM(args[1]); ObjList* list = wrenNewList(vm, size); for (uint32_t i = 0; i < size; i++) { list->elements.data[i] = args[2]; } RETURN_OBJ(list); } DEF_PRIMITIVE(list_new) { RETURN_OBJ(wrenNewList(vm, 0)); } DEF_PRIMITIVE(list_add) { wrenValueBufferWrite(vm, &AS_LIST(args[0])->elements, args[1]); RETURN_VAL(args[1]); } // Adds an element to the list and then returns the list itself. This is called // by the compiler when compiling list literals instead of using add() to // minimize stack churn. DEF_PRIMITIVE(list_addCore) { wrenValueBufferWrite(vm, &AS_LIST(args[0])->elements, args[1]); // Return the list. RETURN_VAL(args[0]); } DEF_PRIMITIVE(list_clear) { wrenValueBufferClear(vm, &AS_LIST(args[0])->elements); RETURN_NULL; } DEF_PRIMITIVE(list_count) { RETURN_NUM(AS_LIST(args[0])->elements.count); } DEF_PRIMITIVE(list_insert) { ObjList* list = AS_LIST(args[0]); // count + 1 here so you can "insert" at the very end. uint32_t index = validateIndex(vm, args[1], list->elements.count + 1, "Index"); if (index == UINT32_MAX) return false; wrenListInsert(vm, list, args[2], index); RETURN_VAL(args[2]); } DEF_PRIMITIVE(list_iterate) { ObjList* list = AS_LIST(args[0]); // If we're starting the iteration, return the first index. if (IS_NULL(args[1])) { if (list->elements.count == 0) RETURN_FALSE; RETURN_NUM(0); } if (!validateInt(vm, args[1], "Iterator")) return false; // Stop if we're out of bounds. double index = AS_NUM(args[1]); if (index < 0 || index >= list->elements.count - 1) RETURN_FALSE; // Otherwise, move to the next index. RETURN_NUM(index + 1); } DEF_PRIMITIVE(list_iteratorValue) { ObjList* list = AS_LIST(args[0]); uint32_t index = validateIndex(vm, args[1], list->elements.count, "Iterator"); if (index == UINT32_MAX) return false; RETURN_VAL(list->elements.data[index]); } DEF_PRIMITIVE(list_removeAt) { ObjList* list = AS_LIST(args[0]); uint32_t index = validateIndex(vm, args[1], list->elements.count, "Index"); if (index == UINT32_MAX) return false; RETURN_VAL(wrenListRemoveAt(vm, list, index)); } DEF_PRIMITIVE(list_subscript) { ObjList* list = AS_LIST(args[0]); if (IS_NUM(args[1])) { uint32_t index = validateIndex(vm, args[1], list->elements.count, "Subscript"); if (index == UINT32_MAX) return false; RETURN_VAL(list->elements.data[index]); } if (!IS_RANGE(args[1])) { RETURN_ERROR("Subscript must be a number or a range."); } int step; uint32_t count = list->elements.count; uint32_t start = calculateRange(vm, AS_RANGE(args[1]), &count, &step); if (start == UINT32_MAX) return false; ObjList* result = wrenNewList(vm, count); for (uint32_t i = 0; i < count; i++) { result->elements.data[i] = list->elements.data[start + i * step]; } RETURN_OBJ(result); } DEF_PRIMITIVE(list_subscriptSetter) { ObjList* list = AS_LIST(args[0]); uint32_t index = validateIndex(vm, args[1], list->elements.count, "Subscript"); if (index == UINT32_MAX) return false; list->elements.data[index] = args[2]; RETURN_VAL(args[2]); } DEF_PRIMITIVE(map_new) { RETURN_OBJ(wrenNewMap(vm)); } DEF_PRIMITIVE(map_subscript) { if (!validateKey(vm, args[1])) return false; ObjMap* map = AS_MAP(args[0]); Value value = wrenMapGet(map, args[1]); if (IS_UNDEFINED(value)) RETURN_NULL; RETURN_VAL(value); } DEF_PRIMITIVE(map_subscriptSetter) { if (!validateKey(vm, args[1])) return false; wrenMapSet(vm, AS_MAP(args[0]), args[1], args[2]); RETURN_VAL(args[2]); } // Adds an entry to the map and then returns the map itself. This is called by // the compiler when compiling map literals instead of using [_]=(_) to // minimize stack churn. DEF_PRIMITIVE(map_addCore) { if (!validateKey(vm, args[1])) return false; wrenMapSet(vm, AS_MAP(args[0]), args[1], args[2]); // Return the map itself. RETURN_VAL(args[0]); } DEF_PRIMITIVE(map_clear) { wrenMapClear(vm, AS_MAP(args[0])); RETURN_NULL; } DEF_PRIMITIVE(map_containsKey) { if (!validateKey(vm, args[1])) return false; RETURN_BOOL(!IS_UNDEFINED(wrenMapGet(AS_MAP(args[0]), args[1]))); } DEF_PRIMITIVE(map_count) { RETURN_NUM(AS_MAP(args[0])->count); } DEF_PRIMITIVE(map_iterate) { ObjMap* map = AS_MAP(args[0]); if (map->count == 0) RETURN_FALSE; // If we're starting the iteration, start at the first used entry. uint32_t index = 0; // Otherwise, start one past the last entry we stopped at. if (!IS_NULL(args[1])) { if (!validateInt(vm, args[1], "Iterator")) return false; if (AS_NUM(args[1]) < 0) RETURN_FALSE; index = (uint32_t)AS_NUM(args[1]); if (index >= map->capacity) RETURN_FALSE; // Advance the iterator. index++; } // Find a used entry, if any. for (; index < map->capacity; index++) { if (!IS_UNDEFINED(map->entries[index].key)) RETURN_NUM(index); } // If we get here, walked all of the entries. RETURN_FALSE; } DEF_PRIMITIVE(map_remove) { if (!validateKey(vm, args[1])) return false; RETURN_VAL(wrenMapRemoveKey(vm, AS_MAP(args[0]), args[1])); } DEF_PRIMITIVE(map_keyIteratorValue) { ObjMap* map = AS_MAP(args[0]); uint32_t index = validateIndex(vm, args[1], map->capacity, "Iterator"); if (index == UINT32_MAX) return false; MapEntry* entry = &map->entries[index]; if (IS_UNDEFINED(entry->key)) { RETURN_ERROR("Invalid map iterator."); } RETURN_VAL(entry->key); } DEF_PRIMITIVE(map_valueIteratorValue) { ObjMap* map = AS_MAP(args[0]); uint32_t index = validateIndex(vm, args[1], map->capacity, "Iterator"); if (index == UINT32_MAX) return false; MapEntry* entry = &map->entries[index]; if (IS_UNDEFINED(entry->key)) { RETURN_ERROR("Invalid map iterator."); } RETURN_VAL(entry->value); } DEF_PRIMITIVE(null_not) { RETURN_VAL(TRUE_VAL); } DEF_PRIMITIVE(null_toString) { RETURN_VAL(CONST_STRING(vm, "null")); } DEF_PRIMITIVE(num_fromString) { if (!validateString(vm, args[1], "Argument")) return false; ObjString* string = AS_STRING(args[1]); // Corner case: Can't parse an empty string. if (string->length == 0) RETURN_NULL; errno = 0; char* end; double number = strtod(string->value, &end); // Skip past any trailing whitespace. while (*end != '\0' && isspace((unsigned char)*end)) end++; if (errno == ERANGE) RETURN_ERROR("Number literal is too large."); // We must have consumed the entire string. Otherwise, it contains non-number // characters and we can't parse it. if (end < string->value + string->length) RETURN_NULL; RETURN_NUM(number); } DEF_PRIMITIVE(num_pi) { RETURN_NUM(3.14159265358979323846); } // Defines a primitive on Num that calls infix [op] and returns [type]. #define DEF_NUM_INFIX(name, op, type) \ DEF_PRIMITIVE(num_##name) \ { \ if (!validateNum(vm, args[1], "Right operand")) return false; \ RETURN_##type(AS_NUM(args[0]) op AS_NUM(args[1])); \ } DEF_NUM_INFIX(minus, -, NUM) DEF_NUM_INFIX(plus, +, NUM) DEF_NUM_INFIX(multiply, *, NUM) DEF_NUM_INFIX(divide, /, NUM) DEF_NUM_INFIX(lt, <, BOOL) DEF_NUM_INFIX(gt, >, BOOL) DEF_NUM_INFIX(lte, <=, BOOL) DEF_NUM_INFIX(gte, >=, BOOL) // Defines a primitive on Num that call infix bitwise [op]. #define DEF_NUM_BITWISE(name, op) \ DEF_PRIMITIVE(num_bitwise##name) \ { \ if (!validateNum(vm, args[1], "Right operand")) return false; \ uint32_t left = (uint32_t)AS_NUM(args[0]); \ uint32_t right = (uint32_t)AS_NUM(args[1]); \ RETURN_NUM(left op right); \ } DEF_NUM_BITWISE(And, &) DEF_NUM_BITWISE(Or, |) DEF_NUM_BITWISE(Xor, ^) DEF_NUM_BITWISE(LeftShift, <<) DEF_NUM_BITWISE(RightShift, >>) // Defines a primitive method on Num that returns the result of [fn]. #define DEF_NUM_FN(name, fn) \ DEF_PRIMITIVE(num_##name) \ { \ RETURN_NUM(fn(AS_NUM(args[0]))); \ } DEF_NUM_FN(abs, fabs) DEF_NUM_FN(acos, acos) DEF_NUM_FN(asin, asin) DEF_NUM_FN(atan, atan) DEF_NUM_FN(ceil, ceil) DEF_NUM_FN(cos, cos) DEF_NUM_FN(floor, floor) DEF_NUM_FN(negate, -) DEF_NUM_FN(round, round) DEF_NUM_FN(sin, sin) DEF_NUM_FN(sqrt, sqrt) DEF_NUM_FN(tan, tan) DEF_NUM_FN(log, log) DEF_NUM_FN(log2, log2) DEF_NUM_FN(exp, exp) DEF_PRIMITIVE(num_mod) { if (!validateNum(vm, args[1], "Right operand")) return false; RETURN_NUM(fmod(AS_NUM(args[0]), AS_NUM(args[1]))); } DEF_PRIMITIVE(num_eqeq) { if (!IS_NUM(args[1])) RETURN_FALSE; RETURN_BOOL(AS_NUM(args[0]) == AS_NUM(args[1])); } DEF_PRIMITIVE(num_bangeq) { if (!IS_NUM(args[1])) RETURN_TRUE; RETURN_BOOL(AS_NUM(args[0]) != AS_NUM(args[1])); } DEF_PRIMITIVE(num_bitwiseNot) { // Bitwise operators always work on 32-bit unsigned ints. RETURN_NUM(~(uint32_t)AS_NUM(args[0])); } DEF_PRIMITIVE(num_dotDot) { if (!validateNum(vm, args[1], "Right hand side of range")) return false; double from = AS_NUM(args[0]); double to = AS_NUM(args[1]); RETURN_VAL(wrenNewRange(vm, from, to, true)); } DEF_PRIMITIVE(num_dotDotDot) { if (!validateNum(vm, args[1], "Right hand side of range")) return false; double from = AS_NUM(args[0]); double to = AS_NUM(args[1]); RETURN_VAL(wrenNewRange(vm, from, to, false)); } DEF_PRIMITIVE(num_atan2) { RETURN_NUM(atan2(AS_NUM(args[0]), AS_NUM(args[1]))); } DEF_PRIMITIVE(num_pow) { RETURN_NUM(pow(AS_NUM(args[0]), AS_NUM(args[1]))); } DEF_PRIMITIVE(num_fraction) { double dummy; RETURN_NUM(modf(AS_NUM(args[0]) , &dummy)); } DEF_PRIMITIVE(num_isInfinity) { RETURN_BOOL(isinf(AS_NUM(args[0]))); } DEF_PRIMITIVE(num_isInteger) { double value = AS_NUM(args[0]); if (isnan(value) || isinf(value)) RETURN_FALSE; RETURN_BOOL(trunc(value) == value); } DEF_PRIMITIVE(num_isNan) { RETURN_BOOL(isnan(AS_NUM(args[0]))); } DEF_PRIMITIVE(num_sign) { double value = AS_NUM(args[0]); if (value > 0) { RETURN_NUM(1); } else if (value < 0) { RETURN_NUM(-1); } else { RETURN_NUM(0); } } DEF_PRIMITIVE(num_largest) { RETURN_NUM(DBL_MAX); } DEF_PRIMITIVE(num_smallest) { RETURN_NUM(DBL_MIN); } DEF_PRIMITIVE(num_toString) { RETURN_VAL(wrenNumToString(vm, AS_NUM(args[0]))); } DEF_PRIMITIVE(num_truncate) { double integer; modf(AS_NUM(args[0]) , &integer); RETURN_NUM(integer); } DEF_PRIMITIVE(object_same) { RETURN_BOOL(wrenValuesEqual(args[1], args[2])); } DEF_PRIMITIVE(object_not) { RETURN_VAL(FALSE_VAL); } DEF_PRIMITIVE(object_eqeq) { RETURN_BOOL(wrenValuesEqual(args[0], args[1])); } DEF_PRIMITIVE(object_bangeq) { RETURN_BOOL(!wrenValuesEqual(args[0], args[1])); } DEF_PRIMITIVE(object_is) { if (!IS_CLASS(args[1])) { RETURN_ERROR("Right operand must be a class."); } ObjClass *classObj = wrenGetClass(vm, args[0]); ObjClass *baseClassObj = AS_CLASS(args[1]); // Walk the superclass chain looking for the class. do { if (baseClassObj == classObj) RETURN_BOOL(true); classObj = classObj->superclass; } while (classObj != NULL); RETURN_BOOL(false); } DEF_PRIMITIVE(object_toString) { Obj* obj = AS_OBJ(args[0]); Value name = OBJ_VAL(obj->classObj->name); RETURN_VAL(wrenStringFormat(vm, "instance of @", name)); } DEF_PRIMITIVE(object_type) { RETURN_OBJ(wrenGetClass(vm, args[0])); } DEF_PRIMITIVE(range_from) { RETURN_NUM(AS_RANGE(args[0])->from); } DEF_PRIMITIVE(range_to) { RETURN_NUM(AS_RANGE(args[0])->to); } DEF_PRIMITIVE(range_min) { ObjRange* range = AS_RANGE(args[0]); RETURN_NUM(fmin(range->from, range->to)); } DEF_PRIMITIVE(range_max) { ObjRange* range = AS_RANGE(args[0]); RETURN_NUM(fmax(range->from, range->to)); } DEF_PRIMITIVE(range_isInclusive) { RETURN_BOOL(AS_RANGE(args[0])->isInclusive); } DEF_PRIMITIVE(range_iterate) { ObjRange* range = AS_RANGE(args[0]); // Special case: empty range. if (range->from == range->to && !range->isInclusive) RETURN_FALSE; // Start the iteration. if (IS_NULL(args[1])) RETURN_NUM(range->from); if (!validateNum(vm, args[1], "Iterator")) return false; double iterator = AS_NUM(args[1]); // Iterate towards [to] from [from]. if (range->from < range->to) { iterator++; if (iterator > range->to) RETURN_FALSE; } else { iterator--; if (iterator < range->to) RETURN_FALSE; } if (!range->isInclusive && iterator == range->to) RETURN_FALSE; RETURN_NUM(iterator); } DEF_PRIMITIVE(range_iteratorValue) { // Assume the iterator is a number so that is the value of the range. RETURN_VAL(args[1]); } DEF_PRIMITIVE(range_toString) { ObjRange* range = AS_RANGE(args[0]); Value from = wrenNumToString(vm, range->from); wrenPushRoot(vm, AS_OBJ(from)); Value to = wrenNumToString(vm, range->to); wrenPushRoot(vm, AS_OBJ(to)); Value result = wrenStringFormat(vm, "@$@", from, range->isInclusive ? ".." : "...", to); wrenPopRoot(vm); wrenPopRoot(vm); RETURN_VAL(result); } DEF_PRIMITIVE(string_fromCodePoint) { if (!validateInt(vm, args[1], "Code point")) return false; int codePoint = (int)AS_NUM(args[1]); if (codePoint < 0) { RETURN_ERROR("Code point cannot be negative."); } else if (codePoint > 0x10ffff) { RETURN_ERROR("Code point cannot be greater than 0x10ffff."); } RETURN_VAL(wrenStringFromCodePoint(vm, codePoint)); } DEF_PRIMITIVE(string_fromByte) { if (!validateInt(vm, args[1], "Byte")) return false; int byte = (int) AS_NUM(args[1]); if (byte < 0) { RETURN_ERROR("Byte cannot be negative."); } else if (byte > 0xff) { RETURN_ERROR("Byte cannot be greater than 0xff."); } RETURN_VAL(wrenStringFromByte(vm, (uint8_t) byte)); } DEF_PRIMITIVE(string_byteAt) { ObjString* string = AS_STRING(args[0]); uint32_t index = validateIndex(vm, args[1], string->length, "Index"); if (index == UINT32_MAX) return false; RETURN_NUM((uint8_t)string->value[index]); } DEF_PRIMITIVE(string_byteCount) { RETURN_NUM(AS_STRING(args[0])->length); } DEF_PRIMITIVE(string_codePointAt) { ObjString* string = AS_STRING(args[0]); uint32_t index = validateIndex(vm, args[1], string->length, "Index"); if (index == UINT32_MAX) return false; // If we are in the middle of a UTF-8 sequence, indicate that. const uint8_t* bytes = (uint8_t*)string->value; if ((bytes[index] & 0xc0) == 0x80) RETURN_NUM(-1); // Decode the UTF-8 sequence. RETURN_NUM(wrenUtf8Decode((uint8_t*)string->value + index, string->length - index)); } DEF_PRIMITIVE(string_contains) { if (!validateString(vm, args[1], "Argument")) return false; ObjString* string = AS_STRING(args[0]); ObjString* search = AS_STRING(args[1]); RETURN_BOOL(wrenStringFind(string, search, 0) != UINT32_MAX); } DEF_PRIMITIVE(string_endsWith) { if (!validateString(vm, args[1], "Argument")) return false; ObjString* string = AS_STRING(args[0]); ObjString* search = AS_STRING(args[1]); // Edge case: If the search string is longer then return false right away. if (search->length > string->length) RETURN_FALSE; RETURN_BOOL(memcmp(string->value + string->length - search->length, search->value, search->length) == 0); } DEF_PRIMITIVE(string_indexOf1) { if (!validateString(vm, args[1], "Argument")) return false; ObjString* string = AS_STRING(args[0]); ObjString* search = AS_STRING(args[1]); uint32_t index = wrenStringFind(string, search, 0); RETURN_NUM(index == UINT32_MAX ? -1 : (int)index); } DEF_PRIMITIVE(string_indexOf2) { if (!validateString(vm, args[1], "Argument")) return false; ObjString* string = AS_STRING(args[0]); ObjString* search = AS_STRING(args[1]); uint32_t start = validateIndex(vm, args[2], string->length, "Start"); if (start == UINT32_MAX) return false; uint32_t index = wrenStringFind(string, search, start); RETURN_NUM(index == UINT32_MAX ? -1 : (int)index); } DEF_PRIMITIVE(string_iterate) { ObjString* string = AS_STRING(args[0]); // If we're starting the iteration, return the first index. if (IS_NULL(args[1])) { if (string->length == 0) RETURN_FALSE; RETURN_NUM(0); } if (!validateInt(vm, args[1], "Iterator")) return false; if (AS_NUM(args[1]) < 0) RETURN_FALSE; uint32_t index = (uint32_t)AS_NUM(args[1]); // Advance to the beginning of the next UTF-8 sequence. do { index++; if (index >= string->length) RETURN_FALSE; } while ((string->value[index] & 0xc0) == 0x80); RETURN_NUM(index); } DEF_PRIMITIVE(string_iterateByte) { ObjString* string = AS_STRING(args[0]); // If we're starting the iteration, return the first index. if (IS_NULL(args[1])) { if (string->length == 0) RETURN_FALSE; RETURN_NUM(0); } if (!validateInt(vm, args[1], "Iterator")) return false; if (AS_NUM(args[1]) < 0) RETURN_FALSE; uint32_t index = (uint32_t)AS_NUM(args[1]); // Advance to the next byte. index++; if (index >= string->length) RETURN_FALSE; RETURN_NUM(index); } DEF_PRIMITIVE(string_iteratorValue) { ObjString* string = AS_STRING(args[0]); uint32_t index = validateIndex(vm, args[1], string->length, "Iterator"); if (index == UINT32_MAX) return false; RETURN_VAL(wrenStringCodePointAt(vm, string, index)); } DEF_PRIMITIVE(string_startsWith) { if (!validateString(vm, args[1], "Argument")) return false; ObjString* string = AS_STRING(args[0]); ObjString* search = AS_STRING(args[1]); // Edge case: If the search string is longer then return false right away. if (search->length > string->length) RETURN_FALSE; RETURN_BOOL(memcmp(string->value, search->value, search->length) == 0); } DEF_PRIMITIVE(string_plus) { if (!validateString(vm, args[1], "Right operand")) return false; RETURN_VAL(wrenStringFormat(vm, "@@", args[0], args[1])); } DEF_PRIMITIVE(string_subscript) { ObjString* string = AS_STRING(args[0]); if (IS_NUM(args[1])) { int index = validateIndex(vm, args[1], string->length, "Subscript"); if (index == -1) return false; RETURN_VAL(wrenStringCodePointAt(vm, string, index)); } if (!IS_RANGE(args[1])) { RETURN_ERROR("Subscript must be a number or a range."); } int step; uint32_t count = string->length; int start = calculateRange(vm, AS_RANGE(args[1]), &count, &step); if (start == -1) return false; RETURN_VAL(wrenNewStringFromRange(vm, string, start, count, step)); } DEF_PRIMITIVE(string_toString) { RETURN_VAL(args[0]); } DEF_PRIMITIVE(system_clock) { RETURN_NUM((double)clock() / CLOCKS_PER_SEC); } DEF_PRIMITIVE(system_gc) { wrenCollectGarbage(vm); RETURN_NULL; } DEF_PRIMITIVE(system_writeString) { if (vm->config.writeFn != NULL) { vm->config.writeFn(vm, AS_CSTRING(args[1])); } RETURN_VAL(args[1]); } // Creates either the Object or Class class in the core module with [name]. static ObjClass* defineClass(WrenVM* vm, ObjModule* module, const char* name) { ObjString* nameString = AS_STRING(wrenNewString(vm, name)); wrenPushRoot(vm, (Obj*)nameString); ObjClass* classObj = wrenNewSingleClass(vm, 0, nameString); wrenDefineVariable(vm, module, name, nameString->length, OBJ_VAL(classObj), NULL); wrenPopRoot(vm); return classObj; } void wrenInitializeCore(WrenVM* vm) { ObjModule* coreModule = wrenNewModule(vm, NULL); wrenPushRoot(vm, (Obj*)coreModule); // The core module's key is null in the module map. wrenMapSet(vm, vm->modules, NULL_VAL, OBJ_VAL(coreModule)); wrenPopRoot(vm); // coreModule. // Define the root Object class. This has to be done a little specially // because it has no superclass. vm->objectClass = defineClass(vm, coreModule, "Object"); PRIMITIVE(vm->objectClass, "!", object_not); PRIMITIVE(vm->objectClass, "==(_)", object_eqeq); PRIMITIVE(vm->objectClass, "!=(_)", object_bangeq); PRIMITIVE(vm->objectClass, "is(_)", object_is); PRIMITIVE(vm->objectClass, "toString", object_toString); PRIMITIVE(vm->objectClass, "type", object_type); // Now we can define Class, which is a subclass of Object. vm->classClass = defineClass(vm, coreModule, "Class"); wrenBindSuperclass(vm, vm->classClass, vm->objectClass); PRIMITIVE(vm->classClass, "name", class_name); PRIMITIVE(vm->classClass, "supertype", class_supertype); PRIMITIVE(vm->classClass, "toString", class_toString); // Finally, we can define Object's metaclass which is a subclass of Class. ObjClass* objectMetaclass = defineClass(vm, coreModule, "Object metaclass"); // Wire up the metaclass relationships now that all three classes are built. vm->objectClass->obj.classObj = objectMetaclass; objectMetaclass->obj.classObj = vm->classClass; vm->classClass->obj.classObj = vm->classClass; // Do this after wiring up the metaclasses so objectMetaclass doesn't get // collected. wrenBindSuperclass(vm, objectMetaclass, vm->classClass); PRIMITIVE(objectMetaclass, "same(_,_)", object_same); // The core class diagram ends up looking like this, where single lines point // to a class's superclass, and double lines point to its metaclass: // // .------------------------------------. .====. // | .---------------. | # # // v | v | v # // .---------. .-------------------. .-------. # // | Object |==>| Object metaclass |==>| Class |==" // '---------' '-------------------' '-------' // ^ ^ ^ ^ ^ // | .--------------' # | # // | | # | # // .---------. .-------------------. # | # -. // | Base |==>| Base metaclass |======" | # | // '---------' '-------------------' | # | // ^ | # | // | .------------------' # | Example classes // | | # | // .---------. .-------------------. # | // | Derived |==>| Derived metaclass |==========" | // '---------' '-------------------' -' // The rest of the classes can now be defined normally. wrenInterpret(vm, NULL, coreModuleSource); vm->boolClass = AS_CLASS(wrenFindVariable(vm, coreModule, "Bool")); PRIMITIVE(vm->boolClass, "toString", bool_toString); PRIMITIVE(vm->boolClass, "!", bool_not); vm->fiberClass = AS_CLASS(wrenFindVariable(vm, coreModule, "Fiber")); PRIMITIVE(vm->fiberClass->obj.classObj, "new(_)", fiber_new); PRIMITIVE(vm->fiberClass->obj.classObj, "abort(_)", fiber_abort); PRIMITIVE(vm->fiberClass->obj.classObj, "current", fiber_current); PRIMITIVE(vm->fiberClass->obj.classObj, "suspend()", fiber_suspend); PRIMITIVE(vm->fiberClass->obj.classObj, "yield()", fiber_yield); PRIMITIVE(vm->fiberClass->obj.classObj, "yield(_)", fiber_yield1); PRIMITIVE(vm->fiberClass, "call()", fiber_call); PRIMITIVE(vm->fiberClass, "call(_)", fiber_call1); PRIMITIVE(vm->fiberClass, "error", fiber_error); PRIMITIVE(vm->fiberClass, "isDone", fiber_isDone); PRIMITIVE(vm->fiberClass, "transfer()", fiber_transfer); PRIMITIVE(vm->fiberClass, "transfer(_)", fiber_transfer1); PRIMITIVE(vm->fiberClass, "transferError(_)", fiber_transferError); PRIMITIVE(vm->fiberClass, "try()", fiber_try); vm->fnClass = AS_CLASS(wrenFindVariable(vm, coreModule, "Fn")); PRIMITIVE(vm->fnClass->obj.classObj, "new(_)", fn_new); PRIMITIVE(vm->fnClass, "arity", fn_arity); FUNCTION_CALL(vm->fnClass, "call()", fn_call0); FUNCTION_CALL(vm->fnClass, "call(_)", fn_call1); FUNCTION_CALL(vm->fnClass, "call(_,_)", fn_call2); FUNCTION_CALL(vm->fnClass, "call(_,_,_)", fn_call3); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_)", fn_call4); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_,_)", fn_call5); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_,_,_)", fn_call6); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_,_,_,_)", fn_call7); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_,_,_,_,_)", fn_call8); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_,_,_,_,_,_)", fn_call9); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_,_,_,_,_,_,_)", fn_call10); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_,_,_,_,_,_,_,_)", fn_call11); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_,_,_,_,_,_,_,_,_)", fn_call12); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_,_,_,_,_,_,_,_,_,_)", fn_call13); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_,_,_,_,_,_,_,_,_,_,_)", fn_call14); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_,_,_,_,_,_,_,_,_,_,_,_)", fn_call15); FUNCTION_CALL(vm->fnClass, "call(_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_)", fn_call16); PRIMITIVE(vm->fnClass, "toString", fn_toString); vm->nullClass = AS_CLASS(wrenFindVariable(vm, coreModule, "Null")); PRIMITIVE(vm->nullClass, "!", null_not); PRIMITIVE(vm->nullClass, "toString", null_toString); vm->numClass = AS_CLASS(wrenFindVariable(vm, coreModule, "Num")); PRIMITIVE(vm->numClass->obj.classObj, "fromString(_)", num_fromString); PRIMITIVE(vm->numClass->obj.classObj, "pi", num_pi); PRIMITIVE(vm->numClass->obj.classObj, "largest", num_largest); PRIMITIVE(vm->numClass->obj.classObj, "smallest", num_smallest); PRIMITIVE(vm->numClass, "-(_)", num_minus); PRIMITIVE(vm->numClass, "+(_)", num_plus); PRIMITIVE(vm->numClass, "*(_)", num_multiply); PRIMITIVE(vm->numClass, "/(_)", num_divide); PRIMITIVE(vm->numClass, "<(_)", num_lt); PRIMITIVE(vm->numClass, ">(_)", num_gt); PRIMITIVE(vm->numClass, "<=(_)", num_lte); PRIMITIVE(vm->numClass, ">=(_)", num_gte); PRIMITIVE(vm->numClass, "&(_)", num_bitwiseAnd); PRIMITIVE(vm->numClass, "|(_)", num_bitwiseOr); PRIMITIVE(vm->numClass, "^(_)", num_bitwiseXor); PRIMITIVE(vm->numClass, "<<(_)", num_bitwiseLeftShift); PRIMITIVE(vm->numClass, ">>(_)", num_bitwiseRightShift); PRIMITIVE(vm->numClass, "abs", num_abs); PRIMITIVE(vm->numClass, "acos", num_acos); PRIMITIVE(vm->numClass, "asin", num_asin); PRIMITIVE(vm->numClass, "atan", num_atan); PRIMITIVE(vm->numClass, "ceil", num_ceil); PRIMITIVE(vm->numClass, "cos", num_cos); PRIMITIVE(vm->numClass, "floor", num_floor); PRIMITIVE(vm->numClass, "-", num_negate); PRIMITIVE(vm->numClass, "round", num_round); PRIMITIVE(vm->numClass, "sin", num_sin); PRIMITIVE(vm->numClass, "sqrt", num_sqrt); PRIMITIVE(vm->numClass, "tan", num_tan); PRIMITIVE(vm->numClass, "log", num_log); PRIMITIVE(vm->numClass, "log2", num_log2); PRIMITIVE(vm->numClass, "exp", num_exp); PRIMITIVE(vm->numClass, "%(_)", num_mod); PRIMITIVE(vm->numClass, "~", num_bitwiseNot); PRIMITIVE(vm->numClass, "..(_)", num_dotDot); PRIMITIVE(vm->numClass, "...(_)", num_dotDotDot); PRIMITIVE(vm->numClass, "atan(_)", num_atan2); PRIMITIVE(vm->numClass, "pow(_)", num_pow); PRIMITIVE(vm->numClass, "fraction", num_fraction); PRIMITIVE(vm->numClass, "isInfinity", num_isInfinity); PRIMITIVE(vm->numClass, "isInteger", num_isInteger); PRIMITIVE(vm->numClass, "isNan", num_isNan); PRIMITIVE(vm->numClass, "sign", num_sign); PRIMITIVE(vm->numClass, "toString", num_toString); PRIMITIVE(vm->numClass, "truncate", num_truncate); // These are defined just so that 0 and -0 are equal, which is specified by // IEEE 754 even though they have different bit representations. PRIMITIVE(vm->numClass, "==(_)", num_eqeq); PRIMITIVE(vm->numClass, "!=(_)", num_bangeq); vm->stringClass = AS_CLASS(wrenFindVariable(vm, coreModule, "String")); PRIMITIVE(vm->stringClass->obj.classObj, "fromCodePoint(_)", string_fromCodePoint); PRIMITIVE(vm->stringClass->obj.classObj, "fromByte(_)", string_fromByte); PRIMITIVE(vm->stringClass, "+(_)", string_plus); PRIMITIVE(vm->stringClass, "[_]", string_subscript); PRIMITIVE(vm->stringClass, "byteAt_(_)", string_byteAt); PRIMITIVE(vm->stringClass, "byteCount_", string_byteCount); PRIMITIVE(vm->stringClass, "codePointAt_(_)", string_codePointAt); PRIMITIVE(vm->stringClass, "contains(_)", string_contains); PRIMITIVE(vm->stringClass, "endsWith(_)", string_endsWith); PRIMITIVE(vm->stringClass, "indexOf(_)", string_indexOf1); PRIMITIVE(vm->stringClass, "indexOf(_,_)", string_indexOf2); PRIMITIVE(vm->stringClass, "iterate(_)", string_iterate); PRIMITIVE(vm->stringClass, "iterateByte_(_)", string_iterateByte); PRIMITIVE(vm->stringClass, "iteratorValue(_)", string_iteratorValue); PRIMITIVE(vm->stringClass, "startsWith(_)", string_startsWith); PRIMITIVE(vm->stringClass, "toString", string_toString); vm->listClass = AS_CLASS(wrenFindVariable(vm, coreModule, "List")); PRIMITIVE(vm->listClass->obj.classObj, "filled(_,_)", list_filled); PRIMITIVE(vm->listClass->obj.classObj, "new()", list_new); PRIMITIVE(vm->listClass, "[_]", list_subscript); PRIMITIVE(vm->listClass, "[_]=(_)", list_subscriptSetter); PRIMITIVE(vm->listClass, "add(_)", list_add); PRIMITIVE(vm->listClass, "addCore_(_)", list_addCore); PRIMITIVE(vm->listClass, "clear()", list_clear); PRIMITIVE(vm->listClass, "count", list_count); PRIMITIVE(vm->listClass, "insert(_,_)", list_insert); PRIMITIVE(vm->listClass, "iterate(_)", list_iterate); PRIMITIVE(vm->listClass, "iteratorValue(_)", list_iteratorValue); PRIMITIVE(vm->listClass, "removeAt(_)", list_removeAt); vm->mapClass = AS_CLASS(wrenFindVariable(vm, coreModule, "Map")); PRIMITIVE(vm->mapClass->obj.classObj, "new()", map_new); PRIMITIVE(vm->mapClass, "[_]", map_subscript); PRIMITIVE(vm->mapClass, "[_]=(_)", map_subscriptSetter); PRIMITIVE(vm->mapClass, "addCore_(_,_)", map_addCore); PRIMITIVE(vm->mapClass, "clear()", map_clear); PRIMITIVE(vm->mapClass, "containsKey(_)", map_containsKey); PRIMITIVE(vm->mapClass, "count", map_count); PRIMITIVE(vm->mapClass, "remove(_)", map_remove); PRIMITIVE(vm->mapClass, "iterate(_)", map_iterate); PRIMITIVE(vm->mapClass, "keyIteratorValue_(_)", map_keyIteratorValue); PRIMITIVE(vm->mapClass, "valueIteratorValue_(_)", map_valueIteratorValue); vm->rangeClass = AS_CLASS(wrenFindVariable(vm, coreModule, "Range")); PRIMITIVE(vm->rangeClass, "from", range_from); PRIMITIVE(vm->rangeClass, "to", range_to); PRIMITIVE(vm->rangeClass, "min", range_min); PRIMITIVE(vm->rangeClass, "max", range_max); PRIMITIVE(vm->rangeClass, "isInclusive", range_isInclusive); PRIMITIVE(vm->rangeClass, "iterate(_)", range_iterate); PRIMITIVE(vm->rangeClass, "iteratorValue(_)", range_iteratorValue); PRIMITIVE(vm->rangeClass, "toString", range_toString); ObjClass* systemClass = AS_CLASS(wrenFindVariable(vm, coreModule, "System")); PRIMITIVE(systemClass->obj.classObj, "clock", system_clock); PRIMITIVE(systemClass->obj.classObj, "gc()", system_gc); PRIMITIVE(systemClass->obj.classObj, "writeString_(_)", system_writeString); // While bootstrapping the core types and running the core module, a number // of string objects have been created, many of which were instantiated // before stringClass was stored in the VM. Some of them *must* be created // first -- the ObjClass for string itself has a reference to the ObjString // for its name. // // These all currently have a NULL classObj pointer, so go back and assign // them now that the string class is known. for (Obj* obj = vm->first; obj != NULL; obj = obj->next) { if (obj->type == OBJ_STRING) obj->classObj = vm->stringClass; } } // End file "wren_core.c" // Begin file "wren_compiler.c" #include <errno.h> #include <stdbool.h> #include <stdio.h> #include <string.h> #if WREN_DEBUG_DUMP_COMPILED_CODE #endif // This is written in bottom-up order, so the tokenization comes first, then // parsing/code generation. This minimizes the number of explicit forward // declarations needed. // The maximum number of local (i.e. not module level) variables that can be // declared in a single function, method, or chunk of top level code. This is // the maximum number of variables in scope at one time, and spans block scopes. // // Note that this limitation is also explicit in the bytecode. Since // `CODE_LOAD_LOCAL` and `CODE_STORE_LOCAL` use a single argument byte to // identify the local, only 256 can be in scope at one time. #define MAX_LOCALS 256 // The maximum number of upvalues (i.e. variables from enclosing functions) // that a function can close over. #define MAX_UPVALUES 256 // The maximum number of distinct constants that a function can contain. This // value is explicit in the bytecode since `CODE_CONSTANT` only takes a single // two-byte argument. #define MAX_CONSTANTS (1 << 16) // The maximum distance a CODE_JUMP or CODE_JUMP_IF instruction can move the // instruction pointer. #define MAX_JUMP (1 << 16) // The maximum depth that interpolation can nest. For example, this string has // three levels: // // "outside %(one + "%(two + "%(three)")")" #define MAX_INTERPOLATION_NESTING 8 // The buffer size used to format a compile error message, excluding the header // with the module name and error location. Using a hardcoded buffer for this // is kind of hairy, but fortunately we can control what the longest possible // message is and handle that. Ideally, we'd use `snprintf()`, but that's not // available in standard C++98. #define ERROR_MESSAGE_SIZE (80 + MAX_VARIABLE_NAME + 15) typedef enum { TOKEN_LEFT_PAREN, TOKEN_RIGHT_PAREN, TOKEN_LEFT_BRACKET, TOKEN_RIGHT_BRACKET, TOKEN_LEFT_BRACE, TOKEN_RIGHT_BRACE, TOKEN_COLON, TOKEN_DOT, TOKEN_DOTDOT, TOKEN_DOTDOTDOT, TOKEN_COMMA, TOKEN_STAR, TOKEN_SLASH, TOKEN_PERCENT, TOKEN_PLUS, TOKEN_MINUS, TOKEN_LTLT, TOKEN_GTGT, TOKEN_PIPE, TOKEN_PIPEPIPE, TOKEN_CARET, TOKEN_AMP, TOKEN_AMPAMP, TOKEN_BANG, TOKEN_TILDE, TOKEN_QUESTION, TOKEN_EQ, TOKEN_LT, TOKEN_GT, TOKEN_LTEQ, TOKEN_GTEQ, TOKEN_EQEQ, TOKEN_BANGEQ, TOKEN_BREAK, TOKEN_CLASS, TOKEN_CONSTRUCT, TOKEN_ELSE, TOKEN_FALSE, TOKEN_FOR, TOKEN_FOREIGN, TOKEN_IF, TOKEN_IMPORT, TOKEN_IN, TOKEN_IS, TOKEN_NULL, TOKEN_RETURN, TOKEN_STATIC, TOKEN_SUPER, TOKEN_THIS, TOKEN_TRUE, TOKEN_VAR, TOKEN_WHILE, TOKEN_FIELD, TOKEN_STATIC_FIELD, TOKEN_NAME, TOKEN_NUMBER, // A string literal without any interpolation, or the last section of a // string following the last interpolated expression. TOKEN_STRING, // A portion of a string literal preceding an interpolated expression. This // string: // // "a %(b) c %(d) e" // // is tokenized to: // // TOKEN_INTERPOLATION "a " // TOKEN_NAME b // TOKEN_INTERPOLATION " c " // TOKEN_NAME d // TOKEN_STRING " e" TOKEN_INTERPOLATION, TOKEN_LINE, TOKEN_ERROR, TOKEN_EOF } TokenType; typedef struct { TokenType type; // The beginning of the token, pointing directly into the source. const char* start; // The length of the token in characters. int length; // The 1-based line where the token appears. int line; // The parsed value if the token is a literal. Value value; } Token; typedef struct { WrenVM* vm; // The module being parsed. ObjModule* module; // The source code being parsed. const char* source; // The beginning of the currently-being-lexed token in [source]. const char* tokenStart; // The current character being lexed in [source]. const char* currentChar; // The 1-based line number of [currentChar]. int currentLine; // The most recently lexed token. Token current; // The most recently consumed/advanced token. Token previous; // Tracks the lexing state when tokenizing interpolated strings. // // Interpolated strings make the lexer not strictly regular: we don't know // whether a ")" should be treated as a RIGHT_PAREN token or as ending an // interpolated expression unless we know whether we are inside a string // interpolation and how many unmatched "(" there are. This is particularly // complex because interpolation can nest: // // " %( " %( inner ) " ) " // // This tracks that state. The parser maintains a stack of ints, one for each // level of current interpolation nesting. Each value is the number of // unmatched "(" that are waiting to be closed. int parens[MAX_INTERPOLATION_NESTING]; int numParens; // If subsequent newline tokens should be discarded. bool skipNewlines; // Whether compile errors should be printed to stderr or discarded. bool printErrors; // If a syntax or compile error has occurred. bool hasError; } Parser; typedef struct { // The name of the local variable. This points directly into the original // source code string. const char* name; // The length of the local variable's name. int length; // The depth in the scope chain that this variable was declared at. Zero is // the outermost scope--parameters for a method, or the first local block in // top level code. One is the scope within that, etc. int depth; // If this local variable is being used as an upvalue. bool isUpvalue; } Local; typedef struct { // True if this upvalue is capturing a local variable from the enclosing // function. False if it's capturing an upvalue. bool isLocal; // The index of the local or upvalue being captured in the enclosing function. int index; } CompilerUpvalue; // Bookkeeping information for the current loop being compiled. typedef struct sLoop { // Index of the instruction that the loop should jump back to. int start; // Index of the argument for the CODE_JUMP_IF instruction used to exit the // loop. Stored so we can patch it once we know where the loop ends. int exitJump; // Index of the first instruction of the body of the loop. int body; // Depth of the scope(s) that need to be exited if a break is hit inside the // loop. int scopeDepth; // The loop enclosing this one, or NULL if this is the outermost loop. struct sLoop* enclosing; } Loop; // The different signature syntaxes for different kinds of methods. typedef enum { // A name followed by a (possibly empty) parenthesized parameter list. Also // used for binary operators. SIG_METHOD, // Just a name. Also used for unary operators. SIG_GETTER, // A name followed by "=". SIG_SETTER, // A square bracketed parameter list. SIG_SUBSCRIPT, // A square bracketed parameter list followed by "=". SIG_SUBSCRIPT_SETTER, // A constructor initializer function. This has a distinct signature to // prevent it from being invoked directly outside of the constructor on the // metaclass. SIG_INITIALIZER } SignatureType; typedef struct { const char* name; int length; SignatureType type; int arity; } Signature; // Bookkeeping information for compiling a class definition. typedef struct { // The name of the class. ObjString* name; // Symbol table for the fields of the class. SymbolTable fields; // Symbols for the methods defined by the class. Used to detect duplicate // method definitions. IntBuffer methods; IntBuffer staticMethods; // True if the class being compiled is a foreign class. bool isForeign; // True if the current method being compiled is static. bool inStatic; // The signature of the method being compiled. Signature* signature; } ClassInfo; struct sCompiler { Parser* parser; // The compiler for the function enclosing this one, or NULL if it's the // top level. struct sCompiler* parent; // The currently in scope local variables. Local locals[MAX_LOCALS]; // The number of local variables currently in scope. int numLocals; // The upvalues that this function has captured from outer scopes. The count // of them is stored in [numUpvalues]. CompilerUpvalue upvalues[MAX_UPVALUES]; // The current level of block scope nesting, where zero is no nesting. A -1 // here means top-level code is being compiled and there is no block scope // in effect at all. Any variables declared will be module-level. int scopeDepth; // The current number of slots (locals and temporaries) in use. // // We use this and maxSlots to track the maximum number of additional slots // a function may need while executing. When the function is called, the // fiber will check to ensure its stack has enough room to cover that worst // case and grow the stack if needed. // // This value here doesn't include parameters to the function. Since those // are already pushed onto the stack by the caller and tracked there, we // don't need to double count them here. int numSlots; // The current innermost loop being compiled, or NULL if not in a loop. Loop* loop; // If this is a compiler for a method, keeps track of the class enclosing it. ClassInfo* enclosingClass; // The function being compiled. ObjFn* fn; ObjMap* constants; }; // Describes where a variable is declared. typedef enum { // A local variable in the current function. SCOPE_LOCAL, // A local variable declared in an enclosing function. SCOPE_UPVALUE, // A top-level module variable. SCOPE_MODULE } Scope; // A reference to a variable and the scope where it is defined. This contains // enough information to emit correct code to load or store the variable. typedef struct { // The stack slot, upvalue slot, or module symbol defining the variable. int index; // Where the variable is declared. Scope scope; } Variable; // The stack effect of each opcode. The index in the array is the opcode, and // the value is the stack effect of that instruction. static const int stackEffects[] = { #define OPCODE(_, effect) effect, // Begin file "wren_opcodes.h" // This defines the bytecode instructions used by the VM. It does so by invoking // an OPCODE() macro which is expected to be defined at the point that this is // included. (See: http://en.wikipedia.org/wiki/X_Macro for more.) // // The first argument is the name of the opcode. The second is its "stack // effect" -- the amount that the op code changes the size of the stack. A // stack effect of 1 means it pushes a value and the stack grows one larger. // -2 means it pops two values, etc. // // Note that the order of instructions here affects the order of the dispatch // table in the VM's interpreter loop. That in turn affects caching which // affects overall performance. Take care to run benchmarks if you change the // order here. // Load the constant at index [arg]. OPCODE(CONSTANT, 1) // Push null onto the stack. OPCODE(NULL, 1) // Push false onto the stack. OPCODE(FALSE, 1) // Push true onto the stack. OPCODE(TRUE, 1) // Pushes the value in the given local slot. OPCODE(LOAD_LOCAL_0, 1) OPCODE(LOAD_LOCAL_1, 1) OPCODE(LOAD_LOCAL_2, 1) OPCODE(LOAD_LOCAL_3, 1) OPCODE(LOAD_LOCAL_4, 1) OPCODE(LOAD_LOCAL_5, 1) OPCODE(LOAD_LOCAL_6, 1) OPCODE(LOAD_LOCAL_7, 1) OPCODE(LOAD_LOCAL_8, 1) // Note: The compiler assumes the following _STORE instructions always // immediately follow their corresponding _LOAD ones. // Pushes the value in local slot [arg]. OPCODE(LOAD_LOCAL, 1) // Stores the top of stack in local slot [arg]. Does not pop it. OPCODE(STORE_LOCAL, 0) // Pushes the value in upvalue [arg]. OPCODE(LOAD_UPVALUE, 1) // Stores the top of stack in upvalue [arg]. Does not pop it. OPCODE(STORE_UPVALUE, 0) // Pushes the value of the top-level variable in slot [arg]. OPCODE(LOAD_MODULE_VAR, 1) // Stores the top of stack in top-level variable slot [arg]. Does not pop it. OPCODE(STORE_MODULE_VAR, 0) // Pushes the value of the field in slot [arg] of the receiver of the current // function. This is used for regular field accesses on "this" directly in // methods. This instruction is faster than the more general CODE_LOAD_FIELD // instruction. OPCODE(LOAD_FIELD_THIS, 1) // Stores the top of the stack in field slot [arg] in the receiver of the // current value. Does not pop the value. This instruction is faster than the // more general CODE_LOAD_FIELD instruction. OPCODE(STORE_FIELD_THIS, 0) // Pops an instance and pushes the value of the field in slot [arg] of it. OPCODE(LOAD_FIELD, 0) // Pops an instance and stores the subsequent top of stack in field slot // [arg] in it. Does not pop the value. OPCODE(STORE_FIELD, -1) // Pop and discard the top of stack. OPCODE(POP, -1) // Invoke the method with symbol [arg]. The number indicates the number of // arguments (not including the receiver). OPCODE(CALL_0, 0) OPCODE(CALL_1, -1) OPCODE(CALL_2, -2) OPCODE(CALL_3, -3) OPCODE(CALL_4, -4) OPCODE(CALL_5, -5) OPCODE(CALL_6, -6) OPCODE(CALL_7, -7) OPCODE(CALL_8, -8) OPCODE(CALL_9, -9) OPCODE(CALL_10, -10) OPCODE(CALL_11, -11) OPCODE(CALL_12, -12) OPCODE(CALL_13, -13) OPCODE(CALL_14, -14) OPCODE(CALL_15, -15) OPCODE(CALL_16, -16) // Invoke a superclass method with symbol [arg]. The number indicates the // number of arguments (not including the receiver). OPCODE(SUPER_0, 0) OPCODE(SUPER_1, -1) OPCODE(SUPER_2, -2) OPCODE(SUPER_3, -3) OPCODE(SUPER_4, -4) OPCODE(SUPER_5, -5) OPCODE(SUPER_6, -6) OPCODE(SUPER_7, -7) OPCODE(SUPER_8, -8) OPCODE(SUPER_9, -9) OPCODE(SUPER_10, -10) OPCODE(SUPER_11, -11) OPCODE(SUPER_12, -12) OPCODE(SUPER_13, -13) OPCODE(SUPER_14, -14) OPCODE(SUPER_15, -15) OPCODE(SUPER_16, -16) // Jump the instruction pointer [arg] forward. OPCODE(JUMP, 0) // Jump the instruction pointer [arg] backward. OPCODE(LOOP, 0) // Pop and if not truthy then jump the instruction pointer [arg] forward. OPCODE(JUMP_IF, -1) // If the top of the stack is false, jump [arg] forward. Otherwise, pop and // continue. OPCODE(AND, -1) // If the top of the stack is non-false, jump [arg] forward. Otherwise, pop // and continue. OPCODE(OR, -1) // Close the upvalue for the local on the top of the stack, then pop it. OPCODE(CLOSE_UPVALUE, -1) // Exit from the current function and return the value on the top of the // stack. OPCODE(RETURN, 0) // Creates a closure for the function stored at [arg] in the constant table. // // Following the function argument is a number of arguments, two for each // upvalue. The first is true if the variable being captured is a local (as // opposed to an upvalue), and the second is the index of the local or // upvalue being captured. // // Pushes the created closure. OPCODE(CLOSURE, 1) // Creates a new instance of a class. // // Assumes the class object is in slot zero, and replaces it with the new // uninitialized instance of that class. This opcode is only emitted by the // compiler-generated constructor metaclass methods. OPCODE(CONSTRUCT, 0) // Creates a new instance of a foreign class. // // Assumes the class object is in slot zero, and replaces it with the new // uninitialized instance of that class. This opcode is only emitted by the // compiler-generated constructor metaclass methods. OPCODE(FOREIGN_CONSTRUCT, 0) // Creates a class. Top of stack is the superclass. Below that is a string for // the name of the class. Byte [arg] is the number of fields in the class. OPCODE(CLASS, -1) // Creates a foreign class. Top of stack is the superclass. Below that is a // string for the name of the class. OPCODE(FOREIGN_CLASS, -1) // Define a method for symbol [arg]. The class receiving the method is popped // off the stack, then the function defining the body is popped. // // If a foreign method is being defined, the "function" will be a string // identifying the foreign method. Otherwise, it will be a function or // closure. OPCODE(METHOD_INSTANCE, -2) // Define a method for symbol [arg]. The class whose metaclass will receive // the method is popped off the stack, then the function defining the body is // popped. // // If a foreign method is being defined, the "function" will be a string // identifying the foreign method. Otherwise, it will be a function or // closure. OPCODE(METHOD_STATIC, -2) // This is executed at the end of the module's body. Pushes NULL onto the stack // as the "return value" of the import statement and stores the module as the // most recently imported one. OPCODE(END_MODULE, 1) // Import a module whose name is the string stored at [arg] in the constant // table. // // Pushes null onto the stack so that the fiber for the imported module can // replace that with a dummy value when it returns. (Fibers always return a // value when resuming a caller.) OPCODE(IMPORT_MODULE, 1) // Import a variable from the most recently imported module. The name of the // variable to import is at [arg] in the constant table. Pushes the loaded // variable's value. OPCODE(IMPORT_VARIABLE, 1) // This pseudo-instruction indicates the end of the bytecode. It should // always be preceded by a `CODE_RETURN`, so is never actually executed. OPCODE(END, 0) // End file "wren_opcodes.h" #undef OPCODE }; static void printError(Parser* parser, int line, const char* label, const char* format, va_list args) { parser->hasError = true; if (!parser->printErrors) return; // Only report errors if there is a WrenErrorFn to handle them. if (parser->vm->config.errorFn == NULL) return; // Format the label and message. char message[ERROR_MESSAGE_SIZE]; int length = sprintf(message, "%s: ", label); length += vsprintf(message + length, format, args); ASSERT(length < ERROR_MESSAGE_SIZE, "Error should not exceed buffer."); ObjString* module = parser->module->name; const char* module_name = module ? module->value : "<unknown>"; parser->vm->config.errorFn(parser->vm, WREN_ERROR_COMPILE, module_name, line, message); } // Outputs a lexical error. static void lexError(Parser* parser, const char* format, ...) { va_list args; va_start(args, format); printError(parser, parser->currentLine, "Error", format, args); va_end(args); } // Outputs a compile or syntax error. This also marks the compilation as having // an error, which ensures that the resulting code will be discarded and never // run. This means that after calling error(), it's fine to generate whatever // invalid bytecode you want since it won't be used. // // You'll note that most places that call error() continue to parse and compile // after that. That's so that we can try to find as many compilation errors in // one pass as possible instead of just bailing at the first one. static void error(Compiler* compiler, const char* format, ...) { Token* token = &compiler->parser->previous; // If the parse error was caused by an error token, the lexer has already // reported it. if (token->type == TOKEN_ERROR) return; va_list args; va_start(args, format); if (token->type == TOKEN_LINE) { printError(compiler->parser, token->line, "Error at newline", format, args); } else if (token->type == TOKEN_EOF) { printError(compiler->parser, token->line, "Error at end of file", format, args); } else { // Make sure we don't exceed the buffer with a very long token. char label[10 + MAX_VARIABLE_NAME + 4 + 1]; if (token->length <= MAX_VARIABLE_NAME) { sprintf(label, "Error at '%.*s'", token->length, token->start); } else { sprintf(label, "Error at '%.*s...'", MAX_VARIABLE_NAME, token->start); } printError(compiler->parser, token->line, label, format, args); } va_end(args); } // Adds [constant] to the constant pool and returns its index. static int addConstant(Compiler* compiler, Value constant) { if (compiler->parser->hasError) return -1; // See if we already have a constant for the value. If so, reuse it. if (compiler->constants != NULL) { Value existing = wrenMapGet(compiler->constants, constant); if (IS_NUM(existing)) return (int)AS_NUM(existing); } // It's a new constant. if (compiler->fn->constants.count < MAX_CONSTANTS) { if (IS_OBJ(constant)) wrenPushRoot(compiler->parser->vm, AS_OBJ(constant)); wrenValueBufferWrite(compiler->parser->vm, &compiler->fn->constants, constant); if (IS_OBJ(constant)) wrenPopRoot(compiler->parser->vm); if (compiler->constants == NULL) { compiler->constants = wrenNewMap(compiler->parser->vm); } wrenMapSet(compiler->parser->vm, compiler->constants, constant, NUM_VAL(compiler->fn->constants.count - 1)); } else { error(compiler, "A function may only contain %d unique constants.", MAX_CONSTANTS); } return compiler->fn->constants.count - 1; } // Initializes [compiler]. static void initCompiler(Compiler* compiler, Parser* parser, Compiler* parent, bool isMethod) { compiler->parser = parser; compiler->parent = parent; compiler->loop = NULL; compiler->enclosingClass = NULL; // Initialize these to NULL before allocating in case a GC gets triggered in // the middle of initializing the compiler. compiler->fn = NULL; compiler->constants = NULL; parser->vm->compiler = compiler; // Declare a local slot for either the closure or method receiver so that we // don't try to reuse that slot for a user-defined local variable. For // methods, we name it "this", so that we can resolve references to that like // a normal variable. For functions, they have no explicit "this", so we use // an empty name. That way references to "this" inside a function walks up // the parent chain to find a method enclosing the function whose "this" we // can close over. compiler->numLocals = 1; compiler->numSlots = compiler->numLocals; if (isMethod) { compiler->locals[0].name = "this"; compiler->locals[0].length = 4; } else { compiler->locals[0].name = NULL; compiler->locals[0].length = 0; } compiler->locals[0].depth = -1; compiler->locals[0].isUpvalue = false; if (parent == NULL) { // Compiling top-level code, so the initial scope is module-level. compiler->scopeDepth = -1; } else { // The initial scope for functions and methods is local scope. compiler->scopeDepth = 0; } compiler->fn = wrenNewFunction(parser->vm, parser->module, compiler->numLocals); } // Lexing ---------------------------------------------------------------------- typedef struct { const char* identifier; size_t length; TokenType tokenType; } Keyword; // The table of reserved words and their associated token types. static Keyword keywords[] = { {"break", 5, TOKEN_BREAK}, {"class", 5, TOKEN_CLASS}, {"construct", 9, TOKEN_CONSTRUCT}, {"else", 4, TOKEN_ELSE}, {"false", 5, TOKEN_FALSE}, {"for", 3, TOKEN_FOR}, {"foreign", 7, TOKEN_FOREIGN}, {"if", 2, TOKEN_IF}, {"import", 6, TOKEN_IMPORT}, {"in", 2, TOKEN_IN}, {"is", 2, TOKEN_IS}, {"null", 4, TOKEN_NULL}, {"return", 6, TOKEN_RETURN}, {"static", 6, TOKEN_STATIC}, {"super", 5, TOKEN_SUPER}, {"this", 4, TOKEN_THIS}, {"true", 4, TOKEN_TRUE}, {"var", 3, TOKEN_VAR}, {"while", 5, TOKEN_WHILE}, {NULL, 0, TOKEN_EOF} // Sentinel to mark the end of the array. }; // Returns true if [c] is a valid (non-initial) identifier character. static bool isName(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'; } // Returns true if [c] is a digit. static bool isDigit(char c) { return c >= '0' && c <= '9'; } // Returns the current character the parser is sitting on. static char peekChar(Parser* parser) { return *parser->currentChar; } // Returns the character after the current character. static char peekNextChar(Parser* parser) { // If we're at the end of the source, don't read past it. if (peekChar(parser) == '\0') return '\0'; return *(parser->currentChar + 1); } // Advances the parser forward one character. static char nextChar(Parser* parser) { char c = peekChar(parser); parser->currentChar++; if (c == '\n') parser->currentLine++; return c; } // If the current character is [c], consumes it and returns `true`. static bool matchChar(Parser* parser, char c) { if (peekChar(parser) != c) return false; nextChar(parser); return true; } // Sets the parser's current token to the given [type] and current character // range. static void makeToken(Parser* parser, TokenType type) { parser->current.type = type; parser->current.start = parser->tokenStart; parser->current.length = (int)(parser->currentChar - parser->tokenStart); parser->current.line = parser->currentLine; // Make line tokens appear on the line containing the "\n". if (type == TOKEN_LINE) parser->current.line--; } // If the current character is [c], then consumes it and makes a token of type // [two]. Otherwise makes a token of type [one]. static void twoCharToken(Parser* parser, char c, TokenType two, TokenType one) { makeToken(parser, matchChar(parser, c) ? two : one); } // Skips the rest of the current line. static void skipLineComment(Parser* parser) { while (peekChar(parser) != '\n' && peekChar(parser) != '\0') { nextChar(parser); } } // Skips the rest of a block comment. static void skipBlockComment(Parser* parser) { int nesting = 1; while (nesting > 0) { if (peekChar(parser) == '\0') { lexError(parser, "Unterminated block comment."); return; } if (peekChar(parser) == '/' && peekNextChar(parser) == '*') { nextChar(parser); nextChar(parser); nesting++; continue; } if (peekChar(parser) == '*' && peekNextChar(parser) == '/') { nextChar(parser); nextChar(parser); nesting--; continue; } // Regular comment character. nextChar(parser); } } // Reads the next character, which should be a hex digit (0-9, a-f, or A-F) and // returns its numeric value. If the character isn't a hex digit, returns -1. static int readHexDigit(Parser* parser) { char c = nextChar(parser); if (c >= '0' && c <= '9') return c - '0'; if (c >= 'a' && c <= 'f') return c - 'a' + 10; if (c >= 'A' && c <= 'F') return c - 'A' + 10; // Don't consume it if it isn't expected. Keeps us from reading past the end // of an unterminated string. parser->currentChar--; return -1; } // Parses the numeric value of the current token. static void makeNumber(Parser* parser, bool isHex) { errno = 0; if (isHex) { parser->current.value = NUM_VAL((double)strtoll(parser->tokenStart, NULL, 16)); } else { parser->current.value = NUM_VAL(strtod(parser->tokenStart, NULL)); } if (errno == ERANGE) { lexError(parser, "Number literal was too large (%d).", sizeof(long int)); parser->current.value = NUM_VAL(0); } // We don't check that the entire token is consumed after calling strtoll() // or strtod() because we've already scanned it ourselves and know it's valid. makeToken(parser, TOKEN_NUMBER); } // Finishes lexing a hexadecimal number literal. static void readHexNumber(Parser* parser) { // Skip past the `x` used to denote a hexadecimal literal. nextChar(parser); // Iterate over all the valid hexadecimal digits found. while (readHexDigit(parser) != -1) continue; makeNumber(parser, true); } // Finishes lexing a number literal. static void readNumber(Parser* parser) { while (isDigit(peekChar(parser))) nextChar(parser); // See if it has a floating point. Make sure there is a digit after the "." // so we don't get confused by method calls on number literals. if (peekChar(parser) == '.' && isDigit(peekNextChar(parser))) { nextChar(parser); while (isDigit(peekChar(parser))) nextChar(parser); } // See if the number is in scientific notation. if (matchChar(parser, 'e') || matchChar(parser, 'E')) { // Allow a single positive/negative exponent symbol. if(!matchChar(parser, '+')) { matchChar(parser, '-'); } if (!isDigit(peekChar(parser))) { lexError(parser, "Unterminated scientific notation."); } while (isDigit(peekChar(parser))) nextChar(parser); } makeNumber(parser, false); } // Finishes lexing an identifier. Handles reserved words. static void readName(Parser* parser, TokenType type) { while (isName(peekChar(parser)) || isDigit(peekChar(parser))) { nextChar(parser); } // Update the type if it's a keyword. size_t length = parser->currentChar - parser->tokenStart; for (int i = 0; keywords[i].identifier != NULL; i++) { if (length == keywords[i].length && memcmp(parser->tokenStart, keywords[i].identifier, length) == 0) { type = keywords[i].tokenType; break; } } makeToken(parser, type); } // Reads [digits] hex digits in a string literal and returns their number value. static int readHexEscape(Parser* parser, int digits, const char* description) { int value = 0; for (int i = 0; i < digits; i++) { if (peekChar(parser) == '"' || peekChar(parser) == '\0') { lexError(parser, "Incomplete %s escape sequence.", description); // Don't consume it if it isn't expected. Keeps us from reading past the // end of an unterminated string. parser->currentChar--; break; } int digit = readHexDigit(parser); if (digit == -1) { lexError(parser, "Invalid %s escape sequence.", description); break; } value = (value * 16) | digit; } return value; } // Reads a hex digit Unicode escape sequence in a string literal. static void readUnicodeEscape(Parser* parser, ByteBuffer* string, int length) { int value = readHexEscape(parser, length, "Unicode"); // Grow the buffer enough for the encoded result. int numBytes = wrenUtf8EncodeNumBytes(value); if (numBytes != 0) { wrenByteBufferFill(parser->vm, string, 0, numBytes); wrenUtf8Encode(value, string->data + string->count - numBytes); } } // Finishes lexing a string literal. static void readString(Parser* parser) { ByteBuffer string; TokenType type = TOKEN_STRING; wrenByteBufferInit(&string); for (;;) { char c = nextChar(parser); if (c == '"') break; if (c == '\0') { lexError(parser, "Unterminated string."); // Don't consume it if it isn't expected. Keeps us from reading past the // end of an unterminated string. parser->currentChar--; break; } if (c == '%') { if (parser->numParens < MAX_INTERPOLATION_NESTING) { // TODO: Allow format string. if (nextChar(parser) != '(') lexError(parser, "Expect '(' after '%%'."); parser->parens[parser->numParens++] = 1; type = TOKEN_INTERPOLATION; break; } lexError(parser, "Interpolation may only nest %d levels deep.", MAX_INTERPOLATION_NESTING); } if (c == '\\') { switch (nextChar(parser)) { case '"': wrenByteBufferWrite(parser->vm, &string, '"'); break; case '\\': wrenByteBufferWrite(parser->vm, &string, '\\'); break; case '%': wrenByteBufferWrite(parser->vm, &string, '%'); break; case '0': wrenByteBufferWrite(parser->vm, &string, '\0'); break; case 'a': wrenByteBufferWrite(parser->vm, &string, '\a'); break; case 'b': wrenByteBufferWrite(parser->vm, &string, '\b'); break; case 'f': wrenByteBufferWrite(parser->vm, &string, '\f'); break; case 'n': wrenByteBufferWrite(parser->vm, &string, '\n'); break; case 'r': wrenByteBufferWrite(parser->vm, &string, '\r'); break; case 't': wrenByteBufferWrite(parser->vm, &string, '\t'); break; case 'u': readUnicodeEscape(parser, &string, 4); break; case 'U': readUnicodeEscape(parser, &string, 8); break; case 'v': wrenByteBufferWrite(parser->vm, &string, '\v'); break; case 'x': wrenByteBufferWrite(parser->vm, &string, (uint8_t)readHexEscape(parser, 2, "byte")); break; default: lexError(parser, "Invalid escape character '%c'.", *(parser->currentChar - 1)); break; } } else { wrenByteBufferWrite(parser->vm, &string, c); } } parser->current.value = wrenNewStringLength(parser->vm, (char*)string.data, string.count); wrenByteBufferClear(parser->vm, &string); makeToken(parser, type); } // Lex the next token and store it in [parser.current]. static void nextToken(Parser* parser) { parser->previous = parser->current; // If we are out of tokens, don't try to tokenize any more. We *do* still // copy the TOKEN_EOF to previous so that code that expects it to be consumed // will still work. if (parser->current.type == TOKEN_EOF) return; while (peekChar(parser) != '\0') { parser->tokenStart = parser->currentChar; char c = nextChar(parser); switch (c) { case '(': // If we are inside an interpolated expression, count the unmatched "(". if (parser->numParens > 0) parser->parens[parser->numParens - 1]++; makeToken(parser, TOKEN_LEFT_PAREN); return; case ')': // If we are inside an interpolated expression, count the ")". if (parser->numParens > 0 && --parser->parens[parser->numParens - 1] == 0) { // This is the final ")", so the interpolation expression has ended. // This ")" now begins the next section of the template string. parser->numParens--; readString(parser); return; } makeToken(parser, TOKEN_RIGHT_PAREN); return; case '[': makeToken(parser, TOKEN_LEFT_BRACKET); return; case ']': makeToken(parser, TOKEN_RIGHT_BRACKET); return; case '{': makeToken(parser, TOKEN_LEFT_BRACE); return; case '}': makeToken(parser, TOKEN_RIGHT_BRACE); return; case ':': makeToken(parser, TOKEN_COLON); return; case ',': makeToken(parser, TOKEN_COMMA); return; case '*': makeToken(parser, TOKEN_STAR); return; case '%': makeToken(parser, TOKEN_PERCENT); return; case '^': makeToken(parser, TOKEN_CARET); return; case '+': makeToken(parser, TOKEN_PLUS); return; case '-': makeToken(parser, TOKEN_MINUS); return; case '~': makeToken(parser, TOKEN_TILDE); return; case '?': makeToken(parser, TOKEN_QUESTION); return; case '|': twoCharToken(parser, '|', TOKEN_PIPEPIPE, TOKEN_PIPE); return; case '&': twoCharToken(parser, '&', TOKEN_AMPAMP, TOKEN_AMP); return; case '=': twoCharToken(parser, '=', TOKEN_EQEQ, TOKEN_EQ); return; case '!': twoCharToken(parser, '=', TOKEN_BANGEQ, TOKEN_BANG); return; case '.': if (matchChar(parser, '.')) { twoCharToken(parser, '.', TOKEN_DOTDOTDOT, TOKEN_DOTDOT); return; } makeToken(parser, TOKEN_DOT); return; case '/': if (matchChar(parser, '/')) { skipLineComment(parser); break; } if (matchChar(parser, '*')) { skipBlockComment(parser); break; } makeToken(parser, TOKEN_SLASH); return; case '<': if (matchChar(parser, '<')) { makeToken(parser, TOKEN_LTLT); } else { twoCharToken(parser, '=', TOKEN_LTEQ, TOKEN_LT); } return; case '>': if (matchChar(parser, '>')) { makeToken(parser, TOKEN_GTGT); } else { twoCharToken(parser, '=', TOKEN_GTEQ, TOKEN_GT); } return; case '\n': makeToken(parser, TOKEN_LINE); return; case ' ': case '\r': case '\t': // Skip forward until we run out of whitespace. while (peekChar(parser) == ' ' || peekChar(parser) == '\r' || peekChar(parser) == '\t') { nextChar(parser); } break; case '"': readString(parser); return; case '_': readName(parser, peekChar(parser) == '_' ? TOKEN_STATIC_FIELD : TOKEN_FIELD); return; case '0': if (peekChar(parser) == 'x') { readHexNumber(parser); return; } readNumber(parser); return; default: if (parser->currentLine == 1 && c == '#' && peekChar(parser) == '!') { // Ignore shebang on the first line. skipLineComment(parser); break; } if (isName(c)) { readName(parser, TOKEN_NAME); } else if (isDigit(c)) { readNumber(parser); } else { if (c >= 32 && c <= 126) { lexError(parser, "Invalid character '%c'.", c); } else { // Don't show non-ASCII values since we didn't UTF-8 decode the // bytes. Since there are no non-ASCII byte values that are // meaningful code units in Wren, the lexer works on raw bytes, // even though the source code and console output are UTF-8. lexError(parser, "Invalid byte 0x%x.", (uint8_t)c); } parser->current.type = TOKEN_ERROR; parser->current.length = 0; } return; } } // If we get here, we're out of source, so just make EOF tokens. parser->tokenStart = parser->currentChar; makeToken(parser, TOKEN_EOF); } // Parsing --------------------------------------------------------------------- // Returns the type of the current token. static TokenType peek(Compiler* compiler) { return compiler->parser->current.type; } // Consumes the current token if its type is [expected]. Returns true if a // token was consumed. static bool match(Compiler* compiler, TokenType expected) { if (peek(compiler) != expected) return false; nextToken(compiler->parser); return true; } // Consumes the current token. Emits an error if its type is not [expected]. static void consume(Compiler* compiler, TokenType expected, const char* errorMessage) { nextToken(compiler->parser); if (compiler->parser->previous.type != expected) { error(compiler, errorMessage); // If the next token is the one we want, assume the current one is just a // spurious error and discard it to minimize the number of cascaded errors. if (compiler->parser->current.type == expected) nextToken(compiler->parser); } } // Matches one or more newlines. Returns true if at least one was found. static bool matchLine(Compiler* compiler) { if (!match(compiler, TOKEN_LINE)) return false; while (match(compiler, TOKEN_LINE)); return true; } // Discards any newlines starting at the current token. static void ignoreNewlines(Compiler* compiler) { matchLine(compiler); } // Consumes the current token. Emits an error if it is not a newline. Then // discards any duplicate newlines following it. static void consumeLine(Compiler* compiler, const char* errorMessage) { consume(compiler, TOKEN_LINE, errorMessage); ignoreNewlines(compiler); } // Variables and scopes -------------------------------------------------------- // Emits one single-byte argument. Returns its index. static int emitByte(Compiler* compiler, int byte) { wrenByteBufferWrite(compiler->parser->vm, &compiler->fn->code, (uint8_t)byte); // Assume the instruction is associated with the most recently consumed token. wrenIntBufferWrite(compiler->parser->vm, &compiler->fn->debug->sourceLines, compiler->parser->previous.line); return compiler->fn->code.count - 1; } // Emits one bytecode instruction. static void emitOp(Compiler* compiler, Code instruction) { emitByte(compiler, instruction); // Keep track of the stack's high water mark. compiler->numSlots += stackEffects[instruction]; if (compiler->numSlots > compiler->fn->maxSlots) { compiler->fn->maxSlots = compiler->numSlots; } } // Emits one 16-bit argument, which will be written big endian. static void emitShort(Compiler* compiler, int arg) { emitByte(compiler, (arg >> 8) & 0xff); emitByte(compiler, arg & 0xff); } // Emits one bytecode instruction followed by a 8-bit argument. Returns the // index of the argument in the bytecode. static int emitByteArg(Compiler* compiler, Code instruction, int arg) { emitOp(compiler, instruction); return emitByte(compiler, arg); } // Emits one bytecode instruction followed by a 16-bit argument, which will be // written big endian. static void emitShortArg(Compiler* compiler, Code instruction, int arg) { emitOp(compiler, instruction); emitShort(compiler, arg); } // Emits [instruction] followed by a placeholder for a jump offset. The // placeholder can be patched by calling [jumpPatch]. Returns the index of the // placeholder. static int emitJump(Compiler* compiler, Code instruction) { emitOp(compiler, instruction); emitByte(compiler, 0xff); return emitByte(compiler, 0xff) - 1; } // Creates a new constant for the current value and emits the bytecode to load // it from the constant table. static void emitConstant(Compiler* compiler, Value value) { int constant = addConstant(compiler, value); // Compile the code to load the constant. emitShortArg(compiler, CODE_CONSTANT, constant); } // Create a new local variable with [name]. Assumes the current scope is local // and the name is unique. static int addLocal(Compiler* compiler, const char* name, int length) { Local* local = &compiler->locals[compiler->numLocals]; local->name = name; local->length = length; local->depth = compiler->scopeDepth; local->isUpvalue = false; return compiler->numLocals++; } // Declares a variable in the current scope whose name is the given token. // // If [token] is `NULL`, uses the previously consumed token. Returns its symbol. static int declareVariable(Compiler* compiler, Token* token) { if (token == NULL) token = &compiler->parser->previous; if (token->length > MAX_VARIABLE_NAME) { error(compiler, "Variable name cannot be longer than %d characters.", MAX_VARIABLE_NAME); } // Top-level module scope. if (compiler->scopeDepth == -1) { int line = -1; int symbol = wrenDefineVariable(compiler->parser->vm, compiler->parser->module, token->start, token->length, NULL_VAL, &line); if (symbol == -1) { error(compiler, "Module variable is already defined."); } else if (symbol == -2) { error(compiler, "Too many module variables defined."); } else if (symbol == -3) { error(compiler, "Variable '%.*s' referenced before this definition (first use at line %d).", token->length, token->start, line); } return symbol; } // See if there is already a variable with this name declared in the current // scope. (Outer scopes are OK: those get shadowed.) for (int i = compiler->numLocals - 1; i >= 0; i--) { Local* local = &compiler->locals[i]; // Once we escape this scope and hit an outer one, we can stop. if (local->depth < compiler->scopeDepth) break; if (local->length == token->length && memcmp(local->name, token->start, token->length) == 0) { error(compiler, "Variable is already declared in this scope."); return i; } } if (compiler->numLocals == MAX_LOCALS) { error(compiler, "Cannot declare more than %d variables in one scope.", MAX_LOCALS); return -1; } return addLocal(compiler, token->start, token->length); } // Parses a name token and declares a variable in the current scope with that // name. Returns its slot. static int declareNamedVariable(Compiler* compiler) { consume(compiler, TOKEN_NAME, "Expect variable name."); return declareVariable(compiler, NULL); } // Stores a variable with the previously defined symbol in the current scope. static void defineVariable(Compiler* compiler, int symbol) { // Store the variable. If it's a local, the result of the initializer is // in the correct slot on the stack already so we're done. if (compiler->scopeDepth >= 0) return; // It's a module-level variable, so store the value in the module slot and // then discard the temporary for the initializer. emitShortArg(compiler, CODE_STORE_MODULE_VAR, symbol); emitOp(compiler, CODE_POP); } // Starts a new local block scope. static void pushScope(Compiler* compiler) { compiler->scopeDepth++; } // Generates code to discard local variables at [depth] or greater. Does *not* // actually undeclare variables or pop any scopes, though. This is called // directly when compiling "break" statements to ditch the local variables // before jumping out of the loop even though they are still in scope *past* // the break instruction. // // Returns the number of local variables that were eliminated. static int discardLocals(Compiler* compiler, int depth) { ASSERT(compiler->scopeDepth > -1, "Cannot exit top-level scope."); int local = compiler->numLocals - 1; while (local >= 0 && compiler->locals[local].depth >= depth) { // If the local was closed over, make sure the upvalue gets closed when it // goes out of scope on the stack. We use emitByte() and not emitOp() here // because we don't want to track that stack effect of these pops since the // variables are still in scope after the break. if (compiler->locals[local].isUpvalue) { emitByte(compiler, CODE_CLOSE_UPVALUE); } else { emitByte(compiler, CODE_POP); } local--; } return compiler->numLocals - local - 1; } // Closes the last pushed block scope and discards any local variables declared // in that scope. This should only be called in a statement context where no // temporaries are still on the stack. static void popScope(Compiler* compiler) { int popped = discardLocals(compiler, compiler->scopeDepth); compiler->numLocals -= popped; compiler->numSlots -= popped; compiler->scopeDepth--; } // Attempts to look up the name in the local variables of [compiler]. If found, // returns its index, otherwise returns -1. static int resolveLocal(Compiler* compiler, const char* name, int length) { // Look it up in the local scopes. Look in reverse order so that the most // nested variable is found first and shadows outer ones. for (int i = compiler->numLocals - 1; i >= 0; i--) { if (compiler->locals[i].length == length && memcmp(name, compiler->locals[i].name, length) == 0) { return i; } } return -1; } // Adds an upvalue to [compiler]'s function with the given properties. Does not // add one if an upvalue for that variable is already in the list. Returns the // index of the upvalue. static int addUpvalue(Compiler* compiler, bool isLocal, int index) { // Look for an existing one. for (int i = 0; i < compiler->fn->numUpvalues; i++) { CompilerUpvalue* upvalue = &compiler->upvalues[i]; if (upvalue->index == index && upvalue->isLocal == isLocal) return i; } // If we got here, it's a new upvalue. compiler->upvalues[compiler->fn->numUpvalues].isLocal = isLocal; compiler->upvalues[compiler->fn->numUpvalues].index = index; return compiler->fn->numUpvalues++; } // Attempts to look up [name] in the functions enclosing the one being compiled // by [compiler]. If found, it adds an upvalue for it to this compiler's list // of upvalues (unless it's already in there) and returns its index. If not // found, returns -1. // // If the name is found outside of the immediately enclosing function, this // will flatten the closure and add upvalues to all of the intermediate // functions so that it gets walked down to this one. // // If it reaches a method boundary, this stops and returns -1 since methods do // not close over local variables. static int findUpvalue(Compiler* compiler, const char* name, int length) { // If we are at the top level, we didn't find it. if (compiler->parent == NULL) return -1; // If we hit the method boundary (and the name isn't a static field), then // stop looking for it. We'll instead treat it as a self send. if (name[0] != '_' && compiler->parent->enclosingClass != NULL) return -1; // See if it's a local variable in the immediately enclosing function. int local = resolveLocal(compiler->parent, name, length); if (local != -1) { // Mark the local as an upvalue so we know to close it when it goes out of // scope. compiler->parent->locals[local].isUpvalue = true; return addUpvalue(compiler, true, local); } // See if it's an upvalue in the immediately enclosing function. In other // words, if it's a local variable in a non-immediately enclosing function. // This "flattens" closures automatically: it adds upvalues to all of the // intermediate functions to get from the function where a local is declared // all the way into the possibly deeply nested function that is closing over // it. int upvalue = findUpvalue(compiler->parent, name, length); if (upvalue != -1) { return addUpvalue(compiler, false, upvalue); } // If we got here, we walked all the way up the parent chain and couldn't // find it. return -1; } // Look up [name] in the current scope to see what variable it refers to. // Returns the variable either in local scope, or the enclosing function's // upvalue list. Does not search the module scope. Returns a variable with // index -1 if not found. static Variable resolveNonmodule(Compiler* compiler, const char* name, int length) { // Look it up in the local scopes. Variable variable; variable.scope = SCOPE_LOCAL; variable.index = resolveLocal(compiler, name, length); if (variable.index != -1) return variable; // Tt's not a local, so guess that it's an upvalue. variable.scope = SCOPE_UPVALUE; variable.index = findUpvalue(compiler, name, length); return variable; } // Look up [name] in the current scope to see what variable it refers to. // Returns the variable either in module scope, local scope, or the enclosing // function's upvalue list. Returns a variable with index -1 if not found. static Variable resolveName(Compiler* compiler, const char* name, int length) { Variable variable = resolveNonmodule(compiler, name, length); if (variable.index != -1) return variable; variable.scope = SCOPE_MODULE; variable.index = wrenSymbolTableFind(&compiler->parser->module->variableNames, name, length); return variable; } static void loadLocal(Compiler* compiler, int slot) { if (slot <= 8) { emitOp(compiler, (Code)(CODE_LOAD_LOCAL_0 + slot)); return; } emitByteArg(compiler, CODE_LOAD_LOCAL, slot); } // Finishes [compiler], which is compiling a function, method, or chunk of top // level code. If there is a parent compiler, then this emits code in the // parent compiler to load the resulting function. static ObjFn* endCompiler(Compiler* compiler, const char* debugName, int debugNameLength) { // If we hit an error, don't finish the function since it's borked anyway. if (compiler->parser->hasError) { compiler->parser->vm->compiler = compiler->parent; return NULL; } // Mark the end of the bytecode. Since it may contain multiple early returns, // we can't rely on CODE_RETURN to tell us we're at the end. emitOp(compiler, CODE_END); wrenFunctionBindName(compiler->parser->vm, compiler->fn, debugName, debugNameLength); // In the function that contains this one, load the resulting function object. if (compiler->parent != NULL) { int constant = addConstant(compiler->parent, OBJ_VAL(compiler->fn)); // Wrap the function in a closure. We do this even if it has no upvalues so // that the VM can uniformly assume all called objects are closures. This // makes creating a function a little slower, but makes invoking them // faster. Given that functions are invoked more often than they are // created, this is a win. emitShortArg(compiler->parent, CODE_CLOSURE, constant); // Emit arguments for each upvalue to know whether to capture a local or // an upvalue. for (int i = 0; i < compiler->fn->numUpvalues; i++) { emitByte(compiler->parent, compiler->upvalues[i].isLocal ? 1 : 0); emitByte(compiler->parent, compiler->upvalues[i].index); } } // Pop this compiler off the stack. compiler->parser->vm->compiler = compiler->parent; #if WREN_DEBUG_DUMP_COMPILED_CODE wrenDumpCode(compiler->parser->vm, compiler->fn); #endif return compiler->fn; } // Grammar --------------------------------------------------------------------- typedef enum { PREC_NONE, PREC_LOWEST, PREC_ASSIGNMENT, // = PREC_CONDITIONAL, // ?: PREC_LOGICAL_OR, // || PREC_LOGICAL_AND, // && PREC_EQUALITY, // == != PREC_IS, // is PREC_COMPARISON, // < > <= >= PREC_BITWISE_OR, // | PREC_BITWISE_XOR, // ^ PREC_BITWISE_AND, // & PREC_BITWISE_SHIFT, // << >> PREC_RANGE, // .. ... PREC_TERM, // + - PREC_FACTOR, // * / % PREC_UNARY, // unary - ! ~ PREC_CALL, // . () [] PREC_PRIMARY } Precedence; typedef void (*GrammarFn)(Compiler*, bool canAssign); typedef void (*SignatureFn)(Compiler* compiler, Signature* signature); typedef struct { GrammarFn prefix; GrammarFn infix; SignatureFn method; Precedence precedence; const char* name; } GrammarRule; // Forward declarations since the grammar is recursive. static GrammarRule* getRule(TokenType type); static void expression(Compiler* compiler); static void statement(Compiler* compiler); static void definition(Compiler* compiler); static void parsePrecedence(Compiler* compiler, Precedence precedence); // Replaces the placeholder argument for a previous CODE_JUMP or CODE_JUMP_IF // instruction with an offset that jumps to the current end of bytecode. static void patchJump(Compiler* compiler, int offset) { // -2 to adjust for the bytecode for the jump offset itself. int jump = compiler->fn->code.count - offset - 2; if (jump > MAX_JUMP) error(compiler, "Too much code to jump over."); compiler->fn->code.data[offset] = (jump >> 8) & 0xff; compiler->fn->code.data[offset + 1] = jump & 0xff; } // Parses a block body, after the initial "{" has been consumed. // // Returns true if it was a expression body, false if it was a statement body. // (More precisely, returns true if a value was left on the stack. An empty // block returns false.) static bool finishBlock(Compiler* compiler) { // Empty blocks do nothing. if (match(compiler, TOKEN_RIGHT_BRACE)) return false; // If there's no line after the "{", it's a single-expression body. if (!matchLine(compiler)) { expression(compiler); consume(compiler, TOKEN_RIGHT_BRACE, "Expect '}' at end of block."); return true; } // Empty blocks (with just a newline inside) do nothing. if (match(compiler, TOKEN_RIGHT_BRACE)) return false; // Compile the definition list. do { definition(compiler); consumeLine(compiler, "Expect newline after statement."); } while (peek(compiler) != TOKEN_RIGHT_BRACE && peek(compiler) != TOKEN_EOF); consume(compiler, TOKEN_RIGHT_BRACE, "Expect '}' at end of block."); return false; } // Parses a method or function body, after the initial "{" has been consumed. // // It [isInitializer] is `true`, this is the body of a constructor initializer. // In that case, this adds the code to ensure it returns `this`. static void finishBody(Compiler* compiler, bool isInitializer) { bool isExpressionBody = finishBlock(compiler); if (isInitializer) { // If the initializer body evaluates to a value, discard it. if (isExpressionBody) emitOp(compiler, CODE_POP); // The receiver is always stored in the first local slot. emitOp(compiler, CODE_LOAD_LOCAL_0); } else if (!isExpressionBody) { // Implicitly return null in statement bodies. emitOp(compiler, CODE_NULL); } emitOp(compiler, CODE_RETURN); } // The VM can only handle a certain number of parameters, so check that we // haven't exceeded that and give a usable error. static void validateNumParameters(Compiler* compiler, int numArgs) { if (numArgs == MAX_PARAMETERS + 1) { // Only show an error at exactly max + 1 so that we can keep parsing the // parameters and minimize cascaded errors. error(compiler, "Methods cannot have more than %d parameters.", MAX_PARAMETERS); } } // Parses the rest of a comma-separated parameter list after the opening // delimeter. Updates `arity` in [signature] with the number of parameters. static void finishParameterList(Compiler* compiler, Signature* signature) { do { ignoreNewlines(compiler); validateNumParameters(compiler, ++signature->arity); // Define a local variable in the method for the parameter. declareNamedVariable(compiler); } while (match(compiler, TOKEN_COMMA)); } // Gets the symbol for a method [name] with [length]. static int methodSymbol(Compiler* compiler, const char* name, int length) { return wrenSymbolTableEnsure(compiler->parser->vm, &compiler->parser->vm->methodNames, name, length); } // Appends characters to [name] (and updates [length]) for [numParams] "_" // surrounded by [leftBracket] and [rightBracket]. static void signatureParameterList(char name[MAX_METHOD_SIGNATURE], int* length, int numParams, char leftBracket, char rightBracket) { name[(*length)++] = leftBracket; // This function may be called with too many parameters. When that happens, // a compile error has already been reported, but we need to make sure we // don't overflow the string too, hence the MAX_PARAMETERS check. for (int i = 0; i < numParams && i < MAX_PARAMETERS; i++) { if (i > 0) name[(*length)++] = ','; name[(*length)++] = '_'; } name[(*length)++] = rightBracket; } // Fills [name] with the stringified version of [signature] and updates // [length] to the resulting length. static void signatureToString(Signature* signature, char name[MAX_METHOD_SIGNATURE], int* length) { *length = 0; // Build the full name from the signature. memcpy(name + *length, signature->name, signature->length); *length += signature->length; switch (signature->type) { case SIG_METHOD: signatureParameterList(name, length, signature->arity, '(', ')'); break; case SIG_GETTER: // The signature is just the name. break; case SIG_SETTER: name[(*length)++] = '='; signatureParameterList(name, length, 1, '(', ')'); break; case SIG_SUBSCRIPT: signatureParameterList(name, length, signature->arity, '[', ']'); break; case SIG_SUBSCRIPT_SETTER: signatureParameterList(name, length, signature->arity - 1, '[', ']'); name[(*length)++] = '='; signatureParameterList(name, length, 1, '(', ')'); break; case SIG_INITIALIZER: memcpy(name, "init ", 5); memcpy(name + 5, signature->name, signature->length); *length = 5 + signature->length; signatureParameterList(name, length, signature->arity, '(', ')'); break; } name[*length] = '\0'; } // Gets the symbol for a method with [signature]. static int signatureSymbol(Compiler* compiler, Signature* signature) { // Build the full name from the signature. char name[MAX_METHOD_SIGNATURE]; int length; signatureToString(signature, name, &length); return methodSymbol(compiler, name, length); } // Returns a signature with [type] whose name is from the last consumed token. static Signature signatureFromToken(Compiler* compiler, SignatureType type) { Signature signature; // Get the token for the method name. Token* token = &compiler->parser->previous; signature.name = token->start; signature.length = token->length; signature.type = type; signature.arity = 0; if (signature.length > MAX_METHOD_NAME) { error(compiler, "Method names cannot be longer than %d characters.", MAX_METHOD_NAME); signature.length = MAX_METHOD_NAME; } return signature; } // Parses a comma-separated list of arguments. Modifies [signature] to include // the arity of the argument list. static void finishArgumentList(Compiler* compiler, Signature* signature) { do { ignoreNewlines(compiler); validateNumParameters(compiler, ++signature->arity); expression(compiler); } while (match(compiler, TOKEN_COMMA)); // Allow a newline before the closing delimiter. ignoreNewlines(compiler); } // Compiles a method call with [signature] using [instruction]. static void callSignature(Compiler* compiler, Code instruction, Signature* signature) { int symbol = signatureSymbol(compiler, signature); emitShortArg(compiler, (Code)(instruction + signature->arity), symbol); if (instruction == CODE_SUPER_0) { // Super calls need to be statically bound to the class's superclass. This // ensures we call the right method even when a method containing a super // call is inherited by another subclass. // // We bind it at class definition time by storing a reference to the // superclass in a constant. So, here, we create a slot in the constant // table and store NULL in it. When the method is bound, we'll look up the // superclass then and store it in the constant slot. emitShort(compiler, addConstant(compiler, NULL_VAL)); } } // Compiles a method call with [numArgs] for a method with [name] with [length]. static void callMethod(Compiler* compiler, int numArgs, const char* name, int length) { int symbol = methodSymbol(compiler, name, length); emitShortArg(compiler, (Code)(CODE_CALL_0 + numArgs), symbol); } // Compiles an (optional) argument list for a method call with [methodSignature] // and then calls it. static void methodCall(Compiler* compiler, Code instruction, Signature* signature) { // Make a new signature that contains the updated arity and type based on // the arguments we find. Signature called = { signature->name, signature->length, SIG_GETTER, 0 }; // Parse the argument list, if any. if (match(compiler, TOKEN_LEFT_PAREN)) { called.type = SIG_METHOD; // Allow empty an argument list. if (peek(compiler) != TOKEN_RIGHT_PAREN) { finishArgumentList(compiler, &called); } consume(compiler, TOKEN_RIGHT_PAREN, "Expect ')' after arguments."); } // Parse the block argument, if any. if (match(compiler, TOKEN_LEFT_BRACE)) { // Include the block argument in the arity. called.type = SIG_METHOD; called.arity++; Compiler fnCompiler; initCompiler(&fnCompiler, compiler->parser, compiler, false); // Make a dummy signature to track the arity. Signature fnSignature = { "", 0, SIG_METHOD, 0 }; // Parse the parameter list, if any. if (match(compiler, TOKEN_PIPE)) { finishParameterList(&fnCompiler, &fnSignature); consume(compiler, TOKEN_PIPE, "Expect '|' after function parameters."); } fnCompiler.fn->arity = fnSignature.arity; finishBody(&fnCompiler, false); // Name the function based on the method its passed to. char blockName[MAX_METHOD_SIGNATURE + 15]; int blockLength; signatureToString(&called, blockName, &blockLength); memmove(blockName + blockLength, " block argument", 16); endCompiler(&fnCompiler, blockName, blockLength + 15); } // TODO: Allow Grace-style mixfix methods? // If this is a super() call for an initializer, make sure we got an actual // argument list. if (signature->type == SIG_INITIALIZER) { if (called.type != SIG_METHOD) { error(compiler, "A superclass constructor must have an argument list."); } called.type = SIG_INITIALIZER; } callSignature(compiler, instruction, &called); } // Compiles a call whose name is the previously consumed token. This includes // getters, method calls with arguments, and setter calls. static void namedCall(Compiler* compiler, bool canAssign, Code instruction) { // Get the token for the method name. Signature signature = signatureFromToken(compiler, SIG_GETTER); if (canAssign && match(compiler, TOKEN_EQ)) { ignoreNewlines(compiler); // Build the setter signature. signature.type = SIG_SETTER; signature.arity = 1; // Compile the assigned value. expression(compiler); callSignature(compiler, instruction, &signature); } else { methodCall(compiler, instruction, &signature); } } // Emits the code to load [variable] onto the stack. static void loadVariable(Compiler* compiler, Variable variable) { switch (variable.scope) { case SCOPE_LOCAL: loadLocal(compiler, variable.index); break; case SCOPE_UPVALUE: emitByteArg(compiler, CODE_LOAD_UPVALUE, variable.index); break; case SCOPE_MODULE: emitShortArg(compiler, CODE_LOAD_MODULE_VAR, variable.index); break; default: UNREACHABLE(); } } // Loads the receiver of the currently enclosing method. Correctly handles // functions defined inside methods. static void loadThis(Compiler* compiler) { loadVariable(compiler, resolveNonmodule(compiler, "this", 4)); } // Pushes the value for a module-level variable implicitly imported from core. static void loadCoreVariable(Compiler* compiler, const char* name) { int symbol = wrenSymbolTableFind(&compiler->parser->module->variableNames, name, strlen(name)); ASSERT(symbol != -1, "Should have already defined core name."); emitShortArg(compiler, CODE_LOAD_MODULE_VAR, symbol); } // A parenthesized expression. static void grouping(Compiler* compiler, bool canAssign) { expression(compiler); consume(compiler, TOKEN_RIGHT_PAREN, "Expect ')' after expression."); } // A list literal. static void list(Compiler* compiler, bool canAssign) { // Instantiate a new list. loadCoreVariable(compiler, "List"); callMethod(compiler, 0, "new()", 5); // Compile the list elements. Each one compiles to a ".add()" call. do { ignoreNewlines(compiler); // Stop if we hit the end of the list. if (peek(compiler) == TOKEN_RIGHT_BRACKET) break; // The element. expression(compiler); callMethod(compiler, 1, "addCore_(_)", 11); } while (match(compiler, TOKEN_COMMA)); // Allow newlines before the closing ']'. ignoreNewlines(compiler); consume(compiler, TOKEN_RIGHT_BRACKET, "Expect ']' after list elements."); } // A map literal. static void map(Compiler* compiler, bool canAssign) { // Instantiate a new map. loadCoreVariable(compiler, "Map"); callMethod(compiler, 0, "new()", 5); // Compile the map elements. Each one is compiled to just invoke the // subscript setter on the map. do { ignoreNewlines(compiler); // Stop if we hit the end of the map. if (peek(compiler) == TOKEN_RIGHT_BRACE) break; // The key. parsePrecedence(compiler, PREC_UNARY); consume(compiler, TOKEN_COLON, "Expect ':' after map key."); ignoreNewlines(compiler); // The value. expression(compiler); callMethod(compiler, 2, "addCore_(_,_)", 13); } while (match(compiler, TOKEN_COMMA)); // Allow newlines before the closing '}'. ignoreNewlines(compiler); consume(compiler, TOKEN_RIGHT_BRACE, "Expect '}' after map entries."); } // Unary operators like `-foo`. static void unaryOp(Compiler* compiler, bool canAssign) { GrammarRule* rule = getRule(compiler->parser->previous.type); ignoreNewlines(compiler); // Compile the argument. parsePrecedence(compiler, (Precedence)(PREC_UNARY + 1)); // Call the operator method on the left-hand side. callMethod(compiler, 0, rule->name, 1); } static void boolean(Compiler* compiler, bool canAssign) { emitOp(compiler, compiler->parser->previous.type == TOKEN_FALSE ? CODE_FALSE : CODE_TRUE); } // Walks the compiler chain to find the compiler for the nearest class // enclosing this one. Returns NULL if not currently inside a class definition. static Compiler* getEnclosingClassCompiler(Compiler* compiler) { while (compiler != NULL) { if (compiler->enclosingClass != NULL) return compiler; compiler = compiler->parent; } return NULL; } // Walks the compiler chain to find the nearest class enclosing this one. // Returns NULL if not currently inside a class definition. static ClassInfo* getEnclosingClass(Compiler* compiler) { compiler = getEnclosingClassCompiler(compiler); return compiler == NULL ? NULL : compiler->enclosingClass; } static void field(Compiler* compiler, bool canAssign) { // Initialize it with a fake value so we can keep parsing and minimize the // number of cascaded errors. int field = MAX_FIELDS; ClassInfo* enclosingClass = getEnclosingClass(compiler); if (enclosingClass == NULL) { error(compiler, "Cannot reference a field outside of a class definition."); } else if (enclosingClass->isForeign) { error(compiler, "Cannot define fields in a foreign class."); } else if (enclosingClass->inStatic) { error(compiler, "Cannot use an instance field in a static method."); } else { // Look up the field, or implicitly define it. field = wrenSymbolTableEnsure(compiler->parser->vm, &enclosingClass->fields, compiler->parser->previous.start, compiler->parser->previous.length); if (field >= MAX_FIELDS) { error(compiler, "A class can only have %d fields.", MAX_FIELDS); } } // If there's an "=" after a field name, it's an assignment. bool isLoad = true; if (canAssign && match(compiler, TOKEN_EQ)) { // Compile the right-hand side. expression(compiler); isLoad = false; } // If we're directly inside a method, use a more optimal instruction. if (compiler->parent != NULL && compiler->parent->enclosingClass == enclosingClass) { emitByteArg(compiler, isLoad ? CODE_LOAD_FIELD_THIS : CODE_STORE_FIELD_THIS, field); } else { loadThis(compiler); emitByteArg(compiler, isLoad ? CODE_LOAD_FIELD : CODE_STORE_FIELD, field); } } // Compiles a read or assignment to [variable]. static void bareName(Compiler* compiler, bool canAssign, Variable variable) { // If there's an "=" after a bare name, it's a variable assignment. if (canAssign && match(compiler, TOKEN_EQ)) { // Compile the right-hand side. expression(compiler); // Emit the store instruction. switch (variable.scope) { case SCOPE_LOCAL: emitByteArg(compiler, CODE_STORE_LOCAL, variable.index); break; case SCOPE_UPVALUE: emitByteArg(compiler, CODE_STORE_UPVALUE, variable.index); break; case SCOPE_MODULE: emitShortArg(compiler, CODE_STORE_MODULE_VAR, variable.index); break; default: UNREACHABLE(); } return; } // Emit the load instruction. loadVariable(compiler, variable); } static void staticField(Compiler* compiler, bool canAssign) { Compiler* classCompiler = getEnclosingClassCompiler(compiler); if (classCompiler == NULL) { error(compiler, "Cannot use a static field outside of a class definition."); return; } // Look up the name in the scope chain. Token* token = &compiler->parser->previous; // If this is the first time we've seen this static field, implicitly // define it as a variable in the scope surrounding the class definition. if (resolveLocal(classCompiler, token->start, token->length) == -1) { int symbol = declareVariable(classCompiler, NULL); // Implicitly initialize it to null. emitOp(classCompiler, CODE_NULL); defineVariable(classCompiler, symbol); } // It definitely exists now, so resolve it properly. This is different from // the above resolveLocal() call because we may have already closed over it // as an upvalue. Variable variable = resolveName(compiler, token->start, token->length); bareName(compiler, canAssign, variable); } // Compiles a variable name or method call with an implicit receiver. static void name(Compiler* compiler, bool canAssign) { // Look for the name in the scope chain up to the nearest enclosing method. Token* token = &compiler->parser->previous; Variable variable = resolveNonmodule(compiler, token->start, token->length); if (variable.index != -1) { bareName(compiler, canAssign, variable); return; } // TODO: The fact that we return above here if the variable is known and parse // an optional argument list below if not means that the grammar is not // context-free. A line of code in a method like "someName(foo)" is a parse // error if "someName" is a defined variable in the surrounding scope and not // if it isn't. Fix this. One option is to have "someName(foo)" always // resolve to a self-call if there is an argument list, but that makes // getters a little confusing. // If we're inside a method and the name is lowercase, treat it as a method // on this. if (wrenIsLocalName(token->start) && getEnclosingClass(compiler) != NULL) { loadThis(compiler); namedCall(compiler, canAssign, CODE_CALL_0); return; } // Otherwise, look for a module-level variable with the name. variable.scope = SCOPE_MODULE; variable.index = wrenSymbolTableFind(&compiler->parser->module->variableNames, token->start, token->length); if (variable.index == -1) { // Implicitly define a module-level variable in // the hopes that we get a real definition later. variable.index = wrenDeclareVariable(compiler->parser->vm, compiler->parser->module, token->start, token->length, token->line); if (variable.index == -2) { error(compiler, "Too many module variables defined."); } } bareName(compiler, canAssign, variable); } static void null(Compiler* compiler, bool canAssign) { emitOp(compiler, CODE_NULL); } // A number or string literal. static void literal(Compiler* compiler, bool canAssign) { emitConstant(compiler, compiler->parser->previous.value); } // A string literal that contains interpolated expressions. // // Interpolation is syntactic sugar for calling ".join()" on a list. So the // string: // // "a %(b + c) d" // // is compiled roughly like: // // ["a ", b + c, " d"].join() static void stringInterpolation(Compiler* compiler, bool canAssign) { // Instantiate a new list. loadCoreVariable(compiler, "List"); callMethod(compiler, 0, "new()", 5); do { // The opening string part. literal(compiler, false); callMethod(compiler, 1, "addCore_(_)", 11); // The interpolated expression. ignoreNewlines(compiler); expression(compiler); callMethod(compiler, 1, "addCore_(_)", 11); ignoreNewlines(compiler); } while (match(compiler, TOKEN_INTERPOLATION)); // The trailing string part. consume(compiler, TOKEN_STRING, "Expect end of string interpolation."); literal(compiler, false); callMethod(compiler, 1, "addCore_(_)", 11); // The list of interpolated parts. callMethod(compiler, 0, "join()", 6); } static void super_(Compiler* compiler, bool canAssign) { ClassInfo* enclosingClass = getEnclosingClass(compiler); if (enclosingClass == NULL) { error(compiler, "Cannot use 'super' outside of a method."); } loadThis(compiler); // TODO: Super operator calls. // TODO: There's no syntax for invoking a superclass constructor with a // different name from the enclosing one. Figure that out. // See if it's a named super call, or an unnamed one. if (match(compiler, TOKEN_DOT)) { // Compile the superclass call. consume(compiler, TOKEN_NAME, "Expect method name after 'super.'."); namedCall(compiler, canAssign, CODE_SUPER_0); } else if (enclosingClass != NULL) { // No explicit name, so use the name of the enclosing method. Make sure we // check that enclosingClass isn't NULL first. We've already reported the // error, but we don't want to crash here. methodCall(compiler, CODE_SUPER_0, enclosingClass->signature); } } static void this_(Compiler* compiler, bool canAssign) { if (getEnclosingClass(compiler) == NULL) { error(compiler, "Cannot use 'this' outside of a method."); return; } loadThis(compiler); } // Subscript or "array indexing" operator like `foo[bar]`. static void subscript(Compiler* compiler, bool canAssign) { Signature signature = { "", 0, SIG_SUBSCRIPT, 0 }; // Parse the argument list. finishArgumentList(compiler, &signature); consume(compiler, TOKEN_RIGHT_BRACKET, "Expect ']' after arguments."); if (canAssign && match(compiler, TOKEN_EQ)) { signature.type = SIG_SUBSCRIPT_SETTER; // Compile the assigned value. validateNumParameters(compiler, ++signature.arity); expression(compiler); } callSignature(compiler, CODE_CALL_0, &signature); } static void call(Compiler* compiler, bool canAssign) { ignoreNewlines(compiler); consume(compiler, TOKEN_NAME, "Expect method name after '.'."); namedCall(compiler, canAssign, CODE_CALL_0); } static void and_(Compiler* compiler, bool canAssign) { ignoreNewlines(compiler); // Skip the right argument if the left is false. int jump = emitJump(compiler, CODE_AND); parsePrecedence(compiler, PREC_LOGICAL_AND); patchJump(compiler, jump); } static void or_(Compiler* compiler, bool canAssign) { ignoreNewlines(compiler); // Skip the right argument if the left is true. int jump = emitJump(compiler, CODE_OR); parsePrecedence(compiler, PREC_LOGICAL_OR); patchJump(compiler, jump); } static void conditional(Compiler* compiler, bool canAssign) { // Ignore newline after '?'. ignoreNewlines(compiler); // Jump to the else branch if the condition is false. int ifJump = emitJump(compiler, CODE_JUMP_IF); // Compile the then branch. parsePrecedence(compiler, PREC_CONDITIONAL); consume(compiler, TOKEN_COLON, "Expect ':' after then branch of conditional operator."); ignoreNewlines(compiler); // Jump over the else branch when the if branch is taken. int elseJump = emitJump(compiler, CODE_JUMP); // Compile the else branch. patchJump(compiler, ifJump); parsePrecedence(compiler, PREC_ASSIGNMENT); // Patch the jump over the else. patchJump(compiler, elseJump); } void infixOp(Compiler* compiler, bool canAssign) { GrammarRule* rule = getRule(compiler->parser->previous.type); // An infix operator cannot end an expression. ignoreNewlines(compiler); // Compile the right-hand side. parsePrecedence(compiler, (Precedence)(rule->precedence + 1)); // Call the operator method on the left-hand side. Signature signature = { rule->name, (int)strlen(rule->name), SIG_METHOD, 1 }; callSignature(compiler, CODE_CALL_0, &signature); } // Compiles a method signature for an infix operator. void infixSignature(Compiler* compiler, Signature* signature) { // Add the RHS parameter. signature->type = SIG_METHOD; signature->arity = 1; // Parse the parameter name. consume(compiler, TOKEN_LEFT_PAREN, "Expect '(' after operator name."); declareNamedVariable(compiler); consume(compiler, TOKEN_RIGHT_PAREN, "Expect ')' after parameter name."); } // Compiles a method signature for an unary operator (i.e. "!"). void unarySignature(Compiler* compiler, Signature* signature) { // Do nothing. The name is already complete. signature->type = SIG_GETTER; } // Compiles a method signature for an operator that can either be unary or // infix (i.e. "-"). void mixedSignature(Compiler* compiler, Signature* signature) { signature->type = SIG_GETTER; // If there is a parameter, it's an infix operator, otherwise it's unary. if (match(compiler, TOKEN_LEFT_PAREN)) { // Add the RHS parameter. signature->type = SIG_METHOD; signature->arity = 1; // Parse the parameter name. declareNamedVariable(compiler); consume(compiler, TOKEN_RIGHT_PAREN, "Expect ')' after parameter name."); } } // Compiles an optional setter parameter in a method [signature]. // // Returns `true` if it was a setter. static bool maybeSetter(Compiler* compiler, Signature* signature) { // See if it's a setter. if (!match(compiler, TOKEN_EQ)) return false; // It's a setter. if (signature->type == SIG_SUBSCRIPT) { signature->type = SIG_SUBSCRIPT_SETTER; } else { signature->type = SIG_SETTER; } // Parse the value parameter. consume(compiler, TOKEN_LEFT_PAREN, "Expect '(' after '='."); declareNamedVariable(compiler); consume(compiler, TOKEN_RIGHT_PAREN, "Expect ')' after parameter name."); signature->arity++; return true; } // Compiles a method signature for a subscript operator. void subscriptSignature(Compiler* compiler, Signature* signature) { signature->type = SIG_SUBSCRIPT; // The signature currently has "[" as its name since that was the token that // matched it. Clear that out. signature->length = 0; // Parse the parameters inside the subscript. finishParameterList(compiler, signature); consume(compiler, TOKEN_RIGHT_BRACKET, "Expect ']' after parameters."); maybeSetter(compiler, signature); } // Parses an optional parenthesized parameter list. Updates `type` and `arity` // in [signature] to match what was parsed. static void parameterList(Compiler* compiler, Signature* signature) { // The parameter list is optional. if (!match(compiler, TOKEN_LEFT_PAREN)) return; signature->type = SIG_METHOD; // Allow an empty parameter list. if (match(compiler, TOKEN_RIGHT_PAREN)) return; finishParameterList(compiler, signature); consume(compiler, TOKEN_RIGHT_PAREN, "Expect ')' after parameters."); } // Compiles a method signature for a named method or setter. void namedSignature(Compiler* compiler, Signature* signature) { signature->type = SIG_GETTER; // If it's a setter, it can't also have a parameter list. if (maybeSetter(compiler, signature)) return; // Regular named method with an optional parameter list. parameterList(compiler, signature); } // Compiles a method signature for a constructor. void constructorSignature(Compiler* compiler, Signature* signature) { consume(compiler, TOKEN_NAME, "Expect constructor name after 'construct'."); // Capture the name. *signature = signatureFromToken(compiler, SIG_INITIALIZER); if (match(compiler, TOKEN_EQ)) { error(compiler, "A constructor cannot be a setter."); } if (!match(compiler, TOKEN_LEFT_PAREN)) { error(compiler, "A constructor cannot be a getter."); return; } // Allow an empty parameter list. if (match(compiler, TOKEN_RIGHT_PAREN)) return; finishParameterList(compiler, signature); consume(compiler, TOKEN_RIGHT_PAREN, "Expect ')' after parameters."); } // This table defines all of the parsing rules for the prefix and infix // expressions in the grammar. Expressions are parsed using a Pratt parser. // // See: http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/ #define UNUSED { NULL, NULL, NULL, PREC_NONE, NULL } #define PREFIX(fn) { fn, NULL, NULL, PREC_NONE, NULL } #define INFIX(prec, fn) { NULL, fn, NULL, prec, NULL } #define INFIX_OPERATOR(prec, name) { NULL, infixOp, infixSignature, prec, name } #define PREFIX_OPERATOR(name) { unaryOp, NULL, unarySignature, PREC_NONE, name } #define OPERATOR(name) { unaryOp, infixOp, mixedSignature, PREC_TERM, name } GrammarRule rules[] = { /* TOKEN_LEFT_PAREN */ PREFIX(grouping), /* TOKEN_RIGHT_PAREN */ UNUSED, /* TOKEN_LEFT_BRACKET */ { list, subscript, subscriptSignature, PREC_CALL, NULL }, /* TOKEN_RIGHT_BRACKET */ UNUSED, /* TOKEN_LEFT_BRACE */ PREFIX(map), /* TOKEN_RIGHT_BRACE */ UNUSED, /* TOKEN_COLON */ UNUSED, /* TOKEN_DOT */ INFIX(PREC_CALL, call), /* TOKEN_DOTDOT */ INFIX_OPERATOR(PREC_RANGE, ".."), /* TOKEN_DOTDOTDOT */ INFIX_OPERATOR(PREC_RANGE, "..."), /* TOKEN_COMMA */ UNUSED, /* TOKEN_STAR */ INFIX_OPERATOR(PREC_FACTOR, "*"), /* TOKEN_SLASH */ INFIX_OPERATOR(PREC_FACTOR, "/"), /* TOKEN_PERCENT */ INFIX_OPERATOR(PREC_FACTOR, "%"), /* TOKEN_PLUS */ INFIX_OPERATOR(PREC_TERM, "+"), /* TOKEN_MINUS */ OPERATOR("-"), /* TOKEN_LTLT */ INFIX_OPERATOR(PREC_BITWISE_SHIFT, "<<"), /* TOKEN_GTGT */ INFIX_OPERATOR(PREC_BITWISE_SHIFT, ">>"), /* TOKEN_PIPE */ INFIX_OPERATOR(PREC_BITWISE_OR, "|"), /* TOKEN_PIPEPIPE */ INFIX(PREC_LOGICAL_OR, or_), /* TOKEN_CARET */ INFIX_OPERATOR(PREC_BITWISE_XOR, "^"), /* TOKEN_AMP */ INFIX_OPERATOR(PREC_BITWISE_AND, "&"), /* TOKEN_AMPAMP */ INFIX(PREC_LOGICAL_AND, and_), /* TOKEN_BANG */ PREFIX_OPERATOR("!"), /* TOKEN_TILDE */ PREFIX_OPERATOR("~"), /* TOKEN_QUESTION */ INFIX(PREC_ASSIGNMENT, conditional), /* TOKEN_EQ */ UNUSED, /* TOKEN_LT */ INFIX_OPERATOR(PREC_COMPARISON, "<"), /* TOKEN_GT */ INFIX_OPERATOR(PREC_COMPARISON, ">"), /* TOKEN_LTEQ */ INFIX_OPERATOR(PREC_COMPARISON, "<="), /* TOKEN_GTEQ */ INFIX_OPERATOR(PREC_COMPARISON, ">="), /* TOKEN_EQEQ */ INFIX_OPERATOR(PREC_EQUALITY, "=="), /* TOKEN_BANGEQ */ INFIX_OPERATOR(PREC_EQUALITY, "!="), /* TOKEN_BREAK */ UNUSED, /* TOKEN_CLASS */ UNUSED, /* TOKEN_CONSTRUCT */ { NULL, NULL, constructorSignature, PREC_NONE, NULL }, /* TOKEN_ELSE */ UNUSED, /* TOKEN_FALSE */ PREFIX(boolean), /* TOKEN_FOR */ UNUSED, /* TOKEN_FOREIGN */ UNUSED, /* TOKEN_IF */ UNUSED, /* TOKEN_IMPORT */ UNUSED, /* TOKEN_IN */ UNUSED, /* TOKEN_IS */ INFIX_OPERATOR(PREC_IS, "is"), /* TOKEN_NULL */ PREFIX(null), /* TOKEN_RETURN */ UNUSED, /* TOKEN_STATIC */ UNUSED, /* TOKEN_SUPER */ PREFIX(super_), /* TOKEN_THIS */ PREFIX(this_), /* TOKEN_TRUE */ PREFIX(boolean), /* TOKEN_VAR */ UNUSED, /* TOKEN_WHILE */ UNUSED, /* TOKEN_FIELD */ PREFIX(field), /* TOKEN_STATIC_FIELD */ PREFIX(staticField), /* TOKEN_NAME */ { name, NULL, namedSignature, PREC_NONE, NULL }, /* TOKEN_NUMBER */ PREFIX(literal), /* TOKEN_STRING */ PREFIX(literal), /* TOKEN_INTERPOLATION */ PREFIX(stringInterpolation), /* TOKEN_LINE */ UNUSED, /* TOKEN_ERROR */ UNUSED, /* TOKEN_EOF */ UNUSED }; // Gets the [GrammarRule] associated with tokens of [type]. static GrammarRule* getRule(TokenType type) { return &rules[type]; } // The main entrypoint for the top-down operator precedence parser. void parsePrecedence(Compiler* compiler, Precedence precedence) { nextToken(compiler->parser); GrammarFn prefix = rules[compiler->parser->previous.type].prefix; if (prefix == NULL) { error(compiler, "Expected expression."); return; } // Track if the precendence of the surrounding expression is low enough to // allow an assignment inside this one. We can't compile an assignment like // a normal expression because it requires us to handle the LHS specially -- // it needs to be an lvalue, not an rvalue. So, for each of the kinds of // expressions that are valid lvalues -- names, subscripts, fields, etc. -- // we pass in whether or not it appears in a context loose enough to allow // "=". If so, it will parse the "=" itself and handle it appropriately. bool canAssign = precedence <= PREC_CONDITIONAL; prefix(compiler, canAssign); while (precedence <= rules[compiler->parser->current.type].precedence) { nextToken(compiler->parser); GrammarFn infix = rules[compiler->parser->previous.type].infix; infix(compiler, canAssign); } } // Parses an expression. Unlike statements, expressions leave a resulting value // on the stack. void expression(Compiler* compiler) { parsePrecedence(compiler, PREC_LOWEST); } // Returns the number of arguments to the instruction at [ip] in [fn]'s // bytecode. static int getByteCountForArguments(const uint8_t* bytecode, const Value* constants, int ip) { Code instruction = (Code)bytecode[ip]; switch (instruction) { case CODE_NULL: case CODE_FALSE: case CODE_TRUE: case CODE_POP: case CODE_CLOSE_UPVALUE: case CODE_RETURN: case CODE_END: case CODE_LOAD_LOCAL_0: case CODE_LOAD_LOCAL_1: case CODE_LOAD_LOCAL_2: case CODE_LOAD_LOCAL_3: case CODE_LOAD_LOCAL_4: case CODE_LOAD_LOCAL_5: case CODE_LOAD_LOCAL_6: case CODE_LOAD_LOCAL_7: case CODE_LOAD_LOCAL_8: case CODE_CONSTRUCT: case CODE_FOREIGN_CONSTRUCT: case CODE_FOREIGN_CLASS: case CODE_END_MODULE: return 0; case CODE_LOAD_LOCAL: case CODE_STORE_LOCAL: case CODE_LOAD_UPVALUE: case CODE_STORE_UPVALUE: case CODE_LOAD_FIELD_THIS: case CODE_STORE_FIELD_THIS: case CODE_LOAD_FIELD: case CODE_STORE_FIELD: case CODE_CLASS: return 1; case CODE_CONSTANT: case CODE_LOAD_MODULE_VAR: case CODE_STORE_MODULE_VAR: case CODE_CALL_0: case CODE_CALL_1: case CODE_CALL_2: case CODE_CALL_3: case CODE_CALL_4: case CODE_CALL_5: case CODE_CALL_6: case CODE_CALL_7: case CODE_CALL_8: case CODE_CALL_9: case CODE_CALL_10: case CODE_CALL_11: case CODE_CALL_12: case CODE_CALL_13: case CODE_CALL_14: case CODE_CALL_15: case CODE_CALL_16: case CODE_JUMP: case CODE_LOOP: case CODE_JUMP_IF: case CODE_AND: case CODE_OR: case CODE_METHOD_INSTANCE: case CODE_METHOD_STATIC: case CODE_IMPORT_MODULE: case CODE_IMPORT_VARIABLE: return 2; case CODE_SUPER_0: case CODE_SUPER_1: case CODE_SUPER_2: case CODE_SUPER_3: case CODE_SUPER_4: case CODE_SUPER_5: case CODE_SUPER_6: case CODE_SUPER_7: case CODE_SUPER_8: case CODE_SUPER_9: case CODE_SUPER_10: case CODE_SUPER_11: case CODE_SUPER_12: case CODE_SUPER_13: case CODE_SUPER_14: case CODE_SUPER_15: case CODE_SUPER_16: return 4; case CODE_CLOSURE: { int constant = (bytecode[ip + 1] << 8) | bytecode[ip + 2]; ObjFn* loadedFn = AS_FN(constants[constant]); // There are two bytes for the constant, then two for each upvalue. return 2 + (loadedFn->numUpvalues * 2); } } UNREACHABLE(); return 0; } // Marks the beginning of a loop. Keeps track of the current instruction so we // know what to loop back to at the end of the body. static void startLoop(Compiler* compiler, Loop* loop) { loop->enclosing = compiler->loop; loop->start = compiler->fn->code.count - 1; loop->scopeDepth = compiler->scopeDepth; compiler->loop = loop; } // Emits the [CODE_JUMP_IF] instruction used to test the loop condition and // potentially exit the loop. Keeps track of the instruction so we can patch it // later once we know where the end of the body is. static void testExitLoop(Compiler* compiler) { compiler->loop->exitJump = emitJump(compiler, CODE_JUMP_IF); } // Compiles the body of the loop and tracks its extent so that contained "break" // statements can be handled correctly. static void loopBody(Compiler* compiler) { compiler->loop->body = compiler->fn->code.count; statement(compiler); } // Ends the current innermost loop. Patches up all jumps and breaks now that // we know where the end of the loop is. static void endLoop(Compiler* compiler) { // We don't check for overflow here since the forward jump over the loop body // will report an error for the same problem. int loopOffset = compiler->fn->code.count - compiler->loop->start + 2; emitShortArg(compiler, CODE_LOOP, loopOffset); patchJump(compiler, compiler->loop->exitJump); // Find any break placeholder instructions (which will be CODE_END in the // bytecode) and replace them with real jumps. int i = compiler->loop->body; while (i < compiler->fn->code.count) { if (compiler->fn->code.data[i] == CODE_END) { compiler->fn->code.data[i] = CODE_JUMP; patchJump(compiler, i + 1); i += 3; } else { // Skip this instruction and its arguments. i += 1 + getByteCountForArguments(compiler->fn->code.data, compiler->fn->constants.data, i); } } compiler->loop = compiler->loop->enclosing; } static void forStatement(Compiler* compiler) { // A for statement like: // // for (i in sequence.expression) { // System.print(i) // } // // Is compiled to bytecode almost as if the source looked like this: // // { // var seq_ = sequence.expression // var iter_ // while (iter_ = seq_.iterate(iter_)) { // var i = seq_.iteratorValue(iter_) // System.print(i) // } // } // // It's not exactly this, because the synthetic variables `seq_` and `iter_` // actually get names that aren't valid Wren identfiers, but that's the basic // idea. // // The important parts are: // - The sequence expression is only evaluated once. // - The .iterate() method is used to advance the iterator and determine if // it should exit the loop. // - The .iteratorValue() method is used to get the value at the current // iterator position. // Create a scope for the hidden local variables used for the iterator. pushScope(compiler); consume(compiler, TOKEN_LEFT_PAREN, "Expect '(' after 'for'."); consume(compiler, TOKEN_NAME, "Expect for loop variable name."); // Remember the name of the loop variable. const char* name = compiler->parser->previous.start; int length = compiler->parser->previous.length; consume(compiler, TOKEN_IN, "Expect 'in' after loop variable."); ignoreNewlines(compiler); // Evaluate the sequence expression and store it in a hidden local variable. // The space in the variable name ensures it won't collide with a user-defined // variable. expression(compiler); // Verify that there is space to hidden local variables. // Note that we expect only two addLocal calls next to each other in the // following code. if (compiler->numLocals + 2 > MAX_LOCALS) { error(compiler, "Cannot declare more than %d variables in one scope. (Not enough space for for-loops internal variables)", MAX_LOCALS); return; } int seqSlot = addLocal(compiler, "seq ", 4); // Create another hidden local for the iterator object. null(compiler, false); int iterSlot = addLocal(compiler, "iter ", 5); consume(compiler, TOKEN_RIGHT_PAREN, "Expect ')' after loop expression."); Loop loop; startLoop(compiler, &loop); // Advance the iterator by calling the ".iterate" method on the sequence. loadLocal(compiler, seqSlot); loadLocal(compiler, iterSlot); // Update and test the iterator. callMethod(compiler, 1, "iterate(_)", 10); emitByteArg(compiler, CODE_STORE_LOCAL, iterSlot); testExitLoop(compiler); // Get the current value in the sequence by calling ".iteratorValue". loadLocal(compiler, seqSlot); loadLocal(compiler, iterSlot); callMethod(compiler, 1, "iteratorValue(_)", 16); // Bind the loop variable in its own scope. This ensures we get a fresh // variable each iteration so that closures for it don't all see the same one. pushScope(compiler); addLocal(compiler, name, length); loopBody(compiler); // Loop variable. popScope(compiler); endLoop(compiler); // Hidden variables. popScope(compiler); } static void ifStatement(Compiler* compiler) { // Compile the condition. consume(compiler, TOKEN_LEFT_PAREN, "Expect '(' after 'if'."); expression(compiler); consume(compiler, TOKEN_RIGHT_PAREN, "Expect ')' after if condition."); // Jump to the else branch if the condition is false. int ifJump = emitJump(compiler, CODE_JUMP_IF); // Compile the then branch. statement(compiler); // Compile the else branch if there is one. if (match(compiler, TOKEN_ELSE)) { // Jump over the else branch when the if branch is taken. int elseJump = emitJump(compiler, CODE_JUMP); patchJump(compiler, ifJump); statement(compiler); // Patch the jump over the else. patchJump(compiler, elseJump); } else { patchJump(compiler, ifJump); } } static void whileStatement(Compiler* compiler) { Loop loop; startLoop(compiler, &loop); // Compile the condition. consume(compiler, TOKEN_LEFT_PAREN, "Expect '(' after 'while'."); expression(compiler); consume(compiler, TOKEN_RIGHT_PAREN, "Expect ')' after while condition."); testExitLoop(compiler); loopBody(compiler); endLoop(compiler); } // Compiles a simple statement. These can only appear at the top-level or // within curly blocks. Simple statements exclude variable binding statements // like "var" and "class" which are not allowed directly in places like the // branches of an "if" statement. // // Unlike expressions, statements do not leave a value on the stack. void statement(Compiler* compiler) { if (match(compiler, TOKEN_BREAK)) { if (compiler->loop == NULL) { error(compiler, "Cannot use 'break' outside of a loop."); return; } // Since we will be jumping out of the scope, make sure any locals in it // are discarded first. discardLocals(compiler, compiler->loop->scopeDepth + 1); // Emit a placeholder instruction for the jump to the end of the body. When // we're done compiling the loop body and know where the end is, we'll // replace these with `CODE_JUMP` instructions with appropriate offsets. // We use `CODE_END` here because that can't occur in the middle of // bytecode. emitJump(compiler, CODE_END); } else if (match(compiler, TOKEN_FOR)) { forStatement(compiler); } else if (match(compiler, TOKEN_IF)) { ifStatement(compiler); } else if (match(compiler, TOKEN_RETURN)) { // Compile the return value. if (peek(compiler) == TOKEN_LINE) { // Implicitly return null if there is no value. emitOp(compiler, CODE_NULL); } else { expression(compiler); } emitOp(compiler, CODE_RETURN); } else if (match(compiler, TOKEN_WHILE)) { whileStatement(compiler); } else if (match(compiler, TOKEN_LEFT_BRACE)) { // Block statement. pushScope(compiler); if (finishBlock(compiler)) { // Block was an expression, so discard it. emitOp(compiler, CODE_POP); } popScope(compiler); } else { // Expression statement. expression(compiler); emitOp(compiler, CODE_POP); } } // Creates a matching constructor method for an initializer with [signature] // and [initializerSymbol]. // // Construction is a two-stage process in Wren that involves two separate // methods. There is a static method that allocates a new instance of the class. // It then invokes an initializer method on the new instance, forwarding all of // the constructor arguments to it. // // The allocator method always has a fixed implementation: // // CODE_CONSTRUCT - Replace the class in slot 0 with a new instance of it. // CODE_CALL - Invoke the initializer on the new instance. // // This creates that method and calls the initializer with [initializerSymbol]. static void createConstructor(Compiler* compiler, Signature* signature, int initializerSymbol) { Compiler methodCompiler; initCompiler(&methodCompiler, compiler->parser, compiler, true); // Allocate the instance. emitOp(&methodCompiler, compiler->enclosingClass->isForeign ? CODE_FOREIGN_CONSTRUCT : CODE_CONSTRUCT); // Run its initializer. emitShortArg(&methodCompiler, (Code)(CODE_CALL_0 + signature->arity), initializerSymbol); // Return the instance. emitOp(&methodCompiler, CODE_RETURN); endCompiler(&methodCompiler, "", 0); } // Loads the enclosing class onto the stack and then binds the function already // on the stack as a method on that class. static void defineMethod(Compiler* compiler, Variable classVariable, bool isStatic, int methodSymbol) { // Load the class. We have to do this for each method because we can't // keep the class on top of the stack. If there are static fields, they // will be locals above the initial variable slot for the class on the // stack. To skip past those, we just load the class each time right before // defining a method. loadVariable(compiler, classVariable); // Define the method. Code instruction = isStatic ? CODE_METHOD_STATIC : CODE_METHOD_INSTANCE; emitShortArg(compiler, instruction, methodSymbol); } // Declares a method in the enclosing class with [signature]. // // Reports an error if a method with that signature is already declared. // Returns the symbol for the method. static int declareMethod(Compiler* compiler, Signature* signature, const char* name, int length) { int symbol = signatureSymbol(compiler, signature); // See if the class has already declared method with this signature. ClassInfo* classInfo = compiler->enclosingClass; IntBuffer* methods = classInfo->inStatic ? &classInfo->staticMethods : &classInfo->methods; for (int i = 0; i < methods->count; i++) { if (methods->data[i] == symbol) { const char* staticPrefix = classInfo->inStatic ? "static " : ""; error(compiler, "Class %s already defines a %smethod '%s'.", &compiler->enclosingClass->name->value, staticPrefix, name); break; } } wrenIntBufferWrite(compiler->parser->vm, methods, symbol); return symbol; } // Compiles a method definition inside a class body. // // Returns `true` if it compiled successfully, or `false` if the method couldn't // be parsed. static bool method(Compiler* compiler, Variable classVariable) { // TODO: What about foreign constructors? bool isForeign = match(compiler, TOKEN_FOREIGN); bool isStatic = match(compiler, TOKEN_STATIC); compiler->enclosingClass->inStatic = isStatic; SignatureFn signatureFn = rules[compiler->parser->current.type].method; nextToken(compiler->parser); if (signatureFn == NULL) { error(compiler, "Expect method definition."); return false; } // Build the method signature. Signature signature = signatureFromToken(compiler, SIG_GETTER); compiler->enclosingClass->signature = &signature; Compiler methodCompiler; initCompiler(&methodCompiler, compiler->parser, compiler, true); // Compile the method signature. signatureFn(&methodCompiler, &signature); if (isStatic && signature.type == SIG_INITIALIZER) { error(compiler, "A constructor cannot be static."); } // Include the full signature in debug messages in stack traces. char fullSignature[MAX_METHOD_SIGNATURE]; int length; signatureToString(&signature, fullSignature, &length); // Check for duplicate methods. Doesn't matter that it's already been // defined, error will discard bytecode anyway. // Check if the method table already contains this symbol int methodSymbol = declareMethod(compiler, &signature, fullSignature, length); if (isForeign) { // Define a constant for the signature. emitConstant(compiler, wrenNewStringLength(compiler->parser->vm, fullSignature, length)); // We don't need the function we started compiling in the parameter list // any more. methodCompiler.parser->vm->compiler = methodCompiler.parent; } else { consume(compiler, TOKEN_LEFT_BRACE, "Expect '{' to begin method body."); finishBody(&methodCompiler, signature.type == SIG_INITIALIZER); endCompiler(&methodCompiler, fullSignature, length); } // Define the method. For a constructor, this defines the instance // initializer method. defineMethod(compiler, classVariable, isStatic, methodSymbol); if (signature.type == SIG_INITIALIZER) { // Also define a matching constructor method on the metaclass. signature.type = SIG_METHOD; int constructorSymbol = signatureSymbol(compiler, &signature); createConstructor(compiler, &signature, methodSymbol); defineMethod(compiler, classVariable, true, constructorSymbol); } return true; } // Compiles a class definition. Assumes the "class" token has already been // consumed (along with a possibly preceding "foreign" token). static void classDefinition(Compiler* compiler, bool isForeign) { // Create a variable to store the class in. Variable classVariable; classVariable.scope = compiler->scopeDepth == -1 ? SCOPE_MODULE : SCOPE_LOCAL; classVariable.index = declareNamedVariable(compiler); // Create shared class name value Value classNameString = wrenNewStringLength(compiler->parser->vm, compiler->parser->previous.start, compiler->parser->previous.length); // Create class name string to track method duplicates ObjString* className = AS_STRING(classNameString); // Make a string constant for the name. emitConstant(compiler, classNameString); // Load the superclass (if there is one). if (match(compiler, TOKEN_IS)) { parsePrecedence(compiler, PREC_CALL); } else { // Implicitly inherit from Object. loadCoreVariable(compiler, "Object"); } // Store a placeholder for the number of fields argument. We don't know the // count until we've compiled all the methods to see which fields are used. int numFieldsInstruction = -1; if (isForeign) { emitOp(compiler, CODE_FOREIGN_CLASS); } else { numFieldsInstruction = emitByteArg(compiler, CODE_CLASS, 255); } // Store it in its name. defineVariable(compiler, classVariable.index); // Push a local variable scope. Static fields in a class body are hoisted out // into local variables declared in this scope. Methods that use them will // have upvalues referencing them. pushScope(compiler); ClassInfo classInfo; classInfo.isForeign = isForeign; classInfo.name = className; // Set up a symbol table for the class's fields. We'll initially compile // them to slots starting at zero. When the method is bound to the class, the // bytecode will be adjusted by [wrenBindMethod] to take inherited fields // into account. wrenSymbolTableInit(&classInfo.fields); // Set up symbol buffers to track duplicate static and instance methods. wrenIntBufferInit(&classInfo.methods); wrenIntBufferInit(&classInfo.staticMethods); compiler->enclosingClass = &classInfo; // Compile the method definitions. consume(compiler, TOKEN_LEFT_BRACE, "Expect '{' after class declaration."); matchLine(compiler); while (!match(compiler, TOKEN_RIGHT_BRACE)) { if (!method(compiler, classVariable)) break; // Don't require a newline after the last definition. if (match(compiler, TOKEN_RIGHT_BRACE)) break; consumeLine(compiler, "Expect newline after definition in class."); } // Update the class with the number of fields. if (!isForeign) { compiler->fn->code.data[numFieldsInstruction] = (uint8_t)classInfo.fields.count; } // Clear symbol tables for tracking field and method names. wrenSymbolTableClear(compiler->parser->vm, &classInfo.fields); wrenIntBufferClear(compiler->parser->vm, &classInfo.methods); wrenIntBufferClear(compiler->parser->vm, &classInfo.staticMethods); compiler->enclosingClass = NULL; popScope(compiler); } // Compiles an "import" statement. // // An import compiles to a series of instructions. Given: // // import "foo" for Bar, Baz // // We compile a single IMPORT_MODULE "foo" instruction to load the module // itself. When that finishes executing the imported module, it leaves the // ObjModule in vm->lastModule. Then, for Bar and Baz, we: // // * Declare a variable in the current scope with that name. // * Emit an IMPORT_VARIABLE instruction to load the variable's value from the // other module. // * Compile the code to store that value in the variable in this scope. static void import(Compiler* compiler) { ignoreNewlines(compiler); consume(compiler, TOKEN_STRING, "Expect a string after 'import'."); int moduleConstant = addConstant(compiler, compiler->parser->previous.value); // Load the module. emitShortArg(compiler, CODE_IMPORT_MODULE, moduleConstant); // Discard the unused result value from calling the module body's closure. emitOp(compiler, CODE_POP); // The for clause is optional. if (!match(compiler, TOKEN_FOR)) return; // Compile the comma-separated list of variables to import. do { ignoreNewlines(compiler); int slot = declareNamedVariable(compiler); // Define a string constant for the variable name. int variableConstant = addConstant(compiler, wrenNewStringLength(compiler->parser->vm, compiler->parser->previous.start, compiler->parser->previous.length)); // Load the variable from the other module. emitShortArg(compiler, CODE_IMPORT_VARIABLE, variableConstant); // Store the result in the variable here. defineVariable(compiler, slot); } while (match(compiler, TOKEN_COMMA)); } // Compiles a "var" variable definition statement. static void variableDefinition(Compiler* compiler) { // Grab its name, but don't declare it yet. A (local) variable shouldn't be // in scope in its own initializer. consume(compiler, TOKEN_NAME, "Expect variable name."); Token nameToken = compiler->parser->previous; // Compile the initializer. if (match(compiler, TOKEN_EQ)) { ignoreNewlines(compiler); expression(compiler); } else { // Default initialize it to null. null(compiler, false); } // Now put it in scope. int symbol = declareVariable(compiler, &nameToken); defineVariable(compiler, symbol); } // Compiles a "definition". These are the statements that bind new variables. // They can only appear at the top level of a block and are prohibited in places // like the non-curly body of an if or while. void definition(Compiler* compiler) { if (match(compiler, TOKEN_CLASS)) { classDefinition(compiler, false); } else if (match(compiler, TOKEN_FOREIGN)) { consume(compiler, TOKEN_CLASS, "Expect 'class' after 'foreign'."); classDefinition(compiler, true); } else if (match(compiler, TOKEN_IMPORT)) { import(compiler); } else if (match(compiler, TOKEN_VAR)) { variableDefinition(compiler); } else { statement(compiler); } } ObjFn* wrenCompile(WrenVM* vm, ObjModule* module, const char* source, bool isExpression, bool printErrors) { // Skip the UTF-8 BOM if there is one. if (strncmp(source, "\xEF\xBB\xBF", 3) == 0) source += 3; Parser parser; parser.vm = vm; parser.module = module; parser.source = source; parser.tokenStart = source; parser.currentChar = source; parser.currentLine = 1; parser.numParens = 0; // Zero-init the current token. This will get copied to previous when // advance() is called below. parser.current.type = TOKEN_ERROR; parser.current.start = source; parser.current.length = 0; parser.current.line = 0; parser.current.value = UNDEFINED_VAL; // Ignore leading newlines. parser.skipNewlines = true; parser.printErrors = printErrors; parser.hasError = false; // Read the first token. nextToken(&parser); int numExistingVariables = module->variables.count; Compiler compiler; initCompiler(&compiler, &parser, NULL, false); ignoreNewlines(&compiler); if (isExpression) { expression(&compiler); consume(&compiler, TOKEN_EOF, "Expect end of expression."); } else { while (!match(&compiler, TOKEN_EOF)) { definition(&compiler); // If there is no newline, it must be the end of file on the same line. if (!matchLine(&compiler)) { consume(&compiler, TOKEN_EOF, "Expect end of file."); break; } } emitOp(&compiler, CODE_END_MODULE); } emitOp(&compiler, CODE_RETURN); // See if there are any implicitly declared module-level variables that never // got an explicit definition. They will have values that are numbers // indicating the line where the variable was first used. for (int i = numExistingVariables; i < parser.module->variables.count; i++) { if (IS_NUM(parser.module->variables.data[i])) { // Synthesize a token for the original use site. parser.previous.type = TOKEN_NAME; parser.previous.start = parser.module->variableNames.data[i]->value; parser.previous.length = parser.module->variableNames.data[i]->length; parser.previous.line = (int)AS_NUM(parser.module->variables.data[i]); error(&compiler, "Variable is used but not defined."); } } return endCompiler(&compiler, "(script)", 8); } void wrenBindMethodCode(ObjClass* classObj, ObjFn* fn) { int ip = 0; for (;;) { Code instruction = (Code)fn->code.data[ip]; switch (instruction) { case CODE_LOAD_FIELD: case CODE_STORE_FIELD: case CODE_LOAD_FIELD_THIS: case CODE_STORE_FIELD_THIS: // Shift this class's fields down past the inherited ones. We don't // check for overflow here because we'll see if the number of fields // overflows when the subclass is created. fn->code.data[ip + 1] += classObj->superclass->numFields; break; case CODE_SUPER_0: case CODE_SUPER_1: case CODE_SUPER_2: case CODE_SUPER_3: case CODE_SUPER_4: case CODE_SUPER_5: case CODE_SUPER_6: case CODE_SUPER_7: case CODE_SUPER_8: case CODE_SUPER_9: case CODE_SUPER_10: case CODE_SUPER_11: case CODE_SUPER_12: case CODE_SUPER_13: case CODE_SUPER_14: case CODE_SUPER_15: case CODE_SUPER_16: { // Fill in the constant slot with a reference to the superclass. int constant = (fn->code.data[ip + 3] << 8) | fn->code.data[ip + 4]; fn->constants.data[constant] = OBJ_VAL(classObj->superclass); break; } case CODE_CLOSURE: { // Bind the nested closure too. int constant = (fn->code.data[ip + 1] << 8) | fn->code.data[ip + 2]; wrenBindMethodCode(classObj, AS_FN(fn->constants.data[constant])); break; } case CODE_END: return; default: // Other instructions are unaffected, so just skip over them. break; } ip += 1 + getByteCountForArguments(fn->code.data, fn->constants.data, ip); } } void wrenMarkCompiler(WrenVM* vm, Compiler* compiler) { wrenGrayValue(vm, compiler->parser->current.value); wrenGrayValue(vm, compiler->parser->previous.value); // Walk up the parent chain to mark the outer compilers too. The VM only // tracks the innermost one. do { wrenGrayObj(vm, (Obj*)compiler->fn); wrenGrayObj(vm, (Obj*)compiler->constants); if (compiler->enclosingClass != NULL) { wrenBlackenSymbolTable(vm, &compiler->enclosingClass->fields); } compiler = compiler->parent; } while (compiler != NULL); } // End file "wren_compiler.c" // Begin file "wren_value.c" #include <math.h> #include <stdarg.h> #include <stdio.h> #include <string.h> #if WREN_DEBUG_TRACE_MEMORY #endif // TODO: Tune these. // The initial (and minimum) capacity of a non-empty list or map object. #define MIN_CAPACITY 16 // The rate at which a collection's capacity grows when the size exceeds the // current capacity. The new capacity will be determined by *multiplying* the // old capacity by this. Growing geometrically is necessary to ensure that // adding to a collection has O(1) amortized complexity. #define GROW_FACTOR 2 // The maximum percentage of map entries that can be filled before the map is // grown. A lower load takes more memory but reduces collisions which makes // lookup faster. #define MAP_LOAD_PERCENT 75 // The number of call frames initially allocated when a fiber is created. Making // this smaller makes fibers use less memory (at first) but spends more time // reallocating when the call stack grows. #define INITIAL_CALL_FRAMES 4 DEFINE_BUFFER(Value, Value); DEFINE_BUFFER(Method, Method); static void initObj(WrenVM* vm, Obj* obj, ObjType type, ObjClass* classObj) { obj->type = type; obj->isDark = false; obj->classObj = classObj; obj->next = vm->first; vm->first = obj; } ObjClass* wrenNewSingleClass(WrenVM* vm, int numFields, ObjString* name) { ObjClass* classObj = ALLOCATE(vm, ObjClass); initObj(vm, &classObj->obj, OBJ_CLASS, NULL); classObj->superclass = NULL; classObj->numFields = numFields; classObj->name = name; wrenPushRoot(vm, (Obj*)classObj); wrenMethodBufferInit(&classObj->methods); wrenPopRoot(vm); return classObj; } void wrenBindSuperclass(WrenVM* vm, ObjClass* subclass, ObjClass* superclass) { ASSERT(superclass != NULL, "Must have superclass."); subclass->superclass = superclass; // Include the superclass in the total number of fields. if (subclass->numFields != -1) { subclass->numFields += superclass->numFields; } else { ASSERT(superclass->numFields == 0, "A foreign class cannot inherit from a class with fields."); } // Inherit methods from its superclass. for (int i = 0; i < superclass->methods.count; i++) { wrenBindMethod(vm, subclass, i, superclass->methods.data[i]); } } ObjClass* wrenNewClass(WrenVM* vm, ObjClass* superclass, int numFields, ObjString* name) { // Create the metaclass. Value metaclassName = wrenStringFormat(vm, "@ metaclass", OBJ_VAL(name)); wrenPushRoot(vm, AS_OBJ(metaclassName)); ObjClass* metaclass = wrenNewSingleClass(vm, 0, AS_STRING(metaclassName)); metaclass->obj.classObj = vm->classClass; wrenPopRoot(vm); // Make sure the metaclass isn't collected when we allocate the class. wrenPushRoot(vm, (Obj*)metaclass); // Metaclasses always inherit Class and do not parallel the non-metaclass // hierarchy. wrenBindSuperclass(vm, metaclass, vm->classClass); ObjClass* classObj = wrenNewSingleClass(vm, numFields, name); // Make sure the class isn't collected while the inherited methods are being // bound. wrenPushRoot(vm, (Obj*)classObj); classObj->obj.classObj = metaclass; wrenBindSuperclass(vm, classObj, superclass); wrenPopRoot(vm); wrenPopRoot(vm); return classObj; } void wrenBindMethod(WrenVM* vm, ObjClass* classObj, int symbol, Method method) { // Make sure the buffer is big enough to contain the symbol's index. if (symbol >= classObj->methods.count) { Method noMethod; noMethod.type = METHOD_NONE; wrenMethodBufferFill(vm, &classObj->methods, noMethod, symbol - classObj->methods.count + 1); } classObj->methods.data[symbol] = method; } ObjClosure* wrenNewClosure(WrenVM* vm, ObjFn* fn) { ObjClosure* closure = ALLOCATE_FLEX(vm, ObjClosure, ObjUpvalue*, fn->numUpvalues); initObj(vm, &closure->obj, OBJ_CLOSURE, vm->fnClass); closure->fn = fn; // Clear the upvalue array. We need to do this in case a GC is triggered // after the closure is created but before the upvalue array is populated. for (int i = 0; i < fn->numUpvalues; i++) closure->upvalues[i] = NULL; return closure; } ObjFiber* wrenNewFiber(WrenVM* vm, ObjClosure* closure) { // Allocate the arrays before the fiber in case it triggers a GC. CallFrame* frames = ALLOCATE_ARRAY(vm, CallFrame, INITIAL_CALL_FRAMES); // Add one slot for the unused implicit receiver slot that the compiler // assumes all functions have. int stackCapacity = closure == NULL ? 1 : wrenPowerOf2Ceil(closure->fn->maxSlots + 1); Value* stack = ALLOCATE_ARRAY(vm, Value, stackCapacity); ObjFiber* fiber = ALLOCATE(vm, ObjFiber); initObj(vm, &fiber->obj, OBJ_FIBER, vm->fiberClass); fiber->stack = stack; fiber->stackTop = fiber->stack; fiber->stackCapacity = stackCapacity; fiber->frames = frames; fiber->frameCapacity = INITIAL_CALL_FRAMES; fiber->numFrames = 0; fiber->openUpvalues = NULL; fiber->caller = NULL; fiber->error = NULL_VAL; fiber->state = FIBER_OTHER; if (closure != NULL) { // Initialize the first call frame. wrenAppendCallFrame(vm, fiber, closure, fiber->stack); // The first slot always holds the closure. fiber->stackTop[0] = OBJ_VAL(closure); fiber->stackTop++; } return fiber; } void wrenEnsureStack(WrenVM* vm, ObjFiber* fiber, int needed) { if (fiber->stackCapacity >= needed) return; int capacity = wrenPowerOf2Ceil(needed); Value* oldStack = fiber->stack; fiber->stack = (Value*)wrenReallocate(vm, fiber->stack, sizeof(Value) * fiber->stackCapacity, sizeof(Value) * capacity); fiber->stackCapacity = capacity; // If the reallocation moves the stack, then we need to recalculate every // pointer that points into the old stack to into the same relative distance // in the new stack. We have to be a little careful about how these are // calculated because pointer subtraction is only well-defined within a // single array, hence the slightly redundant-looking arithmetic below. if (fiber->stack != oldStack) { // Top of the stack. if (vm->apiStack >= oldStack && vm->apiStack <= fiber->stackTop) { vm->apiStack = fiber->stack + (vm->apiStack - oldStack); } // Stack pointer for each call frame. for (int i = 0; i < fiber->numFrames; i++) { CallFrame* frame = &fiber->frames[i]; frame->stackStart = fiber->stack + (frame->stackStart - oldStack); } // Open upvalues. for (ObjUpvalue* upvalue = fiber->openUpvalues; upvalue != NULL; upvalue = upvalue->next) { upvalue->value = fiber->stack + (upvalue->value - oldStack); } fiber->stackTop = fiber->stack + (fiber->stackTop - oldStack); } } ObjForeign* wrenNewForeign(WrenVM* vm, ObjClass* classObj, size_t size) { ObjForeign* object = ALLOCATE_FLEX(vm, ObjForeign, uint8_t, size); initObj(vm, &object->obj, OBJ_FOREIGN, classObj); // Zero out the bytes. memset(object->data, 0, size); return object; } ObjFn* wrenNewFunction(WrenVM* vm, ObjModule* module, int maxSlots) { FnDebug* debug = ALLOCATE(vm, FnDebug); debug->name = NULL; wrenIntBufferInit(&debug->sourceLines); ObjFn* fn = ALLOCATE(vm, ObjFn); initObj(vm, &fn->obj, OBJ_FN, vm->fnClass); wrenValueBufferInit(&fn->constants); wrenByteBufferInit(&fn->code); fn->module = module; fn->maxSlots = maxSlots; fn->numUpvalues = 0; fn->arity = 0; fn->debug = debug; return fn; } void wrenFunctionBindName(WrenVM* vm, ObjFn* fn, const char* name, int length) { fn->debug->name = ALLOCATE_ARRAY(vm, char, length + 1); memcpy(fn->debug->name, name, length); fn->debug->name[length] = '\0'; } Value wrenNewInstance(WrenVM* vm, ObjClass* classObj) { ObjInstance* instance = ALLOCATE_FLEX(vm, ObjInstance, Value, classObj->numFields); initObj(vm, &instance->obj, OBJ_INSTANCE, classObj); // Initialize fields to null. for (int i = 0; i < classObj->numFields; i++) { instance->fields[i] = NULL_VAL; } return OBJ_VAL(instance); } ObjList* wrenNewList(WrenVM* vm, uint32_t numElements) { // Allocate this before the list object in case it triggers a GC which would // free the list. Value* elements = NULL; if (numElements > 0) { elements = ALLOCATE_ARRAY(vm, Value, numElements); } ObjList* list = ALLOCATE(vm, ObjList); initObj(vm, &list->obj, OBJ_LIST, vm->listClass); list->elements.capacity = numElements; list->elements.count = numElements; list->elements.data = elements; return list; } void wrenListInsert(WrenVM* vm, ObjList* list, Value value, uint32_t index) { if (IS_OBJ(value)) wrenPushRoot(vm, AS_OBJ(value)); // Add a slot at the end of the list. wrenValueBufferWrite(vm, &list->elements, NULL_VAL); if (IS_OBJ(value)) wrenPopRoot(vm); // Shift the existing elements down. for (uint32_t i = list->elements.count - 1; i > index; i--) { list->elements.data[i] = list->elements.data[i - 1]; } // Store the new element. list->elements.data[index] = value; } Value wrenListRemoveAt(WrenVM* vm, ObjList* list, uint32_t index) { Value removed = list->elements.data[index]; if (IS_OBJ(removed)) wrenPushRoot(vm, AS_OBJ(removed)); // Shift items up. for (int i = index; i < list->elements.count - 1; i++) { list->elements.data[i] = list->elements.data[i + 1]; } // If we have too much excess capacity, shrink it. if (list->elements.capacity / GROW_FACTOR >= list->elements.count) { list->elements.data = (Value*)wrenReallocate(vm, list->elements.data, sizeof(Value) * list->elements.capacity, sizeof(Value) * (list->elements.capacity / GROW_FACTOR)); list->elements.capacity /= GROW_FACTOR; } if (IS_OBJ(removed)) wrenPopRoot(vm); list->elements.count--; return removed; } ObjMap* wrenNewMap(WrenVM* vm) { ObjMap* map = ALLOCATE(vm, ObjMap); initObj(vm, &map->obj, OBJ_MAP, vm->mapClass); map->capacity = 0; map->count = 0; map->entries = NULL; return map; } static inline uint32_t hashBits(uint64_t hash) { // From v8's ComputeLongHash() which in turn cites: // Thomas Wang, Integer Hash Functions. // http://www.concentric.net/~Ttwang/tech/inthash.htm hash = ~hash + (hash << 18); // hash = (hash << 18) - hash - 1; hash = hash ^ (hash >> 31); hash = hash * 21; // hash = (hash + (hash << 2)) + (hash << 4); hash = hash ^ (hash >> 11); hash = hash + (hash << 6); hash = hash ^ (hash >> 22); return (uint32_t)(hash & 0x3fffffff); } // Generates a hash code for [num]. static inline uint32_t hashNumber(double num) { // Hash the raw bits of the value. DoubleBits bits; bits.num = num; return hashBits(bits.bits64); } // Generates a hash code for [object]. static uint32_t hashObject(Obj* object) { switch (object->type) { case OBJ_CLASS: // Classes just use their name. return hashObject((Obj*)((ObjClass*)object)->name); // Allow bare (non-closure) functions so that we can use a map to find // existing constants in a function's constant table. This is only used // internally. Since user code never sees a non-closure function, they // cannot use them as map keys. case OBJ_FN: { ObjFn* fn = (ObjFn*)object; return hashNumber(fn->arity) ^ hashNumber(fn->code.count); } case OBJ_RANGE: { ObjRange* range = (ObjRange*)object; return hashNumber(range->from) ^ hashNumber(range->to); } case OBJ_STRING: return ((ObjString*)object)->hash; default: ASSERT(false, "Only immutable objects can be hashed."); return 0; } } // Generates a hash code for [value], which must be one of the built-in // immutable types: null, bool, class, num, range, or string. static uint32_t hashValue(Value value) { // TODO: We'll probably want to randomize this at some point. #if WREN_NAN_TAGGING if (IS_OBJ(value)) return hashObject(AS_OBJ(value)); // Hash the raw bits of the unboxed value. return hashBits(value); #else switch (value.type) { case VAL_FALSE: return 0; case VAL_NULL: return 1; case VAL_NUM: return hashNumber(AS_NUM(value)); case VAL_TRUE: return 2; case VAL_OBJ: return hashObject(AS_OBJ(value)); default: UNREACHABLE(); } return 0; #endif } // Looks for an entry with [key] in an array of [capacity] [entries]. // // If found, sets [result] to point to it and returns `true`. Otherwise, // returns `false` and points [result] to the entry where the key/value pair // should be inserted. static bool findEntry(MapEntry* entries, uint32_t capacity, Value key, MapEntry** result) { // If there is no entry array (an empty map), we definitely won't find it. if (capacity == 0) return false; // Figure out where to insert it in the table. Use open addressing and // basic linear probing. uint32_t startIndex = hashValue(key) % capacity; uint32_t index = startIndex; // If we pass a tombstone and don't end up finding the key, its entry will // be re-used for the insert. MapEntry* tombstone = NULL; // Walk the probe sequence until we've tried every slot. do { MapEntry* entry = &entries[index]; if (IS_UNDEFINED(entry->key)) { // If we found an empty slot, the key is not in the table. If we found a // slot that contains a deleted key, we have to keep looking. if (IS_FALSE(entry->value)) { // We found an empty slot, so we've reached the end of the probe // sequence without finding the key. If we passed a tombstone, then // that's where we should insert the item, otherwise, put it here at // the end of the sequence. *result = tombstone != NULL ? tombstone : entry; return false; } else { // We found a tombstone. We need to keep looking in case the key is // after it, but we'll use this entry as the insertion point if the // key ends up not being found. if (tombstone == NULL) tombstone = entry; } } else if (wrenValuesEqual(entry->key, key)) { // We found the key. *result = entry; return true; } // Try the next slot. index = (index + 1) % capacity; } while (index != startIndex); // If we get here, the table is full of tombstones. Return the first one we // found. ASSERT(tombstone != NULL, "Map should have tombstones or empty entries."); *result = tombstone; return false; } // Inserts [key] and [value] in the array of [entries] with the given // [capacity]. // // Returns `true` if this is the first time [key] was added to the map. static bool insertEntry(MapEntry* entries, uint32_t capacity, Value key, Value value) { ASSERT(entries != NULL, "Should ensure capacity before inserting."); MapEntry* entry; if (findEntry(entries, capacity, key, &entry)) { // Already present, so just replace the value. entry->value = value; return false; } else { entry->key = key; entry->value = value; return true; } } // Updates [map]'s entry array to [capacity]. static void resizeMap(WrenVM* vm, ObjMap* map, uint32_t capacity) { // Create the new empty hash table. MapEntry* entries = ALLOCATE_ARRAY(vm, MapEntry, capacity); for (uint32_t i = 0; i < capacity; i++) { entries[i].key = UNDEFINED_VAL; entries[i].value = FALSE_VAL; } // Re-add the existing entries. if (map->capacity > 0) { for (uint32_t i = 0; i < map->capacity; i++) { MapEntry* entry = &map->entries[i]; // Don't copy empty entries or tombstones. if (IS_UNDEFINED(entry->key)) continue; insertEntry(entries, capacity, entry->key, entry->value); } } // Replace the array. DEALLOCATE(vm, map->entries); map->entries = entries; map->capacity = capacity; } Value wrenMapGet(ObjMap* map, Value key) { MapEntry* entry; if (findEntry(map->entries, map->capacity, key, &entry)) return entry->value; return UNDEFINED_VAL; } void wrenMapSet(WrenVM* vm, ObjMap* map, Value key, Value value) { // If the map is getting too full, make room first. if (map->count + 1 > map->capacity * MAP_LOAD_PERCENT / 100) { // Figure out the new hash table size. uint32_t capacity = map->capacity * GROW_FACTOR; if (capacity < MIN_CAPACITY) capacity = MIN_CAPACITY; resizeMap(vm, map, capacity); } if (insertEntry(map->entries, map->capacity, key, value)) { // A new key was added. map->count++; } } void wrenMapClear(WrenVM* vm, ObjMap* map) { DEALLOCATE(vm, map->entries); map->entries = NULL; map->capacity = 0; map->count = 0; } Value wrenMapRemoveKey(WrenVM* vm, ObjMap* map, Value key) { MapEntry* entry; if (!findEntry(map->entries, map->capacity, key, &entry)) return NULL_VAL; // Remove the entry from the map. Set this value to true, which marks it as a // deleted slot. When searching for a key, we will stop on empty slots, but // continue past deleted slots. Value value = entry->value; entry->key = UNDEFINED_VAL; entry->value = TRUE_VAL; if (IS_OBJ(value)) wrenPushRoot(vm, AS_OBJ(value)); map->count--; if (map->count == 0) { // Removed the last item, so free the array. wrenMapClear(vm, map); } else if (map->capacity > MIN_CAPACITY && map->count < map->capacity / GROW_FACTOR * MAP_LOAD_PERCENT / 100) { uint32_t capacity = map->capacity / GROW_FACTOR; if (capacity < MIN_CAPACITY) capacity = MIN_CAPACITY; // The map is getting empty, so shrink the entry array back down. // TODO: Should we do this less aggressively than we grow? resizeMap(vm, map, capacity); } if (IS_OBJ(value)) wrenPopRoot(vm); return value; } ObjModule* wrenNewModule(WrenVM* vm, ObjString* name) { ObjModule* module = ALLOCATE(vm, ObjModule); // Modules are never used as first-class objects, so don't need a class. initObj(vm, (Obj*)module, OBJ_MODULE, NULL); wrenPushRoot(vm, (Obj*)module); wrenSymbolTableInit(&module->variableNames); wrenValueBufferInit(&module->variables); module->name = name; wrenPopRoot(vm); return module; } Value wrenNewRange(WrenVM* vm, double from, double to, bool isInclusive) { ObjRange* range = ALLOCATE(vm, ObjRange); initObj(vm, &range->obj, OBJ_RANGE, vm->rangeClass); range->from = from; range->to = to; range->isInclusive = isInclusive; return OBJ_VAL(range); } // Creates a new string object with a null-terminated buffer large enough to // hold a string of [length] but does not fill in the bytes. // // The caller is expected to fill in the buffer and then calculate the string's // hash. static ObjString* allocateString(WrenVM* vm, size_t length) { ObjString* string = ALLOCATE_FLEX(vm, ObjString, char, length + 1); initObj(vm, &string->obj, OBJ_STRING, vm->stringClass); string->length = (int)length; string->value[length] = '\0'; return string; } // Calculates and stores the hash code for [string]. static void hashString(ObjString* string) { // FNV-1a hash. See: http://www.isthe.com/chongo/tech/comp/fnv/ uint32_t hash = 2166136261u; // This is O(n) on the length of the string, but we only call this when a new // string is created. Since the creation is also O(n) (to copy/initialize all // the bytes), we allow this here. for (uint32_t i = 0; i < string->length; i++) { hash ^= string->value[i]; hash *= 16777619; } string->hash = hash; } Value wrenNewString(WrenVM* vm, const char* text) { return wrenNewStringLength(vm, text, strlen(text)); } Value wrenNewStringLength(WrenVM* vm, const char* text, size_t length) { // Allow NULL if the string is empty since byte buffers don't allocate any // characters for a zero-length string. ASSERT(length == 0 || text != NULL, "Unexpected NULL string."); ObjString* string = allocateString(vm, length); // Copy the string (if given one). if (length > 0 && text != NULL) memcpy(string->value, text, length); hashString(string); return OBJ_VAL(string); } Value wrenNewStringFromRange(WrenVM* vm, ObjString* source, int start, uint32_t count, int step) { uint8_t* from = (uint8_t*)source->value; int length = 0; for (uint32_t i = 0; i < count; i++) { length += wrenUtf8DecodeNumBytes(from[start + i * step]); } ObjString* result = allocateString(vm, length); result->value[length] = '\0'; uint8_t* to = (uint8_t*)result->value; for (uint32_t i = 0; i < count; i++) { int index = start + i * step; int codePoint = wrenUtf8Decode(from + index, source->length - index); if (codePoint != -1) { to += wrenUtf8Encode(codePoint, to); } } hashString(result); return OBJ_VAL(result); } Value wrenNumToString(WrenVM* vm, double value) { // Edge case: If the value is NaN or infinity, different versions of libc // produce different outputs (some will format it signed and some won't). To // get reliable output, handle it ourselves. if (isnan(value)) return CONST_STRING(vm, "nan"); if (isinf(value)) { if (value > 0.0) { return CONST_STRING(vm, "infinity"); } else { return CONST_STRING(vm, "-infinity"); } } // This is large enough to hold any double converted to a string using // "%.14g". Example: // // -1.12345678901234e-1022 // // So we have: // // + 1 char for sign // + 1 char for digit // + 1 char for "." // + 14 chars for decimal digits // + 1 char for "e" // + 1 char for "-" or "+" // + 4 chars for exponent // + 1 char for "\0" // = 24 char buffer[24]; int length = sprintf(buffer, "%.14g", value); return wrenNewStringLength(vm, buffer, length); } Value wrenStringFromCodePoint(WrenVM* vm, int value) { int length = wrenUtf8EncodeNumBytes(value); ASSERT(length != 0, "Value out of range."); ObjString* string = allocateString(vm, length); wrenUtf8Encode(value, (uint8_t*)string->value); hashString(string); return OBJ_VAL(string); } Value wrenStringFromByte(WrenVM *vm, uint8_t value) { int length = 1; ObjString* string = allocateString(vm, length); string->value[0] = value; hashString(string); return OBJ_VAL(string); } Value wrenStringFormat(WrenVM* vm, const char* format, ...) { va_list argList; // Calculate the length of the result string. Do this up front so we can // create the final string with a single allocation. va_start(argList, format); size_t totalLength = 0; for (const char* c = format; *c != '\0'; c++) { switch (*c) { case '$': totalLength += strlen(va_arg(argList, const char*)); break; case '@': totalLength += AS_STRING(va_arg(argList, Value))->length; break; default: // Any other character is interpreted literally. totalLength++; } } va_end(argList); // Concatenate the string. ObjString* result = allocateString(vm, totalLength); va_start(argList, format); char* start = result->value; for (const char* c = format; *c != '\0'; c++) { switch (*c) { case '$': { const char* string = va_arg(argList, const char*); size_t length = strlen(string); memcpy(start, string, length); start += length; break; } case '@': { ObjString* string = AS_STRING(va_arg(argList, Value)); memcpy(start, string->value, string->length); start += string->length; break; } default: // Any other character is interpreted literally. *start++ = *c; } } va_end(argList); hashString(result); return OBJ_VAL(result); } Value wrenStringCodePointAt(WrenVM* vm, ObjString* string, uint32_t index) { ASSERT(index < string->length, "Index out of bounds."); int codePoint = wrenUtf8Decode((uint8_t*)string->value + index, string->length - index); if (codePoint == -1) { // If it isn't a valid UTF-8 sequence, treat it as a single raw byte. char bytes[2]; bytes[0] = string->value[index]; bytes[1] = '\0'; return wrenNewStringLength(vm, bytes, 1); } return wrenStringFromCodePoint(vm, codePoint); } // Uses the Boyer-Moore-Horspool string matching algorithm. uint32_t wrenStringFind(ObjString* haystack, ObjString* needle, uint32_t start) { // Edge case: An empty needle is always found. if (needle->length == 0) return start; // If the needle goes past the haystack it won't be found. if (start + needle->length > haystack->length) return UINT32_MAX; // If the startIndex is too far it also won't be found. if (start >= haystack->length) return UINT32_MAX; // Pre-calculate the shift table. For each character (8-bit value), we // determine how far the search window can be advanced if that character is // the last character in the haystack where we are searching for the needle // and the needle doesn't match there. uint32_t shift[UINT8_MAX]; uint32_t needleEnd = needle->length - 1; // By default, we assume the character is not the needle at all. In that case // case, if a match fails on that character, we can advance one whole needle // width since. for (uint32_t index = 0; index < UINT8_MAX; index++) { shift[index] = needle->length; } // Then, for every character in the needle, determine how far it is from the // end. If a match fails on that character, we can advance the window such // that it the last character in it lines up with the last place we could // find it in the needle. for (uint32_t index = 0; index < needleEnd; index++) { char c = needle->value[index]; shift[(uint8_t)c] = needleEnd - index; } // Slide the needle across the haystack, looking for the first match or // stopping if the needle goes off the end. char lastChar = needle->value[needleEnd]; uint32_t range = haystack->length - needle->length; for (uint32_t index = start; index <= range; ) { // Compare the last character in the haystack's window to the last character // in the needle. If it matches, see if the whole needle matches. char c = haystack->value[index + needleEnd]; if (lastChar == c && memcmp(haystack->value + index, needle->value, needleEnd) == 0) { // Found a match. return index; } // Otherwise, slide the needle forward. index += shift[(uint8_t)c]; } // Not found. return UINT32_MAX; } ObjUpvalue* wrenNewUpvalue(WrenVM* vm, Value* value) { ObjUpvalue* upvalue = ALLOCATE(vm, ObjUpvalue); // Upvalues are never used as first-class objects, so don't need a class. initObj(vm, &upvalue->obj, OBJ_UPVALUE, NULL); upvalue->value = value; upvalue->closed = NULL_VAL; upvalue->next = NULL; return upvalue; } void wrenGrayObj(WrenVM* vm, Obj* obj) { if (obj == NULL) return; // Stop if the object is already darkened so we don't get stuck in a cycle. if (obj->isDark) return; // It's been reached. obj->isDark = true; // Add it to the gray list so it can be recursively explored for // more marks later. if (vm->grayCount >= vm->grayCapacity) { vm->grayCapacity = vm->grayCount * 2; vm->gray = (Obj**)vm->config.reallocateFn(vm->gray, vm->grayCapacity * sizeof(Obj*)); } vm->gray[vm->grayCount++] = obj; } void wrenGrayValue(WrenVM* vm, Value value) { if (!IS_OBJ(value)) return; wrenGrayObj(vm, AS_OBJ(value)); } void wrenGrayBuffer(WrenVM* vm, ValueBuffer* buffer) { for (int i = 0; i < buffer->count; i++) { wrenGrayValue(vm, buffer->data[i]); } } static void blackenClass(WrenVM* vm, ObjClass* classObj) { // The metaclass. wrenGrayObj(vm, (Obj*)classObj->obj.classObj); // The superclass. wrenGrayObj(vm, (Obj*)classObj->superclass); // Method function objects. for (int i = 0; i < classObj->methods.count; i++) { if (classObj->methods.data[i].type == METHOD_BLOCK) { wrenGrayObj(vm, (Obj*)classObj->methods.data[i].as.closure); } } wrenGrayObj(vm, (Obj*)classObj->name); // Keep track of how much memory is still in use. vm->bytesAllocated += sizeof(ObjClass); vm->bytesAllocated += classObj->methods.capacity * sizeof(Method); } static void blackenClosure(WrenVM* vm, ObjClosure* closure) { // Mark the function. wrenGrayObj(vm, (Obj*)closure->fn); // Mark the upvalues. for (int i = 0; i < closure->fn->numUpvalues; i++) { wrenGrayObj(vm, (Obj*)closure->upvalues[i]); } // Keep track of how much memory is still in use. vm->bytesAllocated += sizeof(ObjClosure); vm->bytesAllocated += sizeof(ObjUpvalue*) * closure->fn->numUpvalues; } static void blackenFiber(WrenVM* vm, ObjFiber* fiber) { // Stack functions. for (int i = 0; i < fiber->numFrames; i++) { wrenGrayObj(vm, (Obj*)fiber->frames[i].closure); } // Stack variables. for (Value* slot = fiber->stack; slot < fiber->stackTop; slot++) { wrenGrayValue(vm, *slot); } // Open upvalues. ObjUpvalue* upvalue = fiber->openUpvalues; while (upvalue != NULL) { wrenGrayObj(vm, (Obj*)upvalue); upvalue = upvalue->next; } // The caller. wrenGrayObj(vm, (Obj*)fiber->caller); wrenGrayValue(vm, fiber->error); // Keep track of how much memory is still in use. vm->bytesAllocated += sizeof(ObjFiber); vm->bytesAllocated += fiber->frameCapacity * sizeof(CallFrame); vm->bytesAllocated += fiber->stackCapacity * sizeof(Value); } static void blackenFn(WrenVM* vm, ObjFn* fn) { // Mark the constants. wrenGrayBuffer(vm, &fn->constants); // Keep track of how much memory is still in use. vm->bytesAllocated += sizeof(ObjFn); vm->bytesAllocated += sizeof(uint8_t) * fn->code.capacity; vm->bytesAllocated += sizeof(Value) * fn->constants.capacity; // The debug line number buffer. vm->bytesAllocated += sizeof(int) * fn->code.capacity; // TODO: What about the function name? } static void blackenForeign(WrenVM* vm, ObjForeign* foreign) { // TODO: Keep track of how much memory the foreign object uses. We can store // this in each foreign object, but it will balloon the size. We may not want // that much overhead. One option would be to let the foreign class register // a C function that returns a size for the object. That way the VM doesn't // always have to explicitly store it. } static void blackenInstance(WrenVM* vm, ObjInstance* instance) { wrenGrayObj(vm, (Obj*)instance->obj.classObj); // Mark the fields. for (int i = 0; i < instance->obj.classObj->numFields; i++) { wrenGrayValue(vm, instance->fields[i]); } // Keep track of how much memory is still in use. vm->bytesAllocated += sizeof(ObjInstance); vm->bytesAllocated += sizeof(Value) * instance->obj.classObj->numFields; } static void blackenList(WrenVM* vm, ObjList* list) { // Mark the elements. wrenGrayBuffer(vm, &list->elements); // Keep track of how much memory is still in use. vm->bytesAllocated += sizeof(ObjList); vm->bytesAllocated += sizeof(Value) * list->elements.capacity; } static void blackenMap(WrenVM* vm, ObjMap* map) { // Mark the entries. for (uint32_t i = 0; i < map->capacity; i++) { MapEntry* entry = &map->entries[i]; if (IS_UNDEFINED(entry->key)) continue; wrenGrayValue(vm, entry->key); wrenGrayValue(vm, entry->value); } // Keep track of how much memory is still in use. vm->bytesAllocated += sizeof(ObjMap); vm->bytesAllocated += sizeof(MapEntry) * map->capacity; } static void blackenModule(WrenVM* vm, ObjModule* module) { // Top-level variables. for (int i = 0; i < module->variables.count; i++) { wrenGrayValue(vm, module->variables.data[i]); } wrenBlackenSymbolTable(vm, &module->variableNames); wrenGrayObj(vm, (Obj*)module->name); // Keep track of how much memory is still in use. vm->bytesAllocated += sizeof(ObjModule); } static void blackenRange(WrenVM* vm, ObjRange* range) { // Keep track of how much memory is still in use. vm->bytesAllocated += sizeof(ObjRange); } static void blackenString(WrenVM* vm, ObjString* string) { // Keep track of how much memory is still in use. vm->bytesAllocated += sizeof(ObjString) + string->length + 1; } static void blackenUpvalue(WrenVM* vm, ObjUpvalue* upvalue) { // Mark the closed-over object (in case it is closed). wrenGrayValue(vm, upvalue->closed); // Keep track of how much memory is still in use. vm->bytesAllocated += sizeof(ObjUpvalue); } static void blackenObject(WrenVM* vm, Obj* obj) { #if WREN_DEBUG_TRACE_MEMORY printf("mark "); wrenDumpValue(OBJ_VAL(obj)); printf(" @ %p\n", obj); #endif // Traverse the object's fields. switch (obj->type) { case OBJ_CLASS: blackenClass( vm, (ObjClass*) obj); break; case OBJ_CLOSURE: blackenClosure( vm, (ObjClosure*) obj); break; case OBJ_FIBER: blackenFiber( vm, (ObjFiber*) obj); break; case OBJ_FN: blackenFn( vm, (ObjFn*) obj); break; case OBJ_FOREIGN: blackenForeign( vm, (ObjForeign*) obj); break; case OBJ_INSTANCE: blackenInstance(vm, (ObjInstance*)obj); break; case OBJ_LIST: blackenList( vm, (ObjList*) obj); break; case OBJ_MAP: blackenMap( vm, (ObjMap*) obj); break; case OBJ_MODULE: blackenModule( vm, (ObjModule*) obj); break; case OBJ_RANGE: blackenRange( vm, (ObjRange*) obj); break; case OBJ_STRING: blackenString( vm, (ObjString*) obj); break; case OBJ_UPVALUE: blackenUpvalue( vm, (ObjUpvalue*) obj); break; } } void wrenBlackenObjects(WrenVM* vm) { while (vm->grayCount > 0) { // Pop an item from the gray stack. Obj* obj = vm->gray[--vm->grayCount]; blackenObject(vm, obj); } } void wrenFreeObj(WrenVM* vm, Obj* obj) { #if WREN_DEBUG_TRACE_MEMORY printf("free "); wrenDumpValue(OBJ_VAL(obj)); printf(" @ %p\n", obj); #endif switch (obj->type) { case OBJ_CLASS: wrenMethodBufferClear(vm, &((ObjClass*)obj)->methods); break; case OBJ_FIBER: { ObjFiber* fiber = (ObjFiber*)obj; DEALLOCATE(vm, fiber->frames); DEALLOCATE(vm, fiber->stack); break; } case OBJ_FN: { ObjFn* fn = (ObjFn*)obj; wrenValueBufferClear(vm, &fn->constants); wrenByteBufferClear(vm, &fn->code); wrenIntBufferClear(vm, &fn->debug->sourceLines); DEALLOCATE(vm, fn->debug->name); DEALLOCATE(vm, fn->debug); break; } case OBJ_FOREIGN: wrenFinalizeForeign(vm, (ObjForeign*)obj); break; case OBJ_LIST: wrenValueBufferClear(vm, &((ObjList*)obj)->elements); break; case OBJ_MAP: DEALLOCATE(vm, ((ObjMap*)obj)->entries); break; case OBJ_MODULE: wrenSymbolTableClear(vm, &((ObjModule*)obj)->variableNames); wrenValueBufferClear(vm, &((ObjModule*)obj)->variables); break; case OBJ_CLOSURE: case OBJ_INSTANCE: case OBJ_RANGE: case OBJ_STRING: case OBJ_UPVALUE: break; } DEALLOCATE(vm, obj); } ObjClass* wrenGetClass(WrenVM* vm, Value value) { return wrenGetClassInline(vm, value); } bool wrenValuesEqual(Value a, Value b) { if (wrenValuesSame(a, b)) return true; // If we get here, it's only possible for two heap-allocated immutable objects // to be equal. if (!IS_OBJ(a) || !IS_OBJ(b)) return false; Obj* aObj = AS_OBJ(a); Obj* bObj = AS_OBJ(b); // Must be the same type. if (aObj->type != bObj->type) return false; switch (aObj->type) { case OBJ_RANGE: { ObjRange* aRange = (ObjRange*)aObj; ObjRange* bRange = (ObjRange*)bObj; return aRange->from == bRange->from && aRange->to == bRange->to && aRange->isInclusive == bRange->isInclusive; } case OBJ_STRING: { ObjString* aString = (ObjString*)aObj; ObjString* bString = (ObjString*)bObj; return aString->hash == bString->hash && wrenStringEqualsCString(aString, bString->value, bString->length); } default: // All other types are only equal if they are same, which they aren't if // we get here. return false; } } // End file "wren_value.c" // Begin file "wren_vm.c" #include <stdarg.h> #include <string.h> #if WREN_OPT_META // Begin file "wren_opt_meta.h" #ifndef wren_opt_meta_h #define wren_opt_meta_h // This module defines the Meta class and its associated methods. #if WREN_OPT_META const char* wrenMetaSource(); WrenForeignMethodFn wrenMetaBindForeignMethod(WrenVM* vm, const char* className, bool isStatic, const char* signature); #endif #endif // End file "wren_opt_meta.h" #endif #if WREN_OPT_RANDOM // Begin file "wren_opt_random.h" #ifndef wren_opt_random_h #define wren_opt_random_h #if WREN_OPT_RANDOM const char* wrenRandomSource(); WrenForeignClassMethods wrenRandomBindForeignClass(WrenVM* vm, const char* module, const char* className); WrenForeignMethodFn wrenRandomBindForeignMethod(WrenVM* vm, const char* className, bool isStatic, const char* signature); #endif #endif // End file "wren_opt_random.h" #endif #if WREN_DEBUG_TRACE_MEMORY || WREN_DEBUG_TRACE_GC #include <time.h> #include <stdio.h> #endif // The behavior of realloc() when the size is 0 is implementation defined. It // may return a non-NULL pointer which must not be dereferenced but nevertheless // should be freed. To prevent that, we avoid calling realloc() with a zero // size. static void* defaultReallocate(void* ptr, size_t newSize) { if (newSize == 0) { free(ptr); return NULL; } return realloc(ptr, newSize); } void wrenInitConfiguration(WrenConfiguration* config) { config->reallocateFn = defaultReallocate; config->resolveModuleFn = NULL; config->loadModuleFn = NULL; config->bindForeignMethodFn = NULL; config->bindForeignClassFn = NULL; config->writeFn = NULL; config->errorFn = NULL; config->initialHeapSize = 1024 * 1024 * 10; config->minHeapSize = 1024 * 1024; config->heapGrowthPercent = 50; config->userData = NULL; } WrenVM* wrenNewVM(WrenConfiguration* config) { WrenReallocateFn reallocate = defaultReallocate; if (config != NULL) reallocate = config->reallocateFn; WrenVM* vm = (WrenVM*)reallocate(NULL, sizeof(*vm)); memset(vm, 0, sizeof(WrenVM)); // Copy the configuration if given one. if (config != NULL) { memcpy(&vm->config, config, sizeof(WrenConfiguration)); } else { wrenInitConfiguration(&vm->config); } // TODO: Should we allocate and free this during a GC? vm->grayCount = 0; // TODO: Tune this. vm->grayCapacity = 4; vm->gray = (Obj**)reallocate(NULL, vm->grayCapacity * sizeof(Obj*)); vm->nextGC = vm->config.initialHeapSize; wrenSymbolTableInit(&vm->methodNames); vm->modules = wrenNewMap(vm); wrenInitializeCore(vm); return vm; } void wrenFreeVM(WrenVM* vm) { ASSERT(vm->methodNames.count > 0, "VM appears to have already been freed."); // Free all of the GC objects. Obj* obj = vm->first; while (obj != NULL) { Obj* next = obj->next; wrenFreeObj(vm, obj); obj = next; } // Free up the GC gray set. vm->gray = (Obj**)vm->config.reallocateFn(vm->gray, 0); // Tell the user if they didn't free any handles. We don't want to just free // them here because the host app may still have pointers to them that they // may try to use. Better to tell them about the bug early. ASSERT(vm->handles == NULL, "All handles have not been released."); wrenSymbolTableClear(vm, &vm->methodNames); DEALLOCATE(vm, vm); } void wrenCollectGarbage(WrenVM* vm) { #if WREN_DEBUG_TRACE_MEMORY || WREN_DEBUG_TRACE_GC printf("-- gc --\n"); size_t before = vm->bytesAllocated; double startTime = (double)clock() / CLOCKS_PER_SEC; #endif // Mark all reachable objects. // Reset this. As we mark objects, their size will be counted again so that // we can track how much memory is in use without needing to know the size // of each *freed* object. // // This is important because when freeing an unmarked object, we don't always // know how much memory it is using. For example, when freeing an instance, // we need to know its class to know how big it is, but its class may have // already been freed. vm->bytesAllocated = 0; wrenGrayObj(vm, (Obj*)vm->modules); // Temporary roots. for (int i = 0; i < vm->numTempRoots; i++) { wrenGrayObj(vm, vm->tempRoots[i]); } // The current fiber. wrenGrayObj(vm, (Obj*)vm->fiber); // The handles. for (WrenHandle* handle = vm->handles; handle != NULL; handle = handle->next) { wrenGrayValue(vm, handle->value); } // Any object the compiler is using (if there is one). if (vm->compiler != NULL) wrenMarkCompiler(vm, vm->compiler); // Method names. wrenBlackenSymbolTable(vm, &vm->methodNames); // Now that we have grayed the roots, do a depth-first search over all of the // reachable objects. wrenBlackenObjects(vm); // Collect the white objects. Obj** obj = &vm->first; while (*obj != NULL) { if (!((*obj)->isDark)) { // This object wasn't reached, so remove it from the list and free it. Obj* unreached = *obj; *obj = unreached->next; wrenFreeObj(vm, unreached); } else { // This object was reached, so unmark it (for the next GC) and move on to // the next. (*obj)->isDark = false; obj = &(*obj)->next; } } // Calculate the next gc point, this is the current allocation plus // a configured percentage of the current allocation. vm->nextGC = vm->bytesAllocated + ((vm->bytesAllocated * vm->config.heapGrowthPercent) / 100); if (vm->nextGC < vm->config.minHeapSize) vm->nextGC = vm->config.minHeapSize; #if WREN_DEBUG_TRACE_MEMORY || WREN_DEBUG_TRACE_GC double elapsed = ((double)clock() / CLOCKS_PER_SEC) - startTime; // Explicit cast because size_t has different sizes on 32-bit and 64-bit and // we need a consistent type for the format string. printf("GC %lu before, %lu after (%lu collected), next at %lu. Took %.3fms.\n", (unsigned long)before, (unsigned long)vm->bytesAllocated, (unsigned long)(before - vm->bytesAllocated), (unsigned long)vm->nextGC, elapsed*1000.0); #endif } void* wrenReallocate(WrenVM* vm, void* memory, size_t oldSize, size_t newSize) { #if WREN_DEBUG_TRACE_MEMORY // Explicit cast because size_t has different sizes on 32-bit and 64-bit and // we need a consistent type for the format string. printf("reallocate %p %lu -> %lu\n", memory, (unsigned long)oldSize, (unsigned long)newSize); #endif // If new bytes are being allocated, add them to the total count. If objects // are being completely deallocated, we don't track that (since we don't // track the original size). Instead, that will be handled while marking // during the next GC. vm->bytesAllocated += newSize - oldSize; #if WREN_DEBUG_GC_STRESS // Since collecting calls this function to free things, make sure we don't // recurse. if (newSize > 0) wrenCollectGarbage(vm); #else if (newSize > 0 && vm->bytesAllocated > vm->nextGC) wrenCollectGarbage(vm); #endif return vm->config.reallocateFn(memory, newSize); } // Captures the local variable [local] into an [Upvalue]. If that local is // already in an upvalue, the existing one will be used. (This is important to // ensure that multiple closures closing over the same variable actually see // the same variable.) Otherwise, it will create a new open upvalue and add it // the fiber's list of upvalues. static ObjUpvalue* captureUpvalue(WrenVM* vm, ObjFiber* fiber, Value* local) { // If there are no open upvalues at all, we must need a new one. if (fiber->openUpvalues == NULL) { fiber->openUpvalues = wrenNewUpvalue(vm, local); return fiber->openUpvalues; } ObjUpvalue* prevUpvalue = NULL; ObjUpvalue* upvalue = fiber->openUpvalues; // Walk towards the bottom of the stack until we find a previously existing // upvalue or pass where it should be. while (upvalue != NULL && upvalue->value > local) { prevUpvalue = upvalue; upvalue = upvalue->next; } // Found an existing upvalue for this local. if (upvalue != NULL && upvalue->value == local) return upvalue; // We've walked past this local on the stack, so there must not be an // upvalue for it already. Make a new one and link it in in the right // place to keep the list sorted. ObjUpvalue* createdUpvalue = wrenNewUpvalue(vm, local); if (prevUpvalue == NULL) { // The new one is the first one in the list. fiber->openUpvalues = createdUpvalue; } else { prevUpvalue->next = createdUpvalue; } createdUpvalue->next = upvalue; return createdUpvalue; } // Closes any open upvalues that have been created for stack slots at [last] // and above. static void closeUpvalues(ObjFiber* fiber, Value* last) { while (fiber->openUpvalues != NULL && fiber->openUpvalues->value >= last) { ObjUpvalue* upvalue = fiber->openUpvalues; // Move the value into the upvalue itself and point the upvalue to it. upvalue->closed = *upvalue->value; upvalue->value = &upvalue->closed; // Remove it from the open upvalue list. fiber->openUpvalues = upvalue->next; } } // Looks up a foreign method in [moduleName] on [className] with [signature]. // // This will try the host's foreign method binder first. If that fails, it // falls back to handling the built-in modules. static WrenForeignMethodFn findForeignMethod(WrenVM* vm, const char* moduleName, const char* className, bool isStatic, const char* signature) { WrenForeignMethodFn method = NULL; if (vm->config.bindForeignMethodFn != NULL) { method = vm->config.bindForeignMethodFn(vm, moduleName, className, isStatic, signature); } // If the host didn't provide it, see if it's an optional one. if (method == NULL) { #if WREN_OPT_META if (strcmp(moduleName, "meta") == 0) { method = wrenMetaBindForeignMethod(vm, className, isStatic, signature); } #endif #if WREN_OPT_RANDOM if (strcmp(moduleName, "random") == 0) { method = wrenRandomBindForeignMethod(vm, className, isStatic, signature); } #endif } return method; } // Defines [methodValue] as a method on [classObj]. // // Handles both foreign methods where [methodValue] is a string containing the // method's signature and Wren methods where [methodValue] is a function. // // Aborts the current fiber if the method is a foreign method that could not be // found. static void bindMethod(WrenVM* vm, int methodType, int symbol, ObjModule* module, ObjClass* classObj, Value methodValue) { const char* className = classObj->name->value; if (methodType == CODE_METHOD_STATIC) classObj = classObj->obj.classObj; Method method; if (IS_STRING(methodValue)) { const char* name = AS_CSTRING(methodValue); method.type = METHOD_FOREIGN; method.as.foreign = findForeignMethod(vm, module->name->value, className, methodType == CODE_METHOD_STATIC, name); if (method.as.foreign == NULL) { vm->fiber->error = wrenStringFormat(vm, "Could not find foreign method '@' for class $ in module '$'.", methodValue, classObj->name->value, module->name->value); return; } } else { method.as.closure = AS_CLOSURE(methodValue); method.type = METHOD_BLOCK; // Patch up the bytecode now that we know the superclass. wrenBindMethodCode(classObj, method.as.closure->fn); } wrenBindMethod(vm, classObj, symbol, method); } static void callForeign(WrenVM* vm, ObjFiber* fiber, WrenForeignMethodFn foreign, int numArgs) { ASSERT(vm->apiStack == NULL, "Cannot already be in foreign call."); vm->apiStack = fiber->stackTop - numArgs; foreign(vm); // Discard the stack slots for the arguments and temporaries but leave one // for the result. fiber->stackTop = vm->apiStack + 1; vm->apiStack = NULL; } // Handles the current fiber having aborted because of an error. // // Walks the call chain of fibers, aborting each one until it hits a fiber that // handles the error. If none do, tells the VM to stop. static void runtimeError(WrenVM* vm) { ASSERT(wrenHasError(vm->fiber), "Should only call this after an error."); ObjFiber* current = vm->fiber; Value error = current->error; while (current != NULL) { // Every fiber along the call chain gets aborted with the same error. current->error = error; // If the caller ran this fiber using "try", give it the error and stop. if (current->state == FIBER_TRY) { // Make the caller's try method return the error message. current->caller->stackTop[-1] = vm->fiber->error; vm->fiber = current->caller; return; } // Otherwise, unhook the caller since we will never resume and return to it. ObjFiber* caller = current->caller; current->caller = NULL; current = caller; } // If we got here, nothing caught the error, so show the stack trace. wrenDebugPrintStackTrace(vm); vm->fiber = NULL; vm->apiStack = NULL; } // Aborts the current fiber with an appropriate method not found error for a // method with [symbol] on [classObj]. static void methodNotFound(WrenVM* vm, ObjClass* classObj, int symbol) { vm->fiber->error = wrenStringFormat(vm, "@ does not implement '$'.", OBJ_VAL(classObj->name), vm->methodNames.data[symbol]->value); } // Looks up the previously loaded module with [name]. // // Returns `NULL` if no module with that name has been loaded. static ObjModule* getModule(WrenVM* vm, Value name) { Value moduleValue = wrenMapGet(vm->modules, name); return !IS_UNDEFINED(moduleValue) ? AS_MODULE(moduleValue) : NULL; } static ObjClosure* compileInModule(WrenVM* vm, Value name, const char* source, bool isExpression, bool printErrors) { // See if the module has already been loaded. ObjModule* module = getModule(vm, name); if (module == NULL) { module = wrenNewModule(vm, AS_STRING(name)); // It's possible for the wrenMapSet below to resize the modules map, // and trigger a GC while doing so. When this happens it will collect // the module we've just created. Once in the map it is safe. wrenPushRoot(vm, (Obj*)module); // Store it in the VM's module registry so we don't load the same module // multiple times. wrenMapSet(vm, vm->modules, name, OBJ_VAL(module)); wrenPopRoot(vm); // Implicitly import the core module. ObjModule* coreModule = getModule(vm, NULL_VAL); for (int i = 0; i < coreModule->variables.count; i++) { wrenDefineVariable(vm, module, coreModule->variableNames.data[i]->value, coreModule->variableNames.data[i]->length, coreModule->variables.data[i], NULL); } } ObjFn* fn = wrenCompile(vm, module, source, isExpression, printErrors); if (fn == NULL) { // TODO: Should we still store the module even if it didn't compile? return NULL; } // Functions are always wrapped in closures. wrenPushRoot(vm, (Obj*)fn); ObjClosure* closure = wrenNewClosure(vm, fn); wrenPopRoot(vm); // fn. return closure; } // Verifies that [superclassValue] is a valid object to inherit from. That // means it must be a class and cannot be the class of any built-in type. // // Also validates that it doesn't result in a class with too many fields and // the other limitations foreign classes have. // // If successful, returns `null`. Otherwise, returns a string for the runtime // error message. static Value validateSuperclass(WrenVM* vm, Value name, Value superclassValue, int numFields) { // Make sure the superclass is a class. if (!IS_CLASS(superclassValue)) { return wrenStringFormat(vm, "Class '@' cannot inherit from a non-class object.", name); } // Make sure it doesn't inherit from a sealed built-in type. Primitive methods // on these classes assume the instance is one of the other Obj___ types and // will fail horribly if it's actually an ObjInstance. ObjClass* superclass = AS_CLASS(superclassValue); if (superclass == vm->classClass || superclass == vm->fiberClass || superclass == vm->fnClass || // Includes OBJ_CLOSURE. superclass == vm->listClass || superclass == vm->mapClass || superclass == vm->rangeClass || superclass == vm->stringClass) { return wrenStringFormat(vm, "Class '@' cannot inherit from built-in class '@'.", name, OBJ_VAL(superclass->name)); } if (superclass->numFields == -1) { return wrenStringFormat(vm, "Class '@' cannot inherit from foreign class '@'.", name, OBJ_VAL(superclass->name)); } if (numFields == -1 && superclass->numFields > 0) { return wrenStringFormat(vm, "Foreign class '@' may not inherit from a class with fields.", name); } if (superclass->numFields + numFields > MAX_FIELDS) { return wrenStringFormat(vm, "Class '@' may not have more than 255 fields, including inherited " "ones.", name); } return NULL_VAL; } static void bindForeignClass(WrenVM* vm, ObjClass* classObj, ObjModule* module) { WrenForeignClassMethods methods; methods.allocate = NULL; methods.finalize = NULL; // Check the optional built-in module first so the host can override it. if (vm->config.bindForeignClassFn != NULL) { methods = vm->config.bindForeignClassFn(vm, module->name->value, classObj->name->value); } // If the host didn't provide it, see if it's a built in optional module. if (methods.allocate == NULL && methods.finalize == NULL) { #if WREN_OPT_RANDOM if (strcmp(module->name->value, "random") == 0) { methods = wrenRandomBindForeignClass(vm, module->name->value, classObj->name->value); } #endif } Method method; method.type = METHOD_FOREIGN; // Add the symbol even if there is no allocator so we can ensure that the // symbol itself is always in the symbol table. int symbol = wrenSymbolTableEnsure(vm, &vm->methodNames, "<allocate>", 10); if (methods.allocate != NULL) { method.as.foreign = methods.allocate; wrenBindMethod(vm, classObj, symbol, method); } // Add the symbol even if there is no finalizer so we can ensure that the // symbol itself is always in the symbol table. symbol = wrenSymbolTableEnsure(vm, &vm->methodNames, "<finalize>", 10); if (methods.finalize != NULL) { method.as.foreign = (WrenForeignMethodFn)methods.finalize; wrenBindMethod(vm, classObj, symbol, method); } } // Creates a new class. // // If [numFields] is -1, the class is a foreign class. The name and superclass // should be on top of the fiber's stack. After calling this, the top of the // stack will contain the new class. // // Aborts the current fiber if an error occurs. static void createClass(WrenVM* vm, int numFields, ObjModule* module) { // Pull the name and superclass off the stack. Value name = vm->fiber->stackTop[-2]; Value superclass = vm->fiber->stackTop[-1]; // We have two values on the stack and we are going to leave one, so discard // the other slot. vm->fiber->stackTop--; vm->fiber->error = validateSuperclass(vm, name, superclass, numFields); if (wrenHasError(vm->fiber)) return; ObjClass* classObj = wrenNewClass(vm, AS_CLASS(superclass), numFields, AS_STRING(name)); vm->fiber->stackTop[-1] = OBJ_VAL(classObj); if (numFields == -1) bindForeignClass(vm, classObj, module); } static void createForeign(WrenVM* vm, ObjFiber* fiber, Value* stack) { ObjClass* classObj = AS_CLASS(stack[0]); ASSERT(classObj->numFields == -1, "Class must be a foreign class."); // TODO: Don't look up every time. int symbol = wrenSymbolTableFind(&vm->methodNames, "<allocate>", 10); ASSERT(symbol != -1, "Should have defined <allocate> symbol."); ASSERT(classObj->methods.count > symbol, "Class should have allocator."); Method* method = &classObj->methods.data[symbol]; ASSERT(method->type == METHOD_FOREIGN, "Allocator should be foreign."); // Pass the constructor arguments to the allocator as well. ASSERT(vm->apiStack == NULL, "Cannot already be in foreign call."); vm->apiStack = stack; method->as.foreign(vm); vm->apiStack = NULL; } void wrenFinalizeForeign(WrenVM* vm, ObjForeign* foreign) { // TODO: Don't look up every time. int symbol = wrenSymbolTableFind(&vm->methodNames, "<finalize>", 10); ASSERT(symbol != -1, "Should have defined <finalize> symbol."); // If there are no finalizers, don't finalize it. if (symbol == -1) return; // If the class doesn't have a finalizer, bail out. ObjClass* classObj = foreign->obj.classObj; if (symbol >= classObj->methods.count) return; Method* method = &classObj->methods.data[symbol]; if (method->type == METHOD_NONE) return; ASSERT(method->type == METHOD_FOREIGN, "Finalizer should be foreign."); WrenFinalizerFn finalizer = (WrenFinalizerFn)method->as.foreign; finalizer(foreign->data); } // Let the host resolve an imported module name if it wants to. static Value resolveModule(WrenVM* vm, Value name) { // If the host doesn't care to resolve, leave the name alone. if (vm->config.resolveModuleFn == NULL) return name; ObjFiber* fiber = vm->fiber; ObjFn* fn = fiber->frames[fiber->numFrames - 1].closure->fn; ObjString* importer = fn->module->name; const char* resolved = vm->config.resolveModuleFn(vm, importer->value, AS_CSTRING(name)); if (resolved == NULL) { vm->fiber->error = wrenStringFormat(vm, "Could not resolve module '@' imported from '@'.", name, OBJ_VAL(importer)); return NULL_VAL; } // If they resolved to the exact same string, we don't need to copy it. if (resolved == AS_CSTRING(name)) return name; // Copy the string into a Wren String object. name = wrenNewString(vm, resolved); DEALLOCATE(vm, (char*)resolved); return name; } static Value importModule(WrenVM* vm, Value name) { name = resolveModule(vm, name); // If the module is already loaded, we don't need to do anything. Value existing = wrenMapGet(vm->modules, name); if (!IS_UNDEFINED(existing)) return existing; wrenPushRoot(vm, AS_OBJ(name)); const char* source = NULL; bool allocatedSource = true; // Let the host try to provide the module. if (vm->config.loadModuleFn != NULL) { source = vm->config.loadModuleFn(vm, AS_CSTRING(name)); } // If the host didn't provide it, see if it's a built in optional module. if (source == NULL) { ObjString* nameString = AS_STRING(name); #if WREN_OPT_META if (strcmp(nameString->value, "meta") == 0) source = wrenMetaSource(); #endif #if WREN_OPT_RANDOM if (strcmp(nameString->value, "random") == 0) source = wrenRandomSource(); #endif // TODO: Should we give the host the ability to provide strings that don't // need to be freed? allocatedSource = false; } if (source == NULL) { vm->fiber->error = wrenStringFormat(vm, "Could not load module '@'.", name); wrenPopRoot(vm); // name. return NULL_VAL; } ObjClosure* moduleClosure = compileInModule(vm, name, source, false, true); // Modules loaded by the host are expected to be dynamically allocated with // ownership given to the VM, which will free it. The built in optional // modules are constant strings which don't need to be freed. if (allocatedSource) DEALLOCATE(vm, (char*)source); if (moduleClosure == NULL) { vm->fiber->error = wrenStringFormat(vm, "Could not compile module '@'.", name); wrenPopRoot(vm); // name. return NULL_VAL; } wrenPopRoot(vm); // name. // Return the closure that executes the module. return OBJ_VAL(moduleClosure); } static Value getModuleVariable(WrenVM* vm, ObjModule* module, Value variableName) { ObjString* variable = AS_STRING(variableName); uint32_t variableEntry = wrenSymbolTableFind(&module->variableNames, variable->value, variable->length); // It's a runtime error if the imported variable does not exist. if (variableEntry != UINT32_MAX) { return module->variables.data[variableEntry]; } vm->fiber->error = wrenStringFormat(vm, "Could not find a variable named '@' in module '@'.", variableName, OBJ_VAL(module->name)); return NULL_VAL; } inline static bool checkArity(WrenVM* vm, Value value, int numArgs) { ASSERT(IS_CLOSURE(value), "Receiver must be a closure."); ObjFn* fn = AS_CLOSURE(value)->fn; // We only care about missing arguments, not extras. The "- 1" is because // numArgs includes the receiver, the function itself, which we don't want to // count. if (numArgs - 1 >= fn->arity) return true; vm->fiber->error = CONST_STRING(vm, "Function expects more arguments."); return false; } // The main bytecode interpreter loop. This is where the magic happens. It is // also, as you can imagine, highly performance critical. static WrenInterpretResult runInterpreter(WrenVM* vm, register ObjFiber* fiber) { // Remember the current fiber so we can find it if a GC happens. vm->fiber = fiber; fiber->state = FIBER_ROOT; // Hoist these into local variables. They are accessed frequently in the loop // but assigned less frequently. Keeping them in locals and updating them when // a call frame has been pushed or popped gives a large speed boost. register CallFrame* frame; register Value* stackStart; register uint8_t* ip; register ObjFn* fn; // These macros are designed to only be invoked within this function. #define PUSH(value) (*fiber->stackTop++ = value) #define POP() (*(--fiber->stackTop)) #define DROP() (fiber->stackTop--) #define PEEK() (*(fiber->stackTop - 1)) #define PEEK2() (*(fiber->stackTop - 2)) #define READ_BYTE() (*ip++) #define READ_SHORT() (ip += 2, (uint16_t)((ip[-2] << 8) | ip[-1])) // Use this before a CallFrame is pushed to store the local variables back // into the current one. #define STORE_FRAME() frame->ip = ip // Use this after a CallFrame has been pushed or popped to refresh the local // variables. #define LOAD_FRAME() \ do \ { \ frame = &fiber->frames[fiber->numFrames - 1]; \ stackStart = frame->stackStart; \ ip = frame->ip; \ fn = frame->closure->fn; \ } while (false) // Terminates the current fiber with error string [error]. If another calling // fiber is willing to catch the error, transfers control to it, otherwise // exits the interpreter. #define RUNTIME_ERROR() \ do \ { \ STORE_FRAME(); \ runtimeError(vm); \ if (vm->fiber == NULL) return WREN_RESULT_RUNTIME_ERROR; \ fiber = vm->fiber; \ LOAD_FRAME(); \ DISPATCH(); \ } while (false) #if WREN_DEBUG_TRACE_INSTRUCTIONS // Prints the stack and instruction before each instruction is executed. #define DEBUG_TRACE_INSTRUCTIONS() \ do \ { \ wrenDumpStack(fiber); \ wrenDumpInstruction(vm, fn, (int)(ip - fn->code.data)); \ } while (false) #else #define DEBUG_TRACE_INSTRUCTIONS() do { } while (false) #endif #if WREN_COMPUTED_GOTO static void* dispatchTable[] = { #define OPCODE(name, _) &&code_##name, // Begin file "wren_opcodes.h" // This defines the bytecode instructions used by the VM. It does so by invoking // an OPCODE() macro which is expected to be defined at the point that this is // included. (See: http://en.wikipedia.org/wiki/X_Macro for more.) // // The first argument is the name of the opcode. The second is its "stack // effect" -- the amount that the op code changes the size of the stack. A // stack effect of 1 means it pushes a value and the stack grows one larger. // -2 means it pops two values, etc. // // Note that the order of instructions here affects the order of the dispatch // table in the VM's interpreter loop. That in turn affects caching which // affects overall performance. Take care to run benchmarks if you change the // order here. // Load the constant at index [arg]. OPCODE(CONSTANT, 1) // Push null onto the stack. OPCODE(NULL, 1) // Push false onto the stack. OPCODE(FALSE, 1) // Push true onto the stack. OPCODE(TRUE, 1) // Pushes the value in the given local slot. OPCODE(LOAD_LOCAL_0, 1) OPCODE(LOAD_LOCAL_1, 1) OPCODE(LOAD_LOCAL_2, 1) OPCODE(LOAD_LOCAL_3, 1) OPCODE(LOAD_LOCAL_4, 1) OPCODE(LOAD_LOCAL_5, 1) OPCODE(LOAD_LOCAL_6, 1) OPCODE(LOAD_LOCAL_7, 1) OPCODE(LOAD_LOCAL_8, 1) // Note: The compiler assumes the following _STORE instructions always // immediately follow their corresponding _LOAD ones. // Pushes the value in local slot [arg]. OPCODE(LOAD_LOCAL, 1) // Stores the top of stack in local slot [arg]. Does not pop it. OPCODE(STORE_LOCAL, 0) // Pushes the value in upvalue [arg]. OPCODE(LOAD_UPVALUE, 1) // Stores the top of stack in upvalue [arg]. Does not pop it. OPCODE(STORE_UPVALUE, 0) // Pushes the value of the top-level variable in slot [arg]. OPCODE(LOAD_MODULE_VAR, 1) // Stores the top of stack in top-level variable slot [arg]. Does not pop it. OPCODE(STORE_MODULE_VAR, 0) // Pushes the value of the field in slot [arg] of the receiver of the current // function. This is used for regular field accesses on "this" directly in // methods. This instruction is faster than the more general CODE_LOAD_FIELD // instruction. OPCODE(LOAD_FIELD_THIS, 1) // Stores the top of the stack in field slot [arg] in the receiver of the // current value. Does not pop the value. This instruction is faster than the // more general CODE_LOAD_FIELD instruction. OPCODE(STORE_FIELD_THIS, 0) // Pops an instance and pushes the value of the field in slot [arg] of it. OPCODE(LOAD_FIELD, 0) // Pops an instance and stores the subsequent top of stack in field slot // [arg] in it. Does not pop the value. OPCODE(STORE_FIELD, -1) // Pop and discard the top of stack. OPCODE(POP, -1) // Invoke the method with symbol [arg]. The number indicates the number of // arguments (not including the receiver). OPCODE(CALL_0, 0) OPCODE(CALL_1, -1) OPCODE(CALL_2, -2) OPCODE(CALL_3, -3) OPCODE(CALL_4, -4) OPCODE(CALL_5, -5) OPCODE(CALL_6, -6) OPCODE(CALL_7, -7) OPCODE(CALL_8, -8) OPCODE(CALL_9, -9) OPCODE(CALL_10, -10) OPCODE(CALL_11, -11) OPCODE(CALL_12, -12) OPCODE(CALL_13, -13) OPCODE(CALL_14, -14) OPCODE(CALL_15, -15) OPCODE(CALL_16, -16) // Invoke a superclass method with symbol [arg]. The number indicates the // number of arguments (not including the receiver). OPCODE(SUPER_0, 0) OPCODE(SUPER_1, -1) OPCODE(SUPER_2, -2) OPCODE(SUPER_3, -3) OPCODE(SUPER_4, -4) OPCODE(SUPER_5, -5) OPCODE(SUPER_6, -6) OPCODE(SUPER_7, -7) OPCODE(SUPER_8, -8) OPCODE(SUPER_9, -9) OPCODE(SUPER_10, -10) OPCODE(SUPER_11, -11) OPCODE(SUPER_12, -12) OPCODE(SUPER_13, -13) OPCODE(SUPER_14, -14) OPCODE(SUPER_15, -15) OPCODE(SUPER_16, -16) // Jump the instruction pointer [arg] forward. OPCODE(JUMP, 0) // Jump the instruction pointer [arg] backward. OPCODE(LOOP, 0) // Pop and if not truthy then jump the instruction pointer [arg] forward. OPCODE(JUMP_IF, -1) // If the top of the stack is false, jump [arg] forward. Otherwise, pop and // continue. OPCODE(AND, -1) // If the top of the stack is non-false, jump [arg] forward. Otherwise, pop // and continue. OPCODE(OR, -1) // Close the upvalue for the local on the top of the stack, then pop it. OPCODE(CLOSE_UPVALUE, -1) // Exit from the current function and return the value on the top of the // stack. OPCODE(RETURN, 0) // Creates a closure for the function stored at [arg] in the constant table. // // Following the function argument is a number of arguments, two for each // upvalue. The first is true if the variable being captured is a local (as // opposed to an upvalue), and the second is the index of the local or // upvalue being captured. // // Pushes the created closure. OPCODE(CLOSURE, 1) // Creates a new instance of a class. // // Assumes the class object is in slot zero, and replaces it with the new // uninitialized instance of that class. This opcode is only emitted by the // compiler-generated constructor metaclass methods. OPCODE(CONSTRUCT, 0) // Creates a new instance of a foreign class. // // Assumes the class object is in slot zero, and replaces it with the new // uninitialized instance of that class. This opcode is only emitted by the // compiler-generated constructor metaclass methods. OPCODE(FOREIGN_CONSTRUCT, 0) // Creates a class. Top of stack is the superclass. Below that is a string for // the name of the class. Byte [arg] is the number of fields in the class. OPCODE(CLASS, -1) // Creates a foreign class. Top of stack is the superclass. Below that is a // string for the name of the class. OPCODE(FOREIGN_CLASS, -1) // Define a method for symbol [arg]. The class receiving the method is popped // off the stack, then the function defining the body is popped. // // If a foreign method is being defined, the "function" will be a string // identifying the foreign method. Otherwise, it will be a function or // closure. OPCODE(METHOD_INSTANCE, -2) // Define a method for symbol [arg]. The class whose metaclass will receive // the method is popped off the stack, then the function defining the body is // popped. // // If a foreign method is being defined, the "function" will be a string // identifying the foreign method. Otherwise, it will be a function or // closure. OPCODE(METHOD_STATIC, -2) // This is executed at the end of the module's body. Pushes NULL onto the stack // as the "return value" of the import statement and stores the module as the // most recently imported one. OPCODE(END_MODULE, 1) // Import a module whose name is the string stored at [arg] in the constant // table. // // Pushes null onto the stack so that the fiber for the imported module can // replace that with a dummy value when it returns. (Fibers always return a // value when resuming a caller.) OPCODE(IMPORT_MODULE, 1) // Import a variable from the most recently imported module. The name of the // variable to import is at [arg] in the constant table. Pushes the loaded // variable's value. OPCODE(IMPORT_VARIABLE, 1) // This pseudo-instruction indicates the end of the bytecode. It should // always be preceded by a `CODE_RETURN`, so is never actually executed. OPCODE(END, 0) // End file "wren_opcodes.h" #undef OPCODE }; #define INTERPRET_LOOP DISPATCH(); #define CASE_CODE(name) code_##name #define DISPATCH() \ do \ { \ DEBUG_TRACE_INSTRUCTIONS(); \ goto *dispatchTable[instruction = (Code)READ_BYTE()]; \ } while (false) #else #define INTERPRET_LOOP \ loop: \ DEBUG_TRACE_INSTRUCTIONS(); \ switch (instruction = (Code)READ_BYTE()) #define CASE_CODE(name) case CODE_##name #define DISPATCH() goto loop #endif LOAD_FRAME(); Code instruction; INTERPRET_LOOP { CASE_CODE(LOAD_LOCAL_0): CASE_CODE(LOAD_LOCAL_1): CASE_CODE(LOAD_LOCAL_2): CASE_CODE(LOAD_LOCAL_3): CASE_CODE(LOAD_LOCAL_4): CASE_CODE(LOAD_LOCAL_5): CASE_CODE(LOAD_LOCAL_6): CASE_CODE(LOAD_LOCAL_7): CASE_CODE(LOAD_LOCAL_8): PUSH(stackStart[instruction - CODE_LOAD_LOCAL_0]); DISPATCH(); CASE_CODE(LOAD_LOCAL): PUSH(stackStart[READ_BYTE()]); DISPATCH(); CASE_CODE(LOAD_FIELD_THIS): { uint8_t field = READ_BYTE(); Value receiver = stackStart[0]; ASSERT(IS_INSTANCE(receiver), "Receiver should be instance."); ObjInstance* instance = AS_INSTANCE(receiver); ASSERT(field < instance->obj.classObj->numFields, "Out of bounds field."); PUSH(instance->fields[field]); DISPATCH(); } CASE_CODE(POP): DROP(); DISPATCH(); CASE_CODE(NULL): PUSH(NULL_VAL); DISPATCH(); CASE_CODE(FALSE): PUSH(FALSE_VAL); DISPATCH(); CASE_CODE(TRUE): PUSH(TRUE_VAL); DISPATCH(); CASE_CODE(STORE_LOCAL): stackStart[READ_BYTE()] = PEEK(); DISPATCH(); CASE_CODE(CONSTANT): PUSH(fn->constants.data[READ_SHORT()]); DISPATCH(); { // The opcodes for doing method and superclass calls share a lot of code. // However, doing an if() test in the middle of the instruction sequence // to handle the bit that is special to super calls makes the non-super // call path noticeably slower. // // Instead, we do this old school using an explicit goto to share code for // everything at the tail end of the call-handling code that is the same // between normal and superclass calls. int numArgs; int symbol; Value* args; ObjClass* classObj; Method* method; CASE_CODE(CALL_0): CASE_CODE(CALL_1): CASE_CODE(CALL_2): CASE_CODE(CALL_3): CASE_CODE(CALL_4): CASE_CODE(CALL_5): CASE_CODE(CALL_6): CASE_CODE(CALL_7): CASE_CODE(CALL_8): CASE_CODE(CALL_9): CASE_CODE(CALL_10): CASE_CODE(CALL_11): CASE_CODE(CALL_12): CASE_CODE(CALL_13): CASE_CODE(CALL_14): CASE_CODE(CALL_15): CASE_CODE(CALL_16): // Add one for the implicit receiver argument. numArgs = instruction - CODE_CALL_0 + 1; symbol = READ_SHORT(); // The receiver is the first argument. args = fiber->stackTop - numArgs; classObj = wrenGetClassInline(vm, args[0]); goto completeCall; CASE_CODE(SUPER_0): CASE_CODE(SUPER_1): CASE_CODE(SUPER_2): CASE_CODE(SUPER_3): CASE_CODE(SUPER_4): CASE_CODE(SUPER_5): CASE_CODE(SUPER_6): CASE_CODE(SUPER_7): CASE_CODE(SUPER_8): CASE_CODE(SUPER_9): CASE_CODE(SUPER_10): CASE_CODE(SUPER_11): CASE_CODE(SUPER_12): CASE_CODE(SUPER_13): CASE_CODE(SUPER_14): CASE_CODE(SUPER_15): CASE_CODE(SUPER_16): // Add one for the implicit receiver argument. numArgs = instruction - CODE_SUPER_0 + 1; symbol = READ_SHORT(); // The receiver is the first argument. args = fiber->stackTop - numArgs; // The superclass is stored in a constant. classObj = AS_CLASS(fn->constants.data[READ_SHORT()]); goto completeCall; completeCall: // If the class's method table doesn't include the symbol, bail. if (symbol >= classObj->methods.count || (method = &classObj->methods.data[symbol])->type == METHOD_NONE) { methodNotFound(vm, classObj, symbol); RUNTIME_ERROR(); } switch (method->type) { case METHOD_PRIMITIVE: if (method->as.primitive(vm, args)) { // The result is now in the first arg slot. Discard the other // stack slots. fiber->stackTop -= numArgs - 1; } else { // An error, fiber switch, or call frame change occurred. STORE_FRAME(); // If we don't have a fiber to switch to, stop interpreting. fiber = vm->fiber; if (fiber == NULL) return WREN_RESULT_SUCCESS; if (wrenHasError(fiber)) RUNTIME_ERROR(); LOAD_FRAME(); } break; case METHOD_FUNCTION_CALL: if (!checkArity(vm, args[0], numArgs)) { RUNTIME_ERROR(); break; } STORE_FRAME(); method->as.primitive(vm, args); LOAD_FRAME(); break; case METHOD_FOREIGN: callForeign(vm, fiber, method->as.foreign, numArgs); if (wrenHasError(fiber)) RUNTIME_ERROR(); break; case METHOD_BLOCK: STORE_FRAME(); wrenCallFunction(vm, fiber, (ObjClosure*)method->as.closure, numArgs); LOAD_FRAME(); break; case METHOD_NONE: UNREACHABLE(); break; } DISPATCH(); } CASE_CODE(LOAD_UPVALUE): { ObjUpvalue** upvalues = frame->closure->upvalues; PUSH(*upvalues[READ_BYTE()]->value); DISPATCH(); } CASE_CODE(STORE_UPVALUE): { ObjUpvalue** upvalues = frame->closure->upvalues; *upvalues[READ_BYTE()]->value = PEEK(); DISPATCH(); } CASE_CODE(LOAD_MODULE_VAR): PUSH(fn->module->variables.data[READ_SHORT()]); DISPATCH(); CASE_CODE(STORE_MODULE_VAR): fn->module->variables.data[READ_SHORT()] = PEEK(); DISPATCH(); CASE_CODE(STORE_FIELD_THIS): { uint8_t field = READ_BYTE(); Value receiver = stackStart[0]; ASSERT(IS_INSTANCE(receiver), "Receiver should be instance."); ObjInstance* instance = AS_INSTANCE(receiver); ASSERT(field < instance->obj.classObj->numFields, "Out of bounds field."); instance->fields[field] = PEEK(); DISPATCH(); } CASE_CODE(LOAD_FIELD): { uint8_t field = READ_BYTE(); Value receiver = POP(); ASSERT(IS_INSTANCE(receiver), "Receiver should be instance."); ObjInstance* instance = AS_INSTANCE(receiver); ASSERT(field < instance->obj.classObj->numFields, "Out of bounds field."); PUSH(instance->fields[field]); DISPATCH(); } CASE_CODE(STORE_FIELD): { uint8_t field = READ_BYTE(); Value receiver = POP(); ASSERT(IS_INSTANCE(receiver), "Receiver should be instance."); ObjInstance* instance = AS_INSTANCE(receiver); ASSERT(field < instance->obj.classObj->numFields, "Out of bounds field."); instance->fields[field] = PEEK(); DISPATCH(); } CASE_CODE(JUMP): { uint16_t offset = READ_SHORT(); ip += offset; DISPATCH(); } CASE_CODE(LOOP): { // Jump back to the top of the loop. uint16_t offset = READ_SHORT(); ip -= offset; DISPATCH(); } CASE_CODE(JUMP_IF): { uint16_t offset = READ_SHORT(); Value condition = POP(); if (IS_FALSE(condition) || IS_NULL(condition)) ip += offset; DISPATCH(); } CASE_CODE(AND): { uint16_t offset = READ_SHORT(); Value condition = PEEK(); if (IS_FALSE(condition) || IS_NULL(condition)) { // Short-circuit the right hand side. ip += offset; } else { // Discard the condition and evaluate the right hand side. DROP(); } DISPATCH(); } CASE_CODE(OR): { uint16_t offset = READ_SHORT(); Value condition = PEEK(); if (IS_FALSE(condition) || IS_NULL(condition)) { // Discard the condition and evaluate the right hand side. DROP(); } else { // Short-circuit the right hand side. ip += offset; } DISPATCH(); } CASE_CODE(CLOSE_UPVALUE): // Close the upvalue for the local if we have one. closeUpvalues(fiber, fiber->stackTop - 1); DROP(); DISPATCH(); CASE_CODE(RETURN): { Value result = POP(); fiber->numFrames--; // Close any upvalues still in scope. closeUpvalues(fiber, stackStart); // If the fiber is complete, end it. if (fiber->numFrames == 0) { // See if there's another fiber to return to. If not, we're done. if (fiber->caller == NULL) { // Store the final result value at the beginning of the stack so the // C API can get it. fiber->stack[0] = result; fiber->stackTop = fiber->stack + 1; return WREN_RESULT_SUCCESS; } ObjFiber* resumingFiber = fiber->caller; fiber->caller = NULL; fiber = resumingFiber; vm->fiber = resumingFiber; // Store the result in the resuming fiber. fiber->stackTop[-1] = result; } else { // Store the result of the block in the first slot, which is where the // caller expects it. stackStart[0] = result; // Discard the stack slots for the call frame (leaving one slot for the // result). fiber->stackTop = frame->stackStart + 1; } LOAD_FRAME(); DISPATCH(); } CASE_CODE(CONSTRUCT): ASSERT(IS_CLASS(stackStart[0]), "'this' should be a class."); stackStart[0] = wrenNewInstance(vm, AS_CLASS(stackStart[0])); DISPATCH(); CASE_CODE(FOREIGN_CONSTRUCT): ASSERT(IS_CLASS(stackStart[0]), "'this' should be a class."); createForeign(vm, fiber, stackStart); if (wrenHasError(fiber)) RUNTIME_ERROR(); DISPATCH(); CASE_CODE(CLOSURE): { // Create the closure and push it on the stack before creating upvalues // so that it doesn't get collected. ObjFn* function = AS_FN(fn->constants.data[READ_SHORT()]); ObjClosure* closure = wrenNewClosure(vm, function); PUSH(OBJ_VAL(closure)); // Capture upvalues, if any. for (int i = 0; i < function->numUpvalues; i++) { uint8_t isLocal = READ_BYTE(); uint8_t index = READ_BYTE(); if (isLocal) { // Make an new upvalue to close over the parent's local variable. closure->upvalues[i] = captureUpvalue(vm, fiber, frame->stackStart + index); } else { // Use the same upvalue as the current call frame. closure->upvalues[i] = frame->closure->upvalues[index]; } } DISPATCH(); } CASE_CODE(CLASS): { createClass(vm, READ_BYTE(), NULL); if (wrenHasError(fiber)) RUNTIME_ERROR(); DISPATCH(); } CASE_CODE(FOREIGN_CLASS): { createClass(vm, -1, fn->module); if (wrenHasError(fiber)) RUNTIME_ERROR(); DISPATCH(); } CASE_CODE(METHOD_INSTANCE): CASE_CODE(METHOD_STATIC): { uint16_t symbol = READ_SHORT(); ObjClass* classObj = AS_CLASS(PEEK()); Value method = PEEK2(); bindMethod(vm, instruction, symbol, fn->module, classObj, method); if (wrenHasError(fiber)) RUNTIME_ERROR(); DROP(); DROP(); DISPATCH(); } CASE_CODE(END_MODULE): { vm->lastModule = fn->module; PUSH(NULL_VAL); DISPATCH(); } CASE_CODE(IMPORT_MODULE): { // Make a slot on the stack for the module's fiber to place the return // value. It will be popped after this fiber is resumed. Store the // imported module's closure in the slot in case a GC happens when // invoking the closure. PUSH(importModule(vm, fn->constants.data[READ_SHORT()])); if (wrenHasError(fiber)) RUNTIME_ERROR(); // If we get a closure, call it to execute the module body. if (IS_CLOSURE(PEEK())) { STORE_FRAME(); ObjClosure* closure = AS_CLOSURE(PEEK()); wrenCallFunction(vm, fiber, closure, 1); LOAD_FRAME(); } else { // The module has already been loaded. Remember it so we can import // variables from it if needed. vm->lastModule = AS_MODULE(PEEK()); } DISPATCH(); } CASE_CODE(IMPORT_VARIABLE): { Value variable = fn->constants.data[READ_SHORT()]; ASSERT(vm->lastModule != NULL, "Should have already imported module."); Value result = getModuleVariable(vm, vm->lastModule, variable); if (wrenHasError(fiber)) RUNTIME_ERROR(); PUSH(result); DISPATCH(); } CASE_CODE(END): // A CODE_END should always be preceded by a CODE_RETURN. If we get here, // the compiler generated wrong code. UNREACHABLE(); } // We should only exit this function from an explicit return from CODE_RETURN // or a runtime error. UNREACHABLE(); return WREN_RESULT_RUNTIME_ERROR; #undef READ_BYTE #undef READ_SHORT } WrenHandle* wrenMakeCallHandle(WrenVM* vm, const char* signature) { ASSERT(signature != NULL, "Signature cannot be NULL."); int signatureLength = (int)strlen(signature); ASSERT(signatureLength > 0, "Signature cannot be empty."); // Count the number parameters the method expects. int numParams = 0; if (signature[signatureLength - 1] == ')') { for (int i = signatureLength - 1; i > 0 && signature[i] != '('; i--) { if (signature[i] == '_') numParams++; } } // Count subscript arguments. if (signature[0] == '[') { for (int i = 0; i < signatureLength && signature[i] != ']'; i++) { if (signature[i] == '_') numParams++; } } // Add the signatue to the method table. int method = wrenSymbolTableEnsure(vm, &vm->methodNames, signature, signatureLength); // Create a little stub function that assumes the arguments are on the stack // and calls the method. ObjFn* fn = wrenNewFunction(vm, NULL, numParams + 1); // Wrap the function in a closure and then in a handle. Do this here so it // doesn't get collected as we fill it in. WrenHandle* value = wrenMakeHandle(vm, OBJ_VAL(fn)); value->value = OBJ_VAL(wrenNewClosure(vm, fn)); wrenByteBufferWrite(vm, &fn->code, (uint8_t)(CODE_CALL_0 + numParams)); wrenByteBufferWrite(vm, &fn->code, (method >> 8) & 0xff); wrenByteBufferWrite(vm, &fn->code, method & 0xff); wrenByteBufferWrite(vm, &fn->code, CODE_RETURN); wrenByteBufferWrite(vm, &fn->code, CODE_END); wrenIntBufferFill(vm, &fn->debug->sourceLines, 0, 5); wrenFunctionBindName(vm, fn, signature, signatureLength); return value; } WrenInterpretResult wrenCall(WrenVM* vm, WrenHandle* method) { ASSERT(method != NULL, "Method cannot be NULL."); ASSERT(IS_CLOSURE(method->value), "Method must be a method handle."); ASSERT(vm->fiber != NULL, "Must set up arguments for call first."); ASSERT(vm->apiStack != NULL, "Must set up arguments for call first."); ASSERT(vm->fiber->numFrames == 0, "Can not call from a foreign method."); ObjClosure* closure = AS_CLOSURE(method->value); ASSERT(vm->fiber->stackTop - vm->fiber->stack >= closure->fn->arity, "Stack must have enough arguments for method."); // Clear the API stack. Now that wrenCall() has control, we no longer need // it. We use this being non-null to tell if re-entrant calls to foreign // methods are happening, so it's important to clear it out now so that you // can call foreign methods from within calls to wrenCall(). vm->apiStack = NULL; // Discard any extra temporary slots. We take for granted that the stub // function has exactly one slot for each argument. vm->fiber->stackTop = &vm->fiber->stack[closure->fn->maxSlots]; wrenCallFunction(vm, vm->fiber, closure, 0); WrenInterpretResult result = runInterpreter(vm, vm->fiber); // If the call didn't abort, then set up the API stack to point to the // beginning of the stack so the host can access the call's return value. if (vm->fiber != NULL) vm->apiStack = vm->fiber->stack; return result; } WrenHandle* wrenMakeHandle(WrenVM* vm, Value value) { if (IS_OBJ(value)) wrenPushRoot(vm, AS_OBJ(value)); // Make a handle for it. WrenHandle* handle = ALLOCATE(vm, WrenHandle); handle->value = value; if (IS_OBJ(value)) wrenPopRoot(vm); // Add it to the front of the linked list of handles. if (vm->handles != NULL) vm->handles->prev = handle; handle->prev = NULL; handle->next = vm->handles; vm->handles = handle; return handle; } void wrenReleaseHandle(WrenVM* vm, WrenHandle* handle) { ASSERT(handle != NULL, "Handle cannot be NULL."); // Update the VM's head pointer if we're releasing the first handle. if (vm->handles == handle) vm->handles = handle->next; // Unlink it from the list. if (handle->prev != NULL) handle->prev->next = handle->next; if (handle->next != NULL) handle->next->prev = handle->prev; // Clear it out. This isn't strictly necessary since we're going to free it, // but it makes for easier debugging. handle->prev = NULL; handle->next = NULL; handle->value = NULL_VAL; DEALLOCATE(vm, handle); } WrenInterpretResult wrenInterpret(WrenVM* vm, const char* module, const char* source) { ObjClosure* closure = wrenCompileSource(vm, module, source, false, true); if (closure == NULL) return WREN_RESULT_COMPILE_ERROR; wrenPushRoot(vm, (Obj*)closure); ObjFiber* fiber = wrenNewFiber(vm, closure); wrenPopRoot(vm); // closure. vm->apiStack = NULL; return runInterpreter(vm, fiber); } ObjClosure* wrenCompileSource(WrenVM* vm, const char* module, const char* source, bool isExpression, bool printErrors) { Value nameValue = NULL_VAL; if (module != NULL) { nameValue = wrenNewString(vm, module); wrenPushRoot(vm, AS_OBJ(nameValue)); } ObjClosure* closure = compileInModule(vm, nameValue, source, isExpression, printErrors); if (module != NULL) wrenPopRoot(vm); // nameValue. return closure; } Value wrenGetModuleVariable(WrenVM* vm, Value moduleName, Value variableName) { ObjModule* module = getModule(vm, moduleName); if (module == NULL) { vm->fiber->error = wrenStringFormat(vm, "Module '@' is not loaded.", moduleName); return NULL_VAL; } return getModuleVariable(vm, module, variableName); } Value wrenFindVariable(WrenVM* vm, ObjModule* module, const char* name) { int symbol = wrenSymbolTableFind(&module->variableNames, name, strlen(name)); return module->variables.data[symbol]; } int wrenDeclareVariable(WrenVM* vm, ObjModule* module, const char* name, size_t length, int line) { if (module->variables.count == MAX_MODULE_VARS) return -2; // Implicitly defined variables get a "value" that is the line where the // variable is first used. We'll use that later to report an error on the // right line. wrenValueBufferWrite(vm, &module->variables, NUM_VAL(line)); return wrenSymbolTableAdd(vm, &module->variableNames, name, length); } int wrenDefineVariable(WrenVM* vm, ObjModule* module, const char* name, size_t length, Value value, int* line) { if (module->variables.count == MAX_MODULE_VARS) return -2; if (IS_OBJ(value)) wrenPushRoot(vm, AS_OBJ(value)); // See if the variable is already explicitly or implicitly declared. int symbol = wrenSymbolTableFind(&module->variableNames, name, length); if (symbol == -1) { // Brand new variable. symbol = wrenSymbolTableAdd(vm, &module->variableNames, name, length); wrenValueBufferWrite(vm, &module->variables, value); } else if (IS_NUM(module->variables.data[symbol])) { // An implicitly declared variable's value will always be a number. // Now we have a real definition. if(line) *line = (int)AS_NUM(module->variables.data[symbol]); module->variables.data[symbol] = value; // If this was a localname we want to error if it was // referenced before this definition. if (wrenIsLocalName(name)) symbol = -3; } else { // Already explicitly declared. symbol = -1; } if (IS_OBJ(value)) wrenPopRoot(vm); return symbol; } // TODO: Inline? void wrenPushRoot(WrenVM* vm, Obj* obj) { ASSERT(obj != NULL, "Can't root NULL."); ASSERT(vm->numTempRoots < WREN_MAX_TEMP_ROOTS, "Too many temporary roots."); vm->tempRoots[vm->numTempRoots++] = obj; } void wrenPopRoot(WrenVM* vm) { ASSERT(vm->numTempRoots > 0, "No temporary roots to release."); vm->numTempRoots--; } int wrenGetSlotCount(WrenVM* vm) { if (vm->apiStack == NULL) return 0; return (int)(vm->fiber->stackTop - vm->apiStack); } void wrenEnsureSlots(WrenVM* vm, int numSlots) { // If we don't have a fiber accessible, create one for the API to use. if (vm->apiStack == NULL) { vm->fiber = wrenNewFiber(vm, NULL); vm->apiStack = vm->fiber->stack; } int currentSize = (int)(vm->fiber->stackTop - vm->apiStack); if (currentSize >= numSlots) return; // Grow the stack if needed. int needed = (int)(vm->apiStack - vm->fiber->stack) + numSlots; wrenEnsureStack(vm, vm->fiber, needed); vm->fiber->stackTop = vm->apiStack + numSlots; } // Ensures that [slot] is a valid index into the API's stack of slots. static void validateApiSlot(WrenVM* vm, int slot) { ASSERT(slot >= 0, "Slot cannot be negative."); ASSERT(slot < wrenGetSlotCount(vm), "Not that many slots."); } // Gets the type of the object in [slot]. WrenType wrenGetSlotType(WrenVM* vm, int slot) { validateApiSlot(vm, slot); if (IS_BOOL(vm->apiStack[slot])) return WREN_TYPE_BOOL; if (IS_NUM(vm->apiStack[slot])) return WREN_TYPE_NUM; if (IS_FOREIGN(vm->apiStack[slot])) return WREN_TYPE_FOREIGN; if (IS_LIST(vm->apiStack[slot])) return WREN_TYPE_LIST; if (IS_MAP(vm->apiStack[slot])) return WREN_TYPE_MAP; if (IS_NULL(vm->apiStack[slot])) return WREN_TYPE_NULL; if (IS_STRING(vm->apiStack[slot])) return WREN_TYPE_STRING; return WREN_TYPE_UNKNOWN; } bool wrenGetSlotBool(WrenVM* vm, int slot) { validateApiSlot(vm, slot); ASSERT(IS_BOOL(vm->apiStack[slot]), "Slot must hold a bool."); return AS_BOOL(vm->apiStack[slot]); } const char* wrenGetSlotBytes(WrenVM* vm, int slot, int* length) { validateApiSlot(vm, slot); ASSERT(IS_STRING(vm->apiStack[slot]), "Slot must hold a string."); ObjString* string = AS_STRING(vm->apiStack[slot]); *length = string->length; return string->value; } double wrenGetSlotDouble(WrenVM* vm, int slot) { validateApiSlot(vm, slot); ASSERT(IS_NUM(vm->apiStack[slot]), "Slot must hold a number."); return AS_NUM(vm->apiStack[slot]); } void* wrenGetSlotForeign(WrenVM* vm, int slot) { validateApiSlot(vm, slot); ASSERT(IS_FOREIGN(vm->apiStack[slot]), "Slot must hold a foreign instance."); return AS_FOREIGN(vm->apiStack[slot])->data; } const char* wrenGetSlotString(WrenVM* vm, int slot) { validateApiSlot(vm, slot); ASSERT(IS_STRING(vm->apiStack[slot]), "Slot must hold a string."); return AS_CSTRING(vm->apiStack[slot]); } WrenHandle* wrenGetSlotHandle(WrenVM* vm, int slot) { validateApiSlot(vm, slot); return wrenMakeHandle(vm, vm->apiStack[slot]); } // Stores [value] in [slot] in the foreign call stack. static void setSlot(WrenVM* vm, int slot, Value value) { validateApiSlot(vm, slot); vm->apiStack[slot] = value; } void wrenSetSlotBool(WrenVM* vm, int slot, bool value) { setSlot(vm, slot, BOOL_VAL(value)); } void wrenSetSlotBytes(WrenVM* vm, int slot, const char* bytes, size_t length) { ASSERT(bytes != NULL, "Byte array cannot be NULL."); setSlot(vm, slot, wrenNewStringLength(vm, bytes, length)); } void wrenSetSlotDouble(WrenVM* vm, int slot, double value) { setSlot(vm, slot, NUM_VAL(value)); } void* wrenSetSlotNewForeign(WrenVM* vm, int slot, int classSlot, size_t size) { validateApiSlot(vm, slot); validateApiSlot(vm, classSlot); ASSERT(IS_CLASS(vm->apiStack[classSlot]), "Slot must hold a class."); ObjClass* classObj = AS_CLASS(vm->apiStack[classSlot]); ASSERT(classObj->numFields == -1, "Class must be a foreign class."); ObjForeign* foreign = wrenNewForeign(vm, classObj, size); vm->apiStack[slot] = OBJ_VAL(foreign); return (void*)foreign->data; } void wrenSetSlotNewList(WrenVM* vm, int slot) { setSlot(vm, slot, OBJ_VAL(wrenNewList(vm, 0))); } void wrenSetSlotNewMap(WrenVM* vm, int slot) { setSlot(vm, slot, OBJ_VAL(wrenNewMap(vm))); } void wrenSetSlotNull(WrenVM* vm, int slot) { setSlot(vm, slot, NULL_VAL); } void wrenSetSlotString(WrenVM* vm, int slot, const char* text) { ASSERT(text != NULL, "String cannot be NULL."); setSlot(vm, slot, wrenNewString(vm, text)); } void wrenSetSlotHandle(WrenVM* vm, int slot, WrenHandle* handle) { ASSERT(handle != NULL, "Handle cannot be NULL."); setSlot(vm, slot, handle->value); } int wrenGetListCount(WrenVM* vm, int slot) { validateApiSlot(vm, slot); ASSERT(IS_LIST(vm->apiStack[slot]), "Slot must hold a list."); ValueBuffer elements = AS_LIST(vm->apiStack[slot])->elements; return elements.count; } void wrenGetListElement(WrenVM* vm, int listSlot, int index, int elementSlot) { validateApiSlot(vm, listSlot); validateApiSlot(vm, elementSlot); ASSERT(IS_LIST(vm->apiStack[listSlot]), "Slot must hold a list."); ValueBuffer elements = AS_LIST(vm->apiStack[listSlot])->elements; vm->apiStack[elementSlot] = elements.data[index]; } void wrenInsertInList(WrenVM* vm, int listSlot, int index, int elementSlot) { validateApiSlot(vm, listSlot); validateApiSlot(vm, elementSlot); ASSERT(IS_LIST(vm->apiStack[listSlot]), "Must insert into a list."); ObjList* list = AS_LIST(vm->apiStack[listSlot]); // Negative indices count from the end. if (index < 0) index = list->elements.count + 1 + index; ASSERT(index <= list->elements.count, "Index out of bounds."); wrenListInsert(vm, list, vm->apiStack[elementSlot], index); } int wrenGetMapCount(WrenVM* vm, int slot) { validateApiSlot(vm, slot); ASSERT(IS_MAP(vm->apiStack[slot]), "Slot must hold a map."); ObjMap* map = AS_MAP(vm->apiStack[slot]); return map->count; } bool wrenGetMapContainsKey(WrenVM* vm, int mapSlot, int keySlot) { validateApiSlot(vm, mapSlot); validateApiSlot(vm, keySlot); ASSERT(IS_MAP(vm->apiStack[mapSlot]), "Slot must hold a map."); Value key = vm->apiStack[keySlot]; if (!validateKey(vm, key)) return false; ObjMap* map = AS_MAP(vm->apiStack[mapSlot]); Value value = wrenMapGet(map, key); return !IS_UNDEFINED(value); } void wrenGetMapValue(WrenVM* vm, int mapSlot, int keySlot, int valueSlot) { validateApiSlot(vm, mapSlot); validateApiSlot(vm, keySlot); validateApiSlot(vm, valueSlot); ASSERT(IS_MAP(vm->apiStack[mapSlot]), "Slot must hold a map."); ObjMap* map = AS_MAP(vm->apiStack[mapSlot]); Value value = wrenMapGet(map, vm->apiStack[keySlot]); if (IS_UNDEFINED(value)) { value = NULL_VAL; } vm->apiStack[valueSlot] = value; } void wrenSetMapValue(WrenVM* vm, int mapSlot, int keySlot, int valueSlot) { validateApiSlot(vm, mapSlot); validateApiSlot(vm, keySlot); validateApiSlot(vm, valueSlot); ASSERT(IS_MAP(vm->apiStack[mapSlot]), "Must insert into a map."); Value key = vm->apiStack[keySlot]; if (!validateKey(vm, key)) { return; } Value value = vm->apiStack[valueSlot]; ObjMap* map = AS_MAP(vm->apiStack[mapSlot]); wrenMapSet(vm, map, key, value); } void wrenRemoveMapValue(WrenVM* vm, int mapSlot, int keySlot, int removedValueSlot) { validateApiSlot(vm, mapSlot); validateApiSlot(vm, keySlot); ASSERT(IS_MAP(vm->apiStack[mapSlot]), "Slot must hold a map."); Value key = vm->apiStack[keySlot]; if (!validateKey(vm, key)) { return; } ObjMap* map = AS_MAP(vm->apiStack[mapSlot]); Value removed = wrenMapRemoveKey(vm, map, key); setSlot(vm, removedValueSlot, removed); } void wrenGetVariable(WrenVM* vm, const char* module, const char* name, int slot) { ASSERT(module != NULL, "Module cannot be NULL."); ASSERT(name != NULL, "Variable name cannot be NULL."); Value moduleName = wrenStringFormat(vm, "$", module); wrenPushRoot(vm, AS_OBJ(moduleName)); ObjModule* moduleObj = getModule(vm, moduleName); ASSERT(moduleObj != NULL, "Could not find module."); wrenPopRoot(vm); // moduleName. int variableSlot = wrenSymbolTableFind(&moduleObj->variableNames, name, strlen(name)); ASSERT(variableSlot != -1, "Could not find variable."); setSlot(vm, slot, moduleObj->variables.data[variableSlot]); } void wrenAbortFiber(WrenVM* vm, int slot) { validateApiSlot(vm, slot); vm->fiber->error = vm->apiStack[slot]; } void* wrenGetUserData(WrenVM* vm) { return vm->config.userData; } void wrenSetUserData(WrenVM* vm, void* userData) { vm->config.userData = userData; } // End file "wren_vm.c" // Begin file "wren_opt_random.c" #if WREN_OPT_RANDOM #include <string.h> #include <time.h> // Begin file "wren_opt_random.wren.inc" // Generated automatically from src/optional/wren_opt_random.wren. Do not edit. static const char* randomModuleSource = "foreign class Random {\n" " construct new() {\n" " seed_()\n" " }\n" "\n" " construct new(seed) {\n" " if (seed is Num) {\n" " seed_(seed)\n" " } else if (seed is Sequence) {\n" " if (seed.isEmpty) Fiber.abort(\"Sequence cannot be empty.\")\n" "\n" " // TODO: Empty sequence.\n" " var seeds = []\n" " for (element in seed) {\n" " if (!(element is Num)) Fiber.abort(\"Sequence elements must all be numbers.\")\n" "\n" " seeds.add(element)\n" " if (seeds.count == 16) break\n" " }\n" "\n" " // Cycle the values to fill in any missing slots.\n" " var i = 0\n" " while (seeds.count < 16) {\n" " seeds.add(seeds[i])\n" " i = i + 1\n" " }\n" "\n" " seed_(\n" " seeds[0], seeds[1], seeds[2], seeds[3],\n" " seeds[4], seeds[5], seeds[6], seeds[7],\n" " seeds[8], seeds[9], seeds[10], seeds[11],\n" " seeds[12], seeds[13], seeds[14], seeds[15])\n" " } else {\n" " Fiber.abort(\"Seed must be a number or a sequence of numbers.\")\n" " }\n" " }\n" "\n" " foreign seed_()\n" " foreign seed_(seed)\n" " foreign seed_(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16)\n" "\n" " foreign float()\n" " float(end) { float() * end }\n" " float(start, end) { float() * (end - start) + start }\n" "\n" " foreign int()\n" " int(end) { (float() * end).floor }\n" " int(start, end) { (float() * (end - start)).floor + start }\n" "\n" " sample(list) {\n" " if (list.count == 0) Fiber.abort(\"Not enough elements to sample.\")\n" " return list[int(list.count)]\n" " }\n" " sample(list, count) {\n" " if (count > list.count) Fiber.abort(\"Not enough elements to sample.\")\n" "\n" " var result = []\n" "\n" " // The algorithm described in \"Programming pearls: a sample of brilliance\".\n" " // Use a hash map for sample sizes less than 1/4 of the population size and\n" " // an array of booleans for larger samples. This simple heuristic improves\n" " // performance for large sample sizes as well as reduces memory usage.\n" " if (count * 4 < list.count) {\n" " var picked = {}\n" " for (i in list.count - count...list.count) {\n" " var index = int(i + 1)\n" " if (picked.containsKey(index)) index = i\n" " picked[index] = true\n" " result.add(list[index])\n" " }\n" " } else {\n" " var picked = List.filled(list.count, false)\n" " for (i in list.count - count...list.count) {\n" " var index = int(i + 1)\n" " if (picked[index]) index = i\n" " picked[index] = true\n" " result.add(list[index])\n" " }\n" " }\n" "\n" " return result\n" " }\n" "\n" " shuffle(list) {\n" " if (list.isEmpty) return\n" "\n" " // Fisher-Yates shuffle.\n" " for (i in 0...list.count - 1) {\n" " var from = int(i, list.count)\n" " var temp = list[from]\n" " list[from] = list[i]\n" " list[i] = temp\n" " }\n" " }\n" "}\n"; // End file "wren_opt_random.wren.inc" // Implements the well equidistributed long-period linear PRNG (WELL512a). // // https://en.wikipedia.org/wiki/Well_equidistributed_long-period_linear typedef struct { uint32_t state[16]; uint32_t index; } Well512; // Code from: http://www.lomont.org/Math/Papers/2008/Lomont_PRNG_2008.pdf static uint32_t advanceState(Well512* well) { uint32_t a, b, c, d; a = well->state[well->index]; c = well->state[(well->index + 13) & 15]; b = a ^ c ^ (a << 16) ^ (c << 15); c = well->state[(well->index + 9) & 15]; c ^= (c >> 11); a = well->state[well->index] = b ^ c; d = a ^ ((a << 5) & 0xda442d24U); well->index = (well->index + 15) & 15; a = well->state[well->index]; well->state[well->index] = a ^ b ^ d ^ (a << 2) ^ (b << 18) ^ (c << 28); return well->state[well->index]; } static void randomAllocate(WrenVM* vm) { Well512* well = (Well512*)wrenSetSlotNewForeign(vm, 0, 0, sizeof(Well512)); well->index = 0; } static void randomSeed0(WrenVM* vm) { Well512* well = (Well512*)wrenGetSlotForeign(vm, 0); srand((uint32_t)time(NULL)); for (int i = 0; i < 16; i++) { well->state[i] = rand(); } } static void randomSeed1(WrenVM* vm) { Well512* well = (Well512*)wrenGetSlotForeign(vm, 0); srand((uint32_t)wrenGetSlotDouble(vm, 1)); for (int i = 0; i < 16; i++) { well->state[i] = rand(); } } static void randomSeed16(WrenVM* vm) { Well512* well = (Well512*)wrenGetSlotForeign(vm, 0); for (int i = 0; i < 16; i++) { well->state[i] = (uint32_t)wrenGetSlotDouble(vm, i + 1); } } static void randomFloat(WrenVM* vm) { Well512* well = (Well512*)wrenGetSlotForeign(vm, 0); // A double has 53 bits of precision in its mantissa, and we'd like to take // full advantage of that, so we need 53 bits of random source data. // First, start with 32 random bits, shifted to the left 21 bits. double result = (double)advanceState(well) * (1 << 21); // Then add another 21 random bits. result += (double)(advanceState(well) & ((1 << 21) - 1)); // Now we have a number from 0 - (2^53). Divide be the range to get a double // from 0 to 1.0 (half-inclusive). result /= 9007199254740992.0; wrenSetSlotDouble(vm, 0, result); } static void randomInt0(WrenVM* vm) { Well512* well = (Well512*)wrenGetSlotForeign(vm, 0); wrenSetSlotDouble(vm, 0, (double)advanceState(well)); } const char* wrenRandomSource() { return randomModuleSource; } WrenForeignClassMethods wrenRandomBindForeignClass(WrenVM* vm, const char* module, const char* className) { ASSERT(strcmp(className, "Random") == 0, "Should be in Random class."); WrenForeignClassMethods methods; methods.allocate = randomAllocate; methods.finalize = NULL; return methods; } WrenForeignMethodFn wrenRandomBindForeignMethod(WrenVM* vm, const char* className, bool isStatic, const char* signature) { ASSERT(strcmp(className, "Random") == 0, "Should be in Random class."); if (strcmp(signature, "<allocate>") == 0) return randomAllocate; if (strcmp(signature, "seed_()") == 0) return randomSeed0; if (strcmp(signature, "seed_(_)") == 0) return randomSeed1; if (strcmp(signature, "seed_(_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_)") == 0) { return randomSeed16; } if (strcmp(signature, "float()") == 0) return randomFloat; if (strcmp(signature, "int()") == 0) return randomInt0; ASSERT(false, "Unknown method."); return NULL; } #endif // End file "wren_opt_random.c" // Begin file "wren_opt_meta.c" #if WREN_OPT_META #include <string.h> // Begin file "wren_opt_meta.wren.inc" // Generated automatically from src/optional/wren_opt_meta.wren. Do not edit. static const char* metaModuleSource = "class Meta {\n" " static getModuleVariables(module) {\n" " if (!(module is String)) Fiber.abort(\"Module name must be a string.\")\n" " var result = getModuleVariables_(module)\n" " if (result != null) return result\n" "\n" " Fiber.abort(\"Could not find a module named '%(module)'.\")\n" " }\n" "\n" " static eval(source) {\n" " if (!(source is String)) Fiber.abort(\"Source code must be a string.\")\n" "\n" " var closure = compile_(source, false, false)\n" " // TODO: Include compile errors.\n" " if (closure == null) Fiber.abort(\"Could not compile source code.\")\n" "\n" " closure.call()\n" " }\n" "\n" " static compileExpression(source) {\n" " if (!(source is String)) Fiber.abort(\"Source code must be a string.\")\n" " return compile_(source, true, true)\n" " }\n" "\n" " static compile(source) {\n" " if (!(source is String)) Fiber.abort(\"Source code must be a string.\")\n" " return compile_(source, false, true)\n" " }\n" "\n" " foreign static compile_(source, isExpression, printErrors)\n" " foreign static getModuleVariables_(module)\n" "}\n"; // End file "wren_opt_meta.wren.inc" void metaCompile(WrenVM* vm) { const char* source = wrenGetSlotString(vm, 1); bool isExpression = wrenGetSlotBool(vm, 2); bool printErrors = wrenGetSlotBool(vm, 3); // TODO: Allow passing in module? // Look up the module surrounding the callsite. This is brittle. The -2 walks // up the callstack assuming that the meta module has one level of // indirection before hitting the user's code. Any change to meta may require // this constant to be tweaked. ObjFiber* currentFiber = vm->fiber; ObjFn* fn = currentFiber->frames[currentFiber->numFrames - 2].closure->fn; ObjString* module = fn->module->name; ObjClosure* closure = wrenCompileSource(vm, module->value, source, isExpression, printErrors); // Return the result. We can't use the public API for this since we have a // bare ObjClosure*. if (closure == NULL) { vm->apiStack[0] = NULL_VAL; } else { vm->apiStack[0] = OBJ_VAL(closure); } } void metaGetModuleVariables(WrenVM* vm) { wrenEnsureSlots(vm, 3); Value moduleValue = wrenMapGet(vm->modules, vm->apiStack[1]); if (IS_UNDEFINED(moduleValue)) { vm->apiStack[0] = NULL_VAL; return; } ObjModule* module = AS_MODULE(moduleValue); ObjList* names = wrenNewList(vm, module->variableNames.count); vm->apiStack[0] = OBJ_VAL(names); // Initialize the elements to null in case a collection happens when we // allocate the strings below. for (int i = 0; i < names->elements.count; i++) { names->elements.data[i] = NULL_VAL; } for (int i = 0; i < names->elements.count; i++) { names->elements.data[i] = OBJ_VAL(module->variableNames.data[i]); } } const char* wrenMetaSource() { return metaModuleSource; } WrenForeignMethodFn wrenMetaBindForeignMethod(WrenVM* vm, const char* className, bool isStatic, const char* signature) { // There is only one foreign method in the meta module. ASSERT(strcmp(className, "Meta") == 0, "Should be in Meta class."); ASSERT(isStatic, "Should be static."); if (strcmp(signature, "compile_(_,_,_)") == 0) { return metaCompile; } if (strcmp(signature, "getModuleVariables_(_)") == 0) { return metaGetModuleVariables; } ASSERT(false, "Unknown method."); return NULL; } #endif // End file "wren_opt_meta.c"
the_stack_data/93506.c
/* * https://www.hackerrank.com/challenges/birthday-cake-candles/problem */ #include<stdio.h> int birthdayCakeCandles(int n,int *array) { int max = array[0]; int count = 0; for(int i=0; i<n; i++) { if(array[i] > max) max = array[i]; } for(int i=0; i<n; i++) { if (array[i] == max) count++; } return count; } int main() { int n,i; scanf("%d",&n); int arr[n]; for(int i=0;i<n;i++) { scanf("%d",&arr[i]); } int s= birthdayCakeCandles(n,arr); printf("%d",s); return 0; }
the_stack_data/200142822.c
/* Scrivere un programma che visualizzi una tabella di questo genere N 10*N 100*N 1000*N 1 10 100 10000 2 20 200 20000 fino ad 10 */ #include <stdio.h> int main(){ printf("\tN\t10*N\t100*N\t1000*N\n\n"); int contatore; for(contatore = 1; contatore <= 10; contatore++){ printf("\t%.0d\t%.0d\t%.0d\t%.0d\n", contatore, contatore*10, contatore*100, contatore*1000); } return 0; }
the_stack_data/176704378.c
/* * MIT License * * Copyright (c) 2018 Kalate Hexanome, 4IF, INSA Lyon * * 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", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /* * Multi-line comment. */ #include <stdio.h> #include <stdint.h> int32_t sum(int32_t a, int32_t b) { return a + b; } int32_t main() { int32_t a = 5; putchar('0' + a); putchar('\n'); // putchar(a); // b = a - 1; // putchar(b); // putchar('\n'); return 0; }
the_stack_data/54706.c
#include <unistd.h> #include <sys/ioctl.h> #include <termios.h> #include <errno.h> int isatty(int fd) { pid_t pid; // dummy one int saved; // saved errno int rc; saved = errno; rc = ioctl(fd, TIOCGPGRP, &pid); errno = saved; return !rc; }
the_stack_data/73040.c
/*** * This code is a part of EvoApproxLib library (ehw.fit.vutbr.cz/approxlib) distributed under The MIT License. * When used, please cite the following article(s): V. Mrazek, L. Sekanina, Z. Vasicek "Libraries of Approximate Circuits: Automated Design and Application in CNN Accelerators" IEEE Journal on Emerging and Selected Topics in Circuits and Systems, Vol 10, No 4, 2020 * This file contains a circuit from a sub-set of pareto optimal circuits with respect to the pwr and mre parameters ***/ // MAE% = 0.012 % // MAE = 0.5 // WCE% = 0.024 % // WCE = 1.0 // WCRE% = 100.00 % // EP% = 50.00 % // MRE% = 0.21 % // MSE = 0.5 // PDK45_PWR = 0.052 mW // PDK45_AREA = 102.3 um2 // PDK45_DELAY = 0.92 ns #include <stdint.h> #include <stdlib.h> uint64_t add12se_58Y(const uint64_t B,const uint64_t A) { uint64_t dout_26, dout_27, dout_28, dout_29, dout_30, dout_31, dout_32, dout_33, dout_34, dout_35, dout_36, dout_37, dout_38, dout_39, dout_40, dout_41, dout_42, dout_43, dout_44, dout_45, dout_46, dout_47, dout_48, dout_49, dout_50, dout_51, dout_52, dout_53, dout_54, dout_55, dout_56, dout_57, dout_58, dout_59, dout_60, dout_61, dout_62, dout_63, dout_64, dout_65, dout_66, dout_67, dout_68, dout_69, dout_70, dout_71, dout_72, dout_73, dout_74, dout_75, dout_76, dout_77, dout_78, dout_79, dout_80, dout_81, dout_82, dout_83, dout_84, dout_85, dout_86, dout_87, dout_88, dout_89, dout_90, dout_91, dout_92, dout_93, dout_94, dout_95, dout_96, dout_97, dout_98, dout_99, dout_100, dout_101, dout_102, dout_103, dout_104, dout_105, dout_106, dout_107, dout_108, dout_109, dout_110, dout_111, dout_112; uint64_t O; dout_26=((A >> 1)&1)&((B >> 1)&1); dout_27=((A >> 1)&1)^((B >> 1)&1); dout_28=((A >> 2)&1)&((B >> 2)&1); dout_29=((A >> 2)&1)^((B >> 2)&1); dout_30=((A >> 3)&1)&((B >> 3)&1); dout_31=((A >> 3)&1)^((B >> 3)&1); dout_32=((A >> 4)&1)&((B >> 4)&1); dout_33=((A >> 4)&1)^((B >> 4)&1); dout_34=((A >> 5)&1)&((B >> 5)&1); dout_35=((A >> 5)&1)^((B >> 5)&1); dout_36=((A >> 6)&1)&((B >> 6)&1); dout_37=((A >> 6)&1)^((B >> 6)&1); dout_38=((A >> 7)&1)&((B >> 7)&1); dout_39=((A >> 7)&1)^((B >> 7)&1); dout_40=((A >> 8)&1)&((B >> 8)&1); dout_41=((A >> 8)&1)^((B >> 8)&1); dout_42=((A >> 9)&1)&((B >> 9)&1); dout_43=((A >> 9)&1)^((B >> 9)&1); dout_44=((A >> 10)&1)&((B >> 10)&1); dout_45=((A >> 10)&1)^((B >> 10)&1); dout_46=((A >> 11)&1)&((B >> 11)&1); dout_47=((A >> 11)&1)^((B >> 11)&1); dout_48=((A >> 11)&1)^((B >> 11)&1); dout_49=dout_29&dout_26; dout_50=dout_29&dout_27; dout_51=dout_28|dout_49; dout_52=dout_33&dout_30; dout_53=dout_33&dout_31; dout_54=dout_32|dout_52; dout_55=dout_37&dout_34; dout_56=dout_37&dout_35; dout_57=dout_36|dout_55; dout_58=dout_41&dout_38; dout_59=dout_41&dout_39; dout_60=dout_40|dout_58; dout_61=dout_45&dout_42; dout_62=dout_45&dout_43; dout_63=dout_44|dout_61; dout_64=dout_27&((A >> 0)&1); dout_65=dout_26|dout_64; dout_66=dout_50&((A >> 0)&1); dout_67=dout_51|dout_66; dout_68=dout_35&dout_54; dout_69=dout_35&dout_53; dout_70=dout_34|dout_68; dout_71=dout_56&dout_54; dout_72=dout_56&dout_53; dout_73=dout_57|dout_71; dout_74=dout_43&dout_60; dout_75=dout_43&dout_59; dout_76=dout_42|dout_74; dout_77=dout_62&dout_60; dout_78=dout_62&dout_59; dout_79=dout_63|dout_77; dout_80=dout_31&dout_67; dout_81=dout_30|dout_80; dout_82=dout_53&dout_67; dout_83=dout_54|dout_82; dout_84=dout_69&dout_67; dout_85=dout_70|dout_84; dout_86=dout_72&dout_67; dout_87=dout_73|dout_86; dout_88=dout_47&dout_79; dout_89=dout_47&dout_78; dout_90=dout_46|dout_88; dout_91=dout_39&dout_87; dout_92=dout_38|dout_91; dout_93=dout_59&dout_87; dout_94=dout_60|dout_93; dout_95=dout_75&dout_87; dout_96=dout_76|dout_95; dout_97=dout_78&dout_87; dout_98=dout_79|dout_97; dout_99=dout_89&dout_87; dout_100=dout_90|dout_99; dout_101=dout_27^((A >> 0)&1); dout_102=dout_29^dout_65; dout_103=dout_31^dout_67; dout_104=dout_33^dout_81; dout_105=dout_35^dout_83; dout_106=dout_37^dout_85; dout_107=dout_39^dout_87; dout_108=dout_41^dout_92; dout_109=dout_43^dout_94; dout_110=dout_45^dout_96; dout_111=dout_47^dout_98; dout_112=dout_48^dout_100; O = 0; O |= (0&1) << 0; O |= (dout_101&1) << 1; O |= (dout_102&1) << 2; O |= (dout_103&1) << 3; O |= (dout_104&1) << 4; O |= (dout_105&1) << 5; O |= (dout_106&1) << 6; O |= (dout_107&1) << 7; O |= (dout_108&1) << 8; O |= (dout_109&1) << 9; O |= (dout_110&1) << 10; O |= (dout_111&1) << 11; O |= (dout_112&1) << 12; return O; }
the_stack_data/218892254.c
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); void __VERIFIER_assert(int expression) { if (!expression) { ERROR: /* assert not proved */ /* assert not proved */ __VERIFIER_error(); }; return; } int __global_lock; void __VERIFIER_atomic_begin() { /* reachable */ /* reachable */ /* reachable */ /* reachable */ /* reachable */ /* reachable */ /* reachable */ __VERIFIER_assume(__global_lock==0); __global_lock=1; return; } void __VERIFIER_atomic_end() { __VERIFIER_assume(__global_lock==1); __global_lock=0; return; } #include <assert.h> #include <pthread.h> #ifndef TRUE #define TRUE (_Bool)1 #endif #ifndef FALSE #define FALSE (_Bool)0 #endif #ifndef NULL #define NULL ((void*)0) #endif #ifndef FENCE #define FENCE(x) ((void)0) #endif #ifndef IEEE_FLOAT_EQUAL #define IEEE_FLOAT_EQUAL(x,y) (x==y) #endif #ifndef IEEE_FLOAT_NOTEQUAL #define IEEE_FLOAT_NOTEQUAL(x,y) (x!=y) #endif void * P0(void *arg); void * P1(void *arg); void * P2(void *arg); void fence(); void isync(); void lwfence(); int __unbuffered_cnt; int __unbuffered_cnt = 0; int __unbuffered_p0_EAX; int __unbuffered_p0_EAX = 0; int __unbuffered_p0_EBX; int __unbuffered_p0_EBX = 0; int __unbuffered_p2_EAX; int __unbuffered_p2_EAX = 0; int __unbuffered_p2_EBX; int __unbuffered_p2_EBX = 0; int a; int a = 0; _Bool main$tmp_guard0; _Bool main$tmp_guard1; int x; int x = 0; int y; int y = 0; _Bool y$flush_delayed; int y$mem_tmp; _Bool y$r_buff0_thd0; _Bool y$r_buff0_thd1; _Bool y$r_buff0_thd2; _Bool y$r_buff0_thd3; _Bool y$r_buff1_thd0; _Bool y$r_buff1_thd1; _Bool y$r_buff1_thd2; _Bool y$r_buff1_thd3; _Bool y$read_delayed; int *y$read_delayed_var; int y$w_buff0; _Bool y$w_buff0_used; int y$w_buff1; _Bool y$w_buff1_used; int z; int z = 0; _Bool weak$$choice0; _Bool weak$$choice2; void * P0(void *arg) { __VERIFIER_atomic_begin(); a = 1; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); x = 1; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_p0_EAX = x; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); weak$$choice0 = nondet_0(); weak$$choice2 = nondet_0(); y$flush_delayed = weak$$choice2; y$mem_tmp = y; y = !y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y : (y$w_buff0_used && y$r_buff0_thd1 ? y$w_buff0 : y$w_buff1); y$w_buff0 = weak$$choice2 ? y$w_buff0 : (!y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y$w_buff0 : (y$w_buff0_used && y$r_buff0_thd1 ? y$w_buff0 : y$w_buff0)); y$w_buff1 = weak$$choice2 ? y$w_buff1 : (!y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y$w_buff1 : (y$w_buff0_used && y$r_buff0_thd1 ? y$w_buff1 : y$w_buff1)); y$w_buff0_used = weak$$choice2 ? y$w_buff0_used : (!y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y$w_buff0_used : (y$w_buff0_used && y$r_buff0_thd1 ? FALSE : y$w_buff0_used)); y$w_buff1_used = weak$$choice2 ? y$w_buff1_used : (!y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y$w_buff1_used : (y$w_buff0_used && y$r_buff0_thd1 ? FALSE : FALSE)); y$r_buff0_thd1 = weak$$choice2 ? y$r_buff0_thd1 : (!y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y$r_buff0_thd1 : (y$w_buff0_used && y$r_buff0_thd1 ? FALSE : y$r_buff0_thd1)); y$r_buff1_thd1 = weak$$choice2 ? y$r_buff1_thd1 : (!y$w_buff0_used || !y$r_buff0_thd1 && !y$w_buff1_used || !y$r_buff0_thd1 && !y$r_buff1_thd1 ? y$r_buff1_thd1 : (y$w_buff0_used && y$r_buff0_thd1 ? FALSE : FALSE)); __unbuffered_p0_EBX = y; y = y$flush_delayed ? y$mem_tmp : y; y$flush_delayed = FALSE; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_cnt = __unbuffered_cnt + 1; __VERIFIER_atomic_end(); return nondet_1(); } void * P1(void *arg) { __VERIFIER_atomic_begin(); y$w_buff1 = y$w_buff0; y$w_buff0 = 1; y$w_buff1_used = y$w_buff0_used; y$w_buff0_used = TRUE; __VERIFIER_assert(!(y$w_buff1_used && y$w_buff0_used)); y$r_buff1_thd0 = y$r_buff0_thd0; y$r_buff1_thd1 = y$r_buff0_thd1; y$r_buff1_thd2 = y$r_buff0_thd2; y$r_buff1_thd3 = y$r_buff0_thd3; y$r_buff0_thd2 = TRUE; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); z = 1; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); y = y$w_buff0_used && y$r_buff0_thd2 ? y$w_buff0 : (y$w_buff1_used && y$r_buff1_thd2 ? y$w_buff1 : y); y$w_buff0_used = y$w_buff0_used && y$r_buff0_thd2 ? FALSE : y$w_buff0_used; y$w_buff1_used = y$w_buff0_used && y$r_buff0_thd2 || y$w_buff1_used && y$r_buff1_thd2 ? FALSE : y$w_buff1_used; y$r_buff0_thd2 = y$w_buff0_used && y$r_buff0_thd2 ? FALSE : y$r_buff0_thd2; y$r_buff1_thd2 = y$w_buff0_used && y$r_buff0_thd2 || y$w_buff1_used && y$r_buff1_thd2 ? FALSE : y$r_buff1_thd2; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_cnt = __unbuffered_cnt + 1; __VERIFIER_atomic_end(); return nondet_1(); } void * P2(void *arg) { __VERIFIER_atomic_begin(); z = 2; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_p2_EAX = z; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_p2_EBX = a; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); y = y$w_buff0_used && y$r_buff0_thd3 ? y$w_buff0 : (y$w_buff1_used && y$r_buff1_thd3 ? y$w_buff1 : y); y$w_buff0_used = y$w_buff0_used && y$r_buff0_thd3 ? FALSE : y$w_buff0_used; y$w_buff1_used = y$w_buff0_used && y$r_buff0_thd3 || y$w_buff1_used && y$r_buff1_thd3 ? FALSE : y$w_buff1_used; y$r_buff0_thd3 = y$w_buff0_used && y$r_buff0_thd3 ? FALSE : y$r_buff0_thd3; y$r_buff1_thd3 = y$w_buff0_used && y$r_buff0_thd3 || y$w_buff1_used && y$r_buff1_thd3 ? FALSE : y$r_buff1_thd3; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_cnt = __unbuffered_cnt + 1; __VERIFIER_atomic_end(); return nondet_1(); } void fence() { } void isync() { } void lwfence() { } int main() { pthread_create(NULL, NULL, P0, NULL); pthread_create(NULL, NULL, P1, NULL); pthread_create(NULL, NULL, P2, NULL); __VERIFIER_atomic_begin(); main$tmp_guard0 = __unbuffered_cnt == 3; __VERIFIER_atomic_end(); __VERIFIER_assume(main$tmp_guard0); __VERIFIER_atomic_begin(); y = y$w_buff0_used && y$r_buff0_thd0 ? y$w_buff0 : (y$w_buff1_used && y$r_buff1_thd0 ? y$w_buff1 : y); y$w_buff0_used = y$w_buff0_used && y$r_buff0_thd0 ? FALSE : y$w_buff0_used; y$w_buff1_used = y$w_buff0_used && y$r_buff0_thd0 || y$w_buff1_used && y$r_buff1_thd0 ? FALSE : y$w_buff1_used; y$r_buff0_thd0 = y$w_buff0_used && y$r_buff0_thd0 ? FALSE : y$r_buff0_thd0; y$r_buff1_thd0 = y$w_buff0_used && y$r_buff0_thd0 || y$w_buff1_used && y$r_buff1_thd0 ? FALSE : y$r_buff1_thd0; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); /* Program proven to be relaxed for X86, model checker says YES. */ main$tmp_guard1 = !(z == 2 && __unbuffered_p0_EAX == 1 && __unbuffered_p0_EBX == 0 && __unbuffered_p2_EAX == 2 && __unbuffered_p2_EBX == 0); __VERIFIER_atomic_end(); /* Program proven to be relaxed for X86, model checker says YES. */ __VERIFIER_assert(main$tmp_guard1); /* reachable */ return 0; }
the_stack_data/193892294.c
#include<stdio.h> #include<stdlib.h> struct qsortArgs { int* b; int* e; }; struct qsortArgs a1; int a[] = {7, 5, 9, 10,}; int main(void) { a1 = (struct qsortArgs){a, a + sizeof(a) / sizeof(a[0])}; for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) { printf("%d;", a[i]); } printf("\n"); return 0; }
the_stack_data/57951738.c
/* * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright © 2008 Red Hat, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Soft- * ware"), to deal in the Software without restriction, including without * limitation the rights to use, copy, modify, merge, publish, distribute, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, provided that the above copyright * notice(s) and this permission notice appear in all copies of the Soft- * ware and that both the above copyright notice(s) and this permission * notice appear in supporting documentation. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- * MANCE OF THIS SOFTWARE. * * Except as contained in this notice, the name of a copyright holder shall * not be used in advertising or otherwise to promote the sale, use or * other dealings in this Software without prior written authorization of * the copyright holder. * * Authors: * Kevin E. Martin <[email protected]> * Brian Paul <[email protected]> * Kristian Høgsberg ([email protected]) */ #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) #include <unistd.h> #include <dlfcn.h> #include <stdarg.h> #include "glxclient.h" #include "dri_common.h" #ifndef RTLD_NOW #define RTLD_NOW 0 #endif #ifndef RTLD_GLOBAL #define RTLD_GLOBAL 0 #endif /** * Print informational message to stderr if LIBGL_DEBUG is set to * "verbose". */ _X_HIDDEN void InfoMessageF(const char *f, ...) { va_list args; const char *env; if ((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) { fprintf(stderr, "libGL: "); va_start(args, f); vfprintf(stderr, f, args); va_end(args); } } /** * Print error message to stderr if LIBGL_DEBUG is set to anything but * "quiet", (do nothing if LIBGL_DEBUG is unset). */ _X_HIDDEN void ErrorMessageF(const char *f, ...) { va_list args; const char *env; if ((env = getenv("LIBGL_DEBUG")) && !strstr(env, "quiet")) { fprintf(stderr, "libGL error: "); va_start(args, f); vfprintf(stderr, f, args); va_end(args); } } /** * Print error message unless LIBGL_DEBUG is set to "quiet". * * The distinction between CriticalErrorMessageF and ErrorMessageF is * that critcial errors will be printed by default, (even when * LIBGL_DEBUG is unset). */ _X_HIDDEN void CriticalErrorMessageF(const char *f, ...) { va_list args; const char *env; if (!(env = getenv("LIBGL_DEBUG")) || !strstr(env, "quiet")) { fprintf(stderr, "libGL error: "); va_start(args, f); vfprintf(stderr, f, args); va_end(args); if (!env || !strstr(env, "verbose")) fprintf(stderr, "libGL error: Try again with LIBGL_DEBUG=verbose for more details.\n"); } } #ifndef DEFAULT_DRIVER_DIR /* this is normally defined in Mesa/configs/default with DRI_DRIVER_SEARCH_PATH */ #define DEFAULT_DRIVER_DIR "/usr/local/lib/dri" #endif /** * Try to \c dlopen the named driver. * * This function adds the "_dri.so" suffix to the driver name and searches the * directories specified by the \c LIBGL_DRIVERS_PATH environment variable in * order to find the driver. * * \param driverName - a name like "i965", "radeon", "nouveau", etc. * * \returns * A handle from \c dlopen, or \c NULL if driver file not found. */ _X_HIDDEN void * driOpenDriver(const char *driverName) { void *glhandle, *handle; const char *libPaths, *p, *next; char realDriverName[200]; int len; /* Attempt to make sure libGL symbols will be visible to the driver */ glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL); libPaths = NULL; if (geteuid() == getuid()) { /* don't allow setuid apps to use LIBGL_DRIVERS_PATH */ libPaths = getenv("LIBGL_DRIVERS_PATH"); if (!libPaths) libPaths = getenv("LIBGL_DRIVERS_DIR"); /* deprecated */ } if (libPaths == NULL) libPaths = DEFAULT_DRIVER_DIR; handle = NULL; for (p = libPaths; *p; p = next) { next = strchr(p, ':'); if (next == NULL) { len = strlen(p); next = p + len; } else { len = next - p; next++; } #ifdef GLX_USE_TLS snprintf(realDriverName, sizeof realDriverName, "%.*s/tls/%s_dri.so", len, p, driverName); InfoMessageF("OpenDriver: trying %s\n", realDriverName); handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL); #endif if (handle == NULL) { snprintf(realDriverName, sizeof realDriverName, "%.*s/%s_dri.so", len, p, driverName); InfoMessageF("OpenDriver: trying %s\n", realDriverName); handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL); } if (handle != NULL) break; else ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror()); } if (!handle) ErrorMessageF("unable to load driver: %s_dri.so\n", driverName); if (glhandle) dlclose(glhandle); return handle; } static GLboolean __driGetMSCRate(__DRIdrawable *draw, int32_t * numerator, int32_t * denominator, void *loaderPrivate) { __GLXDRIdrawable *glxDraw = loaderPrivate; return __glxGetMscRate(glxDraw, numerator, denominator); } _X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension = { {__DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION}, __glXGetUST, __driGetMSCRate }; #define __ATTRIB(attrib, field) \ { attrib, offsetof(struct glx_config, field) } static const struct { unsigned int attrib, offset; } attribMap[] = { __ATTRIB(__DRI_ATTRIB_BUFFER_SIZE, rgbBits), __ATTRIB(__DRI_ATTRIB_LEVEL, level), __ATTRIB(__DRI_ATTRIB_RED_SIZE, redBits), __ATTRIB(__DRI_ATTRIB_GREEN_SIZE, greenBits), __ATTRIB(__DRI_ATTRIB_BLUE_SIZE, blueBits), __ATTRIB(__DRI_ATTRIB_ALPHA_SIZE, alphaBits), __ATTRIB(__DRI_ATTRIB_DEPTH_SIZE, depthBits), __ATTRIB(__DRI_ATTRIB_STENCIL_SIZE, stencilBits), __ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE, accumRedBits), __ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE, accumGreenBits), __ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE, accumBlueBits), __ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE, accumAlphaBits), __ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS, sampleBuffers), __ATTRIB(__DRI_ATTRIB_SAMPLES, samples), __ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode), __ATTRIB(__DRI_ATTRIB_STEREO, stereoMode), __ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers), #if 0 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel), __ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentIndex), __ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed), __ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen), __ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue), __ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha), __ATTRIB(__DRI_ATTRIB_RED_MASK, redMask), __ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask), __ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask), __ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask), #endif __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth), __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight), __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels), __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth), __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight), #if 0 __ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod), #endif __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb), __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba), __ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE, bindToMipmapTexture), __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted), __ATTRIB(__DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE, sRGBCapable) }; static int scalarEqual(struct glx_config *mode, unsigned int attrib, unsigned int value) { unsigned int glxValue; int i; for (i = 0; i < ARRAY_SIZE(attribMap); i++) if (attribMap[i].attrib == attrib) { glxValue = *(unsigned int *) ((char *) mode + attribMap[i].offset); return glxValue == GLX_DONT_CARE || glxValue == value; } return GL_TRUE; /* Is a non-existing attribute equal to value? */ } static int driConfigEqual(const __DRIcoreExtension *core, struct glx_config *config, const __DRIconfig *driConfig) { unsigned int attrib, value, glxValue; int i; i = 0; while (core->indexConfigAttrib(driConfig, i++, &attrib, &value)) { switch (attrib) { case __DRI_ATTRIB_RENDER_TYPE: glxValue = 0; if (value & __DRI_ATTRIB_RGBA_BIT) { glxValue |= GLX_RGBA_BIT; } else if (value & __DRI_ATTRIB_COLOR_INDEX_BIT) { glxValue |= GLX_COLOR_INDEX_BIT; } if (glxValue != config->renderType) return GL_FALSE; break; case __DRI_ATTRIB_CONFIG_CAVEAT: if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG) glxValue = GLX_NON_CONFORMANT_CONFIG; else if (value & __DRI_ATTRIB_SLOW_BIT) glxValue = GLX_SLOW_CONFIG; else glxValue = GLX_NONE; if (glxValue != config->visualRating) return GL_FALSE; break; case __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS: glxValue = 0; if (value & __DRI_ATTRIB_TEXTURE_1D_BIT) glxValue |= GLX_TEXTURE_1D_BIT_EXT; if (value & __DRI_ATTRIB_TEXTURE_2D_BIT) glxValue |= GLX_TEXTURE_2D_BIT_EXT; if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT) glxValue |= GLX_TEXTURE_RECTANGLE_BIT_EXT; if (config->bindToTextureTargets != GLX_DONT_CARE && glxValue != config->bindToTextureTargets) return GL_FALSE; break; default: if (!scalarEqual(config, attrib, value)) return GL_FALSE; } } return GL_TRUE; } static struct glx_config * createDriMode(const __DRIcoreExtension * core, struct glx_config *config, const __DRIconfig **driConfigs) { __GLXDRIconfigPrivate *driConfig; int i; for (i = 0; driConfigs[i]; i++) { if (driConfigEqual(core, config, driConfigs[i])) break; } if (driConfigs[i] == NULL) return NULL; driConfig = Xmalloc(sizeof *driConfig); if (driConfig == NULL) return NULL; driConfig->base = *config; driConfig->driConfig = driConfigs[i]; return &driConfig->base; } _X_HIDDEN struct glx_config * driConvertConfigs(const __DRIcoreExtension * core, struct glx_config *configs, const __DRIconfig **driConfigs) { struct glx_config head, *tail, *m; tail = &head; head.next = NULL; for (m = configs; m; m = m->next) { tail->next = createDriMode(core, m, driConfigs); if (tail->next == NULL) { /* no matching dri config for m */ continue; } tail = tail->next; } return head.next; } _X_HIDDEN void driDestroyConfigs(const __DRIconfig **configs) { int i; for (i = 0; configs[i]; i++) free((__DRIconfig *) configs[i]); free(configs); } _X_HIDDEN __GLXDRIdrawable * driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable) { struct glx_display *const priv = __glXInitialize(gc->psc->dpy); __GLXDRIdrawable *pdraw; struct glx_screen *psc; if (priv == NULL) return NULL; psc = priv->screens[gc->screen]; if (priv->drawHash == NULL) return NULL; if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0) { pdraw->refcount ++; return pdraw; } pdraw = psc->driScreen->createDrawable(psc, glxDrawable, glxDrawable, gc->config); if (pdraw == NULL) { ErrorMessageF("failed to create drawable\n"); return NULL; } if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) { (*pdraw->destroyDrawable) (pdraw); return NULL; } pdraw->refcount = 1; return pdraw; } _X_HIDDEN void driReleaseDrawables(struct glx_context *gc) { const struct glx_display *priv = gc->psc->display; __GLXDRIdrawable *pdraw; if (priv == NULL) return; if (__glxHashLookup(priv->drawHash, gc->currentDrawable, (void *) &pdraw) == 0) { if (pdraw->drawable == pdraw->xDrawable) { pdraw->refcount --; if (pdraw->refcount == 0) { (*pdraw->destroyDrawable)(pdraw); __glxHashDelete(priv->drawHash, gc->currentDrawable); } } } if (__glxHashLookup(priv->drawHash, gc->currentReadable, (void *) &pdraw) == 0) { if (pdraw->drawable == pdraw->xDrawable) { pdraw->refcount --; if (pdraw->refcount == 0) { (*pdraw->destroyDrawable)(pdraw); __glxHashDelete(priv->drawHash, gc->currentReadable); } } } gc->currentDrawable = None; gc->currentReadable = None; } _X_HIDDEN bool dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs, unsigned *major_ver, unsigned *minor_ver, uint32_t *flags, unsigned *api, int *reset, unsigned *error) { unsigned i; bool got_profile = false; uint32_t profile; int render_type = GLX_RGBA_TYPE; if (num_attribs == 0) { *api = __DRI_API_OPENGL; return true; } /* This is actually an internal error, but what the heck. */ if (attribs == NULL) { *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE; return false; } *major_ver = 1; *minor_ver = 0; *reset = __DRI_CTX_RESET_NO_NOTIFICATION; for (i = 0; i < num_attribs; i++) { switch (attribs[i * 2]) { case GLX_CONTEXT_MAJOR_VERSION_ARB: *major_ver = attribs[i * 2 + 1]; break; case GLX_CONTEXT_MINOR_VERSION_ARB: *minor_ver = attribs[i * 2 + 1]; break; case GLX_CONTEXT_FLAGS_ARB: *flags = attribs[i * 2 + 1]; break; case GLX_CONTEXT_PROFILE_MASK_ARB: profile = attribs[i * 2 + 1]; got_profile = true; break; case GLX_RENDER_TYPE: render_type = attribs[i * 2 + 1]; break; case GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB: switch (attribs[i * 2 + 1]) { case GLX_NO_RESET_NOTIFICATION_ARB: *reset = __DRI_CTX_RESET_NO_NOTIFICATION; break; case GLX_LOSE_CONTEXT_ON_RESET_ARB: *reset = __DRI_CTX_RESET_LOSE_CONTEXT; break; default: *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE; return false; } break; default: /* If an unknown attribute is received, fail. */ *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE; return false; } } *api = __DRI_API_OPENGL; if (!got_profile) { if (*major_ver > 3 || (*major_ver == 3 && *minor_ver >= 2)) *api = __DRI_API_OPENGL_CORE; } else { switch (profile) { case GLX_CONTEXT_CORE_PROFILE_BIT_ARB: /* There are no profiles before OpenGL 3.2. The * GLX_ARB_create_context_profile spec says: * * "If the requested OpenGL version is less than 3.2, * GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality * of the context is determined solely by the requested version." */ *api = (*major_ver > 3 || (*major_ver == 3 && *minor_ver >= 2)) ? __DRI_API_OPENGL_CORE : __DRI_API_OPENGL; break; case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB: *api = __DRI_API_OPENGL; break; case GLX_CONTEXT_ES2_PROFILE_BIT_EXT: *api = __DRI_API_GLES2; break; default: *error = __DRI_CTX_ERROR_BAD_API; return false; } } /* Unknown flag value. */ if (*flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE | __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS)) { *error = __DRI_CTX_ERROR_UNKNOWN_FLAG; return false; } /* There are no forward-compatible contexts before OpenGL 3.0. The * GLX_ARB_create_context spec says: * * "Forward-compatible contexts are defined only for OpenGL versions * 3.0 and later." */ if (*major_ver < 3 && (*flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) { *error = __DRI_CTX_ERROR_BAD_FLAG; return false; } if (*major_ver >= 3 && render_type == GLX_COLOR_INDEX_TYPE) { *error = __DRI_CTX_ERROR_BAD_FLAG; return false; } /* The GLX_EXT_create_context_es2_profile spec says: * * "... If the version requested is 2.0, and the * GLX_CONTEXT_ES2_PROFILE_BIT_EXT bit is set in the * GLX_CONTEXT_PROFILE_MASK_ARB attribute (see below), then the context * returned will implement OpenGL ES 2.0. This is the only way in which * an implementation may request an OpenGL ES 2.0 context." */ if (*api == __DRI_API_GLES2 && (*major_ver != 2 || *minor_ver != 0)) { *error = __DRI_CTX_ERROR_BAD_API; return false; } *error = __DRI_CTX_ERROR_SUCCESS; return true; } #endif /* GLX_DIRECT_RENDERING */
the_stack_data/29824342.c
// 预定义符号的更多例子 /* 计算给定半径的圆面积、圆周长和球体体积的函数*/ #include <stdio.h> #define PI 3.141592654 double area(double r){ return PI * r * r; } double circumference(double r){ return 2.0 * PI * r; } double volume(double r){ return 4.0 / 3.0 * PI * r * r *r; } int main(void){ double area(double r); double circumference(double r); double volume(double r); printf("radius = 1: %.4f %.4f %.4f\n", area(1), circumference(1), volume(1)); printf("radius = 4.98: %.4f %.4f %.4f\n", area(4.98), circumference(4.98), volume(4.98)); return 0; }
the_stack_data/3617.c
int f1() { return 1; }
the_stack_data/452974.c
#include <stdio.h> #include <stdlib.h> #include <string.h> /*! * \brief Calulates Pisano number and sequence * * Calulates the Mth Pisano period, is the period with which the sequence of Fibonacci numbers taken modulo M repeats * \param[in] M Mth Pisano number (long) * \param[out] Pseq pointer to array where the periodic sequnce of module M stored (long**) * \param[out] P pointer to where Pisano number stored (long*) * \return size of the array where pisano sequence stored (size_t). * */ size_t pisano_sequence( long M, long* *Pseq, long* P) { size_t array_s = 1024; (*Pseq) = (long*) realloc( (*Pseq), sizeof(long) * array_s ); long i = 0; long Fn, Fn1, temp, Max = 6 * M; Fn = 1; Fn1 = temp = 0; (*Pseq)[0] = 0; (*Pseq)[1] = 1; for ( i = 2; i <= Max; ++i) { temp = Fn; Fn = ( Fn1 + Fn ) % M ; Fn1 = temp; if ( i == array_s) { array_s += 1024; (*Pseq) = (long*) realloc ((*Pseq), sizeof(long) * array_s ); if( !(*Pseq) ) { fprintf(stderr, "Cannot allocate memory\n"); exit(EXIT_FAILURE); } } (*Pseq)[i] = (long) (Fn % M); if ((*Pseq)[i-1] == 0 && (*Pseq)[i] == 1) break; } (*P) = i - 1 ; //remove last mesurment becining of the next loop return array_s; } long get_fibonaccihuge(long n, long m) { long *Psequence = (long*) malloc(sizeof(long)); if( !(*Psequence) ) { fprintf(stderr, "Cannot allocate memory\n"); exit(EXIT_FAILURE); } long Pinerval; long out = 0; pisano_sequence( m, &Psequence, &Pinerval); out = (long) Psequence[ (n % Pinerval) ]; free(Psequence); Psequence = NULL; return out; } int main() { long a, b, huge; scanf("%ld %ld", &a, &b); if ( b == 1) { printf("0\n"); return 0; } huge = (long) get_fibonaccihuge(a, b); printf("%ld\n",huge ); return 0; }
the_stack_data/54824248.c
/* PR ipa/78121 */ /* { dg-do compile } */ /* { dg-options "-ansi -O2 -fdump-ipa-cp-details" } */ void fn2 (unsigned char c); int a; static void fn1(c) unsigned char c; { if (a) fn2 (c); fn1('#'); } void fn3() { fn1 (267); } /* { dg-final { scan-ipa-dump-times "Setting value range of param 0 \\\[11, 35\\\]" 1 "cp" } } */
the_stack_data/1243411.c
/* Studente: Lorenzo Gezzi Classe:3INA Data:15/04/2017 Versione: 1.0 */ #include<stdio.h> #include<stdlib.h> #include<math.h> int main(){ char parola1[100]; char parola2[100]; int i; int uguali; printf("Inserire la prima parola "); scanf("%s",parola1); printf("\nInserire la seconda parola "); scanf("%s",parola2); i=0; uguali=1; while((uguali==1)&&(parola1[i]!='\0'||parola2[i]!='\0')){ if(parola1[i]!=parola2[i]){ uguali=0; } i++; } if(uguali==1){ printf("\nLe due parole sono uguali"); } else{ printf("\nLe due parole sono diverse"); } printf("\n"); system("PAUSE"); }