#include <iostream>
#include <sys/mman.h>
#include <string.h>
typedef unsigned char UC;
const static UC v[]={0x55,0x48,0x89,0xe5,0xb8,0x4b,0x0,0x0,0x0,0x5d,0xc3};
const static UC z[]={0x55,0x48,0x89,0xe5,0x89,0xf8,0x88,0x45,0xfc,0x80,0x7d,0xfc,0x0,0x74,0x7,0xb8,0x14,0x0,0x0,0x0,0xeb,0x5,0xb8,0x1e,0x0,0x0,0x0,0x5d,0xc3};
int main(){
void* w=mmap(0,100,PROT_EXEC|PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
int n=11;
memcpy(w,v,n);
int(*a)()=(int(*)())w;
std::cout<<a()<<std::endl;
n=sizeof(z);
memcpy(w,z,n);
int(*x)(bool)=(int(*)(bool))w;
std::cout<<x(1)<<std::endl;
std::cout<<x(0)<<std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3lzL21tYW4uaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKdHlwZWRlZiB1bnNpZ25lZCBjaGFyIFVDOwpjb25zdCBzdGF0aWMgVUMgdltdPXsweDU1LDB4NDgsMHg4OSwweGU1LDB4YjgsMHg0YiwweDAsMHgwLDB4MCwweDVkLDB4YzN9Owpjb25zdCBzdGF0aWMgVUMgeltdPXsweDU1LDB4NDgsMHg4OSwweGU1LDB4ODksMHhmOCwweDg4LDB4NDUsMHhmYywweDgwLDB4N2QsMHhmYywweDAsMHg3NCwweDcsMHhiOCwweDE0LDB4MCwweDAsMHgwLDB4ZWIsMHg1LDB4YjgsMHgxZSwweDAsMHgwLDB4MCwweDVkLDB4YzN9OwoKaW50IG1haW4oKXsKICAgIHZvaWQqIHc9bW1hcCgwLDEwMCxQUk9UX0VYRUN8UFJPVF9SRUFEfFBST1RfV1JJVEUsTUFQX1BSSVZBVEV8TUFQX0FOT05ZTU9VUywtMSwwKTsKICAgIGludCBuPTExOwoJbWVtY3B5KHcsdixuKTsKICAgIGludCgqYSkoKT0oaW50KCopKCkpdzsKICAgIHN0ZDo6Y291dDw8YSgpPDxzdGQ6OmVuZGw7CiAgICBuPXNpemVvZih6KTsKICAgIG1lbWNweSh3LHosbik7CiAgICBpbnQoKngpKGJvb2wpPShpbnQoKikoYm9vbCkpdzsKICAgIHN0ZDo6Y291dDw8eCgxKTw8c3RkOjplbmRsOwogICAgc3RkOjpjb3V0PDx4KDApPDxzdGQ6OmVuZGw7CiAgICByZXR1cm4gMDsKfQo=