// Copyright 2023 Google LLC
//
// 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.

#include <stdlib.h>
#include <stdio.h>
#include <springbok_intrinsics.h>
#include <springbok.h>

class ExampleStatic {
 public:
  ExampleStatic() {
    springbok_simprint_error("Hello pre-main C++ world.", 0);
    value = 1279;
  }

  ~ExampleStatic() {
    springbok_simprint_error("Goodbye pre-main C++ world.", 0);
  }

  unsigned int value;
};

ExampleStatic exampleStatic;

extern "C" __attribute__((constructor)) void boop(void) {
  springbok_simprint_error("Hello pre-main C world.", 0);
}

extern "C" __attribute__((destructor)) void beep(void) {
  springbok_simprint_error("Goodbye pre-main C world.", 0);
}

extern "C" void blerp(void) {
  springbok_simprint_error("Fare thee well, atexit.", 0);
}

extern "C" int main(void) {
  static char thingy[10] = {13, 14, 15, 16};

  atexit(blerp);

  printf("%s(%d): Hello printf!\n", __PRETTY_FUNCTION__, __LINE__);

  const float sorta_pi = 3.141592653589f;
  int chars_needed = float_to_str(0, NULL, sorta_pi);
  char *buffer = new char[chars_needed];
  float_to_str(chars_needed, buffer, sorta_pi);
  printf("Pi is ~%s, %d characters printed\n", buffer, chars_needed);
  delete[] buffer;

  return thingy[0] + thingy[1] + thingy[2] + thingy[3] + exampleStatic.value;
}
