/* Copyright (c) 2026 Jakub Juszczakiewicz
 * All rights reserved.
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "int128acc.h"
#include "version.h"

#define BUFFER_SIZE 10240

char buffer[BUFFER_SIZE];

void usage(const char * argv0)
{
  fprintf(stderr, "Krypto-IT kit-int-sum %s\n", kit_int_sum_version_str);
  fprintf(stderr,
      "Tool for sum all integers from stdin and print result on stdout.\n\n");
  fprintf(stderr, "Usage: %s\n", argv0);
  exit(1);
}

int main(int argc, char * argv[])
{
  if (argc > 1) {
    usage(argv[0]);
  }
  uint128_t sum;
  memset(&sum, 0, sizeof(sum));

  unsigned long long i;
  while (scanf("%llu", &i) == 1) {
    uint128_inc_u64(&sum, i);
  }

  char str[40];
  uint128_export_dec_str(str, &sum);
  puts(str);

  return 0;
}
