// this adapter is unguarded as none of the terms declared by the user require guarding.

extern fn __<%= @func %>(env: beam.env, argc: c_int, argv: [*c] const beam.term) beam.term {

  <%= for {arg, idx} <- Enum.with_index(@args) do %>
  var arg<%= idx %>: <%= arg %> = undefined;<% end %>

  <%= for {arg, idx} <- Enum.with_index(@args) do 
    Zigler.Zig.getfor(arg, idx) <> "\n"
  end %>

  var result: <%= @type %> = <%= @func %>(<%= if @has_env, do: "env, ", else: "" %><%=
    if @args == [] do
      "" 
    else
      0..Enum.count(@args) - 1 |> Enum.map(&"arg#{&1}") |> Enum.join(", ") 
    end
  %>);
  <%= Zigler.Zig.makefor(@type) %>
}
