{"decls":[{"body":["begin",["let","local_sum",0],["let","local_min",256],["let","local_max",0],["let","local_count",["-","end","start"]],["let","freq",["std.btree_map.empty_u32_u32"]],["for","i","start","end",["begin",["let","b",["view.get_u8","input","i"]],["set","local_sum",["+","local_sum","b"]],["if",["<u","b","local_min"],["set","local_min","b"],0],["if",[">u","b","local_max"],["set","local_max","b"],0],["let","old",["std.btree_map.get_u32_u32_or","freq","b",0]],["set","freq",["std.btree_map.put_u32_u32","freq","b",["+","old",1]]],0]],["let","freq_entries",["std.btree_map.len_u32_u32","freq"]],["let","freq_data",["std.btree_map.emit_kv_u32le_u32le","freq"]],["let","out",["std.vec.with_capacity",64]],["set","out",["std.u32.push_le","out","worker_id"]],["set","out",["std.u32.push_le","out","local_sum"]],["set","out",["std.u32.push_le","out","local_min"]],["set","out",["std.u32.push_le","out","local_max"]],["set","out",["std.u32.push_le","out","local_count"]],["set","out",["std.u32.push_le","out",["*","freq_entries",8]]],["set","out",["std.vec.extend_bytes","out","freq_data"]],["let","msg",["std.vec.as_bytes","out"]],["chan.bytes.send","out_chan","msg"],["bytes.alloc",0]],"kind":"defasync","name":"main.worker","params":[{"name":"out_chan","ty":"i32"},{"name":"worker_id","ty":"i32"},{"name":"start","ty":"i32"},{"name":"end","ty":"i32"}],"result":"bytes"}],"imports":["std.btree_map","std.fmt","std.u32","std.vec"],"kind":"entry","module_id":"main","schema_version":"x07.x07ast@0.8.0","solve":["task.scope_v1",["task.scope.cfg_v1",["max_children",8],["max_slot_result_bytes",4096]],["begin",["let","n",["view.len","input"]],["if",["=","n",0],["bytes.lit","ERROR:empty_input"],["begin",["let","num_workers",4],["let","out_chan",["chan.bytes.new","num_workers"]],["for","w",0,"num_workers",["begin",["let","chunk_start",["/",["*","n","w"],"num_workers"]],["let","chunk_end",["/",["*","n",["+","w",1]],"num_workers"]],["task.scope.start_soon_v1",["main.worker","out_chan","w","chunk_start","chunk_end"]],0]],["let","global_sum",0],["let","global_min",256],["let","global_max",0],["let","global_count",0],["let","global_freq",["std.btree_map.empty_u32_u32"]],["for","w",0,"num_workers",["begin",["let","result",["chan.bytes.recv","out_chan"]],["let","local_sum",["codec.read_u32_le","result",4]],["let","local_min",["codec.read_u32_le","result",8]],["let","local_max",["codec.read_u32_le","result",12]],["let","local_count",["codec.read_u32_le","result",16]],["let","freq_len_bytes",["codec.read_u32_le","result",20]],["set","global_sum",["+","global_sum","local_sum"]],["if",["<u","local_min","global_min"],["set","global_min","local_min"],0],["if",[">u","local_max","global_max"],["set","global_max","local_max"],0],["set","global_count",["+","global_count","local_count"]],["let","freq_count",["/","freq_len_bytes",8]],["for","j",0,"freq_count",["begin",["let","foff",["+",24,["*","j",8]]],["let","key",["codec.read_u32_le","result","foff"]],["let","val",["codec.read_u32_le","result",["+","foff",4]]],["let","old",["std.btree_map.get_u32_u32_or","global_freq","key",0]],["set","global_freq",["std.btree_map.put_u32_u32","global_freq","key",["+","old","val"]]],0]],0]],["let","mean",["/","global_sum","global_count"]],["let","unique_bytes",["std.btree_map.len_u32_u32","global_freq"]],["let","out",["std.vec.with_capacity",512]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","===_PARALLEL_MAPREDUCE_ANALYSIS_==="]]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","Workers:_"]]],["set","out",["std.vec.extend_bytes","out",["std.fmt.u32_to_dec","num_workers"]]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","Input_size:_"]]],["set","out",["std.vec.extend_bytes","out",["std.fmt.u32_to_dec","n"]]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","_bytes"]]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","---_Aggregated_Statistics_---"]]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","Total_bytes:_"]]],["set","out",["std.vec.extend_bytes","out",["std.fmt.u32_to_dec","global_count"]]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","Sum:_"]]],["set","out",["std.vec.extend_bytes","out",["std.fmt.u32_to_dec","global_sum"]]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","Min_byte:_"]]],["set","out",["std.vec.extend_bytes","out",["std.fmt.u32_to_dec","global_min"]]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","Max_byte:_"]]],["set","out",["std.vec.extend_bytes","out",["std.fmt.u32_to_dec","global_max"]]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","Mean:_"]]],["set","out",["std.vec.extend_bytes","out",["std.fmt.u32_to_dec","mean"]]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","Unique_byte_values:_"]]],["set","out",["std.vec.extend_bytes","out",["std.fmt.u32_to_dec","unique_bytes"]]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","---_Byte_Frequency_Table_(top_20)_---"]]],["set","out",["std.vec.push","out",10]],["let","freq_count",["std.btree_map.len_u32_u32","global_freq"]],["let","display_count",["if",["<u","freq_count",20],"freq_count",20]],["let","freq_data",["std.btree_map.emit_kv_u32le_u32le","global_freq"]],["let","freq_view",["bytes.view","freq_data"]],["for","i",0,"display_count",["begin",["let","off",["*","i",8]],["let","byte_val",["codec.read_u32_le","freq_view","off"]],["let","cnt",["codec.read_u32_le","freq_view",["+","off",4]]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","__0x"]]],["let","hi",["/","byte_val",16]],["let","lo",["%","byte_val",16]],["set","out",["std.vec.push","out",["if",["<u","hi",10],["+","hi",48],["+","hi",87]]]],["set","out",["std.vec.push","out",["if",["<u","lo",10],["+","lo",48],["+","lo",87]]]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","_("]]],["if",["if",[">=u","byte_val",32],["<u","byte_val",127],0],["begin",["set","out",["std.vec.push","out",39]],["set","out",["std.vec.push","out","byte_val"]],["set","out",["std.vec.push","out",39]]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","..."]]]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","):_"]]],["set","out",["std.vec.extend_bytes","out",["std.fmt.u32_to_dec","cnt"]]],["let","bar_len_raw",["/",["*","cnt",40],"global_count"]],["let","bar_len",["if",["<u","bar_len_raw",1],1,"bar_len_raw"]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","_|"]]],["for","b",0,"bar_len",["begin",["set","out",["std.vec.push","out",35]],0]],["set","out",["std.vec.push","out",124]],["set","out",["std.vec.push","out",10]],0]],["set","out",["std.vec.push","out",10]],["set","out",["std.vec.extend_bytes","out",["bytes.lit","===_END_ANALYSIS_==="]]],["set","out",["std.vec.push","out",10]],["std.vec.as_bytes","out"]]]]]}
