text: #include <core.p4>
  #define V1MODEL_VERSION 20180101
  #include <v1model.p4>
  
  struct fwd_metadata_t {
      bit<32> l2ptr;
      bit<24> out_bd;
  }
  
  header ethernet_t {
      bit<48> dstAddr;
      bit<48> srcAddr;
      bit<16> etherType;
  }
  
  header ipv4_t {
      bit<4>  version;
      bit<4>  ihl;
      bit<8>  diffserv;
      bit<16> totalLen;
      bit<16> identification;
      bit<3>  flags;
      bit<13> fragOffset;
      bit<8>  ttl;
      bit<8>  protocol;
      bit<16> hdrChecksum;
      bit<32> srcAddr;
      bit<32> dstAddr;
  }
  
  struct metadata {
      fwd_metadata_t fwd_metadata;
  }
  
  struct headers {
      ethernet_t ethernet;
      ipv4_t     ipv4;
  }
  
  parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
      state parse_ipv4 {
          packet.extract<ipv4_t>(hdr.ipv4);
          transition accept;
      }
      state start {
          packet.extract<ethernet_t>(hdr.ethernet);
          transition select(hdr.ethernet.etherType) {
              16w0x800: parse_ipv4;
              default: accept;
          }
      }
  }
  
  control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
      @name(".my_drop") action my_drop(inout standard_metadata_t smeta) {
          mark_to_drop(smeta);
      }
      @name("ingress.ipv4_da_lpm_stats") direct_counter(CounterType.packets) ipv4_da_lpm_stats_0;
      @name("ingress.set_l2ptr") action set_l2ptr(bit<32> l2ptr) {
          ipv4_da_lpm_stats_0.count();
          meta.fwd_metadata.l2ptr = l2ptr;
      }
      @name("ingress.drop_with_count") action drop_with_count() {
          ipv4_da_lpm_stats_0.count();
          mark_to_drop(standard_metadata);
      }
      @name("ingress.set_bd_dmac_intf") action set_bd_dmac_intf(bit<24> bd, bit<48> dmac, bit<9> intf) {
          meta.fwd_metadata.out_bd = bd;
          hdr.ethernet.dstAddr = dmac;
          standard_metadata.egress_spec = intf;
          hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255;
      }
      @name("ingress.ipv4_da_lpm") table ipv4_da_lpm_0 {
          actions = {
              set_l2ptr();
              drop_with_count();
          }
          key = {
              hdr.ipv4.dstAddr: lpm @name("hdr.ipv4.dstAddr") ;
          }
          default_action = drop_with_count();
          counters = ipv4_da_lpm_stats_0;
      }
      @name("ingress.mac_da") table mac_da_0 {
          actions = {
              set_bd_dmac_intf();
              my_drop(standard_metadata);
          }
          key = {
              meta.fwd_metadata.l2ptr: exact @name("meta.fwd_metadata.l2ptr") ;
          }
          default_action = my_drop(standard_metadata);
      }
      apply {
          ipv4_da_lpm_0.apply();
          mac_da_0.apply();
      }
  }
  
  control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
      @name(".my_drop") action my_drop_0(inout standard_metadata_t smeta_1) {
          mark_to_drop(smeta_1);
      }
      @name("egress.rewrite_mac") action rewrite_mac(bit<48> smac) {
          hdr.ethernet.srcAddr = smac;
      }
      @name("egress.send_frame") table send_frame_0 {
          actions = {
              rewrite_mac();
              my_drop_0(standard_metadata);
          }
          key = {
              meta.fwd_metadata.out_bd: exact @name("meta.fwd_metadata.out_bd") ;
          }
          default_action = my_drop_0(standard_metadata);
      }
      apply {
          send_frame_0.apply();
      }
  }
  
  control DeparserImpl(packet_out packet, in headers hdr) {
      apply {
          packet.emit<ethernet_t>(hdr.ethernet);
          packet.emit<ipv4_t>(hdr.ipv4);
      }
  }
  
  control verifyChecksum(inout headers hdr, inout metadata meta) {
      apply {
          verify_checksum<tuple<bit<4>, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16);
      }
  }
  
  control computeChecksum(inout headers hdr, inout metadata meta) {
      apply {
          update_checksum<tuple<bit<4>, bit<4>, bit<8>, bit<16>, bit<16>, bit<3>, bit<13>, bit<8>, bit<8>, bit<32>, bit<32>>, bit<16>>(hdr.ipv4.ihl == 4w5, { hdr.ipv4.version, hdr.ipv4.ihl, hdr.ipv4.diffserv, hdr.ipv4.totalLen, hdr.ipv4.identification, hdr.ipv4.flags, hdr.ipv4.fragOffset, hdr.ipv4.ttl, hdr.ipv4.protocol, hdr.ipv4.srcAddr, hdr.ipv4.dstAddr }, hdr.ipv4.hdrChecksum, HashAlgorithm.csum16);
      }
  }
  
  V1Switch<headers, metadata>(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main;
  
  